1 | /******************************************************************************/ |
---|
2 | /* */ |
---|
3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
4 | /* */ |
---|
5 | /* Copyright or or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
6 | /* Cyril Mazauric (Cyril_Mazauric@yahoo.fr) */ |
---|
7 | /* This software is governed by the CeCILL-C license under French law and */ |
---|
8 | /* abiding by the rules of distribution of free software. You can use, */ |
---|
9 | /* modify and/ or redistribute the software under the terms of the CeCILL-C */ |
---|
10 | /* license as circulated by CEA, CNRS and INRIA at the following URL */ |
---|
11 | /* "http://www.cecill.info". */ |
---|
12 | /* */ |
---|
13 | /* As a counterpart to the access to the source code and rights to copy, */ |
---|
14 | /* modify and redistribute granted by the license, users are provided only */ |
---|
15 | /* with a limited warranty and the software's author, the holder of the */ |
---|
16 | /* economic rights, and the successive licensors have only limited */ |
---|
17 | /* liability. */ |
---|
18 | /* */ |
---|
19 | /* In this respect, the user's attention is drawn to the risks associated */ |
---|
20 | /* with loading, using, modifying and/or developing or reproducing the */ |
---|
21 | /* software by the user in light of its specific status of free software, */ |
---|
22 | /* that may mean that it is complicated to manipulate, and that also */ |
---|
23 | /* therefore means that it is reserved for developers and experienced */ |
---|
24 | /* professionals having in-depth computer knowledge. Users are therefore */ |
---|
25 | /* encouraged to load and test the software's suitability as regards their */ |
---|
26 | /* requirements in conditions enabling the security of their systems and/or */ |
---|
27 | /* data to be ensured and, more generally, to use and operate it in the */ |
---|
28 | /* same conditions as regards security. */ |
---|
29 | /* */ |
---|
30 | /* The fact that you are presently reading this means that you have had */ |
---|
31 | /* knowledge of the CeCILL-C license and that you accept its terms. */ |
---|
32 | /******************************************************************************/ |
---|
33 | /* version 1.6 */ |
---|
34 | /******************************************************************************/ |
---|
35 | #include <stdio.h> |
---|
36 | #include <stdlib.h> |
---|
37 | #include <string.h> |
---|
38 | #include "decl.h" |
---|
39 | |
---|
40 | /******************************************************************************/ |
---|
41 | /* initdimprob */ |
---|
42 | /******************************************************************************/ |
---|
43 | /* This subroutine is used to initialized grid dimension variable */ |
---|
44 | /******************************************************************************/ |
---|
45 | /* */ |
---|
46 | /* */ |
---|
47 | /* */ |
---|
48 | /******************************************************************************/ |
---|
49 | void initdimprob(int dimprobmod, char * nx, char * ny,char* nz) |
---|
50 | { |
---|
51 | dimprob = dimprobmod; |
---|
52 | |
---|
53 | strcpy(nbmaillesX,nx); |
---|
54 | strcpy(nbmaillesY,ny); |
---|
55 | strcpy(nbmaillesZ,nz); |
---|
56 | } |
---|
57 | |
---|
58 | /******************************************************************************/ |
---|
59 | /* Variableshouldberemove */ |
---|
60 | /******************************************************************************/ |
---|
61 | /* Firstpass 0 */ |
---|
62 | /******************************************************************************/ |
---|
63 | /* */ |
---|
64 | /* Agrif_<toto>(variable) ====> Agrif_<toto>(variable) */ |
---|
65 | /* */ |
---|
66 | /******************************************************************************/ |
---|
67 | int Variableshouldberemove(char *nom) |
---|
68 | { |
---|
69 | |
---|
70 | int remove; |
---|
71 | |
---|
72 | remove = 0 ; |
---|
73 | |
---|
74 | if ( remove == 0 && Agrif_in_Tok_NAME(nom) == 1 ) remove = 1 ; |
---|
75 | |
---|
76 | return remove; |
---|
77 | } |
---|
78 | |
---|
79 | /******************************************************************************/ |
---|
80 | /* variableisglobal */ |
---|
81 | /******************************************************************************/ |
---|
82 | /* This subroutine is to know if a variable is global */ |
---|
83 | /******************************************************************************/ |
---|
84 | int variableisglobal(listvar *curvar, listvar *listin) |
---|
85 | { |
---|
86 | int Globalite; |
---|
87 | listvar *newvar; |
---|
88 | |
---|
89 | |
---|
90 | Globalite = 0; |
---|
91 | newvar = listin; |
---|
92 | while ( newvar && Globalite == 0 ) |
---|
93 | { |
---|
94 | if ( !strcasecmp(newvar->var->v_nomvar,curvar->var->v_nomvar) ) |
---|
95 | { |
---|
96 | Globalite = 1; |
---|
97 | /* Now we should give the definition of the variable in the */ |
---|
98 | /* table List_UsedInSubroutine_Var */ |
---|
99 | strcpy(curvar->var->v_typevar,newvar->var->v_typevar); |
---|
100 | strcpy(curvar->var->v_dimchar,newvar->var->v_dimchar); |
---|
101 | curvar->var->v_nbdim = newvar->var->v_nbdim; |
---|
102 | curvar->var->v_dimensiongiven = newvar->var->v_dimensiongiven; |
---|
103 | curvar->var->v_allocatable = newvar->var->v_allocatable; |
---|
104 | curvar->var->v_pointerdeclare = newvar->var->v_pointerdeclare; |
---|
105 | curvar->var->v_indicetabvars = newvar->var->v_indicetabvars; |
---|
106 | strcpy(curvar->var->v_nameinttypename,newvar->var->v_nameinttypename); |
---|
107 | strcpy(curvar->var->v_precision,newvar->var->v_precision); |
---|
108 | strcpy(curvar->var->v_readedlistdimension, |
---|
109 | newvar->var->v_readedlistdimension); |
---|
110 | strcpy(curvar->var->v_commoninfile,newvar->var->v_commoninfile); |
---|
111 | } |
---|
112 | else |
---|
113 | { |
---|
114 | newvar = newvar->suiv; |
---|
115 | } |
---|
116 | } |
---|
117 | |
---|
118 | return Globalite ; |
---|
119 | } |
---|
120 | |
---|
121 | int VariableIsInListCommon(listvar *curvar,listvar *listin) |
---|
122 | { |
---|
123 | int present; |
---|
124 | listvar *newvar; |
---|
125 | |
---|
126 | present = 0; |
---|
127 | newvar = listin; |
---|
128 | while ( newvar && present == 0 ) |
---|
129 | { |
---|
130 | if ( !strcasecmp(newvar->var->v_nomvar,curvar->var->v_nomvar) && |
---|
131 | !strcasecmp(newvar->var->v_subroutinename, |
---|
132 | curvar->var->v_subroutinename) |
---|
133 | ) |
---|
134 | { |
---|
135 | CopyRecord(curvar->var,newvar->var); |
---|
136 | present = 1; |
---|
137 | } |
---|
138 | else newvar = newvar->suiv; |
---|
139 | } |
---|
140 | |
---|
141 | return present; |
---|
142 | } |
---|
143 | |
---|
144 | int VariableIsInList(listvar *curvar,listvar *listin) |
---|
145 | { |
---|
146 | int present; |
---|
147 | listvar *newvar; |
---|
148 | |
---|
149 | present = 0; |
---|
150 | newvar = listin; |
---|
151 | while ( newvar && present == 0 ) |
---|
152 | { |
---|
153 | if ( !strcasecmp(newvar->var->v_nomvar,curvar->var->v_nomvar) ) |
---|
154 | { |
---|
155 | CopyRecord(curvar->var,newvar->var); |
---|
156 | present = 1; |
---|
157 | } |
---|
158 | else newvar = newvar->suiv; |
---|
159 | } |
---|
160 | |
---|
161 | return present; |
---|
162 | } |
---|
163 | |
---|
164 | /******************************************************************************/ |
---|
165 | /* variableisglobalinmodule */ |
---|
166 | /******************************************************************************/ |
---|
167 | /* This subroutine is to know if a variable is global */ |
---|
168 | /******************************************************************************/ |
---|
169 | void variableisglobalinmodule(listcouple *listin, char *module, FILE *fileout) |
---|
170 | { |
---|
171 | int Globalite; |
---|
172 | listcouple *newvar; |
---|
173 | listcouple *newvarprec; |
---|
174 | listvar *tempo; |
---|
175 | listvar *newvar2; |
---|
176 | int out; |
---|
177 | |
---|
178 | Globalite = 1; |
---|
179 | newvarprec = (listcouple *)NULL; |
---|
180 | tempo = (listvar *)NULL; |
---|
181 | tempo = Readthedependfile(module,tempo); |
---|
182 | newvar = listin; |
---|
183 | while ( newvar ) |
---|
184 | { |
---|
185 | out = 0; |
---|
186 | newvar2 = tempo; |
---|
187 | while ( newvar2 && out == 0 ) |
---|
188 | { |
---|
189 | if ( !strcasecmp(newvar2->var->v_nomvar,newvar->c_namevar) ) out = 1; |
---|
190 | else newvar2 = newvar2 ->suiv; |
---|
191 | } |
---|
192 | if ( out == 1 ) |
---|
193 | { |
---|
194 | /* remove from the listin */ |
---|
195 | if ( newvar == listin ) |
---|
196 | { |
---|
197 | listin = listin->suiv; |
---|
198 | newvar = listin; |
---|
199 | } |
---|
200 | else |
---|
201 | { |
---|
202 | newvarprec->suiv = newvar->suiv; |
---|
203 | newvar = newvar->suiv; |
---|
204 | } |
---|
205 | } |
---|
206 | else |
---|
207 | { |
---|
208 | newvarprec = newvar; |
---|
209 | newvar = newvar->suiv; |
---|
210 | Globalite = 0; |
---|
211 | } |
---|
212 | } |
---|
213 | if ( Globalite == 0 || !newvar) |
---|
214 | { |
---|
215 | pos_end = setposcur(); |
---|
216 | RemoveWordSET_0(fileout,pos_curuse, |
---|
217 | pos_end-pos_curuse); |
---|
218 | newvar = listin; |
---|
219 | while ( newvar ) |
---|
220 | { |
---|
221 | fprintf(fileout," USE %s, ONLY : %s \n",module,newvar->c_namevar); |
---|
222 | newvar = newvar->suiv; |
---|
223 | } |
---|
224 | } |
---|
225 | } |
---|
226 | |
---|
227 | |
---|
228 | void Remove_Word_Contains_0() |
---|
229 | { |
---|
230 | if ( firstpass == 0 ) |
---|
231 | { |
---|
232 | RemoveWordCUR_0(fortranout,(long)(-9),9); |
---|
233 | } |
---|
234 | } |
---|
235 | |
---|
236 | void Remove_Word_end_module_0() |
---|
237 | { |
---|
238 | if ( firstpass == 0 ) |
---|
239 | { |
---|
240 | RemoveWordCUR_0(fortranout,(long)(-strlen(curmodulename)-12), |
---|
241 | strlen(curmodulename)+11); |
---|
242 | } |
---|
243 | } |
---|
244 | |
---|
245 | void Write_Word_Contains_0() |
---|
246 | { |
---|
247 | if ( firstpass == 0 ) |
---|
248 | { |
---|
249 | fprintf(fortranout,"\n contains\n"); |
---|
250 | } |
---|
251 | } |
---|
252 | |
---|
253 | |
---|
254 | void Write_Word_end_module_0() |
---|
255 | { |
---|
256 | if ( firstpass == 0 ) |
---|
257 | { |
---|
258 | fprintf(fortranout,"\n end module %s",curmodulename); |
---|
259 | } |
---|
260 | } |
---|
261 | |
---|
262 | void Add_Subroutine_For_Alloc(char *nom) |
---|
263 | { |
---|
264 | listnom *parcours; |
---|
265 | listnom *newvar; |
---|
266 | int out; |
---|
267 | |
---|
268 | newvar = (listnom *)malloc(sizeof(listnom)); |
---|
269 | strcpy(newvar->o_nom,nom); |
---|
270 | newvar->suiv = NULL; |
---|
271 | |
---|
272 | if ( !List_Subroutine_For_Alloc ) |
---|
273 | { |
---|
274 | List_Subroutine_For_Alloc = newvar; |
---|
275 | } |
---|
276 | else |
---|
277 | { |
---|
278 | parcours = List_Subroutine_For_Alloc; |
---|
279 | out = 0 ; |
---|
280 | while ( parcours->suiv && out == 0 ) |
---|
281 | { |
---|
282 | if ( !strcasecmp(parcours->o_nom,nom) ) out = 1 ; |
---|
283 | else parcours = parcours ->suiv; |
---|
284 | } |
---|
285 | /* */ |
---|
286 | if ( out == 0 ) |
---|
287 | { |
---|
288 | if ( strcasecmp(parcours->o_nom,nom) ) parcours->suiv = newvar; |
---|
289 | } |
---|
290 | } |
---|
291 | } |
---|
292 | |
---|
293 | |
---|
294 | void Write_Alloc_Subroutine_0() |
---|
295 | { |
---|
296 | listnom *parcours_nom; |
---|
297 | listnom *parcours_nomprec; |
---|
298 | int out; |
---|
299 | char ligne[LONGNOM]; |
---|
300 | |
---|
301 | if ( firstpass == 0 ) |
---|
302 | { |
---|
303 | parcours_nom = List_NameOfModule; |
---|
304 | out = 0 ; |
---|
305 | while ( parcours_nom && out == 0 ) |
---|
306 | { |
---|
307 | /* */ |
---|
308 | if ( !strcasecmp(curmodulename,parcours_nom->o_nom) ) out = 1; |
---|
309 | else parcours_nom = parcours_nom -> suiv; |
---|
310 | } |
---|
311 | if ( out == 1 ) |
---|
312 | { |
---|
313 | if ( parcours_nom->o_val == 1 ) |
---|
314 | { |
---|
315 | strcpy (ligne, "\n PUBLIC Alloc_agrif_"); |
---|
316 | strcat (ligne, curmodulename); |
---|
317 | strcat (ligne, "\n"); |
---|
318 | convert2lower(ligne); |
---|
319 | fprintf(fortranout,ligne); |
---|
320 | } |
---|
321 | } |
---|
322 | Write_Word_Contains_0(); |
---|
323 | if ( out == 1 ) |
---|
324 | { |
---|
325 | if ( parcours_nom->o_val == 1 ) |
---|
326 | { |
---|
327 | sprintf (ligne, "Subroutine Alloc_agrif_%s(Agrif_Gr)", |
---|
328 | curmodulename); |
---|
329 | tofich(fortranout,ligne,1); |
---|
330 | strcpy(ligne,"Use Agrif_Util"); |
---|
331 | tofich(fortranout,ligne,1); |
---|
332 | strcpy (ligne, "Type(Agrif_grid), Pointer :: Agrif_Gr"); |
---|
333 | tofich(fortranout,ligne,1); |
---|
334 | strcpy(ligne, "INTEGER :: i"); |
---|
335 | tofich (fortranout, ligne,1); |
---|
336 | strcpy (ligne, "\n#include \"alloc_agrif_"); |
---|
337 | strcat (ligne, curmodulename); |
---|
338 | strcat (ligne, ".h\"\n"); |
---|
339 | convert2lower(ligne); |
---|
340 | fprintf(fortranout,ligne); |
---|
341 | strcpy (ligne, "Return"); |
---|
342 | tofich(fortranout,ligne,1); |
---|
343 | sprintf (ligne, "End Subroutine Alloc_agrif_%s",curmodulename); |
---|
344 | tofich(fortranout,ligne,1); |
---|
345 | /* List all Call Alloc_agrif_ */ |
---|
346 | Add_Subroutine_For_Alloc(curmodulename); |
---|
347 | } |
---|
348 | else |
---|
349 | { |
---|
350 | parcours_nom = List_Subroutine_For_Alloc; |
---|
351 | out = 0; |
---|
352 | while ( parcours_nom && out == 0 ) |
---|
353 | { |
---|
354 | if ( !strcasecmp(parcours_nom->o_nom,curmodulename) ) out = 1; |
---|
355 | else |
---|
356 | { |
---|
357 | parcours_nomprec = parcours_nom; |
---|
358 | parcours_nom = parcours_nom->suiv; |
---|
359 | } |
---|
360 | } |
---|
361 | if ( out == 1 ) |
---|
362 | { |
---|
363 | if ( parcours_nom == List_Subroutine_For_Alloc) |
---|
364 | { |
---|
365 | List_Subroutine_For_Alloc = List_Subroutine_For_Alloc->suiv; |
---|
366 | } |
---|
367 | else |
---|
368 | { |
---|
369 | parcours_nomprec->suiv = parcours_nom->suiv; |
---|
370 | parcours_nom = parcours_nomprec->suiv ; |
---|
371 | } |
---|
372 | } |
---|
373 | } |
---|
374 | } |
---|
375 | } |
---|
376 | } |
---|
377 | |
---|
378 | |
---|
379 | void Write_Alloc_Subroutine_For_End_0() |
---|
380 | { |
---|
381 | listnom *parcours_nom; |
---|
382 | listnom *parcours_nomprec; |
---|
383 | int out; |
---|
384 | char ligne[LONGNOM]; |
---|
385 | |
---|
386 | if ( firstpass == 0 ) |
---|
387 | { |
---|
388 | parcours_nom = List_NameOfModule; |
---|
389 | out = 0 ; |
---|
390 | while ( parcours_nom && out == 0 ) |
---|
391 | { |
---|
392 | /* */ |
---|
393 | if ( !strcasecmp(curmodulename,parcours_nom->o_nom) ) out = 1; |
---|
394 | else parcours_nom = parcours_nom -> suiv; |
---|
395 | } |
---|
396 | if ( out == 1 ) |
---|
397 | { |
---|
398 | if ( parcours_nom->o_val == 1 ) |
---|
399 | { |
---|
400 | strcpy (ligne, "\n PUBLIC Alloc_agrif_"); |
---|
401 | strcat (ligne, curmodulename); |
---|
402 | strcat (ligne, "\n"); |
---|
403 | convert2lower(ligne); |
---|
404 | fprintf(fortranout,ligne); |
---|
405 | strcpy (ligne, "\n contains\n"); |
---|
406 | fprintf(fortranout,ligne); |
---|
407 | sprintf (ligne, "Subroutine Alloc_agrif_%s(Agrif_Gr)", |
---|
408 | curmodulename); |
---|
409 | tofich(fortranout,ligne,1); |
---|
410 | strcpy(ligne,"Use Agrif_Util"); |
---|
411 | tofich(fortranout,ligne,1); |
---|
412 | strcpy (ligne, "Type(Agrif_grid), Pointer :: Agrif_Gr"); |
---|
413 | tofich(fortranout,ligne,1); |
---|
414 | strcpy(ligne, "INTEGER :: i"); |
---|
415 | tofich (fortranout, ligne,1); |
---|
416 | strcpy (ligne, "\n#include \"alloc_agrif_"); |
---|
417 | strcat (ligne, curmodulename); |
---|
418 | strcat (ligne, ".h\"\n"); |
---|
419 | convert2lower(ligne); |
---|
420 | fprintf(fortranout,ligne); |
---|
421 | strcpy (ligne, "Return"); |
---|
422 | tofich(fortranout,ligne,1); |
---|
423 | sprintf (ligne, "End Subroutine Alloc_agrif_%s",curmodulename); |
---|
424 | tofich(fortranout,ligne,1); |
---|
425 | /* List all Call Alloc_agrif */ |
---|
426 | Add_Subroutine_For_Alloc(parcours_nom->o_nom); |
---|
427 | } |
---|
428 | else |
---|
429 | { |
---|
430 | parcours_nom = List_Subroutine_For_Alloc; |
---|
431 | out = 0; |
---|
432 | while ( parcours_nom && out == 0 ) |
---|
433 | { |
---|
434 | if ( !strcasecmp(parcours_nom->o_nom,curmodulename) ) out = 1; |
---|
435 | else |
---|
436 | { |
---|
437 | parcours_nomprec = parcours_nom; |
---|
438 | parcours_nom = parcours_nom->suiv; |
---|
439 | } |
---|
440 | } |
---|
441 | if ( out == 1 ) |
---|
442 | { |
---|
443 | if ( parcours_nom == List_Subroutine_For_Alloc) |
---|
444 | { |
---|
445 | List_Subroutine_For_Alloc = List_Subroutine_For_Alloc->suiv; |
---|
446 | } |
---|
447 | else |
---|
448 | { |
---|
449 | parcours_nomprec->suiv = parcours_nom->suiv; |
---|
450 | parcours_nom = parcours_nomprec->suiv ; |
---|
451 | } |
---|
452 | } |
---|
453 | } |
---|
454 | } |
---|
455 | } |
---|
456 | } |
---|
457 | |
---|
458 | void Write_GlobalParameter_Declaration_0() |
---|
459 | { |
---|
460 | listvar *parcours; |
---|
461 | |
---|
462 | if ( firstpass == 0 ) |
---|
463 | { |
---|
464 | parcours = List_GlobalParameter_Var; |
---|
465 | while( parcours ) |
---|
466 | { |
---|
467 | if ( !strcasecmp(parcours->var->v_modulename,curmodulename) ) |
---|
468 | { |
---|
469 | writevardeclaration(parcours,module_declar,0); |
---|
470 | } |
---|
471 | parcours = parcours -> suiv; |
---|
472 | } |
---|
473 | } |
---|
474 | } |
---|
475 | |
---|
476 | void Write_NotGridDepend_Declaration_0() |
---|
477 | { |
---|
478 | listvar *parcours; |
---|
479 | |
---|
480 | if ( firstpass == 0 ) |
---|
481 | { |
---|
482 | parcours = List_NotGridDepend_Var; |
---|
483 | while( parcours ) |
---|
484 | { |
---|
485 | if ( !strcasecmp(parcours->var->v_modulename,curmodulename) ) |
---|
486 | { |
---|
487 | writevardeclaration(parcours,fortranout,0); |
---|
488 | } |
---|
489 | parcours = parcours -> suiv; |
---|
490 | } |
---|
491 | } |
---|
492 | } |
---|
493 | |
---|
494 | /******************************************************************************/ |
---|
495 | /* IsTabvarsUseInArgument_0 */ |
---|
496 | /******************************************************************************/ |
---|
497 | /* Firstpass 1 */ |
---|
498 | /******************************************************************************/ |
---|
499 | /* */ |
---|
500 | /******************************************************************************/ |
---|
501 | int IsTabvarsUseInArgument_0() |
---|
502 | { |
---|
503 | int out; |
---|
504 | int doloopout; |
---|
505 | listvar *parcours; |
---|
506 | |
---|
507 | out=1; |
---|
508 | |
---|
509 | if ( List_UsedInSubroutine_Var ) |
---|
510 | { |
---|
511 | doloopout = 0; |
---|
512 | parcours = List_UsedInSubroutine_Var; |
---|
513 | while ( parcours && doloopout == 0 ) |
---|
514 | { |
---|
515 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) |
---|
516 | doloopout = 1; |
---|
517 | else parcours = parcours->suiv; |
---|
518 | } |
---|
519 | if ( doloopout == 0 ) out = 0; |
---|
520 | else out = 1 ; |
---|
521 | } |
---|
522 | else out = 0; |
---|
523 | |
---|
524 | return out; |
---|
525 | } |
---|
526 | |
---|
527 | |
---|
528 | /******************************************************************************/ |
---|
529 | /* ImplicitNoneInSubroutine */ |
---|
530 | /******************************************************************************/ |
---|
531 | /* Firstpass 0 */ |
---|
532 | /******************************************************************************/ |
---|
533 | /* */ |
---|
534 | /******************************************************************************/ |
---|
535 | int ImplicitNoneInSubroutine() |
---|
536 | { |
---|
537 | listname *parcours; |
---|
538 | int out; |
---|
539 | |
---|
540 | parcours= List_ImplicitNoneSubroutine; |
---|
541 | out = 0 ; |
---|
542 | while ( parcours && out == 0 ) |
---|
543 | { |
---|
544 | if ( !strcasecmp(parcours->n_name,subroutinename) ) out = 1; |
---|
545 | else parcours = parcours->suiv; |
---|
546 | } |
---|
547 | return out; |
---|
548 | } |
---|
549 | |
---|
550 | /******************************************************************************/ |
---|
551 | /* Add_Pointer_Var_From_List_1 */ |
---|
552 | /******************************************************************************/ |
---|
553 | /* Firstpass 1 */ |
---|
554 | /******************************************************************************/ |
---|
555 | /* */ |
---|
556 | /******************************************************************************/ |
---|
557 | void Add_Pointer_Var_From_List_1(listvar *listin) |
---|
558 | { |
---|
559 | listvar *parcours; |
---|
560 | int out; |
---|
561 | |
---|
562 | if ( firstpass == 1 ) |
---|
563 | { |
---|
564 | parcours = listin; |
---|
565 | while ( parcours ) |
---|
566 | { |
---|
567 | Add_Pointer_Var_1(parcours->var->v_nomvar); |
---|
568 | parcours = parcours -> suiv ; |
---|
569 | } |
---|
570 | } |
---|
571 | } |
---|
572 | |
---|
573 | /******************************************************************************/ |
---|
574 | /* Add_Pointer_Var_1 */ |
---|
575 | /******************************************************************************/ |
---|
576 | /* Firstpass 1 */ |
---|
577 | /******************************************************************************/ |
---|
578 | /* */ |
---|
579 | /******************************************************************************/ |
---|
580 | void Add_Pointer_Var_1(char *nom) |
---|
581 | { |
---|
582 | listname *newvar; |
---|
583 | listname *parcours; |
---|
584 | int out; |
---|
585 | |
---|
586 | if ( firstpass == 1 ) |
---|
587 | { |
---|
588 | if ( !List_Pointer_Var ) |
---|
589 | { |
---|
590 | newvar = (listname *)malloc(sizeof(listname)); |
---|
591 | strcpy(newvar->n_name,nom); |
---|
592 | newvar->suiv = NULL; |
---|
593 | List_Pointer_Var = newvar; |
---|
594 | } |
---|
595 | else |
---|
596 | { |
---|
597 | parcours = List_Pointer_Var; |
---|
598 | out = 0 ; |
---|
599 | while ( parcours->suiv && out == 0 ) |
---|
600 | { |
---|
601 | if ( !strcasecmp(parcours->n_name,nom) ) out = 1; |
---|
602 | else |
---|
603 | parcours=parcours->suiv; |
---|
604 | } |
---|
605 | if ( out == 0 ) |
---|
606 | { |
---|
607 | if ( !strcasecmp(parcours->n_name,nom) ) out = 1; |
---|
608 | else |
---|
609 | { |
---|
610 | /* add the record */ |
---|
611 | newvar = (listname *)malloc(sizeof(listname)); |
---|
612 | strcpy(newvar->n_name,nom); |
---|
613 | newvar->suiv = NULL; |
---|
614 | parcours->suiv = newvar; |
---|
615 | } |
---|
616 | } |
---|
617 | } |
---|
618 | } |
---|
619 | } |
---|
620 | |
---|
621 | /******************************************************************************/ |
---|
622 | /* varispointer_0 */ |
---|
623 | /******************************************************************************/ |
---|
624 | /* Firstpass 0 */ |
---|
625 | /******************************************************************************/ |
---|
626 | /* */ |
---|
627 | /******************************************************************************/ |
---|
628 | int varispointer_0(char *ident) |
---|
629 | { |
---|
630 | listname *newname; |
---|
631 | int out; |
---|
632 | |
---|
633 | out =0; |
---|
634 | if ( firstpass == 0 ) |
---|
635 | { |
---|
636 | newname = List_Pointer_Var; |
---|
637 | while( newname && out == 0 ) |
---|
638 | { |
---|
639 | if ( !strcasecmp(ident,newname->n_name) ) out = 1 ; |
---|
640 | else newname = newname->suiv; |
---|
641 | } |
---|
642 | } |
---|
643 | return out; |
---|
644 | } |
---|
645 | |
---|
646 | |
---|
647 | /******************************************************************************/ |
---|
648 | /* VariableIsNotFunction */ |
---|
649 | /******************************************************************************/ |
---|
650 | /* */ |
---|
651 | /******************************************************************************/ |
---|
652 | int VariableIsNotFunction(char *ident) |
---|
653 | { |
---|
654 | int out; |
---|
655 | listvar *newvar; |
---|
656 | |
---|
657 | out =0; |
---|
658 | |
---|
659 | if ( !strcasecmp(ident,"size") || |
---|
660 | !strcasecmp(ident,"if") || |
---|
661 | !strcasecmp(ident,"max") || |
---|
662 | !strcasecmp(ident,"min") |
---|
663 | ) |
---|
664 | { |
---|
665 | newvar = List_SubroutineDeclaration_Var; |
---|
666 | while ( newvar && out == 0 ) |
---|
667 | { |
---|
668 | if ( !strcasecmp(subroutinename, newvar->var->v_subroutinename) && |
---|
669 | !strcasecmp(ident, newvar->var->v_nomvar) ) out = 1; |
---|
670 | newvar = newvar -> suiv ; |
---|
671 | } |
---|
672 | if ( out == 1 ) out = 0; |
---|
673 | else out = 1; |
---|
674 | /* if it has not been found */ |
---|
675 | if ( out == 1 ) |
---|
676 | { |
---|
677 | out = 0; |
---|
678 | newvar = List_Global_Var; |
---|
679 | while ( newvar && out == 0 ) |
---|
680 | { |
---|
681 | if ( !strcasecmp(ident, newvar->var->v_nomvar) ) out = 1; |
---|
682 | newvar = newvar -> suiv ; |
---|
683 | } |
---|
684 | if ( out == 1 ) out = 0; |
---|
685 | else out = 1; |
---|
686 | } |
---|
687 | } |
---|
688 | /* */ |
---|
689 | return out; |
---|
690 | } |
---|