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