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