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.7 */ |
---|
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 | Save_Length(nom,23); |
---|
271 | newvar->suiv = NULL; |
---|
272 | |
---|
273 | if ( !List_Subroutine_For_Alloc ) |
---|
274 | { |
---|
275 | List_Subroutine_For_Alloc = newvar; |
---|
276 | } |
---|
277 | else |
---|
278 | { |
---|
279 | parcours = List_Subroutine_For_Alloc; |
---|
280 | out = 0 ; |
---|
281 | while ( parcours->suiv && out == 0 ) |
---|
282 | { |
---|
283 | if ( !strcasecmp(parcours->o_nom,nom) ) out = 1 ; |
---|
284 | else parcours = parcours ->suiv; |
---|
285 | } |
---|
286 | /* */ |
---|
287 | if ( out == 0 ) |
---|
288 | { |
---|
289 | if ( strcasecmp(parcours->o_nom,nom) ) parcours->suiv = newvar; |
---|
290 | } |
---|
291 | } |
---|
292 | } |
---|
293 | |
---|
294 | |
---|
295 | void Write_Alloc_Subroutine_0() |
---|
296 | { |
---|
297 | listnom *parcours_nom; |
---|
298 | listnom *parcours_nomprec; |
---|
299 | int out; |
---|
300 | char ligne[LONG_C]; |
---|
301 | |
---|
302 | if ( firstpass == 0 ) |
---|
303 | { |
---|
304 | parcours_nomprec = (listnom *)NULL; |
---|
305 | parcours_nom = List_NameOfModule; |
---|
306 | out = 0 ; |
---|
307 | while ( parcours_nom && out == 0 ) |
---|
308 | { |
---|
309 | /* */ |
---|
310 | if ( !strcasecmp(curmodulename,parcours_nom->o_nom) ) out = 1; |
---|
311 | else parcours_nom = parcours_nom -> suiv; |
---|
312 | } |
---|
313 | if ( out == 1 ) |
---|
314 | { |
---|
315 | if ( parcours_nom->o_val == 1 ) |
---|
316 | { |
---|
317 | strcpy (ligne, "\n PUBLIC Alloc_agrif_"); |
---|
318 | strcat (ligne, curmodulename); |
---|
319 | strcat (ligne, "\n"); |
---|
320 | convert2lower(ligne); |
---|
321 | fprintf(fortranout,ligne); |
---|
322 | } |
---|
323 | } |
---|
324 | Write_Word_Contains_0(); |
---|
325 | if ( out == 1 ) |
---|
326 | { |
---|
327 | if ( parcours_nom->o_val == 1 ) |
---|
328 | { |
---|
329 | sprintf (ligne, "Subroutine Alloc_agrif_%s(Agrif_Gr)", |
---|
330 | curmodulename); |
---|
331 | tofich(fortranout,ligne,1); |
---|
332 | strcpy(ligne,"Use Agrif_Util"); |
---|
333 | tofich(fortranout,ligne,1); |
---|
334 | strcpy (ligne, "Type(Agrif_grid), Pointer :: Agrif_Gr"); |
---|
335 | tofich(fortranout,ligne,1); |
---|
336 | strcpy(ligne, "INTEGER :: i"); |
---|
337 | tofich (fortranout, ligne,1); |
---|
338 | strcpy (ligne, "\n#include \"alloc_agrif_"); |
---|
339 | strcat (ligne, curmodulename); |
---|
340 | strcat (ligne, ".h\"\n"); |
---|
341 | convert2lower(ligne); |
---|
342 | fprintf(fortranout,ligne); |
---|
343 | strcpy (ligne, "Return"); |
---|
344 | tofich(fortranout,ligne,1); |
---|
345 | sprintf (ligne, "End Subroutine Alloc_agrif_%s",curmodulename); |
---|
346 | tofich(fortranout,ligne,1); |
---|
347 | /* List all Call Alloc_agrif_ */ |
---|
348 | Add_Subroutine_For_Alloc(curmodulename); |
---|
349 | } |
---|
350 | else |
---|
351 | { |
---|
352 | parcours_nom = List_Subroutine_For_Alloc; |
---|
353 | out = 0; |
---|
354 | while ( parcours_nom && out == 0 ) |
---|
355 | { |
---|
356 | if ( !strcasecmp(parcours_nom->o_nom,curmodulename) ) out = 1; |
---|
357 | else |
---|
358 | { |
---|
359 | parcours_nomprec = parcours_nom; |
---|
360 | parcours_nom = parcours_nom->suiv; |
---|
361 | } |
---|
362 | } |
---|
363 | if ( out == 1 ) |
---|
364 | { |
---|
365 | if ( parcours_nom == List_Subroutine_For_Alloc) |
---|
366 | { |
---|
367 | List_Subroutine_For_Alloc = List_Subroutine_For_Alloc->suiv; |
---|
368 | } |
---|
369 | else |
---|
370 | { |
---|
371 | parcours_nomprec->suiv = parcours_nom->suiv; |
---|
372 | parcours_nom = parcours_nomprec->suiv ; |
---|
373 | } |
---|
374 | } |
---|
375 | } |
---|
376 | } |
---|
377 | } |
---|
378 | } |
---|
379 | |
---|
380 | |
---|
381 | void Write_Alloc_Subroutine_For_End_0() |
---|
382 | { |
---|
383 | listnom *parcours_nom; |
---|
384 | listnom *parcours_nomprec; |
---|
385 | int out; |
---|
386 | char ligne[LONG_C]; |
---|
387 | |
---|
388 | if ( firstpass == 0 ) |
---|
389 | { |
---|
390 | parcours_nomprec = (listnom *)NULL; |
---|
391 | parcours_nom = List_NameOfModule; |
---|
392 | out = 0 ; |
---|
393 | while ( parcours_nom && out == 0 ) |
---|
394 | { |
---|
395 | /* */ |
---|
396 | if ( !strcasecmp(curmodulename,parcours_nom->o_nom) ) out = 1; |
---|
397 | else parcours_nom = parcours_nom -> suiv; |
---|
398 | } |
---|
399 | if ( out == 1 ) |
---|
400 | { |
---|
401 | if ( parcours_nom->o_val == 1 ) |
---|
402 | { |
---|
403 | strcpy (ligne, "\n PUBLIC Alloc_agrif_"); |
---|
404 | strcat (ligne, curmodulename); |
---|
405 | strcat (ligne, "\n"); |
---|
406 | convert2lower(ligne); |
---|
407 | fprintf(fortranout,ligne); |
---|
408 | strcpy (ligne, "\n contains\n"); |
---|
409 | fprintf(fortranout,ligne); |
---|
410 | sprintf (ligne, "Subroutine Alloc_agrif_%s(Agrif_Gr)", |
---|
411 | curmodulename); |
---|
412 | tofich(fortranout,ligne,1); |
---|
413 | strcpy(ligne,"Use Agrif_Util"); |
---|
414 | tofich(fortranout,ligne,1); |
---|
415 | strcpy (ligne, "Type(Agrif_grid), Pointer :: Agrif_Gr"); |
---|
416 | tofich(fortranout,ligne,1); |
---|
417 | strcpy(ligne, "INTEGER :: i"); |
---|
418 | tofich (fortranout, ligne,1); |
---|
419 | strcpy (ligne, "\n#include \"alloc_agrif_"); |
---|
420 | strcat (ligne, curmodulename); |
---|
421 | strcat (ligne, ".h\"\n"); |
---|
422 | convert2lower(ligne); |
---|
423 | fprintf(fortranout,ligne); |
---|
424 | strcpy (ligne, "Return"); |
---|
425 | tofich(fortranout,ligne,1); |
---|
426 | sprintf (ligne, "End Subroutine Alloc_agrif_%s",curmodulename); |
---|
427 | tofich(fortranout,ligne,1); |
---|
428 | /* List all Call Alloc_agrif */ |
---|
429 | Add_Subroutine_For_Alloc(parcours_nom->o_nom); |
---|
430 | } |
---|
431 | else |
---|
432 | { |
---|
433 | parcours_nom = List_Subroutine_For_Alloc; |
---|
434 | out = 0; |
---|
435 | while ( parcours_nom && out == 0 ) |
---|
436 | { |
---|
437 | if ( !strcasecmp(parcours_nom->o_nom,curmodulename) ) out = 1; |
---|
438 | else |
---|
439 | { |
---|
440 | parcours_nomprec = parcours_nom; |
---|
441 | parcours_nom = parcours_nom->suiv; |
---|
442 | } |
---|
443 | } |
---|
444 | if ( out == 1 ) |
---|
445 | { |
---|
446 | if ( parcours_nom == List_Subroutine_For_Alloc) |
---|
447 | { |
---|
448 | List_Subroutine_For_Alloc = List_Subroutine_For_Alloc->suiv; |
---|
449 | } |
---|
450 | else |
---|
451 | { |
---|
452 | parcours_nomprec->suiv = parcours_nom->suiv; |
---|
453 | parcours_nom = parcours_nomprec->suiv ; |
---|
454 | } |
---|
455 | } |
---|
456 | } |
---|
457 | } |
---|
458 | } |
---|
459 | } |
---|
460 | |
---|
461 | void Write_GlobalParameter_Declaration_0() |
---|
462 | { |
---|
463 | listvar *parcours; |
---|
464 | |
---|
465 | if ( firstpass == 0 ) |
---|
466 | { |
---|
467 | parcours = List_GlobalParameter_Var; |
---|
468 | while( parcours ) |
---|
469 | { |
---|
470 | if ( !strcasecmp(parcours->var->v_modulename,curmodulename) ) |
---|
471 | { |
---|
472 | writevardeclaration(parcours,module_declar,0); |
---|
473 | } |
---|
474 | parcours = parcours -> suiv; |
---|
475 | } |
---|
476 | } |
---|
477 | } |
---|
478 | |
---|
479 | void Write_NotGridDepend_Declaration_0() |
---|
480 | { |
---|
481 | listvar *parcours; |
---|
482 | |
---|
483 | if ( firstpass == 0 ) |
---|
484 | { |
---|
485 | parcours = List_NotGridDepend_Var; |
---|
486 | while( parcours ) |
---|
487 | { |
---|
488 | if ( !strcasecmp(parcours->var->v_modulename,curmodulename) ) |
---|
489 | { |
---|
490 | writevardeclaration(parcours,fortranout,0); |
---|
491 | } |
---|
492 | parcours = parcours -> suiv; |
---|
493 | } |
---|
494 | } |
---|
495 | } |
---|
496 | |
---|
497 | /******************************************************************************/ |
---|
498 | /* IsTabvarsUseInArgument_0 */ |
---|
499 | /******************************************************************************/ |
---|
500 | /* Firstpass 1 */ |
---|
501 | /******************************************************************************/ |
---|
502 | /* */ |
---|
503 | /******************************************************************************/ |
---|
504 | int IsTabvarsUseInArgument_0() |
---|
505 | { |
---|
506 | int out; |
---|
507 | int doloopout; |
---|
508 | listvar *parcours; |
---|
509 | |
---|
510 | out=1; |
---|
511 | |
---|
512 | if ( List_UsedInSubroutine_Var ) |
---|
513 | { |
---|
514 | doloopout = 0; |
---|
515 | parcours = List_UsedInSubroutine_Var; |
---|
516 | while ( parcours && doloopout == 0 ) |
---|
517 | { |
---|
518 | if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) ) |
---|
519 | doloopout = 1; |
---|
520 | else parcours = parcours->suiv; |
---|
521 | } |
---|
522 | if ( doloopout == 0 ) out = 0; |
---|
523 | else out = 1 ; |
---|
524 | } |
---|
525 | else out = 0; |
---|
526 | |
---|
527 | return out; |
---|
528 | } |
---|
529 | |
---|
530 | |
---|
531 | /******************************************************************************/ |
---|
532 | /* ImplicitNoneInSubroutine */ |
---|
533 | /******************************************************************************/ |
---|
534 | /* Firstpass 0 */ |
---|
535 | /******************************************************************************/ |
---|
536 | /* */ |
---|
537 | /******************************************************************************/ |
---|
538 | int ImplicitNoneInSubroutine() |
---|
539 | { |
---|
540 | listname *parcours; |
---|
541 | int out; |
---|
542 | |
---|
543 | parcours= List_ImplicitNoneSubroutine; |
---|
544 | out = 0 ; |
---|
545 | while ( parcours && out == 0 ) |
---|
546 | { |
---|
547 | if ( !strcasecmp(parcours->n_name,subroutinename) ) out = 1; |
---|
548 | else parcours = parcours->suiv; |
---|
549 | } |
---|
550 | return out; |
---|
551 | } |
---|
552 | |
---|
553 | /******************************************************************************/ |
---|
554 | /* Add_Pointer_Var_From_List_1 */ |
---|
555 | /******************************************************************************/ |
---|
556 | /* Firstpass 1 */ |
---|
557 | /******************************************************************************/ |
---|
558 | /* */ |
---|
559 | /******************************************************************************/ |
---|
560 | void Add_Pointer_Var_From_List_1(listvar *listin) |
---|
561 | { |
---|
562 | listvar *parcours; |
---|
563 | |
---|
564 | if ( firstpass == 1 ) |
---|
565 | { |
---|
566 | parcours = listin; |
---|
567 | while ( parcours ) |
---|
568 | { |
---|
569 | Add_Pointer_Var_1(parcours->var->v_nomvar); |
---|
570 | parcours = parcours -> suiv ; |
---|
571 | } |
---|
572 | } |
---|
573 | } |
---|
574 | |
---|
575 | /******************************************************************************/ |
---|
576 | /* Add_Pointer_Var_1 */ |
---|
577 | /******************************************************************************/ |
---|
578 | /* Firstpass 1 */ |
---|
579 | /******************************************************************************/ |
---|
580 | /* */ |
---|
581 | /******************************************************************************/ |
---|
582 | void Add_Pointer_Var_1(char *nom) |
---|
583 | { |
---|
584 | listname *newvar; |
---|
585 | listname *parcours; |
---|
586 | int out; |
---|
587 | |
---|
588 | if ( firstpass == 1 ) |
---|
589 | { |
---|
590 | if ( !List_Pointer_Var ) |
---|
591 | { |
---|
592 | newvar = (listname *)malloc(sizeof(listname)); |
---|
593 | strcpy(newvar->n_name,nom); |
---|
594 | Save_Length(nom,20); |
---|
595 | newvar->suiv = NULL; |
---|
596 | List_Pointer_Var = newvar; |
---|
597 | } |
---|
598 | else |
---|
599 | { |
---|
600 | parcours = List_Pointer_Var; |
---|
601 | out = 0 ; |
---|
602 | while ( parcours->suiv && out == 0 ) |
---|
603 | { |
---|
604 | if ( !strcasecmp(parcours->n_name,nom) ) out = 1; |
---|
605 | else |
---|
606 | parcours=parcours->suiv; |
---|
607 | } |
---|
608 | if ( out == 0 ) |
---|
609 | { |
---|
610 | if ( !strcasecmp(parcours->n_name,nom) ) out = 1; |
---|
611 | else |
---|
612 | { |
---|
613 | /* add the record */ |
---|
614 | newvar = (listname *)malloc(sizeof(listname)); |
---|
615 | strcpy(newvar->n_name,nom); |
---|
616 | Save_Length(nom,20); |
---|
617 | newvar->suiv = NULL; |
---|
618 | parcours->suiv = newvar; |
---|
619 | } |
---|
620 | } |
---|
621 | } |
---|
622 | } |
---|
623 | } |
---|
624 | |
---|
625 | /******************************************************************************/ |
---|
626 | /* varispointer_0 */ |
---|
627 | /******************************************************************************/ |
---|
628 | /* Firstpass 0 */ |
---|
629 | /******************************************************************************/ |
---|
630 | /* */ |
---|
631 | /******************************************************************************/ |
---|
632 | int varispointer_0(char *ident) |
---|
633 | { |
---|
634 | listname *newname; |
---|
635 | int out; |
---|
636 | |
---|
637 | out =0; |
---|
638 | if ( firstpass == 0 ) |
---|
639 | { |
---|
640 | newname = List_Pointer_Var; |
---|
641 | while( newname && out == 0 ) |
---|
642 | { |
---|
643 | if ( !strcasecmp(ident,newname->n_name) ) out = 1 ; |
---|
644 | else newname = newname->suiv; |
---|
645 | } |
---|
646 | } |
---|
647 | return out; |
---|
648 | } |
---|
649 | |
---|
650 | |
---|
651 | /******************************************************************************/ |
---|
652 | /* VariableIsNotFunction */ |
---|
653 | /******************************************************************************/ |
---|
654 | /* */ |
---|
655 | /******************************************************************************/ |
---|
656 | int VariableIsNotFunction(char *ident) |
---|
657 | { |
---|
658 | int out; |
---|
659 | listvar *newvar; |
---|
660 | |
---|
661 | out =0; |
---|
662 | |
---|
663 | if ( !strcasecmp(ident,"size") || |
---|
664 | !strcasecmp(ident,"if") || |
---|
665 | !strcasecmp(ident,"max") || |
---|
666 | !strcasecmp(ident,"min") |
---|
667 | ) |
---|
668 | { |
---|
669 | newvar = List_SubroutineDeclaration_Var; |
---|
670 | while ( newvar && out == 0 ) |
---|
671 | { |
---|
672 | if ( !strcasecmp(subroutinename, newvar->var->v_subroutinename) && |
---|
673 | !strcasecmp(ident, newvar->var->v_nomvar) ) out = 1; |
---|
674 | newvar = newvar -> suiv ; |
---|
675 | } |
---|
676 | if ( out == 1 ) out = 0; |
---|
677 | else out = 1; |
---|
678 | /* if it has not been found */ |
---|
679 | if ( out == 1 ) |
---|
680 | { |
---|
681 | out = 0; |
---|
682 | newvar = List_Global_Var; |
---|
683 | while ( newvar && out == 0 ) |
---|
684 | { |
---|
685 | if ( !strcasecmp(ident, newvar->var->v_nomvar) ) out = 1; |
---|
686 | newvar = newvar -> suiv ; |
---|
687 | } |
---|
688 | if ( out == 1 ) out = 0; |
---|
689 | else out = 1; |
---|
690 | } |
---|
691 | } |
---|
692 | /* */ |
---|
693 | return out; |
---|
694 | } |
---|