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