Annotation of rpl/src/optimisation.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: Boucle principale optimisé de l'interpréteur 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: logical1 erreur;
! 42:
! 43: long i;
! 44: long point_entree;
! 45:
! 46: unsigned char *message;
! 47:
! 48: unsigned long adresse_point_entree;
! 49:
! 50: if ((*s_etat_processus).debug == d_vrai)
! 51: if (((*s_etat_processus).type_debug &
! 52: d_debug_analyse) != 0)
! 53: {
! 54: if ((*s_etat_processus).langue == 'F')
! 55: {
! 56: printf("[%d] Optimisation\n", (int) getpid());
! 57: }
! 58: else
! 59: {
! 60: printf("+++Optimization [%d]\n", (int) getpid());
! 61: }
! 62:
! 63: printf("\n");
! 64: fflush(stdout);
! 65: }
! 66:
! 67: point_entree = -1;
! 68: adresse_point_entree = 0;
! 69:
! 70: empilement_pile_systeme(s_etat_processus);
! 71: (*(*s_etat_processus).l_base_pile_systeme).retour_definition = 'Y';
! 72: (*s_etat_processus).autorisation_empilement_programme = 'Y';
! 73: (*s_etat_processus).mode_execution_programme = 'N';
! 74:
! 75: for(i = 0; i < (long) (*s_etat_processus).nombre_variables; i++)
! 76: {
! 77: if ((*s_etat_processus).s_liste_variables[i].niveau == 0)
! 78: {
! 79: // Variables qui contiennent les points d'entrée des définitions.
! 80:
! 81: (*s_etat_processus).position_courante = (*((unsigned long *)
! 82: (*((*s_etat_processus).s_liste_variables[i].objet)).objet));
! 83:
! 84: if (point_entree == -1)
! 85: {
! 86: adresse_point_entree = (*s_etat_processus).position_courante;
! 87: point_entree = i;
! 88: }
! 89: else
! 90: {
! 91: if ((*s_etat_processus).position_courante <
! 92: adresse_point_entree)
! 93: {
! 94: adresse_point_entree = (*s_etat_processus)
! 95: .position_courante;
! 96: point_entree = i;
! 97: }
! 98: }
! 99:
! 100: if ((erreur = recherche_instruction_suivante(s_etat_processus))
! 101: == d_erreur)
! 102: {
! 103: if ((*s_etat_processus).langue == 'F')
! 104: {
! 105: printf("+++Fatal : Optimisation impossible\n");
! 106: }
! 107: else
! 108: {
! 109: printf("+++Fatal : Optimization failed\n");
! 110: }
! 111:
! 112: return(d_erreur);
! 113: }
! 114:
! 115: recherche_type(s_etat_processus);
! 116:
! 117: if (((*s_etat_processus).erreur_execution != d_ex) ||
! 118: ((*s_etat_processus).erreur_systeme != d_es))
! 119: {
! 120: if ((*s_etat_processus).langue == 'F')
! 121: {
! 122: printf("+++Fatal : Optimisation impossible\n");
! 123: }
! 124: else
! 125: {
! 126: printf("+++Fatal : Optimization failed\n");
! 127: }
! 128:
! 129: return(d_erreur);
! 130: }
! 131:
! 132: liberation(s_etat_processus,
! 133: (*s_etat_processus).s_liste_variables[i].objet);
! 134:
! 135: if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
! 136: &((*s_etat_processus).s_liste_variables[i].objet))
! 137: == d_erreur)
! 138: {
! 139: if ((*s_etat_processus).langue == 'F')
! 140: {
! 141: printf("+++Fatal : Optimisation impossible\n");
! 142: }
! 143: else
! 144: {
! 145: printf("+++Fatal : Optimization failed\n");
! 146: }
! 147:
! 148: return(d_erreur);
! 149: }
! 150:
! 151: (*s_etat_processus).s_liste_variables[i].origine = 'E';
! 152: free((*s_etat_processus).instruction_courante);
! 153: }
! 154: }
! 155:
! 156: if (point_entree == -1)
! 157: {
! 158: if ((*s_etat_processus).langue == 'F')
! 159: {
! 160: printf("+++Fatal : Optimisation impossible\n");
! 161: }
! 162: else
! 163: {
! 164: printf("+++Fatal : Optimization failed\n");
! 165: }
! 166:
! 167: return(d_erreur);
! 168: }
! 169:
! 170: if ((*s_etat_processus).debug == d_vrai)
! 171: {
! 172: if (((*s_etat_processus).type_debug &
! 173: d_debug_analyse) != 0)
! 174: {
! 175: printf("\n");
! 176:
! 177: if ((*s_etat_processus).langue == 'F')
! 178: {
! 179: printf("[%d] Optimisation achevée\n", (int) getpid());
! 180: }
! 181: else
! 182: {
! 183: printf("[%d] Optimization done\n", (int) getpid());
! 184: }
! 185:
! 186: printf("\n");
! 187: fflush(stdout);
! 188: }
! 189: }
! 190:
! 191: (*s_etat_processus).retour_routine_evaluation = 'Y';
! 192:
! 193: free((*s_etat_processus).definitions_chainees);
! 194:
! 195: if (((*s_etat_processus).definitions_chainees =
! 196: malloc(sizeof(unsigned char))) == NULL)
! 197: {
! 198: if ((*s_etat_processus).langue == 'F')
! 199: {
! 200: printf("+++Fatal : Optimisation impossible\n");
! 201: }
! 202: else
! 203: {
! 204: printf("+++Fatal : Optimization failed\n");
! 205: }
! 206:
! 207: return(d_erreur);
! 208: }
! 209:
! 210: (*s_etat_processus).definitions_chainees[0] = d_code_fin_chaine;
! 211: (*s_etat_processus).longueur_definitions_chainees = 0;
! 212: (*s_etat_processus).evaluation_expression_compilee = 'Y';
! 213:
! 214: if ((*s_etat_processus).profilage == d_vrai)
! 215: {
! 216: profilage(s_etat_processus, (*s_etat_processus).s_liste_variables
! 217: [point_entree].nom);
! 218: }
! 219:
! 220: if ((*s_etat_processus).erreur_systeme != d_es)
! 221: {
! 222: if ((*s_etat_processus).langue == 'F')
! 223: {
! 224: printf("+++Système : Mémoire insuffisante\n");
! 225: }
! 226: else
! 227: {
! 228: printf("+++System : Not enough memory\n");
! 229: }
! 230:
! 231: return(d_erreur);
! 232: }
! 233:
! 234: erreur = evaluation(s_etat_processus, (*s_etat_processus).s_liste_variables
! 235: [point_entree].objet, 'E');
! 236:
! 237: if ((*s_etat_processus).profilage == d_vrai)
! 238: {
! 239: profilage(s_etat_processus, NULL);
! 240: }
! 241:
! 242: (*s_etat_processus).mode_execution_programme = 'N';
! 243:
! 244: if (((*s_etat_processus).erreur_execution != d_ex) ||
! 245: ((*s_etat_processus).exception != d_ep) ||
! 246: ((*s_etat_processus).erreur_systeme != d_es))
! 247: {
! 248: printf("%s [%d]\n", message = messages(s_etat_processus),
! 249: (int) getpid());
! 250:
! 251: if (test_cfsf(s_etat_processus, 51) == d_faux)
! 252: {
! 253: printf("%s", ds_beep);
! 254: }
! 255:
! 256: free(message);
! 257: }
! 258:
! 259: return(erreur);
! 260: }
! 261:
! 262: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>