1: /*
2: ================================================================================
3: RPL/2 (R) version 4.0.18
4: Copyright (C) 1989-2010 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).s_liste_variables[(*s_etat_processus)
352: .position_variable_courante].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).s_liste_variables
363: [(*s_etat_processus).position_variable_courante].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).s_liste_variables
376: [(*s_etat_processus).position_variable_courante].nom,
377: (*s_etat_processus).s_liste_variables
378: [(*s_etat_processus).position_variable_courante]
379: .variable_partagee, (*s_etat_processus).s_liste_variables
380: [(*s_etat_processus).position_variable_courante].origine)
381: == d_faux)
382: {
383: if (pthread_mutex_unlock(&((*(*s_etat_processus)
384: .s_liste_variables_partagees).mutex)) != 0)
385: {
386: (*s_etat_processus).erreur_systeme = d_es_processus;
387: return;
388: }
389:
390: (*s_etat_processus).erreur_systeme = d_es;
391: (*s_etat_processus).erreur_execution =
392: d_ex_variable_non_definie;
393:
394: liberation(s_etat_processus, s_objet_argument_1);
395: liberation(s_etat_processus, s_objet_argument_2);
396:
397: return;
398: }
399:
400: s_objet_argument_3 = (*(*s_etat_processus)
401: .s_liste_variables_partagees).table
402: [(*(*s_etat_processus).s_liste_variables_partagees)
403: .position_variable].objet;
404: variable_partagee = d_vrai;
405: }
406:
407: if ((s_copie_argument_3 = copie_objet(s_etat_processus,
408: s_objet_argument_3, 'Q')) == NULL)
409: {
410: if (variable_partagee == d_vrai)
411: {
412: if (pthread_mutex_unlock(&((*(*s_etat_processus)
413: .s_liste_variables_partagees).mutex)) != 0)
414: {
415: (*s_etat_processus).erreur_systeme = d_es_processus;
416: return;
417: }
418: }
419:
420: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
421: return;
422: }
423:
424: liberation(s_etat_processus, s_objet_argument_3);
425: s_objet_argument_3 = s_copie_argument_3;
426:
427: (*s_etat_processus).s_liste_variables[(*s_etat_processus)
428: .position_variable_courante].objet = s_objet_argument_3;
429: }
430: else
431: {
432: presence_nom = d_faux;
433:
434: if ((s_copie_argument_3 = copie_objet(s_etat_processus,
435: s_objet_argument_3, 'Q')) == NULL)
436: {
437: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
438: return;
439: }
440:
441: liberation(s_etat_processus, s_objet_argument_3);
442: s_objet_argument_3 = s_copie_argument_3;
443: }
444:
445: if (((*((struct_matrice *) (*s_objet_argument_3).objet)).nombre_colonnes
446: == 0) && ((*((struct_matrice *) (*s_objet_argument_3).objet))
447: .nombre_lignes == 1))
448: {
449: matrice_vide = d_vrai;
450: }
451: else
452: {
453: matrice_vide = d_faux;
454:
455: if ((*((struct_matrice *) (*s_objet_argument_1).objet)).nombre_colonnes
456: != (*((struct_matrice *) (*s_objet_argument_3).objet))
457: .nombre_colonnes)
458: {
459: if (variable_partagee == d_vrai)
460: {
461: if (pthread_mutex_unlock(&((*(*s_etat_processus)
462: .s_liste_variables_partagees).mutex)) != 0)
463: {
464: (*s_etat_processus).erreur_systeme = d_es_processus;
465: return;
466: }
467: }
468:
469: liberation(s_etat_processus, s_objet_argument_1);
470: liberation(s_etat_processus, s_objet_argument_2);
471:
472: if (presence_nom == d_faux)
473: {
474: liberation(s_etat_processus, s_objet_argument_3);
475: }
476:
477: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
478: return;
479: }
480: }
481:
482: if ((*s_objet_argument_1).type == MRL)
483: {
484: if ((*s_objet_argument_3).type == MIN)
485: {
486: // Conversion de la matrice entière en matrice réelle
487:
488: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_3).objet))
489: .nombre_lignes; i++)
490: {
491: tampon = (*((struct_matrice *) (*s_objet_argument_3).objet))
492: .tableau[i];
493:
494: if (((*((struct_matrice *) (*s_objet_argument_3).objet))
495: .tableau[i] = malloc((*((struct_matrice *)
496: (*s_objet_argument_3).objet)).nombre_colonnes *
497: sizeof(real8))) == NULL)
498: {
499: if (variable_partagee == d_vrai)
500: {
501: if (pthread_mutex_unlock(&((*(*s_etat_processus)
502: .s_liste_variables_partagees).mutex)) != 0)
503: {
504: (*s_etat_processus).erreur_systeme = d_es_processus;
505: return;
506: }
507: }
508:
509: (*s_etat_processus).erreur_systeme =
510: d_es_allocation_memoire;
511: return;
512: }
513:
514: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_3)
515: .objet)).nombre_colonnes; j++)
516: {
517: ((real8 **) (*((struct_matrice *) (*s_objet_argument_3)
518: .objet)).tableau)[i][j] = (real8) (((integer8 *)
519: tampon)[j]);
520: }
521:
522: free(tampon);
523: }
524:
525: (*((struct_matrice *) (*s_objet_argument_3).objet)).type = 'R';
526: (*s_objet_argument_3).type = MRL;
527: }
528: }
529: else if ((*s_objet_argument_1).type == MCX)
530: {
531: if ((*s_objet_argument_3).type == MIN)
532: {
533: // Conversion de la matrice entière en matrice complexe
534:
535: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_3).objet))
536: .nombre_lignes; i++)
537: {
538: tampon = (*((struct_matrice *) (*s_objet_argument_3).objet))
539: .tableau[i];
540:
541: if (((*((struct_matrice *) (*s_objet_argument_3).objet))
542: .tableau[i] = malloc((*((struct_matrice *)
543: (*s_objet_argument_3).objet)).nombre_colonnes *
544: sizeof(complex16))) == NULL)
545: {
546: if (variable_partagee == d_vrai)
547: {
548: if (pthread_mutex_unlock(&((*(*s_etat_processus)
549: .s_liste_variables_partagees).mutex)) != 0)
550: {
551: (*s_etat_processus).erreur_systeme = d_es_processus;
552: return;
553: }
554: }
555:
556: (*s_etat_processus).erreur_systeme =
557: d_es_allocation_memoire;
558: return;
559: }
560:
561: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_3)
562: .objet)).nombre_colonnes; j++)
563: {
564: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_3)
565: .objet)).tableau)[i][j].partie_reelle =
566: (real8) (((integer8 *) tampon)[j]);
567: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_3)
568: .objet)).tableau)[i][j].partie_imaginaire = 0;
569: }
570:
571: free(tampon);
572: }
573:
574: (*((struct_matrice *) (*s_objet_argument_3).objet)).type = 'C';
575: (*s_objet_argument_3).type = MCX;
576: }
577: else if ((*s_objet_argument_3).type == MRL)
578: {
579: // Conversion de la matrice réelle en matrice complexe
580:
581: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_3).objet))
582: .nombre_lignes; i++)
583: {
584: tampon = (*((struct_matrice *) (*s_objet_argument_3).objet))
585: .tableau[i];
586:
587: if (((*((struct_matrice *) (*s_objet_argument_3).objet))
588: .tableau[i] = malloc((*((struct_matrice *)
589: (*s_objet_argument_3).objet)).nombre_colonnes *
590: sizeof(complex16))) == NULL)
591: {
592: if (variable_partagee == d_vrai)
593: {
594: if (pthread_mutex_unlock(&((*(*s_etat_processus)
595: .s_liste_variables_partagees).mutex)) != 0)
596: {
597: (*s_etat_processus).erreur_systeme = d_es_processus;
598: return;
599: }
600: }
601:
602: (*s_etat_processus).erreur_systeme =
603: d_es_allocation_memoire;
604: return;
605: }
606:
607: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_3)
608: .objet)).nombre_colonnes; j++)
609: {
610: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_3)
611: .objet)).tableau)[i][j].partie_reelle =
612: ((real8 *) tampon)[j];
613: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_3)
614: .objet)).tableau)[i][j].partie_imaginaire = 0;
615: }
616:
617: free(tampon);
618: }
619:
620: (*((struct_matrice *) (*s_objet_argument_3).objet)).type = 'C';
621: (*s_objet_argument_3).type = MCX;
622: }
623: }
624:
625: if ((*s_objet_argument_3).type == MRL)
626: {
627: if ((*s_objet_argument_1).type == MIN)
628: {
629: // Conversion de la matrice entière en matrice réelle
630:
631: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_1).objet))
632: .nombre_lignes; i++)
633: {
634: tampon = (*((struct_matrice *) (*s_objet_argument_1).objet))
635: .tableau[i];
636:
637: if (((*((struct_matrice *) (*s_objet_argument_1).objet))
638: .tableau[i] = malloc((*((struct_matrice *)
639: (*s_objet_argument_1).objet)).nombre_colonnes *
640: sizeof(real8))) == NULL)
641: {
642: if (variable_partagee == d_vrai)
643: {
644: if (pthread_mutex_unlock(&((*(*s_etat_processus)
645: .s_liste_variables_partagees).mutex)) != 0)
646: {
647: (*s_etat_processus).erreur_systeme = d_es_processus;
648: return;
649: }
650: }
651:
652: (*s_etat_processus).erreur_systeme =
653: d_es_allocation_memoire;
654: return;
655: }
656:
657: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_1)
658: .objet)).nombre_colonnes; j++)
659: {
660: ((real8 **) (*((struct_matrice *) (*s_objet_argument_1)
661: .objet)).tableau)[i][j] = (real8) (((integer8 *)
662: tampon)[j]);
663: }
664:
665: free(tampon);
666: }
667:
668: (*((struct_matrice *) (*s_objet_argument_1).objet)).type = 'R';
669: (*s_objet_argument_1).type = MRL;
670: }
671: }
672: else if ((*s_objet_argument_3).type == MCX)
673: {
674: if ((*s_objet_argument_1).type == MIN)
675: {
676: // Conversion de la matrice entière en matrice complexe
677:
678: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_1).objet))
679: .nombre_lignes; i++)
680: {
681: tampon = (*((struct_matrice *) (*s_objet_argument_1).objet))
682: .tableau[i];
683:
684: if (((*((struct_matrice *) (*s_objet_argument_1).objet))
685: .tableau[i] = malloc((*((struct_matrice *)
686: (*s_objet_argument_1).objet)).nombre_colonnes *
687: sizeof(complex16))) == NULL)
688: {
689: if (variable_partagee == d_vrai)
690: {
691: if (pthread_mutex_unlock(&((*(*s_etat_processus)
692: .s_liste_variables_partagees).mutex)) != 0)
693: {
694: (*s_etat_processus).erreur_systeme = d_es_processus;
695: return;
696: }
697: }
698:
699: (*s_etat_processus).erreur_systeme =
700: d_es_allocation_memoire;
701: return;
702: }
703:
704: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_1)
705: .objet)).nombre_colonnes; j++)
706: {
707: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_1)
708: .objet)).tableau)[i][j].partie_reelle =
709: (real8) (((integer8 *) tampon)[j]);
710: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_1)
711: .objet)).tableau)[i][j].partie_imaginaire = 0;
712: }
713:
714: free(tampon);
715: }
716:
717: (*((struct_matrice *) (*s_objet_argument_1).objet)).type = 'C';
718: (*s_objet_argument_1).type = MCX;
719: }
720: else if ((*s_objet_argument_1).type == MRL)
721: {
722: // Conversion de la matrice réelle en matrice complexe
723:
724: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_1).objet))
725: .nombre_lignes; i++)
726: {
727: tampon = (*((struct_matrice *) (*s_objet_argument_1).objet))
728: .tableau[i];
729:
730: if (((*((struct_matrice *) (*s_objet_argument_1).objet))
731: .tableau[i] = malloc((*((struct_matrice *)
732: (*s_objet_argument_1).objet)).nombre_colonnes *
733: sizeof(complex16))) == NULL)
734: {
735: if (variable_partagee == d_vrai)
736: {
737: if (pthread_mutex_unlock(&((*(*s_etat_processus)
738: .s_liste_variables_partagees).mutex)) != 0)
739: {
740: (*s_etat_processus).erreur_systeme = d_es_processus;
741: return;
742: }
743: }
744:
745: (*s_etat_processus).erreur_systeme =
746: d_es_allocation_memoire;
747: return;
748: }
749:
750: for(j = 0; j < (*((struct_matrice *) (*s_objet_argument_1)
751: .objet)).nombre_colonnes; j++)
752: {
753: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_1)
754: .objet)).tableau)[i][j].partie_reelle =
755: ((real8 *) tampon)[j];
756: ((complex16 **) (*((struct_matrice *) (*s_objet_argument_1)
757: .objet)).tableau)[i][j].partie_imaginaire = 0;
758: }
759:
760: free(tampon);
761: }
762:
763: (*((struct_matrice *) (*s_objet_argument_1).objet)).type = 'C';
764: (*s_objet_argument_1).type = MCX;
765: }
766: }
767:
768: position = (*((integer8 *) (*s_objet_argument_2).objet));
769:
770: if (((position < 1) || (position > (integer8) ((*((struct_matrice *)
771: (*s_objet_argument_3).objet)).nombre_lignes + 1))) ||
772: ((position != 1) && (matrice_vide == d_vrai)))
773: {
774: if (variable_partagee == d_vrai)
775: {
776: if (pthread_mutex_unlock(&((*(*s_etat_processus)
777: .s_liste_variables_partagees).mutex)) != 0)
778: {
779: (*s_etat_processus).erreur_systeme = d_es_processus;
780: return;
781: }
782: }
783:
784: liberation(s_etat_processus, s_objet_argument_1);
785: liberation(s_etat_processus, s_objet_argument_2);
786:
787: if (presence_nom == d_faux)
788: {
789: liberation(s_etat_processus, s_objet_argument_3);
790: }
791:
792: (*s_etat_processus).erreur_execution =
793: d_ex_argument_invalide;
794: return;
795: }
796:
797: tableau = (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau;
798:
799: if (matrice_vide == d_faux)
800: {
801: if (((*((struct_matrice *) (*s_objet_argument_3).objet)).tableau
802: = malloc(((*((struct_matrice *) (*s_objet_argument_3).objet))
803: .nombre_lignes + 1) * sizeof(void *))) == NULL)
804: {
805: if (variable_partagee == d_vrai)
806: {
807: if (pthread_mutex_unlock(&((*(*s_etat_processus)
808: .s_liste_variables_partagees).mutex)) != 0)
809: {
810: (*s_etat_processus).erreur_systeme = d_es_processus;
811: return;
812: }
813: }
814:
815: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
816: return;
817: }
818:
819: if (position != ((integer8) (*((struct_matrice *)
820: (*s_objet_argument_3).objet)).nombre_lignes + 1))
821: {
822: for(j = i = 0; i < (*((struct_matrice *)
823: (*s_objet_argument_3).objet)).nombre_lignes; i++)
824: {
825: if (i == (unsigned long) (position - 1))
826: {
827: (*((struct_matrice *) (*s_objet_argument_3).objet))
828: .tableau[i] = (*((struct_matrice *)
829: (*s_objet_argument_1).objet)).tableau[0];
830: j = 1;
831: }
832:
833: (*((struct_matrice *) (*s_objet_argument_3).objet))
834: .tableau[i + j] = tableau[i];
835: }
836: }
837: else
838: {
839: for(i = 0; i < (*((struct_matrice *) (*s_objet_argument_3).objet))
840: .nombre_lignes; i++)
841: {
842: (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau[i]
843: = tableau[i];
844: }
845:
846: (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau
847: [(*((struct_matrice *) (*s_objet_argument_3).objet))
848: .nombre_lignes] = (*((struct_matrice *)
849: (*s_objet_argument_1).objet)).tableau[0];
850: }
851:
852: (*((struct_matrice *) (*s_objet_argument_3).objet)).nombre_lignes++;
853: }
854: else
855: {
856: free((*((struct_matrice *) (*s_objet_argument_3).objet)).tableau[0]);
857:
858: if (((*((struct_matrice *) (*s_objet_argument_3).objet)).tableau
859: = malloc(sizeof(void *))) == NULL)
860: {
861: if (variable_partagee == d_vrai)
862: {
863: if (pthread_mutex_unlock(&((*(*s_etat_processus)
864: .s_liste_variables_partagees).mutex)) != 0)
865: {
866: (*s_etat_processus).erreur_systeme = d_es_processus;
867: return;
868: }
869: }
870:
871: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
872: return;
873: }
874:
875: (*((struct_matrice *) (*s_objet_argument_3).objet)).tableau[0] =
876: (*((struct_matrice *) (*s_objet_argument_1).objet)).tableau[0];
877: (*((struct_matrice *) (*s_objet_argument_3).objet)).nombre_lignes =
878: (*((struct_matrice *) (*s_objet_argument_1).objet))
879: .nombre_lignes;
880: (*((struct_matrice *) (*s_objet_argument_3).objet)).nombre_colonnes =
881: (*((struct_matrice *) (*s_objet_argument_1).objet))
882: .nombre_colonnes;
883: }
884:
885: free(tableau);
886:
887: if (presence_nom == d_faux)
888: {
889: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
890: s_objet_argument_3) == d_erreur)
891: {
892: return;
893: }
894: }
895: else
896: {
897: if (variable_partagee == d_vrai)
898: {
899: (*(*s_etat_processus).s_liste_variables_partagees).table
900: [(*(*s_etat_processus).s_liste_variables_partagees)
901: .position_variable].objet = s_objet_argument_3;
902:
903: if (pthread_mutex_unlock(&((*(*s_etat_processus)
904: .s_liste_variables_partagees).mutex)) != 0)
905: {
906: (*s_etat_processus).erreur_systeme = d_es_processus;
907: return;
908: }
909: }
910: }
911:
912: free((*((struct_matrice *) (*s_objet_argument_1).objet)).tableau);
913: free((*s_objet_argument_1).objet);
914: free(s_objet_argument_1);
915:
916: liberation(s_etat_processus, s_objet_argument_2);
917:
918: return;
919: }
920:
921:
922: /*
923: ================================================================================
924: Fonction 'row-'
925: ================================================================================
926: Entrées : pointeur sur une structure struct_processus
927: --------------------------------------------------------------------------------
928: Sorties :
929: --------------------------------------------------------------------------------
930: Effets de bord : néant
931: ================================================================================
932: */
933:
934: void
935: instruction_row_moins(struct_processus *s_etat_processus)
936: {
937: integer8 position;
938:
939: logical1 presence_variable;
940: logical1 variable_partagee;
941:
942: struct_objet *s_copie_argument_2;
943: struct_objet *s_objet_argument_1;
944: struct_objet *s_objet_argument_2;
945: struct_objet *s_objet_resultat;
946:
947: unsigned long i;
948: unsigned long j;
949: unsigned long colonne;
950:
951: void **tableau;
952:
953: (*s_etat_processus).erreur_execution = d_ex;
954:
955: if ((*s_etat_processus).affichage_arguments == 'Y')
956: {
957: printf("\n ROW- ");
958:
959: if ((*s_etat_processus).langue == 'F')
960: {
961: printf("(retrait d'une ligne dans une matrice)\n\n");
962: }
963: else
964: {
965: printf("(remove a row from a matrix)\n\n");
966: }
967:
968: printf(" 2: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
969: printf(" 1: %s\n", d_INT);
970: printf("-> 2: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX);
971: printf(" 1: %s, %s, %s\n\n", d_MIN, d_MRL, d_MCX);
972:
973: printf(" 2: %s\n", d_NOM);
974: printf(" 1: %s\n", d_INT);
975: printf("-> 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
976:
977: return;
978: }
979: else if ((*s_etat_processus).test_instruction == 'Y')
980: {
981: (*s_etat_processus).nombre_arguments = -1;
982: return;
983: }
984:
985: if (test_cfsf(s_etat_processus, 31) == d_vrai)
986: {
987: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
988: {
989: return;
990: }
991: }
992:
993: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
994: &s_objet_argument_1) == d_erreur)
995: {
996: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
997: return;
998: }
999:
1000: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1001: &s_objet_argument_2) == d_erreur)
1002: {
1003: liberation(s_etat_processus, s_objet_argument_1);
1004:
1005: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1006: return;
1007: }
1008:
1009: variable_partagee = d_faux;
1010:
1011: if ((*s_objet_argument_2).type == NOM)
1012: {
1013: presence_variable = d_vrai;
1014:
1015: if (recherche_variable(s_etat_processus, (*((struct_nom *)
1016: (*s_objet_argument_2).objet)).nom) == d_faux)
1017: {
1018: liberation(s_etat_processus, s_objet_argument_1);
1019: liberation(s_etat_processus, s_objet_argument_2);
1020:
1021: (*s_etat_processus).erreur_systeme = d_es;
1022: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
1023:
1024: return;
1025: }
1026:
1027: liberation(s_etat_processus, s_objet_argument_2);
1028:
1029: if ((*s_etat_processus).s_liste_variables[(*s_etat_processus)
1030: .position_variable_courante].variable_verrouillee == d_vrai)
1031: {
1032: liberation(s_etat_processus, s_objet_argument_1);
1033:
1034: (*s_etat_processus).erreur_execution = d_ex_variable_verrouillee;
1035: return;
1036: }
1037:
1038: s_objet_argument_2 = (*s_etat_processus).s_liste_variables
1039: [(*s_etat_processus).position_variable_courante].objet;
1040:
1041: if (s_objet_argument_2 == NULL)
1042: {
1043: if (pthread_mutex_lock(&((*(*s_etat_processus)
1044: .s_liste_variables_partagees).mutex)) != 0)
1045: {
1046: (*s_etat_processus).erreur_systeme = d_es_processus;
1047: return;
1048: }
1049:
1050: if (recherche_variable_partagee(s_etat_processus,
1051: (*s_etat_processus).s_liste_variables
1052: [(*s_etat_processus).position_variable_courante].nom,
1053: (*s_etat_processus).s_liste_variables
1054: [(*s_etat_processus).position_variable_courante]
1055: .variable_partagee, (*s_etat_processus).s_liste_variables
1056: [(*s_etat_processus).position_variable_courante].origine)
1057: == d_faux)
1058: {
1059: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1060: .s_liste_variables_partagees).mutex)) != 0)
1061: {
1062: (*s_etat_processus).erreur_systeme = d_es_processus;
1063: return;
1064: }
1065:
1066: (*s_etat_processus).erreur_systeme = d_es;
1067: (*s_etat_processus).erreur_execution =
1068: d_ex_variable_non_definie;
1069:
1070: liberation(s_etat_processus, s_objet_argument_1);
1071:
1072: return;
1073: }
1074:
1075: s_objet_argument_2 = (*(*s_etat_processus)
1076: .s_liste_variables_partagees).table
1077: [(*(*s_etat_processus).s_liste_variables_partagees)
1078: .position_variable].objet;
1079: variable_partagee = d_vrai;
1080: }
1081:
1082: if ((s_copie_argument_2 = copie_objet(s_etat_processus,
1083: s_objet_argument_2, 'Q')) == NULL)
1084: {
1085: if (variable_partagee == d_vrai)
1086: {
1087: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1088: .s_liste_variables_partagees).mutex)) != 0)
1089: {
1090: (*s_etat_processus).erreur_systeme = d_es_processus;
1091: return;
1092: }
1093: }
1094:
1095: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1096: return;
1097: }
1098:
1099: liberation(s_etat_processus, s_objet_argument_2);
1100: s_objet_argument_2 = s_copie_argument_2;
1101:
1102: (*s_etat_processus).s_liste_variables[(*s_etat_processus)
1103: .position_variable_courante].objet = s_objet_argument_2;
1104: }
1105: else
1106: {
1107: presence_variable = d_faux;
1108:
1109: if ((s_copie_argument_2 = copie_objet(s_etat_processus,
1110: s_objet_argument_2, 'Q')) == NULL)
1111: {
1112: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1113: return;
1114: }
1115:
1116: liberation(s_etat_processus, s_objet_argument_2);
1117: s_objet_argument_2 = s_copie_argument_2;
1118: }
1119:
1120: if (((*s_objet_argument_2).type == MIN) ||
1121: ((*s_objet_argument_2).type == MRL) ||
1122: ((*s_objet_argument_2).type == MCX))
1123: {
1124: if ((*s_objet_argument_1).type == INT)
1125: {
1126: position = (*((integer8 *) (*s_objet_argument_1).objet));
1127:
1128: if ((position <= 0) || (position > (integer8) (*((struct_matrice *)
1129: (*s_objet_argument_2).objet)).nombre_lignes))
1130: {
1131: if (variable_partagee == d_vrai)
1132: {
1133: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1134: .s_liste_variables_partagees).mutex)) != 0)
1135: {
1136: (*s_etat_processus).erreur_systeme = d_es_processus;
1137: return;
1138: }
1139: }
1140:
1141: liberation(s_etat_processus, s_objet_argument_1);
1142:
1143: if (presence_variable == d_faux)
1144: {
1145: liberation(s_etat_processus, s_objet_argument_2);
1146: }
1147:
1148: (*s_etat_processus).erreur_execution =
1149: d_ex_argument_invalide;
1150: return;
1151: }
1152:
1153: if ((s_objet_resultat = allocation(s_etat_processus,
1154: (*s_objet_argument_2).type)) == NULL)
1155: {
1156: if (variable_partagee == d_vrai)
1157: {
1158: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1159: .s_liste_variables_partagees).mutex)) != 0)
1160: {
1161: (*s_etat_processus).erreur_systeme = d_es_processus;
1162: return;
1163: }
1164: }
1165:
1166: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1167: return;
1168: }
1169:
1170: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_lignes =
1171: 1;
1172: (*((struct_matrice *) (*s_objet_resultat).objet)).nombre_colonnes =
1173: (*((struct_matrice *) (*s_objet_argument_2).objet))
1174: .nombre_colonnes;
1175:
1176: if (((*((struct_matrice *) (*s_objet_resultat).objet)).tableau =
1177: malloc(sizeof(void *))) == NULL)
1178: {
1179: if (variable_partagee == d_vrai)
1180: {
1181: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1182: .s_liste_variables_partagees).mutex)) != 0)
1183: {
1184: (*s_etat_processus).erreur_systeme = d_es_processus;
1185: return;
1186: }
1187: }
1188:
1189: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1190: return;
1191: }
1192:
1193: (*((struct_matrice *) (*s_objet_resultat).objet)).tableau[0] =
1194: (*((struct_matrice *) (*s_objet_argument_2).objet)).tableau
1195: [colonne = position - 1];
1196:
1197: if ((*((struct_matrice *) (*s_objet_argument_2).objet))
1198: .nombre_lignes > 1)
1199: {
1200: tableau = (*((struct_matrice *) (*s_objet_argument_2).objet))
1201: .tableau;
1202:
1203: if (((*((struct_matrice *) (*s_objet_argument_2).objet)).tableau
1204: = malloc(((*((struct_matrice *) (*s_objet_argument_2)
1205: .objet)).nombre_lignes - 1) * sizeof(void *))) == NULL)
1206: {
1207: if (variable_partagee == d_vrai)
1208: {
1209: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1210: .s_liste_variables_partagees).mutex)) != 0)
1211: {
1212: (*s_etat_processus).erreur_systeme = d_es_processus;
1213: return;
1214: }
1215: }
1216:
1217: (*s_etat_processus).erreur_systeme =
1218: d_es_allocation_memoire;
1219: return;
1220: }
1221:
1222: (*((struct_matrice *) (*s_objet_argument_2).objet))
1223: .nombre_lignes--;
1224:
1225: for(i = j = 0; i < (*((struct_matrice *) (*s_objet_argument_2)
1226: .objet)).nombre_lignes; i++)
1227: {
1228: if (i == colonne)
1229: {
1230: j = 1;
1231: }
1232:
1233: (*((struct_matrice *) (*s_objet_argument_2).objet))
1234: .tableau[i] = tableau[i + j];
1235: }
1236:
1237: free(tableau);
1238: }
1239: else
1240: {
1241: if (((*((struct_matrice *) (*s_objet_argument_2).objet))
1242: .tableau[0] = malloc(0)) == NULL)
1243: {
1244: if (variable_partagee == d_vrai)
1245: {
1246: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1247: .s_liste_variables_partagees).mutex)) != 0)
1248: {
1249: (*s_etat_processus).erreur_systeme = d_es_processus;
1250: return;
1251: }
1252: }
1253:
1254: (*s_etat_processus).erreur_systeme =
1255: d_es_allocation_memoire;
1256: return;
1257: }
1258:
1259: (*((struct_matrice *) (*s_objet_argument_2).objet))
1260: .nombre_colonnes = 0;
1261: }
1262: }
1263: else
1264: {
1265: if (variable_partagee == d_vrai)
1266: {
1267: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1268: .s_liste_variables_partagees).mutex)) != 0)
1269: {
1270: (*s_etat_processus).erreur_systeme = d_es_processus;
1271: return;
1272: }
1273: }
1274:
1275: liberation(s_etat_processus, s_objet_argument_1);
1276:
1277: if (presence_variable == d_faux)
1278: {
1279: liberation(s_etat_processus, s_objet_argument_2);
1280: }
1281:
1282: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1283: return;
1284: }
1285: }
1286: else
1287: {
1288: if (variable_partagee == d_vrai)
1289: {
1290: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1291: .s_liste_variables_partagees).mutex)) != 0)
1292: {
1293: (*s_etat_processus).erreur_systeme = d_es_processus;
1294: return;
1295: }
1296: }
1297:
1298: liberation(s_etat_processus, s_objet_argument_1);
1299:
1300: if (presence_variable == d_faux)
1301: {
1302: liberation(s_etat_processus, s_objet_argument_2);
1303: }
1304:
1305: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1306: return;
1307: }
1308:
1309: liberation(s_etat_processus, s_objet_argument_1);
1310:
1311: if (presence_variable == d_faux)
1312: {
1313: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1314: s_objet_argument_2) == d_erreur)
1315: {
1316: return;
1317: }
1318: }
1319: else if (variable_partagee == d_vrai)
1320: {
1321: (*(*s_etat_processus).s_liste_variables_partagees).table
1322: [(*(*s_etat_processus).s_liste_variables_partagees)
1323: .position_variable].objet = s_objet_argument_2;
1324:
1325: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1326: .s_liste_variables_partagees).mutex)) != 0)
1327: {
1328: (*s_etat_processus).erreur_systeme = d_es_processus;
1329: return;
1330: }
1331: }
1332:
1333: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1334: s_objet_resultat) == d_erreur)
1335: {
1336: return;
1337: }
1338:
1339: return;
1340: }
1341:
1342:
1343: /*
1344: ================================================================================
1345: Fonction 'rci'
1346: ================================================================================
1347: Entrées : pointeur sur une structure struct_processus
1348: --------------------------------------------------------------------------------
1349: Sorties :
1350: --------------------------------------------------------------------------------
1351: Effets de bord : néant
1352: ================================================================================
1353: */
1354:
1355: void
1356: instruction_rci(struct_processus *s_etat_processus)
1357: {
1358: logical1 last_valide;
1359:
1360: struct_objet *s_objet_argument_1;
1361: struct_objet *s_objet_argument_2;
1362: struct_objet *s_objet_argument_3;
1363: struct_objet *tampon;
1364:
1365: (*s_etat_processus).erreur_execution = d_ex;
1366:
1367: if ((*s_etat_processus).affichage_arguments == 'Y')
1368: {
1369: printf("\n RCI ");
1370:
1371: if ((*s_etat_processus).langue == 'F')
1372: {
1373: printf("(multiplication d'une ligne d'une matrice)\n\n");
1374: }
1375: else
1376: {
1377: printf("(multiply a row in a matrix)\n\n");
1378: }
1379:
1380: printf(" 3: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1381: printf(" 2: %s, %s, %s\n", d_INT, d_REL, d_CPL);
1382: printf(" 1: %s\n", d_INT);
1383: printf("-> 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1384:
1385: return;
1386: }
1387: else if ((*s_etat_processus).test_instruction == 'Y')
1388: {
1389: (*s_etat_processus).nombre_arguments = -1;
1390: return;
1391: }
1392:
1393: if ((last_valide = test_cfsf(s_etat_processus, 31)) == d_vrai)
1394: {
1395: if (empilement_pile_last(s_etat_processus, 3) == d_erreur)
1396: {
1397: return;
1398: }
1399:
1400: cf(s_etat_processus, 31);
1401: }
1402:
1403: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1404: &s_objet_argument_1) == d_erreur)
1405: {
1406: if (last_valide == d_vrai)
1407: {
1408: sf(s_etat_processus, 31);
1409: }
1410:
1411: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1412: return;
1413: }
1414:
1415: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1416: &s_objet_argument_2) == d_erreur)
1417: {
1418: if (last_valide == d_vrai)
1419: {
1420: sf(s_etat_processus, 31);
1421: }
1422:
1423: liberation(s_etat_processus, s_objet_argument_1);
1424:
1425: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1426: return;
1427: }
1428:
1429: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1430: &s_objet_argument_3) == d_erreur)
1431: {
1432: if (last_valide == d_vrai)
1433: {
1434: sf(s_etat_processus, 31);
1435: }
1436:
1437: liberation(s_etat_processus, s_objet_argument_1);
1438: liberation(s_etat_processus, s_objet_argument_2);
1439:
1440: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1441: return;
1442: }
1443:
1444: if ((((*s_objet_argument_3).type == MIN) ||
1445: ((*s_objet_argument_3).type == MRL) ||
1446: ((*s_objet_argument_3).type == MCX)) &&
1447: (((*s_objet_argument_2).type == INT) ||
1448: ((*s_objet_argument_2).type == REL) ||
1449: ((*s_objet_argument_2).type == CPL)) &&
1450: ((*s_objet_argument_1).type == INT))
1451: {
1452: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1453: s_objet_argument_3) == d_erreur)
1454: {
1455: if (last_valide == d_vrai)
1456: {
1457: sf(s_etat_processus, 31);
1458: }
1459:
1460: return;
1461: }
1462:
1463: tampon = s_objet_argument_1;
1464:
1465: if ((s_objet_argument_1 = allocation(s_etat_processus, LST)) == NULL)
1466: {
1467: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1468: return;
1469: }
1470:
1471: if (((*s_objet_argument_1).objet =
1472: allocation_maillon(s_etat_processus)) == NULL)
1473: {
1474: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1475: return;
1476: }
1477:
1478: (*((struct_liste_chainee *) (*s_objet_argument_1).objet)).donnee =
1479: tampon;
1480: (*((struct_liste_chainee *) (*s_objet_argument_1).objet)).suivant =
1481: NULL;
1482:
1483: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1484: s_objet_argument_1) == d_erreur)
1485: {
1486: if (last_valide == d_vrai)
1487: {
1488: sf(s_etat_processus, 31);
1489: }
1490:
1491: return;
1492: }
1493:
1494: instruction_dup2(s_etat_processus);
1495:
1496: if (((*s_etat_processus).erreur_systeme != d_es) ||
1497: ((*s_etat_processus).erreur_execution != d_ex) ||
1498: ((*s_etat_processus).exception != d_ep))
1499: {
1500: liberation(s_etat_processus, s_objet_argument_1);
1501: liberation(s_etat_processus, s_objet_argument_2);
1502: liberation(s_etat_processus, s_objet_argument_3);
1503:
1504: if (last_valide == d_vrai)
1505: {
1506: sf(s_etat_processus, 31);
1507: }
1508:
1509: return;
1510: }
1511:
1512: instruction_getr(s_etat_processus);
1513:
1514: if (((*s_etat_processus).erreur_systeme != d_es) ||
1515: ((*s_etat_processus).erreur_execution != d_ex) ||
1516: ((*s_etat_processus).exception != d_ep))
1517: {
1518: liberation(s_etat_processus, s_objet_argument_1);
1519: liberation(s_etat_processus, s_objet_argument_2);
1520: liberation(s_etat_processus, s_objet_argument_3);
1521:
1522: if (last_valide == d_vrai)
1523: {
1524: sf(s_etat_processus, 31);
1525: }
1526:
1527: return;
1528: }
1529:
1530: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1531: s_objet_argument_2) == d_erreur)
1532: {
1533: return;
1534: }
1535:
1536: instruction_multiplication(s_etat_processus);
1537:
1538: if (((*s_etat_processus).erreur_systeme != d_es) ||
1539: ((*s_etat_processus).erreur_execution != d_ex) ||
1540: ((*s_etat_processus).exception != d_ep))
1541: {
1542: liberation(s_etat_processus, s_objet_argument_1);
1543: liberation(s_etat_processus, s_objet_argument_2);
1544: liberation(s_etat_processus, s_objet_argument_3);
1545:
1546: if (last_valide == d_vrai)
1547: {
1548: sf(s_etat_processus, 31);
1549: }
1550:
1551: return;
1552: }
1553:
1554: instruction_putr(s_etat_processus);
1555:
1556: if (((*s_etat_processus).erreur_systeme != d_es) ||
1557: ((*s_etat_processus).erreur_execution != d_ex) ||
1558: ((*s_etat_processus).exception != d_ep))
1559: {
1560: liberation(s_etat_processus, s_objet_argument_1);
1561: liberation(s_etat_processus, s_objet_argument_2);
1562: liberation(s_etat_processus, s_objet_argument_3);
1563:
1564: if (last_valide == d_vrai)
1565: {
1566: sf(s_etat_processus, 31);
1567: }
1568:
1569: return;
1570: }
1571: }
1572: else
1573: {
1574: liberation(s_etat_processus, s_objet_argument_1);
1575: liberation(s_etat_processus, s_objet_argument_2);
1576: liberation(s_etat_processus, s_objet_argument_3);
1577:
1578: if (last_valide == d_vrai)
1579: {
1580: sf(s_etat_processus, 31);
1581: }
1582:
1583: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1584: return;
1585: }
1586:
1587: if (last_valide == d_vrai)
1588: {
1589: sf(s_etat_processus, 31);
1590: }
1591:
1592: return;
1593: }
1594:
1595:
1596: /*
1597: ================================================================================
1598: Fonction 'rcij'
1599: ================================================================================
1600: Entrées : pointeur sur une structure struct_processus
1601: --------------------------------------------------------------------------------
1602: Sorties :
1603: --------------------------------------------------------------------------------
1604: Effets de bord : néant
1605: ================================================================================
1606: */
1607:
1608: void
1609: instruction_rcij(struct_processus *s_etat_processus)
1610: {
1611: logical1 last_valide;
1612:
1613: struct_objet *s_objet_argument_1;
1614: struct_objet *s_objet_argument_2;
1615: struct_objet *s_objet_argument_3;
1616: struct_objet *s_objet_argument_4;
1617: struct_objet *tampon;
1618:
1619: (*s_etat_processus).erreur_execution = d_ex;
1620:
1621: if ((*s_etat_processus).affichage_arguments == 'Y')
1622: {
1623: printf("\n RCIJ ");
1624:
1625: if ((*s_etat_processus).langue == 'F')
1626: {
1627: printf("(multiplication puis ajout d'une ligne d'une matrice)\n\n");
1628: }
1629: else
1630: {
1631: printf("(multiply and add a row in a matrix)\n\n");
1632: }
1633:
1634: printf(" 4: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1635: printf(" 3: %s, %s, %s\n", d_INT, d_REL, d_CPL);
1636: printf(" 2: %s\n", d_INT);
1637: printf(" 1: %s\n", d_INT);
1638: printf("-> 1: %s, %s, %s\n", d_MIN, d_MRL, d_MCX);
1639:
1640: return;
1641: }
1642: else if ((*s_etat_processus).test_instruction == 'Y')
1643: {
1644: (*s_etat_processus).nombre_arguments = -1;
1645: return;
1646: }
1647:
1648: if ((last_valide = test_cfsf(s_etat_processus, 31)) == d_vrai)
1649: {
1650: if (empilement_pile_last(s_etat_processus, 4) == d_erreur)
1651: {
1652: return;
1653: }
1654:
1655: cf(s_etat_processus, 31);
1656: }
1657:
1658: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1659: &s_objet_argument_1) == d_erreur)
1660: {
1661: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1662: return;
1663: }
1664:
1665: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1666: &s_objet_argument_2) == d_erreur)
1667: {
1668: liberation(s_etat_processus, s_objet_argument_1);
1669:
1670: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1671: return;
1672: }
1673:
1674: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1675: &s_objet_argument_3) == d_erreur)
1676: {
1677: liberation(s_etat_processus, s_objet_argument_1);
1678: liberation(s_etat_processus, s_objet_argument_2);
1679:
1680: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1681: return;
1682: }
1683:
1684: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1685: &s_objet_argument_4) == d_erreur)
1686: {
1687: liberation(s_etat_processus, s_objet_argument_1);
1688: liberation(s_etat_processus, s_objet_argument_2);
1689: liberation(s_etat_processus, s_objet_argument_3);
1690:
1691: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1692: return;
1693: }
1694:
1695: if ((((*s_objet_argument_4).type == MIN) ||
1696: ((*s_objet_argument_4).type == MRL) ||
1697: ((*s_objet_argument_4).type == MCX)) &&
1698: (((*s_objet_argument_3).type == INT) ||
1699: ((*s_objet_argument_3).type == REL) ||
1700: ((*s_objet_argument_3).type == CPL)) &&
1701: ((*s_objet_argument_2).type == INT) &&
1702: ((*s_objet_argument_1).type == INT))
1703: {
1704: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1705: s_objet_argument_4) == d_erreur)
1706: {
1707: return;
1708: }
1709:
1710: tampon = s_objet_argument_1;
1711:
1712: if ((s_objet_argument_1 = allocation(s_etat_processus, LST)) == NULL)
1713: {
1714: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1715: return;
1716: }
1717:
1718: if (((*s_objet_argument_1).objet =
1719: allocation_maillon(s_etat_processus)) == NULL)
1720: {
1721: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1722: return;
1723: }
1724:
1725: (*((struct_liste_chainee *) (*s_objet_argument_1).objet)).donnee =
1726: tampon;
1727: (*((struct_liste_chainee *) (*s_objet_argument_1).objet)).suivant =
1728: NULL;
1729:
1730: tampon = s_objet_argument_2;
1731:
1732: if ((s_objet_argument_2 = allocation(s_etat_processus, LST)) == NULL)
1733: {
1734: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1735: return;
1736: }
1737:
1738: if (((*s_objet_argument_2).objet =
1739: allocation_maillon(s_etat_processus)) == NULL)
1740: {
1741: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1742: return;
1743: }
1744:
1745: (*((struct_liste_chainee *) (*s_objet_argument_2).objet)).donnee =
1746: tampon;
1747: (*((struct_liste_chainee *) (*s_objet_argument_2).objet)).suivant =
1748: NULL;
1749:
1750: instruction_dup(s_etat_processus);
1751:
1752: if (((*s_etat_processus).erreur_systeme != d_es) ||
1753: ((*s_etat_processus).erreur_execution != d_ex) ||
1754: ((*s_etat_processus).exception != d_ep))
1755: {
1756: liberation(s_etat_processus, s_objet_argument_1);
1757: liberation(s_etat_processus, s_objet_argument_2);
1758: liberation(s_etat_processus, s_objet_argument_3);
1759: liberation(s_etat_processus, s_objet_argument_4);
1760:
1761: if (last_valide == d_vrai)
1762: {
1763: sf(s_etat_processus, 31);
1764: }
1765:
1766: return;
1767: }
1768:
1769: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1770: s_objet_argument_2) == d_erreur)
1771: {
1772: return;
1773: }
1774:
1775: instruction_getr(s_etat_processus);
1776:
1777: if (((*s_etat_processus).erreur_systeme != d_es) ||
1778: ((*s_etat_processus).erreur_execution != d_ex) ||
1779: ((*s_etat_processus).exception != d_ep))
1780: {
1781: liberation(s_etat_processus, s_objet_argument_1);
1782: liberation(s_etat_processus, s_objet_argument_2);
1783: liberation(s_etat_processus, s_objet_argument_3);
1784: liberation(s_etat_processus, s_objet_argument_4);
1785:
1786: if (last_valide == d_vrai)
1787: {
1788: sf(s_etat_processus, 31);
1789: }
1790:
1791: return;
1792: }
1793:
1794: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1795: s_objet_argument_3) == d_erreur)
1796: {
1797: return;
1798: }
1799:
1800: instruction_multiplication(s_etat_processus);
1801:
1802: if (((*s_etat_processus).erreur_systeme != d_es) ||
1803: ((*s_etat_processus).erreur_execution != d_ex) ||
1804: ((*s_etat_processus).exception != d_ep))
1805: {
1806: liberation(s_etat_processus, s_objet_argument_1);
1807: liberation(s_etat_processus, s_objet_argument_2);
1808: liberation(s_etat_processus, s_objet_argument_3);
1809: liberation(s_etat_processus, s_objet_argument_4);
1810:
1811: if (last_valide == d_vrai)
1812: {
1813: sf(s_etat_processus, 31);
1814: }
1815:
1816: return;
1817: }
1818:
1819: instruction_over(s_etat_processus);
1820:
1821: if (((*s_etat_processus).erreur_systeme != d_es) ||
1822: ((*s_etat_processus).erreur_execution != d_ex) ||
1823: ((*s_etat_processus).exception != d_ep))
1824: {
1825: liberation(s_etat_processus, s_objet_argument_1);
1826: liberation(s_etat_processus, s_objet_argument_2);
1827: liberation(s_etat_processus, s_objet_argument_3);
1828: liberation(s_etat_processus, s_objet_argument_4);
1829:
1830: if (last_valide == d_vrai)
1831: {
1832: sf(s_etat_processus, 31);
1833: }
1834:
1835: return;
1836: }
1837:
1838: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1839: s_objet_argument_1) == d_erreur)
1840: {
1841: return;
1842: }
1843:
1844: instruction_swap(s_etat_processus);
1845:
1846: if (((*s_etat_processus).erreur_systeme != d_es) ||
1847: ((*s_etat_processus).erreur_execution != d_ex) ||
1848: ((*s_etat_processus).exception != d_ep))
1849: {
1850: liberation(s_etat_processus, s_objet_argument_1);
1851: liberation(s_etat_processus, s_objet_argument_2);
1852: liberation(s_etat_processus, s_objet_argument_3);
1853: liberation(s_etat_processus, s_objet_argument_4);
1854:
1855: if (last_valide == d_vrai)
1856: {
1857: sf(s_etat_processus, 31);
1858: }
1859:
1860: return;
1861: }
1862:
1863: if (((*s_etat_processus).erreur_systeme != d_es) ||
1864: ((*s_etat_processus).erreur_execution != d_ex) ||
1865: ((*s_etat_processus).exception != d_ep))
1866: {
1867: liberation(s_etat_processus, s_objet_argument_1);
1868: liberation(s_etat_processus, s_objet_argument_2);
1869: liberation(s_etat_processus, s_objet_argument_3);
1870: liberation(s_etat_processus, s_objet_argument_4);
1871:
1872: if (last_valide == d_vrai)
1873: {
1874: sf(s_etat_processus, 31);
1875: }
1876:
1877: return;
1878: }
1879:
1880: instruction_over(s_etat_processus);
1881:
1882: if (((*s_etat_processus).erreur_systeme != d_es) ||
1883: ((*s_etat_processus).erreur_execution != d_ex) ||
1884: ((*s_etat_processus).exception != d_ep))
1885: {
1886: liberation(s_etat_processus, s_objet_argument_1);
1887: liberation(s_etat_processus, s_objet_argument_2);
1888: liberation(s_etat_processus, s_objet_argument_3);
1889: liberation(s_etat_processus, s_objet_argument_4);
1890:
1891: if (last_valide == d_vrai)
1892: {
1893: sf(s_etat_processus, 31);
1894: }
1895:
1896: return;
1897: }
1898:
1899: if (((*s_etat_processus).erreur_systeme != d_es) ||
1900: ((*s_etat_processus).erreur_execution != d_ex) ||
1901: ((*s_etat_processus).exception != d_ep))
1902: {
1903: liberation(s_etat_processus, s_objet_argument_1);
1904: liberation(s_etat_processus, s_objet_argument_2);
1905: liberation(s_etat_processus, s_objet_argument_3);
1906: liberation(s_etat_processus, s_objet_argument_4);
1907:
1908: if (last_valide == d_vrai)
1909: {
1910: sf(s_etat_processus, 31);
1911: }
1912:
1913: return;
1914: }
1915:
1916: instruction_getr(s_etat_processus);
1917:
1918: if (((*s_etat_processus).erreur_systeme != d_es) ||
1919: ((*s_etat_processus).erreur_execution != d_ex) ||
1920: ((*s_etat_processus).exception != d_ep))
1921: {
1922: liberation(s_etat_processus, s_objet_argument_1);
1923: liberation(s_etat_processus, s_objet_argument_2);
1924: liberation(s_etat_processus, s_objet_argument_3);
1925: liberation(s_etat_processus, s_objet_argument_4);
1926:
1927: if (last_valide == d_vrai)
1928: {
1929: sf(s_etat_processus, 31);
1930: }
1931:
1932: return;
1933: }
1934:
1935: if (((*s_etat_processus).erreur_systeme != d_es) ||
1936: ((*s_etat_processus).erreur_execution != d_ex) ||
1937: ((*s_etat_processus).exception != d_ep))
1938: {
1939: liberation(s_etat_processus, s_objet_argument_1);
1940: liberation(s_etat_processus, s_objet_argument_2);
1941: liberation(s_etat_processus, s_objet_argument_3);
1942: liberation(s_etat_processus, s_objet_argument_4);
1943:
1944: if (last_valide == d_vrai)
1945: {
1946: sf(s_etat_processus, 31);
1947: }
1948:
1949: return;
1950: }
1951:
1952: instruction_rot(s_etat_processus);
1953:
1954: if (((*s_etat_processus).erreur_systeme != d_es) ||
1955: ((*s_etat_processus).erreur_execution != d_ex) ||
1956: ((*s_etat_processus).exception != d_ep))
1957: {
1958: liberation(s_etat_processus, s_objet_argument_1);
1959: liberation(s_etat_processus, s_objet_argument_2);
1960: liberation(s_etat_processus, s_objet_argument_3);
1961: liberation(s_etat_processus, s_objet_argument_4);
1962:
1963: if (last_valide == d_vrai)
1964: {
1965: sf(s_etat_processus, 31);
1966: }
1967:
1968: return;
1969: }
1970:
1971: if (((*s_etat_processus).erreur_systeme != d_es) ||
1972: ((*s_etat_processus).erreur_execution != d_ex) ||
1973: ((*s_etat_processus).exception != d_ep))
1974: {
1975: liberation(s_etat_processus, s_objet_argument_1);
1976: liberation(s_etat_processus, s_objet_argument_2);
1977: liberation(s_etat_processus, s_objet_argument_3);
1978: liberation(s_etat_processus, s_objet_argument_4);
1979:
1980: if (last_valide == d_vrai)
1981: {
1982: sf(s_etat_processus, 31);
1983: }
1984:
1985: return;
1986: }
1987:
1988: instruction_plus(s_etat_processus);
1989:
1990: if (((*s_etat_processus).erreur_systeme != d_es) ||
1991: ((*s_etat_processus).erreur_execution != d_ex) ||
1992: ((*s_etat_processus).exception != d_ep))
1993: {
1994: liberation(s_etat_processus, s_objet_argument_1);
1995: liberation(s_etat_processus, s_objet_argument_2);
1996: liberation(s_etat_processus, s_objet_argument_3);
1997: liberation(s_etat_processus, s_objet_argument_4);
1998:
1999: if (last_valide == d_vrai)
2000: {
2001: sf(s_etat_processus, 31);
2002: }
2003:
2004: return;
2005: }
2006:
2007: instruction_putr(s_etat_processus);
2008:
2009: if (((*s_etat_processus).erreur_systeme != d_es) ||
2010: ((*s_etat_processus).erreur_execution != d_ex) ||
2011: ((*s_etat_processus).exception != d_ep))
2012: {
2013: liberation(s_etat_processus, s_objet_argument_1);
2014: liberation(s_etat_processus, s_objet_argument_2);
2015: liberation(s_etat_processus, s_objet_argument_3);
2016: liberation(s_etat_processus, s_objet_argument_4);
2017:
2018: if (last_valide == d_vrai)
2019: {
2020: sf(s_etat_processus, 31);
2021: }
2022:
2023: return;
2024: }
2025: }
2026: else
2027: {
2028: liberation(s_etat_processus, s_objet_argument_1);
2029: liberation(s_etat_processus, s_objet_argument_2);
2030: liberation(s_etat_processus, s_objet_argument_3);
2031: liberation(s_etat_processus, s_objet_argument_4);
2032:
2033: if (last_valide == d_vrai)
2034: {
2035: sf(s_etat_processus, 31);
2036: }
2037:
2038: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2039: return;
2040: }
2041:
2042: if (last_valide == d_vrai)
2043: {
2044: sf(s_etat_processus, 31);
2045: }
2046:
2047: return;
2048: }
2049:
2050: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>