Line data Source code
1 : /* do not edit automatically generated by mc from SymbolTable. */
2 : /* SymbolTable.mod provides access to the symbol table.
3 :
4 : Copyright (C) 2001-2026 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 "gcc-consolidation.h"
26 :
27 : #include <stdbool.h>
28 : # if !defined (PROC_D)
29 : # define PROC_D
30 : typedef void (*PROC_t) (void);
31 : typedef struct { PROC_t proc; } PROC;
32 : # endif
33 :
34 : # if !defined (TRUE)
35 : # define TRUE (1==1)
36 : # endif
37 :
38 : # if !defined (FALSE)
39 : # define FALSE (1==0)
40 : # endif
41 :
42 : # include "GStorage.h"
43 : # include "Gmcrts.h"
44 : #if defined(__cplusplus)
45 : # undef NULL
46 : # define NULL 0
47 : #endif
48 : #define _SymbolTable_C
49 :
50 : #include "GSymbolTable.h"
51 : # include "GSYSTEM.h"
52 : # include "GStorage.h"
53 : # include "GM2Debug.h"
54 : # include "Glibc.h"
55 : # include "GASCII.h"
56 : # include "GIndexing.h"
57 : # include "GSets.h"
58 : # include "Ggcctypes.h"
59 : # include "GM2Options.h"
60 : # include "GM2LexBuf.h"
61 : # include "GM2ALU.h"
62 : # include "GM2Error.h"
63 : # include "GM2MetaError.h"
64 : # include "GFormatStrings.h"
65 : # include "GM2Printf.h"
66 : # include "GDynamicStrings.h"
67 : # include "GLists.h"
68 : # include "GNameKey.h"
69 : # include "GSymbolKey.h"
70 : # include "GM2Base.h"
71 : # include "GM2System.h"
72 : # include "Gm2expr.h"
73 : # include "Gm2linemap.h"
74 : # include "GStrLib.h"
75 : # include "Gm2builtins.h"
76 : # include "GM2Comp.h"
77 : # include "GM2Scaffold.h"
78 : # include "GM2Diagnostic.h"
79 : # include "GM2SymInit.h"
80 : # include "GM2RTS.h"
81 :
82 : # define SymbolTable_NulSym 0
83 : typedef struct SymbolTable_FamilyOperation_p SymbolTable_FamilyOperation;
84 :
85 : # define DebugUnknowns false
86 : # define DebugUnknownToken false
87 : # define BreakNew 97
88 : # define UnboundedAddressName "_m2_contents"
89 : # define UnboundedHighName "_m2_high_%d"
90 : typedef struct SymbolTable_ProcAnyBoolean_p SymbolTable_ProcAnyBoolean;
91 :
92 : typedef struct SymbolTable_ProcAnyCardinal_p SymbolTable_ProcAnyCardinal;
93 :
94 : typedef struct SymbolTable_LRLists_a SymbolTable_LRLists;
95 :
96 : typedef struct SymbolTable_LRInitDesc_a SymbolTable_LRInitDesc;
97 :
98 : typedef struct SymbolTable_Where_r SymbolTable_Where;
99 :
100 : typedef struct SymbolTable_VarDecl_r SymbolTable_VarDecl;
101 :
102 : typedef struct SymbolTable_PackedInfo_r SymbolTable_PackedInfo;
103 :
104 : typedef struct SymbolTable_ModuleCtor_r SymbolTable_ModuleCtor;
105 :
106 : typedef struct SymbolTable_SymImportStatement_r SymbolTable_SymImportStatement;
107 :
108 : typedef struct SymbolTable_SymImport_r SymbolTable_SymImport;
109 :
110 : typedef struct SymbolTable_SymEquiv_r SymbolTable_SymEquiv;
111 :
112 : typedef struct SymbolTable_SymOAFamily_r SymbolTable_SymOAFamily;
113 :
114 : typedef struct SymbolTable_SymTuple_r SymbolTable_SymTuple;
115 :
116 : typedef struct SymbolTable_SymError_r SymbolTable_SymError;
117 :
118 : typedef struct SymbolTable_SymObject_r SymbolTable_SymObject;
119 :
120 : typedef struct SymbolTable_SymUndefined_r SymbolTable_SymUndefined;
121 :
122 : typedef struct SymbolTable_SymGnuAsm_r SymbolTable_SymGnuAsm;
123 :
124 : typedef struct SymbolTable_SymInterface_r SymbolTable_SymInterface;
125 :
126 : typedef struct SymbolTable_SymVarient_r SymbolTable_SymVarient;
127 :
128 : typedef struct SymbolTable_SymRecord_r SymbolTable_SymRecord;
129 :
130 : typedef struct SymbolTable_SymSubrange_r SymbolTable_SymSubrange;
131 :
132 : typedef struct SymbolTable_SymEnumeration_r SymbolTable_SymEnumeration;
133 :
134 : typedef struct SymbolTable_SymArray_r SymbolTable_SymArray;
135 :
136 : typedef struct SymbolTable_SymSubscript_r SymbolTable_SymSubscript;
137 :
138 : typedef struct SymbolTable_SymUnbounded_r SymbolTable_SymUnbounded;
139 :
140 : typedef struct SymbolTable_SymPartialUnbounded_r SymbolTable_SymPartialUnbounded;
141 :
142 : typedef struct SymbolTable_ProcedureDeclaration_r SymbolTable_ProcedureDeclaration;
143 :
144 : typedef struct SymbolTable_SymProcedure_r SymbolTable_SymProcedure;
145 :
146 : typedef struct SymbolTable_SymProcType_r SymbolTable_SymProcType;
147 :
148 : typedef struct SymbolTable_SymParam_r SymbolTable_SymParam;
149 :
150 : typedef struct SymbolTable_SymVarParam_r SymbolTable_SymVarParam;
151 :
152 : typedef struct SymbolTable_SymConstString_r SymbolTable_SymConstString;
153 :
154 : typedef struct SymbolTable_SymConstLit_r SymbolTable_SymConstLit;
155 :
156 : typedef struct SymbolTable_SymConstVar_r SymbolTable_SymConstVar;
157 :
158 : typedef struct SymbolTable_SymVar_r SymbolTable_SymVar;
159 :
160 : typedef struct SymbolTable_SymType_r SymbolTable_SymType;
161 :
162 : typedef struct SymbolTable_SymPointer_r SymbolTable_SymPointer;
163 :
164 : typedef struct SymbolTable_SymRecordField_r SymbolTable_SymRecordField;
165 :
166 : typedef struct SymbolTable_SymVarientField_r SymbolTable_SymVarientField;
167 :
168 : typedef struct SymbolTable_SymEnumerationField_r SymbolTable_SymEnumerationField;
169 :
170 : typedef struct SymbolTable_SymSet_r SymbolTable_SymSet;
171 :
172 : typedef struct SymbolTable_SymDefImp_r SymbolTable_SymDefImp;
173 :
174 : typedef struct SymbolTable_SymModule_r SymbolTable_SymModule;
175 :
176 : typedef struct SymbolTable_SymDummy_r SymbolTable_SymDummy;
177 :
178 : typedef struct SymbolTable_Symbol_r SymbolTable_Symbol;
179 :
180 : typedef struct SymbolTable_CallFrame_r SymbolTable_CallFrame;
181 :
182 : typedef struct SymbolTable_CheckProcedure_p SymbolTable_CheckProcedure;
183 :
184 : typedef SymbolTable_Symbol *SymbolTable_PtrToSymbol;
185 :
186 : typedef SymbolTable_CallFrame *SymbolTable_PtrToCallFrame;
187 :
188 : typedef struct SymbolTable__T4_r SymbolTable__T4;
189 :
190 : typedef SymbolTable__T4 *SymbolTable_ConstLitPoolEntry;
191 :
192 : typedef struct SymbolTable__T5_r SymbolTable__T5;
193 :
194 : typedef SymbolTable__T5 *SymbolTable_PtrToAsmConstraint;
195 :
196 : typedef struct SymbolTable__T6_a SymbolTable__T6;
197 :
198 : typedef enum {SymbolTable_m2str, SymbolTable_cstr, SymbolTable_m2nulstr, SymbolTable_cnulstr} SymbolTable_ConstStringVariant;
199 :
200 : typedef enum {SymbolTable_RecordSym, SymbolTable_VarientSym, SymbolTable_DummySym, SymbolTable_VarSym, SymbolTable_EnumerationSym, SymbolTable_SubrangeSym, SymbolTable_ArraySym, SymbolTable_ConstStringSym, SymbolTable_ConstVarSym, SymbolTable_ConstLitSym, SymbolTable_VarParamSym, SymbolTable_ParamSym, SymbolTable_PointerSym, SymbolTable_UndefinedSym, SymbolTable_TypeSym, SymbolTable_RecordFieldSym, SymbolTable_VarientFieldSym, SymbolTable_EnumerationFieldSym, SymbolTable_DefImpSym, SymbolTable_ModuleSym, SymbolTable_SetSym, SymbolTable_ProcedureSym, SymbolTable_ProcTypeSym, SymbolTable_SubscriptSym, SymbolTable_UnboundedSym, SymbolTable_GnuAsmSym, SymbolTable_InterfaceSym, SymbolTable_ObjectSym, SymbolTable_PartialUnboundedSym, SymbolTable_TupleSym, SymbolTable_OAFamilySym, SymbolTable_ImportSym, SymbolTable_ImportStatementSym, SymbolTable_EquivSym, SymbolTable_ErrorSym} SymbolTable_TypeOfSymbol;
201 :
202 : typedef bool (*SymbolTable_ProcAnyBoolean_t) (unsigned int, SymbolTable_ProcedureKind);
203 : struct SymbolTable_ProcAnyBoolean_p { SymbolTable_ProcAnyBoolean_t proc; };
204 :
205 : typedef unsigned int (*SymbolTable_ProcAnyCardinal_t) (unsigned int, SymbolTable_ProcedureKind);
206 : struct SymbolTable_ProcAnyCardinal_p { SymbolTable_ProcAnyCardinal_t proc; };
207 :
208 : struct SymbolTable_LRLists_a { Lists_List array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
209 : struct SymbolTable_LRInitDesc_a { M2SymInit_InitDesc array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
210 : struct SymbolTable_Where_r {
211 : unsigned int DefDeclared;
212 : unsigned int FirstUsed;
213 : unsigned int ModDeclared;
214 : };
215 :
216 : struct SymbolTable_VarDecl_r {
217 : unsigned int FullTok;
218 : unsigned int VarTok;
219 : unsigned int TypeTok;
220 : };
221 :
222 : struct SymbolTable_PackedInfo_r {
223 : bool IsPacked;
224 : unsigned int PackedEquiv;
225 : };
226 :
227 : struct SymbolTable_ModuleCtor_r {
228 : unsigned int ctor;
229 : unsigned int init;
230 : unsigned int fini;
231 : unsigned int dep;
232 : };
233 :
234 : struct SymbolTable_SymOAFamily_r {
235 : unsigned int MaxDimensions;
236 : unsigned int SimpleType;
237 : Indexing_Index Dimensions;
238 : };
239 :
240 : struct SymbolTable_SymPartialUnbounded_r {
241 : unsigned int Type;
242 : unsigned int NDim;
243 : };
244 :
245 : struct SymbolTable_ProcedureDeclaration_r {
246 : Lists_List ListOfParam;
247 : bool Defined;
248 : bool ParamDefined;
249 : bool HasVarArgs;
250 : bool HasOptArg;
251 : bool IsNoReturn;
252 : bool ReturnOptional;
253 : unsigned int ReturnTypeTok;
254 : unsigned int ProcedureTok;
255 : };
256 :
257 : struct SymbolTable_SymParam_r {
258 : NameKey_Name name;
259 : unsigned int Type;
260 : bool IsUnbounded;
261 : unsigned int Scope;
262 : unsigned int ShadowVar;
263 : unsigned int FullTok;
264 : unsigned int At;
265 : };
266 :
267 : struct SymbolTable_SymVarParam_r {
268 : NameKey_Name name;
269 : unsigned int Type;
270 : bool IsUnbounded;
271 : unsigned int HeapVar;
272 : unsigned int Scope;
273 : unsigned int ShadowVar;
274 : unsigned int FullTok;
275 : unsigned int At;
276 : };
277 :
278 : struct SymbolTable_SymDummy_r {
279 : unsigned int NextFree;
280 : };
281 :
282 : struct SymbolTable_CallFrame_r {
283 : unsigned int Main;
284 : unsigned int Search;
285 : unsigned int Start;
286 : };
287 :
288 : typedef void (*SymbolTable_CheckProcedure_t) (unsigned int);
289 : struct SymbolTable_CheckProcedure_p { SymbolTable_CheckProcedure_t proc; };
290 :
291 : struct SymbolTable__T4_r {
292 : unsigned int sym;
293 : unsigned int tok;
294 : NameKey_Name constName;
295 : unsigned int constType;
296 : SymbolTable_ConstLitPoolEntry next;
297 : };
298 :
299 : struct SymbolTable__T5_r {
300 : unsigned int tokpos;
301 : NameKey_Name name;
302 : unsigned int str;
303 : unsigned int obj;
304 : };
305 :
306 : struct SymbolTable_SymImportStatement_r {
307 : unsigned int listNo;
308 : Lists_List ListOfImports;
309 : SymbolTable_Where at;
310 : };
311 :
312 : struct SymbolTable_SymImport_r {
313 : unsigned int module;
314 : unsigned int listNo;
315 : bool qualified;
316 : SymbolTable_Where at;
317 : };
318 :
319 : struct SymbolTable_SymEquiv_r {
320 : SymbolTable_PackedInfo packedInfo;
321 : unsigned int nonPacked;
322 : };
323 :
324 : struct SymbolTable_SymTuple_r {
325 : SymbolTable_Where At;
326 : unsigned int nTuple;
327 : Indexing_Index list;
328 : };
329 :
330 : struct SymbolTable_SymError_r {
331 : NameKey_Name name;
332 : unsigned int Scope;
333 : SymbolTable_Where At;
334 : };
335 :
336 : struct SymbolTable_SymObject_r {
337 : NameKey_Name name;
338 : SymbolTable_Where At;
339 : };
340 :
341 : struct SymbolTable_SymUndefined_r {
342 : NameKey_Name name;
343 : unsigned int declScope;
344 : bool onImport;
345 : unsigned int oafamily;
346 : M2Error_ErrorScope errorScope;
347 : SymbolTable_Where At;
348 : };
349 :
350 : struct SymbolTable_SymGnuAsm_r {
351 : unsigned int String;
352 : SymbolTable_Where At;
353 : unsigned int Inputs;
354 : unsigned int Outputs;
355 : unsigned int Trashed;
356 : bool Volatile;
357 : bool Simple;
358 : };
359 :
360 : struct SymbolTable_SymInterface_r {
361 : Indexing_Index Parameters;
362 : SymbolTable_Where At;
363 : };
364 :
365 : struct SymbolTable_SymVarient_r {
366 : M2ALU_PtrToValue Size;
367 : Lists_List ListOfSons;
368 : bool DeclPacked;
369 : bool DeclResolved;
370 : unsigned int Parent;
371 : unsigned int Varient;
372 : unsigned int tag;
373 : unsigned int Scope;
374 : SymbolTable_Where At;
375 : };
376 :
377 : struct SymbolTable_SymRecord_r {
378 : NameKey_Name name;
379 : SymbolKey_SymbolTree LocalSymbols;
380 : M2ALU_PtrToValue Size;
381 : Lists_List ListOfSons;
382 : unsigned int Align;
383 : unsigned int DefaultAlign;
384 : bool DeclPacked;
385 : bool DeclResolved;
386 : unsigned int oafamily;
387 : unsigned int Parent;
388 : unsigned int Scope;
389 : SymbolTable_Where At;
390 : };
391 :
392 : struct SymbolTable_SymSubrange_r {
393 : NameKey_Name name;
394 : unsigned int Low;
395 : unsigned int High;
396 : M2ALU_PtrToValue Size;
397 : unsigned int Type;
398 : unsigned int Align;
399 : SymbolKey_SymbolTree ConstLitTree;
400 : SymbolTable_PackedInfo packedInfo;
401 : unsigned int oafamily;
402 : unsigned int Scope;
403 : SymbolTable_Where At;
404 : };
405 :
406 : struct SymbolTable_SymEnumeration_r {
407 : NameKey_Name name;
408 : unsigned int NoOfElements;
409 : SymbolKey_SymbolTree LocalSymbols;
410 : Lists_List ListOfFields;
411 : M2ALU_PtrToValue Size;
412 : SymbolTable_PackedInfo packedInfo;
413 : unsigned int oafamily;
414 : unsigned int Scope;
415 : SymbolTable_Where At;
416 : };
417 :
418 : struct SymbolTable_SymArray_r {
419 : NameKey_Name name;
420 : unsigned int Subscript;
421 : M2ALU_PtrToValue Size;
422 : M2ALU_PtrToValue Offset;
423 : unsigned int Type;
424 : unsigned int Align;
425 : bool Large;
426 : unsigned int oafamily;
427 : unsigned int Scope;
428 : SymbolTable_Where At;
429 : };
430 :
431 : struct SymbolTable_SymSubscript_r {
432 : unsigned int Type;
433 : M2ALU_PtrToValue Size;
434 : M2ALU_PtrToValue Offset;
435 : SymbolTable_Where At;
436 : };
437 :
438 : struct SymbolTable_SymUnbounded_r {
439 : unsigned int Type;
440 : M2ALU_PtrToValue Size;
441 : unsigned int RecordType;
442 : unsigned int Dimensions;
443 : unsigned int Scope;
444 : SymbolTable_Where At;
445 : };
446 :
447 : struct SymbolTable_SymProcType_r {
448 : NameKey_Name name;
449 : Lists_List ListOfParam;
450 : bool HasVarArgs;
451 : bool HasOptArg;
452 : unsigned int OptArgInit;
453 : unsigned int ReturnType;
454 : bool ReturnOptional;
455 : unsigned int ReturnTypeTok;
456 : unsigned int Scope;
457 : M2ALU_PtrToValue Size;
458 : M2ALU_PtrToValue TotalParamSize;
459 : unsigned int oafamily;
460 : SymbolTable_Where At;
461 : };
462 :
463 : struct SymbolTable_SymConstString_r {
464 : NameKey_Name name;
465 : NameKey_Name Contents;
466 : unsigned int Length;
467 : SymbolTable_ConstStringVariant StringVariant;
468 : bool Known;
469 : unsigned int Scope;
470 : SymbolTable_Where At;
471 : };
472 :
473 : struct SymbolTable_SymConstLit_r {
474 : NameKey_Name name;
475 : M2ALU_PtrToValue Value;
476 : unsigned int Type;
477 : bool IsSet;
478 : bool IsConstructor;
479 : bool IsInternal;
480 : unsigned int FromType;
481 : bool RangeError;
482 : bool UnresFromType;
483 : unsigned int Scope;
484 : SymbolTable_Where At;
485 : };
486 :
487 : struct SymbolTable_SymConstVar_r {
488 : NameKey_Name name;
489 : M2ALU_PtrToValue Value;
490 : unsigned int Type;
491 : bool IsConditional;
492 : bool IsSet;
493 : bool IsConstructor;
494 : unsigned int FromType;
495 : bool UnresFromType;
496 : bool IsTemp;
497 : unsigned int Scope;
498 : SymbolTable_Where At;
499 : };
500 :
501 : struct SymbolTable_SymVar_r {
502 : NameKey_Name name;
503 : unsigned int Type;
504 : unsigned int BackType;
505 : M2ALU_PtrToValue Size;
506 : M2ALU_PtrToValue Offset;
507 : SymbolTable_ModeOfAddr AddrMode;
508 : unsigned int Scope;
509 : bool AtAddress;
510 : unsigned int Address;
511 : bool IsComponentRef;
512 : Indexing_Index list;
513 : bool IsConditional;
514 : bool IsTemp;
515 : bool IsParam;
516 : bool IsPointerCheck;
517 : bool IsWritten;
518 : bool IsSSA;
519 : bool IsConst;
520 : bool ArrayRef;
521 : bool Heap;
522 : SymbolTable_LRInitDesc InitState;
523 : SymbolTable_VarDecl Declared;
524 : SymbolTable_Where At;
525 : SymbolTable_LRLists ReadUsageList;
526 : SymbolTable_LRLists WriteUsageList;
527 : };
528 :
529 : struct SymbolTable_SymType_r {
530 : NameKey_Name name;
531 : unsigned int Type;
532 : bool IsHidden;
533 : SymbolKey_SymbolTree ConstLitTree;
534 : M2ALU_PtrToValue Size;
535 : SymbolTable_PackedInfo packedInfo;
536 : unsigned int oafamily;
537 : unsigned int Align;
538 : unsigned int Scope;
539 : SymbolTable_Where At;
540 : };
541 :
542 : struct SymbolTable_SymPointer_r {
543 : NameKey_Name name;
544 : unsigned int Type;
545 : M2ALU_PtrToValue Size;
546 : unsigned int Align;
547 : SymbolKey_SymbolTree ConstLitTree;
548 : unsigned int oafamily;
549 : unsigned int Scope;
550 : SymbolTable_Where At;
551 : };
552 :
553 : struct SymbolTable_SymRecordField_r {
554 : NameKey_Name name;
555 : unsigned int Type;
556 : bool Tag;
557 : M2ALU_PtrToValue Size;
558 : M2ALU_PtrToValue Offset;
559 : unsigned int Parent;
560 : unsigned int Varient;
561 : unsigned int Align;
562 : bool Used;
563 : bool DeclPacked;
564 : bool DeclResolved;
565 : unsigned int Scope;
566 : SymbolTable_Where At;
567 : };
568 :
569 : struct SymbolTable_SymVarientField_r {
570 : NameKey_Name name;
571 : M2ALU_PtrToValue Size;
572 : M2ALU_PtrToValue Offset;
573 : unsigned int Parent;
574 : unsigned int Varient;
575 : Lists_List ListOfSons;
576 : bool DeclPacked;
577 : bool DeclResolved;
578 : unsigned int Scope;
579 : SymbolTable_Where At;
580 : };
581 :
582 : struct SymbolTable_SymEnumerationField_r {
583 : NameKey_Name name;
584 : M2ALU_PtrToValue Value;
585 : unsigned int Type;
586 : unsigned int Scope;
587 : SymbolTable_Where At;
588 : };
589 :
590 : struct SymbolTable_SymSet_r {
591 : NameKey_Name name;
592 : unsigned int Type;
593 : SymbolTable_PackedInfo packedInfo;
594 : bool ispacked;
595 : bool SetInWord;
596 : unsigned int SetArray;
597 : unsigned int Align;
598 : M2ALU_PtrToValue Size;
599 : unsigned int oafamily;
600 : unsigned int Scope;
601 : SymbolTable_Where At;
602 : };
603 :
604 : struct SymbolTable_SymDefImp_r {
605 : NameKey_Name name;
606 : NameKey_Name libname;
607 : SymbolTable_ModuleCtor ctors;
608 : Lists_List DefListOfDep;
609 : Lists_List ModListOfDep;
610 : SymbolKey_SymbolTree ExportQualifiedTree;
611 : SymbolKey_SymbolTree ExportUnQualifiedTree;
612 : SymbolKey_SymbolTree ExportRequest;
613 : Lists_List IncludeList;
614 : Lists_List DefIncludeList;
615 : SymbolKey_SymbolTree ImportTree;
616 : SymbolKey_SymbolTree ExportUndeclared;
617 : SymbolKey_SymbolTree NeedToBeImplemented;
618 : SymbolKey_SymbolTree LocalSymbols;
619 : Lists_List EnumerationScopeList;
620 : SymbolKey_SymbolTree NamedObjects;
621 : SymbolKey_SymbolTree NamedImports;
622 : SymbolKey_SymbolTree WhereImported;
623 : unsigned int Priority;
624 : SymbolKey_SymbolTree Unresolved;
625 : unsigned int StartQuad;
626 : unsigned int EndQuad;
627 : unsigned int StartFinishQuad;
628 : unsigned int EndFinishQuad;
629 : tree FinallyFunction;
630 : bool ExceptionFinally;
631 : bool ExceptionBlock;
632 : bool ContainsHiddenType;
633 : bool ContainsBuiltin;
634 : bool ForC;
635 : bool NeedExportList;
636 : bool ModLink;
637 : bool DefLink;
638 : bool Builtin;
639 : Lists_List ListOfVars;
640 : Lists_List ListOfProcs;
641 : Lists_List ListOfModules;
642 : M2Error_ErrorScope errorScope;
643 : SymbolTable_Where At;
644 : };
645 :
646 : struct SymbolTable_SymModule_r {
647 : NameKey_Name name;
648 : NameKey_Name libname;
649 : SymbolTable_ModuleCtor ctors;
650 : Lists_List ModListOfDep;
651 : SymbolKey_SymbolTree LocalSymbols;
652 : SymbolKey_SymbolTree ExportTree;
653 : Lists_List IncludeList;
654 : SymbolKey_SymbolTree ImportTree;
655 : SymbolKey_SymbolTree ExportUndeclared;
656 : Lists_List EnumerationScopeList;
657 : SymbolKey_SymbolTree NamedObjects;
658 : SymbolKey_SymbolTree NamedImports;
659 : SymbolKey_SymbolTree WhereImported;
660 : unsigned int Scope;
661 : unsigned int Priority;
662 : SymbolKey_SymbolTree Unresolved;
663 : unsigned int StartQuad;
664 : unsigned int EndQuad;
665 : unsigned int StartFinishQuad;
666 : unsigned int EndFinishQuad;
667 : tree FinallyFunction;
668 : bool ExceptionFinally;
669 : bool ExceptionBlock;
670 : bool ModLink;
671 : bool Builtin;
672 : Lists_List ListOfVars;
673 : Lists_List ListOfProcs;
674 : Lists_List ListOfModules;
675 : M2Error_ErrorScope errorScope;
676 : SymbolTable_Where At;
677 : };
678 :
679 : struct SymbolTable__T6_a { SymbolTable_ProcedureDeclaration array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure+1]; };
680 : struct SymbolTable_SymProcedure_r {
681 : NameKey_Name name;
682 : SymbolTable__T6 Decl;
683 : unsigned int OptArgInit;
684 : bool IsExtern;
685 : bool IsPublic;
686 : bool IsCtor;
687 : bool IsMonoName;
688 : bool BuildProcType;
689 : SymbolKey_SymbolTree Unresolved;
690 : unsigned int ScopeQuad;
691 : unsigned int StartQuad;
692 : unsigned int EndQuad;
693 : bool Reachable;
694 : bool SavePriority;
695 : unsigned int ReturnType;
696 : unsigned int ProcedureType;
697 : bool IsBuiltin;
698 : NameKey_Name BuiltinName;
699 : bool IsInline;
700 : SymbolKey_SymbolTree LocalSymbols;
701 : Lists_List EnumerationScopeList;
702 : Lists_List ListOfVars;
703 : Lists_List ListOfProcs;
704 : SymbolKey_SymbolTree NamedObjects;
705 : M2ALU_PtrToValue Size;
706 : M2ALU_PtrToValue TotalParamSize;
707 : bool ExceptionFinally;
708 : bool ExceptionBlock;
709 : unsigned int Scope;
710 : M2Error_ErrorScope errorScope;
711 : Lists_List ListOfModules;
712 : unsigned int Begin;
713 : unsigned int End;
714 : SymbolTable_Where At;
715 : };
716 :
717 : struct SymbolTable_Symbol_r {
718 : SymbolTable_TypeOfSymbol SymbolType; /* case tag */
719 : union {
720 : SymbolTable_SymOAFamily OAFamily;
721 : SymbolTable_SymObject Object;
722 : SymbolTable_SymEquiv Equiv;
723 : SymbolTable_SymRecord Record;
724 : SymbolTable_SymVarient Varient;
725 : SymbolTable_SymVar Var;
726 : SymbolTable_SymEnumeration Enumeration;
727 : SymbolTable_SymSubrange Subrange;
728 : SymbolTable_SymSubscript Subscript;
729 : SymbolTable_SymArray Array;
730 : SymbolTable_SymUnbounded Unbounded;
731 : SymbolTable_SymPartialUnbounded PartialUnbounded;
732 : SymbolTable_SymConstVar ConstVar;
733 : SymbolTable_SymConstLit ConstLit;
734 : SymbolTable_SymConstString ConstString;
735 : SymbolTable_SymVarParam VarParam;
736 : SymbolTable_SymParam Param;
737 : SymbolTable_SymError Error;
738 : SymbolTable_SymUndefined Undefined;
739 : SymbolTable_SymType Type;
740 : SymbolTable_SymPointer Pointer;
741 : SymbolTable_SymRecordField RecordField;
742 : SymbolTable_SymVarientField VarientField;
743 : SymbolTable_SymEnumerationField EnumerationField;
744 : SymbolTable_SymDefImp DefImp;
745 : SymbolTable_SymModule Module;
746 : SymbolTable_SymSet Set;
747 : SymbolTable_SymProcedure Procedure;
748 : SymbolTable_SymProcType ProcType;
749 : SymbolTable_SymImportStatement ImportStatement;
750 : SymbolTable_SymImport Import;
751 : SymbolTable_SymGnuAsm GnuAsm;
752 : SymbolTable_SymInterface Interface;
753 : SymbolTable_SymTuple Tuple;
754 : SymbolTable_SymDummy Dummy;
755 : };
756 : };
757 :
758 : static Indexing_Index Symbols;
759 : static Indexing_Index ScopeCallFrame;
760 : static unsigned int FreeSymbol;
761 : static SymbolKey_SymbolTree DefModuleTree;
762 : static SymbolKey_SymbolTree ModuleTree;
763 : static unsigned int CurrentModule;
764 : static unsigned int MainModule;
765 : static unsigned int FileModule;
766 : static unsigned int ScopePtr;
767 : static unsigned int BaseScopePtr;
768 : static unsigned int BaseModule;
769 : static unsigned int TemporaryNo;
770 : static M2Error_Error CurrentError;
771 : static Lists_List AddressTypes;
772 : static Lists_List UnresolvedConstructorType;
773 : static unsigned int AnonymousName;
774 : static Sets_Set ReportedUnknowns;
775 : static SymbolKey_SymbolTree ConstLitPoolTree;
776 : static Indexing_Index ConstLitArray;
777 : static unsigned int BreakSym;
778 : static M2Diagnostic_Diagnostic SymMemDiag;
779 : static unsigned int recordConsist;
780 : static DynamicStrings_String ListifySentance;
781 : static unsigned int ListifyTotal;
782 : static unsigned int ListifyWordCount;
783 : static unsigned int ExportRequestModule;
784 : static unsigned int ResolveModule;
785 :
786 : /*
787 : FinalSymbol - returns the highest number symbol used.
788 : */
789 :
790 : extern "C" unsigned int SymbolTable_FinalSymbol (void);
791 :
792 : /*
793 : MakeComponentRecord - make a temporary which will be used to reference and field
794 : (or sub field) of record.
795 : */
796 :
797 : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record);
798 :
799 : /*
800 : MakeComponentRef - use, sym, to reference, field, sym is returned.
801 : */
802 :
803 : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field);
804 :
805 : /*
806 : IsComponent - returns TRUE if symbol, sym, is a temporary and a component
807 : reference.
808 : */
809 :
810 : extern "C" bool SymbolTable_IsComponent (unsigned int sym);
811 :
812 : /*
813 : MakeTemporary - Makes a new temporary variable at the highest real scope.
814 : The addressing mode of the temporary is set to NoValue.
815 : */
816 :
817 : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode);
818 :
819 : /*
820 : MakeTemporaryFromExpression - makes a new temporary variable at the
821 : highest real scope. The addressing
822 : mode of the temporary is set and the
823 : type is determined by expressions, e.
824 : */
825 :
826 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode);
827 :
828 : /*
829 : MakeTemporaryFromExpressions - makes a new temporary variable at the
830 : highest real scope. The addressing
831 : mode of the temporary is set and the
832 : type is determined by expressions,
833 : e1 and e2.
834 : */
835 :
836 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode);
837 :
838 : /*
839 : PutMode - Puts the addressing mode, SymMode, into symbol Sym.
840 : The mode may only be altered if the mode
841 : is None.
842 : */
843 :
844 : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode);
845 :
846 : /*
847 : GetMode - Returns the addressing mode of a symbol.
848 : */
849 :
850 : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym);
851 :
852 : /*
853 : StartScope - starts a block scope at Sym. Transparent determines
854 : whether the search for a symbol will look at the
855 : previous ScopeCallFrame if Sym does not contain the
856 : symbol that GetSym is searching.
857 :
858 : WITH statements are partially implemented by calling
859 : StartScope. Therefore we must retain the old Main from
860 : the previous ScopePtr when a record is added to the scope
861 : stack. (Main contains the symbol where all identifiers
862 : should be added.)
863 : */
864 :
865 : extern "C" void SymbolTable_StartScope (unsigned int Sym);
866 :
867 : /*
868 : EndScope - ends a block scope started by StartScope. The current
869 : head of the symbol scope reverts back to the symbol
870 : which was the Head of the symbol scope before the
871 : last StartScope was called.
872 : */
873 :
874 : extern "C" void SymbolTable_EndScope (void);
875 :
876 : /*
877 : PseudoScope - starts a pseudo scope at Sym.
878 : We always connect parent up to the last scope,
879 : to determine the transparancy of a scope we call
880 : TransparentScope.
881 :
882 : A Pseudo scope has no end block,
883 : but is terminated when the next EndScope is used.
884 : The function of the pseudo scope is to provide an
885 : automatic mechanism to solve enumeration types.
886 : A declared enumeration type is a Pseudo scope and
887 : identifiers used with the name of an enumeration
888 : type field will find the enumeration symbol by
889 : the scoping algorithm.
890 : */
891 :
892 : extern "C" void SymbolTable_PseudoScope (unsigned int Sym);
893 :
894 : /*
895 : GetCurrentScope - returns the symbol who is responsible for the current
896 : scope. Note that it ignore pseudo scopes.
897 : */
898 :
899 : extern "C" unsigned int SymbolTable_GetCurrentScope (void);
900 :
901 : /*
902 : IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
903 : */
904 :
905 : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym);
906 :
907 : /*
908 : SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
909 : This Sym must represent the module name of the
910 : file currently being compiled.
911 : */
912 :
913 : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym);
914 :
915 : /*
916 : SetFileModule - Used to set the FileModule to a symbol, Sym.
917 : This Sym must represent the current program module
918 : file which is being parsed.
919 : */
920 :
921 : extern "C" void SymbolTable_SetFileModule (unsigned int Sym);
922 :
923 : /*
924 : SetMainModule - Used to set the MainModule to a symbol, Sym.
925 : This Sym must represent the main module which was
926 : envoked by the user to be compiled.
927 : */
928 :
929 : extern "C" void SymbolTable_SetMainModule (unsigned int Sym);
930 :
931 : /*
932 : CheckAnonymous - checks to see whether the name is NulName and if so
933 : it creates a unique anonymous name.
934 : */
935 :
936 : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name);
937 :
938 : /*
939 : IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
940 : or no name.
941 : */
942 :
943 : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym);
944 :
945 : /*
946 : NoOfVariables - returns the number of variables in scope. The scope maybe
947 : a procedure, module or defimp scope.
948 : */
949 :
950 : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope);
951 :
952 : /*
953 : MakeModule - creates a module sym with ModuleName. It returns the
954 : symbol index.
955 : */
956 :
957 : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName);
958 :
959 : /*
960 : MakeDefImp - creates a definition and implementation module sym
961 : with name DefImpName. It returns the symbol index.
962 : */
963 :
964 : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName);
965 :
966 : /*
967 : MakeInnerModule - creates an inner module sym with ModuleName. It returns the
968 : symbol index.
969 : */
970 :
971 : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName);
972 :
973 : /*
974 : MakeProcedure - creates a procedure sym with name. It returns
975 : the symbol index.
976 : */
977 :
978 : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName);
979 :
980 : /*
981 : MakeProcedureCtorExtern - creates an extern ctor procedure
982 : */
983 :
984 : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename);
985 :
986 : /*
987 : PutLibName - places libname into defimp or module sym.
988 : */
989 :
990 : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname);
991 :
992 : /*
993 : GetLibName - returns libname associated with a defimp or module sym.
994 : */
995 :
996 : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym);
997 :
998 : /*
999 : PutMonoName - changes the IsMonoName boolean inside the procedure.
1000 : */
1001 :
1002 : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value);
1003 :
1004 : /*
1005 : IsMonoName - returns the public boolean associated with a procedure.
1006 : */
1007 :
1008 : extern "C" bool SymbolTable_IsMonoName (unsigned int sym);
1009 :
1010 : /*
1011 : PutExtern - changes the extern boolean inside the procedure.
1012 : */
1013 :
1014 : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value);
1015 :
1016 : /*
1017 : IsExtern - returns the public boolean associated with a procedure.
1018 : */
1019 :
1020 : extern "C" bool SymbolTable_IsExtern (unsigned int sym);
1021 :
1022 : /*
1023 : PutPublic - changes the public boolean inside the procedure.
1024 : */
1025 :
1026 : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value);
1027 :
1028 : /*
1029 : IsPublic - returns the public boolean associated with a procedure.
1030 : */
1031 :
1032 : extern "C" bool SymbolTable_IsPublic (unsigned int sym);
1033 :
1034 : /*
1035 : PutCtor - changes the ctor boolean inside the procedure.
1036 : */
1037 :
1038 : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value);
1039 :
1040 : /*
1041 : IsCtor - returns the ctor boolean associated with a procedure.
1042 : */
1043 :
1044 : extern "C" bool SymbolTable_IsCtor (unsigned int sym);
1045 :
1046 : /*
1047 : GetModuleCtors - mod can be a DefImp or Module symbol. ctor, init and fini
1048 : are assigned for this module. An inner module ctor value will
1049 : be NulSym.
1050 : */
1051 :
1052 : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep);
1053 :
1054 : /*
1055 : MakeModuleCtor - for a defimp or module symbol create all the ctor
1056 : related procedures.
1057 : */
1058 :
1059 : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym);
1060 :
1061 : /*
1062 : PutModuleCtorExtern - for every ctor related procedure in module sym.
1063 : Make it external. It will create any missing
1064 : init/fini procedures but not any missing dep/ctor
1065 : procedures.
1066 : */
1067 :
1068 : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external);
1069 :
1070 : /*
1071 : PutVarHeap - assigns ArrayRef field with value.
1072 : */
1073 :
1074 : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value);
1075 :
1076 : /*
1077 : IsVarHeap - returns ArrayRef field value.
1078 : */
1079 :
1080 : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym);
1081 :
1082 : /*
1083 : MakeVar - creates a variable sym with VarName. It returns the
1084 : symbol index.
1085 : */
1086 :
1087 : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName);
1088 :
1089 : /*
1090 : PutVarConditional - assign IsConditional to value.
1091 : */
1092 :
1093 : extern "C" void SymbolTable_PutVarConditional (unsigned int sym, bool value);
1094 :
1095 : /*
1096 : IsVarConditional - return TRUE if the symbol is a var symbol
1097 : containing the result of a boolean conditional.
1098 : */
1099 :
1100 : extern "C" bool SymbolTable_IsVarConditional (unsigned int sym);
1101 :
1102 : /*
1103 : MakeRecord - makes a Record symbol with name RecordName.
1104 : */
1105 :
1106 : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName);
1107 :
1108 : /*
1109 : MakeVarient - creates a new symbol, a varient symbol for record or varient field
1110 : symbol, RecOrVarFieldSym.
1111 : */
1112 :
1113 : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym);
1114 :
1115 : /*
1116 : MakeFieldVarient - returns a FieldVarient symbol which has been
1117 : assigned to the Varient symbol, Sym.
1118 : */
1119 :
1120 : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym);
1121 :
1122 : /*
1123 : MakeEnumeration - places a new symbol in the current scope, the symbol
1124 : is an enumeration symbol. The symbol index is returned.
1125 : */
1126 :
1127 : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName);
1128 :
1129 : /*
1130 : MakeType - makes a type symbol with name TypeName.
1131 : */
1132 :
1133 : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName);
1134 :
1135 : /*
1136 : MakeHiddenType - makes a type symbol that is hidden from the
1137 : definition module.
1138 : This symbol is placed into the UnImplemented list of
1139 : the definition/implementation module.
1140 : The type will be filled in when the implementation module
1141 : is reached.
1142 : */
1143 :
1144 : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName);
1145 :
1146 : /*
1147 : MakeConstant - create a constant cardinal and return the symbol.
1148 : */
1149 :
1150 : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value);
1151 :
1152 : /*
1153 : MakeConstLit - returns a constant literal of type, constType, with a constName,
1154 : at location, tok.
1155 : */
1156 :
1157 : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
1158 :
1159 : /*
1160 : MakeConstVar - makes a ConstVar type with
1161 : name ConstVarName.
1162 : */
1163 :
1164 : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName);
1165 :
1166 : /*
1167 : MakeConstString - create a string constant in the symboltable.
1168 : */
1169 :
1170 : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName);
1171 :
1172 : /*
1173 : MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
1174 : If known is TRUE then name is assigned to the contents
1175 : and the escape sequences will be converted into characters.
1176 : */
1177 :
1178 : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known);
1179 :
1180 : /*
1181 : MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
1182 : If known is TRUE then name is assigned to the contents
1183 : however the escape sequences are not converted into characters.
1184 : */
1185 :
1186 : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known);
1187 :
1188 : /*
1189 : PutConstStringKnown - if sym is a constvar then convert it into a conststring.
1190 : If known is FALSE then contents is ignored and NulName is
1191 : stored. If escape is TRUE then the contents will have
1192 : any escape sequences converted into single characters.
1193 : */
1194 :
1195 : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known);
1196 :
1197 : /*
1198 : CopyConstString - copies string contents from expr to des
1199 : and retain the kind of string.
1200 : */
1201 :
1202 : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr);
1203 :
1204 : /*
1205 : IsConstStringKnown - returns TRUE if sym is a const string
1206 : and the contents are known.
1207 : */
1208 :
1209 : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym);
1210 :
1211 : /*
1212 : IsConstStringM2 - returns whether this conststring is a
1213 : Modula-2 string.
1214 : */
1215 :
1216 : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym);
1217 :
1218 : /*
1219 : IsConstStringC - returns whether this conststring is a C style string
1220 : which will have any escape translated.
1221 : */
1222 :
1223 : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym);
1224 :
1225 : /*
1226 : IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
1227 : contains a nul terminator.
1228 : */
1229 :
1230 : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym);
1231 :
1232 : /*
1233 : IsConstStringCnul - returns whether this conststring is a C style string
1234 : which will have any escape translated and also contains
1235 : a nul terminator.
1236 : */
1237 :
1238 : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym);
1239 :
1240 : /*
1241 : MakeSubrange - makes a new symbol into a subrange type with
1242 : name SubrangeName.
1243 : */
1244 :
1245 : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName);
1246 :
1247 : /*
1248 : MakeSet - makes a set Symbol with name, SetName.
1249 : */
1250 :
1251 : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName);
1252 :
1253 : /*
1254 : GetSetArray - return the set array for a large set.
1255 : */
1256 :
1257 : extern "C" unsigned int SymbolTable_GetSetArray (unsigned int sym);
1258 :
1259 : /*
1260 : PutSetArray - places array into the setarray field.
1261 : */
1262 :
1263 : extern "C" void SymbolTable_PutSetArray (unsigned int Sym, unsigned int array);
1264 :
1265 : /*
1266 : MakeSetArray - create an ARRAY simpletype OF BOOLEAN.
1267 : */
1268 :
1269 : extern "C" unsigned int SymbolTable_MakeSetArray (unsigned int token, unsigned int subrangetype);
1270 :
1271 : /*
1272 : PutSetInWord - set the SetInWord boolean to value.
1273 : */
1274 :
1275 : extern "C" void SymbolTable_PutSetInWord (unsigned int sym, bool value);
1276 :
1277 : /*
1278 : GetSetInWord - return SetInWord.
1279 : */
1280 :
1281 : extern "C" bool SymbolTable_GetSetInWord (unsigned int sym);
1282 :
1283 : /*
1284 : MakeArray - makes an Array symbol with name ArrayName.
1285 : */
1286 :
1287 : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName);
1288 :
1289 : /*
1290 : PutArrayLarge - indicates that this is a large array in which case
1291 : the interface to gcc maps this array from 0..high-low,
1292 : using an integer indice.
1293 : */
1294 :
1295 : extern "C" void SymbolTable_PutArrayLarge (unsigned int array);
1296 :
1297 : /*
1298 : IsArrayLarge - returns TRUE if we need to treat this as a large array.
1299 : */
1300 :
1301 : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array);
1302 :
1303 : /*
1304 : PutPriority - places a interrupt, priority, value into module, module.
1305 : */
1306 :
1307 : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority);
1308 :
1309 : /*
1310 : GetPriority - returns the interrupt priority which was assigned to
1311 : module, module.
1312 : */
1313 :
1314 : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module);
1315 :
1316 : /*
1317 : PutNeedSavePriority - set a boolean flag indicating that this procedure
1318 : needs to save and restore interrupts.
1319 : */
1320 :
1321 : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym);
1322 :
1323 : /*
1324 : GetNeedSavePriority - returns the boolean flag indicating whether this procedure
1325 : needs to save and restore interrupts.
1326 : */
1327 :
1328 : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym);
1329 :
1330 : /*
1331 : PutVariableAtAddress - determines that a variable, sym, is declared at
1332 : a specific address.
1333 : */
1334 :
1335 : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address);
1336 :
1337 : /*
1338 : GetVariableAtAddress - returns the address at which variable, sym, is declared.
1339 : */
1340 :
1341 : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym);
1342 :
1343 : /*
1344 : IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
1345 : a specific address.
1346 : */
1347 :
1348 : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym);
1349 :
1350 : /*
1351 : PutVariableSSA - assigns value to the SSA field within variable sym.
1352 : */
1353 :
1354 : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value);
1355 :
1356 : /*
1357 : IsVariableSSA - returns TRUE if variable is known to be a SSA.
1358 : */
1359 :
1360 : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym);
1361 :
1362 : /*
1363 : PutVarConst - sets the IsConst field to value indicating the variable is read only.
1364 : */
1365 :
1366 : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value);
1367 :
1368 : /*
1369 : MakeGnuAsm - create a GnuAsm symbol.
1370 : */
1371 :
1372 : extern "C" unsigned int SymbolTable_MakeGnuAsm (void);
1373 :
1374 : /*
1375 : PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
1376 : */
1377 :
1378 : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string);
1379 :
1380 : /*
1381 : PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
1382 : */
1383 :
1384 : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out);
1385 :
1386 : /*
1387 : PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
1388 : */
1389 :
1390 : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in);
1391 :
1392 : /*
1393 : PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
1394 : */
1395 :
1396 : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash);
1397 :
1398 : /*
1399 : GetGnuAsm - returns the string symbol, representing the instruction textual
1400 : of the GnuAsm symbol. It will return a ConstString.
1401 : */
1402 :
1403 : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym);
1404 :
1405 : /*
1406 : GetGnuAsmInput - returns the input list of registers.
1407 : */
1408 :
1409 : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym);
1410 :
1411 : /*
1412 : GetGnuAsmOutput - returns the output list of registers.
1413 : */
1414 :
1415 : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym);
1416 :
1417 : /*
1418 : GetGnuAsmTrash - returns the list of trashed registers.
1419 : */
1420 :
1421 : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym);
1422 :
1423 : /*
1424 : PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
1425 : */
1426 :
1427 : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym);
1428 :
1429 : /*
1430 : PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
1431 : */
1432 :
1433 : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym);
1434 :
1435 : /*
1436 : MakeRegInterface - creates and returns a register interface symbol.
1437 : */
1438 :
1439 : extern "C" unsigned int SymbolTable_MakeRegInterface (void);
1440 :
1441 : /*
1442 : PutRegInterface - places a, name, string, and, object, into the interface array,
1443 : sym, at position, i.
1444 : The string symbol will either be a register name or a constraint.
1445 : The object is an optional Modula-2 variable or constant symbol.
1446 : read and write are the quadruple numbers representing any read
1447 : or write operation.
1448 : */
1449 :
1450 : extern "C" void SymbolTable_PutRegInterface (unsigned int tok, unsigned int sym, unsigned int i, NameKey_Name n, unsigned int string, unsigned int object, unsigned int read_, unsigned int write_);
1451 :
1452 : /*
1453 : GetRegInterface - gets a, name, string, and, object, from the interface array,
1454 : sym, from position, i.
1455 : */
1456 :
1457 : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object);
1458 :
1459 : /*
1460 : GetModule - Returns the Module symbol for the module with name, name.
1461 : */
1462 :
1463 : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name);
1464 :
1465 : /*
1466 : GetCurrentModule - returns the current module Sym that is being
1467 : compiled.
1468 : */
1469 :
1470 : extern "C" unsigned int SymbolTable_GetCurrentModule (void);
1471 :
1472 : /*
1473 : GetFileModule - returns the FileModule symbol that was requested by
1474 : the user to be compiled.
1475 : */
1476 :
1477 : extern "C" unsigned int SymbolTable_GetFileModule (void);
1478 :
1479 : /*
1480 : GetBaseModule - returns the base module symbol that contains Modula-2
1481 : base types, procedures and functions.
1482 : */
1483 :
1484 : extern "C" unsigned int SymbolTable_GetBaseModule (void);
1485 :
1486 : /*
1487 : GetMainModule - returns the main module symbol that was requested by
1488 : the user to be compiled.
1489 : */
1490 :
1491 : extern "C" unsigned int SymbolTable_GetMainModule (void);
1492 :
1493 : /*
1494 : GetCurrentModuleScope - returns the module symbol which forms the
1495 : current (possibly inner most) module.
1496 : */
1497 :
1498 : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void);
1499 :
1500 : /*
1501 : GetLastModuleScope - returns the last module scope encountered,
1502 : the module scope before the Current Module Scope.
1503 : */
1504 :
1505 : extern "C" unsigned int SymbolTable_GetLastModuleScope (void);
1506 :
1507 : /*
1508 : AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
1509 : ModSym.
1510 : */
1511 :
1512 : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym);
1513 :
1514 : /*
1515 : GetType - Returns the symbol that is the TYPE symbol to Sym.
1516 : If zero is returned then we assume type unknown.
1517 : */
1518 :
1519 : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym);
1520 :
1521 : /*
1522 : SkipType - if sym is a TYPE foo = bar
1523 : then call SkipType(bar)
1524 : else return sym
1525 :
1526 : it does not skip over hidden types.
1527 : */
1528 :
1529 : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym);
1530 :
1531 : /*
1532 : SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
1533 : sym is declared as a subrange of bar
1534 : then call SkipTypeAndSubrange(bar)
1535 : else return sym
1536 :
1537 : it does not skip over hidden types.
1538 : */
1539 :
1540 : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym);
1541 :
1542 : /*
1543 : GetLowestType - Returns the lowest type in the type chain of
1544 : symbol Sym.
1545 : If NulSym is returned then we assume type unknown or
1546 : you have reqested the type of a base type.
1547 : */
1548 :
1549 : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym);
1550 :
1551 : /*
1552 : GetLType - get lowest type. It returns the lowest type
1553 : of symbol, sym. It skips over type equivalences.
1554 : It will not skip over base types.
1555 : */
1556 :
1557 : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym);
1558 :
1559 : /*
1560 : GetSType - get source type. It returns the type closest
1561 : to the object. It does not skip over type
1562 : equivalences. It will skip over base types.
1563 : */
1564 :
1565 : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym);
1566 :
1567 : /*
1568 : GetDType - get gcc declared type. It returns the type
1569 : of the object which is declared to GCC.
1570 : It does skip over type equivalences but only
1571 : if they do not contain a user alignment.
1572 : It does not skip over hidden types.
1573 : It does not skip over base types.
1574 : */
1575 :
1576 : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym);
1577 :
1578 : /*
1579 : GetTypeMode - return the type of sym, it returns Address is the
1580 : symbol is a LValue.
1581 : */
1582 :
1583 : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym);
1584 :
1585 : /*
1586 : GetSym - searches the current scope (and previous scopes if the
1587 : scope tranparent allows) for a symbol with name.
1588 : */
1589 :
1590 : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name);
1591 :
1592 : /*
1593 : GetDeclareSym - searches for a symbol with a name SymName in the
1594 : current and previous scopes.
1595 : If the symbol is found then it is returned
1596 : else an unknown symbol is returned.
1597 : This procedure assumes that SymName is being
1598 : declared at this point and therefore it does
1599 : not examine the base scope (for pervasive
1600 : identifiers).
1601 : */
1602 :
1603 : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName);
1604 :
1605 : /*
1606 : GetLocalSym - only searches the scope Sym for a symbol with name
1607 : and returns the index to the symbol.
1608 : */
1609 :
1610 : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name);
1611 :
1612 : /*
1613 : GetRecord - fetches the record symbol from the parent of Sym.
1614 : Sym maybe a varient symbol in which case its parent is searched
1615 : etc.
1616 : */
1617 :
1618 : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym);
1619 :
1620 : /*
1621 : FromModuleGetSym - attempts to find a symbol of name, n, in the
1622 : module, mod, scope. An unknown symbol is created
1623 : at token position tok if necessary.
1624 : */
1625 :
1626 : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod);
1627 :
1628 : /*
1629 : GetNth - returns the n th symbol in the list associated with the scope
1630 : of Sym. Sym may be a Module, DefImp, Procedure, Record or
1631 : Enumeration symbol.
1632 : */
1633 :
1634 : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n);
1635 :
1636 : /*
1637 : GetNthParam - returns the n th parameter of a procedure Sym.
1638 : */
1639 :
1640 : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
1641 :
1642 : /*
1643 : GetVarScope - returns the symbol which is the scope of variable Sym.
1644 : ie a Module, DefImp or Procedure Symbol.
1645 : */
1646 :
1647 : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym);
1648 :
1649 : /*
1650 : GetSubrange - returns HighSym and LowSym - two constants which make up the
1651 : subrange.
1652 : */
1653 :
1654 : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym);
1655 :
1656 : /*
1657 : GetParam - returns the ParamNo parameter from procedure ProcSym
1658 : */
1659 :
1660 : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo);
1661 :
1662 : /*
1663 : GetString - returns the contents of the string symbol sym, note that
1664 : this is not the same as GetName (unless it was a literal).
1665 : */
1666 :
1667 : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym);
1668 :
1669 : /*
1670 : GetStringLength - returns the length of the string symbol Sym.
1671 : */
1672 :
1673 : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym);
1674 :
1675 : /*
1676 : GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
1677 : */
1678 :
1679 : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym);
1680 :
1681 : /*
1682 : PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
1683 : */
1684 :
1685 : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name);
1686 :
1687 : /*
1688 : IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
1689 : */
1690 :
1691 : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym);
1692 :
1693 : /*
1694 : PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
1695 : */
1696 :
1697 : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym);
1698 : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym);
1699 :
1700 : /*
1701 : PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
1702 : sym, indicating that this block as an EXCEPT
1703 : statement sequence.
1704 : */
1705 :
1706 : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym);
1707 :
1708 : /*
1709 : HasExceptionBlock - returns a BOOLEAN determining whether
1710 : module/procedure/defimp, sym, has
1711 : an EXCEPT statement sequence.
1712 : */
1713 :
1714 : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym);
1715 :
1716 : /*
1717 : PutExceptionFinally - sets a BOOLEAN in block module/defimp,
1718 : sym, indicating that this FINALLY block
1719 : as an EXCEPT statement sequence.
1720 : */
1721 :
1722 : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym);
1723 :
1724 : /*
1725 : HasExceptionFinally - returns a BOOLEAN determining whether
1726 : module/defimp, sym, has
1727 : an EXCEPT statement sequence.
1728 : */
1729 :
1730 : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym);
1731 :
1732 : /*
1733 : PutVar - gives the VarSym symbol Sym a type Type.
1734 : */
1735 :
1736 : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType);
1737 :
1738 : /*
1739 : PutVarTok - gives the VarSym symbol Sym a type Type at typetok.
1740 : */
1741 :
1742 : extern "C" void SymbolTable_PutVarTok (unsigned int Sym, unsigned int VarType, unsigned int typetok);
1743 :
1744 : /*
1745 : PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
1746 : The variable must be a LeftValue.
1747 : */
1748 :
1749 : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType);
1750 :
1751 : /*
1752 : GetVarBackEndType - returns the back end type if specified.
1753 : */
1754 :
1755 : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym);
1756 :
1757 : /*
1758 : PutVarPointerCheck - marks variable, sym, as requiring (or not
1759 : depending upon the, value), a NIL pointer check
1760 : when this symbol is dereferenced.
1761 : */
1762 :
1763 : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value);
1764 :
1765 : /*
1766 : GetVarPointerCheck - returns TRUE if this symbol is a variable and
1767 : has been marked as needing a pointer via NIL check.
1768 : */
1769 :
1770 : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym);
1771 :
1772 : /*
1773 : PutVarWritten - marks variable, sym, as being written to (or not
1774 : depending upon the, value).
1775 : */
1776 :
1777 : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value);
1778 :
1779 : /*
1780 : GetVarWritten - returns TRUE if this symbol is a variable and
1781 : has been marked as being written.
1782 : */
1783 :
1784 : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym);
1785 :
1786 : /*
1787 : PutConst - gives the constant symbol Sym a type ConstType.
1788 : */
1789 :
1790 : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType);
1791 :
1792 : /*
1793 : PutConstSet - informs the const var symbol, sym, that it is or will contain
1794 : a set value.
1795 : */
1796 :
1797 : extern "C" void SymbolTable_PutConstSet (unsigned int Sym);
1798 :
1799 : /*
1800 : IsConstSet - returns TRUE if the constant is declared as a set.
1801 : */
1802 :
1803 : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym);
1804 :
1805 : /*
1806 : PutConstructor - informs the const var symbol, sym, that it is or
1807 : will contain a constructor (record, set or array)
1808 : value.
1809 : */
1810 :
1811 : extern "C" void SymbolTable_PutConstructor (unsigned int Sym);
1812 :
1813 : /*
1814 : PutConstructorFrom - sets the from type field in constructor,
1815 : Sym, to, from.
1816 : */
1817 :
1818 : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from);
1819 :
1820 : /*
1821 : PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
1822 : VarSym is a optional varient symbol which can be returned
1823 : by a call to GetVarient(fieldsymbol). The created field
1824 : is returned.
1825 : */
1826 :
1827 : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym);
1828 :
1829 : /*
1830 : PutFieldVarient - places the field varient, Field, as a brother to, the
1831 : varient symbol, sym, and also tells Field that its varient
1832 : parent is Sym.
1833 : */
1834 :
1835 : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym);
1836 :
1837 : /*
1838 : GetVarient - returns the varient symbol associated with the
1839 : record or varient field symbol, Field.
1840 : */
1841 :
1842 : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field);
1843 :
1844 : /*
1845 : IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
1846 : a varient tag.
1847 : */
1848 :
1849 : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym);
1850 :
1851 : /*
1852 : IsEmptyFieldVarient - returns TRUE if the field variant has
1853 : no fields. This will occur then the
1854 : compiler constructs 'else end' variants.
1855 : */
1856 :
1857 : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym);
1858 :
1859 : /*
1860 : GetVarientTag - returns the varient tag from, Sym.
1861 : */
1862 :
1863 : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym);
1864 :
1865 : /*
1866 : PutVarientTag - places, Tag, into varient, Sym.
1867 : */
1868 :
1869 : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag);
1870 :
1871 : /*
1872 : PutFieldEnumeration - places a field into the enumeration type
1873 : Sym. The field has a name FieldName and a
1874 : value FieldVal.
1875 : */
1876 :
1877 : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName);
1878 :
1879 : /*
1880 : PutSubrange - places LowSym and HighSym as two symbols
1881 : which provide the limits of the range.
1882 : */
1883 :
1884 : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol);
1885 :
1886 : /*
1887 : PutSet - places SimpleType as the type for set, Sym.
1888 : */
1889 :
1890 : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed);
1891 :
1892 : /*
1893 : IsSetPacked - returns TRUE if Sym is packed.
1894 : */
1895 :
1896 : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym);
1897 :
1898 : /*
1899 : GetArraySubscript - returns the subscript symbol for array, Sym.
1900 : */
1901 :
1902 : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym);
1903 :
1904 : /*
1905 : PutArraySubscript - places an index field into the array Sym. The
1906 : index field is a subscript sym.
1907 : */
1908 :
1909 : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol);
1910 :
1911 : /*
1912 : PutType - gives a type symbol Sym type TypeSymbol.
1913 : */
1914 :
1915 : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol);
1916 :
1917 : /*
1918 : PutFunction - Places a TypeSym as the return type to a procedure Sym.
1919 : */
1920 :
1921 : extern "C" void SymbolTable_PutFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym);
1922 :
1923 : /*
1924 : PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
1925 : */
1926 :
1927 : extern "C" void SymbolTable_PutOptFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym);
1928 :
1929 : /*
1930 : IsReturnOptional - returns TRUE if the return value for, sym, is
1931 : optional.
1932 : */
1933 :
1934 : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind);
1935 :
1936 : /*
1937 : IsReturnOptionalAny - returns TRUE if the return value for sym is
1938 : optional.
1939 : */
1940 :
1941 : extern "C" bool SymbolTable_IsReturnOptionalAny (unsigned int sym);
1942 :
1943 : /*
1944 : PutParam - Places a Non VAR parameter ParamName with type ParamType into
1945 : procedure Sym:kind. The parameter number is ParamNo.
1946 : If the procedure Sym already has this parameter then
1947 : the parameter is checked for consistancy and the
1948 : consistancy test is returned.
1949 : */
1950 :
1951 : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok);
1952 :
1953 : /*
1954 : PutVarParam - Places a Non VAR parameter ParamName with type
1955 : ParamType into procedure Sym:kind.
1956 : The parameter number is ParamNo.
1957 : If the procedure Sym already has this parameter then
1958 : the parameter is checked for consistancy and the
1959 : consistancy test is returned.
1960 : */
1961 :
1962 : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok);
1963 :
1964 : /*
1965 : PutParamName - assigns a name to paramater no of procedure ProcSym:kind.
1966 : */
1967 :
1968 : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, NameKey_Name name, unsigned int ParamType, unsigned int typetok);
1969 :
1970 : /*
1971 : PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
1972 : main Module.
1973 : */
1974 :
1975 : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym);
1976 :
1977 : /*
1978 : IsProcedureReachable - Returns true if the procedure, Sym, is
1979 : reachable from the main Module.
1980 : */
1981 :
1982 : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym);
1983 :
1984 : /*
1985 : PutProcedureNoReturn - places value into the no return attribute
1986 : field of procedure sym.
1987 : */
1988 :
1989 : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind, bool value);
1990 :
1991 : /*
1992 : IsProcedureNoReturn - returns TRUE if this procedure never returns.
1993 : */
1994 :
1995 : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind);
1996 :
1997 : /*
1998 : GetProcedureProcType - returns the proctype matching procedure sym.
1999 : */
2000 :
2001 : extern "C" unsigned int SymbolTable_GetProcedureProcType (unsigned int sym);
2002 :
2003 : /*
2004 : PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
2005 : QuadNumber is the start quad of Module,
2006 : Sym.
2007 : */
2008 :
2009 : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber);
2010 :
2011 : /*
2012 : PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
2013 : QuadNumber is the end quad of Module,
2014 : Sym.
2015 : */
2016 :
2017 : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber);
2018 :
2019 : /*
2020 : PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
2021 : QuadNumber is the finally start quad of
2022 : Module, Sym.
2023 : */
2024 :
2025 : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber);
2026 :
2027 : /*
2028 : PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
2029 : QuadNumber is the end quad of the finally block
2030 : in Module, Sym.
2031 : */
2032 :
2033 : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber);
2034 :
2035 : /*
2036 : GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
2037 : Quads of a Module, Sym.
2038 : Start and End represent the initialization code
2039 : of the Module, Sym.
2040 : */
2041 :
2042 : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish);
2043 :
2044 : /*
2045 : PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
2046 : */
2047 :
2048 : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, tree finally);
2049 :
2050 : /*
2051 : GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
2052 : */
2053 :
2054 : extern "C" tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym);
2055 :
2056 : /*
2057 : PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
2058 : QuadNumber is the start quad of scope for procedure,
2059 : Sym.
2060 : */
2061 :
2062 : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber);
2063 :
2064 : /*
2065 : PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
2066 : QuadNumber is the start quad of procedure,
2067 : Sym.
2068 : */
2069 :
2070 : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber);
2071 :
2072 : /*
2073 : PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
2074 : QuadNumber is the end quad of procedure,
2075 : Sym.
2076 : */
2077 :
2078 : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber);
2079 :
2080 : /*
2081 : GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
2082 : */
2083 :
2084 : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end);
2085 :
2086 : /*
2087 : GetQuads - assigns Start and End to the beginning and end of
2088 : symbol, Sym, usage.
2089 : */
2090 :
2091 : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2092 :
2093 : /*
2094 : GetReadQuads - assigns Start and End to the beginning and end of
2095 : symbol, Sym, read history usage.
2096 : */
2097 :
2098 : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2099 :
2100 : /*
2101 : GetWriteQuads - assigns Start and End to the beginning and end of
2102 : symbol, Sym, usage.
2103 : */
2104 :
2105 : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2106 :
2107 : /*
2108 : PutReadQuad - places Quad into the list of symbol usage.
2109 : */
2110 :
2111 : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2112 :
2113 : /*
2114 : RemoveReadQuad - places Quad into the list of symbol usage.
2115 : */
2116 :
2117 : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2118 :
2119 : /*
2120 : PutWriteQuad - places Quad into the list of symbol usage.
2121 : */
2122 :
2123 : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2124 :
2125 : /*
2126 : RemoveWriteQuad - places Quad into the list of symbol usage.
2127 : */
2128 :
2129 : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2130 :
2131 : /*
2132 : GetReadLimitQuads - returns Start and End which have been assigned
2133 : the start and end of when the symbol was read
2134 : to within: StartLimit..EndLimit.
2135 : */
2136 :
2137 : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2138 :
2139 : /*
2140 : GetWriteLimitQuads - returns Start and End which have been assigned
2141 : the start and end of when the symbol was written
2142 : to within: StartLimit..EndLimit.
2143 : */
2144 :
2145 : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2146 :
2147 : /*
2148 : GetNthProcedure - Returns the Nth procedure in Module, Sym.
2149 : */
2150 :
2151 : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n);
2152 :
2153 : /*
2154 : GetDeclaredDef - returns the tokenno where the symbol was declared
2155 : in the definition module. UnknownTokenNo is returned
2156 : if no declaration occurred.
2157 : */
2158 :
2159 : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym);
2160 :
2161 : /*
2162 : GetDeclaredMod - returns the tokenno where the symbol was declared.
2163 : in the program or implementation module.
2164 : UnknownTokenNo is returned if no declaration occurred.
2165 : */
2166 :
2167 : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym);
2168 :
2169 : /*
2170 : GetDeclaredFor - returns the token where this forward procedure symbol
2171 : was declared in the program or implementation module.
2172 : UnknownTokenNo is returned if no declaration occurred.
2173 : */
2174 :
2175 : extern "C" unsigned int SymbolTable_GetDeclaredFor (unsigned int Sym);
2176 :
2177 : /*
2178 : GetDeclaredDefinition - returns the token where this symbol
2179 : was declared in the definition module.
2180 : */
2181 :
2182 : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym);
2183 :
2184 : /*
2185 : GetDeclaredModule - returns the token where this symbol was declared
2186 : in an implementation or program module.
2187 : */
2188 :
2189 : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym);
2190 :
2191 : /*
2192 : PutDeclared - adds an entry to symbol, Sym, indicating that it
2193 : was declared at, tok. This routine
2194 : may be called twice, once for definition module
2195 : partial declaration and once when parsing the
2196 : implementation module.
2197 : */
2198 :
2199 : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym);
2200 :
2201 : /*
2202 : GetFirstUsed - returns the token where this symbol was first used.
2203 : */
2204 :
2205 : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym);
2206 :
2207 : /*
2208 : PutProcedureBegin - assigns begin as the token number matching the
2209 : procedure BEGIN.
2210 : */
2211 :
2212 : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin);
2213 :
2214 : /*
2215 : PutProcedureEnd - assigns end as the token number matching the
2216 : procedure END.
2217 : */
2218 :
2219 : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end);
2220 :
2221 : /*
2222 : GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
2223 : */
2224 :
2225 : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end);
2226 :
2227 : /*
2228 : ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
2229 : */
2230 :
2231 : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P);
2232 :
2233 : /*
2234 : ForeachModuleDo - for each module do procedure, P.
2235 : */
2236 :
2237 : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P);
2238 :
2239 : /*
2240 : ForeachInnerModuleDo - for each inner module in module, Sym,
2241 : do procedure, P.
2242 : */
2243 :
2244 : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P);
2245 :
2246 : /*
2247 : IsVarParam - Returns a conditional depending whether parameter ParamNo
2248 : is a VAR parameter.
2249 : */
2250 :
2251 : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
2252 :
2253 : /*
2254 : IsVarParamAny - Returns a conditional depending whether parameter ParamNo
2255 : is a VAR parameter.
2256 : */
2257 :
2258 : extern "C" bool SymbolTable_IsVarParamAny (unsigned int Sym, unsigned int ParamNo);
2259 :
2260 : /*
2261 : IsUnboundedParam - Returns a conditional depending whether parameter
2262 : ParamNo is an unbounded array procedure parameter.
2263 : */
2264 :
2265 : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
2266 : extern "C" bool SymbolTable_IsUnboundedParamAny (unsigned int Sym, unsigned int ParamNo);
2267 :
2268 : /*
2269 : IsParameterUnbounded - returns TRUE if parameter, Sym, is
2270 : unbounded.
2271 : */
2272 :
2273 : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym);
2274 :
2275 : /*
2276 : IsParameterVar - returns true if parameter symbol Sym
2277 : was declared as a VAR.
2278 : */
2279 :
2280 : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym);
2281 :
2282 : /*
2283 : GetParameterShadowVar - returns the local variable associated with the
2284 : parameter symbol, sym.
2285 : */
2286 :
2287 : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym);
2288 :
2289 : /*
2290 : NoOfParam - Returns the number of parameters that procedure Sym contains.
2291 : */
2292 :
2293 : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym, SymbolTable_ProcedureKind kind);
2294 :
2295 : /*
2296 : HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
2297 : */
2298 :
2299 : extern "C" bool SymbolTable_HasVarParameters (unsigned int p);
2300 :
2301 : /*
2302 : NoOfLocalVar - returns the number of local variables that exist in
2303 : procedure Sym. Parameters are NOT included in the
2304 : count.
2305 : */
2306 :
2307 : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym);
2308 :
2309 : /*
2310 : IsDefImp - returns true is the Sym is a DefImp symbol.
2311 : Definition/Implementation module symbol.
2312 : */
2313 :
2314 : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym);
2315 :
2316 : /*
2317 : IsModule - returns true is the Sym is a Module symbol.
2318 : Program module symbol.
2319 : */
2320 :
2321 : extern "C" bool SymbolTable_IsModule (unsigned int Sym);
2322 :
2323 : /*
2324 : IsInnerModule - returns true if the symbol, Sym, is an inner module.
2325 : */
2326 :
2327 : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym);
2328 :
2329 : /*
2330 : GetSymName - returns the symbol name.
2331 : */
2332 :
2333 : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym);
2334 :
2335 : /*
2336 : RenameSym - renames a symbol, Sym, with SymName.
2337 : It also checks the unknown tree for a symbol
2338 : with this new name. Must only be renamed in
2339 : the same scope of being declared.
2340 : */
2341 :
2342 : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName);
2343 :
2344 : /*
2345 : IsUnknown - returns true is the symbol Sym is unknown.
2346 : */
2347 :
2348 : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym);
2349 :
2350 : /*
2351 : IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
2352 : */
2353 :
2354 : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym);
2355 :
2356 : /*
2357 : RequestSym - searches for a symbol with a name SymName in the
2358 : current and previous scopes.
2359 : If the symbol is found then it is returned
2360 : else an unknown symbol is returned create at token
2361 : position, tok.
2362 : This procedure does search the base scope (for
2363 : pervasive identifiers).
2364 : */
2365 :
2366 : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName);
2367 :
2368 : /*
2369 : PutImported - places a symbol, Sym, into the current main scope.
2370 : */
2371 :
2372 : extern "C" void SymbolTable_PutImported (unsigned int Sym);
2373 :
2374 : /*
2375 : PutIncluded - places a symbol, Sym, into the included list of the
2376 : current module.
2377 : Symbols that are placed in this list are indirectly declared
2378 : by:
2379 :
2380 : IMPORT modulename ;
2381 :
2382 : modulename.identifier
2383 : */
2384 :
2385 : extern "C" void SymbolTable_PutIncluded (unsigned int Sym);
2386 :
2387 : /*
2388 : PutExported - places a symbol, Sym into the next level out module.
2389 : Sym is also placed in the ExportTree of the current inner
2390 : module.
2391 : */
2392 :
2393 : extern "C" void SymbolTable_PutExported (unsigned int Sym);
2394 :
2395 : /*
2396 : PutExportQualified - places a symbol with the name, SymName,
2397 : into the export tree of the
2398 : Definition module being compiled.
2399 : The symbol with name has been EXPORT QUALIFIED
2400 : by the definition module and therefore any reference
2401 : to this symbol in the code generation phase
2402 : will be in the form _Module_Name.
2403 : */
2404 :
2405 : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName);
2406 :
2407 : /*
2408 : PutExportUnQualified - places a symbol with the name, SymName,
2409 : into the export tree of the
2410 : Definition module being compiled.
2411 : The symbol with Name has been EXPORT UNQUALIFIED
2412 : by the definition module and therefore any reference
2413 : to this symbol in the code generation phase
2414 : will be in the form _Name.
2415 : */
2416 :
2417 : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName);
2418 :
2419 : /*
2420 : PutExportUnImplemented - places a symbol, Sym, into the currently compiled
2421 : DefImp module NeedToBeImplemented list.
2422 : */
2423 :
2424 : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym);
2425 :
2426 : /*
2427 : GetExported - returns the symbol which has a name SymName,
2428 : and is exported from the definition module ModSym.
2429 :
2430 : */
2431 :
2432 : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName);
2433 :
2434 : /*
2435 : GetFromOuterModule - returns a symbol with name, SymName, which comes
2436 : from outside the current module.
2437 : */
2438 :
2439 : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName);
2440 :
2441 : /*
2442 : TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
2443 : name, name, which is
2444 : currently undefined in the
2445 : outer scope to the inner scope.
2446 : If successful then the symbol is
2447 : returned otherwise NulSym is
2448 : returned.
2449 : */
2450 :
2451 : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name);
2452 :
2453 : /*
2454 : IsExportQualified - returns true if a symbol, Sym, was defined as
2455 : being EXPORT QUALIFIED.
2456 : Sym is expected to be either a procedure or a
2457 : variable.
2458 : */
2459 :
2460 : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym);
2461 :
2462 : /*
2463 : IsExportUnQualified - returns true if a symbol, Sym, was defined as
2464 : being EXPORT UNQUALIFIED.
2465 : */
2466 :
2467 : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym);
2468 :
2469 : /*
2470 : IsExported - returns true if a symbol, Sym, is exported
2471 : from module, ModSym.
2472 : If ModSym is a DefImp symbol then its
2473 : ExportQualified and ExportUnQualified lists are examined.
2474 : */
2475 :
2476 : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym);
2477 :
2478 : /*
2479 : IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
2480 : ModSym must be a defimp symbol.
2481 : */
2482 :
2483 : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym);
2484 :
2485 : /*
2486 : IsImported - returns true if a symbol, Sym, in module, ModSym,
2487 : was imported.
2488 : */
2489 :
2490 : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym);
2491 :
2492 : /*
2493 : PutIncludedByDefinition - places a module symbol, Sym, into the
2494 : included list of the current definition module.
2495 : */
2496 :
2497 : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym);
2498 :
2499 : /*
2500 : IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
2501 : by ModSym's definition module.
2502 : */
2503 :
2504 : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym);
2505 :
2506 : /*
2507 : ForeachImportedDo - calls a procedure, P, foreach imported symbol
2508 : in module, ModSym.
2509 : */
2510 :
2511 : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2512 :
2513 : /*
2514 : ForeachExportedDo - calls a procedure, P, foreach imported symbol
2515 : in module, ModSym.
2516 : */
2517 :
2518 : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2519 :
2520 : /*
2521 : CheckForExportedImplementation - checks to see whether an implementation
2522 : module is currently being compiled, if so,
2523 : symbol, Sym, is removed from the
2524 : NeedToBeImplemented list.
2525 : This procedure is called whenever a symbol
2526 : is declared, thus attempting to reduce
2527 : the NeedToBeImplemented list.
2528 : Only needs to be called when a TYPE or
2529 : PROCEDURE is built since the implementation
2530 : module can only implement these objects
2531 : declared in the definition module.
2532 :
2533 : It also checks whether a definition module
2534 : is currently being compiled and, if so,
2535 : it will ensure that symbol, Sym, is removed
2536 : from the ExportRequest list. If Sym is an
2537 : enumerated type it ensures that its fields
2538 : are also removed.
2539 : */
2540 :
2541 : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym);
2542 :
2543 : /*
2544 : CheckForUnImplementedExports - displays an error and the offending symbols
2545 : which have been exported but not implemented
2546 : from the current compiled module.
2547 : */
2548 :
2549 : extern "C" void SymbolTable_CheckForUnImplementedExports (void);
2550 :
2551 : /*
2552 : CheckForUndeclaredExports - displays an error and the offending symbols
2553 : which have been exported but not declared
2554 : from module, ModSym.
2555 : */
2556 :
2557 : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym);
2558 :
2559 : /*
2560 : CheckForUnknownInModule - checks for any unknown symbols in the
2561 : current module.
2562 : If any unknown symbols are found then
2563 : an error message is displayed.
2564 : */
2565 :
2566 : extern "C" void SymbolTable_CheckForUnknownInModule (unsigned int tokno);
2567 :
2568 : /*
2569 : UnknownReported - if sym is an unknown symbol and has not been reported
2570 : then include it into the set of reported unknowns.
2571 : */
2572 :
2573 : extern "C" void SymbolTable_UnknownReported (unsigned int sym);
2574 :
2575 : /*
2576 : GetUnknownOnImport - returns the onimport field of unknown sym.
2577 : */
2578 :
2579 : extern "C" bool SymbolTable_GetUnknownOnImport (unsigned int sym);
2580 :
2581 : /*
2582 : GetUnknownDeclScope - returns the decl scope of unknown sym.
2583 : */
2584 :
2585 : extern "C" unsigned int SymbolTable_GetUnknownDeclScope (unsigned int sym);
2586 :
2587 : /*
2588 : IsReallyPointer - returns TRUE is sym is a pointer, address or a
2589 : type declared as a pointer or address.
2590 : */
2591 :
2592 : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym);
2593 :
2594 : /*
2595 : CheckHiddenTypeAreAddress - checks to see that any hidden types
2596 : which we have declared are actually
2597 : of type ADDRESS or map onto a POINTER type.
2598 : */
2599 :
2600 : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void);
2601 :
2602 : /*
2603 : PutDefinitionForC - sets a flag in the current compiled module which
2604 : indicates that this module is a wrapper for a C
2605 : file. Parameters passes to procedures in this module
2606 : will adopt the C calling convention.
2607 : */
2608 :
2609 : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym);
2610 :
2611 : /*
2612 : IsDefinitionForC - returns true if this definition module was declared
2613 : as a DEFINITION MODULE FOR "C".
2614 : */
2615 :
2616 : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym);
2617 :
2618 : /*
2619 : PutDoesNeedExportList - sets a flag in module, Sym, which
2620 : indicates that this module requires an explicit
2621 : EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
2622 : */
2623 :
2624 : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym);
2625 :
2626 : /*
2627 : PutDoesNotNeedExportList - sets a flag in module, Sym, which
2628 : indicates that this module does not require an explicit
2629 : EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
2630 : */
2631 :
2632 : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym);
2633 :
2634 : /*
2635 : DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
2636 : EXPORT QUALIFIED list.
2637 : */
2638 :
2639 : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym);
2640 :
2641 : /*
2642 : CheckForEnumerationInCurrentModule - checks to see whether the enumeration
2643 : type symbol, Sym, has been entered into
2644 : the current modules scope list.
2645 : */
2646 :
2647 : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym);
2648 :
2649 : /*
2650 : SanityCheckConstants - must only be called once all constants, types, procedures
2651 : have been declared. It checks to see that constants are
2652 : not used as procedure parameter types.
2653 : */
2654 :
2655 : extern "C" void SymbolTable_SanityCheckConstants (void);
2656 :
2657 : /*
2658 : ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
2659 : perform the procedure, P.
2660 : */
2661 :
2662 : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2663 :
2664 : /*
2665 : ForeachParamSymDo - foreach parameter symbol in procedure Sym
2666 : perform the procedure P. Each symbol
2667 : looked up will be VarParam or Param
2668 : (not the shadow variable). Every parameter
2669 : from each KindProcedure is iterated over.
2670 : */
2671 :
2672 : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2673 :
2674 : /*
2675 : ForeachFieldEnumerationDo - for each field in enumeration, Sym,
2676 : do procedure, P. Each call to P contains
2677 : an enumeration field, the order is alphabetical.
2678 : Use ForeachLocalSymDo for declaration order.
2679 : */
2680 :
2681 : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P);
2682 :
2683 : /*
2684 : IsType - returns true if the Sym is a type symbol.
2685 : */
2686 :
2687 : extern "C" bool SymbolTable_IsType (unsigned int Sym);
2688 :
2689 : /*
2690 : IsProcedure - returns true if Sym is a procedure symbol.
2691 : */
2692 :
2693 : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym);
2694 :
2695 : /*
2696 : IsParameter - returns true if Sym is a parameter symbol.
2697 : */
2698 :
2699 : extern "C" bool SymbolTable_IsParameter (unsigned int Sym);
2700 :
2701 : /*
2702 : GetProcedureKind - returns the procedure kind given the declaration tok.
2703 : The declaration tok must match the ident tok in the
2704 : procedure name. It is only safe to call this
2705 : procedure function during pass 2 onwards.
2706 : */
2707 :
2708 : extern "C" SymbolTable_ProcedureKind SymbolTable_GetProcedureKind (unsigned int sym, unsigned int tok);
2709 :
2710 : /*
2711 : GetProcedureDeclaredTok - return the token where the
2712 : declaration of procedure sym:kind
2713 : occurred.
2714 : */
2715 :
2716 : extern "C" unsigned int SymbolTable_GetProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind);
2717 :
2718 : /*
2719 : PutProcedureDeclaredTok - places the tok where the
2720 : declaration of procedure sym:kind
2721 : occurred.
2722 : */
2723 :
2724 : extern "C" void SymbolTable_PutProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok);
2725 :
2726 : /*
2727 : GetReturnTypeTok - return the token where the
2728 : return type procedure sym:kind or proctype
2729 : was defined.
2730 : */
2731 :
2732 : extern "C" unsigned int SymbolTable_GetReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind);
2733 :
2734 : /*
2735 : PutReturnTypeTok - places the tok where the
2736 : return type of procedure sym:kind or proctype
2737 : was defined.
2738 : */
2739 :
2740 : extern "C" void SymbolTable_PutReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok);
2741 :
2742 : /*
2743 : PutProcedureParametersDefined - the procedure symbol sym:kind
2744 : parameters have been defined.
2745 : */
2746 :
2747 : extern "C" void SymbolTable_PutProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2748 :
2749 : /*
2750 : GetProcedureParametersDefined - returns true if procedure symbol sym:kind
2751 : parameters are defined.
2752 : */
2753 :
2754 : extern "C" bool SymbolTable_GetProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2755 :
2756 : /*
2757 : PutProcedureDefined - the procedure symbol sym:kind is defined.
2758 : */
2759 :
2760 : extern "C" void SymbolTable_PutProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2761 :
2762 : /*
2763 : GetProcedureDefined - returns true if procedure symbol sym:kind
2764 : is defined.
2765 : */
2766 :
2767 : extern "C" bool SymbolTable_GetProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2768 :
2769 : /*
2770 : PutUseVarArgs - tell the symbol table that this procedure, Sym,
2771 : uses varargs.
2772 : The procedure _must_ be declared inside a
2773 : DEFINITION FOR "C"
2774 :
2775 : */
2776 :
2777 : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym);
2778 :
2779 : /*
2780 : UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
2781 : The procedure _must_ be declared inside a
2782 : DEFINITION FOR "C"
2783 : */
2784 :
2785 : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym);
2786 :
2787 : /*
2788 : PutUseOptArg - tell the symbol table that this procedure, Sym,
2789 : uses an optarg.
2790 : */
2791 :
2792 : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind);
2793 :
2794 : /*
2795 : UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
2796 : */
2797 :
2798 : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind);
2799 :
2800 : /*
2801 : PutOptArgInit - makes symbol, Sym, the initializer value to
2802 : procedure, ProcSym.
2803 : */
2804 :
2805 : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym);
2806 :
2807 : /*
2808 : GetOptArgInit - returns the initializer value to the optional parameter in
2809 : procedure, ProcSym.
2810 : */
2811 :
2812 : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym);
2813 :
2814 : /*
2815 : MakePointer - returns a pointer symbol with PointerName.
2816 : */
2817 :
2818 : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName);
2819 :
2820 : /*
2821 : PutPointer - gives a pointer symbol a type, PointerType.
2822 : */
2823 :
2824 : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType);
2825 :
2826 : /*
2827 : IsPointer - returns true is Sym is a pointer type symbol.
2828 : */
2829 :
2830 : extern "C" bool SymbolTable_IsPointer (unsigned int Sym);
2831 :
2832 : /*
2833 : IsRecord - returns true is Sym is a record type symbol.
2834 : */
2835 :
2836 : extern "C" bool SymbolTable_IsRecord (unsigned int Sym);
2837 :
2838 : /*
2839 : IsVarient - returns true if the symbol, Sym, is a
2840 : varient symbol.
2841 : */
2842 :
2843 : extern "C" bool SymbolTable_IsVarient (unsigned int Sym);
2844 :
2845 : /*
2846 : IsFieldVarient - returns true if the symbol, Sym, is a
2847 : varient field.
2848 : */
2849 :
2850 : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym);
2851 :
2852 : /*
2853 : IsFieldEnumeration - returns true if the symbol, Sym, is an
2854 : enumeration field.
2855 : */
2856 :
2857 : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym);
2858 :
2859 : /*
2860 : IsArray - returns true is Sym is an array type symbol.
2861 : */
2862 :
2863 : extern "C" bool SymbolTable_IsArray (unsigned int Sym);
2864 :
2865 : /*
2866 : IsEnumeration - returns true if Sym is an enumeration symbol.
2867 : */
2868 :
2869 : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym);
2870 :
2871 : /*
2872 : IsSet - returns TRUE if Sym is a set symbol.
2873 : */
2874 :
2875 : extern "C" bool SymbolTable_IsSet (unsigned int Sym);
2876 :
2877 : /*
2878 : IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
2879 : */
2880 :
2881 : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym);
2882 :
2883 : /*
2884 : IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
2885 : */
2886 :
2887 : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym);
2888 :
2889 : /*
2890 : GetDimension - return the number of dimensions associated with
2891 : this unbounded ARRAY parameter.
2892 : */
2893 :
2894 : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym);
2895 :
2896 : /*
2897 : MakeOAFamily - makes an OAFamily symbol based on SimpleType.
2898 : It returns the OAFamily symbol. A new symbol
2899 : is created if one does not already exist for
2900 : SimpleType.
2901 : */
2902 :
2903 : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType);
2904 :
2905 : /*
2906 : GetOAFamily - returns the oafamily symbol associated with
2907 : SimpleType.
2908 : */
2909 :
2910 : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType);
2911 :
2912 : /*
2913 : ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
2914 : sym, in the oaf.
2915 : */
2916 :
2917 : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p);
2918 :
2919 : /*
2920 : IsUnbounded - returns true if Sym is an unbounded symbol.
2921 : */
2922 :
2923 : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym);
2924 :
2925 : /*
2926 : GetUnbounded - returns the unbounded symbol associated with
2927 : the OAFamily symbol, oaf, and the number of
2928 : dimensions, ndim, of the open array.
2929 : */
2930 :
2931 : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim);
2932 :
2933 : /*
2934 : GetUnboundedRecordType - returns the record type used to
2935 : implement the unbounded array.
2936 : */
2937 :
2938 : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym);
2939 :
2940 : /*
2941 : GetUnboundedAddressOffset - returns the offset of the address field
2942 : inside the record used to implement the
2943 : unbounded type.
2944 : */
2945 :
2946 : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym);
2947 :
2948 : /*
2949 : GetUnboundedHighOffset - returns the offset of the high field
2950 : inside the record used to implement the
2951 : unbounded type.
2952 : */
2953 :
2954 : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim);
2955 :
2956 : /*
2957 : MakeSubscript - makes a subscript Symbol.
2958 : No name is required.
2959 : */
2960 :
2961 : extern "C" unsigned int SymbolTable_MakeSubscript (void);
2962 :
2963 : /*
2964 : PutSubscript - gives a subscript symbol a type, SimpleType.
2965 : */
2966 :
2967 : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType);
2968 :
2969 : /*
2970 : MakeUnbounded - makes an unbounded array Symbol.
2971 : ndim is the number of dimensions required.
2972 : No name is required.
2973 : */
2974 :
2975 : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim);
2976 :
2977 : /*
2978 : NoOfElements - Returns the number of elements in array Sym,
2979 : or the number of elements in an enumeration Sym or
2980 : the number of interface symbols in an Interface list.
2981 : */
2982 :
2983 : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym);
2984 :
2985 : /*
2986 : PutArray - places a type symbol into an arraysym.
2987 : */
2988 :
2989 : extern "C" void SymbolTable_PutArray (unsigned int arraysym, unsigned int typesym);
2990 :
2991 : /*
2992 : ResolveImports - it examines the import list of all inner modules
2993 : and resolves all relative imports.
2994 : */
2995 :
2996 : extern "C" void SymbolTable_ResolveImports (void);
2997 :
2998 : /*
2999 : ResolveConstructorTypes - to be called at the end of pass three. Its
3000 : purpose is to fix up all constructors whose
3001 : types are unknown.
3002 : */
3003 :
3004 : extern "C" void SymbolTable_ResolveConstructorTypes (void);
3005 :
3006 : /*
3007 : AddNameToScope - adds a Name, n, to the list of objects declared at the
3008 : current scope.
3009 : */
3010 :
3011 : extern "C" void SymbolTable_AddNameToScope (unsigned int tok, NameKey_Name n);
3012 :
3013 : /*
3014 : AddNameToImportList - adds a Name, n, to the import list of the current
3015 : module.
3016 : */
3017 :
3018 : extern "C" void SymbolTable_AddNameToImportList (unsigned int tok, NameKey_Name n);
3019 :
3020 : /*
3021 : GetScope - returns the declaration scope of the symbol.
3022 : */
3023 :
3024 : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym);
3025 :
3026 : /*
3027 : GetModuleScope - returns the module scope of symbol, sym.
3028 : If sym was declared within a nested procedure
3029 : then return the module which defines the
3030 : procedure.
3031 : */
3032 :
3033 : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym);
3034 :
3035 : /*
3036 : GetProcedureScope - returns the innermost procedure (if any)
3037 : in which the symbol, sym, resides.
3038 : A module inside the procedure is skipped
3039 : over.
3040 : */
3041 :
3042 : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym);
3043 :
3044 : /*
3045 : IsModuleWithinProcedure - returns TRUE if module, sym, is
3046 : inside a procedure.
3047 : */
3048 :
3049 : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym);
3050 :
3051 : /*
3052 : GetParent - returns the parent of symbol, Sym.
3053 : */
3054 :
3055 : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym);
3056 :
3057 : /*
3058 : IsRecordField - returns true if Sym is a record field.
3059 : */
3060 :
3061 : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym);
3062 :
3063 : /*
3064 : MakeProcType - returns a procedure type symbol with ProcTypeName.
3065 : */
3066 :
3067 : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName);
3068 :
3069 : /*
3070 : PutProcTypeParam - Places a Non VAR parameter ParamName with type
3071 : ParamType into ProcType Sym.
3072 : */
3073 :
3074 : extern "C" void SymbolTable_PutProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded);
3075 :
3076 : /*
3077 : PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
3078 : ParamType into ProcType Sym.
3079 : */
3080 :
3081 : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded);
3082 :
3083 : /*
3084 : IsProcType - returns true if Sym is a ProcType Symbol.
3085 : */
3086 :
3087 : extern "C" bool SymbolTable_IsProcType (unsigned int Sym);
3088 :
3089 : /*
3090 : IsVar - returns true if Sym is a Var Symbol.
3091 : */
3092 :
3093 : extern "C" bool SymbolTable_IsVar (unsigned int Sym);
3094 :
3095 : /*
3096 : IsVarConst - returns the IsConst field indicating the variable is read only.
3097 : */
3098 :
3099 : extern "C" bool SymbolTable_IsVarConst (unsigned int sym);
3100 :
3101 : /*
3102 : IsConst - returns true if Sym contains a constant value.
3103 : */
3104 :
3105 : extern "C" bool SymbolTable_IsConst (unsigned int Sym);
3106 :
3107 : /*
3108 : IsConstString - returns whether sym is a conststring of any variant.
3109 : */
3110 :
3111 : extern "C" bool SymbolTable_IsConstString (unsigned int sym);
3112 :
3113 : /*
3114 : IsConstStringNulTerminated - returns TRUE if the constant string, sym,
3115 : should be created with a nul terminator.
3116 : */
3117 :
3118 : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym);
3119 :
3120 : /*
3121 : IsConstLit - returns true if Sym is a literal constant.
3122 : */
3123 :
3124 : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym);
3125 :
3126 : /*
3127 : IsConstructor - returns TRUE if the constant is declared as a
3128 : constant set, array or record.
3129 : */
3130 :
3131 : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym);
3132 :
3133 : /*
3134 : IsDummy - returns true if Sym is a Dummy symbol.
3135 : */
3136 :
3137 : extern "C" bool SymbolTable_IsDummy (unsigned int Sym);
3138 :
3139 : /*
3140 : IsTemporary - returns true if Sym is a Temporary symbol.
3141 : */
3142 :
3143 : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym);
3144 :
3145 : /*
3146 : IsVarAParam - returns true if Sym is a variable declared as a parameter.
3147 : */
3148 :
3149 : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym);
3150 :
3151 : /*
3152 : IsSubscript - returns true if Sym is a subscript symbol.
3153 : */
3154 :
3155 : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym);
3156 :
3157 : /*
3158 : IsSubrange - returns true if Sym is a subrange symbol.
3159 : */
3160 :
3161 : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym);
3162 :
3163 : /*
3164 : IsProcedureVariable - returns true if a Sym is a variable and
3165 : it was declared within a procedure.
3166 : */
3167 :
3168 : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym);
3169 :
3170 : /*
3171 : IsProcedureNested - returns TRUE if procedure, Sym, was
3172 : declared as a nested procedure.
3173 : */
3174 :
3175 : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym);
3176 :
3177 : /*
3178 : IsAModula2Type - returns true if Sym, is a:
3179 : IsType, IsPointer, IsRecord, IsEnumeration,
3180 : IsSubrange, IsArray, IsUnbounded, IsProcType.
3181 : NOTE that it different from IsType.
3182 : */
3183 :
3184 : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym);
3185 :
3186 : /*
3187 : IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
3188 : */
3189 :
3190 : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym);
3191 :
3192 : /*
3193 : IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
3194 : */
3195 :
3196 : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym);
3197 :
3198 : /*
3199 : IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
3200 : */
3201 :
3202 : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym);
3203 :
3204 : /*
3205 : IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
3206 : */
3207 :
3208 : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym);
3209 :
3210 : /*
3211 : IsSizeSolved - returns true if the size of Sym is solved.
3212 : */
3213 :
3214 : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym);
3215 :
3216 : /*
3217 : IsOffsetSolved - returns true if the Offset of Sym is solved.
3218 : */
3219 :
3220 : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym);
3221 :
3222 : /*
3223 : IsValueSolved - returns true if the value of Sym is solved.
3224 : */
3225 :
3226 : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym);
3227 :
3228 : /*
3229 : IsConstructorConstant - returns TRUE if constructor, Sym, is
3230 : defined by only constants.
3231 : */
3232 :
3233 : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym);
3234 :
3235 : /*
3236 : IsComposite - returns TRUE if symbol, sym, is a composite
3237 : type: ie an ARRAY or RECORD.
3238 : */
3239 :
3240 : extern "C" bool SymbolTable_IsComposite (unsigned int sym);
3241 :
3242 : /*
3243 : IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
3244 : */
3245 :
3246 : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym);
3247 :
3248 : /*
3249 : PutAlignment - assigns the alignment constant associated with,
3250 : type, with, align.
3251 : */
3252 :
3253 : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align);
3254 :
3255 : /*
3256 : GetAlignment - returns the alignment constant associated with,
3257 : type.
3258 : */
3259 :
3260 : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type);
3261 :
3262 : /*
3263 : GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
3264 : to record, sym.
3265 : */
3266 :
3267 : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym);
3268 :
3269 : /*
3270 : PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
3271 : to record, sym.
3272 : */
3273 :
3274 : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align);
3275 :
3276 : /*
3277 : PutUnused - sets, sym, as unused. This is a gm2 pragma.
3278 : */
3279 :
3280 : extern "C" void SymbolTable_PutUnused (unsigned int sym);
3281 :
3282 : /*
3283 : IsUnused - returns TRUE if the symbol was declared as unused with a
3284 : gm2 pragma.
3285 : */
3286 :
3287 : extern "C" bool SymbolTable_IsUnused (unsigned int sym);
3288 :
3289 : /*
3290 : PutDeclaredPacked - sets the Packed field of the record or record field symbol.
3291 : */
3292 :
3293 : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b);
3294 :
3295 : /*
3296 : IsDeclaredPacked - was the record symbol or record field, sym,
3297 : declared as packed?
3298 : */
3299 :
3300 : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym);
3301 :
3302 : /*
3303 : IsDeclaredPackedResolved - do we know if the record symbol or record
3304 : field, sym, declared as packed or not packed?
3305 : */
3306 :
3307 : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym);
3308 :
3309 : /*
3310 : GetPackedEquivalent - returns the packed equivalent of type, sym.
3311 : sym must be a type, subrange or enumerated type.
3312 : */
3313 :
3314 : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym);
3315 :
3316 : /*
3317 : GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
3318 : */
3319 :
3320 : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym);
3321 :
3322 : /*
3323 : IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
3324 : */
3325 :
3326 : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym);
3327 :
3328 : /*
3329 : PushSize - pushes the size of Sym.
3330 : */
3331 :
3332 : extern "C" void SymbolTable_PushSize (unsigned int Sym);
3333 :
3334 : /*
3335 : PopSize - pops the ALU stack into Size of Sym.
3336 : */
3337 :
3338 : extern "C" void SymbolTable_PopSize (unsigned int Sym);
3339 :
3340 : /*
3341 : PushValue - pushes the Value of Sym onto the ALU stack.
3342 : */
3343 :
3344 : extern "C" void SymbolTable_PushValue (unsigned int Sym);
3345 :
3346 : /*
3347 : PushVarSize - pushes the size of a variable, Sym.
3348 : The runtime size of Sym will depend upon its addressing mode,
3349 : RightValue has size PushSize(GetType(Sym)) and
3350 : LeftValue has size PushSize(Address) since it points to a
3351 : variable.
3352 : */
3353 :
3354 : extern "C" void SymbolTable_PushVarSize (unsigned int Sym);
3355 :
3356 : /*
3357 : PopValue - pops the ALU stack into Value of Sym.
3358 : */
3359 :
3360 : extern "C" void SymbolTable_PopValue (unsigned int Sym);
3361 :
3362 : /*
3363 : IsObject - returns TRUE if the symbol is an object symbol.
3364 : */
3365 :
3366 : extern "C" bool SymbolTable_IsObject (unsigned int Sym);
3367 :
3368 : /*
3369 : IsTuple - returns TRUE if the symbol is a tuple symbol.
3370 : */
3371 :
3372 : extern "C" bool SymbolTable_IsTuple (unsigned int Sym);
3373 :
3374 : /*
3375 : Make2Tuple - creates and returns a 2 tuple from, a, and, b.
3376 : */
3377 :
3378 : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b);
3379 :
3380 : /*
3381 : MakeError - creates an error node, which can be used in MetaError messages.
3382 : It will be removed from ExportUndeclared and Unknown trees.
3383 : */
3384 :
3385 : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name);
3386 :
3387 : /*
3388 : MakeErrorS - creates an error node from a string, which can be used
3389 : in MetaError messages.
3390 : It will be removed from ExportUndeclared and Unknown trees.
3391 : */
3392 :
3393 : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name);
3394 :
3395 : /*
3396 : IsError - returns TRUE if the symbol is an error symbol.
3397 : */
3398 :
3399 : extern "C" bool SymbolTable_IsError (unsigned int Sym);
3400 :
3401 : /*
3402 : IsLegal - returns TRUE if, sym, is a legal symbol.
3403 : */
3404 :
3405 : extern "C" bool SymbolTable_IsLegal (unsigned int sym);
3406 :
3407 : /*
3408 : PutModuleContainsBuiltin - sets a flag in the current compiled module which
3409 : indicates that a builtin procedure is being declared.
3410 : This is only expected to be called when we are
3411 : parsing the definition module.
3412 : */
3413 :
3414 : extern "C" void SymbolTable_PutModuleContainsBuiltin (void);
3415 :
3416 : /*
3417 : IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
3418 : */
3419 :
3420 : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym);
3421 :
3422 : /*
3423 : PutHiddenTypeDeclared - sets a flag in the current compiled module which
3424 : indicates that a Hidden Type is declared within
3425 : the implementation part of the module.
3426 : This procedure is expected to be called while
3427 : compiling the associated definition module.
3428 : */
3429 :
3430 : extern "C" void SymbolTable_PutHiddenTypeDeclared (void);
3431 :
3432 : /*
3433 : IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
3434 : the module, Sym.
3435 : */
3436 :
3437 : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym);
3438 :
3439 : /*
3440 : IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
3441 : type declared as a pointer or address.
3442 : */
3443 :
3444 : extern "C" bool SymbolTable_IsHiddenReallyPointer (unsigned int Sym);
3445 :
3446 : /*
3447 : DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
3448 : */
3449 :
3450 : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym);
3451 :
3452 : /*
3453 : DebugLineNumbers - internal debugging, emit all procedure names in this module
3454 : together with the line numbers for the corresponding begin/end
3455 : tokens.
3456 : */
3457 :
3458 : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym);
3459 :
3460 : /*
3461 : GetErrorScope - returns the error scope for a symbol.
3462 : The error scope is the title scope which is used to
3463 : announce the symbol in the GCC error message.
3464 : */
3465 :
3466 : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym);
3467 :
3468 : /*
3469 : MakeImport - create and return an import symbol.
3470 : moduleSym is the symbol being imported.
3471 : isqualified is FALSE if it were IMPORT modulename and
3472 : TRUE for the qualified FROM modulename IMPORT etc.
3473 : listno is the import list count for this module.
3474 : tok should match this modulename position.
3475 : */
3476 :
3477 : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified);
3478 :
3479 : /*
3480 : MakeImportStatement - return a dependent symbol which represents an import statement
3481 : or a qualified import statement. The tok should either match
3482 : the FROM token or the IMPORT token. listno is the import list
3483 : count for the module.
3484 : */
3485 :
3486 : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno);
3487 :
3488 : /*
3489 : IsImport - returns TRUE if sym is an import symbol.
3490 : */
3491 :
3492 : extern "C" bool SymbolTable_IsImport (unsigned int sym);
3493 :
3494 : /*
3495 : IsImportStatement - returns TRUE if sym is a dependent symbol.
3496 : */
3497 :
3498 : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym);
3499 :
3500 : /*
3501 : GetImportModule - returns the module associated with the import symbol.
3502 : */
3503 :
3504 : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym);
3505 :
3506 : /*
3507 : GetImportDeclared - returns the token associated with the import symbol.
3508 : */
3509 :
3510 : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym);
3511 :
3512 : /*
3513 : GetImportStatementList - returns the list of imports for this dependent.
3514 : Each import symbol corresponds to a module.
3515 : */
3516 :
3517 : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym);
3518 :
3519 : /*
3520 : GetModuleDefImportStatementList - returns the list of dependents associated with
3521 : the definition module.
3522 : */
3523 :
3524 : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym);
3525 :
3526 : /*
3527 : GetModuleModImportStatementList - returns the list of dependents associated with
3528 : the implementation or program module.
3529 : */
3530 :
3531 : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym);
3532 :
3533 : /*
3534 : AppendModuleImportStatement - appends the ImportStatement symbol onto the
3535 : module import list.
3536 :
3537 : For example:
3538 :
3539 : FROM x IMPORT y, z ;
3540 : ^^^^
3541 :
3542 : also:
3543 :
3544 : IMPORT p, q, r;
3545 : ^^^^^^
3546 : will result in a new ImportStatement symbol added
3547 : to the current module import list.
3548 : The statement symbol is expected to be created
3549 : by MakeImportStatement using the token positions
3550 : outlined above.
3551 : */
3552 :
3553 : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement);
3554 :
3555 : /*
3556 : AppendModuleOnImportStatement - appends the import symbol onto the
3557 : dependent list (chain).
3558 :
3559 : For example each:
3560 :
3561 : FROM x IMPORT y, z ;
3562 : ^
3563 : x are added to the dependent list.
3564 :
3565 : also:
3566 :
3567 : IMPORT p, q, r;
3568 : ^ ^ ^
3569 : will result in p, q and r added to
3570 : to the dependent list.
3571 :
3572 : The import symbol is created by MakeImport
3573 : and the token is expected to match the module
3574 : name position outlined above.
3575 : */
3576 :
3577 : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import);
3578 :
3579 : /*
3580 : PutModLink - assigns link to module sym.
3581 : */
3582 :
3583 : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link);
3584 :
3585 : /*
3586 : IsModLink - returns the ModLink value associated with the module symbol.
3587 : */
3588 :
3589 : extern "C" bool SymbolTable_IsModLink (unsigned int sym);
3590 :
3591 : /*
3592 : PutDefLink - assigns link to the definition module sym.
3593 : */
3594 :
3595 : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link);
3596 :
3597 : /*
3598 : IsDefLink - returns the DefLink value associated with the definition module symbol.
3599 : */
3600 :
3601 : extern "C" bool SymbolTable_IsDefLink (unsigned int sym);
3602 :
3603 : /*
3604 : IsModuleBuiltin - returns TRUE if the module is a builtin module.
3605 : (For example _BaseTypes).
3606 : */
3607 :
3608 : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym);
3609 :
3610 : /*
3611 : PutModuleBuiltin - sets the Builtin flag to value.
3612 : Currently the procedure expects sym to be a DefImp
3613 : module only.
3614 : */
3615 :
3616 : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value);
3617 :
3618 : /*
3619 : PutVarArrayRef - assigns ArrayRef field with value.
3620 : */
3621 :
3622 : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value);
3623 :
3624 : /*
3625 : IsVarArrayRef - returns ArrayRef field value.
3626 : */
3627 :
3628 : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym);
3629 :
3630 : /*
3631 : VarCheckReadInit - returns TRUE if sym has been initialized.
3632 : */
3633 :
3634 : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode);
3635 :
3636 : /*
3637 : VarInitState - initializes the init state for variable sym.
3638 : */
3639 :
3640 : extern "C" void SymbolTable_VarInitState (unsigned int sym);
3641 :
3642 : /*
3643 : PutVarInitialized - set sym as initialized.
3644 : */
3645 :
3646 : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode);
3647 :
3648 : /*
3649 : PutVarFieldInitialized - records that field has been initialized with
3650 : variable sym. TRUE is returned if the field
3651 : is detected and changed to initialized.
3652 : */
3653 :
3654 : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
3655 :
3656 : /*
3657 : GetVarFieldInitialized - return TRUE if fieldlist has been initialized
3658 : within variable sym.
3659 : */
3660 :
3661 : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
3662 :
3663 : /*
3664 : PrintInitialized - display variable sym initialization state.
3665 : */
3666 :
3667 : extern "C" void SymbolTable_PrintInitialized (unsigned int sym);
3668 :
3669 : /*
3670 : GetParameterHeapVar - return the heap variable associated with the
3671 : parameter or NulSym.
3672 : */
3673 :
3674 : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym);
3675 :
3676 : /*
3677 : PutProcedureParameterHeapVars - creates heap variables for parameter sym.
3678 : */
3679 :
3680 : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym);
3681 :
3682 : /*
3683 : IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
3684 : for the target architecture.
3685 : */
3686 :
3687 : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure);
3688 :
3689 : /*
3690 : PutConstLitInternal - marks the sym as being an internal constant.
3691 : Currently this is used when generating a default
3692 : BY constant expression during a FOR loop.
3693 : A constant marked as internal will always pass
3694 : an expression type check.
3695 : */
3696 :
3697 : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value);
3698 :
3699 : /*
3700 : IsConstLitInternal - returns the value of the IsInternal field within
3701 : a constant expression.
3702 : */
3703 :
3704 : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym);
3705 :
3706 : /*
3707 : GetVarDeclTypeTok - returns the TypeTok field associate with variable sym.
3708 : */
3709 :
3710 : extern "C" unsigned int SymbolTable_GetVarDeclTypeTok (unsigned int sym);
3711 :
3712 : /*
3713 : PutVarDeclTypeTok - assigns the TypeTok field to typetok.
3714 : sym can be a variable or parameter.
3715 : */
3716 :
3717 : extern "C" void SymbolTable_PutVarDeclTypeTok (unsigned int sym, unsigned int typetok);
3718 :
3719 : /*
3720 : GetVarDeclTok - returns the TypeTok field associate with variable sym.
3721 : */
3722 :
3723 : extern "C" unsigned int SymbolTable_GetVarDeclTok (unsigned int sym);
3724 :
3725 : /*
3726 : PutVarDeclTok - assigns the VarTok field to typetok.
3727 : sym can be a variable or parameter.
3728 : */
3729 :
3730 : extern "C" void SymbolTable_PutVarDeclTok (unsigned int sym, unsigned int vartok);
3731 :
3732 : /*
3733 : GetVarDeclFullTok - returns the full virtual token containing var: type.
3734 : */
3735 :
3736 : extern "C" unsigned int SymbolTable_GetVarDeclFullTok (unsigned int sym);
3737 :
3738 : /*
3739 : IsProcedureAnyNoReturn - return TRUE if any of the defined kinds
3740 : of procedure sym is declared no return.
3741 : */
3742 :
3743 : extern "C" bool SymbolTable_IsProcedureAnyNoReturn (unsigned int sym);
3744 :
3745 : /*
3746 : GetNthParamAny - returns the nth parameter from the order
3747 : proper procedure, forward declaration
3748 : or definition module procedure.
3749 : */
3750 :
3751 : extern "C" unsigned int SymbolTable_GetNthParamAny (unsigned int sym, unsigned int ParamNo);
3752 :
3753 : /*
3754 : NoOfParamAny - return the number of parameters for sym.
3755 : */
3756 :
3757 : extern "C" unsigned int SymbolTable_NoOfParamAny (unsigned int sym);
3758 :
3759 : /*
3760 : SetReturnOptional - sets the ReturnOptional field in the Procedure:kind or
3761 : ProcType symboltable entry.
3762 : */
3763 :
3764 : extern "C" void SymbolTable_SetReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind, bool isopt);
3765 :
3766 : /*
3767 : UsesOptArgAny - returns TRUE if procedure Sym:kind uses an optional argument.
3768 : */
3769 :
3770 : extern "C" bool SymbolTable_UsesOptArgAny (unsigned int Sym);
3771 :
3772 : /*
3773 : GetProcedureKindDesc - return a string describing kind.
3774 : */
3775 :
3776 : extern "C" DynamicStrings_String SymbolTable_GetProcedureKindDesc (SymbolTable_ProcedureKind kind);
3777 :
3778 : /*
3779 : GetNthParamAnyClosest - returns the nth parameter from the order
3780 : proper procedure, forward declaration
3781 : or definition module procedure.
3782 : It chooses the parameter which is closest
3783 : in source terms to currentmodule.
3784 : The same module will return using the order
3785 : proper procedure, forward procedure, definition module.
3786 : Whereas an imported procedure will choose from
3787 : DefProcedure, ProperProcedure, ForwardProcedure.
3788 : */
3789 :
3790 : extern "C" unsigned int SymbolTable_GetNthParamAnyClosest (unsigned int sym, unsigned int ParamNo, unsigned int currentmodule);
3791 :
3792 : /*
3793 : IsConstVar - returns TRUE if sym is a const var. This is a
3794 : constant which might be assigned to TRUE or FALSE
3795 : depending upon the result of the quad stack control flow.
3796 : Typically used in CONST foo = (a AND b) or similar.
3797 : This symbol will only be assigned once with a value, but
3798 : will appear more than once as a designator to an assignment
3799 : in the quad table. However as the quad table is reduced
3800 : only one assignment will remain. If after reducing quads
3801 : two or more assignments remain, then there is an error
3802 : as sym should not have been declared a constant.
3803 : */
3804 :
3805 : extern "C" bool SymbolTable_IsConstVar (unsigned int sym);
3806 : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at);
3807 :
3808 : /*
3809 : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
3810 : */
3811 :
3812 : static void InitWhereDeclared (SymbolTable_Where *at);
3813 :
3814 : /*
3815 : InitWhereFirstUsed - sets the FirstUsed field of record, at.
3816 : */
3817 :
3818 : static void InitWhereFirstUsed (SymbolTable_Where *at);
3819 :
3820 : /*
3821 : InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
3822 : */
3823 :
3824 : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at);
3825 :
3826 : /*
3827 : gdbhook - a debugger convenience hook.
3828 : */
3829 :
3830 : static void gdbhook (void);
3831 :
3832 : /*
3833 : BreakWhenSymCreated - to be called interactively by gdb.
3834 : */
3835 :
3836 : static void BreakWhenSymCreated (unsigned int sym);
3837 :
3838 : /*
3839 : CheckBreak - if sym = BreakSym then call gdbhook.
3840 : */
3841 :
3842 : static void CheckBreak (unsigned int sym);
3843 :
3844 : /*
3845 : NewSym - Sets Sym to a new symbol index.
3846 : */
3847 :
3848 : static void NewSym (unsigned int *sym);
3849 :
3850 : /*
3851 : GetPsym - returns the pointer to, sym.
3852 : */
3853 :
3854 : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym);
3855 :
3856 : /*
3857 : GetPcall - returns the pointer to the CallFrame.
3858 : */
3859 :
3860 : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call);
3861 :
3862 : /*
3863 : DebugProcedureLineNumber -
3864 : */
3865 :
3866 : static void DebugProcedureLineNumber (unsigned int sym);
3867 :
3868 : /*
3869 : PutPartialUnbounded -
3870 : */
3871 :
3872 : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim);
3873 :
3874 : /*
3875 : AlreadyDeclaredError - generate an error message, a, and two areas of code showing
3876 : the places where the symbols were declared.
3877 : */
3878 :
3879 : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance);
3880 :
3881 : /*
3882 : MakeObject - creates an object node.
3883 : */
3884 :
3885 : static unsigned int MakeObject (unsigned int tok, NameKey_Name name);
3886 :
3887 : /*
3888 : DeclareSym - returns a symbol which was either in the unknown tree or
3889 : a New symbol, since name is about to be declared.
3890 : */
3891 :
3892 : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name);
3893 :
3894 : /*
3895 : Init - Initializes the data structures and variables in this module.
3896 : Initialize the trees.
3897 : */
3898 :
3899 : static void Init (void);
3900 :
3901 : /*
3902 : AddSymToUnknown -
3903 : */
3904 :
3905 : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym);
3906 :
3907 : /*
3908 : AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
3909 : unknown tree.
3910 : */
3911 :
3912 : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym);
3913 :
3914 : /*
3915 : SubSymFromUnknownTree - removes a symbol with name, name, from the
3916 : unknown tree.
3917 : */
3918 :
3919 : static void SubSymFromUnknownTree (NameKey_Name name);
3920 :
3921 : /*
3922 : GetSymFromUnknownTree - returns a symbol with name, name, from the
3923 : unknown tree.
3924 : If no symbol with name is found then NulSym
3925 : is returned.
3926 : */
3927 :
3928 : static unsigned int GetSymFromUnknownTree (NameKey_Name name);
3929 :
3930 : /*
3931 : ExamineUnresolvedTree - returns a symbol with name, name, from the
3932 : unresolved tree of module, ModSym.
3933 : If no symbol with name is found then NulSym
3934 : is returned.
3935 : */
3936 :
3937 : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
3938 :
3939 : /*
3940 : RemoveFromUnresolvedTree - removes a symbol with name, name, from the
3941 : unresolved tree of symbol, ScopeSym.
3942 : */
3943 :
3944 : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
3945 :
3946 : /*
3947 : FetchUnknownSym - returns a symbol from the unknown tree if one is
3948 : available. It also updates the unknown tree.
3949 : */
3950 :
3951 : static unsigned int FetchUnknownSym (NameKey_Name name);
3952 :
3953 : /*
3954 : TransparentScope - returns true is the scope symbol Sym is allowed
3955 : to look to an outer level for a symbol.
3956 : ie is the symbol allowed to look to the parent
3957 : scope for a symbol.
3958 : */
3959 :
3960 : static bool TransparentScope (unsigned int Sym);
3961 :
3962 : /*
3963 : GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
3964 : the scope before the current module scope.
3965 : */
3966 :
3967 : static unsigned int GetLastModuleOrProcedureScope (void);
3968 :
3969 : /*
3970 : AddSymToScope - adds a symbol Sym with name name to
3971 : the current scope symbol tree.
3972 : */
3973 :
3974 : static void AddSymToScope (unsigned int Sym, NameKey_Name name);
3975 :
3976 : /*
3977 : PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
3978 : Procedure symbols enumeration
3979 : list onto the scope stack.
3980 : */
3981 :
3982 : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym);
3983 :
3984 : /*
3985 : PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
3986 : scope stack. This list will automatically
3987 : removed via one call to EndScope which
3988 : matches the StartScope by which this
3989 : procedure is invoked.
3990 : */
3991 :
3992 : static void PlaceEnumerationListOntoScope (Lists_List l);
3993 :
3994 : /*
3995 : SetFirstUsed - assigns the FirstUsed field in at to tok providing
3996 : it has not already been set.
3997 : */
3998 :
3999 : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at);
4000 :
4001 : /*
4002 : PutFirstUsed - sets tok to the first used providing it has not already been set.
4003 : It also includes the read and write quad into the usage list
4004 : providing the quad numbers are not 0.
4005 : */
4006 :
4007 : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_);
4008 :
4009 : /*
4010 : CanLookThroughScope - by default this procedure returns TRUE. It only returns
4011 : FALSE if, throughProcedure, is FALSE and the ScopeSym is
4012 : a procedure.
4013 : */
4014 :
4015 : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure);
4016 :
4017 : /*
4018 : GetScopeSym - searches the current scope and below, providing that the
4019 : scopes are transparent, for a symbol with name, name.
4020 : It only passes over procedure scopes if, throughProcedure,
4021 : is TRUE.
4022 : */
4023 :
4024 : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure);
4025 :
4026 : /*
4027 : CheckScopeForSym - checks the scope, ScopeSym, for an identifier
4028 : of name, name. CheckScopeForSym checks for
4029 : the symbol by the GetLocalSym and also
4030 : ExamineUnresolvedTree.
4031 : */
4032 :
4033 : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name);
4034 :
4035 : /*
4036 : GetModuleScopeId - returns the scope index to the next module starting
4037 : at index, Id.
4038 : Id will either point to a null scope (NulSym) or
4039 : alternatively point to a Module or DefImp symbol.
4040 : */
4041 :
4042 : static unsigned int GetModuleScopeId (unsigned int Id);
4043 :
4044 : /*
4045 : GetVisibleSym -
4046 : */
4047 :
4048 : static unsigned int GetVisibleSym (NameKey_Name name);
4049 :
4050 : /*
4051 : IsAlreadyDeclaredSym - returns true if Sym has already been declared
4052 : in the current main scope.
4053 : */
4054 :
4055 : static bool IsAlreadyDeclaredSym (NameKey_Name name);
4056 :
4057 : /*
4058 : GenName - returns a new name consisting of pre, name, post concatenation.
4059 : */
4060 :
4061 : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high);
4062 :
4063 : /*
4064 : InitCtor - initialize the ModuleCtor fields to NulSym.
4065 : */
4066 :
4067 : static void InitCtor (SymbolTable_ModuleCtor *ctor);
4068 :
4069 : /*
4070 : InitCtorFields - initialize the ModuleCtor fields. An inner module has no
4071 : ctor procedure.
4072 : */
4073 :
4074 : static void InitCtorFields (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym, SymbolTable_ModuleCtor *ctor, NameKey_Name name, bool inner, bool pub);
4075 :
4076 : /*
4077 : CheckTok - checks to see that tok is at a known location. If not
4078 : it uses GetTokenNo as a fall back.
4079 : */
4080 :
4081 : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high);
4082 :
4083 : /*
4084 : GetLink - returns TRUE if the current module is only used for linkage.
4085 : */
4086 :
4087 : static bool GetLink (void);
4088 :
4089 : /*
4090 : AddModuleToParent - adds symbol, Sym, to module, Parent.
4091 : */
4092 :
4093 : static void AddModuleToParent (unsigned int Sym, unsigned int Parent);
4094 :
4095 : /*
4096 : PutProcedureExternPublic - if procedure is not NulSym set extern
4097 : and public booleans.
4098 : */
4099 :
4100 : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub);
4101 :
4102 : /*
4103 : PutCtorExtern -
4104 : */
4105 :
4106 : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_);
4107 :
4108 : /*
4109 : InitProcedureDeclaration - initialize all the ProcedureDeclaration
4110 : fields.
4111 : */
4112 :
4113 : static void InitProcedureDeclaration (SymbolTable_ProcedureDeclaration *decl);
4114 :
4115 : /*
4116 : AddProcedureToList - adds a procedure, Proc, to the list of procedures
4117 : in module, Mod.
4118 : */
4119 :
4120 : static void AddProcedureToList (unsigned int Mod, unsigned int Proc);
4121 :
4122 : /*
4123 : AddVarToScopeList - adds symbol, sym, to, scope.
4124 : */
4125 :
4126 : static void AddVarToScopeList (unsigned int scope, unsigned int sym);
4127 :
4128 : /*
4129 : AddVarToList - add a variable symbol to the list of variables maintained
4130 : by the inner most scope. (Procedure or Module).
4131 : */
4132 :
4133 : static void AddVarToList (unsigned int Sym);
4134 :
4135 : /*
4136 : InitVarDecl - initialize the variable and type token location positions.
4137 : */
4138 :
4139 : static void InitVarDecl (SymbolTable_VarDecl *decl, unsigned int vartok);
4140 :
4141 : /*
4142 : doPutVarDeclTypeTok - places typetok into decl.TypeTok.
4143 : sym must be a variable.
4144 : */
4145 :
4146 : static void doPutVarDeclTypeTok (unsigned int sym, unsigned int typetok);
4147 :
4148 : /*
4149 : doPutVarDeclTok - places vartok into decl.VarTok.
4150 : sym must be a variable.
4151 : */
4152 :
4153 : static void doPutVarDeclTok (unsigned int sym, unsigned int vartok);
4154 :
4155 : /*
4156 : doGetVarDeclTok - return decl.VarTok for a variable.
4157 : */
4158 :
4159 : static unsigned int doGetVarDeclTok (unsigned int sym);
4160 :
4161 : /*
4162 : doGetVarDeclTypeTok - return decl.TypeTok for a variable.
4163 : */
4164 :
4165 : static unsigned int doGetVarDeclTypeTok (unsigned int sym);
4166 :
4167 : /*
4168 : doGetVarDeclFullTok - return the full declaration of var: type.
4169 : */
4170 :
4171 : static unsigned int doGetVarDeclFullTok (unsigned int sym);
4172 :
4173 : /*
4174 : FillInRecordFields - given a new symbol, sym, make it a record symbol
4175 : and initialize its fields.
4176 : */
4177 :
4178 : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf);
4179 :
4180 : /*
4181 : HandleHiddenOrDeclare -
4182 : */
4183 :
4184 : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf);
4185 :
4186 : /*
4187 : CreateConstLit -
4188 : */
4189 :
4190 : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
4191 :
4192 : /*
4193 : LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
4194 : matches tok, constName and constType.
4195 : */
4196 :
4197 : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType);
4198 :
4199 : /*
4200 : AddConstLitPoolEntry - adds sym to the constlit pool.
4201 : */
4202 :
4203 : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType);
4204 :
4205 : /*
4206 : InitConstString - initialize the constant string.
4207 : */
4208 :
4209 : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known);
4210 :
4211 : /*
4212 : GetConstStringKind - return the StringVariant field associated with sym.
4213 : */
4214 :
4215 : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym);
4216 :
4217 : /*
4218 : CanUseBuiltin - returns TRUE if the procedure, Sym, can be
4219 : inlined via a builtin function.
4220 : */
4221 :
4222 : static bool CanUseBuiltin (unsigned int Sym);
4223 :
4224 : /*
4225 : InitPacked - initialise packedInfo to FALSE and NulSym.
4226 : */
4227 :
4228 : static void InitPacked (SymbolTable_PackedInfo *packedInfo);
4229 :
4230 : /*
4231 : doEquivalent - create a packed equivalent symbol for, sym, and return the
4232 : new symbol. It sets both fields in packedInfo to FALSE
4233 : and the new symbol.
4234 : */
4235 :
4236 : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
4237 :
4238 : /*
4239 : MakeEquivalent - return the equivalent packed symbol for, sym.
4240 : */
4241 :
4242 : static unsigned int MakeEquivalent (unsigned int sym);
4243 :
4244 : /*
4245 : GetEquivalent -
4246 : */
4247 :
4248 : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
4249 :
4250 : /*
4251 : doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
4252 : */
4253 :
4254 : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase);
4255 :
4256 : /*
4257 : GetTypeOfVar - returns the type of symbol, var.
4258 : */
4259 :
4260 : static unsigned int GetTypeOfVar (unsigned int var);
4261 :
4262 : /*
4263 : GetConstLitType - returns the type of the constant of, name.
4264 : All floating point constants have type LONGREAL.
4265 : Character constants are type CHAR.
4266 : Integer values are INTEGER, LONGINT or LONGCARD
4267 : depending upon their value.
4268 : */
4269 :
4270 : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError);
4271 :
4272 : /*
4273 : GetNthFromComponent -
4274 : */
4275 :
4276 : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n);
4277 :
4278 : /*
4279 : GetNthParamChoice - returns the parameter definition from
4280 : sym:ParamNo:kind or NulSym.
4281 : */
4282 :
4283 : static unsigned int GetNthParamChoice (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind kind);
4284 :
4285 : /*
4286 : GetNthParamOrdered - returns the parameter definition from list {a, b, c}
4287 : in order.
4288 : sym:ParamNo:{a,b,c} or NulSym.
4289 : */
4290 :
4291 : static unsigned int GetNthParamOrdered (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind a, SymbolTable_ProcedureKind b, SymbolTable_ProcedureKind c);
4292 :
4293 : /*
4294 : GetOuterModuleScope - returns the outer module symbol scope for sym.
4295 : */
4296 :
4297 : static unsigned int GetOuterModuleScope (unsigned int sym);
4298 :
4299 : /*
4300 : EnsureOrder - providing that both symbols, a, and, b, exist in
4301 : list, l. Ensure that, b, is placed after a.
4302 : */
4303 :
4304 : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b);
4305 :
4306 : /*
4307 : DumpSons -
4308 : */
4309 :
4310 : static void DumpSons (unsigned int sym);
4311 :
4312 : /*
4313 : CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
4314 : */
4315 :
4316 : static void CheckListOfSons (unsigned int sym);
4317 :
4318 : /*
4319 : CheckRecordConsistency -
4320 : */
4321 :
4322 : static void CheckRecordConsistency (unsigned int sym);
4323 :
4324 : /*
4325 : IsExternalModule - return TRUE if sym is an external program module or defimp module.
4326 : */
4327 :
4328 : static bool IsExternalModule (unsigned int sym);
4329 :
4330 : /*
4331 : PutConstVarTemporary - indicates that constant, sym, is a temporary.
4332 : */
4333 :
4334 : static void PutConstVarTemporary (unsigned int sym);
4335 :
4336 : /*
4337 : buildTemporary - builds the temporary filling in componentRef, record and sets mode.
4338 : */
4339 :
4340 : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record);
4341 :
4342 : /*
4343 : AssertInRange - determines whether the Sym is a legal symbol.
4344 : */
4345 :
4346 : static void AssertInRange (unsigned int Sym);
4347 :
4348 : /*
4349 : CheckForHiddenType - scans the NeedToBeImplemented tree providing
4350 : that we are currently compiling an implementation
4351 : module. If a symbol is found with TypeName
4352 : then its Sym is returned.
4353 : Otherwise NulSym is returned.
4354 : CheckForHiddenType is called before any type is
4355 : created, therefore the compiler allows hidden
4356 : types to be implemented using any type.
4357 : */
4358 :
4359 : static unsigned int CheckForHiddenType (NameKey_Name TypeName);
4360 :
4361 : /*
4362 : RequestFromModule - returns a symbol from module ModSym with name, SymName.
4363 : */
4364 :
4365 : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4366 :
4367 : /*
4368 : RequestFromDefinition - returns a symbol from module ModSym with name,
4369 : SymName.
4370 : */
4371 :
4372 : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4373 :
4374 : /*
4375 : GetWhereImported - returns the token number where this symbol
4376 : was imported into the current module.
4377 : */
4378 :
4379 : static unsigned int GetWhereImported (unsigned int Sym);
4380 :
4381 : /*
4382 : DisplayName - displays the name.
4383 : */
4384 :
4385 : static void DisplayName (unsigned int sym);
4386 :
4387 : /*
4388 : DisplaySymbol - displays the name of a symbol
4389 : */
4390 :
4391 : static void DisplaySymbol (unsigned int sym);
4392 :
4393 : /*
4394 : FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
4395 : */
4396 :
4397 : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4398 :
4399 : /*
4400 : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
4401 : */
4402 :
4403 : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4404 :
4405 : /*
4406 : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
4407 : */
4408 :
4409 : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName);
4410 :
4411 : /*
4412 : UnknownSymbolError - displays symbol name for symbol, sym.
4413 : */
4414 :
4415 : static void UnknownSymbolError (unsigned int sym);
4416 :
4417 : /*
4418 : IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
4419 : reported and is an unknown symbol.
4420 : */
4421 :
4422 : static bool IsUnreportedUnknown (unsigned int sym);
4423 :
4424 : /*
4425 : AddListify -
4426 : */
4427 :
4428 : static void AddListify (unsigned int sym);
4429 :
4430 : /*
4431 : Listify - convert tree into a string list and return the result.
4432 : */
4433 :
4434 : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition);
4435 :
4436 : /*
4437 : CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
4438 : an unknown symbol. All unknown symbols are displayed
4439 : together with an error message.
4440 : */
4441 :
4442 : static void CheckForUnknowns (unsigned int tokno, NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
4443 :
4444 : /*
4445 : SymbolError - displays symbol name for symbol, Sym.
4446 : */
4447 :
4448 : static void SymbolError (unsigned int Sym);
4449 :
4450 : /*
4451 : CheckForSymbols - checks a binary tree, Tree, to see whether it contains
4452 : any symbol. The tree is expected to be empty, if not
4453 : then an error has occurred.
4454 : */
4455 :
4456 : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
4457 :
4458 : /*
4459 : PutExportUndeclared - places a symbol, Sym, into module, ModSym,
4460 : ExportUndeclared list provided that Sym
4461 : is unknown.
4462 : */
4463 :
4464 : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym);
4465 :
4466 : /*
4467 : GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
4468 : which is in the ExportUndeclared list.
4469 : */
4470 :
4471 : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name);
4472 :
4473 : /*
4474 : RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
4475 : ExportUndeclaredTree.
4476 : */
4477 :
4478 : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym);
4479 :
4480 : /*
4481 : CheckForExportedDeclaration - checks to see whether a definition module
4482 : is currently being compiled, if so,
4483 : symbol, Sym, is removed from the
4484 : ExportUndeclared list.
4485 : This procedure is called whenever a symbol
4486 : is declared, thus attempting to reduce
4487 : the ExportUndeclared list.
4488 : */
4489 :
4490 : static void CheckForExportedDeclaration (unsigned int Sym);
4491 :
4492 : /*
4493 : UndeclaredSymbolError - displays symbol name for symbol, Sym.
4494 : */
4495 :
4496 : static void UndeclaredSymbolError (unsigned int Sym);
4497 :
4498 : /*
4499 : RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
4500 : NeedToBeImplemented list.
4501 : */
4502 :
4503 : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym);
4504 :
4505 : /*
4506 : RemoveFromExportRequest -
4507 : */
4508 :
4509 : static void RemoveFromExportRequest (unsigned int Sym);
4510 :
4511 : /*
4512 : RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
4513 : (and its fields) from the ExportRequest tree.
4514 : */
4515 :
4516 : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym);
4517 :
4518 : /*
4519 : UnImplementedSymbolError - displays symbol name for symbol, Sym.
4520 : */
4521 :
4522 : static void UnImplementedSymbolError (unsigned int Sym);
4523 :
4524 : /*
4525 : CheckEnumerationInList - places symbol, Sym, in the list, l,
4526 : providing it does not already exist.
4527 : PseudoScope(Sym) is called if Sym needs to
4528 : be added to the enumeration list, l.
4529 : */
4530 :
4531 : static void CheckEnumerationInList (Lists_List l, unsigned int Sym);
4532 :
4533 : /*
4534 : CheckIfEnumerationExported - An outer module may use an enumeration that
4535 : is declared inside an inner module. The usage
4536 : may occur before definition. The first pass
4537 : exports a symbol, later the symbol is declared
4538 : as an emumeration type. At this stage the
4539 : CheckIfEnumerationExported procedure should be
4540 : called. This procedure ripples from the current
4541 : (inner) module to outer module and every time
4542 : it is exported it must be added to the outer
4543 : module EnumerationScopeList.
4544 : */
4545 :
4546 : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId);
4547 :
4548 : /*
4549 : CheckForEnumerationInOuterModule - checks to see whether the enumeration
4550 : type symbol, Sym, has been entered into
4551 : the outer module, OuterModule, scope list.
4552 : OuterModule may be internal to the
4553 : program module.
4554 : */
4555 :
4556 : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule);
4557 :
4558 : /*
4559 : MakeVariableForParam -
4560 : */
4561 :
4562 : static unsigned int MakeVariableForParam (unsigned int tok, NameKey_Name ParamName, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, unsigned int ParmType, unsigned int typetok);
4563 :
4564 : /*
4565 : AddParameter - adds a parameter ParSym to a procedure Sym.
4566 : */
4567 :
4568 : static void AddParameter (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParSym);
4569 :
4570 : /*
4571 : AddProcedureProcTypeParam - adds ParamType to the parameter ProcType
4572 : associated with procedure Sym.
4573 : */
4574 :
4575 : static void AddProcedureProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded, bool isVarParam);
4576 :
4577 : /*
4578 : IsNthParamVar - returns true if the n th parameter of the parameter list,
4579 : List, is a VAR parameter.
4580 : */
4581 :
4582 : static bool IsNthParamVar (Lists_List Head, unsigned int n);
4583 :
4584 : /*
4585 : MakeParameterHeapVar - create a heap variable if sym is a pointer.
4586 : */
4587 :
4588 : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode);
4589 :
4590 : /*
4591 : PutParameterHeapVar - creates a heap variable associated with parameter sym.
4592 : */
4593 :
4594 : static void PutParameterHeapVar (unsigned int sym);
4595 :
4596 : /*
4597 : IsProcedureAnyBoolean - returns the boolean result from p
4598 : for any of procedure kind which is defined.
4599 : */
4600 :
4601 : static bool IsProcedureAnyBoolean (unsigned int sym, SymbolTable_ProcAnyBoolean p);
4602 :
4603 : /*
4604 : IsProcedureAnyDefaultBoolean - returns the boolean result from p
4605 : for any of procedure kind which is defined.
4606 : */
4607 :
4608 : static bool IsProcedureAnyDefaultBoolean (unsigned int sym, bool default_, SymbolTable_ProcAnyBoolean p);
4609 :
4610 : /*
4611 : FillInUnknownFields - fills in all fields for the undefined sym.
4612 : */
4613 :
4614 : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName, unsigned int descscope, bool onimport);
4615 :
4616 : /*
4617 : FillInPointerFields - given a new symbol, sym, make it a pointer symbol
4618 : and initialize its fields.
4619 : */
4620 :
4621 : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf);
4622 :
4623 : /*
4624 : ForeachParameterDo -
4625 : */
4626 :
4627 : static void ForeachParameterDo (SymbolTable_CheckProcedure p);
4628 :
4629 : /*
4630 : CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
4631 : */
4632 :
4633 : static void CheckUnbounded (unsigned int Sym);
4634 :
4635 : /*
4636 : PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
4637 : */
4638 :
4639 : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf);
4640 :
4641 : /*
4642 : doFillInOAFamily -
4643 : */
4644 :
4645 : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded);
4646 :
4647 : /*
4648 : FillInUnboundedFields -
4649 : */
4650 :
4651 : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim);
4652 :
4653 : /*
4654 : PutUnbounded - associates the unbounded symbol, open, with
4655 : SimpleType.
4656 : */
4657 :
4658 : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim);
4659 :
4660 : /*
4661 : GetArrayDimension - returns the number of dimensions defined.
4662 : */
4663 :
4664 : static unsigned int GetArrayDimension (unsigned int sym);
4665 :
4666 : /*
4667 : ResolveConstructorType - if, sym, has an unresolved constructor type
4668 : then attempt to resolve it by examining the
4669 : from, type.
4670 : */
4671 :
4672 : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres);
4673 :
4674 : /*
4675 : IsConstructorResolved - returns TRUE if the constructor does not
4676 : have an unresolved type.
4677 : */
4678 :
4679 : static bool IsConstructorResolved (unsigned int sym);
4680 :
4681 : /*
4682 : CanResolveConstructor - returns TRUE if the type of the constructor,
4683 : sym, is known.
4684 : */
4685 :
4686 : static bool CanResolveConstructor (unsigned int sym);
4687 :
4688 : /*
4689 : CheckAllConstructorsResolved - checks to see that the
4690 : UnresolvedConstructorType list is
4691 : empty and if it is not then it
4692 : generates error messages.
4693 : */
4694 :
4695 : static void CheckAllConstructorsResolved (void);
4696 :
4697 : /*
4698 : SanityCheckParameters -
4699 : */
4700 :
4701 : static void SanityCheckParameters (unsigned int sym);
4702 :
4703 : /*
4704 : SanityCheckArray - checks to see that an array has a correct subrange type.
4705 : */
4706 :
4707 : static void SanityCheckArray (unsigned int sym);
4708 :
4709 : /*
4710 : ForeachSymbolDo - foreach symbol, call, P(sym).
4711 : */
4712 :
4713 : static void ForeachSymbolDo (SymbolKey_PerformOperation P);
4714 :
4715 : /*
4716 : SanityCheckProcedure - check to see that procedure parameters do not use constants
4717 : instead of types in their formal parameter section.
4718 : */
4719 :
4720 : static void SanityCheckProcedure (unsigned int sym);
4721 :
4722 : /*
4723 : SanityCheckModule -
4724 : */
4725 :
4726 : static void SanityCheckModule (unsigned int sym);
4727 :
4728 : /*
4729 : AddNameTo - adds Name, n, to tree, s.
4730 : */
4731 :
4732 : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o);
4733 :
4734 : /*
4735 : CollectSymbolFrom -
4736 : */
4737 :
4738 : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n);
4739 :
4740 : /*
4741 : CollectUnknown -
4742 : */
4743 :
4744 : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n);
4745 :
4746 : /*
4747 : ResolveImport -
4748 : */
4749 :
4750 : static void ResolveImport (unsigned int o);
4751 :
4752 : /*
4753 : ResolveRelativeImport -
4754 : */
4755 :
4756 : static void ResolveRelativeImport (unsigned int sym);
4757 :
4758 : /*
4759 : Max -
4760 : */
4761 :
4762 : static unsigned int Max (unsigned int a, unsigned int b);
4763 :
4764 : /*
4765 : Min -
4766 : */
4767 :
4768 : static unsigned int Min (unsigned int a, unsigned int b);
4769 :
4770 : /*
4771 : DoFindLimits - assigns, Start, and, End, to the start and end
4772 : limits contained in the list, l. It ensures that
4773 : Start and End are within StartLimit..EndLimit.
4774 : If StartLimit or EndLimit are 0 then Start is
4775 : is set to the first value and End to the last.
4776 : */
4777 :
4778 : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l);
4779 :
4780 : /*
4781 : PutDeclaredDefinition - associates the current tokenno with
4782 : the symbols declaration in the definition
4783 : module.
4784 : */
4785 :
4786 : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym);
4787 :
4788 : /*
4789 : PutDeclaredModule - returns the token where this symbol was declared
4790 : in an implementation or program module.
4791 : */
4792 :
4793 : static void PutDeclaredModule (unsigned int tok, unsigned int Sym);
4794 :
4795 : /*
4796 : DoIsConst - returns TRUE if Sym is defined as a constant
4797 : or is an enumeration field or string.
4798 : */
4799 :
4800 : static bool DoIsConst (unsigned int Sym);
4801 :
4802 : /*
4803 : GetFromIndex - return a value from list, i, at position, n.
4804 : */
4805 :
4806 : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n);
4807 :
4808 : /*
4809 : PutIntoIndex - places value, v, into list, i, at position, n.
4810 : */
4811 :
4812 : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v);
4813 :
4814 : /*
4815 : PushConstString - pushes the character string onto the ALU stack.
4816 : It assumes that the character string is only
4817 : one character long.
4818 : */
4819 :
4820 : static void PushConstString (unsigned int Sym);
4821 :
4822 37116150 : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at)
4823 : {
4824 : /*
4825 : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
4826 : */
4827 37116150 : if (M2Comp_CompilingDefinitionModule ())
4828 : {
4829 : (*at).DefDeclared = tok;
4830 : (*at).ModDeclared = M2LexBuf_UnknownTokenNo;
4831 : }
4832 : else
4833 : {
4834 17601418 : (*at).DefDeclared = M2LexBuf_UnknownTokenNo;
4835 17601418 : (*at).ModDeclared = tok;
4836 : }
4837 37116150 : (*at).FirstUsed = tok; /* we assign this field to something legal */
4838 0 : }
4839 :
4840 :
4841 : /*
4842 : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
4843 : */
4844 :
4845 593782 : static void InitWhereDeclared (SymbolTable_Where *at)
4846 : {
4847 593782 : InitWhereDeclaredTok (M2LexBuf_GetTokenNo (), at);
4848 593782 : }
4849 :
4850 :
4851 : /*
4852 : InitWhereFirstUsed - sets the FirstUsed field of record, at.
4853 : */
4854 :
4855 3158 : static void InitWhereFirstUsed (SymbolTable_Where *at)
4856 : {
4857 0 : InitWhereFirstUsedTok (M2LexBuf_GetTokenNo (), at);
4858 0 : }
4859 :
4860 :
4861 : /*
4862 : InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
4863 : */
4864 :
4865 11193255 : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at)
4866 : {
4867 11193255 : (*at).FirstUsed = tok;
4868 0 : }
4869 :
4870 :
4871 : /*
4872 : gdbhook - a debugger convenience hook.
4873 : */
4874 :
4875 0 : static void gdbhook (void)
4876 : {
4877 0 : }
4878 :
4879 :
4880 : /*
4881 : BreakWhenSymCreated - to be called interactively by gdb.
4882 : */
4883 :
4884 15451 : static void BreakWhenSymCreated (unsigned int sym)
4885 : {
4886 15451 : BreakSym = sym;
4887 0 : }
4888 :
4889 :
4890 : /*
4891 : CheckBreak - if sym = BreakSym then call gdbhook.
4892 : */
4893 :
4894 0 : static void CheckBreak (unsigned int sym)
4895 : {
4896 0 : if (sym == BreakSym)
4897 : {
4898 0 : gdbhook ();
4899 : }
4900 0 : }
4901 :
4902 :
4903 : /*
4904 : NewSym - Sets Sym to a new symbol index.
4905 : */
4906 :
4907 63238547 : static void NewSym (unsigned int *sym)
4908 : {
4909 63238547 : SymbolTable_PtrToSymbol pSym;
4910 :
4911 63238547 : (*sym) = FreeSymbol;
4912 63238547 : Storage_ALLOCATE ((void **) &pSym, sizeof (SymbolTable_Symbol));
4913 63238547 : pSym->SymbolType = SymbolTable_DummySym;
4914 63238547 : Indexing_PutIndice (Symbols, (*sym), reinterpret_cast <void *> (pSym));
4915 63238547 : CheckBreak ((*sym));
4916 63238547 : FreeSymbol += 1;
4917 63238547 : M2Diagnostic_MemSet (SymMemDiag, 1, FreeSymbol-1);
4918 63238547 : M2Diagnostic_MemIncr (SymMemDiag, 2, sizeof ((*pSym)));
4919 63238547 : }
4920 :
4921 :
4922 : /*
4923 : GetPsym - returns the pointer to, sym.
4924 : */
4925 :
4926 15423823049 : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym)
4927 : {
4928 15423823049 : SymbolTable_PtrToSymbol pSym;
4929 :
4930 15423823049 : if (Indexing_InBounds (Symbols, sym))
4931 : {
4932 15423823049 : pSym = static_cast<SymbolTable_PtrToSymbol> (Indexing_GetIndice (Symbols, sym));
4933 15423823049 : return pSym;
4934 : }
4935 : else
4936 : {
4937 0 : M2Error_InternalError ((const char *) "symbol out of bounds", 20);
4938 : }
4939 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
4940 : __builtin_unreachable ();
4941 : }
4942 :
4943 :
4944 : /*
4945 : GetPcall - returns the pointer to the CallFrame.
4946 : */
4947 :
4948 421582503 : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call)
4949 : {
4950 421582503 : SymbolTable_PtrToCallFrame pCall;
4951 :
4952 421582503 : if (Indexing_InBounds (ScopeCallFrame, call))
4953 : {
4954 421582503 : pCall = static_cast<SymbolTable_PtrToCallFrame> (Indexing_GetIndice (ScopeCallFrame, call));
4955 421582503 : return pCall;
4956 : }
4957 : else
4958 : {
4959 0 : M2Error_InternalError ((const char *) "symbol out of bounds", 20);
4960 : }
4961 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
4962 : __builtin_unreachable ();
4963 : }
4964 :
4965 :
4966 : /*
4967 : DebugProcedureLineNumber -
4968 : */
4969 :
4970 0 : static void DebugProcedureLineNumber (unsigned int sym)
4971 : {
4972 0 : unsigned int begin;
4973 0 : unsigned int end;
4974 0 : NameKey_Name n;
4975 0 : DynamicStrings_String f;
4976 0 : unsigned int l;
4977 :
4978 0 : SymbolTable_GetProcedureBeginEnd (sym, &begin, &end);
4979 0 : n = SymbolTable_GetSymName (sym);
4980 0 : if (begin != 0)
4981 : {
4982 0 : f = M2LexBuf_FindFileNameFromToken (begin, 0);
4983 0 : l = M2LexBuf_TokenToLineNo (begin, 0);
4984 0 : M2Printf_printf3 ((const char *) "%s:%d:%a:begin\\n", 16, (const unsigned char *) &f, (sizeof (f)-1), (const unsigned char *) &l, (sizeof (l)-1), (const unsigned char *) &n, (sizeof (n)-1));
4985 : }
4986 0 : if (end != 0)
4987 : {
4988 0 : f = M2LexBuf_FindFileNameFromToken (end, 0);
4989 0 : l = M2LexBuf_TokenToLineNo (end, 0);
4990 0 : M2Printf_printf3 ((const char *) "%s:%d:%a:end\\n", 14, (const unsigned char *) &f, (sizeof (f)-1), (const unsigned char *) &l, (sizeof (l)-1), (const unsigned char *) &n, (sizeof (n)-1));
4991 : }
4992 0 : }
4993 :
4994 :
4995 : /*
4996 : PutPartialUnbounded -
4997 : */
4998 :
4999 0 : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim)
5000 : {
5001 0 : SymbolTable_PtrToSymbol pSym;
5002 :
5003 0 : pSym = GetPsym (sym);
5004 0 : if (SymbolTable_IsDummy (sym))
5005 : {
5006 0 : pSym->SymbolType = SymbolTable_PartialUnboundedSym;
5007 : }
5008 0 : switch (pSym->SymbolType)
5009 : {
5010 0 : case SymbolTable_PartialUnboundedSym:
5011 0 : pSym->PartialUnbounded.Type = type;
5012 0 : pSym->PartialUnbounded.NDim = ndim;
5013 0 : break;
5014 :
5015 :
5016 0 : default:
5017 0 : M2Error_InternalError ((const char *) "not expecting this type", 23);
5018 0 : break;
5019 : }
5020 0 : }
5021 :
5022 :
5023 : /*
5024 : AlreadyDeclaredError - generate an error message, a, and two areas of code showing
5025 : the places where the symbols were declared.
5026 : */
5027 :
5028 0 : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance)
5029 : {
5030 0 : M2Error_Error e;
5031 :
5032 0 : if ((OtherOccurance == 0) || (OtherOccurance == (M2LexBuf_GetTokenNo ())))
5033 : {
5034 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
5035 0 : M2Error_ErrorString (e, s);
5036 : }
5037 : else
5038 : {
5039 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
5040 0 : M2Error_ErrorString (e, s);
5041 0 : e = M2Error_ChainError (OtherOccurance, e);
5042 0 : M2Error_ErrorFormat1 (e, (const char *) "and symbol (%a) is also declared here", 37, (const unsigned char *) &name, (sizeof (name)-1));
5043 : }
5044 0 : }
5045 :
5046 :
5047 : /*
5048 : MakeObject - creates an object node.
5049 : */
5050 :
5051 8104970 : static unsigned int MakeObject (unsigned int tok, NameKey_Name name)
5052 : {
5053 8104970 : SymbolTable_PtrToSymbol pSym;
5054 8104970 : unsigned int Sym;
5055 :
5056 8104970 : NewSym (&Sym);
5057 8104970 : pSym = GetPsym (Sym);
5058 8104970 : pSym->SymbolType = SymbolTable_ObjectSym;
5059 8104970 : pSym->Object.name = name;
5060 8104970 : InitWhereDeclaredTok (tok, &pSym->Object.At);
5061 8104970 : InitWhereFirstUsedTok (tok, &pSym->Object.At);
5062 8104970 : return Sym;
5063 : /* static analysis guarentees a RETURN statement will be used before here. */
5064 : __builtin_unreachable ();
5065 : }
5066 :
5067 :
5068 : /*
5069 : DeclareSym - returns a symbol which was either in the unknown tree or
5070 : a New symbol, since name is about to be declared.
5071 : */
5072 :
5073 25254484 : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name)
5074 : {
5075 25254484 : unsigned int Sym;
5076 :
5077 25254484 : if (name == NameKey_NulName)
5078 : {
5079 5615526 : NewSym (&Sym);
5080 : }
5081 19638958 : else if (IsAlreadyDeclaredSym (name))
5082 : {
5083 : /* avoid dangling else. */
5084 36 : Sym = SymbolTable_GetSym (name);
5085 36 : if (SymbolTable_IsImported (SymbolTable_GetCurrentModuleScope (), Sym))
5086 : {
5087 : /* avoid dangling else. */
5088 6 : M2MetaError_MetaErrorT1 (GetWhereImported (Sym), (const char *) "symbol {%1Rad} is already present in this scope, check both definition and implementation modules, use a different name or remove the import", 140, Sym);
5089 6 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
5090 6 : if (Sym != (GetVisibleSym (name)))
5091 : {
5092 0 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
5093 : }
5094 : }
5095 : else
5096 : {
5097 30 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1RMad} is already declared in this scope, use a different name or remove the declaration", 97, Sym);
5098 30 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
5099 30 : if (Sym != (GetVisibleSym (name)))
5100 : {
5101 0 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
5102 : }
5103 : }
5104 36 : Sym = SymbolTable_MakeError (tok, name);
5105 : }
5106 : else
5107 : {
5108 : /* avoid dangling else. */
5109 19638922 : Sym = FetchUnknownSym (name);
5110 19638922 : if (Sym == SymbolTable_NulSym)
5111 : {
5112 14863911 : NewSym (&Sym);
5113 : }
5114 19638922 : CheckForExportedDeclaration (Sym);
5115 : }
5116 25254484 : return Sym;
5117 : /* static analysis guarentees a RETURN statement will be used before here. */
5118 : __builtin_unreachable ();
5119 : }
5120 :
5121 :
5122 : /*
5123 : Init - Initializes the data structures and variables in this module.
5124 : Initialize the trees.
5125 : */
5126 :
5127 15451 : static void Init (void)
5128 : {
5129 15451 : SymbolTable_PtrToCallFrame pCall;
5130 :
5131 15451 : SymMemDiag = M2Diagnostic_InitMemDiagnostic ((const char *) "SymbolTable:Symbols", 19, (const char *) "{0N} total symbols {1d} consuming {2M} ram {0M} ({2P})", 54);
5132 15451 : BreakWhenSymCreated (SymbolTable_NulSym); /* Disable the intereactive sym watch. */
5133 : /* To examine the symbol table when a symbol is created run cc1gm2 from gdb
5134 : and set a break point on gdbhook.
5135 : (gdb) break gdbhook
5136 : (gdb) run
5137 : Now below interactively call BreakWhenSymCreated with the symbol
5138 : under investigation. */
5139 15451 : gdbhook ();
5140 : /* Now is the time to interactively call gdb, for example:
5141 : (gdb) print BreakWhenSymCreated (1234)
5142 : (gdb) cont
5143 : and you will arrive at gdbhook when this symbol is created. */
5144 15451 : AnonymousName = 0;
5145 15451 : CurrentError = static_cast<M2Error_Error> (NULL);
5146 15451 : SymbolKey_InitTree (&ConstLitPoolTree);
5147 15451 : SymbolKey_InitTree (&DefModuleTree);
5148 15451 : SymbolKey_InitTree (&ModuleTree);
5149 15451 : Symbols = Indexing_InitIndexTuned (1, (1024*1024) / 16, 16);
5150 15451 : ConstLitArray = Indexing_InitIndex (1);
5151 15451 : FreeSymbol = 1;
5152 15451 : ScopePtr = 1;
5153 15451 : ScopeCallFrame = Indexing_InitIndex (1);
5154 15451 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
5155 15451 : pCall->Main = SymbolTable_NulSym;
5156 15451 : pCall->Search = SymbolTable_NulSym;
5157 15451 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
5158 15451 : CurrentModule = SymbolTable_NulSym;
5159 15451 : MainModule = SymbolTable_NulSym;
5160 15451 : FileModule = SymbolTable_NulSym;
5161 15451 : TemporaryNo = 0;
5162 : /*
5163 : InitList(FreeFVarientList) ; Lists used to maintain GC of field
5164 : InitList(UsedFVarientList) ; varients.
5165 : */
5166 15451 : Lists_InitList (&UnresolvedConstructorType);
5167 15451 : M2Base_InitBase (m2linemap_BuiltinsLocation (), &BaseModule);
5168 15451 : SymbolTable_StartScope (BaseModule); /* BaseModule scope placed at the bottom of the stack */
5169 15451 : BaseScopePtr = ScopePtr; /* BaseScopePtr points to the top of the BaseModule scope */
5170 15451 : Lists_InitList (&AddressTypes); /* BaseScopePtr points to the top of the BaseModule scope */
5171 15451 : ReportedUnknowns = Sets_InitSet (1);
5172 15451 : }
5173 :
5174 :
5175 : /*
5176 : AddSymToUnknown -
5177 : */
5178 :
5179 10854563 : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym)
5180 : {
5181 10854563 : SymbolTable_PtrToSymbol pSym;
5182 10854563 : NameKey_Name n;
5183 :
5184 10854563 : if (DebugUnknowns)
5185 : {
5186 : n = SymbolTable_GetSymName (scope);
5187 : M2Printf_printf3 ((const char *) "adding unknown %a (%d) to scope %a\\n", 36, (const unsigned char *) &name, (sizeof (name)-1), (const unsigned char *) &Sym, (sizeof (Sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
5188 : }
5189 : /* Add symbol to unknown tree */
5190 10854563 : pSym = GetPsym (scope);
5191 10854563 : switch (pSym->SymbolType)
5192 : {
5193 10844380 : case SymbolTable_DefImpSym:
5194 10844380 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, name, Sym);
5195 10844380 : break;
5196 :
5197 10183 : case SymbolTable_ModuleSym:
5198 10183 : SymbolKey_PutSymKey (pSym->Module.Unresolved, name, Sym);
5199 10183 : break;
5200 :
5201 0 : case SymbolTable_ProcedureSym:
5202 0 : SymbolKey_PutSymKey (pSym->Procedure.Unresolved, name, Sym);
5203 0 : break;
5204 :
5205 :
5206 0 : default:
5207 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5208 10854563 : break;
5209 : }
5210 10854563 : }
5211 :
5212 :
5213 : /*
5214 : AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
5215 : unknown tree.
5216 : */
5217 :
5218 10854545 : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym)
5219 : {
5220 10854545 : SymbolTable_PtrToCallFrame pCall;
5221 10854545 : unsigned int ScopeSym;
5222 :
5223 10854545 : if (ScopeId > 0)
5224 : {
5225 : /* choose to place the unknown symbol in the first module scope
5226 : outside the current scope */
5227 10855237 : do {
5228 10855237 : pCall = GetPcall (static_cast<unsigned int> (ScopeId));
5229 10855237 : ScopeSym = pCall->Main;
5230 10855237 : if ((ScopeSym > 0) && ((SymbolTable_IsDefImp (ScopeSym)) || (SymbolTable_IsModule (ScopeSym))))
5231 : {
5232 10854545 : AddSymToUnknown (ScopeSym, name, Sym);
5233 10854545 : return;
5234 : }
5235 692 : ScopeId -= 1;
5236 692 : } while (! (ScopeId == 0));
5237 : }
5238 0 : AddSymToUnknown (CurrentModule, name, Sym);
5239 : }
5240 :
5241 :
5242 : /*
5243 : SubSymFromUnknownTree - removes a symbol with name, name, from the
5244 : unknown tree.
5245 : */
5246 :
5247 4775017 : static void SubSymFromUnknownTree (NameKey_Name name)
5248 : {
5249 4775017 : SymbolTable_PtrToCallFrame pCall;
5250 4775017 : unsigned int ScopeSym;
5251 4775017 : unsigned int ScopeId;
5252 :
5253 4775017 : if (ScopePtr > 0)
5254 : {
5255 : ScopeId = ScopePtr;
5256 6146768 : do {
5257 6146768 : pCall = GetPcall (ScopeId);
5258 6146768 : ScopeSym = pCall->Search;
5259 6146768 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
5260 : {
5261 4775635 : if (RemoveFromUnresolvedTree (ScopeSym, name))
5262 : {
5263 : return;
5264 : }
5265 : }
5266 1371751 : ScopeId -= 1;
5267 2743502 : } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
5268 : }
5269 0 : if (RemoveFromUnresolvedTree (CurrentModule, name))
5270 : {} /* empty. */
5271 : }
5272 :
5273 :
5274 : /*
5275 : GetSymFromUnknownTree - returns a symbol with name, name, from the
5276 : unknown tree.
5277 : If no symbol with name is found then NulSym
5278 : is returned.
5279 : */
5280 :
5281 30493674 : static unsigned int GetSymFromUnknownTree (NameKey_Name name)
5282 : {
5283 30493674 : SymbolTable_PtrToCallFrame pCall;
5284 30493674 : unsigned int ScopeSym;
5285 30493674 : unsigned int ScopeId;
5286 30493674 : unsigned int Sym;
5287 :
5288 30493674 : if (ScopePtr > 0)
5289 : {
5290 : ScopeId = ScopePtr;
5291 49754706 : do {
5292 49754706 : pCall = GetPcall (ScopeId);
5293 49754706 : ScopeSym = pCall->Search;
5294 49754706 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
5295 : {
5296 42036320 : Sym = ExamineUnresolvedTree (ScopeSym, name);
5297 42036320 : if (Sym != SymbolTable_NulSym)
5298 : {
5299 : return Sym;
5300 : }
5301 : }
5302 44979689 : ScopeId -= 1;
5303 64240721 : } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
5304 : }
5305 : /* Get symbol from unknown tree */
5306 25718657 : return ExamineUnresolvedTree (CurrentModule, name);
5307 : /* static analysis guarentees a RETURN statement will be used before here. */
5308 : __builtin_unreachable ();
5309 : }
5310 :
5311 :
5312 : /*
5313 : ExamineUnresolvedTree - returns a symbol with name, name, from the
5314 : unresolved tree of module, ModSym.
5315 : If no symbol with name is found then NulSym
5316 : is returned.
5317 : */
5318 :
5319 141932960 : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
5320 : {
5321 141932960 : SymbolTable_PtrToSymbol pSym;
5322 141932960 : unsigned int Sym;
5323 :
5324 : /* Get symbol from unknown tree */
5325 141932960 : pSym = GetPsym (ScopeSym);
5326 141932960 : switch (pSym->SymbolType)
5327 : {
5328 85313952 : case SymbolTable_DefImpSym:
5329 85313952 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name));
5330 85313952 : break;
5331 :
5332 14418150 : case SymbolTable_ModuleSym:
5333 14418150 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, name));
5334 14418150 : break;
5335 :
5336 42200858 : case SymbolTable_ProcedureSym:
5337 42200858 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name));
5338 42200858 : break;
5339 :
5340 :
5341 0 : default:
5342 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5343 141932960 : break;
5344 : }
5345 141932960 : return Sym;
5346 : /* static analysis guarentees a RETURN statement will be used before here. */
5347 : __builtin_unreachable ();
5348 : }
5349 :
5350 :
5351 : /*
5352 : RemoveFromUnresolvedTree - removes a symbol with name, name, from the
5353 : unresolved tree of symbol, ScopeSym.
5354 : */
5355 :
5356 4775635 : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
5357 : {
5358 4775635 : SymbolTable_PtrToSymbol pSym;
5359 :
5360 : /* Get symbol from unknown tree */
5361 4775635 : pSym = GetPsym (ScopeSym);
5362 4775635 : switch (pSym->SymbolType)
5363 : {
5364 4764996 : case SymbolTable_DefImpSym:
5365 4764996 : if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) != SymbolKey_NulKey)
5366 : {
5367 4764996 : SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
5368 4764996 : return true;
5369 : }
5370 : break;
5371 :
5372 10003 : case SymbolTable_ModuleSym:
5373 10003 : if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) != SymbolKey_NulKey)
5374 : {
5375 10003 : SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
5376 10003 : return true;
5377 : }
5378 : break;
5379 :
5380 636 : case SymbolTable_ProcedureSym:
5381 636 : if ((SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name)) != SymbolKey_NulKey)
5382 : {
5383 18 : SymbolKey_DelSymKey (pSym->Procedure.Unresolved, name);
5384 18 : return true;
5385 : }
5386 : break;
5387 :
5388 :
5389 0 : default:
5390 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5391 : break;
5392 : }
5393 : return false;
5394 : /* static analysis guarentees a RETURN statement will be used before here. */
5395 : __builtin_unreachable ();
5396 : }
5397 :
5398 :
5399 : /*
5400 : FetchUnknownSym - returns a symbol from the unknown tree if one is
5401 : available. It also updates the unknown tree.
5402 : */
5403 :
5404 19639129 : static unsigned int FetchUnknownSym (NameKey_Name name)
5405 : {
5406 19639129 : unsigned int Sym;
5407 :
5408 19639129 : Sym = GetSymFromUnknownTree (name);
5409 19639129 : if (Sym != SymbolTable_NulSym)
5410 : {
5411 4775017 : SubSymFromUnknownTree (name);
5412 : }
5413 19639129 : return Sym;
5414 : /* static analysis guarentees a RETURN statement will be used before here. */
5415 : __builtin_unreachable ();
5416 : }
5417 :
5418 :
5419 : /*
5420 : TransparentScope - returns true is the scope symbol Sym is allowed
5421 : to look to an outer level for a symbol.
5422 : ie is the symbol allowed to look to the parent
5423 : scope for a symbol.
5424 : */
5425 :
5426 117331231 : static bool TransparentScope (unsigned int Sym)
5427 : {
5428 117331231 : SymbolTable_PtrToSymbol pSym;
5429 :
5430 117331231 : pSym = GetPsym (Sym);
5431 117331231 : return (pSym->SymbolType != SymbolTable_DefImpSym) && (pSym->SymbolType != SymbolTable_ModuleSym);
5432 : /* static analysis guarentees a RETURN statement will be used before here. */
5433 : __builtin_unreachable ();
5434 : }
5435 :
5436 :
5437 : /*
5438 : GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
5439 : the scope before the current module scope.
5440 : */
5441 :
5442 276 : static unsigned int GetLastModuleOrProcedureScope (void)
5443 : {
5444 276 : SymbolTable_PtrToCallFrame pCall;
5445 276 : unsigned int i;
5446 :
5447 : /* find current inner module */
5448 276 : i = ScopePtr;
5449 276 : pCall = GetPcall (i);
5450 552 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
5451 : {
5452 0 : M2Debug_Assert (i > 0);
5453 0 : i -= 1;
5454 0 : pCall = GetPcall (i);
5455 : }
5456 : /* found module at position, i. */
5457 276 : i -= 1; /* Move to an outer level module or procedure scope */
5458 276 : pCall = GetPcall (i); /* Move to an outer level module or procedure scope */
5459 552 : while (((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search)))) && (! (SymbolTable_IsProcedure (pCall->Search))))
5460 : {
5461 0 : M2Debug_Assert (i > 0);
5462 0 : i -= 1;
5463 0 : pCall = GetPcall (i);
5464 : }
5465 : /* Found module at position, i. */
5466 276 : return pCall->Search;
5467 : /* static analysis guarentees a RETURN statement will be used before here. */
5468 : __builtin_unreachable ();
5469 : }
5470 :
5471 :
5472 : /*
5473 : AddSymToScope - adds a symbol Sym with name name to
5474 : the current scope symbol tree.
5475 : */
5476 :
5477 24749486 : static void AddSymToScope (unsigned int Sym, NameKey_Name name)
5478 : {
5479 24749486 : SymbolTable_PtrToSymbol pSym;
5480 24749486 : SymbolTable_PtrToCallFrame pCall;
5481 24749486 : unsigned int ScopeId;
5482 :
5483 24749486 : pCall = GetPcall (ScopePtr);
5484 24749486 : ScopeId = pCall->Main;
5485 : /*
5486 : WriteString('Adding ') ; WriteKey(name) ; WriteString(' :') ; WriteCard(Sym, 4) ; WriteString(' to scope: ') ;
5487 : WriteKey(GetSymName(ScopeId)) ; WriteLn ;
5488 : */
5489 24749486 : pSym = GetPsym (ScopeId);
5490 24749486 : switch (pSym->SymbolType)
5491 : {
5492 10694032 : case SymbolTable_DefImpSym:
5493 10694032 : if (name != NameKey_NulName)
5494 : {
5495 6105822 : SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, name, Sym);
5496 : }
5497 10694032 : if (SymbolTable_IsEnumeration (Sym))
5498 : {
5499 33938 : CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
5500 : }
5501 : break;
5502 :
5503 2356375 : case SymbolTable_ModuleSym:
5504 2356375 : if (name != NameKey_NulName)
5505 : {
5506 1532267 : SymbolKey_PutSymKey (pSym->Module.LocalSymbols, name, Sym);
5507 : }
5508 2356375 : if (SymbolTable_IsEnumeration (Sym))
5509 : {
5510 16429 : CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
5511 : }
5512 : break;
5513 :
5514 11699079 : case SymbolTable_ProcedureSym:
5515 11699079 : if (name != NameKey_NulName)
5516 : {
5517 11495871 : SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, name, Sym);
5518 : }
5519 11699079 : if (SymbolTable_IsEnumeration (Sym))
5520 : {
5521 0 : CheckEnumerationInList (pSym->Procedure.EnumerationScopeList, Sym);
5522 : }
5523 : break;
5524 :
5525 :
5526 0 : default:
5527 0 : M2Error_InternalError ((const char *) "should never get here", 21);
5528 24749486 : break;
5529 : }
5530 24749486 : }
5531 :
5532 :
5533 : /*
5534 : PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
5535 : Procedure symbols enumeration
5536 : list onto the scope stack.
5537 : */
5538 :
5539 31964047 : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym)
5540 : {
5541 31964047 : SymbolTable_PtrToSymbol pSym;
5542 :
5543 31964047 : pSym = GetPsym (Sym);
5544 31964047 : switch (pSym->SymbolType)
5545 : {
5546 10390676 : case SymbolTable_DefImpSym:
5547 10390676 : PlaceEnumerationListOntoScope (pSym->DefImp.EnumerationScopeList);
5548 10390676 : break;
5549 :
5550 80080 : case SymbolTable_ModuleSym:
5551 80080 : PlaceEnumerationListOntoScope (pSym->Module.EnumerationScopeList);
5552 80080 : break;
5553 :
5554 21493290 : case SymbolTable_ProcedureSym:
5555 21493290 : PlaceEnumerationListOntoScope (pSym->Procedure.EnumerationScopeList);
5556 21493290 : break;
5557 :
5558 :
5559 1 : default:
5560 1 : M2Error_InternalError ((const char *) "expecting - DefImp, Module or Procedure symbol", 46);
5561 31964046 : break;
5562 : }
5563 31964046 : }
5564 :
5565 :
5566 : /*
5567 : PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
5568 : scope stack. This list will automatically
5569 : removed via one call to EndScope which
5570 : matches the StartScope by which this
5571 : procedure is invoked.
5572 : */
5573 :
5574 31964046 : static void PlaceEnumerationListOntoScope (Lists_List l)
5575 : {
5576 31964046 : unsigned int i;
5577 31964046 : unsigned int n;
5578 :
5579 31964046 : n = Lists_NoOfItemsInList (l);
5580 31964046 : i = 1;
5581 64513926 : while (i <= n)
5582 : {
5583 585834 : SymbolTable_PseudoScope (Lists_GetItemFromList (l, i));
5584 585834 : i += 1;
5585 : }
5586 31964046 : }
5587 :
5588 :
5589 : /*
5590 : SetFirstUsed - assigns the FirstUsed field in at to tok providing
5591 : it has not already been set.
5592 : */
5593 :
5594 33 : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at)
5595 : {
5596 0 : if ((*at).FirstUsed == M2LexBuf_UnknownTokenNo)
5597 : {
5598 0 : (*at).FirstUsed = tok;
5599 : }
5600 0 : }
5601 :
5602 :
5603 : /*
5604 : PutFirstUsed - sets tok to the first used providing it has not already been set.
5605 : It also includes the read and write quad into the usage list
5606 : providing the quad numbers are not 0.
5607 : */
5608 :
5609 36 : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_)
5610 : {
5611 36 : SymbolTable_PtrToSymbol pSym;
5612 :
5613 36 : if (SymbolTable_IsVar (object))
5614 : {
5615 33 : pSym = GetPsym (object);
5616 33 : SetFirstUsed (tok, &pSym->Var.At);
5617 33 : if (read_ != 0)
5618 : {
5619 18 : SymbolTable_PutReadQuad (object, SymbolTable_GetMode (object), read_);
5620 : }
5621 33 : if (write_ != 0)
5622 : {
5623 15 : SymbolTable_PutWriteQuad (object, SymbolTable_GetMode (object), write_);
5624 : }
5625 : }
5626 36 : }
5627 :
5628 :
5629 : /*
5630 : CanLookThroughScope - by default this procedure returns TRUE. It only returns
5631 : FALSE if, throughProcedure, is FALSE and the ScopeSym is
5632 : a procedure.
5633 : */
5634 :
5635 78216386 : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure)
5636 : {
5637 78216386 : if (SymbolTable_IsProcedure (ScopeSym))
5638 : {
5639 : return throughProcedure;
5640 : }
5641 : else
5642 : {
5643 0 : return true;
5644 : }
5645 : /* static analysis guarentees a RETURN statement will be used before here. */
5646 : __builtin_unreachable ();
5647 : }
5648 :
5649 :
5650 : /*
5651 : GetScopeSym - searches the current scope and below, providing that the
5652 : scopes are transparent, for a symbol with name, name.
5653 : It only passes over procedure scopes if, throughProcedure,
5654 : is TRUE.
5655 : */
5656 :
5657 107950016 : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure)
5658 : {
5659 107950016 : SymbolTable_PtrToCallFrame pCall;
5660 107950016 : unsigned int ScopeSym;
5661 107950016 : unsigned int ScopeId;
5662 107950016 : unsigned int Sym;
5663 :
5664 : /* DisplayScopes ; */
5665 107950016 : ScopeId = ScopePtr;
5666 107950016 : pCall = GetPcall (ScopeId);
5667 107950016 : ScopeSym = pCall->Search;
5668 : /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) ; */
5669 107950016 : Sym = CheckScopeForSym (ScopeSym, name);
5670 442105621 : while ((((ScopeId > 0) && (Sym == SymbolTable_NulSym)) && (TransparentScope (ScopeSym))) && (CanLookThroughScope (ScopeSym, throughProcedure)))
5671 : {
5672 78216386 : ScopeId -= 1;
5673 78216386 : pCall = GetPcall (ScopeId);
5674 78216386 : ScopeSym = pCall->Search;
5675 78216386 : Sym = CheckScopeForSym (ScopeSym, name);
5676 : }
5677 : /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) */
5678 : /* IF Sym#NulSym THEN WriteKey(GetSymName(Sym)) END ; WriteLn ; */
5679 107950016 : return Sym;
5680 : /* static analysis guarentees a RETURN statement will be used before here. */
5681 : __builtin_unreachable ();
5682 : }
5683 :
5684 :
5685 : /*
5686 : CheckScopeForSym - checks the scope, ScopeSym, for an identifier
5687 : of name, name. CheckScopeForSym checks for
5688 : the symbol by the GetLocalSym and also
5689 : ExamineUnresolvedTree.
5690 : */
5691 :
5692 186166668 : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name)
5693 : {
5694 186166668 : unsigned int Sym;
5695 :
5696 186166668 : Sym = SymbolTable_GetLocalSym (ScopeSym, name);
5697 186166668 : if ((Sym == SymbolTable_NulSym) && (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym))))
5698 : {
5699 74177835 : Sym = ExamineUnresolvedTree (ScopeSym, name);
5700 : }
5701 186166668 : return Sym;
5702 : /* static analysis guarentees a RETURN statement will be used before here. */
5703 : __builtin_unreachable ();
5704 : }
5705 :
5706 :
5707 : /*
5708 : GetModuleScopeId - returns the scope index to the next module starting
5709 : at index, Id.
5710 : Id will either point to a null scope (NulSym) or
5711 : alternatively point to a Module or DefImp symbol.
5712 : */
5713 :
5714 139172 : static unsigned int GetModuleScopeId (unsigned int Id)
5715 : {
5716 139172 : SymbolTable_PtrToCallFrame pCall;
5717 139172 : unsigned int s;
5718 :
5719 139172 : pCall = GetPcall (Id);
5720 139172 : s = pCall->Search;
5721 231097 : while (((Id > 0) && (s != SymbolTable_NulSym)) && ((! (SymbolTable_IsModule (s))) && (! (SymbolTable_IsDefImp (s)))))
5722 : {
5723 91925 : Id -= 1;
5724 91925 : pCall = GetPcall (Id);
5725 91925 : s = pCall->Search;
5726 : }
5727 139172 : return Id;
5728 : /* static analysis guarentees a RETURN statement will be used before here. */
5729 : __builtin_unreachable ();
5730 : }
5731 :
5732 :
5733 : /*
5734 : GetVisibleSym -
5735 : */
5736 :
5737 36 : static unsigned int GetVisibleSym (NameKey_Name name)
5738 : {
5739 36 : SymbolTable_PtrToCallFrame pCall;
5740 36 : unsigned int Sym;
5741 36 : unsigned int i;
5742 :
5743 36 : i = ScopePtr;
5744 42 : while (i >= 1)
5745 : {
5746 42 : pCall = GetPcall (i);
5747 42 : if (pCall->Search == pCall->Main)
5748 : {
5749 30 : return SymbolTable_GetLocalSym (pCall->Main, name);
5750 : }
5751 : else
5752 : {
5753 12 : if (SymbolTable_IsEnumeration (pCall->Search))
5754 : {
5755 12 : Sym = SymbolTable_GetLocalSym (pCall->Search, name);
5756 12 : if (Sym != SymbolTable_NulSym)
5757 : {
5758 : return Sym;
5759 : }
5760 : }
5761 : }
5762 6 : i -= 1;
5763 : }
5764 : return SymbolTable_NulSym;
5765 : /* static analysis guarentees a RETURN statement will be used before here. */
5766 : __builtin_unreachable ();
5767 : }
5768 :
5769 :
5770 : /*
5771 : IsAlreadyDeclaredSym - returns true if Sym has already been declared
5772 : in the current main scope.
5773 : */
5774 :
5775 19638958 : static bool IsAlreadyDeclaredSym (NameKey_Name name)
5776 : {
5777 19638958 : SymbolTable_PtrToCallFrame pCall;
5778 19638958 : unsigned int i;
5779 :
5780 19638958 : i = ScopePtr;
5781 22612238 : while (i >= 1)
5782 : {
5783 22612238 : pCall = GetPcall (i);
5784 22612238 : if (pCall->Search == pCall->Main)
5785 : {
5786 19638952 : return (SymbolTable_GetLocalSym (pCall->Main, name)) != SymbolTable_NulSym;
5787 : }
5788 : else
5789 : {
5790 2973286 : if ((SymbolTable_IsEnumeration (pCall->Search)) && ((SymbolTable_GetLocalSym (pCall->Search, name)) != SymbolTable_NulSym))
5791 : {
5792 : return true;
5793 : }
5794 : }
5795 2973280 : i -= 1;
5796 : }
5797 : return false;
5798 : /* static analysis guarentees a RETURN statement will be used before here. */
5799 : __builtin_unreachable ();
5800 : }
5801 :
5802 :
5803 : /*
5804 : GenName - returns a new name consisting of pre, name, post concatenation.
5805 : */
5806 :
5807 417224 : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high)
5808 : {
5809 417224 : DynamicStrings_String str;
5810 417224 : NameKey_Name result;
5811 417224 : char pre[_pre_high+1];
5812 417224 : char post[_post_high+1];
5813 :
5814 : /* make a local copy of each unbounded array. */
5815 417224 : memcpy (pre, pre_, _pre_high+1);
5816 417224 : memcpy (post, post_, _post_high+1);
5817 :
5818 417224 : str = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (libname));
5819 417224 : str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) pre, _pre_high)));
5820 417224 : str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
5821 417224 : str = DynamicStrings_ConCat (str, DynamicStrings_InitString ((const char *) post, _post_high));
5822 417224 : result = NameKey_makekey (DynamicStrings_string (str));
5823 417224 : str = DynamicStrings_KillString (str);
5824 417224 : return result;
5825 : /* static analysis guarentees a RETURN statement will be used before here. */
5826 : __builtin_unreachable ();
5827 417224 : }
5828 :
5829 :
5830 : /*
5831 : InitCtor - initialize the ModuleCtor fields to NulSym.
5832 : */
5833 :
5834 206198 : static void InitCtor (SymbolTable_ModuleCtor *ctor)
5835 : {
5836 206198 : (*ctor).ctor = SymbolTable_NulSym;
5837 206198 : (*ctor).dep = SymbolTable_NulSym;
5838 206198 : (*ctor).init = SymbolTable_NulSym;
5839 206198 : (*ctor).fini = SymbolTable_NulSym;
5840 0 : }
5841 :
5842 :
5843 : /*
5844 : InitCtorFields - initialize the ModuleCtor fields. An inner module has no
5845 : ctor procedure.
5846 : */
5847 :
5848 85023 : static void InitCtorFields (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym, SymbolTable_ModuleCtor *ctor, NameKey_Name name, bool inner, bool pub)
5849 : {
5850 85023 : if (M2Options_ScaffoldDynamic && ! inner)
5851 : {
5852 : /* The ctor procedure must be public. */
5853 84237 : (*ctor).ctor = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_ctor", 5));
5854 84237 : SymbolTable_PutCtor ((*ctor).ctor, true);
5855 84237 : M2Debug_Assert (pub);
5856 84237 : SymbolTable_PutPublic ((*ctor).ctor, pub);
5857 84237 : SymbolTable_PutExtern ((*ctor).ctor, ! pub);
5858 84237 : SymbolTable_PutMonoName ((*ctor).ctor, true);
5859 : /* The dep procedure is local to the module. */
5860 84237 : (*ctor).dep = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_dep", 4));
5861 84237 : SymbolTable_PutMonoName ((*ctor).dep, true);
5862 : }
5863 : else
5864 : {
5865 786 : (*ctor).ctor = SymbolTable_NulSym;
5866 786 : (*ctor).dep = SymbolTable_NulSym;
5867 : }
5868 : /* The init/fini procedures must be public. */
5869 85023 : (*ctor).init = SymbolTable_MakeProcedure (beginTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_init", 5));
5870 85023 : SymbolTable_PutPublic ((*ctor).init, pub);
5871 85023 : SymbolTable_PutExtern ((*ctor).init, ! pub);
5872 85023 : SymbolTable_PutMonoName ((*ctor).init, ! inner);
5873 85023 : M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).init);
5874 85023 : (*ctor).fini = SymbolTable_MakeProcedure (finallyTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_fini", 5));
5875 85023 : SymbolTable_PutPublic ((*ctor).fini, pub);
5876 85023 : SymbolTable_PutExtern ((*ctor).fini, ! pub);
5877 85023 : SymbolTable_PutMonoName ((*ctor).fini, ! inner);
5878 85023 : M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).fini);
5879 85023 : }
5880 :
5881 :
5882 : /*
5883 : CheckTok - checks to see that tok is at a known location. If not
5884 : it uses GetTokenNo as a fall back.
5885 : */
5886 :
5887 24544686 : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high)
5888 : {
5889 24544686 : DynamicStrings_String s;
5890 24544686 : char name[_name_high+1];
5891 :
5892 : /* make a local copy of each unbounded array. */
5893 24544686 : memcpy (name, name_, _name_high+1);
5894 :
5895 24544686 : if (tok == M2LexBuf_UnknownTokenNo)
5896 : {
5897 45516 : tok = M2LexBuf_GetTokenNo ();
5898 45516 : if (DebugUnknownToken)
5899 : {
5900 : s = DynamicStrings_InitString ((const char *) name, _name_high);
5901 : s = DynamicStrings_ConCat (s, DynamicStrings_InitString ((const char *) " symbol {%W} has been created with an unknown token location", 60));
5902 : M2MetaError_MetaErrorStringT0 (M2LexBuf_GetTokenNo (), s);
5903 : }
5904 : }
5905 24544686 : return tok;
5906 : /* static analysis guarentees a RETURN statement will be used before here. */
5907 : __builtin_unreachable ();
5908 0 : }
5909 :
5910 :
5911 : /*
5912 : GetLink - returns TRUE if the current module is only used for linkage.
5913 : */
5914 :
5915 384487 : static bool GetLink (void)
5916 : {
5917 384487 : unsigned int OuterModule;
5918 :
5919 384487 : OuterModule = SymbolTable_GetCurrentModule ();
5920 384487 : if (OuterModule != SymbolTable_NulSym)
5921 : {
5922 : /* avoid gcc warning by using compound statement even if not strictly necessary. */
5923 369036 : if (M2Comp_CompilingDefinitionModule ())
5924 : {
5925 8718 : return SymbolTable_IsDefLink (OuterModule);
5926 : }
5927 : else
5928 : {
5929 360318 : return SymbolTable_IsModLink (OuterModule);
5930 : }
5931 : }
5932 : /* Default is that the module is for compiling. */
5933 : return false;
5934 : /* static analysis guarentees a RETURN statement will be used before here. */
5935 : __builtin_unreachable ();
5936 : }
5937 :
5938 :
5939 : /*
5940 : AddModuleToParent - adds symbol, Sym, to module, Parent.
5941 : */
5942 :
5943 446 : static void AddModuleToParent (unsigned int Sym, unsigned int Parent)
5944 : {
5945 446 : SymbolTable_PtrToSymbol pSym;
5946 :
5947 446 : pSym = GetPsym (Parent);
5948 446 : switch (pSym->SymbolType)
5949 : {
5950 18 : case SymbolTable_DefImpSym:
5951 18 : Lists_PutItemIntoList (pSym->DefImp.ListOfModules, Sym);
5952 18 : break;
5953 :
5954 272 : case SymbolTable_ModuleSym:
5955 272 : Lists_PutItemIntoList (pSym->Module.ListOfModules, Sym);
5956 272 : break;
5957 :
5958 156 : case SymbolTable_ProcedureSym:
5959 156 : Lists_PutItemIntoList (pSym->Procedure.ListOfModules, Sym);
5960 156 : break;
5961 :
5962 :
5963 0 : default:
5964 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
5965 446 : break;
5966 : }
5967 446 : }
5968 :
5969 :
5970 : /*
5971 : PutProcedureExternPublic - if procedure is not NulSym set extern
5972 : and public booleans.
5973 : */
5974 :
5975 461920 : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub)
5976 : {
5977 461920 : if (procedure != SymbolTable_NulSym)
5978 : {
5979 461920 : SymbolTable_PutExtern (procedure, extern_);
5980 461920 : SymbolTable_PutPublic (procedure, pub);
5981 : }
5982 461920 : }
5983 :
5984 :
5985 : /*
5986 : PutCtorExtern -
5987 : */
5988 :
5989 115480 : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_)
5990 : {
5991 : /* If the ctor does not exist then make it extern/ (~extern) public. */
5992 115480 : if ((*ctor).ctor == SymbolTable_NulSym)
5993 : {
5994 19808 : (*ctor).ctor = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_ctor", 5));
5995 19808 : SymbolTable_PutMonoName ((*ctor).ctor, true);
5996 : }
5997 115480 : PutProcedureExternPublic ((*ctor).ctor, extern_, ! extern_);
5998 115480 : SymbolTable_PutCtor ((*ctor).ctor, true);
5999 : /* If the ctor does not exist then make it extern/ (~extern) public. */
6000 115480 : if ((*ctor).dep == SymbolTable_NulSym)
6001 : {
6002 19808 : (*ctor).dep = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_dep", 4));
6003 19808 : SymbolTable_PutMonoName ((*ctor).dep, true);
6004 : }
6005 115480 : PutProcedureExternPublic ((*ctor).dep, extern_, ! extern_);
6006 : /* If init/fini do not exist then create them. */
6007 115480 : if ((*ctor).init == SymbolTable_NulSym)
6008 : {
6009 19544 : (*ctor).init = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_init", 5));
6010 19544 : M2Scaffold_DeclareArgEnvParams (tok, (*ctor).init);
6011 19544 : SymbolTable_PutMonoName ((*ctor).init, ! (SymbolTable_IsInnerModule (sym)));
6012 : }
6013 115480 : PutProcedureExternPublic ((*ctor).init, extern_, ! extern_);
6014 115480 : if ((*ctor).fini == SymbolTable_NulSym)
6015 : {
6016 19544 : (*ctor).fini = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_fini", 5));
6017 19544 : M2Scaffold_DeclareArgEnvParams (tok, (*ctor).fini);
6018 19544 : SymbolTable_PutMonoName ((*ctor).fini, ! (SymbolTable_IsInnerModule (sym)));
6019 : }
6020 115480 : PutProcedureExternPublic ((*ctor).fini, extern_, ! extern_);
6021 115480 : }
6022 :
6023 :
6024 : /*
6025 : InitProcedureDeclaration - initialize all the ProcedureDeclaration
6026 : fields.
6027 : */
6028 :
6029 15540651 : static void InitProcedureDeclaration (SymbolTable_ProcedureDeclaration *decl)
6030 : {
6031 15540651 : (*decl).Defined = false; /* Has the procedure been */
6032 : /* declared yet? */
6033 15540651 : (*decl).ParamDefined = false; /* Have the parameters been */
6034 : /* defined yet? */
6035 15540651 : (*decl).HasVarArgs = false; /* Does the procedure use ... ? */
6036 15540651 : (*decl).HasOptArg = false; /* Does this procedure use [ ] ? */
6037 15540651 : (*decl).IsNoReturn = false; /* Declared attribute noreturn ? */
6038 15540651 : (*decl).ReturnOptional = false; /* Is the return value optional? */
6039 15540651 : (*decl).ProcedureTok = M2LexBuf_UnknownTokenNo; /* Is the return value optional? */
6040 0 : }
6041 :
6042 :
6043 : /*
6044 : AddProcedureToList - adds a procedure, Proc, to the list of procedures
6045 : in module, Mod.
6046 : */
6047 :
6048 5180217 : static void AddProcedureToList (unsigned int Mod, unsigned int Proc)
6049 : {
6050 5180217 : SymbolTable_PtrToSymbol pSym;
6051 :
6052 5180217 : pSym = GetPsym (Mod);
6053 5180217 : switch (pSym->SymbolType)
6054 : {
6055 4493399 : case SymbolTable_DefImpSym:
6056 4493399 : Lists_PutItemIntoList (pSym->DefImp.ListOfProcs, Proc);
6057 4493399 : break;
6058 :
6059 686386 : case SymbolTable_ModuleSym:
6060 686386 : Lists_PutItemIntoList (pSym->Module.ListOfProcs, Proc);
6061 686386 : break;
6062 :
6063 432 : case SymbolTable_ProcedureSym:
6064 432 : Lists_PutItemIntoList (pSym->Procedure.ListOfProcs, Proc);
6065 432 : break;
6066 :
6067 :
6068 0 : default:
6069 0 : M2Error_InternalError ((const char *) "expecting ModuleSym, DefImpSym or ProcedureSym symbol", 53);
6070 5180217 : break;
6071 : }
6072 5180217 : }
6073 :
6074 :
6075 : /*
6076 : AddVarToScopeList - adds symbol, sym, to, scope.
6077 : */
6078 :
6079 11606225 : static void AddVarToScopeList (unsigned int scope, unsigned int sym)
6080 : {
6081 11606225 : SymbolTable_PtrToSymbol pSym;
6082 :
6083 11606225 : pSym = GetPsym (scope);
6084 11606225 : switch (pSym->SymbolType)
6085 : {
6086 11353342 : case SymbolTable_ProcedureSym:
6087 11353342 : Lists_PutItemIntoList (pSym->Procedure.ListOfVars, sym);
6088 11353342 : break;
6089 :
6090 103077 : case SymbolTable_ModuleSym:
6091 103077 : Lists_PutItemIntoList (pSym->Module.ListOfVars, sym);
6092 103077 : break;
6093 :
6094 149806 : case SymbolTable_DefImpSym:
6095 149806 : Lists_PutItemIntoList (pSym->DefImp.ListOfVars, sym);
6096 149806 : break;
6097 :
6098 :
6099 0 : default:
6100 0 : M2Error_InternalError ((const char *) "expecting Procedure or Module symbol", 36);
6101 11606225 : break;
6102 : }
6103 11606225 : }
6104 :
6105 :
6106 : /*
6107 : AddVarToList - add a variable symbol to the list of variables maintained
6108 : by the inner most scope. (Procedure or Module).
6109 : */
6110 :
6111 11606207 : static void AddVarToList (unsigned int Sym)
6112 : {
6113 11606207 : SymbolTable_PtrToCallFrame pCall;
6114 :
6115 11606207 : pCall = GetPcall (ScopePtr);
6116 11606207 : AddVarToScopeList (pCall->Main, Sym);
6117 11606207 : }
6118 :
6119 :
6120 : /*
6121 : InitVarDecl - initialize the variable and type token location positions.
6122 : */
6123 :
6124 11606207 : static void InitVarDecl (SymbolTable_VarDecl *decl, unsigned int vartok)
6125 : {
6126 11606207 : (*decl).FullTok = M2LexBuf_UnknownTokenNo;
6127 11606207 : (*decl).VarTok = vartok;
6128 11606207 : (*decl).TypeTok = M2LexBuf_UnknownTokenNo;
6129 0 : }
6130 :
6131 :
6132 : /*
6133 : doPutVarDeclTypeTok - places typetok into decl.TypeTok.
6134 : sym must be a variable.
6135 : */
6136 :
6137 0 : static void doPutVarDeclTypeTok (unsigned int sym, unsigned int typetok)
6138 : {
6139 0 : SymbolTable_PtrToSymbol pSym;
6140 :
6141 0 : M2Debug_Assert (SymbolTable_IsVar (sym));
6142 0 : pSym = GetPsym (sym);
6143 0 : pSym->Var.Declared.TypeTok = typetok;
6144 0 : }
6145 :
6146 :
6147 : /*
6148 : doPutVarDeclTok - places vartok into decl.VarTok.
6149 : sym must be a variable.
6150 : */
6151 :
6152 1735869 : static void doPutVarDeclTok (unsigned int sym, unsigned int vartok)
6153 : {
6154 1735869 : SymbolTable_PtrToSymbol pSym;
6155 :
6156 1735869 : M2Debug_Assert (SymbolTable_IsVar (sym));
6157 1735869 : pSym = GetPsym (sym);
6158 1735869 : pSym->Var.Declared.VarTok = vartok;
6159 1735869 : }
6160 :
6161 :
6162 : /*
6163 : doGetVarDeclTok - return decl.VarTok for a variable.
6164 : */
6165 :
6166 60 : static unsigned int doGetVarDeclTok (unsigned int sym)
6167 : {
6168 60 : SymbolTable_PtrToSymbol pSym;
6169 :
6170 60 : pSym = GetPsym (sym);
6171 60 : M2Debug_Assert (SymbolTable_IsVar (sym));
6172 60 : return pSym->Var.Declared.VarTok;
6173 : /* static analysis guarentees a RETURN statement will be used before here. */
6174 : __builtin_unreachable ();
6175 : }
6176 :
6177 :
6178 : /*
6179 : doGetVarDeclTypeTok - return decl.TypeTok for a variable.
6180 : */
6181 :
6182 0 : static unsigned int doGetVarDeclTypeTok (unsigned int sym)
6183 : {
6184 0 : SymbolTable_PtrToSymbol pSym;
6185 :
6186 0 : pSym = GetPsym (sym);
6187 0 : M2Debug_Assert (SymbolTable_IsVar (sym));
6188 0 : return pSym->Var.Declared.TypeTok;
6189 : /* static analysis guarentees a RETURN statement will be used before here. */
6190 : __builtin_unreachable ();
6191 : }
6192 :
6193 :
6194 : /*
6195 : doGetVarDeclFullTok - return the full declaration of var: type.
6196 : */
6197 :
6198 282 : static unsigned int doGetVarDeclFullTok (unsigned int sym)
6199 : {
6200 282 : SymbolTable_PtrToSymbol pSym;
6201 :
6202 282 : pSym = GetPsym (sym);
6203 282 : M2Debug_Assert (SymbolTable_IsVar (sym));
6204 282 : if (pSym->Var.Declared.FullTok == M2LexBuf_UnknownTokenNo)
6205 : {
6206 : /* avoid gcc warning by using compound statement even if not strictly necessary. */
6207 282 : if (pSym->Var.Declared.TypeTok == M2LexBuf_UnknownTokenNo)
6208 : {
6209 66 : return pSym->Var.Declared.VarTok;
6210 : }
6211 : else
6212 : {
6213 216 : pSym->Var.Declared.FullTok = M2LexBuf_MakeVirtual2Tok (pSym->Var.Declared.VarTok, pSym->Var.Declared.TypeTok);
6214 : }
6215 : }
6216 216 : return pSym->Var.Declared.FullTok;
6217 : /* static analysis guarentees a RETURN statement will be used before here. */
6218 : __builtin_unreachable ();
6219 : }
6220 :
6221 :
6222 : /*
6223 : FillInRecordFields - given a new symbol, sym, make it a record symbol
6224 : and initialize its fields.
6225 : */
6226 :
6227 104029 : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf)
6228 : {
6229 104029 : SymbolTable_PtrToSymbol pSym;
6230 :
6231 104029 : if (! (SymbolTable_IsError (sym)))
6232 : {
6233 104023 : pSym = GetPsym (sym);
6234 104023 : pSym->SymbolType = SymbolTable_RecordSym;
6235 104023 : pSym->Record.name = RecordName;
6236 104023 : SymbolKey_InitTree (&pSym->Record.LocalSymbols);
6237 104023 : pSym->Record.Size = M2ALU_InitValue ();
6238 104023 : Lists_InitList (&pSym->Record.ListOfSons); /* List of RecordFieldSym and VarientSym */
6239 104023 : pSym->Record.oafamily = oaf; /* List of RecordFieldSym and VarientSym */
6240 104023 : pSym->Record.Parent = SymbolTable_NulSym;
6241 104023 : pSym->Record.Align = SymbolTable_NulSym;
6242 104023 : pSym->Record.DefaultAlign = SymbolTable_NulSym;
6243 104023 : pSym->Record.DeclPacked = false;
6244 104023 : pSym->Record.DeclResolved = false;
6245 104023 : pSym->Record.Scope = scope;
6246 208046 : InitWhereDeclaredTok (tok, &pSym->Record.At);
6247 : }
6248 104029 : }
6249 :
6250 :
6251 : /*
6252 : HandleHiddenOrDeclare -
6253 : */
6254 :
6255 6596148 : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf)
6256 : {
6257 6596148 : unsigned int sym;
6258 :
6259 6596148 : sym = CheckForHiddenType (name);
6260 6596148 : if (sym == SymbolTable_NulSym)
6261 : {
6262 6580082 : sym = DeclareSym (tok, name);
6263 6580082 : if (! (SymbolTable_IsError (sym)))
6264 : {
6265 : /* Now add this type to the symbol table of the current scope */
6266 6580070 : AddSymToScope (sym, name);
6267 : }
6268 : }
6269 6596148 : (*oaf) = SymbolTable_GetOAFamily (sym);
6270 6596148 : return sym;
6271 : /* static analysis guarentees a RETURN statement will be used before here. */
6272 : __builtin_unreachable ();
6273 : }
6274 :
6275 :
6276 : /*
6277 : CreateConstLit -
6278 : */
6279 :
6280 624946 : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
6281 : {
6282 624946 : SymbolTable_PtrToSymbol pSym;
6283 624946 : unsigned int Sym;
6284 624946 : bool overflow;
6285 :
6286 624946 : overflow = false;
6287 624946 : if (constType == SymbolTable_NulSym)
6288 : {
6289 477394 : constType = GetConstLitType (tok, constName, &overflow, true);
6290 : }
6291 624946 : NewSym (&Sym);
6292 624946 : pSym = GetPsym (Sym);
6293 624946 : pSym->SymbolType = SymbolTable_ConstLitSym;
6294 624946 : switch (pSym->SymbolType)
6295 : {
6296 624946 : case SymbolTable_ConstLitSym:
6297 624946 : pSym->ConstLit.name = constName;
6298 624946 : pSym->ConstLit.Value = M2ALU_InitValue ();
6299 624946 : M2ALU_PushString (tok, constName, ! overflow);
6300 624946 : M2ALU_PopInto (pSym->ConstLit.Value);
6301 624946 : pSym->ConstLit.Type = constType;
6302 624946 : pSym->ConstLit.IsSet = false;
6303 624946 : pSym->ConstLit.IsInternal = false; /* Is it a default BY constant
6304 : expression? */
6305 624946 : pSym->ConstLit.IsConstructor = false; /* Is it a default BY constant
6306 : expression? */
6307 624946 : pSym->ConstLit.FromType = SymbolTable_NulSym; /* type is determined FromType */
6308 624946 : pSym->ConstLit.RangeError = overflow; /* type is determined FromType */
6309 624946 : pSym->ConstLit.UnresFromType = false; /* is Type resolved? */
6310 624946 : pSym->ConstLit.Scope = SymbolTable_GetCurrentScope (); /* is Type resolved? */
6311 624946 : InitWhereDeclaredTok (tok, &pSym->ConstLit.At);
6312 624946 : InitWhereFirstUsedTok (tok, &pSym->ConstLit.At);
6313 624946 : break;
6314 :
6315 :
6316 : default:
6317 : M2Error_InternalError ((const char *) "expecting ConstLit symbol", 25);
6318 624946 : break;
6319 : }
6320 624946 : return Sym;
6321 : /* static analysis guarentees a RETURN statement will be used before here. */
6322 : __builtin_unreachable ();
6323 : }
6324 :
6325 :
6326 : /*
6327 : LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
6328 : matches tok, constName and constType.
6329 : */
6330 :
6331 1676533 : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType)
6332 : {
6333 1676533 : SymbolTable_ConstLitPoolEntry pe;
6334 1676533 : unsigned int rootIndex;
6335 :
6336 1676533 : rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
6337 1676533 : if (rootIndex != 0)
6338 : {
6339 1370088 : pe = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
6340 17059235 : while (pe != NULL)
6341 : {
6342 15370646 : if (((pe->tok == tok) && (pe->constName == constName)) && (pe->constType == constType))
6343 : {
6344 1051587 : return pe->sym;
6345 : }
6346 14319059 : pe = pe->next;
6347 : }
6348 : }
6349 : return SymbolTable_NulSym;
6350 : /* static analysis guarentees a RETURN statement will be used before here. */
6351 : __builtin_unreachable ();
6352 : }
6353 :
6354 :
6355 : /*
6356 : AddConstLitPoolEntry - adds sym to the constlit pool.
6357 : */
6358 :
6359 624946 : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType)
6360 : {
6361 624946 : SymbolTable_ConstLitPoolEntry pe;
6362 624946 : SymbolTable_ConstLitPoolEntry old;
6363 624946 : unsigned int rootIndex;
6364 624946 : unsigned int high;
6365 :
6366 624946 : rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
6367 624946 : if (rootIndex == SymbolKey_NulKey)
6368 : {
6369 306445 : high = Indexing_HighIndice (ConstLitArray);
6370 306445 : Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
6371 306445 : if (pe == NULL)
6372 : {
6373 0 : M2Error_InternalError ((const char *) "out of memory", 13);
6374 : }
6375 : else
6376 : {
6377 306445 : pe->sym = sym;
6378 306445 : pe->tok = tok;
6379 306445 : pe->constName = constName;
6380 306445 : pe->constType = constType;
6381 306445 : pe->next = NULL;
6382 306445 : SymbolKey_PutSymKey (ConstLitPoolTree, constName, high+1);
6383 306445 : Indexing_PutIndice (ConstLitArray, high+1, reinterpret_cast <void *> (pe));
6384 : }
6385 : }
6386 : else
6387 : {
6388 318501 : Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
6389 318501 : if (pe == NULL)
6390 : {
6391 0 : M2Error_InternalError ((const char *) "out of memory", 13);
6392 : }
6393 : else
6394 : {
6395 318501 : old = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
6396 318501 : pe->sym = sym;
6397 318501 : pe->tok = tok;
6398 318501 : pe->constName = constName;
6399 318501 : pe->constType = constType;
6400 318501 : pe->next = old;
6401 318501 : Indexing_PutIndice (ConstLitArray, rootIndex, reinterpret_cast <void *> (pe));
6402 : }
6403 : }
6404 624946 : }
6405 :
6406 :
6407 : /*
6408 : InitConstString - initialize the constant string.
6409 : */
6410 :
6411 377246 : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known)
6412 : {
6413 377246 : SymbolTable_PtrToSymbol pSym;
6414 :
6415 377246 : pSym = GetPsym (sym);
6416 377246 : pSym->SymbolType = SymbolTable_ConstStringSym;
6417 377246 : switch (pSym->SymbolType)
6418 : {
6419 377246 : case SymbolTable_ConstStringSym:
6420 377246 : pSym->ConstString.name = name;
6421 377246 : pSym->ConstString.StringVariant = kind;
6422 377246 : pSym->ConstString.Scope = SymbolTable_GetCurrentScope ();
6423 377246 : InitWhereDeclaredTok (tok, &pSym->ConstString.At);
6424 377246 : SymbolTable_PutConstStringKnown (tok, sym, contents, escape, known);
6425 377246 : break;
6426 :
6427 :
6428 : default:
6429 : M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
6430 377246 : break;
6431 : }
6432 377246 : }
6433 :
6434 :
6435 : /*
6436 : GetConstStringKind - return the StringVariant field associated with sym.
6437 : */
6438 :
6439 297553 : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym)
6440 : {
6441 297553 : SymbolTable_PtrToSymbol pSym;
6442 :
6443 297553 : pSym = GetPsym (sym);
6444 297553 : switch (pSym->SymbolType)
6445 : {
6446 297553 : case SymbolTable_ConstStringSym:
6447 297553 : return pSym->ConstString.StringVariant;
6448 0 : break;
6449 :
6450 :
6451 0 : default:
6452 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
6453 : break;
6454 : }
6455 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6456 : __builtin_unreachable ();
6457 : }
6458 :
6459 :
6460 : /*
6461 : CanUseBuiltin - returns TRUE if the procedure, Sym, can be
6462 : inlined via a builtin function.
6463 : */
6464 :
6465 19162 : static bool CanUseBuiltin (unsigned int Sym)
6466 : {
6467 19162 : return ! M2Options_DebugBuiltins && ((m2builtins_BuiltinExists (reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetProcedureBuiltin (Sym))))) || (m2builtins_BuiltinExists (reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (Sym))))));
6468 : /* static analysis guarentees a RETURN statement will be used before here. */
6469 : __builtin_unreachable ();
6470 : }
6471 :
6472 :
6473 : /*
6474 : InitPacked - initialise packedInfo to FALSE and NulSym.
6475 : */
6476 :
6477 973661 : static void InitPacked (SymbolTable_PackedInfo *packedInfo)
6478 : {
6479 973661 : (*packedInfo).IsPacked = false;
6480 973661 : (*packedInfo).PackedEquiv = SymbolTable_NulSym;
6481 0 : }
6482 :
6483 :
6484 : /*
6485 : doEquivalent - create a packed equivalent symbol for, sym, and return the
6486 : new symbol. It sets both fields in packedInfo to FALSE
6487 : and the new symbol.
6488 : */
6489 :
6490 14521 : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
6491 : {
6492 14521 : unsigned int nSym;
6493 14521 : SymbolTable_PtrToSymbol pSym;
6494 :
6495 14521 : NewSym (&nSym);
6496 14521 : pSym = GetPsym (nSym);
6497 14521 : pSym->SymbolType = SymbolTable_EquivSym;
6498 14521 : pSym->Equiv.nonPacked = sym;
6499 14521 : pSym->Equiv.packedInfo.IsPacked = true;
6500 14521 : pSym->Equiv.packedInfo.PackedEquiv = SymbolTable_NulSym;
6501 14521 : (*packedInfo).IsPacked = false;
6502 14521 : (*packedInfo).PackedEquiv = nSym;
6503 14521 : return nSym;
6504 : /* static analysis guarentees a RETURN statement will be used before here. */
6505 : __builtin_unreachable ();
6506 : }
6507 :
6508 :
6509 : /*
6510 : MakeEquivalent - return the equivalent packed symbol for, sym.
6511 : */
6512 :
6513 14521 : static unsigned int MakeEquivalent (unsigned int sym)
6514 : {
6515 14521 : SymbolTable_PtrToSymbol pSym;
6516 :
6517 14521 : pSym = GetPsym (sym);
6518 14521 : switch (pSym->SymbolType)
6519 : {
6520 14461 : case SymbolTable_EnumerationSym:
6521 14461 : return doEquivalent (&pSym->Enumeration.packedInfo, sym);
6522 60 : break;
6523 :
6524 60 : case SymbolTable_SubrangeSym:
6525 60 : return doEquivalent (&pSym->Subrange.packedInfo, sym);
6526 0 : break;
6527 :
6528 0 : case SymbolTable_TypeSym:
6529 0 : return doEquivalent (&pSym->Type.packedInfo, sym);
6530 0 : break;
6531 :
6532 0 : case SymbolTable_SetSym:
6533 0 : return doEquivalent (&pSym->Set.packedInfo, sym);
6534 0 : break;
6535 :
6536 :
6537 0 : default:
6538 0 : M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
6539 : break;
6540 : }
6541 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6542 : __builtin_unreachable ();
6543 : }
6544 :
6545 :
6546 : /*
6547 : GetEquivalent -
6548 : */
6549 :
6550 14761 : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
6551 : {
6552 14761 : if ((*packedInfo).IsPacked)
6553 : {
6554 : return sym;
6555 : }
6556 14761 : else if ((*packedInfo).PackedEquiv == SymbolTable_NulSym)
6557 : {
6558 : /* avoid dangling else. */
6559 14521 : (*packedInfo).PackedEquiv = MakeEquivalent (sym);
6560 : }
6561 14761 : return (*packedInfo).PackedEquiv;
6562 : /* static analysis guarentees a RETURN statement will be used before here. */
6563 : __builtin_unreachable ();
6564 : }
6565 :
6566 :
6567 : /*
6568 : doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
6569 : */
6570 :
6571 1369106126 : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase)
6572 : {
6573 1385182699 : SymbolTable_PtrToSymbol pSym;
6574 1385182699 : unsigned int type;
6575 :
6576 1385182699 : type = SymbolTable_NulSym;
6577 1385182699 : M2Debug_Assert (sym != SymbolTable_NulSym);
6578 1385182699 : pSym = GetPsym (sym);
6579 1385182699 : switch (pSym->SymbolType)
6580 : {
6581 0 : case SymbolTable_OAFamilySym:
6582 0 : type = pSym->OAFamily.SimpleType;
6583 0 : break;
6584 :
6585 160139712 : case SymbolTable_VarSym:
6586 160139712 : type = GetTypeOfVar (sym);
6587 160139712 : break;
6588 :
6589 44499128 : case SymbolTable_ConstLitSym:
6590 44499128 : type = pSym->ConstLit.Type;
6591 44499128 : break;
6592 :
6593 39109116 : case SymbolTable_ConstVarSym:
6594 39109116 : type = pSym->ConstVar.Type;
6595 39109116 : break;
6596 :
6597 9877075 : case SymbolTable_ConstStringSym:
6598 9877075 : if (pSym->ConstString.Length == 1)
6599 : {
6600 2012875 : type = M2Base_Char;
6601 : }
6602 : else
6603 : {
6604 : type = SymbolTable_NulSym; /* No type for a string */
6605 : }
6606 : break;
6607 :
6608 189408872 : case SymbolTable_TypeSym:
6609 189408872 : type = pSym->Type.Type;
6610 189408872 : break;
6611 :
6612 482729862 : case SymbolTable_RecordFieldSym:
6613 482729862 : type = pSym->RecordField.Type;
6614 482729862 : break;
6615 :
6616 : case SymbolTable_RecordSym:
6617 : type = SymbolTable_NulSym; /* No type for a record */
6618 : break;
6619 :
6620 : case SymbolTable_VarientSym:
6621 : type = SymbolTable_NulSym; /* No type for a record */
6622 : break;
6623 :
6624 87932931 : case SymbolTable_EnumerationFieldSym:
6625 87932931 : type = pSym->EnumerationField.Type; /* No type for a record */
6626 87932931 : break;
6627 :
6628 : case SymbolTable_EnumerationSym:
6629 : type = SymbolTable_NulSym; /* No type for enumeration */
6630 : break;
6631 :
6632 200468797 : case SymbolTable_PointerSym:
6633 200468797 : type = pSym->Pointer.Type; /* No type for enumeration */
6634 200468797 : break;
6635 :
6636 26707048 : case SymbolTable_ProcedureSym:
6637 26707048 : type = pSym->Procedure.ReturnType;
6638 26707048 : break;
6639 :
6640 11144404 : case SymbolTable_ProcTypeSym:
6641 11144404 : type = pSym->ProcType.ReturnType;
6642 11144404 : break;
6643 :
6644 19405839 : case SymbolTable_ParamSym:
6645 19405839 : type = pSym->Param.Type;
6646 19405839 : break;
6647 :
6648 4324312 : case SymbolTable_VarParamSym:
6649 4324312 : type = pSym->VarParam.Type;
6650 4324312 : break;
6651 :
6652 24594112 : case SymbolTable_SubrangeSym:
6653 24594112 : type = pSym->Subrange.Type;
6654 24594112 : break;
6655 :
6656 11033816 : case SymbolTable_ArraySym:
6657 11033816 : type = pSym->Array.Type;
6658 11033816 : break;
6659 :
6660 11217332 : case SymbolTable_SubscriptSym:
6661 11217332 : type = pSym->Subscript.Type;
6662 11217332 : break;
6663 :
6664 2268345 : case SymbolTable_SetSym:
6665 2268345 : type = pSym->Set.Type;
6666 2268345 : break;
6667 :
6668 59140191 : case SymbolTable_UnboundedSym:
6669 59140191 : type = pSym->Unbounded.Type;
6670 59140191 : break;
6671 :
6672 : case SymbolTable_UndefinedSym:
6673 : type = SymbolTable_NulSym;
6674 : break;
6675 :
6676 0 : case SymbolTable_PartialUnboundedSym:
6677 0 : type = pSym->PartialUnbounded.Type;
6678 0 : break;
6679 :
6680 : case SymbolTable_ObjectSym:
6681 : type = SymbolTable_NulSym;
6682 : break;
6683 :
6684 :
6685 6 : default:
6686 6 : M2Error_InternalError ((const char *) "not implemented yet", 19);
6687 1376136692 : break;
6688 : }
6689 1385182693 : if (((type == SymbolTable_NulSym) && (SymbolTable_IsType (sym))) && ! skipBase)
6690 : {
6691 : return sym; /* sym is a base type */
6692 : }
6693 1369598869 : else if (type != SymbolTable_NulSym)
6694 : {
6695 : /* avoid dangling else. */
6696 1161951522 : if ((SymbolTable_IsType (type)) && skipEquiv)
6697 : {
6698 16246916 : if ((! (SymbolTable_IsHiddenType (type))) || skipHidden)
6699 : {
6700 16076591 : if (((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym) || skipAlign)
6701 : {
6702 16076573 : return doGetType (type, skipEquiv, skipAlign, skipHidden, skipBase);
6703 : }
6704 : }
6705 : }
6706 : }
6707 : return type;
6708 : /* static analysis guarentees a RETURN statement will be used before here. */
6709 : __builtin_unreachable ();
6710 : }
6711 :
6712 :
6713 : /*
6714 : GetTypeOfVar - returns the type of symbol, var.
6715 : */
6716 :
6717 251433988 : static unsigned int GetTypeOfVar (unsigned int var)
6718 : {
6719 251433988 : SymbolTable_PtrToSymbol pSym;
6720 251433988 : unsigned int high;
6721 :
6722 251433988 : pSym = GetPsym (var);
6723 251433988 : switch (pSym->SymbolType)
6724 : {
6725 251433988 : case SymbolTable_VarSym:
6726 251433988 : if (pSym->Var.IsTemp && pSym->Var.IsComponentRef)
6727 : {
6728 6349060 : high = Indexing_HighIndice (pSym->Var.list);
6729 12698120 : return SymbolTable_GetType (GetFromIndex (pSym->Var.list, high));
6730 : }
6731 : else
6732 : {
6733 245084928 : return pSym->Var.Type;
6734 : }
6735 0 : break;
6736 :
6737 :
6738 0 : default:
6739 0 : M2Error_InternalError ((const char *) "expecting a var symbol", 22);
6740 : break;
6741 : }
6742 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6743 : __builtin_unreachable ();
6744 : }
6745 :
6746 :
6747 : /*
6748 : GetConstLitType - returns the type of the constant of, name.
6749 : All floating point constants have type LONGREAL.
6750 : Character constants are type CHAR.
6751 : Integer values are INTEGER, LONGINT or LONGCARD
6752 : depending upon their value.
6753 : */
6754 :
6755 477394 : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError)
6756 : {
6757 477394 : location_t loc;
6758 477394 : DynamicStrings_String s;
6759 :
6760 477394 : s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name));
6761 477394 : if ((DynamicStrings_char (s, -1)) == 'C')
6762 : {
6763 122319 : s = DynamicStrings_KillString (s);
6764 122319 : return M2Base_Char;
6765 : }
6766 : else
6767 : {
6768 355075 : if ((DynamicStrings_Index (s, '.', 0)) != -1) /* found a '.' in our constant */
6769 : {
6770 6856 : s = DynamicStrings_KillString (s);
6771 6856 : return M2Base_RType;
6772 : }
6773 348219 : loc = M2LexBuf_TokenToLocation (tok);
6774 348219 : switch (DynamicStrings_char (s, -1))
6775 : {
6776 694 : case 'H':
6777 694 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 16, issueError);
6778 694 : break;
6779 :
6780 2806 : case 'B':
6781 2806 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 8, issueError);
6782 2806 : break;
6783 :
6784 24 : case 'A':
6785 24 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 2, issueError);
6786 24 : break;
6787 :
6788 :
6789 344695 : default:
6790 344695 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 10, issueError);
6791 344695 : break;
6792 : }
6793 348219 : s = DynamicStrings_KillString (s);
6794 348219 : return M2Base_ZType;
6795 : }
6796 : /* static analysis guarentees a RETURN statement will be used before here. */
6797 : __builtin_unreachable ();
6798 : }
6799 :
6800 :
6801 : /*
6802 : GetNthFromComponent -
6803 : */
6804 :
6805 373243 : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n)
6806 : {
6807 373243 : SymbolTable_PtrToSymbol pSym;
6808 :
6809 373243 : pSym = GetPsym (Sym);
6810 373243 : switch (pSym->SymbolType)
6811 : {
6812 373243 : case SymbolTable_VarSym:
6813 373243 : if (SymbolTable_IsComponent (Sym))
6814 : {
6815 373243 : if (Indexing_InBounds (pSym->Var.list, n))
6816 : {
6817 501052 : return GetFromIndex (pSym->Var.list, n);
6818 : }
6819 : else
6820 : {
6821 : return SymbolTable_NulSym;
6822 : }
6823 : }
6824 : else
6825 : {
6826 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
6827 : }
6828 0 : break;
6829 :
6830 :
6831 0 : default:
6832 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
6833 : break;
6834 : }
6835 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6836 : __builtin_unreachable ();
6837 : }
6838 :
6839 :
6840 : /*
6841 : GetNthParamChoice - returns the parameter definition from
6842 : sym:ParamNo:kind or NulSym.
6843 : */
6844 :
6845 632812 : static unsigned int GetNthParamChoice (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind kind)
6846 : {
6847 632812 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
6848 : {
6849 632812 : return SymbolTable_GetNthParam (sym, kind, ParamNo);
6850 : }
6851 : else
6852 : {
6853 : return SymbolTable_NulSym;
6854 : }
6855 : /* static analysis guarentees a RETURN statement will be used before here. */
6856 : __builtin_unreachable ();
6857 : }
6858 :
6859 :
6860 : /*
6861 : GetNthParamOrdered - returns the parameter definition from list {a, b, c}
6862 : in order.
6863 : sym:ParamNo:{a,b,c} or NulSym.
6864 : */
6865 :
6866 632812 : static unsigned int GetNthParamOrdered (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind a, SymbolTable_ProcedureKind b, SymbolTable_ProcedureKind c)
6867 : {
6868 632812 : if (SymbolTable_GetProcedureParametersDefined (sym, a))
6869 : {
6870 632812 : return GetNthParamChoice (sym, ParamNo, a);
6871 : }
6872 0 : else if (SymbolTable_GetProcedureParametersDefined (sym, b))
6873 : {
6874 : /* avoid dangling else. */
6875 0 : return GetNthParamChoice (sym, ParamNo, b);
6876 : }
6877 0 : else if (SymbolTable_GetProcedureParametersDefined (sym, c))
6878 : {
6879 : /* avoid dangling else. */
6880 0 : return GetNthParamChoice (sym, ParamNo, c);
6881 : }
6882 : else
6883 : {
6884 : /* avoid dangling else. */
6885 : return SymbolTable_NulSym;
6886 : }
6887 : /* static analysis guarentees a RETURN statement will be used before here. */
6888 : __builtin_unreachable ();
6889 : }
6890 :
6891 :
6892 : /*
6893 : GetOuterModuleScope - returns the outer module symbol scope for sym.
6894 : */
6895 :
6896 1265624 : static unsigned int GetOuterModuleScope (unsigned int sym)
6897 : {
6898 1898622 : do {
6899 1898622 : if (SymbolTable_IsDefImp (sym))
6900 : {
6901 : /* Definition/implementation module. */
6902 : return sym;
6903 : }
6904 1144725 : else if (SymbolTable_IsModule (sym))
6905 : {
6906 : /* avoid dangling else. */
6907 511811 : if ((SymbolTable_GetScope (sym)) == SymbolTable_NulSym)
6908 : {
6909 : /* Outer module. */
6910 : return sym;
6911 : }
6912 : }
6913 632998 : sym = SymbolTable_GetScope (sym);
6914 632998 : } while (! (sym == SymbolTable_NulSym));
6915 0 : M2Error_InternalError ((const char *) "not expecting to reach an outer scope", 37);
6916 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6917 : __builtin_unreachable ();
6918 : }
6919 :
6920 :
6921 : /*
6922 : EnsureOrder - providing that both symbols, a, and, b, exist in
6923 : list, l. Ensure that, b, is placed after a.
6924 : */
6925 :
6926 3042 : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b)
6927 : {
6928 3042 : unsigned int n;
6929 :
6930 3042 : n = Lists_NoOfItemsInList (l);
6931 3042 : if ((Lists_IsItemInList (l, a)) && (Lists_IsItemInList (l, b)))
6932 : {
6933 3042 : Lists_RemoveItemFromList (l, b);
6934 3042 : Lists_IncludeItemIntoList (l, b);
6935 : }
6936 3042 : M2Debug_Assert (n == (Lists_NoOfItemsInList (l)));
6937 3042 : }
6938 :
6939 :
6940 : /*
6941 : DumpSons -
6942 : */
6943 :
6944 0 : static void DumpSons (unsigned int sym)
6945 : {
6946 0 : SymbolTable_PtrToSymbol pSym;
6947 0 : unsigned int f;
6948 0 : unsigned int n;
6949 0 : unsigned int i;
6950 :
6951 0 : pSym = GetPsym (sym);
6952 0 : switch (pSym->SymbolType)
6953 : {
6954 0 : case SymbolTable_RecordSym:
6955 0 : n = Lists_NoOfItemsInList (pSym->Record.ListOfSons);
6956 0 : i = 1;
6957 0 : while (i <= n)
6958 : {
6959 0 : f = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, i));
6960 0 : M2Printf_printf3 ((const char *) "record %d field %d is %d\\n", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &i, (sizeof (i)-1), (const unsigned char *) &f, (sizeof (f)-1));
6961 0 : i += 1;
6962 : }
6963 0 : break;
6964 :
6965 :
6966 0 : default:
6967 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
6968 0 : break;
6969 : }
6970 0 : }
6971 :
6972 :
6973 : /*
6974 : CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
6975 : */
6976 :
6977 0 : static void CheckListOfSons (unsigned int sym)
6978 : {
6979 0 : SymbolTable_PtrToSymbol pSym;
6980 :
6981 0 : pSym = GetPsym (recordConsist);
6982 0 : switch (pSym->SymbolType)
6983 : {
6984 0 : case SymbolTable_RecordSym:
6985 0 : if (! (Lists_IsItemInList (pSym->Record.ListOfSons, sym)))
6986 : {
6987 0 : DumpSons (recordConsist);
6988 0 : M2MetaError_MetaError1 ((const char *) "internal error: expecting {%1ad} to exist in record ListOfSons", 63, sym);
6989 : }
6990 0 : break;
6991 :
6992 :
6993 0 : default:
6994 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
6995 0 : break;
6996 : }
6997 0 : }
6998 :
6999 :
7000 : /*
7001 : CheckRecordConsistency -
7002 : */
7003 :
7004 0 : static void CheckRecordConsistency (unsigned int sym)
7005 : {
7006 0 : SymbolTable_PtrToSymbol pSym;
7007 :
7008 0 : return;
7009 : pSym = GetPsym (sym);
7010 : switch (pSym->SymbolType)
7011 : {
7012 : case SymbolTable_RecordSym:
7013 : recordConsist = sym;
7014 : SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) CheckListOfSons});
7015 : break;
7016 :
7017 :
7018 : default:
7019 : M2Error_InternalError ((const char *) "record symbol expected", 22);
7020 0 : break;
7021 : }
7022 : }
7023 :
7024 :
7025 : /*
7026 : IsExternalModule - return TRUE if sym is an external program module or defimp module.
7027 : */
7028 :
7029 12 : static bool IsExternalModule (unsigned int sym)
7030 : {
7031 0 : return SymbolTable_IsDefImp (sym);
7032 : /* static analysis guarentees a RETURN statement will be used before here. */
7033 : __builtin_unreachable ();
7034 : }
7035 :
7036 :
7037 : /*
7038 : PutConstVarTemporary - indicates that constant, sym, is a temporary.
7039 : */
7040 :
7041 467974 : static void PutConstVarTemporary (unsigned int sym)
7042 : {
7043 467974 : SymbolTable_PtrToSymbol pSym;
7044 :
7045 467974 : pSym = GetPsym (sym);
7046 467974 : switch (pSym->SymbolType)
7047 : {
7048 467974 : case SymbolTable_ConstVarSym:
7049 467974 : pSym->ConstVar.IsTemp = true;
7050 467974 : break;
7051 :
7052 :
7053 0 : default:
7054 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
7055 467974 : break;
7056 : }
7057 467974 : }
7058 :
7059 :
7060 : /*
7061 : buildTemporary - builds the temporary filling in componentRef, record and sets mode.
7062 : */
7063 :
7064 1171517 : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record)
7065 : {
7066 1171517 : SymbolTable_PtrToSymbol pSym;
7067 1171517 : DynamicStrings_String s;
7068 1171517 : unsigned int Sym;
7069 :
7070 1171517 : TemporaryNo += 1;
7071 : /* Make the name */
7072 1171517 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
7073 1171517 : if (Mode == SymbolTable_ImmediateValue)
7074 : {
7075 432800 : Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
7076 432800 : PutConstVarTemporary (Sym);
7077 : }
7078 : else
7079 : {
7080 738717 : Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
7081 738717 : pSym = GetPsym (Sym);
7082 738717 : switch (pSym->SymbolType)
7083 : {
7084 738717 : case SymbolTable_VarSym:
7085 738717 : pSym->Var.AddrMode = Mode;
7086 738717 : pSym->Var.IsComponentRef = componentRef;
7087 738717 : pSym->Var.IsTemp = true; /* Variable is a temporary var */
7088 738717 : if (componentRef) /* Variable is a temporary var */
7089 : {
7090 145895 : pSym->Var.list = Indexing_InitIndex (1);
7091 145895 : PutIntoIndex (&pSym->Var.list, 1, record);
7092 : }
7093 738717 : InitWhereDeclaredTok (tok, &pSym->Var.At); /* Declared here */
7094 738717 : InitWhereFirstUsedTok (tok, &pSym->Var.At); /* Where symbol first used. */
7095 738717 : break;
7096 :
7097 :
7098 0 : default:
7099 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22); /* Where symbol first used. */
7100 1171517 : break;
7101 : }
7102 : }
7103 1171517 : s = DynamicStrings_KillString (s);
7104 1171517 : return Sym;
7105 : /* static analysis guarentees a RETURN statement will be used before here. */
7106 : __builtin_unreachable ();
7107 : }
7108 :
7109 :
7110 : /*
7111 : AssertInRange - determines whether the Sym is a legal symbol.
7112 : */
7113 :
7114 3147901561 : static void AssertInRange (unsigned int Sym)
7115 : {
7116 3147901561 : if ((Sym < 1) || (Sym > (SymbolTable_FinalSymbol ())))
7117 : {
7118 8 : M2Error_InternalError ((const char *) "illegal symbol", 14);
7119 : }
7120 3147901553 : }
7121 :
7122 :
7123 : /*
7124 : CheckForHiddenType - scans the NeedToBeImplemented tree providing
7125 : that we are currently compiling an implementation
7126 : module. If a symbol is found with TypeName
7127 : then its Sym is returned.
7128 : Otherwise NulSym is returned.
7129 : CheckForHiddenType is called before any type is
7130 : created, therefore the compiler allows hidden
7131 : types to be implemented using any type.
7132 : */
7133 :
7134 7151483 : static unsigned int CheckForHiddenType (NameKey_Name TypeName)
7135 : {
7136 7151483 : SymbolTable_PtrToSymbol pSym;
7137 7151483 : unsigned int Sym;
7138 :
7139 7151483 : Sym = SymbolTable_NulSym;
7140 7151483 : if ((((M2Comp_CompilingImplementationModule ()) && (SymbolTable_IsDefImp (CurrentModule))) && (SymbolTable_IsHiddenTypeDeclared (CurrentModule))) && (TypeName != NameKey_NulName))
7141 : {
7142 : /* Check to see whether we are declaring a HiddenType. */
7143 106981 : pSym = GetPsym (CurrentModule);
7144 106981 : switch (pSym->SymbolType)
7145 : {
7146 106981 : case SymbolTable_DefImpSym:
7147 106981 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, TypeName));
7148 106981 : break;
7149 :
7150 :
7151 0 : default:
7152 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7153 106981 : break;
7154 : }
7155 : }
7156 7151483 : return Sym;
7157 : /* static analysis guarentees a RETURN statement will be used before here. */
7158 : __builtin_unreachable ();
7159 : }
7160 :
7161 :
7162 : /*
7163 : RequestFromModule - returns a symbol from module ModSym with name, SymName.
7164 : */
7165 :
7166 108 : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7167 : {
7168 108 : SymbolTable_PtrToSymbol pSym;
7169 108 : unsigned int Sym;
7170 :
7171 108 : pSym = GetPsym (ModSym);
7172 108 : switch (pSym->SymbolType)
7173 : {
7174 0 : case SymbolTable_DefImpSym:
7175 0 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymName));
7176 0 : if (Sym == SymbolTable_NulSym)
7177 : {
7178 0 : Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
7179 : }
7180 : break;
7181 :
7182 108 : case SymbolTable_ModuleSym:
7183 108 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymName));
7184 108 : if (Sym == SymbolTable_NulSym)
7185 : {
7186 12 : Sym = FetchUnknownFromModule (tok, ModSym, SymName);
7187 : }
7188 : break;
7189 :
7190 :
7191 0 : default:
7192 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7193 108 : break;
7194 : }
7195 108 : return Sym;
7196 : /* static analysis guarentees a RETURN statement will be used before here. */
7197 : __builtin_unreachable ();
7198 : }
7199 :
7200 :
7201 : /*
7202 : RequestFromDefinition - returns a symbol from module ModSym with name,
7203 : SymName.
7204 : */
7205 :
7206 2825525 : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7207 : {
7208 2825525 : SymbolTable_PtrToSymbol pSym;
7209 2825525 : unsigned int Sym;
7210 2825525 : unsigned int OldScopePtr;
7211 :
7212 2825525 : pSym = GetPsym (ModSym);
7213 2825525 : switch (pSym->SymbolType)
7214 : {
7215 2825525 : case SymbolTable_DefImpSym:
7216 2825525 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName));
7217 2825525 : if (Sym == SymbolTable_NulSym)
7218 : {
7219 782870 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName));
7220 782870 : if (Sym == SymbolTable_NulSym)
7221 : {
7222 373390 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
7223 373390 : if (Sym == SymbolTable_NulSym)
7224 : {
7225 335510 : OldScopePtr = ScopePtr;
7226 335510 : SymbolTable_StartScope (ModSym);
7227 335510 : Sym = GetScopeSym (SymName, true);
7228 335510 : SymbolTable_EndScope ();
7229 335510 : M2Debug_Assert (OldScopePtr == ScopePtr);
7230 335510 : if (Sym == SymbolTable_NulSym)
7231 : {
7232 335478 : Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
7233 : }
7234 : else
7235 : {
7236 32 : if (SymbolTable_IsFieldEnumeration (Sym))
7237 : {
7238 6 : if (SymbolTable_IsExported (ModSym, SymbolTable_GetType (Sym)))
7239 : {
7240 : return Sym;
7241 : }
7242 : }
7243 : }
7244 335504 : SymbolKey_PutSymKey (pSym->DefImp.ExportRequest, SymName, Sym);
7245 : }
7246 : }
7247 : }
7248 : break;
7249 :
7250 :
7251 0 : default:
7252 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7253 : break;
7254 : }
7255 : return Sym;
7256 : /* static analysis guarentees a RETURN statement will be used before here. */
7257 : __builtin_unreachable ();
7258 : }
7259 :
7260 :
7261 : /*
7262 : GetWhereImported - returns the token number where this symbol
7263 : was imported into the current module.
7264 : */
7265 :
7266 6 : static unsigned int GetWhereImported (unsigned int Sym)
7267 : {
7268 6 : SymbolTable_PtrToSymbol pSym;
7269 :
7270 6 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
7271 6 : switch (pSym->SymbolType)
7272 : {
7273 6 : case SymbolTable_DefImpSym:
7274 6 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym));
7275 0 : break;
7276 :
7277 0 : case SymbolTable_ModuleSym:
7278 0 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym));
7279 0 : break;
7280 :
7281 :
7282 0 : default:
7283 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
7284 : break;
7285 : }
7286 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7287 : __builtin_unreachable ();
7288 : }
7289 :
7290 :
7291 : /*
7292 : DisplayName - displays the name.
7293 : */
7294 :
7295 0 : static void DisplayName (unsigned int sym)
7296 : {
7297 0 : M2Printf_printf1 ((const char *) " %a", 5, (const unsigned char *) &sym, (sizeof (sym)-1));
7298 0 : }
7299 :
7300 :
7301 : /*
7302 : DisplaySymbol - displays the name of a symbol
7303 : */
7304 :
7305 0 : static void DisplaySymbol (unsigned int sym)
7306 : {
7307 0 : DynamicStrings_String s;
7308 :
7309 0 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym))));
7310 0 : M2Printf_printf2 ((const char *) " %s (%d)", 10, (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &sym, (sizeof (sym)-1));
7311 0 : }
7312 :
7313 :
7314 : /*
7315 : FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
7316 : */
7317 :
7318 12 : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7319 : {
7320 12 : SymbolTable_PtrToSymbol pSym;
7321 12 : unsigned int Sym;
7322 :
7323 12 : pSym = GetPsym (ModSym);
7324 12 : switch (pSym->SymbolType)
7325 : {
7326 12 : case SymbolTable_ModuleSym:
7327 12 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
7328 12 : if (Sym == SymbolTable_NulSym)
7329 : {
7330 12 : NewSym (&Sym);
7331 12 : FillInUnknownFields (tok, Sym, SymName, ModSym, true);
7332 12 : SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
7333 : }
7334 12 : break;
7335 :
7336 :
7337 0 : default:
7338 0 : M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
7339 12 : break;
7340 : }
7341 12 : return Sym;
7342 : /* static analysis guarentees a RETURN statement will be used before here. */
7343 : __builtin_unreachable ();
7344 : }
7345 :
7346 :
7347 : /*
7348 : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
7349 : */
7350 :
7351 335478 : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7352 : {
7353 335478 : SymbolTable_PtrToSymbol pSym;
7354 335478 : unsigned int Sym;
7355 :
7356 335478 : pSym = GetPsym (ModSym);
7357 335478 : switch (pSym->SymbolType)
7358 : {
7359 335478 : case SymbolTable_DefImpSym:
7360 335478 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
7361 335478 : if (Sym == SymbolTable_NulSym)
7362 : {
7363 335478 : NewSym (&Sym);
7364 335478 : FillInUnknownFields (tok, Sym, SymName, ModSym, true);
7365 335478 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
7366 : }
7367 335478 : break;
7368 :
7369 :
7370 0 : default:
7371 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7372 335478 : break;
7373 : }
7374 335478 : return Sym;
7375 : /* static analysis guarentees a RETURN statement will be used before here. */
7376 : __builtin_unreachable ();
7377 : }
7378 :
7379 :
7380 : /*
7381 : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
7382 : */
7383 :
7384 62 : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName)
7385 : {
7386 62 : SymbolTable_PtrToSymbol pSym;
7387 62 : unsigned int Sym;
7388 :
7389 62 : pSym = GetPsym (scope);
7390 62 : switch (pSym->SymbolType)
7391 : {
7392 0 : case SymbolTable_DefImpSym:
7393 0 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
7394 0 : if (Sym == SymbolTable_NulSym)
7395 : {
7396 0 : NewSym (&Sym);
7397 0 : FillInUnknownFields (tok, Sym, SymName, scope, true);
7398 0 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
7399 : }
7400 : break;
7401 :
7402 44 : case SymbolTable_ModuleSym:
7403 44 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
7404 44 : if (Sym == SymbolTable_NulSym)
7405 : {
7406 44 : NewSym (&Sym);
7407 44 : FillInUnknownFields (tok, Sym, SymName, scope, true);
7408 44 : SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
7409 : }
7410 : break;
7411 :
7412 18 : case SymbolTable_ProcedureSym:
7413 18 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, SymName));
7414 18 : if (Sym == SymbolTable_NulSym)
7415 : {
7416 18 : NewSym (&Sym);
7417 18 : FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
7418 18 : SymbolKey_PutSymKey (pSym->Procedure.Unresolved, SymName, Sym);
7419 : }
7420 : break;
7421 :
7422 :
7423 0 : default:
7424 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module or Procedure symbol", 48);
7425 62 : break;
7426 : }
7427 62 : return Sym;
7428 : /* static analysis guarentees a RETURN statement will be used before here. */
7429 : __builtin_unreachable ();
7430 : }
7431 :
7432 :
7433 : /*
7434 : UnknownSymbolError - displays symbol name for symbol, sym.
7435 : */
7436 :
7437 177 : static void UnknownSymbolError (unsigned int sym)
7438 : {
7439 177 : if (IsUnreportedUnknown (sym))
7440 : {
7441 151 : Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
7442 151 : M2MetaError_MetaErrorStringT1 (SymbolTable_GetFirstUsed (sym), DynamicStrings_InitString ((const char *) "unknown symbol {%1EUad} {%1&s}", 30), sym);
7443 : }
7444 177 : }
7445 :
7446 :
7447 : /*
7448 : IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
7449 : reported and is an unknown symbol.
7450 : */
7451 :
7452 34289874 : static bool IsUnreportedUnknown (unsigned int sym)
7453 : {
7454 34289874 : return (SymbolTable_IsUnknown (sym)) && (! (Sets_IsElementInSet (ReportedUnknowns, sym)));
7455 : /* static analysis guarentees a RETURN statement will be used before here. */
7456 : __builtin_unreachable ();
7457 : }
7458 :
7459 :
7460 : /*
7461 : AddListify -
7462 : */
7463 :
7464 0 : static void AddListify (unsigned int sym)
7465 : {
7466 0 : ListifyWordCount += 1;
7467 : /* printf ("AddListify: ListifyWordCount = %d, ListifyTotal = %d
7468 : ",
7469 : ListifyWordCount, ListifyTotal) ; */
7470 0 : if (ListifyWordCount > 1)
7471 : {
7472 : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7473 0 : if (ListifyWordCount == ListifyTotal)
7474 : {
7475 0 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) " and ", 5)));
7476 : }
7477 : else
7478 : {
7479 0 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ", ", 2)));
7480 : }
7481 : }
7482 0 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym)))));
7483 0 : }
7484 :
7485 :
7486 : /*
7487 : Listify - convert tree into a string list and return the result.
7488 : */
7489 :
7490 0 : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition)
7491 : {
7492 0 : ListifyTotal = SymbolKey_NoOfNodes (tree, isCondition);
7493 0 : ListifyWordCount = 0;
7494 0 : ListifySentance = DynamicStrings_InitString ((const char *) "", 0);
7495 0 : SymbolKey_ForeachNodeConditionDo (tree, isCondition, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) AddListify});
7496 0 : return ListifySentance;
7497 : /* static analysis guarentees a RETURN statement will be used before here. */
7498 : __builtin_unreachable ();
7499 : }
7500 :
7501 :
7502 : /*
7503 : CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
7504 : an unknown symbol. All unknown symbols are displayed
7505 : together with an error message.
7506 : */
7507 :
7508 1999088 : static void CheckForUnknowns (unsigned int tokno, NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
7509 : {
7510 1999088 : DynamicStrings_String s;
7511 1999088 : char a[_a_high+1];
7512 :
7513 : /* make a local copy of each unbounded array. */
7514 1999088 : memcpy (a, a_, _a_high+1);
7515 :
7516 1999088 : if (SymbolKey_DoesTreeContainAny (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown}))
7517 : {
7518 127 : SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnknownSymbolError});
7519 127 : if ((SymbolKey_NoOfNodes (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown})) > 0)
7520 : {
7521 0 : s = DynamicStrings_InitString ((const char *) "{%E} the following unknown symbols in module %<", 47);
7522 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
7523 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%> were ", 8)));
7524 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
7525 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ": ", 2)));
7526 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (Listify (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown})));
7527 0 : M2MetaError_MetaErrorStringT0 (tokno, s);
7528 : }
7529 : }
7530 1999088 : }
7531 :
7532 :
7533 : /*
7534 : SymbolError - displays symbol name for symbol, Sym.
7535 : */
7536 :
7537 0 : static void SymbolError (unsigned int Sym)
7538 : {
7539 0 : M2Error_Error e;
7540 0 : NameKey_Name n;
7541 :
7542 0 : n = SymbolTable_GetSymName (Sym);
7543 0 : e = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
7544 0 : M2Error_ErrorFormat1 (e, (const char *) "unknown symbol '%a' found", 25, (const unsigned char *) &n, (sizeof (n)-1));
7545 0 : }
7546 :
7547 :
7548 : /*
7549 : CheckForSymbols - checks a binary tree, Tree, to see whether it contains
7550 : any symbol. The tree is expected to be empty, if not
7551 : then an error has occurred.
7552 : */
7553 :
7554 475565 : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
7555 : {
7556 475565 : DynamicStrings_String s;
7557 475565 : char a[_a_high+1];
7558 :
7559 : /* make a local copy of each unbounded array. */
7560 475565 : memcpy (a, a_, _a_high+1);
7561 :
7562 475565 : if (SymbolKey_DoesTreeContainAny (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown}))
7563 : {
7564 0 : s = DynamicStrings_InitString ((const char *) "the symbols are unknown at the end of module {%1Ea} when ", 57);
7565 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
7566 0 : M2MetaError_MetaErrorString1 (s, MainModule);
7567 0 : SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SymbolError});
7568 : }
7569 475565 : }
7570 :
7571 :
7572 : /*
7573 : PutExportUndeclared - places a symbol, Sym, into module, ModSym,
7574 : ExportUndeclared list provided that Sym
7575 : is unknown.
7576 : */
7577 :
7578 4619602 : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym)
7579 : {
7580 4619602 : SymbolTable_PtrToSymbol pSym;
7581 :
7582 4619602 : if (SymbolTable_IsUnknown (Sym))
7583 : {
7584 4077906 : pSym = GetPsym (ModSym);
7585 4077906 : switch (pSym->SymbolType)
7586 : {
7587 294 : case SymbolTable_ModuleSym:
7588 294 : SymbolKey_PutSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
7589 294 : break;
7590 :
7591 4077612 : case SymbolTable_DefImpSym:
7592 4077612 : SymbolKey_PutSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
7593 4077612 : break;
7594 :
7595 :
7596 0 : default:
7597 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7598 : break;
7599 : }
7600 : }
7601 4619602 : }
7602 :
7603 :
7604 : /*
7605 : GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
7606 : which is in the ExportUndeclared list.
7607 : */
7608 :
7609 234 : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name)
7610 : {
7611 234 : SymbolTable_PtrToSymbol pSym;
7612 :
7613 234 : pSym = GetPsym (ModSym);
7614 234 : switch (pSym->SymbolType)
7615 : {
7616 228 : case SymbolTable_ModuleSym:
7617 228 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, name));
7618 6 : break;
7619 :
7620 6 : case SymbolTable_DefImpSym:
7621 6 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, name));
7622 0 : break;
7623 :
7624 :
7625 0 : default:
7626 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7627 : break;
7628 : }
7629 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7630 : __builtin_unreachable ();
7631 : }
7632 :
7633 :
7634 : /*
7635 : RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
7636 : ExportUndeclaredTree.
7637 : */
7638 :
7639 11307983 : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym)
7640 : {
7641 11307983 : SymbolTable_PtrToSymbol pSym;
7642 :
7643 11307983 : pSym = GetPsym (ModSym);
7644 11307983 : switch (pSym->SymbolType)
7645 : {
7646 18 : case SymbolTable_ModuleSym:
7647 18 : if ((SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
7648 : {
7649 18 : SymbolKey_DelSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym));
7650 : }
7651 : break;
7652 :
7653 11307965 : case SymbolTable_DefImpSym:
7654 11307965 : if ((SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
7655 : {
7656 4077252 : SymbolKey_DelSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym));
7657 : }
7658 : break;
7659 :
7660 :
7661 0 : default:
7662 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7663 11307983 : break;
7664 : }
7665 11307983 : }
7666 :
7667 :
7668 : /*
7669 : CheckForExportedDeclaration - checks to see whether a definition module
7670 : is currently being compiled, if so,
7671 : symbol, Sym, is removed from the
7672 : ExportUndeclared list.
7673 : This procedure is called whenever a symbol
7674 : is declared, thus attempting to reduce
7675 : the ExportUndeclared list.
7676 : */
7677 :
7678 19638922 : static void CheckForExportedDeclaration (unsigned int Sym)
7679 : {
7680 19638922 : if (M2Comp_CompilingDefinitionModule ())
7681 : {
7682 11307959 : RemoveExportUndeclared (SymbolTable_GetCurrentModule (), Sym);
7683 : }
7684 19638922 : }
7685 :
7686 :
7687 : /*
7688 : UndeclaredSymbolError - displays symbol name for symbol, Sym.
7689 : */
7690 :
7691 0 : static void UndeclaredSymbolError (unsigned int Sym)
7692 : {
7693 0 : if (DebugUnknowns)
7694 : {
7695 : M2Printf_printf1 ((const char *) "undeclared symbol (%d)\\n", 24, (const unsigned char *) &Sym, (sizeof (Sym)-1));
7696 : }
7697 0 : M2MetaError_MetaError1 ((const char *) "{%1UC} undeclared symbol {%1a}", 30, Sym);
7698 0 : }
7699 :
7700 :
7701 : /*
7702 : RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
7703 : NeedToBeImplemented list.
7704 : */
7705 :
7706 2303335 : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym)
7707 : {
7708 2303335 : SymbolTable_PtrToSymbol pSym;
7709 :
7710 2303335 : pSym = GetPsym (ModSym);
7711 2303335 : switch (pSym->SymbolType)
7712 : {
7713 2303335 : case SymbolTable_DefImpSym:
7714 2303335 : if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
7715 : {
7716 1302529 : SymbolKey_DelSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym));
7717 : }
7718 2303335 : break;
7719 :
7720 :
7721 0 : default:
7722 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7723 2303335 : break;
7724 : }
7725 2303335 : }
7726 :
7727 :
7728 : /*
7729 : RemoveFromExportRequest -
7730 : */
7731 :
7732 421290 : static void RemoveFromExportRequest (unsigned int Sym)
7733 : {
7734 421290 : SymbolTable_PtrToSymbol pSym;
7735 :
7736 421290 : pSym = GetPsym (ExportRequestModule);
7737 421290 : switch (pSym->SymbolType)
7738 : {
7739 421290 : case SymbolTable_DefImpSym:
7740 421290 : if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym))) == Sym)
7741 : {
7742 6 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym));
7743 : }
7744 421290 : break;
7745 :
7746 :
7747 0 : default:
7748 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7749 421290 : break;
7750 : }
7751 421290 : }
7752 :
7753 :
7754 : /*
7755 : RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
7756 : (and its fields) from the ExportRequest tree.
7757 : */
7758 :
7759 19201 : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym)
7760 : {
7761 19201 : if (SymbolTable_IsEnumeration (Sym))
7762 : {
7763 19201 : ExportRequestModule = ModSym;
7764 19201 : RemoveFromExportRequest (Sym);
7765 19201 : SymbolTable_ForeachLocalSymDo (Sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) RemoveFromExportRequest});
7766 : }
7767 19201 : }
7768 :
7769 :
7770 : /*
7771 : UnImplementedSymbolError - displays symbol name for symbol, Sym.
7772 : */
7773 :
7774 0 : static void UnImplementedSymbolError (unsigned int Sym)
7775 : {
7776 0 : NameKey_Name n;
7777 :
7778 0 : CurrentError = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
7779 0 : if (SymbolTable_IsType (Sym))
7780 : {
7781 0 : n = SymbolTable_GetSymName (Sym);
7782 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "hidden type is undeclared (%a)", 30, (const unsigned char *) &n, (sizeof (n)-1));
7783 : }
7784 0 : else if (SymbolTable_IsProcedure (Sym))
7785 : {
7786 : /* avoid dangling else. */
7787 0 : n = SymbolTable_GetSymName (Sym);
7788 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure is undeclared (%a)", 28, (const unsigned char *) &n, (sizeof (n)-1));
7789 : }
7790 0 : else if (SymbolTable_IsProcType (Sym))
7791 : {
7792 : /* avoid dangling else. */
7793 0 : n = SymbolTable_GetSymName (Sym);
7794 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure type is undeclared (%a)", 33, (const unsigned char *) &n, (sizeof (n)-1));
7795 : }
7796 : else
7797 : {
7798 : /* avoid dangling else. */
7799 0 : M2Error_ErrorFormat0 (CurrentError, (const char *) "undeclared symbol", 17);
7800 : }
7801 0 : }
7802 :
7803 :
7804 : /*
7805 : CheckEnumerationInList - places symbol, Sym, in the list, l,
7806 : providing it does not already exist.
7807 : PseudoScope(Sym) is called if Sym needs to
7808 : be added to the enumeration list, l.
7809 : */
7810 :
7811 68467 : static void CheckEnumerationInList (Lists_List l, unsigned int Sym)
7812 : {
7813 68467 : if (! (Lists_IsItemInList (l, Sym)))
7814 : {
7815 59742 : Lists_PutItemIntoList (l, Sym);
7816 59742 : SymbolTable_PseudoScope (Sym);
7817 : }
7818 68467 : }
7819 :
7820 :
7821 : /*
7822 : CheckIfEnumerationExported - An outer module may use an enumeration that
7823 : is declared inside an inner module. The usage
7824 : may occur before definition. The first pass
7825 : exports a symbol, later the symbol is declared
7826 : as an emumeration type. At this stage the
7827 : CheckIfEnumerationExported procedure should be
7828 : called. This procedure ripples from the current
7829 : (inner) module to outer module and every time
7830 : it is exported it must be added to the outer
7831 : module EnumerationScopeList.
7832 : */
7833 :
7834 50367 : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId)
7835 : {
7836 69586 : SymbolTable_PtrToCallFrame pCall;
7837 69586 : unsigned int InnerModId;
7838 69586 : unsigned int OuterModId;
7839 69586 : unsigned int InnerModSym;
7840 69586 : unsigned int OuterModSym;
7841 :
7842 69586 : InnerModId = GetModuleScopeId (ScopeId);
7843 69586 : if (InnerModId > 0)
7844 : {
7845 69586 : OuterModId = GetModuleScopeId (InnerModId-1);
7846 69586 : if (OuterModId > 0)
7847 : {
7848 69586 : pCall = GetPcall (InnerModId);
7849 69586 : InnerModSym = pCall->Search;
7850 69586 : pCall = GetPcall (OuterModId);
7851 69586 : OuterModSym = pCall->Search;
7852 69586 : if ((InnerModSym != SymbolTable_NulSym) && (OuterModSym != SymbolTable_NulSym))
7853 : {
7854 34940 : if (SymbolTable_IsExported (InnerModSym, Sym))
7855 : {
7856 19219 : CheckForEnumerationInOuterModule (Sym, OuterModSym);
7857 19219 : CheckIfEnumerationExported (Sym, OuterModId);
7858 : }
7859 : }
7860 : }
7861 : }
7862 50367 : }
7863 :
7864 :
7865 : /*
7866 : CheckForEnumerationInOuterModule - checks to see whether the enumeration
7867 : type symbol, Sym, has been entered into
7868 : the outer module, OuterModule, scope list.
7869 : OuterModule may be internal to the
7870 : program module.
7871 : */
7872 :
7873 19219 : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule)
7874 : {
7875 19219 : SymbolTable_PtrToSymbol pSym;
7876 :
7877 19219 : pSym = GetPsym (OuterModule);
7878 19219 : switch (pSym->SymbolType)
7879 : {
7880 0 : case SymbolTable_DefImpSym:
7881 0 : Lists_IncludeItemIntoList (pSym->DefImp.EnumerationScopeList, Sym);
7882 0 : break;
7883 :
7884 19219 : case SymbolTable_ModuleSym:
7885 19219 : Lists_IncludeItemIntoList (pSym->Module.EnumerationScopeList, Sym);
7886 19219 : break;
7887 :
7888 :
7889 0 : default:
7890 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7891 19219 : break;
7892 : }
7893 19219 : }
7894 :
7895 :
7896 : /*
7897 : MakeVariableForParam -
7898 : */
7899 :
7900 9070680 : static unsigned int MakeVariableForParam (unsigned int tok, NameKey_Name ParamName, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, unsigned int ParmType, unsigned int typetok)
7901 : {
7902 9070680 : SymbolTable_PtrToSymbol pSym;
7903 9070680 : unsigned int VariableSym;
7904 :
7905 9070680 : tok = CheckTok (tok, (const char *) "parameter", 9);
7906 9070680 : VariableSym = SymbolTable_MakeVar (tok, ParamName);
7907 9070680 : pSym = GetPsym (VariableSym);
7908 9070680 : switch (pSym->SymbolType)
7909 : {
7910 : case SymbolTable_ErrorSym:
7911 : return SymbolTable_NulSym;
7912 9070680 : break;
7913 :
7914 9070680 : case SymbolTable_VarSym:
7915 9070680 : pSym->Var.IsParam = true; /* Variable is really a parameter. */
7916 9070680 : break;
7917 :
7918 :
7919 0 : default:
7920 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
7921 9070680 : break;
7922 : }
7923 : /* Note that the parameter is now treated as a local variable. */
7924 9070680 : SymbolTable_PutVarTok (VariableSym, ParmType, typetok);
7925 9070680 : SymbolTable_PutDeclared (tok, VariableSym);
7926 : /*
7927 : Normal VAR parameters have LeftValue,
7928 : however Unbounded VAR parameters have RightValue.
7929 : Non VAR parameters always have RightValue.
7930 : */
7931 9070680 : if ((SymbolTable_IsVarParam (ProcSym, kind, no)) && (! (SymbolTable_IsUnboundedParam (ProcSym, kind, no))))
7932 : {
7933 273439 : SymbolTable_PutMode (VariableSym, SymbolTable_LeftValue);
7934 : }
7935 : else
7936 : {
7937 8797241 : SymbolTable_PutMode (VariableSym, SymbolTable_RightValue);
7938 : }
7939 : return VariableSym;
7940 : /* static analysis guarentees a RETURN statement will be used before here. */
7941 : __builtin_unreachable ();
7942 : }
7943 :
7944 :
7945 : /*
7946 : AddParameter - adds a parameter ParSym to a procedure Sym.
7947 : */
7948 :
7949 20686739 : static void AddParameter (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParSym)
7950 : {
7951 20686739 : SymbolTable_PtrToSymbol pSym;
7952 :
7953 20686739 : pSym = GetPsym (Sym);
7954 20686739 : switch (pSym->SymbolType)
7955 : {
7956 : case SymbolTable_ErrorSym:
7957 : break;
7958 :
7959 11530320 : case SymbolTable_ProcedureSym:
7960 11530320 : Lists_PutItemIntoList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParSym);
7961 11530320 : break;
7962 :
7963 9156419 : case SymbolTable_ProcTypeSym:
7964 9156419 : Lists_PutItemIntoList (pSym->ProcType.ListOfParam, ParSym);
7965 9156419 : break;
7966 :
7967 :
7968 0 : default:
7969 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
7970 20686739 : break;
7971 : }
7972 20686739 : }
7973 :
7974 :
7975 : /*
7976 : AddProcedureProcTypeParam - adds ParamType to the parameter ProcType
7977 : associated with procedure Sym.
7978 : */
7979 :
7980 11530320 : static void AddProcedureProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded, bool isVarParam)
7981 : {
7982 11530320 : SymbolTable_PtrToSymbol pSym;
7983 :
7984 11530320 : pSym = GetPsym (Sym);
7985 11530320 : switch (pSym->SymbolType)
7986 : {
7987 11530320 : case SymbolTable_ProcedureSym:
7988 11530320 : if (pSym->Procedure.BuildProcType)
7989 : {
7990 : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7991 9070680 : if (isVarParam)
7992 : {
7993 767851 : SymbolTable_PutProcTypeVarParam (tok, pSym->Procedure.ProcedureType, ParamType, isUnbounded);
7994 : }
7995 : else
7996 : {
7997 8302829 : SymbolTable_PutProcTypeParam (tok, pSym->Procedure.ProcedureType, ParamType, isUnbounded);
7998 : }
7999 : }
8000 11530320 : break;
8001 :
8002 :
8003 0 : default:
8004 0 : M2Error_InternalError ((const char *) "expecting Sym to be a procedure", 31);
8005 11530320 : break;
8006 : }
8007 11530320 : }
8008 :
8009 :
8010 : /*
8011 : IsNthParamVar - returns true if the n th parameter of the parameter list,
8012 : List, is a VAR parameter.
8013 : */
8014 :
8015 21500530 : static bool IsNthParamVar (Lists_List Head, unsigned int n)
8016 : {
8017 21500530 : SymbolTable_PtrToSymbol pSym;
8018 21500530 : unsigned int p;
8019 :
8020 21500530 : p = static_cast<unsigned int> (Lists_GetItemFromList (Head, n));
8021 21500530 : if (p == SymbolTable_NulSym)
8022 : {
8023 0 : M2Error_InternalError ((const char *) "parameter does not exist", 24);
8024 : }
8025 : else
8026 : {
8027 21500530 : pSym = GetPsym (p);
8028 21500530 : switch (pSym->SymbolType)
8029 : {
8030 : case SymbolTable_ErrorSym:
8031 : return false;
8032 1309465 : break;
8033 :
8034 1309465 : case SymbolTable_VarParamSym:
8035 1309465 : return true;
8036 : break;
8037 :
8038 : case SymbolTable_ParamSym:
8039 : return false;
8040 0 : break;
8041 :
8042 :
8043 0 : default:
8044 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
8045 : break;
8046 : }
8047 : }
8048 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8049 : __builtin_unreachable ();
8050 : }
8051 :
8052 :
8053 : /*
8054 : MakeParameterHeapVar - create a heap variable if sym is a pointer.
8055 : */
8056 :
8057 548396 : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode)
8058 : {
8059 548396 : unsigned int heapvar;
8060 :
8061 548396 : tok = CheckTok (tok, (const char *) "parameter heap var", 18);
8062 548396 : heapvar = SymbolTable_NulSym;
8063 548396 : type = SymbolTable_SkipType (type);
8064 548396 : if (SymbolTable_IsPointer (type))
8065 : {
8066 53790 : heapvar = SymbolTable_MakeTemporary (tok, mode);
8067 53790 : SymbolTable_PutVar (heapvar, type);
8068 53790 : SymbolTable_PutVarHeap (heapvar, true);
8069 : }
8070 548396 : return heapvar;
8071 : /* static analysis guarentees a RETURN statement will be used before here. */
8072 : __builtin_unreachable ();
8073 : }
8074 :
8075 :
8076 : /*
8077 : PutParameterHeapVar - creates a heap variable associated with parameter sym.
8078 : */
8079 :
8080 6080037 : static void PutParameterHeapVar (unsigned int sym)
8081 : {
8082 6080037 : SymbolTable_PtrToSymbol pSym;
8083 :
8084 6080037 : pSym = GetPsym (sym);
8085 6080037 : switch (pSym->SymbolType)
8086 : {
8087 : case SymbolTable_ParamSym:
8088 : break;
8089 :
8090 548396 : case SymbolTable_VarParamSym:
8091 548396 : pSym->VarParam.HeapVar = MakeParameterHeapVar (SymbolTable_GetDeclaredMod (sym), pSym->VarParam.Type, SymbolTable_LeftValue); /* Nothing to do for the non var parameter. */
8092 548396 : break;
8093 :
8094 :
8095 0 : default:
8096 0 : M2Error_InternalError ((const char *) "Param or VarParam symbol expected", 33);
8097 6080037 : break;
8098 : }
8099 6080037 : }
8100 :
8101 :
8102 : /*
8103 : IsProcedureAnyBoolean - returns the boolean result from p
8104 : for any of procedure kind which is defined.
8105 : */
8106 :
8107 9109 : static bool IsProcedureAnyBoolean (unsigned int sym, SymbolTable_ProcAnyBoolean p)
8108 : {
8109 9109 : SymbolTable_ProcedureKind kind;
8110 :
8111 26963 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
8112 : {
8113 26963 : if (SymbolTable_GetProcedureDefined (sym, kind))
8114 : {
8115 9109 : return (*p.proc) (sym, kind);
8116 : }
8117 : }
8118 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
8119 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8120 : __builtin_unreachable ();
8121 : }
8122 :
8123 :
8124 : /*
8125 : IsProcedureAnyDefaultBoolean - returns the boolean result from p
8126 : for any of procedure kind which is defined.
8127 : */
8128 :
8129 3967769 : static bool IsProcedureAnyDefaultBoolean (unsigned int sym, bool default_, SymbolTable_ProcAnyBoolean p)
8130 : {
8131 3967769 : SymbolTable_ProcedureKind kind;
8132 :
8133 9358416 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
8134 : {
8135 8951893 : if (SymbolTable_GetProcedureDefined (sym, kind))
8136 : {
8137 3561246 : return (*p.proc) (sym, kind);
8138 : }
8139 : }
8140 : return default_;
8141 : /* static analysis guarentees a RETURN statement will be used before here. */
8142 : __builtin_unreachable ();
8143 : }
8144 :
8145 :
8146 : /*
8147 : FillInUnknownFields - fills in all fields for the undefined sym.
8148 : */
8149 :
8150 11190097 : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName, unsigned int descscope, bool onimport)
8151 : {
8152 11190097 : SymbolTable_PtrToSymbol pSym;
8153 :
8154 11190097 : pSym = GetPsym (sym);
8155 11190097 : pSym->SymbolType = SymbolTable_UndefinedSym;
8156 11190097 : pSym->Undefined.name = SymName;
8157 11190097 : pSym->Undefined.oafamily = SymbolTable_NulSym;
8158 11190097 : pSym->Undefined.errorScope = M2Error_GetCurrentErrorScope ();
8159 11190097 : pSym->Undefined.declScope = descscope;
8160 11190097 : pSym->Undefined.onImport = onimport;
8161 11190097 : InitWhereFirstUsedTok (tok, &pSym->Undefined.At);
8162 11190097 : }
8163 :
8164 :
8165 : /*
8166 : FillInPointerFields - given a new symbol, sym, make it a pointer symbol
8167 : and initialize its fields.
8168 : */
8169 :
8170 206166 : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf)
8171 : {
8172 206166 : SymbolTable_PtrToSymbol pSym;
8173 :
8174 206166 : if (! (SymbolTable_IsError (Sym)))
8175 : {
8176 206166 : pSym = GetPsym (Sym);
8177 206166 : pSym->SymbolType = SymbolTable_PointerSym;
8178 206166 : switch (pSym->SymbolType)
8179 : {
8180 206166 : case SymbolTable_PointerSym:
8181 206166 : pSym->Pointer.Type = SymbolTable_NulSym;
8182 206166 : pSym->Pointer.name = PointerName;
8183 206166 : pSym->Pointer.oafamily = oaf; /* The unbounded for this */
8184 206166 : SymbolKey_InitTree (&pSym->Pointer.ConstLitTree); /* constants of this type */
8185 206166 : pSym->Pointer.Scope = scope; /* Which scope created it */
8186 206166 : pSym->Pointer.Size = M2ALU_InitValue (); /* Which scope created it */
8187 206166 : pSym->Pointer.Align = SymbolTable_NulSym; /* Alignment of this type */
8188 206166 : break;
8189 :
8190 :
8191 : default:
8192 : M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26); /* Alignment of this type */
8193 206166 : break;
8194 : }
8195 : }
8196 206166 : }
8197 :
8198 :
8199 : /*
8200 : ForeachParameterDo -
8201 : */
8202 :
8203 30836 : static void ForeachParameterDo (SymbolTable_CheckProcedure p)
8204 : {
8205 30836 : unsigned int l;
8206 30836 : unsigned int h;
8207 :
8208 30836 : l = Indexing_LowIndice (Symbols);
8209 30836 : h = Indexing_HighIndice (Symbols);
8210 48261052 : while (l <= h)
8211 : {
8212 48199380 : if (SymbolTable_IsParameter (l))
8213 : {
8214 3338397 : (*p.proc) (l);
8215 : }
8216 48199380 : l += 1;
8217 : }
8218 30836 : }
8219 :
8220 :
8221 : /*
8222 : CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
8223 : */
8224 :
8225 3338397 : static void CheckUnbounded (unsigned int Sym)
8226 : {
8227 3338397 : SymbolTable_PtrToSymbol pSym;
8228 :
8229 3338397 : AssertInRange (Sym);
8230 3338397 : pSym = GetPsym (Sym);
8231 3338397 : switch (pSym->SymbolType)
8232 : {
8233 2377857 : case SymbolTable_ParamSym:
8234 2377857 : if (SymbolTable_IsUnbounded (pSym->Param.Type))
8235 : {
8236 431160 : pSym->Param.IsUnbounded = true;
8237 : }
8238 : break;
8239 :
8240 960540 : case SymbolTable_VarParamSym:
8241 960540 : if (SymbolTable_IsUnbounded (pSym->VarParam.Type))
8242 : {
8243 946612 : pSym->VarParam.IsUnbounded = true;
8244 : }
8245 : break;
8246 :
8247 :
8248 0 : default:
8249 0 : M2RTS_HALT (-1);
8250 : __builtin_unreachable ();
8251 3338397 : break;
8252 : }
8253 3338397 : }
8254 :
8255 :
8256 : /*
8257 : PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
8258 : */
8259 :
8260 30776 : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf)
8261 : {
8262 30776 : SymbolTable_PtrToSymbol pSym;
8263 :
8264 30776 : pSym = GetPsym (SimpleType);
8265 30776 : switch (pSym->SymbolType)
8266 : {
8267 : case SymbolTable_ErrorSym:
8268 : break;
8269 :
8270 12 : case SymbolTable_RecordSym:
8271 12 : pSym->Record.oafamily = oaf;
8272 12 : break;
8273 :
8274 0 : case SymbolTable_SubrangeSym:
8275 0 : pSym->Subrange.oafamily = oaf;
8276 0 : break;
8277 :
8278 18 : case SymbolTable_EnumerationSym:
8279 18 : pSym->Enumeration.oafamily = oaf;
8280 18 : break;
8281 :
8282 6 : case SymbolTable_ArraySym:
8283 6 : pSym->Array.oafamily = oaf;
8284 6 : break;
8285 :
8286 0 : case SymbolTable_ProcTypeSym:
8287 0 : pSym->ProcType.oafamily = oaf;
8288 0 : break;
8289 :
8290 30740 : case SymbolTable_TypeSym:
8291 30740 : pSym->Type.oafamily = oaf;
8292 30740 : break;
8293 :
8294 0 : case SymbolTable_PointerSym:
8295 0 : pSym->Pointer.oafamily = oaf;
8296 0 : break;
8297 :
8298 0 : case SymbolTable_SetSym:
8299 0 : pSym->Set.oafamily = oaf;
8300 0 : break;
8301 :
8302 0 : case SymbolTable_UndefinedSym:
8303 0 : pSym->Undefined.oafamily = oaf;
8304 0 : break;
8305 :
8306 :
8307 0 : default:
8308 0 : M2Error_InternalError ((const char *) "not expecting this SimpleType", 29);
8309 30776 : break;
8310 : }
8311 30776 : }
8312 :
8313 :
8314 : /*
8315 : doFillInOAFamily -
8316 : */
8317 :
8318 0 : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded)
8319 : {
8320 0 : unsigned int SimpleType;
8321 :
8322 0 : SimpleType = SymbolTable_GetType (oaf);
8323 0 : if (unbounded != SymbolTable_NulSym)
8324 : {
8325 0 : FillInUnboundedFields (M2LexBuf_GetTokenNo (), unbounded, SimpleType, i);
8326 : }
8327 0 : }
8328 :
8329 :
8330 : /*
8331 : FillInUnboundedFields -
8332 : */
8333 :
8334 30836 : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim)
8335 : {
8336 30836 : SymbolTable_PtrToSymbol pSym;
8337 30836 : unsigned int Contents;
8338 30836 : unsigned int i;
8339 :
8340 30836 : if (sym != SymbolTable_NulSym)
8341 : {
8342 30836 : pSym = GetPsym (sym);
8343 30836 : pSym->SymbolType = SymbolTable_UnboundedSym;
8344 30836 : pSym->Unbounded.Type = SimpleType; /* Index to a simple type. */
8345 30836 : pSym->Unbounded.Size = M2ALU_InitValue (); /* Size in bytes for this sym */
8346 30836 : pSym->Unbounded.Scope = SymbolTable_GetScope (SimpleType); /* Which scope will create it */
8347 30836 : InitWhereDeclaredTok (tok, &pSym->Unbounded.At); /* Declared here */
8348 30836 : NewSym (&pSym->Unbounded.RecordType); /* Declared here */
8349 30836 : FillInRecordFields (tok, pSym->Unbounded.RecordType, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
8350 30836 : NewSym (&Contents);
8351 30836 : FillInPointerFields (Contents, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
8352 30836 : SymbolTable_PutPointer (Contents, SimpleType);
8353 : /* create the contents field for the unbounded array. */
8354 30836 : M2Debug_Assert ((SymbolTable_PutFieldRecord (pSym->Unbounded.RecordType, NameKey_MakeKey ((const char *) "_m2_contents", 12), Contents, SymbolTable_NulSym)) != SymbolTable_NulSym);
8355 : /* create all the high fields for the unbounded array. */
8356 30836 : i = 1;
8357 61816 : while (i <= ndim)
8358 : {
8359 30980 : M2Debug_Assert ((SymbolTable_PutFieldRecord (pSym->Unbounded.RecordType, NameKey_makekey (DynamicStrings_string (DynamicStrings_Mark (FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_m2_high_%d", 11)), (const unsigned char *) &i, (sizeof (i)-1))))), M2Base_Cardinal, SymbolTable_NulSym)) != SymbolTable_NulSym);
8360 30980 : i += 1;
8361 : }
8362 30836 : pSym->Unbounded.Dimensions = ndim;
8363 30836 : ForeachParameterDo ((SymbolTable_CheckProcedure) {(SymbolTable_CheckProcedure_t) CheckUnbounded});
8364 : }
8365 30836 : }
8366 :
8367 :
8368 : /*
8369 : PutUnbounded - associates the unbounded symbol, open, with
8370 : SimpleType.
8371 : */
8372 :
8373 30836 : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim)
8374 : {
8375 30836 : SymbolTable_PtrToSymbol pSym;
8376 :
8377 30836 : pSym = GetPsym (oaf);
8378 30836 : switch (pSym->SymbolType)
8379 : {
8380 : case SymbolTable_OAFamilySym:
8381 : /* need to check to see if we need to add NulSym for all dimensions < ndim
8382 : which have not been used. */
8383 61756 : while (pSym->OAFamily.MaxDimensions < ndim)
8384 : {
8385 30920 : pSym->OAFamily.MaxDimensions += 1;
8386 30920 : if (pSym->OAFamily.MaxDimensions < ndim)
8387 : {
8388 : /* add NulSym to an unused dimension. */
8389 84 : PutIntoIndex (&pSym->OAFamily.Dimensions, pSym->OAFamily.MaxDimensions, SymbolTable_NulSym);
8390 : }
8391 : }
8392 : /* and finally add the known sym. */
8393 30836 : PutIntoIndex (&pSym->OAFamily.Dimensions, ndim, sym);
8394 30836 : break;
8395 :
8396 :
8397 0 : default:
8398 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
8399 30836 : break;
8400 : }
8401 30836 : }
8402 :
8403 :
8404 : /*
8405 : GetArrayDimension - returns the number of dimensions defined.
8406 : */
8407 :
8408 6759 : static unsigned int GetArrayDimension (unsigned int sym)
8409 : {
8410 6759 : unsigned int n;
8411 :
8412 6759 : n = 0;
8413 13692 : while (SymbolTable_IsArray (sym))
8414 : {
8415 6933 : sym = SymbolTable_SkipType (SymbolTable_GetType (sym));
8416 6933 : n += 1;
8417 : }
8418 6759 : return n;
8419 : /* static analysis guarentees a RETURN statement will be used before here. */
8420 : __builtin_unreachable ();
8421 : }
8422 :
8423 :
8424 : /*
8425 : ResolveConstructorType - if, sym, has an unresolved constructor type
8426 : then attempt to resolve it by examining the
8427 : from, type.
8428 : */
8429 :
8430 37178 : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres)
8431 : {
8432 37178 : if ((*unres))
8433 : {
8434 : /* avoid gcc warning by using compound statement even if not strictly necessary. */
8435 37178 : if (SymbolTable_IsConstructor ((*from)))
8436 : {
8437 : /* avoid dangling else. */
8438 0 : if (IsConstructorResolved ((*from)))
8439 : {
8440 0 : (*unres) = false;
8441 0 : (*type) = SymbolTable_GetType ((*from));
8442 0 : if (((*type) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*type)))))
8443 : {
8444 0 : SymbolTable_PutConstSet (sym);
8445 : }
8446 : }
8447 : }
8448 37178 : else if (((*from) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*from)))))
8449 : {
8450 : /* avoid dangling else. */
8451 33946 : (*unres) = false;
8452 33946 : (*type) = (*from);
8453 33946 : SymbolTable_PutConstSet (sym);
8454 : }
8455 3232 : else if (((*from) != SymbolTable_NulSym) && ((SymbolTable_IsRecord (SymbolTable_SkipType ((*from)))) || (SymbolTable_IsArray (SymbolTable_SkipType ((*from))))))
8456 : {
8457 : /* avoid dangling else. */
8458 3226 : (*unres) = false;
8459 3226 : (*type) = (*from);
8460 : }
8461 : }
8462 37178 : }
8463 :
8464 :
8465 : /*
8466 : IsConstructorResolved - returns TRUE if the constructor does not
8467 : have an unresolved type.
8468 : */
8469 :
8470 74356 : static bool IsConstructorResolved (unsigned int sym)
8471 : {
8472 74356 : SymbolTable_PtrToSymbol pSym;
8473 :
8474 74356 : pSym = GetPsym (sym);
8475 74356 : switch (pSym->SymbolType)
8476 : {
8477 74356 : case SymbolTable_ConstVarSym:
8478 74356 : return ! pSym->ConstVar.UnresFromType;
8479 0 : break;
8480 :
8481 0 : case SymbolTable_ConstLitSym:
8482 0 : return ! pSym->ConstLit.UnresFromType;
8483 0 : break;
8484 :
8485 :
8486 0 : default:
8487 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
8488 : break;
8489 : }
8490 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8491 : __builtin_unreachable ();
8492 : }
8493 :
8494 :
8495 : /*
8496 : CanResolveConstructor - returns TRUE if the type of the constructor,
8497 : sym, is known.
8498 : */
8499 :
8500 37178 : static bool CanResolveConstructor (unsigned int sym)
8501 : {
8502 37178 : SymbolTable_PtrToSymbol pSym;
8503 :
8504 37178 : if (! (IsConstructorResolved (sym)))
8505 : {
8506 37178 : pSym = GetPsym (sym);
8507 37178 : switch (pSym->SymbolType)
8508 : {
8509 37178 : case SymbolTable_ConstVarSym:
8510 37178 : ResolveConstructorType (sym, &pSym->ConstVar.Type, &pSym->ConstVar.FromType, &pSym->ConstVar.UnresFromType);
8511 37178 : break;
8512 :
8513 0 : case SymbolTable_ConstLitSym:
8514 0 : ResolveConstructorType (sym, &pSym->ConstLit.Type, &pSym->ConstLit.FromType, &pSym->ConstLit.UnresFromType);
8515 0 : break;
8516 :
8517 :
8518 0 : default:
8519 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
8520 : break;
8521 : }
8522 : }
8523 37178 : return IsConstructorResolved (sym);
8524 : /* static analysis guarentees a RETURN statement will be used before here. */
8525 : __builtin_unreachable ();
8526 : }
8527 :
8528 :
8529 : /*
8530 : CheckAllConstructorsResolved - checks to see that the
8531 : UnresolvedConstructorType list is
8532 : empty and if it is not then it
8533 : generates error messages.
8534 : */
8535 :
8536 15163 : static void CheckAllConstructorsResolved (void)
8537 : {
8538 15163 : unsigned int i;
8539 15163 : unsigned int n;
8540 15163 : unsigned int s;
8541 15163 : M2Error_Error e;
8542 :
8543 15163 : n = Lists_NoOfItemsInList (UnresolvedConstructorType);
8544 15163 : if (n > 0)
8545 : {
8546 12 : for (i=1; i<=n; i++)
8547 : {
8548 6 : s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
8549 6 : e = M2Error_NewError (SymbolTable_GetDeclaredMod (s));
8550 6 : M2Error_ErrorFormat0 (e, (const char *) "constructor has an unknown type", 31);
8551 : }
8552 6 : M2Error_FlushErrors ();
8553 : }
8554 15157 : }
8555 :
8556 :
8557 : /*
8558 : SanityCheckParameters -
8559 : */
8560 :
8561 5024023 : static void SanityCheckParameters (unsigned int sym)
8562 : {
8563 5024023 : unsigned int p;
8564 5024023 : unsigned int i;
8565 5024023 : unsigned int n;
8566 :
8567 5024023 : i = 1;
8568 5024023 : n = SymbolTable_NoOfParamAny (sym);
8569 18832175 : while (i <= n)
8570 : {
8571 8784129 : p = SymbolTable_GetType (SymbolTable_GetParam (sym, i));
8572 8784129 : if (SymbolTable_IsConst (p))
8573 : {
8574 0 : M2MetaError_MetaError3 ((const char *) "the {%1N} formal parameter in procedure {%2Dad} should have a type rather than a constant {%3Dad}", 97, i, sym, p);
8575 : }
8576 8784129 : i += 1;
8577 : }
8578 5024023 : }
8579 :
8580 :
8581 : /*
8582 : SanityCheckArray - checks to see that an array has a correct subrange type.
8583 : */
8584 :
8585 62206016 : static void SanityCheckArray (unsigned int sym)
8586 : {
8587 62206016 : unsigned int type;
8588 62206016 : unsigned int subscript;
8589 :
8590 62206016 : if (SymbolTable_IsArray (sym))
8591 : {
8592 103831 : subscript = SymbolTable_GetArraySubscript (sym);
8593 103831 : if (subscript != SymbolTable_NulSym)
8594 : {
8595 103831 : type = SymbolTable_SkipType (SymbolTable_GetType (subscript));
8596 103831 : if (SymbolTable_IsAModula2Type (type))
8597 : {} /* empty. */
8598 : else
8599 : {
8600 : /* Ok all is good. */
8601 0 : M2MetaError_MetaError2 ((const char *) "the array {%1Dad} must be declared with a simpletype in the [..] component rather than a {%2dv}", 95, sym, type);
8602 : }
8603 : }
8604 : }
8605 62206016 : }
8606 :
8607 :
8608 : /*
8609 : ForeachSymbolDo - foreach symbol, call, P(sym).
8610 : */
8611 :
8612 15157 : static void ForeachSymbolDo (SymbolKey_PerformOperation P)
8613 : {
8614 15157 : unsigned int i;
8615 15157 : unsigned int n;
8616 :
8617 15157 : i = Indexing_LowIndice (Symbols);
8618 15157 : n = Indexing_HighIndice (Symbols);
8619 53965651 : while (i <= n)
8620 : {
8621 53935337 : (*P.proc) (i);
8622 53935337 : i += 1;
8623 : }
8624 15157 : }
8625 :
8626 :
8627 : /*
8628 : SanityCheckProcedure - check to see that procedure parameters do not use constants
8629 : instead of types in their formal parameter section.
8630 : */
8631 :
8632 5024023 : static void SanityCheckProcedure (unsigned int sym)
8633 : {
8634 5024023 : SanityCheckParameters (sym);
8635 5024023 : }
8636 :
8637 :
8638 : /*
8639 : SanityCheckModule -
8640 : */
8641 :
8642 192571 : static void SanityCheckModule (unsigned int sym)
8643 : {
8644 192571 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
8645 192571 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckProcedure});
8646 192571 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
8647 192571 : }
8648 :
8649 :
8650 : /*
8651 : AddNameTo - adds Name, n, to tree, s.
8652 : */
8653 :
8654 8104970 : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o)
8655 : {
8656 8104970 : if ((SymbolKey_GetSymKey (s, SymbolTable_GetSymName (o))) == SymbolKey_NulKey)
8657 : {
8658 6797939 : SymbolKey_PutSymKey (s, SymbolTable_GetSymName (o), o);
8659 : }
8660 8104970 : }
8661 :
8662 :
8663 : /*
8664 : CollectSymbolFrom -
8665 : */
8666 :
8667 152 : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n)
8668 : {
8669 152 : NameKey_Name n1;
8670 152 : unsigned int sym;
8671 :
8672 152 : n1 = SymbolTable_GetSymName (scope);
8673 152 : if (DebugUnknowns)
8674 : {
8675 : M2Printf_printf2 ((const char *) "declaring %a in %a", 18, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n1, (sizeof (n1)-1));
8676 : }
8677 152 : sym = CheckScopeForSym (scope, n);
8678 152 : if (sym == SymbolTable_NulSym)
8679 : {
8680 62 : sym = FetchUnknownFrom (tok, scope, n);
8681 : }
8682 152 : if (DebugUnknowns)
8683 : {
8684 : M2Printf_printf1 ((const char *) " symbol created (%d)\\n", 22, (const unsigned char *) &sym, (sizeof (sym)-1));
8685 : }
8686 152 : return sym;
8687 : /* static analysis guarentees a RETURN statement will be used before here. */
8688 : __builtin_unreachable ();
8689 : }
8690 :
8691 :
8692 : /*
8693 : CollectUnknown -
8694 : */
8695 :
8696 188 : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n)
8697 : {
8698 248 : SymbolTable_PtrToSymbol pSym;
8699 248 : unsigned int s;
8700 :
8701 248 : s = SymbolTable_NulSym;
8702 248 : if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
8703 : {
8704 134 : return CollectSymbolFrom (tok, sym, n);
8705 : }
8706 114 : else if (SymbolTable_IsProcedure (sym))
8707 : {
8708 : /* avoid dangling else. */
8709 114 : s = CheckScopeForSym (sym, n);
8710 114 : if (s == SymbolTable_NulSym)
8711 : {
8712 78 : pSym = GetPsym (sym);
8713 78 : switch (pSym->SymbolType)
8714 : {
8715 78 : case SymbolTable_ProcedureSym:
8716 78 : if ((SymbolKey_GetSymKey (pSym->Procedure.NamedObjects, n)) != SymbolKey_NulKey)
8717 : {
8718 18 : return CollectSymbolFrom (tok, sym, n);
8719 : }
8720 60 : break;
8721 :
8722 :
8723 0 : default:
8724 0 : M2Error_InternalError ((const char *) "expecting - Procedure symbol", 28);
8725 60 : break;
8726 : }
8727 60 : s = CollectUnknown (tok, SymbolTable_GetScope (sym), n);
8728 : }
8729 : }
8730 : return s;
8731 : /* static analysis guarentees a RETURN statement will be used before here. */
8732 : __builtin_unreachable ();
8733 : }
8734 :
8735 :
8736 : /*
8737 : ResolveImport -
8738 : */
8739 :
8740 188 : static void ResolveImport (unsigned int o)
8741 : {
8742 188 : NameKey_Name n1;
8743 188 : NameKey_Name n2;
8744 188 : unsigned int tok;
8745 188 : unsigned int sym;
8746 :
8747 188 : if (DebugUnknowns)
8748 : {
8749 : n1 = SymbolTable_GetSymName (o);
8750 : M2Printf_printf1 ((const char *) "attempting to find out where %a was declared\\n", 46, (const unsigned char *) &n1, (sizeof (n1)-1));
8751 : n1 = SymbolTable_GetSymName (ResolveModule);
8752 : n2 = SymbolTable_GetSymName (SymbolTable_GetScope (ResolveModule));
8753 : M2Printf_printf2 ((const char *) "scope of module %a is %a\\n", 26, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
8754 : }
8755 188 : tok = SymbolTable_GetFirstUsed (o);
8756 188 : sym = CollectUnknown (tok, SymbolTable_GetScope (ResolveModule), SymbolTable_GetSymName (o));
8757 188 : if (sym == SymbolTable_NulSym)
8758 : {
8759 0 : M2MetaError_MetaError2 ((const char *) "unknown symbol {%1Uad} found in import list of module {%2a}", 59, o, ResolveModule);
8760 : }
8761 : else
8762 : {
8763 188 : SymbolTable_AddSymToModuleScope (ResolveModule, sym);
8764 : }
8765 188 : }
8766 :
8767 :
8768 : /*
8769 : ResolveRelativeImport -
8770 : */
8771 :
8772 1981175 : static void ResolveRelativeImport (unsigned int sym)
8773 : {
8774 1981175 : SymbolTable_PtrToSymbol pSym;
8775 :
8776 1981175 : if (SymbolTable_IsModule (sym))
8777 : {
8778 446 : ResolveModule = sym;
8779 446 : pSym = GetPsym (sym);
8780 446 : switch (pSym->SymbolType)
8781 : {
8782 446 : case SymbolTable_ModuleSym:
8783 446 : SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveImport});
8784 446 : break;
8785 :
8786 :
8787 0 : default:
8788 0 : M2Error_InternalError ((const char *) "expecting - Module symbol", 25);
8789 446 : break;
8790 : }
8791 : }
8792 1981175 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
8793 1981175 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
8794 1981175 : }
8795 :
8796 :
8797 : /*
8798 : Max -
8799 : */
8800 :
8801 0 : static unsigned int Max (unsigned int a, unsigned int b)
8802 : {
8803 0 : if (a > b)
8804 : {
8805 : return a;
8806 : }
8807 : else
8808 : {
8809 : return b;
8810 : }
8811 : /* static analysis guarentees a RETURN statement will be used before here. */
8812 : __builtin_unreachable ();
8813 : }
8814 :
8815 :
8816 : /*
8817 : Min -
8818 : */
8819 :
8820 0 : static unsigned int Min (unsigned int a, unsigned int b)
8821 : {
8822 0 : if (a < b)
8823 : {
8824 : return a;
8825 : }
8826 : else
8827 : {
8828 : return b;
8829 : }
8830 : /* static analysis guarentees a RETURN statement will be used before here. */
8831 : __builtin_unreachable ();
8832 : }
8833 :
8834 :
8835 : /*
8836 : DoFindLimits - assigns, Start, and, End, to the start and end
8837 : limits contained in the list, l. It ensures that
8838 : Start and End are within StartLimit..EndLimit.
8839 : If StartLimit or EndLimit are 0 then Start is
8840 : is set to the first value and End to the last.
8841 : */
8842 :
8843 30 : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l)
8844 : {
8845 30 : unsigned int i;
8846 30 : unsigned int j;
8847 30 : unsigned int n;
8848 :
8849 30 : (*End) = 0;
8850 30 : (*Start) = 0;
8851 30 : i = 1;
8852 30 : n = Lists_NoOfItemsInList (l);
8853 90 : while (i <= n)
8854 : {
8855 30 : j = static_cast<unsigned int> (Lists_GetItemFromList (l, i));
8856 30 : if (((j > (*End)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
8857 : {
8858 24 : (*End) = j;
8859 : }
8860 30 : if ((((((*Start) == 0) || (j < (*Start))) && (j != 0)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
8861 : {
8862 24 : (*Start) = j;
8863 : }
8864 30 : i += 1;
8865 : }
8866 30 : }
8867 :
8868 :
8869 : /*
8870 : PutDeclaredDefinition - associates the current tokenno with
8871 : the symbols declaration in the definition
8872 : module.
8873 : */
8874 :
8875 18965152 : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym)
8876 : {
8877 18965152 : SymbolTable_PtrToSymbol pSym;
8878 :
8879 18965152 : pSym = GetPsym (Sym);
8880 18965152 : switch (pSym->SymbolType)
8881 : {
8882 0 : case SymbolTable_ErrorSym:
8883 0 : pSym->Error.At.DefDeclared = tok;
8884 0 : break;
8885 :
8886 0 : case SymbolTable_ObjectSym:
8887 0 : pSym->Object.At.DefDeclared = tok;
8888 0 : break;
8889 :
8890 0 : case SymbolTable_VarientSym:
8891 0 : pSym->Varient.At.DefDeclared = tok;
8892 0 : break;
8893 :
8894 0 : case SymbolTable_RecordSym:
8895 0 : pSym->Record.At.DefDeclared = tok;
8896 0 : break;
8897 :
8898 0 : case SymbolTable_SubrangeSym:
8899 0 : pSym->Subrange.At.DefDeclared = tok;
8900 0 : break;
8901 :
8902 0 : case SymbolTable_EnumerationSym:
8903 0 : pSym->Enumeration.At.DefDeclared = tok;
8904 0 : break;
8905 :
8906 1097 : case SymbolTable_ArraySym:
8907 1097 : pSym->Array.At.DefDeclared = tok;
8908 1097 : break;
8909 :
8910 0 : case SymbolTable_SubscriptSym:
8911 0 : pSym->Subscript.At.DefDeclared = tok;
8912 0 : break;
8913 :
8914 0 : case SymbolTable_UnboundedSym:
8915 0 : pSym->Unbounded.At.DefDeclared = tok;
8916 0 : break;
8917 :
8918 3352598 : case SymbolTable_ProcedureSym:
8919 3352598 : pSym->Procedure.At.DefDeclared = tok;
8920 3352598 : break;
8921 :
8922 0 : case SymbolTable_ProcTypeSym:
8923 0 : pSym->ProcType.At.DefDeclared = tok;
8924 0 : break;
8925 :
8926 0 : case SymbolTable_ConstStringSym:
8927 0 : pSym->ConstString.At.DefDeclared = tok;
8928 0 : break;
8929 :
8930 0 : case SymbolTable_ConstLitSym:
8931 0 : pSym->ConstLit.At.DefDeclared = tok;
8932 0 : break;
8933 :
8934 3940 : case SymbolTable_ConstVarSym:
8935 3940 : pSym->ConstVar.At.DefDeclared = tok;
8936 3940 : break;
8937 :
8938 7150508 : case SymbolTable_VarSym:
8939 7150508 : pSym->Var.At.DefDeclared = tok;
8940 7150508 : break;
8941 :
8942 0 : case SymbolTable_TypeSym:
8943 0 : pSym->Type.At.DefDeclared = tok;
8944 0 : break;
8945 :
8946 0 : case SymbolTable_PointerSym:
8947 0 : pSym->Pointer.At.DefDeclared = tok;
8948 0 : break;
8949 :
8950 96475 : case SymbolTable_RecordFieldSym:
8951 96475 : pSym->RecordField.At.DefDeclared = tok;
8952 96475 : break;
8953 :
8954 0 : case SymbolTable_VarientFieldSym:
8955 0 : pSym->VarientField.At.DefDeclared = tok;
8956 0 : break;
8957 :
8958 0 : case SymbolTable_EnumerationFieldSym:
8959 0 : pSym->EnumerationField.At.DefDeclared = tok;
8960 0 : break;
8961 :
8962 0 : case SymbolTable_SetSym:
8963 0 : pSym->Set.At.DefDeclared = tok;
8964 0 : break;
8965 :
8966 8360348 : case SymbolTable_DefImpSym:
8967 8360348 : pSym->DefImp.At.DefDeclared = tok;
8968 8360348 : break;
8969 :
8970 186 : case SymbolTable_ModuleSym:
8971 186 : pSym->Module.At.DefDeclared = tok;
8972 186 : break;
8973 :
8974 : case SymbolTable_UndefinedSym:
8975 : break;
8976 :
8977 0 : case SymbolTable_PartialUnboundedSym:
8978 0 : PutDeclaredDefinition (tok, pSym->PartialUnbounded.Type);
8979 0 : break;
8980 :
8981 :
8982 0 : default:
8983 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
8984 18965152 : break;
8985 : }
8986 18965152 : }
8987 :
8988 :
8989 : /*
8990 : PutDeclaredModule - returns the token where this symbol was declared
8991 : in an implementation or program module.
8992 : */
8993 :
8994 13254901 : static void PutDeclaredModule (unsigned int tok, unsigned int Sym)
8995 : {
8996 13254901 : SymbolTable_PtrToSymbol pSym;
8997 :
8998 13254901 : pSym = GetPsym (Sym);
8999 13254901 : switch (pSym->SymbolType)
9000 : {
9001 0 : case SymbolTable_ErrorSym:
9002 0 : pSym->Error.At.ModDeclared = tok;
9003 0 : break;
9004 :
9005 0 : case SymbolTable_ObjectSym:
9006 0 : pSym->Object.At.ModDeclared = tok;
9007 0 : break;
9008 :
9009 0 : case SymbolTable_VarientSym:
9010 0 : pSym->Varient.At.ModDeclared = tok;
9011 0 : break;
9012 :
9013 0 : case SymbolTable_RecordSym:
9014 0 : pSym->Record.At.ModDeclared = tok;
9015 0 : break;
9016 :
9017 0 : case SymbolTable_SubrangeSym:
9018 0 : pSym->Subrange.At.ModDeclared = tok;
9019 0 : break;
9020 :
9021 0 : case SymbolTable_EnumerationSym:
9022 0 : pSym->Enumeration.At.ModDeclared = tok;
9023 0 : break;
9024 :
9025 101459 : case SymbolTable_ArraySym:
9026 101459 : pSym->Array.At.ModDeclared = tok;
9027 101459 : break;
9028 :
9029 0 : case SymbolTable_SubscriptSym:
9030 0 : pSym->Subscript.At.ModDeclared = tok;
9031 0 : break;
9032 :
9033 0 : case SymbolTable_UnboundedSym:
9034 0 : pSym->Unbounded.At.ModDeclared = tok;
9035 0 : break;
9036 :
9037 3232938 : case SymbolTable_ProcedureSym:
9038 3232938 : pSym->Procedure.At.ModDeclared = tok;
9039 3232938 : break;
9040 :
9041 0 : case SymbolTable_ProcTypeSym:
9042 0 : pSym->ProcType.At.ModDeclared = tok;
9043 0 : break;
9044 :
9045 0 : case SymbolTable_ConstStringSym:
9046 0 : pSym->ConstString.At.ModDeclared = tok;
9047 0 : break;
9048 :
9049 0 : case SymbolTable_ConstLitSym:
9050 0 : pSym->ConstLit.At.ModDeclared = tok;
9051 0 : break;
9052 :
9053 7061 : case SymbolTable_ConstVarSym:
9054 7061 : pSym->ConstVar.At.ModDeclared = tok;
9055 7061 : break;
9056 :
9057 3656174 : case SymbolTable_VarSym:
9058 3656174 : pSym->Var.At.ModDeclared = tok;
9059 3656174 : break;
9060 :
9061 0 : case SymbolTable_TypeSym:
9062 0 : pSym->Type.At.ModDeclared = tok;
9063 0 : break;
9064 :
9065 0 : case SymbolTable_PointerSym:
9066 0 : pSym->Pointer.At.ModDeclared = tok;
9067 0 : break;
9068 :
9069 255202 : case SymbolTable_RecordFieldSym:
9070 255202 : pSym->RecordField.At.ModDeclared = tok;
9071 255202 : break;
9072 :
9073 0 : case SymbolTable_VarientFieldSym:
9074 0 : pSym->VarientField.At.ModDeclared = tok;
9075 0 : break;
9076 :
9077 0 : case SymbolTable_EnumerationFieldSym:
9078 0 : pSym->EnumerationField.At.ModDeclared = tok;
9079 0 : break;
9080 :
9081 0 : case SymbolTable_SetSym:
9082 0 : pSym->Set.At.ModDeclared = tok;
9083 0 : break;
9084 :
9085 5942539 : case SymbolTable_DefImpSym:
9086 5942539 : pSym->DefImp.At.ModDeclared = tok;
9087 5942539 : break;
9088 :
9089 59528 : case SymbolTable_ModuleSym:
9090 59528 : pSym->Module.At.ModDeclared = tok;
9091 59528 : break;
9092 :
9093 : case SymbolTable_UndefinedSym:
9094 : break;
9095 :
9096 0 : case SymbolTable_PartialUnboundedSym:
9097 0 : PutDeclaredModule (tok, pSym->PartialUnbounded.Type);
9098 0 : break;
9099 :
9100 :
9101 0 : default:
9102 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
9103 13254901 : break;
9104 : }
9105 13254901 : }
9106 :
9107 :
9108 : /*
9109 : DoIsConst - returns TRUE if Sym is defined as a constant
9110 : or is an enumeration field or string.
9111 : */
9112 :
9113 235992637 : static bool DoIsConst (unsigned int Sym)
9114 : {
9115 235992637 : SymbolTable_PtrToSymbol pSym;
9116 :
9117 235992637 : pSym = GetPsym (Sym);
9118 235992637 : return ((((pSym->SymbolType == SymbolTable_ConstVarSym) || (pSym->SymbolType == SymbolTable_ConstLitSym)) || (pSym->SymbolType == SymbolTable_ConstStringSym)) || ((pSym->SymbolType == SymbolTable_VarSym) && (pSym->Var.AddrMode == SymbolTable_ImmediateValue))) || (pSym->SymbolType == SymbolTable_EnumerationFieldSym);
9119 : /* static analysis guarentees a RETURN statement will be used before here. */
9120 : __builtin_unreachable ();
9121 : }
9122 :
9123 :
9124 : /*
9125 : GetFromIndex - return a value from list, i, at position, n.
9126 : */
9127 :
9128 7662556 : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n)
9129 : {
9130 7662556 : typedef unsigned int *GetFromIndex__T2;
9131 :
9132 7662556 : GetFromIndex__T2 p;
9133 :
9134 6599586 : p = static_cast<GetFromIndex__T2> (Indexing_GetIndice (i, n));
9135 6599586 : return (*p);
9136 : /* static analysis guarentees a RETURN statement will be used before here. */
9137 : __builtin_unreachable ();
9138 : }
9139 :
9140 :
9141 : /*
9142 : PutIntoIndex - places value, v, into list, i, at position, n.
9143 : */
9144 :
9145 329026 : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v)
9146 : {
9147 329026 : typedef unsigned int *PutIntoIndex__T3;
9148 :
9149 329026 : PutIntoIndex__T3 p;
9150 :
9151 329026 : Storage_ALLOCATE ((void **) &p, sizeof (unsigned int));
9152 329026 : (*p) = v;
9153 329026 : Indexing_PutIndice ((*i), n, reinterpret_cast <void *> (p));
9154 329026 : }
9155 :
9156 :
9157 : /*
9158 : PushConstString - pushes the character string onto the ALU stack.
9159 : It assumes that the character string is only
9160 : one character long.
9161 : */
9162 :
9163 32938 : static void PushConstString (unsigned int Sym)
9164 : {
9165 32938 : typedef struct PushConstString__T7_a PushConstString__T7;
9166 :
9167 32938 : struct PushConstString__T7_a { char array[10+1]; };
9168 32938 : SymbolTable_PtrToSymbol pSym;
9169 32938 : PushConstString__T7 a;
9170 :
9171 32938 : AssertInRange (Sym);
9172 32938 : pSym = GetPsym (Sym);
9173 32938 : switch (pSym->SymbolType)
9174 : {
9175 32938 : case SymbolTable_ConstStringSym:
9176 32938 : if (pSym->ConstString.Length == 0)
9177 : {
9178 6 : M2ALU_PushChar (ASCII_nul);
9179 : }
9180 32932 : else if (pSym->ConstString.Length == 1)
9181 : {
9182 : /* avoid dangling else. */
9183 32932 : NameKey_GetKey (pSym->ConstString.Contents, (char *) &a.array[0], 10);
9184 32932 : M2ALU_PushChar (a.array[0]);
9185 : }
9186 : else
9187 : {
9188 : /* avoid dangling else. */
9189 0 : M2Error_WriteFormat0 ((const char *) "ConstString must be length 0 or 1", 33);
9190 : }
9191 32938 : break;
9192 :
9193 :
9194 0 : default:
9195 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
9196 32938 : break;
9197 : }
9198 32938 : }
9199 :
9200 :
9201 : /*
9202 : FinalSymbol - returns the highest number symbol used.
9203 : */
9204 :
9205 5512631172 : extern "C" unsigned int SymbolTable_FinalSymbol (void)
9206 : {
9207 5512631172 : return FreeSymbol-1;
9208 : /* static analysis guarentees a RETURN statement will be used before here. */
9209 : __builtin_unreachable ();
9210 : }
9211 :
9212 :
9213 : /*
9214 : MakeComponentRecord - make a temporary which will be used to reference and field
9215 : (or sub field) of record.
9216 : */
9217 :
9218 145895 : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record)
9219 : {
9220 145895 : return buildTemporary (tok, Mode, true, record);
9221 : /* static analysis guarentees a RETURN statement will be used before here. */
9222 : __builtin_unreachable ();
9223 : }
9224 :
9225 :
9226 : /*
9227 : MakeComponentRef - use, sym, to reference, field, sym is returned.
9228 : */
9229 :
9230 145895 : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field)
9231 : {
9232 145895 : SymbolTable_PtrToSymbol pSym;
9233 145895 : unsigned int high;
9234 :
9235 145895 : pSym = GetPsym (sym);
9236 145895 : switch (pSym->SymbolType)
9237 : {
9238 145895 : case SymbolTable_VarSym:
9239 145895 : if (! pSym->Var.IsTemp)
9240 : {
9241 0 : M2Error_InternalError ((const char *) "variable must be a temporary", 28);
9242 : }
9243 145895 : else if (pSym->Var.IsComponentRef)
9244 : {
9245 : /* avoid dangling else. */
9246 145895 : high = Indexing_HighIndice (pSym->Var.list);
9247 145895 : PutIntoIndex (&pSym->Var.list, high+1, field);
9248 : }
9249 : else
9250 : {
9251 : /* avoid dangling else. */
9252 0 : M2Error_InternalError ((const char *) "temporary is not a component reference", 38);
9253 : }
9254 145895 : break;
9255 :
9256 :
9257 0 : default:
9258 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
9259 145895 : break;
9260 : }
9261 145895 : return sym;
9262 : /* static analysis guarentees a RETURN statement will be used before here. */
9263 : __builtin_unreachable ();
9264 : }
9265 :
9266 :
9267 : /*
9268 : IsComponent - returns TRUE if symbol, sym, is a temporary and a component
9269 : reference.
9270 : */
9271 :
9272 421419068 : extern "C" bool SymbolTable_IsComponent (unsigned int sym)
9273 : {
9274 421419068 : SymbolTable_PtrToSymbol pSym;
9275 :
9276 421419068 : pSym = GetPsym (sym);
9277 421419068 : switch (pSym->SymbolType)
9278 : {
9279 2703303 : case SymbolTable_VarSym:
9280 2703303 : return pSym->Var.IsComponentRef;
9281 : break;
9282 :
9283 :
9284 : default:
9285 : return false;
9286 : break;
9287 : }
9288 : /* static analysis guarentees a RETURN statement will be used before here. */
9289 : __builtin_unreachable ();
9290 : }
9291 :
9292 :
9293 : /*
9294 : MakeTemporary - Makes a new temporary variable at the highest real scope.
9295 : The addressing mode of the temporary is set to NoValue.
9296 : */
9297 :
9298 1025622 : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode)
9299 : {
9300 1025622 : tok = CheckTok (tok, (const char *) "temporary", 9);
9301 1025622 : return buildTemporary (tok, Mode, false, SymbolTable_NulSym);
9302 : /* static analysis guarentees a RETURN statement will be used before here. */
9303 : __builtin_unreachable ();
9304 : }
9305 :
9306 :
9307 : /*
9308 : MakeTemporaryFromExpression - makes a new temporary variable at the
9309 : highest real scope. The addressing
9310 : mode of the temporary is set and the
9311 : type is determined by expressions, e.
9312 : */
9313 :
9314 0 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode)
9315 : {
9316 0 : return SymbolTable_MakeTemporaryFromExpressions (tok, e, e, mode);
9317 : /* static analysis guarentees a RETURN statement will be used before here. */
9318 : __builtin_unreachable ();
9319 : }
9320 :
9321 :
9322 : /*
9323 : MakeTemporaryFromExpressions - makes a new temporary variable at the
9324 : highest real scope. The addressing
9325 : mode of the temporary is set and the
9326 : type is determined by expressions,
9327 : e1 and e2.
9328 : */
9329 :
9330 77914 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode)
9331 : {
9332 77914 : SymbolTable_PtrToSymbol pSym;
9333 77914 : DynamicStrings_String s;
9334 77914 : unsigned int t;
9335 77914 : unsigned int Sym;
9336 :
9337 77914 : TemporaryNo += 1;
9338 : /* Make the name */
9339 77914 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
9340 77914 : if (mode == SymbolTable_ImmediateValue)
9341 : {
9342 35174 : Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
9343 35174 : if (SymbolTable_IsConstructor (e1))
9344 : {
9345 218 : SymbolTable_PutConstructor (Sym);
9346 218 : SymbolTable_PutConstructorFrom (Sym, e1);
9347 : }
9348 34956 : else if (SymbolTable_IsConstructor (e2))
9349 : {
9350 : /* avoid dangling else. */
9351 12 : SymbolTable_PutConstructor (Sym);
9352 12 : SymbolTable_PutConstructorFrom (Sym, e2);
9353 : }
9354 : else
9355 : {
9356 : /* avoid dangling else. */
9357 34944 : SymbolTable_PutVar (Sym, M2Base_MixTypes (SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok));
9358 : }
9359 35174 : PutConstVarTemporary (Sym);
9360 : }
9361 : else
9362 : {
9363 42740 : Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
9364 42740 : pSym = GetPsym (Sym);
9365 42740 : switch (pSym->SymbolType)
9366 : {
9367 42740 : case SymbolTable_VarSym:
9368 42740 : pSym->Var.AddrMode = mode;
9369 42740 : pSym->Var.IsComponentRef = false;
9370 42740 : pSym->Var.IsTemp = true; /* Variable is a temporary var */
9371 : /* Declared here */
9372 42740 : InitWhereDeclaredTok (tok, &pSym->Var.At);
9373 42740 : break;
9374 :
9375 :
9376 0 : default:
9377 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
9378 42740 : break;
9379 : }
9380 42740 : t = M2Base_MixTypesDecl (e1, e2, SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok);
9381 42632 : if (t != SymbolTable_NulSym)
9382 : {
9383 42620 : M2Debug_Assert (! (SymbolTable_IsConstructor (t)));
9384 42620 : SymbolTable_PutVar (Sym, t);
9385 : }
9386 : }
9387 77806 : s = DynamicStrings_KillString (s);
9388 77806 : return Sym;
9389 : /* static analysis guarentees a RETURN statement will be used before here. */
9390 : __builtin_unreachable ();
9391 : }
9392 :
9393 :
9394 : /*
9395 : PutMode - Puts the addressing mode, SymMode, into symbol Sym.
9396 : The mode may only be altered if the mode
9397 : is None.
9398 : */
9399 :
9400 9070734 : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode)
9401 : {
9402 9070734 : SymbolTable_PtrToSymbol pSym;
9403 :
9404 9070734 : pSym = GetPsym (Sym);
9405 9070734 : switch (pSym->SymbolType)
9406 : {
9407 : case SymbolTable_ErrorSym:
9408 : break;
9409 :
9410 9070734 : case SymbolTable_VarSym:
9411 9070734 : pSym->Var.AddrMode = SymMode;
9412 9070734 : break;
9413 :
9414 :
9415 0 : default:
9416 0 : M2Error_InternalError ((const char *) "Expecting VarSym", 16);
9417 9070734 : break;
9418 : }
9419 9070734 : }
9420 :
9421 :
9422 : /*
9423 : GetMode - Returns the addressing mode of a symbol.
9424 : */
9425 :
9426 10554037 : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym)
9427 : {
9428 10554037 : SymbolTable_PtrToSymbol pSym;
9429 :
9430 10554037 : pSym = GetPsym (Sym);
9431 10554037 : switch (pSym->SymbolType)
9432 : {
9433 6 : case SymbolTable_ErrorSym:
9434 6 : M2Error_ErrorAbort0 ((const char *) "", 0);
9435 8526453 : break;
9436 :
9437 8526453 : case SymbolTable_VarSym:
9438 8526453 : return pSym->Var.AddrMode;
9439 : break;
9440 :
9441 : case SymbolTable_ConstLitSym:
9442 : return SymbolTable_ImmediateValue;
9443 : break;
9444 :
9445 : case SymbolTable_ConstVarSym:
9446 : return SymbolTable_ImmediateValue;
9447 : break;
9448 :
9449 : case SymbolTable_ConstStringSym:
9450 : return SymbolTable_ImmediateValue;
9451 : break;
9452 :
9453 : case SymbolTable_EnumerationFieldSym:
9454 : return SymbolTable_ImmediateValue;
9455 : break;
9456 :
9457 : case SymbolTable_ProcedureSym:
9458 : return SymbolTable_ImmediateValue;
9459 : break;
9460 :
9461 : case SymbolTable_RecordFieldSym:
9462 : return SymbolTable_ImmediateValue;
9463 : break;
9464 :
9465 : case SymbolTable_VarientFieldSym:
9466 : return SymbolTable_ImmediateValue;
9467 : break;
9468 :
9469 : case SymbolTable_TypeSym:
9470 : return SymbolTable_NoValue;
9471 : break;
9472 :
9473 : case SymbolTable_ArraySym:
9474 : return SymbolTable_NoValue;
9475 : break;
9476 :
9477 : case SymbolTable_SubrangeSym:
9478 : return SymbolTable_NoValue;
9479 : break;
9480 :
9481 : case SymbolTable_EnumerationSym:
9482 : return SymbolTable_NoValue;
9483 : break;
9484 :
9485 : case SymbolTable_RecordSym:
9486 : return SymbolTable_NoValue;
9487 : break;
9488 :
9489 : case SymbolTable_PointerSym:
9490 : return SymbolTable_NoValue;
9491 : break;
9492 :
9493 : case SymbolTable_SetSym:
9494 : return SymbolTable_NoValue;
9495 : break;
9496 :
9497 : case SymbolTable_ProcTypeSym:
9498 : return SymbolTable_NoValue;
9499 : break;
9500 :
9501 : case SymbolTable_UnboundedSym:
9502 : return SymbolTable_NoValue;
9503 : break;
9504 :
9505 : case SymbolTable_UndefinedSym:
9506 : return SymbolTable_NoValue;
9507 0 : break;
9508 :
9509 :
9510 0 : default:
9511 0 : M2Error_InternalError ((const char *) "not expecting this type", 23);
9512 : break;
9513 : }
9514 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9515 : __builtin_unreachable ();
9516 : }
9517 :
9518 :
9519 : /*
9520 : StartScope - starts a block scope at Sym. Transparent determines
9521 : whether the search for a symbol will look at the
9522 : previous ScopeCallFrame if Sym does not contain the
9523 : symbol that GetSym is searching.
9524 :
9525 : WITH statements are partially implemented by calling
9526 : StartScope. Therefore we must retain the old Main from
9527 : the previous ScopePtr when a record is added to the scope
9528 : stack. (Main contains the symbol where all identifiers
9529 : should be added.)
9530 : */
9531 :
9532 31996760 : extern "C" void SymbolTable_StartScope (unsigned int Sym)
9533 : {
9534 31996760 : SymbolTable_PtrToCallFrame oCall;
9535 31996760 : SymbolTable_PtrToCallFrame pCall;
9536 :
9537 31996760 : Sym = SymbolTable_SkipType (Sym);
9538 : /*
9539 : WriteString('New scope is: ') ; WriteKey(GetSymName(Sym)) ; WriteLn ;
9540 : */
9541 31996760 : ScopePtr += 1;
9542 31996760 : if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
9543 : {
9544 31929940 : pCall = GetPcall (ScopePtr);
9545 : }
9546 : else
9547 : {
9548 66820 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
9549 66820 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
9550 : }
9551 31996760 : pCall->Start = ScopePtr-1; /* Previous ScopePtr value before StartScope */
9552 31996760 : pCall->Search = Sym;
9553 : /* new symbols to ie temporary variables. */
9554 31996760 : if (SymbolTable_IsRecord (Sym))
9555 : {
9556 32705 : oCall = GetPcall (ScopePtr-1);
9557 32705 : pCall->Main = oCall->Main;
9558 : }
9559 : else
9560 : {
9561 31964047 : pCall->Main = Sym;
9562 31964047 : PlaceMajorScopesEnumerationListOntoStack (Sym);
9563 : }
9564 31996751 : }
9565 :
9566 :
9567 : /*
9568 : EndScope - ends a block scope started by StartScope. The current
9569 : head of the symbol scope reverts back to the symbol
9570 : which was the Head of the symbol scope before the
9571 : last StartScope was called.
9572 : */
9573 :
9574 31980977 : extern "C" void SymbolTable_EndScope (void)
9575 : {
9576 31980977 : SymbolTable_PtrToCallFrame pCall;
9577 :
9578 : /*
9579 : ; WriteString('EndScope - ending scope: ') ;
9580 : pCall := GetPcall(ScopePtr) ;
9581 : ; WriteKey(GetSymName(pCall^.Search)) ; WriteLn ;
9582 : */
9583 31980977 : pCall = GetPcall (ScopePtr);
9584 : /* ; DisplayScopes */
9585 31980977 : ScopePtr = pCall->Start;
9586 31980977 : }
9587 :
9588 :
9589 : /*
9590 : PseudoScope - starts a pseudo scope at Sym.
9591 : We always connect parent up to the last scope,
9592 : to determine the transparancy of a scope we call
9593 : TransparentScope.
9594 :
9595 : A Pseudo scope has no end block,
9596 : but is terminated when the next EndScope is used.
9597 : The function of the pseudo scope is to provide an
9598 : automatic mechanism to solve enumeration types.
9599 : A declared enumeration type is a Pseudo scope and
9600 : identifiers used with the name of an enumeration
9601 : type field will find the enumeration symbol by
9602 : the scoping algorithm.
9603 : */
9604 :
9605 645576 : extern "C" void SymbolTable_PseudoScope (unsigned int Sym)
9606 : {
9607 645576 : SymbolTable_PtrToCallFrame oCall;
9608 645576 : SymbolTable_PtrToCallFrame pCall;
9609 :
9610 645576 : if (SymbolTable_IsEnumeration (Sym))
9611 : {
9612 645576 : ScopePtr += 1;
9613 645576 : if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
9614 : {
9615 626231 : pCall = GetPcall (ScopePtr);
9616 : }
9617 : else
9618 : {
9619 19345 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
9620 19345 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
9621 : }
9622 645576 : oCall = GetPcall (ScopePtr-1);
9623 645576 : pCall->Main = oCall->Main;
9624 645576 : pCall->Start = oCall->Start;
9625 645576 : pCall->Search = Sym;
9626 : }
9627 : else
9628 : {
9629 0 : M2Error_InternalError ((const char *) "expecting EnumerationSym", 24);
9630 : }
9631 645576 : }
9632 :
9633 :
9634 : /*
9635 : GetCurrentScope - returns the symbol who is responsible for the current
9636 : scope. Note that it ignore pseudo scopes.
9637 : */
9638 :
9639 40954325 : extern "C" unsigned int SymbolTable_GetCurrentScope (void)
9640 : {
9641 40954325 : SymbolTable_PtrToCallFrame pCall;
9642 :
9643 40954325 : pCall = GetPcall (ScopePtr);
9644 40954325 : return pCall->Main;
9645 : /* static analysis guarentees a RETURN statement will be used before here. */
9646 : __builtin_unreachable ();
9647 : }
9648 :
9649 :
9650 : /*
9651 : IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
9652 : */
9653 :
9654 258692 : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym)
9655 : {
9656 258692 : unsigned int s;
9657 :
9658 258692 : s = SymbolTable_GetScope (sym);
9659 517384 : while (s != scope)
9660 : {
9661 1462 : if ((((s == SymbolTable_NulSym) || (SymbolTable_IsProcedure (s))) || (SymbolTable_IsModule (s))) || (SymbolTable_IsDefImp (s)))
9662 : {
9663 : return false;
9664 : }
9665 : else
9666 : {
9667 0 : s = SymbolTable_GetScope (s);
9668 : }
9669 : }
9670 : return true;
9671 : /* static analysis guarentees a RETURN statement will be used before here. */
9672 : __builtin_unreachable ();
9673 : }
9674 :
9675 :
9676 : /*
9677 : SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
9678 : This Sym must represent the module name of the
9679 : file currently being compiled.
9680 : */
9681 :
9682 1300269 : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym)
9683 : {
9684 1300269 : CurrentModule = Sym;
9685 1300269 : }
9686 :
9687 :
9688 : /*
9689 : SetFileModule - Used to set the FileModule to a symbol, Sym.
9690 : This Sym must represent the current program module
9691 : file which is being parsed.
9692 : */
9693 :
9694 1252160 : extern "C" void SymbolTable_SetFileModule (unsigned int Sym)
9695 : {
9696 1252160 : FileModule = Sym;
9697 1252160 : }
9698 :
9699 :
9700 : /*
9701 : SetMainModule - Used to set the MainModule to a symbol, Sym.
9702 : This Sym must represent the main module which was
9703 : envoked by the user to be compiled.
9704 : */
9705 :
9706 15444 : extern "C" void SymbolTable_SetMainModule (unsigned int Sym)
9707 : {
9708 15444 : MainModule = Sym;
9709 15444 : }
9710 :
9711 :
9712 : /*
9713 : CheckAnonymous - checks to see whether the name is NulName and if so
9714 : it creates a unique anonymous name.
9715 : */
9716 :
9717 1485718 : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name)
9718 : {
9719 1485718 : if (name == NameKey_NulName)
9720 : {
9721 66487 : AnonymousName += 1;
9722 66487 : name = NameKey_makekey (DynamicStrings_string (DynamicStrings_Mark (FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "__anon%d", 8)), (const unsigned char *) &AnonymousName, (sizeof (AnonymousName)-1)))));
9723 : }
9724 1485718 : return name;
9725 : /* static analysis guarentees a RETURN statement will be used before here. */
9726 : __builtin_unreachable ();
9727 : }
9728 :
9729 :
9730 : /*
9731 : IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
9732 : or no name.
9733 : */
9734 :
9735 56972 : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym)
9736 : {
9737 56972 : typedef struct IsNameAnonymous__T8_a IsNameAnonymous__T8;
9738 :
9739 56972 : struct IsNameAnonymous__T8_a { char array[5+1]; };
9740 56972 : IsNameAnonymous__T8 a;
9741 56972 : NameKey_Name n;
9742 :
9743 56972 : n = SymbolTable_GetSymName (sym);
9744 56972 : if (n == NameKey_NulName)
9745 : {
9746 : return true;
9747 : }
9748 : else
9749 : {
9750 55718 : NameKey_GetKey (n, (char *) &a.array[0], 5);
9751 55718 : return StrLib_StrEqual ((const char *) &a.array[0], 5, (const char *) "__anon", 6);
9752 : }
9753 : /* static analysis guarentees a RETURN statement will be used before here. */
9754 : __builtin_unreachable ();
9755 : }
9756 :
9757 :
9758 : /*
9759 : NoOfVariables - returns the number of variables in scope. The scope maybe
9760 : a procedure, module or defimp scope.
9761 : */
9762 :
9763 30 : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope)
9764 : {
9765 30 : SymbolTable_PtrToSymbol pSym;
9766 :
9767 30 : if (SymbolTable_IsProcedure (scope))
9768 : {
9769 30 : return SymbolTable_NoOfLocalVar (scope);
9770 : }
9771 0 : else if (SymbolTable_IsModule (scope))
9772 : {
9773 : /* avoid dangling else. */
9774 0 : pSym = GetPsym (scope);
9775 0 : switch (pSym->SymbolType)
9776 : {
9777 0 : case SymbolTable_ModuleSym:
9778 0 : return Lists_NoOfItemsInList (pSym->Module.ListOfVars);
9779 0 : break;
9780 :
9781 :
9782 0 : default:
9783 0 : M2Error_InternalError ((const char *) "expecting module symbol", 23);
9784 0 : break;
9785 : }
9786 : }
9787 0 : else if (SymbolTable_IsDefImp (scope))
9788 : {
9789 : /* avoid dangling else. */
9790 0 : pSym = GetPsym (scope);
9791 0 : switch (pSym->SymbolType)
9792 : {
9793 0 : case SymbolTable_DefImpSym:
9794 0 : return Lists_NoOfItemsInList (pSym->DefImp.ListOfVars);
9795 0 : break;
9796 :
9797 :
9798 0 : default:
9799 0 : M2Error_InternalError ((const char *) "expecting defimp symbol", 23);
9800 0 : break;
9801 : }
9802 : }
9803 : else
9804 : {
9805 : /* avoid dangling else. */
9806 0 : M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
9807 : }
9808 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9809 : __builtin_unreachable ();
9810 : }
9811 :
9812 :
9813 : /*
9814 : MakeModule - creates a module sym with ModuleName. It returns the
9815 : symbol index.
9816 : */
9817 :
9818 27463 : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName)
9819 : {
9820 27463 : SymbolTable_PtrToSymbol pSym;
9821 27463 : SymbolTable_PtrToCallFrame pCall;
9822 27463 : unsigned int Sym;
9823 :
9824 : /*
9825 : Make a new symbol since we are at the outer scope level.
9826 : DeclareSym examines the current scope level for any symbols
9827 : that have the correct name, but are yet undefined.
9828 : Therefore we must not call DeclareSym but create a symbol
9829 : directly.
9830 : */
9831 27463 : NewSym (&Sym);
9832 27463 : pSym = GetPsym (Sym);
9833 27463 : pSym->SymbolType = SymbolTable_ModuleSym;
9834 27463 : pSym->Module.name = ModuleName; /* Index into name array, name */
9835 : /* of record field. */
9836 27463 : pSym->Module.libname = NameKey_NulName; /* Library association. */
9837 27463 : InitCtor (&pSym->Module.ctors); /* Init all ctor functions. */
9838 27463 : Lists_InitList (&pSym->Module.ModListOfDep); /* Vector of SymDependency. */
9839 27463 : SymbolKey_InitTree (&pSym->Module.LocalSymbols); /* The LocalSymbols hold all the */
9840 : /* END WeAreHere. */
9841 27463 : SymbolKey_InitTree (&pSym->Module.ExportTree); /* Holds all the exported */
9842 : /* deleted at the end of Pass 1. */
9843 27463 : SymbolKey_InitTree (&pSym->Module.ImportTree); /* Contains all IMPORTed */
9844 : /* identifiers. */
9845 27463 : Lists_InitList (&pSym->Module.IncludeList); /* Contains all included symbols */
9846 : /* modulename.Symbol */
9847 27463 : SymbolKey_InitTree (&pSym->Module.ExportUndeclared); /* ExportUndeclared contains all */
9848 : /* been declared. */
9849 27463 : Lists_InitList (&pSym->Module.EnumerationScopeList); /* Enumeration scope list which */
9850 : /* Outer Module. */
9851 27463 : SymbolKey_InitTree (&pSym->Module.NamedObjects); /* Names of all items declared. */
9852 27463 : SymbolKey_InitTree (&pSym->Module.NamedImports); /* Names of items imported. */
9853 27463 : SymbolKey_InitTree (&pSym->Module.WhereImported); /* Sym to TokenNo where import */
9854 : /* occurs. Error message use. */
9855 27463 : pSym->Module.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9856 : /* is an index to a constant. */
9857 27463 : SymbolKey_InitTree (&pSym->Module.Unresolved); /* All symbols currently */
9858 : /* unresolved in this module. */
9859 27463 : pSym->Module.StartQuad = 0; /* Signify the initialization */
9860 : /* code. */
9861 27463 : pSym->Module.EndQuad = 0; /* EndQuad should point to a */
9862 : /* goto quad. */
9863 27463 : pSym->Module.StartFinishQuad = 0; /* Signify the finalization */
9864 : /* code. */
9865 27463 : pSym->Module.EndFinishQuad = 0; /* should point to a finish */
9866 27463 : pSym->Module.FinallyFunction = NULL; /* The GCC function for finally */
9867 27463 : pSym->Module.ExceptionFinally = false; /* does it have an exception? */
9868 27463 : pSym->Module.ExceptionBlock = false; /* does it have an exception? */
9869 27463 : pSym->Module.ModLink = GetLink (); /* Is this parsed for linkage? */
9870 27463 : pSym->Module.Builtin = false; /* Is the module builtin? */
9871 27463 : Lists_InitList (&pSym->Module.ListOfVars); /* List of variables in this */
9872 : /* scope. */
9873 27463 : Lists_InitList (&pSym->Module.ListOfProcs); /* List of all procedures */
9874 : /* declared within this module. */
9875 27463 : Lists_InitList (&pSym->Module.ListOfModules); /* List of all inner modules. */
9876 27463 : InitWhereDeclaredTok (tok, &pSym->Module.At); /* Where symbol declared. */
9877 27463 : InitWhereFirstUsedTok (tok, &pSym->Module.At); /* Where symbol first used. */
9878 27463 : pCall = GetPcall (ScopePtr); /* Where symbol first used. */
9879 27463 : if (pCall->Main == (SymbolTable_GetBaseModule ()))
9880 : {
9881 : pSym->Module.Scope = SymbolTable_NulSym;
9882 : }
9883 : else
9884 : {
9885 0 : pSym->Module.Scope = pCall->Main;
9886 : }
9887 27463 : pSym->Module.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9888 27463 : SymbolKey_PutSymKey (ModuleTree, ModuleName, Sym); /* Title error scope. */
9889 27463 : return Sym;
9890 : /* static analysis guarentees a RETURN statement will be used before here. */
9891 : __builtin_unreachable ();
9892 : }
9893 :
9894 :
9895 : /*
9896 : MakeDefImp - creates a definition and implementation module sym
9897 : with name DefImpName. It returns the symbol index.
9898 : */
9899 :
9900 178289 : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName)
9901 : {
9902 178289 : SymbolTable_PtrToSymbol pSym;
9903 178289 : unsigned int Sym;
9904 :
9905 : /* tok := CheckTok (tok, 'defimp') ; */
9906 178289 : NewSym (&Sym);
9907 178289 : pSym = GetPsym (Sym);
9908 178289 : pSym->SymbolType = SymbolTable_DefImpSym;
9909 178289 : pSym->DefImp.name = DefImpName; /* Index into name array, name */
9910 : /* of record field. */
9911 178289 : pSym->DefImp.libname = NameKey_NulName; /* Library association. */
9912 178289 : InitCtor (&pSym->DefImp.ctors);
9913 : /* Init all ctor functions. */
9914 178289 : Lists_InitList (&pSym->DefImp.DefListOfDep); /* Vector of SymDependency. */
9915 178289 : Lists_InitList (&pSym->DefImp.ModListOfDep); /* Vector of SymDependency. */
9916 178289 : SymbolKey_InitTree (&pSym->DefImp.ExportQualifiedTree);
9917 : /* deleted at the end of Pass 1. */
9918 178289 : SymbolKey_InitTree (&pSym->DefImp.ExportUnQualifiedTree);
9919 : /* deleted at the end of Pass 1. */
9920 178289 : SymbolKey_InitTree (&pSym->DefImp.ExportRequest); /* Contains all identifiers that */
9921 : /* this list. */
9922 178289 : SymbolKey_InitTree (&pSym->DefImp.ImportTree); /* Contains all IMPORTed */
9923 : /* identifiers. */
9924 178289 : Lists_InitList (&pSym->DefImp.IncludeList); /* Contains all included symbols */
9925 : /* modulename.Symbol */
9926 178289 : Lists_InitList (&pSym->DefImp.DefIncludeList); /* Contains all included symbols */
9927 : /* in the definition module only */
9928 178289 : SymbolKey_InitTree (&pSym->DefImp.ExportUndeclared); /* ExportUndeclared contains all */
9929 : /* been declared. */
9930 178289 : SymbolKey_InitTree (&pSym->DefImp.NeedToBeImplemented);
9931 : /* implemented. */
9932 178289 : SymbolKey_InitTree (&pSym->DefImp.LocalSymbols); /* The LocalSymbols hold all the */
9933 : /* END WeAreHere. */
9934 178289 : Lists_InitList (&pSym->DefImp.EnumerationScopeList);
9935 : /* visable within this scope. */
9936 178289 : SymbolKey_InitTree (&pSym->DefImp.NamedObjects); /* names of all items declared. */
9937 178289 : SymbolKey_InitTree (&pSym->DefImp.NamedImports); /* Names of items imported. */
9938 178289 : SymbolKey_InitTree (&pSym->DefImp.WhereImported); /* Sym to TokenNo where import */
9939 : /* occurs. Error message use. */
9940 178289 : pSym->DefImp.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9941 : /* is an index to a constant. */
9942 178289 : SymbolKey_InitTree (&pSym->DefImp.Unresolved); /* All symbols currently */
9943 : /* unresolved in this module. */
9944 178289 : pSym->DefImp.StartQuad = 0; /* Signify the initialization */
9945 : /* code. */
9946 178289 : pSym->DefImp.EndQuad = 0; /* EndQuad should point to a */
9947 : /* goto quad. */
9948 178289 : pSym->DefImp.StartFinishQuad = 0; /* Signify the finalization */
9949 : /* code. */
9950 178289 : pSym->DefImp.EndFinishQuad = 0; /* should point to a finish */
9951 178289 : pSym->DefImp.FinallyFunction = NULL; /* The GCC function for finally */
9952 178289 : pSym->DefImp.ExceptionFinally = false; /* does it have an exception? */
9953 178289 : pSym->DefImp.ExceptionBlock = false; /* does it have an exception? */
9954 178289 : pSym->DefImp.ContainsHiddenType = false; /* True if this module */
9955 : /* implements a hidden type. */
9956 178289 : pSym->DefImp.ContainsBuiltin = false; /* Does module define a builtin */
9957 : /* procedure? */
9958 178289 : pSym->DefImp.ForC = false; /* Is it a definition for "C" */
9959 178289 : pSym->DefImp.NeedExportList = false; /* Must user supply export list? */
9960 178289 : pSym->DefImp.DefLink = GetLink (); /* Is the def/mod file only */
9961 178289 : pSym->DefImp.ModLink = GetLink (); /* parsed for linkage? */
9962 178289 : pSym->DefImp.Builtin = false; /* Is the module builtin? */
9963 178289 : Lists_InitList (&pSym->DefImp.ListOfVars); /* List of variables in this */
9964 : /* scope. */
9965 178289 : Lists_InitList (&pSym->DefImp.ListOfProcs); /* List of all procedures */
9966 : /* declared within this module. */
9967 178289 : Lists_InitList (&pSym->DefImp.ListOfModules); /* List of all inner modules. */
9968 178289 : InitWhereDeclaredTok (tok, &pSym->DefImp.At); /* Where symbol declared. */
9969 178289 : InitWhereFirstUsedTok (tok, &pSym->DefImp.At); /* Where symbol first used. */
9970 178289 : pSym->DefImp.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9971 178289 : SymbolKey_PutSymKey (ModuleTree, DefImpName, Sym); /* Title error scope. */
9972 178289 : return Sym;
9973 : /* static analysis guarentees a RETURN statement will be used before here. */
9974 : __builtin_unreachable ();
9975 : }
9976 :
9977 :
9978 : /*
9979 : MakeInnerModule - creates an inner module sym with ModuleName. It returns the
9980 : symbol index.
9981 : */
9982 :
9983 446 : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName)
9984 : {
9985 446 : SymbolTable_PtrToSymbol pSym;
9986 446 : unsigned int Sym;
9987 :
9988 446 : Sym = DeclareSym (tok, ModuleName);
9989 446 : if (! (SymbolTable_IsError (Sym)))
9990 : {
9991 446 : pSym = GetPsym (Sym);
9992 446 : pSym->SymbolType = SymbolTable_ModuleSym;
9993 446 : pSym->Module.name = ModuleName; /* Index into name array, name */
9994 : /* of record field. */
9995 446 : pSym->Module.libname = NameKey_NulName; /* Library association. */
9996 446 : InitCtor (&pSym->Module.ctors); /* Init all ctor functions. */
9997 446 : SymbolKey_InitTree (&pSym->Module.LocalSymbols); /* The LocalSymbols hold all the */
9998 : /* END WeAreHere. */
9999 446 : SymbolKey_InitTree (&pSym->Module.ExportTree); /* Holds all the exported */
10000 : /* deleted at the end of Pass 1. */
10001 446 : SymbolKey_InitTree (&pSym->Module.ImportTree); /* Contains all IMPORTed */
10002 : /* identifiers. */
10003 446 : Lists_InitList (&pSym->Module.IncludeList); /* Contains all included symbols */
10004 : /* modulename.Symbol */
10005 446 : SymbolKey_InitTree (&pSym->Module.ExportUndeclared); /* ExportUndeclared contains all */
10006 : /* been declared. */
10007 446 : Lists_InitList (&pSym->Module.EnumerationScopeList); /* Enumeration scope list which */
10008 : /* visable within this scope. */
10009 446 : SymbolKey_InitTree (&pSym->Module.NamedObjects); /* Names of all items declared. */
10010 446 : SymbolKey_InitTree (&pSym->Module.NamedImports); /* Names of items imported. */
10011 446 : SymbolKey_InitTree (&pSym->Module.WhereImported); /* Sym to TokenNo where import */
10012 : /* occurs. Error message use. */
10013 446 : pSym->Module.Priority = SymbolTable_NulSym; /* Priority of the module. This */
10014 : /* is an index to a constant. */
10015 446 : SymbolKey_InitTree (&pSym->Module.Unresolved); /* All symbols currently */
10016 : /* unresolved in this module. */
10017 446 : pSym->Module.StartQuad = 0; /* Signify the initialization */
10018 : /* code. */
10019 446 : pSym->Module.EndQuad = 0; /* EndQuad should point to a */
10020 : /* goto quad. */
10021 446 : pSym->Module.StartFinishQuad = 0; /* Signify the finalization */
10022 : /* code. */
10023 446 : pSym->Module.EndFinishQuad = 0; /* should point to a finish */
10024 446 : pSym->Module.FinallyFunction = NULL; /* The GCC function for finally */
10025 446 : pSym->Module.ExceptionFinally = false; /* does it have an exception? */
10026 446 : pSym->Module.ExceptionBlock = false; /* does it have an exception? */
10027 446 : pSym->Module.ModLink = GetLink (); /* Is this parsed for linkage? */
10028 446 : Lists_InitList (&pSym->Module.ListOfVars); /* List of variables in this */
10029 : /* scope. */
10030 446 : Lists_InitList (&pSym->Module.ListOfProcs); /* List of all procedures */
10031 : /* declared within this module. */
10032 446 : Lists_InitList (&pSym->Module.ListOfModules); /* List of all inner modules. */
10033 446 : InitWhereDeclaredTok (tok, &pSym->Module.At); /* Where symbol declared. */
10034 446 : InitWhereFirstUsedTok (tok, &pSym->Module.At); /* Where symbol first used. */
10035 446 : if ((SymbolTable_GetCurrentScope ()) == (SymbolTable_GetBaseModule ())) /* Where symbol first used. */
10036 : {
10037 0 : pSym->Module.Scope = SymbolTable_NulSym;
10038 : }
10039 : else
10040 : {
10041 446 : pSym->Module.Scope = SymbolTable_GetCurrentScope ();
10042 446 : AddModuleToParent (Sym, pSym->Module.Scope);
10043 : }
10044 446 : pSym->Module.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
10045 446 : AddSymToScope (Sym, ModuleName); /* Title error scope. */
10046 : }
10047 446 : return Sym;
10048 : /* static analysis guarentees a RETURN statement will be used before here. */
10049 : __builtin_unreachable ();
10050 : }
10051 :
10052 :
10053 : /*
10054 : MakeProcedure - creates a procedure sym with name. It returns
10055 : the symbol index.
10056 : */
10057 :
10058 5180217 : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName)
10059 : {
10060 5180217 : SymbolTable_PtrToSymbol pSym;
10061 5180217 : unsigned int Sym;
10062 5180217 : SymbolTable_ProcedureKind kind;
10063 :
10064 5180217 : tok = CheckTok (tok, (const char *) "procedure", 9);
10065 5180217 : Sym = DeclareSym (tok, ProcedureName);
10066 5180217 : CheckBreak (Sym);
10067 5180217 : if (! (SymbolTable_IsError (Sym)))
10068 : {
10069 5180217 : pSym = GetPsym (Sym);
10070 5180217 : pSym->SymbolType = SymbolTable_ProcedureSym;
10071 5180217 : pSym->Procedure.name = ProcedureName;
10072 20720868 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
10073 : {
10074 15540651 : InitProcedureDeclaration (&pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure]);
10075 15540651 : Lists_InitList (&pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam);
10076 : }
10077 5180217 : pSym->Procedure.OptArgInit = SymbolTable_NulSym; /* The optional arg default */
10078 : /* value. */
10079 5180217 : pSym->Procedure.IsExtern = false; /* Make this procedure external. */
10080 5180217 : pSym->Procedure.IsPublic = false; /* Make this procedure visible. */
10081 5180217 : pSym->Procedure.IsCtor = false; /* Is this procedure a ctor? */
10082 5180217 : pSym->Procedure.IsMonoName = false; /* Overrides module name prefix. */
10083 5180217 : pSym->Procedure.BuildProcType = true; /* Are we building the */
10084 : /* proctype associated with sym? */
10085 5180217 : pSym->Procedure.Scope = SymbolTable_GetCurrentScope (); /* Scope of procedure. */
10086 5180217 : SymbolKey_InitTree (&pSym->Procedure.Unresolved); /* All symbols currently */
10087 : /* unresolved in this procedure. */
10088 5180217 : pSym->Procedure.ScopeQuad = 0; /* Index into list of quads, */
10089 5180217 : pSym->Procedure.StartQuad = 0; /* defining the scope, start and */
10090 5180217 : pSym->Procedure.EndQuad = 0; /* end of the procedure. */
10091 5180217 : pSym->Procedure.Reachable = false; /* Procedure not known to be */
10092 : /* reachable. */
10093 5180217 : pSym->Procedure.SavePriority = false; /* Does procedure need to save */
10094 : /* and restore interrupts? */
10095 5180217 : pSym->Procedure.ReturnType = SymbolTable_NulSym; /* Not a function yet! */
10096 : /* The ProcType equivalent. */
10097 5180217 : pSym->Procedure.ProcedureType = SymbolTable_MakeProcType (tok, NameKey_NulName);
10098 5180217 : SymbolKey_InitTree (&pSym->Procedure.LocalSymbols);
10099 5180217 : Lists_InitList (&pSym->Procedure.EnumerationScopeList);
10100 : /* visable within this scope. */
10101 5180217 : SymbolKey_InitTree (&pSym->Procedure.NamedObjects); /* Names of all items declared. */
10102 5180217 : Lists_InitList (&pSym->Procedure.ListOfVars); /* List of variables in this */
10103 : /* scope. */
10104 5180217 : Lists_InitList (&pSym->Procedure.ListOfProcs); /* List of all procedures */
10105 : /* procedure. */
10106 5180217 : Lists_InitList (&pSym->Procedure.ListOfModules); /* List of all inner modules. */
10107 5180217 : pSym->Procedure.ExceptionFinally = false; /* does it have an exception? */
10108 5180217 : pSym->Procedure.ExceptionBlock = false; /* does it have an exception? */
10109 5180217 : pSym->Procedure.IsBuiltin = false; /* Was it declared __BUILTIN__ ? */
10110 5180217 : pSym->Procedure.BuiltinName = NameKey_NulName; /* name of equivalent builtin */
10111 5180217 : pSym->Procedure.IsInline = false; /* Was is declared __INLINE__ ? */
10112 5180217 : pSym->Procedure.Size = M2ALU_InitValue (); /* Activation record size. */
10113 5180217 : pSym->Procedure.TotalParamSize = M2ALU_InitValue (); /* size of all parameters. */
10114 5180217 : pSym->Procedure.Begin = 0; /* token number for BEGIN */
10115 5180217 : pSym->Procedure.End = 0; /* token number for END */
10116 5180217 : InitWhereDeclaredTok (tok, &pSym->Procedure.At); /* Where the symbol was declared. */
10117 5180217 : pSym->Procedure.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
10118 : /* Now add this procedure to the symbol table of the current scope */
10119 5180217 : AddSymToScope (Sym, ProcedureName);
10120 5180217 : AddProcedureToList (SymbolTable_GetCurrentScope (), Sym);
10121 : }
10122 5180217 : return Sym;
10123 : /* static analysis guarentees a RETURN statement will be used before here. */
10124 : __builtin_unreachable ();
10125 : }
10126 :
10127 :
10128 : /*
10129 : MakeProcedureCtorExtern - creates an extern ctor procedure
10130 : */
10131 :
10132 0 : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename)
10133 : {
10134 0 : unsigned int ctor;
10135 :
10136 0 : ctor = SymbolTable_MakeProcedure (tokenno, GenName (libname, (const char *) "_M2_", 4, modulename, (const char *) "_ctor", 5));
10137 0 : SymbolTable_PutExtern (ctor, true);
10138 0 : return ctor;
10139 : /* static analysis guarentees a RETURN statement will be used before here. */
10140 : __builtin_unreachable ();
10141 : }
10142 :
10143 :
10144 : /*
10145 : PutLibName - places libname into defimp or module sym.
10146 : */
10147 :
10148 251651 : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname)
10149 : {
10150 251651 : SymbolTable_PtrToSymbol pSym;
10151 :
10152 503302 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10153 251651 : pSym = GetPsym (sym);
10154 251651 : switch (pSym->SymbolType)
10155 : {
10156 239639 : case SymbolTable_DefImpSym:
10157 239639 : pSym->DefImp.libname = libname;
10158 239639 : break;
10159 :
10160 12012 : case SymbolTable_ModuleSym:
10161 12012 : pSym->Module.libname = libname;
10162 12012 : break;
10163 :
10164 :
10165 0 : default:
10166 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10167 251651 : break;
10168 : }
10169 251651 : }
10170 :
10171 :
10172 : /*
10173 : GetLibName - returns libname associated with a defimp or module sym.
10174 : */
10175 :
10176 5477928 : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym)
10177 : {
10178 5477928 : SymbolTable_PtrToSymbol pSym;
10179 :
10180 10955856 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10181 5477928 : pSym = GetPsym (sym);
10182 5477928 : switch (pSym->SymbolType)
10183 : {
10184 5383422 : case SymbolTable_DefImpSym:
10185 5383422 : return pSym->DefImp.libname;
10186 94506 : break;
10187 :
10188 94506 : case SymbolTable_ModuleSym:
10189 94506 : return pSym->Module.libname;
10190 0 : break;
10191 :
10192 :
10193 0 : default:
10194 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10195 : break;
10196 : }
10197 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10198 : __builtin_unreachable ();
10199 : }
10200 :
10201 :
10202 : /*
10203 : PutMonoName - changes the IsMonoName boolean inside the procedure.
10204 : */
10205 :
10206 465175 : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value)
10207 : {
10208 465175 : SymbolTable_PtrToSymbol pSym;
10209 :
10210 465175 : pSym = GetPsym (sym);
10211 465175 : switch (pSym->SymbolType)
10212 : {
10213 465175 : case SymbolTable_ProcedureSym:
10214 465175 : pSym->Procedure.IsMonoName = value;
10215 465175 : break;
10216 :
10217 :
10218 0 : default:
10219 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10220 465175 : break;
10221 : }
10222 465175 : }
10223 :
10224 :
10225 : /*
10226 : IsMonoName - returns the public boolean associated with a procedure.
10227 : */
10228 :
10229 3755851 : extern "C" bool SymbolTable_IsMonoName (unsigned int sym)
10230 : {
10231 3755851 : SymbolTable_PtrToSymbol pSym;
10232 :
10233 3755851 : pSym = GetPsym (sym);
10234 3755851 : switch (pSym->SymbolType)
10235 : {
10236 3755851 : case SymbolTable_ProcedureSym:
10237 3755851 : return pSym->Procedure.IsMonoName;
10238 0 : break;
10239 :
10240 :
10241 0 : default:
10242 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10243 : break;
10244 : }
10245 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10246 : __builtin_unreachable ();
10247 : }
10248 :
10249 :
10250 : /*
10251 : PutExtern - changes the extern boolean inside the procedure.
10252 : */
10253 :
10254 716203 : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value)
10255 : {
10256 716203 : SymbolTable_PtrToSymbol pSym;
10257 :
10258 716203 : pSym = GetPsym (sym);
10259 716203 : switch (pSym->SymbolType)
10260 : {
10261 716203 : case SymbolTable_ProcedureSym:
10262 716203 : pSym->Procedure.IsExtern = value;
10263 716203 : break;
10264 :
10265 :
10266 0 : default:
10267 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10268 716203 : break;
10269 : }
10270 716203 : }
10271 :
10272 :
10273 : /*
10274 : IsExtern - returns the public boolean associated with a procedure.
10275 : */
10276 :
10277 5249422 : extern "C" bool SymbolTable_IsExtern (unsigned int sym)
10278 : {
10279 5249422 : SymbolTable_PtrToSymbol pSym;
10280 :
10281 5249422 : pSym = GetPsym (sym);
10282 5249422 : switch (pSym->SymbolType)
10283 : {
10284 5249422 : case SymbolTable_ProcedureSym:
10285 5249422 : return pSym->Procedure.IsExtern;
10286 0 : break;
10287 :
10288 :
10289 0 : default:
10290 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10291 : break;
10292 : }
10293 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10294 : __builtin_unreachable ();
10295 : }
10296 :
10297 :
10298 : /*
10299 : PutPublic - changes the public boolean inside the procedure.
10300 : */
10301 :
10302 731270 : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value)
10303 : {
10304 731270 : SymbolTable_PtrToSymbol pSym;
10305 :
10306 731270 : pSym = GetPsym (sym);
10307 731270 : switch (pSym->SymbolType)
10308 : {
10309 731270 : case SymbolTable_ProcedureSym:
10310 731270 : pSym->Procedure.IsPublic = value;
10311 731270 : break;
10312 :
10313 :
10314 0 : default:
10315 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10316 731270 : break;
10317 : }
10318 731270 : }
10319 :
10320 :
10321 : /*
10322 : IsPublic - returns the public boolean associated with a procedure.
10323 : */
10324 :
10325 110755 : extern "C" bool SymbolTable_IsPublic (unsigned int sym)
10326 : {
10327 110755 : SymbolTable_PtrToSymbol pSym;
10328 :
10329 110755 : pSym = GetPsym (sym);
10330 110755 : switch (pSym->SymbolType)
10331 : {
10332 110755 : case SymbolTable_ProcedureSym:
10333 110755 : return pSym->Procedure.IsPublic;
10334 0 : break;
10335 :
10336 :
10337 0 : default:
10338 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10339 : break;
10340 : }
10341 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10342 : __builtin_unreachable ();
10343 : }
10344 :
10345 :
10346 : /*
10347 : PutCtor - changes the ctor boolean inside the procedure.
10348 : */
10349 :
10350 199717 : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value)
10351 : {
10352 199717 : SymbolTable_PtrToSymbol pSym;
10353 :
10354 199717 : pSym = GetPsym (sym);
10355 199717 : switch (pSym->SymbolType)
10356 : {
10357 199717 : case SymbolTable_ProcedureSym:
10358 199717 : pSym->Procedure.IsCtor = value;
10359 199717 : break;
10360 :
10361 :
10362 0 : default:
10363 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10364 199717 : break;
10365 : }
10366 199717 : }
10367 :
10368 :
10369 : /*
10370 : IsCtor - returns the ctor boolean associated with a procedure.
10371 : */
10372 :
10373 161074 : extern "C" bool SymbolTable_IsCtor (unsigned int sym)
10374 : {
10375 161074 : SymbolTable_PtrToSymbol pSym;
10376 :
10377 161074 : pSym = GetPsym (sym);
10378 161074 : switch (pSym->SymbolType)
10379 : {
10380 161074 : case SymbolTable_ProcedureSym:
10381 161074 : return pSym->Procedure.IsCtor;
10382 0 : break;
10383 :
10384 :
10385 0 : default:
10386 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10387 : break;
10388 : }
10389 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10390 : __builtin_unreachable ();
10391 : }
10392 :
10393 :
10394 : /*
10395 : GetModuleCtors - mod can be a DefImp or Module symbol. ctor, init and fini
10396 : are assigned for this module. An inner module ctor value will
10397 : be NulSym.
10398 : */
10399 :
10400 157789 : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep)
10401 : {
10402 157789 : SymbolTable_PtrToSymbol pSym;
10403 :
10404 157789 : pSym = GetPsym (mod);
10405 157789 : switch (pSym->SymbolType)
10406 : {
10407 84339 : case SymbolTable_ModuleSym:
10408 84339 : (*ctor) = pSym->Module.ctors.ctor;
10409 84339 : (*init) = pSym->Module.ctors.init;
10410 84339 : (*fini) = pSym->Module.ctors.fini;
10411 84339 : (*dep) = pSym->Module.ctors.dep;
10412 84339 : break;
10413 :
10414 73450 : case SymbolTable_DefImpSym:
10415 73450 : (*ctor) = pSym->DefImp.ctors.ctor;
10416 73450 : (*init) = pSym->DefImp.ctors.init;
10417 73450 : (*fini) = pSym->DefImp.ctors.fini;
10418 73450 : (*dep) = pSym->DefImp.ctors.dep;
10419 73450 : break;
10420 :
10421 :
10422 0 : default:
10423 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
10424 157789 : break;
10425 : }
10426 157789 : }
10427 :
10428 :
10429 : /*
10430 : MakeModuleCtor - for a defimp or module symbol create all the ctor
10431 : related procedures.
10432 : */
10433 :
10434 85023 : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym)
10435 : {
10436 85023 : SymbolTable_PtrToSymbol pSym;
10437 :
10438 170046 : M2Debug_Assert ((SymbolTable_IsDefImp (moduleSym)) || (SymbolTable_IsModule (moduleSym)));
10439 85023 : pSym = GetPsym (moduleSym);
10440 85023 : if (SymbolTable_IsDefImp (moduleSym))
10441 : {
10442 72710 : InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->DefImp.ctors, SymbolTable_GetSymName (moduleSym), false, true);
10443 : }
10444 : else
10445 : {
10446 12313 : InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->Module.ctors, SymbolTable_GetSymName (moduleSym), SymbolTable_IsInnerModule (moduleSym), true);
10447 : }
10448 85023 : }
10449 :
10450 :
10451 : /*
10452 : PutModuleCtorExtern - for every ctor related procedure in module sym.
10453 : Make it external. It will create any missing
10454 : init/fini procedures but not any missing dep/ctor
10455 : procedures.
10456 : */
10457 :
10458 115480 : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external)
10459 : {
10460 115480 : SymbolTable_PtrToSymbol pSym;
10461 :
10462 230960 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10463 115480 : pSym = GetPsym (sym);
10464 115480 : switch (pSym->SymbolType)
10465 : {
10466 115480 : case SymbolTable_DefImpSym:
10467 115480 : PutCtorExtern (tok, sym, &pSym->DefImp.ctors, external);
10468 115480 : break;
10469 :
10470 0 : case SymbolTable_ModuleSym:
10471 0 : PutCtorExtern (tok, sym, &pSym->Module.ctors, external);
10472 0 : break;
10473 :
10474 :
10475 0 : default:
10476 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10477 115480 : break;
10478 : }
10479 115480 : }
10480 :
10481 :
10482 : /*
10483 : PutVarHeap - assigns ArrayRef field with value.
10484 : */
10485 :
10486 55078 : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value)
10487 : {
10488 55078 : SymbolTable_PtrToSymbol pSym;
10489 :
10490 55078 : pSym = GetPsym (sym);
10491 55078 : switch (pSym->SymbolType)
10492 : {
10493 55078 : case SymbolTable_VarSym:
10494 55078 : pSym->Var.Heap = value;
10495 55078 : break;
10496 :
10497 :
10498 0 : default:
10499 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
10500 55078 : break;
10501 : }
10502 55078 : }
10503 :
10504 :
10505 : /*
10506 : IsVarHeap - returns ArrayRef field value.
10507 : */
10508 :
10509 637510 : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym)
10510 : {
10511 637510 : SymbolTable_PtrToSymbol pSym;
10512 :
10513 637510 : pSym = GetPsym (sym);
10514 637510 : switch (pSym->SymbolType)
10515 : {
10516 637510 : case SymbolTable_VarSym:
10517 637510 : return pSym->Var.Heap;
10518 0 : break;
10519 :
10520 :
10521 0 : default:
10522 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
10523 : break;
10524 : }
10525 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10526 : __builtin_unreachable ();
10527 : }
10528 :
10529 :
10530 : /*
10531 : MakeVar - creates a variable sym with VarName. It returns the
10532 : symbol index.
10533 : */
10534 :
10535 11606219 : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName)
10536 : {
10537 11606219 : SymbolTable_PtrToSymbol pSym;
10538 11606219 : unsigned int Sym;
10539 :
10540 11606219 : Sym = DeclareSym (tok, VarName);
10541 11606219 : if (! (SymbolTable_IsError (Sym)))
10542 : {
10543 11606207 : pSym = GetPsym (Sym);
10544 11606207 : pSym->SymbolType = SymbolTable_VarSym;
10545 11606207 : pSym->Var.name = VarName;
10546 11606207 : pSym->Var.Type = SymbolTable_NulSym;
10547 11606207 : pSym->Var.BackType = SymbolTable_NulSym;
10548 11606207 : pSym->Var.Size = M2ALU_InitValue ();
10549 11606207 : pSym->Var.Offset = M2ALU_InitValue ();
10550 11606207 : pSym->Var.AddrMode = SymbolTable_RightValue;
10551 11606207 : pSym->Var.Scope = SymbolTable_GetCurrentScope (); /* Procedure or Module? */
10552 11606207 : pSym->Var.AtAddress = false; /* Procedure or Module? */
10553 11606207 : pSym->Var.Address = SymbolTable_NulSym; /* Address at which declared. */
10554 11606207 : pSym->Var.IsConditional = false; /* Address at which declared. */
10555 11606207 : pSym->Var.IsTemp = false;
10556 11606207 : pSym->Var.IsComponentRef = false;
10557 11606207 : pSym->Var.IsParam = false;
10558 11606207 : pSym->Var.IsPointerCheck = false;
10559 11606207 : pSym->Var.IsWritten = false;
10560 11606207 : pSym->Var.IsSSA = false;
10561 11606207 : pSym->Var.IsConst = false;
10562 11606207 : pSym->Var.ArrayRef = false;
10563 11606207 : pSym->Var.Heap = false;
10564 11606207 : InitVarDecl (&pSym->Var.Declared, tok);
10565 11606207 : InitWhereDeclaredTok (tok, &pSym->Var.At);
10566 11606207 : InitWhereFirstUsedTok (tok, &pSym->Var.At); /* Where symbol first used. */
10567 11606207 : Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]); /* Where symbol first used. */
10568 11606207 : Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]);
10569 11606207 : Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
10570 11606207 : Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
10571 11606207 : pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
10572 11606207 : pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
10573 : /* Add Var to Procedure or Module variable list. */
10574 11606207 : AddVarToList (Sym);
10575 : /* Now add this Var to the symbol table of the current scope. */
10576 11606207 : AddSymToScope (Sym, VarName);
10577 : }
10578 11606219 : return Sym;
10579 : /* static analysis guarentees a RETURN statement will be used before here. */
10580 : __builtin_unreachable ();
10581 : }
10582 :
10583 :
10584 : /*
10585 : PutVarConditional - assign IsConditional to value.
10586 : */
10587 :
10588 17307 : extern "C" void SymbolTable_PutVarConditional (unsigned int sym, bool value)
10589 : {
10590 17307 : SymbolTable_PtrToSymbol pSym;
10591 :
10592 17307 : pSym = GetPsym (sym);
10593 17307 : switch (pSym->SymbolType)
10594 : {
10595 17025 : case SymbolTable_VarSym:
10596 17025 : pSym->Var.IsConditional = value;
10597 17025 : break;
10598 :
10599 282 : case SymbolTable_ConstVarSym:
10600 282 : pSym->ConstVar.IsConditional = value;
10601 282 : break;
10602 :
10603 :
10604 0 : default:
10605 0 : M2Error_InternalError ((const char *) "expecting Var", 13);
10606 17307 : break;
10607 : }
10608 17307 : }
10609 :
10610 :
10611 : /*
10612 : IsVarConditional - return TRUE if the symbol is a var symbol
10613 : containing the result of a boolean conditional.
10614 : */
10615 :
10616 324419 : extern "C" bool SymbolTable_IsVarConditional (unsigned int sym)
10617 : {
10618 324419 : SymbolTable_PtrToSymbol pSym;
10619 :
10620 324419 : pSym = GetPsym (sym);
10621 324419 : switch (pSym->SymbolType)
10622 : {
10623 20022 : case SymbolTable_VarSym:
10624 20022 : return pSym->Var.IsConditional;
10625 303144 : break;
10626 :
10627 303144 : case SymbolTable_ConstVarSym:
10628 303144 : return pSym->ConstVar.IsConditional;
10629 : break;
10630 :
10631 :
10632 : default:
10633 : return false;
10634 : break;
10635 : }
10636 : return false;
10637 : /* static analysis guarentees a RETURN statement will be used before here. */
10638 : __builtin_unreachable ();
10639 : }
10640 :
10641 :
10642 : /*
10643 : MakeRecord - makes a Record symbol with name RecordName.
10644 : */
10645 :
10646 73193 : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName)
10647 : {
10648 73193 : unsigned int oaf;
10649 73193 : unsigned int sym;
10650 :
10651 73193 : tok = CheckTok (tok, (const char *) "record", 6);
10652 73193 : sym = HandleHiddenOrDeclare (tok, RecordName, &oaf);
10653 73193 : FillInRecordFields (tok, sym, RecordName, SymbolTable_GetCurrentScope (), oaf);
10654 73193 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10655 73193 : return sym;
10656 : /* static analysis guarentees a RETURN statement will be used before here. */
10657 : __builtin_unreachable ();
10658 : }
10659 :
10660 :
10661 : /*
10662 : MakeVarient - creates a new symbol, a varient symbol for record or varient field
10663 : symbol, RecOrVarFieldSym.
10664 : */
10665 :
10666 3054 : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym)
10667 : {
10668 3054 : SymbolTable_PtrToSymbol pSym;
10669 3054 : unsigned int Sym;
10670 :
10671 3054 : tok = CheckTok (tok, (const char *) "varient", 7);
10672 3054 : NewSym (&Sym);
10673 3054 : pSym = GetPsym (Sym);
10674 3054 : pSym->SymbolType = SymbolTable_VarientSym;
10675 3054 : pSym->Varient.Size = M2ALU_InitValue ();
10676 3054 : pSym->Varient.Parent = RecOrVarFieldSym; /* GetRecord(RecOrVarFieldSym) ; */
10677 3054 : if (SymbolTable_IsRecord (RecOrVarFieldSym)) /* GetRecord(RecOrVarFieldSym) ; */
10678 : {
10679 : pSym->Varient.Varient = SymbolTable_NulSym;
10680 : }
10681 : else
10682 : {
10683 36 : pSym->Varient.Varient = RecOrVarFieldSym;
10684 : }
10685 3054 : pSym->Varient.tag = SymbolTable_NulSym;
10686 3054 : pSym->Varient.DeclPacked = false;
10687 3054 : pSym->Varient.Scope = SymbolTable_GetCurrentScope ();
10688 3054 : Lists_InitList (&pSym->Varient.ListOfSons);
10689 3054 : InitWhereDeclaredTok (tok, &pSym->Varient.At);
10690 : /* Now add Sym to the record RecSym field list */
10691 3054 : pSym = GetPsym (RecOrVarFieldSym);
10692 3054 : switch (pSym->SymbolType)
10693 : {
10694 3018 : case SymbolTable_RecordSym:
10695 3018 : Lists_PutItemIntoList (pSym->Record.ListOfSons, Sym);
10696 3018 : break;
10697 :
10698 36 : case SymbolTable_VarientFieldSym:
10699 36 : Lists_PutItemIntoList (pSym->VarientField.ListOfSons, Sym);
10700 36 : break;
10701 :
10702 :
10703 0 : default:
10704 0 : M2Error_InternalError ((const char *) "expecting Record or VarientField symbol", 39);
10705 3054 : break;
10706 : }
10707 3054 : return Sym;
10708 : /* static analysis guarentees a RETURN statement will be used before here. */
10709 : __builtin_unreachable ();
10710 : }
10711 :
10712 :
10713 : /*
10714 : MakeFieldVarient - returns a FieldVarient symbol which has been
10715 : assigned to the Varient symbol, Sym.
10716 : */
10717 :
10718 6222 : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym)
10719 : {
10720 6222 : SymbolTable_PtrToSymbol pSym;
10721 6222 : unsigned int SonSym;
10722 :
10723 6222 : NewSym (&SonSym);
10724 : /* Fill in Sym */
10725 6222 : pSym = GetPsym (SonSym);
10726 6222 : pSym->SymbolType = SymbolTable_VarientFieldSym;
10727 6222 : pSym->VarientField.name = n;
10728 6222 : Lists_InitList (&pSym->VarientField.ListOfSons);
10729 6222 : pSym->VarientField.Parent = SymbolTable_GetRecord (Sym);
10730 6222 : pSym->VarientField.Varient = SymbolTable_NulSym;
10731 6222 : pSym->VarientField.Size = M2ALU_InitValue ();
10732 6222 : pSym->VarientField.Offset = M2ALU_InitValue ();
10733 6222 : pSym->VarientField.DeclPacked = false;
10734 6222 : pSym->VarientField.DeclResolved = false;
10735 6222 : pSym->VarientField.Scope = SymbolTable_GetCurrentScope ();
10736 6222 : InitWhereDeclared (&pSym->VarientField.At);
10737 6222 : return SonSym;
10738 : /* static analysis guarentees a RETURN statement will be used before here. */
10739 : __builtin_unreachable ();
10740 : }
10741 :
10742 :
10743 : /*
10744 : MakeEnumeration - places a new symbol in the current scope, the symbol
10745 : is an enumeration symbol. The symbol index is returned.
10746 : */
10747 :
10748 50367 : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName)
10749 : {
10750 50367 : SymbolTable_PtrToSymbol pSym;
10751 50367 : unsigned int sym;
10752 50367 : unsigned int oaf;
10753 :
10754 50367 : tok = CheckTok (tok, (const char *) "enumeration", 11);
10755 50367 : sym = CheckForHiddenType (EnumerationName);
10756 50367 : if (sym == SymbolTable_NulSym)
10757 : {
10758 : /* avoid dangling else. */
10759 50367 : sym = DeclareSym (tok, EnumerationName);
10760 50367 : oaf = SymbolTable_GetOAFamily (sym);
10761 50367 : if (! (SymbolTable_IsError (sym)))
10762 : {
10763 50367 : pSym = GetPsym (sym);
10764 50367 : pSym->SymbolType = SymbolTable_EnumerationSym; /* To satisfy AddSymToScope */
10765 : /* Now add this type to the symbol table of the current scope */
10766 50367 : AddSymToScope (sym, EnumerationName);
10767 : }
10768 : }
10769 : else
10770 : {
10771 0 : oaf = SymbolTable_GetOAFamily (sym);
10772 : }
10773 50367 : if (! (SymbolTable_IsError (sym)))
10774 : {
10775 50367 : pSym = GetPsym (sym);
10776 50367 : pSym->SymbolType = SymbolTable_EnumerationSym;
10777 50367 : pSym->Enumeration.name = EnumerationName; /* Name of enumeration. */
10778 50367 : pSym->Enumeration.NoOfElements = 0; /* No of elements in the */
10779 : /* enumeration type. */
10780 50367 : pSym->Enumeration.Size = M2ALU_InitValue (); /* Size at runtime of sym */
10781 50367 : SymbolKey_InitTree (&pSym->Enumeration.LocalSymbols); /* Enumeration fields. */
10782 50367 : Lists_InitList (&pSym->Enumeration.ListOfFields); /* Ordered as declared. */
10783 50367 : InitPacked (&pSym->Enumeration.packedInfo); /* not packed and no */
10784 : /* equivalent (yet). */
10785 50367 : pSym->Enumeration.oafamily = oaf; /* The open array family */
10786 50367 : pSym->Enumeration.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10787 50367 : InitWhereDeclaredTok (tok, &pSym->Enumeration.At); /* Declared here */
10788 50367 : CheckIfEnumerationExported (sym, ScopePtr);
10789 : }
10790 50367 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10791 50367 : return sym;
10792 : /* static analysis guarentees a RETURN statement will be used before here. */
10793 : __builtin_unreachable ();
10794 : }
10795 :
10796 :
10797 : /*
10798 : MakeType - makes a type symbol with name TypeName.
10799 : */
10800 :
10801 625169 : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName)
10802 : {
10803 625169 : SymbolTable_PtrToSymbol pSym;
10804 625169 : unsigned int sym;
10805 625169 : unsigned int oaf;
10806 :
10807 625169 : sym = HandleHiddenOrDeclare (tok, TypeName, &oaf);
10808 625169 : if (! (SymbolTable_IsError (sym)))
10809 : {
10810 625163 : pSym = GetPsym (sym);
10811 625163 : pSym->SymbolType = SymbolTable_TypeSym;
10812 625163 : pSym->Type.name = TypeName; /* Index into name array, name */
10813 : /* of type. */
10814 625163 : pSym->Type.Type = SymbolTable_NulSym; /* Index to a type symbol. */
10815 625163 : pSym->Type.IsHidden = false; /* Was it declared as hidden? */
10816 625163 : SymbolKey_InitTree (&pSym->Type.ConstLitTree); /* constants of this type. */
10817 625163 : pSym->Type.Size = M2ALU_InitValue (); /* Runtime size of symbol. */
10818 625163 : pSym->Type.Align = SymbolTable_NulSym; /* Alignment of this type. */
10819 625163 : InitPacked (&pSym->Type.packedInfo); /* not packed and no */
10820 : /* equivalent yet. */
10821 625163 : pSym->Type.oafamily = oaf; /* The open array family. */
10822 625163 : pSym->Type.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10823 1250326 : InitWhereDeclaredTok (tok, &pSym->Type.At); /* Declared here */
10824 : }
10825 625169 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10826 625169 : return sym;
10827 : /* static analysis guarentees a RETURN statement will be used before here. */
10828 : __builtin_unreachable ();
10829 : }
10830 :
10831 :
10832 : /*
10833 : MakeHiddenType - makes a type symbol that is hidden from the
10834 : definition module.
10835 : This symbol is placed into the UnImplemented list of
10836 : the definition/implementation module.
10837 : The type will be filled in when the implementation module
10838 : is reached.
10839 : */
10840 :
10841 29335 : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName)
10842 : {
10843 29335 : SymbolTable_PtrToSymbol pSym;
10844 29335 : unsigned int Sym;
10845 :
10846 29335 : tok = CheckTok (tok, (const char *) "hidden", 6);
10847 29335 : Sym = DeclareSym (tok, TypeName);
10848 29335 : if (! (SymbolTable_IsError (Sym)))
10849 : {
10850 29335 : pSym = GetPsym (Sym);
10851 29335 : pSym->SymbolType = SymbolTable_TypeSym;
10852 29335 : pSym->Type.name = TypeName; /* Index into name array, name */
10853 : /* of type. */
10854 29335 : pSym->Type.IsHidden = (SymbolTable_GetMainModule ()) != (SymbolTable_GetCurrentScope ());
10855 29335 : if (M2Options_ExtendedOpaque || ! pSym->Type.IsHidden)
10856 : {
10857 1502 : pSym->Type.Type = SymbolTable_NulSym; /* will be filled in later */
10858 : }
10859 : else
10860 : {
10861 27833 : pSym->Type.Type = M2System_Address;
10862 : }
10863 29335 : pSym->Type.Align = SymbolTable_NulSym; /* Alignment of this type. */
10864 29335 : pSym->Type.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10865 29335 : pSym->Type.oafamily = SymbolTable_NulSym; /* Which scope created it */
10866 29335 : if (! M2Options_ExtendedOpaque)
10867 : {
10868 27939 : Lists_IncludeItemIntoList (AddressTypes, Sym);
10869 : }
10870 29335 : pSym->Type.Size = M2ALU_InitValue (); /* Runtime size of symbol. */
10871 29335 : InitWhereDeclaredTok (tok, &pSym->Type.At); /* Declared here */
10872 29335 : SymbolTable_PutExportUnImplemented (tok, Sym);
10873 29335 : if (M2Options_ExtendedOpaque || ((SymbolTable_GetMainModule ()) == (SymbolTable_GetCurrentScope ())))
10874 : {
10875 1502 : SymbolTable_PutHiddenTypeDeclared ();
10876 : }
10877 : /* Now add this type to the symbol table of the current scope */
10878 29335 : AddSymToScope (Sym, TypeName);
10879 : }
10880 29335 : return Sym;
10881 : /* static analysis guarentees a RETURN statement will be used before here. */
10882 : __builtin_unreachable ();
10883 : }
10884 :
10885 :
10886 : /*
10887 : MakeConstant - create a constant cardinal and return the symbol.
10888 : */
10889 :
10890 102794 : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value)
10891 : {
10892 102794 : DynamicStrings_String str;
10893 102794 : unsigned int sym;
10894 :
10895 102794 : tok = CheckTok (tok, (const char *) "constant", 8);
10896 102794 : str = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%d", 2)), (const unsigned char *) &value, (sizeof (value)-1));
10897 102794 : sym = SymbolTable_MakeConstLit (tok, NameKey_makekey (DynamicStrings_string (str)), M2Base_Cardinal);
10898 102794 : str = DynamicStrings_KillString (str);
10899 102794 : return sym;
10900 : /* static analysis guarentees a RETURN statement will be used before here. */
10901 : __builtin_unreachable ();
10902 : }
10903 :
10904 :
10905 : /*
10906 : MakeConstLit - returns a constant literal of type, constType, with a constName,
10907 : at location, tok.
10908 : */
10909 :
10910 1676533 : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
10911 : {
10912 1676533 : unsigned int sym;
10913 :
10914 1676533 : tok = CheckTok (tok, (const char *) "constlit", 8);
10915 1676533 : sym = LookupConstLitPoolEntry (tok, constName, constType);
10916 1676533 : if (sym == SymbolTable_NulSym)
10917 : {
10918 624946 : sym = CreateConstLit (tok, constName, constType);
10919 624946 : AddConstLitPoolEntry (sym, tok, constName, constType);
10920 : }
10921 1676533 : return sym;
10922 : /* static analysis guarentees a RETURN statement will be used before here. */
10923 : __builtin_unreachable ();
10924 : }
10925 :
10926 :
10927 : /*
10928 : MakeConstVar - makes a ConstVar type with
10929 : name ConstVarName.
10930 : */
10931 :
10932 1302850 : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName)
10933 : {
10934 1302850 : SymbolTable_PtrToSymbol pSym;
10935 1302850 : unsigned int Sym;
10936 1302850 : bool temp;
10937 :
10938 1302850 : temp = ConstVarName == NameKey_NulName;
10939 1302850 : ConstVarName = SymbolTable_CheckAnonymous (ConstVarName);
10940 1302850 : Sym = DeclareSym (tok, ConstVarName);
10941 1302850 : if (! (SymbolTable_IsError (Sym)))
10942 : {
10943 1302844 : pSym = GetPsym (Sym);
10944 1302844 : pSym->SymbolType = SymbolTable_ConstVarSym;
10945 1302844 : pSym->ConstVar.name = ConstVarName;
10946 1302844 : pSym->ConstVar.Value = M2ALU_InitValue ();
10947 1302844 : pSym->ConstVar.Type = SymbolTable_NulSym;
10948 1302844 : pSym->ConstVar.IsSet = false;
10949 1302844 : pSym->ConstVar.IsConditional = false;
10950 1302844 : pSym->ConstVar.IsConstructor = false;
10951 1302844 : pSym->ConstVar.FromType = SymbolTable_NulSym; /* type is determined FromType */
10952 1302844 : pSym->ConstVar.UnresFromType = false; /* is Type resolved? */
10953 1302844 : pSym->ConstVar.IsTemp = temp; /* is Type resolved? */
10954 1302844 : pSym->ConstVar.Scope = SymbolTable_GetCurrentScope ();
10955 1302844 : InitWhereDeclaredTok (tok, &pSym->ConstVar.At);
10956 : /* Now add this constant to the symbol table of the current scope */
10957 1302844 : AddSymToScope (Sym, ConstVarName);
10958 : }
10959 1302850 : return Sym;
10960 : /* static analysis guarentees a RETURN statement will be used before here. */
10961 : __builtin_unreachable ();
10962 : }
10963 :
10964 :
10965 : /*
10966 : MakeConstString - create a string constant in the symboltable.
10967 : */
10968 :
10969 330286 : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName)
10970 : {
10971 330286 : unsigned int newstr;
10972 :
10973 330286 : NewSym (&newstr);
10974 330286 : InitConstString (tok, newstr, ConstName, ConstName, SymbolTable_m2nulstr, false, true);
10975 330286 : return newstr;
10976 : /* static analysis guarentees a RETURN statement will be used before here. */
10977 : __builtin_unreachable ();
10978 : }
10979 :
10980 :
10981 : /*
10982 : MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
10983 : If known is TRUE then name is assigned to the contents
10984 : and the escape sequences will be converted into characters.
10985 : */
10986 :
10987 9762 : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known)
10988 : {
10989 9762 : unsigned int newstr;
10990 :
10991 9762 : tok = CheckTok (tok, (const char *) "conststringcnul", 15);
10992 9762 : NewSym (&newstr);
10993 9762 : InitConstString (tok, newstr, name, name, SymbolTable_cnulstr, true, known);
10994 9762 : return newstr;
10995 : /* static analysis guarentees a RETURN statement will be used before here. */
10996 : __builtin_unreachable ();
10997 : }
10998 :
10999 :
11000 : /*
11001 : MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
11002 : If known is TRUE then name is assigned to the contents
11003 : however the escape sequences are not converted into characters.
11004 : */
11005 :
11006 34638 : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known)
11007 : {
11008 34638 : unsigned int newstr;
11009 :
11010 34638 : NewSym (&newstr);
11011 34638 : InitConstString (tok, newstr, name, name, SymbolTable_m2nulstr, false, known);
11012 34638 : return newstr;
11013 : /* static analysis guarentees a RETURN statement will be used before here. */
11014 : __builtin_unreachable ();
11015 : }
11016 :
11017 :
11018 : /*
11019 : PutConstStringKnown - if sym is a constvar then convert it into a conststring.
11020 : If known is FALSE then contents is ignored and NulName is
11021 : stored. If escape is TRUE then the contents will have
11022 : any escape sequences converted into single characters.
11023 : */
11024 :
11025 432085 : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known)
11026 : {
11027 432085 : SymbolTable_PtrToSymbol pSym;
11028 432085 : DynamicStrings_String s;
11029 :
11030 432085 : pSym = GetPsym (sym);
11031 432085 : switch (pSym->SymbolType)
11032 : {
11033 430802 : case SymbolTable_ConstStringSym:
11034 430802 : if (known)
11035 : {
11036 384639 : if (escape)
11037 : {
11038 9738 : s = FormatStrings_HandleEscape (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (contents)));
11039 9738 : contents = NameKey_makekey (DynamicStrings_string (s));
11040 9738 : s = DynamicStrings_KillString (s);
11041 : }
11042 384639 : pSym->ConstString.Length = NameKey_LengthKey (contents);
11043 384639 : pSym->ConstString.Contents = contents;
11044 : }
11045 : else
11046 : {
11047 46163 : pSym->ConstString.Length = 0;
11048 46163 : pSym->ConstString.Contents = NameKey_NulName;
11049 : }
11050 430802 : pSym->ConstString.Known = known;
11051 430802 : InitWhereDeclaredTok (tok, &pSym->ConstString.At);
11052 430802 : InitWhereFirstUsedTok (tok, &pSym->ConstString.At);
11053 430802 : break;
11054 :
11055 1283 : case SymbolTable_ConstVarSym:
11056 1283 : InitConstString (tok, sym, pSym->ConstVar.name, contents, SymbolTable_m2str, escape, known); /* Change a ConstVar to a ConstString copy name
11057 : and alter symboltype. */
11058 1283 : break;
11059 :
11060 :
11061 0 : default:
11062 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
11063 432085 : break;
11064 : }
11065 432085 : }
11066 :
11067 :
11068 : /*
11069 : CopyConstString - copies string contents from expr to des
11070 : and retain the kind of string.
11071 : */
11072 :
11073 1277 : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr)
11074 : {
11075 1277 : SymbolTable_PtrToSymbol pSym;
11076 :
11077 1277 : M2Debug_Assert (SymbolTable_IsConstStringKnown (expr));
11078 1277 : pSym = GetPsym (des);
11079 1277 : switch (pSym->SymbolType)
11080 : {
11081 1253 : case SymbolTable_ConstStringSym:
11082 1253 : InitConstString (tok, des, pSym->ConstString.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true);
11083 1253 : break;
11084 :
11085 24 : case SymbolTable_ConstVarSym:
11086 24 : InitConstString (tok, des, pSym->ConstVar.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true); /* Change a ConstVar to a ConstString copy name
11087 : and alter symboltype. */
11088 24 : break;
11089 :
11090 :
11091 0 : default:
11092 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
11093 1277 : break;
11094 : }
11095 1277 : }
11096 :
11097 :
11098 : /*
11099 : IsConstStringKnown - returns TRUE if sym is a const string
11100 : and the contents are known.
11101 : */
11102 :
11103 916580 : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym)
11104 : {
11105 916580 : SymbolTable_PtrToSymbol pSym;
11106 :
11107 916580 : pSym = GetPsym (sym);
11108 916580 : switch (pSym->SymbolType)
11109 : {
11110 916556 : case SymbolTable_ConstStringSym:
11111 916556 : return pSym->ConstString.Known;
11112 : break;
11113 :
11114 :
11115 : default:
11116 : return false;
11117 : break;
11118 : }
11119 : /* static analysis guarentees a RETURN statement will be used before here. */
11120 : __builtin_unreachable ();
11121 : }
11122 :
11123 :
11124 : /*
11125 : IsConstStringM2 - returns whether this conststring is a
11126 : Modula-2 string.
11127 : */
11128 :
11129 0 : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym)
11130 : {
11131 0 : return (GetConstStringKind (sym)) == SymbolTable_m2str;
11132 : /* static analysis guarentees a RETURN statement will be used before here. */
11133 : __builtin_unreachable ();
11134 : }
11135 :
11136 :
11137 : /*
11138 : IsConstStringC - returns whether this conststring is a C style string
11139 : which will have any escape translated.
11140 : */
11141 :
11142 0 : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym)
11143 : {
11144 0 : return (GetConstStringKind (sym)) == SymbolTable_cstr;
11145 : /* static analysis guarentees a RETURN statement will be used before here. */
11146 : __builtin_unreachable ();
11147 : }
11148 :
11149 :
11150 : /*
11151 : IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
11152 : contains a nul terminator.
11153 : */
11154 :
11155 286878 : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym)
11156 : {
11157 286878 : return (GetConstStringKind (sym)) == SymbolTable_m2nulstr;
11158 : /* static analysis guarentees a RETURN statement will be used before here. */
11159 : __builtin_unreachable ();
11160 : }
11161 :
11162 :
11163 : /*
11164 : IsConstStringCnul - returns whether this conststring is a C style string
11165 : which will have any escape translated and also contains
11166 : a nul terminator.
11167 : */
11168 :
11169 9398 : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym)
11170 : {
11171 9398 : return (GetConstStringKind (sym)) == SymbolTable_cnulstr;
11172 : /* static analysis guarentees a RETURN statement will be used before here. */
11173 : __builtin_unreachable ();
11174 : }
11175 :
11176 :
11177 : /*
11178 : MakeSubrange - makes a new symbol into a subrange type with
11179 : name SubrangeName.
11180 : */
11181 :
11182 231448 : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName)
11183 : {
11184 231448 : SymbolTable_PtrToSymbol pSym;
11185 231448 : unsigned int sym;
11186 231448 : unsigned int oaf;
11187 :
11188 231448 : tok = CheckTok (tok, (const char *) "subrange", 8);
11189 231448 : sym = HandleHiddenOrDeclare (tok, SubrangeName, &oaf);
11190 231448 : if (! (SymbolTable_IsError (sym)))
11191 : {
11192 231448 : pSym = GetPsym (sym);
11193 231448 : pSym->SymbolType = SymbolTable_SubrangeSym;
11194 231448 : pSym->Subrange.name = SubrangeName;
11195 231448 : pSym->Subrange.Low = SymbolTable_NulSym; /* Index to a symbol determining */
11196 : /* ConstExpression. */
11197 231448 : pSym->Subrange.High = SymbolTable_NulSym; /* Index to a symbol determining */
11198 : /* ConstExpression. */
11199 231448 : pSym->Subrange.Type = SymbolTable_NulSym; /* Index to a type. Determines */
11200 : /* the type of subrange. */
11201 231448 : pSym->Subrange.Align = SymbolTable_NulSym; /* The alignment of this type. */
11202 231448 : InitPacked (&pSym->Subrange.packedInfo); /* not packed and no equivalent */
11203 231448 : SymbolKey_InitTree (&pSym->Subrange.ConstLitTree); /* constants of this type. */
11204 231448 : pSym->Subrange.Size = M2ALU_InitValue (); /* Size determines the type size */
11205 231448 : pSym->Subrange.oafamily = oaf; /* The unbounded sym for this */
11206 231448 : pSym->Subrange.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11207 462896 : InitWhereDeclaredTok (tok, &pSym->Subrange.At); /* Declared here */
11208 : }
11209 231448 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11210 231448 : return sym;
11211 : /* static analysis guarentees a RETURN statement will be used before here. */
11212 : __builtin_unreachable ();
11213 : }
11214 :
11215 :
11216 : /*
11217 : MakeSet - makes a set Symbol with name, SetName.
11218 : */
11219 :
11220 66683 : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName)
11221 : {
11222 66683 : SymbolTable_PtrToSymbol pSym;
11223 66683 : unsigned int oaf;
11224 66683 : unsigned int sym;
11225 :
11226 66683 : tok = CheckTok (tok, (const char *) "set", 3);
11227 66683 : sym = HandleHiddenOrDeclare (tok, SetName, &oaf);
11228 66683 : if (! (SymbolTable_IsError (sym)))
11229 : {
11230 66683 : pSym = GetPsym (sym);
11231 66683 : pSym->SymbolType = SymbolTable_SetSym;
11232 66683 : pSym->Set.name = SetName; /* The name of the set. */
11233 66683 : pSym->Set.Type = SymbolTable_NulSym; /* Index to a subrange symbol. */
11234 66683 : pSym->Set.Size = M2ALU_InitValue (); /* Size of this set */
11235 66683 : InitPacked (&pSym->Set.packedInfo); /* not packed and no */
11236 : /* equivalent (yet). */
11237 66683 : pSym->Set.ispacked = false; /* Not yet known to be packed. */
11238 66683 : pSym->Set.SetInWord = true; /* Can the set be stored in a */
11239 : /* single word? */
11240 66683 : pSym->Set.SetArray = SymbolTable_NulSym; /* Set used for large sets. */
11241 66683 : pSym->Set.Align = SymbolTable_NulSym; /* Set used for large sets. */
11242 66683 : pSym->Set.oafamily = oaf; /* The unbounded sym for this */
11243 66683 : pSym->Set.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11244 133366 : InitWhereDeclaredTok (tok, &pSym->Set.At); /* Declared here */
11245 : }
11246 66683 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11247 66683 : return sym;
11248 : /* static analysis guarentees a RETURN statement will be used before here. */
11249 : __builtin_unreachable ();
11250 : }
11251 :
11252 :
11253 : /*
11254 : GetSetArray - return the set array for a large set.
11255 : */
11256 :
11257 1684015 : extern "C" unsigned int SymbolTable_GetSetArray (unsigned int sym)
11258 : {
11259 1684015 : SymbolTable_PtrToSymbol pSym;
11260 :
11261 1684015 : AssertInRange (sym);
11262 1684015 : pSym = GetPsym (sym);
11263 1684015 : switch (pSym->SymbolType)
11264 : {
11265 1684015 : case SymbolTable_SetSym:
11266 1684015 : return pSym->Set.SetArray;
11267 : break;
11268 :
11269 :
11270 : default:
11271 : return SymbolTable_NulSym;
11272 : break;
11273 : }
11274 : /* static analysis guarentees a RETURN statement will be used before here. */
11275 : __builtin_unreachable ();
11276 : }
11277 :
11278 :
11279 : /*
11280 : PutSetArray - places array into the setarray field.
11281 : */
11282 :
11283 62501 : extern "C" void SymbolTable_PutSetArray (unsigned int Sym, unsigned int array)
11284 : {
11285 62501 : SymbolTable_PtrToSymbol pSym;
11286 :
11287 62501 : pSym = GetPsym (Sym);
11288 62501 : switch (pSym->SymbolType)
11289 : {
11290 : case SymbolTable_ErrorSym:
11291 : break;
11292 :
11293 62501 : case SymbolTable_SetSym:
11294 62501 : pSym->Set.SetArray = array;
11295 62501 : break;
11296 :
11297 :
11298 0 : default:
11299 0 : M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
11300 62501 : break;
11301 : }
11302 62501 : }
11303 :
11304 :
11305 : /*
11306 : MakeSetArray - create an ARRAY simpletype OF BOOLEAN.
11307 : */
11308 :
11309 62501 : extern "C" unsigned int SymbolTable_MakeSetArray (unsigned int token, unsigned int subrangetype)
11310 : {
11311 62501 : unsigned int array;
11312 62501 : unsigned int subscript;
11313 :
11314 62501 : array = SymbolTable_MakeArray (token, SymbolTable_NulSym);
11315 62501 : SymbolTable_PutArray (array, M2System_Byte);
11316 62501 : subscript = SymbolTable_MakeSubscript ();
11317 62501 : SymbolTable_PutSubscript (subscript, subrangetype);
11318 62501 : SymbolTable_PutArraySubscript (array, subscript);
11319 62501 : return array;
11320 : /* static analysis guarentees a RETURN statement will be used before here. */
11321 : __builtin_unreachable ();
11322 : }
11323 :
11324 :
11325 : /*
11326 : PutSetInWord - set the SetInWord boolean to value.
11327 : */
11328 :
11329 67302 : extern "C" void SymbolTable_PutSetInWord (unsigned int sym, bool value)
11330 : {
11331 67302 : SymbolTable_PtrToSymbol pSym;
11332 :
11333 67302 : AssertInRange (sym);
11334 67302 : pSym = GetPsym (sym);
11335 67302 : switch (pSym->SymbolType)
11336 : {
11337 67302 : case SymbolTable_SetSym:
11338 67302 : pSym->Set.SetInWord = value;
11339 67302 : if (value)
11340 : {
11341 65744 : pSym->Set.Align = SymbolTable_MakeConstant (SymbolTable_GetDeclaredMod (sym), 0);
11342 65744 : pSym->Set.ispacked = true;
11343 : }
11344 67302 : break;
11345 :
11346 :
11347 0 : default:
11348 0 : M2Error_InternalError ((const char *) "expecting a set symbol", 22);
11349 67302 : break;
11350 : }
11351 67302 : }
11352 :
11353 :
11354 : /*
11355 : GetSetInWord - return SetInWord.
11356 : */
11357 :
11358 20410 : extern "C" bool SymbolTable_GetSetInWord (unsigned int sym)
11359 : {
11360 20410 : SymbolTable_PtrToSymbol pSym;
11361 :
11362 20410 : AssertInRange (sym);
11363 20410 : pSym = GetPsym (sym);
11364 20410 : switch (pSym->SymbolType)
11365 : {
11366 20410 : case SymbolTable_SetSym:
11367 20410 : return pSym->Set.SetInWord;
11368 0 : break;
11369 :
11370 :
11371 0 : default:
11372 0 : M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
11373 : break;
11374 : }
11375 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11376 : __builtin_unreachable ();
11377 : }
11378 :
11379 :
11380 : /*
11381 : MakeArray - makes an Array symbol with name ArrayName.
11382 : */
11383 :
11384 167807 : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName)
11385 : {
11386 167807 : SymbolTable_PtrToSymbol pSym;
11387 167807 : unsigned int sym;
11388 167807 : unsigned int oaf;
11389 :
11390 167807 : sym = HandleHiddenOrDeclare (tok, ArrayName, &oaf);
11391 167807 : if (! (SymbolTable_IsError (sym)))
11392 : {
11393 167807 : pSym = GetPsym (sym);
11394 167807 : pSym->SymbolType = SymbolTable_ArraySym;
11395 167807 : pSym->Array.name = ArrayName;
11396 167807 : pSym->Array.Subscript = SymbolTable_NulSym; /* Contains the array subscripts. */
11397 167807 : pSym->Array.Size = M2ALU_InitValue (); /* Size of array. */
11398 167807 : pSym->Array.Offset = M2ALU_InitValue (); /* Offset of array. */
11399 167807 : pSym->Array.Type = SymbolTable_NulSym; /* The Array Type. ARRAY OF Type. */
11400 167807 : pSym->Array.Align = SymbolTable_NulSym; /* Alignment of this type. */
11401 167807 : pSym->Array.Large = false; /* is this array large? */
11402 167807 : pSym->Array.oafamily = oaf; /* The unbounded for this array */
11403 167807 : pSym->Array.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11404 335614 : InitWhereDeclaredTok (tok, &pSym->Array.At); /* Declared here */
11405 : }
11406 167807 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11407 167807 : return sym;
11408 : /* static analysis guarentees a RETURN statement will be used before here. */
11409 : __builtin_unreachable ();
11410 : }
11411 :
11412 :
11413 : /*
11414 : PutArrayLarge - indicates that this is a large array in which case
11415 : the interface to gcc maps this array from 0..high-low,
11416 : using an integer indice.
11417 : */
11418 :
11419 24 : extern "C" void SymbolTable_PutArrayLarge (unsigned int array)
11420 : {
11421 24 : SymbolTable_PtrToSymbol pSym;
11422 :
11423 24 : if (! (SymbolTable_IsError (array)))
11424 : {
11425 24 : M2Debug_Assert (SymbolTable_IsArray (array));
11426 24 : pSym = GetPsym (array);
11427 24 : pSym->Array.Large = true;
11428 : }
11429 24 : }
11430 :
11431 :
11432 : /*
11433 : IsArrayLarge - returns TRUE if we need to treat this as a large array.
11434 : */
11435 :
11436 47374 : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array)
11437 : {
11438 47374 : SymbolTable_PtrToSymbol pSym;
11439 :
11440 47374 : M2Debug_Assert (SymbolTable_IsArray (array));
11441 47374 : pSym = GetPsym (array);
11442 47374 : return pSym->Array.Large;
11443 : /* static analysis guarentees a RETURN statement will be used before here. */
11444 : __builtin_unreachable ();
11445 : }
11446 :
11447 :
11448 : /*
11449 : PutPriority - places a interrupt, priority, value into module, module.
11450 : */
11451 :
11452 38 : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority)
11453 : {
11454 38 : SymbolTable_PtrToSymbol pSym;
11455 :
11456 38 : M2Debug_Assert (module != SymbolTable_NulSym);
11457 38 : pSym = GetPsym (module);
11458 38 : switch (pSym->SymbolType)
11459 : {
11460 14 : case SymbolTable_DefImpSym:
11461 14 : pSym->DefImp.Priority = priority;
11462 14 : break;
11463 :
11464 24 : case SymbolTable_ModuleSym:
11465 24 : pSym->Module.Priority = priority;
11466 24 : break;
11467 :
11468 :
11469 0 : default:
11470 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
11471 38 : break;
11472 : }
11473 38 : }
11474 :
11475 :
11476 : /*
11477 : GetPriority - returns the interrupt priority which was assigned to
11478 : module, module.
11479 : */
11480 :
11481 468337 : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module)
11482 : {
11483 468337 : SymbolTable_PtrToSymbol pSym;
11484 :
11485 468337 : M2Debug_Assert (module != SymbolTable_NulSym);
11486 468337 : pSym = GetPsym (module);
11487 468337 : switch (pSym->SymbolType)
11488 : {
11489 330130 : case SymbolTable_DefImpSym:
11490 330130 : return pSym->DefImp.Priority;
11491 138207 : break;
11492 :
11493 138207 : case SymbolTable_ModuleSym:
11494 138207 : return pSym->Module.Priority;
11495 0 : break;
11496 :
11497 :
11498 0 : default:
11499 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
11500 : break;
11501 : }
11502 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11503 : __builtin_unreachable ();
11504 : }
11505 :
11506 :
11507 : /*
11508 : PutNeedSavePriority - set a boolean flag indicating that this procedure
11509 : needs to save and restore interrupts.
11510 : */
11511 :
11512 162 : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym)
11513 : {
11514 162 : SymbolTable_PtrToSymbol pSym;
11515 :
11516 162 : pSym = GetPsym (sym);
11517 162 : switch (pSym->SymbolType)
11518 : {
11519 162 : case SymbolTable_ProcedureSym:
11520 162 : pSym->Procedure.SavePriority = true;
11521 162 : break;
11522 :
11523 :
11524 0 : default:
11525 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
11526 162 : break;
11527 : }
11528 162 : }
11529 :
11530 :
11531 : /*
11532 : GetNeedSavePriority - returns the boolean flag indicating whether this procedure
11533 : needs to save and restore interrupts.
11534 : */
11535 :
11536 680 : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym)
11537 : {
11538 680 : SymbolTable_PtrToSymbol pSym;
11539 :
11540 680 : pSym = GetPsym (sym);
11541 680 : switch (pSym->SymbolType)
11542 : {
11543 680 : case SymbolTable_ProcedureSym:
11544 680 : return pSym->Procedure.SavePriority;
11545 0 : break;
11546 :
11547 :
11548 0 : default:
11549 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
11550 : break;
11551 : }
11552 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11553 : __builtin_unreachable ();
11554 : }
11555 :
11556 :
11557 : /*
11558 : PutVariableAtAddress - determines that a variable, sym, is declared at
11559 : a specific address.
11560 : */
11561 :
11562 108 : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address)
11563 : {
11564 108 : SymbolTable_PtrToSymbol pSym;
11565 :
11566 108 : M2Debug_Assert (sym != SymbolTable_NulSym);
11567 108 : pSym = GetPsym (sym);
11568 108 : switch (pSym->SymbolType)
11569 : {
11570 108 : case SymbolTable_VarSym:
11571 108 : pSym->Var.AtAddress = true;
11572 108 : pSym->Var.Address = address;
11573 108 : break;
11574 :
11575 :
11576 0 : default:
11577 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11578 108 : break;
11579 : }
11580 108 : }
11581 :
11582 :
11583 : /*
11584 : GetVariableAtAddress - returns the address at which variable, sym, is declared.
11585 : */
11586 :
11587 54 : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym)
11588 : {
11589 54 : SymbolTable_PtrToSymbol pSym;
11590 :
11591 54 : M2Debug_Assert (sym != SymbolTable_NulSym);
11592 54 : pSym = GetPsym (sym);
11593 54 : switch (pSym->SymbolType)
11594 : {
11595 54 : case SymbolTable_VarSym:
11596 54 : return pSym->Var.Address;
11597 0 : break;
11598 :
11599 :
11600 0 : default:
11601 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11602 : break;
11603 : }
11604 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11605 : __builtin_unreachable ();
11606 : }
11607 :
11608 :
11609 : /*
11610 : IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
11611 : a specific address.
11612 : */
11613 :
11614 344536 : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym)
11615 : {
11616 344536 : SymbolTable_PtrToSymbol pSym;
11617 :
11618 344536 : M2Debug_Assert (sym != SymbolTable_NulSym);
11619 344536 : pSym = GetPsym (sym);
11620 344536 : switch (pSym->SymbolType)
11621 : {
11622 344536 : case SymbolTable_VarSym:
11623 344536 : return pSym->Var.AtAddress;
11624 0 : break;
11625 :
11626 :
11627 0 : default:
11628 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11629 : break;
11630 : }
11631 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11632 : __builtin_unreachable ();
11633 : }
11634 :
11635 :
11636 : /*
11637 : PutVariableSSA - assigns value to the SSA field within variable sym.
11638 : */
11639 :
11640 0 : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value)
11641 : {
11642 0 : SymbolTable_PtrToSymbol pSym;
11643 :
11644 0 : M2Debug_Assert (sym != SymbolTable_NulSym);
11645 0 : pSym = GetPsym (sym);
11646 0 : switch (pSym->SymbolType)
11647 : {
11648 0 : case SymbolTable_VarSym:
11649 0 : pSym->Var.IsSSA = value;
11650 0 : break;
11651 :
11652 :
11653 0 : default:
11654 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11655 0 : break;
11656 : }
11657 0 : }
11658 :
11659 :
11660 : /*
11661 : IsVariableSSA - returns TRUE if variable is known to be a SSA.
11662 : */
11663 :
11664 195541 : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym)
11665 : {
11666 195541 : SymbolTable_PtrToSymbol pSym;
11667 :
11668 195541 : M2Debug_Assert (sym != SymbolTable_NulSym);
11669 195541 : pSym = GetPsym (sym);
11670 195541 : switch (pSym->SymbolType)
11671 : {
11672 195541 : case SymbolTable_VarSym:
11673 195541 : return pSym->Var.IsSSA;
11674 : break;
11675 :
11676 :
11677 : default:
11678 : return false;
11679 : break;
11680 : }
11681 : /* static analysis guarentees a RETURN statement will be used before here. */
11682 : __builtin_unreachable ();
11683 : }
11684 :
11685 :
11686 : /*
11687 : PutVarConst - sets the IsConst field to value indicating the variable is read only.
11688 : */
11689 :
11690 193563 : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value)
11691 : {
11692 193563 : SymbolTable_PtrToSymbol pSym;
11693 :
11694 193563 : if (SymbolTable_IsVar (sym))
11695 : {
11696 193563 : pSym = GetPsym (sym);
11697 193563 : pSym->Var.IsConst = value;
11698 : }
11699 193563 : }
11700 :
11701 :
11702 : /*
11703 : MakeGnuAsm - create a GnuAsm symbol.
11704 : */
11705 :
11706 27 : extern "C" unsigned int SymbolTable_MakeGnuAsm (void)
11707 : {
11708 27 : SymbolTable_PtrToSymbol pSym;
11709 27 : unsigned int Sym;
11710 :
11711 27 : NewSym (&Sym);
11712 27 : pSym = GetPsym (Sym);
11713 27 : pSym->SymbolType = SymbolTable_GnuAsmSym;
11714 27 : pSym->GnuAsm.String = SymbolTable_NulSym;
11715 27 : InitWhereDeclared (&pSym->GnuAsm.At);
11716 27 : pSym->GnuAsm.Inputs = SymbolTable_NulSym;
11717 27 : pSym->GnuAsm.Outputs = SymbolTable_NulSym;
11718 27 : pSym->GnuAsm.Trashed = SymbolTable_NulSym;
11719 27 : pSym->GnuAsm.Volatile = false;
11720 27 : pSym->GnuAsm.Simple = false;
11721 27 : return Sym;
11722 : /* static analysis guarentees a RETURN statement will be used before here. */
11723 : __builtin_unreachable ();
11724 : }
11725 :
11726 :
11727 : /*
11728 : PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
11729 : */
11730 :
11731 27 : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string)
11732 : {
11733 27 : SymbolTable_PtrToSymbol pSym;
11734 :
11735 27 : M2Debug_Assert (SymbolTable_IsConstString (string));
11736 27 : pSym = GetPsym (sym);
11737 27 : switch (pSym->SymbolType)
11738 : {
11739 27 : case SymbolTable_GnuAsmSym:
11740 27 : pSym->GnuAsm.String = string;
11741 27 : break;
11742 :
11743 :
11744 0 : default:
11745 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11746 27 : break;
11747 : }
11748 27 : }
11749 :
11750 :
11751 : /*
11752 : PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
11753 : */
11754 :
11755 21 : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out)
11756 : {
11757 21 : SymbolTable_PtrToSymbol pSym;
11758 :
11759 21 : pSym = GetPsym (sym);
11760 21 : switch (pSym->SymbolType)
11761 : {
11762 21 : case SymbolTable_GnuAsmSym:
11763 21 : pSym->GnuAsm.Outputs = out;
11764 21 : break;
11765 :
11766 :
11767 0 : default:
11768 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11769 21 : break;
11770 : }
11771 21 : }
11772 :
11773 :
11774 : /*
11775 : PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
11776 : */
11777 :
11778 15 : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in)
11779 : {
11780 15 : SymbolTable_PtrToSymbol pSym;
11781 :
11782 15 : pSym = GetPsym (sym);
11783 15 : switch (pSym->SymbolType)
11784 : {
11785 15 : case SymbolTable_GnuAsmSym:
11786 15 : pSym->GnuAsm.Inputs = in;
11787 15 : break;
11788 :
11789 :
11790 0 : default:
11791 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11792 15 : break;
11793 : }
11794 15 : }
11795 :
11796 :
11797 : /*
11798 : PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
11799 : */
11800 :
11801 9 : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash)
11802 : {
11803 9 : SymbolTable_PtrToSymbol pSym;
11804 :
11805 9 : pSym = GetPsym (sym);
11806 9 : switch (pSym->SymbolType)
11807 : {
11808 9 : case SymbolTable_GnuAsmSym:
11809 9 : pSym->GnuAsm.Trashed = trash;
11810 9 : break;
11811 :
11812 :
11813 0 : default:
11814 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11815 9 : break;
11816 : }
11817 9 : }
11818 :
11819 :
11820 : /*
11821 : GetGnuAsm - returns the string symbol, representing the instruction textual
11822 : of the GnuAsm symbol. It will return a ConstString.
11823 : */
11824 :
11825 27 : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym)
11826 : {
11827 27 : SymbolTable_PtrToSymbol pSym;
11828 :
11829 27 : pSym = GetPsym (sym);
11830 27 : switch (pSym->SymbolType)
11831 : {
11832 27 : case SymbolTable_GnuAsmSym:
11833 27 : return pSym->GnuAsm.String;
11834 0 : break;
11835 :
11836 :
11837 0 : default:
11838 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11839 : break;
11840 : }
11841 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11842 : __builtin_unreachable ();
11843 : }
11844 :
11845 :
11846 : /*
11847 : GetGnuAsmInput - returns the input list of registers.
11848 : */
11849 :
11850 27 : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym)
11851 : {
11852 27 : SymbolTable_PtrToSymbol pSym;
11853 :
11854 27 : pSym = GetPsym (sym);
11855 27 : switch (pSym->SymbolType)
11856 : {
11857 27 : case SymbolTable_GnuAsmSym:
11858 27 : return pSym->GnuAsm.Inputs;
11859 0 : break;
11860 :
11861 :
11862 0 : default:
11863 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11864 : break;
11865 : }
11866 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11867 : __builtin_unreachable ();
11868 : }
11869 :
11870 :
11871 : /*
11872 : GetGnuAsmOutput - returns the output list of registers.
11873 : */
11874 :
11875 27 : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym)
11876 : {
11877 27 : SymbolTable_PtrToSymbol pSym;
11878 :
11879 27 : pSym = GetPsym (sym);
11880 27 : switch (pSym->SymbolType)
11881 : {
11882 27 : case SymbolTable_GnuAsmSym:
11883 27 : return pSym->GnuAsm.Outputs;
11884 0 : break;
11885 :
11886 :
11887 0 : default:
11888 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11889 : break;
11890 : }
11891 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11892 : __builtin_unreachable ();
11893 : }
11894 :
11895 :
11896 : /*
11897 : GetGnuAsmTrash - returns the list of trashed registers.
11898 : */
11899 :
11900 27 : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym)
11901 : {
11902 27 : SymbolTable_PtrToSymbol pSym;
11903 :
11904 27 : pSym = GetPsym (sym);
11905 27 : switch (pSym->SymbolType)
11906 : {
11907 27 : case SymbolTable_GnuAsmSym:
11908 27 : return pSym->GnuAsm.Trashed;
11909 0 : break;
11910 :
11911 :
11912 0 : default:
11913 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11914 : break;
11915 : }
11916 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11917 : __builtin_unreachable ();
11918 : }
11919 :
11920 :
11921 : /*
11922 : PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
11923 : */
11924 :
11925 15 : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym)
11926 : {
11927 15 : SymbolTable_PtrToSymbol pSym;
11928 :
11929 15 : pSym = GetPsym (Sym);
11930 15 : switch (pSym->SymbolType)
11931 : {
11932 15 : case SymbolTable_GnuAsmSym:
11933 15 : pSym->GnuAsm.Volatile = true;
11934 15 : break;
11935 :
11936 :
11937 0 : default:
11938 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11939 15 : break;
11940 : }
11941 15 : }
11942 :
11943 :
11944 : /*
11945 : PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
11946 : */
11947 :
11948 6 : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym)
11949 : {
11950 6 : SymbolTable_PtrToSymbol pSym;
11951 :
11952 6 : pSym = GetPsym (Sym);
11953 6 : switch (pSym->SymbolType)
11954 : {
11955 6 : case SymbolTable_GnuAsmSym:
11956 6 : pSym->GnuAsm.Simple = true;
11957 6 : break;
11958 :
11959 :
11960 0 : default:
11961 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11962 6 : break;
11963 : }
11964 6 : }
11965 :
11966 :
11967 : /*
11968 : MakeRegInterface - creates and returns a register interface symbol.
11969 : */
11970 :
11971 33 : extern "C" unsigned int SymbolTable_MakeRegInterface (void)
11972 : {
11973 33 : SymbolTable_PtrToSymbol pSym;
11974 33 : unsigned int Sym;
11975 :
11976 33 : NewSym (&Sym);
11977 33 : pSym = GetPsym (Sym);
11978 33 : pSym->SymbolType = SymbolTable_InterfaceSym;
11979 33 : pSym->Interface.Parameters = Indexing_InitIndex (1);
11980 33 : InitWhereDeclared (&pSym->Interface.At);
11981 33 : return Sym;
11982 : /* static analysis guarentees a RETURN statement will be used before here. */
11983 : __builtin_unreachable ();
11984 : }
11985 :
11986 :
11987 : /*
11988 : PutRegInterface - places a, name, string, and, object, into the interface array,
11989 : sym, at position, i.
11990 : The string symbol will either be a register name or a constraint.
11991 : The object is an optional Modula-2 variable or constant symbol.
11992 : read and write are the quadruple numbers representing any read
11993 : or write operation.
11994 : */
11995 :
11996 36 : extern "C" void SymbolTable_PutRegInterface (unsigned int tok, unsigned int sym, unsigned int i, NameKey_Name n, unsigned int string, unsigned int object, unsigned int read_, unsigned int write_)
11997 : {
11998 36 : SymbolTable_PtrToSymbol pSym;
11999 36 : SymbolTable_PtrToAsmConstraint p;
12000 :
12001 36 : pSym = GetPsym (sym);
12002 36 : switch (pSym->SymbolType)
12003 : {
12004 36 : case SymbolTable_InterfaceSym:
12005 36 : if (Indexing_InBounds (pSym->Interface.Parameters, i))
12006 : {
12007 0 : p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
12008 : }
12009 36 : else if (i == ((Indexing_HighIndice (pSym->Interface.Parameters))+1))
12010 : {
12011 : /* avoid dangling else. */
12012 36 : Storage_ALLOCATE ((void **) &p, sizeof (SymbolTable__T5));
12013 36 : Indexing_PutIndice (pSym->Interface.Parameters, i, reinterpret_cast <void *> (p));
12014 : }
12015 : else
12016 : {
12017 : /* avoid dangling else. */
12018 0 : M2Error_InternalError ((const char *) "expecting to add parameters sequentially", 40);
12019 : }
12020 36 : p->tokpos = tok;
12021 36 : p->name = n;
12022 36 : p->str = string;
12023 36 : p->obj = object;
12024 36 : PutFirstUsed (object, tok, read_, write_);
12025 36 : break;
12026 :
12027 :
12028 0 : default:
12029 0 : M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
12030 36 : break;
12031 : }
12032 36 : }
12033 :
12034 :
12035 : /*
12036 : GetRegInterface - gets a, name, string, and, object, from the interface array,
12037 : sym, from position, i.
12038 : */
12039 :
12040 69 : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object)
12041 : {
12042 69 : SymbolTable_PtrToSymbol pSym;
12043 69 : SymbolTable_PtrToAsmConstraint p;
12044 :
12045 69 : pSym = GetPsym (sym);
12046 69 : switch (pSym->SymbolType)
12047 : {
12048 69 : case SymbolTable_InterfaceSym:
12049 69 : if (Indexing_InBounds (pSym->Interface.Parameters, i))
12050 : {
12051 36 : p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
12052 36 : (*tok) = p->tokpos;
12053 36 : (*n) = p->name;
12054 36 : (*string) = p->str;
12055 36 : (*object) = p->obj;
12056 : }
12057 : else
12058 : {
12059 33 : (*tok) = M2LexBuf_UnknownTokenNo;
12060 33 : (*n) = NameKey_NulName;
12061 33 : (*string) = SymbolTable_NulSym;
12062 33 : (*object) = SymbolTable_NulSym;
12063 : }
12064 69 : break;
12065 :
12066 :
12067 0 : default:
12068 0 : M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
12069 69 : break;
12070 : }
12071 69 : }
12072 :
12073 :
12074 : /*
12075 : GetModule - Returns the Module symbol for the module with name, name.
12076 : */
12077 :
12078 413786 : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name)
12079 : {
12080 413786 : return static_cast<unsigned int> (SymbolKey_GetSymKey (ModuleTree, name));
12081 : /* static analysis guarentees a RETURN statement will be used before here. */
12082 : __builtin_unreachable ();
12083 : }
12084 :
12085 :
12086 : /*
12087 : GetCurrentModule - returns the current module Sym that is being
12088 : compiled.
12089 : */
12090 :
12091 60671317 : extern "C" unsigned int SymbolTable_GetCurrentModule (void)
12092 : {
12093 60671317 : return CurrentModule;
12094 : /* static analysis guarentees a RETURN statement will be used before here. */
12095 : __builtin_unreachable ();
12096 : }
12097 :
12098 :
12099 : /*
12100 : GetFileModule - returns the FileModule symbol that was requested by
12101 : the user to be compiled.
12102 : */
12103 :
12104 285324 : extern "C" unsigned int SymbolTable_GetFileModule (void)
12105 : {
12106 285324 : return FileModule;
12107 : /* static analysis guarentees a RETURN statement will be used before here. */
12108 : __builtin_unreachable ();
12109 : }
12110 :
12111 :
12112 : /*
12113 : GetBaseModule - returns the base module symbol that contains Modula-2
12114 : base types, procedures and functions.
12115 : */
12116 :
12117 9129465 : extern "C" unsigned int SymbolTable_GetBaseModule (void)
12118 : {
12119 9129465 : return BaseModule;
12120 : /* static analysis guarentees a RETURN statement will be used before here. */
12121 : __builtin_unreachable ();
12122 : }
12123 :
12124 :
12125 : /*
12126 : GetMainModule - returns the main module symbol that was requested by
12127 : the user to be compiled.
12128 : */
12129 :
12130 20513236 : extern "C" unsigned int SymbolTable_GetMainModule (void)
12131 : {
12132 20513236 : return MainModule;
12133 : /* static analysis guarentees a RETURN statement will be used before here. */
12134 : __builtin_unreachable ();
12135 : }
12136 :
12137 :
12138 : /*
12139 : GetCurrentModuleScope - returns the module symbol which forms the
12140 : current (possibly inner most) module.
12141 : */
12142 :
12143 2331026 : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void)
12144 : {
12145 2331026 : SymbolTable_PtrToCallFrame pCall;
12146 2331026 : unsigned int i;
12147 :
12148 2331026 : i = ScopePtr;
12149 2331026 : pCall = GetPcall (i);
12150 5453317 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
12151 : {
12152 791265 : M2Debug_Assert (i > 0);
12153 791265 : i -= 1;
12154 791265 : pCall = GetPcall (i);
12155 : }
12156 2331026 : return pCall->Search;
12157 : /* static analysis guarentees a RETURN statement will be used before here. */
12158 : __builtin_unreachable ();
12159 : }
12160 :
12161 :
12162 : /*
12163 : GetLastModuleScope - returns the last module scope encountered,
12164 : the module scope before the Current Module Scope.
12165 : */
12166 :
12167 0 : extern "C" unsigned int SymbolTable_GetLastModuleScope (void)
12168 : {
12169 0 : SymbolTable_PtrToCallFrame pCall;
12170 0 : unsigned int i;
12171 :
12172 0 : i = ScopePtr;
12173 0 : pCall = GetPcall (i);
12174 0 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
12175 : {
12176 0 : M2Debug_Assert (i > 0);
12177 0 : i -= 1;
12178 0 : pCall = GetPcall (i);
12179 : }
12180 : /* Found module at position, i. */
12181 0 : i -= 1; /* Move to an outer level module scope */
12182 0 : pCall = GetPcall (i); /* Move to an outer level module scope */
12183 0 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
12184 : {
12185 0 : M2Debug_Assert (i > 0);
12186 0 : i -= 1;
12187 0 : pCall = GetPcall (i);
12188 : }
12189 : /* Found module at position, i. */
12190 0 : return pCall->Search;
12191 : /* static analysis guarentees a RETURN statement will be used before here. */
12192 : __builtin_unreachable ();
12193 : }
12194 :
12195 :
12196 : /*
12197 : AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
12198 : ModSym.
12199 : */
12200 :
12201 1029413 : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym)
12202 : {
12203 1029413 : SymbolTable_PtrToSymbol pSym;
12204 :
12205 1029413 : pSym = GetPsym (ModSym);
12206 1029413 : switch (pSym->SymbolType)
12207 : {
12208 908441 : case SymbolTable_DefImpSym:
12209 908441 : if ((SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
12210 : {
12211 908441 : SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
12212 : }
12213 0 : else if (! (IsExternalModule (Sym)))
12214 : {
12215 : /* avoid dangling else. */
12216 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
12217 : }
12218 : break;
12219 :
12220 120912 : case SymbolTable_ModuleSym:
12221 120912 : if ((SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
12222 : {
12223 120900 : SymbolKey_PutSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
12224 : }
12225 12 : else if (! (IsExternalModule (Sym)))
12226 : {
12227 : /* avoid dangling else. */
12228 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
12229 : }
12230 : break;
12231 :
12232 60 : case SymbolTable_ProcedureSym:
12233 60 : if ((SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
12234 : {
12235 60 : SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
12236 : }
12237 0 : else if (! (IsExternalModule (Sym)))
12238 : {
12239 : /* avoid dangling else. */
12240 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
12241 : }
12242 : break;
12243 :
12244 :
12245 0 : default:
12246 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
12247 1029413 : break;
12248 : }
12249 1029413 : }
12250 :
12251 :
12252 : /*
12253 : GetType - Returns the symbol that is the TYPE symbol to Sym.
12254 : If zero is returned then we assume type unknown.
12255 : */
12256 :
12257 757825020 : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym)
12258 : {
12259 757825020 : SymbolTable_PtrToSymbol pSym;
12260 757825020 : unsigned int type;
12261 :
12262 757825020 : M2Debug_Assert (Sym != SymbolTable_NulSym);
12263 757825014 : pSym = GetPsym (Sym);
12264 757825014 : switch (pSym->SymbolType)
12265 : {
12266 0 : case SymbolTable_OAFamilySym:
12267 0 : type = pSym->OAFamily.SimpleType;
12268 0 : break;
12269 :
12270 91294276 : case SymbolTable_VarSym:
12271 91294276 : type = GetTypeOfVar (Sym);
12272 91294276 : break;
12273 :
12274 22557131 : case SymbolTable_ConstLitSym:
12275 22557131 : type = pSym->ConstLit.Type;
12276 22557131 : break;
12277 :
12278 22115358 : case SymbolTable_ConstVarSym:
12279 22115358 : type = pSym->ConstVar.Type;
12280 22115358 : break;
12281 :
12282 5911498 : case SymbolTable_ConstStringSym:
12283 5911498 : if (pSym->ConstString.Length == 1)
12284 : {
12285 1035277 : type = M2Base_Char;
12286 : }
12287 : else
12288 : {
12289 : type = SymbolTable_NulSym; /* No type for a string */
12290 : }
12291 : break;
12292 :
12293 111846679 : case SymbolTable_TypeSym:
12294 111846679 : type = pSym->Type.Type;
12295 111846679 : break;
12296 :
12297 247950000 : case SymbolTable_RecordFieldSym:
12298 247950000 : type = pSym->RecordField.Type;
12299 247950000 : break;
12300 :
12301 : case SymbolTable_RecordSym:
12302 : type = SymbolTable_NulSym; /* No type for a record */
12303 : break;
12304 :
12305 : case SymbolTable_VarientSym:
12306 : type = SymbolTable_NulSym; /* No type for a record */
12307 : break;
12308 :
12309 45705794 : case SymbolTable_EnumerationFieldSym:
12310 45705794 : type = pSym->EnumerationField.Type; /* No type for a record */
12311 45705794 : break;
12312 :
12313 : case SymbolTable_EnumerationSym:
12314 : type = SymbolTable_NulSym; /* No type for enumeration */
12315 : break;
12316 :
12317 105608704 : case SymbolTable_PointerSym:
12318 105608704 : type = pSym->Pointer.Type; /* No type for enumeration */
12319 105608704 : break;
12320 :
12321 18303130 : case SymbolTable_ProcedureSym:
12322 18303130 : type = pSym->Procedure.ReturnType;
12323 18303130 : break;
12324 :
12325 5335092 : case SymbolTable_ProcTypeSym:
12326 5335092 : type = pSym->ProcType.ReturnType;
12327 5335092 : break;
12328 :
12329 21511705 : case SymbolTable_ParamSym:
12330 21511705 : type = pSym->Param.Type;
12331 21511705 : break;
12332 :
12333 3520907 : case SymbolTable_VarParamSym:
12334 3520907 : type = pSym->VarParam.Type;
12335 3520907 : break;
12336 :
12337 12340837 : case SymbolTable_SubrangeSym:
12338 12340837 : type = pSym->Subrange.Type;
12339 12340837 : break;
12340 :
12341 5536814 : case SymbolTable_ArraySym:
12342 5536814 : type = pSym->Array.Type;
12343 5536814 : break;
12344 :
12345 5543920 : case SymbolTable_SubscriptSym:
12346 5543920 : type = pSym->Subscript.Type;
12347 5543920 : break;
12348 :
12349 577878 : case SymbolTable_SetSym:
12350 577878 : type = pSym->Set.Type;
12351 577878 : break;
12352 :
12353 29871297 : case SymbolTable_UnboundedSym:
12354 29871297 : type = pSym->Unbounded.Type;
12355 29871297 : break;
12356 :
12357 : case SymbolTable_UndefinedSym:
12358 : type = SymbolTable_NulSym;
12359 : break;
12360 :
12361 0 : case SymbolTable_PartialUnboundedSym:
12362 0 : type = pSym->PartialUnbounded.Type;
12363 0 : break;
12364 :
12365 : case SymbolTable_ObjectSym:
12366 : type = SymbolTable_NulSym;
12367 : break;
12368 :
12369 :
12370 0 : default:
12371 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
12372 757825014 : break;
12373 : }
12374 757825014 : return type;
12375 : /* static analysis guarentees a RETURN statement will be used before here. */
12376 : __builtin_unreachable ();
12377 : }
12378 :
12379 :
12380 : /*
12381 : SkipType - if sym is a TYPE foo = bar
12382 : then call SkipType(bar)
12383 : else return sym
12384 :
12385 : it does not skip over hidden types.
12386 : */
12387 :
12388 59577634 : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym)
12389 : {
12390 59845360 : if ((((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
12391 : {
12392 267726 : return SymbolTable_SkipType (SymbolTable_GetType (Sym));
12393 : }
12394 : else
12395 : {
12396 59577634 : return Sym;
12397 : }
12398 : /* static analysis guarentees a RETURN statement will be used before here. */
12399 : __builtin_unreachable ();
12400 : }
12401 :
12402 :
12403 : /*
12404 : SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
12405 : sym is declared as a subrange of bar
12406 : then call SkipTypeAndSubrange(bar)
12407 : else return sym
12408 :
12409 : it does not skip over hidden types.
12410 : */
12411 :
12412 4301 : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym)
12413 : {
12414 4349 : if ((((Sym != SymbolTable_NulSym) && ((SymbolTable_IsType (Sym)) || (SymbolTable_IsSubrange (Sym)))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
12415 : {
12416 48 : return SymbolTable_SkipTypeAndSubrange (SymbolTable_GetType (Sym));
12417 : }
12418 : else
12419 : {
12420 4301 : return Sym;
12421 : }
12422 : /* static analysis guarentees a RETURN statement will be used before here. */
12423 : __builtin_unreachable ();
12424 : }
12425 :
12426 :
12427 : /*
12428 : GetLowestType - Returns the lowest type in the type chain of
12429 : symbol Sym.
12430 : If NulSym is returned then we assume type unknown or
12431 : you have reqested the type of a base type.
12432 : */
12433 :
12434 1509982 : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym)
12435 : {
12436 2568525 : SymbolTable_PtrToSymbol pSym;
12437 2568525 : unsigned int type;
12438 :
12439 2568525 : M2Debug_Assert (Sym != SymbolTable_NulSym);
12440 2568525 : pSym = GetPsym (Sym);
12441 2568525 : switch (pSym->SymbolType)
12442 : {
12443 464588 : case SymbolTable_VarSym:
12444 464588 : type = pSym->Var.Type;
12445 464588 : break;
12446 :
12447 282691 : case SymbolTable_ConstLitSym:
12448 282691 : type = pSym->ConstLit.Type;
12449 282691 : break;
12450 :
12451 392988 : case SymbolTable_ConstVarSym:
12452 392988 : type = pSym->ConstVar.Type;
12453 392988 : break;
12454 :
12455 : case SymbolTable_ConstStringSym:
12456 : type = SymbolTable_NulSym; /* No type for a string */
12457 : break;
12458 :
12459 1082372 : case SymbolTable_TypeSym:
12460 1082372 : type = pSym->Type.Type; /* No type for a string */
12461 1082372 : break;
12462 :
12463 0 : case SymbolTable_RecordFieldSym:
12464 0 : type = pSym->RecordField.Type;
12465 0 : break;
12466 :
12467 : case SymbolTable_RecordSym:
12468 : type = SymbolTable_NulSym; /* No type for a record */
12469 : break;
12470 :
12471 58982 : case SymbolTable_EnumerationFieldSym:
12472 58982 : type = pSym->EnumerationField.Type; /* No type for a record */
12473 58982 : break;
12474 :
12475 : case SymbolTable_EnumerationSym:
12476 : type = SymbolTable_NulSym; /* No type for enumeration */
12477 : break;
12478 :
12479 : case SymbolTable_PointerSym:
12480 31509 : type = Sym; /* we don't go to Pointer.Type */
12481 : break;
12482 :
12483 62433 : case SymbolTable_ProcedureSym:
12484 62433 : type = pSym->Procedure.ReturnType; /* we don't go to Pointer.Type */
12485 62433 : break;
12486 :
12487 12 : case SymbolTable_ProcTypeSym:
12488 12 : type = pSym->ProcType.ReturnType;
12489 12 : break;
12490 :
12491 133310 : case SymbolTable_ParamSym:
12492 133310 : type = pSym->Param.Type;
12493 133310 : break;
12494 :
12495 6941 : case SymbolTable_VarParamSym:
12496 6941 : type = pSym->VarParam.Type;
12497 6941 : break;
12498 :
12499 48 : case SymbolTable_SubrangeSym:
12500 48 : type = pSym->Subrange.Type;
12501 48 : break;
12502 :
12503 24 : case SymbolTable_ArraySym:
12504 24 : type = pSym->Array.Type;
12505 24 : break;
12506 :
12507 47464 : case SymbolTable_SubscriptSym:
12508 47464 : type = pSym->Subscript.Type;
12509 47464 : break;
12510 :
12511 : case SymbolTable_SetSym:
12512 31509 : type = Sym; /* Stop at the set type. */
12513 : break;
12514 :
12515 0 : case SymbolTable_UnboundedSym:
12516 0 : type = pSym->Unbounded.Type; /* Stop at the set type. */
12517 0 : break;
12518 :
12519 : case SymbolTable_UndefinedSym:
12520 : type = SymbolTable_NulSym;
12521 : break;
12522 :
12523 : case SymbolTable_DummySym:
12524 : type = SymbolTable_NulSym;
12525 : break;
12526 :
12527 :
12528 6 : default:
12529 6 : M2Error_InternalError ((const char *) "not implemented yet", 19);
12530 2568519 : break;
12531 : }
12532 2568519 : pSym = GetPsym (Sym);
12533 2568519 : if ((pSym->SymbolType == SymbolTable_TypeSym) && (type == SymbolTable_NulSym))
12534 : {
12535 : type = Sym; /* Base Type */
12536 : }
12537 1508471 : else if (((type != SymbolTable_NulSym) && (SymbolTable_IsType (type))) && ((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym))
12538 : {
12539 : /* avoid dangling else. */
12540 : type = SymbolTable_GetLowestType (type); /* Type def */
12541 : }
12542 1509976 : return type;
12543 : /* static analysis guarentees a RETURN statement will be used before here. */
12544 : __builtin_unreachable ();
12545 : }
12546 :
12547 :
12548 : /*
12549 : GetLType - get lowest type. It returns the lowest type
12550 : of symbol, sym. It skips over type equivalences.
12551 : It will not skip over base types.
12552 : */
12553 :
12554 8700357 : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym)
12555 : {
12556 : /*
12557 : Assert (doGetType (sym, TRUE, TRUE, TRUE, FALSE) = GetLowestType (sym)) ;
12558 : */
12559 8700357 : return doGetType (sym, true, true, true, false);
12560 : /* static analysis guarentees a RETURN statement will be used before here. */
12561 : __builtin_unreachable ();
12562 : }
12563 :
12564 :
12565 : /*
12566 : GetSType - get source type. It returns the type closest
12567 : to the object. It does not skip over type
12568 : equivalences. It will skip over base types.
12569 : */
12570 :
12571 668090228 : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym)
12572 : {
12573 668090228 : M2Debug_Assert ((doGetType (sym, false, false, false, true)) == (SymbolTable_GetType (sym)));
12574 668090228 : return doGetType (sym, false, false, false, true);
12575 : /* static analysis guarentees a RETURN statement will be used before here. */
12576 : __builtin_unreachable ();
12577 : }
12578 :
12579 :
12580 : /*
12581 : GetDType - get gcc declared type. It returns the type
12582 : of the object which is declared to GCC.
12583 : It does skip over type equivalences but only
12584 : if they do not contain a user alignment.
12585 : It does not skip over hidden types.
12586 : It does not skip over base types.
12587 : */
12588 :
12589 24225313 : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym)
12590 : {
12591 : /*
12592 : Assert (doGetType (sym, TRUE, FALSE, FALSE, FALSE) = SkipType(GetType(sym))) ;
12593 : */
12594 24225313 : return doGetType (sym, true, false, false, false);
12595 : /* static analysis guarentees a RETURN statement will be used before here. */
12596 : __builtin_unreachable ();
12597 : }
12598 :
12599 :
12600 : /*
12601 : GetTypeMode - return the type of sym, it returns Address is the
12602 : symbol is a LValue.
12603 : */
12604 :
12605 20982 : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym)
12606 : {
12607 20982 : if ((SymbolTable_GetMode (sym)) == SymbolTable_LeftValue)
12608 : {
12609 90 : return M2System_Address;
12610 : }
12611 : else
12612 : {
12613 20892 : return SymbolTable_GetType (sym);
12614 : }
12615 : /* static analysis guarentees a RETURN statement will be used before here. */
12616 : __builtin_unreachable ();
12617 : }
12618 :
12619 :
12620 : /*
12621 : GetSym - searches the current scope (and previous scopes if the
12622 : scope tranparent allows) for a symbol with name.
12623 : */
12624 :
12625 72415305 : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name)
12626 : {
12627 72415305 : unsigned int Sym;
12628 72415305 : unsigned int OldScopePtr;
12629 :
12630 72415305 : Sym = GetScopeSym (name, true);
12631 72415305 : if (Sym == SymbolTable_NulSym)
12632 : {
12633 : /* Check default base types for symbol */
12634 25617115 : OldScopePtr = ScopePtr; /* Save ScopePtr */
12635 25617115 : ScopePtr = BaseScopePtr; /* Alter ScopePtr to point to top of BaseModule */
12636 25617115 : Sym = GetScopeSym (name, false); /* Search BaseModule for name */
12637 25617115 : ScopePtr = OldScopePtr; /* Restored ScopePtr */
12638 : }
12639 72415305 : return Sym;
12640 : /* static analysis guarentees a RETURN statement will be used before here. */
12641 : __builtin_unreachable ();
12642 : }
12643 :
12644 :
12645 : /*
12646 : GetDeclareSym - searches for a symbol with a name SymName in the
12647 : current and previous scopes.
12648 : If the symbol is found then it is returned
12649 : else an unknown symbol is returned.
12650 : This procedure assumes that SymName is being
12651 : declared at this point and therefore it does
12652 : not examine the base scope (for pervasive
12653 : identifiers).
12654 : */
12655 :
12656 9582086 : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName)
12657 : {
12658 9582086 : unsigned int Sym;
12659 :
12660 9582086 : Sym = GetScopeSym (SymName, false); /* must not be allowed to fetch a symbol through a procedure scope */
12661 9582086 : if (Sym == SymbolTable_NulSym) /* must not be allowed to fetch a symbol through a procedure scope */
12662 : {
12663 3742515 : Sym = GetSymFromUnknownTree (SymName);
12664 3742515 : if (Sym == SymbolTable_NulSym)
12665 : {
12666 : /* Make unknown */
12667 3742515 : NewSym (&Sym);
12668 3742515 : FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
12669 : /*
12670 : ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
12671 : */
12672 3742515 : AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
12673 : }
12674 : }
12675 9582086 : return Sym;
12676 : /* static analysis guarentees a RETURN statement will be used before here. */
12677 : __builtin_unreachable ();
12678 : }
12679 :
12680 :
12681 : /*
12682 : GetLocalSym - only searches the scope Sym for a symbol with name
12683 : and returns the index to the symbol.
12684 : */
12685 :
12686 209307613 : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name)
12687 : {
12688 209307613 : SymbolTable_PtrToSymbol pSym;
12689 209307613 : unsigned int LocalSym;
12690 :
12691 : /*
12692 : WriteString('Attempting to retrieve symbol from ') ; WriteKey(GetSymName(Sym)) ;
12693 : WriteString(' local symbol table') ; WriteLn ;
12694 : */
12695 209307613 : pSym = GetPsym (Sym);
12696 209307613 : switch (pSym->SymbolType)
12697 : {
12698 51917033 : case SymbolTable_EnumerationSym:
12699 51917033 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, name));
12700 51917033 : break;
12701 :
12702 636348 : case SymbolTable_RecordSym:
12703 636348 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, name));
12704 636348 : break;
12705 :
12706 55248038 : case SymbolTable_ProcedureSym:
12707 55248038 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, name));
12708 55248038 : break;
12709 :
12710 26876305 : case SymbolTable_ModuleSym:
12711 26876305 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, name));
12712 26876305 : break;
12713 :
12714 74629889 : case SymbolTable_DefImpSym:
12715 74629889 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, name));
12716 74629889 : break;
12717 :
12718 :
12719 0 : default:
12720 0 : M2Error_InternalError ((const char *) "symbol does not have a LocalSymbols field", 41);
12721 209307613 : break;
12722 : }
12723 209307613 : return LocalSym;
12724 : /* static analysis guarentees a RETURN statement will be used before here. */
12725 : __builtin_unreachable ();
12726 : }
12727 :
12728 :
12729 : /*
12730 : GetRecord - fetches the record symbol from the parent of Sym.
12731 : Sym maybe a varient symbol in which case its parent is searched
12732 : etc.
12733 : */
12734 :
12735 49594 : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym)
12736 : {
12737 56070 : SymbolTable_PtrToSymbol pSym;
12738 :
12739 56070 : pSym = GetPsym (Sym);
12740 56070 : switch (pSym->SymbolType)
12741 : {
12742 : case SymbolTable_RecordSym:
12743 : return Sym;
12744 6222 : break;
12745 :
12746 6222 : case SymbolTable_VarientSym:
12747 6222 : return SymbolTable_GetRecord (pSym->Varient.Parent);
12748 254 : break;
12749 :
12750 254 : case SymbolTable_VarientFieldSym:
12751 254 : return SymbolTable_GetRecord (pSym->VarientField.Parent);
12752 0 : break;
12753 :
12754 :
12755 0 : default:
12756 0 : M2Error_InternalError ((const char *) "expecting Record or Varient symbol", 34);
12757 : break;
12758 : }
12759 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12760 : __builtin_unreachable ();
12761 : }
12762 :
12763 :
12764 : /*
12765 : FromModuleGetSym - attempts to find a symbol of name, n, in the
12766 : module, mod, scope. An unknown symbol is created
12767 : at token position tok if necessary.
12768 : */
12769 :
12770 8298150 : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod)
12771 : {
12772 8298150 : NameKey_Name n1;
12773 8298150 : unsigned int sym;
12774 8298150 : unsigned int OldScopePtr;
12775 :
12776 8298150 : OldScopePtr = ScopePtr;
12777 8298150 : SymbolTable_StartScope (mod);
12778 8298150 : sym = SymbolTable_RequestSym (tok, n);
12779 8298150 : SymbolTable_EndScope ();
12780 8298150 : if (sym == SymbolTable_NulSym)
12781 : {
12782 : /* --fixme-- can sym ever be NulSym? */
12783 0 : n1 = SymbolTable_GetSymName (mod);
12784 0 : M2Error_WriteFormat2 ((const char *) "cannot find procedure %a in module, %a", 38, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n1, (sizeof (n1)-1));
12785 : }
12786 8298150 : ScopePtr = OldScopePtr;
12787 8298150 : return sym;
12788 : /* static analysis guarentees a RETURN statement will be used before here. */
12789 : __builtin_unreachable ();
12790 : }
12791 :
12792 :
12793 : /*
12794 : GetNth - returns the n th symbol in the list associated with the scope
12795 : of Sym. Sym may be a Module, DefImp, Procedure, Record or
12796 : Enumeration symbol.
12797 : */
12798 :
12799 375931744 : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n)
12800 : {
12801 375931744 : SymbolTable_PtrToSymbol pSym;
12802 375931744 : unsigned int i;
12803 :
12804 375931744 : pSym = GetPsym (Sym);
12805 375931744 : switch (pSym->SymbolType)
12806 : {
12807 287349322 : case SymbolTable_RecordSym:
12808 287349322 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, n));
12809 287349322 : break;
12810 :
12811 3126254 : case SymbolTable_VarientSym:
12812 3126254 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Varient.ListOfSons, n));
12813 3126254 : break;
12814 :
12815 5629482 : case SymbolTable_VarientFieldSym:
12816 5629482 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->VarientField.ListOfSons, n));
12817 5629482 : break;
12818 :
12819 78180784 : case SymbolTable_ProcedureSym:
12820 78180784 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.ListOfVars, n));
12821 78180784 : break;
12822 :
12823 654857 : case SymbolTable_DefImpSym:
12824 654857 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfVars, n));
12825 654857 : break;
12826 :
12827 568732 : case SymbolTable_ModuleSym:
12828 568732 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfVars, n));
12829 568732 : break;
12830 :
12831 49052 : case SymbolTable_TupleSym:
12832 49052 : i = GetFromIndex (pSym->Tuple.list, n);
12833 49052 : break;
12834 :
12835 373243 : case SymbolTable_VarSym:
12836 373243 : i = GetNthFromComponent (Sym, n);
12837 373243 : break;
12838 :
12839 18 : case SymbolTable_EnumerationSym:
12840 18 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Enumeration.ListOfFields, n));
12841 18 : break;
12842 :
12843 :
12844 0 : default:
12845 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
12846 375931744 : break;
12847 : }
12848 375931744 : return i;
12849 : /* static analysis guarentees a RETURN statement will be used before here. */
12850 : __builtin_unreachable ();
12851 : }
12852 :
12853 :
12854 : /*
12855 : GetNthParam - returns the n th parameter of a procedure Sym.
12856 : */
12857 :
12858 54275399 : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
12859 : {
12860 54275399 : SymbolTable_PtrToSymbol pSym;
12861 54275399 : unsigned int i;
12862 :
12863 54275399 : if (ParamNo == 0)
12864 : {
12865 : /* The return type of the function */
12866 0 : i = SymbolTable_GetType (Sym);
12867 : }
12868 : else
12869 : {
12870 54275399 : pSym = GetPsym (Sym);
12871 54275399 : switch (pSym->SymbolType)
12872 : {
12873 45326233 : case SymbolTable_ProcedureSym:
12874 45326233 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo));
12875 45326233 : break;
12876 :
12877 8949166 : case SymbolTable_ProcTypeSym:
12878 8949166 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, ParamNo));
12879 8949166 : break;
12880 :
12881 :
12882 0 : default:
12883 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym or ProcTypeSym", 37);
12884 54275399 : break;
12885 : }
12886 : }
12887 54275399 : return i;
12888 : /* static analysis guarentees a RETURN statement will be used before here. */
12889 : __builtin_unreachable ();
12890 : }
12891 :
12892 :
12893 : /*
12894 : GetVarScope - returns the symbol which is the scope of variable Sym.
12895 : ie a Module, DefImp or Procedure Symbol.
12896 : */
12897 :
12898 20942 : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym)
12899 : {
12900 20942 : SymbolTable_PtrToSymbol pSym;
12901 :
12902 20942 : pSym = GetPsym (Sym);
12903 20942 : switch (pSym->SymbolType)
12904 : {
12905 : case SymbolTable_ErrorSym:
12906 : return SymbolTable_NulSym;
12907 20942 : break;
12908 :
12909 20942 : case SymbolTable_VarSym:
12910 20942 : return pSym->Var.Scope;
12911 0 : break;
12912 :
12913 :
12914 0 : default:
12915 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
12916 : break;
12917 : }
12918 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12919 : __builtin_unreachable ();
12920 : }
12921 :
12922 :
12923 : /*
12924 : GetSubrange - returns HighSym and LowSym - two constants which make up the
12925 : subrange.
12926 : */
12927 :
12928 26757242 : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym)
12929 : {
12930 26757242 : SymbolTable_PtrToSymbol pSym;
12931 :
12932 26757242 : pSym = GetPsym (Sym);
12933 26757242 : switch (pSym->SymbolType)
12934 : {
12935 26757242 : case SymbolTable_SubrangeSym:
12936 26757242 : (*HighSym) = pSym->Subrange.High;
12937 26757242 : (*LowSym) = pSym->Subrange.Low;
12938 26757242 : break;
12939 :
12940 :
12941 0 : default:
12942 0 : M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
12943 26757242 : break;
12944 : }
12945 26757242 : }
12946 :
12947 :
12948 : /*
12949 : GetParam - returns the ParamNo parameter from procedure ProcSym
12950 : */
12951 :
12952 9469759 : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo)
12953 : {
12954 9469759 : AssertInRange (Sym);
12955 9469759 : if (ParamNo == 0)
12956 : {
12957 : /* Parameter Zero is the return argument for the Function */
12958 0 : return SymbolTable_GetType (Sym);
12959 : }
12960 : else
12961 : {
12962 9469759 : return SymbolTable_GetNthParamAny (Sym, ParamNo);
12963 : }
12964 : /* static analysis guarentees a RETURN statement will be used before here. */
12965 : __builtin_unreachable ();
12966 : }
12967 :
12968 :
12969 : /*
12970 : GetString - returns the contents of the string symbol sym, note that
12971 : this is not the same as GetName (unless it was a literal).
12972 : */
12973 :
12974 495291 : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym)
12975 : {
12976 495291 : SymbolTable_PtrToSymbol pSym;
12977 :
12978 495291 : pSym = GetPsym (Sym);
12979 495291 : switch (pSym->SymbolType)
12980 : {
12981 495291 : case SymbolTable_ConstStringSym:
12982 495291 : if (pSym->ConstString.Known)
12983 : {
12984 495291 : return pSym->ConstString.Contents;
12985 : }
12986 : else
12987 : {
12988 0 : M2Error_InternalError ((const char *) "const string contents are unknown", 33);
12989 : }
12990 0 : break;
12991 :
12992 :
12993 0 : default:
12994 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
12995 : break;
12996 : }
12997 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12998 : __builtin_unreachable ();
12999 : }
13000 :
13001 :
13002 : /*
13003 : GetStringLength - returns the length of the string symbol Sym.
13004 : */
13005 :
13006 991054 : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym)
13007 : {
13008 991054 : SymbolTable_PtrToSymbol pSym;
13009 :
13010 991054 : pSym = GetPsym (sym);
13011 991054 : switch (pSym->SymbolType)
13012 : {
13013 991054 : case SymbolTable_ConstStringSym:
13014 991054 : if (pSym->ConstString.Known)
13015 : {
13016 991054 : return pSym->ConstString.Length;
13017 : }
13018 : else
13019 : {
13020 0 : M2MetaError_MetaErrorT0 (tok, (const char *) "const string contents are unknown", 33);
13021 0 : return 0;
13022 : }
13023 0 : break;
13024 :
13025 :
13026 0 : default:
13027 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
13028 : break;
13029 : }
13030 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13031 : __builtin_unreachable ();
13032 : }
13033 :
13034 :
13035 : /*
13036 : GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
13037 : */
13038 :
13039 21466 : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym)
13040 : {
13041 21466 : SymbolTable_PtrToSymbol pSym;
13042 :
13043 21466 : pSym = GetPsym (Sym);
13044 21466 : switch (pSym->SymbolType)
13045 : {
13046 21466 : case SymbolTable_ProcedureSym:
13047 21466 : return pSym->Procedure.BuiltinName;
13048 0 : break;
13049 :
13050 :
13051 0 : default:
13052 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13053 : break;
13054 : }
13055 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13056 : __builtin_unreachable ();
13057 : }
13058 :
13059 :
13060 : /*
13061 : PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
13062 : */
13063 :
13064 877990 : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name)
13065 : {
13066 877990 : SymbolTable_PtrToSymbol pSym;
13067 :
13068 877990 : pSym = GetPsym (Sym);
13069 877990 : switch (pSym->SymbolType)
13070 : {
13071 877990 : case SymbolTable_ProcedureSym:
13072 877990 : pSym->Procedure.BuiltinName = name;
13073 877990 : pSym->Procedure.IsBuiltin = true;
13074 : /* we use the same extra pass method as hidden types for builtins */
13075 877990 : SymbolTable_PutHiddenTypeDeclared ();
13076 877990 : break;
13077 :
13078 :
13079 0 : default:
13080 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13081 877990 : break;
13082 : }
13083 877990 : }
13084 :
13085 :
13086 : /*
13087 : IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
13088 : */
13089 :
13090 1235458 : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym)
13091 : {
13092 1235458 : SymbolTable_PtrToSymbol pSym;
13093 :
13094 1235458 : pSym = GetPsym (Sym);
13095 1235458 : switch (pSym->SymbolType)
13096 : {
13097 1235458 : case SymbolTable_ProcedureSym:
13098 1235458 : return pSym->Procedure.IsBuiltin;
13099 0 : break;
13100 :
13101 :
13102 0 : default:
13103 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13104 : break;
13105 : }
13106 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13107 : __builtin_unreachable ();
13108 : }
13109 :
13110 :
13111 : /*
13112 : PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
13113 : */
13114 :
13115 0 : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym)
13116 : {
13117 0 : SymbolTable_PtrToSymbol pSym;
13118 :
13119 0 : pSym = GetPsym (Sym);
13120 0 : switch (pSym->SymbolType)
13121 : {
13122 0 : case SymbolTable_ProcedureSym:
13123 0 : pSym->Procedure.IsInline = true;
13124 0 : break;
13125 :
13126 :
13127 0 : default:
13128 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13129 0 : break;
13130 : }
13131 0 : }
13132 :
13133 80549 : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym)
13134 : {
13135 80549 : SymbolTable_PtrToSymbol pSym;
13136 :
13137 : /*
13138 : IsProcedureBuiltin - returns TRUE if this procedure was declared as inlined.
13139 : */
13140 80549 : pSym = GetPsym (Sym);
13141 80549 : switch (pSym->SymbolType)
13142 : {
13143 80549 : case SymbolTable_ProcedureSym:
13144 80549 : return pSym->Procedure.IsInline;
13145 0 : break;
13146 :
13147 :
13148 0 : default:
13149 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13150 : break;
13151 : }
13152 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13153 : __builtin_unreachable ();
13154 : }
13155 :
13156 :
13157 : /*
13158 : PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
13159 : sym, indicating that this block as an EXCEPT
13160 : statement sequence.
13161 : */
13162 :
13163 222 : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym)
13164 : {
13165 222 : SymbolTable_PtrToSymbol pSym;
13166 :
13167 222 : pSym = GetPsym (sym);
13168 222 : switch (pSym->SymbolType)
13169 : {
13170 168 : case SymbolTable_ProcedureSym:
13171 168 : pSym->Procedure.ExceptionBlock = true;
13172 168 : break;
13173 :
13174 54 : case SymbolTable_ModuleSym:
13175 54 : pSym->Module.ExceptionBlock = true;
13176 54 : break;
13177 :
13178 0 : case SymbolTable_DefImpSym:
13179 0 : pSym->DefImp.ExceptionBlock = true;
13180 0 : break;
13181 :
13182 :
13183 0 : default:
13184 0 : M2Error_InternalError ((const char *) "expecting Procedure", 19);
13185 222 : break;
13186 : }
13187 222 : }
13188 :
13189 :
13190 : /*
13191 : HasExceptionBlock - returns a BOOLEAN determining whether
13192 : module/procedure/defimp, sym, has
13193 : an EXCEPT statement sequence.
13194 : */
13195 :
13196 334827 : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym)
13197 : {
13198 334827 : SymbolTable_PtrToSymbol pSym;
13199 :
13200 334827 : pSym = GetPsym (sym);
13201 334827 : switch (pSym->SymbolType)
13202 : {
13203 165492 : case SymbolTable_ProcedureSym:
13204 165492 : return pSym->Procedure.ExceptionBlock;
13205 24047 : break;
13206 :
13207 24047 : case SymbolTable_ModuleSym:
13208 24047 : return pSym->Module.ExceptionBlock;
13209 145288 : break;
13210 :
13211 145288 : case SymbolTable_DefImpSym:
13212 145288 : return pSym->DefImp.ExceptionBlock;
13213 0 : break;
13214 :
13215 :
13216 0 : default:
13217 0 : M2Error_InternalError ((const char *) "expecting Procedure", 19);
13218 : break;
13219 : }
13220 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13221 : __builtin_unreachable ();
13222 : }
13223 :
13224 :
13225 : /*
13226 : PutExceptionFinally - sets a BOOLEAN in block module/defimp,
13227 : sym, indicating that this FINALLY block
13228 : as an EXCEPT statement sequence.
13229 : */
13230 :
13231 0 : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym)
13232 : {
13233 0 : SymbolTable_PtrToSymbol pSym;
13234 :
13235 0 : pSym = GetPsym (sym);
13236 0 : switch (pSym->SymbolType)
13237 : {
13238 0 : case SymbolTable_ProcedureSym:
13239 0 : pSym->Procedure.ExceptionFinally = true;
13240 0 : break;
13241 :
13242 0 : case SymbolTable_ModuleSym:
13243 0 : pSym->Module.ExceptionFinally = true;
13244 0 : break;
13245 :
13246 0 : case SymbolTable_DefImpSym:
13247 0 : pSym->DefImp.ExceptionFinally = true;
13248 0 : break;
13249 :
13250 :
13251 0 : default:
13252 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
13253 0 : break;
13254 : }
13255 0 : }
13256 :
13257 :
13258 : /*
13259 : HasExceptionFinally - returns a BOOLEAN determining whether
13260 : module/defimp, sym, has
13261 : an EXCEPT statement sequence.
13262 : */
13263 :
13264 31616 : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym)
13265 : {
13266 31616 : SymbolTable_PtrToSymbol pSym;
13267 :
13268 31616 : pSym = GetPsym (sym);
13269 31616 : switch (pSym->SymbolType)
13270 : {
13271 0 : case SymbolTable_ProcedureSym:
13272 0 : return pSym->Procedure.ExceptionFinally;
13273 23884 : break;
13274 :
13275 23884 : case SymbolTable_ModuleSym:
13276 23884 : return pSym->Module.ExceptionFinally;
13277 7732 : break;
13278 :
13279 7732 : case SymbolTable_DefImpSym:
13280 7732 : return pSym->DefImp.ExceptionFinally;
13281 0 : break;
13282 :
13283 :
13284 0 : default:
13285 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
13286 : break;
13287 : }
13288 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13289 : __builtin_unreachable ();
13290 : }
13291 :
13292 :
13293 : /*
13294 : PutVar - gives the VarSym symbol Sym a type Type.
13295 : */
13296 :
13297 1478222 : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType)
13298 : {
13299 1478222 : SymbolTable_PtrToSymbol pSym;
13300 :
13301 1478222 : pSym = GetPsym (Sym);
13302 1478222 : switch (pSym->SymbolType)
13303 : {
13304 577711 : case SymbolTable_VarSym:
13305 577711 : pSym->Var.Type = VarType;
13306 577711 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), Sym);
13307 577711 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), Sym);
13308 577711 : break;
13309 :
13310 900511 : case SymbolTable_ConstVarSym:
13311 900511 : pSym->ConstVar.Type = VarType;
13312 900511 : break;
13313 :
13314 :
13315 0 : default:
13316 0 : M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
13317 1478222 : break;
13318 : }
13319 1478222 : }
13320 :
13321 :
13322 : /*
13323 : PutVarTok - gives the VarSym symbol Sym a type Type at typetok.
13324 : */
13325 :
13326 10806561 : extern "C" void SymbolTable_PutVarTok (unsigned int Sym, unsigned int VarType, unsigned int typetok)
13327 : {
13328 10806561 : SymbolTable_PtrToSymbol pSym;
13329 :
13330 10806561 : pSym = GetPsym (Sym);
13331 10806561 : switch (pSym->SymbolType)
13332 : {
13333 10806549 : case SymbolTable_VarSym:
13334 10806549 : pSym->Var.Type = VarType;
13335 10806549 : pSym->Var.Declared.TypeTok = typetok;
13336 10806549 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), Sym);
13337 10806549 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), Sym);
13338 10806549 : break;
13339 :
13340 0 : case SymbolTable_ConstVarSym:
13341 0 : pSym->ConstVar.Type = VarType;
13342 0 : break;
13343 :
13344 :
13345 12 : default:
13346 12 : M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
13347 10806549 : break;
13348 : }
13349 10806549 : }
13350 :
13351 :
13352 : /*
13353 : PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
13354 : The variable must be a LeftValue.
13355 : */
13356 :
13357 76371 : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType)
13358 : {
13359 76371 : SymbolTable_PtrToSymbol pSym;
13360 :
13361 76371 : M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue);
13362 76371 : pSym = GetPsym (Sym);
13363 76371 : switch (pSym->SymbolType)
13364 : {
13365 76371 : case SymbolTable_VarSym:
13366 76371 : pSym->Var.Type = FrontType;
13367 76371 : pSym->Var.BackType = BackType;
13368 76371 : SymbolTable_PushSize (M2System_Address);
13369 76371 : M2ALU_PopInto (pSym->Var.Size);
13370 76371 : break;
13371 :
13372 :
13373 0 : default:
13374 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
13375 76371 : break;
13376 : }
13377 76371 : }
13378 :
13379 :
13380 : /*
13381 : GetVarBackEndType - returns the back end type if specified.
13382 : */
13383 :
13384 1126291 : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym)
13385 : {
13386 1126291 : SymbolTable_PtrToSymbol pSym;
13387 :
13388 1126291 : M2Debug_Assert (Sym != SymbolTable_NulSym);
13389 1126291 : pSym = GetPsym (Sym);
13390 1126291 : switch (pSym->SymbolType)
13391 : {
13392 1126291 : case SymbolTable_VarSym:
13393 1126291 : return pSym->Var.BackType;
13394 : break;
13395 :
13396 :
13397 : default:
13398 : return SymbolTable_NulSym;
13399 : break;
13400 : }
13401 : /* static analysis guarentees a RETURN statement will be used before here. */
13402 : __builtin_unreachable ();
13403 : }
13404 :
13405 :
13406 : /*
13407 : PutVarPointerCheck - marks variable, sym, as requiring (or not
13408 : depending upon the, value), a NIL pointer check
13409 : when this symbol is dereferenced.
13410 : */
13411 :
13412 39854 : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value)
13413 : {
13414 39854 : SymbolTable_PtrToSymbol pSym;
13415 :
13416 39854 : if (SymbolTable_IsVar (sym))
13417 : {
13418 39848 : pSym = GetPsym (sym);
13419 39848 : pSym->Var.IsPointerCheck = value;
13420 : }
13421 39854 : }
13422 :
13423 :
13424 : /*
13425 : GetVarPointerCheck - returns TRUE if this symbol is a variable and
13426 : has been marked as needing a pointer via NIL check.
13427 : */
13428 :
13429 80198 : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym)
13430 : {
13431 80198 : SymbolTable_PtrToSymbol pSym;
13432 :
13433 80198 : if (SymbolTable_IsVar (sym))
13434 : {
13435 80198 : pSym = GetPsym (sym);
13436 80198 : return pSym->Var.IsPointerCheck;
13437 : }
13438 : return false;
13439 : /* static analysis guarentees a RETURN statement will be used before here. */
13440 : __builtin_unreachable ();
13441 : }
13442 :
13443 :
13444 : /*
13445 : PutVarWritten - marks variable, sym, as being written to (or not
13446 : depending upon the, value).
13447 : */
13448 :
13449 12649 : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value)
13450 : {
13451 12649 : SymbolTable_PtrToSymbol pSym;
13452 :
13453 12649 : if (SymbolTable_IsVar (sym))
13454 : {
13455 12649 : pSym = GetPsym (sym);
13456 12649 : pSym->Var.IsWritten = value;
13457 : }
13458 12649 : }
13459 :
13460 :
13461 : /*
13462 : GetVarWritten - returns TRUE if this symbol is a variable and
13463 : has been marked as being written.
13464 : */
13465 :
13466 93769 : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym)
13467 : {
13468 93769 : SymbolTable_PtrToSymbol pSym;
13469 :
13470 93769 : pSym = GetPsym (sym);
13471 93769 : switch (pSym->SymbolType)
13472 : {
13473 93769 : case SymbolTable_VarSym:
13474 93769 : return pSym->Var.IsWritten;
13475 0 : break;
13476 :
13477 :
13478 0 : default:
13479 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
13480 : break;
13481 : }
13482 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13483 : __builtin_unreachable ();
13484 : }
13485 :
13486 :
13487 : /*
13488 : PutConst - gives the constant symbol Sym a type ConstType.
13489 : */
13490 :
13491 435541 : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType)
13492 : {
13493 435541 : SymbolTable_PtrToSymbol pSym;
13494 :
13495 435541 : pSym = GetPsym (Sym);
13496 435541 : CheckBreak (Sym);
13497 435541 : switch (pSym->SymbolType)
13498 : {
13499 435541 : case SymbolTable_ConstVarSym:
13500 435541 : pSym->ConstVar.Type = ConstType;
13501 435541 : break;
13502 :
13503 :
13504 0 : default:
13505 0 : M2Error_InternalError ((const char *) "expecting ConstVarSym", 21);
13506 435541 : break;
13507 : }
13508 435541 : }
13509 :
13510 :
13511 : /*
13512 : PutConstSet - informs the const var symbol, sym, that it is or will contain
13513 : a set value.
13514 : */
13515 :
13516 50168 : extern "C" void SymbolTable_PutConstSet (unsigned int Sym)
13517 : {
13518 50168 : SymbolTable_PtrToSymbol pSym;
13519 :
13520 50168 : pSym = GetPsym (Sym);
13521 50168 : switch (pSym->SymbolType)
13522 : {
13523 50168 : case SymbolTable_ConstVarSym:
13524 50168 : pSym->ConstVar.IsSet = true;
13525 50168 : break;
13526 :
13527 0 : case SymbolTable_ConstLitSym:
13528 0 : pSym->ConstLit.IsSet = true;
13529 0 : break;
13530 :
13531 :
13532 0 : default:
13533 0 : M2Error_InternalError ((const char *) "expecting ConstVar symbol", 25);
13534 50168 : break;
13535 : }
13536 50168 : }
13537 :
13538 :
13539 : /*
13540 : IsConstSet - returns TRUE if the constant is declared as a set.
13541 : */
13542 :
13543 82781509 : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym)
13544 : {
13545 82781509 : SymbolTable_PtrToSymbol pSym;
13546 :
13547 82781509 : pSym = GetPsym (Sym);
13548 82781509 : switch (pSym->SymbolType)
13549 : {
13550 14114593 : case SymbolTable_ConstVarSym:
13551 14114593 : return pSym->ConstVar.IsSet;
13552 20193463 : break;
13553 :
13554 20193463 : case SymbolTable_ConstLitSym:
13555 20193463 : return pSym->ConstLit.IsSet;
13556 : break;
13557 :
13558 :
13559 : default:
13560 : return false;
13561 : break;
13562 : }
13563 : /* static analysis guarentees a RETURN statement will be used before here. */
13564 : __builtin_unreachable ();
13565 : }
13566 :
13567 :
13568 : /*
13569 : PutConstructor - informs the const var symbol, sym, that it is or
13570 : will contain a constructor (record, set or array)
13571 : value.
13572 : */
13573 :
13574 42266 : extern "C" void SymbolTable_PutConstructor (unsigned int Sym)
13575 : {
13576 42266 : SymbolTable_PtrToSymbol pSym;
13577 :
13578 42266 : pSym = GetPsym (Sym);
13579 42266 : switch (pSym->SymbolType)
13580 : {
13581 42266 : case SymbolTable_ConstVarSym:
13582 42266 : pSym->ConstVar.IsConstructor = true;
13583 42266 : break;
13584 :
13585 0 : case SymbolTable_ConstLitSym:
13586 0 : pSym->ConstLit.IsConstructor = true;
13587 0 : break;
13588 :
13589 :
13590 0 : default:
13591 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
13592 42266 : break;
13593 : }
13594 42266 : }
13595 :
13596 :
13597 : /*
13598 : PutConstructorFrom - sets the from type field in constructor,
13599 : Sym, to, from.
13600 : */
13601 :
13602 37408 : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from)
13603 : {
13604 37408 : SymbolTable_PtrToSymbol pSym;
13605 :
13606 37408 : pSym = GetPsym (Sym);
13607 37408 : switch (pSym->SymbolType)
13608 : {
13609 37408 : case SymbolTable_ConstVarSym:
13610 37408 : pSym->ConstVar.FromType = from;
13611 37408 : pSym->ConstVar.UnresFromType = true;
13612 37408 : break;
13613 :
13614 0 : case SymbolTable_ConstLitSym:
13615 0 : pSym->ConstLit.FromType = from;
13616 0 : pSym->ConstLit.UnresFromType = true;
13617 0 : break;
13618 :
13619 :
13620 0 : default:
13621 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
13622 37408 : break;
13623 : }
13624 37408 : Lists_IncludeItemIntoList (UnresolvedConstructorType, Sym);
13625 37408 : }
13626 :
13627 :
13628 : /*
13629 : PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
13630 : VarSym is a optional varient symbol which can be returned
13631 : by a call to GetVarient(fieldsymbol). The created field
13632 : is returned.
13633 : */
13634 :
13635 416535 : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym)
13636 : {
13637 416535 : SymbolTable_PtrToSymbol oSym;
13638 416535 : SymbolTable_PtrToSymbol pSym;
13639 416535 : unsigned int esym;
13640 416535 : unsigned int ParSym;
13641 416535 : unsigned int SonSym;
13642 :
13643 416535 : NewSym (&SonSym); /* Cannot be used before declared since use occurs */
13644 : /* ensure that it is connected its parent. */
13645 416535 : pSym = GetPsym (Sym);
13646 416535 : switch (pSym->SymbolType)
13647 : {
13648 410313 : case SymbolTable_RecordSym:
13649 410313 : Lists_PutItemIntoList (pSym->Record.ListOfSons, SonSym);
13650 410313 : M2Debug_Assert (Lists_IsItemInList (pSym->Record.ListOfSons, SonSym));
13651 : /* Ensure that the Field is in the Parents Local Symbols */
13652 410313 : if (FieldName != NameKey_NulName)
13653 : {
13654 : /* avoid gcc warning by using compound statement even if not strictly necessary. */
13655 410283 : if ((SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName)) == SymbolKey_NulKey)
13656 : {
13657 410283 : SymbolKey_PutSymKey (pSym->Record.LocalSymbols, FieldName, SonSym);
13658 : }
13659 : else
13660 : {
13661 0 : esym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName));
13662 0 : M2MetaError_MetaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, esym);
13663 : }
13664 : }
13665 : CheckRecordConsistency (Sym);
13666 : break;
13667 :
13668 6222 : case SymbolTable_VarientFieldSym:
13669 6222 : Lists_PutItemIntoList (pSym->VarientField.ListOfSons, SonSym);
13670 6222 : ParSym = SymbolTable_GetRecord (pSym->VarientField.Parent);
13671 6222 : oSym = GetPsym (ParSym);
13672 6222 : M2Debug_Assert (oSym->SymbolType == SymbolTable_RecordSym);
13673 6222 : if (FieldName != NameKey_NulName)
13674 : {
13675 6210 : oSym = GetPsym (ParSym);
13676 6210 : SymbolKey_PutSymKey (oSym->Record.LocalSymbols, FieldName, SonSym);
13677 : }
13678 : break;
13679 :
13680 :
13681 0 : default:
13682 0 : M2Error_InternalError ((const char *) "expecting Record symbol", 23);
13683 416535 : break;
13684 : }
13685 : /* Fill in SonSym */
13686 416535 : oSym = GetPsym (SonSym);
13687 416535 : oSym->SymbolType = SymbolTable_RecordFieldSym;
13688 416535 : oSym->RecordField.Type = FieldType;
13689 416535 : oSym->RecordField.name = FieldName;
13690 416535 : oSym->RecordField.Tag = false;
13691 416535 : oSym->RecordField.Parent = Sym;
13692 416535 : oSym->RecordField.Varient = VarSym;
13693 416535 : oSym->RecordField.Align = SymbolTable_NulSym;
13694 416535 : oSym->RecordField.Used = true;
13695 416535 : oSym->RecordField.DeclPacked = false; /* not known as packed (yet). */
13696 416535 : oSym->RecordField.DeclResolved = false; /* not known as packed (yet). */
13697 416535 : oSym->RecordField.Scope = SymbolTable_GetScope (Sym);
13698 416535 : oSym->RecordField.Size = M2ALU_InitValue ();
13699 416535 : oSym->RecordField.Offset = M2ALU_InitValue ();
13700 416535 : InitWhereDeclared (&oSym->RecordField.At);
13701 416535 : return SonSym;
13702 : /* static analysis guarentees a RETURN statement will be used before here. */
13703 : __builtin_unreachable ();
13704 : }
13705 :
13706 :
13707 : /*
13708 : PutFieldVarient - places the field varient, Field, as a brother to, the
13709 : varient symbol, sym, and also tells Field that its varient
13710 : parent is Sym.
13711 : */
13712 :
13713 12348 : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym)
13714 : {
13715 12348 : SymbolTable_PtrToSymbol pSym;
13716 :
13717 12348 : M2Debug_Assert (SymbolTable_IsVarient (Sym));
13718 12348 : M2Debug_Assert (SymbolTable_IsFieldVarient (Field));
13719 12348 : pSym = GetPsym (Sym);
13720 12348 : switch (pSym->SymbolType)
13721 : {
13722 12348 : case SymbolTable_VarientSym:
13723 12348 : Lists_IncludeItemIntoList (pSym->Varient.ListOfSons, Field);
13724 12348 : break;
13725 :
13726 :
13727 0 : default:
13728 0 : M2Error_InternalError ((const char *) "expecting Varient symbol", 24);
13729 12348 : break;
13730 : }
13731 12348 : pSym = GetPsym (Field);
13732 12348 : switch (pSym->SymbolType)
13733 : {
13734 12348 : case SymbolTable_VarientFieldSym:
13735 12348 : pSym->VarientField.Varient = Sym;
13736 12348 : break;
13737 :
13738 :
13739 0 : default:
13740 0 : M2Error_InternalError ((const char *) "expecting VarientField symbol", 29);
13741 12348 : break;
13742 : }
13743 12348 : }
13744 :
13745 :
13746 : /*
13747 : GetVarient - returns the varient symbol associated with the
13748 : record or varient field symbol, Field.
13749 : */
13750 :
13751 237681356 : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field)
13752 : {
13753 237681356 : SymbolTable_PtrToSymbol pSym;
13754 :
13755 237681356 : pSym = GetPsym (Field);
13756 237681356 : switch (pSym->SymbolType)
13757 : {
13758 0 : case SymbolTable_VarientFieldSym:
13759 0 : return pSym->VarientField.Varient;
13760 237097780 : break;
13761 :
13762 237097780 : case SymbolTable_RecordFieldSym:
13763 237097780 : return pSym->RecordField.Varient;
13764 583576 : break;
13765 :
13766 583576 : case SymbolTable_VarientSym:
13767 583576 : return pSym->Varient.Varient;
13768 : break;
13769 :
13770 :
13771 : default:
13772 : return SymbolTable_NulSym;
13773 : break;
13774 : }
13775 : /* static analysis guarentees a RETURN statement will be used before here. */
13776 : __builtin_unreachable ();
13777 : }
13778 :
13779 :
13780 : /*
13781 : IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
13782 : a varient tag.
13783 : */
13784 :
13785 3468394 : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym)
13786 : {
13787 3468394 : SymbolTable_PtrToSymbol pSym;
13788 :
13789 3468394 : if (SymbolTable_IsRecordField (sym))
13790 : {
13791 3468394 : pSym = GetPsym (sym);
13792 3468394 : return pSym->RecordField.Tag;
13793 : }
13794 : else
13795 : {
13796 0 : M2Error_InternalError ((const char *) "record field symbol expected", 28);
13797 : }
13798 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13799 : __builtin_unreachable ();
13800 : }
13801 :
13802 :
13803 : /*
13804 : IsEmptyFieldVarient - returns TRUE if the field variant has
13805 : no fields. This will occur then the
13806 : compiler constructs 'else end' variants.
13807 : */
13808 :
13809 0 : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym)
13810 : {
13811 0 : SymbolTable_PtrToSymbol pSym;
13812 :
13813 0 : pSym = GetPsym (sym);
13814 0 : switch (pSym->SymbolType)
13815 : {
13816 0 : case SymbolTable_VarientFieldSym:
13817 0 : return (Lists_NoOfItemsInList (pSym->VarientField.ListOfSons)) == 0;
13818 0 : break;
13819 :
13820 :
13821 0 : default:
13822 0 : M2Error_InternalError ((const char *) "varient field symbol expected", 29);
13823 : break;
13824 : }
13825 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13826 : __builtin_unreachable ();
13827 : }
13828 :
13829 :
13830 : /*
13831 : GetVarientTag - returns the varient tag from, Sym.
13832 : */
13833 :
13834 13074 : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym)
13835 : {
13836 13074 : SymbolTable_PtrToSymbol pSym;
13837 :
13838 13074 : pSym = GetPsym (Sym);
13839 13074 : switch (pSym->SymbolType)
13840 : {
13841 13074 : case SymbolTable_VarientSym:
13842 13074 : return pSym->Varient.tag;
13843 0 : break;
13844 :
13845 :
13846 0 : default:
13847 0 : M2Error_InternalError ((const char *) "varient symbol expected", 23);
13848 : break;
13849 : }
13850 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13851 : __builtin_unreachable ();
13852 : }
13853 :
13854 :
13855 : /*
13856 : PutVarientTag - places, Tag, into varient, Sym.
13857 : */
13858 :
13859 3054 : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag)
13860 : {
13861 3054 : SymbolTable_PtrToSymbol pSym;
13862 3054 : unsigned int parent;
13863 :
13864 3054 : pSym = GetPsym (Sym);
13865 3054 : switch (pSym->SymbolType)
13866 : {
13867 3054 : case SymbolTable_VarientSym:
13868 3054 : pSym->Varient.tag = Tag;
13869 3054 : break;
13870 :
13871 :
13872 0 : default:
13873 0 : M2Error_InternalError ((const char *) "varient symbol expected", 23);
13874 3054 : break;
13875 : }
13876 : /* now ensure that if Tag is a RecordField then it must be
13877 : placed before the varient symbol in its parent ListOfSons.
13878 : This allows M2GCCDeclare to declare record fields in order
13879 : and preserve the order of fields. Otherwise it will add the
13880 : tag field after the C union. */
13881 3054 : if (SymbolTable_IsRecordField (Tag))
13882 : {
13883 3042 : pSym = GetPsym (Tag);
13884 3042 : pSym->RecordField.Tag = true;
13885 3042 : parent = SymbolTable_GetParent (Sym);
13886 3042 : pSym = GetPsym (parent);
13887 3042 : switch (pSym->SymbolType)
13888 : {
13889 : case SymbolTable_ErrorSym:
13890 : break;
13891 :
13892 0 : case SymbolTable_VarientSym:
13893 0 : EnsureOrder (pSym->Varient.ListOfSons, Tag, Sym);
13894 0 : break;
13895 :
13896 36 : case SymbolTable_VarientFieldSym:
13897 36 : EnsureOrder (pSym->VarientField.ListOfSons, Tag, Sym);
13898 36 : break;
13899 :
13900 3006 : case SymbolTable_RecordSym:
13901 3006 : EnsureOrder (pSym->Record.ListOfSons, Tag, Sym);
13902 3006 : CheckRecordConsistency (parent);
13903 3006 : break;
13904 :
13905 :
13906 0 : default:
13907 0 : M2Error_InternalError ((const char *) "not expecting this symbol type", 30);
13908 : break;
13909 : }
13910 : }
13911 3054 : }
13912 :
13913 :
13914 : /*
13915 : PutFieldEnumeration - places a field into the enumeration type
13916 : Sym. The field has a name FieldName and a
13917 : value FieldVal.
13918 : */
13919 :
13920 504968 : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName)
13921 : {
13922 504968 : SymbolTable_PtrToSymbol oSym;
13923 504968 : SymbolTable_PtrToSymbol pSym;
13924 504968 : DynamicStrings_String s;
13925 504968 : unsigned int Field;
13926 :
13927 504968 : Field = CheckForHiddenType (FieldName);
13928 504968 : if (Field == SymbolTable_NulSym)
13929 : {
13930 504968 : Field = DeclareSym (tok, FieldName);
13931 : }
13932 504968 : if (! (SymbolTable_IsError (Field)))
13933 : {
13934 504962 : pSym = GetPsym (Field);
13935 504962 : pSym->SymbolType = SymbolTable_EnumerationFieldSym;
13936 504962 : pSym->EnumerationField.name = FieldName; /* Index into name array, name */
13937 : /* of type. */
13938 504962 : oSym = GetPsym (Sym);
13939 504962 : M2ALU_PushCard (oSym->Enumeration.NoOfElements);
13940 504962 : pSym->EnumerationField.Value = M2ALU_InitValue ();
13941 504962 : M2ALU_PopInto (pSym->EnumerationField.Value);
13942 504962 : pSym->EnumerationField.Type = Sym;
13943 504962 : pSym->EnumerationField.Scope = SymbolTable_GetCurrentScope ();
13944 504962 : InitWhereDeclaredTok (tok, &pSym->EnumerationField.At); /* Declared here */
13945 504962 : pSym = GetPsym (Sym);
13946 504962 : switch (pSym->SymbolType)
13947 : {
13948 504962 : case SymbolTable_EnumerationSym:
13949 504962 : pSym->Enumeration.NoOfElements += 1;
13950 504962 : if ((SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, FieldName)) != SymbolTable_NulSym)
13951 : {
13952 0 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (FieldName)));
13953 0 : AlreadyDeclaredError (FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "enumeration field (%s) is already declared elsewhere, use a different name or remove the declaration", 100)), (const unsigned char *) &s, (sizeof (s)-1)), FieldName, SymbolTable_GetDeclaredMod (SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, FieldName)));
13954 : }
13955 : else
13956 : {
13957 504962 : SymbolKey_PutSymKey (pSym->Enumeration.LocalSymbols, FieldName, Field);
13958 504962 : Lists_IncludeItemIntoList (pSym->Enumeration.ListOfFields, Field);
13959 : }
13960 : break;
13961 :
13962 :
13963 0 : default:
13964 0 : M2Error_InternalError ((const char *) "expecting Sym=Enumeration", 25);
13965 : break;
13966 : }
13967 : }
13968 504968 : }
13969 :
13970 :
13971 : /*
13972 : PutSubrange - places LowSym and HighSym as two symbols
13973 : which provide the limits of the range.
13974 : */
13975 :
13976 335651 : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol)
13977 : {
13978 335651 : SymbolTable_PtrToSymbol pSym;
13979 :
13980 335651 : pSym = GetPsym (Sym);
13981 335651 : switch (pSym->SymbolType)
13982 : {
13983 335651 : case SymbolTable_SubrangeSym:
13984 335651 : pSym->Subrange.Low = LowSym; /* Index to symbol for lower */
13985 335651 : pSym->Subrange.High = HighSym; /* Index to symbol for higher */
13986 335651 : pSym->Subrange.Type = TypeSymbol; /* Index to type symbol for */
13987 335651 : break;
13988 :
13989 :
13990 0 : default:
13991 : /* the type of subrange. */
13992 0 : M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
13993 335651 : break;
13994 : }
13995 335651 : }
13996 :
13997 :
13998 : /*
13999 : PutSet - places SimpleType as the type for set, Sym.
14000 : */
14001 :
14002 66683 : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed)
14003 : {
14004 66683 : SymbolTable_PtrToSymbol pSym;
14005 :
14006 66683 : pSym = GetPsym (Sym);
14007 66683 : switch (pSym->SymbolType)
14008 : {
14009 : case SymbolTable_ErrorSym:
14010 : break;
14011 :
14012 66683 : case SymbolTable_SetSym:
14013 66683 : pSym->Set.Type = SimpleType; /* Index to a subrange symbol */
14014 : /* or an enumeration type. */
14015 66683 : pSym->Set.ispacked = packed;
14016 66683 : break;
14017 :
14018 :
14019 0 : default:
14020 0 : M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
14021 66683 : break;
14022 : }
14023 66683 : }
14024 :
14025 :
14026 : /*
14027 : IsSetPacked - returns TRUE if Sym is packed.
14028 : */
14029 :
14030 0 : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym)
14031 : {
14032 0 : SymbolTable_PtrToSymbol pSym;
14033 :
14034 0 : AssertInRange (Sym);
14035 0 : pSym = GetPsym (Sym);
14036 0 : return (pSym->SymbolType == SymbolTable_SetSym) && pSym->Set.ispacked;
14037 : /* static analysis guarentees a RETURN statement will be used before here. */
14038 : __builtin_unreachable ();
14039 : }
14040 :
14041 :
14042 : /*
14043 : GetArraySubscript - returns the subscript symbol for array, Sym.
14044 : */
14045 :
14046 6334370 : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym)
14047 : {
14048 6334370 : SymbolTable_PtrToSymbol pSym;
14049 :
14050 6334370 : pSym = GetPsym (Sym);
14051 6334370 : switch (pSym->SymbolType)
14052 : {
14053 : case SymbolTable_ErrorSym:
14054 : return SymbolTable_NulSym;
14055 6334370 : break;
14056 :
14057 6334370 : case SymbolTable_ArraySym:
14058 6334370 : return pSym->Array.Subscript;
14059 0 : break;
14060 :
14061 :
14062 0 : default:
14063 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
14064 : break;
14065 : }
14066 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14067 : __builtin_unreachable ();
14068 : }
14069 :
14070 :
14071 : /*
14072 : PutArraySubscript - places an index field into the array Sym. The
14073 : index field is a subscript sym.
14074 : */
14075 :
14076 167807 : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol)
14077 : {
14078 167807 : SymbolTable_PtrToSymbol pSym;
14079 :
14080 167807 : pSym = GetPsym (Sym);
14081 167807 : switch (pSym->SymbolType)
14082 : {
14083 : case SymbolTable_ErrorSym:
14084 : break;
14085 :
14086 167807 : case SymbolTable_ArraySym:
14087 167807 : pSym->Array.Subscript = SubscriptSymbol;
14088 167807 : break;
14089 :
14090 :
14091 0 : default:
14092 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
14093 167807 : break;
14094 : }
14095 167807 : }
14096 :
14097 :
14098 : /*
14099 : PutType - gives a type symbol Sym type TypeSymbol.
14100 : */
14101 :
14102 625163 : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol)
14103 : {
14104 625163 : SymbolTable_PtrToSymbol pSym;
14105 :
14106 625163 : if (TypeSymbol == Sym)
14107 : {
14108 0 : M2Error_InternalError ((const char *) "not expecting a type to be declared as itself", 45);
14109 : }
14110 625163 : pSym = GetPsym (Sym);
14111 625163 : switch (pSym->SymbolType)
14112 : {
14113 : case SymbolTable_ErrorSym:
14114 : break;
14115 :
14116 625163 : case SymbolTable_TypeSym:
14117 625163 : pSym->Type.Type = TypeSymbol;
14118 625163 : break;
14119 :
14120 :
14121 0 : default:
14122 0 : M2Error_InternalError ((const char *) "expecting a Type symbol", 23);
14123 625163 : break;
14124 : }
14125 625163 : }
14126 :
14127 :
14128 : /*
14129 : PutFunction - Places a TypeSym as the return type to a procedure Sym.
14130 : */
14131 :
14132 8491030 : extern "C" void SymbolTable_PutFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym)
14133 : {
14134 16974084 : SymbolTable_PtrToSymbol pSym;
14135 :
14136 16974084 : pSym = GetPsym (Sym);
14137 16974084 : switch (pSym->SymbolType)
14138 : {
14139 : case SymbolTable_ErrorSym:
14140 : break;
14141 :
14142 8483054 : case SymbolTable_ProcedureSym:
14143 8483054 : pSym->Procedure.ReturnType = TypeSym;
14144 8483054 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
14145 8483054 : SymbolTable_PutFunction (tok, pSym->Procedure.ProcedureType, kind, TypeSym);
14146 8483054 : break;
14147 :
14148 8491030 : case SymbolTable_ProcTypeSym:
14149 8491030 : pSym->ProcType.ReturnType = TypeSym;
14150 8491030 : pSym->ProcType.ReturnTypeTok = tok;
14151 8491030 : break;
14152 :
14153 :
14154 0 : default:
14155 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14156 8491030 : break;
14157 : }
14158 8491030 : }
14159 :
14160 :
14161 : /*
14162 : PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
14163 : */
14164 :
14165 136105 : extern "C" void SymbolTable_PutOptFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym)
14166 : {
14167 272210 : SymbolTable_PtrToSymbol pSym;
14168 :
14169 272210 : pSym = GetPsym (Sym);
14170 272210 : switch (pSym->SymbolType)
14171 : {
14172 : case SymbolTable_ErrorSym:
14173 : break;
14174 :
14175 136105 : case SymbolTable_ProcedureSym:
14176 136105 : pSym->Procedure.ReturnType = TypeSym;
14177 136105 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional = true;
14178 136105 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
14179 136105 : SymbolTable_PutOptFunction (tok, pSym->Procedure.ProcedureType, kind, TypeSym);
14180 136105 : break;
14181 :
14182 136105 : case SymbolTable_ProcTypeSym:
14183 136105 : pSym->ProcType.ReturnType = TypeSym;
14184 136105 : pSym->ProcType.ReturnTypeTok = tok;
14185 136105 : break;
14186 :
14187 :
14188 0 : default:
14189 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14190 136105 : break;
14191 : }
14192 136105 : }
14193 :
14194 :
14195 : /*
14196 : IsReturnOptional - returns TRUE if the return value for, sym, is
14197 : optional.
14198 : */
14199 :
14200 1705753 : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind)
14201 : {
14202 1705753 : SymbolTable_PtrToSymbol pSym;
14203 :
14204 1705753 : pSym = GetPsym (sym);
14205 1705753 : switch (pSym->SymbolType)
14206 : {
14207 1673921 : case SymbolTable_ProcedureSym:
14208 1673921 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional;
14209 31832 : break;
14210 :
14211 31832 : case SymbolTable_ProcTypeSym:
14212 31832 : return pSym->ProcType.ReturnOptional;
14213 0 : break;
14214 :
14215 :
14216 0 : default:
14217 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14218 : break;
14219 : }
14220 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14221 : __builtin_unreachable ();
14222 : }
14223 :
14224 :
14225 : /*
14226 : IsReturnOptionalAny - returns TRUE if the return value for sym is
14227 : optional.
14228 : */
14229 :
14230 9109 : extern "C" bool SymbolTable_IsReturnOptionalAny (unsigned int sym)
14231 : {
14232 9109 : SymbolTable_PtrToSymbol pSym;
14233 :
14234 9109 : pSym = GetPsym (sym);
14235 9109 : switch (pSym->SymbolType)
14236 : {
14237 9109 : case SymbolTable_ProcedureSym:
14238 9109 : return IsProcedureAnyBoolean (sym, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_IsReturnOptional});
14239 0 : break;
14240 :
14241 0 : case SymbolTable_ProcTypeSym:
14242 0 : return pSym->ProcType.ReturnOptional;
14243 0 : break;
14244 :
14245 :
14246 0 : default:
14247 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14248 : break;
14249 : }
14250 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14251 : __builtin_unreachable ();
14252 : }
14253 :
14254 :
14255 : /*
14256 : PutParam - Places a Non VAR parameter ParamName with type ParamType into
14257 : procedure Sym:kind. The parameter number is ParamNo.
14258 : If the procedure Sym already has this parameter then
14259 : the parameter is checked for consistancy and the
14260 : consistancy test is returned.
14261 : */
14262 :
14263 10547586 : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok)
14264 : {
14265 10547586 : SymbolTable_PtrToSymbol pSym;
14266 10547586 : unsigned int ParSym;
14267 10547586 : unsigned int VariableSym;
14268 :
14269 10547586 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
14270 : {
14271 : /* ParamNo <= NoOfParamAny (Sym) */
14272 0 : M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
14273 : }
14274 : else
14275 : {
14276 : /* Add a new parameter */
14277 10547586 : NewSym (&ParSym);
14278 10547586 : pSym = GetPsym (ParSym);
14279 10547586 : pSym->SymbolType = SymbolTable_ParamSym;
14280 10547586 : pSym->Param.name = ParamName;
14281 10547586 : pSym->Param.Type = ParamType;
14282 10547586 : pSym->Param.IsUnbounded = isUnbounded;
14283 10547586 : pSym->Param.Scope = Sym;
14284 10547586 : pSym->Param.ShadowVar = SymbolTable_NulSym;
14285 10547586 : pSym->Param.FullTok = M2LexBuf_MakeVirtual2Tok (tok, typetok);
14286 10547586 : pSym->Param.At = tok;
14287 10547586 : AddParameter (Sym, kind, ParSym);
14288 : /* Only declare a parameter as a local variable if it has not been done before.
14289 : It might be declared during the definition module, forward declaration or
14290 : proper procedure. Name mismatches are checked in P2SymBuild.mod. */
14291 10547586 : if ((ParamName != NameKey_NulName) && ((SymbolTable_GetNth (Sym, ParamNo)) == SymbolTable_NulSym))
14292 : {
14293 8302829 : VariableSym = MakeVariableForParam (tok, ParamName, Sym, kind, ParamNo, ParamType, typetok);
14294 8302829 : if (VariableSym == SymbolTable_NulSym)
14295 : {
14296 : return false;
14297 : }
14298 : else
14299 : {
14300 8302829 : pSym = GetPsym (ParSym);
14301 8302829 : pSym->Param.ShadowVar = VariableSym;
14302 : }
14303 : }
14304 10547586 : AddProcedureProcTypeParam (tok, Sym, ParamType, isUnbounded, false);
14305 : }
14306 10547586 : return true;
14307 : /* static analysis guarentees a RETURN statement will be used before here. */
14308 : __builtin_unreachable ();
14309 : }
14310 :
14311 :
14312 : /*
14313 : PutVarParam - Places a Non VAR parameter ParamName with type
14314 : ParamType into procedure Sym:kind.
14315 : The parameter number is ParamNo.
14316 : If the procedure Sym already has this parameter then
14317 : the parameter is checked for consistancy and the
14318 : consistancy test is returned.
14319 : */
14320 :
14321 982734 : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok)
14322 : {
14323 982734 : SymbolTable_PtrToSymbol pSym;
14324 982734 : unsigned int ParSym;
14325 982734 : unsigned int VariableSym;
14326 :
14327 982734 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
14328 : {
14329 0 : M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
14330 : }
14331 : else
14332 : {
14333 : /* Add a new parameter */
14334 982734 : NewSym (&ParSym);
14335 982734 : pSym = GetPsym (ParSym);
14336 982734 : pSym->SymbolType = SymbolTable_VarParamSym;
14337 982734 : pSym->VarParam.name = ParamName;
14338 982734 : pSym->VarParam.Type = ParamType;
14339 982734 : pSym->VarParam.IsUnbounded = isUnbounded;
14340 982734 : pSym->VarParam.Scope = Sym;
14341 982734 : pSym->VarParam.ShadowVar = SymbolTable_NulSym;
14342 982734 : pSym->VarParam.HeapVar = SymbolTable_NulSym; /* Will contain a pointer value. */
14343 982734 : pSym->VarParam.FullTok = M2LexBuf_MakeVirtual2Tok (tok, typetok); /* Will contain a pointer value. */
14344 982734 : pSym->VarParam.At = tok;
14345 982734 : AddParameter (Sym, kind, ParSym);
14346 : /* Only declare a parameter as a local variable if it has not been done before.
14347 : It might be declared during the definition module, forward declaration or
14348 : proper procedure. Name mismatches are checked in P2SymBuild.mod. */
14349 982734 : if ((ParamName != NameKey_NulName) && ((SymbolTable_GetNth (Sym, ParamNo)) == SymbolTable_NulSym))
14350 : {
14351 767851 : VariableSym = MakeVariableForParam (tok, ParamName, Sym, kind, ParamNo, ParamType, typetok);
14352 767851 : if (VariableSym == SymbolTable_NulSym)
14353 : {
14354 : return false;
14355 : }
14356 : else
14357 : {
14358 767851 : pSym = GetPsym (ParSym);
14359 767851 : pSym->VarParam.ShadowVar = VariableSym;
14360 : }
14361 : }
14362 982734 : AddProcedureProcTypeParam (tok, Sym, ParamType, isUnbounded, true);
14363 : }
14364 982734 : return true;
14365 : /* static analysis guarentees a RETURN statement will be used before here. */
14366 : __builtin_unreachable ();
14367 : }
14368 :
14369 :
14370 : /*
14371 : PutParamName - assigns a name to paramater no of procedure ProcSym:kind.
14372 : */
14373 :
14374 0 : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, NameKey_Name name, unsigned int ParamType, unsigned int typetok)
14375 : {
14376 0 : SymbolTable_PtrToSymbol pSym;
14377 0 : unsigned int ParSym;
14378 :
14379 0 : pSym = GetPsym (ProcSym);
14380 0 : ParSym = SymbolTable_NulSym;
14381 0 : switch (pSym->SymbolType)
14382 : {
14383 : case SymbolTable_ErrorSym:
14384 : return;
14385 0 : break;
14386 :
14387 0 : case SymbolTable_ProcedureSym:
14388 0 : ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, no));
14389 0 : break;
14390 :
14391 0 : case SymbolTable_ProcTypeSym:
14392 0 : ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, no));
14393 0 : break;
14394 :
14395 :
14396 0 : default:
14397 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14398 0 : break;
14399 : }
14400 0 : pSym = GetPsym (ParSym);
14401 0 : switch (pSym->SymbolType)
14402 : {
14403 0 : case SymbolTable_ParamSym:
14404 0 : if (pSym->Param.name == NameKey_NulName)
14405 : {
14406 0 : pSym->Param.name = name;
14407 0 : pSym->Param.ShadowVar = MakeVariableForParam (tok, name, ProcSym, kind, no, ParamType, typetok);
14408 : }
14409 : else
14410 : {
14411 0 : M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
14412 : }
14413 0 : break;
14414 :
14415 0 : case SymbolTable_VarParamSym:
14416 0 : if (pSym->VarParam.name == NameKey_NulName)
14417 : {
14418 0 : pSym->VarParam.name = name;
14419 0 : pSym->VarParam.ShadowVar = MakeVariableForParam (tok, name, ProcSym, kind, no, ParamType, typetok);
14420 : }
14421 : else
14422 : {
14423 0 : M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
14424 : }
14425 0 : break;
14426 :
14427 :
14428 0 : default:
14429 0 : M2Error_InternalError ((const char *) "expecting a VarParam or Param symbol", 36);
14430 0 : break;
14431 : }
14432 : }
14433 :
14434 :
14435 : /*
14436 : PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
14437 : main Module.
14438 : */
14439 :
14440 73375 : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym)
14441 : {
14442 73375 : SymbolTable_PtrToSymbol pSym;
14443 :
14444 73375 : pSym = GetPsym (Sym);
14445 73375 : switch (pSym->SymbolType)
14446 : {
14447 : case SymbolTable_ErrorSym:
14448 : break;
14449 :
14450 73375 : case SymbolTable_ProcedureSym:
14451 73375 : pSym->Procedure.Reachable = true;
14452 73375 : break;
14453 :
14454 :
14455 0 : default:
14456 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14457 73375 : break;
14458 : }
14459 73375 : }
14460 :
14461 :
14462 : /*
14463 : IsProcedureReachable - Returns true if the procedure, Sym, is
14464 : reachable from the main Module.
14465 : */
14466 :
14467 244639 : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym)
14468 : {
14469 244639 : SymbolTable_PtrToSymbol pSym;
14470 :
14471 244639 : pSym = GetPsym (Sym);
14472 244639 : switch (pSym->SymbolType)
14473 : {
14474 244639 : case SymbolTable_ProcedureSym:
14475 244639 : return pSym->Procedure.Reachable;
14476 0 : break;
14477 :
14478 :
14479 0 : default:
14480 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14481 : break;
14482 : }
14483 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14484 : __builtin_unreachable ();
14485 : }
14486 :
14487 :
14488 : /*
14489 : PutProcedureNoReturn - places value into the no return attribute
14490 : field of procedure sym.
14491 : */
14492 :
14493 499729 : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind, bool value)
14494 : {
14495 499729 : SymbolTable_PtrToSymbol pSym;
14496 :
14497 499729 : pSym = GetPsym (Sym);
14498 499729 : switch (pSym->SymbolType)
14499 : {
14500 499729 : case SymbolTable_ProcedureSym:
14501 499729 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].IsNoReturn = value;
14502 499729 : break;
14503 :
14504 :
14505 0 : default:
14506 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
14507 499729 : break;
14508 : }
14509 499729 : }
14510 :
14511 :
14512 : /*
14513 : IsProcedureNoReturn - returns TRUE if this procedure never returns.
14514 : */
14515 :
14516 3352083 : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind)
14517 : {
14518 3352083 : SymbolTable_PtrToSymbol pSym;
14519 :
14520 3352083 : pSym = GetPsym (Sym);
14521 3352083 : switch (pSym->SymbolType)
14522 : {
14523 3352083 : case SymbolTable_ProcedureSym:
14524 3352083 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].IsNoReturn;
14525 0 : break;
14526 :
14527 :
14528 0 : default:
14529 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
14530 : break;
14531 : }
14532 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14533 : __builtin_unreachable ();
14534 : }
14535 :
14536 :
14537 : /*
14538 : GetProcedureProcType - returns the proctype matching procedure sym.
14539 : */
14540 :
14541 765336 : extern "C" unsigned int SymbolTable_GetProcedureProcType (unsigned int sym)
14542 : {
14543 765336 : SymbolTable_PtrToSymbol pSym;
14544 :
14545 765336 : pSym = GetPsym (sym);
14546 765336 : switch (pSym->SymbolType)
14547 : {
14548 765336 : case SymbolTable_ProcedureSym:
14549 765336 : return pSym->Procedure.ProcedureType;
14550 0 : break;
14551 :
14552 :
14553 0 : default:
14554 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14555 : break;
14556 : }
14557 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14558 : __builtin_unreachable ();
14559 : }
14560 :
14561 :
14562 : /*
14563 : PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
14564 : QuadNumber is the start quad of Module,
14565 : Sym.
14566 : */
14567 :
14568 84743 : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber)
14569 : {
14570 84743 : SymbolTable_PtrToSymbol pSym;
14571 :
14572 84743 : pSym = GetPsym (Sym);
14573 84743 : switch (pSym->SymbolType)
14574 : {
14575 12099 : case SymbolTable_ModuleSym:
14576 12099 : pSym->Module.StartQuad = QuadNumber;
14577 12099 : break;
14578 :
14579 72644 : case SymbolTable_DefImpSym:
14580 72644 : pSym->DefImp.StartQuad = QuadNumber;
14581 72644 : break;
14582 :
14583 :
14584 0 : default:
14585 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14586 84743 : break;
14587 : }
14588 84743 : }
14589 :
14590 :
14591 : /*
14592 : PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
14593 : QuadNumber is the end quad of Module,
14594 : Sym.
14595 : */
14596 :
14597 84592 : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber)
14598 : {
14599 84592 : SymbolTable_PtrToSymbol pSym;
14600 :
14601 84592 : pSym = GetPsym (Sym);
14602 84592 : switch (pSym->SymbolType)
14603 : {
14604 11948 : case SymbolTable_ModuleSym:
14605 11948 : pSym->Module.EndQuad = QuadNumber;
14606 11948 : break;
14607 :
14608 72644 : case SymbolTable_DefImpSym:
14609 72644 : pSym->DefImp.EndQuad = QuadNumber;
14610 72644 : break;
14611 :
14612 :
14613 0 : default:
14614 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14615 84592 : break;
14616 : }
14617 84592 : }
14618 :
14619 :
14620 : /*
14621 : PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
14622 : QuadNumber is the finally start quad of
14623 : Module, Sym.
14624 : */
14625 :
14626 15808 : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber)
14627 : {
14628 15808 : SymbolTable_PtrToSymbol pSym;
14629 :
14630 15808 : pSym = GetPsym (Sym);
14631 15808 : switch (pSym->SymbolType)
14632 : {
14633 11942 : case SymbolTable_ModuleSym:
14634 11942 : pSym->Module.StartFinishQuad = QuadNumber;
14635 11942 : break;
14636 :
14637 3866 : case SymbolTable_DefImpSym:
14638 3866 : pSym->DefImp.StartFinishQuad = QuadNumber;
14639 3866 : break;
14640 :
14641 :
14642 0 : default:
14643 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14644 15808 : break;
14645 : }
14646 15808 : }
14647 :
14648 :
14649 : /*
14650 : PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
14651 : QuadNumber is the end quad of the finally block
14652 : in Module, Sym.
14653 : */
14654 :
14655 15808 : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber)
14656 : {
14657 15808 : SymbolTable_PtrToSymbol pSym;
14658 :
14659 15808 : pSym = GetPsym (Sym);
14660 15808 : switch (pSym->SymbolType)
14661 : {
14662 11942 : case SymbolTable_ModuleSym:
14663 11942 : pSym->Module.EndFinishQuad = QuadNumber;
14664 11942 : break;
14665 :
14666 3866 : case SymbolTable_DefImpSym:
14667 3866 : pSym->DefImp.EndFinishQuad = QuadNumber;
14668 3866 : break;
14669 :
14670 :
14671 0 : default:
14672 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14673 15808 : break;
14674 : }
14675 15808 : }
14676 :
14677 :
14678 : /*
14679 : GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
14680 : Quads of a Module, Sym.
14681 : Start and End represent the initialization code
14682 : of the Module, Sym.
14683 : */
14684 :
14685 0 : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish)
14686 : {
14687 0 : SymbolTable_PtrToSymbol pSym;
14688 :
14689 0 : pSym = GetPsym (Sym);
14690 0 : switch (pSym->SymbolType)
14691 : {
14692 0 : case SymbolTable_ModuleSym:
14693 0 : (*StartInit) = pSym->Module.StartQuad;
14694 0 : (*EndInit) = pSym->Module.EndQuad;
14695 0 : (*StartFinish) = pSym->Module.StartFinishQuad;
14696 0 : (*EndFinish) = pSym->Module.EndFinishQuad;
14697 0 : break;
14698 :
14699 0 : case SymbolTable_DefImpSym:
14700 0 : (*StartInit) = pSym->DefImp.StartQuad;
14701 0 : (*EndInit) = pSym->DefImp.EndQuad;
14702 0 : (*StartFinish) = pSym->DefImp.StartFinishQuad;
14703 0 : (*EndFinish) = pSym->DefImp.EndFinishQuad;
14704 0 : break;
14705 :
14706 :
14707 0 : default:
14708 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14709 0 : break;
14710 : }
14711 0 : }
14712 :
14713 :
14714 : /*
14715 : PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
14716 : */
14717 :
14718 0 : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, tree finally)
14719 : {
14720 0 : SymbolTable_PtrToSymbol pSym;
14721 :
14722 0 : pSym = GetPsym (Sym);
14723 0 : switch (pSym->SymbolType)
14724 : {
14725 0 : case SymbolTable_ModuleSym:
14726 0 : pSym->Module.FinallyFunction = finally;
14727 0 : break;
14728 :
14729 0 : case SymbolTable_DefImpSym:
14730 0 : pSym->DefImp.FinallyFunction = finally;
14731 0 : break;
14732 :
14733 :
14734 0 : default:
14735 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14736 0 : break;
14737 : }
14738 0 : }
14739 :
14740 :
14741 : /*
14742 : GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
14743 : */
14744 :
14745 0 : extern "C" tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym)
14746 : {
14747 0 : SymbolTable_PtrToSymbol pSym;
14748 :
14749 0 : pSym = GetPsym (Sym);
14750 0 : switch (pSym->SymbolType)
14751 : {
14752 0 : case SymbolTable_ModuleSym:
14753 0 : return pSym->Module.FinallyFunction;
14754 0 : break;
14755 :
14756 0 : case SymbolTable_DefImpSym:
14757 0 : return pSym->DefImp.FinallyFunction;
14758 0 : break;
14759 :
14760 :
14761 0 : default:
14762 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14763 : break;
14764 : }
14765 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14766 : __builtin_unreachable ();
14767 : }
14768 :
14769 :
14770 : /*
14771 : PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
14772 : QuadNumber is the start quad of scope for procedure,
14773 : Sym.
14774 : */
14775 :
14776 82774 : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber)
14777 : {
14778 82774 : SymbolTable_PtrToSymbol pSym;
14779 :
14780 82774 : pSym = GetPsym (Sym);
14781 82774 : switch (pSym->SymbolType)
14782 : {
14783 82774 : case SymbolTable_ProcedureSym:
14784 82774 : pSym->Procedure.ScopeQuad = QuadNumber;
14785 82774 : break;
14786 :
14787 :
14788 0 : default:
14789 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14790 82774 : break;
14791 : }
14792 82774 : }
14793 :
14794 :
14795 : /*
14796 : PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
14797 : QuadNumber is the start quad of procedure,
14798 : Sym.
14799 : */
14800 :
14801 82762 : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber)
14802 : {
14803 82762 : SymbolTable_PtrToSymbol pSym;
14804 :
14805 82762 : pSym = GetPsym (Sym);
14806 82762 : switch (pSym->SymbolType)
14807 : {
14808 82762 : case SymbolTable_ProcedureSym:
14809 82762 : pSym->Procedure.StartQuad = QuadNumber;
14810 82762 : break;
14811 :
14812 :
14813 0 : default:
14814 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14815 82762 : break;
14816 : }
14817 82762 : }
14818 :
14819 :
14820 : /*
14821 : PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
14822 : QuadNumber is the end quad of procedure,
14823 : Sym.
14824 : */
14825 :
14826 82730 : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber)
14827 : {
14828 82730 : SymbolTable_PtrToSymbol pSym;
14829 :
14830 82730 : pSym = GetPsym (Sym);
14831 82730 : switch (pSym->SymbolType)
14832 : {
14833 82730 : case SymbolTable_ProcedureSym:
14834 82730 : pSym->Procedure.EndQuad = QuadNumber;
14835 82730 : break;
14836 :
14837 :
14838 0 : default:
14839 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14840 82730 : break;
14841 : }
14842 82730 : }
14843 :
14844 :
14845 : /*
14846 : GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
14847 : */
14848 :
14849 717585 : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end)
14850 : {
14851 717585 : SymbolTable_PtrToSymbol pSym;
14852 :
14853 717585 : pSym = GetPsym (Sym);
14854 717585 : switch (pSym->SymbolType)
14855 : {
14856 717585 : case SymbolTable_ProcedureSym:
14857 717585 : (*scope) = pSym->Procedure.ScopeQuad;
14858 717585 : (*start) = pSym->Procedure.StartQuad;
14859 717585 : (*end) = pSym->Procedure.EndQuad;
14860 717585 : break;
14861 :
14862 :
14863 0 : default:
14864 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14865 717585 : break;
14866 : }
14867 717585 : }
14868 :
14869 :
14870 : /*
14871 : GetQuads - assigns Start and End to the beginning and end of
14872 : symbol, Sym, usage.
14873 : */
14874 :
14875 0 : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14876 : {
14877 0 : unsigned int StartRead;
14878 0 : unsigned int EndRead;
14879 0 : unsigned int StartWrite;
14880 0 : unsigned int EndWrite;
14881 :
14882 0 : SymbolTable_GetReadQuads (Sym, m, &StartRead, &EndRead);
14883 0 : SymbolTable_GetWriteQuads (Sym, m, &StartWrite, &EndWrite);
14884 0 : if (StartRead == 0)
14885 : {
14886 0 : (*Start) = StartWrite;
14887 : }
14888 0 : else if (StartWrite == 0)
14889 : {
14890 : /* avoid dangling else. */
14891 0 : (*Start) = StartRead;
14892 : }
14893 : else
14894 : {
14895 : /* avoid dangling else. */
14896 0 : (*Start) = Min (StartRead, StartWrite);
14897 : }
14898 0 : if (EndRead == 0)
14899 : {
14900 0 : (*End) = EndWrite;
14901 : }
14902 0 : else if (EndWrite == 0)
14903 : {
14904 : /* avoid dangling else. */
14905 0 : (*End) = EndRead;
14906 : }
14907 : else
14908 : {
14909 : /* avoid dangling else. */
14910 0 : (*End) = Max (EndRead, EndWrite);
14911 : }
14912 0 : }
14913 :
14914 :
14915 : /*
14916 : GetReadQuads - assigns Start and End to the beginning and end of
14917 : symbol, Sym, read history usage.
14918 : */
14919 :
14920 0 : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14921 : {
14922 0 : SymbolTable_GetReadLimitQuads (Sym, m, 0, 0, Start, End);
14923 0 : }
14924 :
14925 :
14926 : /*
14927 : GetWriteQuads - assigns Start and End to the beginning and end of
14928 : symbol, Sym, usage.
14929 : */
14930 :
14931 0 : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14932 : {
14933 0 : SymbolTable_GetWriteLimitQuads (Sym, m, 0, 0, Start, End);
14934 0 : }
14935 :
14936 :
14937 : /*
14938 : PutReadQuad - places Quad into the list of symbol usage.
14939 : */
14940 :
14941 1626291 : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14942 : {
14943 1626291 : SymbolTable_PtrToSymbol pSym;
14944 :
14945 1626291 : pSym = GetPsym (Sym);
14946 1626291 : switch (pSym->SymbolType)
14947 : {
14948 1626291 : case SymbolTable_VarSym:
14949 1626291 : Lists_IncludeItemIntoList (static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]), Quad);
14950 1626291 : break;
14951 :
14952 :
14953 0 : default:
14954 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14955 1626291 : break;
14956 : }
14957 1626291 : }
14958 :
14959 :
14960 : /*
14961 : RemoveReadQuad - places Quad into the list of symbol usage.
14962 : */
14963 :
14964 134207 : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14965 : {
14966 134207 : SymbolTable_PtrToSymbol pSym;
14967 :
14968 134207 : pSym = GetPsym (Sym);
14969 134207 : switch (pSym->SymbolType)
14970 : {
14971 134207 : case SymbolTable_VarSym:
14972 134207 : Lists_RemoveItemFromList (static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]), Quad);
14973 134207 : break;
14974 :
14975 :
14976 0 : default:
14977 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14978 134207 : break;
14979 : }
14980 134207 : }
14981 :
14982 :
14983 : /*
14984 : PutWriteQuad - places Quad into the list of symbol usage.
14985 : */
14986 :
14987 1056162 : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14988 : {
14989 1056162 : SymbolTable_PtrToSymbol pSym;
14990 :
14991 1056162 : pSym = GetPsym (Sym);
14992 1056162 : switch (pSym->SymbolType)
14993 : {
14994 1056162 : case SymbolTable_VarSym:
14995 1056162 : Lists_IncludeItemIntoList (static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]), Quad);
14996 1056162 : break;
14997 :
14998 :
14999 0 : default:
15000 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
15001 1056162 : break;
15002 : }
15003 1056162 : }
15004 :
15005 :
15006 : /*
15007 : RemoveWriteQuad - places Quad into the list of symbol usage.
15008 : */
15009 :
15010 217709 : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
15011 : {
15012 217709 : SymbolTable_PtrToSymbol pSym;
15013 :
15014 217709 : pSym = GetPsym (Sym);
15015 217709 : switch (pSym->SymbolType)
15016 : {
15017 217709 : case SymbolTable_VarSym:
15018 217709 : Lists_RemoveItemFromList (static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]), Quad);
15019 217709 : break;
15020 :
15021 :
15022 0 : default:
15023 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
15024 217709 : break;
15025 : }
15026 217709 : }
15027 :
15028 :
15029 : /*
15030 : GetReadLimitQuads - returns Start and End which have been assigned
15031 : the start and end of when the symbol was read
15032 : to within: StartLimit..EndLimit.
15033 : */
15034 :
15035 0 : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
15036 : {
15037 0 : SymbolTable_PtrToSymbol pSym;
15038 :
15039 0 : pSym = GetPsym (Sym);
15040 0 : switch (pSym->SymbolType)
15041 : {
15042 0 : case SymbolTable_VarSym:
15043 0 : DoFindLimits (StartLimit, EndLimit, Start, End, static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]));
15044 0 : break;
15045 :
15046 :
15047 0 : default:
15048 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
15049 0 : break;
15050 : }
15051 0 : }
15052 :
15053 :
15054 : /*
15055 : GetWriteLimitQuads - returns Start and End which have been assigned
15056 : the start and end of when the symbol was written
15057 : to within: StartLimit..EndLimit.
15058 : */
15059 :
15060 30 : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
15061 : {
15062 30 : SymbolTable_PtrToSymbol pSym;
15063 :
15064 30 : pSym = GetPsym (Sym);
15065 30 : switch (pSym->SymbolType)
15066 : {
15067 30 : case SymbolTable_VarSym:
15068 30 : DoFindLimits (StartLimit, EndLimit, Start, End, static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]));
15069 30 : break;
15070 :
15071 :
15072 0 : default:
15073 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
15074 30 : break;
15075 : }
15076 30 : }
15077 :
15078 :
15079 : /*
15080 : GetNthProcedure - Returns the Nth procedure in Module, Sym.
15081 : */
15082 :
15083 12661 : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n)
15084 : {
15085 12661 : SymbolTable_PtrToSymbol pSym;
15086 :
15087 12661 : pSym = GetPsym (Sym);
15088 12661 : switch (pSym->SymbolType)
15089 : {
15090 12652 : case SymbolTable_DefImpSym:
15091 12652 : return static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfProcs, n));
15092 9 : break;
15093 :
15094 9 : case SymbolTable_ModuleSym:
15095 9 : return static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfProcs, n));
15096 0 : break;
15097 :
15098 :
15099 0 : default:
15100 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
15101 : break;
15102 : }
15103 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15104 : __builtin_unreachable ();
15105 : }
15106 :
15107 :
15108 : /*
15109 : GetDeclaredDef - returns the tokenno where the symbol was declared
15110 : in the definition module. UnknownTokenNo is returned
15111 : if no declaration occurred.
15112 : */
15113 :
15114 36 : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym)
15115 : {
15116 36 : return SymbolTable_GetDeclaredDefinition (Sym);
15117 : /* static analysis guarentees a RETURN statement will be used before here. */
15118 : __builtin_unreachable ();
15119 : }
15120 :
15121 :
15122 : /*
15123 : GetDeclaredMod - returns the tokenno where the symbol was declared.
15124 : in the program or implementation module.
15125 : UnknownTokenNo is returned if no declaration occurred.
15126 : */
15127 :
15128 35716567 : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym)
15129 : {
15130 35716567 : return SymbolTable_GetDeclaredModule (Sym);
15131 : /* static analysis guarentees a RETURN statement will be used before here. */
15132 : __builtin_unreachable ();
15133 : }
15134 :
15135 :
15136 : /*
15137 : GetDeclaredFor - returns the token where this forward procedure symbol
15138 : was declared in the program or implementation module.
15139 : UnknownTokenNo is returned if no declaration occurred.
15140 : */
15141 :
15142 0 : extern "C" unsigned int SymbolTable_GetDeclaredFor (unsigned int Sym)
15143 : {
15144 0 : if (SymbolTable_IsProcedure (Sym))
15145 : {
15146 0 : return SymbolTable_GetProcedureDeclaredTok (Sym, SymbolTable_ForwardProcedure);
15147 : }
15148 : else
15149 : {
15150 : return M2LexBuf_UnknownTokenNo;
15151 : }
15152 : /* static analysis guarentees a RETURN statement will be used before here. */
15153 : __builtin_unreachable ();
15154 : }
15155 :
15156 :
15157 : /*
15158 : GetDeclaredDefinition - returns the token where this symbol
15159 : was declared in the definition module.
15160 : */
15161 :
15162 23061 : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym)
15163 : {
15164 23061 : SymbolTable_PtrToSymbol pSym;
15165 :
15166 23061 : pSym = GetPsym (Sym);
15167 23061 : switch (pSym->SymbolType)
15168 : {
15169 0 : case SymbolTable_ErrorSym:
15170 0 : return pSym->Error.At.DefDeclared;
15171 0 : break;
15172 :
15173 0 : case SymbolTable_ObjectSym:
15174 0 : return pSym->Object.At.DefDeclared;
15175 0 : break;
15176 :
15177 0 : case SymbolTable_VarientSym:
15178 0 : return pSym->Varient.At.DefDeclared;
15179 6 : break;
15180 :
15181 6 : case SymbolTable_RecordSym:
15182 6 : return pSym->Record.At.DefDeclared;
15183 0 : break;
15184 :
15185 0 : case SymbolTable_SubrangeSym:
15186 0 : return pSym->Subrange.At.DefDeclared;
15187 0 : break;
15188 :
15189 0 : case SymbolTable_EnumerationSym:
15190 0 : return pSym->Enumeration.At.DefDeclared;
15191 0 : break;
15192 :
15193 0 : case SymbolTable_ArraySym:
15194 0 : return pSym->Array.At.DefDeclared;
15195 0 : break;
15196 :
15197 0 : case SymbolTable_SubscriptSym:
15198 0 : return pSym->Subscript.At.DefDeclared;
15199 0 : break;
15200 :
15201 0 : case SymbolTable_UnboundedSym:
15202 0 : return pSym->Unbounded.At.DefDeclared;
15203 0 : break;
15204 :
15205 0 : case SymbolTable_ProcedureSym:
15206 0 : return pSym->Procedure.At.DefDeclared;
15207 0 : break;
15208 :
15209 0 : case SymbolTable_ProcTypeSym:
15210 0 : return pSym->ProcType.At.DefDeclared;
15211 30 : break;
15212 :
15213 30 : case SymbolTable_ParamSym:
15214 30 : return pSym->Param.At;
15215 0 : break;
15216 :
15217 0 : case SymbolTable_VarParamSym:
15218 0 : return pSym->VarParam.At;
15219 0 : break;
15220 :
15221 0 : case SymbolTable_ConstStringSym:
15222 0 : return pSym->ConstString.At.DefDeclared;
15223 0 : break;
15224 :
15225 0 : case SymbolTable_ConstLitSym:
15226 0 : return pSym->ConstLit.At.DefDeclared;
15227 0 : break;
15228 :
15229 0 : case SymbolTable_ConstVarSym:
15230 0 : return pSym->ConstVar.At.DefDeclared;
15231 0 : break;
15232 :
15233 0 : case SymbolTable_VarSym:
15234 0 : return pSym->Var.At.DefDeclared;
15235 0 : break;
15236 :
15237 0 : case SymbolTable_TypeSym:
15238 0 : return pSym->Type.At.DefDeclared;
15239 0 : break;
15240 :
15241 0 : case SymbolTable_PointerSym:
15242 0 : return pSym->Pointer.At.DefDeclared;
15243 0 : break;
15244 :
15245 0 : case SymbolTable_RecordFieldSym:
15246 0 : return pSym->RecordField.At.DefDeclared;
15247 0 : break;
15248 :
15249 0 : case SymbolTable_VarientFieldSym:
15250 0 : return pSym->VarientField.At.DefDeclared;
15251 0 : break;
15252 :
15253 0 : case SymbolTable_EnumerationFieldSym:
15254 0 : return pSym->EnumerationField.At.DefDeclared;
15255 0 : break;
15256 :
15257 0 : case SymbolTable_SetSym:
15258 0 : return pSym->Set.At.DefDeclared;
15259 0 : break;
15260 :
15261 0 : case SymbolTable_DefImpSym:
15262 0 : return pSym->DefImp.At.DefDeclared;
15263 0 : break;
15264 :
15265 0 : case SymbolTable_ModuleSym:
15266 0 : return pSym->Module.At.DefDeclared;
15267 0 : break;
15268 :
15269 0 : case SymbolTable_UndefinedSym:
15270 0 : return SymbolTable_GetFirstUsed (Sym);
15271 23025 : break;
15272 :
15273 23025 : case SymbolTable_ImportSym:
15274 23025 : return pSym->Import.at.DefDeclared;
15275 0 : break;
15276 :
15277 0 : case SymbolTable_ImportStatementSym:
15278 0 : return pSym->ImportStatement.at.DefDeclared;
15279 0 : break;
15280 :
15281 0 : case SymbolTable_PartialUnboundedSym:
15282 0 : return SymbolTable_GetDeclaredDefinition (pSym->PartialUnbounded.Type);
15283 0 : break;
15284 :
15285 :
15286 0 : default:
15287 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15288 : break;
15289 : }
15290 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15291 : __builtin_unreachable ();
15292 : }
15293 :
15294 :
15295 : /*
15296 : GetDeclaredModule - returns the token where this symbol was declared
15297 : in an implementation or program module.
15298 : */
15299 :
15300 35737791 : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym)
15301 : {
15302 35737791 : SymbolTable_PtrToSymbol pSym;
15303 :
15304 35737791 : pSym = GetPsym (Sym);
15305 35737791 : switch (pSym->SymbolType)
15306 : {
15307 0 : case SymbolTable_ErrorSym:
15308 0 : return pSym->Error.At.ModDeclared;
15309 0 : break;
15310 :
15311 0 : case SymbolTable_ObjectSym:
15312 0 : return pSym->Object.At.ModDeclared;
15313 6108 : break;
15314 :
15315 6108 : case SymbolTable_VarientSym:
15316 6108 : return pSym->Varient.At.ModDeclared;
15317 306081 : break;
15318 :
15319 306081 : case SymbolTable_RecordSym:
15320 306081 : return pSym->Record.At.ModDeclared;
15321 6298045 : break;
15322 :
15323 6298045 : case SymbolTable_SubrangeSym:
15324 6298045 : return pSym->Subrange.At.ModDeclared;
15325 35742 : break;
15326 :
15327 35742 : case SymbolTable_EnumerationSym:
15328 35742 : return pSym->Enumeration.At.ModDeclared;
15329 172919 : break;
15330 :
15331 172919 : case SymbolTable_ArraySym:
15332 172919 : return pSym->Array.At.ModDeclared;
15333 0 : break;
15334 :
15335 0 : case SymbolTable_SubscriptSym:
15336 0 : return pSym->Subscript.At.ModDeclared;
15337 46384 : break;
15338 :
15339 46384 : case SymbolTable_UnboundedSym:
15340 46384 : return pSym->Unbounded.At.ModDeclared;
15341 5461164 : break;
15342 :
15343 5461164 : case SymbolTable_ProcedureSym:
15344 5461164 : return pSym->Procedure.At.ModDeclared;
15345 58984 : break;
15346 :
15347 58984 : case SymbolTable_ProcTypeSym:
15348 58984 : return pSym->ProcType.At.ModDeclared;
15349 76443 : break;
15350 :
15351 76443 : case SymbolTable_ParamSym:
15352 76443 : return pSym->Param.At;
15353 554962 : break;
15354 :
15355 554962 : case SymbolTable_VarParamSym:
15356 554962 : return pSym->VarParam.At;
15357 971661 : break;
15358 :
15359 971661 : case SymbolTable_ConstStringSym:
15360 971661 : return pSym->ConstString.At.ModDeclared;
15361 1293463 : break;
15362 :
15363 1293463 : case SymbolTable_ConstLitSym:
15364 1293463 : return pSym->ConstLit.At.ModDeclared;
15365 663529 : break;
15366 :
15367 663529 : case SymbolTable_ConstVarSym:
15368 663529 : return pSym->ConstVar.At.ModDeclared;
15369 8348720 : break;
15370 :
15371 8348720 : case SymbolTable_VarSym:
15372 8348720 : return pSym->Var.At.ModDeclared;
15373 38760 : break;
15374 :
15375 38760 : case SymbolTable_TypeSym:
15376 38760 : return pSym->Type.At.ModDeclared;
15377 12 : break;
15378 :
15379 12 : case SymbolTable_PointerSym:
15380 12 : return pSym->Pointer.At.ModDeclared;
15381 412222 : break;
15382 :
15383 412222 : case SymbolTable_RecordFieldSym:
15384 412222 : return pSym->RecordField.At.ModDeclared;
15385 12444 : break;
15386 :
15387 12444 : case SymbolTable_VarientFieldSym:
15388 12444 : return pSym->VarientField.At.ModDeclared;
15389 10584103 : break;
15390 :
15391 10584103 : case SymbolTable_EnumerationFieldSym:
15392 10584103 : return pSym->EnumerationField.At.ModDeclared;
15393 344598 : break;
15394 :
15395 344598 : case SymbolTable_SetSym:
15396 344598 : return pSym->Set.At.ModDeclared;
15397 7743 : break;
15398 :
15399 7743 : case SymbolTable_DefImpSym:
15400 7743 : return pSym->DefImp.At.ModDeclared;
15401 22486 : break;
15402 :
15403 22486 : case SymbolTable_ModuleSym:
15404 22486 : return pSym->Module.At.ModDeclared;
15405 0 : break;
15406 :
15407 0 : case SymbolTable_UndefinedSym:
15408 0 : return SymbolTable_GetFirstUsed (Sym);
15409 21218 : break;
15410 :
15411 21218 : case SymbolTable_ImportSym:
15412 21218 : return pSym->Import.at.ModDeclared;
15413 0 : break;
15414 :
15415 0 : case SymbolTable_ImportStatementSym:
15416 0 : return pSym->ImportStatement.at.ModDeclared;
15417 0 : break;
15418 :
15419 0 : case SymbolTable_PartialUnboundedSym:
15420 0 : return SymbolTable_GetDeclaredModule (pSym->PartialUnbounded.Type);
15421 0 : break;
15422 :
15423 :
15424 0 : default:
15425 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15426 : break;
15427 : }
15428 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15429 : __builtin_unreachable ();
15430 : }
15431 :
15432 :
15433 : /*
15434 : PutDeclared - adds an entry to symbol, Sym, indicating that it
15435 : was declared at, tok. This routine
15436 : may be called twice, once for definition module
15437 : partial declaration and once when parsing the
15438 : implementation module.
15439 : */
15440 :
15441 32220053 : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym)
15442 : {
15443 32220053 : if (M2Comp_CompilingDefinitionModule ())
15444 : {
15445 18965152 : PutDeclaredDefinition (tok, Sym);
15446 : }
15447 : else
15448 : {
15449 13254901 : PutDeclaredModule (tok, Sym);
15450 : }
15451 32220053 : }
15452 :
15453 :
15454 : /*
15455 : GetFirstUsed - returns the token where this symbol was first used.
15456 : */
15457 :
15458 558 : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym)
15459 : {
15460 558 : SymbolTable_PtrToSymbol pSym;
15461 :
15462 558 : pSym = GetPsym (Sym);
15463 558 : switch (pSym->SymbolType)
15464 : {
15465 0 : case SymbolTable_ErrorSym:
15466 0 : return pSym->Error.At.FirstUsed;
15467 188 : break;
15468 :
15469 188 : case SymbolTable_ObjectSym:
15470 188 : return pSym->Object.At.FirstUsed;
15471 358 : break;
15472 :
15473 358 : case SymbolTable_UndefinedSym:
15474 358 : return pSym->Undefined.At.FirstUsed;
15475 0 : break;
15476 :
15477 0 : case SymbolTable_VarientSym:
15478 0 : return pSym->Varient.At.FirstUsed;
15479 0 : break;
15480 :
15481 0 : case SymbolTable_RecordSym:
15482 0 : return pSym->Record.At.FirstUsed;
15483 0 : break;
15484 :
15485 0 : case SymbolTable_SubrangeSym:
15486 0 : return pSym->Subrange.At.FirstUsed;
15487 0 : break;
15488 :
15489 0 : case SymbolTable_EnumerationSym:
15490 0 : return pSym->Enumeration.At.FirstUsed;
15491 0 : break;
15492 :
15493 0 : case SymbolTable_ArraySym:
15494 0 : return pSym->Array.At.FirstUsed;
15495 0 : break;
15496 :
15497 0 : case SymbolTable_SubscriptSym:
15498 0 : return pSym->Subscript.At.FirstUsed;
15499 0 : break;
15500 :
15501 0 : case SymbolTable_UnboundedSym:
15502 0 : return pSym->Unbounded.At.FirstUsed;
15503 0 : break;
15504 :
15505 0 : case SymbolTable_ProcedureSym:
15506 0 : return pSym->Procedure.At.FirstUsed;
15507 0 : break;
15508 :
15509 0 : case SymbolTable_ProcTypeSym:
15510 0 : return pSym->ProcType.At.FirstUsed;
15511 0 : break;
15512 :
15513 0 : case SymbolTable_ConstStringSym:
15514 : /*
15515 : ParamSym : RETURN( Param.At.FirstUsed ) |
15516 : VarParamSym : RETURN( VarParam.At.FirstUsed ) |
15517 : */
15518 0 : return pSym->ConstString.At.FirstUsed;
15519 0 : break;
15520 :
15521 0 : case SymbolTable_ConstLitSym:
15522 0 : return pSym->ConstLit.At.FirstUsed;
15523 6 : break;
15524 :
15525 6 : case SymbolTable_ConstVarSym:
15526 6 : return pSym->ConstVar.At.FirstUsed;
15527 6 : break;
15528 :
15529 6 : case SymbolTable_VarSym:
15530 6 : return pSym->Var.At.FirstUsed;
15531 0 : break;
15532 :
15533 0 : case SymbolTable_TypeSym:
15534 0 : return pSym->Type.At.FirstUsed;
15535 0 : break;
15536 :
15537 0 : case SymbolTable_PointerSym:
15538 0 : return pSym->Pointer.At.FirstUsed;
15539 0 : break;
15540 :
15541 0 : case SymbolTable_RecordFieldSym:
15542 0 : return pSym->RecordField.At.FirstUsed;
15543 0 : break;
15544 :
15545 0 : case SymbolTable_VarientFieldSym:
15546 0 : return pSym->VarientField.At.FirstUsed;
15547 0 : break;
15548 :
15549 0 : case SymbolTable_EnumerationFieldSym:
15550 0 : return pSym->EnumerationField.At.FirstUsed;
15551 0 : break;
15552 :
15553 0 : case SymbolTable_SetSym:
15554 0 : return pSym->Set.At.FirstUsed;
15555 0 : break;
15556 :
15557 0 : case SymbolTable_DefImpSym:
15558 0 : return pSym->DefImp.At.FirstUsed;
15559 0 : break;
15560 :
15561 0 : case SymbolTable_ModuleSym:
15562 0 : return pSym->Module.At.FirstUsed;
15563 0 : break;
15564 :
15565 :
15566 0 : default:
15567 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15568 : break;
15569 : }
15570 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15571 : __builtin_unreachable ();
15572 : }
15573 :
15574 :
15575 : /*
15576 : PutProcedureBegin - assigns begin as the token number matching the
15577 : procedure BEGIN.
15578 : */
15579 :
15580 82762 : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin)
15581 : {
15582 82762 : SymbolTable_PtrToSymbol pSym;
15583 :
15584 82762 : pSym = GetPsym (Sym);
15585 82762 : switch (pSym->SymbolType)
15586 : {
15587 82762 : case SymbolTable_ProcedureSym:
15588 82762 : pSym->Procedure.Begin = begin;
15589 82762 : break;
15590 :
15591 :
15592 0 : default:
15593 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15594 82762 : break;
15595 : }
15596 82762 : }
15597 :
15598 :
15599 : /*
15600 : PutProcedureEnd - assigns end as the token number matching the
15601 : procedure END.
15602 : */
15603 :
15604 82730 : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end)
15605 : {
15606 82730 : SymbolTable_PtrToSymbol pSym;
15607 :
15608 82730 : pSym = GetPsym (Sym);
15609 82730 : switch (pSym->SymbolType)
15610 : {
15611 82730 : case SymbolTable_ProcedureSym:
15612 82730 : pSym->Procedure.End = end;
15613 82730 : break;
15614 :
15615 :
15616 0 : default:
15617 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15618 82730 : break;
15619 : }
15620 82730 : }
15621 :
15622 :
15623 : /*
15624 : GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
15625 : */
15626 :
15627 3997480 : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end)
15628 : {
15629 3997480 : SymbolTable_PtrToSymbol pSym;
15630 :
15631 3997480 : pSym = GetPsym (Sym);
15632 3997480 : switch (pSym->SymbolType)
15633 : {
15634 3997480 : case SymbolTable_ProcedureSym:
15635 3997480 : (*begin) = pSym->Procedure.Begin;
15636 3997480 : (*end) = pSym->Procedure.End;
15637 3997480 : break;
15638 :
15639 :
15640 0 : default:
15641 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15642 3997480 : break;
15643 : }
15644 3997480 : }
15645 :
15646 :
15647 : /*
15648 : ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
15649 : */
15650 :
15651 2924106 : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P)
15652 : {
15653 2924106 : SymbolTable_PtrToSymbol pSym;
15654 :
15655 2924106 : pSym = GetPsym (Sym);
15656 2924106 : switch (pSym->SymbolType)
15657 : {
15658 443840 : case SymbolTable_DefImpSym:
15659 443840 : Lists_ForeachItemInListDo (pSym->DefImp.ListOfProcs, P);
15660 443840 : break;
15661 :
15662 112059 : case SymbolTable_ModuleSym:
15663 112059 : Lists_ForeachItemInListDo (pSym->Module.ListOfProcs, P);
15664 112059 : break;
15665 :
15666 2368207 : case SymbolTable_ProcedureSym:
15667 2368207 : Lists_ForeachItemInListDo (pSym->Procedure.ListOfProcs, P);
15668 2368207 : break;
15669 :
15670 :
15671 0 : default:
15672 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
15673 2924088 : break;
15674 : }
15675 2924088 : }
15676 :
15677 :
15678 : /*
15679 : ForeachModuleDo - for each module do procedure, P.
15680 : */
15681 :
15682 48323 : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P)
15683 : {
15684 48323 : SymbolKey_ForeachNodeDo (ModuleTree, P);
15685 48323 : }
15686 :
15687 :
15688 : /*
15689 : ForeachInnerModuleDo - for each inner module in module, Sym,
15690 : do procedure, P.
15691 : */
15692 :
15693 3383015 : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P)
15694 : {
15695 3383015 : SymbolTable_PtrToSymbol pSym;
15696 :
15697 3383015 : pSym = GetPsym (Sym);
15698 3383015 : switch (pSym->SymbolType)
15699 : {
15700 451417 : case SymbolTable_DefImpSym:
15701 451417 : Lists_ForeachItemInListDo (pSym->DefImp.ListOfModules, P);
15702 451417 : break;
15703 :
15704 167826 : case SymbolTable_ModuleSym:
15705 167826 : Lists_ForeachItemInListDo (pSym->Module.ListOfModules, P);
15706 167826 : break;
15707 :
15708 2763772 : case SymbolTable_ProcedureSym:
15709 2763772 : Lists_ForeachItemInListDo (pSym->Procedure.ListOfModules, P);
15710 2763772 : break;
15711 :
15712 :
15713 0 : default:
15714 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
15715 3383015 : break;
15716 : }
15717 3383015 : }
15718 :
15719 :
15720 : /*
15721 : IsVarParam - Returns a conditional depending whether parameter ParamNo
15722 : is a VAR parameter.
15723 : */
15724 :
15725 11530314 : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
15726 : {
15727 11530314 : SymbolTable_PtrToSymbol pSym;
15728 11530314 : bool IsVar;
15729 :
15730 11530314 : IsVar = false;
15731 11530314 : pSym = GetPsym (Sym);
15732 11530314 : switch (pSym->SymbolType)
15733 : {
15734 : case SymbolTable_ErrorSym:
15735 : break;
15736 :
15737 11530314 : case SymbolTable_ProcedureSym:
15738 11530314 : IsVar = IsNthParamVar (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo);
15739 11530314 : break;
15740 :
15741 0 : case SymbolTable_ProcTypeSym:
15742 0 : IsVar = IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
15743 0 : break;
15744 :
15745 :
15746 0 : default:
15747 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15748 11530314 : break;
15749 : }
15750 11530314 : return IsVar;
15751 : /* static analysis guarentees a RETURN statement will be used before here. */
15752 : __builtin_unreachable ();
15753 : }
15754 :
15755 :
15756 : /*
15757 : IsVarParamAny - Returns a conditional depending whether parameter ParamNo
15758 : is a VAR parameter.
15759 : */
15760 :
15761 10822582 : extern "C" bool SymbolTable_IsVarParamAny (unsigned int Sym, unsigned int ParamNo)
15762 : {
15763 10822582 : SymbolTable_PtrToSymbol pSym;
15764 10822582 : SymbolTable_ProcedureKind kind;
15765 :
15766 10822582 : pSym = GetPsym (Sym);
15767 10822582 : switch (pSym->SymbolType)
15768 : {
15769 : case SymbolTable_ErrorSym:
15770 : break;
15771 :
15772 : case SymbolTable_ProcedureSym:
15773 23686469 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
15774 : {
15775 22834103 : if (SymbolTable_GetProcedureDefined (Sym, kind))
15776 : {
15777 9397177 : return IsNthParamVar (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo);
15778 : }
15779 : }
15780 : break;
15781 :
15782 573039 : case SymbolTable_ProcTypeSym:
15783 573039 : return IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
15784 0 : break;
15785 :
15786 :
15787 0 : default:
15788 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15789 : break;
15790 : }
15791 : return false;
15792 : /* static analysis guarentees a RETURN statement will be used before here. */
15793 : __builtin_unreachable ();
15794 : }
15795 :
15796 :
15797 : /*
15798 : IsUnboundedParam - Returns a conditional depending whether parameter
15799 : ParamNo is an unbounded array procedure parameter.
15800 : */
15801 :
15802 23445121 : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
15803 : {
15804 23445121 : unsigned int param;
15805 :
15806 23445121 : param = SymbolTable_GetNthParam (Sym, kind, ParamNo);
15807 23445121 : return SymbolTable_IsParameterUnbounded (param);
15808 : /* static analysis guarentees a RETURN statement will be used before here. */
15809 : __builtin_unreachable ();
15810 : }
15811 :
15812 20217636 : extern "C" bool SymbolTable_IsUnboundedParamAny (unsigned int Sym, unsigned int ParamNo)
15813 : {
15814 20217636 : SymbolTable_ProcedureKind kind;
15815 :
15816 41076398 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
15817 : {
15818 : /*
15819 : IsUnboundedParam - Returns a conditional depending whether parameter
15820 : ParamNo is an unbounded array procedure parameter.
15821 : */
15822 41076398 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
15823 : {
15824 20217636 : return SymbolTable_IsUnboundedParam (Sym, kind, ParamNo);
15825 : }
15826 : }
15827 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
15828 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15829 : __builtin_unreachable ();
15830 : }
15831 :
15832 :
15833 : /*
15834 : IsParameterUnbounded - returns TRUE if parameter, Sym, is
15835 : unbounded.
15836 : */
15837 :
15838 23445133 : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym)
15839 : {
15840 23445133 : SymbolTable_PtrToSymbol pSym;
15841 :
15842 23445133 : pSym = GetPsym (Sym);
15843 23445133 : switch (pSym->SymbolType)
15844 : {
15845 20868836 : case SymbolTable_ParamSym:
15846 20868836 : return pSym->Param.IsUnbounded;
15847 2576297 : break;
15848 :
15849 2576297 : case SymbolTable_VarParamSym:
15850 2576297 : return pSym->VarParam.IsUnbounded;
15851 0 : break;
15852 :
15853 :
15854 0 : default:
15855 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
15856 : break;
15857 : }
15858 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15859 : __builtin_unreachable ();
15860 : }
15861 :
15862 :
15863 : /*
15864 : IsParameterVar - returns true if parameter symbol Sym
15865 : was declared as a VAR.
15866 : */
15867 :
15868 204 : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym)
15869 : {
15870 204 : SymbolTable_PtrToSymbol pSym;
15871 :
15872 204 : pSym = GetPsym (Sym);
15873 204 : switch (pSym->SymbolType)
15874 : {
15875 : case SymbolTable_ParamSym:
15876 : return false;
15877 24 : break;
15878 :
15879 24 : case SymbolTable_VarParamSym:
15880 24 : return true;
15881 0 : break;
15882 :
15883 :
15884 0 : default:
15885 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
15886 : break;
15887 : }
15888 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15889 : __builtin_unreachable ();
15890 : }
15891 :
15892 :
15893 : /*
15894 : GetParameterShadowVar - returns the local variable associated with the
15895 : parameter symbol, sym.
15896 : */
15897 :
15898 47116 : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym)
15899 : {
15900 47116 : SymbolTable_PtrToSymbol pSym;
15901 :
15902 47116 : pSym = GetPsym (sym);
15903 47116 : switch (pSym->SymbolType)
15904 : {
15905 39836 : case SymbolTable_ParamSym:
15906 39836 : return pSym->Param.ShadowVar;
15907 7280 : break;
15908 :
15909 7280 : case SymbolTable_VarParamSym:
15910 7280 : return pSym->VarParam.ShadowVar;
15911 0 : break;
15912 :
15913 :
15914 0 : default:
15915 0 : M2Error_InternalError ((const char *) "expecting a ParamSym or VarParamSym", 35);
15916 : break;
15917 : }
15918 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15919 : __builtin_unreachable ();
15920 : }
15921 :
15922 :
15923 : /*
15924 : NoOfParam - Returns the number of parameters that procedure Sym contains.
15925 : */
15926 :
15927 27089820 : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym, SymbolTable_ProcedureKind kind)
15928 : {
15929 27089820 : SymbolTable_PtrToSymbol pSym;
15930 27089820 : unsigned int n;
15931 :
15932 27089820 : AssertInRange (Sym);
15933 27089820 : pSym = GetPsym (Sym);
15934 27089820 : switch (pSym->SymbolType)
15935 : {
15936 : case SymbolTable_ErrorSym:
15937 : n = 0;
15938 : break;
15939 :
15940 27089820 : case SymbolTable_ProcedureSym:
15941 27089820 : n = Lists_NoOfItemsInList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam);
15942 27089820 : break;
15943 :
15944 0 : case SymbolTable_ProcTypeSym:
15945 0 : n = Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
15946 0 : break;
15947 :
15948 :
15949 0 : default:
15950 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15951 27089820 : break;
15952 : }
15953 27089820 : return n;
15954 : /* static analysis guarentees a RETURN statement will be used before here. */
15955 : __builtin_unreachable ();
15956 : }
15957 :
15958 :
15959 : /*
15960 : HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
15961 : */
15962 :
15963 0 : extern "C" bool SymbolTable_HasVarParameters (unsigned int p)
15964 : {
15965 0 : unsigned int i;
15966 0 : unsigned int n;
15967 :
15968 0 : n = SymbolTable_NoOfParamAny (p);
15969 0 : i = 1;
15970 0 : while (i <= n)
15971 : {
15972 0 : if (SymbolTable_IsParameterVar (SymbolTable_GetNthParamAny (p, i)))
15973 : {
15974 : return true;
15975 : }
15976 0 : i += 1;
15977 : }
15978 : return false;
15979 : /* static analysis guarentees a RETURN statement will be used before here. */
15980 : __builtin_unreachable ();
15981 : }
15982 :
15983 :
15984 : /*
15985 : NoOfLocalVar - returns the number of local variables that exist in
15986 : procedure Sym. Parameters are NOT included in the
15987 : count.
15988 : */
15989 :
15990 30 : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym)
15991 : {
15992 30 : SymbolTable_PtrToSymbol pSym;
15993 30 : unsigned int n;
15994 :
15995 30 : pSym = GetPsym (Sym);
15996 30 : switch (pSym->SymbolType)
15997 : {
15998 : case SymbolTable_ErrorSym:
15999 : n = 0;
16000 : break;
16001 :
16002 30 : case SymbolTable_ProcedureSym:
16003 30 : n = Lists_NoOfItemsInList (pSym->Procedure.ListOfVars);
16004 30 : break;
16005 :
16006 :
16007 0 : default:
16008 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
16009 30 : break;
16010 : }
16011 : /*
16012 : Parameters are actually included in the list of local varaibles,
16013 : therefore we must subtract the Parameter Number from local variable
16014 : total.
16015 : */
16016 30 : return n-(SymbolTable_NoOfParamAny (Sym));
16017 : /* static analysis guarentees a RETURN statement will be used before here. */
16018 : __builtin_unreachable ();
16019 : }
16020 :
16021 :
16022 : /*
16023 : IsDefImp - returns true is the Sym is a DefImp symbol.
16024 : Definition/Implementation module symbol.
16025 : */
16026 :
16027 362167452 : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym)
16028 : {
16029 362167452 : SymbolTable_PtrToSymbol pSym;
16030 :
16031 362167452 : pSym = GetPsym (Sym);
16032 362167452 : return pSym->SymbolType == SymbolTable_DefImpSym;
16033 : /* static analysis guarentees a RETURN statement will be used before here. */
16034 : __builtin_unreachable ();
16035 : }
16036 :
16037 :
16038 : /*
16039 : IsModule - returns true is the Sym is a Module symbol.
16040 : Program module symbol.
16041 : */
16042 :
16043 300168656 : extern "C" bool SymbolTable_IsModule (unsigned int Sym)
16044 : {
16045 300168656 : SymbolTable_PtrToSymbol pSym;
16046 :
16047 300168656 : pSym = GetPsym (Sym);
16048 300168656 : return pSym->SymbolType == SymbolTable_ModuleSym;
16049 : /* static analysis guarentees a RETURN statement will be used before here. */
16050 : __builtin_unreachable ();
16051 : }
16052 :
16053 :
16054 : /*
16055 : IsInnerModule - returns true if the symbol, Sym, is an inner module.
16056 : */
16057 :
16058 10300616 : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym)
16059 : {
16060 10300616 : if (SymbolTable_IsModule (Sym))
16061 : {
16062 226914 : return (SymbolTable_GetScope (Sym)) != SymbolTable_NulSym;
16063 : }
16064 : else
16065 : {
16066 : return false;
16067 : }
16068 : /* static analysis guarentees a RETURN statement will be used before here. */
16069 : __builtin_unreachable ();
16070 : }
16071 :
16072 :
16073 : /*
16074 : GetSymName - returns the symbol name.
16075 : */
16076 :
16077 1144163425 : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym)
16078 : {
16079 1144163425 : SymbolTable_PtrToSymbol pSym;
16080 1144163425 : NameKey_Name n;
16081 :
16082 1144163425 : if (Sym == SymbolTable_NulSym)
16083 : {
16084 : n = SymbolKey_NulKey;
16085 : }
16086 : else
16087 : {
16088 1144163425 : pSym = GetPsym (Sym);
16089 1144163425 : switch (pSym->SymbolType)
16090 : {
16091 355 : case SymbolTable_ErrorSym:
16092 355 : n = pSym->Error.name;
16093 355 : break;
16094 :
16095 14903097 : case SymbolTable_ObjectSym:
16096 14903097 : n = pSym->Object.name;
16097 14903097 : break;
16098 :
16099 8350478 : case SymbolTable_DefImpSym:
16100 8350478 : n = pSym->DefImp.name;
16101 8350478 : break;
16102 :
16103 511692 : case SymbolTable_ModuleSym:
16104 511692 : n = pSym->Module.name;
16105 511692 : break;
16106 :
16107 882321823 : case SymbolTable_TypeSym:
16108 882321823 : n = pSym->Type.name;
16109 882321823 : break;
16110 :
16111 10105354 : case SymbolTable_VarSym:
16112 10105354 : n = pSym->Var.name;
16113 10105354 : break;
16114 :
16115 15045 : case SymbolTable_ConstLitSym:
16116 15045 : n = pSym->ConstLit.name;
16117 15045 : break;
16118 :
16119 157346 : case SymbolTable_ConstVarSym:
16120 157346 : n = pSym->ConstVar.name;
16121 157346 : break;
16122 :
16123 14367 : case SymbolTable_ConstStringSym:
16124 14367 : n = pSym->ConstString.name;
16125 14367 : break;
16126 :
16127 1761255 : case SymbolTable_EnumerationSym:
16128 1761255 : n = pSym->Enumeration.name;
16129 1761255 : break;
16130 :
16131 1562371 : case SymbolTable_EnumerationFieldSym:
16132 1562371 : n = pSym->EnumerationField.name;
16133 1562371 : break;
16134 :
16135 14580778 : case SymbolTable_UndefinedSym:
16136 14580778 : n = pSym->Undefined.name;
16137 14580778 : break;
16138 :
16139 51524997 : case SymbolTable_ProcedureSym:
16140 51524997 : n = pSym->Procedure.name;
16141 51524997 : break;
16142 :
16143 562212 : case SymbolTable_ProcTypeSym:
16144 562212 : n = pSym->ProcType.name;
16145 562212 : break;
16146 :
16147 1233954 : case SymbolTable_RecordFieldSym:
16148 1233954 : n = pSym->RecordField.name;
16149 1233954 : break;
16150 :
16151 434230 : case SymbolTable_RecordSym:
16152 434230 : n = pSym->Record.name;
16153 434230 : break;
16154 :
16155 : case SymbolTable_VarientSym:
16156 : n = NameKey_NulName;
16157 : break;
16158 :
16159 17430 : case SymbolTable_VarientFieldSym:
16160 17430 : n = pSym->VarientField.name;
16161 17430 : break;
16162 :
16163 12311 : case SymbolTable_VarParamSym:
16164 12311 : n = pSym->VarParam.name;
16165 12311 : break;
16166 :
16167 126228 : case SymbolTable_ParamSym:
16168 126228 : n = pSym->Param.name;
16169 126228 : break;
16170 :
16171 63086585 : case SymbolTable_PointerSym:
16172 63086585 : n = pSym->Pointer.name;
16173 63086585 : break;
16174 :
16175 102164 : case SymbolTable_ArraySym:
16176 102164 : n = pSym->Array.name;
16177 102164 : break;
16178 :
16179 : case SymbolTable_UnboundedSym:
16180 : n = NameKey_NulName;
16181 : break;
16182 :
16183 450132 : case SymbolTable_SubrangeSym:
16184 450132 : n = pSym->Subrange.name;
16185 450132 : break;
16186 :
16187 85098384 : case SymbolTable_SetSym:
16188 85098384 : n = pSym->Set.name;
16189 85098384 : break;
16190 :
16191 : case SymbolTable_SubscriptSym:
16192 : n = NameKey_NulName;
16193 : break;
16194 :
16195 : case SymbolTable_DummySym:
16196 : n = NameKey_NulName;
16197 : break;
16198 :
16199 0 : case SymbolTable_PartialUnboundedSym:
16200 0 : n = SymbolTable_GetSymName (pSym->PartialUnbounded.Type);
16201 0 : break;
16202 :
16203 : case SymbolTable_TupleSym:
16204 : n = NameKey_NulName;
16205 : break;
16206 :
16207 : case SymbolTable_GnuAsmSym:
16208 : n = NameKey_NulName;
16209 : break;
16210 :
16211 : case SymbolTable_InterfaceSym:
16212 : n = NameKey_NulName;
16213 : break;
16214 :
16215 : case SymbolTable_ImportSym:
16216 : n = NameKey_NulName;
16217 : break;
16218 :
16219 : case SymbolTable_ImportStatementSym:
16220 : n = NameKey_NulName;
16221 : break;
16222 :
16223 :
16224 0 : default:
16225 0 : M2Error_InternalError ((const char *) "unexpected symbol type", 22);
16226 1144163425 : break;
16227 : }
16228 : }
16229 1144163425 : return n;
16230 : /* static analysis guarentees a RETURN statement will be used before here. */
16231 : __builtin_unreachable ();
16232 : }
16233 :
16234 :
16235 : /*
16236 : RenameSym - renames a symbol, Sym, with SymName.
16237 : It also checks the unknown tree for a symbol
16238 : with this new name. Must only be renamed in
16239 : the same scope of being declared.
16240 : */
16241 :
16242 0 : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName)
16243 : {
16244 0 : SymbolTable_PtrToSymbol pSym;
16245 :
16246 0 : if ((SymbolTable_GetSymName (Sym)) == NameKey_NulName)
16247 : {
16248 0 : pSym = GetPsym (Sym);
16249 0 : switch (pSym->SymbolType)
16250 : {
16251 0 : case SymbolTable_ErrorSym:
16252 0 : M2Error_ErrorAbort0 ((const char *) "", 0);
16253 0 : break;
16254 :
16255 0 : case SymbolTable_TypeSym:
16256 0 : pSym->Type.name = SymName;
16257 0 : break;
16258 :
16259 0 : case SymbolTable_VarSym:
16260 0 : pSym->Var.name = SymName;
16261 0 : break;
16262 :
16263 0 : case SymbolTable_ConstLitSym:
16264 0 : pSym->ConstLit.name = SymName;
16265 0 : break;
16266 :
16267 0 : case SymbolTable_ConstVarSym:
16268 0 : pSym->ConstVar.name = SymName;
16269 0 : break;
16270 :
16271 0 : case SymbolTable_UndefinedSym:
16272 0 : pSym->Undefined.name = SymName;
16273 0 : break;
16274 :
16275 0 : case SymbolTable_RecordSym:
16276 0 : pSym->Record.name = SymName;
16277 0 : break;
16278 :
16279 0 : case SymbolTable_PointerSym:
16280 0 : pSym->Pointer.name = SymName;
16281 0 : break;
16282 :
16283 :
16284 0 : default:
16285 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
16286 0 : break;
16287 : }
16288 0 : AddSymToScope (Sym, SymName);
16289 : }
16290 : else
16291 : {
16292 0 : M2Error_InternalError ((const char *) "old name of symbol must be nul", 30);
16293 : }
16294 0 : }
16295 :
16296 :
16297 : /*
16298 : IsUnknown - returns true is the symbol Sym is unknown.
16299 : */
16300 :
16301 51194278 : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym)
16302 : {
16303 51194278 : SymbolTable_PtrToSymbol pSym;
16304 :
16305 51194278 : AssertInRange (Sym);
16306 51194278 : pSym = GetPsym (Sym);
16307 51194278 : return pSym->SymbolType == SymbolTable_UndefinedSym;
16308 : /* static analysis guarentees a RETURN statement will be used before here. */
16309 : __builtin_unreachable ();
16310 : }
16311 :
16312 :
16313 : /*
16314 : IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
16315 : */
16316 :
16317 1023446 : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym)
16318 : {
16319 1023446 : SymbolTable_PtrToSymbol pSym;
16320 :
16321 1023446 : if (sym > 0)
16322 : {
16323 1023446 : pSym = GetPsym (sym);
16324 1023446 : switch (pSym->SymbolType)
16325 : {
16326 : case SymbolTable_PartialUnboundedSym:
16327 : return true;
16328 1023446 : break;
16329 :
16330 :
16331 1023446 : default:
16332 1023446 : return false;
16333 : break;
16334 : }
16335 : }
16336 : else
16337 : {
16338 : return false;
16339 : }
16340 : /* static analysis guarentees a RETURN statement will be used before here. */
16341 : __builtin_unreachable ();
16342 : }
16343 :
16344 :
16345 : /*
16346 : RequestSym - searches for a symbol with a name SymName in the
16347 : current and previous scopes.
16348 : If the symbol is found then it is returned
16349 : else an unknown symbol is returned create at token
16350 : position, tok.
16351 : This procedure does search the base scope (for
16352 : pervasive identifiers).
16353 : */
16354 :
16355 47429072 : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName)
16356 : {
16357 47429072 : unsigned int Sym;
16358 :
16359 : /*
16360 : WriteString('RequestSym for: ') ; WriteKey(SymName) ; WriteLn ;
16361 : */
16362 47429072 : Sym = SymbolTable_GetSym (SymName);
16363 47429072 : if (Sym == SymbolTable_NulSym)
16364 : {
16365 7112030 : Sym = GetSymFromUnknownTree (SymName);
16366 7112030 : if (Sym == SymbolTable_NulSym)
16367 : {
16368 : /* Make unknown. */
16369 7112030 : NewSym (&Sym);
16370 7112030 : FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
16371 : /*
16372 : ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
16373 : */
16374 7112030 : AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
16375 : }
16376 : }
16377 47429072 : return Sym;
16378 : /* static analysis guarentees a RETURN statement will be used before here. */
16379 : __builtin_unreachable ();
16380 : }
16381 :
16382 :
16383 : /*
16384 : PutImported - places a symbol, Sym, into the current main scope.
16385 : */
16386 :
16387 1013741 : extern "C" void SymbolTable_PutImported (unsigned int Sym)
16388 : {
16389 1013741 : SymbolTable_PtrToSymbol pSym;
16390 1013741 : unsigned int ModSym;
16391 1013741 : NameKey_Name n;
16392 :
16393 : /*
16394 : We have currently imported Sym, now place it into the current module.
16395 : */
16396 1013741 : ModSym = SymbolTable_GetCurrentModuleScope ();
16397 2027482 : M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
16398 1013741 : pSym = GetPsym (ModSym);
16399 1013741 : switch (pSym->SymbolType)
16400 : {
16401 105209 : case SymbolTable_ModuleSym:
16402 105209 : if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
16403 : {
16404 : /* avoid dangling else. */
16405 90 : if (M2Options_Pedantic)
16406 : {
16407 6 : n = SymbolTable_GetSymName (Sym);
16408 6 : M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
16409 : }
16410 : }
16411 105119 : else if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
16412 : {
16413 : /* avoid dangling else. */
16414 105119 : if ((SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym)) == SymbolKey_NulKey)
16415 : {
16416 105119 : SymbolKey_PutSymKey (pSym->Module.WhereImported, Sym, M2LexBuf_GetTokenNo ());
16417 : }
16418 105119 : SymbolKey_PutSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym), Sym);
16419 105119 : SymbolTable_AddSymToModuleScope (ModSym, Sym);
16420 : }
16421 : else
16422 : {
16423 : /* avoid dangling else. */
16424 0 : n = SymbolTable_GetSymName (Sym);
16425 0 : M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
16426 : }
16427 : break;
16428 :
16429 908532 : case SymbolTable_DefImpSym:
16430 908532 : if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
16431 : {
16432 : /* avoid dangling else. */
16433 97 : if (M2Options_Pedantic)
16434 : {
16435 0 : n = SymbolTable_GetSymName (Sym);
16436 0 : M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
16437 : }
16438 : }
16439 908435 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
16440 : {
16441 : /* avoid dangling else. */
16442 908435 : if ((SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym)) == SymbolKey_NulKey)
16443 : {
16444 908435 : SymbolKey_PutSymKey (pSym->DefImp.WhereImported, Sym, M2LexBuf_GetTokenNo ());
16445 : }
16446 908435 : SymbolKey_PutSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym), Sym);
16447 908435 : SymbolTable_AddSymToModuleScope (ModSym, Sym);
16448 : }
16449 : else
16450 : {
16451 : /* avoid dangling else. */
16452 0 : n = SymbolTable_GetSymName (Sym);
16453 0 : M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
16454 : }
16455 : break;
16456 :
16457 :
16458 0 : default:
16459 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
16460 1013741 : break;
16461 : }
16462 1013741 : }
16463 :
16464 :
16465 : /*
16466 : PutIncluded - places a symbol, Sym, into the included list of the
16467 : current module.
16468 : Symbols that are placed in this list are indirectly declared
16469 : by:
16470 :
16471 : IMPORT modulename ;
16472 :
16473 : modulename.identifier
16474 : */
16475 :
16476 788440 : extern "C" void SymbolTable_PutIncluded (unsigned int Sym)
16477 : {
16478 788440 : SymbolTable_PtrToSymbol pSym;
16479 788440 : unsigned int ModSym;
16480 788440 : NameKey_Name n1;
16481 788440 : NameKey_Name n2;
16482 :
16483 : /*
16484 : We have referenced Sym, via modulename.Sym
16485 : now place it into the current module include list.
16486 : */
16487 788440 : ModSym = SymbolTable_GetCurrentModuleScope ();
16488 1576880 : M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
16489 788440 : if (DebugUnknowns)
16490 : {
16491 : n1 = SymbolTable_GetSymName (Sym);
16492 : n2 = SymbolTable_GetSymName (ModSym);
16493 : M2Printf_printf2 ((const char *) "including %a into scope %a\\n", 28, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
16494 : }
16495 788440 : pSym = GetPsym (ModSym);
16496 788440 : switch (pSym->SymbolType)
16497 : {
16498 4766 : case SymbolTable_ModuleSym:
16499 4766 : Lists_IncludeItemIntoList (pSym->Module.IncludeList, Sym);
16500 4766 : break;
16501 :
16502 783674 : case SymbolTable_DefImpSym:
16503 783674 : Lists_IncludeItemIntoList (pSym->DefImp.IncludeList, Sym);
16504 783674 : break;
16505 :
16506 :
16507 0 : default:
16508 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
16509 788440 : break;
16510 : }
16511 788440 : }
16512 :
16513 :
16514 : /*
16515 : PutExported - places a symbol, Sym into the next level out module.
16516 : Sym is also placed in the ExportTree of the current inner
16517 : module.
16518 : */
16519 :
16520 276 : extern "C" void SymbolTable_PutExported (unsigned int Sym)
16521 : {
16522 276 : SymbolTable_PtrToSymbol pSym;
16523 :
16524 : /*
16525 : WriteString('PutExported') ; WriteLn ;
16526 : */
16527 276 : SymbolTable_AddSymToModuleScope (GetLastModuleOrProcedureScope (), Sym);
16528 276 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
16529 276 : switch (pSym->SymbolType)
16530 : {
16531 276 : case SymbolTable_ModuleSym:
16532 276 : SymbolKey_PutSymKey (pSym->Module.ExportTree, SymbolTable_GetSymName (Sym), Sym);
16533 276 : if (SymbolTable_IsUnknown (Sym))
16534 : {
16535 276 : PutExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
16536 : }
16537 : /*
16538 : ; WriteKey(Module.name) ; WriteString(' exports ') ;
16539 : ; WriteKey(GetSymName(Sym)) ; WriteLn ;
16540 : */
16541 276 : break;
16542 :
16543 :
16544 0 : default:
16545 0 : M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
16546 276 : break;
16547 : }
16548 276 : }
16549 :
16550 :
16551 : /*
16552 : PutExportQualified - places a symbol with the name, SymName,
16553 : into the export tree of the
16554 : Definition module being compiled.
16555 : The symbol with name has been EXPORT QUALIFIED
16556 : by the definition module and therefore any reference
16557 : to this symbol in the code generation phase
16558 : will be in the form _Module_Name.
16559 : */
16560 :
16561 3782654 : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName)
16562 : {
16563 3782654 : SymbolTable_PtrToSymbol pSym;
16564 3782654 : NameKey_Name n;
16565 3782654 : unsigned int Sym;
16566 3782654 : unsigned int ModSym;
16567 :
16568 3782654 : ModSym = SymbolTable_GetCurrentModule ();
16569 3782654 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16570 7565308 : M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
16571 : /*
16572 : WriteString('1st MODULE ') ; WriteKey(GetSymName(ModSym)) ;
16573 : WriteString(' identifier ') ; WriteKey(SymName) ; WriteLn ;
16574 : */
16575 3782654 : pSym = GetPsym (ModSym);
16576 3782654 : switch (pSym->SymbolType)
16577 : {
16578 3782654 : case SymbolTable_DefImpSym:
16579 3782654 : if (((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
16580 : {
16581 6 : n = SymbolTable_GetSymName (ModSym);
16582 6 : M2Error_WriteFormat2 ((const char *) "identifier (%a) has already been exported from MODULE %a", 56, (const unsigned char *) &SymName, (sizeof (SymName)-1), (const unsigned char *) &n, (sizeof (n)-1));
16583 : }
16584 3782648 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
16585 : {
16586 : /* avoid dangling else. */
16587 310485 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
16588 310485 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
16589 310485 : SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
16590 310485 : PutExportUndeclared (ModSym, Sym);
16591 : }
16592 : else
16593 : {
16594 : /* avoid dangling else. */
16595 3472163 : Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
16596 3472163 : SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
16597 3472163 : PutExportUndeclared (ModSym, Sym);
16598 : }
16599 3782654 : break;
16600 :
16601 :
16602 0 : default:
16603 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16604 3782654 : break;
16605 : }
16606 3782654 : }
16607 :
16608 :
16609 : /*
16610 : PutExportUnQualified - places a symbol with the name, SymName,
16611 : into the export tree of the
16612 : Definition module being compiled.
16613 : The symbol with Name has been EXPORT UNQUALIFIED
16614 : by the definition module and therefore any reference
16615 : to this symbol in the code generation phase
16616 : will be in the form _Name.
16617 : */
16618 :
16619 836660 : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName)
16620 : {
16621 836660 : SymbolTable_PtrToSymbol pSym;
16622 836660 : NameKey_Name n;
16623 836660 : unsigned int Sym;
16624 836660 : unsigned int ModSym;
16625 :
16626 836660 : ModSym = SymbolTable_GetCurrentModule ();
16627 836660 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16628 1673320 : M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
16629 836660 : pSym = GetPsym (ModSym);
16630 836660 : switch (pSym->SymbolType)
16631 : {
16632 836660 : case SymbolTable_DefImpSym:
16633 836660 : if (((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
16634 : {
16635 0 : n = SymbolTable_GetSymName (ModSym);
16636 0 : M2Error_WriteFormat2 ((const char *) "identifier (%a) has already been exported from MODULE %a", 56, (const unsigned char *) &SymName, (sizeof (SymName)-1), (const unsigned char *) &n, (sizeof (n)-1));
16637 : }
16638 836660 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
16639 : {
16640 : /* avoid dangling else. */
16641 24612 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
16642 24612 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
16643 24612 : SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
16644 24612 : PutExportUndeclared (ModSym, Sym);
16645 : }
16646 : else
16647 : {
16648 : /* avoid dangling else. */
16649 812048 : Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
16650 812048 : SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
16651 812048 : PutExportUndeclared (ModSym, Sym);
16652 : }
16653 836660 : break;
16654 :
16655 :
16656 0 : default:
16657 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16658 836660 : break;
16659 : }
16660 836660 : }
16661 :
16662 :
16663 : /*
16664 : PutExportUnImplemented - places a symbol, Sym, into the currently compiled
16665 : DefImp module NeedToBeImplemented list.
16666 : */
16667 :
16668 3381927 : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym)
16669 : {
16670 3381927 : SymbolTable_PtrToSymbol pSym;
16671 :
16672 3381927 : pSym = GetPsym (CurrentModule);
16673 3381927 : switch (pSym->SymbolType)
16674 : {
16675 3381927 : case SymbolTable_DefImpSym:
16676 3381927 : if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
16677 : {
16678 : /*
16679 : n1 := GetSymName (Sym) ;
16680 : n2 := GetSymName (CurrentModule) ;
16681 : WriteFormat2 ('symbol (%a) already exported from module (%a)', n1, n2)
16682 : */
16683 0 : M2MetaError_MetaErrorT2 (tokenno, (const char *) "symbol {%1a} is already exported from module {%2a}", 50, Sym, CurrentModule);
16684 : }
16685 : else
16686 : {
16687 3381927 : SymbolKey_PutSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym), Sym);
16688 : }
16689 3381927 : break;
16690 :
16691 :
16692 0 : default:
16693 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16694 3381927 : break;
16695 : }
16696 3381927 : }
16697 :
16698 :
16699 : /*
16700 : GetExported - returns the symbol which has a name SymName,
16701 : and is exported from the definition module ModSym.
16702 :
16703 : */
16704 :
16705 2825633 : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName)
16706 : {
16707 2825633 : SymbolTable_PtrToSymbol pSym;
16708 2825633 : unsigned int Sym;
16709 :
16710 2825633 : pSym = GetPsym (ModSym);
16711 2825633 : switch (pSym->SymbolType)
16712 : {
16713 2825525 : case SymbolTable_DefImpSym:
16714 2825525 : Sym = RequestFromDefinition (tokenno, ModSym, SymName);
16715 2825525 : break;
16716 :
16717 108 : case SymbolTable_ModuleSym:
16718 108 : Sym = RequestFromModule (tokenno, ModSym, SymName);
16719 108 : break;
16720 :
16721 :
16722 0 : default:
16723 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16724 2825633 : break;
16725 : }
16726 2825633 : return Sym;
16727 : /* static analysis guarentees a RETURN statement will be used before here. */
16728 : __builtin_unreachable ();
16729 : }
16730 :
16731 :
16732 : /*
16733 : GetFromOuterModule - returns a symbol with name, SymName, which comes
16734 : from outside the current module.
16735 : */
16736 :
16737 376 : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName)
16738 : {
16739 376 : SymbolTable_PtrToCallFrame pCall;
16740 376 : unsigned int ScopeId;
16741 376 : unsigned int Sym;
16742 376 : unsigned int ScopeSym;
16743 :
16744 376 : ScopeId = ScopePtr;
16745 376 : pCall = GetPcall (ScopeId);
16746 776 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
16747 : {
16748 24 : M2Debug_Assert (ScopeId > 0);
16749 24 : ScopeId -= 1;
16750 24 : pCall = GetPcall (ScopeId);
16751 : }
16752 376 : ScopeId -= 1;
16753 : /* we are now below the current module */
16754 532 : while (ScopeId > 0)
16755 : {
16756 532 : pCall = GetPcall (ScopeId);
16757 532 : ScopeSym = pCall->Search;
16758 532 : if (ScopeSym != SymbolTable_NulSym)
16759 : {
16760 532 : Sym = SymbolTable_GetLocalSym (ScopeSym, SymName);
16761 532 : if (Sym == SymbolTable_NulSym)
16762 : {
16763 : /* avoid dangling else. */
16764 184 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsProcedure (ScopeSym))) || (SymbolTable_IsDefImp (ScopeSym)))
16765 : {
16766 148 : if (Sym == SymbolTable_NulSym)
16767 : {
16768 148 : Sym = ExamineUnresolvedTree (ScopeSym, SymName);
16769 148 : if (Sym != SymbolTable_NulSym)
16770 : {
16771 : return Sym;
16772 : }
16773 : }
16774 : }
16775 : }
16776 : else
16777 : {
16778 : return Sym;
16779 : }
16780 : }
16781 156 : ScopeId -= 1;
16782 156 : pCall = GetPcall (ScopeId);
16783 : }
16784 : /* at this point we force an unknown from the last module scope */
16785 0 : return RequestFromModule (tokenno, SymbolTable_GetLastModuleScope (), SymName);
16786 : /* static analysis guarentees a RETURN statement will be used before here. */
16787 : __builtin_unreachable ();
16788 : }
16789 :
16790 :
16791 : /*
16792 : TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
16793 : name, name, which is
16794 : currently undefined in the
16795 : outer scope to the inner scope.
16796 : If successful then the symbol is
16797 : returned otherwise NulSym is
16798 : returned.
16799 : */
16800 :
16801 234 : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name)
16802 : {
16803 234 : SymbolTable_PtrToSymbol pSym;
16804 234 : unsigned int sym;
16805 :
16806 : /* assume this should not be called if OuterScope was a procedure
16807 : as this case is handled by the caller (P1SymBuild)
16808 : */
16809 468 : M2Debug_Assert ((SymbolTable_IsModule (OuterScope)) || (SymbolTable_IsDefImp (OuterScope)));
16810 234 : sym = GetExportUndeclared (OuterScope, name);
16811 234 : if (sym != SymbolTable_NulSym)
16812 : {
16813 18 : M2Debug_Assert (SymbolTable_IsUnknown (sym));
16814 18 : RemoveExportUndeclared (OuterScope, sym);
16815 18 : SymbolTable_AddSymToModuleScope (OuterScope, sym);
16816 18 : AddVarToScopeList (OuterScope, sym);
16817 18 : pSym = GetPsym (OuterScope);
16818 18 : switch (pSym->SymbolType)
16819 : {
16820 0 : case SymbolTable_DefImpSym:
16821 0 : if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) == sym)
16822 : {
16823 0 : SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
16824 : }
16825 : break;
16826 :
16827 18 : case SymbolTable_ModuleSym:
16828 18 : if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) == sym)
16829 : {
16830 18 : SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
16831 : }
16832 : break;
16833 :
16834 :
16835 0 : default:
16836 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module symbol", 31);
16837 18 : break;
16838 : }
16839 18 : AddSymToUnknown (InnerScope, name, sym);
16840 18 : PutExportUndeclared (InnerScope, sym);
16841 : }
16842 234 : return sym;
16843 : /* static analysis guarentees a RETURN statement will be used before here. */
16844 : __builtin_unreachable ();
16845 : }
16846 :
16847 :
16848 : /*
16849 : IsExportQualified - returns true if a symbol, Sym, was defined as
16850 : being EXPORT QUALIFIED.
16851 : Sym is expected to be either a procedure or a
16852 : variable.
16853 : */
16854 :
16855 8443193 : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym)
16856 : {
16857 8443193 : SymbolTable_PtrToSymbol pSym;
16858 8443193 : unsigned int OuterModule;
16859 :
16860 8443193 : OuterModule = Sym;
16861 9122852 : do {
16862 9122852 : OuterModule = SymbolTable_GetScope (OuterModule);
16863 9122852 : } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
16864 8443193 : pSym = GetPsym (OuterModule);
16865 8443193 : switch (pSym->SymbolType)
16866 : {
16867 : case SymbolTable_ModuleSym:
16868 : return false;
16869 7981553 : break;
16870 :
16871 7981553 : case SymbolTable_DefImpSym:
16872 7981553 : return (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
16873 0 : break;
16874 :
16875 :
16876 0 : default:
16877 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16878 : break;
16879 : }
16880 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16881 : __builtin_unreachable ();
16882 : }
16883 :
16884 :
16885 : /*
16886 : IsExportUnQualified - returns true if a symbol, Sym, was defined as
16887 : being EXPORT UNQUALIFIED.
16888 : */
16889 :
16890 4152178 : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym)
16891 : {
16892 4152178 : SymbolTable_PtrToSymbol pSym;
16893 4152178 : unsigned int OuterModule;
16894 :
16895 4152178 : OuterModule = Sym;
16896 4152178 : do {
16897 4152178 : OuterModule = SymbolTable_GetScope (OuterModule);
16898 4152178 : } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
16899 4152178 : pSym = GetPsym (OuterModule);
16900 4152178 : switch (pSym->SymbolType)
16901 : {
16902 : case SymbolTable_ModuleSym:
16903 : return false;
16904 4074153 : break;
16905 :
16906 4074153 : case SymbolTable_DefImpSym:
16907 4074153 : return (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
16908 0 : break;
16909 :
16910 :
16911 0 : default:
16912 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16913 : break;
16914 : }
16915 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16916 : __builtin_unreachable ();
16917 : }
16918 :
16919 :
16920 : /*
16921 : IsExported - returns true if a symbol, Sym, is exported
16922 : from module, ModSym.
16923 : If ModSym is a DefImp symbol then its
16924 : ExportQualified and ExportUnQualified lists are examined.
16925 : */
16926 :
16927 8740725 : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym)
16928 : {
16929 8740725 : SymbolTable_PtrToSymbol pSym;
16930 8740725 : NameKey_Name SymName;
16931 :
16932 8740725 : SymName = SymbolTable_GetSymName (Sym);
16933 8740725 : pSym = GetPsym (ModSym);
16934 8740725 : switch (pSym->SymbolType)
16935 : {
16936 8198172 : case SymbolTable_DefImpSym:
16937 8198172 : return ((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) == Sym) || ((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) == Sym);
16938 542553 : break;
16939 :
16940 542553 : case SymbolTable_ModuleSym:
16941 542553 : return (SymbolKey_GetSymKey (pSym->Module.ExportTree, SymName)) == Sym;
16942 0 : break;
16943 :
16944 :
16945 0 : default:
16946 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16947 : break;
16948 : }
16949 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16950 : __builtin_unreachable ();
16951 : }
16952 :
16953 :
16954 : /*
16955 : IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
16956 : ModSym must be a defimp symbol.
16957 : */
16958 :
16959 90 : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym)
16960 : {
16961 90 : unsigned int type;
16962 90 : SymbolTable_PtrToSymbol pSym;
16963 :
16964 90 : if ((SymbolTable_IsDefImp (ModSym)) && (SymbolTable_IsFieldEnumeration (Sym)))
16965 : {
16966 66 : pSym = GetPsym (ModSym);
16967 66 : type = SymbolTable_SkipType (SymbolTable_GetType (Sym));
16968 66 : return Lists_IsItemInList (pSym->DefImp.EnumerationScopeList, type);
16969 : }
16970 : return false;
16971 : /* static analysis guarentees a RETURN statement will be used before here. */
16972 : __builtin_unreachable ();
16973 : }
16974 :
16975 :
16976 : /*
16977 : IsImported - returns true if a symbol, Sym, in module, ModSym,
16978 : was imported.
16979 : */
16980 :
16981 35162296 : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym)
16982 : {
16983 35162296 : SymbolTable_PtrToSymbol pSym;
16984 35162296 : NameKey_Name SymName;
16985 :
16986 35162296 : SymName = SymbolTable_GetSymName (Sym);
16987 35162296 : pSym = GetPsym (ModSym);
16988 35162296 : switch (pSym->SymbolType)
16989 : {
16990 23047785 : case SymbolTable_DefImpSym:
16991 23047785 : return ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->DefImp.IncludeList, Sym));
16992 12114511 : break;
16993 :
16994 12114511 : case SymbolTable_ModuleSym:
16995 12114511 : return ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->Module.IncludeList, Sym));
16996 0 : break;
16997 :
16998 :
16999 0 : default:
17000 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17001 : break;
17002 : }
17003 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17004 : __builtin_unreachable ();
17005 : }
17006 :
17007 :
17008 : /*
17009 : PutIncludedByDefinition - places a module symbol, Sym, into the
17010 : included list of the current definition module.
17011 : */
17012 :
17013 10189 : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym)
17014 : {
17015 10189 : SymbolTable_PtrToSymbol pSym;
17016 10189 : unsigned int ModSym;
17017 :
17018 10189 : ModSym = SymbolTable_GetCurrentModuleScope ();
17019 10189 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
17020 10189 : M2Debug_Assert (SymbolTable_IsDefImp (Sym));
17021 10189 : pSym = GetPsym (ModSym);
17022 10189 : switch (pSym->SymbolType)
17023 : {
17024 10189 : case SymbolTable_DefImpSym:
17025 10189 : Lists_IncludeItemIntoList (pSym->DefImp.DefIncludeList, Sym);
17026 10189 : break;
17027 :
17028 :
17029 0 : default:
17030 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17031 10189 : break;
17032 : }
17033 10189 : }
17034 :
17035 :
17036 : /*
17037 : IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
17038 : by ModSym's definition module.
17039 : */
17040 :
17041 12 : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym)
17042 : {
17043 12 : SymbolTable_PtrToSymbol pSym;
17044 :
17045 12 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
17046 12 : M2Debug_Assert (SymbolTable_IsDefImp (Sym));
17047 12 : pSym = GetPsym (ModSym);
17048 12 : switch (pSym->SymbolType)
17049 : {
17050 12 : case SymbolTable_DefImpSym:
17051 12 : return Lists_IsItemInList (pSym->DefImp.DefIncludeList, Sym);
17052 0 : break;
17053 :
17054 :
17055 0 : default:
17056 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17057 : break;
17058 : }
17059 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17060 : __builtin_unreachable ();
17061 : }
17062 :
17063 :
17064 : /*
17065 : ForeachImportedDo - calls a procedure, P, foreach imported symbol
17066 : in module, ModSym.
17067 : */
17068 :
17069 14893 : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
17070 : {
17071 14893 : SymbolTable_PtrToSymbol pSym;
17072 :
17073 14893 : pSym = GetPsym (ModSym);
17074 14893 : switch (pSym->SymbolType)
17075 : {
17076 3866 : case SymbolTable_DefImpSym:
17077 3866 : SymbolKey_ForeachNodeDo (pSym->DefImp.ImportTree, P);
17078 3866 : Lists_ForeachItemInListDo (pSym->DefImp.IncludeList, P);
17079 3866 : break;
17080 :
17081 11027 : case SymbolTable_ModuleSym:
17082 11027 : SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, P);
17083 11027 : Lists_ForeachItemInListDo (pSym->Module.IncludeList, P);
17084 11027 : break;
17085 :
17086 :
17087 0 : default:
17088 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17089 14893 : break;
17090 : }
17091 14893 : }
17092 :
17093 :
17094 : /*
17095 : ForeachExportedDo - calls a procedure, P, foreach imported symbol
17096 : in module, ModSym.
17097 : */
17098 :
17099 8891 : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
17100 : {
17101 8891 : SymbolTable_PtrToSymbol pSym;
17102 :
17103 8891 : pSym = GetPsym (ModSym);
17104 8891 : switch (pSym->SymbolType)
17105 : {
17106 3444 : case SymbolTable_DefImpSym:
17107 3444 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, P);
17108 3444 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, P);
17109 3444 : break;
17110 :
17111 5447 : case SymbolTable_ModuleSym:
17112 5447 : SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, P);
17113 5447 : break;
17114 :
17115 :
17116 0 : default:
17117 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17118 8891 : break;
17119 : }
17120 8891 : }
17121 :
17122 :
17123 : /*
17124 : CheckForExportedImplementation - checks to see whether an implementation
17125 : module is currently being compiled, if so,
17126 : symbol, Sym, is removed from the
17127 : NeedToBeImplemented list.
17128 : This procedure is called whenever a symbol
17129 : is declared, thus attempting to reduce
17130 : the NeedToBeImplemented list.
17131 : Only needs to be called when a TYPE or
17132 : PROCEDURE is built since the implementation
17133 : module can only implement these objects
17134 : declared in the definition module.
17135 :
17136 : It also checks whether a definition module
17137 : is currently being compiled and, if so,
17138 : it will ensure that symbol, Sym, is removed
17139 : from the ExportRequest list. If Sym is an
17140 : enumerated type it ensures that its fields
17141 : are also removed.
17142 : */
17143 :
17144 2451579 : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym)
17145 : {
17146 2451579 : if (M2Comp_CompilingImplementationModule ())
17147 : {
17148 2303335 : RemoveExportUnImplemented (SymbolTable_GetCurrentModule (), Sym);
17149 : }
17150 2451579 : if ((M2Comp_CompilingDefinitionModule ()) && (SymbolTable_IsEnumeration (Sym)))
17151 : {
17152 19201 : RemoveEnumerationFromExportRequest (SymbolTable_GetCurrentModule (), Sym);
17153 : }
17154 2451579 : }
17155 :
17156 :
17157 : /*
17158 : CheckForUnImplementedExports - displays an error and the offending symbols
17159 : which have been exported but not implemented
17160 : from the current compiled module.
17161 : */
17162 :
17163 72710 : extern "C" void SymbolTable_CheckForUnImplementedExports (void)
17164 : {
17165 72710 : SymbolTable_PtrToSymbol pSym;
17166 :
17167 : /* WriteString('Inside CheckForImplementedExports') ; WriteLn ; */
17168 72710 : pSym = GetPsym (CurrentModule);
17169 72710 : switch (pSym->SymbolType)
17170 : {
17171 72710 : case SymbolTable_DefImpSym:
17172 72710 : if (! (SymbolKey_IsEmptyTree (pSym->DefImp.NeedToBeImplemented)))
17173 : {
17174 0 : CurrentError = M2Error_NewError (M2LexBuf_GetTokenNo ());
17175 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "unimplemented identifier(s) in EXPORT list of DEFINITION MODULE %a\\nthe implementation module fails to implement the following exported identifier(s)", 149, (const unsigned char *) &pSym->DefImp.name, (sizeof (pSym->DefImp.name)-1));
17176 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NeedToBeImplemented, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnImplementedSymbolError});
17177 : }
17178 72710 : break;
17179 :
17180 :
17181 0 : default:
17182 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17183 72710 : break;
17184 : }
17185 72710 : }
17186 :
17187 :
17188 : /*
17189 : CheckForUndeclaredExports - displays an error and the offending symbols
17190 : which have been exported but not declared
17191 : from module, ModSym.
17192 : */
17193 :
17194 178254 : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym)
17195 : {
17196 178254 : SymbolTable_PtrToSymbol pSym;
17197 :
17198 : /* WriteString('Inside CheckForUndeclaredExports') ; WriteLn ; */
17199 178254 : pSym = GetPsym (ModSym);
17200 178254 : switch (pSym->SymbolType)
17201 : {
17202 12289 : case SymbolTable_ModuleSym:
17203 12289 : if (! (SymbolKey_IsEmptyTree (pSym->Module.ExportUndeclared)))
17204 : {
17205 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in EXPORT list of {%1ERd} {%1a}", 56, ModSym);
17206 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
17207 : }
17208 : break;
17209 :
17210 165965 : case SymbolTable_DefImpSym:
17211 165965 : if (! (SymbolKey_IsEmptyTree (pSym->DefImp.ExportUndeclared)))
17212 : {
17213 0 : if (SymbolTable_DoesNotNeedExportList (ModSym))
17214 : {
17215 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in {%1ERd} {%1a}", 41, ModSym);
17216 : }
17217 : else
17218 : {
17219 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in export list of {%1ERd} {%1a}", 56, ModSym);
17220 : }
17221 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
17222 : }
17223 : break;
17224 :
17225 :
17226 0 : default:
17227 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17228 178254 : break;
17229 : }
17230 178254 : }
17231 :
17232 :
17233 : /*
17234 : CheckForUnknownInModule - checks for any unknown symbols in the
17235 : current module.
17236 : If any unknown symbols are found then
17237 : an error message is displayed.
17238 : */
17239 :
17240 499772 : extern "C" void SymbolTable_CheckForUnknownInModule (unsigned int tokno)
17241 : {
17242 499772 : SymbolTable_PtrToSymbol pSym;
17243 :
17244 499772 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
17245 499772 : switch (pSym->SymbolType)
17246 : {
17247 475565 : case SymbolTable_DefImpSym:
17248 475565 : CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.ExportQualifiedTree, (const char *) "EXPORT QUALIFIED", 16);
17249 475565 : CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.ExportUnQualifiedTree, (const char *) "EXPORT UNQUALIFIED", 18);
17250 475565 : CheckForSymbols (pSym->DefImp.ExportRequest, (const char *) "requested by another module import and the symbol has not been exported by the appropriate definition module", 108);
17251 475565 : CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.Unresolved, (const char *) "unresolved", 10);
17252 475565 : CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.LocalSymbols, (const char *) "locally used", 12);
17253 475565 : break;
17254 :
17255 24207 : case SymbolTable_ModuleSym:
17256 24207 : CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.Unresolved, (const char *) "unresolved", 10);
17257 24207 : CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.ExportUndeclared, (const char *) "exported but undeclared", 23);
17258 24207 : CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.ExportTree, (const char *) "exported but undeclared", 23);
17259 24207 : CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.LocalSymbols, (const char *) "locally used", 12);
17260 24207 : break;
17261 :
17262 :
17263 0 : default:
17264 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17265 499772 : break;
17266 : }
17267 499772 : }
17268 :
17269 :
17270 : /*
17271 : UnknownReported - if sym is an unknown symbol and has not been reported
17272 : then include it into the set of reported unknowns.
17273 : */
17274 :
17275 63 : extern "C" void SymbolTable_UnknownReported (unsigned int sym)
17276 : {
17277 63 : if (IsUnreportedUnknown (sym))
17278 : {
17279 56 : Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
17280 : }
17281 63 : }
17282 :
17283 :
17284 : /*
17285 : GetUnknownOnImport - returns the onimport field of unknown sym.
17286 : */
17287 :
17288 256 : extern "C" bool SymbolTable_GetUnknownOnImport (unsigned int sym)
17289 : {
17290 256 : SymbolTable_PtrToSymbol pSym;
17291 :
17292 256 : M2Debug_Assert (SymbolTable_IsUnknown (sym));
17293 256 : pSym = GetPsym (sym);
17294 256 : return pSym->Undefined.onImport;
17295 : /* static analysis guarentees a RETURN statement will be used before here. */
17296 : __builtin_unreachable ();
17297 : }
17298 :
17299 :
17300 : /*
17301 : GetUnknownDeclScope - returns the decl scope of unknown sym.
17302 : */
17303 :
17304 18 : extern "C" unsigned int SymbolTable_GetUnknownDeclScope (unsigned int sym)
17305 : {
17306 18 : SymbolTable_PtrToSymbol pSym;
17307 :
17308 18 : M2Debug_Assert (SymbolTable_IsUnknown (sym));
17309 18 : pSym = GetPsym (sym);
17310 18 : return pSym->Undefined.declScope;
17311 : /* static analysis guarentees a RETURN statement will be used before here. */
17312 : __builtin_unreachable ();
17313 : }
17314 :
17315 :
17316 : /*
17317 : IsReallyPointer - returns TRUE is sym is a pointer, address or a
17318 : type declared as a pointer or address.
17319 : */
17320 :
17321 780848 : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym)
17322 : {
17323 780848 : if (SymbolTable_IsVar (Sym))
17324 : {
17325 231481 : Sym = SymbolTable_GetType (Sym);
17326 : }
17327 780848 : Sym = SymbolTable_SkipType (Sym);
17328 780848 : return ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address)) || (SymbolTable_IsHiddenReallyPointer (Sym));
17329 : /* static analysis guarentees a RETURN statement will be used before here. */
17330 : __builtin_unreachable ();
17331 : }
17332 :
17333 :
17334 : /*
17335 : CheckHiddenTypeAreAddress - checks to see that any hidden types
17336 : which we have declared are actually
17337 : of type ADDRESS or map onto a POINTER type.
17338 : */
17339 :
17340 14425 : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void)
17341 : {
17342 14425 : NameKey_Name name;
17343 14425 : M2Error_Error e;
17344 14425 : unsigned int sym;
17345 14425 : unsigned int i;
17346 14425 : unsigned int n;
17347 :
17348 14425 : i = 1;
17349 14425 : n = Lists_NoOfItemsInList (AddressTypes);
17350 55873 : while (i <= n)
17351 : {
17352 27023 : sym = static_cast<unsigned int> (Lists_GetItemFromList (AddressTypes, i));
17353 27023 : if (! (SymbolTable_IsHiddenReallyPointer (sym)))
17354 : {
17355 6 : name = SymbolTable_GetSymName (sym);
17356 6 : e = M2Error_NewError (SymbolTable_GetDeclaredDef (sym));
17357 6 : M2Error_ErrorFormat1 (e, (const char *) "opaque type (%a) should be equivalent to a POINTER or an ADDRESS", 64, (const unsigned char *) &name, (sizeof (name)-1));
17358 6 : e = M2Error_NewError (SymbolTable_GetDeclaredMod (sym));
17359 6 : M2Error_ErrorFormat0 (e, (const char *) "if you really need a non POINTER type use the -fextended-opaque switch", 70);
17360 : }
17361 27023 : i += 1;
17362 : }
17363 14425 : }
17364 :
17365 :
17366 : /*
17367 : PutDefinitionForC - sets a flag in the current compiled module which
17368 : indicates that this module is a wrapper for a C
17369 : file. Parameters passes to procedures in this module
17370 : will adopt the C calling convention.
17371 : */
17372 :
17373 26880 : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym)
17374 : {
17375 26880 : SymbolTable_PtrToSymbol pSym;
17376 :
17377 26880 : pSym = GetPsym (Sym);
17378 26880 : switch (pSym->SymbolType)
17379 : {
17380 26880 : case SymbolTable_DefImpSym:
17381 26880 : pSym->DefImp.ForC = true;
17382 26880 : break;
17383 :
17384 :
17385 0 : default:
17386 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17387 26880 : break;
17388 : }
17389 26880 : }
17390 :
17391 :
17392 : /*
17393 : IsDefinitionForC - returns true if this definition module was declared
17394 : as a DEFINITION MODULE FOR "C".
17395 : */
17396 :
17397 1240203 : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym)
17398 : {
17399 1240203 : SymbolTable_PtrToSymbol pSym;
17400 :
17401 1240203 : pSym = GetPsym (Sym);
17402 1240203 : switch (pSym->SymbolType)
17403 : {
17404 1240203 : case SymbolTable_DefImpSym:
17405 1240203 : return pSym->DefImp.ForC;
17406 0 : break;
17407 :
17408 :
17409 0 : default:
17410 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17411 : break;
17412 : }
17413 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17414 : __builtin_unreachable ();
17415 : }
17416 :
17417 :
17418 : /*
17419 : PutDoesNeedExportList - sets a flag in module, Sym, which
17420 : indicates that this module requires an explicit
17421 : EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
17422 : */
17423 :
17424 87755 : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym)
17425 : {
17426 87755 : SymbolTable_PtrToSymbol pSym;
17427 :
17428 87755 : pSym = GetPsym (Sym);
17429 87755 : switch (pSym->SymbolType)
17430 : {
17431 87755 : case SymbolTable_DefImpSym:
17432 87755 : pSym->DefImp.NeedExportList = true;
17433 87755 : break;
17434 :
17435 :
17436 0 : default:
17437 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17438 87755 : break;
17439 : }
17440 87755 : }
17441 :
17442 :
17443 : /*
17444 : PutDoesNotNeedExportList - sets a flag in module, Sym, which
17445 : indicates that this module does not require an explicit
17446 : EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
17447 : */
17448 :
17449 166133 : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym)
17450 : {
17451 166133 : SymbolTable_PtrToSymbol pSym;
17452 :
17453 166133 : pSym = GetPsym (Sym);
17454 166133 : switch (pSym->SymbolType)
17455 : {
17456 166133 : case SymbolTable_DefImpSym:
17457 166133 : pSym->DefImp.NeedExportList = false;
17458 166133 : break;
17459 :
17460 :
17461 0 : default:
17462 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17463 166133 : break;
17464 : }
17465 166133 : }
17466 :
17467 :
17468 : /*
17469 : DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
17470 : EXPORT QUALIFIED list.
17471 : */
17472 :
17473 4115963 : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym)
17474 : {
17475 4115963 : SymbolTable_PtrToSymbol pSym;
17476 :
17477 4115963 : pSym = GetPsym (Sym);
17478 4115963 : switch (pSym->SymbolType)
17479 : {
17480 4115963 : case SymbolTable_DefImpSym:
17481 4115963 : return ! pSym->DefImp.NeedExportList;
17482 0 : break;
17483 :
17484 :
17485 0 : default:
17486 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17487 : break;
17488 : }
17489 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17490 : __builtin_unreachable ();
17491 : }
17492 :
17493 :
17494 : /*
17495 : CheckForEnumerationInCurrentModule - checks to see whether the enumeration
17496 : type symbol, Sym, has been entered into
17497 : the current modules scope list.
17498 : */
17499 :
17500 1738682 : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym)
17501 : {
17502 1738682 : SymbolTable_PtrToSymbol pSym;
17503 1738682 : unsigned int ModSym;
17504 :
17505 1738682 : if (((SymbolTable_SkipType (Sym)) != SymbolTable_NulSym) && (SymbolTable_IsEnumeration (SymbolTable_SkipType (Sym))))
17506 : {
17507 18100 : Sym = SymbolTable_SkipType (Sym);
17508 : }
17509 1738682 : if (SymbolTable_IsEnumeration (Sym))
17510 : {
17511 18100 : ModSym = SymbolTable_GetCurrentModuleScope ();
17512 18100 : pSym = GetPsym (ModSym);
17513 18100 : switch (pSym->SymbolType)
17514 : {
17515 17698 : case SymbolTable_DefImpSym:
17516 17698 : CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
17517 17698 : break;
17518 :
17519 402 : case SymbolTable_ModuleSym:
17520 402 : CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
17521 402 : break;
17522 :
17523 :
17524 0 : default:
17525 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17526 : break;
17527 : }
17528 : }
17529 1738682 : }
17530 :
17531 :
17532 : /*
17533 : SanityCheckConstants - must only be called once all constants, types, procedures
17534 : have been declared. It checks to see that constants are
17535 : not used as procedure parameter types.
17536 : */
17537 :
17538 15157 : extern "C" void SymbolTable_SanityCheckConstants (void)
17539 : {
17540 15157 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
17541 15157 : ForeachSymbolDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
17542 15157 : }
17543 :
17544 :
17545 : /*
17546 : ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
17547 : perform the procedure, P.
17548 : */
17549 :
17550 13539347 : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
17551 : {
17552 13539347 : SymbolTable_PtrToSymbol pSym;
17553 :
17554 13539347 : pSym = GetPsym (Sym);
17555 13539347 : switch (pSym->SymbolType)
17556 : {
17557 610038 : case SymbolTable_DefImpSym:
17558 610038 : SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, P);
17559 610038 : break;
17560 :
17561 95017 : case SymbolTable_ModuleSym:
17562 95017 : SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, P);
17563 95017 : break;
17564 :
17565 263586 : case SymbolTable_ProcedureSym:
17566 263586 : SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, P);
17567 263586 : break;
17568 :
17569 0 : case SymbolTable_RecordSym:
17570 0 : SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, P);
17571 0 : break;
17572 :
17573 12570706 : case SymbolTable_EnumerationSym:
17574 12570706 : SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
17575 12570706 : break;
17576 :
17577 :
17578 0 : default:
17579 0 : M2Error_InternalError ((const char *) "expecting a DefImp, Module or Procedure symbol", 46);
17580 13539347 : break;
17581 : }
17582 13539347 : }
17583 :
17584 :
17585 : /*
17586 : ForeachParamSymDo - foreach parameter symbol in procedure Sym
17587 : perform the procedure P. Each symbol
17588 : looked up will be VarParam or Param
17589 : (not the shadow variable). Every parameter
17590 : from each KindProcedure is iterated over.
17591 : */
17592 :
17593 1979209 : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
17594 : {
17595 1979209 : SymbolTable_ProcedureKind kind;
17596 1979209 : unsigned int param;
17597 1979209 : unsigned int p;
17598 1979209 : unsigned int i;
17599 :
17600 1979209 : if (SymbolTable_IsProcedure (Sym))
17601 : {
17602 7858108 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
17603 : {
17604 5893581 : p = SymbolTable_NoOfParam (Sym, kind);
17605 5893581 : i = p;
17606 17914315 : while (i > 0)
17607 : {
17608 6127153 : param = SymbolTable_GetNthParam (Sym, kind, i);
17609 6127153 : (*P.proc) (param);
17610 6127153 : i -= 1;
17611 : }
17612 : }
17613 : }
17614 1979209 : }
17615 :
17616 :
17617 : /*
17618 : ForeachFieldEnumerationDo - for each field in enumeration, Sym,
17619 : do procedure, P. Each call to P contains
17620 : an enumeration field, the order is alphabetical.
17621 : Use ForeachLocalSymDo for declaration order.
17622 : */
17623 :
17624 93765 : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P)
17625 : {
17626 93765 : SymbolTable_PtrToSymbol pSym;
17627 :
17628 93765 : pSym = GetPsym (Sym);
17629 93765 : switch (pSym->SymbolType)
17630 : {
17631 93765 : case SymbolTable_EnumerationSym:
17632 93765 : SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
17633 93765 : break;
17634 :
17635 :
17636 0 : default:
17637 0 : M2Error_InternalError ((const char *) "expecting Enumeration symbol", 28);
17638 93765 : break;
17639 : }
17640 93765 : }
17641 :
17642 :
17643 : /*
17644 : IsType - returns true if the Sym is a type symbol.
17645 : */
17646 :
17647 1689210873 : extern "C" bool SymbolTable_IsType (unsigned int Sym)
17648 : {
17649 1689210873 : SymbolTable_PtrToSymbol pSym;
17650 :
17651 1689210873 : pSym = GetPsym (Sym);
17652 1689210873 : return pSym->SymbolType == SymbolTable_TypeSym;
17653 : /* static analysis guarentees a RETURN statement will be used before here. */
17654 : __builtin_unreachable ();
17655 : }
17656 :
17657 :
17658 : /*
17659 : IsProcedure - returns true if Sym is a procedure symbol.
17660 : */
17661 :
17662 437720681 : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym)
17663 : {
17664 437720681 : SymbolTable_PtrToSymbol pSym;
17665 :
17666 437720681 : AssertInRange (Sym);
17667 437720681 : pSym = GetPsym (Sym);
17668 437720681 : return pSym->SymbolType == SymbolTable_ProcedureSym;
17669 : /* static analysis guarentees a RETURN statement will be used before here. */
17670 : __builtin_unreachable ();
17671 : }
17672 :
17673 :
17674 : /*
17675 : IsParameter - returns true if Sym is a parameter symbol.
17676 : */
17677 :
17678 75178447 : extern "C" bool SymbolTable_IsParameter (unsigned int Sym)
17679 : {
17680 75178447 : SymbolTable_PtrToSymbol pSym;
17681 :
17682 75178447 : pSym = GetPsym (Sym);
17683 75178447 : switch (pSym->SymbolType)
17684 : {
17685 : case SymbolTable_ParamSym:
17686 : case SymbolTable_VarParamSym:
17687 : return true;
17688 67099478 : break;
17689 :
17690 :
17691 67099478 : default:
17692 67099478 : return false;
17693 : break;
17694 : }
17695 : /* static analysis guarentees a RETURN statement will be used before here. */
17696 : __builtin_unreachable ();
17697 : }
17698 :
17699 :
17700 : /*
17701 : GetProcedureKind - returns the procedure kind given the declaration tok.
17702 : The declaration tok must match the ident tok in the
17703 : procedure name. It is only safe to call this
17704 : procedure function during pass 2 onwards.
17705 : */
17706 :
17707 33007711 : extern "C" SymbolTable_ProcedureKind SymbolTable_GetProcedureKind (unsigned int sym, unsigned int tok)
17708 : {
17709 33007711 : SymbolTable_ProcedureKind kind;
17710 33007711 : SymbolTable_PtrToSymbol pSym;
17711 :
17712 33007711 : pSym = GetPsym (sym);
17713 33007711 : switch (pSym->SymbolType)
17714 : {
17715 : case SymbolTable_ProcedureSym:
17716 73116731 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
17717 : {
17718 73116731 : if (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok == tok)
17719 : {
17720 : return kind;
17721 : }
17722 : }
17723 0 : break;
17724 :
17725 : case SymbolTable_ProcTypeSym:
17726 : return SymbolTable_ProperProcedure;
17727 0 : break;
17728 :
17729 :
17730 0 : default:
17731 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
17732 0 : break;
17733 : }
17734 0 : M2Error_InternalError ((const char *) "ProcedureSym kind has not yet been declared", 43);
17735 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17736 : __builtin_unreachable ();
17737 : }
17738 :
17739 :
17740 : /*
17741 : GetProcedureDeclaredTok - return the token where the
17742 : declaration of procedure sym:kind
17743 : occurred.
17744 : */
17745 :
17746 36 : extern "C" unsigned int SymbolTable_GetProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind)
17747 : {
17748 36 : SymbolTable_PtrToSymbol pSym;
17749 :
17750 36 : pSym = GetPsym (sym);
17751 36 : switch (pSym->SymbolType)
17752 : {
17753 36 : case SymbolTable_ProcedureSym:
17754 36 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok;
17755 0 : break;
17756 :
17757 :
17758 0 : default:
17759 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17760 : break;
17761 : }
17762 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17763 : __builtin_unreachable ();
17764 : }
17765 :
17766 :
17767 : /*
17768 : PutProcedureDeclaredTok - places the tok where the
17769 : declaration of procedure sym:kind
17770 : occurred.
17771 : */
17772 :
17773 5557716 : extern "C" void SymbolTable_PutProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok)
17774 : {
17775 5557716 : SymbolTable_PtrToSymbol pSym;
17776 :
17777 5557716 : pSym = GetPsym (sym);
17778 5557716 : switch (pSym->SymbolType)
17779 : {
17780 5557716 : case SymbolTable_ProcedureSym:
17781 5557716 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok = tok;
17782 5557716 : break;
17783 :
17784 :
17785 0 : default:
17786 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17787 5557716 : break;
17788 : }
17789 5557716 : }
17790 :
17791 :
17792 : /*
17793 : GetReturnTypeTok - return the token where the
17794 : return type procedure sym:kind or proctype
17795 : was defined.
17796 : */
17797 :
17798 6 : extern "C" unsigned int SymbolTable_GetReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind)
17799 : {
17800 6 : SymbolTable_PtrToSymbol pSym;
17801 :
17802 6 : pSym = GetPsym (sym);
17803 6 : switch (pSym->SymbolType)
17804 : {
17805 6 : case SymbolTable_ProcedureSym:
17806 6 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok;
17807 0 : break;
17808 :
17809 0 : case SymbolTable_ProcTypeSym:
17810 0 : return pSym->ProcType.ReturnTypeTok;
17811 0 : break;
17812 :
17813 :
17814 0 : default:
17815 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17816 : break;
17817 : }
17818 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17819 : __builtin_unreachable ();
17820 : }
17821 :
17822 :
17823 : /*
17824 : PutReturnTypeTok - places the tok where the
17825 : return type of procedure sym:kind or proctype
17826 : was defined.
17827 : */
17828 :
17829 0 : extern "C" void SymbolTable_PutReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok)
17830 : {
17831 0 : SymbolTable_PtrToSymbol pSym;
17832 :
17833 0 : pSym = GetPsym (sym);
17834 0 : switch (pSym->SymbolType)
17835 : {
17836 0 : case SymbolTable_ProcedureSym:
17837 0 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
17838 0 : break;
17839 :
17840 0 : case SymbolTable_ProcTypeSym:
17841 0 : pSym->ProcType.ReturnTypeTok = tok;
17842 0 : break;
17843 :
17844 :
17845 0 : default:
17846 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17847 0 : break;
17848 : }
17849 0 : }
17850 :
17851 :
17852 : /*
17853 : PutProcedureParametersDefined - the procedure symbol sym:kind
17854 : parameters have been defined.
17855 : */
17856 :
17857 10931923 : extern "C" void SymbolTable_PutProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17858 : {
17859 10931923 : SymbolTable_PtrToSymbol pSym;
17860 :
17861 10931923 : AssertInRange (sym);
17862 10931923 : pSym = GetPsym (sym);
17863 10931923 : switch (pSym->SymbolType)
17864 : {
17865 : case SymbolTable_ErrorSym:
17866 : break;
17867 :
17868 10931923 : case SymbolTable_ProcedureSym:
17869 10931923 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ParamDefined = true;
17870 10931923 : pSym->Procedure.BuildProcType = false;
17871 10931923 : break;
17872 :
17873 : case SymbolTable_ProcTypeSym:
17874 : break;
17875 :
17876 :
17877 0 : default:
17878 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17879 10931923 : break;
17880 : }
17881 10931923 : }
17882 :
17883 :
17884 : /*
17885 : GetProcedureParametersDefined - returns true if procedure symbol sym:kind
17886 : parameters are defined.
17887 : */
17888 :
17889 186631398 : extern "C" bool SymbolTable_GetProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17890 : {
17891 186631398 : SymbolTable_PtrToSymbol pSym;
17892 :
17893 186631398 : AssertInRange (sym);
17894 186631398 : pSym = GetPsym (sym);
17895 186631398 : switch (pSym->SymbolType)
17896 : {
17897 : case SymbolTable_ErrorSym:
17898 : return false;
17899 177664904 : break;
17900 :
17901 177664904 : case SymbolTable_ProcedureSym:
17902 177664904 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ParamDefined;
17903 8966494 : break;
17904 :
17905 8966494 : case SymbolTable_ProcTypeSym:
17906 8966494 : return true;
17907 0 : break;
17908 :
17909 :
17910 0 : default:
17911 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17912 : break;
17913 : }
17914 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17915 : __builtin_unreachable ();
17916 : }
17917 :
17918 :
17919 : /*
17920 : PutProcedureDefined - the procedure symbol sym:kind is defined.
17921 : */
17922 :
17923 7378851 : extern "C" void SymbolTable_PutProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17924 : {
17925 7378851 : SymbolTable_PtrToSymbol pSym;
17926 :
17927 7378851 : AssertInRange (sym);
17928 7378851 : pSym = GetPsym (sym);
17929 7378851 : switch (pSym->SymbolType)
17930 : {
17931 : case SymbolTable_ErrorSym:
17932 : break;
17933 :
17934 7378851 : case SymbolTable_ProcedureSym:
17935 7378851 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].Defined = true;
17936 7378851 : break;
17937 :
17938 :
17939 0 : default:
17940 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17941 7378851 : break;
17942 : }
17943 7378851 : }
17944 :
17945 :
17946 : /*
17947 : GetProcedureDefined - returns true if procedure symbol sym:kind
17948 : is defined.
17949 : */
17950 :
17951 37116352 : extern "C" bool SymbolTable_GetProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17952 : {
17953 37116352 : SymbolTable_PtrToSymbol pSym;
17954 :
17955 37116352 : AssertInRange (sym);
17956 37116352 : pSym = GetPsym (sym);
17957 37116352 : switch (pSym->SymbolType)
17958 : {
17959 : case SymbolTable_ErrorSym:
17960 : return false;
17961 37116352 : break;
17962 :
17963 37116352 : case SymbolTable_ProcedureSym:
17964 37116352 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].Defined;
17965 0 : break;
17966 :
17967 :
17968 0 : default:
17969 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17970 : break;
17971 : }
17972 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17973 : __builtin_unreachable ();
17974 : }
17975 :
17976 :
17977 : /*
17978 : PutUseVarArgs - tell the symbol table that this procedure, Sym,
17979 : uses varargs.
17980 : The procedure _must_ be declared inside a
17981 : DEFINITION FOR "C"
17982 :
17983 : */
17984 :
17985 11520 : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym)
17986 : {
17987 11520 : SymbolTable_PtrToSymbol pSym;
17988 :
17989 11520 : AssertInRange (Sym);
17990 11520 : pSym = GetPsym (Sym);
17991 11520 : switch (pSym->SymbolType)
17992 : {
17993 : case SymbolTable_ErrorSym:
17994 : break;
17995 :
17996 11520 : case SymbolTable_ProcedureSym:
17997 : /* Currently can only declare var args in a definition module. */
17998 11520 : pSym->Procedure.Decl.array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure].HasVarArgs = true;
17999 11520 : break;
18000 :
18001 0 : case SymbolTable_ProcTypeSym:
18002 0 : pSym->ProcType.HasVarArgs = true;
18003 0 : break;
18004 :
18005 :
18006 0 : default:
18007 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18008 11520 : break;
18009 : }
18010 11520 : }
18011 :
18012 :
18013 : /*
18014 : UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
18015 : The procedure _must_ be declared inside a
18016 : DEFINITION FOR "C"
18017 : */
18018 :
18019 3881609 : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym)
18020 : {
18021 3881609 : SymbolTable_PtrToSymbol pSym;
18022 :
18023 3881609 : AssertInRange (Sym);
18024 3881609 : pSym = GetPsym (Sym);
18025 3881609 : switch (pSym->SymbolType)
18026 : {
18027 : case SymbolTable_ErrorSym:
18028 : return false;
18029 3822637 : break;
18030 :
18031 3822637 : case SymbolTable_ProcedureSym:
18032 : /* Currently can only declare var args in a definition module. */
18033 3822637 : return pSym->Procedure.Decl.array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure].HasVarArgs;
18034 58972 : break;
18035 :
18036 58972 : case SymbolTable_ProcTypeSym:
18037 58972 : return pSym->ProcType.HasVarArgs;
18038 0 : break;
18039 :
18040 :
18041 0 : default:
18042 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18043 : break;
18044 : }
18045 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18046 : __builtin_unreachable ();
18047 : }
18048 :
18049 :
18050 : /*
18051 : PutUseOptArg - tell the symbol table that this procedure, Sym,
18052 : uses an optarg.
18053 : */
18054 :
18055 18181 : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind)
18056 : {
18057 18181 : SymbolTable_PtrToSymbol pSym;
18058 :
18059 18181 : AssertInRange (Sym);
18060 18181 : pSym = GetPsym (Sym);
18061 18181 : switch (pSym->SymbolType)
18062 : {
18063 : case SymbolTable_ErrorSym:
18064 : break;
18065 :
18066 18181 : case SymbolTable_ProcedureSym:
18067 18181 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].HasOptArg = true;
18068 18181 : break;
18069 :
18070 0 : case SymbolTable_ProcTypeSym:
18071 0 : pSym->ProcType.HasOptArg = true;
18072 0 : break;
18073 :
18074 :
18075 0 : default:
18076 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18077 18181 : break;
18078 : }
18079 18181 : }
18080 :
18081 :
18082 : /*
18083 : UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
18084 : */
18085 :
18086 220683 : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind)
18087 : {
18088 220683 : SymbolTable_PtrToSymbol pSym;
18089 :
18090 220683 : AssertInRange (Sym);
18091 220683 : pSym = GetPsym (Sym);
18092 220683 : switch (pSym->SymbolType)
18093 : {
18094 : case SymbolTable_ErrorSym:
18095 : return false;
18096 220683 : break;
18097 :
18098 220683 : case SymbolTable_ProcedureSym:
18099 220683 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].HasOptArg;
18100 0 : break;
18101 :
18102 0 : case SymbolTable_ProcTypeSym:
18103 0 : return pSym->ProcType.HasOptArg;
18104 0 : break;
18105 :
18106 :
18107 0 : default:
18108 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18109 : break;
18110 : }
18111 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18112 : __builtin_unreachable ();
18113 : }
18114 :
18115 :
18116 : /*
18117 : PutOptArgInit - makes symbol, Sym, the initializer value to
18118 : procedure, ProcSym.
18119 : */
18120 :
18121 15163 : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym)
18122 : {
18123 15163 : SymbolTable_PtrToSymbol pSym;
18124 :
18125 15163 : AssertInRange (Sym);
18126 15163 : if (! (SymbolTable_IsError (ProcSym)))
18127 : {
18128 15163 : pSym = GetPsym (ProcSym);
18129 15163 : switch (pSym->SymbolType)
18130 : {
18131 : case SymbolTable_ErrorSym:
18132 : break;
18133 :
18134 15163 : case SymbolTable_ProcedureSym:
18135 15163 : pSym->Procedure.OptArgInit = Sym;
18136 15163 : break;
18137 :
18138 0 : case SymbolTable_ProcTypeSym:
18139 0 : pSym->ProcType.OptArgInit = Sym;
18140 0 : break;
18141 :
18142 :
18143 0 : default:
18144 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18145 : break;
18146 : }
18147 : }
18148 15163 : }
18149 :
18150 :
18151 : /*
18152 : GetOptArgInit - returns the initializer value to the optional parameter in
18153 : procedure, ProcSym.
18154 : */
18155 :
18156 3493 : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym)
18157 : {
18158 3493 : SymbolTable_PtrToSymbol pSym;
18159 :
18160 3493 : if (! (SymbolTable_IsError (ProcSym)))
18161 : {
18162 3493 : pSym = GetPsym (ProcSym);
18163 3493 : switch (pSym->SymbolType)
18164 : {
18165 : case SymbolTable_ErrorSym:
18166 : break;
18167 :
18168 3493 : case SymbolTable_ProcedureSym:
18169 3493 : return pSym->Procedure.OptArgInit;
18170 0 : break;
18171 :
18172 0 : case SymbolTable_ProcTypeSym:
18173 0 : return pSym->ProcType.OptArgInit;
18174 0 : break;
18175 :
18176 :
18177 0 : default:
18178 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18179 : break;
18180 : }
18181 : }
18182 : return SymbolTable_NulSym;
18183 : /* static analysis guarentees a RETURN statement will be used before here. */
18184 : __builtin_unreachable ();
18185 : }
18186 :
18187 :
18188 : /*
18189 : MakePointer - returns a pointer symbol with PointerName.
18190 : */
18191 :
18192 175330 : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName)
18193 : {
18194 175330 : unsigned int oaf;
18195 175330 : unsigned int sym;
18196 :
18197 175330 : tok = CheckTok (tok, (const char *) "pointer", 7);
18198 175330 : sym = HandleHiddenOrDeclare (tok, PointerName, &oaf);
18199 175330 : FillInPointerFields (sym, PointerName, SymbolTable_GetCurrentScope (), oaf);
18200 175330 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
18201 175330 : return sym;
18202 : /* static analysis guarentees a RETURN statement will be used before here. */
18203 : __builtin_unreachable ();
18204 : }
18205 :
18206 :
18207 : /*
18208 : PutPointer - gives a pointer symbol a type, PointerType.
18209 : */
18210 :
18211 206166 : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType)
18212 : {
18213 206166 : SymbolTable_PtrToSymbol pSym;
18214 :
18215 206166 : pSym = GetPsym (Sym);
18216 206166 : switch (pSym->SymbolType)
18217 : {
18218 : case SymbolTable_ErrorSym:
18219 : break;
18220 :
18221 206166 : case SymbolTable_PointerSym:
18222 206166 : pSym->Pointer.Type = PointerType;
18223 206166 : break;
18224 :
18225 :
18226 0 : default:
18227 0 : M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26);
18228 206166 : break;
18229 : }
18230 206166 : }
18231 :
18232 :
18233 : /*
18234 : IsPointer - returns true is Sym is a pointer type symbol.
18235 : */
18236 :
18237 480430890 : extern "C" bool SymbolTable_IsPointer (unsigned int Sym)
18238 : {
18239 480430890 : SymbolTable_PtrToSymbol pSym;
18240 :
18241 480430890 : AssertInRange (Sym);
18242 480430890 : pSym = GetPsym (Sym);
18243 480430890 : return pSym->SymbolType == SymbolTable_PointerSym;
18244 : /* static analysis guarentees a RETURN statement will be used before here. */
18245 : __builtin_unreachable ();
18246 : }
18247 :
18248 :
18249 : /*
18250 : IsRecord - returns true is Sym is a record type symbol.
18251 : */
18252 :
18253 481425628 : extern "C" bool SymbolTable_IsRecord (unsigned int Sym)
18254 : {
18255 481425628 : SymbolTable_PtrToSymbol pSym;
18256 :
18257 481425628 : AssertInRange (Sym);
18258 481425620 : pSym = GetPsym (Sym);
18259 481425620 : return pSym->SymbolType == SymbolTable_RecordSym;
18260 : /* static analysis guarentees a RETURN statement will be used before here. */
18261 : __builtin_unreachable ();
18262 : }
18263 :
18264 :
18265 : /*
18266 : IsVarient - returns true if the symbol, Sym, is a
18267 : varient symbol.
18268 : */
18269 :
18270 393211568 : extern "C" bool SymbolTable_IsVarient (unsigned int Sym)
18271 : {
18272 393211568 : SymbolTable_PtrToSymbol pSym;
18273 :
18274 393211568 : pSym = GetPsym (Sym);
18275 393211568 : return pSym->SymbolType == SymbolTable_VarientSym;
18276 : /* static analysis guarentees a RETURN statement will be used before here. */
18277 : __builtin_unreachable ();
18278 : }
18279 :
18280 :
18281 : /*
18282 : IsFieldVarient - returns true if the symbol, Sym, is a
18283 : varient field.
18284 : */
18285 :
18286 226282865 : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym)
18287 : {
18288 226282865 : SymbolTable_PtrToSymbol pSym;
18289 :
18290 226282865 : pSym = GetPsym (Sym);
18291 226282865 : return pSym->SymbolType == SymbolTable_VarientFieldSym;
18292 : /* static analysis guarentees a RETURN statement will be used before here. */
18293 : __builtin_unreachable ();
18294 : }
18295 :
18296 :
18297 : /*
18298 : IsFieldEnumeration - returns true if the symbol, Sym, is an
18299 : enumeration field.
18300 : */
18301 :
18302 11729998 : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym)
18303 : {
18304 11729998 : SymbolTable_PtrToSymbol pSym;
18305 :
18306 11729998 : pSym = GetPsym (Sym);
18307 11729998 : return pSym->SymbolType == SymbolTable_EnumerationFieldSym;
18308 : /* static analysis guarentees a RETURN statement will be used before here. */
18309 : __builtin_unreachable ();
18310 : }
18311 :
18312 :
18313 : /*
18314 : IsArray - returns true is Sym is an array type symbol.
18315 : */
18316 :
18317 332656450 : extern "C" bool SymbolTable_IsArray (unsigned int Sym)
18318 : {
18319 332656450 : SymbolTable_PtrToSymbol pSym;
18320 :
18321 332656450 : AssertInRange (Sym);
18322 332656450 : pSym = GetPsym (Sym);
18323 332656450 : return pSym->SymbolType == SymbolTable_ArraySym;
18324 : /* static analysis guarentees a RETURN statement will be used before here. */
18325 : __builtin_unreachable ();
18326 : }
18327 :
18328 :
18329 : /*
18330 : IsEnumeration - returns true if Sym is an enumeration symbol.
18331 : */
18332 :
18333 475168633 : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym)
18334 : {
18335 475168633 : SymbolTable_PtrToSymbol pSym;
18336 :
18337 475168633 : AssertInRange (Sym);
18338 475168633 : pSym = GetPsym (Sym);
18339 475168633 : return pSym->SymbolType == SymbolTable_EnumerationSym;
18340 : /* static analysis guarentees a RETURN statement will be used before here. */
18341 : __builtin_unreachable ();
18342 : }
18343 :
18344 :
18345 : /*
18346 : IsSet - returns TRUE if Sym is a set symbol.
18347 : */
18348 :
18349 204703573 : extern "C" bool SymbolTable_IsSet (unsigned int Sym)
18350 : {
18351 204703573 : SymbolTable_PtrToSymbol pSym;
18352 :
18353 204703573 : AssertInRange (Sym);
18354 204703573 : pSym = GetPsym (Sym);
18355 204703573 : return pSym->SymbolType == SymbolTable_SetSym;
18356 : /* static analysis guarentees a RETURN statement will be used before here. */
18357 : __builtin_unreachable ();
18358 : }
18359 :
18360 :
18361 : /*
18362 : IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
18363 : */
18364 :
18365 26874312 : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym)
18366 : {
18367 26874312 : SymbolTable_PtrToSymbol pSym;
18368 :
18369 26874312 : pSym = GetPsym (Sym);
18370 26874312 : switch (pSym->SymbolType)
18371 : {
18372 26844001 : case SymbolTable_TypeSym:
18373 26844001 : return pSym->Type.IsHidden;
18374 : break;
18375 :
18376 :
18377 : default:
18378 : return false;
18379 : break;
18380 : }
18381 : /* static analysis guarentees a RETURN statement will be used before here. */
18382 : __builtin_unreachable ();
18383 : }
18384 :
18385 :
18386 : /*
18387 : IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
18388 : */
18389 :
18390 0 : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym)
18391 : {
18392 0 : SymbolTable_PtrToSymbol pSym;
18393 :
18394 0 : AssertInRange (Sym);
18395 0 : pSym = GetPsym (Sym);
18396 0 : return pSym->SymbolType == SymbolTable_OAFamilySym;
18397 : /* static analysis guarentees a RETURN statement will be used before here. */
18398 : __builtin_unreachable ();
18399 : }
18400 :
18401 :
18402 : /*
18403 : GetDimension - return the number of dimensions associated with
18404 : this unbounded ARRAY parameter.
18405 : */
18406 :
18407 382347 : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym)
18408 : {
18409 680989 : SymbolTable_PtrToSymbol pSym;
18410 :
18411 680989 : pSym = GetPsym (sym);
18412 680989 : switch (pSym->SymbolType)
18413 : {
18414 0 : case SymbolTable_PartialUnboundedSym:
18415 0 : return pSym->PartialUnbounded.NDim;
18416 375588 : break;
18417 :
18418 375588 : case SymbolTable_UnboundedSym:
18419 375588 : return pSym->Unbounded.Dimensions;
18420 0 : break;
18421 :
18422 0 : case SymbolTable_OAFamilySym:
18423 0 : return pSym->OAFamily.MaxDimensions;
18424 180174 : break;
18425 :
18426 180174 : case SymbolTable_ParamSym:
18427 180174 : if (pSym->Param.IsUnbounded)
18428 : {
18429 180174 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18430 : }
18431 : else
18432 : {
18433 0 : M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
18434 : }
18435 118432 : break;
18436 :
18437 118432 : case SymbolTable_VarParamSym:
18438 118432 : if (pSym->VarParam.IsUnbounded)
18439 : {
18440 118432 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18441 : }
18442 : else
18443 : {
18444 0 : M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
18445 : }
18446 6759 : break;
18447 :
18448 6759 : case SymbolTable_ArraySym:
18449 6759 : return GetArrayDimension (sym);
18450 0 : break;
18451 :
18452 0 : case SymbolTable_TypeSym:
18453 0 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18454 36 : break;
18455 :
18456 36 : case SymbolTable_VarSym:
18457 36 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18458 0 : break;
18459 :
18460 :
18461 0 : default:
18462 0 : M2Error_InternalError ((const char *) "expecting PartialUnbounded", 26);
18463 : break;
18464 : }
18465 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18466 : __builtin_unreachable ();
18467 : }
18468 :
18469 :
18470 : /*
18471 : MakeOAFamily - makes an OAFamily symbol based on SimpleType.
18472 : It returns the OAFamily symbol. A new symbol
18473 : is created if one does not already exist for
18474 : SimpleType.
18475 : */
18476 :
18477 1044754 : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType)
18478 : {
18479 1044754 : SymbolTable_PtrToSymbol pSym;
18480 1044754 : unsigned int sym;
18481 :
18482 1044754 : sym = SymbolTable_GetOAFamily (SimpleType);
18483 1044754 : if (sym == SymbolTable_NulSym)
18484 : {
18485 30776 : NewSym (&sym);
18486 30776 : pSym = GetPsym (sym);
18487 30776 : pSym->SymbolType = SymbolTable_OAFamilySym;
18488 30776 : pSym->OAFamily.MaxDimensions = 0;
18489 30776 : pSym->OAFamily.SimpleType = SimpleType;
18490 30776 : pSym->OAFamily.Dimensions = Indexing_InitIndex (1);
18491 30776 : PutOAFamily (SimpleType, sym);
18492 : }
18493 1044754 : return sym;
18494 : /* static analysis guarentees a RETURN statement will be used before here. */
18495 : __builtin_unreachable ();
18496 : }
18497 :
18498 :
18499 : /*
18500 : GetOAFamily - returns the oafamily symbol associated with
18501 : SimpleType.
18502 : */
18503 :
18504 427892147 : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType)
18505 : {
18506 427892147 : SymbolTable_PtrToSymbol pSym;
18507 :
18508 427892147 : pSym = GetPsym (SimpleType);
18509 427892147 : switch (pSym->SymbolType)
18510 : {
18511 : case SymbolTable_ErrorSym:
18512 : return SymbolTable_NulSym;
18513 41895866 : break;
18514 :
18515 41895866 : case SymbolTable_RecordSym:
18516 41895866 : return pSym->Record.oafamily;
18517 5667474 : break;
18518 :
18519 5667474 : case SymbolTable_SubrangeSym:
18520 5667474 : return pSym->Subrange.oafamily;
18521 11561777 : break;
18522 :
18523 11561777 : case SymbolTable_EnumerationSym:
18524 11561777 : return pSym->Enumeration.oafamily;
18525 4837761 : break;
18526 :
18527 4837761 : case SymbolTable_ArraySym:
18528 4837761 : return pSym->Array.oafamily;
18529 4754462 : break;
18530 :
18531 4754462 : case SymbolTable_ProcTypeSym:
18532 4754462 : return pSym->ProcType.oafamily;
18533 87418237 : break;
18534 :
18535 87418237 : case SymbolTable_TypeSym:
18536 87418237 : return pSym->Type.oafamily;
18537 49137566 : break;
18538 :
18539 49137566 : case SymbolTable_PointerSym:
18540 49137566 : return pSym->Pointer.oafamily;
18541 1692904 : break;
18542 :
18543 1692904 : case SymbolTable_SetSym:
18544 1692904 : return pSym->Set.oafamily;
18545 129903 : break;
18546 :
18547 129903 : case SymbolTable_UndefinedSym:
18548 129903 : return pSym->Undefined.oafamily;
18549 : break;
18550 :
18551 :
18552 : default:
18553 : return SymbolTable_NulSym;
18554 : break;
18555 : }
18556 : /* static analysis guarentees a RETURN statement will be used before here. */
18557 : __builtin_unreachable ();
18558 : }
18559 :
18560 :
18561 : /*
18562 : ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
18563 : sym, in the oaf.
18564 : */
18565 :
18566 426847393 : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p)
18567 : {
18568 426847393 : typedef unsigned int *ForeachOAFamily__T1;
18569 :
18570 426847393 : SymbolTable_PtrToSymbol pSym;
18571 426847393 : unsigned int h;
18572 426847393 : unsigned int i;
18573 426847393 : ForeachOAFamily__T1 pc;
18574 :
18575 426847393 : if (sym != SymbolTable_NulSym)
18576 : {
18577 26342098 : pSym = GetPsym (sym);
18578 26342098 : switch (pSym->SymbolType)
18579 : {
18580 26342098 : case SymbolTable_OAFamilySym:
18581 26342098 : h = Indexing_HighIndice (pSym->OAFamily.Dimensions);
18582 26342098 : i = 1;
18583 79189836 : while (i <= h)
18584 : {
18585 26505640 : pc = static_cast<ForeachOAFamily__T1> (Indexing_GetIndice (pSym->OAFamily.Dimensions, i));
18586 26505640 : if (pc != NULL)
18587 : {
18588 26505640 : (*p.proc) (sym, i, (*pc));
18589 : }
18590 26505640 : i += 1;
18591 : }
18592 : break;
18593 :
18594 :
18595 0 : default:
18596 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
18597 : break;
18598 : }
18599 : }
18600 426847393 : }
18601 :
18602 :
18603 : /*
18604 : IsUnbounded - returns true if Sym is an unbounded symbol.
18605 : */
18606 :
18607 257596696 : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym)
18608 : {
18609 257596696 : SymbolTable_PtrToSymbol pSym;
18610 :
18611 257596696 : AssertInRange (Sym);
18612 257596696 : pSym = GetPsym (Sym);
18613 257596696 : return pSym->SymbolType == SymbolTable_UnboundedSym;
18614 : /* static analysis guarentees a RETURN statement will be used before here. */
18615 : __builtin_unreachable ();
18616 : }
18617 :
18618 :
18619 : /*
18620 : GetUnbounded - returns the unbounded symbol associated with
18621 : the OAFamily symbol, oaf, and the number of
18622 : dimensions, ndim, of the open array.
18623 : */
18624 :
18625 1044754 : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim)
18626 : {
18627 1044754 : SymbolTable_PtrToSymbol pSym;
18628 :
18629 1044754 : pSym = GetPsym (oaf);
18630 1044754 : switch (pSym->SymbolType)
18631 : {
18632 1044754 : case SymbolTable_OAFamilySym:
18633 1044754 : if (ndim > pSym->OAFamily.MaxDimensions)
18634 : {
18635 : return SymbolTable_NulSym;
18636 : }
18637 : else
18638 : {
18639 1013918 : return GetFromIndex (pSym->OAFamily.Dimensions, ndim);
18640 : }
18641 0 : break;
18642 :
18643 :
18644 0 : default:
18645 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
18646 : break;
18647 : }
18648 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18649 : __builtin_unreachable ();
18650 : }
18651 :
18652 :
18653 : /*
18654 : GetUnboundedRecordType - returns the record type used to
18655 : implement the unbounded array.
18656 : */
18657 :
18658 29644166 : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym)
18659 : {
18660 29644166 : SymbolTable_PtrToSymbol pSym;
18661 :
18662 29644166 : pSym = GetPsym (Sym);
18663 29644166 : switch (pSym->SymbolType)
18664 : {
18665 29644166 : case SymbolTable_UnboundedSym:
18666 29644166 : return pSym->Unbounded.RecordType;
18667 0 : break;
18668 :
18669 :
18670 0 : default:
18671 0 : M2Error_InternalError ((const char *) "expecting an UnBounded symbol", 29);
18672 : break;
18673 : }
18674 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18675 : __builtin_unreachable ();
18676 : }
18677 :
18678 :
18679 : /*
18680 : GetUnboundedAddressOffset - returns the offset of the address field
18681 : inside the record used to implement the
18682 : unbounded type.
18683 : */
18684 :
18685 77473 : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym)
18686 : {
18687 77473 : unsigned int field;
18688 77473 : unsigned int rec;
18689 :
18690 77473 : rec = SymbolTable_GetUnboundedRecordType (sym);
18691 77473 : if (rec == SymbolTable_NulSym)
18692 : {
18693 0 : M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
18694 : }
18695 : else
18696 : {
18697 77473 : field = SymbolTable_GetLocalSym (rec, NameKey_MakeKey ((const char *) "_m2_contents", 12));
18698 77473 : if (field == SymbolTable_NulSym)
18699 : {
18700 0 : M2Error_InternalError ((const char *) "expecting address field to be present inside unbounded record", 61);
18701 : }
18702 : else
18703 : {
18704 77473 : return field;
18705 : }
18706 : }
18707 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18708 : __builtin_unreachable ();
18709 : }
18710 :
18711 :
18712 : /*
18713 : GetUnboundedHighOffset - returns the offset of the high field
18714 : inside the record used to implement the
18715 : unbounded type.
18716 : */
18717 :
18718 64014 : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim)
18719 : {
18720 64014 : unsigned int rec;
18721 :
18722 64014 : rec = SymbolTable_GetUnboundedRecordType (sym);
18723 64014 : if (rec == SymbolTable_NulSym)
18724 : {
18725 0 : M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
18726 : }
18727 : else
18728 : {
18729 64014 : return SymbolTable_GetLocalSym (rec, NameKey_makekey (DynamicStrings_string (DynamicStrings_Mark (FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_m2_high_%d", 11)), (const unsigned char *) &ndim, (sizeof (ndim)-1))))));
18730 : }
18731 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18732 : __builtin_unreachable ();
18733 : }
18734 :
18735 :
18736 : /*
18737 : MakeSubscript - makes a subscript Symbol.
18738 : No name is required.
18739 : */
18740 :
18741 167807 : extern "C" unsigned int SymbolTable_MakeSubscript (void)
18742 : {
18743 167807 : SymbolTable_PtrToSymbol pSym;
18744 167807 : unsigned int Sym;
18745 :
18746 167807 : NewSym (&Sym);
18747 167807 : pSym = GetPsym (Sym);
18748 167807 : pSym->SymbolType = SymbolTable_SubscriptSym;
18749 167807 : pSym->Subscript.Type = SymbolTable_NulSym; /* Index to a subrange symbol. */
18750 167807 : pSym->Subscript.Size = M2ALU_InitValue (); /* Size of this indice in*Size */
18751 167807 : pSym->Subscript.Offset = M2ALU_InitValue (); /* Offset at runtime of symbol */
18752 167807 : InitWhereDeclared (&pSym->Subscript.At); /* Declared here */
18753 167807 : return Sym;
18754 : /* static analysis guarentees a RETURN statement will be used before here. */
18755 : __builtin_unreachable ();
18756 : }
18757 :
18758 :
18759 : /*
18760 : PutSubscript - gives a subscript symbol a type, SimpleType.
18761 : */
18762 :
18763 167807 : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType)
18764 : {
18765 167807 : SymbolTable_PtrToSymbol pSym;
18766 :
18767 167807 : pSym = GetPsym (Sym);
18768 167807 : switch (pSym->SymbolType)
18769 : {
18770 : case SymbolTable_ErrorSym:
18771 : break;
18772 :
18773 167807 : case SymbolTable_SubscriptSym:
18774 167807 : pSym->Subscript.Type = SimpleType;
18775 167807 : break;
18776 :
18777 :
18778 0 : default:
18779 0 : M2Error_InternalError ((const char *) "expecting a SubScript symbol", 28);
18780 167807 : break;
18781 : }
18782 167807 : }
18783 :
18784 :
18785 : /*
18786 : MakeUnbounded - makes an unbounded array Symbol.
18787 : ndim is the number of dimensions required.
18788 : No name is required.
18789 : */
18790 :
18791 1044754 : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim)
18792 : {
18793 1044754 : unsigned int sym;
18794 1044754 : unsigned int oaf;
18795 :
18796 1044754 : tok = CheckTok (tok, (const char *) "unbounded", 9);
18797 1044754 : oaf = SymbolTable_MakeOAFamily (SimpleType);
18798 1044754 : sym = SymbolTable_GetUnbounded (oaf, ndim);
18799 1044754 : if (sym == SymbolTable_NulSym)
18800 : {
18801 30836 : NewSym (&sym);
18802 30836 : if (SymbolTable_IsUnknown (SimpleType))
18803 : {
18804 0 : PutPartialUnbounded (sym, SimpleType, ndim);
18805 : }
18806 : else
18807 : {
18808 30836 : FillInUnboundedFields (tok, sym, SimpleType, ndim);
18809 : }
18810 30836 : PutUnbounded (oaf, sym, ndim);
18811 : }
18812 1044754 : return sym;
18813 : /* static analysis guarentees a RETURN statement will be used before here. */
18814 : __builtin_unreachable ();
18815 : }
18816 :
18817 :
18818 : /*
18819 : NoOfElements - Returns the number of elements in array Sym,
18820 : or the number of elements in an enumeration Sym or
18821 : the number of interface symbols in an Interface list.
18822 : */
18823 :
18824 244 : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym)
18825 : {
18826 244 : SymbolTable_PtrToSymbol pSym;
18827 244 : unsigned int n;
18828 :
18829 244 : pSym = GetPsym (Sym);
18830 244 : switch (pSym->SymbolType)
18831 : {
18832 : case SymbolTable_ErrorSym:
18833 : n = 0;
18834 : break;
18835 :
18836 244 : case SymbolTable_EnumerationSym:
18837 244 : n = pSym->Enumeration.NoOfElements;
18838 244 : break;
18839 :
18840 0 : case SymbolTable_InterfaceSym:
18841 0 : n = Indexing_HighIndice (pSym->Interface.Parameters);
18842 0 : break;
18843 :
18844 :
18845 0 : default:
18846 0 : M2Error_InternalError ((const char *) "expecting an Array or UnBounded symbol", 38);
18847 244 : break;
18848 : }
18849 244 : return n;
18850 : /* static analysis guarentees a RETURN statement will be used before here. */
18851 : __builtin_unreachable ();
18852 : }
18853 :
18854 :
18855 : /*
18856 : PutArray - places a type symbol into an arraysym.
18857 : */
18858 :
18859 167807 : extern "C" void SymbolTable_PutArray (unsigned int arraysym, unsigned int typesym)
18860 : {
18861 167807 : SymbolTable_PtrToSymbol pSym;
18862 :
18863 167807 : pSym = GetPsym (arraysym);
18864 167807 : switch (pSym->SymbolType)
18865 : {
18866 : case SymbolTable_ErrorSym:
18867 : break;
18868 :
18869 167807 : case SymbolTable_ArraySym:
18870 167807 : pSym->Array.Type = typesym; /* The ARRAY OF typesym. */
18871 167807 : break;
18872 :
18873 :
18874 0 : default:
18875 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
18876 167807 : break;
18877 : }
18878 167807 : }
18879 :
18880 :
18881 : /*
18882 : ResolveImports - it examines the import list of all inner modules
18883 : and resolves all relative imports.
18884 : */
18885 :
18886 84697 : extern "C" void SymbolTable_ResolveImports (void)
18887 : {
18888 84697 : unsigned int scope;
18889 :
18890 84697 : scope = SymbolTable_GetCurrentScope ();
18891 84697 : if (DebugUnknowns)
18892 : {
18893 : SymbolTable_DisplayTrees (scope);
18894 : }
18895 84697 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
18896 84697 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
18897 84697 : }
18898 :
18899 :
18900 : /*
18901 : ResolveConstructorTypes - to be called at the end of pass three. Its
18902 : purpose is to fix up all constructors whose
18903 : types are unknown.
18904 : */
18905 :
18906 15163 : extern "C" void SymbolTable_ResolveConstructorTypes (void)
18907 : {
18908 52335 : bool finished;
18909 52335 : unsigned int i;
18910 52335 : unsigned int n;
18911 52335 : unsigned int s;
18912 :
18913 52335 : do {
18914 52335 : n = Lists_NoOfItemsInList (UnresolvedConstructorType);
18915 52335 : finished = true;
18916 52335 : i = 1;
18917 141848 : while (i <= n)
18918 : {
18919 37178 : s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
18920 37178 : M2Debug_Assert (SymbolTable_IsConstructor (s));
18921 37178 : if (CanResolveConstructor (s))
18922 : {
18923 37172 : finished = false;
18924 37172 : Lists_RemoveItemFromList (UnresolvedConstructorType, s);
18925 37172 : i = n;
18926 : }
18927 37178 : i += 1;
18928 : }
18929 52335 : } while (! (finished));
18930 15163 : CheckAllConstructorsResolved ();
18931 15157 : }
18932 :
18933 :
18934 : /*
18935 : AddNameToScope - adds a Name, n, to the list of objects declared at the
18936 : current scope.
18937 : */
18938 :
18939 8104782 : extern "C" void SymbolTable_AddNameToScope (unsigned int tok, NameKey_Name n)
18940 : {
18941 8104782 : SymbolTable_PtrToSymbol pSym;
18942 8104782 : unsigned int scope;
18943 :
18944 8104782 : scope = SymbolTable_GetCurrentScope ();
18945 8104782 : pSym = GetPsym (scope);
18946 8104782 : switch (pSym->SymbolType)
18947 : {
18948 1605277 : case SymbolTable_ProcedureSym:
18949 1605277 : AddNameTo (pSym->Procedure.NamedObjects, MakeObject (tok, n));
18950 1605277 : break;
18951 :
18952 45939 : case SymbolTable_ModuleSym:
18953 45939 : AddNameTo (pSym->Module.NamedObjects, MakeObject (tok, n));
18954 45939 : break;
18955 :
18956 6453566 : case SymbolTable_DefImpSym:
18957 6453566 : AddNameTo (pSym->DefImp.NamedObjects, MakeObject (tok, n));
18958 6453566 : break;
18959 :
18960 :
18961 0 : default:
18962 0 : M2Error_InternalError ((const char *) "expecting - DefImp", 18);
18963 8104782 : break;
18964 : }
18965 8104782 : }
18966 :
18967 :
18968 : /*
18969 : AddNameToImportList - adds a Name, n, to the import list of the current
18970 : module.
18971 : */
18972 :
18973 188 : extern "C" void SymbolTable_AddNameToImportList (unsigned int tok, NameKey_Name n)
18974 : {
18975 188 : SymbolTable_PtrToSymbol pSym;
18976 188 : unsigned int scope;
18977 :
18978 188 : scope = SymbolTable_GetCurrentScope ();
18979 188 : pSym = GetPsym (scope);
18980 188 : switch (pSym->SymbolType)
18981 : {
18982 188 : case SymbolTable_ModuleSym:
18983 188 : AddNameTo (pSym->Module.NamedImports, MakeObject (tok, n));
18984 188 : break;
18985 :
18986 0 : case SymbolTable_DefImpSym:
18987 0 : AddNameTo (pSym->DefImp.NamedImports, MakeObject (tok, n));
18988 0 : break;
18989 :
18990 :
18991 0 : default:
18992 0 : M2Error_InternalError ((const char *) "expecting - DefImp or Module symbol", 35);
18993 188 : break;
18994 : }
18995 188 : }
18996 :
18997 :
18998 : /*
18999 : GetScope - returns the declaration scope of the symbol.
19000 : */
19001 :
19002 80160495 : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym)
19003 : {
19004 80160495 : SymbolTable_PtrToSymbol pSym;
19005 :
19006 80160495 : pSym = GetPsym (Sym);
19007 80160495 : switch (pSym->SymbolType)
19008 : {
19009 0 : case SymbolTable_ErrorSym:
19010 0 : return pSym->Error.Scope;
19011 : break;
19012 :
19013 : case SymbolTable_DefImpSym:
19014 : return SymbolTable_NulSym;
19015 3383411 : break;
19016 :
19017 3383411 : case SymbolTable_ModuleSym:
19018 3383411 : return pSym->Module.Scope;
19019 3245789 : break;
19020 :
19021 3245789 : case SymbolTable_VarSym:
19022 3245789 : return pSym->Var.Scope;
19023 48502642 : break;
19024 :
19025 48502642 : case SymbolTable_ProcedureSym:
19026 48502642 : return pSym->Procedure.Scope;
19027 239760 : break;
19028 :
19029 239760 : case SymbolTable_ProcTypeSym:
19030 239760 : return pSym->ProcType.Scope;
19031 1163950 : break;
19032 :
19033 1163950 : case SymbolTable_RecordFieldSym:
19034 1163950 : return pSym->RecordField.Scope;
19035 8646 : break;
19036 :
19037 8646 : case SymbolTable_VarientSym:
19038 8646 : return pSym->Varient.Scope;
19039 23652 : break;
19040 :
19041 23652 : case SymbolTable_VarientFieldSym:
19042 23652 : return pSym->VarientField.Scope;
19043 137632 : break;
19044 :
19045 137632 : case SymbolTable_EnumerationSym:
19046 137632 : return pSym->Enumeration.Scope;
19047 1874248 : break;
19048 :
19049 1874248 : case SymbolTable_EnumerationFieldSym:
19050 1874248 : return pSym->EnumerationField.Scope;
19051 347047 : break;
19052 :
19053 347047 : case SymbolTable_SubrangeSym:
19054 347047 : return pSym->Subrange.Scope;
19055 1401 : break;
19056 :
19057 1401 : case SymbolTable_ArraySym:
19058 1401 : return pSym->Array.Scope;
19059 191202 : break;
19060 :
19061 191202 : case SymbolTable_TypeSym:
19062 191202 : return pSym->Type.Scope;
19063 103443 : break;
19064 :
19065 103443 : case SymbolTable_PointerSym:
19066 103443 : return pSym->Pointer.Scope;
19067 722859 : break;
19068 :
19069 722859 : case SymbolTable_RecordSym:
19070 722859 : return pSym->Record.Scope;
19071 16544 : break;
19072 :
19073 16544 : case SymbolTable_SetSym:
19074 16544 : return pSym->Set.Scope;
19075 24 : break;
19076 :
19077 24 : case SymbolTable_UnboundedSym:
19078 24 : return pSym->Unbounded.Scope;
19079 12 : break;
19080 :
19081 12 : case SymbolTable_ConstLitSym:
19082 12 : return pSym->ConstLit.Scope;
19083 48 : break;
19084 :
19085 48 : case SymbolTable_ConstStringSym:
19086 48 : return pSym->ConstString.Scope;
19087 260 : break;
19088 :
19089 260 : case SymbolTable_ConstVarSym:
19090 260 : return pSym->ConstVar.Scope;
19091 150 : break;
19092 :
19093 150 : case SymbolTable_ParamSym:
19094 150 : return pSym->Param.Scope;
19095 12 : break;
19096 :
19097 12 : case SymbolTable_VarParamSym:
19098 12 : return pSym->VarParam.Scope;
19099 : break;
19100 :
19101 : case SymbolTable_UndefinedSym:
19102 : return SymbolTable_NulSym;
19103 0 : break;
19104 :
19105 0 : case SymbolTable_PartialUnboundedSym:
19106 0 : M2Error_InternalError ((const char *) "should not be requesting the scope of a PartialUnbounded symbol", 63);
19107 0 : break;
19108 :
19109 :
19110 0 : default:
19111 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
19112 : break;
19113 : }
19114 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19115 : __builtin_unreachable ();
19116 : }
19117 :
19118 :
19119 : /*
19120 : GetModuleScope - returns the module scope of symbol, sym.
19121 : If sym was declared within a nested procedure
19122 : then return the module which defines the
19123 : procedure.
19124 : */
19125 :
19126 469458 : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym)
19127 : {
19128 469458 : unsigned int mod;
19129 :
19130 469458 : mod = SymbolTable_GetScope (sym);
19131 939972 : while (((mod != SymbolTable_NulSym) && (! (SymbolTable_IsDefImp (mod)))) && (! (SymbolTable_IsModule (mod))))
19132 : {
19133 1056 : mod = SymbolTable_GetScope (mod);
19134 : }
19135 469458 : return mod;
19136 : /* static analysis guarentees a RETURN statement will be used before here. */
19137 : __builtin_unreachable ();
19138 : }
19139 :
19140 :
19141 : /*
19142 : GetProcedureScope - returns the innermost procedure (if any)
19143 : in which the symbol, sym, resides.
19144 : A module inside the procedure is skipped
19145 : over.
19146 : */
19147 :
19148 377319 : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym)
19149 : {
19150 759414 : while ((sym != SymbolTable_NulSym) && (! (SymbolTable_IsProcedure (sym))))
19151 : {
19152 382095 : sym = SymbolTable_GetScope (sym);
19153 : }
19154 377319 : if ((sym != SymbolTable_NulSym) && (SymbolTable_IsProcedure (sym)))
19155 : {
19156 2334 : return sym;
19157 : }
19158 : else
19159 : {
19160 : return SymbolTable_NulSym;
19161 : }
19162 : /* static analysis guarentees a RETURN statement will be used before here. */
19163 : __builtin_unreachable ();
19164 : }
19165 :
19166 :
19167 : /*
19168 : IsModuleWithinProcedure - returns TRUE if module, sym, is
19169 : inside a procedure.
19170 : */
19171 :
19172 269637 : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym)
19173 : {
19174 269637 : return (SymbolTable_GetProcedureScope (sym)) != SymbolTable_NulSym;
19175 : /* static analysis guarentees a RETURN statement will be used before here. */
19176 : __builtin_unreachable ();
19177 : }
19178 :
19179 :
19180 : /*
19181 : GetParent - returns the parent of symbol, Sym.
19182 : */
19183 :
19184 2548022 : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym)
19185 : {
19186 2548022 : SymbolTable_PtrToSymbol pSym;
19187 :
19188 2548022 : pSym = GetPsym (Sym);
19189 2548022 : switch (pSym->SymbolType)
19190 : {
19191 6 : case SymbolTable_ErrorSym:
19192 6 : M2Error_ErrorAbort0 ((const char *) "", 0);
19193 628402 : break;
19194 :
19195 628402 : case SymbolTable_VarientSym:
19196 628402 : return pSym->Varient.Parent;
19197 1888590 : break;
19198 :
19199 1888590 : case SymbolTable_VarientFieldSym:
19200 1888590 : return pSym->VarientField.Parent;
19201 31024 : break;
19202 :
19203 31024 : case SymbolTable_RecordFieldSym:
19204 31024 : return pSym->RecordField.Parent;
19205 0 : break;
19206 :
19207 0 : case SymbolTable_EnumerationFieldSym:
19208 0 : return pSym->EnumerationField.Type;
19209 0 : break;
19210 :
19211 :
19212 0 : default:
19213 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
19214 : break;
19215 : }
19216 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19217 : __builtin_unreachable ();
19218 : }
19219 :
19220 :
19221 : /*
19222 : IsRecordField - returns true if Sym is a record field.
19223 : */
19224 :
19225 681362047 : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym)
19226 : {
19227 681362047 : SymbolTable_PtrToSymbol pSym;
19228 :
19229 681362047 : pSym = GetPsym (Sym);
19230 681362047 : return pSym->SymbolType == SymbolTable_RecordFieldSym;
19231 : /* static analysis guarentees a RETURN statement will be used before here. */
19232 : __builtin_unreachable ();
19233 : }
19234 :
19235 :
19236 : /*
19237 : MakeProcType - returns a procedure type symbol with ProcTypeName.
19238 : */
19239 :
19240 5256518 : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName)
19241 : {
19242 5256518 : SymbolTable_PtrToSymbol pSym;
19243 5256518 : unsigned int oaf;
19244 5256518 : unsigned int sym;
19245 :
19246 5256518 : tok = CheckTok (tok, (const char *) "proctype", 8);
19247 5256518 : sym = HandleHiddenOrDeclare (tok, ProcTypeName, &oaf);
19248 5256518 : if (! (SymbolTable_IsError (sym)))
19249 : {
19250 5256518 : pSym = GetPsym (sym);
19251 5256518 : pSym->SymbolType = SymbolTable_ProcTypeSym;
19252 5256518 : switch (pSym->SymbolType)
19253 : {
19254 5256518 : case SymbolTable_ProcTypeSym:
19255 5256518 : pSym->ProcType.ReturnType = SymbolTable_NulSym;
19256 5256518 : pSym->ProcType.name = ProcTypeName;
19257 5256518 : Lists_InitList (&pSym->ProcType.ListOfParam);
19258 5256518 : pSym->ProcType.HasVarArgs = false; /* Does this proc type use ... ? */
19259 5256518 : pSym->ProcType.HasOptArg = false; /* Does this proc type use [ ] ? */
19260 5256518 : pSym->ProcType.OptArgInit = SymbolTable_NulSym; /* The optarg initial value. */
19261 5256518 : pSym->ProcType.ReturnOptional = false; /* Is the return value optional? */
19262 5256518 : pSym->ProcType.ReturnTypeTok = M2LexBuf_UnknownTokenNo; /* Is the return value optional? */
19263 5256518 : pSym->ProcType.Scope = SymbolTable_GetCurrentScope ();
19264 : /* scope of procedure. */
19265 5256518 : pSym->ProcType.Size = M2ALU_InitValue ();
19266 5256518 : pSym->ProcType.TotalParamSize = M2ALU_InitValue (); /* size of all parameters */
19267 5256518 : pSym->ProcType.oafamily = oaf; /* The oa family for this symbol */
19268 5256518 : InitWhereDeclaredTok (tok, &pSym->ProcType.At); /* Declared here */
19269 5256518 : break;
19270 :
19271 :
19272 : default:
19273 : M2Error_InternalError ((const char *) "expecting ProcType symbol", 25);
19274 5256518 : break;
19275 : }
19276 : }
19277 5256518 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
19278 5256518 : return sym;
19279 : /* static analysis guarentees a RETURN statement will be used before here. */
19280 : __builtin_unreachable ();
19281 : }
19282 :
19283 :
19284 : /*
19285 : PutProcTypeParam - Places a Non VAR parameter ParamName with type
19286 : ParamType into ProcType Sym.
19287 : */
19288 :
19289 8381996 : extern "C" void SymbolTable_PutProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded)
19290 : {
19291 8381996 : SymbolTable_PtrToSymbol pSym;
19292 8381996 : unsigned int ParSym;
19293 :
19294 8381996 : NewSym (&ParSym);
19295 8381996 : pSym = GetPsym (ParSym);
19296 8381996 : pSym->SymbolType = SymbolTable_ParamSym;
19297 8381996 : pSym->Param.name = NameKey_NulName;
19298 8381996 : pSym->Param.Type = ParamType;
19299 8381996 : pSym->Param.IsUnbounded = isUnbounded;
19300 8381996 : pSym->Param.ShadowVar = SymbolTable_NulSym;
19301 8381996 : pSym->Param.FullTok = tok;
19302 8381996 : pSym->Param.At = tok;
19303 8381996 : AddParameter (Sym, SymbolTable_ProperProcedure, ParSym);
19304 8381996 : }
19305 :
19306 :
19307 : /*
19308 : PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
19309 : ParamType into ProcType Sym.
19310 : */
19311 :
19312 774423 : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded)
19313 : {
19314 774423 : SymbolTable_PtrToSymbol pSym;
19315 774423 : unsigned int ParSym;
19316 :
19317 774423 : NewSym (&ParSym);
19318 774423 : pSym = GetPsym (ParSym);
19319 774423 : pSym->SymbolType = SymbolTable_VarParamSym;
19320 774423 : pSym->Param.name = NameKey_NulName;
19321 774423 : pSym->Param.Type = ParamType;
19322 774423 : pSym->Param.IsUnbounded = isUnbounded;
19323 774423 : pSym->Param.ShadowVar = SymbolTable_NulSym;
19324 774423 : pSym->Param.FullTok = tok;
19325 774423 : pSym->Param.At = tok;
19326 774423 : AddParameter (Sym, SymbolTable_ProperProcedure, ParSym);
19327 774423 : }
19328 :
19329 :
19330 : /*
19331 : IsProcType - returns true if Sym is a ProcType Symbol.
19332 : */
19333 :
19334 283084252 : extern "C" bool SymbolTable_IsProcType (unsigned int Sym)
19335 : {
19336 283084252 : SymbolTable_PtrToSymbol pSym;
19337 :
19338 283084252 : pSym = GetPsym (Sym);
19339 283084252 : return pSym->SymbolType == SymbolTable_ProcTypeSym;
19340 : /* static analysis guarentees a RETURN statement will be used before here. */
19341 : __builtin_unreachable ();
19342 : }
19343 :
19344 :
19345 : /*
19346 : IsVar - returns true if Sym is a Var Symbol.
19347 : */
19348 :
19349 155040286 : extern "C" bool SymbolTable_IsVar (unsigned int Sym)
19350 : {
19351 155040286 : SymbolTable_PtrToSymbol pSym;
19352 :
19353 155040286 : pSym = GetPsym (Sym);
19354 155040286 : return pSym->SymbolType == SymbolTable_VarSym;
19355 : /* static analysis guarentees a RETURN statement will be used before here. */
19356 : __builtin_unreachable ();
19357 : }
19358 :
19359 :
19360 : /*
19361 : IsVarConst - returns the IsConst field indicating the variable is read only.
19362 : */
19363 :
19364 320022 : extern "C" bool SymbolTable_IsVarConst (unsigned int sym)
19365 : {
19366 320022 : SymbolTable_PtrToSymbol pSym;
19367 :
19368 320022 : pSym = GetPsym (sym);
19369 320022 : switch (pSym->SymbolType)
19370 : {
19371 320022 : case SymbolTable_VarSym:
19372 320022 : return pSym->Var.IsConst;
19373 0 : break;
19374 :
19375 :
19376 0 : default:
19377 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
19378 : break;
19379 : }
19380 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19381 : __builtin_unreachable ();
19382 : }
19383 :
19384 :
19385 : /*
19386 : IsConst - returns true if Sym contains a constant value.
19387 : */
19388 :
19389 239581490 : extern "C" bool SymbolTable_IsConst (unsigned int Sym)
19390 : {
19391 239581490 : if (SymbolTable_IsConstructor (Sym))
19392 : {
19393 3588853 : return SymbolTable_IsConstructorConstant (Sym);
19394 : }
19395 : else
19396 : {
19397 235992637 : return DoIsConst (Sym);
19398 : }
19399 : /* static analysis guarentees a RETURN statement will be used before here. */
19400 : __builtin_unreachable ();
19401 : }
19402 :
19403 :
19404 : /*
19405 : IsConstString - returns whether sym is a conststring of any variant.
19406 : */
19407 :
19408 7576747 : extern "C" bool SymbolTable_IsConstString (unsigned int sym)
19409 : {
19410 7576747 : SymbolTable_PtrToSymbol pSym;
19411 :
19412 7576747 : pSym = GetPsym (sym);
19413 7576747 : return pSym->SymbolType == SymbolTable_ConstStringSym;
19414 : /* static analysis guarentees a RETURN statement will be used before here. */
19415 : __builtin_unreachable ();
19416 : }
19417 :
19418 :
19419 : /*
19420 : IsConstStringNulTerminated - returns TRUE if the constant string, sym,
19421 : should be created with a nul terminator.
19422 : */
19423 :
19424 0 : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym)
19425 : {
19426 0 : SymbolTable_PtrToSymbol pSym;
19427 :
19428 0 : pSym = GetPsym (sym);
19429 0 : switch (pSym->SymbolType)
19430 : {
19431 0 : case SymbolTable_ConstStringSym:
19432 0 : return (pSym->ConstString.StringVariant == SymbolTable_m2nulstr) || (pSym->ConstString.StringVariant == SymbolTable_cnulstr);
19433 0 : break;
19434 :
19435 :
19436 0 : default:
19437 0 : M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
19438 : break;
19439 : }
19440 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19441 : __builtin_unreachable ();
19442 : }
19443 :
19444 :
19445 : /*
19446 : IsConstLit - returns true if Sym is a literal constant.
19447 : */
19448 :
19449 9063137 : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym)
19450 : {
19451 9063137 : SymbolTable_PtrToSymbol pSym;
19452 :
19453 9063137 : pSym = GetPsym (Sym);
19454 9063137 : return pSym->SymbolType == SymbolTable_ConstLitSym;
19455 : /* static analysis guarentees a RETURN statement will be used before here. */
19456 : __builtin_unreachable ();
19457 : }
19458 :
19459 :
19460 : /*
19461 : IsConstructor - returns TRUE if the constant is declared as a
19462 : constant set, array or record.
19463 : */
19464 :
19465 389825242 : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym)
19466 : {
19467 389825242 : SymbolTable_PtrToSymbol pSym;
19468 :
19469 389825242 : pSym = GetPsym (Sym);
19470 389825242 : switch (pSym->SymbolType)
19471 : {
19472 63467261 : case SymbolTable_ConstVarSym:
19473 63467261 : return pSym->ConstVar.IsConstructor;
19474 67908691 : break;
19475 :
19476 67908691 : case SymbolTable_ConstLitSym:
19477 67908691 : return pSym->ConstLit.IsConstructor;
19478 : break;
19479 :
19480 :
19481 : default:
19482 : return false;
19483 : break;
19484 : }
19485 : /* static analysis guarentees a RETURN statement will be used before here. */
19486 : __builtin_unreachable ();
19487 : }
19488 :
19489 :
19490 : /*
19491 : IsDummy - returns true if Sym is a Dummy symbol.
19492 : */
19493 :
19494 0 : extern "C" bool SymbolTable_IsDummy (unsigned int Sym)
19495 : {
19496 0 : SymbolTable_PtrToSymbol pSym;
19497 :
19498 0 : pSym = GetPsym (Sym);
19499 0 : return pSym->SymbolType == SymbolTable_DummySym;
19500 : /* static analysis guarentees a RETURN statement will be used before here. */
19501 : __builtin_unreachable ();
19502 : }
19503 :
19504 :
19505 : /*
19506 : IsTemporary - returns true if Sym is a Temporary symbol.
19507 : */
19508 :
19509 2031565 : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym)
19510 : {
19511 2031565 : SymbolTable_PtrToSymbol pSym;
19512 :
19513 2031565 : pSym = GetPsym (Sym);
19514 2031565 : switch (pSym->SymbolType)
19515 : {
19516 1946683 : case SymbolTable_VarSym:
19517 1946683 : return pSym->Var.IsTemp;
19518 3580 : break;
19519 :
19520 3580 : case SymbolTable_ConstVarSym:
19521 3580 : return pSym->ConstVar.IsTemp;
19522 : break;
19523 :
19524 :
19525 : default:
19526 : return false;
19527 : break;
19528 : }
19529 : /* static analysis guarentees a RETURN statement will be used before here. */
19530 : __builtin_unreachable ();
19531 : }
19532 :
19533 :
19534 : /*
19535 : IsVarAParam - returns true if Sym is a variable declared as a parameter.
19536 : */
19537 :
19538 34315 : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym)
19539 : {
19540 34315 : SymbolTable_PtrToSymbol pSym;
19541 :
19542 34315 : pSym = GetPsym (Sym);
19543 34315 : switch (pSym->SymbolType)
19544 : {
19545 34315 : case SymbolTable_VarSym:
19546 34315 : return pSym->Var.IsParam;
19547 : break;
19548 :
19549 :
19550 : default:
19551 : return false;
19552 : break;
19553 : }
19554 : /* static analysis guarentees a RETURN statement will be used before here. */
19555 : __builtin_unreachable ();
19556 : }
19557 :
19558 :
19559 : /*
19560 : IsSubscript - returns true if Sym is a subscript symbol.
19561 : */
19562 :
19563 5897184 : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym)
19564 : {
19565 5897184 : SymbolTable_PtrToSymbol pSym;
19566 :
19567 5897184 : pSym = GetPsym (Sym);
19568 5897184 : return pSym->SymbolType == SymbolTable_SubscriptSym;
19569 : /* static analysis guarentees a RETURN statement will be used before here. */
19570 : __builtin_unreachable ();
19571 : }
19572 :
19573 :
19574 : /*
19575 : IsSubrange - returns true if Sym is a subrange symbol.
19576 : */
19577 :
19578 447106762 : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym)
19579 : {
19580 447106762 : SymbolTable_PtrToSymbol pSym;
19581 :
19582 447106762 : pSym = GetPsym (Sym);
19583 447106762 : return pSym->SymbolType == SymbolTable_SubrangeSym;
19584 : /* static analysis guarentees a RETURN statement will be used before here. */
19585 : __builtin_unreachable ();
19586 : }
19587 :
19588 :
19589 : /*
19590 : IsProcedureVariable - returns true if a Sym is a variable and
19591 : it was declared within a procedure.
19592 : */
19593 :
19594 0 : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym)
19595 : {
19596 0 : AssertInRange (Sym);
19597 0 : return (SymbolTable_IsVar (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetVarScope (Sym)));
19598 : /* static analysis guarentees a RETURN statement will be used before here. */
19599 : __builtin_unreachable ();
19600 : }
19601 :
19602 :
19603 : /*
19604 : IsProcedureNested - returns TRUE if procedure, Sym, was
19605 : declared as a nested procedure.
19606 : */
19607 :
19608 4677356 : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym)
19609 : {
19610 4677356 : return (SymbolTable_IsProcedure (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetScope (Sym)));
19611 : /* static analysis guarentees a RETURN statement will be used before here. */
19612 : __builtin_unreachable ();
19613 : }
19614 :
19615 :
19616 : /*
19617 : IsAModula2Type - returns true if Sym, is a:
19618 : IsType, IsPointer, IsRecord, IsEnumeration,
19619 : IsSubrange, IsArray, IsUnbounded, IsProcType.
19620 : NOTE that it different from IsType.
19621 : */
19622 :
19623 48524453 : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym)
19624 : {
19625 48524453 : AssertInRange (Sym);
19626 48524453 : return ((((((((SymbolTable_IsType (Sym)) || (SymbolTable_IsRecord (Sym))) || (SymbolTable_IsPointer (Sym))) || (SymbolTable_IsEnumeration (Sym))) || (SymbolTable_IsSubrange (Sym))) || (SymbolTable_IsArray (Sym))) || (SymbolTable_IsUnbounded (Sym))) || (SymbolTable_IsProcType (Sym))) || (SymbolTable_IsSet (Sym));
19627 : /* static analysis guarentees a RETURN statement will be used before here. */
19628 : __builtin_unreachable ();
19629 : }
19630 :
19631 :
19632 : /*
19633 : IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
19634 : */
19635 :
19636 27 : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym)
19637 : {
19638 27 : SymbolTable_PtrToSymbol pSym;
19639 :
19640 27 : pSym = GetPsym (Sym);
19641 27 : switch (pSym->SymbolType)
19642 : {
19643 27 : case SymbolTable_GnuAsmSym:
19644 27 : return pSym->GnuAsm.Volatile;
19645 0 : break;
19646 :
19647 :
19648 0 : default:
19649 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
19650 : break;
19651 : }
19652 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19653 : __builtin_unreachable ();
19654 : }
19655 :
19656 :
19657 : /*
19658 : IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
19659 : */
19660 :
19661 27 : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym)
19662 : {
19663 27 : SymbolTable_PtrToSymbol pSym;
19664 :
19665 27 : pSym = GetPsym (Sym);
19666 27 : switch (pSym->SymbolType)
19667 : {
19668 27 : case SymbolTable_GnuAsmSym:
19669 27 : return pSym->GnuAsm.Simple;
19670 0 : break;
19671 :
19672 :
19673 0 : default:
19674 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
19675 : break;
19676 : }
19677 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19678 : __builtin_unreachable ();
19679 : }
19680 :
19681 :
19682 : /*
19683 : IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
19684 : */
19685 :
19686 108 : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym)
19687 : {
19688 108 : SymbolTable_PtrToSymbol pSym;
19689 :
19690 108 : pSym = GetPsym (Sym);
19691 108 : return pSym->SymbolType == SymbolTable_GnuAsmSym;
19692 : /* static analysis guarentees a RETURN statement will be used before here. */
19693 : __builtin_unreachable ();
19694 : }
19695 :
19696 :
19697 : /*
19698 : IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
19699 : */
19700 :
19701 0 : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym)
19702 : {
19703 0 : SymbolTable_PtrToSymbol pSym;
19704 :
19705 0 : pSym = GetPsym (Sym);
19706 0 : return pSym->SymbolType == SymbolTable_InterfaceSym;
19707 : /* static analysis guarentees a RETURN statement will be used before here. */
19708 : __builtin_unreachable ();
19709 : }
19710 :
19711 :
19712 : /*
19713 : IsSizeSolved - returns true if the size of Sym is solved.
19714 : */
19715 :
19716 24507 : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym)
19717 : {
19718 24507 : SymbolTable_PtrToSymbol pSym;
19719 :
19720 24507 : AssertInRange (Sym);
19721 24507 : pSym = GetPsym (Sym);
19722 24507 : switch (pSym->SymbolType)
19723 : {
19724 0 : case SymbolTable_ProcedureSym:
19725 0 : return M2ALU_IsSolved (pSym->Procedure.Size);
19726 4040 : break;
19727 :
19728 4040 : case SymbolTable_VarSym:
19729 4040 : return M2ALU_IsSolved (pSym->Var.Size);
19730 16105 : break;
19731 :
19732 16105 : case SymbolTable_TypeSym:
19733 16105 : return M2ALU_IsSolved (pSym->Type.Size);
19734 788 : break;
19735 :
19736 788 : case SymbolTable_SetSym:
19737 788 : return M2ALU_IsSolved (pSym->Set.Size);
19738 12 : break;
19739 :
19740 12 : case SymbolTable_RecordSym:
19741 12 : return M2ALU_IsSolved (pSym->Record.Size);
19742 0 : break;
19743 :
19744 0 : case SymbolTable_VarientSym:
19745 0 : return M2ALU_IsSolved (pSym->Varient.Size);
19746 12 : break;
19747 :
19748 12 : case SymbolTable_EnumerationSym:
19749 12 : return M2ALU_IsSolved (pSym->Enumeration.Size);
19750 52 : break;
19751 :
19752 52 : case SymbolTable_PointerSym:
19753 52 : return M2ALU_IsSolved (pSym->Pointer.Size);
19754 3486 : break;
19755 :
19756 3486 : case SymbolTable_ArraySym:
19757 3486 : return M2ALU_IsSolved (pSym->Array.Size);
19758 0 : break;
19759 :
19760 0 : case SymbolTable_RecordFieldSym:
19761 0 : return M2ALU_IsSolved (pSym->RecordField.Size);
19762 0 : break;
19763 :
19764 0 : case SymbolTable_VarientFieldSym:
19765 0 : return M2ALU_IsSolved (pSym->VarientField.Size);
19766 0 : break;
19767 :
19768 0 : case SymbolTable_SubrangeSym:
19769 0 : return M2ALU_IsSolved (pSym->Subrange.Size);
19770 0 : break;
19771 :
19772 0 : case SymbolTable_SubscriptSym:
19773 0 : return M2ALU_IsSolved (pSym->Subscript.Size);
19774 12 : break;
19775 :
19776 12 : case SymbolTable_ProcTypeSym:
19777 12 : return M2ALU_IsSolved (pSym->ProcType.Size);
19778 0 : break;
19779 :
19780 0 : case SymbolTable_UnboundedSym:
19781 0 : return M2ALU_IsSolved (pSym->Unbounded.Size);
19782 0 : break;
19783 :
19784 :
19785 0 : default:
19786 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19787 : break;
19788 : }
19789 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19790 : __builtin_unreachable ();
19791 : }
19792 :
19793 :
19794 : /*
19795 : IsOffsetSolved - returns true if the Offset of Sym is solved.
19796 : */
19797 :
19798 0 : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym)
19799 : {
19800 0 : SymbolTable_PtrToSymbol pSym;
19801 :
19802 0 : AssertInRange (Sym);
19803 0 : pSym = GetPsym (Sym);
19804 0 : switch (pSym->SymbolType)
19805 : {
19806 0 : case SymbolTable_VarSym:
19807 0 : return M2ALU_IsSolved (pSym->Var.Offset);
19808 0 : break;
19809 :
19810 0 : case SymbolTable_RecordFieldSym:
19811 0 : return M2ALU_IsSolved (pSym->RecordField.Offset);
19812 0 : break;
19813 :
19814 0 : case SymbolTable_VarientFieldSym:
19815 0 : return M2ALU_IsSolved (pSym->VarientField.Offset);
19816 0 : break;
19817 :
19818 :
19819 0 : default:
19820 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19821 : break;
19822 : }
19823 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19824 : __builtin_unreachable ();
19825 : }
19826 :
19827 :
19828 : /*
19829 : IsValueSolved - returns true if the value of Sym is solved.
19830 : */
19831 :
19832 3742105 : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym)
19833 : {
19834 3742105 : SymbolTable_PtrToSymbol pSym;
19835 :
19836 3742105 : AssertInRange (Sym);
19837 3742105 : pSym = GetPsym (Sym);
19838 3742105 : switch (pSym->SymbolType)
19839 : {
19840 2106211 : case SymbolTable_ConstLitSym:
19841 2106211 : return M2ALU_IsSolved (pSym->ConstLit.Value);
19842 800785 : break;
19843 :
19844 800785 : case SymbolTable_ConstVarSym:
19845 800785 : return M2ALU_IsSolved (pSym->ConstVar.Value);
19846 557929 : break;
19847 :
19848 557929 : case SymbolTable_EnumerationFieldSym:
19849 557929 : return M2ALU_IsSolved (pSym->EnumerationField.Value);
19850 : break;
19851 :
19852 : case SymbolTable_ConstStringSym:
19853 : return true;
19854 6 : break;
19855 :
19856 :
19857 6 : default:
19858 6 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19859 : break;
19860 : }
19861 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19862 : __builtin_unreachable ();
19863 : }
19864 :
19865 :
19866 : /*
19867 : IsConstructorConstant - returns TRUE if constructor, Sym, is
19868 : defined by only constants.
19869 : */
19870 :
19871 4196395 : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym)
19872 : {
19873 4196395 : SymbolTable_PtrToSymbol pSym;
19874 :
19875 4196395 : if ((SymbolTable_IsConstructor (Sym)) || (SymbolTable_IsConstSet (Sym)))
19876 : {
19877 4196395 : pSym = GetPsym (Sym);
19878 4196395 : switch (pSym->SymbolType)
19879 : {
19880 4196395 : case SymbolTable_ConstVarSym:
19881 4196395 : return M2ALU_IsValueConst (pSym->ConstVar.Value);
19882 0 : break;
19883 :
19884 0 : case SymbolTable_ConstLitSym:
19885 0 : return M2ALU_IsValueConst (pSym->ConstLit.Value);
19886 0 : break;
19887 :
19888 :
19889 0 : default:
19890 0 : M2Error_InternalError ((const char *) "expecting Constructor", 21);
19891 0 : break;
19892 : }
19893 : }
19894 : else
19895 : {
19896 0 : M2Error_InternalError ((const char *) "expecting Constructor", 21);
19897 : }
19898 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19899 : __builtin_unreachable ();
19900 : }
19901 :
19902 :
19903 : /*
19904 : IsComposite - returns TRUE if symbol, sym, is a composite
19905 : type: ie an ARRAY or RECORD.
19906 : */
19907 :
19908 148610 : extern "C" bool SymbolTable_IsComposite (unsigned int sym)
19909 : {
19910 148610 : if (sym == SymbolTable_NulSym)
19911 : {
19912 : return false;
19913 : }
19914 : else
19915 : {
19916 148586 : sym = SymbolTable_SkipType (sym);
19917 148586 : return (SymbolTable_IsArray (sym)) || (SymbolTable_IsRecord (sym));
19918 : }
19919 : /* static analysis guarentees a RETURN statement will be used before here. */
19920 : __builtin_unreachable ();
19921 : }
19922 :
19923 :
19924 : /*
19925 : IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
19926 : */
19927 :
19928 0 : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym)
19929 : {
19930 0 : SymbolTable_PtrToSymbol pSym;
19931 :
19932 0 : AssertInRange (Sym);
19933 0 : pSym = GetPsym (Sym);
19934 0 : switch (pSym->SymbolType)
19935 : {
19936 0 : case SymbolTable_ProcedureSym:
19937 0 : return M2ALU_IsSolved (pSym->Procedure.TotalParamSize);
19938 0 : break;
19939 :
19940 0 : case SymbolTable_ProcTypeSym:
19941 0 : return M2ALU_IsSolved (pSym->ProcType.TotalParamSize);
19942 0 : break;
19943 :
19944 :
19945 0 : default:
19946 0 : M2Error_InternalError ((const char *) "expecting Procedure or ProcType symbol", 38);
19947 : break;
19948 : }
19949 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19950 : __builtin_unreachable ();
19951 : }
19952 :
19953 :
19954 : /*
19955 : PutAlignment - assigns the alignment constant associated with,
19956 : type, with, align.
19957 : */
19958 :
19959 192 : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align)
19960 : {
19961 192 : SymbolTable_PtrToSymbol pSym;
19962 :
19963 192 : pSym = GetPsym (type);
19964 192 : switch (pSym->SymbolType)
19965 : {
19966 0 : case SymbolTable_RecordSym:
19967 0 : pSym->Record.Align = align;
19968 0 : break;
19969 :
19970 120 : case SymbolTable_RecordFieldSym:
19971 120 : pSym->RecordField.Align = align;
19972 120 : break;
19973 :
19974 18 : case SymbolTable_TypeSym:
19975 18 : pSym->Type.Align = align;
19976 18 : break;
19977 :
19978 12 : case SymbolTable_PointerSym:
19979 12 : pSym->Pointer.Align = align;
19980 12 : break;
19981 :
19982 12 : case SymbolTable_SubrangeSym:
19983 12 : pSym->Subrange.Align = align;
19984 12 : break;
19985 :
19986 0 : case SymbolTable_SetSym:
19987 0 : pSym->Set.Align = align;
19988 0 : break;
19989 :
19990 30 : case SymbolTable_ArraySym:
19991 30 : pSym->Array.Align = align;
19992 30 : break;
19993 :
19994 :
19995 0 : default:
19996 0 : M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
19997 192 : break;
19998 : }
19999 192 : }
20000 :
20001 :
20002 : /*
20003 : GetAlignment - returns the alignment constant associated with,
20004 : type.
20005 : */
20006 :
20007 405068017 : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type)
20008 : {
20009 405074311 : SymbolTable_PtrToSymbol pSym;
20010 :
20011 405074311 : pSym = GetPsym (type);
20012 405074311 : switch (pSym->SymbolType)
20013 : {
20014 108281 : case SymbolTable_RecordSym:
20015 108281 : return pSym->Record.Align;
20016 239257566 : break;
20017 :
20018 239257566 : case SymbolTable_RecordFieldSym:
20019 239257566 : return pSym->RecordField.Align;
20020 103617183 : break;
20021 :
20022 103617183 : case SymbolTable_TypeSym:
20023 103617183 : return pSym->Type.Align;
20024 50478926 : break;
20025 :
20026 50478926 : case SymbolTable_PointerSym:
20027 50478926 : return pSym->Pointer.Align;
20028 6258 : break;
20029 :
20030 6258 : case SymbolTable_VarientFieldSym:
20031 6258 : return SymbolTable_GetAlignment (pSym->VarientField.Parent);
20032 36 : break;
20033 :
20034 36 : case SymbolTable_VarientSym:
20035 36 : return SymbolTable_GetAlignment (pSym->Varient.Parent);
20036 6122017 : break;
20037 :
20038 6122017 : case SymbolTable_SubrangeSym:
20039 6122017 : return pSym->Subrange.Align;
20040 0 : break;
20041 :
20042 0 : case SymbolTable_SetSym:
20043 0 : return pSym->Set.Align;
20044 5484044 : break;
20045 :
20046 5484044 : case SymbolTable_ArraySym:
20047 5484044 : return pSym->Array.Align;
20048 0 : break;
20049 :
20050 :
20051 0 : default:
20052 0 : M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
20053 : break;
20054 : }
20055 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20056 : __builtin_unreachable ();
20057 : }
20058 :
20059 :
20060 : /*
20061 : GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
20062 : to record, sym.
20063 : */
20064 :
20065 45786524 : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym)
20066 : {
20067 45792710 : SymbolTable_PtrToSymbol pSym;
20068 :
20069 45792710 : pSym = GetPsym (sym);
20070 45792710 : switch (pSym->SymbolType)
20071 : {
20072 45786524 : case SymbolTable_RecordSym:
20073 45786524 : return pSym->Record.DefaultAlign;
20074 6186 : break;
20075 :
20076 6186 : case SymbolTable_VarientFieldSym:
20077 6186 : return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
20078 0 : break;
20079 :
20080 0 : case SymbolTable_VarientSym:
20081 0 : return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
20082 0 : break;
20083 :
20084 :
20085 0 : default:
20086 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
20087 : break;
20088 : }
20089 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20090 : __builtin_unreachable ();
20091 : }
20092 :
20093 :
20094 : /*
20095 : PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
20096 : to record, sym.
20097 : */
20098 :
20099 36 : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align)
20100 : {
20101 36 : SymbolTable_PtrToSymbol pSym;
20102 :
20103 36 : pSym = GetPsym (sym);
20104 36 : switch (pSym->SymbolType)
20105 : {
20106 36 : case SymbolTable_RecordSym:
20107 36 : pSym->Record.DefaultAlign = align;
20108 36 : break;
20109 :
20110 :
20111 0 : default:
20112 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
20113 36 : break;
20114 : }
20115 36 : }
20116 :
20117 :
20118 : /*
20119 : PutUnused - sets, sym, as unused. This is a gm2 pragma.
20120 : */
20121 :
20122 0 : extern "C" void SymbolTable_PutUnused (unsigned int sym)
20123 : {
20124 0 : SymbolTable_PtrToSymbol pSym;
20125 :
20126 0 : pSym = GetPsym (sym);
20127 0 : switch (pSym->SymbolType)
20128 : {
20129 0 : case SymbolTable_RecordFieldSym:
20130 0 : pSym->RecordField.Used = false;
20131 0 : break;
20132 :
20133 :
20134 0 : default:
20135 0 : M2MetaError_MetaError1 ((const char *) "cannot use pragma 'unused' on symbol {%1ad}", 43, sym);
20136 0 : break;
20137 : }
20138 0 : }
20139 :
20140 :
20141 : /*
20142 : IsUnused - returns TRUE if the symbol was declared as unused with a
20143 : gm2 pragma.
20144 : */
20145 :
20146 145895 : extern "C" bool SymbolTable_IsUnused (unsigned int sym)
20147 : {
20148 145895 : SymbolTable_PtrToSymbol pSym;
20149 :
20150 145895 : pSym = GetPsym (sym);
20151 145895 : switch (pSym->SymbolType)
20152 : {
20153 145895 : case SymbolTable_RecordFieldSym:
20154 145895 : return ! pSym->RecordField.Used;
20155 0 : break;
20156 :
20157 :
20158 0 : default:
20159 0 : M2Error_InternalError ((const char *) "expecting a record field symbol", 31);
20160 : break;
20161 : }
20162 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20163 : __builtin_unreachable ();
20164 : }
20165 :
20166 :
20167 : /*
20168 : PutDeclaredPacked - sets the Packed field of the record or record field symbol.
20169 : */
20170 :
20171 526137 : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b)
20172 : {
20173 526137 : SymbolTable_PtrToSymbol pSym;
20174 :
20175 526137 : pSym = GetPsym (sym);
20176 526137 : switch (pSym->SymbolType)
20177 : {
20178 102023 : case SymbolTable_RecordSym:
20179 102023 : pSym->Record.DeclPacked = b;
20180 102023 : pSym->Record.DeclResolved = true;
20181 102023 : break;
20182 :
20183 411898 : case SymbolTable_RecordFieldSym:
20184 411898 : pSym->RecordField.DeclPacked = b;
20185 411898 : pSym->RecordField.DeclResolved = true;
20186 411898 : break;
20187 :
20188 6156 : case SymbolTable_VarientFieldSym:
20189 6156 : pSym->VarientField.DeclPacked = b;
20190 6156 : pSym->VarientField.DeclResolved = true;
20191 6156 : break;
20192 :
20193 6060 : case SymbolTable_VarientSym:
20194 6060 : pSym->Varient.DeclPacked = b;
20195 6060 : pSym->Varient.DeclResolved = true;
20196 6060 : break;
20197 :
20198 :
20199 0 : default:
20200 0 : M2Error_InternalError ((const char *) "expecting a record or field record symbol", 41);
20201 526137 : break;
20202 : }
20203 526137 : }
20204 :
20205 :
20206 : /*
20207 : IsDeclaredPacked - was the record symbol or record field, sym,
20208 : declared as packed?
20209 : */
20210 :
20211 1458514 : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym)
20212 : {
20213 1458514 : SymbolTable_PtrToSymbol pSym;
20214 :
20215 1458514 : pSym = GetPsym (sym);
20216 1458514 : switch (pSym->SymbolType)
20217 : {
20218 204046 : case SymbolTable_RecordSym:
20219 204046 : return pSym->Record.DeclPacked;
20220 1235916 : break;
20221 :
20222 1235916 : case SymbolTable_RecordFieldSym:
20223 1235916 : return pSym->RecordField.DeclPacked;
20224 12444 : break;
20225 :
20226 12444 : case SymbolTable_VarientFieldSym:
20227 12444 : return pSym->VarientField.DeclPacked;
20228 6108 : break;
20229 :
20230 6108 : case SymbolTable_VarientSym:
20231 6108 : return pSym->Varient.DeclPacked;
20232 0 : break;
20233 :
20234 :
20235 0 : default:
20236 0 : M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
20237 : break;
20238 : }
20239 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20240 : __builtin_unreachable ();
20241 : }
20242 :
20243 :
20244 : /*
20245 : IsDeclaredPackedResolved - do we know if the record symbol or record
20246 : field, sym, declared as packed or not packed?
20247 : */
20248 :
20249 0 : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym)
20250 : {
20251 0 : SymbolTable_PtrToSymbol pSym;
20252 :
20253 0 : pSym = GetPsym (sym);
20254 0 : switch (pSym->SymbolType)
20255 : {
20256 0 : case SymbolTable_RecordSym:
20257 0 : return pSym->Record.DeclResolved;
20258 0 : break;
20259 :
20260 0 : case SymbolTable_RecordFieldSym:
20261 0 : return pSym->RecordField.DeclResolved;
20262 0 : break;
20263 :
20264 0 : case SymbolTable_VarientFieldSym:
20265 0 : return pSym->VarientField.DeclResolved;
20266 0 : break;
20267 :
20268 0 : case SymbolTable_VarientSym:
20269 0 : return pSym->Varient.DeclResolved;
20270 0 : break;
20271 :
20272 :
20273 0 : default:
20274 0 : M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
20275 : break;
20276 : }
20277 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20278 : __builtin_unreachable ();
20279 : }
20280 :
20281 :
20282 : /*
20283 : GetPackedEquivalent - returns the packed equivalent of type, sym.
20284 : sym must be a type, subrange or enumerated type.
20285 : */
20286 :
20287 14761 : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym)
20288 : {
20289 14761 : SymbolTable_PtrToSymbol pSym;
20290 :
20291 14761 : pSym = GetPsym (sym);
20292 14761 : switch (pSym->SymbolType)
20293 : {
20294 14641 : case SymbolTable_EnumerationSym:
20295 14641 : return GetEquivalent (&pSym->Enumeration.packedInfo, sym);
20296 120 : break;
20297 :
20298 120 : case SymbolTable_SubrangeSym:
20299 120 : return GetEquivalent (&pSym->Subrange.packedInfo, sym);
20300 0 : break;
20301 :
20302 0 : case SymbolTable_TypeSym:
20303 0 : return GetEquivalent (&pSym->Type.packedInfo, sym);
20304 0 : break;
20305 :
20306 0 : case SymbolTable_SetSym:
20307 0 : return GetEquivalent (&pSym->Set.packedInfo, sym);
20308 0 : break;
20309 :
20310 :
20311 0 : default:
20312 0 : M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
20313 : break;
20314 : }
20315 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20316 : __builtin_unreachable ();
20317 : }
20318 :
20319 :
20320 : /*
20321 : GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
20322 : */
20323 :
20324 0 : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym)
20325 : {
20326 0 : SymbolTable_PtrToSymbol pSym;
20327 :
20328 0 : pSym = GetPsym (sym);
20329 0 : switch (pSym->SymbolType)
20330 : {
20331 0 : case SymbolTable_EquivSym:
20332 0 : return pSym->Equiv.nonPacked;
20333 0 : break;
20334 :
20335 :
20336 0 : default:
20337 0 : M2Error_InternalError ((const char *) "expecting equivalent symbol", 27);
20338 : break;
20339 : }
20340 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20341 : __builtin_unreachable ();
20342 : }
20343 :
20344 :
20345 : /*
20346 : IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
20347 : */
20348 :
20349 0 : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym)
20350 : {
20351 0 : SymbolTable_PtrToSymbol pSym;
20352 :
20353 0 : pSym = GetPsym (sym);
20354 0 : switch (pSym->SymbolType)
20355 : {
20356 : case SymbolTable_EquivSym:
20357 : return true;
20358 0 : break;
20359 :
20360 :
20361 0 : default:
20362 0 : return false;
20363 : break;
20364 : }
20365 : /* static analysis guarentees a RETURN statement will be used before here. */
20366 : __builtin_unreachable ();
20367 : }
20368 :
20369 :
20370 : /*
20371 : PushSize - pushes the size of Sym.
20372 : */
20373 :
20374 100878 : extern "C" void SymbolTable_PushSize (unsigned int Sym)
20375 : {
20376 100878 : SymbolTable_PtrToSymbol pSym;
20377 :
20378 100878 : AssertInRange (Sym);
20379 100878 : pSym = GetPsym (Sym);
20380 100878 : switch (pSym->SymbolType)
20381 : {
20382 0 : case SymbolTable_ProcedureSym:
20383 0 : M2ALU_PushFrom (pSym->Procedure.Size);
20384 0 : break;
20385 :
20386 4040 : case SymbolTable_VarSym:
20387 4040 : M2ALU_PushFrom (pSym->Var.Size);
20388 4040 : break;
20389 :
20390 16105 : case SymbolTable_TypeSym:
20391 16105 : M2ALU_PushFrom (pSym->Type.Size);
20392 16105 : break;
20393 :
20394 788 : case SymbolTable_SetSym:
20395 788 : M2ALU_PushFrom (pSym->Set.Size);
20396 788 : break;
20397 :
20398 0 : case SymbolTable_VarientSym:
20399 0 : M2ALU_PushFrom (pSym->Varient.Size);
20400 0 : break;
20401 :
20402 12 : case SymbolTable_RecordSym:
20403 12 : M2ALU_PushFrom (pSym->Record.Size);
20404 12 : break;
20405 :
20406 12 : case SymbolTable_EnumerationSym:
20407 12 : M2ALU_PushFrom (pSym->Enumeration.Size);
20408 12 : break;
20409 :
20410 76423 : case SymbolTable_PointerSym:
20411 76423 : M2ALU_PushFrom (pSym->Pointer.Size);
20412 76423 : break;
20413 :
20414 3486 : case SymbolTable_ArraySym:
20415 3486 : M2ALU_PushFrom (pSym->Array.Size);
20416 3486 : break;
20417 :
20418 0 : case SymbolTable_RecordFieldSym:
20419 0 : M2ALU_PushFrom (pSym->RecordField.Size);
20420 0 : break;
20421 :
20422 0 : case SymbolTable_VarientFieldSym:
20423 0 : M2ALU_PushFrom (pSym->VarientField.Size);
20424 0 : break;
20425 :
20426 0 : case SymbolTable_SubrangeSym:
20427 0 : M2ALU_PushFrom (pSym->Subrange.Size);
20428 0 : break;
20429 :
20430 0 : case SymbolTable_SubscriptSym:
20431 0 : M2ALU_PushFrom (pSym->Subscript.Size);
20432 0 : break;
20433 :
20434 12 : case SymbolTable_ProcTypeSym:
20435 12 : M2ALU_PushFrom (pSym->ProcType.Size);
20436 12 : break;
20437 :
20438 0 : case SymbolTable_UnboundedSym:
20439 0 : M2ALU_PushFrom (pSym->Unbounded.Size);
20440 0 : break;
20441 :
20442 :
20443 0 : default:
20444 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20445 100878 : break;
20446 : }
20447 100878 : }
20448 :
20449 :
20450 : /*
20451 : PopSize - pops the ALU stack into Size of Sym.
20452 : */
20453 :
20454 864499 : extern "C" void SymbolTable_PopSize (unsigned int Sym)
20455 : {
20456 864499 : SymbolTable_PtrToSymbol pSym;
20457 :
20458 864499 : AssertInRange (Sym);
20459 864499 : pSym = GetPsym (Sym);
20460 864499 : switch (pSym->SymbolType)
20461 : {
20462 0 : case SymbolTable_ProcedureSym:
20463 0 : M2ALU_PopInto (pSym->Procedure.Size);
20464 0 : break;
20465 :
20466 3370 : case SymbolTable_VarSym:
20467 3370 : M2ALU_PopInto (pSym->Var.Size);
20468 3370 : break;
20469 :
20470 602603 : case SymbolTable_TypeSym:
20471 602603 : M2ALU_PopInto (pSym->Type.Size);
20472 602603 : break;
20473 :
20474 12 : case SymbolTable_RecordSym:
20475 12 : M2ALU_PopInto (pSym->Record.Size);
20476 12 : break;
20477 :
20478 0 : case SymbolTable_VarientSym:
20479 0 : M2ALU_PopInto (pSym->Varient.Size);
20480 0 : break;
20481 :
20482 6 : case SymbolTable_EnumerationSym:
20483 6 : M2ALU_PopInto (pSym->Enumeration.Size);
20484 6 : break;
20485 :
20486 15479 : case SymbolTable_PointerSym:
20487 15479 : M2ALU_PopInto (pSym->Pointer.Size);
20488 15479 : break;
20489 :
20490 636 : case SymbolTable_ArraySym:
20491 636 : M2ALU_PopInto (pSym->Array.Size);
20492 636 : break;
20493 :
20494 0 : case SymbolTable_RecordFieldSym:
20495 0 : M2ALU_PopInto (pSym->RecordField.Size);
20496 0 : break;
20497 :
20498 0 : case SymbolTable_VarientFieldSym:
20499 0 : M2ALU_PopInto (pSym->VarientField.Size);
20500 0 : break;
20501 :
20502 0 : case SymbolTable_SubrangeSym:
20503 0 : M2ALU_PopInto (pSym->Subrange.Size);
20504 0 : break;
20505 :
20506 165086 : case SymbolTable_SubscriptSym:
20507 165086 : M2ALU_PopInto (pSym->Subscript.Size);
20508 165086 : break;
20509 :
20510 15463 : case SymbolTable_ProcTypeSym:
20511 15463 : M2ALU_PopInto (pSym->ProcType.Size);
20512 15463 : break;
20513 :
20514 0 : case SymbolTable_UnboundedSym:
20515 0 : M2ALU_PopInto (pSym->Unbounded.Size);
20516 0 : break;
20517 :
20518 61844 : case SymbolTable_SetSym:
20519 61844 : M2ALU_PopInto (pSym->Set.Size);
20520 61844 : break;
20521 :
20522 :
20523 0 : default:
20524 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20525 864499 : break;
20526 : }
20527 864499 : }
20528 :
20529 :
20530 : /*
20531 : PushValue - pushes the Value of Sym onto the ALU stack.
20532 : */
20533 :
20534 25848487 : extern "C" void SymbolTable_PushValue (unsigned int Sym)
20535 : {
20536 25848487 : SymbolTable_PtrToSymbol pSym;
20537 :
20538 25848487 : AssertInRange (Sym);
20539 25848487 : pSym = GetPsym (Sym);
20540 25848487 : switch (pSym->SymbolType)
20541 : {
20542 2502239 : case SymbolTable_ConstLitSym:
20543 2502239 : M2ALU_PushFrom (pSym->ConstLit.Value);
20544 2502239 : break;
20545 :
20546 1868519 : case SymbolTable_ConstVarSym:
20547 1868519 : M2ALU_PushFrom (pSym->ConstVar.Value);
20548 1868519 : break;
20549 :
20550 21444791 : case SymbolTable_EnumerationFieldSym:
20551 21444791 : M2ALU_PushFrom (pSym->EnumerationField.Value);
20552 21444791 : break;
20553 :
20554 32938 : case SymbolTable_ConstStringSym:
20555 32938 : PushConstString (Sym);
20556 32938 : break;
20557 :
20558 :
20559 0 : default:
20560 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20561 25848487 : break;
20562 : }
20563 25848487 : }
20564 :
20565 :
20566 : /*
20567 : PushVarSize - pushes the size of a variable, Sym.
20568 : The runtime size of Sym will depend upon its addressing mode,
20569 : RightValue has size PushSize(GetType(Sym)) and
20570 : LeftValue has size PushSize(Address) since it points to a
20571 : variable.
20572 : */
20573 :
20574 0 : extern "C" void SymbolTable_PushVarSize (unsigned int Sym)
20575 : {
20576 0 : AssertInRange (Sym);
20577 0 : M2Debug_Assert (SymbolTable_IsVar (Sym));
20578 0 : if ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue)
20579 : {
20580 0 : SymbolTable_PushSize (M2System_Address);
20581 : }
20582 : else
20583 : {
20584 0 : M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_RightValue);
20585 0 : SymbolTable_PushSize (SymbolTable_GetType (Sym));
20586 : }
20587 0 : }
20588 :
20589 :
20590 : /*
20591 : PopValue - pops the ALU stack into Value of Sym.
20592 : */
20593 :
20594 1383495 : extern "C" void SymbolTable_PopValue (unsigned int Sym)
20595 : {
20596 1383495 : SymbolTable_PtrToSymbol pSym;
20597 :
20598 1383495 : AssertInRange (Sym);
20599 1383495 : pSym = GetPsym (Sym);
20600 1383495 : switch (pSym->SymbolType)
20601 : {
20602 0 : case SymbolTable_ConstLitSym:
20603 0 : M2ALU_PopInto (pSym->ConstLit.Value);
20604 0 : break;
20605 :
20606 1383495 : case SymbolTable_ConstVarSym:
20607 1383495 : M2ALU_PopInto (pSym->ConstVar.Value);
20608 1383495 : break;
20609 :
20610 0 : case SymbolTable_EnumerationFieldSym:
20611 0 : M2Error_InternalError ((const char *) "cannot pop into an enumeration field", 36);
20612 0 : break;
20613 :
20614 :
20615 0 : default:
20616 0 : M2Error_InternalError ((const char *) "symbol type not expected", 24);
20617 1383495 : break;
20618 : }
20619 1383495 : }
20620 :
20621 :
20622 : /*
20623 : IsObject - returns TRUE if the symbol is an object symbol.
20624 : */
20625 :
20626 0 : extern "C" bool SymbolTable_IsObject (unsigned int Sym)
20627 : {
20628 0 : SymbolTable_PtrToSymbol pSym;
20629 :
20630 0 : AssertInRange (Sym);
20631 0 : pSym = GetPsym (Sym);
20632 0 : return pSym->SymbolType == SymbolTable_ObjectSym;
20633 : /* static analysis guarentees a RETURN statement will be used before here. */
20634 : __builtin_unreachable ();
20635 : }
20636 :
20637 :
20638 : /*
20639 : IsTuple - returns TRUE if the symbol is a tuple symbol.
20640 : */
20641 :
20642 17726 : extern "C" bool SymbolTable_IsTuple (unsigned int Sym)
20643 : {
20644 17726 : SymbolTable_PtrToSymbol pSym;
20645 :
20646 17726 : AssertInRange (Sym);
20647 17726 : pSym = GetPsym (Sym);
20648 17726 : return pSym->SymbolType == SymbolTable_TupleSym;
20649 : /* static analysis guarentees a RETURN statement will be used before here. */
20650 : __builtin_unreachable ();
20651 : }
20652 :
20653 :
20654 : /*
20655 : Make2Tuple - creates and returns a 2 tuple from, a, and, b.
20656 : */
20657 :
20658 3158 : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b)
20659 : {
20660 3158 : SymbolTable_PtrToSymbol pSym;
20661 3158 : unsigned int Sym;
20662 :
20663 3158 : NewSym (&Sym);
20664 3158 : pSym = GetPsym (Sym);
20665 3158 : pSym->SymbolType = SymbolTable_TupleSym;
20666 3158 : pSym->Tuple.nTuple = 2;
20667 3158 : pSym->Tuple.list = Indexing_InitIndex (1);
20668 3158 : PutIntoIndex (&pSym->Tuple.list, 1, a);
20669 3158 : PutIntoIndex (&pSym->Tuple.list, 2, b);
20670 3158 : InitWhereDeclared (&pSym->Tuple.At);
20671 3158 : InitWhereFirstUsed (&pSym->Tuple.At);
20672 3158 : return Sym;
20673 : /* static analysis guarentees a RETURN statement will be used before here. */
20674 : __builtin_unreachable ();
20675 : }
20676 :
20677 :
20678 : /*
20679 : MakeError - creates an error node, which can be used in MetaError messages.
20680 : It will be removed from ExportUndeclared and Unknown trees.
20681 : */
20682 :
20683 207 : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name)
20684 : {
20685 207 : SymbolTable_PtrToSymbol pSym;
20686 207 : unsigned int Sym;
20687 :
20688 : /* if Sym is present on the unknown tree then remove it */
20689 207 : Sym = FetchUnknownSym (name);
20690 207 : if (Sym == SymbolTable_NulSym)
20691 : {
20692 201 : NewSym (&Sym);
20693 : }
20694 : else
20695 : {
20696 : /*
20697 : remove symbol from this tree as we have already generated
20698 : a meaningful error message
20699 : */
20700 6 : RemoveExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
20701 : }
20702 207 : pSym = GetPsym (Sym);
20703 207 : pSym->SymbolType = SymbolTable_ErrorSym;
20704 207 : pSym->Error.name = name;
20705 207 : pSym->Error.Scope = SymbolTable_GetCurrentScope ();
20706 207 : InitWhereDeclaredTok (tok, &pSym->Error.At);
20707 207 : InitWhereFirstUsedTok (tok, &pSym->Error.At);
20708 207 : return Sym;
20709 : /* static analysis guarentees a RETURN statement will be used before here. */
20710 : __builtin_unreachable ();
20711 : }
20712 :
20713 :
20714 : /*
20715 : MakeErrorS - creates an error node from a string, which can be used
20716 : in MetaError messages.
20717 : It will be removed from ExportUndeclared and Unknown trees.
20718 : */
20719 :
20720 0 : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name)
20721 : {
20722 0 : return SymbolTable_MakeError (tok, NameKey_makekey (DynamicStrings_string (name)));
20723 : /* static analysis guarentees a RETURN statement will be used before here. */
20724 : __builtin_unreachable ();
20725 : }
20726 :
20727 :
20728 : /*
20729 : IsError - returns TRUE if the symbol is an error symbol.
20730 : */
20731 :
20732 32389580 : extern "C" bool SymbolTable_IsError (unsigned int Sym)
20733 : {
20734 32389580 : SymbolTable_PtrToSymbol pSym;
20735 :
20736 32389580 : AssertInRange (Sym);
20737 32389580 : pSym = GetPsym (Sym);
20738 32389580 : return pSym->SymbolType == SymbolTable_ErrorSym;
20739 : /* static analysis guarentees a RETURN statement will be used before here. */
20740 : __builtin_unreachable ();
20741 : }
20742 :
20743 :
20744 : /*
20745 : IsLegal - returns TRUE if, sym, is a legal symbol.
20746 : */
20747 :
20748 1060613 : extern "C" bool SymbolTable_IsLegal (unsigned int sym)
20749 : {
20750 1060613 : return sym < FreeSymbol;
20751 : /* static analysis guarentees a RETURN statement will be used before here. */
20752 : __builtin_unreachable ();
20753 : }
20754 :
20755 :
20756 : /*
20757 : PutModuleContainsBuiltin - sets a flag in the current compiled module which
20758 : indicates that a builtin procedure is being declared.
20759 : This is only expected to be called when we are
20760 : parsing the definition module.
20761 : */
20762 :
20763 425318 : extern "C" void SymbolTable_PutModuleContainsBuiltin (void)
20764 : {
20765 425318 : SymbolTable_PtrToSymbol pSym;
20766 :
20767 425318 : SymbolTable_PutHiddenTypeDeclared ();
20768 425318 : pSym = GetPsym (CurrentModule);
20769 425318 : switch (pSym->SymbolType)
20770 : {
20771 425318 : case SymbolTable_DefImpSym:
20772 425318 : pSym->DefImp.ContainsBuiltin = true;
20773 425318 : break;
20774 :
20775 :
20776 0 : default:
20777 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20778 425318 : break;
20779 : }
20780 425318 : }
20781 :
20782 :
20783 : /*
20784 : IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
20785 : */
20786 :
20787 161971 : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym)
20788 : {
20789 161971 : SymbolTable_PtrToSymbol pSym;
20790 :
20791 161971 : pSym = GetPsym (Sym);
20792 161971 : switch (pSym->SymbolType)
20793 : {
20794 161971 : case SymbolTable_DefImpSym:
20795 161971 : return pSym->DefImp.ContainsBuiltin;
20796 0 : break;
20797 :
20798 :
20799 0 : default:
20800 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20801 : break;
20802 : }
20803 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20804 : __builtin_unreachable ();
20805 : }
20806 :
20807 :
20808 : /*
20809 : PutHiddenTypeDeclared - sets a flag in the current compiled module which
20810 : indicates that a Hidden Type is declared within
20811 : the implementation part of the module.
20812 : This procedure is expected to be called while
20813 : compiling the associated definition module.
20814 : */
20815 :
20816 1334288 : extern "C" void SymbolTable_PutHiddenTypeDeclared (void)
20817 : {
20818 1334288 : SymbolTable_PtrToSymbol pSym;
20819 :
20820 1334288 : pSym = GetPsym (CurrentModule);
20821 1334288 : switch (pSym->SymbolType)
20822 : {
20823 1334288 : case SymbolTable_DefImpSym:
20824 1334288 : pSym->DefImp.ContainsHiddenType = true;
20825 1334288 : break;
20826 :
20827 :
20828 0 : default:
20829 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20830 1334288 : break;
20831 : }
20832 1334288 : }
20833 :
20834 :
20835 : /*
20836 : IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
20837 : the module, Sym.
20838 : */
20839 :
20840 8503510 : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym)
20841 : {
20842 8503510 : SymbolTable_PtrToSymbol pSym;
20843 :
20844 8503510 : pSym = GetPsym (Sym);
20845 8503510 : switch (pSym->SymbolType)
20846 : {
20847 8503510 : case SymbolTable_DefImpSym:
20848 8503510 : return pSym->DefImp.ContainsHiddenType;
20849 0 : break;
20850 :
20851 :
20852 0 : default:
20853 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20854 : break;
20855 : }
20856 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20857 : __builtin_unreachable ();
20858 : }
20859 :
20860 :
20861 : /*
20862 : IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
20863 : type declared as a pointer or address.
20864 : */
20865 :
20866 440249 : extern "C" bool SymbolTable_IsHiddenReallyPointer (unsigned int Sym)
20867 : {
20868 440249 : if (SymbolTable_IsVar (Sym))
20869 : {
20870 0 : Sym = SymbolTable_GetType (Sym);
20871 : }
20872 461064 : while ((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym)))
20873 : {
20874 20815 : Sym = SymbolTable_SkipType (SymbolTable_GetType (Sym));
20875 : }
20876 440249 : return (Sym != SymbolTable_NulSym) && ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address));
20877 : /* static analysis guarentees a RETURN statement will be used before here. */
20878 : __builtin_unreachable ();
20879 : }
20880 :
20881 :
20882 : /*
20883 : DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
20884 : */
20885 :
20886 0 : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym)
20887 : {
20888 0 : SymbolTable_PtrToSymbol pSym;
20889 0 : NameKey_Name n;
20890 :
20891 0 : n = SymbolTable_GetSymName (ModSym);
20892 0 : M2Printf_printf1 ((const char *) "Symbol trees for module/procedure: %a\\n", 39, (const unsigned char *) &n, (sizeof (n)-1));
20893 0 : pSym = GetPsym (ModSym);
20894 0 : switch (pSym->SymbolType)
20895 : {
20896 0 : case SymbolTable_DefImpSym:
20897 0 : n = SymbolTable_GetSymName (ModSym);
20898 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20899 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20900 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20901 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20902 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20903 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20904 0 : M2Printf_printf1 ((const char *) "%a ExportRequest", 17, (const unsigned char *) &n, (sizeof (n)-1));
20905 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportRequest, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20906 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20907 0 : M2Printf_printf1 ((const char *) "%a ExportQualified", 19, (const unsigned char *) &n, (sizeof (n)-1));
20908 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20909 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20910 0 : M2Printf_printf1 ((const char *) "%a ExportUnQualified", 21, (const unsigned char *) &n, (sizeof (n)-1));
20911 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20912 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20913 0 : M2Printf_printf1 ((const char *) "%a ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
20914 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20915 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20916 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20917 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20918 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20919 0 : M2Printf_printf1 ((const char *) "%a ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20920 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20921 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20922 0 : break;
20923 :
20924 0 : case SymbolTable_ModuleSym:
20925 0 : n = SymbolTable_GetSymName (ModSym);
20926 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20927 0 : SymbolKey_ForeachNodeDo (pSym->Module.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20928 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20929 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20930 0 : SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20931 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20932 0 : M2Printf_printf1 ((const char *) "%a ImportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
20933 0 : SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20934 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20935 0 : M2Printf_printf1 ((const char *) "%a ExportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
20936 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20937 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20938 0 : M2Printf_printf1 ((const char *) "%a ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
20939 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20940 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20941 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20942 0 : SymbolKey_ForeachNodeDo (pSym->Module.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20943 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20944 0 : M2Printf_printf1 ((const char *) "%a ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20945 0 : SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20946 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20947 0 : break;
20948 :
20949 0 : case SymbolTable_ProcedureSym:
20950 0 : n = SymbolTable_GetSymName (ModSym);
20951 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20952 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20953 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20954 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20955 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20956 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20957 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20958 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20959 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20960 0 : break;
20961 :
20962 :
20963 0 : default:
20964 0 : M2Error_InternalError ((const char *) "expecting DefImp symbol", 23);
20965 0 : break;
20966 : }
20967 0 : }
20968 :
20969 :
20970 : /*
20971 : DebugLineNumbers - internal debugging, emit all procedure names in this module
20972 : together with the line numbers for the corresponding begin/end
20973 : tokens.
20974 : */
20975 :
20976 14137 : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym)
20977 : {
20978 14137 : if (M2Options_GetDebugFunctionLineNumbers ())
20979 : {
20980 0 : M2Printf_printf0 ((const char *) "<lines>\\n", 9);
20981 0 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DebugProcedureLineNumber});
20982 0 : M2Printf_printf0 ((const char *) "</lines>\\n", 10);
20983 : }
20984 14137 : }
20985 :
20986 :
20987 : /*
20988 : GetErrorScope - returns the error scope for a symbol.
20989 : The error scope is the title scope which is used to
20990 : announce the symbol in the GCC error message.
20991 : */
20992 :
20993 151219426 : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym)
20994 : {
20995 151219426 : SymbolTable_PtrToSymbol pSym;
20996 :
20997 151219426 : pSym = GetPsym (sym);
20998 151219426 : switch (pSym->SymbolType)
20999 : {
21000 1656807 : case SymbolTable_ProcedureSym:
21001 1656807 : return pSym->Procedure.errorScope;
21002 4468007 : break;
21003 :
21004 4468007 : case SymbolTable_ModuleSym:
21005 4468007 : return pSym->Module.errorScope;
21006 145094612 : break;
21007 :
21008 145094612 : case SymbolTable_DefImpSym:
21009 145094612 : return pSym->DefImp.errorScope;
21010 0 : break;
21011 :
21012 0 : case SymbolTable_UndefinedSym:
21013 0 : return pSym->Undefined.errorScope;
21014 0 : break;
21015 :
21016 :
21017 0 : default:
21018 0 : M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
21019 : break;
21020 : }
21021 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21022 : __builtin_unreachable ();
21023 : }
21024 :
21025 :
21026 : /*
21027 : MakeImport - create and return an import symbol.
21028 : moduleSym is the symbol being imported.
21029 : isqualified is FALSE if it were IMPORT modulename and
21030 : TRUE for the qualified FROM modulename IMPORT etc.
21031 : listno is the import list count for this module.
21032 : tok should match this modulename position.
21033 : */
21034 :
21035 426205 : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified)
21036 : {
21037 426205 : unsigned int importSym;
21038 426205 : SymbolTable_PtrToSymbol pSym;
21039 :
21040 426205 : NewSym (&importSym);
21041 426205 : pSym = GetPsym (importSym);
21042 426205 : pSym->SymbolType = SymbolTable_ImportSym;
21043 426205 : pSym->Import.module = moduleSym;
21044 426205 : pSym->Import.listNo = listno;
21045 426205 : pSym->Import.qualified = isqualified;
21046 426205 : InitWhereDeclaredTok (tok, &pSym->Import.at);
21047 426205 : return importSym;
21048 : /* static analysis guarentees a RETURN statement will be used before here. */
21049 : __builtin_unreachable ();
21050 : }
21051 :
21052 :
21053 : /*
21054 : MakeImportStatement - return a dependent symbol which represents an import statement
21055 : or a qualified import statement. The tok should either match
21056 : the FROM token or the IMPORT token. listno is the import list
21057 : count for the module.
21058 : */
21059 :
21060 410873 : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno)
21061 : {
21062 410873 : unsigned int dependentSym;
21063 410873 : SymbolTable_PtrToSymbol pSym;
21064 :
21065 410873 : NewSym (&dependentSym);
21066 410873 : pSym = GetPsym (dependentSym);
21067 410873 : pSym->SymbolType = SymbolTable_ImportStatementSym;
21068 410873 : pSym->ImportStatement.listNo = listno;
21069 410873 : Lists_InitList (&pSym->ImportStatement.ListOfImports);
21070 410873 : InitWhereDeclaredTok (tok, &pSym->ImportStatement.at);
21071 410873 : return dependentSym;
21072 : /* static analysis guarentees a RETURN statement will be used before here. */
21073 : __builtin_unreachable ();
21074 : }
21075 :
21076 :
21077 : /*
21078 : IsImport - returns TRUE if sym is an import symbol.
21079 : */
21080 :
21081 1180852 : extern "C" bool SymbolTable_IsImport (unsigned int sym)
21082 : {
21083 1180852 : SymbolTable_PtrToSymbol pSym;
21084 :
21085 1180852 : pSym = GetPsym (sym);
21086 1180852 : return pSym->SymbolType == SymbolTable_ImportSym;
21087 : /* static analysis guarentees a RETURN statement will be used before here. */
21088 : __builtin_unreachable ();
21089 : }
21090 :
21091 :
21092 : /*
21093 : IsImportStatement - returns TRUE if sym is a dependent symbol.
21094 : */
21095 :
21096 1559472 : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym)
21097 : {
21098 1559472 : SymbolTable_PtrToSymbol pSym;
21099 :
21100 1559472 : pSym = GetPsym (sym);
21101 1559472 : return pSym->SymbolType == SymbolTable_ImportStatementSym;
21102 : /* static analysis guarentees a RETURN statement will be used before here. */
21103 : __builtin_unreachable ();
21104 : }
21105 :
21106 :
21107 : /*
21108 : GetImportModule - returns the module associated with the import symbol.
21109 : */
21110 :
21111 365811 : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym)
21112 : {
21113 365811 : SymbolTable_PtrToSymbol pSym;
21114 :
21115 365811 : M2Debug_Assert (SymbolTable_IsImport (sym));
21116 365811 : pSym = GetPsym (sym);
21117 365811 : return pSym->Import.module;
21118 : /* static analysis guarentees a RETURN statement will be used before here. */
21119 : __builtin_unreachable ();
21120 : }
21121 :
21122 :
21123 : /*
21124 : GetImportDeclared - returns the token associated with the import symbol.
21125 : */
21126 :
21127 23025 : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym)
21128 : {
21129 23025 : unsigned int tok;
21130 :
21131 23025 : M2Debug_Assert (SymbolTable_IsImport (sym));
21132 23025 : tok = SymbolTable_GetDeclaredDefinition (sym);
21133 23025 : if (tok == M2LexBuf_UnknownTokenNo)
21134 : {
21135 21218 : return SymbolTable_GetDeclaredModule (sym);
21136 : }
21137 : return tok;
21138 : /* static analysis guarentees a RETURN statement will be used before here. */
21139 : __builtin_unreachable ();
21140 : }
21141 :
21142 :
21143 : /*
21144 : GetImportStatementList - returns the list of imports for this dependent.
21145 : Each import symbol corresponds to a module.
21146 : */
21147 :
21148 779736 : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym)
21149 : {
21150 779736 : SymbolTable_PtrToSymbol pSym;
21151 :
21152 779736 : M2Debug_Assert (SymbolTable_IsImportStatement (sym));
21153 779736 : pSym = GetPsym (sym);
21154 779736 : return pSym->ImportStatement.ListOfImports;
21155 : /* static analysis guarentees a RETURN statement will be used before here. */
21156 : __builtin_unreachable ();
21157 : }
21158 :
21159 :
21160 : /*
21161 : GetModuleDefImportStatementList - returns the list of dependents associated with
21162 : the definition module.
21163 : */
21164 :
21165 219977 : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym)
21166 : {
21167 219977 : SymbolTable_PtrToSymbol pSym;
21168 :
21169 439954 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
21170 219977 : if (SymbolTable_IsDefImp (sym))
21171 : {
21172 205572 : pSym = GetPsym (sym);
21173 205572 : return pSym->DefImp.DefListOfDep;
21174 : }
21175 : return static_cast<Lists_List> (NULL);
21176 : /* static analysis guarentees a RETURN statement will be used before here. */
21177 : __builtin_unreachable ();
21178 : }
21179 :
21180 :
21181 : /*
21182 : GetModuleModImportStatementList - returns the list of dependents associated with
21183 : the implementation or program module.
21184 : */
21185 :
21186 416102 : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym)
21187 : {
21188 416102 : SymbolTable_PtrToSymbol pSym;
21189 :
21190 832204 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
21191 416102 : pSym = GetPsym (sym);
21192 416102 : if (SymbolTable_IsDefImp (sym))
21193 : {
21194 386970 : return pSym->DefImp.ModListOfDep;
21195 : }
21196 : else
21197 : {
21198 29132 : return pSym->Module.ModListOfDep;
21199 : }
21200 : /* static analysis guarentees a RETURN statement will be used before here. */
21201 : __builtin_unreachable ();
21202 : }
21203 :
21204 :
21205 : /*
21206 : AppendModuleImportStatement - appends the ImportStatement symbol onto the
21207 : module import list.
21208 :
21209 : For example:
21210 :
21211 : FROM x IMPORT y, z ;
21212 : ^^^^
21213 :
21214 : also:
21215 :
21216 : IMPORT p, q, r;
21217 : ^^^^^^
21218 : will result in a new ImportStatement symbol added
21219 : to the current module import list.
21220 : The statement symbol is expected to be created
21221 : by MakeImportStatement using the token positions
21222 : outlined above.
21223 : */
21224 :
21225 410873 : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement)
21226 : {
21227 410873 : SymbolTable_PtrToSymbol pSym;
21228 :
21229 410873 : if (SymbolTable_IsDefImp (module))
21230 : {
21231 396554 : pSym = GetPsym (module);
21232 396554 : if (M2Comp_CompilingDefinitionModule ())
21233 : {
21234 112632 : Lists_IncludeItemIntoList (pSym->DefImp.DefListOfDep, statement);
21235 : }
21236 : else
21237 : {
21238 283922 : Lists_IncludeItemIntoList (pSym->DefImp.ModListOfDep, statement);
21239 : }
21240 : }
21241 14319 : else if (SymbolTable_IsModule (module))
21242 : {
21243 : /* avoid dangling else. */
21244 14319 : pSym = GetPsym (module);
21245 14319 : Lists_IncludeItemIntoList (pSym->Module.ModListOfDep, statement);
21246 : }
21247 : else
21248 : {
21249 : /* avoid dangling else. */
21250 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
21251 : }
21252 410873 : }
21253 :
21254 :
21255 : /*
21256 : AppendModuleOnImportStatement - appends the import symbol onto the
21257 : dependent list (chain).
21258 :
21259 : For example each:
21260 :
21261 : FROM x IMPORT y, z ;
21262 : ^
21263 : x are added to the dependent list.
21264 :
21265 : also:
21266 :
21267 : IMPORT p, q, r;
21268 : ^ ^ ^
21269 : will result in p, q and r added to
21270 : to the dependent list.
21271 :
21272 : The import symbol is created by MakeImport
21273 : and the token is expected to match the module
21274 : name position outlined above.
21275 : */
21276 :
21277 426205 : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import)
21278 : {
21279 426205 : Lists_List l;
21280 426205 : unsigned int lastImportStatement;
21281 :
21282 426205 : M2Debug_Assert (SymbolTable_IsImport (import));
21283 426205 : if (M2Comp_CompilingDefinitionModule ())
21284 : {
21285 115040 : l = SymbolTable_GetModuleDefImportStatementList (module);
21286 : }
21287 : else
21288 : {
21289 311165 : l = SymbolTable_GetModuleModImportStatementList (module);
21290 : }
21291 426205 : M2Debug_Assert (l != NULL);
21292 426205 : M2Debug_Assert ((Lists_NoOfItemsInList (l)) > 0); /* There should always be one on the list. */
21293 426205 : lastImportStatement = static_cast<unsigned int> (Lists_GetItemFromList (l, Lists_NoOfItemsInList (l))); /* There should always be one on the list. */
21294 426205 : M2Debug_Assert (SymbolTable_IsImportStatement (lastImportStatement));
21295 426205 : l = SymbolTable_GetImportStatementList (lastImportStatement);
21296 426205 : Lists_IncludeItemIntoList (l, import);
21297 426205 : }
21298 :
21299 :
21300 : /*
21301 : PutModLink - assigns link to module sym.
21302 : */
21303 :
21304 64464 : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link)
21305 : {
21306 64464 : SymbolTable_PtrToSymbol pSym;
21307 :
21308 64464 : if (SymbolTable_IsModule (sym))
21309 : {
21310 0 : pSym = GetPsym (sym);
21311 0 : pSym->Module.ModLink = link;
21312 : }
21313 64464 : else if (SymbolTable_IsDefImp (sym))
21314 : {
21315 : /* avoid dangling else. */
21316 64464 : pSym = GetPsym (sym);
21317 64464 : pSym->DefImp.ModLink = link;
21318 : }
21319 : else
21320 : {
21321 : /* avoid dangling else. */
21322 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
21323 : }
21324 64464 : }
21325 :
21326 :
21327 : /*
21328 : IsModLink - returns the ModLink value associated with the module symbol.
21329 : */
21330 :
21331 380678 : extern "C" bool SymbolTable_IsModLink (unsigned int sym)
21332 : {
21333 380678 : SymbolTable_PtrToSymbol pSym;
21334 :
21335 380678 : if (SymbolTable_IsModule (sym))
21336 : {
21337 181628 : pSym = GetPsym (sym);
21338 181628 : return pSym->Module.ModLink;
21339 : }
21340 199050 : else if (SymbolTable_IsDefImp (sym))
21341 : {
21342 : /* avoid dangling else. */
21343 199050 : pSym = GetPsym (sym);
21344 199050 : return pSym->DefImp.ModLink;
21345 : }
21346 : else
21347 : {
21348 : /* avoid dangling else. */
21349 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
21350 : }
21351 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21352 : __builtin_unreachable ();
21353 : }
21354 :
21355 :
21356 : /*
21357 : PutDefLink - assigns link to the definition module sym.
21358 : */
21359 :
21360 0 : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link)
21361 : {
21362 0 : SymbolTable_PtrToSymbol pSym;
21363 :
21364 0 : if (SymbolTable_IsDefImp (sym))
21365 : {
21366 0 : pSym = GetPsym (sym);
21367 0 : pSym->DefImp.DefLink = link;
21368 : }
21369 : else
21370 : {
21371 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
21372 : }
21373 0 : }
21374 :
21375 :
21376 : /*
21377 : IsDefLink - returns the DefLink value associated with the definition module symbol.
21378 : */
21379 :
21380 175485 : extern "C" bool SymbolTable_IsDefLink (unsigned int sym)
21381 : {
21382 175485 : SymbolTable_PtrToSymbol pSym;
21383 :
21384 175485 : if (SymbolTable_IsDefImp (sym))
21385 : {
21386 175485 : pSym = GetPsym (sym);
21387 175485 : return pSym->DefImp.DefLink;
21388 : }
21389 : else
21390 : {
21391 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
21392 : }
21393 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21394 : __builtin_unreachable ();
21395 : }
21396 :
21397 :
21398 : /*
21399 : IsModuleBuiltin - returns TRUE if the module is a builtin module.
21400 : (For example _BaseTypes).
21401 : */
21402 :
21403 89418 : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym)
21404 : {
21405 89418 : SymbolTable_PtrToSymbol pSym;
21406 :
21407 89418 : if (SymbolTable_IsDefImp (sym))
21408 : {
21409 86668 : pSym = GetPsym (sym);
21410 86668 : return pSym->DefImp.Builtin;
21411 : }
21412 2750 : else if (SymbolTable_IsModule (sym))
21413 : {
21414 : /* avoid dangling else. */
21415 2750 : pSym = GetPsym (sym);
21416 2750 : return pSym->Module.Builtin;
21417 : }
21418 : return false;
21419 : /* static analysis guarentees a RETURN statement will be used before here. */
21420 : __builtin_unreachable ();
21421 : }
21422 :
21423 :
21424 : /*
21425 : PutModuleBuiltin - sets the Builtin flag to value.
21426 : Currently the procedure expects sym to be a DefImp
21427 : module only.
21428 : */
21429 :
21430 15451 : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value)
21431 : {
21432 15451 : SymbolTable_PtrToSymbol pSym;
21433 :
21434 15451 : if (SymbolTable_IsDefImp (sym))
21435 : {
21436 0 : pSym = GetPsym (sym);
21437 0 : pSym->DefImp.Builtin = value;
21438 : }
21439 15451 : else if (SymbolTable_IsModule (sym))
21440 : {
21441 : /* avoid dangling else. */
21442 15451 : pSym = GetPsym (sym);
21443 15451 : pSym->Module.Builtin = value;
21444 : }
21445 : else
21446 : {
21447 : /* avoid dangling else. */
21448 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
21449 : }
21450 15451 : }
21451 :
21452 :
21453 : /*
21454 : PutVarArrayRef - assigns ArrayRef field with value.
21455 : */
21456 :
21457 56444 : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value)
21458 : {
21459 56444 : SymbolTable_PtrToSymbol pSym;
21460 :
21461 56444 : pSym = GetPsym (sym);
21462 56444 : switch (pSym->SymbolType)
21463 : {
21464 56444 : case SymbolTable_VarSym:
21465 56444 : pSym->Var.ArrayRef = value;
21466 56444 : break;
21467 :
21468 :
21469 0 : default:
21470 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
21471 56444 : break;
21472 : }
21473 56444 : }
21474 :
21475 :
21476 : /*
21477 : IsVarArrayRef - returns ArrayRef field value.
21478 : */
21479 :
21480 18286 : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym)
21481 : {
21482 18286 : SymbolTable_PtrToSymbol pSym;
21483 :
21484 18286 : pSym = GetPsym (sym);
21485 18286 : switch (pSym->SymbolType)
21486 : {
21487 18286 : case SymbolTable_VarSym:
21488 18286 : return pSym->Var.ArrayRef;
21489 0 : break;
21490 :
21491 :
21492 0 : default:
21493 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
21494 : break;
21495 : }
21496 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21497 : __builtin_unreachable ();
21498 : }
21499 :
21500 :
21501 : /*
21502 : VarCheckReadInit - returns TRUE if sym has been initialized.
21503 : */
21504 :
21505 9874 : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode)
21506 : {
21507 9874 : SymbolTable_PtrToSymbol pSym;
21508 :
21509 9874 : if (SymbolTable_IsVar (sym))
21510 : {
21511 9874 : pSym = GetPsym (sym);
21512 9874 : switch (pSym->SymbolType)
21513 : {
21514 9874 : case SymbolTable_VarSym:
21515 9874 : return M2SymInit_GetInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]));
21516 : break;
21517 :
21518 :
21519 : default:
21520 : break;
21521 : }
21522 : }
21523 : return false;
21524 : /* static analysis guarentees a RETURN statement will be used before here. */
21525 : __builtin_unreachable ();
21526 : }
21527 :
21528 :
21529 : /*
21530 : VarInitState - initializes the init state for variable sym.
21531 : */
21532 :
21533 212032 : extern "C" void SymbolTable_VarInitState (unsigned int sym)
21534 : {
21535 212032 : SymbolTable_PtrToSymbol pSym;
21536 :
21537 212032 : if (SymbolTable_IsVar (sym))
21538 : {
21539 212032 : pSym = GetPsym (sym);
21540 212032 : switch (pSym->SymbolType)
21541 : {
21542 212032 : case SymbolTable_VarSym:
21543 212032 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), sym);
21544 212032 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), sym);
21545 212032 : break;
21546 :
21547 :
21548 : default:
21549 : break;
21550 : }
21551 : }
21552 212032 : }
21553 :
21554 :
21555 : /*
21556 : PutVarInitialized - set sym as initialized.
21557 : */
21558 :
21559 40759 : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode)
21560 : {
21561 40759 : SymbolTable_PtrToSymbol pSym;
21562 :
21563 40759 : if (SymbolTable_IsVar (sym))
21564 : {
21565 40759 : pSym = GetPsym (sym);
21566 40759 : switch (pSym->SymbolType)
21567 : {
21568 40759 : case SymbolTable_VarSym:
21569 40759 : M2SymInit_SetInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]));
21570 40759 : break;
21571 :
21572 :
21573 : default:
21574 : break;
21575 : }
21576 : }
21577 40759 : }
21578 :
21579 :
21580 : /*
21581 : PutVarFieldInitialized - records that field has been initialized with
21582 : variable sym. TRUE is returned if the field
21583 : is detected and changed to initialized.
21584 : */
21585 :
21586 3364 : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
21587 : {
21588 3364 : SymbolTable_PtrToSymbol pSym;
21589 :
21590 3364 : if (SymbolTable_IsVar (sym))
21591 : {
21592 3364 : pSym = GetPsym (sym);
21593 3364 : switch (pSym->SymbolType)
21594 : {
21595 3364 : case SymbolTable_VarSym:
21596 3364 : return M2SymInit_SetFieldInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]), fieldlist);
21597 : break;
21598 :
21599 :
21600 : default:
21601 : break;
21602 : }
21603 : }
21604 : return false;
21605 : /* static analysis guarentees a RETURN statement will be used before here. */
21606 : __builtin_unreachable ();
21607 : }
21608 :
21609 :
21610 : /*
21611 : GetVarFieldInitialized - return TRUE if fieldlist has been initialized
21612 : within variable sym.
21613 : */
21614 :
21615 232 : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
21616 : {
21617 232 : SymbolTable_PtrToSymbol pSym;
21618 :
21619 232 : if (SymbolTable_IsVar (sym))
21620 : {
21621 232 : pSym = GetPsym (sym);
21622 232 : switch (pSym->SymbolType)
21623 : {
21624 232 : case SymbolTable_VarSym:
21625 232 : return M2SymInit_GetFieldInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]), fieldlist);
21626 : break;
21627 :
21628 :
21629 : default:
21630 : break;
21631 : }
21632 : }
21633 : return false;
21634 : /* static analysis guarentees a RETURN statement will be used before here. */
21635 : __builtin_unreachable ();
21636 : }
21637 :
21638 :
21639 : /*
21640 : PrintInitialized - display variable sym initialization state.
21641 : */
21642 :
21643 0 : extern "C" void SymbolTable_PrintInitialized (unsigned int sym)
21644 : {
21645 0 : SymbolTable_PtrToSymbol pSym;
21646 :
21647 0 : if (SymbolTable_IsVar (sym))
21648 : {
21649 0 : pSym = GetPsym (sym);
21650 0 : switch (pSym->SymbolType)
21651 : {
21652 0 : case SymbolTable_VarSym:
21653 0 : M2Printf_printf0 ((const char *) "LeftMode init: ", 15);
21654 0 : M2SymInit_PrintSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]));
21655 0 : M2Printf_printf0 ((const char *) "RightMode init: ", 16);
21656 0 : M2SymInit_PrintSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]));
21657 0 : break;
21658 :
21659 :
21660 : default:
21661 : break;
21662 : }
21663 : }
21664 0 : }
21665 :
21666 :
21667 : /*
21668 : GetParameterHeapVar - return the heap variable associated with the
21669 : parameter or NulSym.
21670 : */
21671 :
21672 47116 : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym)
21673 : {
21674 47116 : SymbolTable_PtrToSymbol pSym;
21675 :
21676 47116 : pSym = GetPsym (ParSym);
21677 47116 : switch (pSym->SymbolType)
21678 : {
21679 : case SymbolTable_ParamSym:
21680 : return SymbolTable_NulSym; /* Only VarParam has the pointer. */
21681 7280 : break;
21682 :
21683 7280 : case SymbolTable_VarParamSym:
21684 7280 : return pSym->VarParam.HeapVar; /* Only VarParam has the pointer. */
21685 0 : break;
21686 :
21687 :
21688 0 : default:
21689 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
21690 : break;
21691 : }
21692 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21693 : __builtin_unreachable ();
21694 : }
21695 :
21696 :
21697 : /*
21698 : PutProcedureParameterHeapVars - creates heap variables for parameter sym.
21699 : */
21700 :
21701 1944789 : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym)
21702 : {
21703 1944789 : M2Debug_Assert (SymbolTable_IsProcedure (sym));
21704 1944789 : SymbolTable_ForeachParamSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PutParameterHeapVar});
21705 1944789 : }
21706 :
21707 :
21708 : /*
21709 : IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
21710 : for the target architecture.
21711 : */
21712 :
21713 1235428 : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure)
21714 : {
21715 1235428 : return (SymbolTable_IsProcedureBuiltin (procedure)) && (CanUseBuiltin (procedure));
21716 : /* static analysis guarentees a RETURN statement will be used before here. */
21717 : __builtin_unreachable ();
21718 : }
21719 :
21720 :
21721 : /*
21722 : PutConstLitInternal - marks the sym as being an internal constant.
21723 : Currently this is used when generating a default
21724 : BY constant expression during a FOR loop.
21725 : A constant marked as internal will always pass
21726 : an expression type check.
21727 : */
21728 :
21729 15739 : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value)
21730 : {
21731 15739 : SymbolTable_PtrToSymbol pSym;
21732 :
21733 15739 : pSym = GetPsym (sym);
21734 15739 : switch (pSym->SymbolType)
21735 : {
21736 15739 : case SymbolTable_ConstLitSym:
21737 15739 : pSym->ConstLit.IsInternal = value;
21738 15739 : break;
21739 :
21740 :
21741 0 : default:
21742 0 : M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
21743 15739 : break;
21744 : }
21745 15739 : }
21746 :
21747 :
21748 : /*
21749 : IsConstLitInternal - returns the value of the IsInternal field within
21750 : a constant expression.
21751 : */
21752 :
21753 843848 : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym)
21754 : {
21755 843848 : SymbolTable_PtrToSymbol pSym;
21756 :
21757 843848 : pSym = GetPsym (sym);
21758 843848 : switch (pSym->SymbolType)
21759 : {
21760 843848 : case SymbolTable_ConstLitSym:
21761 843848 : return pSym->ConstLit.IsInternal;
21762 0 : break;
21763 :
21764 :
21765 0 : default:
21766 0 : M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
21767 : break;
21768 : }
21769 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21770 : __builtin_unreachable ();
21771 : }
21772 :
21773 :
21774 : /*
21775 : GetVarDeclTypeTok - returns the TypeTok field associate with variable sym.
21776 : */
21777 :
21778 0 : extern "C" unsigned int SymbolTable_GetVarDeclTypeTok (unsigned int sym)
21779 : {
21780 0 : SymbolTable_PtrToSymbol pSym;
21781 :
21782 0 : if (SymbolTable_IsParameter (sym))
21783 : {
21784 0 : pSym = GetPsym (sym);
21785 0 : if (SymbolTable_IsParameterVar (sym))
21786 : {
21787 0 : return SymbolTable_GetVarDeclTypeTok (pSym->VarParam.ShadowVar);
21788 : }
21789 : else
21790 : {
21791 0 : return SymbolTable_GetVarDeclTypeTok (pSym->Param.ShadowVar);
21792 : }
21793 : }
21794 0 : else if (SymbolTable_IsVar (sym))
21795 : {
21796 : /* avoid dangling else. */
21797 0 : return doGetVarDeclTypeTok (sym);
21798 : }
21799 : else
21800 : {
21801 : /* avoid dangling else. */
21802 : return M2LexBuf_UnknownTokenNo;
21803 : }
21804 : /* static analysis guarentees a RETURN statement will be used before here. */
21805 : __builtin_unreachable ();
21806 : }
21807 :
21808 :
21809 : /*
21810 : PutVarDeclTypeTok - assigns the TypeTok field to typetok.
21811 : sym can be a variable or parameter.
21812 : */
21813 :
21814 0 : extern "C" void SymbolTable_PutVarDeclTypeTok (unsigned int sym, unsigned int typetok)
21815 : {
21816 0 : SymbolTable_PtrToSymbol pSym;
21817 :
21818 0 : if (SymbolTable_IsParameter (sym))
21819 : {
21820 0 : pSym = GetPsym (sym);
21821 0 : if (SymbolTable_IsParameterVar (sym))
21822 : {
21823 0 : SymbolTable_PutVarDeclTypeTok (pSym->VarParam.ShadowVar, typetok);
21824 : }
21825 : else
21826 : {
21827 0 : SymbolTable_PutVarDeclTypeTok (pSym->Param.ShadowVar, typetok);
21828 : }
21829 : }
21830 0 : else if (SymbolTable_IsVar (sym))
21831 : {
21832 : /* avoid dangling else. */
21833 0 : doPutVarDeclTypeTok (sym, typetok);
21834 : }
21835 0 : }
21836 :
21837 :
21838 : /*
21839 : GetVarDeclTok - returns the TypeTok field associate with variable sym.
21840 : */
21841 :
21842 96 : extern "C" unsigned int SymbolTable_GetVarDeclTok (unsigned int sym)
21843 : {
21844 156 : SymbolTable_PtrToSymbol pSym;
21845 :
21846 156 : if (SymbolTable_IsParameter (sym))
21847 : {
21848 96 : pSym = GetPsym (sym);
21849 96 : if (SymbolTable_IsParameterVar (sym))
21850 : {
21851 6 : if (pSym->VarParam.ShadowVar == SymbolTable_NulSym)
21852 : {
21853 0 : return pSym->VarParam.At;
21854 : }
21855 : else
21856 : {
21857 : return SymbolTable_GetVarDeclTok (pSym->VarParam.ShadowVar);
21858 : }
21859 : }
21860 : else
21861 : {
21862 90 : if (pSym->Param.ShadowVar == SymbolTable_NulSym)
21863 : {
21864 36 : return pSym->Param.At;
21865 : }
21866 : else
21867 : {
21868 : return SymbolTable_GetVarDeclTok (pSym->Param.ShadowVar);
21869 : }
21870 : }
21871 : }
21872 60 : else if (SymbolTable_IsVar (sym))
21873 : {
21874 : /* avoid dangling else. */
21875 60 : return doGetVarDeclTok (sym);
21876 : }
21877 : else
21878 : {
21879 : /* avoid dangling else. */
21880 : return M2LexBuf_UnknownTokenNo;
21881 : }
21882 : /* static analysis guarentees a RETURN statement will be used before here. */
21883 : __builtin_unreachable ();
21884 : }
21885 :
21886 :
21887 : /*
21888 : PutVarDeclTok - assigns the VarTok field to typetok.
21889 : sym can be a variable or parameter.
21890 : */
21891 :
21892 1735869 : extern "C" void SymbolTable_PutVarDeclTok (unsigned int sym, unsigned int vartok)
21893 : {
21894 1735869 : SymbolTable_PtrToSymbol pSym;
21895 :
21896 1735869 : if (SymbolTable_IsParameter (sym))
21897 : {
21898 0 : pSym = GetPsym (sym);
21899 0 : if (SymbolTable_IsParameterVar (sym))
21900 : {
21901 0 : SymbolTable_PutVarDeclTok (pSym->VarParam.ShadowVar, vartok);
21902 : }
21903 : else
21904 : {
21905 0 : SymbolTable_PutVarDeclTok (pSym->Param.ShadowVar, vartok);
21906 : }
21907 : }
21908 1735869 : else if (SymbolTable_IsVar (sym))
21909 : {
21910 : /* avoid dangling else. */
21911 1735869 : doPutVarDeclTok (sym, vartok);
21912 : }
21913 1735869 : }
21914 :
21915 :
21916 : /*
21917 : GetVarDeclFullTok - returns the full virtual token containing var: type.
21918 : */
21919 :
21920 360 : extern "C" unsigned int SymbolTable_GetVarDeclFullTok (unsigned int sym)
21921 : {
21922 360 : SymbolTable_PtrToSymbol pSym;
21923 :
21924 360 : pSym = GetPsym (sym);
21925 360 : if (SymbolTable_IsParameter (sym))
21926 : {
21927 78 : if (SymbolTable_IsParameterVar (sym))
21928 : {
21929 6 : return pSym->VarParam.FullTok;
21930 : }
21931 : else
21932 : {
21933 72 : return pSym->Param.FullTok;
21934 : }
21935 : }
21936 282 : else if (SymbolTable_IsVar (sym))
21937 : {
21938 : /* avoid dangling else. */
21939 282 : return doGetVarDeclFullTok (sym);
21940 : }
21941 : else
21942 : {
21943 : /* avoid dangling else. */
21944 : return M2LexBuf_UnknownTokenNo;
21945 : }
21946 : /* static analysis guarentees a RETURN statement will be used before here. */
21947 : __builtin_unreachable ();
21948 : }
21949 :
21950 :
21951 : /*
21952 : IsProcedureAnyNoReturn - return TRUE if any of the defined kinds
21953 : of procedure sym is declared no return.
21954 : */
21955 :
21956 3755851 : extern "C" bool SymbolTable_IsProcedureAnyNoReturn (unsigned int sym)
21957 : {
21958 3755851 : return IsProcedureAnyDefaultBoolean (sym, false, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_IsProcedureNoReturn});
21959 : /* static analysis guarentees a RETURN statement will be used before here. */
21960 : __builtin_unreachable ();
21961 : }
21962 :
21963 :
21964 : /*
21965 : GetNthParamAny - returns the nth parameter from the order
21966 : proper procedure, forward declaration
21967 : or definition module procedure.
21968 : */
21969 :
21970 21318736 : extern "C" unsigned int SymbolTable_GetNthParamAny (unsigned int sym, unsigned int ParamNo)
21971 : {
21972 21318736 : SymbolTable_ProcedureKind kind;
21973 :
21974 33901562 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
21975 : {
21976 33901562 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
21977 : {
21978 21318736 : return SymbolTable_GetNthParam (sym, kind, ParamNo);
21979 : }
21980 : }
21981 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
21982 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21983 : __builtin_unreachable ();
21984 : }
21985 :
21986 :
21987 : /*
21988 : NoOfParamAny - return the number of parameters for sym.
21989 : */
21990 :
21991 26200681 : extern "C" unsigned int SymbolTable_NoOfParamAny (unsigned int sym)
21992 : {
21993 26200681 : SymbolTable_ProcedureKind kind;
21994 26200681 : SymbolTable_PtrToSymbol pSym;
21995 :
21996 26200681 : AssertInRange (sym);
21997 26200681 : pSym = GetPsym (sym);
21998 26200681 : switch (pSym->SymbolType)
21999 : {
22000 : case SymbolTable_ErrorSym:
22001 : return 0;
22002 : break;
22003 :
22004 : case SymbolTable_ProcedureSym:
22005 43039696 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
22006 : {
22007 40837486 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
22008 : {
22009 17450052 : return SymbolTable_NoOfParam (sym, kind);
22010 : }
22011 : }
22012 : break;
22013 :
22014 6548407 : case SymbolTable_ProcTypeSym:
22015 6548407 : return Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
22016 12 : break;
22017 :
22018 :
22019 12 : default:
22020 12 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
22021 : break;
22022 : }
22023 : return 0;
22024 : /* static analysis guarentees a RETURN statement will be used before here. */
22025 : __builtin_unreachable ();
22026 : }
22027 :
22028 :
22029 : /*
22030 : SetReturnOptional - sets the ReturnOptional field in the Procedure:kind or
22031 : ProcType symboltable entry.
22032 : */
22033 :
22034 3196825 : extern "C" void SymbolTable_SetReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind, bool isopt)
22035 : {
22036 3196825 : SymbolTable_PtrToSymbol pSym;
22037 :
22038 3196825 : pSym = GetPsym (sym);
22039 3196825 : switch (pSym->SymbolType)
22040 : {
22041 3188867 : case SymbolTable_ProcedureSym:
22042 3188867 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional = isopt;
22043 3188867 : break;
22044 :
22045 7958 : case SymbolTable_ProcTypeSym:
22046 7958 : pSym->ProcType.ReturnOptional = isopt;
22047 7958 : break;
22048 :
22049 :
22050 0 : default:
22051 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
22052 3196825 : break;
22053 : }
22054 3196825 : }
22055 :
22056 :
22057 : /*
22058 : UsesOptArgAny - returns TRUE if procedure Sym:kind uses an optional argument.
22059 : */
22060 :
22061 212690 : extern "C" bool SymbolTable_UsesOptArgAny (unsigned int Sym)
22062 : {
22063 212690 : SymbolTable_PtrToSymbol pSym;
22064 :
22065 212690 : pSym = GetPsym (Sym);
22066 212690 : switch (pSym->SymbolType)
22067 : {
22068 : case SymbolTable_ErrorSym:
22069 : return false;
22070 211918 : break;
22071 :
22072 211918 : case SymbolTable_ProcedureSym:
22073 211918 : return IsProcedureAnyDefaultBoolean (Sym, false, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_UsesOptArg});
22074 772 : break;
22075 :
22076 772 : case SymbolTable_ProcTypeSym:
22077 772 : return pSym->ProcType.HasOptArg;
22078 0 : break;
22079 :
22080 :
22081 0 : default:
22082 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
22083 : break;
22084 : }
22085 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
22086 : __builtin_unreachable ();
22087 : }
22088 :
22089 :
22090 : /*
22091 : GetProcedureKindDesc - return a string describing kind.
22092 : */
22093 :
22094 180 : extern "C" DynamicStrings_String SymbolTable_GetProcedureKindDesc (SymbolTable_ProcedureKind kind)
22095 : {
22096 180 : if (kind == SymbolTable_ProperProcedure)
22097 : {
22098 90 : return DynamicStrings_InitString ((const char *) "proper procedure", 16);
22099 : }
22100 90 : else if (kind == SymbolTable_ForwardProcedure)
22101 : {
22102 : /* avoid dangling else. */
22103 24 : return DynamicStrings_InitString ((const char *) "forward procedure", 17);
22104 : }
22105 66 : else if (kind == SymbolTable_DefProcedure)
22106 : {
22107 : /* avoid dangling else. */
22108 66 : return DynamicStrings_InitString ((const char *) "definition procedure", 20);
22109 : }
22110 0 : M2Error_InternalError ((const char *) "unknown kind value", 18);
22111 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
22112 : __builtin_unreachable ();
22113 : }
22114 :
22115 :
22116 : /*
22117 : GetNthParamAnyClosest - returns the nth parameter from the order
22118 : proper procedure, forward declaration
22119 : or definition module procedure.
22120 : It chooses the parameter which is closest
22121 : in source terms to currentmodule.
22122 : The same module will return using the order
22123 : proper procedure, forward procedure, definition module.
22124 : Whereas an imported procedure will choose from
22125 : DefProcedure, ProperProcedure, ForwardProcedure.
22126 : */
22127 :
22128 632812 : extern "C" unsigned int SymbolTable_GetNthParamAnyClosest (unsigned int sym, unsigned int ParamNo, unsigned int currentmodule)
22129 : {
22130 632812 : if (SymbolTable_IsUnknown (sym))
22131 : {
22132 0 : M2Error_InternalError ((const char *) "/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.mod:GetNthParamAnyClosest:not expecting an unknown symbol", 131);
22133 : }
22134 632812 : if ((GetOuterModuleScope (currentmodule)) == (GetOuterModuleScope (sym)))
22135 : {
22136 : /* Same module. */
22137 231697 : return GetNthParamOrdered (sym, ParamNo, SymbolTable_ProperProcedure, SymbolTable_ForwardProcedure, SymbolTable_DefProcedure);
22138 : }
22139 : else
22140 : {
22141 : /* Procedure is imported. */
22142 401115 : return GetNthParamOrdered (sym, ParamNo, SymbolTable_DefProcedure, SymbolTable_ProperProcedure, SymbolTable_ForwardProcedure);
22143 : }
22144 : /* static analysis guarentees a RETURN statement will be used before here. */
22145 : __builtin_unreachable ();
22146 : }
22147 :
22148 :
22149 : /*
22150 : IsConstVar - returns TRUE if sym is a const var. This is a
22151 : constant which might be assigned to TRUE or FALSE
22152 : depending upon the result of the quad stack control flow.
22153 : Typically used in CONST foo = (a AND b) or similar.
22154 : This symbol will only be assigned once with a value, but
22155 : will appear more than once as a designator to an assignment
22156 : in the quad table. However as the quad table is reduced
22157 : only one assignment will remain. If after reducing quads
22158 : two or more assignments remain, then there is an error
22159 : as sym should not have been declared a constant.
22160 : */
22161 :
22162 150 : extern "C" bool SymbolTable_IsConstVar (unsigned int sym)
22163 : {
22164 150 : SymbolTable_PtrToSymbol pSym;
22165 :
22166 150 : pSym = GetPsym (sym);
22167 150 : return pSym->SymbolType == SymbolTable_ConstVarSym;
22168 : /* static analysis guarentees a RETURN statement will be used before here. */
22169 : __builtin_unreachable ();
22170 : }
22171 :
22172 15451 : extern "C" void _M2_SymbolTable_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
22173 : {
22174 15451 : Init ();
22175 15451 : }
22176 :
22177 0 : extern "C" void _M2_SymbolTable_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
22178 : {
22179 0 : }
|