File:
[local] /
rpl /
src /
instructions_r5.c
Revision
1.25:
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Jun 21 15:26:33 2011 UTC (13 years, 10 months ago) by
bertrand
Branches:
MAIN
CVS tags:
HEAD
Correction d'une réinitialisation sauvage de la pile des variables par niveau
dans la copie de la structure de description du processus. Cela corrige
la fonction SPAWN qui échouait sur un segmentation fault car la pile des
variables par niveau était vide alors même que l'arbre des variables contenait
bien les variables. Passage à la prerelease 2.
1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.0.prerelease.2
4: Copyright (C) 1989-2011 Dr. BERTRAND Joël
5:
6: This file is part of RPL/2.
7:
8: RPL/2 is free software; you can redistribute it and/or modify it
9: under the terms of the CeCILL V2 License as published by the french
10: CEA, CNRS and INRIA.
11:
12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
15: for more details.
16:
17: You should have received a copy of the CeCILL License
18: along with RPL/2. If not, write to info@cecill.info.
19: ================================================================================
20: */
21:
22:
23: #include "rpl-conv.h"
24:
25:
26: /*
27: ================================================================================
28: Fonction 'rswp'
29: ================================================================================
30: Entrées : pointeur sur une structure struct_processus
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_rswp(struct_processus *s_etat_processus)
40: {
41: struct_objet *s_copie_argument_3;
42: struct_objet *s_objet_argument_1;
43: struct_objet *s_objet_argument_2;
44: struct_objet *s_objet_argument_3;
45:
46: signed long ligne_1;
47: signed long ligne_2;
48:
49: void *tampon;
50:
51: (*s_etat_processus).erreur_execution = d_ex;
52:
53: if ((*s_etat_processus).affichage_arguments == 'Y')
54: {
55: printf("\n RSWP ");
56:
57: if ((*s_etat_processus).langue == 'F')
58: {
59: printf("(échange de deux lignes d'une matrice)\n\n");
60: }
61: else
62: {
63: printf("(swap two rows of a matrix)\n\n");
64: }
65:
66: printf(" 3: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
67: printf(" 2: %s\n", d_INT);
68: printf(" 1: %s\n", d_INT);
69: printf("-> 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
70:
71: return;
72: }
73: else if ((*s_etat_processus).test_instruction == 'Y')
74: {
75: (*s_etat_processus).nombre_arguments = -1;
76: return;
77: }
78:
79: if (test_cfsf(s_etat_processus, 31) == d_vrai)
80: {
81: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
82: {
83: return;
84: }
85: }
86:
87: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
88: &s_objet_argument_1) == d_erreur)
89: {
90: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
91: return;
92: }
93:
94: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
95: &s_objet_argument_2) == d_erreur)
96: {
97: liberation(s_etat_processus, s_objet_argument_1);
98:
99: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
100: return;
101: }
102:
103: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
104: &s_objet_argument_3) == d_erreur)
105: {
106: liberation(s_etat_processus, s_objet_argument_1);
107: liberation(s_etat_processus, s_objet_argument_2);
108:
109: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
110: return;
111: }
112:
113: if (((*s_objet_argument_1).type == INT) &&
114: ((*s_objet_argument_2).type == INT))
115: {
116: if (((*s_objet_argument_3).type == MIN) ||
117: ((*s_objet_argument_3).type == MRL) ||
118: ((*s_objet_argument_3).type == MCX))
119: {
120: ligne_1 = (*((integer8 *) (*s_objet_argument_1).objet)) - 1;
121: ligne_2 = (*((integer8 *) (*s_objet_argument_2).objet)) - 1;
122:
123: if ((ligne_1 < 0) || (ligne_1 >= (long) (*((struct_matrice *)
124: (*s_objet_argument_3).objet)).nombre_lignes) ||
125: (ligne_2 < 0) || (ligne_2 >= (long) (*((struct_matrice *)
126: (*s_objet_argument_3).objet)).nombre_lignes))
127: {
128: liberation(s_etat_processus, s_objet_argument_1);
129: liberation(s_etat_processus, s_objet_argument_2);
130: liberation(s_etat_processus, s_objet_argument_3);
131:
132: (*s_etat_processus).erreur_execution =
133: d_ex_dimensions_invalides;
134: return;
135: }
136:
137: if ((s_copie_argument_3 = copie_objet(s_etat_processus,
138: s_objet_argument_3, 'Q')) == NULL)
139: {
140: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
141: return;
142: }
143:
144: liberation(s_etat_processus, s_objet_argument_3);
145: s_objet_argument_3 = s_copie_argument_3;
146:
147: tampon = (*((struct_matrice *) (*s_objet_argument_3).objet))
148: .tableau[ligne_1];
149: (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau[ligne_1]
150: = (*((struct_matrice *) (*s_objet_argument_3).objet))
151: .tableau[ligne_2];
152: (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau[ligne_2]
153: = tampon;
154: }
155: else
156: {
157: liberation(s_etat_processus, s_objet_argument_1);
158: liberation(s_etat_processus, s_objet_argument_2);
159: liberation(s_etat_processus, s_objet_argument_3);
160:
161: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
162: return;
163: }
164: }
165: else
166: {
167: liberation(s_etat_processus, s_objet_argument_1);
168: liberation(s_etat_processus, s_objet_argument_2);
169: liberation(s_etat_processus, s_objet_argument_3);
170:
171: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
172: return;
173: }
174:
175: liberation(s_etat_processus, s_objet_argument_1);
176: liberation(s_etat_processus, s_objet_argument_2);
177:
178: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
179: s_objet_argument_3) == d_erreur)
180: {
181: return;
182: }
183:
184: return;
185: }
186:
187:
188: /*
189: ================================================================================
190: Fonction 'row+'
191: ================================================================================
192: Entrées :
193: --------------------------------------------------------------------------------
194: Sorties :
195: --------------------------------------------------------------------------------
196: Effets de bord : néant
197: ================================================================================
198: */
199:
200: void
201: instruction_row_plus(struct_processus *s_etat_processus)
202: {
203: integer8 position;
204:
205: logical1 matrice_vide;
206: logical1 presence_nom;
207: logical1 variable_partagee;
208:
209: struct_objet *s_copie_argument_1;
210: struct_objet *s_copie_argument_3;
211: struct_objet *s_objet_argument_1;
212: struct_objet *s_objet_argument_2;
213: struct_objet *s_objet_argument_3;
214:
215: unsigned long i;
216: unsigned long j;
217:
218: void **tableau;
219: void *tampon;
220:
221: (*s_etat_processus).erreur_execution = d_ex;
222:
223: if ((*s_etat_processus).affichage_arguments == 'Y')
224: {
225: printf("\n ROW+ ");
226:
227: if ((*s_etat_processus).langue == 'F')
228: {
229: printf("(ajout d'une ligne dans une matrice)\n\n");
230: }
231: else
232: {
233: printf("(add a row in a matrix)\n\n");
234: }
235:
236: printf(" 3: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
237: printf(" 2: %s\n", d_INT);
238: printf(" 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX);
239: printf("-> 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX);
240:
241: printf(" 3: %s\n", d_NOM);
242: printf(" 2: %s\n", d_INT);
243: printf(" 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
244:
245: return;
246: }
247: else if ((*s_etat_processus).test_instruction == 'Y')
248: {
249: (*s_etat_processus).nombre_arguments = -1;
250: return;
251: }
252:
253: if (test_cfsf(s_etat_processus, 31) == d_vrai)
254: {
255: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
256: {
257: return;
258: }
259: }
260:
261: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
262: &s_objet_argument_1) == d_erreur)
263: {
264: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
265: return;
266: }
267:
268: if ((s_copie_argument_1 = copie_objet(s_etat_processus, s_objet_argument_1,
269: 'O')) == NULL)
270: {
271: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
272: return;
273: }
274:
275: liberation(s_etat_processus, s_objet_argument_1);
276: s_objet_argument_1 = s_copie_argument_1;
277:
278: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
279: &s_objet_argument_2) == d_erreur)
280: {
281: liberation(s_etat_processus, s_objet_argument_1);
282:
283: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
284: return;
285: }
286:
287: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
288: &s_objet_argument_3) == d_erreur)
289: {
290: liberation(s_etat_processus, s_objet_argument_1);
291: liberation(s_etat_processus, s_objet_argument_2);
292:
293: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
294: return;
295: }
296:
297: if (((*s_objet_argument_1).type != MIN) &&
298: ((*s_objet_argument_1).type != MRL) &&
299: ((*s_objet_argument_1).type != MCX))
300: {
301: liberation(s_etat_processus, s_objet_argument_1);
302: liberation(s_etat_processus, s_objet_argument_2);
303: liberation(s_etat_processus, s_objet_argument_3);
304:
305: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
306: return;
307: }
308:
309: if ((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_lignes
310: != 1)
311: {
312: liberation(s_etat_processus, s_objet_argument_1);
313: liberation(s_etat_processus, s_objet_argument_2);
314: liberation(s_etat_processus, s_objet_argument_3);
315:
316: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
317: return;
318: }
319:
320: if ((*s_objet_argument_2).type != INT)
321: {
322: liberation(s_etat_processus, s_objet_argument_1);
323: liberation(s_etat_processus, s_objet_argument_2);
324: liberation(s_etat_processus, s_objet_argument_3);
325:
326: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
327: return;
328: }
329:
330: variable_partagee = d_faux;
331:
332: if ((*s_objet_argument_3).type == NOM)
333: {
334: presence_nom = d_vrai;
335:
336: if (recherche_variable(s_etat_processus, (*((struct_nom *)
337: (*s_objet_argument_3).objet)).nom) == d_faux)
338: {
339: (*s_etat_processus).erreur_systeme = d_es;
340: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
341:
342: liberation(s_etat_processus, s_objet_argument_1);
343: liberation(s_etat_processus, s_objet_argument_2);
344: liberation(s_etat_processus, s_objet_argument_3);
345:
346: return;
347: }
348:
349: liberation(s_etat_processus, s_objet_argument_3);
350:
351: if ((*(*s_etat_processus).pointeur_variable_courante)
352: .variable_verrouillee == d_vrai)
353: {
354: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
355:
356: liberation(s_etat_processus, s_objet_argument_1);
357: liberation(s_etat_processus, s_objet_argument_2);
358:
359: return;
360: }
361:
362: s_objet_argument_3 = (*(*s_etat_processus).pointeur_variable_courante)
363: .objet;
364:
365: if (s_objet_argument_3 == NULL)
366: {
367: if (pthread_mutex_lock(&((*(*s_etat_processus)
368: .s_liste_variables_partagees).mutex)) != 0)
369: {
370: (*s_etat_processus).erreur_systeme = d_es_processus;
371: return;
372: }
373:
374: if (recherche_variable_partagee(s_etat_processus,
375: (*(*s_etat_processus).pointeur_variable_courante).nom,
376: (*(*s_etat_processus).pointeur_variable_courante)
377: .variable_partagee, (*(*s_etat_processus)
378: .pointeur_variable_courante).origine)
379: == d_faux)
380: {
381: if (pthread_mutex_unlock(&((*(*s_etat_processus)
382: .s_liste_variables_partagees).mutex)) != 0)
383: {
384: (*s_etat_processus).erreur_systeme = d_es_processus;
385: return;
386: }
387:
388: (*s_etat_processus).erreur_systeme = d_es;
389: (*s_etat_processus).erreur_execution =
390: d_ex_variable_non_definie;
391:
392: liberation(s_etat_processus, s_objet_argument_1);
393: liberation(s_etat_processus, s_objet_argument_2);
394:
395: return;
396: }
397:
398: s_objet_argument_3 = (*(*s_etat_processus)
399: .s_liste_variables_partagees).table
400: [(*(*s_etat_processus).s_liste_variables_partagees)
401: .position_variable].objet;
402: variable_partagee = d_vrai;
403: }
404:
405: if ((s_copie_argument_3 = copie_objet(s_etat_processus,
406: s_objet_argument_3, 'Q')) == NULL)
407: {
408: if (variable_partagee == d_vrai)
409: {
410: if (pthread_mutex_unlock(&((*(*s_etat_processus)
411: .s_liste_variables_partagees).mutex)) != 0)
412: {
413: (*s_etat_processus).erreur_systeme = d_es_processus;
414: return;
415: }
416: }
417:
418: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
419: return;
420: }
421:
422: liberation(s_etat_processus, s_objet_argument_3);
423: s_objet_argument_3 = s_copie_argument_3;
424:
425: (*(*s_etat_processus).pointeur_variable_courante).objet =
426: s_objet_argument_3;
427: }
428: else
429: {
430: presence_nom = d_faux;
431:
432: if ((s_copie_argument_3 = copie_objet(s_etat_processus,
433: s_objet_argument_3, 'Q')) == NULL)
434: {
435: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
436: return;
437: }
438:
439: liberation(s_etat_processus, s_objet_argument_3);
440: s_objet_argument_3 = s_copie_argument_3;
441: }
442:
443: if (((*((struct_matrice *) (*s_objet_argument_3).objet)).nombre_colonnes
444: == 0) && ((*((struct_matrice *) (*s_objet_argument_3).objet))
445: .nombre_lignes == 1))
446: {
447: matrice_vide = d_vrai;
448: }
449: else
450: {
451: matrice_vide = d_faux;
452:
453: if ((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_colonnes
454: != (*((struct_matrice *) (*s_objet_argument_3).objet))
455: .nombre_colonnes)
456: {
457: if (variable_partagee == d_vrai)
458: {
459: if (pthread_mutex_unlock(&((*(*s_etat_processus)
460: .s_liste_variables_partagees).mutex)) != 0)
461: {
462: (*s_etat_processus).erreur_systeme = d_es_processus;
463: return;
464: }
465: }
466:
467: liberation(s_etat_processus, s_objet_argument_1);
468: liberation(s_etat_processus, s_objet_argument_2);
469:
470: if (presence_nom == d_faux)
471: {
472: liberation(s_etat_processus, s_objet_argument_3);
473: }
474:
475: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
476: return;
477: }
478: }
479:
480: if ((*s_objet_argument_1).type == MRL)
481: {
482: if ((*s_objet_argument_3).type == MIN)
483: {
484: // Conversion de la matrice entière en matrice réelle
485:
486: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_3).objet))
487: .nombre_lignes; i++)
488: {
489: tampon = (*((struct_matrice *) (*s_objet_argument_3).objet))
490: .tableau[i];
491:
492: if (((*((struct_matrice *) (*s_objet_argument_3).objet))
493: .tableau[i] = malloc((*((struct_matrice *)
494: (*s_objet_argument_3).objet)).nombre_colonnes *
495: sizeof(real8))) == NULL)
496: {
497: if (variable_partagee == d_vrai)
498: {
499: if (pthread_mutex_unlock(&((*(*s_etat_processus)
500: .s_liste_variables_partagees).mutex)) != 0)
501: {
502: (*s_etat_processus).erreur_systeme = d_es_processus;
503: return;
504: }
505: }
506:
507: (*s_etat_processus).erreur_systeme =
508: d_es_allocation_memoire;
509: return;
510: }
511:
512: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_3)
513: .objet)).nombre_colonnes; j++)
514: {
515: ((real8 **) (*((struct_matrice *) (*s_objet_argument_3)
516: .objet)).tableau)[i][j] = (real8) (((integer8 *)
517: tampon)[j]);
518: }
519:
520: free(tampon);
521: }
522:
523: (*((struct_matrice *) (*s_objet_argument_3).objet)).type = 'R';
524: (*s_objet_argument_3).type = MRL;
525: }
526: }
527: else if ((*s_objet_argument_1).type == MCX)
528: {
529: if ((*s_objet_argument_3).type == MIN)
530: {
531: // Conversion de la matrice entière en matrice complexe
532:
533: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_3).objet))
534: .nombre_lignes; i++)
535: {
536: tampon = (*((struct_matrice *) (*s_objet_argument_3).objet))
537: .tableau[i];
538:
539: if (((*((struct_matrice *) (*s_objet_argument_3).objet))
540: .tableau[i] = malloc((*((struct_matrice *)
541: (*s_objet_argument_3).objet)).nombre_colonnes *
542: sizeof(complex16))) == NULL)
543: {
544: if (variable_partagee == d_vrai)
545: {
546: if (pthread_mutex_unlock(&((*(*s_etat_processus)
547: .s_liste_variables_partagees).mutex)) != 0)
548: {
549: (*s_etat_processus).erreur_systeme = d_es_processus;
550: return;
551: }
552: }
553:
554: (*s_etat_processus).erreur_systeme =
555: d_es_allocation_memoire;
556: return;
557: }
558:
559: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_3)
560: .objet)).nombre_colonnes; j++)
561: {
562: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_3)
563: .objet)).tableau)[i][j].partie_reelle =
564: (real8) (((integer8 *) tampon)[j]);
565: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_3)
566: .objet)).tableau)[i][j].partie_imaginaire = 0;
567: }
568:
569: free(tampon);
570: }
571:
572: (*((struct_matrice *) (*s_objet_argument_3).objet)).type = 'C';
573: (*s_objet_argument_3).type = MCX;
574: }
575: else if ((*s_objet_argument_3).type == MRL)
576: {
577: // Conversion de la matrice réelle en matrice complexe
578:
579: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_3).objet))
580: .nombre_lignes; i++)
581: {
582: tampon = (*((struct_matrice *) (*s_objet_argument_3).objet))
583: .tableau[i];
584:
585: if (((*((struct_matrice *) (*s_objet_argument_3).objet))
586: .tableau[i] = malloc((*((struct_matrice *)
587: (*s_objet_argument_3).objet)).nombre_colonnes *
588: sizeof(complex16))) == NULL)
589: {
590: if (variable_partagee == d_vrai)
591: {
592: if (pthread_mutex_unlock(&((*(*s_etat_processus)
593: .s_liste_variables_partagees).mutex)) != 0)
594: {
595: (*s_etat_processus).erreur_systeme = d_es_processus;
596: return;
597: }
598: }
599:
600: (*s_etat_processus).erreur_systeme =
601: d_es_allocation_memoire;
602: return;
603: }
604:
605: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_3)
606: .objet)).nombre_colonnes; j++)
607: {
608: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_3)
609: .objet)).tableau)[i][j].partie_reelle =
610: ((real8 *) tampon)[j];
611: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_3)
612: .objet)).tableau)[i][j].partie_imaginaire = 0;
613: }
614:
615: free(tampon);
616: }
617:
618: (*((struct_matrice *) (*s_objet_argument_3).objet)).type = 'C';
619: (*s_objet_argument_3).type = MCX;
620: }
621: }
622:
623: if ((*s_objet_argument_3).type == MRL)
624: {
625: if ((*s_objet_argument_1).type == MIN)
626: {
627: // Conversion de la matrice entière en matrice réelle
628:
629: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_1).objet))
630: .nombre_lignes; i++)
631: {
632: tampon = (*((struct_matrice *) (*s_objet_argument_1).objet))
633: .tableau[i];
634:
635: if (((*((struct_matrice *) (*s_objet_argument_1).objet))
636: .tableau[i] = malloc((*((struct_matrice *)
637: (*s_objet_argument_1).objet)).nombre_colonnes *
638: sizeof(real8))) == NULL)
639: {
640: if (variable_partagee == d_vrai)
641: {
642: if (pthread_mutex_unlock(&((*(*s_etat_processus)
643: .s_liste_variables_partagees).mutex)) != 0)
644: {
645: (*s_etat_processus).erreur_systeme = d_es_processus;
646: return;
647: }
648: }
649:
650: (*s_etat_processus).erreur_systeme =
651: d_es_allocation_memoire;
652: return;
653: }
654:
655: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_1)
656: .objet)).nombre_colonnes; j++)
657: {
658: ((real8 **) (*((struct_matrice *) (*s_objet_argument_1)
659: .objet)).tableau)[i][j] = (real8) (((integer8 *)
660: tampon)[j]);
661: }
662:
663: free(tampon);
664: }
665:
666: (*((struct_matrice *) (*s_objet_argument_1).objet)).type = 'R';
667: (*s_objet_argument_1).type = MRL;
668: }
669: }
670: else if ((*s_objet_argument_3).type == MCX)
671: {
672: if ((*s_objet_argument_1).type == MIN)
673: {
674: // Conversion de la matrice entière en matrice complexe
675:
676: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_1).objet))
677: .nombre_lignes; i++)
678: {
679: tampon = (*((struct_matrice *) (*s_objet_argument_1).objet))
680: .tableau[i];
681:
682: if (((*((struct_matrice *) (*s_objet_argument_1).objet))
683: .tableau[i] = malloc((*((struct_matrice *)
684: (*s_objet_argument_1).objet)).nombre_colonnes *
685: sizeof(complex16))) == NULL)
686: {
687: if (variable_partagee == d_vrai)
688: {
689: if (pthread_mutex_unlock(&((*(*s_etat_processus)
690: .s_liste_variables_partagees).mutex)) != 0)
691: {
692: (*s_etat_processus).erreur_systeme = d_es_processus;
693: return;
694: }
695: }
696:
697: (*s_etat_processus).erreur_systeme =
698: d_es_allocation_memoire;
699: return;
700: }
701:
702: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_1)
703: .objet)).nombre_colonnes; j++)
704: {
705: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_1)
706: .objet)).tableau)[i][j].partie_reelle =
707: (real8) (((integer8 *) tampon)[j]);
708: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_1)
709: .objet)).tableau)[i][j].partie_imaginaire = 0;
710: }
711:
712: free(tampon);
713: }
714:
715: (*((struct_matrice *) (*s_objet_argument_1).objet)).type = 'C';
716: (*s_objet_argument_1).type = MCX;
717: }
718: else if ((*s_objet_argument_1).type == MRL)
719: {
720: // Conversion de la matrice réelle en matrice complexe
721:
722: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_1).objet))
723: .nombre_lignes; i++)
724: {
725: tampon = (*((struct_matrice *) (*s_objet_argument_1).objet))
726: .tableau[i];
727:
728: if (((*((struct_matrice *) (*s_objet_argument_1).objet))
729: .tableau[i] = malloc((*((struct_matrice *)
730: (*s_objet_argument_1).objet)).nombre_colonnes *
731: sizeof(complex16))) == NULL)
732: {
733: if (variable_partagee == d_vrai)
734: {
735: if (pthread_mutex_unlock(&((*(*s_etat_processus)
736: .s_liste_variables_partagees).mutex)) != 0)
737: {
738: (*s_etat_processus).erreur_systeme = d_es_processus;
739: return;
740: }
741: }
742:
743: (*s_etat_processus).erreur_systeme =
744: d_es_allocation_memoire;
745: return;
746: }
747:
748: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_1)
749: .objet)).nombre_colonnes; j++)
750: {
751: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_1)
752: .objet)).tableau)[i][j].partie_reelle =
753: ((real8 *) tampon)[j];
754: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_1)
755: .objet)).tableau)[i][j].partie_imaginaire = 0;
756: }
757:
758: free(tampon);
759: }
760:
761: (*((struct_matrice *) (*s_objet_argument_1).objet)).type = 'C';
762: (*s_objet_argument_1).type = MCX;
763: }
764: }
765:
766: position = (*((integer8 *) (*s_objet_argument_2).objet));
767:
768: if (((position < 1) || (position > (integer8) ((*((struct_matrice *)
769: (*s_objet_argument_3).objet)).nombre_lignes + 1))) ||
770: ((position != 1) && (matrice_vide == d_vrai)))
771: {
772: if (variable_partagee == d_vrai)
773: {
774: if (pthread_mutex_unlock(&((*(*s_etat_processus)
775: .s_liste_variables_partagees).mutex)) != 0)
776: {
777: (*s_etat_processus).erreur_systeme = d_es_processus;
778: return;
779: }
780: }
781:
782: liberation(s_etat_processus, s_objet_argument_1);
783: liberation(s_etat_processus, s_objet_argument_2);
784:
785: if (presence_nom == d_faux)
786: {
787: liberation(s_etat_processus, s_objet_argument_3);
788: }
789:
790: (*s_etat_processus).erreur_execution =
791: d_ex_argument_invalide;
792: return;
793: }
794:
795: tableau = (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau;
796:
797: if (matrice_vide == d_faux)
798: {
799: if (((*((struct_matrice *) (*s_objet_argument_3).objet)).tableau
800: = malloc(((*((struct_matrice *) (*s_objet_argument_3).objet))
801: .nombre_lignes + 1) * sizeof(void *))) == NULL)
802: {
803: if (variable_partagee == d_vrai)
804: {
805: if (pthread_mutex_unlock(&((*(*s_etat_processus)
806: .s_liste_variables_partagees).mutex)) != 0)
807: {
808: (*s_etat_processus).erreur_systeme = d_es_processus;
809: return;
810: }
811: }
812:
813: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
814: return;
815: }
816:
817: if (position != ((integer8) (*((struct_matrice *)
818: (*s_objet_argument_3).objet)).nombre_lignes + 1))
819: {
820: for(j = i = 0; i < (*((struct_matrice *)
821: (*s_objet_argument_3).objet)).nombre_lignes; i++)
822: {
823: if (i == (unsigned long) (position - 1))
824: {
825: (*((struct_matrice *) (*s_objet_argument_3).objet))
826: .tableau[i] = (*((struct_matrice *)
827: (*s_objet_argument_1).objet)).tableau[0];
828: j = 1;
829: }
830:
831: (*((struct_matrice *) (*s_objet_argument_3).objet))
832: .tableau[i + j] = tableau[i];
833: }
834: }
835: else
836: {
837: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_3).objet))
838: .nombre_lignes; i++)
839: {
840: (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau[i]
841: = tableau[i];
842: }
843:
844: (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau
845: [(*((struct_matrice *) (*s_objet_argument_3).objet))
846: .nombre_lignes] = (*((struct_matrice *)
847: (*s_objet_argument_1).objet)).tableau[0];
848: }
849:
850: (*((struct_matrice *) (*s_objet_argument_3).objet)).nombre_lignes++;
851: }
852: else
853: {
854: free((*((struct_matrice *) (*s_objet_argument_3).objet)).tableau[0]);
855:
856: if (((*((struct_matrice *) (*s_objet_argument_3).objet)).tableau
857: = malloc(sizeof(void *))) == NULL)
858: {
859: if (variable_partagee == d_vrai)
860: {
861: if (pthread_mutex_unlock(&((*(*s_etat_processus)
862: .s_liste_variables_partagees).mutex)) != 0)
863: {
864: (*s_etat_processus).erreur_systeme = d_es_processus;
865: return;
866: }
867: }
868:
869: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
870: return;
871: }
872:
873: (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau[0] =
874: (*((struct_matrice *) (*s_objet_argument_1).objet)).tableau[0];
875: (*((struct_matrice *) (*s_objet_argument_3).objet)).nombre_lignes =
876: (*((struct_matrice *) (*s_objet_argument_1).objet))
877: .nombre_lignes;
878: (*((struct_matrice *) (*s_objet_argument_3).objet)).nombre_colonnes =
879: (*((struct_matrice *) (*s_objet_argument_1).objet))
880: .nombre_colonnes;
881: }
882:
883: free(tableau);
884:
885: if (presence_nom == d_faux)
886: {
887: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
888: s_objet_argument_3) == d_erreur)
889: {
890: return;
891: }
892: }
893: else
894: {
895: if (variable_partagee == d_vrai)
896: {
897: (*(*s_etat_processus).s_liste_variables_partagees).table
898: [(*(*s_etat_processus).s_liste_variables_partagees)
899: .position_variable].objet = s_objet_argument_3;
900:
901: if (pthread_mutex_unlock(&((*(*s_etat_processus)
902: .s_liste_variables_partagees).mutex)) != 0)
903: {
904: (*s_etat_processus).erreur_systeme = d_es_processus;
905: return;
906: }
907: }
908: }
909:
910: free((*((struct_matrice *) (*s_objet_argument_1).objet)).tableau);
911: free((*s_objet_argument_1).objet);
912: free(s_objet_argument_1);
913:
914: liberation(s_etat_processus, s_objet_argument_2);
915:
916: return;
917: }
918:
919:
920: /*
921: ================================================================================
922: Fonction 'row-'
923: ================================================================================
924: Entrées : pointeur sur une structure struct_processus
925: --------------------------------------------------------------------------------
926: Sorties :
927: --------------------------------------------------------------------------------
928: Effets de bord : néant
929: ================================================================================
930: */
931:
932: void
933: instruction_row_moins(struct_processus *s_etat_processus)
934: {
935: integer8 position;
936:
937: logical1 presence_variable;
938: logical1 variable_partagee;
939:
940: struct_objet *s_copie_argument_2;
941: struct_objet *s_objet_argument_1;
942: struct_objet *s_objet_argument_2;
943: struct_objet *s_objet_resultat;
944:
945: unsigned long i;
946: unsigned long j;
947: unsigned long colonne;
948:
949: void **tableau;
950:
951: (*s_etat_processus).erreur_execution = d_ex;
952:
953: if ((*s_etat_processus).affichage_arguments == 'Y')
954: {
955: printf("\n ROW- ");
956:
957: if ((*s_etat_processus).langue == 'F')
958: {
959: printf("(retrait d'une ligne dans une matrice)\n\n");
960: }
961: else
962: {
963: printf("(remove a row from a matrix)\n\n");
964: }
965:
966: printf(" 2: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
967: printf(" 1: %s\n", d_INT);
968: printf("-> 2: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX);
969: printf(" 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX);
970:
971: printf(" 2: %s\n", d_NOM);
972: printf(" 1: %s\n", d_INT);
973: printf("-> 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
974:
975: return;
976: }
977: else if ((*s_etat_processus).test_instruction == 'Y')
978: {
979: (*s_etat_processus).nombre_arguments = -1;
980: return;
981: }
982:
983: if (test_cfsf(s_etat_processus, 31) == d_vrai)
984: {
985: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
986: {
987: return;
988: }
989: }
990:
991: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
992: &s_objet_argument_1) == d_erreur)
993: {
994: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
995: return;
996: }
997:
998: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
999: &s_objet_argument_2) == d_erreur)
1000: {
1001: liberation(s_etat_processus, s_objet_argument_1);
1002:
1003: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1004: return;
1005: }
1006:
1007: variable_partagee = d_faux;
1008:
1009: if ((*s_objet_argument_2).type == NOM)
1010: {
1011: presence_variable = d_vrai;
1012:
1013: if (recherche_variable(s_etat_processus, (*((struct_nom *)
1014: (*s_objet_argument_2).objet)).nom) == d_faux)
1015: {
1016: liberation(s_etat_processus, s_objet_argument_1);
1017: liberation(s_etat_processus, s_objet_argument_2);
1018:
1019: (*s_etat_processus).erreur_systeme = d_es;
1020: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
1021:
1022: return;
1023: }
1024:
1025: liberation(s_etat_processus, s_objet_argument_2);
1026:
1027: if ((*(*s_etat_processus).pointeur_variable_courante)
1028: .variable_verrouillee == d_vrai)
1029: {
1030: liberation(s_etat_processus, s_objet_argument_1);
1031:
1032: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
1033: return;
1034: }
1035:
1036: s_objet_argument_2 = (*(*s_etat_processus).pointeur_variable_courante)
1037: .objet;
1038:
1039: if (s_objet_argument_2 == NULL)
1040: {
1041: if (pthread_mutex_lock(&((*(*s_etat_processus)
1042: .s_liste_variables_partagees).mutex)) != 0)
1043: {
1044: (*s_etat_processus).erreur_systeme = d_es_processus;
1045: return;
1046: }
1047:
1048: if (recherche_variable_partagee(s_etat_processus,
1049: (*(*s_etat_processus).pointeur_variable_courante).nom,
1050: (*(*s_etat_processus).pointeur_variable_courante)
1051: .variable_partagee, (*(*s_etat_processus)
1052: .pointeur_variable_courante).origine) == d_faux)
1053: {
1054: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1055: .s_liste_variables_partagees).mutex)) != 0)
1056: {
1057: (*s_etat_processus).erreur_systeme = d_es_processus;
1058: return;
1059: }
1060:
1061: (*s_etat_processus).erreur_systeme = d_es;
1062: (*s_etat_processus).erreur_execution =
1063: d_ex_variable_non_definie;
1064:
1065: liberation(s_etat_processus, s_objet_argument_1);
1066:
1067: return;
1068: }
1069:
1070: s_objet_argument_2 = (*(*s_etat_processus)
1071: .s_liste_variables_partagees).table
1072: [(*(*s_etat_processus).s_liste_variables_partagees)
1073: .position_variable].objet;
1074: variable_partagee = d_vrai;
1075: }
1076:
1077: if ((s_copie_argument_2 = copie_objet(s_etat_processus,
1078: s_objet_argument_2, 'Q')) == NULL)
1079: {
1080: if (variable_partagee == d_vrai)
1081: {
1082: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1083: .s_liste_variables_partagees).mutex)) != 0)
1084: {
1085: (*s_etat_processus).erreur_systeme = d_es_processus;
1086: return;
1087: }
1088: }
1089:
1090: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1091: return;
1092: }
1093:
1094: liberation(s_etat_processus, s_objet_argument_2);
1095: s_objet_argument_2 = s_copie_argument_2;
1096:
1097: (*(*s_etat_processus).pointeur_variable_courante).objet =
1098: s_objet_argument_2;
1099: }
1100: else
1101: {
1102: presence_variable = d_faux;
1103:
1104: if ((s_copie_argument_2 = copie_objet(s_etat_processus,
1105: s_objet_argument_2, 'Q')) == NULL)
1106: {
1107: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1108: return;
1109: }
1110:
1111: liberation(s_etat_processus, s_objet_argument_2);
1112: s_objet_argument_2 = s_copie_argument_2;
1113: }
1114:
1115: if (((*s_objet_argument_2).type == MIN) ||
1116: ((*s_objet_argument_2).type == MRL) ||
1117: ((*s_objet_argument_2).type == MCX))
1118: {
1119: if ((*s_objet_argument_1).type == INT)
1120: {
1121: position = (*((integer8 *) (*s_objet_argument_1).objet));
1122:
1123: if ((position <= 0) || (position > (integer8) (*((struct_matrice *)
1124: (*s_objet_argument_2).objet)).nombre_lignes))
1125: {
1126: if (variable_partagee == d_vrai)
1127: {
1128: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1129: .s_liste_variables_partagees).mutex)) != 0)
1130: {
1131: (*s_etat_processus).erreur_systeme = d_es_processus;
1132: return;
1133: }
1134: }
1135:
1136: liberation(s_etat_processus, s_objet_argument_1);
1137:
1138: if (presence_variable == d_faux)
1139: {
1140: liberation(s_etat_processus, s_objet_argument_2);
1141: }
1142:
1143: (*s_etat_processus).erreur_execution =
1144: d_ex_argument_invalide;
1145: return;
1146: }
1147:
1148: if ((s_objet_resultat = allocation(s_etat_processus,
1149: (*s_objet_argument_2).type)) == NULL)
1150: {
1151: if (variable_partagee == d_vrai)
1152: {
1153: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1154: .s_liste_variables_partagees).mutex)) != 0)
1155: {
1156: (*s_etat_processus).erreur_systeme = d_es_processus;
1157: return;
1158: }
1159: }
1160:
1161: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1162: return;
1163: }
1164:
1165: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
1166: 1;
1167: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
1168: (*((struct_matrice *) (*s_objet_argument_2).objet))
1169: .nombre_colonnes;
1170:
1171: if (((*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
1172: malloc(sizeof(void *))) == NULL)
1173: {
1174: if (variable_partagee == d_vrai)
1175: {
1176: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1177: .s_liste_variables_partagees).mutex)) != 0)
1178: {
1179: (*s_etat_processus).erreur_systeme = d_es_processus;
1180: return;
1181: }
1182: }
1183:
1184: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1185: return;
1186: }
1187:
1188: (*((struct_matrice *) (*s_objet_resultat).objet)).tableau[0] =
1189: (*((struct_matrice *) (*s_objet_argument_2).objet)).tableau
1190: [colonne = position - 1];
1191:
1192: if ((*((struct_matrice *) (*s_objet_argument_2).objet))
1193: .nombre_lignes > 1)
1194: {
1195: tableau = (*((struct_matrice *) (*s_objet_argument_2).objet))
1196: .tableau;
1197:
1198: if (((*((struct_matrice *) (*s_objet_argument_2).objet)).tableau
1199: = malloc(((*((struct_matrice *) (*s_objet_argument_2)
1200: .objet)).nombre_lignes - 1) * sizeof(void *))) == NULL)
1201: {
1202: if (variable_partagee == d_vrai)
1203: {
1204: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1205: .s_liste_variables_partagees).mutex)) != 0)
1206: {
1207: (*s_etat_processus).erreur_systeme = d_es_processus;
1208: return;
1209: }
1210: }
1211:
1212: (*s_etat_processus).erreur_systeme =
1213: d_es_allocation_memoire;
1214: return;
1215: }
1216:
1217: (*((struct_matrice *) (*s_objet_argument_2).objet))
1218: .nombre_lignes--;
1219:
1220: for(i = j = 0; i < (*((struct_matrice *) (*s_objet_argument_2)
1221: .objet)).nombre_lignes; i++)
1222: {
1223: if (i == colonne)
1224: {
1225: j = 1;
1226: }
1227:
1228: (*((struct_matrice *) (*s_objet_argument_2).objet))
1229: .tableau[i] = tableau[i + j];
1230: }
1231:
1232: free(tableau);
1233: }
1234: else
1235: {
1236: if (((*((struct_matrice *) (*s_objet_argument_2).objet))
1237: .tableau[0] = malloc(0)) == NULL)
1238: {
1239: if (variable_partagee == d_vrai)
1240: {
1241: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1242: .s_liste_variables_partagees).mutex)) != 0)
1243: {
1244: (*s_etat_processus).erreur_systeme = d_es_processus;
1245: return;
1246: }
1247: }
1248:
1249: (*s_etat_processus).erreur_systeme =
1250: d_es_allocation_memoire;
1251: return;
1252: }
1253:
1254: (*((struct_matrice *) (*s_objet_argument_2).objet))
1255: .nombre_colonnes = 0;
1256: }
1257: }
1258: else
1259: {
1260: if (variable_partagee == d_vrai)
1261: {
1262: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1263: .s_liste_variables_partagees).mutex)) != 0)
1264: {
1265: (*s_etat_processus).erreur_systeme = d_es_processus;
1266: return;
1267: }
1268: }
1269:
1270: liberation(s_etat_processus, s_objet_argument_1);
1271:
1272: if (presence_variable == d_faux)
1273: {
1274: liberation(s_etat_processus, s_objet_argument_2);
1275: }
1276:
1277: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1278: return;
1279: }
1280: }
1281: else
1282: {
1283: if (variable_partagee == d_vrai)
1284: {
1285: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1286: .s_liste_variables_partagees).mutex)) != 0)
1287: {
1288: (*s_etat_processus).erreur_systeme = d_es_processus;
1289: return;
1290: }
1291: }
1292:
1293: liberation(s_etat_processus, s_objet_argument_1);
1294:
1295: if (presence_variable == d_faux)
1296: {
1297: liberation(s_etat_processus, s_objet_argument_2);
1298: }
1299:
1300: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1301: return;
1302: }
1303:
1304: liberation(s_etat_processus, s_objet_argument_1);
1305:
1306: if (presence_variable == d_faux)
1307: {
1308: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1309: s_objet_argument_2) == d_erreur)
1310: {
1311: return;
1312: }
1313: }
1314: else if (variable_partagee == d_vrai)
1315: {
1316: (*(*s_etat_processus).s_liste_variables_partagees).table
1317: [(*(*s_etat_processus).s_liste_variables_partagees)
1318: .position_variable].objet = s_objet_argument_2;
1319:
1320: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1321: .s_liste_variables_partagees).mutex)) != 0)
1322: {
1323: (*s_etat_processus).erreur_systeme = d_es_processus;
1324: return;
1325: }
1326: }
1327:
1328: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1329: s_objet_resultat) == d_erreur)
1330: {
1331: return;
1332: }
1333:
1334: return;
1335: }
1336:
1337:
1338: /*
1339: ================================================================================
1340: Fonction 'rci'
1341: ================================================================================
1342: Entrées : pointeur sur une structure struct_processus
1343: --------------------------------------------------------------------------------
1344: Sorties :
1345: --------------------------------------------------------------------------------
1346: Effets de bord : néant
1347: ================================================================================
1348: */
1349:
1350: void
1351: instruction_rci(struct_processus *s_etat_processus)
1352: {
1353: logical1 last_valide;
1354:
1355: struct_objet *s_objet_argument_1;
1356: struct_objet *s_objet_argument_2;
1357: struct_objet *s_objet_argument_3;
1358: struct_objet *tampon;
1359:
1360: (*s_etat_processus).erreur_execution = d_ex;
1361:
1362: if ((*s_etat_processus).affichage_arguments == 'Y')
1363: {
1364: printf("\n RCI ");
1365:
1366: if ((*s_etat_processus).langue == 'F')
1367: {
1368: printf("(multiplication d'une ligne d'une matrice)\n\n");
1369: }
1370: else
1371: {
1372: printf("(multiply a row in a matrix)\n\n");
1373: }
1374:
1375: printf(" 3: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1376: printf(" 2: %s, %s, %s\n", d_INT, d_REL, d_CPL);
1377: printf(" 1: %s\n", d_INT);
1378: printf("-> 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1379:
1380: return;
1381: }
1382: else if ((*s_etat_processus).test_instruction == 'Y')
1383: {
1384: (*s_etat_processus).nombre_arguments = -1;
1385: return;
1386: }
1387:
1388: if ((last_valide = test_cfsf(s_etat_processus, 31)) == d_vrai)
1389: {
1390: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
1391: {
1392: return;
1393: }
1394:
1395: cf(s_etat_processus, 31);
1396: }
1397:
1398: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1399: &s_objet_argument_1) == d_erreur)
1400: {
1401: if (last_valide == d_vrai)
1402: {
1403: sf(s_etat_processus, 31);
1404: }
1405:
1406: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1407: return;
1408: }
1409:
1410: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1411: &s_objet_argument_2) == d_erreur)
1412: {
1413: if (last_valide == d_vrai)
1414: {
1415: sf(s_etat_processus, 31);
1416: }
1417:
1418: liberation(s_etat_processus, s_objet_argument_1);
1419:
1420: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1421: return;
1422: }
1423:
1424: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1425: &s_objet_argument_3) == d_erreur)
1426: {
1427: if (last_valide == d_vrai)
1428: {
1429: sf(s_etat_processus, 31);
1430: }
1431:
1432: liberation(s_etat_processus, s_objet_argument_1);
1433: liberation(s_etat_processus, s_objet_argument_2);
1434:
1435: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1436: return;
1437: }
1438:
1439: if ((((*s_objet_argument_3).type == MIN) ||
1440: ((*s_objet_argument_3).type == MRL) ||
1441: ((*s_objet_argument_3).type == MCX)) &&
1442: (((*s_objet_argument_2).type == INT) ||
1443: ((*s_objet_argument_2).type == REL) ||
1444: ((*s_objet_argument_2).type == CPL)) &&
1445: ((*s_objet_argument_1).type == INT))
1446: {
1447: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1448: s_objet_argument_3) == d_erreur)
1449: {
1450: if (last_valide == d_vrai)
1451: {
1452: sf(s_etat_processus, 31);
1453: }
1454:
1455: return;
1456: }
1457:
1458: tampon = s_objet_argument_1;
1459:
1460: if ((s_objet_argument_1 = allocation(s_etat_processus, LST)) == NULL)
1461: {
1462: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1463: return;
1464: }
1465:
1466: if (((*s_objet_argument_1).objet =
1467: allocation_maillon(s_etat_processus)) == NULL)
1468: {
1469: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1470: return;
1471: }
1472:
1473: (*((struct_liste_chainee *) (*s_objet_argument_1).objet)).donnee =
1474: tampon;
1475: (*((struct_liste_chainee *) (*s_objet_argument_1).objet)).suivant =
1476: NULL;
1477:
1478: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1479: s_objet_argument_1) == d_erreur)
1480: {
1481: if (last_valide == d_vrai)
1482: {
1483: sf(s_etat_processus, 31);
1484: }
1485:
1486: return;
1487: }
1488:
1489: instruction_dup2(s_etat_processus);
1490:
1491: if (((*s_etat_processus).erreur_systeme != d_es) ||
1492: ((*s_etat_processus).erreur_execution != d_ex) ||
1493: ((*s_etat_processus).exception != d_ep))
1494: {
1495: liberation(s_etat_processus, s_objet_argument_1);
1496: liberation(s_etat_processus, s_objet_argument_2);
1497: liberation(s_etat_processus, s_objet_argument_3);
1498:
1499: if (last_valide == d_vrai)
1500: {
1501: sf(s_etat_processus, 31);
1502: }
1503:
1504: return;
1505: }
1506:
1507: instruction_getr(s_etat_processus);
1508:
1509: if (((*s_etat_processus).erreur_systeme != d_es) ||
1510: ((*s_etat_processus).erreur_execution != d_ex) ||
1511: ((*s_etat_processus).exception != d_ep))
1512: {
1513: liberation(s_etat_processus, s_objet_argument_1);
1514: liberation(s_etat_processus, s_objet_argument_2);
1515: liberation(s_etat_processus, s_objet_argument_3);
1516:
1517: if (last_valide == d_vrai)
1518: {
1519: sf(s_etat_processus, 31);
1520: }
1521:
1522: return;
1523: }
1524:
1525: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1526: s_objet_argument_2) == d_erreur)
1527: {
1528: return;
1529: }
1530:
1531: instruction_multiplication(s_etat_processus);
1532:
1533: if (((*s_etat_processus).erreur_systeme != d_es) ||
1534: ((*s_etat_processus).erreur_execution != d_ex) ||
1535: ((*s_etat_processus).exception != d_ep))
1536: {
1537: liberation(s_etat_processus, s_objet_argument_1);
1538: liberation(s_etat_processus, s_objet_argument_2);
1539: liberation(s_etat_processus, s_objet_argument_3);
1540:
1541: if (last_valide == d_vrai)
1542: {
1543: sf(s_etat_processus, 31);
1544: }
1545:
1546: return;
1547: }
1548:
1549: instruction_putr(s_etat_processus);
1550:
1551: if (((*s_etat_processus).erreur_systeme != d_es) ||
1552: ((*s_etat_processus).erreur_execution != d_ex) ||
1553: ((*s_etat_processus).exception != d_ep))
1554: {
1555: liberation(s_etat_processus, s_objet_argument_1);
1556: liberation(s_etat_processus, s_objet_argument_2);
1557: liberation(s_etat_processus, s_objet_argument_3);
1558:
1559: if (last_valide == d_vrai)
1560: {
1561: sf(s_etat_processus, 31);
1562: }
1563:
1564: return;
1565: }
1566: }
1567: else
1568: {
1569: liberation(s_etat_processus, s_objet_argument_1);
1570: liberation(s_etat_processus, s_objet_argument_2);
1571: liberation(s_etat_processus, s_objet_argument_3);
1572:
1573: if (last_valide == d_vrai)
1574: {
1575: sf(s_etat_processus, 31);
1576: }
1577:
1578: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1579: return;
1580: }
1581:
1582: if (last_valide == d_vrai)
1583: {
1584: sf(s_etat_processus, 31);
1585: }
1586:
1587: return;
1588: }
1589:
1590:
1591: /*
1592: ================================================================================
1593: Fonction 'rcij'
1594: ================================================================================
1595: Entrées : pointeur sur une structure struct_processus
1596: --------------------------------------------------------------------------------
1597: Sorties :
1598: --------------------------------------------------------------------------------
1599: Effets de bord : néant
1600: ================================================================================
1601: */
1602:
1603: void
1604: instruction_rcij(struct_processus *s_etat_processus)
1605: {
1606: logical1 last_valide;
1607:
1608: struct_objet *s_objet_argument_1;
1609: struct_objet *s_objet_argument_2;
1610: struct_objet *s_objet_argument_3;
1611: struct_objet *s_objet_argument_4;
1612: struct_objet *tampon;
1613:
1614: (*s_etat_processus).erreur_execution = d_ex;
1615:
1616: if ((*s_etat_processus).affichage_arguments == 'Y')
1617: {
1618: printf("\n RCIJ ");
1619:
1620: if ((*s_etat_processus).langue == 'F')
1621: {
1622: printf("(multiplication puis ajout d'une ligne d'une matrice)\n\n");
1623: }
1624: else
1625: {
1626: printf("(multiply and add a row in a matrix)\n\n");
1627: }
1628:
1629: printf(" 4: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1630: printf(" 3: %s, %s, %s\n", d_INT, d_REL, d_CPL);
1631: printf(" 2: %s\n", d_INT);
1632: printf(" 1: %s\n", d_INT);
1633: printf("-> 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1634:
1635: return;
1636: }
1637: else if ((*s_etat_processus).test_instruction == 'Y')
1638: {
1639: (*s_etat_processus).nombre_arguments = -1;
1640: return;
1641: }
1642:
1643: if ((last_valide = test_cfsf(s_etat_processus, 31)) == d_vrai)
1644: {
1645: if (empilement_pile_last(s_etat_processus, 4) == d_erreur)
1646: {
1647: return;
1648: }
1649:
1650: cf(s_etat_processus, 31);
1651: }
1652:
1653: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1654: &s_objet_argument_1) == d_erreur)
1655: {
1656: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1657: return;
1658: }
1659:
1660: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1661: &s_objet_argument_2) == d_erreur)
1662: {
1663: liberation(s_etat_processus, s_objet_argument_1);
1664:
1665: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1666: return;
1667: }
1668:
1669: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1670: &s_objet_argument_3) == d_erreur)
1671: {
1672: liberation(s_etat_processus, s_objet_argument_1);
1673: liberation(s_etat_processus, s_objet_argument_2);
1674:
1675: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1676: return;
1677: }
1678:
1679: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1680: &s_objet_argument_4) == d_erreur)
1681: {
1682: liberation(s_etat_processus, s_objet_argument_1);
1683: liberation(s_etat_processus, s_objet_argument_2);
1684: liberation(s_etat_processus, s_objet_argument_3);
1685:
1686: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1687: return;
1688: }
1689:
1690: if ((((*s_objet_argument_4).type == MIN) ||
1691: ((*s_objet_argument_4).type == MRL) ||
1692: ((*s_objet_argument_4).type == MCX)) &&
1693: (((*s_objet_argument_3).type == INT) ||
1694: ((*s_objet_argument_3).type == REL) ||
1695: ((*s_objet_argument_3).type == CPL)) &&
1696: ((*s_objet_argument_2).type == INT) &&
1697: ((*s_objet_argument_1).type == INT))
1698: {
1699: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1700: s_objet_argument_4) == d_erreur)
1701: {
1702: return;
1703: }
1704:
1705: tampon = s_objet_argument_1;
1706:
1707: if ((s_objet_argument_1 = allocation(s_etat_processus, LST)) == NULL)
1708: {
1709: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1710: return;
1711: }
1712:
1713: if (((*s_objet_argument_1).objet =
1714: allocation_maillon(s_etat_processus)) == NULL)
1715: {
1716: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1717: return;
1718: }
1719:
1720: (*((struct_liste_chainee *) (*s_objet_argument_1).objet)).donnee =
1721: tampon;
1722: (*((struct_liste_chainee *) (*s_objet_argument_1).objet)).suivant =
1723: NULL;
1724:
1725: tampon = s_objet_argument_2;
1726:
1727: if ((s_objet_argument_2 = allocation(s_etat_processus, LST)) == NULL)
1728: {
1729: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1730: return;
1731: }
1732:
1733: if (((*s_objet_argument_2).objet =
1734: allocation_maillon(s_etat_processus)) == NULL)
1735: {
1736: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1737: return;
1738: }
1739:
1740: (*((struct_liste_chainee *) (*s_objet_argument_2).objet)).donnee =
1741: tampon;
1742: (*((struct_liste_chainee *) (*s_objet_argument_2).objet)).suivant =
1743: NULL;
1744:
1745: instruction_dup(s_etat_processus);
1746:
1747: if (((*s_etat_processus).erreur_systeme != d_es) ||
1748: ((*s_etat_processus).erreur_execution != d_ex) ||
1749: ((*s_etat_processus).exception != d_ep))
1750: {
1751: liberation(s_etat_processus, s_objet_argument_1);
1752: liberation(s_etat_processus, s_objet_argument_2);
1753: liberation(s_etat_processus, s_objet_argument_3);
1754: liberation(s_etat_processus, s_objet_argument_4);
1755:
1756: if (last_valide == d_vrai)
1757: {
1758: sf(s_etat_processus, 31);
1759: }
1760:
1761: return;
1762: }
1763:
1764: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1765: s_objet_argument_2) == d_erreur)
1766: {
1767: return;
1768: }
1769:
1770: instruction_getr(s_etat_processus);
1771:
1772: if (((*s_etat_processus).erreur_systeme != d_es) ||
1773: ((*s_etat_processus).erreur_execution != d_ex) ||
1774: ((*s_etat_processus).exception != d_ep))
1775: {
1776: liberation(s_etat_processus, s_objet_argument_1);
1777: liberation(s_etat_processus, s_objet_argument_2);
1778: liberation(s_etat_processus, s_objet_argument_3);
1779: liberation(s_etat_processus, s_objet_argument_4);
1780:
1781: if (last_valide == d_vrai)
1782: {
1783: sf(s_etat_processus, 31);
1784: }
1785:
1786: return;
1787: }
1788:
1789: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1790: s_objet_argument_3) == d_erreur)
1791: {
1792: return;
1793: }
1794:
1795: instruction_multiplication(s_etat_processus);
1796:
1797: if (((*s_etat_processus).erreur_systeme != d_es) ||
1798: ((*s_etat_processus).erreur_execution != d_ex) ||
1799: ((*s_etat_processus).exception != d_ep))
1800: {
1801: liberation(s_etat_processus, s_objet_argument_1);
1802: liberation(s_etat_processus, s_objet_argument_2);
1803: liberation(s_etat_processus, s_objet_argument_3);
1804: liberation(s_etat_processus, s_objet_argument_4);
1805:
1806: if (last_valide == d_vrai)
1807: {
1808: sf(s_etat_processus, 31);
1809: }
1810:
1811: return;
1812: }
1813:
1814: instruction_over(s_etat_processus);
1815:
1816: if (((*s_etat_processus).erreur_systeme != d_es) ||
1817: ((*s_etat_processus).erreur_execution != d_ex) ||
1818: ((*s_etat_processus).exception != d_ep))
1819: {
1820: liberation(s_etat_processus, s_objet_argument_1);
1821: liberation(s_etat_processus, s_objet_argument_2);
1822: liberation(s_etat_processus, s_objet_argument_3);
1823: liberation(s_etat_processus, s_objet_argument_4);
1824:
1825: if (last_valide == d_vrai)
1826: {
1827: sf(s_etat_processus, 31);
1828: }
1829:
1830: return;
1831: }
1832:
1833: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1834: s_objet_argument_1) == d_erreur)
1835: {
1836: return;
1837: }
1838:
1839: instruction_swap(s_etat_processus);
1840:
1841: if (((*s_etat_processus).erreur_systeme != d_es) ||
1842: ((*s_etat_processus).erreur_execution != d_ex) ||
1843: ((*s_etat_processus).exception != d_ep))
1844: {
1845: liberation(s_etat_processus, s_objet_argument_1);
1846: liberation(s_etat_processus, s_objet_argument_2);
1847: liberation(s_etat_processus, s_objet_argument_3);
1848: liberation(s_etat_processus, s_objet_argument_4);
1849:
1850: if (last_valide == d_vrai)
1851: {
1852: sf(s_etat_processus, 31);
1853: }
1854:
1855: return;
1856: }
1857:
1858: if (((*s_etat_processus).erreur_systeme != d_es) ||
1859: ((*s_etat_processus).erreur_execution != d_ex) ||
1860: ((*s_etat_processus).exception != d_ep))
1861: {
1862: liberation(s_etat_processus, s_objet_argument_1);
1863: liberation(s_etat_processus, s_objet_argument_2);
1864: liberation(s_etat_processus, s_objet_argument_3);
1865: liberation(s_etat_processus, s_objet_argument_4);
1866:
1867: if (last_valide == d_vrai)
1868: {
1869: sf(s_etat_processus, 31);
1870: }
1871:
1872: return;
1873: }
1874:
1875: instruction_over(s_etat_processus);
1876:
1877: if (((*s_etat_processus).erreur_systeme != d_es) ||
1878: ((*s_etat_processus).erreur_execution != d_ex) ||
1879: ((*s_etat_processus).exception != d_ep))
1880: {
1881: liberation(s_etat_processus, s_objet_argument_1);
1882: liberation(s_etat_processus, s_objet_argument_2);
1883: liberation(s_etat_processus, s_objet_argument_3);
1884: liberation(s_etat_processus, s_objet_argument_4);
1885:
1886: if (last_valide == d_vrai)
1887: {
1888: sf(s_etat_processus, 31);
1889: }
1890:
1891: return;
1892: }
1893:
1894: if (((*s_etat_processus).erreur_systeme != d_es) ||
1895: ((*s_etat_processus).erreur_execution != d_ex) ||
1896: ((*s_etat_processus).exception != d_ep))
1897: {
1898: liberation(s_etat_processus, s_objet_argument_1);
1899: liberation(s_etat_processus, s_objet_argument_2);
1900: liberation(s_etat_processus, s_objet_argument_3);
1901: liberation(s_etat_processus, s_objet_argument_4);
1902:
1903: if (last_valide == d_vrai)
1904: {
1905: sf(s_etat_processus, 31);
1906: }
1907:
1908: return;
1909: }
1910:
1911: instruction_getr(s_etat_processus);
1912:
1913: if (((*s_etat_processus).erreur_systeme != d_es) ||
1914: ((*s_etat_processus).erreur_execution != d_ex) ||
1915: ((*s_etat_processus).exception != d_ep))
1916: {
1917: liberation(s_etat_processus, s_objet_argument_1);
1918: liberation(s_etat_processus, s_objet_argument_2);
1919: liberation(s_etat_processus, s_objet_argument_3);
1920: liberation(s_etat_processus, s_objet_argument_4);
1921:
1922: if (last_valide == d_vrai)
1923: {
1924: sf(s_etat_processus, 31);
1925: }
1926:
1927: return;
1928: }
1929:
1930: if (((*s_etat_processus).erreur_systeme != d_es) ||
1931: ((*s_etat_processus).erreur_execution != d_ex) ||
1932: ((*s_etat_processus).exception != d_ep))
1933: {
1934: liberation(s_etat_processus, s_objet_argument_1);
1935: liberation(s_etat_processus, s_objet_argument_2);
1936: liberation(s_etat_processus, s_objet_argument_3);
1937: liberation(s_etat_processus, s_objet_argument_4);
1938:
1939: if (last_valide == d_vrai)
1940: {
1941: sf(s_etat_processus, 31);
1942: }
1943:
1944: return;
1945: }
1946:
1947: instruction_rot(s_etat_processus);
1948:
1949: if (((*s_etat_processus).erreur_systeme != d_es) ||
1950: ((*s_etat_processus).erreur_execution != d_ex) ||
1951: ((*s_etat_processus).exception != d_ep))
1952: {
1953: liberation(s_etat_processus, s_objet_argument_1);
1954: liberation(s_etat_processus, s_objet_argument_2);
1955: liberation(s_etat_processus, s_objet_argument_3);
1956: liberation(s_etat_processus, s_objet_argument_4);
1957:
1958: if (last_valide == d_vrai)
1959: {
1960: sf(s_etat_processus, 31);
1961: }
1962:
1963: return;
1964: }
1965:
1966: if (((*s_etat_processus).erreur_systeme != d_es) ||
1967: ((*s_etat_processus).erreur_execution != d_ex) ||
1968: ((*s_etat_processus).exception != d_ep))
1969: {
1970: liberation(s_etat_processus, s_objet_argument_1);
1971: liberation(s_etat_processus, s_objet_argument_2);
1972: liberation(s_etat_processus, s_objet_argument_3);
1973: liberation(s_etat_processus, s_objet_argument_4);
1974:
1975: if (last_valide == d_vrai)
1976: {
1977: sf(s_etat_processus, 31);
1978: }
1979:
1980: return;
1981: }
1982:
1983: instruction_plus(s_etat_processus);
1984:
1985: if (((*s_etat_processus).erreur_systeme != d_es) ||
1986: ((*s_etat_processus).erreur_execution != d_ex) ||
1987: ((*s_etat_processus).exception != d_ep))
1988: {
1989: liberation(s_etat_processus, s_objet_argument_1);
1990: liberation(s_etat_processus, s_objet_argument_2);
1991: liberation(s_etat_processus, s_objet_argument_3);
1992: liberation(s_etat_processus, s_objet_argument_4);
1993:
1994: if (last_valide == d_vrai)
1995: {
1996: sf(s_etat_processus, 31);
1997: }
1998:
1999: return;
2000: }
2001:
2002: instruction_putr(s_etat_processus);
2003:
2004: if (((*s_etat_processus).erreur_systeme != d_es) ||
2005: ((*s_etat_processus).erreur_execution != d_ex) ||
2006: ((*s_etat_processus).exception != d_ep))
2007: {
2008: liberation(s_etat_processus, s_objet_argument_1);
2009: liberation(s_etat_processus, s_objet_argument_2);
2010: liberation(s_etat_processus, s_objet_argument_3);
2011: liberation(s_etat_processus, s_objet_argument_4);
2012:
2013: if (last_valide == d_vrai)
2014: {
2015: sf(s_etat_processus, 31);
2016: }
2017:
2018: return;
2019: }
2020: }
2021: else
2022: {
2023: liberation(s_etat_processus, s_objet_argument_1);
2024: liberation(s_etat_processus, s_objet_argument_2);
2025: liberation(s_etat_processus, s_objet_argument_3);
2026: liberation(s_etat_processus, s_objet_argument_4);
2027:
2028: if (last_valide == d_vrai)
2029: {
2030: sf(s_etat_processus, 31);
2031: }
2032:
2033: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2034: return;
2035: }
2036:
2037: if (last_valide == d_vrai)
2038: {
2039: sf(s_etat_processus, 31);
2040: }
2041:
2042: return;
2043: }
2044:
2045: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>