Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2Batch. */
2 : : /* M2Batch.mod implements a queue for modules pending compilation.
3 : :
4 : : Copyright (C) 2001-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 : : # include "GStorage.h"
33 : : # include "Gmcrts.h"
34 : : #if defined(__cplusplus)
35 : : # undef NULL
36 : : # define NULL 0
37 : : #endif
38 : : #define _M2Batch_H
39 : : #define _M2Batch_C
40 : :
41 : : # include "GM2Debug.h"
42 : : # include "GSymbolTable.h"
43 : : # include "GNameKey.h"
44 : : # include "GM2Printf.h"
45 : : # include "GM2Error.h"
46 : : # include "GM2MetaError.h"
47 : : # include "GIndexing.h"
48 : : # include "GLists.h"
49 : : # include "GStorage.h"
50 : : # include "GDynamicStrings.h"
51 : : # include "GM2Pass.h"
52 : :
53 : : typedef struct M2Batch_DoProcedure_p M2Batch_DoProcedure;
54 : :
55 : : typedef struct M2Batch__T1_r M2Batch__T1;
56 : :
57 : : typedef M2Batch__T1 *M2Batch_Module;
58 : :
59 : : typedef void (*M2Batch_DoProcedure_t) (unsigned int);
60 : : struct M2Batch_DoProcedure_p { M2Batch_DoProcedure_t proc; };
61 : :
62 : : struct M2Batch__T1_r {
63 : : unsigned int SymNo;
64 : : NameKey_Name Key;
65 : : DynamicStrings_String DefFile;
66 : : DynamicStrings_String ModFile;
67 : : };
68 : :
69 : : static Indexing_Index SeenList;
70 : : static Lists_List PendingQueue;
71 : :
72 : : /*
73 : : MakeDefinitionSource - is given a Name, n, which is used to create a Definition
74 : : module.
75 : : The Definition Module will be placed onto the
76 : : compilation pending queue if it has not yet been
77 : : compiled.
78 : : If the module has been compiled then no action is
79 : : taken. The Module Sym is returned.
80 : : */
81 : :
82 : : extern "C" unsigned int M2Batch_MakeDefinitionSource (unsigned int tok, NameKey_Name n);
83 : :
84 : : /*
85 : : MakeImplementationSource - is given a Name, n, which is used to create an
86 : : implementation module.
87 : : The implementation Module will be placed onto
88 : : the compilation pending
89 : : queue if it has not yet been compiled.
90 : : If the module has been compiled then no
91 : : action is taken. The Module Sym is returned.
92 : : */
93 : :
94 : : extern "C" unsigned int M2Batch_MakeImplementationSource (unsigned int tok, NameKey_Name n);
95 : :
96 : : /*
97 : : MakeProgramSource - is given a Name, n, which is used to create a program module.
98 : : The program module will be placed onto the compilation
99 : : pending queue if it has not yet been compiled.
100 : : If the module has been compiled then no action is taken.
101 : : The Module Sym is returned.
102 : : */
103 : :
104 : : extern "C" unsigned int M2Batch_MakeProgramSource (unsigned int tok, NameKey_Name n);
105 : :
106 : : /*
107 : : GetSource - returns with the symbol Sym of the next module to be compiled.
108 : : If Sym returns with value 0 then no module should be compiled.
109 : : */
110 : :
111 : : extern "C" unsigned int M2Batch_GetSource (void);
112 : :
113 : : /*
114 : : GetModuleNo - returns with symbol number of the nth module read during Pass 1.
115 : : */
116 : :
117 : : extern "C" unsigned int M2Batch_GetModuleNo (unsigned int nth);
118 : :
119 : : /*
120 : : IsModuleKnown - returns TRUE if the Name n matches a module.
121 : : */
122 : :
123 : : extern "C" bool M2Batch_IsModuleKnown (NameKey_Name n);
124 : :
125 : : /*
126 : : AssociateDefinition - associate the source file, filename, with the definition module,
127 : : Sym.
128 : : */
129 : :
130 : : extern "C" DynamicStrings_String M2Batch_AssociateDefinition (DynamicStrings_String filename, unsigned int Sym);
131 : :
132 : : /*
133 : : GetDefinitionModuleFile - returns the filename associated with the definition module, Sym.
134 : : It may return a temporary preprocessed file.
135 : : */
136 : :
137 : : extern "C" DynamicStrings_String M2Batch_GetDefinitionModuleFile (unsigned int Sym);
138 : :
139 : : /*
140 : : AssociateModule - associate the source file, filename, with the implementation/program
141 : : module, Sym.
142 : : */
143 : :
144 : : extern "C" DynamicStrings_String M2Batch_AssociateModule (DynamicStrings_String filename, unsigned int Sym);
145 : :
146 : : /*
147 : : GetModuleFile - returns the filename associated with the implementation/program module, Sym.
148 : : It may return a temporary preprocessed file.
149 : : */
150 : :
151 : : extern "C" DynamicStrings_String M2Batch_GetModuleFile (unsigned int Sym);
152 : :
153 : : /*
154 : : ForeachSourceModuleDo - for each source file call procedure, p.
155 : : */
156 : :
157 : : extern "C" void M2Batch_ForeachSourceModuleDo (M2Batch_DoProcedure p);
158 : :
159 : : /*
160 : : IsSourceSeen - returns TRUE if the source for the program module or
161 : : implementation module has been seen.
162 : : */
163 : :
164 : : extern "C" bool M2Batch_IsSourceSeen (unsigned int sym);
165 : :
166 : : /*
167 : : IsModuleSeen - returns TRUE if the source for module, name, has been seen.
168 : : */
169 : :
170 : : extern "C" bool M2Batch_IsModuleSeen (NameKey_Name n);
171 : :
172 : : /*
173 : : LookupModule - looks up a module in the current scope, if a module does not exist
174 : : then it creates a DefImp module.
175 : : */
176 : :
177 : : extern "C" unsigned int M2Batch_LookupModule (unsigned int tok, NameKey_Name n);
178 : :
179 : : /*
180 : : LookupOuterModule - looks up a module in the order of: current scope, then outer scope, finally if a
181 : : module does not exist then it creates a DefImp module.
182 : : */
183 : :
184 : : extern "C" unsigned int M2Batch_LookupOuterModule (unsigned int tok, NameKey_Name n);
185 : :
186 : : /*
187 : : Get - returns the module symbol matching name n.
188 : : */
189 : :
190 : : extern "C" unsigned int M2Batch_Get (NameKey_Name n);
191 : :
192 : : /*
193 : : DisplayModules - a debugging routine to textually emit the names of modules in the SeenList.
194 : : */
195 : :
196 : : extern "C" void M2Batch_DisplayModules (void);
197 : :
198 : : /*
199 : : Get - returns the module symbol matching name n.
200 : : */
201 : :
202 : : static void Put (unsigned int Sym, NameKey_Name n);
203 : :
204 : : /*
205 : : Get - returns the module symbol matching name n.
206 : : */
207 : :
208 : : static void Push (unsigned int Sym);
209 : :
210 : : /*
211 : : Get - returns the module symbol matching name n.
212 : : */
213 : :
214 : : static unsigned int Pop (void);
215 : :
216 : :
217 : : /*
218 : : Get - returns the module symbol matching name n.
219 : : */
220 : :
221 : 130008 : static void Put (unsigned int Sym, NameKey_Name n)
222 : : {
223 : 130008 : M2Batch_Module m;
224 : :
225 : 130008 : Storage_ALLOCATE ((void **) &m, sizeof (M2Batch__T1));
226 : 130008 : Indexing_IncludeIndiceIntoIndex (SeenList, reinterpret_cast<void *> (m));
227 : 130008 : m->SymNo = Sym;
228 : 130008 : m->Key = n;
229 : 130008 : m->DefFile = static_cast<DynamicStrings_String> (NULL);
230 : 130008 : m->ModFile = static_cast<DynamicStrings_String> (NULL);
231 : 130008 : }
232 : :
233 : :
234 : : /*
235 : : Get - returns the module symbol matching name n.
236 : : */
237 : :
238 : 130008 : static void Push (unsigned int Sym)
239 : : {
240 : 0 : Lists_IncludeItemIntoList (PendingQueue, Sym);
241 : 130008 : }
242 : :
243 : :
244 : : /*
245 : : Get - returns the module symbol matching name n.
246 : : */
247 : :
248 : 0 : static unsigned int Pop (void)
249 : : {
250 : 0 : unsigned int n;
251 : 0 : unsigned int Sym;
252 : :
253 : 0 : n = Lists_NoOfItemsInList (PendingQueue);
254 : 0 : if (n == 0)
255 : : {
256 : : return SymbolTable_NulSym;
257 : : }
258 : : else
259 : : {
260 : 0 : Sym = static_cast<unsigned int> (Lists_GetItemFromList (PendingQueue, n));
261 : 0 : Lists_RemoveItemFromList (PendingQueue, Sym);
262 : 0 : return Sym;
263 : : }
264 : : /* static analysis guarentees a RETURN statement will be used before here. */
265 : : __builtin_unreachable ();
266 : : }
267 : :
268 : :
269 : : /*
270 : : MakeDefinitionSource - is given a Name, n, which is used to create a Definition
271 : : module.
272 : : The Definition Module will be placed onto the
273 : : compilation pending queue if it has not yet been
274 : : compiled.
275 : : If the module has been compiled then no action is
276 : : taken. The Module Sym is returned.
277 : : */
278 : :
279 : 7440929 : extern "C" unsigned int M2Batch_MakeDefinitionSource (unsigned int tok, NameKey_Name n)
280 : : {
281 : 7440929 : unsigned int Sym;
282 : :
283 : 7440929 : Sym = M2Batch_Get (n);
284 : 7440929 : if (Sym == SymbolTable_NulSym)
285 : : {
286 : 117106 : M2Debug_Assert ((((! (M2Pass_IsPass1 ())) && (! (M2Pass_IsPass2 ()))) && (! (M2Pass_IsPass3 ()))) && (! (M2Pass_IsPassC ())));
287 : : /* Neither been compiled or on the Pending Queue */
288 : 117106 : Sym = SymbolTable_MakeDefImp (tok, n);
289 : 117106 : Put (Sym, n);
290 : 117106 : Push (Sym);
291 : : }
292 : : else
293 : : {
294 : 7323823 : SymbolTable_PutDeclared (tok, Sym);
295 : : }
296 : 7440929 : return Sym;
297 : : /* static analysis guarentees a RETURN statement will be used before here. */
298 : : __builtin_unreachable ();
299 : : }
300 : :
301 : :
302 : : /*
303 : : MakeImplementationSource - is given a Name, n, which is used to create an
304 : : implementation module.
305 : : The implementation Module will be placed onto
306 : : the compilation pending
307 : : queue if it has not yet been compiled.
308 : : If the module has been compiled then no
309 : : action is taken. The Module Sym is returned.
310 : : */
311 : :
312 : 247338 : extern "C" unsigned int M2Batch_MakeImplementationSource (unsigned int tok, NameKey_Name n)
313 : : {
314 : 247338 : unsigned int Sym;
315 : :
316 : 247338 : Sym = M2Batch_Get (n);
317 : 247338 : if (Sym == SymbolTable_NulSym)
318 : : {
319 : 2494 : M2Debug_Assert ((((! (M2Pass_IsPass1 ())) && (! (M2Pass_IsPass2 ()))) && (! (M2Pass_IsPass3 ()))) && (! (M2Pass_IsPassC ())));
320 : : /* Neither been compiled or on the Pending Queue */
321 : 2494 : Sym = SymbolTable_MakeDefImp (tok, n);
322 : 2494 : Put (Sym, n);
323 : 2494 : Push (Sym);
324 : : }
325 : : else
326 : : {
327 : 244844 : SymbolTable_PutDeclared (tok, Sym);
328 : : }
329 : 247338 : return Sym;
330 : : /* static analysis guarentees a RETURN statement will be used before here. */
331 : : __builtin_unreachable ();
332 : : }
333 : :
334 : :
335 : : /*
336 : : MakeProgramSource - is given a Name, n, which is used to create a program module.
337 : : The program module will be placed onto the compilation
338 : : pending queue if it has not yet been compiled.
339 : : If the module has been compiled then no action is taken.
340 : : The Module Sym is returned.
341 : : */
342 : :
343 : 62232 : extern "C" unsigned int M2Batch_MakeProgramSource (unsigned int tok, NameKey_Name n)
344 : : {
345 : 62232 : unsigned int Sym;
346 : :
347 : 62232 : Sym = M2Batch_Get (n);
348 : 62232 : if (Sym == SymbolTable_NulSym)
349 : : {
350 : 10408 : M2Debug_Assert ((((! (M2Pass_IsPass1 ())) && (! (M2Pass_IsPass2 ()))) && (! (M2Pass_IsPass3 ()))) && (! (M2Pass_IsPassC ())));
351 : : /* Neither been compiled or on the Pending Queue */
352 : 10408 : Sym = SymbolTable_MakeModule (tok, n);
353 : 10408 : Put (Sym, n);
354 : 10408 : Push (Sym);
355 : : }
356 : : else
357 : : {
358 : 51824 : SymbolTable_PutDeclared (tok, Sym);
359 : : }
360 : 62232 : return Sym;
361 : : /* static analysis guarentees a RETURN statement will be used before here. */
362 : : __builtin_unreachable ();
363 : : }
364 : :
365 : :
366 : : /*
367 : : GetSource - returns with the symbol Sym of the next module to be compiled.
368 : : If Sym returns with value 0 then no module should be compiled.
369 : : */
370 : :
371 : 0 : extern "C" unsigned int M2Batch_GetSource (void)
372 : : {
373 : 0 : return Pop ();
374 : : /* static analysis guarentees a RETURN statement will be used before here. */
375 : : __builtin_unreachable ();
376 : : }
377 : :
378 : :
379 : : /*
380 : : GetModuleNo - returns with symbol number of the nth module read during Pass 1.
381 : : */
382 : :
383 : 651483 : extern "C" unsigned int M2Batch_GetModuleNo (unsigned int nth)
384 : : {
385 : 651483 : M2Batch_Module m;
386 : :
387 : 651483 : M2Debug_Assert (nth != 0);
388 : 651483 : if (Indexing_InBounds (SeenList, nth))
389 : : {
390 : 587203 : m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, nth));
391 : 587203 : return m->SymNo;
392 : : }
393 : : else
394 : : {
395 : : return SymbolTable_NulSym;
396 : : }
397 : : /* static analysis guarentees a RETURN statement will be used before here. */
398 : : __builtin_unreachable ();
399 : : }
400 : :
401 : :
402 : : /*
403 : : IsModuleKnown - returns TRUE if the Name n matches a module.
404 : : */
405 : :
406 : 0 : extern "C" bool M2Batch_IsModuleKnown (NameKey_Name n)
407 : : {
408 : 0 : return (M2Batch_Get (n)) != SymbolTable_NulSym;
409 : : /* static analysis guarentees a RETURN statement will be used before here. */
410 : : __builtin_unreachable ();
411 : : }
412 : :
413 : :
414 : : /*
415 : : AssociateDefinition - associate the source file, filename, with the definition module,
416 : : Sym.
417 : : */
418 : :
419 : 107411 : extern "C" DynamicStrings_String M2Batch_AssociateDefinition (DynamicStrings_String filename, unsigned int Sym)
420 : : {
421 : 107411 : unsigned int no;
422 : 107411 : unsigned int i;
423 : 107411 : M2Batch_Module m;
424 : :
425 : 107411 : i = 1;
426 : 107411 : no = Indexing_HighIndice (SeenList);
427 : 1156309 : while (i <= no)
428 : : {
429 : 1048898 : m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
430 : 1048898 : if (m->SymNo == Sym)
431 : : {
432 : 107411 : m->DefFile = filename;
433 : 107411 : return filename;
434 : : }
435 : : else
436 : : {
437 : 941487 : i += 1;
438 : : }
439 : : }
440 : 0 : M2Error_InternalError ((const char *) "failed to find module sym", 25);
441 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Batch.def", 20, 1);
442 : : __builtin_unreachable ();
443 : : }
444 : :
445 : :
446 : : /*
447 : : GetDefinitionModuleFile - returns the filename associated with the definition module, Sym.
448 : : It may return a temporary preprocessed file.
449 : : */
450 : :
451 : 469374 : extern "C" DynamicStrings_String M2Batch_GetDefinitionModuleFile (unsigned int Sym)
452 : : {
453 : 469374 : unsigned int no;
454 : 469374 : unsigned int i;
455 : 469374 : M2Batch_Module m;
456 : :
457 : 469374 : i = 1;
458 : 469374 : no = Indexing_HighIndice (SeenList);
459 : 4821366 : while (i <= no)
460 : : {
461 : 4351992 : m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
462 : 4351992 : if (m->SymNo == Sym)
463 : : {
464 : 469374 : return m->DefFile;
465 : : }
466 : : else
467 : : {
468 : 3882618 : i += 1;
469 : : }
470 : : }
471 : : return static_cast<DynamicStrings_String> (NULL);
472 : : /* static analysis guarentees a RETURN statement will be used before here. */
473 : : __builtin_unreachable ();
474 : : }
475 : :
476 : :
477 : : /*
478 : : AssociateModule - associate the source file, filename, with the implementation/program
479 : : module, Sym.
480 : : */
481 : :
482 : 59456 : extern "C" DynamicStrings_String M2Batch_AssociateModule (DynamicStrings_String filename, unsigned int Sym)
483 : : {
484 : 59456 : unsigned int no;
485 : 59456 : unsigned int i;
486 : 59456 : M2Batch_Module m;
487 : :
488 : 59456 : i = 1;
489 : 59456 : no = Indexing_HighIndice (SeenList);
490 : 711224 : while (i <= no)
491 : : {
492 : 651768 : m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
493 : 651768 : if (m->SymNo == Sym)
494 : : {
495 : 59456 : m->ModFile = filename;
496 : 59456 : return filename;
497 : : }
498 : : else
499 : : {
500 : 592312 : i += 1;
501 : : }
502 : : }
503 : 0 : M2Error_InternalError ((const char *) "failed to find module sym", 25);
504 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Batch.def", 20, 1);
505 : : __builtin_unreachable ();
506 : : }
507 : :
508 : :
509 : : /*
510 : : GetModuleFile - returns the filename associated with the implementation/program module, Sym.
511 : : It may return a temporary preprocessed file.
512 : : */
513 : :
514 : 481728 : extern "C" DynamicStrings_String M2Batch_GetModuleFile (unsigned int Sym)
515 : : {
516 : 481728 : unsigned int no;
517 : 481728 : unsigned int i;
518 : 481728 : M2Batch_Module m;
519 : :
520 : 481728 : i = 1;
521 : 481728 : no = Indexing_HighIndice (SeenList);
522 : 4959150 : while (i <= no)
523 : : {
524 : 4477422 : m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
525 : 4477422 : if (m->SymNo == Sym)
526 : : {
527 : 481728 : return m->ModFile;
528 : : }
529 : : else
530 : : {
531 : 3995694 : i += 1;
532 : : }
533 : : }
534 : : return static_cast<DynamicStrings_String> (NULL);
535 : : /* static analysis guarentees a RETURN statement will be used before here. */
536 : : __builtin_unreachable ();
537 : : }
538 : :
539 : :
540 : : /*
541 : : ForeachSourceModuleDo - for each source file call procedure, p.
542 : : */
543 : :
544 : 96 : extern "C" void M2Batch_ForeachSourceModuleDo (M2Batch_DoProcedure p)
545 : : {
546 : 96 : unsigned int i;
547 : 96 : unsigned int no;
548 : 96 : M2Batch_Module m;
549 : :
550 : 96 : i = 1;
551 : 96 : no = Indexing_HighIndice (SeenList);
552 : 2328 : while (i <= no)
553 : : {
554 : 2136 : m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
555 : 2136 : if (m->ModFile != NULL)
556 : : {
557 : 1632 : (*p.proc) (m->SymNo);
558 : : }
559 : 2136 : i += 1;
560 : : }
561 : 96 : }
562 : :
563 : :
564 : : /*
565 : : IsSourceSeen - returns TRUE if the source for the program module or
566 : : implementation module has been seen.
567 : : */
568 : :
569 : 1482 : extern "C" bool M2Batch_IsSourceSeen (unsigned int sym)
570 : : {
571 : 2964 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
572 : 1482 : return (M2Batch_GetModuleFile (sym)) != NULL;
573 : : /* static analysis guarentees a RETURN statement will be used before here. */
574 : : __builtin_unreachable ();
575 : : }
576 : :
577 : :
578 : : /*
579 : : IsModuleSeen - returns TRUE if the source for module, name, has been seen.
580 : : */
581 : :
582 : 0 : extern "C" bool M2Batch_IsModuleSeen (NameKey_Name n)
583 : : {
584 : 0 : return (M2Batch_Get (n)) != SymbolTable_NulSym;
585 : : /* static analysis guarentees a RETURN statement will be used before here. */
586 : : __builtin_unreachable ();
587 : : }
588 : :
589 : :
590 : : /*
591 : : LookupModule - looks up a module in the current scope, if a module does not exist
592 : : then it creates a DefImp module.
593 : : */
594 : :
595 : 1004124 : extern "C" unsigned int M2Batch_LookupModule (unsigned int tok, NameKey_Name n)
596 : : {
597 : 1004124 : unsigned int sym;
598 : :
599 : 1004124 : sym = SymbolTable_GetSym (n);
600 : 1004124 : if (sym == SymbolTable_NulSym)
601 : : {
602 : 992096 : return M2Batch_MakeDefinitionSource (tok, n);
603 : : }
604 : 12028 : else if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
605 : : {
606 : : /* avoid dangling else. */
607 : 11274 : return sym;
608 : : }
609 : : else
610 : : {
611 : : /* avoid dangling else. */
612 : 754 : return M2Batch_MakeDefinitionSource (tok, n);
613 : : }
614 : : /* static analysis guarentees a RETURN statement will be used before here. */
615 : : __builtin_unreachable ();
616 : : }
617 : :
618 : :
619 : : /*
620 : : LookupOuterModule - looks up a module in the order of: current scope, then outer scope, finally if a
621 : : module does not exist then it creates a DefImp module.
622 : : */
623 : :
624 : 75356 : extern "C" unsigned int M2Batch_LookupOuterModule (unsigned int tok, NameKey_Name n)
625 : : {
626 : 75356 : unsigned int outer;
627 : 75356 : unsigned int sym;
628 : :
629 : 75356 : sym = SymbolTable_GetSym (n);
630 : 75356 : if (sym == SymbolTable_NulSym)
631 : : {
632 : 74593 : outer = SymbolTable_GetScope (SymbolTable_GetCurrentScope ());
633 : 74593 : if (outer != SymbolTable_NulSym)
634 : : {
635 : 264 : sym = SymbolTable_GetLocalSym (outer, n);
636 : : }
637 : 74593 : if (sym == SymbolTable_NulSym)
638 : : {
639 : : /* not a local module, so it must be refering to a definition module. */
640 : 74449 : sym = M2Batch_MakeDefinitionSource (tok, n);
641 : : }
642 : : }
643 : 75356 : if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
644 : : {
645 : 75321 : return sym;
646 : : }
647 : : else
648 : : {
649 : 35 : return M2Batch_MakeDefinitionSource (tok, n);
650 : : }
651 : : /* static analysis guarentees a RETURN statement will be used before here. */
652 : : __builtin_unreachable ();
653 : : }
654 : :
655 : :
656 : : /*
657 : : Get - returns the module symbol matching name n.
658 : : */
659 : :
660 : 7750499 : extern "C" unsigned int M2Batch_Get (NameKey_Name n)
661 : : {
662 : 7750499 : unsigned int i;
663 : 7750499 : unsigned int no;
664 : 7750499 : M2Batch_Module m;
665 : :
666 : 7750499 : i = 1;
667 : 7750499 : no = Indexing_HighIndice (SeenList);
668 : 71956790 : while (i <= no)
669 : : {
670 : 64076283 : m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
671 : 64076283 : if (m->Key == n)
672 : : {
673 : 7620491 : return m->SymNo;
674 : : }
675 : : else
676 : : {
677 : 56455792 : i += 1;
678 : : }
679 : : }
680 : : return SymbolTable_NulSym;
681 : : /* static analysis guarentees a RETURN statement will be used before here. */
682 : : __builtin_unreachable ();
683 : : }
684 : :
685 : :
686 : : /*
687 : : DisplayModules - a debugging routine to textually emit the names of modules in the SeenList.
688 : : */
689 : :
690 : 0 : extern "C" void M2Batch_DisplayModules (void)
691 : : {
692 : 0 : M2Batch_Module m;
693 : 0 : unsigned int n;
694 : 0 : unsigned int i;
695 : :
696 : 0 : i = 1;
697 : 0 : n = Indexing_HighIndice (SeenList);
698 : 0 : while (i <= n)
699 : : {
700 : 0 : m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
701 : 0 : M2Printf_printf2 ((const char *) "Module %a %d\\n", 14, (const unsigned char *) &m->Key, (sizeof (m->Key)-1), (const unsigned char *) &i, (sizeof (i)-1));
702 : 0 : i += 1;
703 : : }
704 : 0 : }
705 : :
706 : 12963 : extern "C" void _M2_M2Batch_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
707 : : {
708 : 12963 : Lists_InitList (&PendingQueue);
709 : 12963 : SeenList = Indexing_InitIndex (1);
710 : 12963 : }
711 : :
712 : 0 : extern "C" void _M2_M2Batch_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
713 : : {
714 : 0 : }
|