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