![]() ![]() | ![]() |
Passage de la branche 4.1 en branche stable.
1: /* 2: ================================================================================ 3: RPL/2 (R) version 4.1.0 4: Copyright (C) 1989-2011 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: Boucle principale optimisée de l'interprète RPL/2 29: ================================================================================ 30: Entrées : structure sur l'état du processus 31: -------------------------------------------------------------------------------- 32: Sorties : Néant 33: -------------------------------------------------------------------------------- 34: Effets de bord : néant 35: ================================================================================ 36: */ 37: 38: logical1 39: sequenceur_optimise(struct_processus *s_etat_processus) 40: { 41: int i; 42: int nb_variables; 43: int point_entree; 44: 45: logical1 erreur; 46: 47: struct_objet *programme_principal; 48: 49: struct_tableau_variables *tableau; 50: 51: unsigned char *message; 52: unsigned char registre; 53: 54: unsigned long adresse_point_entree; 55: 56: if ((*s_etat_processus).debug == d_vrai) 57: if (((*s_etat_processus).type_debug & 58: d_debug_analyse) != 0) 59: { 60: if ((*s_etat_processus).langue == 'F') 61: { 62: printf("+++Compilation [%d]\n", (int) getpid()); 63: } 64: else 65: { 66: printf("+++Compilation [%d]\n", (int) getpid()); 67: } 68: 69: printf("\n"); 70: fflush(stdout); 71: } 72: 73: point_entree = -1; 74: adresse_point_entree = 0; 75: 76: empilement_pile_systeme(s_etat_processus); 77: (*(*s_etat_processus).l_base_pile_systeme).retour_definition = 'Y'; 78: (*s_etat_processus).autorisation_empilement_programme = 'Y'; 79: (*s_etat_processus).mode_execution_programme = 'N'; 80: 81: nb_variables = nombre_variables(s_etat_processus, 82: (*s_etat_processus).s_arbre_variables); 83: 84: if ((tableau = malloc(nb_variables * sizeof(struct_tableau_variables))) 85: == NULL) 86: { 87: if ((*s_etat_processus).langue == 'F') 88: { 89: printf("+++Système : Mémoire insuffisante\n"); 90: } 91: else 92: { 93: printf("+++System : Not enough memory\n"); 94: } 95: 96: return(d_erreur); 97: } 98: 99: liste_variables(s_etat_processus, tableau, 0, 100: (*s_etat_processus).s_arbre_variables); 101: 102: for(i = 0; i < nb_variables; i++) 103: { 104: if (tableau[i].niveau == 0) 105: { 106: // Variables qui contiennent les points d'entrée des définitions. 107: 108: (*s_etat_processus).position_courante = (*((unsigned long *) 109: (*(tableau[i].objet)).objet)); 110: 111: if (point_entree == -1) 112: { 113: adresse_point_entree = (*s_etat_processus).position_courante; 114: point_entree = i; 115: } 116: else 117: { 118: if ((*s_etat_processus).position_courante < 119: adresse_point_entree) 120: { 121: adresse_point_entree = (*s_etat_processus) 122: .position_courante; 123: point_entree = i; 124: } 125: } 126: 127: if ((erreur = recherche_instruction_suivante(s_etat_processus)) 128: == d_erreur) 129: { 130: if ((*s_etat_processus).langue == 'F') 131: { 132: printf("+++Fatal : Compilation impossible\n"); 133: } 134: else 135: { 136: printf("+++Fatal : Compilation failed\n"); 137: } 138: 139: free(tableau); 140: return(d_erreur); 141: } 142: 143: // Il faut désactiver la vérification des variables 144: // implicites car aucune variable de niveau strictement 145: // positif étant créée, la fonction recherche_type() pourrait 146: // échouer. 147: 148: registre = (*s_etat_processus).autorisation_nom_implicite; 149: (*s_etat_processus).autorisation_nom_implicite = 'Y'; 150: recherche_type(s_etat_processus); 151: (*s_etat_processus).autorisation_nom_implicite = registre; 152: 153: if (((*s_etat_processus).erreur_execution != d_ex) || 154: ((*s_etat_processus).erreur_systeme != d_es)) 155: { 156: if ((*s_etat_processus).core == d_vrai) 157: { 158: if ((*s_etat_processus).langue == 'F') 159: { 160: printf("+++Information : " 161: "Génération du fichier rpl-core " 162: "[%d]\n", (int) getpid()); 163: } 164: else 165: { 166: printf("+++Information : " 167: "Writing rpl-core file [%d]\n", 168: (int) getpid()); 169: } 170: 171: rplcore(s_etat_processus); 172: 173: if ((*s_etat_processus).langue == 'F') 174: { 175: printf("+++Information : " 176: "Processus tracé [%d]\n", 177: (int) getpid()); 178: } 179: else 180: { 181: printf("+++Information : Done [%d]\n", 182: (int) getpid()); 183: } 184: 185: fflush(stdout); 186: } 187: 188: if ((*s_etat_processus).langue == 'F') 189: { 190: printf("+++Fatal : Compilation impossible\n"); 191: } 192: else 193: { 194: printf("+++Fatal : Compilation failed\n"); 195: } 196: 197: free(tableau); 198: return(d_erreur); 199: } 200: 201: // Modification de la variable. Il n'existe à cet instant 202: // que des variables de niveau 0. 203: 204: if (recherche_variable(s_etat_processus, tableau[i].nom) == 205: d_faux) 206: { 207: if ((*s_etat_processus).langue == 'F') 208: { 209: printf("+++Fatal : Compilation impossible\n"); 210: } 211: else 212: { 213: printf("+++Fatal : Compilation failed\n"); 214: } 215: 216: free(tableau); 217: return(d_erreur); 218: } 219: 220: liberation(s_etat_processus, tableau[i].objet); 221: 222: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile), 223: &((*(*s_etat_processus).pointeur_variable_courante).objet)) 224: == d_erreur) 225: { 226: if ((*s_etat_processus).langue == 'F') 227: { 228: printf("+++Fatal : Compilation impossible\n"); 229: } 230: else 231: { 232: printf("+++Fatal : Compilation failed\n"); 233: } 234: 235: free(tableau); 236: return(d_erreur); 237: } 238: 239: (*(*s_etat_processus).pointeur_variable_courante).origine = 'E'; 240: free((*s_etat_processus).instruction_courante); 241: 242: if (point_entree == i) 243: { 244: programme_principal = (*(*s_etat_processus) 245: .pointeur_variable_courante).objet; 246: } 247: } 248: } 249: 250: if (point_entree == -1) 251: { 252: if ((*s_etat_processus).langue == 'F') 253: { 254: printf("+++Fatal : Compilation impossible\n"); 255: } 256: else 257: { 258: printf("+++Fatal : Compilation failed\n"); 259: } 260: 261: free(tableau); 262: return(d_erreur); 263: } 264: 265: if ((*s_etat_processus).debug == d_vrai) 266: { 267: if (((*s_etat_processus).type_debug & 268: d_debug_analyse) != 0) 269: { 270: printf("\n"); 271: 272: if ((*s_etat_processus).langue == 'F') 273: { 274: printf("[%d] Compilation achevée\n", (int) getpid()); 275: } 276: else 277: { 278: printf("[%d] Compilation done\n", (int) getpid()); 279: } 280: 281: printf("\n"); 282: fflush(stdout); 283: } 284: } 285: 286: (*s_etat_processus).retour_routine_evaluation = 'Y'; 287: 288: free((*s_etat_processus).definitions_chainees); 289: 290: if (((*s_etat_processus).definitions_chainees = 291: malloc(sizeof(unsigned char))) == NULL) 292: { 293: if ((*s_etat_processus).langue == 'F') 294: { 295: printf("+++Fatal : Compilation impossible\n"); 296: } 297: else 298: { 299: printf("+++Fatal : Compilation failed\n"); 300: } 301: 302: free(tableau); 303: return(d_erreur); 304: } 305: 306: (*s_etat_processus).definitions_chainees[0] = d_code_fin_chaine; 307: (*s_etat_processus).longueur_definitions_chainees = 0; 308: (*s_etat_processus).evaluation_expression_compilee = 'Y'; 309: 310: if ((*s_etat_processus).profilage == d_vrai) 311: { 312: profilage(s_etat_processus, tableau[point_entree].nom); 313: } 314: 315: if ((*s_etat_processus).erreur_systeme != d_es) 316: { 317: if ((*s_etat_processus).langue == 'F') 318: { 319: printf("+++Système : Mémoire insuffisante\n"); 320: } 321: else 322: { 323: printf("+++System : Not enough memory\n"); 324: } 325: 326: free(tableau); 327: return(d_erreur); 328: } 329: 330: free(tableau); 331: 332: erreur = evaluation(s_etat_processus, programme_principal, 'E'); 333: 334: if ((*s_etat_processus).profilage == d_vrai) 335: { 336: profilage(s_etat_processus, NULL); 337: } 338: 339: (*s_etat_processus).mode_execution_programme = 'N'; 340: 341: if (((*s_etat_processus).erreur_execution != d_ex) || 342: ((*s_etat_processus).exception != d_ep) || 343: ((*s_etat_processus).erreur_systeme != d_es)) 344: { 345: printf("%s [%d]\n", message = messages(s_etat_processus), 346: (int) getpid()); 347: 348: if (test_cfsf(s_etat_processus, 51) == d_faux) 349: { 350: printf("%s", ds_beep); 351: } 352: 353: free(message); 354: } 355: 356: return(erreur); 357: } 358: 359: // vim: ts=4