1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.29
4: Copyright (C) 1989-2018 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 'get'
29: ================================================================================
30: Entrées :
31: --------------------------------------------------------------------------------
32: Sorties :
33: --------------------------------------------------------------------------------
34: Effets de bord : néant
35: ================================================================================
36: */
37:
38: void
39: instruction_get(struct_processus *s_etat_processus)
40: {
41: logical1 variable_partagee;
42:
43: struct_liste_chainee *l_element_courant;
44:
45: struct_objet *s_objet_1;
46: struct_objet *s_objet_2;
47: struct_objet *s_objet_3;
48: struct_objet *s_objet_element;
49: struct_objet *s_objet_resultat;
50:
51: integer8 indice_i;
52: integer8 indice_j;
53: integer8 nombre_dimensions;
54:
55: unsigned char *registre_instruction_courante;
56: unsigned char registre_instruction_valide;
57: unsigned char registre_test;
58:
59: (*s_etat_processus).erreur_execution = d_ex;
60:
61: if ((*s_etat_processus).affichage_arguments == 'Y')
62: {
63: printf("\n GET ");
64:
65: if ((*s_etat_processus).langue == 'F')
66: {
67: printf("(prend un élément)\n\n");
68: }
69: else
70: {
71: printf("(get element)\n\n");
72: }
73:
74: printf(" 2: %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_NOM);
75: printf(" 1: %s\n", d_LST);
76: printf("-> 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
77:
78: printf(" 2: %s, %s, %s, %s\n", d_MIN, d_MRL, d_MCX, d_NOM);
79: printf(" 1: %s\n", d_LST);
80: printf("-> 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
81:
82: printf(" 2: %s, %s\n", d_TAB, d_NOM);
83: printf(" 1: %s\n", d_LST);
84: printf("-> 1: %s, %s, %s, %s, %s, %s,\n"
85: " %s, %s, %s, %s, %s,\n"
86: " %s, %s, %s, %s, %s,\n"
87: " %s, %s, %s, %s,\n"
88: " %s, %s\n\n",
89: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
90: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
91: d_SQL, d_SLB, d_PRC, d_MTX);
92:
93: printf(" 2: %s, %s\n", d_LST, d_NOM);
94: printf(" 1: %s\n", d_INT);
95: printf("-> 1: %s, %s, %s, %s, %s, %s,\n"
96: " %s, %s, %s, %s, %s,\n"
97: " %s, %s, %s, %s, %s,\n"
98: " %s, %s, %s, %s,\n"
99: " %s, %s\n",
100: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
101: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
102: d_SQL, d_SLB, d_PRC, d_MTX);
103:
104: return;
105: }
106: else if ((*s_etat_processus).test_instruction == 'Y')
107: {
108: (*s_etat_processus).nombre_arguments = -1;
109: return;
110: }
111:
112: if (test_cfsf(s_etat_processus, 31) == d_vrai)
113: {
114: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
115: {
116: return;
117: }
118: }
119:
120: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
121: &s_objet_1) == d_erreur)
122: {
123: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
124: return;
125: }
126:
127: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
128: &s_objet_2) == d_erreur)
129: {
130: liberation(s_etat_processus, s_objet_1);
131:
132: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
133: return;
134: }
135:
136: /*
137: --------------------------------------------------------------------------------
138: Traitement des éléments des vecteurs
139: --------------------------------------------------------------------------------
140: */
141:
142: if (((*s_objet_2).type == VIN) ||
143: ((*s_objet_2).type == VRL) ||
144: ((*s_objet_2).type == VCX))
145: {
146: if ((*s_objet_1).type != LST)
147: {
148: liberation(s_etat_processus, s_objet_1);
149: liberation(s_etat_processus, s_objet_2);
150:
151: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
152: return;
153: }
154:
155: l_element_courant = (*s_objet_1).objet;
156: nombre_dimensions = 0;
157:
158: while(l_element_courant != NULL)
159: {
160: nombre_dimensions++;
161: l_element_courant = (*l_element_courant).suivant;
162: }
163:
164: if (nombre_dimensions != 1)
165: {
166: liberation(s_etat_processus, s_objet_1);
167: liberation(s_etat_processus, s_objet_2);
168:
169: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
170: return;
171: }
172:
173: l_element_courant = (*s_objet_1).objet;
174:
175: if ((*(*l_element_courant).donnee).type != INT)
176: {
177: liberation(s_etat_processus, s_objet_1);
178: liberation(s_etat_processus, s_objet_2);
179:
180: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
181: return;
182: }
183:
184: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
185: {
186: liberation(s_etat_processus, s_objet_1);
187: liberation(s_etat_processus, s_objet_2);
188:
189: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
190: return;
191: }
192: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
193: (integer8) (*((struct_vecteur *) (*s_objet_2).objet)).taille)
194: {
195: liberation(s_etat_processus, s_objet_1);
196: liberation(s_etat_processus, s_objet_2);
197:
198: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
199: return;
200: }
201:
202: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
203:
204: if ((*s_objet_2).type == VIN)
205: {
206: /*
207: * Vecteur d'entiers
208: */
209:
210: if ((s_objet_resultat = allocation(s_etat_processus, INT))
211: == NULL)
212: {
213: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
214: return;
215: }
216:
217: (*((integer8 *) (*s_objet_resultat).objet)) =
218: ((integer8 *) (*((struct_vecteur *) (*s_objet_2).objet))
219: .tableau)[indice_i - 1];
220: }
221: else if ((*s_objet_2).type == VRL)
222: {
223: /*
224: * Vecteur de réels
225: */
226:
227: if ((s_objet_resultat = allocation(s_etat_processus, REL))
228: == NULL)
229: {
230: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
231: return;
232: }
233:
234: (*((real8 *) (*s_objet_resultat).objet)) =
235: ((real8 *) (*((struct_vecteur *) (*s_objet_2).objet))
236: .tableau)[indice_i - 1];
237: }
238: else
239: {
240: /*
241: * Vecteur de complexes
242: */
243:
244: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
245: == NULL)
246: {
247: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
248: return;
249: }
250:
251: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
252: ((struct_complexe16 *) (*((struct_vecteur *)
253: (*s_objet_2).objet)).tableau)[indice_i - 1].partie_reelle;
254: (*((struct_complexe16 *) (*s_objet_resultat).objet))
255: .partie_imaginaire = ((struct_complexe16 *)
256: (*((struct_vecteur *) (*s_objet_2).objet)).tableau)
257: [indice_i - 1].partie_imaginaire;
258: }
259: }
260:
261: /*
262: --------------------------------------------------------------------------------
263: Traitement des éléments des matrices
264: --------------------------------------------------------------------------------
265: */
266:
267: else if (((*s_objet_2).type == MIN) ||
268: ((*s_objet_2).type == MRL) ||
269: ((*s_objet_2).type == MCX))
270: {
271: if ((*s_objet_1).type != LST)
272: {
273: liberation(s_etat_processus, s_objet_1);
274: liberation(s_etat_processus, s_objet_2);
275:
276: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
277: return;
278: }
279:
280: l_element_courant = (*s_objet_1).objet;
281: nombre_dimensions = 0;
282:
283: while(l_element_courant != NULL)
284: {
285: nombre_dimensions++;
286: l_element_courant = (*l_element_courant).suivant;
287: }
288:
289: if (nombre_dimensions != 2)
290: {
291: liberation(s_etat_processus, s_objet_1);
292: liberation(s_etat_processus, s_objet_2);
293:
294: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
295: return;
296: }
297:
298: l_element_courant = (*s_objet_1).objet;
299:
300: indice_i = 0;
301: indice_j = 0;
302:
303: while(l_element_courant != NULL)
304: {
305: if ((*(*l_element_courant).donnee).type != INT)
306: {
307: liberation(s_etat_processus, s_objet_1);
308: liberation(s_etat_processus, s_objet_2);
309:
310: (*s_etat_processus).erreur_execution =
311: d_ex_erreur_type_argument;
312: return;
313: }
314:
315: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
316: {
317: liberation(s_etat_processus, s_objet_1);
318: liberation(s_etat_processus, s_objet_2);
319:
320: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
321: return;
322: }
323:
324: if (indice_i == 0)
325: {
326: indice_i = (*((integer8 *)
327: (*(*l_element_courant).donnee).objet));
328: }
329: else
330: {
331: indice_j = (*((integer8 *)
332: (*(*l_element_courant).donnee).objet));
333: }
334:
335: l_element_courant = (*l_element_courant).suivant;
336: }
337:
338: if ((indice_i > (*((struct_matrice *) (*s_objet_2).objet))
339: .nombre_lignes) || (indice_j > (*((struct_matrice *)
340: (*s_objet_2).objet)).nombre_colonnes))
341: {
342: liberation(s_etat_processus, s_objet_1);
343: liberation(s_etat_processus, s_objet_2);
344:
345: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
346: return;
347: }
348:
349: if ((*s_objet_2).type == MIN)
350: {
351: /*
352: * Matrice d'entiers
353: */
354:
355: if ((s_objet_resultat = allocation(s_etat_processus, INT))
356: == NULL)
357: {
358: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
359: return;
360: }
361:
362: (*((integer8 *) (*s_objet_resultat).objet)) =
363: ((integer8 **) (*((struct_matrice *) (*s_objet_2).objet))
364: .tableau)[indice_i - 1][indice_j - 1];
365: }
366: else if ((*s_objet_2).type == MRL)
367: {
368: /*
369: * Matrice de réels
370: */
371:
372: if ((s_objet_resultat = allocation(s_etat_processus, REL))
373: == NULL)
374: {
375: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
376: return;
377: }
378:
379: (*((real8 *) (*s_objet_resultat).objet)) =
380: ((real8 **) (*((struct_matrice *) (*s_objet_2).objet))
381: .tableau)[indice_i - 1][indice_j - 1];
382: }
383: else
384: {
385: /*
386: * Matrices de complexes
387: */
388:
389: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
390: == NULL)
391: {
392: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
393: return;
394: }
395:
396: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
397: ((struct_complexe16 **) (*((struct_matrice *)
398: (*s_objet_2).objet)).tableau)[indice_i - 1]
399: [indice_j - 1].partie_reelle;
400: (*((struct_complexe16 *) (*s_objet_resultat).objet))
401: .partie_imaginaire = ((struct_complexe16 **)
402: (*((struct_matrice *) (*s_objet_2).objet)).tableau)
403: [indice_i - 1][indice_j - 1].partie_imaginaire;
404: }
405: }
406:
407: /*
408: --------------------------------------------------------------------------------
409: Traitement des listes
410: --------------------------------------------------------------------------------
411: */
412:
413: else if ((*s_objet_2).type == LST)
414: {
415: if ((*s_objet_1).type != INT)
416: {
417: liberation(s_etat_processus, s_objet_1);
418: liberation(s_etat_processus, s_objet_2);
419:
420: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
421: return;
422: }
423:
424: indice_i = (*((integer8 *) (*s_objet_1).objet));
425: indice_j = 1;
426:
427: l_element_courant = (*s_objet_2).objet;
428:
429: while((l_element_courant != NULL) && (indice_j != indice_i))
430: {
431: l_element_courant = (*l_element_courant).suivant;
432: indice_j++;
433: }
434:
435: if (l_element_courant != NULL)
436: {
437: if ((s_objet_resultat = copie_objet(s_etat_processus,
438: (*l_element_courant).donnee, 'P')) == NULL)
439: {
440: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
441: return;
442: }
443: }
444: else
445: {
446: liberation(s_etat_processus, s_objet_1);
447: liberation(s_etat_processus, s_objet_2);
448:
449: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
450: return;
451: }
452: }
453:
454: /*
455: --------------------------------------------------------------------------------
456: Traitement des tables
457: --------------------------------------------------------------------------------
458: */
459:
460: else if ((*s_objet_2).type == TBL)
461: {
462: if ((*s_objet_1).type != LST)
463: {
464: liberation(s_etat_processus, s_objet_1);
465: liberation(s_etat_processus, s_objet_2);
466:
467: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
468: return;
469: }
470:
471: l_element_courant = (*s_objet_1).objet;
472: s_objet_element = s_objet_2;
473:
474: while(l_element_courant != NULL)
475: {
476: if ((*(*l_element_courant).donnee).type != INT)
477: {
478: liberation(s_etat_processus, s_objet_1);
479: liberation(s_etat_processus, s_objet_2);
480:
481: (*s_etat_processus).erreur_execution =
482: d_ex_erreur_type_argument;
483: return;
484: }
485:
486: if ((*s_objet_element).type != TBL)
487: {
488: liberation(s_etat_processus, s_objet_1);
489: liberation(s_etat_processus, s_objet_2);
490:
491: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
492: return;
493: }
494:
495: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
496:
497: if ((indice_i < 1) || (indice_i > (*((struct_tableau *)
498: (*s_objet_element).objet)).nombre_elements))
499: {
500: liberation(s_etat_processus, s_objet_1);
501: liberation(s_etat_processus, s_objet_2);
502:
503: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
504: return;
505: }
506:
507: s_objet_element = (*((struct_tableau *) (*s_objet_element)
508: .objet)).elements[indice_i - 1];
509: l_element_courant = (*l_element_courant).suivant;
510: }
511:
512: if ((s_objet_resultat = copie_objet(s_etat_processus,
513: s_objet_element, 'P')) == NULL)
514: {
515: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
516: return;
517: }
518: }
519:
520: /*
521: --------------------------------------------------------------------------------
522: Traitement des variables
523: --------------------------------------------------------------------------------
524: */
525:
526: else if ((*s_objet_2).type == NOM)
527: {
528: variable_partagee = d_faux;
529:
530: if (recherche_variable(s_etat_processus, (*((struct_nom *)
531: (*s_objet_2).objet)).nom) == d_faux)
532: {
533: (*s_etat_processus).erreur_systeme = d_es;
534: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
535:
536: liberation(s_etat_processus, s_objet_1);
537: liberation(s_etat_processus, s_objet_2);
538:
539: return;
540: }
541:
542: s_objet_3 = (*(*s_etat_processus).pointeur_variable_courante).objet;
543:
544: if (s_objet_3 == NULL)
545: {
546: if (recherche_variable_partagee(s_etat_processus,
547: (*(*s_etat_processus).pointeur_variable_courante).nom,
548: (*(*s_etat_processus).pointeur_variable_courante)
549: .variable_partagee, (*(*s_etat_processus)
550: .pointeur_variable_courante).origine) == NULL)
551: {
552: (*s_etat_processus).erreur_systeme = d_es;
553: (*s_etat_processus).erreur_execution =
554: d_ex_variable_non_definie;
555:
556: liberation(s_etat_processus, s_objet_1);
557: liberation(s_etat_processus, s_objet_2);
558:
559: return;
560: }
561:
562: s_objet_3 = (*(*s_etat_processus)
563: .pointeur_variable_partagee_courante).objet;
564: variable_partagee = d_vrai;
565: }
566:
567: if (((*s_objet_3).type == VIN) ||
568: ((*s_objet_3).type == VRL) ||
569: ((*s_objet_3).type == VCX))
570: {
571: if ((*s_objet_1).type != LST)
572: {
573: if (variable_partagee == d_vrai)
574: {
575: if (pthread_mutex_unlock(&((*(*s_etat_processus)
576: .pointeur_variable_partagee_courante).mutex)) != 0)
577: {
578: (*s_etat_processus).erreur_systeme = d_es_processus;
579: return;
580: }
581: }
582:
583: liberation(s_etat_processus, s_objet_1);
584: liberation(s_etat_processus, s_objet_2);
585:
586: (*s_etat_processus).erreur_execution =
587: d_ex_erreur_type_argument;
588: return;
589: }
590:
591: l_element_courant = (*s_objet_1).objet;
592: nombre_dimensions = 0;
593:
594: while(l_element_courant != NULL)
595: {
596: nombre_dimensions++;
597: l_element_courant = (*l_element_courant).suivant;
598: }
599:
600: if (nombre_dimensions != 1)
601: {
602: if (variable_partagee == d_vrai)
603: {
604: if (pthread_mutex_unlock(&((*(*s_etat_processus)
605: .pointeur_variable_partagee_courante).mutex)) != 0)
606: {
607: (*s_etat_processus).erreur_systeme = d_es_processus;
608: return;
609: }
610: }
611:
612: liberation(s_etat_processus, s_objet_1);
613: liberation(s_etat_processus, s_objet_2);
614:
615: (*s_etat_processus).erreur_execution =
616: d_ex_dimensions_invalides;
617: return;
618: }
619:
620: l_element_courant = (*s_objet_1).objet;
621:
622: if ((*(*l_element_courant).donnee).type != INT)
623: {
624: if (variable_partagee == d_vrai)
625: {
626: if (pthread_mutex_unlock(&((*(*s_etat_processus)
627: .pointeur_variable_partagee_courante).mutex)) != 0)
628: {
629: (*s_etat_processus).erreur_systeme = d_es_processus;
630: return;
631: }
632: }
633:
634: liberation(s_etat_processus, s_objet_1);
635: liberation(s_etat_processus, s_objet_2);
636:
637: (*s_etat_processus).erreur_execution =
638: d_ex_erreur_type_argument;
639: return;
640: }
641:
642: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
643: {
644: if (variable_partagee == d_vrai)
645: {
646: if (pthread_mutex_unlock(&((*(*s_etat_processus)
647: .pointeur_variable_partagee_courante).mutex)) != 0)
648: {
649: (*s_etat_processus).erreur_systeme = d_es_processus;
650: return;
651: }
652: }
653:
654: liberation(s_etat_processus, s_objet_1);
655: liberation(s_etat_processus, s_objet_2);
656:
657: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
658: return;
659: }
660: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
661: (integer8) (*((struct_vecteur *) (*s_objet_3).objet))
662: .taille)
663: {
664: if (variable_partagee == d_vrai)
665: {
666: if (pthread_mutex_unlock(&((*(*s_etat_processus)
667: .pointeur_variable_partagee_courante).mutex)) != 0)
668: {
669: (*s_etat_processus).erreur_systeme = d_es_processus;
670: return;
671: }
672: }
673:
674: liberation(s_etat_processus, s_objet_1);
675: liberation(s_etat_processus, s_objet_2);
676:
677: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
678: return;
679: }
680:
681: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
682:
683: if ((*s_objet_3).type == VIN)
684: {
685: /*
686: * Vecteur d'entiers
687: */
688:
689: if ((s_objet_resultat = allocation(s_etat_processus, INT))
690: == NULL)
691: {
692: if (variable_partagee == d_vrai)
693: {
694: if (pthread_mutex_unlock(&((*(*s_etat_processus)
695: .pointeur_variable_partagee_courante).mutex))
696: != 0)
697: {
698: (*s_etat_processus).erreur_systeme = d_es_processus;
699: return;
700: }
701: }
702:
703: (*s_etat_processus).erreur_systeme
704: = d_es_allocation_memoire;
705: return;
706: }
707:
708: (*((integer8 *) (*s_objet_resultat).objet)) =
709: ((integer8 *) (*((struct_vecteur *)
710: (*s_objet_3).objet)).tableau)[indice_i - 1];
711: }
712: else if ((*s_objet_3).type == VRL)
713: {
714: /*
715: * Vecteur de réels
716: */
717:
718: if ((s_objet_resultat = allocation(s_etat_processus, REL))
719: == 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: (*((real8 *) (*s_objet_resultat).objet)) =
738: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
739: .tableau)[indice_i - 1];
740: }
741: else
742: {
743: /*
744: * Vecteur de complexes
745: */
746:
747: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
748: == NULL)
749: {
750: if (variable_partagee == d_vrai)
751: {
752: if (pthread_mutex_unlock(&((*(*s_etat_processus)
753: .pointeur_variable_partagee_courante).mutex))
754: != 0)
755: {
756: (*s_etat_processus).erreur_systeme = d_es_processus;
757: return;
758: }
759: }
760:
761: (*s_etat_processus).erreur_systeme
762: = d_es_allocation_memoire;
763: return;
764: }
765:
766: (*((struct_complexe16 *) (*s_objet_resultat).objet))
767: .partie_reelle = ((struct_complexe16 *)
768: (*((struct_vecteur *) (*s_objet_3).objet))
769: .tableau)[indice_i - 1].partie_reelle;
770: (*((struct_complexe16 *) (*s_objet_resultat).objet))
771: .partie_imaginaire = ((struct_complexe16 *)
772: (*((struct_vecteur *) (*s_objet_3).objet)).tableau)
773: [indice_i - 1].partie_imaginaire;
774: }
775: }
776: else if (((*s_objet_3).type == MIN) ||
777: ((*s_objet_3).type == MRL) ||
778: ((*s_objet_3).type == MCX))
779: {
780: if ((*s_objet_1).type != LST)
781: {
782: if (variable_partagee == d_vrai)
783: {
784: if (pthread_mutex_unlock(&((*(*s_etat_processus)
785: .pointeur_variable_partagee_courante).mutex)) != 0)
786: {
787: (*s_etat_processus).erreur_systeme = d_es_processus;
788: return;
789: }
790: }
791:
792: liberation(s_etat_processus, s_objet_1);
793: liberation(s_etat_processus, s_objet_2);
794:
795: (*s_etat_processus).erreur_execution =
796: d_ex_erreur_type_argument;
797: return;
798: }
799:
800: l_element_courant = (*s_objet_1).objet;
801: nombre_dimensions = 0;
802:
803: while(l_element_courant != NULL)
804: {
805: nombre_dimensions++;
806: l_element_courant = (*l_element_courant).suivant;
807: }
808:
809: if (nombre_dimensions != 2)
810: {
811: if (variable_partagee == d_vrai)
812: {
813: if (pthread_mutex_unlock(&((*(*s_etat_processus)
814: .pointeur_variable_partagee_courante).mutex)) != 0)
815: {
816: (*s_etat_processus).erreur_systeme = d_es_processus;
817: return;
818: }
819: }
820:
821: liberation(s_etat_processus, s_objet_1);
822: liberation(s_etat_processus, s_objet_2);
823:
824: (*s_etat_processus).erreur_execution =
825: d_ex_dimensions_invalides;
826: return;
827: }
828:
829: l_element_courant = (*s_objet_1).objet;
830:
831: indice_i = 0;
832: indice_j = 0;
833:
834: while(l_element_courant != NULL)
835: {
836: if ((*(*l_element_courant).donnee).type != INT)
837: {
838: if (variable_partagee == d_vrai)
839: {
840: if (pthread_mutex_unlock(&((*(*s_etat_processus)
841: .pointeur_variable_partagee_courante).mutex))
842: != 0)
843: {
844: (*s_etat_processus).erreur_systeme = d_es_processus;
845: return;
846: }
847: }
848:
849: liberation(s_etat_processus, s_objet_1);
850: liberation(s_etat_processus, s_objet_2);
851:
852: (*s_etat_processus).erreur_execution =
853: d_ex_erreur_type_argument;
854: return;
855: }
856:
857: if ((*((integer8 *) (*(*l_element_courant)
858: .donnee).objet)) <= 0)
859: {
860: if (variable_partagee == d_vrai)
861: {
862: if (pthread_mutex_unlock(&((*(*s_etat_processus)
863: .pointeur_variable_partagee_courante).mutex))
864: != 0)
865: {
866: (*s_etat_processus).erreur_systeme = d_es_processus;
867: return;
868: }
869: }
870:
871: liberation(s_etat_processus, s_objet_1);
872: liberation(s_etat_processus, s_objet_2);
873:
874: (*s_etat_processus).erreur_execution =
875: d_ex_argument_invalide;
876: return;
877: }
878:
879: if (indice_i == 0)
880: {
881: indice_i = (*((integer8 *)
882: (*(*l_element_courant).donnee).objet));
883: }
884: else
885: {
886: indice_j = (*((integer8 *)
887: (*(*l_element_courant).donnee).objet));
888: }
889:
890: l_element_courant = (*l_element_courant).suivant;
891: }
892:
893: if ((indice_i > (*((struct_matrice *) (*s_objet_3).objet))
894: .nombre_lignes) || (indice_j > (*((struct_matrice *)
895: (*s_objet_3).objet)).nombre_colonnes))
896: {
897: if (variable_partagee == d_vrai)
898: {
899: if (pthread_mutex_unlock(&((*(*s_etat_processus)
900: .pointeur_variable_partagee_courante).mutex)) != 0)
901: {
902: (*s_etat_processus).erreur_systeme = d_es_processus;
903: return;
904: }
905: }
906:
907: liberation(s_etat_processus, s_objet_1);
908: liberation(s_etat_processus, s_objet_2);
909:
910: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
911: return;
912: }
913:
914: if ((*s_objet_3).type == MIN)
915: {
916: /*
917: * Matrice d'entiers
918: */
919:
920: if ((s_objet_resultat = allocation(s_etat_processus, INT))
921: == NULL)
922: {
923: if (variable_partagee == d_vrai)
924: {
925: if (pthread_mutex_unlock(&((*(*s_etat_processus)
926: .pointeur_variable_partagee_courante).mutex))
927: != 0)
928: {
929: (*s_etat_processus).erreur_systeme = d_es_processus;
930: return;
931: }
932: }
933:
934: (*s_etat_processus).erreur_systeme =
935: d_es_allocation_memoire;
936: return;
937: }
938:
939: (*((integer8 *) (*s_objet_resultat).objet)) =
940: ((integer8 **) (*((struct_matrice *)
941: (*s_objet_3).objet))
942: .tableau)[indice_i - 1][indice_j - 1];
943: }
944: else if ((*s_objet_3).type == MRL)
945: {
946: /*
947: * Matrice de réels
948: */
949:
950: if ((s_objet_resultat = allocation(s_etat_processus, REL))
951: == NULL)
952: {
953: if (variable_partagee == d_vrai)
954: {
955: if (pthread_mutex_unlock(&((*(*s_etat_processus)
956: .pointeur_variable_partagee_courante).mutex))
957: != 0)
958: {
959: (*s_etat_processus).erreur_systeme = d_es_processus;
960: return;
961: }
962: }
963:
964: (*s_etat_processus).erreur_systeme =
965: d_es_allocation_memoire;
966: return;
967: }
968:
969: (*((real8 *) (*s_objet_resultat).objet)) =
970: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
971: .tableau)[indice_i - 1][indice_j - 1];
972: }
973: else
974: {
975: /*
976: * Matrices de complexes
977: */
978:
979: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
980: == NULL)
981: {
982: if (variable_partagee == d_vrai)
983: {
984: if (pthread_mutex_unlock(&((*(*s_etat_processus)
985: .pointeur_variable_partagee_courante).mutex))
986: != 0)
987: {
988: (*s_etat_processus).erreur_systeme = d_es_processus;
989: return;
990: }
991: }
992:
993: (*s_etat_processus).erreur_systeme =
994: d_es_allocation_memoire;
995: return;
996: }
997:
998: (*((struct_complexe16 *) (*s_objet_resultat).objet))
999: .partie_reelle = ((struct_complexe16 **)
1000: (*((struct_matrice *)
1001: (*s_objet_3).objet)).tableau)[indice_i - 1]
1002: [indice_j - 1].partie_reelle;
1003: (*((struct_complexe16 *) (*s_objet_resultat).objet))
1004: .partie_imaginaire = ((struct_complexe16 **)
1005: (*((struct_matrice *) (*s_objet_3).objet)).tableau)
1006: [indice_i - 1][indice_j - 1].partie_imaginaire;
1007: }
1008: }
1009: else if ((*s_objet_3).type == LST)
1010: {
1011: if ((*s_objet_1).type != INT)
1012: {
1013: if (variable_partagee == d_vrai)
1014: {
1015: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1016: .pointeur_variable_partagee_courante).mutex)) != 0)
1017: {
1018: (*s_etat_processus).erreur_systeme = d_es_processus;
1019: return;
1020: }
1021: }
1022:
1023: liberation(s_etat_processus, s_objet_1);
1024: liberation(s_etat_processus, s_objet_2);
1025:
1026: (*s_etat_processus).erreur_execution =
1027: d_ex_erreur_type_argument;
1028: return;
1029: }
1030:
1031: indice_i = (*((integer8 *) (*s_objet_1).objet));
1032: indice_j = 1;
1033:
1034: l_element_courant = (*s_objet_3).objet;
1035:
1036: while((l_element_courant != NULL) && (indice_j != indice_i))
1037: {
1038: l_element_courant = (*l_element_courant).suivant;
1039: indice_j++;
1040: }
1041:
1042: if (l_element_courant != NULL)
1043: {
1044: if ((s_objet_resultat = copie_objet(s_etat_processus,
1045: (*l_element_courant).donnee, 'P')) == NULL)
1046: {
1047: if (variable_partagee == d_vrai)
1048: {
1049: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1050: .pointeur_variable_partagee_courante).mutex))
1051: != 0)
1052: {
1053: (*s_etat_processus).erreur_systeme = d_es_processus;
1054: return;
1055: }
1056: }
1057:
1058: (*s_etat_processus).erreur_systeme =
1059: d_es_allocation_memoire;
1060: return;
1061: }
1062: }
1063: else
1064: {
1065: if (variable_partagee == d_vrai)
1066: {
1067: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1068: .pointeur_variable_partagee_courante).mutex)) != 0)
1069: {
1070: (*s_etat_processus).erreur_systeme = d_es_processus;
1071: return;
1072: }
1073: }
1074:
1075: liberation(s_etat_processus, s_objet_1);
1076: liberation(s_etat_processus, s_objet_2);
1077:
1078: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1079: return;
1080: }
1081: }
1082: else if ((*s_objet_3).type == TBL)
1083: {
1084: if ((*s_objet_1).type != LST)
1085: {
1086: if (variable_partagee == d_vrai)
1087: {
1088: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1089: .pointeur_variable_partagee_courante).mutex)) != 0)
1090: {
1091: (*s_etat_processus).erreur_systeme = d_es_processus;
1092: return;
1093: }
1094: }
1095:
1096: liberation(s_etat_processus, s_objet_1);
1097: liberation(s_etat_processus, s_objet_2);
1098:
1099: (*s_etat_processus).erreur_execution =
1100: d_ex_erreur_type_argument;
1101: return;
1102: }
1103:
1104: l_element_courant = (*s_objet_1).objet;
1105: s_objet_element = s_objet_3;
1106:
1107: while(l_element_courant != NULL)
1108: {
1109: if ((*(*l_element_courant).donnee).type != INT)
1110: {
1111: if (variable_partagee == d_vrai)
1112: {
1113: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1114: .pointeur_variable_partagee_courante).mutex))
1115: != 0)
1116: {
1117: (*s_etat_processus).erreur_systeme = d_es_processus;
1118: return;
1119: }
1120: }
1121:
1122: liberation(s_etat_processus, s_objet_1);
1123: liberation(s_etat_processus, s_objet_2);
1124:
1125: (*s_etat_processus).erreur_execution =
1126: d_ex_erreur_type_argument;
1127: return;
1128: }
1129:
1130: if ((*s_objet_element).type != TBL)
1131: {
1132: if (variable_partagee == d_vrai)
1133: {
1134: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1135: .pointeur_variable_partagee_courante).mutex))
1136: != 0)
1137: {
1138: (*s_etat_processus).erreur_systeme = d_es_processus;
1139: return;
1140: }
1141: }
1142:
1143: liberation(s_etat_processus, s_objet_1);
1144: liberation(s_etat_processus, s_objet_2);
1145:
1146: (*s_etat_processus).erreur_execution =
1147: d_ex_element_inexistant;
1148: return;
1149: }
1150:
1151: indice_i = (*((integer8 *) (*(*l_element_courant)
1152: .donnee).objet));
1153:
1154: if ((indice_i < 1) || (indice_i > (*((struct_tableau *)
1155: (*s_objet_element).objet)).nombre_elements))
1156: {
1157: if (variable_partagee == d_vrai)
1158: {
1159: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1160: .pointeur_variable_partagee_courante).mutex))
1161: != 0)
1162: {
1163: (*s_etat_processus).erreur_systeme = d_es_processus;
1164: return;
1165: }
1166: }
1167:
1168: liberation(s_etat_processus, s_objet_1);
1169: liberation(s_etat_processus, s_objet_2);
1170:
1171: (*s_etat_processus).erreur_execution =
1172: d_ex_element_inexistant;
1173: return;
1174: }
1175:
1176: s_objet_element = (*((struct_tableau *) (*s_objet_element)
1177: .objet)).elements[indice_i - 1];
1178: l_element_courant = (*l_element_courant).suivant;
1179: }
1180:
1181: if ((s_objet_resultat = copie_objet(s_etat_processus,
1182: s_objet_element, 'P')) == NULL)
1183: {
1184: if (variable_partagee == d_vrai)
1185: {
1186: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1187: .pointeur_variable_partagee_courante).mutex)) != 0)
1188: {
1189: (*s_etat_processus).erreur_systeme = d_es_processus;
1190: return;
1191: }
1192: }
1193:
1194: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1195: return;
1196: }
1197: }
1198: else
1199: {
1200: if (variable_partagee == d_vrai)
1201: {
1202: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1203: .pointeur_variable_partagee_courante).mutex)) != 0)
1204: {
1205: (*s_etat_processus).erreur_systeme = d_es_processus;
1206: return;
1207: }
1208: }
1209:
1210: liberation(s_etat_processus, s_objet_1);
1211: liberation(s_etat_processus, s_objet_2);
1212:
1213: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1214: return;
1215: }
1216:
1217: if (variable_partagee == d_vrai)
1218: {
1219: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1220: .pointeur_variable_partagee_courante).mutex)) != 0)
1221: {
1222: (*s_etat_processus).erreur_systeme = d_es_processus;
1223: return;
1224: }
1225: }
1226: }
1227:
1228: /*
1229: --------------------------------------------------------------------------------
1230: Type incompatible avec la fonction GET
1231: --------------------------------------------------------------------------------
1232: */
1233:
1234: else
1235: {
1236: liberation(s_etat_processus, s_objet_1);
1237: liberation(s_etat_processus, s_objet_2);
1238:
1239: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1240: return;
1241: }
1242:
1243: liberation(s_etat_processus, s_objet_1);
1244: liberation(s_etat_processus, s_objet_2);
1245:
1246: if ((*s_objet_resultat).type == NOM)
1247: {
1248: if ((*((struct_nom *) (*s_objet_resultat).objet)).symbole == d_faux)
1249: {
1250: if (evaluation(s_etat_processus, s_objet_resultat, 'E') == d_erreur)
1251: {
1252: return;
1253: }
1254: }
1255: else
1256: {
1257: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1258: s_objet_resultat) == d_erreur)
1259: {
1260: return;
1261: }
1262: }
1263: }
1264: else if ((*s_objet_resultat).type == FCT)
1265: {
1266: registre_test = (*s_etat_processus).test_instruction;
1267: registre_instruction_courante = (*s_etat_processus)
1268: .instruction_courante;
1269: registre_instruction_valide = (*s_etat_processus)
1270: .instruction_valide;
1271:
1272: (*s_etat_processus).test_instruction = 'Y';
1273: (*s_etat_processus).instruction_courante =
1274: (*((struct_fonction *) (*s_objet_resultat).objet)).nom_fonction;
1275:
1276: analyse(s_etat_processus, NULL);
1277:
1278: (*s_etat_processus).test_instruction = registre_test;
1279: (*s_etat_processus).instruction_courante =
1280: registre_instruction_courante;
1281:
1282: if (((*s_etat_processus).instruction_valide == 'Y') &&
1283: (*s_etat_processus).constante_symbolique == 'Y')
1284: {
1285: if (evaluation(s_etat_processus, s_objet_resultat, 'E') == d_erreur)
1286: {
1287: (*s_etat_processus).instruction_valide =
1288: registre_instruction_valide;
1289: return;
1290: }
1291: }
1292: else
1293: {
1294: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1295: s_objet_resultat) == d_erreur)
1296: {
1297: (*s_etat_processus).instruction_valide =
1298: registre_instruction_valide;
1299: return;
1300: }
1301: }
1302:
1303: (*s_etat_processus).instruction_valide = registre_instruction_valide;
1304: }
1305: else
1306: {
1307: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1308: s_objet_resultat) == d_erreur)
1309: {
1310: return;
1311: }
1312: }
1313:
1314: return;
1315: }
1316:
1317:
1318: /*
1319: ================================================================================
1320: Fonction 'geti'
1321: ================================================================================
1322: Entrées :
1323: --------------------------------------------------------------------------------
1324: Sorties :
1325: --------------------------------------------------------------------------------
1326: Effets de bord : néant
1327: ================================================================================
1328: */
1329:
1330: void
1331: instruction_geti(struct_processus *s_etat_processus)
1332: {
1333: logical1 variable_partagee;
1334:
1335: struct_liste_chainee *l_element_courant;
1336:
1337: struct_objet *s_copie_1;
1338: struct_objet *s_objet_1;
1339: struct_objet *s_objet_2;
1340: struct_objet *s_objet_3;
1341: struct_objet *s_objet_resultat;
1342:
1343: integer8 indice_i;
1344: integer8 indice_j;
1345: integer8 nombre_dimensions;
1346: integer8 nombre_elements;
1347:
1348: unsigned char *registre_instruction_courante;
1349: unsigned char registre_instruction_valide;
1350: unsigned char registre_test;
1351:
1352: (*s_etat_processus).erreur_execution = d_ex;
1353:
1354: if ((*s_etat_processus).affichage_arguments == 'Y')
1355: {
1356: printf("\n GETI ");
1357:
1358: if ((*s_etat_processus).langue == 'F')
1359: {
1360: printf("(prend un élément)\n\n");
1361: }
1362: else
1363: {
1364: printf("(get element)\n\n");
1365: }
1366:
1367: printf(" 2: %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_NOM);
1368: printf(" 1: %s\n", d_LST);
1369: printf("-> 3: %s, %s, %s, %s\n", d_VIN, d_VRL, d_VCX, d_NOM);
1370: printf(" 2: %s\n", d_LST);
1371: printf(" 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
1372:
1373: printf(" 2: %s, %s, %s, %s\n", d_MIN, d_MRL, d_MCX, d_NOM);
1374: printf(" 1: %s\n", d_LST);
1375: printf("-> 3: %s, %s, %s, %s\n", d_MIN, d_MRL, d_MCX, d_NOM);
1376: printf(" 2: %s\n", d_LST);
1377: printf(" 1: %s, %s, %s\n\n", d_INT, d_REL, d_CPL);
1378:
1379: printf(" 2: %s, %s\n", d_LST, d_NOM);
1380: printf(" 1: %s\n", d_INT);
1381: printf("-> 3: %s, %s\n", d_LST, d_NOM);
1382: printf(" 2: %s\n", d_INT);
1383: printf(" 1: %s, %s, %s, %s, %s, %s,\n"
1384: " %s, %s, %s, %s, %s,\n"
1385: " %s, %s, %s, %s, %s,\n"
1386: " %s, %s, %s, %s,\n"
1387: " %s, %s\n",
1388: d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
1389: d_TAB, d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_FCH, d_SCK,
1390: d_SQL, d_SLB, d_PRC, d_MTX);
1391:
1392: return;
1393: }
1394: else if ((*s_etat_processus).test_instruction == 'Y')
1395: {
1396: (*s_etat_processus).nombre_arguments = -1;
1397: return;
1398: }
1399:
1400: if (test_cfsf(s_etat_processus, 31) == d_vrai)
1401: {
1402: if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
1403: {
1404: return;
1405: }
1406: }
1407:
1408: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
1409: &s_objet_1) == d_erreur)
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_2) == d_erreur)
1417: {
1418: liberation(s_etat_processus, s_objet_1);
1419:
1420: (*s_etat_processus).erreur_execution = d_ex_manque_argument;
1421: return;
1422: }
1423:
1424: if ((s_copie_1 = copie_objet(s_etat_processus, s_objet_1, 'O')) == NULL)
1425: {
1426: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1427: return;
1428: }
1429:
1430: liberation(s_etat_processus, s_objet_1);
1431: s_objet_1 = s_copie_1;
1432:
1433: /*
1434: --------------------------------------------------------------------------------
1435: Traitement des éléments des vecteurs
1436: --------------------------------------------------------------------------------
1437: */
1438:
1439: if (((*s_objet_2).type == VIN) ||
1440: ((*s_objet_2).type == VRL) ||
1441: ((*s_objet_2).type == VCX))
1442: {
1443: if ((*s_objet_1).type != LST)
1444: {
1445: liberation(s_etat_processus, s_objet_1);
1446: liberation(s_etat_processus, s_objet_2);
1447:
1448: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1449: return;
1450: }
1451:
1452: l_element_courant = (*s_objet_1).objet;
1453: nombre_dimensions = 0;
1454:
1455: while(l_element_courant != NULL)
1456: {
1457: nombre_dimensions++;
1458: l_element_courant = (*l_element_courant).suivant;
1459: }
1460:
1461: if (nombre_dimensions != 1)
1462: {
1463: liberation(s_etat_processus, s_objet_1);
1464: liberation(s_etat_processus, s_objet_2);
1465:
1466: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
1467: return;
1468: }
1469:
1470: l_element_courant = (*s_objet_1).objet;
1471:
1472: if ((*(*l_element_courant).donnee).type != INT)
1473: {
1474: liberation(s_etat_processus, s_objet_1);
1475: liberation(s_etat_processus, s_objet_2);
1476:
1477: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1478: return;
1479: }
1480:
1481: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
1482: {
1483: liberation(s_etat_processus, s_objet_1);
1484: liberation(s_etat_processus, s_objet_2);
1485:
1486: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1487: return;
1488: }
1489: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
1490: (integer8) (*((struct_vecteur *) (*s_objet_2).objet)).taille)
1491: {
1492: liberation(s_etat_processus, s_objet_1);
1493: liberation(s_etat_processus, s_objet_2);
1494:
1495: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1496: return;
1497: }
1498:
1499: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
1500:
1501: if ((*s_objet_2).type == VIN)
1502: {
1503: /*
1504: * Vecteur d'entiers
1505: */
1506:
1507: if ((s_objet_resultat = allocation(s_etat_processus, INT))
1508: == NULL)
1509: {
1510: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1511: return;
1512: }
1513:
1514: (*((integer8 *) (*s_objet_resultat).objet)) =
1515: ((integer8 *) (*((struct_vecteur *) (*s_objet_2).objet))
1516: .tableau)[indice_i - 1];
1517: }
1518: else if ((*s_objet_2).type == VRL)
1519: {
1520: /*
1521: * Vecteur de réels
1522: */
1523:
1524: if ((s_objet_resultat = allocation(s_etat_processus, REL))
1525: == NULL)
1526: {
1527: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1528: return;
1529: }
1530:
1531: (*((real8 *) (*s_objet_resultat).objet)) =
1532: ((real8 *) (*((struct_vecteur *) (*s_objet_2).objet))
1533: .tableau)[indice_i - 1];
1534: }
1535: else
1536: {
1537: /*
1538: * Vecteur de complexes
1539: */
1540:
1541: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
1542: == NULL)
1543: {
1544: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1545: return;
1546: }
1547:
1548: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
1549: ((struct_complexe16 *) (*((struct_vecteur *)
1550: (*s_objet_2).objet)).tableau)[indice_i - 1].partie_reelle;
1551: (*((struct_complexe16 *) (*s_objet_resultat).objet))
1552: .partie_imaginaire = ((struct_complexe16 *)
1553: (*((struct_vecteur *) (*s_objet_2).objet)).tableau)
1554: [indice_i - 1].partie_imaginaire;
1555: }
1556:
1557: (*((integer8 *) (*(*l_element_courant).donnee).objet)) =
1558: (indice_i % (*((struct_vecteur *) (*s_objet_2).objet)).taille)
1559: + 1;
1560: }
1561:
1562: /*
1563: --------------------------------------------------------------------------------
1564: Traitement des éléments des matrices
1565: --------------------------------------------------------------------------------
1566: */
1567:
1568: else if (((*s_objet_2).type == MIN) ||
1569: ((*s_objet_2).type == MRL) ||
1570: ((*s_objet_2).type == MCX))
1571: {
1572: if ((*s_objet_1).type != LST)
1573: {
1574: liberation(s_etat_processus, s_objet_1);
1575: liberation(s_etat_processus, s_objet_2);
1576:
1577: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1578: return;
1579: }
1580:
1581: l_element_courant = (*s_objet_1).objet;
1582: nombre_dimensions = 0;
1583:
1584: while(l_element_courant != NULL)
1585: {
1586: nombre_dimensions++;
1587: l_element_courant = (*l_element_courant).suivant;
1588: }
1589:
1590: if (nombre_dimensions != 2)
1591: {
1592: liberation(s_etat_processus, s_objet_1);
1593: liberation(s_etat_processus, s_objet_2);
1594:
1595: (*s_etat_processus).erreur_execution = d_ex_dimensions_invalides;
1596: return;
1597: }
1598:
1599: l_element_courant = (*s_objet_1).objet;
1600:
1601: indice_i = 0;
1602: indice_j = 0;
1603:
1604: while(l_element_courant != NULL)
1605: {
1606: if ((*(*l_element_courant).donnee).type != INT)
1607: {
1608: liberation(s_etat_processus, s_objet_1);
1609: liberation(s_etat_processus, s_objet_2);
1610:
1611: (*s_etat_processus).erreur_execution =
1612: d_ex_erreur_type_argument;
1613: return;
1614: }
1615:
1616: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
1617: {
1618: liberation(s_etat_processus, s_objet_1);
1619: liberation(s_etat_processus, s_objet_2);
1620:
1621: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1622: return;
1623: }
1624:
1625: if (indice_i == 0)
1626: {
1627: indice_i = (*((integer8 *)
1628: (*(*l_element_courant).donnee).objet));
1629: }
1630: else
1631: {
1632: indice_j = (*((integer8 *)
1633: (*(*l_element_courant).donnee).objet));
1634: }
1635:
1636: l_element_courant = (*l_element_courant).suivant;
1637: }
1638:
1639: if ((indice_i > (*((struct_matrice *) (*s_objet_2).objet))
1640: .nombre_lignes) || (indice_j > (*((struct_matrice *)
1641: (*s_objet_2).objet)).nombre_colonnes))
1642: {
1643: liberation(s_etat_processus, s_objet_1);
1644: liberation(s_etat_processus, s_objet_2);
1645:
1646: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1647: return;
1648: }
1649:
1650: if ((*s_objet_2).type == MIN)
1651: {
1652: /*
1653: * Matrice d'entiers
1654: */
1655:
1656: if ((s_objet_resultat = allocation(s_etat_processus, INT))
1657: == NULL)
1658: {
1659: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1660: return;
1661: }
1662:
1663: (*((integer8 *) (*s_objet_resultat).objet)) =
1664: ((integer8 **) (*((struct_matrice *) (*s_objet_2).objet))
1665: .tableau)[indice_i - 1][indice_j - 1];
1666: }
1667: else if ((*s_objet_2).type == MRL)
1668: {
1669: /*
1670: * Matrice de réels
1671: */
1672:
1673: if ((s_objet_resultat = allocation(s_etat_processus, REL))
1674: == NULL)
1675: {
1676: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1677: return;
1678: }
1679:
1680: (*((real8 *) (*s_objet_resultat).objet)) =
1681: ((real8 **) (*((struct_matrice *) (*s_objet_2).objet))
1682: .tableau)[indice_i - 1][indice_j - 1];
1683: }
1684: else
1685: {
1686: /*
1687: * Matrices de complexes
1688: */
1689:
1690: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
1691: == NULL)
1692: {
1693: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1694: return;
1695: }
1696:
1697: (*((struct_complexe16 *) (*s_objet_resultat).objet)).partie_reelle =
1698: ((struct_complexe16 **) (*((struct_matrice *)
1699: (*s_objet_2).objet)).tableau)[indice_i - 1]
1700: [indice_j - 1].partie_reelle;
1701: (*((struct_complexe16 *) (*s_objet_resultat).objet))
1702: .partie_imaginaire = ((struct_complexe16 **)
1703: (*((struct_matrice *) (*s_objet_2).objet)).tableau)
1704: [indice_i - 1][indice_j - 1].partie_imaginaire;
1705: }
1706:
1707:
1708: if ((++(*((integer8 *) (*(*(*((struct_liste_chainee *)
1709: (*s_objet_1).objet)).suivant).donnee).objet))) >
1710: (integer8) (*((struct_matrice *) (*s_objet_2).objet))
1711: .nombre_colonnes)
1712: {
1713: (*((integer8 *) (*(*(*((struct_liste_chainee *) (*s_objet_1)
1714: .objet)).suivant).donnee).objet)) = 1;
1715:
1716: if ((++(*((integer8 *) (*(*((struct_liste_chainee *)
1717: (*s_objet_1).objet)).donnee).objet))) >
1718: (integer8) (*((struct_matrice *) (*s_objet_2).objet))
1719: .nombre_lignes)
1720: {
1721: (*((integer8 *) (*(*((struct_liste_chainee *)
1722: (*s_objet_1).objet)).donnee).objet)) = 1;
1723: }
1724: }
1725: }
1726:
1727: /*
1728: --------------------------------------------------------------------------------
1729: Traitement des listes
1730: --------------------------------------------------------------------------------
1731: */
1732:
1733: else if ((*s_objet_2).type == LST)
1734: {
1735: if ((*s_objet_1).type != INT)
1736: {
1737: liberation(s_etat_processus, s_objet_1);
1738: liberation(s_etat_processus, s_objet_2);
1739:
1740: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
1741: return;
1742: }
1743:
1744: nombre_elements = 0;
1745: l_element_courant = (*s_objet_2).objet;
1746:
1747: while(l_element_courant != NULL)
1748: {
1749: l_element_courant = (*l_element_courant).suivant;
1750: nombre_elements++;
1751: }
1752:
1753: indice_i = (*((integer8 *) (*s_objet_1).objet));
1754: indice_j = 1;
1755: l_element_courant = (*s_objet_2).objet;
1756:
1757: while((l_element_courant != NULL) && (indice_j != indice_i))
1758: {
1759: l_element_courant = (*l_element_courant).suivant;
1760: indice_j++;
1761: }
1762:
1763: if (l_element_courant != NULL)
1764: {
1765: if ((s_objet_resultat = copie_objet(s_etat_processus,
1766: (*l_element_courant).donnee, 'O')) == NULL)
1767: {
1768: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
1769: return;
1770: }
1771: }
1772: else
1773: {
1774: liberation(s_etat_processus, s_objet_1);
1775: liberation(s_etat_processus, s_objet_2);
1776:
1777: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1778: return;
1779: }
1780:
1781: (*((integer8 *) (*s_objet_1).objet)) =
1782: (indice_i % nombre_elements) + 1;
1783: }
1784:
1785: /*
1786: --------------------------------------------------------------------------------
1787: Traitement des variables
1788: --------------------------------------------------------------------------------
1789: */
1790:
1791: else if ((*s_objet_2).type == NOM)
1792: {
1793: variable_partagee = d_faux;
1794:
1795: if (recherche_variable(s_etat_processus, (*((struct_nom *)
1796: (*s_objet_2).objet)).nom) == d_faux)
1797: {
1798: (*s_etat_processus).erreur_systeme = d_es;
1799: (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
1800:
1801: liberation(s_etat_processus, s_objet_1);
1802: liberation(s_etat_processus, s_objet_2);
1803:
1804: return;
1805: }
1806:
1807: s_objet_3 = (*(*s_etat_processus).pointeur_variable_courante).objet;
1808:
1809: if (s_objet_3 == NULL)
1810: {
1811: if (recherche_variable_partagee(s_etat_processus,
1812: (*(*s_etat_processus).pointeur_variable_courante).nom,
1813: (*(*s_etat_processus).pointeur_variable_courante)
1814: .variable_partagee, (*(*s_etat_processus)
1815: .pointeur_variable_courante).origine) == NULL)
1816: {
1817: (*s_etat_processus).erreur_systeme = d_es;
1818: (*s_etat_processus).erreur_execution =
1819: d_ex_variable_non_definie;
1820:
1821: liberation(s_etat_processus, s_objet_1);
1822: liberation(s_etat_processus, s_objet_2);
1823:
1824: return;
1825: }
1826:
1827: s_objet_3 = (*(*s_etat_processus)
1828: .pointeur_variable_partagee_courante).objet;
1829: variable_partagee = d_vrai;
1830: }
1831:
1832: if (((*s_objet_3).type == VIN) ||
1833: ((*s_objet_3).type == VRL) ||
1834: ((*s_objet_3).type == VCX))
1835: {
1836: if ((*s_objet_1).type != LST)
1837: {
1838: if (variable_partagee == d_vrai)
1839: {
1840: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1841: .pointeur_variable_partagee_courante).mutex)) != 0)
1842: {
1843: (*s_etat_processus).erreur_systeme = d_es_processus;
1844: return;
1845: }
1846: }
1847:
1848: liberation(s_etat_processus, s_objet_1);
1849: liberation(s_etat_processus, s_objet_2);
1850:
1851: (*s_etat_processus).erreur_execution =
1852: d_ex_erreur_type_argument;
1853: return;
1854: }
1855:
1856: l_element_courant = (*s_objet_1).objet;
1857: nombre_dimensions = 0;
1858:
1859: while(l_element_courant != NULL)
1860: {
1861: nombre_dimensions++;
1862: l_element_courant = (*l_element_courant).suivant;
1863: }
1864:
1865: if (nombre_dimensions != 1)
1866: {
1867: if (variable_partagee == d_vrai)
1868: {
1869: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1870: .pointeur_variable_partagee_courante).mutex)) != 0)
1871: {
1872: (*s_etat_processus).erreur_systeme = d_es_processus;
1873: return;
1874: }
1875: }
1876:
1877: liberation(s_etat_processus, s_objet_1);
1878: liberation(s_etat_processus, s_objet_2);
1879:
1880: (*s_etat_processus).erreur_execution =
1881: d_ex_dimensions_invalides;
1882: return;
1883: }
1884:
1885: l_element_courant = (*s_objet_1).objet;
1886:
1887: if ((*(*l_element_courant).donnee).type != INT)
1888: {
1889: if (variable_partagee == d_vrai)
1890: {
1891: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1892: .pointeur_variable_partagee_courante).mutex)) != 0)
1893: {
1894: (*s_etat_processus).erreur_systeme = d_es_processus;
1895: return;
1896: }
1897: }
1898:
1899: liberation(s_etat_processus, s_objet_1);
1900: liberation(s_etat_processus, s_objet_2);
1901:
1902: (*s_etat_processus).erreur_execution =
1903: d_ex_erreur_type_argument;
1904: return;
1905: }
1906:
1907: if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) <= 0)
1908: {
1909: if (variable_partagee == d_vrai)
1910: {
1911: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1912: .pointeur_variable_partagee_courante).mutex)) != 0)
1913: {
1914: (*s_etat_processus).erreur_systeme = d_es_processus;
1915: return;
1916: }
1917: }
1918:
1919: liberation(s_etat_processus, s_objet_1);
1920: liberation(s_etat_processus, s_objet_2);
1921:
1922: (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
1923: return;
1924: }
1925: else if ((*((integer8 *) (*(*l_element_courant).donnee).objet)) >
1926: (integer8) (*((struct_vecteur *) (*s_objet_3).objet))
1927: .taille)
1928: {
1929: if (variable_partagee == d_vrai)
1930: {
1931: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1932: .pointeur_variable_partagee_courante).mutex)) != 0)
1933: {
1934: (*s_etat_processus).erreur_systeme = d_es_processus;
1935: return;
1936: }
1937: }
1938:
1939: liberation(s_etat_processus, s_objet_1);
1940: liberation(s_etat_processus, s_objet_2);
1941:
1942: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
1943: return;
1944: }
1945:
1946: indice_i = (*((integer8 *) (*(*l_element_courant).donnee).objet));
1947:
1948: if ((*s_objet_3).type == VIN)
1949: {
1950: /*
1951: * Vecteur d'entiers
1952: */
1953:
1954: if ((s_objet_resultat = allocation(s_etat_processus, INT))
1955: == NULL)
1956: {
1957: if (variable_partagee == d_vrai)
1958: {
1959: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1960: .pointeur_variable_partagee_courante).mutex))
1961: != 0)
1962: {
1963: (*s_etat_processus).erreur_systeme = d_es_processus;
1964: return;
1965: }
1966: }
1967:
1968: (*s_etat_processus).erreur_systeme
1969: = d_es_allocation_memoire;
1970: return;
1971: }
1972:
1973: (*((integer8 *) (*s_objet_resultat).objet)) =
1974: ((integer8 *) (*((struct_vecteur *)
1975: (*s_objet_3).objet)).tableau)[indice_i - 1];
1976: }
1977: else if ((*s_objet_3).type == VRL)
1978: {
1979: /*
1980: * Vecteur de réels
1981: */
1982:
1983: if ((s_objet_resultat = allocation(s_etat_processus, REL))
1984: == NULL)
1985: {
1986: if (variable_partagee == d_vrai)
1987: {
1988: if (pthread_mutex_unlock(&((*(*s_etat_processus)
1989: .pointeur_variable_partagee_courante).mutex))
1990: != 0)
1991: {
1992: (*s_etat_processus).erreur_systeme = d_es_processus;
1993: return;
1994: }
1995: }
1996:
1997: (*s_etat_processus).erreur_systeme
1998: = d_es_allocation_memoire;
1999: return;
2000: }
2001:
2002: (*((real8 *) (*s_objet_resultat).objet)) =
2003: ((real8 *) (*((struct_vecteur *) (*s_objet_3).objet))
2004: .tableau)[indice_i - 1];
2005: }
2006: else
2007: {
2008: /*
2009: * Vecteur de complexes
2010: */
2011:
2012: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
2013: == NULL)
2014: {
2015: if (variable_partagee == d_vrai)
2016: {
2017: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2018: .pointeur_variable_partagee_courante).mutex))
2019: != 0)
2020: {
2021: (*s_etat_processus).erreur_systeme = d_es_processus;
2022: return;
2023: }
2024: }
2025:
2026: (*s_etat_processus).erreur_systeme
2027: = d_es_allocation_memoire;
2028: return;
2029: }
2030:
2031: (*((struct_complexe16 *) (*s_objet_resultat).objet))
2032: .partie_reelle = ((struct_complexe16 *)
2033: (*((struct_vecteur *) (*s_objet_3).objet))
2034: .tableau)[indice_i - 1].partie_reelle;
2035: (*((struct_complexe16 *) (*s_objet_resultat).objet))
2036: .partie_imaginaire = ((struct_complexe16 *)
2037: (*((struct_vecteur *) (*s_objet_3).objet)).tableau)
2038: [indice_i - 1].partie_imaginaire;
2039: }
2040:
2041: (*((integer8 *) (*(*l_element_courant).donnee).objet)) =
2042: (indice_i % (*((struct_vecteur *) (*s_objet_3).objet))
2043: .taille) + 1;
2044: }
2045: else if (((*s_objet_3).type == MIN) ||
2046: ((*s_objet_3).type == MRL) ||
2047: ((*s_objet_3).type == MCX))
2048: {
2049: if ((*s_objet_1).type != LST)
2050: {
2051: if (variable_partagee == d_vrai)
2052: {
2053: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2054: .pointeur_variable_partagee_courante).mutex)) != 0)
2055: {
2056: (*s_etat_processus).erreur_systeme = d_es_processus;
2057: return;
2058: }
2059: }
2060:
2061: liberation(s_etat_processus, s_objet_1);
2062: liberation(s_etat_processus, s_objet_2);
2063:
2064: (*s_etat_processus).erreur_execution =
2065: d_ex_erreur_type_argument;
2066: return;
2067: }
2068:
2069: l_element_courant = (*s_objet_1).objet;
2070: nombre_dimensions = 0;
2071:
2072: while(l_element_courant != NULL)
2073: {
2074: nombre_dimensions++;
2075: l_element_courant = (*l_element_courant).suivant;
2076: }
2077:
2078: if (nombre_dimensions != 2)
2079: {
2080: if (variable_partagee == d_vrai)
2081: {
2082: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2083: .pointeur_variable_partagee_courante).mutex)) != 0)
2084: {
2085: (*s_etat_processus).erreur_systeme = d_es_processus;
2086: return;
2087: }
2088: }
2089:
2090: liberation(s_etat_processus, s_objet_1);
2091: liberation(s_etat_processus, s_objet_2);
2092:
2093: (*s_etat_processus).erreur_execution =
2094: d_ex_dimensions_invalides;
2095: return;
2096: }
2097:
2098: l_element_courant = (*s_objet_1).objet;
2099:
2100: indice_i = 0;
2101: indice_j = 0;
2102:
2103: while(l_element_courant != NULL)
2104: {
2105: if ((*(*l_element_courant).donnee).type != INT)
2106: {
2107: if (variable_partagee == d_vrai)
2108: {
2109: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2110: .pointeur_variable_partagee_courante).mutex))
2111: != 0)
2112: {
2113: (*s_etat_processus).erreur_systeme = d_es_processus;
2114: return;
2115: }
2116: }
2117:
2118: liberation(s_etat_processus, s_objet_1);
2119: liberation(s_etat_processus, s_objet_2);
2120:
2121: (*s_etat_processus).erreur_execution =
2122: d_ex_erreur_type_argument;
2123: return;
2124: }
2125:
2126: if ((*((integer8 *) (*(*l_element_courant)
2127: .donnee).objet)) <= 0)
2128: {
2129: if (variable_partagee == d_vrai)
2130: {
2131: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2132: .pointeur_variable_partagee_courante).mutex))
2133: != 0)
2134: {
2135: (*s_etat_processus).erreur_systeme = d_es_processus;
2136: return;
2137: }
2138: }
2139:
2140: liberation(s_etat_processus, s_objet_1);
2141: liberation(s_etat_processus, s_objet_2);
2142:
2143: (*s_etat_processus).erreur_execution =
2144: d_ex_argument_invalide;
2145: return;
2146: }
2147:
2148: if (indice_i == 0)
2149: {
2150: indice_i = (*((integer8 *)
2151: (*(*l_element_courant).donnee).objet));
2152: }
2153: else
2154: {
2155: indice_j = (*((integer8 *)
2156: (*(*l_element_courant).donnee).objet));
2157: }
2158:
2159: l_element_courant = (*l_element_courant).suivant;
2160: }
2161:
2162: if ((indice_i > (*((struct_matrice *) (*s_objet_3).objet))
2163: .nombre_lignes) || (indice_j > (*((struct_matrice *)
2164: (*s_objet_3).objet)).nombre_colonnes))
2165: {
2166: if (variable_partagee == d_vrai)
2167: {
2168: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2169: .pointeur_variable_partagee_courante).mutex)) != 0)
2170: {
2171: (*s_etat_processus).erreur_systeme = d_es_processus;
2172: return;
2173: }
2174: }
2175:
2176: liberation(s_etat_processus, s_objet_1);
2177: liberation(s_etat_processus, s_objet_2);
2178:
2179: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
2180: return;
2181: }
2182:
2183: if ((*s_objet_3).type == MIN)
2184: {
2185: /*
2186: * Matrice d'entiers
2187: */
2188:
2189: if ((s_objet_resultat = allocation(s_etat_processus, INT))
2190: == NULL)
2191: {
2192: if (variable_partagee == d_vrai)
2193: {
2194: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2195: .pointeur_variable_partagee_courante).mutex))
2196: != 0)
2197: {
2198: (*s_etat_processus).erreur_systeme = d_es_processus;
2199: return;
2200: }
2201: }
2202:
2203: (*s_etat_processus).erreur_systeme =
2204: d_es_allocation_memoire;
2205: return;
2206: }
2207:
2208: (*((integer8 *) (*s_objet_resultat).objet)) =
2209: ((integer8 **) (*((struct_matrice *)
2210: (*s_objet_3).objet))
2211: .tableau)[indice_i - 1][indice_j - 1];
2212: }
2213: else if ((*s_objet_3).type == MRL)
2214: {
2215: /*
2216: * Matrice de réels
2217: */
2218:
2219: if ((s_objet_resultat = allocation(s_etat_processus, REL))
2220: == NULL)
2221: {
2222: if (variable_partagee == d_vrai)
2223: {
2224: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2225: .pointeur_variable_partagee_courante).mutex))
2226: != 0)
2227: {
2228: (*s_etat_processus).erreur_systeme = d_es_processus;
2229: return;
2230: }
2231: }
2232:
2233: (*s_etat_processus).erreur_systeme =
2234: d_es_allocation_memoire;
2235: return;
2236: }
2237:
2238: (*((real8 *) (*s_objet_resultat).objet)) =
2239: ((real8 **) (*((struct_matrice *) (*s_objet_3).objet))
2240: .tableau)[indice_i - 1][indice_j - 1];
2241: }
2242: else
2243: {
2244: /*
2245: * Matrices de complexes
2246: */
2247:
2248: if ((s_objet_resultat = allocation(s_etat_processus, CPL))
2249: == NULL)
2250: {
2251: if (variable_partagee == d_vrai)
2252: {
2253: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2254: .pointeur_variable_partagee_courante).mutex))
2255: != 0)
2256: {
2257: (*s_etat_processus).erreur_systeme = d_es_processus;
2258: return;
2259: }
2260: }
2261:
2262: (*s_etat_processus).erreur_systeme =
2263: d_es_allocation_memoire;
2264: return;
2265: }
2266:
2267: (*((struct_complexe16 *) (*s_objet_resultat).objet))
2268: .partie_reelle = ((struct_complexe16 **)
2269: (*((struct_matrice *)
2270: (*s_objet_3).objet)).tableau)[indice_i - 1]
2271: [indice_j - 1].partie_reelle;
2272: (*((struct_complexe16 *) (*s_objet_resultat).objet))
2273: .partie_imaginaire = ((struct_complexe16 **)
2274: (*((struct_matrice *) (*s_objet_3).objet)).tableau)
2275: [indice_i - 1][indice_j - 1].partie_imaginaire;
2276: }
2277:
2278: if ((++(*((integer8 *) (*(*(*((struct_liste_chainee *)
2279: (*s_objet_1).objet)).suivant).donnee).objet))) >
2280: (integer8) (*((struct_matrice *) (*s_objet_3).objet))
2281: .nombre_colonnes)
2282: {
2283: (*((integer8 *) (*(*(*((struct_liste_chainee *) (*s_objet_1)
2284: .objet)).suivant).donnee).objet)) = 1;
2285:
2286: if ((++(*((integer8 *) (*(*((struct_liste_chainee *)
2287: (*s_objet_1).objet)).donnee).objet))) >
2288: (integer8) (*((struct_matrice *) (*s_objet_3).objet))
2289: .nombre_lignes)
2290: {
2291: (*((integer8 *) (*(*((struct_liste_chainee *)
2292: (*s_objet_1).objet)).donnee).objet)) = 1;
2293: }
2294: }
2295: }
2296: else if ((*s_objet_3).type == LST)
2297: {
2298: if ((*s_objet_1).type != INT)
2299: {
2300: if (variable_partagee == d_vrai)
2301: {
2302: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2303: .pointeur_variable_partagee_courante).mutex)) != 0)
2304: {
2305: (*s_etat_processus).erreur_systeme = d_es_processus;
2306: return;
2307: }
2308: }
2309:
2310: liberation(s_etat_processus, s_objet_1);
2311: liberation(s_etat_processus, s_objet_2);
2312:
2313: (*s_etat_processus).erreur_execution =
2314: d_ex_erreur_type_argument;
2315: return;
2316: }
2317:
2318: nombre_elements = 0;
2319: l_element_courant = (*s_objet_3).objet;
2320:
2321: while(l_element_courant != NULL)
2322: {
2323: l_element_courant = (*l_element_courant).suivant;
2324: nombre_elements++;
2325: }
2326:
2327: indice_i = (*((integer8 *) (*s_objet_1).objet));
2328: indice_j = 1;
2329: l_element_courant = (*s_objet_3).objet;
2330:
2331: while((l_element_courant != NULL) && (indice_j != indice_i))
2332: {
2333: l_element_courant = (*l_element_courant).suivant;
2334: indice_j++;
2335: }
2336:
2337: if (l_element_courant != NULL)
2338: {
2339: if ((s_objet_resultat = copie_objet(s_etat_processus,
2340: (*l_element_courant).donnee, 'O')) == NULL)
2341: {
2342: if (variable_partagee == d_vrai)
2343: {
2344: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2345: .pointeur_variable_partagee_courante).mutex))
2346: != 0)
2347: {
2348: (*s_etat_processus).erreur_systeme = d_es_processus;
2349: return;
2350: }
2351: }
2352:
2353: (*s_etat_processus).erreur_systeme =
2354: d_es_allocation_memoire;
2355: return;
2356: }
2357: }
2358: else
2359: {
2360: if (variable_partagee == d_vrai)
2361: {
2362: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2363: .pointeur_variable_partagee_courante).mutex)) != 0)
2364: {
2365: (*s_etat_processus).erreur_systeme = d_es_processus;
2366: return;
2367: }
2368: }
2369:
2370: liberation(s_etat_processus, s_objet_1);
2371: liberation(s_etat_processus, s_objet_2);
2372:
2373: (*s_etat_processus).erreur_execution = d_ex_element_inexistant;
2374: return;
2375: }
2376:
2377: (*((integer8 *) (*s_objet_1).objet)) =
2378: (indice_i % nombre_elements) + 1;
2379: }
2380: else
2381: {
2382: if (variable_partagee == d_vrai)
2383: {
2384: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2385: .pointeur_variable_partagee_courante).mutex)) != 0)
2386: {
2387: (*s_etat_processus).erreur_systeme = d_es_processus;
2388: return;
2389: }
2390: }
2391:
2392: liberation(s_etat_processus, s_objet_1);
2393: liberation(s_etat_processus, s_objet_2);
2394:
2395: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2396: return;
2397: }
2398:
2399: if (variable_partagee == d_vrai)
2400: {
2401: if (pthread_mutex_unlock(&((*(*s_etat_processus)
2402: .pointeur_variable_partagee_courante).mutex)) != 0)
2403: {
2404: (*s_etat_processus).erreur_systeme = d_es_processus;
2405: return;
2406: }
2407: }
2408: }
2409:
2410: /*
2411: --------------------------------------------------------------------------------
2412: Type incompatible avec la fonction GETI
2413: --------------------------------------------------------------------------------
2414: */
2415:
2416: else
2417: {
2418: liberation(s_etat_processus, s_objet_1);
2419: liberation(s_etat_processus, s_objet_2);
2420:
2421: (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
2422: return;
2423: }
2424:
2425: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2426: s_objet_2) == d_erreur)
2427: {
2428: return;
2429: }
2430:
2431: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2432: s_objet_1) == d_erreur)
2433: {
2434: return;
2435: }
2436:
2437: if ((*s_objet_resultat).type == NOM)
2438: {
2439: if ((*((struct_nom *) (*s_objet_resultat).objet)).symbole == d_faux)
2440: {
2441: if (evaluation(s_etat_processus, s_objet_resultat, 'E') == d_erreur)
2442: {
2443: return;
2444: }
2445: }
2446: else
2447: {
2448: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2449: s_objet_resultat) == d_erreur)
2450: {
2451: return;
2452: }
2453: }
2454: }
2455: else if ((*s_objet_resultat).type == FCT)
2456: {
2457: registre_test = (*s_etat_processus).test_instruction;
2458: registre_instruction_courante = (*s_etat_processus)
2459: .instruction_courante;
2460: registre_instruction_valide = (*s_etat_processus)
2461: .instruction_valide;
2462:
2463: (*s_etat_processus).test_instruction = 'Y';
2464: (*s_etat_processus).instruction_courante =
2465: (*((struct_fonction *) (*s_objet_resultat).objet)).nom_fonction;
2466:
2467: analyse(s_etat_processus, NULL);
2468:
2469: (*s_etat_processus).test_instruction = registre_test;
2470: (*s_etat_processus).instruction_courante =
2471: registre_instruction_courante;
2472:
2473: if (((*s_etat_processus).instruction_valide == 'Y') &&
2474: (*s_etat_processus).constante_symbolique == 'Y')
2475: {
2476: if (evaluation(s_etat_processus, s_objet_resultat, 'E') == d_erreur)
2477: {
2478: (*s_etat_processus).instruction_valide =
2479: registre_instruction_valide;
2480: return;
2481: }
2482: }
2483: else
2484: {
2485: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2486: s_objet_resultat) == d_erreur)
2487: {
2488: (*s_etat_processus).instruction_valide =
2489: registre_instruction_valide;
2490: return;
2491: }
2492: }
2493:
2494: (*s_etat_processus).instruction_valide = registre_instruction_valide;
2495: }
2496: else
2497: {
2498: if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
2499: s_objet_resultat) == d_erreur)
2500: {
2501: return;
2502: }
2503: }
2504:
2505: return;
2506: }
2507:
2508: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>