Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2Scope. */
2 : : /* M2Scope.mod derive the subset of quadruples for each scope.
3 : :
4 : : Copyright (C) 2003-2024 Free Software Foundation, Inc.
5 : : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 : :
7 : : This file is part of GNU Modula-2.
8 : :
9 : : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : : it under the terms of the GNU General Public License as published by
11 : : the Free Software Foundation; either version 3, or (at your option)
12 : : any later version.
13 : :
14 : : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include <stdbool.h>
26 : : # if !defined (PROC_D)
27 : : # define PROC_D
28 : : typedef void (*PROC_t) (void);
29 : : typedef struct { PROC_t proc; } PROC;
30 : : # endif
31 : :
32 : : # if !defined (TRUE)
33 : : # define TRUE (1==1)
34 : : # endif
35 : :
36 : : # if !defined (FALSE)
37 : : # define FALSE (1==0)
38 : : # endif
39 : :
40 : : # include "GStorage.h"
41 : : # include "Gmcrts.h"
42 : : #if defined(__cplusplus)
43 : : # undef NULL
44 : : # define NULL 0
45 : : #endif
46 : : #define _M2Scope_H
47 : : #define _M2Scope_C
48 : :
49 : : # include "GStorage.h"
50 : : # include "GM2Debug.h"
51 : : # include "GNameKey.h"
52 : : # include "GSymbolTable.h"
53 : : # include "GM2Printf.h"
54 : : # include "GM2Quads.h"
55 : : # include "GM2StackWord.h"
56 : : # include "GM2Error.h"
57 : :
58 : : typedef struct M2Scope_ScopeProcedure2_p M2Scope_ScopeProcedure2;
59 : :
60 : : typedef struct M2Scope_ScopeProcedure3_p M2Scope_ScopeProcedure3;
61 : :
62 : : # define Debugging false
63 : : # define TraceQuadruples false
64 : : typedef struct M2Scope__T1_r M2Scope__T1;
65 : :
66 : : typedef enum {M2Scope_unsetscope, M2Scope_ignorescope, M2Scope_procedurescope, M2Scope_modulescope, M2Scope_definitionscope, M2Scope_implementationscope, M2Scope_programscope} M2Scope_scopeKind;
67 : :
68 : : typedef M2Scope__T1 *M2Scope_ScopeBlock;
69 : :
70 : : typedef void (*M2Scope_ScopeProcedure2_t) (unsigned int, unsigned int);
71 : : struct M2Scope_ScopeProcedure2_p { M2Scope_ScopeProcedure2_t proc; };
72 : :
73 : : typedef void (*M2Scope_ScopeProcedure3_t) (unsigned int, unsigned int, unsigned int);
74 : : struct M2Scope_ScopeProcedure3_p { M2Scope_ScopeProcedure3_t proc; };
75 : :
76 : : struct M2Scope__T1_r {
77 : : unsigned int scopeSym;
78 : : M2Scope_scopeKind kindScope;
79 : : unsigned int low;
80 : : unsigned int high;
81 : : M2Scope_ScopeBlock next;
82 : : };
83 : :
84 : : static M2Scope_ScopeBlock FreeList;
85 : :
86 : : /*
87 : : InitScopeBlock -
88 : : */
89 : :
90 : : extern "C" M2Scope_ScopeBlock M2Scope_InitScopeBlock (unsigned int scope);
91 : :
92 : : /*
93 : : KillScopeBlock - destroys the ScopeBlock sb and assign sb to NIL.
94 : : */
95 : :
96 : : extern "C" void M2Scope_KillScopeBlock (M2Scope_ScopeBlock *sb);
97 : :
98 : : /*
99 : : ForeachScopeBlockDo2 - calls a procedure p for each block of contigeous quadruples
100 : : defining an outer scope sb.
101 : : */
102 : :
103 : : extern "C" void M2Scope_ForeachScopeBlockDo2 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure2 p);
104 : :
105 : : /*
106 : : ForeachScopeBlockDo3 - calls a procedure p for each block of contigeous quadruples
107 : : defining an outer scope sb.
108 : : */
109 : :
110 : : extern "C" void M2Scope_ForeachScopeBlockDo3 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure3 p);
111 : :
112 : : /*
113 : : New -
114 : : */
115 : :
116 : : static void New (M2Scope_ScopeBlock *sb);
117 : :
118 : : /*
119 : : Dispose -
120 : : */
121 : :
122 : : static void Dispose (M2Scope_ScopeBlock *sb);
123 : :
124 : : /*
125 : : SetScope - assigns the scopeSym and kindScope.
126 : : */
127 : :
128 : : static void SetScope (M2Scope_ScopeBlock sb, unsigned int sym, M2Scope_scopeKind kindScope);
129 : :
130 : : /*
131 : : AddToRange - returns a ScopeBlock pointer to the last block. The,
132 : : quad, will be added to the end of sb or a later block
133 : : if First is TRUE.
134 : : */
135 : :
136 : : static M2Scope_ScopeBlock AddToRange (M2Scope_ScopeBlock sb, bool First, unsigned int quad);
137 : :
138 : : /*
139 : : GetGlobalQuads -
140 : : */
141 : :
142 : : static M2Scope_ScopeBlock GetGlobalQuads (M2Scope_ScopeBlock sb, unsigned int scope);
143 : :
144 : : /*
145 : : GetProcQuads -
146 : : */
147 : :
148 : : static M2Scope_ScopeBlock GetProcQuads (M2Scope_ScopeBlock sb, unsigned int proc);
149 : :
150 : : /*
151 : : DisplayScope -
152 : : */
153 : :
154 : : static void DisplayScope (M2Scope_ScopeBlock sb);
155 : :
156 : : /*
157 : : enter -
158 : : */
159 : :
160 : : static void enter (M2Scope_ScopeBlock sb);
161 : :
162 : : /*
163 : : leave -
164 : : */
165 : :
166 : : static void leave (M2Scope_ScopeBlock sb);
167 : :
168 : : /*
169 : : Init - initializes the global variables for this module.
170 : : */
171 : :
172 : : static void Init (void);
173 : :
174 : :
175 : : /*
176 : : New -
177 : : */
178 : :
179 : 1707805 : static void New (M2Scope_ScopeBlock *sb)
180 : : {
181 : 1707805 : if (FreeList == NULL)
182 : : {
183 : 307034 : Storage_ALLOCATE ((void **) &(*sb), sizeof (M2Scope__T1));
184 : : }
185 : : else
186 : : {
187 : 1400771 : (*sb) = FreeList;
188 : 1400771 : FreeList = FreeList->next;
189 : : }
190 : 1707805 : }
191 : :
192 : :
193 : : /*
194 : : Dispose -
195 : : */
196 : :
197 : 1707373 : static void Dispose (M2Scope_ScopeBlock *sb)
198 : : {
199 : 1707373 : (*sb)->next = FreeList;
200 : 1707373 : FreeList = (*sb);
201 : 1707373 : (*sb) = NULL;
202 : 1707373 : }
203 : :
204 : :
205 : : /*
206 : : SetScope - assigns the scopeSym and kindScope.
207 : : */
208 : :
209 : 2188862 : static void SetScope (M2Scope_ScopeBlock sb, unsigned int sym, M2Scope_scopeKind kindScope)
210 : : {
211 : 2188862 : sb->scopeSym = sym;
212 : 2188862 : sb->kindScope = kindScope;
213 : 1660838 : }
214 : :
215 : :
216 : : /*
217 : : AddToRange - returns a ScopeBlock pointer to the last block. The,
218 : : quad, will be added to the end of sb or a later block
219 : : if First is TRUE.
220 : : */
221 : :
222 : 18941297 : static M2Scope_ScopeBlock AddToRange (M2Scope_ScopeBlock sb, bool First, unsigned int quad)
223 : : {
224 : 18941297 : if (First)
225 : : {
226 : 1099226 : if (sb->high == 0)
227 : : {
228 : 69368 : sb->high = sb->low;
229 : : }
230 : 1099226 : sb->next = M2Scope_InitScopeBlock (SymbolTable_NulSym);
231 : 1099226 : sb = sb->next;
232 : : }
233 : 18941297 : if (sb->low == 0)
234 : : {
235 : 1099862 : sb->low = quad;
236 : : }
237 : 18941297 : sb->high = quad;
238 : 18941297 : return sb;
239 : : /* static analysis guarentees a RETURN statement will be used before here. */
240 : : __builtin_unreachable ();
241 : : }
242 : :
243 : :
244 : : /*
245 : : GetGlobalQuads -
246 : : */
247 : :
248 : 68468 : static M2Scope_ScopeBlock GetGlobalQuads (M2Scope_ScopeBlock sb, unsigned int scope)
249 : : {
250 : 68468 : M2Scope_ScopeBlock prev;
251 : 68468 : M2Scope_ScopeBlock nb;
252 : 68468 : unsigned int NestedLevel;
253 : 68468 : unsigned int i;
254 : 68468 : M2Quads_QuadOperator op;
255 : 68468 : unsigned int op1;
256 : 68468 : unsigned int op2;
257 : 68468 : unsigned int op3;
258 : 68468 : bool First;
259 : 68468 : unsigned int start;
260 : 68468 : unsigned int end;
261 : :
262 : 68468 : NestedLevel = 0;
263 : 68468 : prev = NULL;
264 : 68468 : First = false;
265 : 68468 : if (((SymbolTable_GetScope (scope)) != SymbolTable_NulSym) && ((SymbolTable_IsProcedure (SymbolTable_GetScope (scope))) || ((SymbolTable_IsModule (scope)) && (SymbolTable_IsModuleWithinProcedure (scope)))))
266 : : {
267 : 636 : SymbolTable_GetProcedureQuads (SymbolTable_GetProcedureScope (scope), &i, &start, &end);
268 : 636 : M2Quads_GetQuad (i, &op, &op1, &op2, &op3);
269 : 2886 : while ((op != M2Quads_ModuleScopeOp) || (op3 != scope))
270 : : {
271 : 1614 : i = M2Quads_GetNextQuad (i);
272 : 1614 : M2Quads_GetQuad (i, &op, &op1, &op2, &op3);
273 : : }
274 : 636 : end = i;
275 : 636 : M2Quads_GetQuad (end, &op, &op1, &op2, &op3);
276 : 7134 : while ((op != M2Quads_FinallyEndOp) || (op3 != scope))
277 : : {
278 : 5862 : end = M2Quads_GetNextQuad (end);
279 : 5862 : M2Quads_GetQuad (end, &op, &op1, &op2, &op3);
280 : : }
281 : : }
282 : : else
283 : : {
284 : 67832 : i = M2Quads_GetFirstQuad ();
285 : 67832 : end = 0;
286 : : }
287 : 68468 : nb = sb;
288 : 68468 : sb->low = 0;
289 : 68468 : sb->high = 0;
290 : 90756880 : for (;;)
291 : : {
292 : 45412674 : if (i == 0)
293 : : {
294 : : if (Debugging)
295 : : {
296 : : DisplayScope (sb);
297 : : }
298 : : return sb;
299 : : }
300 : 45344842 : M2Quads_GetQuad (i, &op, &op1, &op2, &op3);
301 : 45344842 : if (op == M2Quads_ProcedureScopeOp)
302 : : {
303 : 686764 : NestedLevel += 1;
304 : : }
305 : 44658078 : else if (op == M2Quads_ReturnOp)
306 : : {
307 : : /* avoid dangling else. */
308 : 686764 : if (NestedLevel > 0)
309 : : {
310 : 686764 : NestedLevel -= 1;
311 : : }
312 : 686764 : if (NestedLevel == 0)
313 : : {
314 : 685012 : First = true;
315 : : }
316 : : }
317 : 43971314 : else if (NestedLevel == 0)
318 : : {
319 : : /* avoid dangling else. */
320 : 6291362 : if (op == M2Quads_StartDefFileOp)
321 : : {
322 : 528024 : nb = AddToRange (nb, true, i);
323 : 528024 : SetScope (nb, op3, M2Scope_definitionscope);
324 : 528024 : prev = nb;
325 : : }
326 : 5763338 : else if ((op == M2Quads_StartModFileOp) || (op == M2Quads_InitStartOp))
327 : : {
328 : : /* avoid dangling else. */
329 : 551640 : nb = AddToRange (nb, true, i);
330 : 551640 : if (SymbolTable_IsDefImp (op3))
331 : : {
332 : 465352 : SetScope (nb, op3, M2Scope_implementationscope);
333 : : }
334 : : else
335 : : {
336 : 86288 : SetScope (nb, op3, M2Scope_programscope);
337 : : }
338 : : prev = nb;
339 : : }
340 : : else
341 : : {
342 : : /* avoid dangling else. */
343 : 5211698 : nb = AddToRange (nb, First, i);
344 : 5211698 : if (op == M2Quads_InitEndOp)
345 : : {
346 : 277542 : if (SymbolTable_IsDefImp (op3))
347 : : {
348 : 232676 : SetScope (nb, op3, M2Scope_implementationscope);
349 : : }
350 : : else
351 : : {
352 : 44866 : SetScope (nb, op3, M2Scope_programscope);
353 : : }
354 : : prev = nb;
355 : : }
356 : 4934156 : else if (First)
357 : : {
358 : : /* avoid dangling else. */
359 : 17954 : M2Debug_Assert (prev != NULL);
360 : 17954 : SetScope (nb, prev->scopeSym, prev->kindScope);
361 : : }
362 : : }
363 : : First = false;
364 : : }
365 : 45344842 : if (i == end)
366 : : {
367 : : if (Debugging)
368 : : {
369 : : DisplayScope (sb);
370 : : }
371 : : return sb;
372 : : }
373 : 45344206 : i = M2Quads_GetNextQuad (i);
374 : : }
375 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Scope.def", 20, 1);
376 : : __builtin_unreachable ();
377 : : }
378 : :
379 : :
380 : : /*
381 : : GetProcQuads -
382 : : */
383 : :
384 : 540111 : static M2Scope_ScopeBlock GetProcQuads (M2Scope_ScopeBlock sb, unsigned int proc)
385 : : {
386 : 540111 : M2Scope_ScopeBlock nb;
387 : 540111 : unsigned int scope;
388 : 540111 : unsigned int start;
389 : 540111 : unsigned int end;
390 : 540111 : unsigned int i;
391 : 540111 : unsigned int last;
392 : 540111 : M2Quads_QuadOperator op;
393 : 540111 : unsigned int op1;
394 : 540111 : unsigned int op2;
395 : 540111 : unsigned int op3;
396 : 540111 : bool First;
397 : 540111 : M2StackWord_StackOfWord s;
398 : 540111 : NameKey_Name n;
399 : :
400 : 540111 : s = M2StackWord_InitStackWord ();
401 : 540111 : if (Debugging)
402 : : {
403 : : n = SymbolTable_GetSymName (proc);
404 : : M2Printf_printf1 ((const char *) "GetProcQuads for %a\\n", 21, (const unsigned char *) &n, (sizeof (n)-1));
405 : : }
406 : 540111 : M2Debug_Assert (SymbolTable_IsProcedure (proc));
407 : 540111 : SymbolTable_GetProcedureQuads (proc, &scope, &start, &end);
408 : 540111 : if (Debugging)
409 : : {
410 : : M2Printf_printf1 ((const char *) " proc %d\\n", 10, (const unsigned char *) &proc, (sizeof (proc)-1));
411 : : M2Printf_printf1 ((const char *) " scope %d\\n", 11, (const unsigned char *) &scope, (sizeof (scope)-1));
412 : : M2Printf_printf1 ((const char *) " start %d\\n", 11, (const unsigned char *) &start, (sizeof (start)-1));
413 : : M2Printf_printf1 ((const char *) " end %d\\n", 9, (const unsigned char *) &end, (sizeof (end)-1));
414 : : }
415 : 540111 : M2StackWord_PushWord (s, static_cast<unsigned int> (0));
416 : 540111 : First = false;
417 : 540111 : i = scope;
418 : 540111 : last = scope;
419 : 540111 : nb = sb;
420 : 540111 : sb->low = scope;
421 : 540111 : sb->high = 0;
422 : 540111 : SetScope (sb, proc, M2Scope_procedurescope);
423 : 13760874 : while ((i <= end) && (start != 0))
424 : : {
425 : 13220763 : M2Quads_GetQuad (i, &op, &op1, &op2, &op3);
426 : 13220763 : if ((op == M2Quads_ProcedureScopeOp) || (op == M2Quads_ModuleScopeOp))
427 : : {
428 : 273591 : if (((M2StackWord_PeepWord (s, 1)) == proc) && (op3 == proc))
429 : : {
430 : 0 : nb = AddToRange (nb, First, last);
431 : 0 : First = false;
432 : : }
433 : 273591 : M2StackWord_PushWord (s, op3);
434 : 273591 : if (op == M2Quads_ProcedureScopeOp)
435 : : {
436 : 273045 : SetScope (nb, proc, M2Scope_procedurescope);
437 : : }
438 : : else
439 : : {
440 : 546 : SetScope (nb, proc, M2Scope_modulescope);
441 : : }
442 : : }
443 : 12947172 : else if ((op == M2Quads_ReturnOp) || (op == M2Quads_FinallyEndOp))
444 : : {
445 : : /* avoid dangling else. */
446 : 273591 : op3 = static_cast<unsigned int> (M2StackWord_PopWord (s));
447 : 273591 : if ((M2StackWord_PeepWord (s, 1)) == proc)
448 : : {
449 : 13220763 : First = true;
450 : : }
451 : : }
452 : : else
453 : : {
454 : : /* avoid dangling else. */
455 : 12673581 : if ((M2StackWord_PeepWord (s, 1)) == proc)
456 : : {
457 : 12649935 : nb = AddToRange (nb, First, i);
458 : 12649935 : First = false;
459 : : }
460 : : }
461 : 13220763 : last = i;
462 : 13220763 : i = M2Quads_GetNextQuad (i);
463 : : }
464 : 540111 : if (start <= nb->high)
465 : : {
466 : 540111 : nb->high = end;
467 : : }
468 : : else
469 : : {
470 : 0 : nb->next = M2Scope_InitScopeBlock (SymbolTable_NulSym);
471 : 0 : nb = nb->next;
472 : 0 : SetScope (nb, proc, M2Scope_unsetscope);
473 : 0 : nb->low = start;
474 : 0 : nb->high = end;
475 : : }
476 : 540111 : s = M2StackWord_KillStackWord (s);
477 : 540111 : return sb;
478 : : /* static analysis guarentees a RETURN statement will be used before here. */
479 : : __builtin_unreachable ();
480 : : }
481 : :
482 : :
483 : : /*
484 : : DisplayScope -
485 : : */
486 : :
487 : 0 : static void DisplayScope (M2Scope_ScopeBlock sb)
488 : : {
489 : 0 : NameKey_Name name;
490 : :
491 : 0 : M2Printf_printf0 ((const char *) "scope: ", 7);
492 : 0 : switch (sb->kindScope)
493 : : {
494 : 0 : case M2Scope_unsetscope:
495 : 0 : M2Printf_printf0 ((const char *) "unset", 5);
496 : 0 : break;
497 : :
498 : 0 : case M2Scope_ignorescope:
499 : 0 : M2Printf_printf0 ((const char *) "ignore", 6);
500 : 0 : break;
501 : :
502 : 0 : case M2Scope_procedurescope:
503 : 0 : name = SymbolTable_GetSymName (sb->scopeSym);
504 : 0 : M2Printf_printf1 ((const char *) "procedure %a", 12, (const unsigned char *) &name, (sizeof (name)-1));
505 : 0 : break;
506 : :
507 : 0 : case M2Scope_modulescope:
508 : 0 : name = SymbolTable_GetSymName (sb->scopeSym);
509 : 0 : M2Printf_printf1 ((const char *) "inner module %a", 15, (const unsigned char *) &name, (sizeof (name)-1));
510 : 0 : break;
511 : :
512 : 0 : case M2Scope_definitionscope:
513 : 0 : name = SymbolTable_GetSymName (sb->scopeSym);
514 : 0 : M2Printf_printf1 ((const char *) "definition module %a", 20, (const unsigned char *) &name, (sizeof (name)-1));
515 : 0 : break;
516 : :
517 : 0 : case M2Scope_implementationscope:
518 : 0 : name = SymbolTable_GetSymName (sb->scopeSym);
519 : 0 : M2Printf_printf1 ((const char *) "implementation module %a", 24, (const unsigned char *) &name, (sizeof (name)-1));
520 : 0 : break;
521 : :
522 : 0 : case M2Scope_programscope:
523 : 0 : name = SymbolTable_GetSymName (sb->scopeSym);
524 : 0 : M2Printf_printf1 ((const char *) "program module %a", 17, (const unsigned char *) &name, (sizeof (name)-1));
525 : 0 : break;
526 : :
527 : :
528 : 0 : default:
529 : 0 : CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Scope.def", 20, 1);
530 : 0 : __builtin_unreachable ();
531 : : }
532 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
533 : 0 : M2Quads_DisplayQuadRange (sb->scopeSym, sb->low, sb->high);
534 : 0 : if (sb->next != NULL)
535 : : {
536 : 0 : DisplayScope (sb->next);
537 : : }
538 : 0 : }
539 : :
540 : :
541 : : /*
542 : : enter -
543 : : */
544 : :
545 : 3644451 : static void enter (M2Scope_ScopeBlock sb)
546 : : {
547 : 3644451 : switch (sb->kindScope)
548 : : {
549 : : case M2Scope_unsetscope:
550 : : case M2Scope_ignorescope:
551 : : break;
552 : :
553 : 3499087 : case M2Scope_procedurescope:
554 : 3499087 : case M2Scope_modulescope:
555 : 3499087 : case M2Scope_definitionscope:
556 : 3499087 : case M2Scope_implementationscope:
557 : 3499087 : case M2Scope_programscope:
558 : 3499087 : M2Error_EnterErrorScope (SymbolTable_GetErrorScope (sb->scopeSym));
559 : 3499087 : break;
560 : :
561 : :
562 : 0 : default:
563 : 0 : CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Scope.def", 20, 1);
564 : 0 : __builtin_unreachable ();
565 : : }
566 : 3644451 : }
567 : :
568 : :
569 : : /*
570 : : leave -
571 : : */
572 : :
573 : 3644385 : static void leave (M2Scope_ScopeBlock sb)
574 : : {
575 : 0 : switch (sb->kindScope)
576 : : {
577 : : case M2Scope_unsetscope:
578 : : case M2Scope_ignorescope:
579 : : break;
580 : :
581 : :
582 : 3499021 : default:
583 : 3499021 : M2Error_LeaveErrorScope ();
584 : 3499021 : break;
585 : : }
586 : 0 : }
587 : :
588 : :
589 : : /*
590 : : Init - initializes the global variables for this module.
591 : : */
592 : :
593 : 0 : static void Init (void)
594 : : {
595 : 0 : FreeList = NULL;
596 : 0 : }
597 : :
598 : :
599 : : /*
600 : : InitScopeBlock -
601 : : */
602 : :
603 : 1707805 : extern "C" M2Scope_ScopeBlock M2Scope_InitScopeBlock (unsigned int scope)
604 : : {
605 : 1707805 : M2Scope_ScopeBlock sb;
606 : :
607 : 1707805 : New (&sb);
608 : 1707805 : sb->next = NULL;
609 : 1707805 : sb->kindScope = M2Scope_unsetscope;
610 : 1707805 : if (scope == SymbolTable_NulSym)
611 : : {
612 : 1099226 : sb->low = 0;
613 : 1099226 : sb->high = 0;
614 : : }
615 : : else
616 : : {
617 : 608579 : if (SymbolTable_IsProcedure (scope))
618 : : {
619 : 540111 : sb = GetProcQuads (sb, scope);
620 : : }
621 : : else
622 : : {
623 : 68468 : sb = GetGlobalQuads (sb, scope);
624 : : }
625 : : if (TraceQuadruples)
626 : : {
627 : : DisplayScope (sb);
628 : : }
629 : : }
630 : 1707805 : return sb;
631 : : /* static analysis guarentees a RETURN statement will be used before here. */
632 : : __builtin_unreachable ();
633 : : }
634 : :
635 : :
636 : : /*
637 : : KillScopeBlock - destroys the ScopeBlock sb and assign sb to NIL.
638 : : */
639 : :
640 : 608507 : extern "C" void M2Scope_KillScopeBlock (M2Scope_ScopeBlock *sb)
641 : : {
642 : 608507 : M2Scope_ScopeBlock t;
643 : :
644 : 608507 : t = (*sb);
645 : 2315880 : while (t != NULL)
646 : : {
647 : 1707373 : (*sb) = t;
648 : 1707373 : t = t->next;
649 : 1707373 : Dispose (sb);
650 : : }
651 : 608507 : (*sb) = NULL;
652 : 608507 : }
653 : :
654 : :
655 : : /*
656 : : ForeachScopeBlockDo2 - calls a procedure p for each block of contigeous quadruples
657 : : defining an outer scope sb.
658 : : */
659 : :
660 : 298085 : extern "C" void M2Scope_ForeachScopeBlockDo2 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure2 p)
661 : : {
662 : 298085 : if (TraceQuadruples)
663 : : {
664 : : M2Printf_printf0 ((const char *) "ForeachScopeBlockDo\\n", 21);
665 : : }
666 : 1128754 : while (sb != NULL)
667 : : {
668 : 830675 : if (TraceQuadruples)
669 : : {
670 : : DisplayScope (sb);
671 : : }
672 : 830675 : enter (sb);
673 : 830675 : if ((sb->low != 0) && (sb->high != 0))
674 : : {
675 : 647347 : (*p.proc) (sb->low, sb->high);
676 : : }
677 : 830669 : leave (sb);
678 : 830669 : sb = sb->next;
679 : : }
680 : 298079 : if (TraceQuadruples)
681 : : {
682 : : M2Printf_printf0 ((const char *) "end ForeachScopeBlockDo\\n\\n", 27);
683 : : }
684 : 298079 : }
685 : :
686 : :
687 : : /*
688 : : ForeachScopeBlockDo3 - calls a procedure p for each block of contigeous quadruples
689 : : defining an outer scope sb.
690 : : */
691 : :
692 : 1062340 : extern "C" void M2Scope_ForeachScopeBlockDo3 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure3 p)
693 : : {
694 : 1062340 : if (TraceQuadruples)
695 : : {
696 : : M2Printf_printf0 ((const char *) "ForeachScopeBlockDo\\n", 21);
697 : : }
698 : 3876056 : while (sb != NULL)
699 : : {
700 : 2813776 : if (TraceQuadruples)
701 : : {
702 : : DisplayScope (sb);
703 : : }
704 : 2813776 : enter (sb);
705 : 2813776 : if ((sb->low != 0) && (sb->high != 0))
706 : : {
707 : 2231874 : (*p.proc) (sb->scopeSym, sb->low, sb->high);
708 : : }
709 : 2813716 : leave (sb);
710 : 2813716 : sb = sb->next;
711 : : }
712 : 1062280 : if (TraceQuadruples)
713 : : {
714 : : M2Printf_printf0 ((const char *) "end ForeachScopeBlockDo\\n\\n", 27);
715 : : }
716 : 1062280 : }
717 : :
718 : 0 : extern "C" void _M2_M2Scope_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
719 : : {
720 : 0 : Init ();
721 : 0 : }
722 : :
723 : 0 : extern "C" void _M2_M2Scope_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
724 : : {
725 : 0 : }
|