Branch data 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-2024 Free Software Foundation, Inc.
5 : : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 : :
7 : : This file is part of GNU Modula-2.
8 : :
9 : : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : : it under the terms of the GNU General Public License as published by
11 : : the Free Software Foundation; either version 3, or (at your option)
12 : : any later version.
13 : :
14 : : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include <stdbool.h>
26 : : # if !defined (PROC_D)
27 : : # define PROC_D
28 : : typedef void (*PROC_t) (void);
29 : : typedef struct { PROC_t proc; } PROC;
30 : : # endif
31 : :
32 : : # if !defined (TRUE)
33 : : # define TRUE (1==1)
34 : : # endif
35 : :
36 : : # if !defined (FALSE)
37 : : # define FALSE (1==0)
38 : : # endif
39 : :
40 : : # include "GStorage.h"
41 : : # include "Gmcrts.h"
42 : : #if defined(__cplusplus)
43 : : # undef NULL
44 : : # define NULL 0
45 : : #endif
46 : : #define _SymbolTable_H
47 : : #define _SymbolTable_C
48 : :
49 : : # include "GSYSTEM.h"
50 : : # include "GStorage.h"
51 : : # include "GM2Debug.h"
52 : : # include "Glibc.h"
53 : : # include "GIndexing.h"
54 : : # include "GSets.h"
55 : : # include "Gm2linemap.h"
56 : : # include "GM2Options.h"
57 : : # include "GM2LexBuf.h"
58 : : # include "GM2ALU.h"
59 : : # include "GM2Error.h"
60 : : # include "GM2MetaError.h"
61 : : # include "GFormatStrings.h"
62 : : # include "GM2Printf.h"
63 : : # include "GDynamicStrings.h"
64 : : # include "GLists.h"
65 : : # include "GNameKey.h"
66 : : # include "GSymbolKey.h"
67 : : # include "GM2Base.h"
68 : : # include "GM2System.h"
69 : : # include "Gm2expr.h"
70 : : # include "Gm2tree.h"
71 : : # include "GStrLib.h"
72 : : # include "Gm2builtins.h"
73 : : # include "GM2Comp.h"
74 : : # include "GM2Scaffold.h"
75 : : # include "GM2SymInit.h"
76 : : # include "GM2RTS.h"
77 : :
78 : : # define SymbolTable_NulSym 0
79 : : typedef struct SymbolTable_FamilyOperation_p SymbolTable_FamilyOperation;
80 : :
81 : : # define DebugUnknowns false
82 : : # define DebugUnknownToken false
83 : : # define UnboundedAddressName "_m2_contents"
84 : : # define UnboundedHighName "_m2_high_%d"
85 : : # define BreakSym 8496
86 : : typedef struct SymbolTable_LRLists_a SymbolTable_LRLists;
87 : :
88 : : typedef struct SymbolTable_LRInitDesc_a SymbolTable_LRInitDesc;
89 : :
90 : : typedef struct SymbolTable_Where_r SymbolTable_Where;
91 : :
92 : : typedef struct SymbolTable_PackedInfo_r SymbolTable_PackedInfo;
93 : :
94 : : typedef struct SymbolTable_ModuleCtor_r SymbolTable_ModuleCtor;
95 : :
96 : : typedef struct SymbolTable_SymImportStatement_r SymbolTable_SymImportStatement;
97 : :
98 : : typedef struct SymbolTable_SymImport_r SymbolTable_SymImport;
99 : :
100 : : typedef struct SymbolTable_SymEquiv_r SymbolTable_SymEquiv;
101 : :
102 : : typedef struct SymbolTable_SymOAFamily_r SymbolTable_SymOAFamily;
103 : :
104 : : typedef struct SymbolTable_SymTuple_r SymbolTable_SymTuple;
105 : :
106 : : typedef struct SymbolTable_SymError_r SymbolTable_SymError;
107 : :
108 : : typedef struct SymbolTable_SymObject_r SymbolTable_SymObject;
109 : :
110 : : typedef struct SymbolTable_SymUndefined_r SymbolTable_SymUndefined;
111 : :
112 : : typedef struct SymbolTable_SymGnuAsm_r SymbolTable_SymGnuAsm;
113 : :
114 : : typedef struct SymbolTable_SymInterface_r SymbolTable_SymInterface;
115 : :
116 : : typedef struct SymbolTable_SymVarient_r SymbolTable_SymVarient;
117 : :
118 : : typedef struct SymbolTable_SymRecord_r SymbolTable_SymRecord;
119 : :
120 : : typedef struct SymbolTable_SymSubrange_r SymbolTable_SymSubrange;
121 : :
122 : : typedef struct SymbolTable_SymEnumeration_r SymbolTable_SymEnumeration;
123 : :
124 : : typedef struct SymbolTable_SymArray_r SymbolTable_SymArray;
125 : :
126 : : typedef struct SymbolTable_SymSubscript_r SymbolTable_SymSubscript;
127 : :
128 : : typedef struct SymbolTable_SymUnbounded_r SymbolTable_SymUnbounded;
129 : :
130 : : typedef struct SymbolTable_SymPartialUnbounded_r SymbolTable_SymPartialUnbounded;
131 : :
132 : : typedef struct SymbolTable_SymProcedure_r SymbolTable_SymProcedure;
133 : :
134 : : typedef struct SymbolTable_SymProcType_r SymbolTable_SymProcType;
135 : :
136 : : typedef struct SymbolTable_SymParam_r SymbolTable_SymParam;
137 : :
138 : : typedef struct SymbolTable_SymVarParam_r SymbolTable_SymVarParam;
139 : :
140 : : typedef struct SymbolTable_SymConstString_r SymbolTable_SymConstString;
141 : :
142 : : typedef struct SymbolTable_SymConstLit_r SymbolTable_SymConstLit;
143 : :
144 : : typedef struct SymbolTable_SymConstVar_r SymbolTable_SymConstVar;
145 : :
146 : : typedef struct SymbolTable_SymVar_r SymbolTable_SymVar;
147 : :
148 : : typedef struct SymbolTable_SymType_r SymbolTable_SymType;
149 : :
150 : : typedef struct SymbolTable_SymPointer_r SymbolTable_SymPointer;
151 : :
152 : : typedef struct SymbolTable_SymRecordField_r SymbolTable_SymRecordField;
153 : :
154 : : typedef struct SymbolTable_SymVarientField_r SymbolTable_SymVarientField;
155 : :
156 : : typedef struct SymbolTable_SymEnumerationField_r SymbolTable_SymEnumerationField;
157 : :
158 : : typedef struct SymbolTable_SymSet_r SymbolTable_SymSet;
159 : :
160 : : typedef struct SymbolTable_SymDefImp_r SymbolTable_SymDefImp;
161 : :
162 : : typedef struct SymbolTable_SymModule_r SymbolTable_SymModule;
163 : :
164 : : typedef struct SymbolTable_SymDummy_r SymbolTable_SymDummy;
165 : :
166 : : typedef struct SymbolTable_Symbol_r SymbolTable_Symbol;
167 : :
168 : : typedef struct SymbolTable_CallFrame_r SymbolTable_CallFrame;
169 : :
170 : : typedef struct SymbolTable_CheckProcedure_p SymbolTable_CheckProcedure;
171 : :
172 : : typedef SymbolTable_Symbol *SymbolTable_PtrToSymbol;
173 : :
174 : : typedef SymbolTable_CallFrame *SymbolTable_PtrToCallFrame;
175 : :
176 : : typedef struct SymbolTable__T4_r SymbolTable__T4;
177 : :
178 : : typedef SymbolTable__T4 *SymbolTable_ConstLitPoolEntry;
179 : :
180 : : typedef struct SymbolTable__T5_r SymbolTable__T5;
181 : :
182 : : typedef SymbolTable__T5 *SymbolTable_PtrToAsmConstraint;
183 : :
184 : : typedef enum {SymbolTable_NoValue, SymbolTable_ImmediateValue, SymbolTable_RightValue, SymbolTable_LeftValue} SymbolTable_ModeOfAddr;
185 : :
186 : : typedef enum {SymbolTable_m2str, SymbolTable_cstr, SymbolTable_m2nulstr, SymbolTable_cnulstr} SymbolTable_ConstStringVariant;
187 : :
188 : : 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;
189 : :
190 : : typedef void (*SymbolTable_FamilyOperation_t) (unsigned int, unsigned int, unsigned int);
191 : : struct SymbolTable_FamilyOperation_p { SymbolTable_FamilyOperation_t proc; };
192 : :
193 : : struct SymbolTable_LRLists_a { Lists_List array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
194 : : struct SymbolTable_LRInitDesc_a { M2SymInit_InitDesc array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
195 : : struct SymbolTable_Where_r {
196 : : unsigned int DefDeclared;
197 : : unsigned int ModDeclared;
198 : : unsigned int FirstUsed;
199 : : };
200 : :
201 : : struct SymbolTable_PackedInfo_r {
202 : : bool IsPacked;
203 : : unsigned int PackedEquiv;
204 : : };
205 : :
206 : : struct SymbolTable_ModuleCtor_r {
207 : : unsigned int ctor;
208 : : unsigned int init;
209 : : unsigned int fini;
210 : : unsigned int dep;
211 : : };
212 : :
213 : : struct SymbolTable_SymOAFamily_r {
214 : : unsigned int MaxDimensions;
215 : : unsigned int SimpleType;
216 : : Indexing_Index Dimensions;
217 : : };
218 : :
219 : : struct SymbolTable_SymPartialUnbounded_r {
220 : : unsigned int Type;
221 : : unsigned int NDim;
222 : : };
223 : :
224 : : struct SymbolTable_SymDummy_r {
225 : : unsigned int NextFree;
226 : : };
227 : :
228 : : struct SymbolTable_CallFrame_r {
229 : : unsigned int Main;
230 : : unsigned int Search;
231 : : unsigned int Start;
232 : : };
233 : :
234 : : typedef void (*SymbolTable_CheckProcedure_t) (unsigned int);
235 : : struct SymbolTable_CheckProcedure_p { SymbolTable_CheckProcedure_t proc; };
236 : :
237 : : struct SymbolTable__T4_r {
238 : : unsigned int sym;
239 : : unsigned int tok;
240 : : NameKey_Name constName;
241 : : unsigned int constType;
242 : : SymbolTable_ConstLitPoolEntry next;
243 : : };
244 : :
245 : : struct SymbolTable__T5_r {
246 : : unsigned int tokpos;
247 : : NameKey_Name name;
248 : : unsigned int str;
249 : : unsigned int obj;
250 : : };
251 : :
252 : : struct SymbolTable_SymImportStatement_r {
253 : : unsigned int listNo;
254 : : Lists_List ListOfImports;
255 : : SymbolTable_Where at;
256 : : };
257 : :
258 : : struct SymbolTable_SymImport_r {
259 : : unsigned int module;
260 : : unsigned int listNo;
261 : : bool qualified;
262 : : SymbolTable_Where at;
263 : : };
264 : :
265 : : struct SymbolTable_SymEquiv_r {
266 : : SymbolTable_PackedInfo packedInfo;
267 : : unsigned int nonPacked;
268 : : };
269 : :
270 : : struct SymbolTable_SymTuple_r {
271 : : SymbolTable_Where At;
272 : : unsigned int nTuple;
273 : : Indexing_Index list;
274 : : };
275 : :
276 : : struct SymbolTable_SymError_r {
277 : : NameKey_Name name;
278 : : SymbolTable_Where At;
279 : : };
280 : :
281 : : struct SymbolTable_SymObject_r {
282 : : NameKey_Name name;
283 : : SymbolTable_Where At;
284 : : };
285 : :
286 : : struct SymbolTable_SymUndefined_r {
287 : : NameKey_Name name;
288 : : unsigned int oafamily;
289 : : M2Error_ErrorScope errorScope;
290 : : SymbolTable_Where At;
291 : : };
292 : :
293 : : struct SymbolTable_SymGnuAsm_r {
294 : : unsigned int String;
295 : : SymbolTable_Where At;
296 : : unsigned int Inputs;
297 : : unsigned int Outputs;
298 : : unsigned int Trashed;
299 : : bool Volatile;
300 : : bool Simple;
301 : : };
302 : :
303 : : struct SymbolTable_SymInterface_r {
304 : : Indexing_Index Parameters;
305 : : SymbolTable_Where At;
306 : : };
307 : :
308 : : struct SymbolTable_SymVarient_r {
309 : : M2ALU_PtrToValue Size;
310 : : Lists_List ListOfSons;
311 : : bool DeclPacked;
312 : : bool DeclResolved;
313 : : unsigned int Parent;
314 : : unsigned int Varient;
315 : : unsigned int tag;
316 : : unsigned int Scope;
317 : : SymbolTable_Where At;
318 : : };
319 : :
320 : : struct SymbolTable_SymRecord_r {
321 : : NameKey_Name name;
322 : : SymbolKey_SymbolTree LocalSymbols;
323 : : M2ALU_PtrToValue Size;
324 : : Lists_List ListOfSons;
325 : : unsigned int Align;
326 : : unsigned int DefaultAlign;
327 : : bool DeclPacked;
328 : : bool DeclResolved;
329 : : unsigned int oafamily;
330 : : unsigned int Parent;
331 : : unsigned int Scope;
332 : : SymbolTable_Where At;
333 : : };
334 : :
335 : : struct SymbolTable_SymSubrange_r {
336 : : NameKey_Name name;
337 : : unsigned int Low;
338 : : unsigned int High;
339 : : M2ALU_PtrToValue Size;
340 : : unsigned int Type;
341 : : unsigned int Align;
342 : : SymbolKey_SymbolTree ConstLitTree;
343 : : SymbolTable_PackedInfo packedInfo;
344 : : unsigned int oafamily;
345 : : unsigned int Scope;
346 : : SymbolTable_Where At;
347 : : };
348 : :
349 : : struct SymbolTable_SymEnumeration_r {
350 : : NameKey_Name name;
351 : : unsigned int NoOfElements;
352 : : SymbolKey_SymbolTree LocalSymbols;
353 : : Lists_List ListOfFields;
354 : : M2ALU_PtrToValue Size;
355 : : SymbolTable_PackedInfo packedInfo;
356 : : unsigned int oafamily;
357 : : unsigned int Scope;
358 : : SymbolTable_Where At;
359 : : };
360 : :
361 : : struct SymbolTable_SymArray_r {
362 : : NameKey_Name name;
363 : : unsigned int Subscript;
364 : : M2ALU_PtrToValue Size;
365 : : M2ALU_PtrToValue Offset;
366 : : unsigned int Type;
367 : : unsigned int Align;
368 : : bool Large;
369 : : unsigned int oafamily;
370 : : unsigned int Scope;
371 : : SymbolTable_Where At;
372 : : };
373 : :
374 : : struct SymbolTable_SymSubscript_r {
375 : : unsigned int Type;
376 : : M2ALU_PtrToValue Size;
377 : : M2ALU_PtrToValue Offset;
378 : : SymbolTable_Where At;
379 : : };
380 : :
381 : : struct SymbolTable_SymUnbounded_r {
382 : : unsigned int Type;
383 : : M2ALU_PtrToValue Size;
384 : : unsigned int RecordType;
385 : : unsigned int Dimensions;
386 : : unsigned int Scope;
387 : : SymbolTable_Where At;
388 : : };
389 : :
390 : : struct SymbolTable_SymProcedure_r {
391 : : NameKey_Name name;
392 : : Lists_List ListOfParam;
393 : : bool ParamDefined;
394 : : bool DefinedInDef;
395 : : bool DefinedInImp;
396 : : bool HasVarArgs;
397 : : bool HasOptArg;
398 : : unsigned int OptArgInit;
399 : : bool IsBuiltin;
400 : : NameKey_Name BuiltinName;
401 : : bool IsInline;
402 : : bool IsNoReturn;
403 : : bool ReturnOptional;
404 : : bool IsExtern;
405 : : bool IsPublic;
406 : : bool IsCtor;
407 : : bool IsMonoName;
408 : : SymbolKey_SymbolTree Unresolved;
409 : : unsigned int ScopeQuad;
410 : : unsigned int StartQuad;
411 : : unsigned int EndQuad;
412 : : bool Reachable;
413 : : bool SavePriority;
414 : : unsigned int ReturnType;
415 : : unsigned int Offset;
416 : : SymbolKey_SymbolTree LocalSymbols;
417 : : Lists_List EnumerationScopeList;
418 : : Lists_List ListOfVars;
419 : : Lists_List ListOfProcs;
420 : : SymbolKey_SymbolTree NamedObjects;
421 : : M2ALU_PtrToValue Size;
422 : : M2ALU_PtrToValue TotalParamSize;
423 : : bool ExceptionFinally;
424 : : bool ExceptionBlock;
425 : : unsigned int Scope;
426 : : M2Error_ErrorScope errorScope;
427 : : Lists_List ListOfModules;
428 : : unsigned int Begin;
429 : : unsigned int End;
430 : : SymbolTable_Where At;
431 : : };
432 : :
433 : : struct SymbolTable_SymProcType_r {
434 : : NameKey_Name name;
435 : : Lists_List ListOfParam;
436 : : bool HasVarArgs;
437 : : bool HasOptArg;
438 : : unsigned int OptArgInit;
439 : : unsigned int ReturnType;
440 : : bool ReturnOptional;
441 : : unsigned int Scope;
442 : : M2ALU_PtrToValue Size;
443 : : M2ALU_PtrToValue TotalParamSize;
444 : : unsigned int oafamily;
445 : : SymbolTable_Where At;
446 : : };
447 : :
448 : : struct SymbolTable_SymParam_r {
449 : : NameKey_Name name;
450 : : unsigned int Type;
451 : : bool IsUnbounded;
452 : : unsigned int ShadowVar;
453 : : SymbolTable_Where At;
454 : : };
455 : :
456 : : struct SymbolTable_SymVarParam_r {
457 : : NameKey_Name name;
458 : : unsigned int Type;
459 : : bool IsUnbounded;
460 : : unsigned int HeapVar;
461 : : unsigned int ShadowVar;
462 : : SymbolTable_Where At;
463 : : };
464 : :
465 : : struct SymbolTable_SymConstString_r {
466 : : NameKey_Name name;
467 : : NameKey_Name Contents;
468 : : unsigned int Length;
469 : : SymbolTable_ConstStringVariant StringVariant;
470 : : bool Known;
471 : : unsigned int Scope;
472 : : SymbolTable_Where At;
473 : : };
474 : :
475 : : struct SymbolTable_SymConstLit_r {
476 : : NameKey_Name name;
477 : : M2ALU_PtrToValue Value;
478 : : unsigned int Type;
479 : : bool IsSet;
480 : : bool IsConstructor;
481 : : bool IsInternal;
482 : : unsigned int FromType;
483 : : bool RangeError;
484 : : bool UnresFromType;
485 : : unsigned int Scope;
486 : : SymbolTable_Where At;
487 : : };
488 : :
489 : : struct SymbolTable_SymConstVar_r {
490 : : NameKey_Name name;
491 : : M2ALU_PtrToValue Value;
492 : : unsigned int Type;
493 : : bool IsSet;
494 : : bool IsConstructor;
495 : : unsigned int FromType;
496 : : bool UnresFromType;
497 : : bool IsTemp;
498 : : unsigned int Scope;
499 : : SymbolTable_Where At;
500 : : };
501 : :
502 : : struct SymbolTable_SymVar_r {
503 : : NameKey_Name name;
504 : : unsigned int Type;
505 : : unsigned int BackType;
506 : : M2ALU_PtrToValue Size;
507 : : M2ALU_PtrToValue Offset;
508 : : SymbolTable_ModeOfAddr AddrMode;
509 : : unsigned int Scope;
510 : : bool AtAddress;
511 : : unsigned int Address;
512 : : bool IsComponentRef;
513 : : Indexing_Index list;
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_Where At;
524 : : SymbolTable_LRLists ReadUsageList;
525 : : SymbolTable_LRLists WriteUsageList;
526 : : };
527 : :
528 : : struct SymbolTable_SymType_r {
529 : : NameKey_Name name;
530 : : unsigned int Type;
531 : : bool IsHidden;
532 : : SymbolKey_SymbolTree ConstLitTree;
533 : : M2ALU_PtrToValue Size;
534 : : SymbolTable_PackedInfo packedInfo;
535 : : unsigned int oafamily;
536 : : unsigned int Align;
537 : : unsigned int Scope;
538 : : SymbolTable_Where At;
539 : : };
540 : :
541 : : struct SymbolTable_SymPointer_r {
542 : : NameKey_Name name;
543 : : unsigned int Type;
544 : : M2ALU_PtrToValue Size;
545 : : unsigned int Align;
546 : : SymbolKey_SymbolTree ConstLitTree;
547 : : unsigned int oafamily;
548 : : unsigned int Scope;
549 : : SymbolTable_Where At;
550 : : };
551 : :
552 : : struct SymbolTable_SymRecordField_r {
553 : : NameKey_Name name;
554 : : unsigned int Type;
555 : : bool Tag;
556 : : M2ALU_PtrToValue Size;
557 : : M2ALU_PtrToValue Offset;
558 : : unsigned int Parent;
559 : : unsigned int Varient;
560 : : unsigned int Align;
561 : : bool Used;
562 : : bool DeclPacked;
563 : : bool DeclResolved;
564 : : unsigned int Scope;
565 : : SymbolTable_Where At;
566 : : };
567 : :
568 : : struct SymbolTable_SymVarientField_r {
569 : : NameKey_Name name;
570 : : M2ALU_PtrToValue Size;
571 : : M2ALU_PtrToValue Offset;
572 : : unsigned int Parent;
573 : : unsigned int Varient;
574 : : Lists_List ListOfSons;
575 : : bool DeclPacked;
576 : : bool DeclResolved;
577 : : unsigned int Scope;
578 : : SymbolTable_Where At;
579 : : };
580 : :
581 : : struct SymbolTable_SymEnumerationField_r {
582 : : NameKey_Name name;
583 : : M2ALU_PtrToValue Value;
584 : : unsigned int Type;
585 : : unsigned int Scope;
586 : : SymbolTable_Where At;
587 : : };
588 : :
589 : : struct SymbolTable_SymSet_r {
590 : : NameKey_Name name;
591 : : unsigned int Type;
592 : : SymbolTable_PackedInfo packedInfo;
593 : : bool ispacked;
594 : : M2ALU_PtrToValue Size;
595 : : unsigned int oafamily;
596 : : unsigned int Scope;
597 : : SymbolTable_Where At;
598 : : };
599 : :
600 : : struct SymbolTable_SymDefImp_r {
601 : : NameKey_Name name;
602 : : NameKey_Name libname;
603 : : SymbolTable_ModuleCtor ctors;
604 : : Lists_List DefListOfDep;
605 : : Lists_List ModListOfDep;
606 : : SymbolKey_SymbolTree ExportQualifiedTree;
607 : : SymbolKey_SymbolTree ExportUnQualifiedTree;
608 : : SymbolKey_SymbolTree ExportRequest;
609 : : Lists_List IncludeList;
610 : : Lists_List DefIncludeList;
611 : : SymbolKey_SymbolTree ImportTree;
612 : : SymbolKey_SymbolTree ExportUndeclared;
613 : : SymbolKey_SymbolTree NeedToBeImplemented;
614 : : SymbolKey_SymbolTree LocalSymbols;
615 : : Lists_List EnumerationScopeList;
616 : : SymbolKey_SymbolTree NamedObjects;
617 : : SymbolKey_SymbolTree NamedImports;
618 : : SymbolKey_SymbolTree WhereImported;
619 : : unsigned int Priority;
620 : : SymbolKey_SymbolTree Unresolved;
621 : : unsigned int StartQuad;
622 : : unsigned int EndQuad;
623 : : unsigned int StartFinishQuad;
624 : : unsigned int EndFinishQuad;
625 : : m2tree_Tree FinallyFunction;
626 : : bool ExceptionFinally;
627 : : bool ExceptionBlock;
628 : : bool ContainsHiddenType;
629 : : bool ContainsBuiltin;
630 : : bool ForC;
631 : : bool NeedExportList;
632 : : bool ModLink;
633 : : bool DefLink;
634 : : bool Builtin;
635 : : Lists_List ListOfVars;
636 : : Lists_List ListOfProcs;
637 : : Lists_List ListOfModules;
638 : : M2Error_ErrorScope errorScope;
639 : : SymbolTable_Where At;
640 : : };
641 : :
642 : : struct SymbolTable_SymModule_r {
643 : : NameKey_Name name;
644 : : NameKey_Name libname;
645 : : SymbolTable_ModuleCtor ctors;
646 : : Lists_List ModListOfDep;
647 : : SymbolKey_SymbolTree LocalSymbols;
648 : : SymbolKey_SymbolTree ExportTree;
649 : : Lists_List IncludeList;
650 : : SymbolKey_SymbolTree ImportTree;
651 : : SymbolKey_SymbolTree ExportUndeclared;
652 : : Lists_List EnumerationScopeList;
653 : : SymbolKey_SymbolTree NamedObjects;
654 : : SymbolKey_SymbolTree NamedImports;
655 : : SymbolKey_SymbolTree WhereImported;
656 : : unsigned int Scope;
657 : : unsigned int Priority;
658 : : SymbolKey_SymbolTree Unresolved;
659 : : unsigned int StartQuad;
660 : : unsigned int EndQuad;
661 : : unsigned int StartFinishQuad;
662 : : unsigned int EndFinishQuad;
663 : : m2tree_Tree FinallyFunction;
664 : : bool ExceptionFinally;
665 : : bool ExceptionBlock;
666 : : bool ModLink;
667 : : bool Builtin;
668 : : Lists_List ListOfVars;
669 : : Lists_List ListOfProcs;
670 : : Lists_List ListOfModules;
671 : : M2Error_ErrorScope errorScope;
672 : : SymbolTable_Where At;
673 : : };
674 : :
675 : : struct SymbolTable_Symbol_r {
676 : : SymbolTable_TypeOfSymbol SymbolType; /* case tag */
677 : : union {
678 : : SymbolTable_SymOAFamily OAFamily;
679 : : SymbolTable_SymObject Object;
680 : : SymbolTable_SymEquiv Equiv;
681 : : SymbolTable_SymRecord Record;
682 : : SymbolTable_SymVarient Varient;
683 : : SymbolTable_SymVar Var;
684 : : SymbolTable_SymEnumeration Enumeration;
685 : : SymbolTable_SymSubrange Subrange;
686 : : SymbolTable_SymSubscript Subscript;
687 : : SymbolTable_SymArray Array;
688 : : SymbolTable_SymUnbounded Unbounded;
689 : : SymbolTable_SymPartialUnbounded PartialUnbounded;
690 : : SymbolTable_SymConstVar ConstVar;
691 : : SymbolTable_SymConstLit ConstLit;
692 : : SymbolTable_SymConstString ConstString;
693 : : SymbolTable_SymVarParam VarParam;
694 : : SymbolTable_SymParam Param;
695 : : SymbolTable_SymError Error;
696 : : SymbolTable_SymUndefined Undefined;
697 : : SymbolTable_SymType Type;
698 : : SymbolTable_SymPointer Pointer;
699 : : SymbolTable_SymRecordField RecordField;
700 : : SymbolTable_SymVarientField VarientField;
701 : : SymbolTable_SymEnumerationField EnumerationField;
702 : : SymbolTable_SymDefImp DefImp;
703 : : SymbolTable_SymModule Module;
704 : : SymbolTable_SymSet Set;
705 : : SymbolTable_SymProcedure Procedure;
706 : : SymbolTable_SymProcType ProcType;
707 : : SymbolTable_SymImportStatement ImportStatement;
708 : : SymbolTable_SymImport Import;
709 : : SymbolTable_SymGnuAsm GnuAsm;
710 : : SymbolTable_SymInterface Interface;
711 : : SymbolTable_SymTuple Tuple;
712 : : SymbolTable_SymDummy Dummy;
713 : : };
714 : : };
715 : :
716 : : static Indexing_Index Symbols;
717 : : static Indexing_Index ScopeCallFrame;
718 : : static unsigned int FreeSymbol;
719 : : static SymbolKey_SymbolTree DefModuleTree;
720 : : static SymbolKey_SymbolTree ModuleTree;
721 : : static unsigned int CurrentModule;
722 : : static unsigned int MainModule;
723 : : static unsigned int FileModule;
724 : : static unsigned int ScopePtr;
725 : : static unsigned int BaseScopePtr;
726 : : static unsigned int BaseModule;
727 : : static unsigned int TemporaryNo;
728 : : static M2Error_Error CurrentError;
729 : : static Lists_List AddressTypes;
730 : : static Lists_List UnresolvedConstructorType;
731 : : static unsigned int AnonymousName;
732 : : static Sets_Set ReportedUnknowns;
733 : : static SymbolKey_SymbolTree ConstLitPoolTree;
734 : : static Indexing_Index ConstLitArray;
735 : : static unsigned int recordConsist;
736 : : static DynamicStrings_String ListifySentance;
737 : : static unsigned int ListifyTotal;
738 : : static unsigned int ListifyWordCount;
739 : : static unsigned int ExportRequestModule;
740 : : static unsigned int ResolveModule;
741 : :
742 : : /*
743 : : FinalSymbol - returns the highest number symbol used.
744 : : */
745 : :
746 : : extern "C" unsigned int SymbolTable_FinalSymbol (void);
747 : :
748 : : /*
749 : : MakeComponentRecord - make a temporary which will be used to reference and field
750 : : (or sub field) of record.
751 : : */
752 : :
753 : : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record);
754 : :
755 : : /*
756 : : MakeComponentRef - use, sym, to reference, field, sym is returned.
757 : : */
758 : :
759 : : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field);
760 : :
761 : : /*
762 : : IsComponent - returns TRUE if symbol, sym, is a temporary and a component
763 : : reference.
764 : : */
765 : :
766 : : extern "C" bool SymbolTable_IsComponent (unsigned int sym);
767 : :
768 : : /*
769 : : MakeTemporary - Makes a new temporary variable at the highest real scope.
770 : : The addressing mode of the temporary is set to NoValue.
771 : : */
772 : :
773 : : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode);
774 : :
775 : : /*
776 : : MakeTemporaryFromExpression - makes a new temporary variable at the
777 : : highest real scope. The addressing
778 : : mode of the temporary is set and the
779 : : type is determined by expressions, e.
780 : : */
781 : :
782 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode);
783 : :
784 : : /*
785 : : MakeTemporaryFromExpressions - makes a new temporary variable at the
786 : : highest real scope. The addressing
787 : : mode of the temporary is set and the
788 : : type is determined by expressions,
789 : : e1 and e2.
790 : : */
791 : :
792 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode);
793 : :
794 : : /*
795 : : PutMode - Puts the addressing mode, SymMode, into symbol Sym.
796 : : The mode may only be altered if the mode
797 : : is None.
798 : : */
799 : :
800 : : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode);
801 : :
802 : : /*
803 : : GetMode - Returns the addressing mode of a symbol.
804 : : */
805 : :
806 : : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym);
807 : :
808 : : /*
809 : : StartScope - starts a block scope at Sym. Transparent determines
810 : : whether the search for a symbol will look at the
811 : : previous ScopeCallFrame if Sym does not contain the
812 : : symbol that GetSym is searching.
813 : :
814 : : WITH statements are partially implemented by calling
815 : : StartScope. Therefore we must retain the old Main from
816 : : the previous ScopePtr when a record is added to the scope
817 : : stack. (Main contains the symbol where all identifiers
818 : : should be added.)
819 : : */
820 : :
821 : : extern "C" void SymbolTable_StartScope (unsigned int Sym);
822 : :
823 : : /*
824 : : EndScope - ends a block scope started by StartScope. The current
825 : : head of the symbol scope reverts back to the symbol
826 : : which was the Head of the symbol scope before the
827 : : last StartScope was called.
828 : : */
829 : :
830 : : extern "C" void SymbolTable_EndScope (void);
831 : :
832 : : /*
833 : : PseudoScope - starts a pseudo scope at Sym.
834 : : We always connect parent up to the last scope,
835 : : to determine the transparancy of a scope we call
836 : : TransparentScope.
837 : :
838 : : A Pseudo scope has no end block,
839 : : but is terminated when the next EndScope is used.
840 : : The function of the pseudo scope is to provide an
841 : : automatic mechanism to solve enumeration types.
842 : : A declared enumeration type is a Pseudo scope and
843 : : identifiers used with the name of an enumeration
844 : : type field will find the enumeration symbol by
845 : : the scoping algorithm.
846 : : */
847 : :
848 : : extern "C" void SymbolTable_PseudoScope (unsigned int Sym);
849 : :
850 : : /*
851 : : GetCurrentScope - returns the symbol who is responsible for the current
852 : : scope. Note that it ignore pseudo scopes.
853 : : */
854 : :
855 : : extern "C" unsigned int SymbolTable_GetCurrentScope (void);
856 : :
857 : : /*
858 : : IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
859 : : */
860 : :
861 : : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym);
862 : :
863 : : /*
864 : : SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
865 : : This Sym must represent the module name of the
866 : : file currently being compiled.
867 : : */
868 : :
869 : : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym);
870 : :
871 : : /*
872 : : SetFileModule - Used to set the FileModule to a symbol, Sym.
873 : : This Sym must represent the current program module
874 : : file which is being parsed.
875 : : */
876 : :
877 : : extern "C" void SymbolTable_SetFileModule (unsigned int Sym);
878 : :
879 : : /*
880 : : SetMainModule - Used to set the MainModule to a symbol, Sym.
881 : : This Sym must represent the main module which was
882 : : envoked by the user to be compiled.
883 : : */
884 : :
885 : : extern "C" void SymbolTable_SetMainModule (unsigned int Sym);
886 : :
887 : : /*
888 : : CheckAnonymous - checks to see whether the name is NulName and if so
889 : : it creates a unique anonymous name.
890 : : */
891 : :
892 : : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name);
893 : :
894 : : /*
895 : : IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
896 : : or no name.
897 : : */
898 : :
899 : : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym);
900 : :
901 : : /*
902 : : NoOfVariables - returns the number of variables in scope. The scope maybe
903 : : a procedure, module or defimp scope.
904 : : */
905 : :
906 : : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope);
907 : :
908 : : /*
909 : : MakeModule - creates a module sym with ModuleName. It returns the
910 : : symbol index.
911 : : */
912 : :
913 : : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName);
914 : :
915 : : /*
916 : : MakeDefImp - creates a definition and implementation module sym
917 : : with name DefImpName. It returns the symbol index.
918 : : */
919 : :
920 : : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName);
921 : :
922 : : /*
923 : : MakeInnerModule - creates an inner module sym with ModuleName. It returns the
924 : : symbol index.
925 : : */
926 : :
927 : : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName);
928 : :
929 : : /*
930 : : MakeProcedure - creates a procedure sym with name. It returns
931 : : the symbol index.
932 : : */
933 : :
934 : : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName);
935 : :
936 : : /*
937 : : MakeProcedureCtorExtern - creates an extern ctor procedure
938 : : */
939 : :
940 : : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename);
941 : :
942 : : /*
943 : : PutLibName - places libname into defimp or module sym.
944 : : */
945 : :
946 : : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname);
947 : :
948 : : /*
949 : : GetLibName - returns libname associated with a defimp or module sym.
950 : : */
951 : :
952 : : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym);
953 : :
954 : : /*
955 : : PutMonoName - changes the IsMonoName boolean inside the procedure.
956 : : */
957 : :
958 : : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value);
959 : :
960 : : /*
961 : : IsMonoName - returns the public boolean associated with a procedure.
962 : : */
963 : :
964 : : extern "C" bool SymbolTable_IsMonoName (unsigned int sym);
965 : :
966 : : /*
967 : : PutExtern - changes the extern boolean inside the procedure.
968 : : */
969 : :
970 : : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value);
971 : :
972 : : /*
973 : : IsExtern - returns the public boolean associated with a procedure.
974 : : */
975 : :
976 : : extern "C" bool SymbolTable_IsExtern (unsigned int sym);
977 : :
978 : : /*
979 : : PutPublic - changes the public boolean inside the procedure.
980 : : */
981 : :
982 : : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value);
983 : :
984 : : /*
985 : : IsPublic - returns the public boolean associated with a procedure.
986 : : */
987 : :
988 : : extern "C" bool SymbolTable_IsPublic (unsigned int sym);
989 : :
990 : : /*
991 : : PutCtor - changes the ctor boolean inside the procedure.
992 : : */
993 : :
994 : : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value);
995 : :
996 : : /*
997 : : IsCtor - returns the ctor boolean associated with a procedure.
998 : : */
999 : :
1000 : : extern "C" bool SymbolTable_IsCtor (unsigned int sym);
1001 : :
1002 : : /*
1003 : : GetModuleCtors - mod can be a DefImp or Module symbol. ctor, init and fini
1004 : : are assigned for this module. An inner module ctor value will
1005 : : be NulSym.
1006 : : */
1007 : :
1008 : : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep);
1009 : :
1010 : : /*
1011 : : MakeModuleCtor - for a defimp or module symbol create all the ctor
1012 : : related procedures.
1013 : : */
1014 : :
1015 : : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym);
1016 : :
1017 : : /*
1018 : : PutModuleCtorExtern - for every ctor related procedure in module sym.
1019 : : Make it external. It will create any missing
1020 : : init/fini procedures but not any missing dep/ctor
1021 : : procedures.
1022 : : */
1023 : :
1024 : : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external);
1025 : :
1026 : : /*
1027 : : PutVarHeap - assigns ArrayRef field with value.
1028 : : */
1029 : :
1030 : : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value);
1031 : :
1032 : : /*
1033 : : IsVarHeap - returns ArrayRef field value.
1034 : : */
1035 : :
1036 : : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym);
1037 : :
1038 : : /*
1039 : : MakeVar - creates a variable sym with VarName. It returns the
1040 : : symbol index.
1041 : : */
1042 : :
1043 : : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName);
1044 : :
1045 : : /*
1046 : : MakeRecord - makes a Record symbol with name RecordName.
1047 : : */
1048 : :
1049 : : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName);
1050 : :
1051 : : /*
1052 : : MakeVarient - creates a new symbol, a varient symbol for record or varient field
1053 : : symbol, RecOrVarFieldSym.
1054 : : */
1055 : :
1056 : : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym);
1057 : :
1058 : : /*
1059 : : MakeFieldVarient - returns a FieldVarient symbol which has been
1060 : : assigned to the Varient symbol, Sym.
1061 : : */
1062 : :
1063 : : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym);
1064 : :
1065 : : /*
1066 : : MakeEnumeration - places a new symbol in the current scope, the symbol
1067 : : is an enumeration symbol. The symbol index is returned.
1068 : : */
1069 : :
1070 : : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName);
1071 : :
1072 : : /*
1073 : : MakeType - makes a type symbol with name TypeName.
1074 : : */
1075 : :
1076 : : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName);
1077 : :
1078 : : /*
1079 : : MakeHiddenType - makes a type symbol that is hidden from the
1080 : : definition module.
1081 : : This symbol is placed into the UnImplemented list of
1082 : : the definition/implementation module.
1083 : : The type will be filled in when the implementation module
1084 : : is reached.
1085 : : */
1086 : :
1087 : : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName);
1088 : :
1089 : : /*
1090 : : MakeConstant - create a constant cardinal and return the symbol.
1091 : : */
1092 : :
1093 : : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value);
1094 : :
1095 : : /*
1096 : : MakeConstLit - returns a constant literal of type, constType, with a constName,
1097 : : at location, tok.
1098 : : */
1099 : :
1100 : : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
1101 : :
1102 : : /*
1103 : : MakeConstVar - makes a ConstVar type with
1104 : : name ConstVarName.
1105 : : */
1106 : :
1107 : : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName);
1108 : :
1109 : : /*
1110 : : MakeConstString - create a string constant in the symboltable.
1111 : : */
1112 : :
1113 : : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName);
1114 : :
1115 : : /*
1116 : : MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
1117 : : If known is TRUE then name is assigned to the contents
1118 : : and the escape sequences will be converted into characters.
1119 : : */
1120 : :
1121 : : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known);
1122 : :
1123 : : /*
1124 : : MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
1125 : : If known is TRUE then name is assigned to the contents
1126 : : however the escape sequences are not converted into characters.
1127 : : */
1128 : :
1129 : : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known);
1130 : :
1131 : : /*
1132 : : PutConstStringKnown - if sym is a constvar then convert it into a conststring.
1133 : : If known is FALSE then contents is ignored and NulName is
1134 : : stored. If escape is TRUE then the contents will have
1135 : : any escape sequences converted into single characters.
1136 : : */
1137 : :
1138 : : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known);
1139 : :
1140 : : /*
1141 : : CopyConstString - copies string contents from expr to des
1142 : : and retain the kind of string.
1143 : : */
1144 : :
1145 : : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr);
1146 : :
1147 : : /*
1148 : : IsConstStringKnown - returns TRUE if sym is a const string
1149 : : and the contents are known.
1150 : : */
1151 : :
1152 : : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym);
1153 : :
1154 : : /*
1155 : : IsConstStringM2 - returns whether this conststring is a
1156 : : Modula-2 string.
1157 : : */
1158 : :
1159 : : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym);
1160 : :
1161 : : /*
1162 : : IsConstStringC - returns whether this conststring is a C style string
1163 : : which will have any escape translated.
1164 : : */
1165 : :
1166 : : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym);
1167 : :
1168 : : /*
1169 : : IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
1170 : : contains a nul terminator.
1171 : : */
1172 : :
1173 : : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym);
1174 : :
1175 : : /*
1176 : : IsConstStringCnul - returns whether this conststring is a C style string
1177 : : which will have any escape translated and also contains
1178 : : a nul terminator.
1179 : : */
1180 : :
1181 : : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym);
1182 : :
1183 : : /*
1184 : : MakeSubrange - makes a new symbol into a subrange type with
1185 : : name SubrangeName.
1186 : : */
1187 : :
1188 : : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName);
1189 : :
1190 : : /*
1191 : : MakeSet - makes a set Symbol with name, SetName.
1192 : : */
1193 : :
1194 : : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName);
1195 : :
1196 : : /*
1197 : : MakeArray - makes an Array symbol with name ArrayName.
1198 : : */
1199 : :
1200 : : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName);
1201 : :
1202 : : /*
1203 : : PutArrayLarge - indicates that this is a large array in which case
1204 : : the interface to gcc maps this array from 0..high-low,
1205 : : using an integer indice.
1206 : : */
1207 : :
1208 : : extern "C" void SymbolTable_PutArrayLarge (unsigned int array);
1209 : :
1210 : : /*
1211 : : IsArrayLarge - returns TRUE if we need to treat this as a large array.
1212 : : */
1213 : :
1214 : : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array);
1215 : :
1216 : : /*
1217 : : PutPriority - places a interrupt, priority, value into module, module.
1218 : : */
1219 : :
1220 : : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority);
1221 : :
1222 : : /*
1223 : : GetPriority - returns the interrupt priority which was assigned to
1224 : : module, module.
1225 : : */
1226 : :
1227 : : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module);
1228 : :
1229 : : /*
1230 : : PutNeedSavePriority - set a boolean flag indicating that this procedure
1231 : : needs to save and restore interrupts.
1232 : : */
1233 : :
1234 : : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym);
1235 : :
1236 : : /*
1237 : : GetNeedSavePriority - returns the boolean flag indicating whether this procedure
1238 : : needs to save and restore interrupts.
1239 : : */
1240 : :
1241 : : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym);
1242 : :
1243 : : /*
1244 : : PutVariableAtAddress - determines that a variable, sym, is declared at
1245 : : a specific address.
1246 : : */
1247 : :
1248 : : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address);
1249 : :
1250 : : /*
1251 : : GetVariableAtAddress - returns the address at which variable, sym, is declared.
1252 : : */
1253 : :
1254 : : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym);
1255 : :
1256 : : /*
1257 : : IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
1258 : : a specific address.
1259 : : */
1260 : :
1261 : : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym);
1262 : :
1263 : : /*
1264 : : PutVariableSSA - assigns value to the SSA field within variable sym.
1265 : : */
1266 : :
1267 : : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value);
1268 : :
1269 : : /*
1270 : : IsVariableSSA - returns TRUE if variable is known to be a SSA.
1271 : : */
1272 : :
1273 : : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym);
1274 : :
1275 : : /*
1276 : : PutVarConst - sets the IsConst field to value indicating the variable is read only.
1277 : : */
1278 : :
1279 : : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value);
1280 : :
1281 : : /*
1282 : : MakeGnuAsm - create a GnuAsm symbol.
1283 : : */
1284 : :
1285 : : extern "C" unsigned int SymbolTable_MakeGnuAsm (void);
1286 : :
1287 : : /*
1288 : : PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
1289 : : */
1290 : :
1291 : : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string);
1292 : :
1293 : : /*
1294 : : PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
1295 : : */
1296 : :
1297 : : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out);
1298 : :
1299 : : /*
1300 : : PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
1301 : : */
1302 : :
1303 : : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in);
1304 : :
1305 : : /*
1306 : : PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
1307 : : */
1308 : :
1309 : : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash);
1310 : :
1311 : : /*
1312 : : GetGnuAsm - returns the string symbol, representing the instruction textual
1313 : : of the GnuAsm symbol. It will return a ConstString.
1314 : : */
1315 : :
1316 : : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym);
1317 : :
1318 : : /*
1319 : : GetGnuAsmInput - returns the input list of registers.
1320 : : */
1321 : :
1322 : : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym);
1323 : :
1324 : : /*
1325 : : GetGnuAsmOutput - returns the output list of registers.
1326 : : */
1327 : :
1328 : : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym);
1329 : :
1330 : : /*
1331 : : GetGnuAsmTrash - returns the list of trashed registers.
1332 : : */
1333 : :
1334 : : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym);
1335 : :
1336 : : /*
1337 : : PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
1338 : : */
1339 : :
1340 : : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym);
1341 : :
1342 : : /*
1343 : : PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
1344 : : */
1345 : :
1346 : : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym);
1347 : :
1348 : : /*
1349 : : MakeRegInterface - creates and returns a register interface symbol.
1350 : : */
1351 : :
1352 : : extern "C" unsigned int SymbolTable_MakeRegInterface (void);
1353 : :
1354 : : /*
1355 : : PutRegInterface - places a, name, string, and, object, into the interface array,
1356 : : sym, at position, i.
1357 : : The string symbol will either be a register name or a constraint.
1358 : : The object is an optional Modula-2 variable or constant symbol.
1359 : : read and write are the quadruple numbers representing any read
1360 : : or write operation.
1361 : : */
1362 : :
1363 : : 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_);
1364 : :
1365 : : /*
1366 : : GetRegInterface - gets a, name, string, and, object, from the interface array,
1367 : : sym, from position, i.
1368 : : */
1369 : :
1370 : : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object);
1371 : :
1372 : : /*
1373 : : GetModule - Returns the Module symbol for the module with name, name.
1374 : : */
1375 : :
1376 : : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name);
1377 : :
1378 : : /*
1379 : : GetCurrentModule - returns the current module Sym that is being
1380 : : compiled.
1381 : : */
1382 : :
1383 : : extern "C" unsigned int SymbolTable_GetCurrentModule (void);
1384 : :
1385 : : /*
1386 : : GetFileModule - returns the FileModule symbol that was requested by
1387 : : the user to be compiled.
1388 : : */
1389 : :
1390 : : extern "C" unsigned int SymbolTable_GetFileModule (void);
1391 : :
1392 : : /*
1393 : : GetBaseModule - returns the base module symbol that contains Modula-2
1394 : : base types, procedures and functions.
1395 : : */
1396 : :
1397 : : extern "C" unsigned int SymbolTable_GetBaseModule (void);
1398 : :
1399 : : /*
1400 : : GetMainModule - returns the main module symbol that was requested by
1401 : : the user to be compiled.
1402 : : */
1403 : :
1404 : : extern "C" unsigned int SymbolTable_GetMainModule (void);
1405 : :
1406 : : /*
1407 : : GetCurrentModuleScope - returns the module symbol which forms the
1408 : : current (possibly inner most) module.
1409 : : */
1410 : :
1411 : : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void);
1412 : :
1413 : : /*
1414 : : GetLastModuleScope - returns the last module scope encountered,
1415 : : the module scope before the Current Module Scope.
1416 : : */
1417 : :
1418 : : extern "C" unsigned int SymbolTable_GetLastModuleScope (void);
1419 : :
1420 : : /*
1421 : : AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
1422 : : ModSym.
1423 : : */
1424 : :
1425 : : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym);
1426 : :
1427 : : /*
1428 : : GetType - Returns the symbol that is the TYPE symbol to Sym.
1429 : : If zero is returned then we assume type unknown.
1430 : : */
1431 : :
1432 : : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym);
1433 : :
1434 : : /*
1435 : : SkipType - if sym is a TYPE foo = bar
1436 : : then call SkipType(bar)
1437 : : else return sym
1438 : :
1439 : : it does not skip over hidden types.
1440 : : */
1441 : :
1442 : : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym);
1443 : :
1444 : : /*
1445 : : SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
1446 : : sym is declared as a subrange of bar
1447 : : then call SkipTypeAndSubrange(bar)
1448 : : else return sym
1449 : :
1450 : : it does not skip over hidden types.
1451 : : */
1452 : :
1453 : : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym);
1454 : :
1455 : : /*
1456 : : GetLowestType - Returns the lowest type in the type chain of
1457 : : symbol Sym.
1458 : : If NulSym is returned then we assume type unknown or
1459 : : you have reqested the type of a base type.
1460 : : */
1461 : :
1462 : : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym);
1463 : :
1464 : : /*
1465 : : GetLType - get lowest type. It returns the lowest type
1466 : : of symbol, sym. It skips over type equivalences.
1467 : : It will not skip over base types.
1468 : : */
1469 : :
1470 : : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym);
1471 : :
1472 : : /*
1473 : : GetSType - get source type. It returns the type closest
1474 : : to the object. It does not skip over type
1475 : : equivalences. It will skip over base types.
1476 : : */
1477 : :
1478 : : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym);
1479 : :
1480 : : /*
1481 : : GetDType - get gcc declared type. It returns the type
1482 : : of the object which is declared to GCC.
1483 : : It does skip over type equivalences but only
1484 : : if they do not contain a user alignment.
1485 : : It does not skip over hidden types.
1486 : : It does not skip over base types.
1487 : : */
1488 : :
1489 : : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym);
1490 : :
1491 : : /*
1492 : : GetTypeMode - return the type of sym, it returns Address is the
1493 : : symbol is a LValue.
1494 : : */
1495 : :
1496 : : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym);
1497 : :
1498 : : /*
1499 : : GetSym - searches the current scope (and previous scopes if the
1500 : : scope tranparent allows) for a symbol with name.
1501 : : */
1502 : :
1503 : : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name);
1504 : :
1505 : : /*
1506 : : GetDeclareSym - searches for a symbol with a name SymName in the
1507 : : current and previous scopes.
1508 : : If the symbol is found then it is returned
1509 : : else an unknown symbol is returned.
1510 : : This procedure assumes that SymName is being
1511 : : declared at this point and therefore it does
1512 : : not examine the base scope (for pervasive
1513 : : identifiers).
1514 : : */
1515 : :
1516 : : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName);
1517 : :
1518 : : /*
1519 : : GetLocalSym - only searches the scope Sym for a symbol with name
1520 : : and returns the index to the symbol.
1521 : : */
1522 : :
1523 : : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name);
1524 : :
1525 : : /*
1526 : : GetRecord - fetches the record symbol from the parent of Sym.
1527 : : Sym maybe a varient symbol in which case its parent is searched
1528 : : etc.
1529 : : */
1530 : :
1531 : : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym);
1532 : :
1533 : : /*
1534 : : FromModuleGetSym - attempts to find a symbol of name, n, in the
1535 : : module, mod, scope. An unknown symbol is created
1536 : : at token position tok if necessary.
1537 : : */
1538 : :
1539 : : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod);
1540 : :
1541 : : /*
1542 : : GetNth - returns the n th symbol in the list associated with the scope
1543 : : of Sym. Sym may be a Module, DefImp, Procedure, Record or
1544 : : Enumeration symbol.
1545 : : */
1546 : :
1547 : : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n);
1548 : :
1549 : : /*
1550 : : GetNthParam - returns the n th parameter of a procedure Sym.
1551 : : */
1552 : :
1553 : : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, unsigned int ParamNo);
1554 : :
1555 : : /*
1556 : : GetVarScope - returns the symbol which is the scope of variable Sym.
1557 : : ie a Module, DefImp or Procedure Symbol.
1558 : : */
1559 : :
1560 : : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym);
1561 : :
1562 : : /*
1563 : : GetSubrange - returns HighSym and LowSym - two constants which make up the
1564 : : subrange.
1565 : : */
1566 : :
1567 : : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym);
1568 : :
1569 : : /*
1570 : : GetParam - returns the ParamNo parameter from procedure ProcSym
1571 : : */
1572 : :
1573 : : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo);
1574 : :
1575 : : /*
1576 : : GetString - returns the contents of the string symbol sym, note that
1577 : : this is not the same as GetName (unless it was a literal).
1578 : : */
1579 : :
1580 : : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym);
1581 : :
1582 : : /*
1583 : : GetStringLength - returns the length of the string symbol Sym.
1584 : : */
1585 : :
1586 : : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym);
1587 : :
1588 : : /*
1589 : : GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
1590 : : */
1591 : :
1592 : : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym);
1593 : :
1594 : : /*
1595 : : PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
1596 : : */
1597 : :
1598 : : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name);
1599 : :
1600 : : /*
1601 : : IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
1602 : : */
1603 : :
1604 : : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym);
1605 : :
1606 : : /*
1607 : : PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
1608 : : */
1609 : :
1610 : : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym);
1611 : : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym);
1612 : :
1613 : : /*
1614 : : PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
1615 : : sym, indicating that this block as an EXCEPT
1616 : : statement sequence.
1617 : : */
1618 : :
1619 : : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym);
1620 : :
1621 : : /*
1622 : : HasExceptionBlock - returns a BOOLEAN determining whether
1623 : : module/procedure/defimp, sym, has
1624 : : an EXCEPT statement sequence.
1625 : : */
1626 : :
1627 : : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym);
1628 : :
1629 : : /*
1630 : : PutExceptionFinally - sets a BOOLEAN in block module/defimp,
1631 : : sym, indicating that this FINALLY block
1632 : : as an EXCEPT statement sequence.
1633 : : */
1634 : :
1635 : : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym);
1636 : :
1637 : : /*
1638 : : HasExceptionFinally - returns a BOOLEAN determining whether
1639 : : module/defimp, sym, has
1640 : : an EXCEPT statement sequence.
1641 : : */
1642 : :
1643 : : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym);
1644 : :
1645 : : /*
1646 : : PutVar - gives the VarSym symbol Sym a type Type.
1647 : : */
1648 : :
1649 : : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType);
1650 : :
1651 : : /*
1652 : : PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
1653 : : The variable must be a LeftValue.
1654 : : */
1655 : :
1656 : : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType);
1657 : :
1658 : : /*
1659 : : GetVarBackEndType - returns the back end type if specified.
1660 : : */
1661 : :
1662 : : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym);
1663 : :
1664 : : /*
1665 : : PutVarPointerCheck - marks variable, sym, as requiring (or not
1666 : : depending upon the, value), a NIL pointer check
1667 : : when this symbol is dereferenced.
1668 : : */
1669 : :
1670 : : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value);
1671 : :
1672 : : /*
1673 : : GetVarPointerCheck - returns TRUE if this symbol is a variable and
1674 : : has been marked as needing a pointer via NIL check.
1675 : : */
1676 : :
1677 : : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym);
1678 : :
1679 : : /*
1680 : : PutVarWritten - marks variable, sym, as being written to (or not
1681 : : depending upon the, value).
1682 : : */
1683 : :
1684 : : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value);
1685 : :
1686 : : /*
1687 : : GetVarWritten - returns TRUE if this symbol is a variable and
1688 : : has been marked as being written.
1689 : : */
1690 : :
1691 : : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym);
1692 : :
1693 : : /*
1694 : : PutConst - gives the constant symbol Sym a type ConstType.
1695 : : */
1696 : :
1697 : : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType);
1698 : :
1699 : : /*
1700 : : PutConstSet - informs the const var symbol, sym, that it is or will contain
1701 : : a set value.
1702 : : */
1703 : :
1704 : : extern "C" void SymbolTable_PutConstSet (unsigned int Sym);
1705 : :
1706 : : /*
1707 : : IsConstSet - returns TRUE if the constant is declared as a set.
1708 : : */
1709 : :
1710 : : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym);
1711 : :
1712 : : /*
1713 : : PutConstructor - informs the const var symbol, sym, that it is or
1714 : : will contain a constructor (record, set or array)
1715 : : value.
1716 : : */
1717 : :
1718 : : extern "C" void SymbolTable_PutConstructor (unsigned int Sym);
1719 : :
1720 : : /*
1721 : : PutConstructorFrom - sets the from type field in constructor,
1722 : : Sym, to, from.
1723 : : */
1724 : :
1725 : : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from);
1726 : :
1727 : : /*
1728 : : PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
1729 : : VarSym is a optional varient symbol which can be returned
1730 : : by a call to GetVarient(fieldsymbol). The created field
1731 : : is returned.
1732 : : */
1733 : :
1734 : : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym);
1735 : :
1736 : : /*
1737 : : PutFieldVarient - places the field varient, Field, as a brother to, the
1738 : : varient symbol, sym, and also tells Field that its varient
1739 : : parent is Sym.
1740 : : */
1741 : :
1742 : : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym);
1743 : :
1744 : : /*
1745 : : GetVarient - returns the varient symbol associated with the
1746 : : record or varient field symbol, Field.
1747 : : */
1748 : :
1749 : : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field);
1750 : :
1751 : : /*
1752 : : IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
1753 : : a varient tag.
1754 : : */
1755 : :
1756 : : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym);
1757 : :
1758 : : /*
1759 : : IsEmptyFieldVarient - returns TRUE if the field variant has
1760 : : no fields. This will occur then the
1761 : : compiler constructs 'else end' variants.
1762 : : */
1763 : :
1764 : : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym);
1765 : :
1766 : : /*
1767 : : GetVarientTag - returns the varient tag from, Sym.
1768 : : */
1769 : :
1770 : : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym);
1771 : :
1772 : : /*
1773 : : PutVarientTag - places, Tag, into varient, Sym.
1774 : : */
1775 : :
1776 : : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag);
1777 : :
1778 : : /*
1779 : : PutFieldEnumeration - places a field into the enumeration type
1780 : : Sym. The field has a name FieldName and a
1781 : : value FieldVal.
1782 : : */
1783 : :
1784 : : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName);
1785 : :
1786 : : /*
1787 : : PutSubrange - places LowSym and HighSym as two symbols
1788 : : which provide the limits of the range.
1789 : : */
1790 : :
1791 : : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol);
1792 : :
1793 : : /*
1794 : : PutSet - places SimpleType as the type for set, Sym.
1795 : : */
1796 : :
1797 : : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed);
1798 : :
1799 : : /*
1800 : : IsSetPacked - returns TRUE if Sym is packed.
1801 : : */
1802 : :
1803 : : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym);
1804 : :
1805 : : /*
1806 : : GetArraySubscript - returns the subscript symbol for array, Sym.
1807 : : */
1808 : :
1809 : : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym);
1810 : :
1811 : : /*
1812 : : PutArraySubscript - places an index field into the array Sym. The
1813 : : index field is a subscript sym.
1814 : : */
1815 : :
1816 : : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol);
1817 : :
1818 : : /*
1819 : : PutType - gives a type symbol Sym type TypeSymbol.
1820 : : */
1821 : :
1822 : : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol);
1823 : :
1824 : : /*
1825 : : PutFunction - Places a TypeSym as the return type to a procedure Sym.
1826 : : */
1827 : :
1828 : : extern "C" void SymbolTable_PutFunction (unsigned int Sym, unsigned int TypeSym);
1829 : :
1830 : : /*
1831 : : PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
1832 : : */
1833 : :
1834 : : extern "C" void SymbolTable_PutOptFunction (unsigned int Sym, unsigned int TypeSym);
1835 : :
1836 : : /*
1837 : : IsReturnOptional - returns TRUE if the return value for, sym, is
1838 : : optional.
1839 : : */
1840 : :
1841 : : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym);
1842 : :
1843 : : /*
1844 : : PutParam - Places a Non VAR parameter ParamName with type ParamType into
1845 : : procedure Sym. The parameter number is ParamNo.
1846 : : If the procedure Sym already has this parameter then
1847 : : the parameter is checked for consistancy and the
1848 : : consistancy test is returned.
1849 : : */
1850 : :
1851 : : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded);
1852 : :
1853 : : /*
1854 : : PutVarParam - Places a Non VAR parameter ParamName with type
1855 : : ParamType into procedure Sym.
1856 : : The parameter number is ParamNo.
1857 : : If the procedure Sym already has this parameter then
1858 : : the parameter is checked for consistancy and the
1859 : : consistancy test is returned.
1860 : : */
1861 : :
1862 : : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded);
1863 : :
1864 : : /*
1865 : : PutParamName - assigns a name, name, to paramater, no, of procedure,
1866 : : ProcSym.
1867 : : */
1868 : :
1869 : : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, unsigned int no, NameKey_Name name);
1870 : :
1871 : : /*
1872 : : PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
1873 : : main Module.
1874 : : */
1875 : :
1876 : : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym);
1877 : :
1878 : : /*
1879 : : IsProcedureReachable - Returns true if the procedure, Sym, is
1880 : : reachable from the main Module.
1881 : : */
1882 : :
1883 : : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym);
1884 : :
1885 : : /*
1886 : : PutProcedureNoReturn - places value into the no return attribute
1887 : : field of procedure sym.
1888 : : */
1889 : :
1890 : : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, bool value);
1891 : :
1892 : : /*
1893 : : IsProcedureNoReturn - returns TRUE if this procedure never returns.
1894 : : */
1895 : :
1896 : : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym);
1897 : :
1898 : : /*
1899 : : PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
1900 : : QuadNumber is the start quad of Module,
1901 : : Sym.
1902 : : */
1903 : :
1904 : : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber);
1905 : :
1906 : : /*
1907 : : PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
1908 : : QuadNumber is the end quad of Module,
1909 : : Sym.
1910 : : */
1911 : :
1912 : : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber);
1913 : :
1914 : : /*
1915 : : PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
1916 : : QuadNumber is the finally start quad of
1917 : : Module, Sym.
1918 : : */
1919 : :
1920 : : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber);
1921 : :
1922 : : /*
1923 : : PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
1924 : : QuadNumber is the end quad of the finally block
1925 : : in Module, Sym.
1926 : : */
1927 : :
1928 : : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber);
1929 : :
1930 : : /*
1931 : : GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
1932 : : Quads of a Module, Sym.
1933 : : Start and End represent the initialization code
1934 : : of the Module, Sym.
1935 : : */
1936 : :
1937 : : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish);
1938 : :
1939 : : /*
1940 : : PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
1941 : : */
1942 : :
1943 : : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, m2tree_Tree finally);
1944 : :
1945 : : /*
1946 : : GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
1947 : : */
1948 : :
1949 : : extern "C" m2tree_Tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym);
1950 : :
1951 : : /*
1952 : : PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
1953 : : QuadNumber is the start quad of scope for procedure,
1954 : : Sym.
1955 : : */
1956 : :
1957 : : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber);
1958 : :
1959 : : /*
1960 : : PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
1961 : : QuadNumber is the start quad of procedure,
1962 : : Sym.
1963 : : */
1964 : :
1965 : : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber);
1966 : :
1967 : : /*
1968 : : PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
1969 : : QuadNumber is the end quad of procedure,
1970 : : Sym.
1971 : : */
1972 : :
1973 : : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber);
1974 : :
1975 : : /*
1976 : : GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
1977 : : */
1978 : :
1979 : : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end);
1980 : :
1981 : : /*
1982 : : GetQuads - assigns Start and End to the beginning and end of
1983 : : symbol, Sym, usage.
1984 : : */
1985 : :
1986 : : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
1987 : :
1988 : : /*
1989 : : GetReadQuads - assigns Start and End to the beginning and end of
1990 : : symbol, Sym, read history usage.
1991 : : */
1992 : :
1993 : : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
1994 : :
1995 : : /*
1996 : : GetWriteQuads - assigns Start and End to the beginning and end of
1997 : : symbol, Sym, usage.
1998 : : */
1999 : :
2000 : : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2001 : :
2002 : : /*
2003 : : PutReadQuad - places Quad into the list of symbol usage.
2004 : : */
2005 : :
2006 : : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2007 : :
2008 : : /*
2009 : : RemoveReadQuad - places Quad into the list of symbol usage.
2010 : : */
2011 : :
2012 : : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2013 : :
2014 : : /*
2015 : : PutWriteQuad - places Quad into the list of symbol usage.
2016 : : */
2017 : :
2018 : : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2019 : :
2020 : : /*
2021 : : RemoveWriteQuad - places Quad into the list of symbol usage.
2022 : : */
2023 : :
2024 : : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2025 : :
2026 : : /*
2027 : : GetReadLimitQuads - returns Start and End which have been assigned
2028 : : the start and end of when the symbol was read
2029 : : to within: StartLimit..EndLimit.
2030 : : */
2031 : :
2032 : : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2033 : :
2034 : : /*
2035 : : GetWriteLimitQuads - returns Start and End which have been assigned
2036 : : the start and end of when the symbol was written
2037 : : to within: StartLimit..EndLimit.
2038 : : */
2039 : :
2040 : : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2041 : :
2042 : : /*
2043 : : GetNthProcedure - Returns the Nth procedure in Module, Sym.
2044 : : */
2045 : :
2046 : : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n);
2047 : :
2048 : : /*
2049 : : GetDeclaredDef - returns the tokenno where the symbol was declared.
2050 : : The priority of declaration is definition, implementation
2051 : : and program module.
2052 : : */
2053 : :
2054 : : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym);
2055 : :
2056 : : /*
2057 : : GetDeclaredMod - returns the tokenno where the symbol was declared.
2058 : : The priority of declaration is program,
2059 : : implementation and definition module.
2060 : : */
2061 : :
2062 : : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym);
2063 : :
2064 : : /*
2065 : : GetDeclaredDefinition - returns the token where this symbol
2066 : : was declared in the definition module.
2067 : : */
2068 : :
2069 : : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym);
2070 : :
2071 : : /*
2072 : : GetDeclaredModule - returns the token where this symbol was declared
2073 : : in an implementation or program module.
2074 : : */
2075 : :
2076 : : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym);
2077 : :
2078 : : /*
2079 : : PutDeclared - adds an entry to symbol, Sym, indicating that it
2080 : : was declared at, tok. This routine
2081 : : may be called twice, once for definition module
2082 : : partial declaration and once when parsing the
2083 : : implementation module.
2084 : : */
2085 : :
2086 : : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym);
2087 : :
2088 : : /*
2089 : : GetFirstUsed - returns the token where this symbol was first used.
2090 : : */
2091 : :
2092 : : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym);
2093 : :
2094 : : /*
2095 : : PutProcedureBegin - assigns begin as the token number matching the
2096 : : procedure BEGIN.
2097 : : */
2098 : :
2099 : : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin);
2100 : :
2101 : : /*
2102 : : PutProcedureEnd - assigns end as the token number matching the
2103 : : procedure END.
2104 : : */
2105 : :
2106 : : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end);
2107 : :
2108 : : /*
2109 : : GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
2110 : : */
2111 : :
2112 : : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end);
2113 : :
2114 : : /*
2115 : : ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
2116 : : */
2117 : :
2118 : : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P);
2119 : :
2120 : : /*
2121 : : ForeachModuleDo - for each module do procedure, P.
2122 : : */
2123 : :
2124 : : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P);
2125 : :
2126 : : /*
2127 : : ForeachInnerModuleDo - for each inner module in module, Sym,
2128 : : do procedure, P.
2129 : : */
2130 : :
2131 : : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P);
2132 : :
2133 : : /*
2134 : : IsVarParam - Returns a conditional depending whether parameter ParamNo
2135 : : is a VAR parameter.
2136 : : */
2137 : :
2138 : : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, unsigned int ParamNo);
2139 : :
2140 : : /*
2141 : : IsUnboundedParam - Returns a conditional depending whether parameter
2142 : : ParamNo is an unbounded array procedure parameter.
2143 : : */
2144 : :
2145 : : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, unsigned int ParamNo);
2146 : :
2147 : : /*
2148 : : IsParameterUnbounded - returns TRUE if parameter, Sym, is
2149 : : unbounded.
2150 : : */
2151 : :
2152 : : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym);
2153 : :
2154 : : /*
2155 : : IsParameterVar - returns true if parameter symbol Sym
2156 : : was declared as a VAR.
2157 : : */
2158 : :
2159 : : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym);
2160 : :
2161 : : /*
2162 : : GetParameterShadowVar - returns the local variable associated with the
2163 : : parameter symbol, sym.
2164 : : */
2165 : :
2166 : : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym);
2167 : :
2168 : : /*
2169 : : NoOfParam - Returns the number of parameters that procedure Sym contains.
2170 : : */
2171 : :
2172 : : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym);
2173 : :
2174 : : /*
2175 : : HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
2176 : : */
2177 : :
2178 : : extern "C" bool SymbolTable_HasVarParameters (unsigned int p);
2179 : :
2180 : : /*
2181 : : NoOfLocalVar - returns the number of local variables that exist in
2182 : : procedure Sym. Parameters are NOT included in the
2183 : : count.
2184 : : */
2185 : :
2186 : : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym);
2187 : :
2188 : : /*
2189 : : IsDefImp - returns true is the Sym is a DefImp symbol.
2190 : : Definition/Implementation module symbol.
2191 : : */
2192 : :
2193 : : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym);
2194 : :
2195 : : /*
2196 : : IsModule - returns true is the Sym is a Module symbol.
2197 : : Program module symbol.
2198 : : */
2199 : :
2200 : : extern "C" bool SymbolTable_IsModule (unsigned int Sym);
2201 : :
2202 : : /*
2203 : : IsInnerModule - returns true if the symbol, Sym, is an inner module.
2204 : : */
2205 : :
2206 : : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym);
2207 : :
2208 : : /*
2209 : : GetSymName - returns the symbol name.
2210 : : */
2211 : :
2212 : : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym);
2213 : :
2214 : : /*
2215 : : RenameSym - renames a symbol, Sym, with SymName.
2216 : : It also checks the unknown tree for a symbol
2217 : : with this new name. Must only be renamed in
2218 : : the same scope of being declared.
2219 : : */
2220 : :
2221 : : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName);
2222 : :
2223 : : /*
2224 : : IsUnknown - returns true is the symbol Sym is unknown.
2225 : : */
2226 : :
2227 : : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym);
2228 : :
2229 : : /*
2230 : : IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
2231 : : */
2232 : :
2233 : : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym);
2234 : :
2235 : : /*
2236 : : RequestSym - searches for a symbol with a name SymName in the
2237 : : current and previous scopes.
2238 : : If the symbol is found then it is returned
2239 : : else an unknown symbol is returned create at token
2240 : : position, tok.
2241 : : This procedure does search the base scope (for
2242 : : pervasive identifiers).
2243 : : */
2244 : :
2245 : : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName);
2246 : :
2247 : : /*
2248 : : PutImported - places a symbol, Sym, into the current main scope.
2249 : : */
2250 : :
2251 : : extern "C" void SymbolTable_PutImported (unsigned int Sym);
2252 : :
2253 : : /*
2254 : : PutIncluded - places a symbol, Sym, into the included list of the
2255 : : current module.
2256 : : Symbols that are placed in this list are indirectly declared
2257 : : by:
2258 : :
2259 : : IMPORT modulename ;
2260 : :
2261 : : modulename.identifier
2262 : : */
2263 : :
2264 : : extern "C" void SymbolTable_PutIncluded (unsigned int Sym);
2265 : :
2266 : : /*
2267 : : PutExported - places a symbol, Sym into the next level out module.
2268 : : Sym is also placed in the ExportTree of the current inner
2269 : : module.
2270 : : */
2271 : :
2272 : : extern "C" void SymbolTable_PutExported (unsigned int Sym);
2273 : :
2274 : : /*
2275 : : PutExportQualified - places a symbol with the name, SymName,
2276 : : into the export tree of the
2277 : : Definition module being compiled.
2278 : : The symbol with name has been EXPORT QUALIFIED
2279 : : by the definition module and therefore any reference
2280 : : to this symbol in the code generation phase
2281 : : will be in the form _Module_Name.
2282 : : */
2283 : :
2284 : : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName);
2285 : :
2286 : : /*
2287 : : PutExportUnQualified - places a symbol with the name, SymName,
2288 : : into the export tree of the
2289 : : Definition module being compiled.
2290 : : The symbol with Name has been EXPORT UNQUALIFIED
2291 : : by the definition module and therefore any reference
2292 : : to this symbol in the code generation phase
2293 : : will be in the form _Name.
2294 : : */
2295 : :
2296 : : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName);
2297 : :
2298 : : /*
2299 : : PutExportUnImplemented - places a symbol, Sym, into the currently compiled
2300 : : DefImp module NeedToBeImplemented list.
2301 : : */
2302 : :
2303 : : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym);
2304 : :
2305 : : /*
2306 : : GetExported - returns the symbol which has a name SymName,
2307 : : and is exported from the definition module ModSym.
2308 : :
2309 : : */
2310 : :
2311 : : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName);
2312 : :
2313 : : /*
2314 : : GetFromOuterModule - returns a symbol with name, SymName, which comes
2315 : : from outside the current module.
2316 : : */
2317 : :
2318 : : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName);
2319 : :
2320 : : /*
2321 : : TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
2322 : : name, name, which is
2323 : : currently undefined in the
2324 : : outer scope to the inner scope.
2325 : : If successful then the symbol is
2326 : : returned otherwise NulSym is
2327 : : returned.
2328 : : */
2329 : :
2330 : : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name);
2331 : :
2332 : : /*
2333 : : IsExportQualified - returns true if a symbol, Sym, was defined as
2334 : : being EXPORT QUALIFIED.
2335 : : Sym is expected to be either a procedure or a
2336 : : variable.
2337 : : */
2338 : :
2339 : : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym);
2340 : :
2341 : : /*
2342 : : IsExportUnQualified - returns true if a symbol, Sym, was defined as
2343 : : being EXPORT UNQUALIFIED.
2344 : : */
2345 : :
2346 : : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym);
2347 : :
2348 : : /*
2349 : : IsExported - returns true if a symbol, Sym, is exported
2350 : : from module, ModSym.
2351 : : If ModSym is a DefImp symbol then its
2352 : : ExportQualified and ExportUnQualified lists are examined.
2353 : : */
2354 : :
2355 : : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym);
2356 : :
2357 : : /*
2358 : : IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
2359 : : ModSym must be a defimp symbol.
2360 : : */
2361 : :
2362 : : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym);
2363 : :
2364 : : /*
2365 : : IsImported - returns true if a symbol, Sym, in module, ModSym,
2366 : : was imported.
2367 : : */
2368 : :
2369 : : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym);
2370 : :
2371 : : /*
2372 : : PutIncludedByDefinition - places a module symbol, Sym, into the
2373 : : included list of the current definition module.
2374 : : */
2375 : :
2376 : : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym);
2377 : :
2378 : : /*
2379 : : IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
2380 : : by ModSym's definition module.
2381 : : */
2382 : :
2383 : : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym);
2384 : :
2385 : : /*
2386 : : ForeachImportedDo - calls a procedure, P, foreach imported symbol
2387 : : in module, ModSym.
2388 : : */
2389 : :
2390 : : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2391 : :
2392 : : /*
2393 : : ForeachExportedDo - calls a procedure, P, foreach imported symbol
2394 : : in module, ModSym.
2395 : : */
2396 : :
2397 : : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2398 : :
2399 : : /*
2400 : : CheckForExportedImplementation - checks to see whether an implementation
2401 : : module is currently being compiled, if so,
2402 : : symbol, Sym, is removed from the
2403 : : NeedToBeImplemented list.
2404 : : This procedure is called whenever a symbol
2405 : : is declared, thus attempting to reduce
2406 : : the NeedToBeImplemented list.
2407 : : Only needs to be called when a TYPE or
2408 : : PROCEDURE is built since the implementation
2409 : : module can only implement these objects
2410 : : declared in the definition module.
2411 : :
2412 : : It also checks whether a definition module
2413 : : is currently being compiled and, if so,
2414 : : it will ensure that symbol, Sym, is removed
2415 : : from the ExportRequest list. If Sym is an
2416 : : enumerated type it ensures that its fields
2417 : : are also removed.
2418 : : */
2419 : :
2420 : : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym);
2421 : :
2422 : : /*
2423 : : CheckForUnImplementedExports - displays an error and the offending symbols
2424 : : which have been exported but not implemented
2425 : : from the current compiled module.
2426 : : */
2427 : :
2428 : : extern "C" void SymbolTable_CheckForUnImplementedExports (void);
2429 : :
2430 : : /*
2431 : : CheckForUndeclaredExports - displays an error and the offending symbols
2432 : : which have been exported but not declared
2433 : : from module, ModSym.
2434 : : */
2435 : :
2436 : : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym);
2437 : :
2438 : : /*
2439 : : CheckForUnknownInModule - checks for any unknown symbols in the
2440 : : current module.
2441 : : If any unknown symbols are found then
2442 : : an error message is displayed.
2443 : : */
2444 : :
2445 : : extern "C" void SymbolTable_CheckForUnknownInModule (void);
2446 : :
2447 : : /*
2448 : : UnknownReported - if sym is an unknown symbol and has not been reported
2449 : : then include it into the set of reported unknowns.
2450 : : */
2451 : :
2452 : : extern "C" void SymbolTable_UnknownReported (unsigned int sym);
2453 : :
2454 : : /*
2455 : : IsReallyPointer - returns TRUE is sym is a pointer, address or a
2456 : : type declared as a pointer or address.
2457 : : */
2458 : :
2459 : : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym);
2460 : :
2461 : : /*
2462 : : CheckHiddenTypeAreAddress - checks to see that any hidden types
2463 : : which we have declared are actually
2464 : : of type ADDRESS or map onto a POINTER type.
2465 : : */
2466 : :
2467 : : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void);
2468 : :
2469 : : /*
2470 : : PutDefinitionForC - sets a flag in the current compiled module which
2471 : : indicates that this module is a wrapper for a C
2472 : : file. Parameters passes to procedures in this module
2473 : : will adopt the C calling convention.
2474 : : */
2475 : :
2476 : : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym);
2477 : :
2478 : : /*
2479 : : IsDefinitionForC - returns true if this definition module was declared
2480 : : as a DEFINITION MODULE FOR "C".
2481 : : */
2482 : :
2483 : : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym);
2484 : :
2485 : : /*
2486 : : PutDoesNeedExportList - sets a flag in module, Sym, which
2487 : : indicates that this module requires an explicit
2488 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
2489 : : */
2490 : :
2491 : : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym);
2492 : :
2493 : : /*
2494 : : PutDoesNotNeedExportList - sets a flag in module, Sym, which
2495 : : indicates that this module does not require an explicit
2496 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
2497 : : */
2498 : :
2499 : : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym);
2500 : :
2501 : : /*
2502 : : DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
2503 : : EXPORT QUALIFIED list.
2504 : : */
2505 : :
2506 : : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym);
2507 : :
2508 : : /*
2509 : : CheckForEnumerationInCurrentModule - checks to see whether the enumeration
2510 : : type symbol, Sym, has been entered into
2511 : : the current modules scope list.
2512 : : */
2513 : :
2514 : : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym);
2515 : :
2516 : : /*
2517 : : SanityCheckConstants - must only be called once all constants, types, procedures
2518 : : have been declared. It checks to see that constants are
2519 : : not used as procedure parameter types.
2520 : : */
2521 : :
2522 : : extern "C" void SymbolTable_SanityCheckConstants (void);
2523 : :
2524 : : /*
2525 : : ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
2526 : : perform the procedure, P.
2527 : : */
2528 : :
2529 : : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2530 : :
2531 : : /*
2532 : : ForeachParamSymDo - foreach parameter symbol in procedure, Sym,
2533 : : perform the procedure, P. Each symbol
2534 : : looked up will be VarParam or Param
2535 : : (not the shadow variable).
2536 : : */
2537 : :
2538 : : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2539 : :
2540 : : /*
2541 : : ForeachFieldEnumerationDo - for each field in enumeration, Sym,
2542 : : do procedure, P. Each call to P contains
2543 : : an enumeration field, the order is alphabetical.
2544 : : Use ForeachLocalSymDo for declaration order.
2545 : : */
2546 : :
2547 : : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P);
2548 : :
2549 : : /*
2550 : : IsType - returns true if the Sym is a type symbol.
2551 : : */
2552 : :
2553 : : extern "C" bool SymbolTable_IsType (unsigned int Sym);
2554 : :
2555 : : /*
2556 : : IsProcedure - returns true if Sym is a procedure symbol.
2557 : : */
2558 : :
2559 : : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym);
2560 : :
2561 : : /*
2562 : : IsParameter - returns true if Sym is a parameter symbol.
2563 : : */
2564 : :
2565 : : extern "C" bool SymbolTable_IsParameter (unsigned int Sym);
2566 : :
2567 : : /*
2568 : : ProcedureParametersDefined - dictates to procedure symbol, Sym,
2569 : : that its parameters have been defined.
2570 : : */
2571 : :
2572 : : extern "C" void SymbolTable_ProcedureParametersDefined (unsigned int Sym);
2573 : :
2574 : : /*
2575 : : AreProcedureParametersDefined - returns true if the parameters to procedure
2576 : : symbol, Sym, have been defined.
2577 : : */
2578 : :
2579 : : extern "C" bool SymbolTable_AreProcedureParametersDefined (unsigned int Sym);
2580 : :
2581 : : /*
2582 : : ParametersDefinedInDefinition - dictates to procedure symbol, Sym,
2583 : : that its parameters have been defined in
2584 : : a definition module.
2585 : : */
2586 : :
2587 : : extern "C" void SymbolTable_ParametersDefinedInDefinition (unsigned int Sym);
2588 : :
2589 : : /*
2590 : : AreParametersDefinedInDefinition - returns true if procedure symbol, Sym,
2591 : : has had its parameters been defined in
2592 : : a definition module.
2593 : : */
2594 : :
2595 : : extern "C" bool SymbolTable_AreParametersDefinedInDefinition (unsigned int Sym);
2596 : :
2597 : : /*
2598 : : ParametersDefinedInImplementation - dictates to procedure symbol, Sym,
2599 : : that its parameters have been defined in
2600 : : a implemtation module.
2601 : : */
2602 : :
2603 : : extern "C" void SymbolTable_ParametersDefinedInImplementation (unsigned int Sym);
2604 : :
2605 : : /*
2606 : : AreParametersDefinedInImplementation - returns true if procedure symbol, Sym,
2607 : : has had its parameters been defined in
2608 : : an implementation module.
2609 : : */
2610 : :
2611 : : extern "C" bool SymbolTable_AreParametersDefinedInImplementation (unsigned int Sym);
2612 : :
2613 : : /*
2614 : : PutUseVarArgs - tell the symbol table that this procedure, Sym,
2615 : : uses varargs.
2616 : : The procedure _must_ be declared inside a
2617 : : DEFINITION FOR "C"
2618 : :
2619 : : */
2620 : :
2621 : : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym);
2622 : :
2623 : : /*
2624 : : UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
2625 : : The procedure _must_ be declared inside a
2626 : : DEFINITION FOR "C"
2627 : : */
2628 : :
2629 : : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym);
2630 : :
2631 : : /*
2632 : : PutUseOptArg - tell the symbol table that this procedure, Sym,
2633 : : uses an optarg.
2634 : : */
2635 : :
2636 : : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym);
2637 : :
2638 : : /*
2639 : : UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
2640 : : */
2641 : :
2642 : : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym);
2643 : :
2644 : : /*
2645 : : PutOptArgInit - makes symbol, Sym, the initializer value to
2646 : : procedure, ProcSym.
2647 : : */
2648 : :
2649 : : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym);
2650 : :
2651 : : /*
2652 : : GetOptArgInit - returns the initializer value to the optional parameter in
2653 : : procedure, ProcSym.
2654 : : */
2655 : :
2656 : : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym);
2657 : :
2658 : : /*
2659 : : MakePointer - returns a pointer symbol with PointerName.
2660 : : */
2661 : :
2662 : : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName);
2663 : :
2664 : : /*
2665 : : PutPointer - gives a pointer symbol a type, PointerType.
2666 : : */
2667 : :
2668 : : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType);
2669 : :
2670 : : /*
2671 : : IsPointer - returns true is Sym is a pointer type symbol.
2672 : : */
2673 : :
2674 : : extern "C" bool SymbolTable_IsPointer (unsigned int Sym);
2675 : :
2676 : : /*
2677 : : IsRecord - returns true is Sym is a record type symbol.
2678 : : */
2679 : :
2680 : : extern "C" bool SymbolTable_IsRecord (unsigned int Sym);
2681 : :
2682 : : /*
2683 : : IsVarient - returns true if the symbol, Sym, is a
2684 : : varient symbol.
2685 : : */
2686 : :
2687 : : extern "C" bool SymbolTable_IsVarient (unsigned int Sym);
2688 : :
2689 : : /*
2690 : : IsFieldVarient - returns true if the symbol, Sym, is a
2691 : : varient field.
2692 : : */
2693 : :
2694 : : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym);
2695 : :
2696 : : /*
2697 : : IsFieldEnumeration - returns true if the symbol, Sym, is an
2698 : : enumeration field.
2699 : : */
2700 : :
2701 : : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym);
2702 : :
2703 : : /*
2704 : : IsArray - returns true is Sym is an array type symbol.
2705 : : */
2706 : :
2707 : : extern "C" bool SymbolTable_IsArray (unsigned int Sym);
2708 : :
2709 : : /*
2710 : : IsEnumeration - returns true if Sym is an enumeration symbol.
2711 : : */
2712 : :
2713 : : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym);
2714 : :
2715 : : /*
2716 : : IsSet - returns TRUE if Sym is a set symbol.
2717 : : */
2718 : :
2719 : : extern "C" bool SymbolTable_IsSet (unsigned int Sym);
2720 : :
2721 : : /*
2722 : : IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
2723 : : */
2724 : :
2725 : : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym);
2726 : :
2727 : : /*
2728 : : IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
2729 : : */
2730 : :
2731 : : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym);
2732 : :
2733 : : /*
2734 : : GetDimension - return the number of dimensions associated with
2735 : : this unbounded ARRAY parameter.
2736 : : */
2737 : :
2738 : : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym);
2739 : :
2740 : : /*
2741 : : MakeOAFamily - makes an OAFamily symbol based on SimpleType.
2742 : : It returns the OAFamily symbol. A new symbol
2743 : : is created if one does not already exist for
2744 : : SimpleType.
2745 : : */
2746 : :
2747 : : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType);
2748 : :
2749 : : /*
2750 : : GetOAFamily - returns the oafamily symbol associated with
2751 : : SimpleType.
2752 : : */
2753 : :
2754 : : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType);
2755 : :
2756 : : /*
2757 : : ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
2758 : : sym, in the oaf.
2759 : : */
2760 : :
2761 : : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p);
2762 : :
2763 : : /*
2764 : : IsUnbounded - returns true if Sym is an unbounded symbol.
2765 : : */
2766 : :
2767 : : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym);
2768 : :
2769 : : /*
2770 : : GetUnbounded - returns the unbounded symbol associated with
2771 : : the OAFamily symbol, oaf, and the number of
2772 : : dimensions, ndim, of the open array.
2773 : : */
2774 : :
2775 : : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim);
2776 : :
2777 : : /*
2778 : : GetUnboundedRecordType - returns the record type used to
2779 : : implement the unbounded array.
2780 : : */
2781 : :
2782 : : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym);
2783 : :
2784 : : /*
2785 : : GetUnboundedAddressOffset - returns the offset of the address field
2786 : : inside the record used to implement the
2787 : : unbounded type.
2788 : : */
2789 : :
2790 : : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym);
2791 : :
2792 : : /*
2793 : : GetUnboundedHighOffset - returns the offset of the high field
2794 : : inside the record used to implement the
2795 : : unbounded type.
2796 : : */
2797 : :
2798 : : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim);
2799 : :
2800 : : /*
2801 : : MakeSubscript - makes a subscript Symbol.
2802 : : No name is required.
2803 : : */
2804 : :
2805 : : extern "C" unsigned int SymbolTable_MakeSubscript (void);
2806 : :
2807 : : /*
2808 : : PutSubscript - gives a subscript symbol a type, SimpleType.
2809 : : */
2810 : :
2811 : : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType);
2812 : :
2813 : : /*
2814 : : MakeUnbounded - makes an unbounded array Symbol.
2815 : : ndim is the number of dimensions required.
2816 : : No name is required.
2817 : : */
2818 : :
2819 : : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim);
2820 : :
2821 : : /*
2822 : : NoOfElements - Returns the number of elements in array Sym,
2823 : : or the number of elements in an enumeration Sym or
2824 : : the number of interface symbols in an Interface list.
2825 : : */
2826 : :
2827 : : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym);
2828 : :
2829 : : /*
2830 : : PutArray - places a type symbol into an Array.
2831 : : */
2832 : :
2833 : : extern "C" void SymbolTable_PutArray (unsigned int Sym, unsigned int TypeSymbol);
2834 : :
2835 : : /*
2836 : : ResolveImports - it examines the import list of all inner modules
2837 : : and resolves all relative imports.
2838 : : */
2839 : :
2840 : : extern "C" void SymbolTable_ResolveImports (void);
2841 : :
2842 : : /*
2843 : : ResolveConstructorTypes - to be called at the end of pass three. Its
2844 : : purpose is to fix up all constructors whose
2845 : : types are unknown.
2846 : : */
2847 : :
2848 : : extern "C" void SymbolTable_ResolveConstructorTypes (void);
2849 : :
2850 : : /*
2851 : : AddNameToScope - adds a Name, n, to the list of objects declared at the
2852 : : current scope.
2853 : : */
2854 : :
2855 : : extern "C" void SymbolTable_AddNameToScope (NameKey_Name n);
2856 : :
2857 : : /*
2858 : : AddNameToImportList - adds a Name, n, to the import list of the current
2859 : : module.
2860 : : */
2861 : :
2862 : : extern "C" void SymbolTable_AddNameToImportList (NameKey_Name n);
2863 : :
2864 : : /*
2865 : : GetScope - returns the declaration scope of the symbol.
2866 : : */
2867 : :
2868 : : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym);
2869 : :
2870 : : /*
2871 : : GetModuleScope - returns the module scope of symbol, sym.
2872 : : If sym was declared within a nested procedure
2873 : : then return the module which defines the
2874 : : procedure.
2875 : : */
2876 : :
2877 : : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym);
2878 : :
2879 : : /*
2880 : : GetProcedureScope - returns the innermost procedure (if any)
2881 : : in which the symbol, sym, resides.
2882 : : A module inside the procedure is skipped
2883 : : over.
2884 : : */
2885 : :
2886 : : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym);
2887 : :
2888 : : /*
2889 : : IsModuleWithinProcedure - returns TRUE if module, sym, is
2890 : : inside a procedure.
2891 : : */
2892 : :
2893 : : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym);
2894 : :
2895 : : /*
2896 : : GetParent - returns the parent of symbol, Sym.
2897 : : */
2898 : :
2899 : : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym);
2900 : :
2901 : : /*
2902 : : IsRecordField - returns true if Sym is a record field.
2903 : : */
2904 : :
2905 : : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym);
2906 : :
2907 : : /*
2908 : : MakeProcType - returns a procedure type symbol with ProcTypeName.
2909 : : */
2910 : :
2911 : : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName);
2912 : :
2913 : : /*
2914 : : PutProcTypeParam - Places a Non VAR parameter ParamName with type
2915 : : ParamType into ProcType Sym.
2916 : : */
2917 : :
2918 : : extern "C" void SymbolTable_PutProcTypeParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded);
2919 : :
2920 : : /*
2921 : : PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
2922 : : ParamType into ProcType Sym.
2923 : : */
2924 : :
2925 : : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded);
2926 : :
2927 : : /*
2928 : : IsProcType - returns true if Sym is a ProcType Symbol.
2929 : : */
2930 : :
2931 : : extern "C" bool SymbolTable_IsProcType (unsigned int Sym);
2932 : :
2933 : : /*
2934 : : IsVar - returns true if Sym is a Var Symbol.
2935 : : */
2936 : :
2937 : : extern "C" bool SymbolTable_IsVar (unsigned int Sym);
2938 : :
2939 : : /*
2940 : : IsVarConst - returns the IsConst field indicating the variable is read only.
2941 : : */
2942 : :
2943 : : extern "C" bool SymbolTable_IsVarConst (unsigned int sym);
2944 : :
2945 : : /*
2946 : : IsConst - returns true if Sym contains a constant value.
2947 : : */
2948 : :
2949 : : extern "C" bool SymbolTable_IsConst (unsigned int Sym);
2950 : :
2951 : : /*
2952 : : IsConstString - returns whether sym is a conststring of any variant.
2953 : : */
2954 : :
2955 : : extern "C" bool SymbolTable_IsConstString (unsigned int sym);
2956 : :
2957 : : /*
2958 : : IsConstStringNulTerminated - returns TRUE if the constant string, sym,
2959 : : should be created with a nul terminator.
2960 : : */
2961 : :
2962 : : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym);
2963 : :
2964 : : /*
2965 : : IsConstLit - returns true if Sym is a literal constant.
2966 : : */
2967 : :
2968 : : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym);
2969 : :
2970 : : /*
2971 : : IsConstructor - returns TRUE if the constant is declared as a
2972 : : constant set, array or record.
2973 : : */
2974 : :
2975 : : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym);
2976 : :
2977 : : /*
2978 : : IsDummy - returns true if Sym is a Dummy symbol.
2979 : : */
2980 : :
2981 : : extern "C" bool SymbolTable_IsDummy (unsigned int Sym);
2982 : :
2983 : : /*
2984 : : IsTemporary - returns true if Sym is a Temporary symbol.
2985 : : */
2986 : :
2987 : : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym);
2988 : :
2989 : : /*
2990 : : IsVarAParam - returns true if Sym is a variable declared as a parameter.
2991 : : */
2992 : :
2993 : : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym);
2994 : :
2995 : : /*
2996 : : IsSubscript - returns true if Sym is a subscript symbol.
2997 : : */
2998 : :
2999 : : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym);
3000 : :
3001 : : /*
3002 : : IsSubrange - returns true if Sym is a subrange symbol.
3003 : : */
3004 : :
3005 : : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym);
3006 : :
3007 : : /*
3008 : : IsProcedureVariable - returns true if a Sym is a variable and
3009 : : it was declared within a procedure.
3010 : : */
3011 : :
3012 : : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym);
3013 : :
3014 : : /*
3015 : : IsProcedureNested - returns TRUE if procedure, Sym, was
3016 : : declared as a nested procedure.
3017 : : */
3018 : :
3019 : : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym);
3020 : :
3021 : : /*
3022 : : IsAModula2Type - returns true if Sym, is a:
3023 : : IsType, IsPointer, IsRecord, IsEnumeration,
3024 : : IsSubrange, IsArray, IsUnbounded, IsProcType.
3025 : : NOTE that it different from IsType.
3026 : : */
3027 : :
3028 : : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym);
3029 : :
3030 : : /*
3031 : : IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
3032 : : */
3033 : :
3034 : : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym);
3035 : :
3036 : : /*
3037 : : IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
3038 : : */
3039 : :
3040 : : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym);
3041 : :
3042 : : /*
3043 : : IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
3044 : : */
3045 : :
3046 : : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym);
3047 : :
3048 : : /*
3049 : : IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
3050 : : */
3051 : :
3052 : : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym);
3053 : :
3054 : : /*
3055 : : IsSizeSolved - returns true if the size of Sym is solved.
3056 : : */
3057 : :
3058 : : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym);
3059 : :
3060 : : /*
3061 : : IsOffsetSolved - returns true if the Offset of Sym is solved.
3062 : : */
3063 : :
3064 : : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym);
3065 : :
3066 : : /*
3067 : : IsValueSolved - returns true if the value of Sym is solved.
3068 : : */
3069 : :
3070 : : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym);
3071 : :
3072 : : /*
3073 : : IsConstructorConstant - returns TRUE if constructor, Sym, is
3074 : : defined by only constants.
3075 : : */
3076 : :
3077 : : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym);
3078 : :
3079 : : /*
3080 : : IsComposite - returns TRUE if symbol, sym, is a composite
3081 : : type: ie an ARRAY or RECORD.
3082 : : */
3083 : :
3084 : : extern "C" bool SymbolTable_IsComposite (unsigned int sym);
3085 : :
3086 : : /*
3087 : : IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
3088 : : */
3089 : :
3090 : : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym);
3091 : :
3092 : : /*
3093 : : PutAlignment - assigns the alignment constant associated with,
3094 : : type, with, align.
3095 : : */
3096 : :
3097 : : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align);
3098 : :
3099 : : /*
3100 : : GetAlignment - returns the alignment constant associated with,
3101 : : type.
3102 : : */
3103 : :
3104 : : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type);
3105 : :
3106 : : /*
3107 : : GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
3108 : : to record, sym.
3109 : : */
3110 : :
3111 : : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym);
3112 : :
3113 : : /*
3114 : : PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
3115 : : to record, sym.
3116 : : */
3117 : :
3118 : : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align);
3119 : :
3120 : : /*
3121 : : PutUnused - sets, sym, as unused. This is a gm2 pragma.
3122 : : */
3123 : :
3124 : : extern "C" void SymbolTable_PutUnused (unsigned int sym);
3125 : :
3126 : : /*
3127 : : IsUnused - returns TRUE if the symbol was declared as unused with a
3128 : : gm2 pragma.
3129 : : */
3130 : :
3131 : : extern "C" bool SymbolTable_IsUnused (unsigned int sym);
3132 : :
3133 : : /*
3134 : : PutDeclaredPacked - sets the Packed field of the record or record field symbol.
3135 : : */
3136 : :
3137 : : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b);
3138 : :
3139 : : /*
3140 : : IsDeclaredPacked - was the record symbol or record field, sym,
3141 : : declared as packed?
3142 : : */
3143 : :
3144 : : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym);
3145 : :
3146 : : /*
3147 : : IsDeclaredPackedResolved - do we know if the record symbol or record
3148 : : field, sym, declared as packed or not packed?
3149 : : */
3150 : :
3151 : : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym);
3152 : :
3153 : : /*
3154 : : GetPackedEquivalent - returns the packed equivalent of type, sym.
3155 : : sym must be a type, subrange or enumerated type.
3156 : : */
3157 : :
3158 : : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym);
3159 : :
3160 : : /*
3161 : : GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
3162 : : */
3163 : :
3164 : : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym);
3165 : :
3166 : : /*
3167 : : IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
3168 : : */
3169 : :
3170 : : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym);
3171 : :
3172 : : /*
3173 : : PushSize - pushes the size of Sym.
3174 : : */
3175 : :
3176 : : extern "C" void SymbolTable_PushSize (unsigned int Sym);
3177 : :
3178 : : /*
3179 : : PushOffset - pushes the Offset of Sym.
3180 : : */
3181 : :
3182 : : extern "C" void SymbolTable_PushOffset (unsigned int Sym);
3183 : :
3184 : : /*
3185 : : PushValue - pushes the Value of Sym onto the ALU stack.
3186 : : */
3187 : :
3188 : : extern "C" void SymbolTable_PushValue (unsigned int Sym);
3189 : :
3190 : : /*
3191 : : PushParamSize - push the size of parameter, ParamNo,
3192 : : of procedure Sym onto the ALU stack.
3193 : : */
3194 : :
3195 : : extern "C" void SymbolTable_PushParamSize (unsigned int Sym, unsigned int ParamNo);
3196 : :
3197 : : /*
3198 : : PushSumOfLocalVarSize - push the total size of all local variables
3199 : : onto the ALU stack.
3200 : : */
3201 : :
3202 : : extern "C" void SymbolTable_PushSumOfLocalVarSize (unsigned int Sym);
3203 : :
3204 : : /*
3205 : : PushSumOfParamSize - push the total size of all parameters onto
3206 : : the ALU stack.
3207 : : */
3208 : :
3209 : : extern "C" void SymbolTable_PushSumOfParamSize (unsigned int Sym);
3210 : :
3211 : : /*
3212 : : PushVarSize - pushes the size of a variable, Sym.
3213 : : The runtime size of Sym will depend upon its addressing mode,
3214 : : RightValue has size PushSize(GetType(Sym)) and
3215 : : LeftValue has size PushSize(Address) since it points to a
3216 : : variable.
3217 : : */
3218 : :
3219 : : extern "C" void SymbolTable_PushVarSize (unsigned int Sym);
3220 : :
3221 : : /*
3222 : : PopValue - pops the ALU stack into Value of Sym.
3223 : : */
3224 : :
3225 : : extern "C" void SymbolTable_PopValue (unsigned int Sym);
3226 : :
3227 : : /*
3228 : : PopSize - pops the ALU stack into Size of Sym.
3229 : : */
3230 : :
3231 : : extern "C" void SymbolTable_PopSize (unsigned int Sym);
3232 : :
3233 : : /*
3234 : : PopOffset - pops the ALU stack into Offset of Sym.
3235 : : */
3236 : :
3237 : : extern "C" void SymbolTable_PopOffset (unsigned int Sym);
3238 : :
3239 : : /*
3240 : : PopSumOfParamSize - pop the total value on the ALU stack as the
3241 : : sum of all parameters.
3242 : : */
3243 : :
3244 : : extern "C" void SymbolTable_PopSumOfParamSize (unsigned int Sym);
3245 : :
3246 : : /*
3247 : : IsObject - returns TRUE if the symbol is an object symbol.
3248 : : */
3249 : :
3250 : : extern "C" bool SymbolTable_IsObject (unsigned int Sym);
3251 : :
3252 : : /*
3253 : : IsTuple - returns TRUE if the symbol is a tuple symbol.
3254 : : */
3255 : :
3256 : : extern "C" bool SymbolTable_IsTuple (unsigned int Sym);
3257 : :
3258 : : /*
3259 : : Make2Tuple - creates and returns a 2 tuple from, a, and, b.
3260 : : */
3261 : :
3262 : : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b);
3263 : :
3264 : : /*
3265 : : MakeError - creates an error node, which can be used in MetaError messages.
3266 : : It will be removed from ExportUndeclared and Unknown trees.
3267 : : */
3268 : :
3269 : : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name);
3270 : :
3271 : : /*
3272 : : MakeErrorS - creates an error node from a string, which can be used
3273 : : in MetaError messages.
3274 : : It will be removed from ExportUndeclared and Unknown trees.
3275 : : */
3276 : :
3277 : : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name);
3278 : :
3279 : : /*
3280 : : IsError - returns TRUE if the symbol is an error symbol.
3281 : : */
3282 : :
3283 : : extern "C" bool SymbolTable_IsError (unsigned int Sym);
3284 : :
3285 : : /*
3286 : : IsLegal - returns TRUE if, sym, is a legal symbol.
3287 : : */
3288 : :
3289 : : extern "C" bool SymbolTable_IsLegal (unsigned int sym);
3290 : :
3291 : : /*
3292 : : PutModuleContainsBuiltin - sets a flag in the current compiled module which
3293 : : indicates that a builtin procedure is being declared.
3294 : : This is only expected to be called when we are
3295 : : parsing the definition module.
3296 : : */
3297 : :
3298 : : extern "C" void SymbolTable_PutModuleContainsBuiltin (void);
3299 : :
3300 : : /*
3301 : : IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
3302 : : */
3303 : :
3304 : : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym);
3305 : :
3306 : : /*
3307 : : PutHiddenTypeDeclared - sets a flag in the current compiled module which
3308 : : indicates that a Hidden Type is declared within
3309 : : the implementation part of the module.
3310 : : This procedure is expected to be called while
3311 : : compiling the associated definition module.
3312 : : */
3313 : :
3314 : : extern "C" void SymbolTable_PutHiddenTypeDeclared (void);
3315 : :
3316 : : /*
3317 : : IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
3318 : : the module, Sym.
3319 : : */
3320 : :
3321 : : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym);
3322 : :
3323 : : /*
3324 : : DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
3325 : : */
3326 : :
3327 : : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym);
3328 : :
3329 : : /*
3330 : : DebugLineNumbers - internal debugging, emit all procedure names in this module
3331 : : together with the line numbers for the corresponding begin/end
3332 : : tokens.
3333 : : */
3334 : :
3335 : : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym);
3336 : :
3337 : : /*
3338 : : GetErrorScope - returns the error scope for a symbol.
3339 : : The error scope is the title scope which is used to
3340 : : announce the symbol in the GCC error message.
3341 : : */
3342 : :
3343 : : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym);
3344 : :
3345 : : /*
3346 : : MakeImport - create and return an import symbol.
3347 : : moduleSym is the symbol being imported.
3348 : : isqualified is FALSE if it were IMPORT modulename and
3349 : : TRUE for the qualified FROM modulename IMPORT etc.
3350 : : listno is the import list count for this module.
3351 : : tok should match this modulename position.
3352 : : */
3353 : :
3354 : : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified);
3355 : :
3356 : : /*
3357 : : MakeImportStatement - return a dependent symbol which represents an import statement
3358 : : or a qualified import statement. The tok should either match
3359 : : the FROM token or the IMPORT token. listno is the import list
3360 : : count for the module.
3361 : : */
3362 : :
3363 : : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno);
3364 : :
3365 : : /*
3366 : : IsImport - returns TRUE if sym is an import symbol.
3367 : : */
3368 : :
3369 : : extern "C" bool SymbolTable_IsImport (unsigned int sym);
3370 : :
3371 : : /*
3372 : : IsImportStatement - returns TRUE if sym is a dependent symbol.
3373 : : */
3374 : :
3375 : : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym);
3376 : :
3377 : : /*
3378 : : GetImportModule - returns the module associated with the import symbol.
3379 : : */
3380 : :
3381 : : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym);
3382 : :
3383 : : /*
3384 : : GetImportDeclared - returns the token associated with the import symbol.
3385 : : */
3386 : :
3387 : : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym);
3388 : :
3389 : : /*
3390 : : GetImportStatementList - returns the list of imports for this dependent.
3391 : : Each import symbol corresponds to a module.
3392 : : */
3393 : :
3394 : : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym);
3395 : :
3396 : : /*
3397 : : GetModuleDefImportStatementList - returns the list of dependents associated with
3398 : : the definition module.
3399 : : */
3400 : :
3401 : : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym);
3402 : :
3403 : : /*
3404 : : GetModuleModImportStatementList - returns the list of dependents associated with
3405 : : the implementation or program module.
3406 : : */
3407 : :
3408 : : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym);
3409 : :
3410 : : /*
3411 : : AppendModuleImportStatement - appends the ImportStatement symbol onto the
3412 : : module import list.
3413 : :
3414 : : For example:
3415 : :
3416 : : FROM x IMPORT y, z ;
3417 : : ^^^^
3418 : :
3419 : : also:
3420 : :
3421 : : IMPORT p, q, r;
3422 : : ^^^^^^
3423 : : will result in a new ImportStatement symbol added
3424 : : to the current module import list.
3425 : : The statement symbol is expected to be created
3426 : : by MakeImportStatement using the token positions
3427 : : outlined above.
3428 : : */
3429 : :
3430 : : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement);
3431 : :
3432 : : /*
3433 : : AppendModuleOnImportStatement - appends the import symbol onto the
3434 : : dependent list (chain).
3435 : :
3436 : : For example each:
3437 : :
3438 : : FROM x IMPORT y, z ;
3439 : : ^
3440 : : x are added to the dependent list.
3441 : :
3442 : : also:
3443 : :
3444 : : IMPORT p, q, r;
3445 : : ^ ^ ^
3446 : : will result in p, q and r added to
3447 : : to the dependent list.
3448 : :
3449 : : The import symbol is created by MakeImport
3450 : : and the token is expected to match the module
3451 : : name position outlined above.
3452 : : */
3453 : :
3454 : : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import);
3455 : :
3456 : : /*
3457 : : PutModLink - assigns link to module sym.
3458 : : */
3459 : :
3460 : : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link);
3461 : :
3462 : : /*
3463 : : IsModLink - returns the ModLink value associated with the module symbol.
3464 : : */
3465 : :
3466 : : extern "C" bool SymbolTable_IsModLink (unsigned int sym);
3467 : :
3468 : : /*
3469 : : PutDefLink - assigns link to the definition module sym.
3470 : : */
3471 : :
3472 : : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link);
3473 : :
3474 : : /*
3475 : : IsDefLink - returns the DefLink value associated with the definition module symbol.
3476 : : */
3477 : :
3478 : : extern "C" bool SymbolTable_IsDefLink (unsigned int sym);
3479 : :
3480 : : /*
3481 : : IsModuleBuiltin - returns TRUE if the module is a builtin module.
3482 : : (For example _BaseTypes).
3483 : : */
3484 : :
3485 : : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym);
3486 : :
3487 : : /*
3488 : : PutModuleBuiltin - sets the Builtin flag to value.
3489 : : Currently the procedure expects sym to be a DefImp
3490 : : module only.
3491 : : */
3492 : :
3493 : : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value);
3494 : :
3495 : : /*
3496 : : PutVarArrayRef - assigns ArrayRef field with value.
3497 : : */
3498 : :
3499 : : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value);
3500 : :
3501 : : /*
3502 : : IsVarArrayRef - returns ArrayRef field value.
3503 : : */
3504 : :
3505 : : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym);
3506 : :
3507 : : /*
3508 : : VarCheckReadInit - returns TRUE if sym has been initialized.
3509 : : */
3510 : :
3511 : : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode);
3512 : :
3513 : : /*
3514 : : VarInitState - initializes the init state for variable sym.
3515 : : */
3516 : :
3517 : : extern "C" void SymbolTable_VarInitState (unsigned int sym);
3518 : :
3519 : : /*
3520 : : PutVarInitialized - set sym as initialized.
3521 : : */
3522 : :
3523 : : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode);
3524 : :
3525 : : /*
3526 : : PutVarFieldInitialized - records that field has been initialized with
3527 : : variable sym. TRUE is returned if the field
3528 : : is detected and changed to initialized.
3529 : : */
3530 : :
3531 : : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
3532 : :
3533 : : /*
3534 : : GetVarFieldInitialized - return TRUE if fieldlist has been initialized
3535 : : within variable sym.
3536 : : */
3537 : :
3538 : : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
3539 : :
3540 : : /*
3541 : : PrintInitialized - display variable sym initialization state.
3542 : : */
3543 : :
3544 : : extern "C" void SymbolTable_PrintInitialized (unsigned int sym);
3545 : :
3546 : : /*
3547 : : GetParameterHeapVar - return the heap variable associated with the
3548 : : parameter or NulSym.
3549 : : */
3550 : :
3551 : : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym);
3552 : :
3553 : : /*
3554 : : PutProcedureParameterHeapVars - creates heap variables for parameter sym.
3555 : : */
3556 : :
3557 : : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym);
3558 : :
3559 : : /*
3560 : : IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
3561 : : for the target architecture.
3562 : : */
3563 : :
3564 : : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure);
3565 : :
3566 : : /*
3567 : : PutConstLitInternal - marks the sym as being an internal constant.
3568 : : Currently this is used when generating a default
3569 : : BY constant expression during a FOR loop.
3570 : : A constant marked as internal will always pass
3571 : : an expression type check.
3572 : : */
3573 : :
3574 : : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value);
3575 : :
3576 : : /*
3577 : : IsConstLitInternal - returns the value of the IsInternal field within
3578 : : a constant expression.
3579 : : */
3580 : :
3581 : : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym);
3582 : : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at);
3583 : :
3584 : : /*
3585 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
3586 : : */
3587 : :
3588 : : static void InitWhereDeclared (SymbolTable_Where *at);
3589 : :
3590 : : /*
3591 : : InitWhereFirstUsed - sets the FirstUsed field of record, at.
3592 : : */
3593 : :
3594 : : static void InitWhereFirstUsed (SymbolTable_Where *at);
3595 : :
3596 : : /*
3597 : : InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
3598 : : */
3599 : :
3600 : : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at);
3601 : :
3602 : : /*
3603 : : stop - a debugger convenience hook.
3604 : : */
3605 : :
3606 : : static void stop (void);
3607 : :
3608 : : /*
3609 : : NewSym - Sets Sym to a new symbol index.
3610 : : */
3611 : :
3612 : : static void NewSym (unsigned int *sym);
3613 : :
3614 : : /*
3615 : : GetPsym - returns the pointer to, sym.
3616 : : */
3617 : :
3618 : : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym);
3619 : :
3620 : : /*
3621 : : GetPcall - returns the pointer to the CallFrame.
3622 : : */
3623 : :
3624 : : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call);
3625 : :
3626 : : /*
3627 : : DebugProcedureLineNumber -
3628 : : */
3629 : :
3630 : : static void DebugProcedureLineNumber (unsigned int sym);
3631 : :
3632 : : /*
3633 : : PutPartialUnbounded -
3634 : : */
3635 : :
3636 : : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim);
3637 : :
3638 : : /*
3639 : : AlreadyDeclaredError - generate an error message, a, and two areas of code showing
3640 : : the places where the symbols were declared.
3641 : : */
3642 : :
3643 : : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance);
3644 : :
3645 : : /*
3646 : : MakeObject - creates an object node.
3647 : : */
3648 : :
3649 : : static unsigned int MakeObject (NameKey_Name name);
3650 : :
3651 : : /*
3652 : : DeclareSym - returns a symbol which was either in the unknown tree or
3653 : : a New symbol, since name is about to be declared.
3654 : : */
3655 : :
3656 : : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name);
3657 : :
3658 : : /*
3659 : : Init - Initializes the data structures and variables in this module.
3660 : : Initialize the trees.
3661 : : */
3662 : :
3663 : : static void Init (void);
3664 : :
3665 : : /*
3666 : : AddSymToUnknown -
3667 : : */
3668 : :
3669 : : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym);
3670 : :
3671 : : /*
3672 : : AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
3673 : : unknown tree.
3674 : : */
3675 : :
3676 : : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym);
3677 : :
3678 : : /*
3679 : : SubSymFromUnknownTree - removes a symbol with name, name, from the
3680 : : unknown tree.
3681 : : */
3682 : :
3683 : : static void SubSymFromUnknownTree (NameKey_Name name);
3684 : :
3685 : : /*
3686 : : GetSymFromUnknownTree - returns a symbol with name, name, from the
3687 : : unknown tree.
3688 : : If no symbol with name is found then NulSym
3689 : : is returned.
3690 : : */
3691 : :
3692 : : static unsigned int GetSymFromUnknownTree (NameKey_Name name);
3693 : :
3694 : : /*
3695 : : ExamineUnresolvedTree - returns a symbol with name, name, from the
3696 : : unresolved tree of module, ModSym.
3697 : : If no symbol with name is found then NulSym
3698 : : is returned.
3699 : : */
3700 : :
3701 : : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
3702 : :
3703 : : /*
3704 : : RemoveFromUnresolvedTree - removes a symbol with name, name, from the
3705 : : unresolved tree of symbol, ScopeSym.
3706 : : */
3707 : :
3708 : : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
3709 : :
3710 : : /*
3711 : : FetchUnknownSym - returns a symbol from the unknown tree if one is
3712 : : available. It also updates the unknown tree.
3713 : : */
3714 : :
3715 : : static unsigned int FetchUnknownSym (NameKey_Name name);
3716 : :
3717 : : /*
3718 : : TransparentScope - returns true is the scope symbol Sym is allowed
3719 : : to look to an outer level for a symbol.
3720 : : ie is the symbol allowed to look to the parent
3721 : : scope for a symbol.
3722 : : */
3723 : :
3724 : : static bool TransparentScope (unsigned int Sym);
3725 : :
3726 : : /*
3727 : : GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
3728 : : the scope before the current module scope.
3729 : : */
3730 : :
3731 : : static unsigned int GetLastModuleOrProcedureScope (void);
3732 : :
3733 : : /*
3734 : : AddSymToScope - adds a symbol Sym with name name to
3735 : : the current scope symbol tree.
3736 : : */
3737 : :
3738 : : static void AddSymToScope (unsigned int Sym, NameKey_Name name);
3739 : :
3740 : : /*
3741 : : PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
3742 : : Procedure symbols enumeration
3743 : : list onto the scope stack.
3744 : : */
3745 : :
3746 : : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym);
3747 : :
3748 : : /*
3749 : : PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
3750 : : scope stack. This list will automatically
3751 : : removed via one call to EndScope which
3752 : : matches the StartScope by which this
3753 : : procedure is invoked.
3754 : : */
3755 : :
3756 : : static void PlaceEnumerationListOntoScope (Lists_List l);
3757 : :
3758 : : /*
3759 : : SetFirstUsed - assigns the FirstUsed field in at to tok providing
3760 : : it has not already been set.
3761 : : */
3762 : :
3763 : : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at);
3764 : :
3765 : : /*
3766 : : PutFirstUsed - sets tok to the first used providing it has not already been set.
3767 : : It also includes the read and write quad into the usage list
3768 : : providing the quad numbers are not 0.
3769 : : */
3770 : :
3771 : : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_);
3772 : :
3773 : : /*
3774 : : CanLookThroughScope - by default this procedure returns TRUE. It only returns
3775 : : FALSE if, throughProcedure, is FALSE and the ScopeSym is
3776 : : a procedure.
3777 : : */
3778 : :
3779 : : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure);
3780 : :
3781 : : /*
3782 : : GetScopeSym - searches the current scope and below, providing that the
3783 : : scopes are transparent, for a symbol with name, name.
3784 : : It only passes over procedure scopes if, throughProcedure,
3785 : : is TRUE.
3786 : : */
3787 : :
3788 : : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure);
3789 : :
3790 : : /*
3791 : : CheckScopeForSym - checks the scope, ScopeSym, for an identifier
3792 : : of name, name. CheckScopeForSym checks for
3793 : : the symbol by the GetLocalSym and also
3794 : : ExamineUnresolvedTree.
3795 : : */
3796 : :
3797 : : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name);
3798 : :
3799 : : /*
3800 : : GetModuleScopeId - returns the scope index to the next module starting
3801 : : at index, Id.
3802 : : Id will either point to a null scope (NulSym) or
3803 : : alternatively point to a Module or DefImp symbol.
3804 : : */
3805 : :
3806 : : static unsigned int GetModuleScopeId (unsigned int Id);
3807 : :
3808 : : /*
3809 : : GetVisibleSym -
3810 : : */
3811 : :
3812 : : static unsigned int GetVisibleSym (NameKey_Name name);
3813 : :
3814 : : /*
3815 : : IsAlreadyDeclaredSym - returns true if Sym has already been declared
3816 : : in the current main scope.
3817 : : */
3818 : :
3819 : : static bool IsAlreadyDeclaredSym (NameKey_Name name);
3820 : :
3821 : : /*
3822 : : GenName - returns a new name consisting of pre, name, post concatenation.
3823 : : */
3824 : :
3825 : : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high);
3826 : :
3827 : : /*
3828 : : InitCtor - initialize the ModuleCtor fields to NulSym.
3829 : : */
3830 : :
3831 : : static void InitCtor (SymbolTable_ModuleCtor *ctor);
3832 : :
3833 : : /*
3834 : : InitCtorFields - initialize the ModuleCtor fields. An inner module has no
3835 : : ctor procedure.
3836 : : */
3837 : :
3838 : : 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);
3839 : :
3840 : : /*
3841 : : CheckTok - checks to see that tok is at a known location. If not
3842 : : it uses GetTokenNo as a fall back.
3843 : : */
3844 : :
3845 : : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high);
3846 : :
3847 : : /*
3848 : : GetLink - returns TRUE if the current module is only used for linkage.
3849 : : */
3850 : :
3851 : : static bool GetLink (void);
3852 : :
3853 : : /*
3854 : : AddModuleToParent - adds symbol, Sym, to module, Parent.
3855 : : */
3856 : :
3857 : : static void AddModuleToParent (unsigned int Sym, unsigned int Parent);
3858 : :
3859 : : /*
3860 : : PutProcedureExternPublic - if procedure is not NulSym set extern
3861 : : and public booleans.
3862 : : */
3863 : :
3864 : : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub);
3865 : :
3866 : : /*
3867 : : PutCtorExtern -
3868 : : */
3869 : :
3870 : : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_);
3871 : :
3872 : : /*
3873 : : AddProcedureToList - adds a procedure, Proc, to the list of procedures
3874 : : in module, Mod.
3875 : : */
3876 : :
3877 : : static void AddProcedureToList (unsigned int Mod, unsigned int Proc);
3878 : :
3879 : : /*
3880 : : AddVarToScopeList - adds symbol, sym, to, scope.
3881 : : */
3882 : :
3883 : : static void AddVarToScopeList (unsigned int scope, unsigned int sym);
3884 : :
3885 : : /*
3886 : : AddVarToList - add a variable symbol to the list of variables maintained
3887 : : by the inner most scope. (Procedure or Module).
3888 : : */
3889 : :
3890 : : static void AddVarToList (unsigned int Sym);
3891 : :
3892 : : /*
3893 : : FillInRecordFields - given a new symbol, sym, make it a record symbol
3894 : : and initialize its fields.
3895 : : */
3896 : :
3897 : : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf);
3898 : :
3899 : : /*
3900 : : HandleHiddenOrDeclare -
3901 : : */
3902 : :
3903 : : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf);
3904 : :
3905 : : /*
3906 : : CreateConstLit -
3907 : : */
3908 : :
3909 : : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
3910 : :
3911 : : /*
3912 : : LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
3913 : : matches tok, constName and constType.
3914 : : */
3915 : :
3916 : : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType);
3917 : :
3918 : : /*
3919 : : AddConstLitPoolEntry - adds sym to the constlit pool.
3920 : : */
3921 : :
3922 : : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType);
3923 : :
3924 : : /*
3925 : : InitConstString - initialize the constant string.
3926 : : */
3927 : :
3928 : : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known);
3929 : :
3930 : : /*
3931 : : GetConstStringKind - return the StringVariant field associated with sym.
3932 : : */
3933 : :
3934 : : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym);
3935 : :
3936 : : /*
3937 : : CanUseBuiltin - returns TRUE if the procedure, Sym, can be
3938 : : inlined via a builtin function.
3939 : : */
3940 : :
3941 : : static bool CanUseBuiltin (unsigned int Sym);
3942 : :
3943 : : /*
3944 : : InitPacked - initialise packedInfo to FALSE and NulSym.
3945 : : */
3946 : :
3947 : : static void InitPacked (SymbolTable_PackedInfo *packedInfo);
3948 : :
3949 : : /*
3950 : : doEquivalent - create a packed equivalent symbol for, sym, and return the
3951 : : new symbol. It sets both fields in packedInfo to FALSE
3952 : : and the new symbol.
3953 : : */
3954 : :
3955 : : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
3956 : :
3957 : : /*
3958 : : MakeEquivalent - return the equivalent packed symbol for, sym.
3959 : : */
3960 : :
3961 : : static unsigned int MakeEquivalent (unsigned int sym);
3962 : :
3963 : : /*
3964 : : GetEquivalent -
3965 : : */
3966 : :
3967 : : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
3968 : :
3969 : : /*
3970 : : doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
3971 : : */
3972 : :
3973 : : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase);
3974 : :
3975 : : /*
3976 : : GetTypeOfVar - returns the type of symbol, var.
3977 : : */
3978 : :
3979 : : static unsigned int GetTypeOfVar (unsigned int var);
3980 : :
3981 : : /*
3982 : : GetConstLitType - returns the type of the constant of, name.
3983 : : All floating point constants have type LONGREAL.
3984 : : Character constants are type CHAR.
3985 : : Integer values are INTEGER, LONGINT or LONGCARD
3986 : : depending upon their value.
3987 : : */
3988 : :
3989 : : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError);
3990 : :
3991 : : /*
3992 : : GetNthFromComponent -
3993 : : */
3994 : :
3995 : : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n);
3996 : :
3997 : : /*
3998 : : EnsureOrder - providing that both symbols, a, and, b, exist in
3999 : : list, l. Ensure that, b, is placed after a.
4000 : : */
4001 : :
4002 : : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b);
4003 : :
4004 : : /*
4005 : : DumpSons -
4006 : : */
4007 : :
4008 : : static void DumpSons (unsigned int sym);
4009 : :
4010 : : /*
4011 : : CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
4012 : : */
4013 : :
4014 : : static void CheckListOfSons (unsigned int sym);
4015 : :
4016 : : /*
4017 : : CheckRecordConsistency -
4018 : : */
4019 : :
4020 : : static void CheckRecordConsistency (unsigned int sym);
4021 : :
4022 : : /*
4023 : : PutConstVarTemporary - indicates that constant, sym, is a temporary.
4024 : : */
4025 : :
4026 : : static void PutConstVarTemporary (unsigned int sym);
4027 : :
4028 : : /*
4029 : : buildTemporary - builds the temporary filling in componentRef, record and sets mode.
4030 : : */
4031 : :
4032 : : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record);
4033 : :
4034 : : /*
4035 : : CheckLegal - determines whether the Sym is a legal symbol.
4036 : : */
4037 : :
4038 : : static void CheckLegal (unsigned int Sym);
4039 : :
4040 : : /*
4041 : : CheckForHiddenType - scans the NeedToBeImplemented tree providing
4042 : : that we are currently compiling an implementation
4043 : : module. If a symbol is found with TypeName
4044 : : then its Sym is returned.
4045 : : Otherwise NulSym is returned.
4046 : : CheckForHiddenType is called before any type is
4047 : : created, therefore the compiler allows hidden
4048 : : types to be implemented using any type.
4049 : : */
4050 : :
4051 : : static unsigned int CheckForHiddenType (NameKey_Name TypeName);
4052 : :
4053 : : /*
4054 : : IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
4055 : : type declared as a pointer or address.
4056 : : */
4057 : :
4058 : : static bool IsHiddenReallyPointer (unsigned int Sym);
4059 : :
4060 : : /*
4061 : : RequestFromModule - returns a symbol from module ModSym with name, SymName.
4062 : : */
4063 : :
4064 : : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4065 : :
4066 : : /*
4067 : : RequestFromDefinition - returns a symbol from module ModSym with name,
4068 : : SymName.
4069 : : */
4070 : :
4071 : : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4072 : :
4073 : : /*
4074 : : GetWhereImported - returns the token number where this symbol
4075 : : was imported into the current module.
4076 : : */
4077 : :
4078 : : static unsigned int GetWhereImported (unsigned int Sym);
4079 : :
4080 : : /*
4081 : : DisplayName - displays the name.
4082 : : */
4083 : :
4084 : : static void DisplayName (unsigned int sym);
4085 : :
4086 : : /*
4087 : : DisplaySymbol - displays the name of a symbol
4088 : : */
4089 : :
4090 : : static void DisplaySymbol (unsigned int sym);
4091 : :
4092 : : /*
4093 : : FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
4094 : : */
4095 : :
4096 : : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4097 : :
4098 : : /*
4099 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
4100 : : */
4101 : :
4102 : : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4103 : :
4104 : : /*
4105 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
4106 : : */
4107 : :
4108 : : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName);
4109 : :
4110 : : /*
4111 : : UnknownSymbolError - displays symbol name for symbol, sym.
4112 : : */
4113 : :
4114 : : static void UnknownSymbolError (unsigned int sym);
4115 : :
4116 : : /*
4117 : : IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
4118 : : reported and is an unknown symbol.
4119 : : */
4120 : :
4121 : : static bool IsUnreportedUnknown (unsigned int sym);
4122 : :
4123 : : /*
4124 : : AddListify -
4125 : : */
4126 : :
4127 : : static void AddListify (unsigned int sym);
4128 : :
4129 : : /*
4130 : : Listify - convert tree into a string list and return the result.
4131 : : */
4132 : :
4133 : : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition);
4134 : :
4135 : : /*
4136 : : CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
4137 : : an unknown symbol. All unknown symbols are displayed
4138 : : together with an error message.
4139 : : */
4140 : :
4141 : : static void CheckForUnknowns (NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
4142 : :
4143 : : /*
4144 : : SymbolError - displays symbol name for symbol, Sym.
4145 : : */
4146 : :
4147 : : static void SymbolError (unsigned int Sym);
4148 : :
4149 : : /*
4150 : : CheckForSymbols - checks a binary tree, Tree, to see whether it contains
4151 : : any symbol. The tree is expected to be empty, if not
4152 : : then an error has occurred.
4153 : : */
4154 : :
4155 : : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
4156 : :
4157 : : /*
4158 : : PutExportUndeclared - places a symbol, Sym, into module, ModSym,
4159 : : ExportUndeclared list provided that Sym
4160 : : is unknown.
4161 : : */
4162 : :
4163 : : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym);
4164 : :
4165 : : /*
4166 : : GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
4167 : : which is in the ExportUndeclared list.
4168 : : */
4169 : :
4170 : : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name);
4171 : :
4172 : : /*
4173 : : RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
4174 : : ExportUndeclaredTree.
4175 : : */
4176 : :
4177 : : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym);
4178 : :
4179 : : /*
4180 : : CheckForExportedDeclaration - checks to see whether a definition module
4181 : : is currently being compiled, if so,
4182 : : symbol, Sym, is removed from the
4183 : : ExportUndeclared list.
4184 : : This procedure is called whenever a symbol
4185 : : is declared, thus attempting to reduce
4186 : : the ExportUndeclared list.
4187 : : */
4188 : :
4189 : : static void CheckForExportedDeclaration (unsigned int Sym);
4190 : :
4191 : : /*
4192 : : UndeclaredSymbolError - displays symbol name for symbol, Sym.
4193 : : */
4194 : :
4195 : : static void UndeclaredSymbolError (unsigned int Sym);
4196 : :
4197 : : /*
4198 : : RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
4199 : : NeedToBeImplemented list.
4200 : : */
4201 : :
4202 : : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym);
4203 : :
4204 : : /*
4205 : : RemoveFromExportRequest -
4206 : : */
4207 : :
4208 : : static void RemoveFromExportRequest (unsigned int Sym);
4209 : :
4210 : : /*
4211 : : RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
4212 : : (and its fields) from the ExportRequest tree.
4213 : : */
4214 : :
4215 : : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym);
4216 : :
4217 : : /*
4218 : : UnImplementedSymbolError - displays symbol name for symbol, Sym.
4219 : : */
4220 : :
4221 : : static void UnImplementedSymbolError (unsigned int Sym);
4222 : :
4223 : : /*
4224 : : CheckEnumerationInList - places symbol, Sym, in the list, l,
4225 : : providing it does not already exist.
4226 : : PseudoScope(Sym) is called if Sym needs to
4227 : : be added to the enumeration list, l.
4228 : : */
4229 : :
4230 : : static void CheckEnumerationInList (Lists_List l, unsigned int Sym);
4231 : :
4232 : : /*
4233 : : CheckIfEnumerationExported - An outer module may use an enumeration that
4234 : : is declared inside an inner module. The usage
4235 : : may occur before definition. The first pass
4236 : : exports a symbol, later the symbol is declared
4237 : : as an emumeration type. At this stage the
4238 : : CheckIfEnumerationExported procedure should be
4239 : : called. This procedure ripples from the current
4240 : : (inner) module to outer module and every time
4241 : : it is exported it must be added to the outer
4242 : : module EnumerationScopeList.
4243 : : */
4244 : :
4245 : : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId);
4246 : :
4247 : : /*
4248 : : CheckForEnumerationInOuterModule - checks to see whether the enumeration
4249 : : type symbol, Sym, has been entered into
4250 : : the outer module, OuterModule, scope list.
4251 : : OuterModule may be internal to the
4252 : : program module.
4253 : : */
4254 : :
4255 : : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule);
4256 : :
4257 : : /*
4258 : : SetReturnOptional - sets the ReturnOptional field in the Procedure or
4259 : : ProcType symboltable entry.
4260 : : */
4261 : :
4262 : : static void SetReturnOptional (unsigned int sym, bool isopt);
4263 : :
4264 : : /*
4265 : : CheckOptFunction - checks to see whether the optional return value
4266 : : has been set before and if it differs it will
4267 : : generate an error message. It will set the
4268 : : new value to, isopt.
4269 : : */
4270 : :
4271 : : static void CheckOptFunction (unsigned int sym, bool isopt);
4272 : :
4273 : : /*
4274 : : MakeVariableForParam -
4275 : : */
4276 : :
4277 : : static unsigned int MakeVariableForParam (unsigned int tok, NameKey_Name ParamName, unsigned int ProcSym, unsigned int no);
4278 : :
4279 : : /*
4280 : : AddParameter - adds a parameter ParSym to a procedure Sym.
4281 : : */
4282 : :
4283 : : static void AddParameter (unsigned int Sym, unsigned int ParSym);
4284 : :
4285 : : /*
4286 : : IsNthParamVar - returns true if the n th parameter of the parameter list,
4287 : : List, is a VAR parameter.
4288 : : */
4289 : :
4290 : : static bool IsNthParamVar (Lists_List Head, unsigned int n);
4291 : :
4292 : : /*
4293 : : MakeParameterHeapVar - create a heap variable if sym is a pointer.
4294 : : */
4295 : :
4296 : : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode);
4297 : :
4298 : : /*
4299 : : PutParameterHeapVar - creates a heap variable associated with parameter sym.
4300 : : */
4301 : :
4302 : : static void PutParameterHeapVar (unsigned int sym);
4303 : :
4304 : : /*
4305 : : FillInUnknownFields -
4306 : : */
4307 : :
4308 : : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName);
4309 : :
4310 : : /*
4311 : : FillInPointerFields - given a new symbol, sym, make it a pointer symbol
4312 : : and initialize its fields.
4313 : : */
4314 : :
4315 : : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf);
4316 : :
4317 : : /*
4318 : : ForeachParameterDo -
4319 : : */
4320 : :
4321 : : static void ForeachParameterDo (SymbolTable_CheckProcedure p);
4322 : :
4323 : : /*
4324 : : CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
4325 : : */
4326 : :
4327 : : static void CheckUnbounded (unsigned int Sym);
4328 : :
4329 : : /*
4330 : : PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
4331 : : */
4332 : :
4333 : : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf);
4334 : :
4335 : : /*
4336 : : doFillInOAFamily -
4337 : : */
4338 : :
4339 : : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded);
4340 : :
4341 : : /*
4342 : : FillInUnboundedFields -
4343 : : */
4344 : :
4345 : : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim);
4346 : :
4347 : : /*
4348 : : PutUnbounded - associates the unbounded symbol, open, with
4349 : : SimpleType.
4350 : : */
4351 : :
4352 : : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim);
4353 : :
4354 : : /*
4355 : : GetArrayDimension - returns the number of dimensions defined.
4356 : : */
4357 : :
4358 : : static unsigned int GetArrayDimension (unsigned int sym);
4359 : :
4360 : : /*
4361 : : ResolveConstructorType - if, sym, has an unresolved constructor type
4362 : : then attempt to resolve it by examining the
4363 : : from, type.
4364 : : */
4365 : :
4366 : : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres);
4367 : :
4368 : : /*
4369 : : IsConstructorResolved - returns TRUE if the constructor does not
4370 : : have an unresolved type.
4371 : : */
4372 : :
4373 : : static bool IsConstructorResolved (unsigned int sym);
4374 : :
4375 : : /*
4376 : : CanResolveConstructor - returns TRUE if the type of the constructor,
4377 : : sym, is known.
4378 : : */
4379 : :
4380 : : static bool CanResolveConstructor (unsigned int sym);
4381 : :
4382 : : /*
4383 : : CheckAllConstructorsResolved - checks to see that the
4384 : : UnresolvedConstructorType list is
4385 : : empty and if it is not then it
4386 : : generates error messages.
4387 : : */
4388 : :
4389 : : static void CheckAllConstructorsResolved (void);
4390 : :
4391 : : /*
4392 : : SanityCheckParameters -
4393 : : */
4394 : :
4395 : : static void SanityCheckParameters (unsigned int sym);
4396 : :
4397 : : /*
4398 : : SanityCheckArray - checks to see that an array has a correct subrange type.
4399 : : */
4400 : :
4401 : : static void SanityCheckArray (unsigned int sym);
4402 : :
4403 : : /*
4404 : : ForeachSymbolDo - foreach symbol, call, P(sym).
4405 : : */
4406 : :
4407 : : static void ForeachSymbolDo (SymbolKey_PerformOperation P);
4408 : :
4409 : : /*
4410 : : SanityCheckProcedure - check to see that procedure parameters do not use constants
4411 : : instead of types in their formal parameter section.
4412 : : */
4413 : :
4414 : : static void SanityCheckProcedure (unsigned int sym);
4415 : :
4416 : : /*
4417 : : SanityCheckModule -
4418 : : */
4419 : :
4420 : : static void SanityCheckModule (unsigned int sym);
4421 : :
4422 : : /*
4423 : : AddNameTo - adds Name, n, to tree, s.
4424 : : */
4425 : :
4426 : : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o);
4427 : :
4428 : : /*
4429 : : CollectSymbolFrom -
4430 : : */
4431 : :
4432 : : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n);
4433 : :
4434 : : /*
4435 : : CollectUnknown -
4436 : : */
4437 : :
4438 : : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n);
4439 : :
4440 : : /*
4441 : : ResolveImport -
4442 : : */
4443 : :
4444 : : static void ResolveImport (unsigned int o);
4445 : :
4446 : : /*
4447 : : ResolveRelativeImport -
4448 : : */
4449 : :
4450 : : static void ResolveRelativeImport (unsigned int sym);
4451 : :
4452 : : /*
4453 : : Max -
4454 : : */
4455 : :
4456 : : static unsigned int Max (unsigned int a, unsigned int b);
4457 : :
4458 : : /*
4459 : : Min -
4460 : : */
4461 : :
4462 : : static unsigned int Min (unsigned int a, unsigned int b);
4463 : :
4464 : : /*
4465 : : DoFindLimits - assigns, Start, and, End, to the start and end
4466 : : limits contained in the list, l. It ensures that
4467 : : Start and End are within StartLimit..EndLimit.
4468 : : If StartLimit or EndLimit are 0 then Start is
4469 : : is set to the first value and End to the last.
4470 : : */
4471 : :
4472 : : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l);
4473 : :
4474 : : /*
4475 : : PutDeclaredDefinition - associates the current tokenno with
4476 : : the symbols declaration in the definition
4477 : : module.
4478 : : */
4479 : :
4480 : : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym);
4481 : :
4482 : : /*
4483 : : PutDeclaredModule - returns the token where this symbol was declared
4484 : : in an implementation or program module.
4485 : : */
4486 : :
4487 : : static void PutDeclaredModule (unsigned int tok, unsigned int Sym);
4488 : :
4489 : : /*
4490 : : DoIsConst - returns TRUE if Sym is defined as a constant
4491 : : or is an enumeration field or string.
4492 : : */
4493 : :
4494 : : static bool DoIsConst (unsigned int Sym);
4495 : :
4496 : : /*
4497 : : GetFromIndex - return a value from list, i, at position, n.
4498 : : */
4499 : :
4500 : : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n);
4501 : :
4502 : : /*
4503 : : PutIntoIndex - places value, v, into list, i, at position, n.
4504 : : */
4505 : :
4506 : : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v);
4507 : :
4508 : : /*
4509 : : PushConstString - pushes the character string onto the ALU stack.
4510 : : It assumes that the character string is only
4511 : : one character long.
4512 : : */
4513 : :
4514 : : static void PushConstString (unsigned int Sym);
4515 : :
4516 : 27867367 : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at)
4517 : : {
4518 : : /*
4519 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
4520 : : */
4521 : 27867367 : if (M2Comp_CompilingDefinitionModule ())
4522 : : {
4523 : 15959049 : (*at).DefDeclared = tok;
4524 : 15959049 : (*at).ModDeclared = M2LexBuf_UnknownTokenNo;
4525 : : }
4526 : : else
4527 : : {
4528 : 11908318 : (*at).DefDeclared = M2LexBuf_UnknownTokenNo;
4529 : 11908318 : (*at).ModDeclared = tok;
4530 : : }
4531 : 27867367 : (*at).FirstUsed = tok; /* we assign this field to something legal */
4532 : 27867367 : }
4533 : :
4534 : :
4535 : : /*
4536 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
4537 : : */
4538 : :
4539 : 5158180 : static void InitWhereDeclared (SymbolTable_Where *at)
4540 : : {
4541 : 5158180 : InitWhereDeclaredTok (M2LexBuf_GetTokenNo (), at);
4542 : 5158180 : }
4543 : :
4544 : :
4545 : : /*
4546 : : InitWhereFirstUsed - sets the FirstUsed field of record, at.
4547 : : */
4548 : :
4549 : 4669360 : static void InitWhereFirstUsed (SymbolTable_Where *at)
4550 : : {
4551 : 0 : InitWhereFirstUsedTok (M2LexBuf_GetTokenNo (), at);
4552 : 0 : }
4553 : :
4554 : :
4555 : : /*
4556 : : InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
4557 : : */
4558 : :
4559 : 20785244 : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at)
4560 : : {
4561 : 20785244 : (*at).FirstUsed = tok;
4562 : 1049791 : }
4563 : :
4564 : :
4565 : : /*
4566 : : stop - a debugger convenience hook.
4567 : : */
4568 : :
4569 : 0 : static void stop (void)
4570 : : {
4571 : 0 : }
4572 : :
4573 : :
4574 : : /*
4575 : : NewSym - Sets Sym to a new symbol index.
4576 : : */
4577 : :
4578 : 30616898 : static void NewSym (unsigned int *sym)
4579 : : {
4580 : 30616898 : SymbolTable_PtrToSymbol pSym;
4581 : :
4582 : 30616898 : (*sym) = FreeSymbol;
4583 : 30616898 : Storage_ALLOCATE ((void **) &pSym, sizeof (SymbolTable_Symbol));
4584 : 30616898 : pSym->SymbolType = SymbolTable_DummySym;
4585 : 30616898 : Indexing_PutIndice (Symbols, (*sym), reinterpret_cast<void *> (pSym));
4586 : 30616898 : if ((*sym) == BreakSym)
4587 : : {
4588 : 30616898 : stop ();
4589 : : }
4590 : 30616898 : FreeSymbol += 1;
4591 : 30616898 : }
4592 : :
4593 : :
4594 : : /*
4595 : : GetPsym - returns the pointer to, sym.
4596 : : */
4597 : :
4598 : 5259814015 : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym)
4599 : : {
4600 : 5259814015 : SymbolTable_PtrToSymbol pSym;
4601 : :
4602 : 5259814015 : if (Indexing_InBounds (Symbols, sym))
4603 : : {
4604 : 5259814003 : pSym = static_cast<SymbolTable_PtrToSymbol> (Indexing_GetIndice (Symbols, sym));
4605 : 5259814003 : return pSym;
4606 : : }
4607 : : else
4608 : : {
4609 : 12 : M2Error_InternalError ((const char *) "symbol out of bounds", 20);
4610 : : }
4611 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
4612 : : __builtin_unreachable ();
4613 : : }
4614 : :
4615 : :
4616 : : /*
4617 : : GetPcall - returns the pointer to the CallFrame.
4618 : : */
4619 : :
4620 : 230919928 : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call)
4621 : : {
4622 : 230919928 : SymbolTable_PtrToCallFrame pCall;
4623 : :
4624 : 230919928 : if (Indexing_InBounds (ScopeCallFrame, call))
4625 : : {
4626 : 230919928 : pCall = static_cast<SymbolTable_PtrToCallFrame> (Indexing_GetIndice (ScopeCallFrame, call));
4627 : 230919928 : return pCall;
4628 : : }
4629 : : else
4630 : : {
4631 : 0 : M2Error_InternalError ((const char *) "symbol out of bounds", 20);
4632 : : }
4633 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
4634 : : __builtin_unreachable ();
4635 : : }
4636 : :
4637 : :
4638 : : /*
4639 : : DebugProcedureLineNumber -
4640 : : */
4641 : :
4642 : 0 : static void DebugProcedureLineNumber (unsigned int sym)
4643 : : {
4644 : 0 : unsigned int begin;
4645 : 0 : unsigned int end;
4646 : 0 : NameKey_Name n;
4647 : 0 : DynamicStrings_String f;
4648 : 0 : unsigned int l;
4649 : :
4650 : 0 : SymbolTable_GetProcedureBeginEnd (sym, &begin, &end);
4651 : 0 : n = SymbolTable_GetSymName (sym);
4652 : 0 : if (begin != 0)
4653 : : {
4654 : 0 : f = M2LexBuf_FindFileNameFromToken (begin, 0);
4655 : 0 : l = M2LexBuf_TokenToLineNo (begin, 0);
4656 : 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));
4657 : : }
4658 : 0 : if (end != 0)
4659 : : {
4660 : 0 : f = M2LexBuf_FindFileNameFromToken (end, 0);
4661 : 0 : l = M2LexBuf_TokenToLineNo (end, 0);
4662 : 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));
4663 : : }
4664 : 0 : }
4665 : :
4666 : :
4667 : : /*
4668 : : PutPartialUnbounded -
4669 : : */
4670 : :
4671 : 0 : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim)
4672 : : {
4673 : 0 : SymbolTable_PtrToSymbol pSym;
4674 : :
4675 : 0 : pSym = GetPsym (sym);
4676 : 0 : if (SymbolTable_IsDummy (sym))
4677 : : {
4678 : 0 : pSym->SymbolType = SymbolTable_PartialUnboundedSym;
4679 : : }
4680 : 0 : switch (pSym->SymbolType)
4681 : : {
4682 : 0 : case SymbolTable_PartialUnboundedSym:
4683 : 0 : pSym->PartialUnbounded.Type = type;
4684 : 0 : pSym->PartialUnbounded.NDim = ndim;
4685 : 0 : break;
4686 : :
4687 : :
4688 : 0 : default:
4689 : 0 : M2Error_InternalError ((const char *) "not expecting this type", 23);
4690 : 0 : break;
4691 : : }
4692 : 0 : }
4693 : :
4694 : :
4695 : : /*
4696 : : AlreadyDeclaredError - generate an error message, a, and two areas of code showing
4697 : : the places where the symbols were declared.
4698 : : */
4699 : :
4700 : 0 : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance)
4701 : : {
4702 : 0 : M2Error_Error e;
4703 : :
4704 : 0 : if ((OtherOccurance == 0) || (OtherOccurance == (M2LexBuf_GetTokenNo ())))
4705 : : {
4706 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
4707 : 0 : M2Error_ErrorString (e, s);
4708 : : }
4709 : : else
4710 : : {
4711 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
4712 : 0 : M2Error_ErrorString (e, s);
4713 : 0 : e = M2Error_ChainError (OtherOccurance, e);
4714 : 0 : M2Error_ErrorFormat1 (e, (const char *) "and symbol (%a) is also declared here", 37, (const unsigned char *) &name, (sizeof (name)-1));
4715 : : }
4716 : 0 : }
4717 : :
4718 : :
4719 : : /*
4720 : : MakeObject - creates an object node.
4721 : : */
4722 : :
4723 : 4668874 : static unsigned int MakeObject (NameKey_Name name)
4724 : : {
4725 : 4668874 : SymbolTable_PtrToSymbol pSym;
4726 : 4668874 : unsigned int Sym;
4727 : :
4728 : 4668874 : NewSym (&Sym);
4729 : 4668874 : pSym = GetPsym (Sym);
4730 : 4668874 : pSym->SymbolType = SymbolTable_ObjectSym;
4731 : 4668874 : pSym->Object.name = name;
4732 : 4668874 : InitWhereDeclared (&pSym->Object.At);
4733 : 4668874 : InitWhereFirstUsed (&pSym->Object.At);
4734 : 4668874 : return Sym;
4735 : : /* static analysis guarentees a RETURN statement will be used before here. */
4736 : : __builtin_unreachable ();
4737 : : }
4738 : :
4739 : :
4740 : : /*
4741 : : DeclareSym - returns a symbol which was either in the unknown tree or
4742 : : a New symbol, since name is about to be declared.
4743 : : */
4744 : :
4745 : 13995897 : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name)
4746 : : {
4747 : 13995897 : unsigned int Sym;
4748 : :
4749 : 13995897 : if (name == NameKey_NulName)
4750 : : {
4751 : 263075 : NewSym (&Sym);
4752 : : }
4753 : 13732822 : else if (IsAlreadyDeclaredSym (name))
4754 : : {
4755 : : /* avoid dangling else. */
4756 : 30 : Sym = SymbolTable_GetSym (name);
4757 : 30 : if (SymbolTable_IsImported (SymbolTable_GetCurrentModuleScope (), Sym))
4758 : : {
4759 : : /* avoid dangling else. */
4760 : 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);
4761 : 6 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
4762 : 6 : if (Sym != (GetVisibleSym (name)))
4763 : : {
4764 : 0 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
4765 : : }
4766 : : }
4767 : : else
4768 : : {
4769 : 24 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1RMad} is already declared in this scope, use a different name or remove the declaration", 97, Sym);
4770 : 24 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
4771 : 24 : if (Sym != (GetVisibleSym (name)))
4772 : : {
4773 : 0 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
4774 : : }
4775 : : }
4776 : 30 : Sym = SymbolTable_MakeError (tok, name);
4777 : : }
4778 : : else
4779 : : {
4780 : : /* avoid dangling else. */
4781 : 13732792 : Sym = FetchUnknownSym (name);
4782 : 13732792 : if (Sym == SymbolTable_NulSym)
4783 : : {
4784 : 10729169 : NewSym (&Sym);
4785 : : }
4786 : 13732792 : CheckForExportedDeclaration (Sym);
4787 : : }
4788 : 13995897 : return Sym;
4789 : : /* static analysis guarentees a RETURN statement will be used before here. */
4790 : : __builtin_unreachable ();
4791 : : }
4792 : :
4793 : :
4794 : : /*
4795 : : Init - Initializes the data structures and variables in this module.
4796 : : Initialize the trees.
4797 : : */
4798 : :
4799 : 16817 : static void Init (void)
4800 : : {
4801 : 16817 : SymbolTable_PtrToCallFrame pCall;
4802 : :
4803 : 16817 : AnonymousName = 0;
4804 : 16817 : CurrentError = static_cast<M2Error_Error> (NULL);
4805 : 16817 : SymbolKey_InitTree (&ConstLitPoolTree);
4806 : 16817 : SymbolKey_InitTree (&DefModuleTree);
4807 : 16817 : SymbolKey_InitTree (&ModuleTree);
4808 : 16817 : Symbols = Indexing_InitIndexTuned (1, (1024*1024) / 16, 16);
4809 : 16817 : ConstLitArray = Indexing_InitIndex (1);
4810 : 16817 : FreeSymbol = 1;
4811 : 16817 : ScopePtr = 1;
4812 : 16817 : ScopeCallFrame = Indexing_InitIndex (1);
4813 : 16817 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
4814 : 16817 : pCall->Main = SymbolTable_NulSym;
4815 : 16817 : pCall->Search = SymbolTable_NulSym;
4816 : 16817 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast<void *> (pCall));
4817 : 16817 : CurrentModule = SymbolTable_NulSym;
4818 : 16817 : MainModule = SymbolTable_NulSym;
4819 : 16817 : FileModule = SymbolTable_NulSym;
4820 : 16817 : TemporaryNo = 0;
4821 : : /*
4822 : : InitList(FreeFVarientList) ; Lists used to maintain GC of field
4823 : : InitList(UsedFVarientList) ; varients.
4824 : : */
4825 : 16817 : Lists_InitList (&UnresolvedConstructorType);
4826 : 16817 : M2Base_InitBase (m2linemap_BuiltinsLocation (), &BaseModule);
4827 : 16817 : SymbolTable_StartScope (BaseModule); /* BaseModule scope placed at the bottom of the stack */
4828 : 16817 : BaseScopePtr = ScopePtr; /* BaseScopePtr points to the top of the BaseModule scope */
4829 : 16817 : Lists_InitList (&AddressTypes); /* BaseScopePtr points to the top of the BaseModule scope */
4830 : 16817 : ReportedUnknowns = Sets_InitSet (1);
4831 : 16817 : }
4832 : :
4833 : :
4834 : : /*
4835 : : AddSymToUnknown -
4836 : : */
4837 : :
4838 : 6353712 : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym)
4839 : : {
4840 : 6353712 : SymbolTable_PtrToSymbol pSym;
4841 : 6353712 : NameKey_Name n;
4842 : :
4843 : 6353712 : if (DebugUnknowns)
4844 : : {
4845 : : n = SymbolTable_GetSymName (scope);
4846 : : 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));
4847 : : }
4848 : : /* Add symbol to unknown tree */
4849 : 6353712 : pSym = GetPsym (scope);
4850 : 6353712 : switch (pSym->SymbolType)
4851 : : {
4852 : 6344880 : case SymbolTable_DefImpSym:
4853 : 6344880 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, name, Sym);
4854 : 6344880 : break;
4855 : :
4856 : 8832 : case SymbolTable_ModuleSym:
4857 : 8832 : SymbolKey_PutSymKey (pSym->Module.Unresolved, name, Sym);
4858 : 8832 : break;
4859 : :
4860 : 0 : case SymbolTable_ProcedureSym:
4861 : 0 : SymbolKey_PutSymKey (pSym->Procedure.Unresolved, name, Sym);
4862 : 0 : break;
4863 : :
4864 : :
4865 : 0 : default:
4866 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
4867 : 6353712 : break;
4868 : : }
4869 : 6353712 : }
4870 : :
4871 : :
4872 : : /*
4873 : : AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
4874 : : unknown tree.
4875 : : */
4876 : :
4877 : 6353694 : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym)
4878 : : {
4879 : 6353694 : SymbolTable_PtrToCallFrame pCall;
4880 : 6353694 : unsigned int ScopeSym;
4881 : :
4882 : 6353694 : if (ScopeId > 0)
4883 : : {
4884 : : /* choose to place the unknown symbol in the first module scope
4885 : : outside the current scope */
4886 : 6354318 : do {
4887 : 6354318 : pCall = GetPcall (static_cast<unsigned int> (ScopeId));
4888 : 6354318 : ScopeSym = pCall->Main;
4889 : 6354318 : if ((ScopeSym > 0) && ((SymbolTable_IsDefImp (ScopeSym)) || (SymbolTable_IsModule (ScopeSym))))
4890 : : {
4891 : 6353694 : AddSymToUnknown (ScopeSym, name, Sym);
4892 : 6353694 : return ;
4893 : : }
4894 : 624 : ScopeId -= 1;
4895 : 624 : } while (! (ScopeId == 0));
4896 : : }
4897 : 0 : AddSymToUnknown (CurrentModule, name, Sym);
4898 : : }
4899 : :
4900 : :
4901 : : /*
4902 : : SubSymFromUnknownTree - removes a symbol with name, name, from the
4903 : : unknown tree.
4904 : : */
4905 : :
4906 : 3003629 : static void SubSymFromUnknownTree (NameKey_Name name)
4907 : : {
4908 : 3003629 : SymbolTable_PtrToCallFrame pCall;
4909 : 3003629 : unsigned int ScopeSym;
4910 : 3003629 : unsigned int ScopeId;
4911 : :
4912 : 3003629 : if (ScopePtr > 0)
4913 : : {
4914 : : ScopeId = ScopePtr;
4915 : 4012237 : do {
4916 : 4012237 : pCall = GetPcall (ScopeId);
4917 : 4012237 : ScopeSym = pCall->Search;
4918 : 4012237 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
4919 : : {
4920 : 3004181 : if (RemoveFromUnresolvedTree (ScopeSym, name))
4921 : : {
4922 : : return ;
4923 : : }
4924 : : }
4925 : 1008608 : ScopeId -= 1;
4926 : 2017216 : } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
4927 : : }
4928 : 0 : if (RemoveFromUnresolvedTree (CurrentModule, name))
4929 : : {} /* empty. */
4930 : : }
4931 : :
4932 : :
4933 : : /*
4934 : : GetSymFromUnknownTree - returns a symbol with name, name, from the
4935 : : unknown tree.
4936 : : If no symbol with name is found then NulSym
4937 : : is returned.
4938 : : */
4939 : :
4940 : 20086558 : static unsigned int GetSymFromUnknownTree (NameKey_Name name)
4941 : : {
4942 : 20086558 : SymbolTable_PtrToCallFrame pCall;
4943 : 20086558 : unsigned int ScopeSym;
4944 : 20086558 : unsigned int ScopeId;
4945 : 20086558 : unsigned int Sym;
4946 : :
4947 : 20086558 : if (ScopePtr > 0)
4948 : : {
4949 : : ScopeId = ScopePtr;
4950 : 33317257 : do {
4951 : 33317257 : pCall = GetPcall (ScopeId);
4952 : 33317257 : ScopeSym = pCall->Search;
4953 : 33317257 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
4954 : : {
4955 : 27742699 : Sym = ExamineUnresolvedTree (ScopeSym, name);
4956 : 27742699 : if (Sym != SymbolTable_NulSym)
4957 : : {
4958 : 3003629 : return Sym;
4959 : : }
4960 : : }
4961 : 30313628 : ScopeId -= 1;
4962 : 60627256 : } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
4963 : : }
4964 : : /* Get symbol from unknown tree */
4965 : 17082929 : return ExamineUnresolvedTree (CurrentModule, name);
4966 : : /* static analysis guarentees a RETURN statement will be used before here. */
4967 : : __builtin_unreachable ();
4968 : : }
4969 : :
4970 : :
4971 : : /*
4972 : : ExamineUnresolvedTree - returns a symbol with name, name, from the
4973 : : unresolved tree of module, ModSym.
4974 : : If no symbol with name is found then NulSym
4975 : : is returned.
4976 : : */
4977 : :
4978 : 78458759 : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
4979 : : {
4980 : 78458759 : SymbolTable_PtrToSymbol pSym;
4981 : 78458759 : unsigned int Sym;
4982 : :
4983 : : /* Get symbol from unknown tree */
4984 : 78458759 : pSym = GetPsym (ScopeSym);
4985 : 78458759 : switch (pSym->SymbolType)
4986 : : {
4987 : 48657690 : case SymbolTable_DefImpSym:
4988 : 48657690 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name));
4989 : 48657690 : break;
4990 : :
4991 : 10238810 : case SymbolTable_ModuleSym:
4992 : 10238810 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, name));
4993 : 10238810 : break;
4994 : :
4995 : 19562259 : case SymbolTable_ProcedureSym:
4996 : 19562259 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name));
4997 : 19562259 : break;
4998 : :
4999 : :
5000 : 0 : default:
5001 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5002 : 78458759 : break;
5003 : : }
5004 : 78458759 : return Sym;
5005 : : /* static analysis guarentees a RETURN statement will be used before here. */
5006 : : __builtin_unreachable ();
5007 : : }
5008 : :
5009 : :
5010 : : /*
5011 : : RemoveFromUnresolvedTree - removes a symbol with name, name, from the
5012 : : unresolved tree of symbol, ScopeSym.
5013 : : */
5014 : :
5015 : 3004181 : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
5016 : : {
5017 : 3004181 : SymbolTable_PtrToSymbol pSym;
5018 : :
5019 : : /* Get symbol from unknown tree */
5020 : 3004181 : pSym = GetPsym (ScopeSym);
5021 : 3004181 : switch (pSym->SymbolType)
5022 : : {
5023 : 2994839 : case SymbolTable_DefImpSym:
5024 : 2994839 : if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) != SymbolKey_NulKey)
5025 : : {
5026 : 2994839 : SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
5027 : 2994839 : return true;
5028 : : }
5029 : : break;
5030 : :
5031 : 8772 : case SymbolTable_ModuleSym:
5032 : 8772 : if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) != SymbolKey_NulKey)
5033 : : {
5034 : 8772 : SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
5035 : 8772 : return true;
5036 : : }
5037 : : break;
5038 : :
5039 : 570 : case SymbolTable_ProcedureSym:
5040 : 570 : if ((SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name)) != SymbolKey_NulKey)
5041 : : {
5042 : 18 : SymbolKey_DelSymKey (pSym->Procedure.Unresolved, name);
5043 : 18 : return true;
5044 : : }
5045 : : break;
5046 : :
5047 : :
5048 : 0 : default:
5049 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5050 : : break;
5051 : : }
5052 : : return false;
5053 : : /* static analysis guarentees a RETURN statement will be used before here. */
5054 : : __builtin_unreachable ();
5055 : : }
5056 : :
5057 : :
5058 : : /*
5059 : : FetchUnknownSym - returns a symbol from the unknown tree if one is
5060 : : available. It also updates the unknown tree.
5061 : : */
5062 : :
5063 : 13732864 : static unsigned int FetchUnknownSym (NameKey_Name name)
5064 : : {
5065 : 13732864 : unsigned int Sym;
5066 : :
5067 : 13732864 : Sym = GetSymFromUnknownTree (name);
5068 : 13732864 : if (Sym != SymbolTable_NulSym)
5069 : : {
5070 : 3003629 : SubSymFromUnknownTree (name);
5071 : : }
5072 : 13732864 : return Sym;
5073 : : /* static analysis guarentees a RETURN statement will be used before here. */
5074 : : __builtin_unreachable ();
5075 : : }
5076 : :
5077 : :
5078 : : /*
5079 : : TransparentScope - returns true is the scope symbol Sym is allowed
5080 : : to look to an outer level for a symbol.
5081 : : ie is the symbol allowed to look to the parent
5082 : : scope for a symbol.
5083 : : */
5084 : :
5085 : 53902689 : static bool TransparentScope (unsigned int Sym)
5086 : : {
5087 : 53902689 : SymbolTable_PtrToSymbol pSym;
5088 : :
5089 : 53902689 : pSym = GetPsym (Sym);
5090 : 53902689 : return (pSym->SymbolType != SymbolTable_DefImpSym) && (pSym->SymbolType != SymbolTable_ModuleSym);
5091 : : /* static analysis guarentees a RETURN statement will be used before here. */
5092 : : __builtin_unreachable ();
5093 : : }
5094 : :
5095 : :
5096 : : /*
5097 : : GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
5098 : : the scope before the current module scope.
5099 : : */
5100 : :
5101 : 276 : static unsigned int GetLastModuleOrProcedureScope (void)
5102 : : {
5103 : 276 : SymbolTable_PtrToCallFrame pCall;
5104 : 276 : unsigned int i;
5105 : :
5106 : : /* find current inner module */
5107 : 276 : i = ScopePtr;
5108 : 276 : pCall = GetPcall (i);
5109 : 552 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
5110 : : {
5111 : 0 : M2Debug_Assert (i > 0);
5112 : 0 : i -= 1;
5113 : 0 : pCall = GetPcall (i);
5114 : : }
5115 : : /* found module at position, i. */
5116 : 276 : i -= 1; /* Move to an outer level module or procedure scope */
5117 : 276 : pCall = GetPcall (i); /* Move to an outer level module or procedure scope */
5118 : 552 : while (((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search)))) && (! (SymbolTable_IsProcedure (pCall->Search))))
5119 : : {
5120 : 0 : M2Debug_Assert (i > 0);
5121 : 0 : i -= 1;
5122 : 0 : pCall = GetPcall (i);
5123 : : }
5124 : : /* Found module at position, i. */
5125 : 276 : return pCall->Search;
5126 : : /* static analysis guarentees a RETURN statement will be used before here. */
5127 : : __builtin_unreachable ();
5128 : : }
5129 : :
5130 : :
5131 : : /*
5132 : : AddSymToScope - adds a symbol Sym with name name to
5133 : : the current scope symbol tree.
5134 : : */
5135 : :
5136 : 13568526 : static void AddSymToScope (unsigned int Sym, NameKey_Name name)
5137 : : {
5138 : 13568526 : SymbolTable_PtrToSymbol pSym;
5139 : 13568526 : SymbolTable_PtrToCallFrame pCall;
5140 : 13568526 : unsigned int ScopeId;
5141 : :
5142 : 13568526 : pCall = GetPcall (ScopePtr);
5143 : 13568526 : ScopeId = pCall->Main;
5144 : : /*
5145 : : WriteString('Adding ') ; WriteKey(name) ; WriteString(' :') ; WriteCard(Sym, 4) ; WriteString(' to scope: ') ;
5146 : : WriteKey(GetSymName(ScopeId)) ; WriteLn ;
5147 : : */
5148 : 13568526 : pSym = GetPsym (ScopeId);
5149 : 13568526 : switch (pSym->SymbolType)
5150 : : {
5151 : 4268540 : case SymbolTable_DefImpSym:
5152 : 4268540 : if (name != NameKey_NulName)
5153 : : {
5154 : 4184045 : SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, name, Sym);
5155 : : }
5156 : 4268540 : if (SymbolTable_IsEnumeration (Sym))
5157 : : {
5158 : 21041 : CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
5159 : : }
5160 : : break;
5161 : :
5162 : 1528153 : case SymbolTable_ModuleSym:
5163 : 1528153 : if (name != NameKey_NulName)
5164 : : {
5165 : 1516685 : SymbolKey_PutSymKey (pSym->Module.LocalSymbols, name, Sym);
5166 : : }
5167 : 1528153 : if (SymbolTable_IsEnumeration (Sym))
5168 : : {
5169 : 17735 : CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
5170 : : }
5171 : : break;
5172 : :
5173 : 7771833 : case SymbolTable_ProcedureSym:
5174 : 7771833 : if (name != NameKey_NulName)
5175 : : {
5176 : 7604721 : SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, name, Sym);
5177 : : }
5178 : 7771833 : if (SymbolTable_IsEnumeration (Sym))
5179 : : {
5180 : 0 : CheckEnumerationInList (pSym->Procedure.EnumerationScopeList, Sym);
5181 : : }
5182 : : break;
5183 : :
5184 : :
5185 : 0 : default:
5186 : 0 : M2Error_InternalError ((const char *) "should never get here", 21);
5187 : 13568526 : break;
5188 : : }
5189 : 13568526 : }
5190 : :
5191 : :
5192 : : /*
5193 : : PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
5194 : : Procedure symbols enumeration
5195 : : list onto the scope stack.
5196 : : */
5197 : :
5198 : 18128467 : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym)
5199 : : {
5200 : 18128467 : SymbolTable_PtrToSymbol pSym;
5201 : :
5202 : 18128467 : pSym = GetPsym (Sym);
5203 : 18128467 : switch (pSym->SymbolType)
5204 : : {
5205 : 6136970 : case SymbolTable_DefImpSym:
5206 : 6136970 : PlaceEnumerationListOntoScope (pSym->DefImp.EnumerationScopeList);
5207 : 6136970 : break;
5208 : :
5209 : 76826 : case SymbolTable_ModuleSym:
5210 : 76826 : PlaceEnumerationListOntoScope (pSym->Module.EnumerationScopeList);
5211 : 76826 : break;
5212 : :
5213 : 11914671 : case SymbolTable_ProcedureSym:
5214 : 11914671 : PlaceEnumerationListOntoScope (pSym->Procedure.EnumerationScopeList);
5215 : 11914671 : break;
5216 : :
5217 : :
5218 : 0 : default:
5219 : 0 : M2Error_InternalError ((const char *) "expecting - DefImp, Module or Procedure symbol", 46);
5220 : 18128467 : break;
5221 : : }
5222 : 18128467 : }
5223 : :
5224 : :
5225 : : /*
5226 : : PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
5227 : : scope stack. This list will automatically
5228 : : removed via one call to EndScope which
5229 : : matches the StartScope by which this
5230 : : procedure is invoked.
5231 : : */
5232 : :
5233 : 18128467 : static void PlaceEnumerationListOntoScope (Lists_List l)
5234 : : {
5235 : 18128467 : unsigned int i;
5236 : 18128467 : unsigned int n;
5237 : :
5238 : 18128467 : n = Lists_NoOfItemsInList (l);
5239 : 18128467 : i = 1;
5240 : 36616445 : while (i <= n)
5241 : : {
5242 : 359511 : SymbolTable_PseudoScope (Lists_GetItemFromList (l, i));
5243 : 359511 : i += 1;
5244 : : }
5245 : 18128467 : }
5246 : :
5247 : :
5248 : : /*
5249 : : SetFirstUsed - assigns the FirstUsed field in at to tok providing
5250 : : it has not already been set.
5251 : : */
5252 : :
5253 : 24 : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at)
5254 : : {
5255 : 0 : if ((*at).FirstUsed == M2LexBuf_UnknownTokenNo)
5256 : : {
5257 : 0 : (*at).FirstUsed = tok;
5258 : : }
5259 : 0 : }
5260 : :
5261 : :
5262 : : /*
5263 : : PutFirstUsed - sets tok to the first used providing it has not already been set.
5264 : : It also includes the read and write quad into the usage list
5265 : : providing the quad numbers are not 0.
5266 : : */
5267 : :
5268 : 24 : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_)
5269 : : {
5270 : 24 : SymbolTable_PtrToSymbol pSym;
5271 : :
5272 : 24 : if (SymbolTable_IsVar (object))
5273 : : {
5274 : 24 : pSym = GetPsym (object);
5275 : 24 : SetFirstUsed (tok, &pSym->Var.At);
5276 : 24 : if (read_ != 0)
5277 : : {
5278 : 12 : SymbolTable_PutReadQuad (object, SymbolTable_GetMode (object), read_);
5279 : : }
5280 : 24 : if (write_ != 0)
5281 : : {
5282 : 12 : SymbolTable_PutWriteQuad (object, SymbolTable_GetMode (object), write_);
5283 : : }
5284 : : }
5285 : 24 : }
5286 : :
5287 : :
5288 : : /*
5289 : : CanLookThroughScope - by default this procedure returns TRUE. It only returns
5290 : : FALSE if, throughProcedure, is FALSE and the ScopeSym is
5291 : : a procedure.
5292 : : */
5293 : :
5294 : 34291117 : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure)
5295 : : {
5296 : 34291117 : if (SymbolTable_IsProcedure (ScopeSym))
5297 : : {
5298 : : return throughProcedure;
5299 : : }
5300 : : else
5301 : : {
5302 : 0 : return true;
5303 : : }
5304 : : /* static analysis guarentees a RETURN statement will be used before here. */
5305 : : __builtin_unreachable ();
5306 : : }
5307 : :
5308 : :
5309 : : /*
5310 : : GetScopeSym - searches the current scope and below, providing that the
5311 : : scopes are transparent, for a symbol with name, name.
5312 : : It only passes over procedure scopes if, throughProcedure,
5313 : : is TRUE.
5314 : : */
5315 : :
5316 : 52199315 : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure)
5317 : : {
5318 : 52199315 : SymbolTable_PtrToCallFrame pCall;
5319 : 52199315 : unsigned int ScopeSym;
5320 : 52199315 : unsigned int ScopeId;
5321 : 52199315 : unsigned int Sym;
5322 : :
5323 : : /* DisplayScopes ; */
5324 : 52199315 : ScopeId = ScopePtr;
5325 : 52199315 : pCall = GetPcall (ScopeId);
5326 : 52199315 : ScopeSym = pCall->Search;
5327 : : /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) ; */
5328 : 52199315 : Sym = CheckScopeForSym (ScopeSym, name);
5329 : 204498314 : while ((((ScopeId > 0) && (Sym == SymbolTable_NulSym)) && (TransparentScope (ScopeSym))) && (CanLookThroughScope (ScopeSym, throughProcedure)))
5330 : : {
5331 : 34291117 : ScopeId -= 1;
5332 : 34291117 : pCall = GetPcall (ScopeId);
5333 : 34291117 : ScopeSym = pCall->Search;
5334 : 34291117 : Sym = CheckScopeForSym (ScopeSym, name);
5335 : : }
5336 : : /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) */
5337 : : /* IF Sym#NulSym THEN WriteKey(GetSymName(Sym)) END ; WriteLn ; */
5338 : 52199315 : return Sym;
5339 : : /* static analysis guarentees a RETURN statement will be used before here. */
5340 : : __builtin_unreachable ();
5341 : : }
5342 : :
5343 : :
5344 : : /*
5345 : : CheckScopeForSym - checks the scope, ScopeSym, for an identifier
5346 : : of name, name. CheckScopeForSym checks for
5347 : : the symbol by the GetLocalSym and also
5348 : : ExamineUnresolvedTree.
5349 : : */
5350 : :
5351 : 86490672 : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name)
5352 : : {
5353 : 86490672 : unsigned int Sym;
5354 : :
5355 : 86490672 : Sym = SymbolTable_GetLocalSym (ScopeSym, name);
5356 : 86490672 : if ((Sym == SymbolTable_NulSym) && (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym))))
5357 : : {
5358 : 33632999 : Sym = ExamineUnresolvedTree (ScopeSym, name);
5359 : : }
5360 : 86490672 : return Sym;
5361 : : /* static analysis guarentees a RETURN statement will be used before here. */
5362 : : __builtin_unreachable ();
5363 : : }
5364 : :
5365 : :
5366 : : /*
5367 : : GetModuleScopeId - returns the scope index to the next module starting
5368 : : at index, Id.
5369 : : Id will either point to a null scope (NulSym) or
5370 : : alternatively point to a Module or DefImp symbol.
5371 : : */
5372 : :
5373 : 103000 : static unsigned int GetModuleScopeId (unsigned int Id)
5374 : : {
5375 : 103000 : SymbolTable_PtrToCallFrame pCall;
5376 : 103000 : unsigned int s;
5377 : :
5378 : 103000 : pCall = GetPcall (Id);
5379 : 103000 : s = pCall->Search;
5380 : 169605 : while (((Id > 0) && (s != SymbolTable_NulSym)) && ((! (SymbolTable_IsModule (s))) && (! (SymbolTable_IsDefImp (s)))))
5381 : : {
5382 : 66605 : Id -= 1;
5383 : 66605 : pCall = GetPcall (Id);
5384 : 66605 : s = pCall->Search;
5385 : : }
5386 : 103000 : return Id;
5387 : : /* static analysis guarentees a RETURN statement will be used before here. */
5388 : : __builtin_unreachable ();
5389 : : }
5390 : :
5391 : :
5392 : : /*
5393 : : GetVisibleSym -
5394 : : */
5395 : :
5396 : 30 : static unsigned int GetVisibleSym (NameKey_Name name)
5397 : : {
5398 : 30 : SymbolTable_PtrToCallFrame pCall;
5399 : 30 : unsigned int Sym;
5400 : 30 : unsigned int i;
5401 : :
5402 : 30 : i = ScopePtr;
5403 : 36 : while (i >= 1)
5404 : : {
5405 : 36 : pCall = GetPcall (i);
5406 : 36 : if (pCall->Search == pCall->Main)
5407 : : {
5408 : 24 : return SymbolTable_GetLocalSym (pCall->Main, name);
5409 : : }
5410 : : else
5411 : : {
5412 : 12 : if (SymbolTable_IsEnumeration (pCall->Search))
5413 : : {
5414 : 12 : Sym = SymbolTable_GetLocalSym (pCall->Search, name);
5415 : 12 : if (Sym != SymbolTable_NulSym)
5416 : : {
5417 : 6 : return Sym;
5418 : : }
5419 : : }
5420 : : }
5421 : 6 : i -= 1;
5422 : : }
5423 : : return SymbolTable_NulSym;
5424 : : /* static analysis guarentees a RETURN statement will be used before here. */
5425 : : __builtin_unreachable ();
5426 : : }
5427 : :
5428 : :
5429 : : /*
5430 : : IsAlreadyDeclaredSym - returns true if Sym has already been declared
5431 : : in the current main scope.
5432 : : */
5433 : :
5434 : 13732822 : static bool IsAlreadyDeclaredSym (NameKey_Name name)
5435 : : {
5436 : 13732822 : SymbolTable_PtrToCallFrame pCall;
5437 : 13732822 : unsigned int i;
5438 : :
5439 : 13732822 : i = ScopePtr;
5440 : 16230949 : while (i >= 1)
5441 : : {
5442 : 16230949 : pCall = GetPcall (i);
5443 : 16230949 : if (pCall->Search == pCall->Main)
5444 : : {
5445 : 13732816 : return (SymbolTable_GetLocalSym (pCall->Main, name)) != SymbolTable_NulSym;
5446 : : }
5447 : : else
5448 : : {
5449 : 2498133 : if ((SymbolTable_IsEnumeration (pCall->Search)) && ((SymbolTable_GetLocalSym (pCall->Search, name)) != SymbolTable_NulSym))
5450 : : {
5451 : : return true;
5452 : : }
5453 : : }
5454 : 2498127 : i -= 1;
5455 : : }
5456 : : return false;
5457 : : /* static analysis guarentees a RETURN statement will be used before here. */
5458 : : __builtin_unreachable ();
5459 : : }
5460 : :
5461 : :
5462 : : /*
5463 : : GenName - returns a new name consisting of pre, name, post concatenation.
5464 : : */
5465 : :
5466 : 295140 : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high)
5467 : : {
5468 : 295140 : DynamicStrings_String str;
5469 : 295140 : NameKey_Name result;
5470 : 295140 : char pre[_pre_high+1];
5471 : 295140 : char post[_post_high+1];
5472 : :
5473 : : /* make a local copy of each unbounded array. */
5474 : 295140 : memcpy (pre, pre_, _pre_high+1);
5475 : 295140 : memcpy (post, post_, _post_high+1);
5476 : :
5477 : 295140 : str = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (libname));
5478 : 295140 : str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) pre, _pre_high)));
5479 : 295140 : str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
5480 : 295140 : str = DynamicStrings_ConCat (str, DynamicStrings_InitString ((const char *) post, _post_high));
5481 : 295140 : result = NameKey_makekey (DynamicStrings_string (str));
5482 : 295140 : str = DynamicStrings_KillString (str);
5483 : 295140 : return result;
5484 : : /* static analysis guarentees a RETURN statement will be used before here. */
5485 : : __builtin_unreachable ();
5486 : 295140 : }
5487 : :
5488 : :
5489 : : /*
5490 : : InitCtor - initialize the ModuleCtor fields to NulSym.
5491 : : */
5492 : :
5493 : 169363 : static void InitCtor (SymbolTable_ModuleCtor *ctor)
5494 : : {
5495 : 169363 : (*ctor).ctor = SymbolTable_NulSym;
5496 : 169363 : (*ctor).dep = SymbolTable_NulSym;
5497 : 169363 : (*ctor).init = SymbolTable_NulSym;
5498 : 169363 : (*ctor).fini = SymbolTable_NulSym;
5499 : 0 : }
5500 : :
5501 : :
5502 : : /*
5503 : : InitCtorFields - initialize the ModuleCtor fields. An inner module has no
5504 : : ctor procedure.
5505 : : */
5506 : :
5507 : 63568 : 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)
5508 : : {
5509 : 63568 : if (M2Options_ScaffoldDynamic && ! inner)
5510 : : {
5511 : : /* The ctor procedure must be public. */
5512 : 62914 : (*ctor).ctor = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_ctor", 5));
5513 : 62914 : SymbolTable_PutCtor ((*ctor).ctor, true);
5514 : 62914 : M2Debug_Assert (pub);
5515 : 62914 : SymbolTable_PutPublic ((*ctor).ctor, pub);
5516 : 62914 : SymbolTable_PutExtern ((*ctor).ctor, ! pub);
5517 : 62914 : SymbolTable_PutMonoName ((*ctor).ctor, true);
5518 : : /* The dep procedure is local to the module. */
5519 : 62914 : (*ctor).dep = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_dep", 4));
5520 : 62914 : SymbolTable_PutMonoName ((*ctor).dep, true);
5521 : : }
5522 : : else
5523 : : {
5524 : 654 : (*ctor).ctor = SymbolTable_NulSym;
5525 : 654 : (*ctor).dep = SymbolTable_NulSym;
5526 : : }
5527 : : /* The init/fini procedures must be public. */
5528 : 63568 : (*ctor).init = SymbolTable_MakeProcedure (beginTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_init", 5));
5529 : 63568 : SymbolTable_PutPublic ((*ctor).init, pub);
5530 : 63568 : SymbolTable_PutExtern ((*ctor).init, ! pub);
5531 : 63568 : SymbolTable_PutMonoName ((*ctor).init, ! inner);
5532 : 63568 : M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).init);
5533 : 63568 : (*ctor).fini = SymbolTable_MakeProcedure (finallyTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_fini", 5));
5534 : 63568 : SymbolTable_PutPublic ((*ctor).fini, pub);
5535 : 63568 : SymbolTable_PutExtern ((*ctor).fini, ! pub);
5536 : 63568 : SymbolTable_PutMonoName ((*ctor).fini, ! inner);
5537 : 63568 : M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).fini);
5538 : 63568 : }
5539 : :
5540 : :
5541 : : /*
5542 : : CheckTok - checks to see that tok is at a known location. If not
5543 : : it uses GetTokenNo as a fall back.
5544 : : */
5545 : :
5546 : 12754901 : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high)
5547 : : {
5548 : 12754901 : DynamicStrings_String s;
5549 : 12754901 : char name[_name_high+1];
5550 : :
5551 : : /* make a local copy of each unbounded array. */
5552 : 12754901 : memcpy (name, name_, _name_high+1);
5553 : :
5554 : 12754901 : if (tok == M2LexBuf_UnknownTokenNo)
5555 : : {
5556 : 39564 : tok = M2LexBuf_GetTokenNo ();
5557 : 39564 : if (DebugUnknownToken)
5558 : : {
5559 : : s = DynamicStrings_InitString ((const char *) name, _name_high);
5560 : : s = DynamicStrings_ConCat (s, DynamicStrings_InitString ((const char *) " symbol {%W} has been created with an unknown token location", 60));
5561 : : M2MetaError_MetaErrorStringT0 (M2LexBuf_GetTokenNo (), s);
5562 : : }
5563 : : }
5564 : 12754901 : return tok;
5565 : : /* static analysis guarentees a RETURN statement will be used before here. */
5566 : : __builtin_unreachable ();
5567 : 0 : }
5568 : :
5569 : :
5570 : : /*
5571 : : GetLink - returns TRUE if the current module is only used for linkage.
5572 : : */
5573 : :
5574 : 311063 : static bool GetLink (void)
5575 : : {
5576 : 311063 : unsigned int OuterModule;
5577 : :
5578 : 311063 : OuterModule = SymbolTable_GetCurrentModule ();
5579 : 311063 : if (OuterModule != SymbolTable_NulSym)
5580 : : {
5581 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
5582 : 294246 : if (M2Comp_CompilingDefinitionModule ())
5583 : : {
5584 : 4454 : return SymbolTable_IsDefLink (OuterModule);
5585 : : }
5586 : : else
5587 : : {
5588 : 289792 : return SymbolTable_IsModLink (OuterModule);
5589 : : }
5590 : : }
5591 : : /* Default is that the module is for compiling. */
5592 : : return false;
5593 : : /* static analysis guarentees a RETURN statement will be used before here. */
5594 : : __builtin_unreachable ();
5595 : : }
5596 : :
5597 : :
5598 : : /*
5599 : : AddModuleToParent - adds symbol, Sym, to module, Parent.
5600 : : */
5601 : :
5602 : 420 : static void AddModuleToParent (unsigned int Sym, unsigned int Parent)
5603 : : {
5604 : 420 : SymbolTable_PtrToSymbol pSym;
5605 : :
5606 : 420 : pSym = GetPsym (Parent);
5607 : 420 : switch (pSym->SymbolType)
5608 : : {
5609 : 18 : case SymbolTable_DefImpSym:
5610 : 18 : Lists_PutItemIntoList (pSym->DefImp.ListOfModules, Sym);
5611 : 18 : break;
5612 : :
5613 : 246 : case SymbolTable_ModuleSym:
5614 : 246 : Lists_PutItemIntoList (pSym->Module.ListOfModules, Sym);
5615 : 246 : break;
5616 : :
5617 : 156 : case SymbolTable_ProcedureSym:
5618 : 156 : Lists_PutItemIntoList (pSym->Procedure.ListOfModules, Sym);
5619 : 156 : break;
5620 : :
5621 : :
5622 : 0 : default:
5623 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
5624 : 420 : break;
5625 : : }
5626 : 420 : }
5627 : :
5628 : :
5629 : : /*
5630 : : PutProcedureExternPublic - if procedure is not NulSym set extern
5631 : : and public booleans.
5632 : : */
5633 : :
5634 : 303352 : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub)
5635 : : {
5636 : 303352 : if (procedure != SymbolTable_NulSym)
5637 : : {
5638 : 303352 : SymbolTable_PutExtern (procedure, extern_);
5639 : 303352 : SymbolTable_PutPublic (procedure, pub);
5640 : : }
5641 : 303352 : }
5642 : :
5643 : :
5644 : : /*
5645 : : PutCtorExtern -
5646 : : */
5647 : :
5648 : 75838 : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_)
5649 : : {
5650 : : /* If the ctor does not exist then make it extern/ (~extern) public. */
5651 : 75838 : if ((*ctor).ctor == SymbolTable_NulSym)
5652 : : {
5653 : 10640 : (*ctor).ctor = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_ctor", 5));
5654 : 10640 : SymbolTable_PutMonoName ((*ctor).ctor, true);
5655 : : }
5656 : 75838 : PutProcedureExternPublic ((*ctor).ctor, extern_, ! extern_);
5657 : 75838 : SymbolTable_PutCtor ((*ctor).ctor, true);
5658 : : /* If the ctor does not exist then make it extern/ (~extern) public. */
5659 : 75838 : if ((*ctor).dep == SymbolTable_NulSym)
5660 : : {
5661 : 10640 : (*ctor).dep = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_dep", 4));
5662 : 10640 : SymbolTable_PutMonoName ((*ctor).dep, true);
5663 : : }
5664 : 75838 : PutProcedureExternPublic ((*ctor).dep, extern_, ! extern_);
5665 : : /* If init/fini do not exist then create them. */
5666 : 75838 : if ((*ctor).init == SymbolTable_NulSym)
5667 : : {
5668 : 10448 : (*ctor).init = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_init", 5));
5669 : 10448 : M2Scaffold_DeclareArgEnvParams (tok, (*ctor).init);
5670 : 10448 : SymbolTable_PutMonoName ((*ctor).init, ! (SymbolTable_IsInnerModule (sym)));
5671 : : }
5672 : 75838 : PutProcedureExternPublic ((*ctor).init, extern_, ! extern_);
5673 : 75838 : if ((*ctor).fini == SymbolTable_NulSym)
5674 : : {
5675 : 10448 : (*ctor).fini = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_fini", 5));
5676 : 10448 : M2Scaffold_DeclareArgEnvParams (tok, (*ctor).fini);
5677 : 10448 : SymbolTable_PutMonoName ((*ctor).fini, ! (SymbolTable_IsInnerModule (sym)));
5678 : : }
5679 : 75838 : PutProcedureExternPublic ((*ctor).fini, extern_, ! extern_);
5680 : 75838 : }
5681 : :
5682 : :
5683 : : /*
5684 : : AddProcedureToList - adds a procedure, Proc, to the list of procedures
5685 : : in module, Mod.
5686 : : */
5687 : :
5688 : 3451105 : static void AddProcedureToList (unsigned int Mod, unsigned int Proc)
5689 : : {
5690 : 3451105 : SymbolTable_PtrToSymbol pSym;
5691 : :
5692 : 3451105 : pSym = GetPsym (Mod);
5693 : 3451105 : switch (pSym->SymbolType)
5694 : : {
5695 : 2767736 : case SymbolTable_DefImpSym:
5696 : 2767736 : Lists_PutItemIntoList (pSym->DefImp.ListOfProcs, Proc);
5697 : 2767736 : break;
5698 : :
5699 : 682967 : case SymbolTable_ModuleSym:
5700 : 682967 : Lists_PutItemIntoList (pSym->Module.ListOfProcs, Proc);
5701 : 682967 : break;
5702 : :
5703 : 402 : case SymbolTable_ProcedureSym:
5704 : 402 : Lists_PutItemIntoList (pSym->Procedure.ListOfProcs, Proc);
5705 : 402 : break;
5706 : :
5707 : :
5708 : 0 : default:
5709 : 0 : M2Error_InternalError ((const char *) "expecting ModuleSym, DefImpSym or ProcedureSym symbol", 53);
5710 : 3451105 : break;
5711 : : }
5712 : 3451105 : }
5713 : :
5714 : :
5715 : : /*
5716 : : AddVarToScopeList - adds symbol, sym, to, scope.
5717 : : */
5718 : :
5719 : 7719797 : static void AddVarToScopeList (unsigned int scope, unsigned int sym)
5720 : : {
5721 : 7719797 : SymbolTable_PtrToSymbol pSym;
5722 : :
5723 : 7719797 : pSym = GetPsym (scope);
5724 : 7719797 : switch (pSym->SymbolType)
5725 : : {
5726 : 7517279 : case SymbolTable_ProcedureSym:
5727 : 7517279 : Lists_PutItemIntoList (pSym->Procedure.ListOfVars, sym);
5728 : 7517279 : break;
5729 : :
5730 : 96224 : case SymbolTable_ModuleSym:
5731 : 96224 : Lists_PutItemIntoList (pSym->Module.ListOfVars, sym);
5732 : 96224 : break;
5733 : :
5734 : 106294 : case SymbolTable_DefImpSym:
5735 : 106294 : Lists_PutItemIntoList (pSym->DefImp.ListOfVars, sym);
5736 : 106294 : break;
5737 : :
5738 : :
5739 : 0 : default:
5740 : 0 : M2Error_InternalError ((const char *) "expecting Procedure or Module symbol", 36);
5741 : 7719797 : break;
5742 : : }
5743 : 7719797 : }
5744 : :
5745 : :
5746 : : /*
5747 : : AddVarToList - add a variable symbol to the list of variables maintained
5748 : : by the inner most scope. (Procedure or Module).
5749 : : */
5750 : :
5751 : 7719779 : static void AddVarToList (unsigned int Sym)
5752 : : {
5753 : 7719779 : SymbolTable_PtrToCallFrame pCall;
5754 : :
5755 : 7719779 : pCall = GetPcall (ScopePtr);
5756 : 7719779 : AddVarToScopeList (pCall->Main, Sym);
5757 : 7719779 : }
5758 : :
5759 : :
5760 : : /*
5761 : : FillInRecordFields - given a new symbol, sym, make it a record symbol
5762 : : and initialize its fields.
5763 : : */
5764 : :
5765 : 84243 : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf)
5766 : : {
5767 : 84243 : SymbolTable_PtrToSymbol pSym;
5768 : :
5769 : 84243 : if (! (SymbolTable_IsError (sym)))
5770 : : {
5771 : 84237 : pSym = GetPsym (sym);
5772 : 84237 : pSym->SymbolType = SymbolTable_RecordSym;
5773 : 84237 : pSym->Record.name = RecordName;
5774 : 84237 : SymbolKey_InitTree (&pSym->Record.LocalSymbols);
5775 : 84237 : pSym->Record.Size = M2ALU_InitValue ();
5776 : 84237 : Lists_InitList (&pSym->Record.ListOfSons); /* List of RecordFieldSym and VarientSym */
5777 : 84237 : pSym->Record.oafamily = oaf; /* List of RecordFieldSym and VarientSym */
5778 : 84237 : pSym->Record.Parent = SymbolTable_NulSym;
5779 : 84237 : pSym->Record.Align = SymbolTable_NulSym;
5780 : 84237 : pSym->Record.DefaultAlign = SymbolTable_NulSym;
5781 : 84237 : pSym->Record.DeclPacked = false;
5782 : 84237 : pSym->Record.DeclResolved = false;
5783 : 84237 : pSym->Record.Scope = scope;
5784 : 84237 : InitWhereDeclaredTok (tok, &pSym->Record.At);
5785 : : }
5786 : 84243 : }
5787 : :
5788 : :
5789 : : /*
5790 : : HandleHiddenOrDeclare -
5791 : : */
5792 : :
5793 : 1221054 : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf)
5794 : : {
5795 : 1221054 : unsigned int sym;
5796 : :
5797 : 1221054 : sym = CheckForHiddenType (name);
5798 : 1221054 : if (sym == SymbolTable_NulSym)
5799 : : {
5800 : 1211688 : sym = DeclareSym (tok, name);
5801 : 1211688 : if (! (SymbolTable_IsError (sym)))
5802 : : {
5803 : : /* Now add this type to the symbol table of the current scope */
5804 : 1211676 : AddSymToScope (sym, name);
5805 : : }
5806 : : }
5807 : 1221054 : (*oaf) = SymbolTable_GetOAFamily (sym);
5808 : 1221054 : return sym;
5809 : : /* static analysis guarentees a RETURN statement will be used before here. */
5810 : : __builtin_unreachable ();
5811 : : }
5812 : :
5813 : :
5814 : : /*
5815 : : CreateConstLit -
5816 : : */
5817 : :
5818 : 546807 : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
5819 : : {
5820 : 546807 : SymbolTable_PtrToSymbol pSym;
5821 : 546807 : unsigned int Sym;
5822 : 546807 : bool overflow;
5823 : :
5824 : 546807 : overflow = false;
5825 : 546807 : if (constType == SymbolTable_NulSym)
5826 : : {
5827 : 407346 : constType = GetConstLitType (tok, constName, &overflow, true);
5828 : : }
5829 : 546807 : NewSym (&Sym);
5830 : 546807 : pSym = GetPsym (Sym);
5831 : 546807 : pSym->SymbolType = SymbolTable_ConstLitSym;
5832 : 546807 : switch (pSym->SymbolType)
5833 : : {
5834 : 546807 : case SymbolTable_ConstLitSym:
5835 : 546807 : pSym->ConstLit.name = constName;
5836 : 546807 : pSym->ConstLit.Value = M2ALU_InitValue ();
5837 : 546807 : M2ALU_PushString (tok, constName, ! overflow);
5838 : 546807 : M2ALU_PopInto (pSym->ConstLit.Value);
5839 : 546807 : pSym->ConstLit.Type = constType;
5840 : 546807 : pSym->ConstLit.IsSet = false;
5841 : 546807 : pSym->ConstLit.IsInternal = false; /* Is it a default BY constant
5842 : : expression? */
5843 : 546807 : pSym->ConstLit.IsConstructor = false; /* Is it a default BY constant
5844 : : expression? */
5845 : 546807 : pSym->ConstLit.FromType = SymbolTable_NulSym; /* type is determined FromType */
5846 : 546807 : pSym->ConstLit.RangeError = overflow; /* type is determined FromType */
5847 : 546807 : pSym->ConstLit.UnresFromType = false; /* is Type resolved? */
5848 : 546807 : pSym->ConstLit.Scope = SymbolTable_GetCurrentScope (); /* is Type resolved? */
5849 : 546807 : InitWhereDeclaredTok (tok, &pSym->ConstLit.At);
5850 : 546807 : InitWhereFirstUsedTok (tok, &pSym->ConstLit.At);
5851 : 546807 : break;
5852 : :
5853 : :
5854 : : default:
5855 : : M2Error_InternalError ((const char *) "expecting ConstLit symbol", 25);
5856 : 546807 : break;
5857 : : }
5858 : 546807 : return Sym;
5859 : : /* static analysis guarentees a RETURN statement will be used before here. */
5860 : : __builtin_unreachable ();
5861 : : }
5862 : :
5863 : :
5864 : : /*
5865 : : LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
5866 : : matches tok, constName and constType.
5867 : : */
5868 : :
5869 : 1098455 : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType)
5870 : : {
5871 : 1098455 : SymbolTable_ConstLitPoolEntry pe;
5872 : 1098455 : unsigned int rootIndex;
5873 : :
5874 : 1098455 : rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
5875 : 1098455 : if (rootIndex != 0)
5876 : : {
5877 : 809754 : pe = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
5878 : 7692393 : while (pe != NULL)
5879 : : {
5880 : 6624533 : if (((pe->tok == tok) && (pe->constName == constName)) && (pe->constType == constType))
5881 : : {
5882 : 551648 : return pe->sym;
5883 : : }
5884 : 6072885 : pe = pe->next;
5885 : : }
5886 : : }
5887 : : return SymbolTable_NulSym;
5888 : : /* static analysis guarentees a RETURN statement will be used before here. */
5889 : : __builtin_unreachable ();
5890 : : }
5891 : :
5892 : :
5893 : : /*
5894 : : AddConstLitPoolEntry - adds sym to the constlit pool.
5895 : : */
5896 : :
5897 : 546807 : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType)
5898 : : {
5899 : 546807 : SymbolTable_ConstLitPoolEntry pe;
5900 : 546807 : SymbolTable_ConstLitPoolEntry old;
5901 : 546807 : unsigned int rootIndex;
5902 : 546807 : unsigned int high;
5903 : :
5904 : 546807 : rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
5905 : 546807 : if (rootIndex == SymbolKey_NulKey)
5906 : : {
5907 : 288701 : high = Indexing_HighIndice (ConstLitArray);
5908 : 288701 : Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
5909 : 288701 : if (pe == NULL)
5910 : : {
5911 : 0 : M2Error_InternalError ((const char *) "out of memory", 13);
5912 : : }
5913 : : else
5914 : : {
5915 : 288701 : pe->sym = sym;
5916 : 288701 : pe->tok = tok;
5917 : 288701 : pe->constName = constName;
5918 : 288701 : pe->constType = constType;
5919 : 288701 : pe->next = NULL;
5920 : 288701 : SymbolKey_PutSymKey (ConstLitPoolTree, constName, high+1);
5921 : 288701 : Indexing_PutIndice (ConstLitArray, high+1, reinterpret_cast<void *> (pe));
5922 : : }
5923 : : }
5924 : : else
5925 : : {
5926 : 258106 : Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
5927 : 258106 : if (pe == NULL)
5928 : : {
5929 : 0 : M2Error_InternalError ((const char *) "out of memory", 13);
5930 : : }
5931 : : else
5932 : : {
5933 : 258106 : old = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
5934 : 258106 : pe->sym = sym;
5935 : 258106 : pe->tok = tok;
5936 : 258106 : pe->constName = constName;
5937 : 258106 : pe->constType = constType;
5938 : 258106 : pe->next = old;
5939 : 258106 : Indexing_PutIndice (ConstLitArray, rootIndex, reinterpret_cast<void *> (pe));
5940 : : }
5941 : : }
5942 : 546807 : }
5943 : :
5944 : :
5945 : : /*
5946 : : InitConstString - initialize the constant string.
5947 : : */
5948 : :
5949 : 320205 : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known)
5950 : : {
5951 : 320205 : SymbolTable_PtrToSymbol pSym;
5952 : :
5953 : 320205 : pSym = GetPsym (sym);
5954 : 320205 : pSym->SymbolType = SymbolTable_ConstStringSym;
5955 : 320205 : switch (pSym->SymbolType)
5956 : : {
5957 : 320205 : case SymbolTable_ConstStringSym:
5958 : 320205 : pSym->ConstString.name = name;
5959 : 320205 : pSym->ConstString.StringVariant = kind;
5960 : 320205 : pSym->ConstString.Scope = SymbolTable_GetCurrentScope ();
5961 : 320205 : InitWhereDeclaredTok (tok, &pSym->ConstString.At);
5962 : 320205 : SymbolTable_PutConstStringKnown (tok, sym, contents, escape, known);
5963 : 320205 : break;
5964 : :
5965 : :
5966 : : default:
5967 : : M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
5968 : 320205 : break;
5969 : : }
5970 : 320205 : }
5971 : :
5972 : :
5973 : : /*
5974 : : GetConstStringKind - return the StringVariant field associated with sym.
5975 : : */
5976 : :
5977 : 272012 : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym)
5978 : : {
5979 : 272012 : SymbolTable_PtrToSymbol pSym;
5980 : :
5981 : 272012 : pSym = GetPsym (sym);
5982 : 272012 : switch (pSym->SymbolType)
5983 : : {
5984 : 272012 : case SymbolTable_ConstStringSym:
5985 : 272012 : return pSym->ConstString.StringVariant;
5986 : 0 : break;
5987 : :
5988 : :
5989 : 0 : default:
5990 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
5991 : : break;
5992 : : }
5993 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
5994 : : __builtin_unreachable ();
5995 : : }
5996 : :
5997 : :
5998 : : /*
5999 : : CanUseBuiltin - returns TRUE if the procedure, Sym, can be
6000 : : inlined via a builtin function.
6001 : : */
6002 : :
6003 : 7194 : static bool CanUseBuiltin (unsigned int Sym)
6004 : : {
6005 : 7194 : return ! M2Options_DebugBuiltins && ((m2builtins_BuiltinExists (NameKey_KeyToCharStar (SymbolTable_GetProcedureBuiltin (Sym)))) || (m2builtins_BuiltinExists (NameKey_KeyToCharStar (SymbolTable_GetSymName (Sym)))));
6006 : : /* static analysis guarentees a RETURN statement will be used before here. */
6007 : : __builtin_unreachable ();
6008 : : }
6009 : :
6010 : :
6011 : : /*
6012 : : InitPacked - initialise packedInfo to FALSE and NulSym.
6013 : : */
6014 : :
6015 : 911853 : static void InitPacked (SymbolTable_PackedInfo *packedInfo)
6016 : : {
6017 : 911853 : (*packedInfo).IsPacked = false;
6018 : 911853 : (*packedInfo).PackedEquiv = SymbolTable_NulSym;
6019 : 0 : }
6020 : :
6021 : :
6022 : : /*
6023 : : doEquivalent - create a packed equivalent symbol for, sym, and return the
6024 : : new symbol. It sets both fields in packedInfo to FALSE
6025 : : and the new symbol.
6026 : : */
6027 : :
6028 : 16404 : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
6029 : : {
6030 : 16404 : unsigned int nSym;
6031 : 16404 : SymbolTable_PtrToSymbol pSym;
6032 : :
6033 : 16404 : NewSym (&nSym);
6034 : 16404 : pSym = GetPsym (nSym);
6035 : 16404 : pSym->SymbolType = SymbolTable_EquivSym;
6036 : 16404 : pSym->Equiv.nonPacked = sym;
6037 : 16404 : pSym->Equiv.packedInfo.IsPacked = true;
6038 : 16404 : pSym->Equiv.packedInfo.PackedEquiv = SymbolTable_NulSym;
6039 : 16404 : (*packedInfo).IsPacked = false;
6040 : 16404 : (*packedInfo).PackedEquiv = nSym;
6041 : 16404 : return nSym;
6042 : : /* static analysis guarentees a RETURN statement will be used before here. */
6043 : : __builtin_unreachable ();
6044 : : }
6045 : :
6046 : :
6047 : : /*
6048 : : MakeEquivalent - return the equivalent packed symbol for, sym.
6049 : : */
6050 : :
6051 : 16404 : static unsigned int MakeEquivalent (unsigned int sym)
6052 : : {
6053 : 16404 : SymbolTable_PtrToSymbol pSym;
6054 : :
6055 : 16404 : pSym = GetPsym (sym);
6056 : 16404 : switch (pSym->SymbolType)
6057 : : {
6058 : 16344 : case SymbolTable_EnumerationSym:
6059 : 16344 : return doEquivalent (&pSym->Enumeration.packedInfo, sym);
6060 : 60 : break;
6061 : :
6062 : 60 : case SymbolTable_SubrangeSym:
6063 : 60 : return doEquivalent (&pSym->Subrange.packedInfo, sym);
6064 : 0 : break;
6065 : :
6066 : 0 : case SymbolTable_TypeSym:
6067 : 0 : return doEquivalent (&pSym->Type.packedInfo, sym);
6068 : 0 : break;
6069 : :
6070 : 0 : case SymbolTable_SetSym:
6071 : 0 : return doEquivalent (&pSym->Set.packedInfo, sym);
6072 : 0 : break;
6073 : :
6074 : :
6075 : 0 : default:
6076 : 0 : M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
6077 : : break;
6078 : : }
6079 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6080 : : __builtin_unreachable ();
6081 : : }
6082 : :
6083 : :
6084 : : /*
6085 : : GetEquivalent -
6086 : : */
6087 : :
6088 : 16644 : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
6089 : : {
6090 : 16644 : if ((*packedInfo).IsPacked)
6091 : : {
6092 : : return sym;
6093 : : }
6094 : 16644 : else if ((*packedInfo).PackedEquiv == SymbolTable_NulSym)
6095 : : {
6096 : : /* avoid dangling else. */
6097 : 16404 : (*packedInfo).PackedEquiv = MakeEquivalent (sym);
6098 : : }
6099 : 16644 : return (*packedInfo).PackedEquiv;
6100 : : /* static analysis guarentees a RETURN statement will be used before here. */
6101 : : __builtin_unreachable ();
6102 : : }
6103 : :
6104 : :
6105 : : /*
6106 : : doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
6107 : : */
6108 : :
6109 : 332178657 : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase)
6110 : : {
6111 : 332178657 : SymbolTable_PtrToSymbol pSym;
6112 : 332178657 : unsigned int type;
6113 : :
6114 : 332178657 : type = SymbolTable_NulSym;
6115 : 332178657 : M2Debug_Assert (sym != SymbolTable_NulSym);
6116 : 332178657 : pSym = GetPsym (sym);
6117 : 332178657 : switch (pSym->SymbolType)
6118 : : {
6119 : 0 : case SymbolTable_OAFamilySym:
6120 : 0 : type = pSym->OAFamily.SimpleType;
6121 : 0 : break;
6122 : :
6123 : 65258947 : case SymbolTable_VarSym:
6124 : 65258947 : type = GetTypeOfVar (sym);
6125 : 65258947 : break;
6126 : :
6127 : 15210288 : case SymbolTable_ConstLitSym:
6128 : 15210288 : type = pSym->ConstLit.Type;
6129 : 15210288 : break;
6130 : :
6131 : 12065688 : case SymbolTable_ConstVarSym:
6132 : 12065688 : type = pSym->ConstVar.Type;
6133 : 12065688 : break;
6134 : :
6135 : 3390191 : case SymbolTable_ConstStringSym:
6136 : 3390191 : if (pSym->ConstString.Length == 1)
6137 : : {
6138 : 597421 : type = M2Base_Char;
6139 : : }
6140 : : else
6141 : : {
6142 : : type = SymbolTable_NulSym; /* No type for a string */
6143 : : }
6144 : : break;
6145 : :
6146 : 49437863 : case SymbolTable_TypeSym:
6147 : 49437863 : type = pSym->Type.Type;
6148 : 49437863 : break;
6149 : :
6150 : 83865846 : case SymbolTable_RecordFieldSym:
6151 : 83865846 : type = pSym->RecordField.Type;
6152 : 83865846 : break;
6153 : :
6154 : : case SymbolTable_RecordSym:
6155 : : type = SymbolTable_NulSym; /* No type for a record */
6156 : : break;
6157 : :
6158 : : case SymbolTable_VarientSym:
6159 : : type = SymbolTable_NulSym; /* No type for a record */
6160 : : break;
6161 : :
6162 : 24344079 : case SymbolTable_EnumerationFieldSym:
6163 : 24344079 : type = pSym->EnumerationField.Type; /* No type for a record */
6164 : 24344079 : break;
6165 : :
6166 : : case SymbolTable_EnumerationSym:
6167 : : type = SymbolTable_NulSym; /* No type for enumeration */
6168 : : break;
6169 : :
6170 : 24820334 : case SymbolTable_PointerSym:
6171 : 24820334 : type = pSym->Pointer.Type; /* No type for enumeration */
6172 : 24820334 : break;
6173 : :
6174 : 7866439 : case SymbolTable_ProcedureSym:
6175 : 7866439 : type = pSym->Procedure.ReturnType;
6176 : 7866439 : break;
6177 : :
6178 : 4751108 : case SymbolTable_ProcTypeSym:
6179 : 4751108 : type = pSym->ProcType.ReturnType;
6180 : 4751108 : break;
6181 : :
6182 : 11986134 : case SymbolTable_ParamSym:
6183 : 11986134 : type = pSym->Param.Type;
6184 : 11986134 : break;
6185 : :
6186 : 2187702 : case SymbolTable_VarParamSym:
6187 : 2187702 : type = pSym->VarParam.Type;
6188 : 2187702 : break;
6189 : :
6190 : 8995708 : case SymbolTable_SubrangeSym:
6191 : 8995708 : type = pSym->Subrange.Type;
6192 : 8995708 : break;
6193 : :
6194 : 3598442 : case SymbolTable_ArraySym:
6195 : 3598442 : type = pSym->Array.Type;
6196 : 3598442 : break;
6197 : :
6198 : 4378847 : case SymbolTable_SubscriptSym:
6199 : 4378847 : type = pSym->Subscript.Type;
6200 : 4378847 : break;
6201 : :
6202 : 1326627 : case SymbolTable_SetSym:
6203 : 1326627 : type = pSym->Set.Type;
6204 : 1326627 : break;
6205 : :
6206 : 8665506 : case SymbolTable_UnboundedSym:
6207 : 8665506 : type = pSym->Unbounded.Type;
6208 : 8665506 : break;
6209 : :
6210 : : case SymbolTable_UndefinedSym:
6211 : : type = SymbolTable_NulSym;
6212 : : break;
6213 : :
6214 : 0 : case SymbolTable_PartialUnboundedSym:
6215 : 0 : type = pSym->PartialUnbounded.Type;
6216 : 0 : break;
6217 : :
6218 : : case SymbolTable_ObjectSym:
6219 : : type = SymbolTable_NulSym;
6220 : : break;
6221 : :
6222 : :
6223 : 0 : default:
6224 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
6225 : 329356979 : break;
6226 : : }
6227 : 332178657 : if (((type == SymbolTable_NulSym) && (SymbolTable_IsType (sym))) && ! skipBase)
6228 : : {
6229 : : return sym; /* sym is a base type */
6230 : : }
6231 : 323428101 : else if (type != SymbolTable_NulSym)
6232 : : {
6233 : : /* avoid dangling else. */
6234 : 267612536 : if ((SymbolTable_IsType (type)) && skipEquiv)
6235 : : {
6236 : 9266302 : if ((! (SymbolTable_IsHiddenType (type))) || skipHidden)
6237 : : {
6238 : 9121135 : if (((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym) || skipAlign)
6239 : : {
6240 : 9121117 : return doGetType (type, skipEquiv, skipAlign, skipHidden, skipBase);
6241 : : }
6242 : : }
6243 : : }
6244 : : }
6245 : : return type;
6246 : : /* static analysis guarentees a RETURN statement will be used before here. */
6247 : : __builtin_unreachable ();
6248 : : }
6249 : :
6250 : :
6251 : : /*
6252 : : GetTypeOfVar - returns the type of symbol, var.
6253 : : */
6254 : :
6255 : 104643022 : static unsigned int GetTypeOfVar (unsigned int var)
6256 : : {
6257 : 104643022 : SymbolTable_PtrToSymbol pSym;
6258 : 104643022 : unsigned int high;
6259 : :
6260 : 104643022 : pSym = GetPsym (var);
6261 : 104643022 : switch (pSym->SymbolType)
6262 : : {
6263 : 104643022 : case SymbolTable_VarSym:
6264 : 104643022 : if (pSym->Var.IsTemp && pSym->Var.IsComponentRef)
6265 : : {
6266 : 2792249 : high = Indexing_HighIndice (pSym->Var.list);
6267 : 5584498 : return SymbolTable_GetType (GetFromIndex (pSym->Var.list, high));
6268 : : }
6269 : : else
6270 : : {
6271 : 101850773 : return pSym->Var.Type;
6272 : : }
6273 : 0 : break;
6274 : :
6275 : :
6276 : 0 : default:
6277 : 0 : M2Error_InternalError ((const char *) "expecting a var symbol", 22);
6278 : : break;
6279 : : }
6280 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6281 : : __builtin_unreachable ();
6282 : : }
6283 : :
6284 : :
6285 : : /*
6286 : : GetConstLitType - returns the type of the constant of, name.
6287 : : All floating point constants have type LONGREAL.
6288 : : Character constants are type CHAR.
6289 : : Integer values are INTEGER, LONGINT or LONGCARD
6290 : : depending upon their value.
6291 : : */
6292 : :
6293 : 407346 : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError)
6294 : : {
6295 : 407346 : m2linemap_location_t loc;
6296 : 407346 : DynamicStrings_String s;
6297 : :
6298 : 407346 : s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name));
6299 : 407346 : if ((DynamicStrings_char (s, -1)) == 'C')
6300 : : {
6301 : 114794 : s = DynamicStrings_KillString (s);
6302 : 114794 : return M2Base_Char;
6303 : : }
6304 : : else
6305 : : {
6306 : 292552 : if ((DynamicStrings_Index (s, '.', 0)) != -1) /* found a '.' in our constant */
6307 : : {
6308 : 6406 : s = DynamicStrings_KillString (s);
6309 : 6406 : return M2Base_RType;
6310 : : }
6311 : 286146 : loc = M2LexBuf_TokenToLocation (tok);
6312 : 286146 : switch (DynamicStrings_char (s, -1))
6313 : : {
6314 : 742 : case 'H':
6315 : 742 : (*overflow) = m2expr_OverflowZType (loc, DynamicStrings_string (s), 16, issueError);
6316 : 742 : break;
6317 : :
6318 : 2446 : case 'B':
6319 : 2446 : (*overflow) = m2expr_OverflowZType (loc, DynamicStrings_string (s), 8, issueError);
6320 : 2446 : break;
6321 : :
6322 : 24 : case 'A':
6323 : 24 : (*overflow) = m2expr_OverflowZType (loc, DynamicStrings_string (s), 2, issueError);
6324 : 24 : break;
6325 : :
6326 : :
6327 : 282934 : default:
6328 : 282934 : (*overflow) = m2expr_OverflowZType (loc, DynamicStrings_string (s), 10, issueError);
6329 : 282934 : break;
6330 : : }
6331 : 286146 : s = DynamicStrings_KillString (s);
6332 : 286146 : return M2Base_ZType;
6333 : : }
6334 : : /* static analysis guarentees a RETURN statement will be used before here. */
6335 : : __builtin_unreachable ();
6336 : : }
6337 : :
6338 : :
6339 : : /*
6340 : : GetNthFromComponent -
6341 : : */
6342 : :
6343 : 758730 : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n)
6344 : : {
6345 : 758730 : SymbolTable_PtrToSymbol pSym;
6346 : :
6347 : 758730 : pSym = GetPsym (Sym);
6348 : 758730 : switch (pSym->SymbolType)
6349 : : {
6350 : 758730 : case SymbolTable_VarSym:
6351 : 758730 : if (SymbolTable_IsComponent (Sym))
6352 : : {
6353 : 758730 : if (Indexing_InBounds (pSym->Var.list, n))
6354 : : {
6355 : 1012408 : return GetFromIndex (pSym->Var.list, n);
6356 : : }
6357 : : else
6358 : : {
6359 : : return SymbolTable_NulSym;
6360 : : }
6361 : : }
6362 : : else
6363 : : {
6364 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
6365 : : }
6366 : 0 : break;
6367 : :
6368 : :
6369 : 0 : default:
6370 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
6371 : : break;
6372 : : }
6373 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6374 : : __builtin_unreachable ();
6375 : : }
6376 : :
6377 : :
6378 : : /*
6379 : : EnsureOrder - providing that both symbols, a, and, b, exist in
6380 : : list, l. Ensure that, b, is placed after a.
6381 : : */
6382 : :
6383 : 264 : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b)
6384 : : {
6385 : 264 : unsigned int n;
6386 : :
6387 : 264 : n = Lists_NoOfItemsInList (l);
6388 : 264 : if ((Lists_IsItemInList (l, a)) && (Lists_IsItemInList (l, b)))
6389 : : {
6390 : 264 : Lists_RemoveItemFromList (l, b);
6391 : 264 : Lists_IncludeItemIntoList (l, b);
6392 : : }
6393 : 264 : M2Debug_Assert (n == (Lists_NoOfItemsInList (l)));
6394 : 264 : }
6395 : :
6396 : :
6397 : : /*
6398 : : DumpSons -
6399 : : */
6400 : :
6401 : 0 : static void DumpSons (unsigned int sym)
6402 : : {
6403 : 0 : SymbolTable_PtrToSymbol pSym;
6404 : 0 : unsigned int f;
6405 : 0 : unsigned int n;
6406 : 0 : unsigned int i;
6407 : :
6408 : 0 : pSym = GetPsym (sym);
6409 : 0 : switch (pSym->SymbolType)
6410 : : {
6411 : 0 : case SymbolTable_RecordSym:
6412 : 0 : n = Lists_NoOfItemsInList (pSym->Record.ListOfSons);
6413 : 0 : i = 1;
6414 : 0 : while (i <= n)
6415 : : {
6416 : 0 : f = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, i));
6417 : 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));
6418 : 0 : i += 1;
6419 : : }
6420 : 0 : break;
6421 : :
6422 : :
6423 : 0 : default:
6424 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
6425 : 0 : break;
6426 : : }
6427 : 0 : }
6428 : :
6429 : :
6430 : : /*
6431 : : CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
6432 : : */
6433 : :
6434 : 0 : static void CheckListOfSons (unsigned int sym)
6435 : : {
6436 : 0 : SymbolTable_PtrToSymbol pSym;
6437 : :
6438 : 0 : pSym = GetPsym (recordConsist);
6439 : 0 : switch (pSym->SymbolType)
6440 : : {
6441 : 0 : case SymbolTable_RecordSym:
6442 : 0 : if (! (Lists_IsItemInList (pSym->Record.ListOfSons, sym)))
6443 : : {
6444 : 0 : DumpSons (recordConsist);
6445 : 0 : M2MetaError_MetaError1 ((const char *) "internal error: expecting {%1ad} to exist in record ListOfSons", 63, sym);
6446 : : }
6447 : 0 : break;
6448 : :
6449 : :
6450 : 0 : default:
6451 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
6452 : 0 : break;
6453 : : }
6454 : 0 : }
6455 : :
6456 : :
6457 : : /*
6458 : : CheckRecordConsistency -
6459 : : */
6460 : :
6461 : 0 : static void CheckRecordConsistency (unsigned int sym)
6462 : : {
6463 : 0 : SymbolTable_PtrToSymbol pSym;
6464 : :
6465 : 0 : return ;
6466 : : pSym = GetPsym (sym);
6467 : : switch (pSym->SymbolType)
6468 : : {
6469 : : case SymbolTable_RecordSym:
6470 : : recordConsist = sym;
6471 : : SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) CheckListOfSons});
6472 : : break;
6473 : :
6474 : :
6475 : : default:
6476 : : M2Error_InternalError ((const char *) "record symbol expected", 22);
6477 : 0 : break;
6478 : : }
6479 : : }
6480 : :
6481 : :
6482 : : /*
6483 : : PutConstVarTemporary - indicates that constant, sym, is a temporary.
6484 : : */
6485 : :
6486 : 463383 : static void PutConstVarTemporary (unsigned int sym)
6487 : : {
6488 : 463383 : SymbolTable_PtrToSymbol pSym;
6489 : :
6490 : 463383 : pSym = GetPsym (sym);
6491 : 463383 : switch (pSym->SymbolType)
6492 : : {
6493 : 463383 : case SymbolTable_ConstVarSym:
6494 : 463383 : pSym->ConstVar.IsTemp = true;
6495 : 463383 : break;
6496 : :
6497 : :
6498 : 0 : default:
6499 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
6500 : 463383 : break;
6501 : : }
6502 : 463383 : }
6503 : :
6504 : :
6505 : : /*
6506 : : buildTemporary - builds the temporary filling in componentRef, record and sets mode.
6507 : : */
6508 : :
6509 : 1117360 : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record)
6510 : : {
6511 : 1117360 : SymbolTable_PtrToSymbol pSym;
6512 : 1117360 : DynamicStrings_String s;
6513 : 1117360 : unsigned int Sym;
6514 : :
6515 : 1117360 : TemporaryNo += 1;
6516 : : /* Make the name */
6517 : 1117360 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
6518 : 1117360 : if (Mode == SymbolTable_ImmediateValue)
6519 : : {
6520 : 437275 : Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
6521 : 437275 : PutConstVarTemporary (Sym);
6522 : : }
6523 : : else
6524 : : {
6525 : 680085 : Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
6526 : 680085 : pSym = GetPsym (Sym);
6527 : 680085 : switch (pSym->SymbolType)
6528 : : {
6529 : 680085 : case SymbolTable_VarSym:
6530 : 680085 : pSym->Var.AddrMode = Mode;
6531 : 680085 : pSym->Var.IsComponentRef = componentRef;
6532 : 680085 : pSym->Var.IsTemp = true; /* Variable is a temporary var */
6533 : 680085 : if (componentRef) /* Variable is a temporary var */
6534 : : {
6535 : 151543 : pSym->Var.list = Indexing_InitIndex (1);
6536 : 151543 : PutIntoIndex (&pSym->Var.list, 1, record);
6537 : : }
6538 : 680085 : InitWhereDeclaredTok (tok, &pSym->Var.At); /* Declared here */
6539 : 680085 : InitWhereFirstUsedTok (tok, &pSym->Var.At); /* Where symbol first used. */
6540 : 680085 : break;
6541 : :
6542 : :
6543 : 0 : default:
6544 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22); /* Where symbol first used. */
6545 : 1117360 : break;
6546 : : }
6547 : : }
6548 : 1117360 : s = DynamicStrings_KillString (s);
6549 : 1117360 : return Sym;
6550 : : /* static analysis guarentees a RETURN statement will be used before here. */
6551 : : __builtin_unreachable ();
6552 : : }
6553 : :
6554 : :
6555 : : /*
6556 : : CheckLegal - determines whether the Sym is a legal symbol.
6557 : : */
6558 : :
6559 : 983083979 : static void CheckLegal (unsigned int Sym)
6560 : : {
6561 : 983083979 : if ((Sym < 1) || (Sym > (SymbolTable_FinalSymbol ())))
6562 : : {
6563 : 0 : M2Error_InternalError ((const char *) "illegal symbol", 14);
6564 : : }
6565 : 983083979 : }
6566 : :
6567 : :
6568 : : /*
6569 : : CheckForHiddenType - scans the NeedToBeImplemented tree providing
6570 : : that we are currently compiling an implementation
6571 : : module. If a symbol is found with TypeName
6572 : : then its Sym is returned.
6573 : : Otherwise NulSym is returned.
6574 : : CheckForHiddenType is called before any type is
6575 : : created, therefore the compiler allows hidden
6576 : : types to be implemented using any type.
6577 : : */
6578 : :
6579 : 1687177 : static unsigned int CheckForHiddenType (NameKey_Name TypeName)
6580 : : {
6581 : 1687177 : SymbolTable_PtrToSymbol pSym;
6582 : 1687177 : unsigned int Sym;
6583 : :
6584 : 1687177 : Sym = SymbolTable_NulSym;
6585 : 1687177 : if ((((M2Comp_CompilingImplementationModule ()) && (SymbolTable_IsDefImp (CurrentModule))) && (SymbolTable_IsHiddenTypeDeclared (CurrentModule))) && (TypeName != NameKey_NulName))
6586 : : {
6587 : : /* Check to see whether we are declaring a HiddenType. */
6588 : 44550 : pSym = GetPsym (CurrentModule);
6589 : 44550 : switch (pSym->SymbolType)
6590 : : {
6591 : 44550 : case SymbolTable_DefImpSym:
6592 : 44550 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, TypeName));
6593 : 44550 : break;
6594 : :
6595 : :
6596 : 0 : default:
6597 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
6598 : 44550 : break;
6599 : : }
6600 : : }
6601 : 1687177 : return Sym;
6602 : : /* static analysis guarentees a RETURN statement will be used before here. */
6603 : : __builtin_unreachable ();
6604 : : }
6605 : :
6606 : :
6607 : : /*
6608 : : IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
6609 : : type declared as a pointer or address.
6610 : : */
6611 : :
6612 : 23110 : static bool IsHiddenReallyPointer (unsigned int Sym)
6613 : : {
6614 : 23110 : if (SymbolTable_IsVar (Sym))
6615 : : {
6616 : 0 : Sym = SymbolTable_GetType (Sym);
6617 : : }
6618 : 38372 : while ((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym)))
6619 : : {
6620 : 15262 : Sym = SymbolTable_SkipType (SymbolTable_GetType (Sym));
6621 : : }
6622 : 23110 : return (Sym != SymbolTable_NulSym) && ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address));
6623 : : /* static analysis guarentees a RETURN statement will be used before here. */
6624 : : __builtin_unreachable ();
6625 : : }
6626 : :
6627 : :
6628 : : /*
6629 : : RequestFromModule - returns a symbol from module ModSym with name, SymName.
6630 : : */
6631 : :
6632 : 108 : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
6633 : : {
6634 : 108 : SymbolTable_PtrToSymbol pSym;
6635 : 108 : unsigned int Sym;
6636 : :
6637 : 108 : pSym = GetPsym (ModSym);
6638 : 108 : switch (pSym->SymbolType)
6639 : : {
6640 : 0 : case SymbolTable_DefImpSym:
6641 : 0 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymName));
6642 : 0 : if (Sym == SymbolTable_NulSym)
6643 : : {
6644 : 0 : Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
6645 : : }
6646 : : break;
6647 : :
6648 : 108 : case SymbolTable_ModuleSym:
6649 : 108 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymName));
6650 : 108 : if (Sym == SymbolTable_NulSym)
6651 : : {
6652 : 12 : Sym = FetchUnknownFromModule (tok, ModSym, SymName);
6653 : : }
6654 : : break;
6655 : :
6656 : :
6657 : 0 : default:
6658 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
6659 : 108 : break;
6660 : : }
6661 : 108 : return Sym;
6662 : : /* static analysis guarentees a RETURN statement will be used before here. */
6663 : : __builtin_unreachable ();
6664 : : }
6665 : :
6666 : :
6667 : : /*
6668 : : RequestFromDefinition - returns a symbol from module ModSym with name,
6669 : : SymName.
6670 : : */
6671 : :
6672 : 1949735 : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
6673 : : {
6674 : 1949735 : SymbolTable_PtrToSymbol pSym;
6675 : 1949735 : unsigned int Sym;
6676 : 1949735 : unsigned int OldScopePtr;
6677 : :
6678 : 1949735 : pSym = GetPsym (ModSym);
6679 : 1949735 : switch (pSym->SymbolType)
6680 : : {
6681 : 1949735 : case SymbolTable_DefImpSym:
6682 : 1949735 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName));
6683 : 1949735 : if (Sym == SymbolTable_NulSym)
6684 : : {
6685 : 618402 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName));
6686 : 618402 : if (Sym == SymbolTable_NulSym)
6687 : : {
6688 : 306668 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
6689 : 306668 : if (Sym == SymbolTable_NulSym)
6690 : : {
6691 : 276344 : OldScopePtr = ScopePtr;
6692 : 276344 : SymbolTable_StartScope (ModSym);
6693 : 276344 : Sym = GetScopeSym (SymName, true);
6694 : 276344 : SymbolTable_EndScope ();
6695 : 276344 : M2Debug_Assert (OldScopePtr == ScopePtr);
6696 : 276344 : if (Sym == SymbolTable_NulSym)
6697 : : {
6698 : 276312 : Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
6699 : : }
6700 : : else
6701 : : {
6702 : 32 : if (SymbolTable_IsFieldEnumeration (Sym))
6703 : : {
6704 : 6 : if (SymbolTable_IsExported (ModSym, SymbolTable_GetType (Sym)))
6705 : : {
6706 : : return Sym;
6707 : : }
6708 : : }
6709 : : }
6710 : 276338 : SymbolKey_PutSymKey (pSym->DefImp.ExportRequest, SymName, Sym);
6711 : : }
6712 : : }
6713 : : }
6714 : : break;
6715 : :
6716 : :
6717 : 0 : default:
6718 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
6719 : : break;
6720 : : }
6721 : : return Sym;
6722 : : /* static analysis guarentees a RETURN statement will be used before here. */
6723 : : __builtin_unreachable ();
6724 : : }
6725 : :
6726 : :
6727 : : /*
6728 : : GetWhereImported - returns the token number where this symbol
6729 : : was imported into the current module.
6730 : : */
6731 : :
6732 : 6 : static unsigned int GetWhereImported (unsigned int Sym)
6733 : : {
6734 : 6 : SymbolTable_PtrToSymbol pSym;
6735 : :
6736 : 6 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
6737 : 6 : switch (pSym->SymbolType)
6738 : : {
6739 : 6 : case SymbolTable_DefImpSym:
6740 : 6 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym));
6741 : 0 : break;
6742 : :
6743 : 0 : case SymbolTable_ModuleSym:
6744 : 0 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym));
6745 : 0 : break;
6746 : :
6747 : :
6748 : 0 : default:
6749 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
6750 : : break;
6751 : : }
6752 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6753 : : __builtin_unreachable ();
6754 : : }
6755 : :
6756 : :
6757 : : /*
6758 : : DisplayName - displays the name.
6759 : : */
6760 : :
6761 : 0 : static void DisplayName (unsigned int sym)
6762 : : {
6763 : 0 : M2Printf_printf1 ((const char *) " %a", 5, (const unsigned char *) &sym, (sizeof (sym)-1));
6764 : 0 : }
6765 : :
6766 : :
6767 : : /*
6768 : : DisplaySymbol - displays the name of a symbol
6769 : : */
6770 : :
6771 : 0 : static void DisplaySymbol (unsigned int sym)
6772 : : {
6773 : 0 : DynamicStrings_String s;
6774 : :
6775 : 0 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym))));
6776 : 0 : M2Printf_printf2 ((const char *) " %s (%d)", 10, (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &sym, (sizeof (sym)-1));
6777 : 0 : }
6778 : :
6779 : :
6780 : : /*
6781 : : FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
6782 : : */
6783 : :
6784 : 12 : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
6785 : : {
6786 : 12 : SymbolTable_PtrToSymbol pSym;
6787 : 12 : unsigned int Sym;
6788 : :
6789 : 12 : pSym = GetPsym (ModSym);
6790 : 12 : switch (pSym->SymbolType)
6791 : : {
6792 : 12 : case SymbolTable_ModuleSym:
6793 : 12 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
6794 : 12 : if (Sym == SymbolTable_NulSym)
6795 : : {
6796 : 12 : NewSym (&Sym);
6797 : 12 : FillInUnknownFields (tok, Sym, SymName);
6798 : 12 : SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
6799 : : }
6800 : 12 : break;
6801 : :
6802 : :
6803 : 0 : default:
6804 : 0 : M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
6805 : 12 : break;
6806 : : }
6807 : 12 : return Sym;
6808 : : /* static analysis guarentees a RETURN statement will be used before here. */
6809 : : __builtin_unreachable ();
6810 : : }
6811 : :
6812 : :
6813 : : /*
6814 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
6815 : : */
6816 : :
6817 : 276312 : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
6818 : : {
6819 : 276312 : SymbolTable_PtrToSymbol pSym;
6820 : 276312 : unsigned int Sym;
6821 : :
6822 : 276312 : pSym = GetPsym (ModSym);
6823 : 276312 : switch (pSym->SymbolType)
6824 : : {
6825 : 276312 : case SymbolTable_DefImpSym:
6826 : 276312 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
6827 : 276312 : if (Sym == SymbolTable_NulSym)
6828 : : {
6829 : 276312 : NewSym (&Sym);
6830 : 276312 : FillInUnknownFields (tok, Sym, SymName);
6831 : 276312 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
6832 : : }
6833 : 276312 : break;
6834 : :
6835 : :
6836 : 0 : default:
6837 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
6838 : 276312 : break;
6839 : : }
6840 : 276312 : return Sym;
6841 : : /* static analysis guarentees a RETURN statement will be used before here. */
6842 : : __builtin_unreachable ();
6843 : : }
6844 : :
6845 : :
6846 : : /*
6847 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
6848 : : */
6849 : :
6850 : 54 : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName)
6851 : : {
6852 : 54 : SymbolTable_PtrToSymbol pSym;
6853 : 54 : unsigned int Sym;
6854 : :
6855 : 54 : pSym = GetPsym (scope);
6856 : 54 : switch (pSym->SymbolType)
6857 : : {
6858 : 0 : case SymbolTable_DefImpSym:
6859 : 0 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
6860 : 0 : if (Sym == SymbolTable_NulSym)
6861 : : {
6862 : 0 : NewSym (&Sym);
6863 : 0 : FillInUnknownFields (tok, Sym, SymName);
6864 : 0 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
6865 : : }
6866 : : break;
6867 : :
6868 : 36 : case SymbolTable_ModuleSym:
6869 : 36 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
6870 : 36 : if (Sym == SymbolTable_NulSym)
6871 : : {
6872 : 36 : NewSym (&Sym);
6873 : 36 : FillInUnknownFields (tok, Sym, SymName);
6874 : 36 : SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
6875 : : }
6876 : : break;
6877 : :
6878 : 18 : case SymbolTable_ProcedureSym:
6879 : 18 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, SymName));
6880 : 18 : if (Sym == SymbolTable_NulSym)
6881 : : {
6882 : 18 : NewSym (&Sym);
6883 : 18 : FillInUnknownFields (tok, Sym, SymName);
6884 : 18 : SymbolKey_PutSymKey (pSym->Procedure.Unresolved, SymName, Sym);
6885 : : }
6886 : : break;
6887 : :
6888 : :
6889 : 0 : default:
6890 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module or Procedure symbol", 48);
6891 : 54 : break;
6892 : : }
6893 : 54 : return Sym;
6894 : : /* static analysis guarentees a RETURN statement will be used before here. */
6895 : : __builtin_unreachable ();
6896 : : }
6897 : :
6898 : :
6899 : : /*
6900 : : UnknownSymbolError - displays symbol name for symbol, sym.
6901 : : */
6902 : :
6903 : 90 : static void UnknownSymbolError (unsigned int sym)
6904 : : {
6905 : 90 : if (IsUnreportedUnknown (sym))
6906 : : {
6907 : 90 : Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
6908 : 90 : M2MetaError_MetaErrorStringT1 (SymbolTable_GetFirstUsed (sym), DynamicStrings_InitString ((const char *) "unknown symbol {%1EUad}", 23), sym);
6909 : : }
6910 : 90 : }
6911 : :
6912 : :
6913 : : /*
6914 : : IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
6915 : : reported and is an unknown symbol.
6916 : : */
6917 : :
6918 : 22106345 : static bool IsUnreportedUnknown (unsigned int sym)
6919 : : {
6920 : 22106345 : return (SymbolTable_IsUnknown (sym)) && (! (Sets_IsElementInSet (ReportedUnknowns, sym)));
6921 : : /* static analysis guarentees a RETURN statement will be used before here. */
6922 : : __builtin_unreachable ();
6923 : : }
6924 : :
6925 : :
6926 : : /*
6927 : : AddListify -
6928 : : */
6929 : :
6930 : 90 : static void AddListify (unsigned int sym)
6931 : : {
6932 : 90 : ListifyWordCount += 1;
6933 : : /* printf ("AddListify: ListifyWordCount = %d, ListifyTotal = %d
6934 : : ",
6935 : : ListifyWordCount, ListifyTotal) ; */
6936 : 90 : if (ListifyWordCount > 1)
6937 : : {
6938 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
6939 : 18 : if (ListifyWordCount == ListifyTotal)
6940 : : {
6941 : 18 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) " and ", 5)));
6942 : : }
6943 : : else
6944 : : {
6945 : 0 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ", ", 2)));
6946 : : }
6947 : : }
6948 : 90 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym)))));
6949 : 90 : }
6950 : :
6951 : :
6952 : : /*
6953 : : Listify - convert tree into a string list and return the result.
6954 : : */
6955 : :
6956 : 72 : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition)
6957 : : {
6958 : 72 : ListifyTotal = SymbolKey_NoOfNodes (tree, isCondition);
6959 : 72 : ListifyWordCount = 0;
6960 : 72 : ListifySentance = DynamicStrings_InitString ((const char *) "", 0);
6961 : 72 : SymbolKey_ForeachNodeConditionDo (tree, isCondition, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) AddListify});
6962 : 72 : return ListifySentance;
6963 : : /* static analysis guarentees a RETURN statement will be used before here. */
6964 : : __builtin_unreachable ();
6965 : : }
6966 : :
6967 : :
6968 : : /*
6969 : : CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
6970 : : an unknown symbol. All unknown symbols are displayed
6971 : : together with an error message.
6972 : : */
6973 : :
6974 : 1508136 : static void CheckForUnknowns (NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
6975 : : {
6976 : 1508136 : DynamicStrings_String s;
6977 : 1508136 : char a[_a_high+1];
6978 : :
6979 : : /* make a local copy of each unbounded array. */
6980 : 1508136 : memcpy (a, a_, _a_high+1);
6981 : :
6982 : 1508136 : if (SymbolKey_DoesTreeContainAny (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown}))
6983 : : {
6984 : 72 : CurrentError = M2Error_NewError (M2LexBuf_GetTokenNo ());
6985 : 72 : s = DynamicStrings_InitString ((const char *) "{%E} the following unknown symbols in module %<", 47);
6986 : 72 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
6987 : 72 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%> were ", 8)));
6988 : 72 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
6989 : 72 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ": ", 2)));
6990 : 72 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (Listify (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown})));
6991 : 72 : M2MetaError_MetaErrorStringT0 (M2LexBuf_GetTokenNo (), s);
6992 : 72 : SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnknownSymbolError});
6993 : : }
6994 : 1508136 : }
6995 : :
6996 : :
6997 : : /*
6998 : : SymbolError - displays symbol name for symbol, Sym.
6999 : : */
7000 : :
7001 : 0 : static void SymbolError (unsigned int Sym)
7002 : : {
7003 : 0 : M2Error_Error e;
7004 : 0 : NameKey_Name n;
7005 : :
7006 : 0 : n = SymbolTable_GetSymName (Sym);
7007 : 0 : e = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
7008 : 0 : M2Error_ErrorFormat1 (e, (const char *) "unknown symbol '%a' found", 25, (const unsigned char *) &n, (sizeof (n)-1));
7009 : 0 : }
7010 : :
7011 : :
7012 : : /*
7013 : : CheckForSymbols - checks a binary tree, Tree, to see whether it contains
7014 : : any symbol. The tree is expected to be empty, if not
7015 : : then an error has occurred.
7016 : : */
7017 : :
7018 : 355618 : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
7019 : : {
7020 : 355618 : DynamicStrings_String s;
7021 : 355618 : char a[_a_high+1];
7022 : :
7023 : : /* make a local copy of each unbounded array. */
7024 : 355618 : memcpy (a, a_, _a_high+1);
7025 : :
7026 : 355618 : if (! (SymbolKey_IsEmptyTree (Tree)))
7027 : : {
7028 : 0 : s = DynamicStrings_InitString ((const char *) "the symbols are unknown at the end of module {%1Ea} when ", 57);
7029 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
7030 : 0 : M2MetaError_MetaErrorString1 (s, MainModule);
7031 : 0 : SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SymbolError});
7032 : : }
7033 : 355618 : }
7034 : :
7035 : :
7036 : : /*
7037 : : PutExportUndeclared - places a symbol, Sym, into module, ModSym,
7038 : : ExportUndeclared list provided that Sym
7039 : : is unknown.
7040 : : */
7041 : :
7042 : 3148564 : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym)
7043 : : {
7044 : 3148564 : SymbolTable_PtrToSymbol pSym;
7045 : :
7046 : 3148564 : if (SymbolTable_IsUnknown (Sym))
7047 : : {
7048 : 2579165 : pSym = GetPsym (ModSym);
7049 : 2579165 : switch (pSym->SymbolType)
7050 : : {
7051 : 294 : case SymbolTable_ModuleSym:
7052 : 294 : SymbolKey_PutSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
7053 : 294 : break;
7054 : :
7055 : 2578871 : case SymbolTable_DefImpSym:
7056 : 2578871 : SymbolKey_PutSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
7057 : 2578871 : break;
7058 : :
7059 : :
7060 : 0 : default:
7061 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7062 : : break;
7063 : : }
7064 : : }
7065 : 3148564 : }
7066 : :
7067 : :
7068 : : /*
7069 : : GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
7070 : : which is in the ExportUndeclared list.
7071 : : */
7072 : :
7073 : 234 : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name)
7074 : : {
7075 : 234 : SymbolTable_PtrToSymbol pSym;
7076 : :
7077 : 234 : pSym = GetPsym (ModSym);
7078 : 234 : switch (pSym->SymbolType)
7079 : : {
7080 : 228 : case SymbolTable_ModuleSym:
7081 : 228 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, name));
7082 : 6 : break;
7083 : :
7084 : 6 : case SymbolTable_DefImpSym:
7085 : 6 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, name));
7086 : 0 : break;
7087 : :
7088 : :
7089 : 0 : default:
7090 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7091 : : break;
7092 : : }
7093 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7094 : : __builtin_unreachable ();
7095 : : }
7096 : :
7097 : :
7098 : : /*
7099 : : RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
7100 : : ExportUndeclaredTree.
7101 : : */
7102 : :
7103 : 7617069 : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym)
7104 : : {
7105 : 7617069 : SymbolTable_PtrToSymbol pSym;
7106 : :
7107 : 7617069 : pSym = GetPsym (ModSym);
7108 : 7617069 : switch (pSym->SymbolType)
7109 : : {
7110 : 18 : case SymbolTable_ModuleSym:
7111 : 18 : if ((SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
7112 : : {
7113 : 18 : SymbolKey_DelSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym));
7114 : : }
7115 : : break;
7116 : :
7117 : 7617051 : case SymbolTable_DefImpSym:
7118 : 7617051 : if ((SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
7119 : : {
7120 : 2578565 : SymbolKey_DelSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym));
7121 : : }
7122 : : break;
7123 : :
7124 : :
7125 : 0 : default:
7126 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7127 : 7617069 : break;
7128 : : }
7129 : 7617069 : }
7130 : :
7131 : :
7132 : : /*
7133 : : CheckForExportedDeclaration - checks to see whether a definition module
7134 : : is currently being compiled, if so,
7135 : : symbol, Sym, is removed from the
7136 : : ExportUndeclared list.
7137 : : This procedure is called whenever a symbol
7138 : : is declared, thus attempting to reduce
7139 : : the ExportUndeclared list.
7140 : : */
7141 : :
7142 : 13732792 : static void CheckForExportedDeclaration (unsigned int Sym)
7143 : : {
7144 : 13732792 : if (M2Comp_CompilingDefinitionModule ())
7145 : : {
7146 : 7617045 : RemoveExportUndeclared (SymbolTable_GetCurrentModule (), Sym);
7147 : : }
7148 : 13732792 : }
7149 : :
7150 : :
7151 : : /*
7152 : : UndeclaredSymbolError - displays symbol name for symbol, Sym.
7153 : : */
7154 : :
7155 : 0 : static void UndeclaredSymbolError (unsigned int Sym)
7156 : : {
7157 : 0 : if (DebugUnknowns)
7158 : : {
7159 : : M2Printf_printf1 ((const char *) "undeclared symbol (%d)\\n", 24, (const unsigned char *) &Sym, (sizeof (Sym)-1));
7160 : : }
7161 : 0 : M2MetaError_MetaError1 ((const char *) "{%1UC} undeclared symbol {%1a}", 30, Sym);
7162 : 0 : }
7163 : :
7164 : :
7165 : : /*
7166 : : RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
7167 : : NeedToBeImplemented list.
7168 : : */
7169 : :
7170 : 1143942 : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym)
7171 : : {
7172 : 1143942 : SymbolTable_PtrToSymbol pSym;
7173 : :
7174 : 1143942 : pSym = GetPsym (ModSym);
7175 : 1143942 : switch (pSym->SymbolType)
7176 : : {
7177 : 1143942 : case SymbolTable_DefImpSym:
7178 : 1143942 : if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
7179 : : {
7180 : 579792 : SymbolKey_DelSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym));
7181 : : }
7182 : 1143942 : break;
7183 : :
7184 : :
7185 : 0 : default:
7186 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7187 : 1143942 : break;
7188 : : }
7189 : 1143942 : }
7190 : :
7191 : :
7192 : : /*
7193 : : RemoveFromExportRequest -
7194 : : */
7195 : :
7196 : 356066 : static void RemoveFromExportRequest (unsigned int Sym)
7197 : : {
7198 : 356066 : SymbolTable_PtrToSymbol pSym;
7199 : :
7200 : 356066 : pSym = GetPsym (ExportRequestModule);
7201 : 356066 : switch (pSym->SymbolType)
7202 : : {
7203 : 356066 : case SymbolTable_DefImpSym:
7204 : 356066 : if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym))) == Sym)
7205 : : {
7206 : 6 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym));
7207 : : }
7208 : 356066 : break;
7209 : :
7210 : :
7211 : 0 : default:
7212 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7213 : 356066 : break;
7214 : : }
7215 : 356066 : }
7216 : :
7217 : :
7218 : : /*
7219 : : RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
7220 : : (and its fields) from the ExportRequest tree.
7221 : : */
7222 : :
7223 : 12722 : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym)
7224 : : {
7225 : 12722 : if (SymbolTable_IsEnumeration (Sym))
7226 : : {
7227 : 12722 : ExportRequestModule = ModSym;
7228 : 12722 : RemoveFromExportRequest (Sym);
7229 : 12722 : SymbolTable_ForeachLocalSymDo (Sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) RemoveFromExportRequest});
7230 : : }
7231 : 12722 : }
7232 : :
7233 : :
7234 : : /*
7235 : : UnImplementedSymbolError - displays symbol name for symbol, Sym.
7236 : : */
7237 : :
7238 : 0 : static void UnImplementedSymbolError (unsigned int Sym)
7239 : : {
7240 : 0 : NameKey_Name n;
7241 : :
7242 : 0 : CurrentError = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
7243 : 0 : if (SymbolTable_IsType (Sym))
7244 : : {
7245 : 0 : n = SymbolTable_GetSymName (Sym);
7246 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "hidden type is undeclared (%a)", 30, (const unsigned char *) &n, (sizeof (n)-1));
7247 : : }
7248 : 0 : else if (SymbolTable_IsProcedure (Sym))
7249 : : {
7250 : : /* avoid dangling else. */
7251 : 0 : n = SymbolTable_GetSymName (Sym);
7252 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure is undeclared (%a)", 28, (const unsigned char *) &n, (sizeof (n)-1));
7253 : : }
7254 : 0 : else if (SymbolTable_IsProcType (Sym))
7255 : : {
7256 : : /* avoid dangling else. */
7257 : 0 : n = SymbolTable_GetSymName (Sym);
7258 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure type is undeclared (%a)", 33, (const unsigned char *) &n, (sizeof (n)-1));
7259 : : }
7260 : : else
7261 : : {
7262 : : /* avoid dangling else. */
7263 : 0 : M2Error_ErrorFormat0 (CurrentError, (const char *) "undeclared symbol", 17);
7264 : : }
7265 : 0 : }
7266 : :
7267 : :
7268 : : /*
7269 : : CheckEnumerationInList - places symbol, Sym, in the list, l,
7270 : : providing it does not already exist.
7271 : : PseudoScope(Sym) is called if Sym needs to
7272 : : be added to the enumeration list, l.
7273 : : */
7274 : :
7275 : 50386 : static void CheckEnumerationInList (Lists_List l, unsigned int Sym)
7276 : : {
7277 : 50386 : if (! (Lists_IsItemInList (l, Sym)))
7278 : : {
7279 : 44807 : Lists_PutItemIntoList (l, Sym);
7280 : 44807 : SymbolTable_PseudoScope (Sym);
7281 : : }
7282 : 50386 : }
7283 : :
7284 : :
7285 : : /*
7286 : : CheckIfEnumerationExported - An outer module may use an enumeration that
7287 : : is declared inside an inner module. The usage
7288 : : may occur before definition. The first pass
7289 : : exports a symbol, later the symbol is declared
7290 : : as an emumeration type. At this stage the
7291 : : CheckIfEnumerationExported procedure should be
7292 : : called. This procedure ripples from the current
7293 : : (inner) module to outer module and every time
7294 : : it is exported it must be added to the outer
7295 : : module EnumerationScopeList.
7296 : : */
7297 : :
7298 : 38776 : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId)
7299 : : {
7300 : 51500 : SymbolTable_PtrToCallFrame pCall;
7301 : 51500 : unsigned int InnerModId;
7302 : 51500 : unsigned int OuterModId;
7303 : 51500 : unsigned int InnerModSym;
7304 : 51500 : unsigned int OuterModSym;
7305 : :
7306 : 51500 : InnerModId = GetModuleScopeId (ScopeId);
7307 : 51500 : if (InnerModId > 0)
7308 : : {
7309 : 51500 : OuterModId = GetModuleScopeId (InnerModId-1);
7310 : 51500 : if (OuterModId > 0)
7311 : : {
7312 : 51500 : pCall = GetPcall (InnerModId);
7313 : 51500 : InnerModSym = pCall->Search;
7314 : 51500 : pCall = GetPcall (OuterModId);
7315 : 51500 : OuterModSym = pCall->Search;
7316 : 51500 : if ((InnerModSym != SymbolTable_NulSym) && (OuterModSym != SymbolTable_NulSym))
7317 : : {
7318 : 21983 : if (SymbolTable_IsExported (InnerModSym, Sym))
7319 : : {
7320 : 12724 : CheckForEnumerationInOuterModule (Sym, OuterModSym);
7321 : 12724 : CheckIfEnumerationExported (Sym, OuterModId);
7322 : : }
7323 : : }
7324 : : }
7325 : : }
7326 : 38776 : }
7327 : :
7328 : :
7329 : : /*
7330 : : CheckForEnumerationInOuterModule - checks to see whether the enumeration
7331 : : type symbol, Sym, has been entered into
7332 : : the outer module, OuterModule, scope list.
7333 : : OuterModule may be internal to the
7334 : : program module.
7335 : : */
7336 : :
7337 : 12724 : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule)
7338 : : {
7339 : 12724 : SymbolTable_PtrToSymbol pSym;
7340 : :
7341 : 12724 : pSym = GetPsym (OuterModule);
7342 : 12724 : switch (pSym->SymbolType)
7343 : : {
7344 : 0 : case SymbolTable_DefImpSym:
7345 : 0 : Lists_IncludeItemIntoList (pSym->DefImp.EnumerationScopeList, Sym);
7346 : 0 : break;
7347 : :
7348 : 12724 : case SymbolTable_ModuleSym:
7349 : 12724 : Lists_IncludeItemIntoList (pSym->Module.EnumerationScopeList, Sym);
7350 : 12724 : break;
7351 : :
7352 : :
7353 : 0 : default:
7354 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7355 : 12724 : break;
7356 : : }
7357 : 12724 : }
7358 : :
7359 : :
7360 : : /*
7361 : : SetReturnOptional - sets the ReturnOptional field in the Procedure or
7362 : : ProcType symboltable entry.
7363 : : */
7364 : :
7365 : 1720343 : static void SetReturnOptional (unsigned int sym, bool isopt)
7366 : : {
7367 : 1720343 : SymbolTable_PtrToSymbol pSym;
7368 : :
7369 : 1720343 : pSym = GetPsym (sym);
7370 : 1720343 : switch (pSym->SymbolType)
7371 : : {
7372 : 1713421 : case SymbolTable_ProcedureSym:
7373 : 1713421 : pSym->Procedure.ReturnOptional = isopt;
7374 : 1713421 : break;
7375 : :
7376 : 6922 : case SymbolTable_ProcTypeSym:
7377 : 6922 : pSym->ProcType.ReturnOptional = isopt;
7378 : 6922 : break;
7379 : :
7380 : :
7381 : 0 : default:
7382 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
7383 : 1720343 : break;
7384 : : }
7385 : 1720343 : }
7386 : :
7387 : :
7388 : : /*
7389 : : CheckOptFunction - checks to see whether the optional return value
7390 : : has been set before and if it differs it will
7391 : : generate an error message. It will set the
7392 : : new value to, isopt.
7393 : : */
7394 : :
7395 : 1720343 : static void CheckOptFunction (unsigned int sym, bool isopt)
7396 : : {
7397 : 1720343 : NameKey_Name n;
7398 : 1720343 : M2Error_Error e;
7399 : :
7400 : 1720343 : if ((SymbolTable_GetType (sym)) != SymbolTable_NulSym)
7401 : : {
7402 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7403 : 233820 : if ((SymbolTable_IsReturnOptional (sym)) && ! isopt)
7404 : : {
7405 : 0 : n = SymbolTable_GetSymName (sym);
7406 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
7407 : 0 : M2Error_ErrorFormat1 (e, (const char *) "function (%a) has no optional return value here", 47, (const unsigned char *) &n, (sizeof (n)-1));
7408 : 0 : e = M2Error_ChainError (SymbolTable_GetDeclaredMod (sym), e);
7409 : 0 : M2Error_ErrorFormat1 (e, (const char *) "whereas the same function (%a) was declared to have an optional return value at this point", 90, (const unsigned char *) &n, (sizeof (n)-1));
7410 : : }
7411 : 233820 : else if ((! (SymbolTable_IsReturnOptional (sym))) && isopt)
7412 : : {
7413 : : /* avoid dangling else. */
7414 : 0 : n = SymbolTable_GetSymName (sym);
7415 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
7416 : 0 : M2Error_ErrorFormat1 (e, (const char *) "function (%a) has an optional return value", 42, (const unsigned char *) &n, (sizeof (n)-1));
7417 : 0 : e = M2Error_ChainError (SymbolTable_GetDeclaredMod (sym), e);
7418 : 0 : M2Error_ErrorFormat1 (e, (const char *) "whereas the same function (%a) was declared to have no optional return value at this point", 90, (const unsigned char *) &n, (sizeof (n)-1));
7419 : : }
7420 : : }
7421 : 1720343 : SetReturnOptional (sym, isopt);
7422 : 1720343 : }
7423 : :
7424 : :
7425 : : /*
7426 : : MakeVariableForParam -
7427 : : */
7428 : :
7429 : 6081995 : static unsigned int MakeVariableForParam (unsigned int tok, NameKey_Name ParamName, unsigned int ProcSym, unsigned int no)
7430 : : {
7431 : 6081995 : SymbolTable_PtrToSymbol pSym;
7432 : 6081995 : unsigned int VariableSym;
7433 : :
7434 : 6081995 : tok = CheckTok (tok, (const char *) "parameter", 9);
7435 : 6081995 : VariableSym = SymbolTable_MakeVar (tok, ParamName);
7436 : 6081995 : pSym = GetPsym (VariableSym);
7437 : 6081995 : switch (pSym->SymbolType)
7438 : : {
7439 : : case SymbolTable_ErrorSym:
7440 : : return SymbolTable_NulSym;
7441 : 6081995 : break;
7442 : :
7443 : 6081995 : case SymbolTable_VarSym:
7444 : 6081995 : pSym->Var.IsParam = true; /* Variable is really a parameter. */
7445 : 6081995 : break;
7446 : :
7447 : :
7448 : 0 : default:
7449 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
7450 : 6081995 : break;
7451 : : }
7452 : : /* Note that the parameter is now treated as a local variable. */
7453 : 6081995 : SymbolTable_PutVar (VariableSym, SymbolTable_GetType (SymbolTable_GetNthParam (ProcSym, no)));
7454 : 6081995 : SymbolTable_PutDeclared (tok, VariableSym);
7455 : : /*
7456 : : Normal VAR parameters have LeftValue,
7457 : : however Unbounded VAR parameters have RightValue.
7458 : : Non VAR parameters always have RightValue.
7459 : : */
7460 : 6081995 : if ((SymbolTable_IsVarParam (ProcSym, no)) && (! (SymbolTable_IsUnboundedParam (ProcSym, no))))
7461 : : {
7462 : 179363 : SymbolTable_PutMode (VariableSym, SymbolTable_LeftValue);
7463 : : }
7464 : : else
7465 : : {
7466 : 5902632 : SymbolTable_PutMode (VariableSym, SymbolTable_RightValue);
7467 : : }
7468 : : return VariableSym;
7469 : : /* static analysis guarentees a RETURN statement will be used before here. */
7470 : : __builtin_unreachable ();
7471 : : }
7472 : :
7473 : :
7474 : : /*
7475 : : AddParameter - adds a parameter ParSym to a procedure Sym.
7476 : : */
7477 : :
7478 : 6163913 : static void AddParameter (unsigned int Sym, unsigned int ParSym)
7479 : : {
7480 : 6163913 : SymbolTable_PtrToSymbol pSym;
7481 : :
7482 : 6163913 : pSym = GetPsym (Sym);
7483 : 6163913 : switch (pSym->SymbolType)
7484 : : {
7485 : : case SymbolTable_ErrorSym:
7486 : : break;
7487 : :
7488 : 6081995 : case SymbolTable_ProcedureSym:
7489 : 6081995 : Lists_PutItemIntoList (pSym->Procedure.ListOfParam, ParSym);
7490 : 6081995 : break;
7491 : :
7492 : 81918 : case SymbolTable_ProcTypeSym:
7493 : 81918 : Lists_PutItemIntoList (pSym->ProcType.ListOfParam, ParSym);
7494 : 81918 : break;
7495 : :
7496 : :
7497 : 0 : default:
7498 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
7499 : 6163913 : break;
7500 : : }
7501 : 6163913 : }
7502 : :
7503 : :
7504 : : /*
7505 : : IsNthParamVar - returns true if the n th parameter of the parameter list,
7506 : : List, is a VAR parameter.
7507 : : */
7508 : :
7509 : 15678903 : static bool IsNthParamVar (Lists_List Head, unsigned int n)
7510 : : {
7511 : 15678903 : SymbolTable_PtrToSymbol pSym;
7512 : 15678903 : unsigned int p;
7513 : :
7514 : 15678903 : p = static_cast<unsigned int> (Lists_GetItemFromList (Head, n));
7515 : 15678903 : if (p == SymbolTable_NulSym)
7516 : : {
7517 : 0 : M2Error_InternalError ((const char *) "parameter does not exist", 24);
7518 : : }
7519 : : else
7520 : : {
7521 : 15678903 : pSym = GetPsym (p);
7522 : 15678903 : switch (pSym->SymbolType)
7523 : : {
7524 : : case SymbolTable_ErrorSym:
7525 : : return false;
7526 : 825924 : break;
7527 : :
7528 : 825924 : case SymbolTable_VarParamSym:
7529 : 825924 : return true;
7530 : : break;
7531 : :
7532 : : case SymbolTable_ParamSym:
7533 : : return false;
7534 : 0 : break;
7535 : :
7536 : :
7537 : 0 : default:
7538 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
7539 : : break;
7540 : : }
7541 : : }
7542 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7543 : : __builtin_unreachable ();
7544 : : }
7545 : :
7546 : :
7547 : : /*
7548 : : MakeParameterHeapVar - create a heap variable if sym is a pointer.
7549 : : */
7550 : :
7551 : 183629 : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode)
7552 : : {
7553 : 183629 : unsigned int heapvar;
7554 : :
7555 : 183629 : tok = CheckTok (tok, (const char *) "parameter heap var", 18);
7556 : 183629 : heapvar = SymbolTable_NulSym;
7557 : 183629 : type = SymbolTable_SkipType (type);
7558 : 183629 : if (SymbolTable_IsPointer (type))
7559 : : {
7560 : 24920 : heapvar = SymbolTable_MakeTemporary (tok, mode);
7561 : 24920 : SymbolTable_PutVar (heapvar, type);
7562 : 24920 : SymbolTable_PutVarHeap (heapvar, true);
7563 : : }
7564 : 183629 : return heapvar;
7565 : : /* static analysis guarentees a RETURN statement will be used before here. */
7566 : : __builtin_unreachable ();
7567 : : }
7568 : :
7569 : :
7570 : : /*
7571 : : PutParameterHeapVar - creates a heap variable associated with parameter sym.
7572 : : */
7573 : :
7574 : 1751844 : static void PutParameterHeapVar (unsigned int sym)
7575 : : {
7576 : 1751844 : SymbolTable_PtrToSymbol pSym;
7577 : :
7578 : 1751844 : pSym = GetPsym (sym);
7579 : 1751844 : switch (pSym->SymbolType)
7580 : : {
7581 : : case SymbolTable_ParamSym:
7582 : : break;
7583 : :
7584 : 183629 : case SymbolTable_VarParamSym:
7585 : 183629 : pSym->VarParam.HeapVar = MakeParameterHeapVar (SymbolTable_GetDeclaredMod (sym), pSym->VarParam.Type, SymbolTable_LeftValue); /* Nothing to do for the non var parameter. */
7586 : 183629 : break;
7587 : :
7588 : :
7589 : 0 : default:
7590 : 0 : M2Error_InternalError ((const char *) "Param or VarParam symbol expected", 33);
7591 : 1751844 : break;
7592 : : }
7593 : 1751844 : }
7594 : :
7595 : :
7596 : : /*
7597 : : FillInUnknownFields -
7598 : : */
7599 : :
7600 : 6630072 : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName)
7601 : : {
7602 : 6630072 : SymbolTable_PtrToSymbol pSym;
7603 : :
7604 : 6630072 : pSym = GetPsym (sym);
7605 : 6630072 : pSym->SymbolType = SymbolTable_UndefinedSym;
7606 : 6630072 : pSym->Undefined.name = SymName;
7607 : 6630072 : pSym->Undefined.oafamily = SymbolTable_NulSym;
7608 : 6630072 : pSym->Undefined.errorScope = M2Error_GetCurrentErrorScope ();
7609 : 6630072 : InitWhereFirstUsedTok (tok, &pSym->Undefined.At);
7610 : 6630072 : }
7611 : :
7612 : :
7613 : : /*
7614 : : FillInPointerFields - given a new symbol, sym, make it a pointer symbol
7615 : : and initialize its fields.
7616 : : */
7617 : :
7618 : 179763 : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf)
7619 : : {
7620 : 179763 : SymbolTable_PtrToSymbol pSym;
7621 : :
7622 : 179763 : if (! (SymbolTable_IsError (Sym)))
7623 : : {
7624 : 179763 : pSym = GetPsym (Sym);
7625 : 179763 : pSym->SymbolType = SymbolTable_PointerSym;
7626 : 179763 : switch (pSym->SymbolType)
7627 : : {
7628 : 179763 : case SymbolTable_PointerSym:
7629 : 179763 : pSym->Pointer.Type = SymbolTable_NulSym;
7630 : 179763 : pSym->Pointer.name = PointerName;
7631 : 179763 : pSym->Pointer.oafamily = oaf; /* The unbounded for this */
7632 : 179763 : SymbolKey_InitTree (&pSym->Pointer.ConstLitTree); /* constants of this type */
7633 : 179763 : pSym->Pointer.Scope = scope; /* Which scope created it */
7634 : 179763 : pSym->Pointer.Size = M2ALU_InitValue (); /* Which scope created it */
7635 : 179763 : pSym->Pointer.Align = SymbolTable_NulSym; /* Alignment of this type */
7636 : 179763 : break;
7637 : :
7638 : :
7639 : : default:
7640 : : M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26); /* Alignment of this type */
7641 : 179763 : break;
7642 : : }
7643 : : }
7644 : 179763 : }
7645 : :
7646 : :
7647 : : /*
7648 : : ForeachParameterDo -
7649 : : */
7650 : :
7651 : 36529 : static void ForeachParameterDo (SymbolTable_CheckProcedure p)
7652 : : {
7653 : 36529 : unsigned int l;
7654 : 36529 : unsigned int h;
7655 : :
7656 : 36529 : l = Indexing_LowIndice (Symbols);
7657 : 36529 : h = Indexing_HighIndice (Symbols);
7658 : 35330422 : while (l <= h)
7659 : : {
7660 : 35257364 : if (SymbolTable_IsParameter (l))
7661 : : {
7662 : 2891869 : (*p.proc) (l);
7663 : : }
7664 : 35257364 : l += 1;
7665 : : }
7666 : 36529 : }
7667 : :
7668 : :
7669 : : /*
7670 : : CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
7671 : : */
7672 : :
7673 : 2891869 : static void CheckUnbounded (unsigned int Sym)
7674 : : {
7675 : 2891869 : SymbolTable_PtrToSymbol pSym;
7676 : :
7677 : 2891869 : CheckLegal (Sym);
7678 : 2891869 : pSym = GetPsym (Sym);
7679 : 2891869 : switch (pSym->SymbolType)
7680 : : {
7681 : 2517563 : case SymbolTable_ParamSym:
7682 : 2517563 : if (SymbolTable_IsUnbounded (pSym->Param.Type))
7683 : : {
7684 : 127297 : pSym->Param.IsUnbounded = true;
7685 : : }
7686 : : break;
7687 : :
7688 : 374306 : case SymbolTable_VarParamSym:
7689 : 374306 : if (SymbolTable_IsUnbounded (pSym->VarParam.Type))
7690 : : {
7691 : 266616 : pSym->VarParam.IsUnbounded = true;
7692 : : }
7693 : : break;
7694 : :
7695 : :
7696 : 0 : default:
7697 : 0 : M2RTS_HALT (-1);
7698 : : __builtin_unreachable ();
7699 : 2891869 : break;
7700 : : }
7701 : 2891869 : }
7702 : :
7703 : :
7704 : : /*
7705 : : PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
7706 : : */
7707 : :
7708 : 36469 : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf)
7709 : : {
7710 : 36469 : SymbolTable_PtrToSymbol pSym;
7711 : :
7712 : 36469 : pSym = GetPsym (SimpleType);
7713 : 36469 : switch (pSym->SymbolType)
7714 : : {
7715 : : case SymbolTable_ErrorSym:
7716 : : break;
7717 : :
7718 : 12 : case SymbolTable_RecordSym:
7719 : 12 : pSym->Record.oafamily = oaf;
7720 : 12 : break;
7721 : :
7722 : 0 : case SymbolTable_SubrangeSym:
7723 : 0 : pSym->Subrange.oafamily = oaf;
7724 : 0 : break;
7725 : :
7726 : 0 : case SymbolTable_EnumerationSym:
7727 : 0 : pSym->Enumeration.oafamily = oaf;
7728 : 0 : break;
7729 : :
7730 : 6 : case SymbolTable_ArraySym:
7731 : 6 : pSym->Array.oafamily = oaf;
7732 : 6 : break;
7733 : :
7734 : 0 : case SymbolTable_ProcTypeSym:
7735 : 0 : pSym->ProcType.oafamily = oaf;
7736 : 0 : break;
7737 : :
7738 : 19711 : case SymbolTable_TypeSym:
7739 : 19711 : pSym->Type.oafamily = oaf;
7740 : 19711 : break;
7741 : :
7742 : 0 : case SymbolTable_PointerSym:
7743 : 0 : pSym->Pointer.oafamily = oaf;
7744 : 0 : break;
7745 : :
7746 : 16740 : case SymbolTable_SetSym:
7747 : 16740 : pSym->Set.oafamily = oaf;
7748 : 16740 : break;
7749 : :
7750 : 0 : case SymbolTable_UndefinedSym:
7751 : 0 : pSym->Undefined.oafamily = oaf;
7752 : 0 : break;
7753 : :
7754 : :
7755 : 0 : default:
7756 : 0 : M2Error_InternalError ((const char *) "not expecting this SimpleType", 29);
7757 : 36469 : break;
7758 : : }
7759 : 36469 : }
7760 : :
7761 : :
7762 : : /*
7763 : : doFillInOAFamily -
7764 : : */
7765 : :
7766 : 0 : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded)
7767 : : {
7768 : 0 : unsigned int SimpleType;
7769 : :
7770 : 0 : SimpleType = SymbolTable_GetType (oaf);
7771 : 0 : if (unbounded != SymbolTable_NulSym)
7772 : : {
7773 : 0 : FillInUnboundedFields (M2LexBuf_GetTokenNo (), unbounded, SimpleType, i);
7774 : : }
7775 : 0 : }
7776 : :
7777 : :
7778 : : /*
7779 : : FillInUnboundedFields -
7780 : : */
7781 : :
7782 : 36529 : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim)
7783 : : {
7784 : 36529 : SymbolTable_PtrToSymbol pSym;
7785 : 36529 : unsigned int Contents;
7786 : 36529 : unsigned int i;
7787 : :
7788 : 36529 : if (sym != SymbolTable_NulSym)
7789 : : {
7790 : 36529 : pSym = GetPsym (sym);
7791 : 36529 : pSym->SymbolType = SymbolTable_UnboundedSym;
7792 : 36529 : pSym->Unbounded.Type = SimpleType; /* Index to a simple type. */
7793 : 36529 : pSym->Unbounded.Size = M2ALU_InitValue (); /* Size in bytes for this sym */
7794 : 36529 : pSym->Unbounded.Scope = SymbolTable_GetScope (SimpleType); /* Which scope will create it */
7795 : 36529 : InitWhereDeclaredTok (tok, &pSym->Unbounded.At); /* Declared here */
7796 : 36529 : NewSym (&pSym->Unbounded.RecordType); /* Declared here */
7797 : 36529 : FillInRecordFields (tok, pSym->Unbounded.RecordType, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
7798 : 36529 : NewSym (&Contents);
7799 : 36529 : FillInPointerFields (Contents, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
7800 : 36529 : SymbolTable_PutPointer (Contents, SimpleType);
7801 : : /* create the contents field for the unbounded array. */
7802 : 36529 : M2Debug_Assert ((SymbolTable_PutFieldRecord (pSym->Unbounded.RecordType, NameKey_MakeKey ((const char *) "_m2_contents", 12), Contents, SymbolTable_NulSym)) != SymbolTable_NulSym);
7803 : : /* create all the high fields for the unbounded array. */
7804 : 36529 : i = 1;
7805 : 73178 : while (i <= ndim)
7806 : : {
7807 : 36649 : 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);
7808 : 36649 : i += 1;
7809 : : }
7810 : 36529 : pSym->Unbounded.Dimensions = ndim;
7811 : 36529 : ForeachParameterDo ((SymbolTable_CheckProcedure) {(SymbolTable_CheckProcedure_t) CheckUnbounded});
7812 : : }
7813 : 36529 : }
7814 : :
7815 : :
7816 : : /*
7817 : : PutUnbounded - associates the unbounded symbol, open, with
7818 : : SimpleType.
7819 : : */
7820 : :
7821 : 36529 : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim)
7822 : : {
7823 : 36529 : SymbolTable_PtrToSymbol pSym;
7824 : :
7825 : 36529 : pSym = GetPsym (oaf);
7826 : 36529 : switch (pSym->SymbolType)
7827 : : {
7828 : : case SymbolTable_OAFamilySym:
7829 : : /* need to check to see if we need to add NulSym for all dimensions < ndim
7830 : : which have not been used. */
7831 : 73118 : while (pSym->OAFamily.MaxDimensions < ndim)
7832 : : {
7833 : 36589 : pSym->OAFamily.MaxDimensions += 1;
7834 : 36589 : if (pSym->OAFamily.MaxDimensions < ndim)
7835 : : {
7836 : : /* add NulSym to an unused dimension. */
7837 : 60 : PutIntoIndex (&pSym->OAFamily.Dimensions, pSym->OAFamily.MaxDimensions, SymbolTable_NulSym);
7838 : : }
7839 : : }
7840 : : /* and finally add the known sym. */
7841 : 36529 : PutIntoIndex (&pSym->OAFamily.Dimensions, ndim, sym);
7842 : 36529 : break;
7843 : :
7844 : :
7845 : 0 : default:
7846 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
7847 : 36529 : break;
7848 : : }
7849 : 36529 : }
7850 : :
7851 : :
7852 : : /*
7853 : : GetArrayDimension - returns the number of dimensions defined.
7854 : : */
7855 : :
7856 : 7887 : static unsigned int GetArrayDimension (unsigned int sym)
7857 : : {
7858 : 7887 : unsigned int n;
7859 : :
7860 : 7887 : n = 0;
7861 : 15936 : while (SymbolTable_IsArray (sym))
7862 : : {
7863 : 8049 : sym = SymbolTable_SkipType (SymbolTable_GetType (sym));
7864 : 8049 : n += 1;
7865 : : }
7866 : 7887 : return n;
7867 : : /* static analysis guarentees a RETURN statement will be used before here. */
7868 : : __builtin_unreachable ();
7869 : : }
7870 : :
7871 : :
7872 : : /*
7873 : : ResolveConstructorType - if, sym, has an unresolved constructor type
7874 : : then attempt to resolve it by examining the
7875 : : from, type.
7876 : : */
7877 : :
7878 : 20468 : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres)
7879 : : {
7880 : 20468 : if ((*unres))
7881 : : {
7882 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7883 : 20468 : if (SymbolTable_IsConstructor ((*from)))
7884 : : {
7885 : : /* avoid dangling else. */
7886 : 0 : if (IsConstructorResolved ((*from)))
7887 : : {
7888 : 0 : (*unres) = false;
7889 : 0 : (*type) = SymbolTable_GetType ((*from));
7890 : 0 : if (((*type) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*type)))))
7891 : : {
7892 : 0 : SymbolTable_PutConstSet (sym);
7893 : : }
7894 : : }
7895 : : }
7896 : 20468 : else if (((*from) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*from)))))
7897 : : {
7898 : : /* avoid dangling else. */
7899 : 17398 : (*unres) = false;
7900 : 17398 : (*type) = (*from);
7901 : 17398 : SymbolTable_PutConstSet (sym);
7902 : : }
7903 : 3070 : else if (((*from) != SymbolTable_NulSym) && ((SymbolTable_IsRecord (SymbolTable_SkipType ((*from)))) || (SymbolTable_IsArray (SymbolTable_SkipType ((*from))))))
7904 : : {
7905 : : /* avoid dangling else. */
7906 : 3064 : (*unres) = false;
7907 : 3064 : (*type) = (*from);
7908 : : }
7909 : : }
7910 : 20468 : }
7911 : :
7912 : :
7913 : : /*
7914 : : IsConstructorResolved - returns TRUE if the constructor does not
7915 : : have an unresolved type.
7916 : : */
7917 : :
7918 : 40936 : static bool IsConstructorResolved (unsigned int sym)
7919 : : {
7920 : 40936 : SymbolTable_PtrToSymbol pSym;
7921 : :
7922 : 40936 : pSym = GetPsym (sym);
7923 : 40936 : switch (pSym->SymbolType)
7924 : : {
7925 : 40936 : case SymbolTable_ConstVarSym:
7926 : 40936 : return ! pSym->ConstVar.UnresFromType;
7927 : 0 : break;
7928 : :
7929 : 0 : case SymbolTable_ConstLitSym:
7930 : 0 : return ! pSym->ConstLit.UnresFromType;
7931 : 0 : break;
7932 : :
7933 : :
7934 : 0 : default:
7935 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
7936 : : break;
7937 : : }
7938 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7939 : : __builtin_unreachable ();
7940 : : }
7941 : :
7942 : :
7943 : : /*
7944 : : CanResolveConstructor - returns TRUE if the type of the constructor,
7945 : : sym, is known.
7946 : : */
7947 : :
7948 : 20468 : static bool CanResolveConstructor (unsigned int sym)
7949 : : {
7950 : 20468 : SymbolTable_PtrToSymbol pSym;
7951 : :
7952 : 20468 : if (! (IsConstructorResolved (sym)))
7953 : : {
7954 : 20468 : pSym = GetPsym (sym);
7955 : 20468 : switch (pSym->SymbolType)
7956 : : {
7957 : 20468 : case SymbolTable_ConstVarSym:
7958 : 20468 : ResolveConstructorType (sym, &pSym->ConstVar.Type, &pSym->ConstVar.FromType, &pSym->ConstVar.UnresFromType);
7959 : 20468 : break;
7960 : :
7961 : 0 : case SymbolTable_ConstLitSym:
7962 : 0 : ResolveConstructorType (sym, &pSym->ConstLit.Type, &pSym->ConstLit.FromType, &pSym->ConstLit.UnresFromType);
7963 : 0 : break;
7964 : :
7965 : :
7966 : 0 : default:
7967 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
7968 : : break;
7969 : : }
7970 : : }
7971 : 20468 : return IsConstructorResolved (sym);
7972 : : /* static analysis guarentees a RETURN statement will be used before here. */
7973 : : __builtin_unreachable ();
7974 : : }
7975 : :
7976 : :
7977 : : /*
7978 : : CheckAllConstructorsResolved - checks to see that the
7979 : : UnresolvedConstructorType list is
7980 : : empty and if it is not then it
7981 : : generates error messages.
7982 : : */
7983 : :
7984 : 16710 : static void CheckAllConstructorsResolved (void)
7985 : : {
7986 : 16710 : unsigned int i;
7987 : 16710 : unsigned int n;
7988 : 16710 : unsigned int s;
7989 : 16710 : M2Error_Error e;
7990 : :
7991 : 16710 : n = Lists_NoOfItemsInList (UnresolvedConstructorType);
7992 : 16710 : if (n > 0)
7993 : : {
7994 : 12 : for (i=1; i<=n; i++)
7995 : : {
7996 : 6 : s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
7997 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredMod (s));
7998 : 6 : M2Error_ErrorFormat0 (e, (const char *) "constructor has an unknown type", 31);
7999 : : }
8000 : 6 : M2Error_FlushErrors ();
8001 : : }
8002 : 16704 : }
8003 : :
8004 : :
8005 : : /*
8006 : : SanityCheckParameters -
8007 : : */
8008 : :
8009 : 3345342 : static void SanityCheckParameters (unsigned int sym)
8010 : : {
8011 : 3345342 : unsigned int p;
8012 : 3345342 : unsigned int i;
8013 : 3345342 : unsigned int n;
8014 : :
8015 : 3345342 : i = 1;
8016 : 3345342 : n = SymbolTable_NoOfParam (sym);
8017 : 12547817 : while (i <= n)
8018 : : {
8019 : 5857133 : p = SymbolTable_GetType (SymbolTable_GetParam (sym, i));
8020 : 5857133 : if (SymbolTable_IsConst (p))
8021 : : {
8022 : 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);
8023 : : }
8024 : 5857133 : i += 1;
8025 : : }
8026 : 3345342 : }
8027 : :
8028 : :
8029 : : /*
8030 : : SanityCheckArray - checks to see that an array has a correct subrange type.
8031 : : */
8032 : :
8033 : 31218914 : static void SanityCheckArray (unsigned int sym)
8034 : : {
8035 : 31218914 : unsigned int type;
8036 : 31218914 : unsigned int subscript;
8037 : :
8038 : 31218914 : if (SymbolTable_IsArray (sym))
8039 : : {
8040 : 81445 : subscript = SymbolTable_GetArraySubscript (sym);
8041 : 81445 : if (subscript != SymbolTable_NulSym)
8042 : : {
8043 : 81445 : type = SymbolTable_SkipType (SymbolTable_GetType (subscript));
8044 : 81445 : if (SymbolTable_IsAModula2Type (type))
8045 : : {} /* empty. */
8046 : : else
8047 : : {
8048 : : /* ok all is good */
8049 : 0 : M2MetaError_MetaError2 ((const char *) "the array {%1Dad} must be declared with a simpletype in the [..] component rather than a {%2d}", 94, sym, type);
8050 : : }
8051 : : }
8052 : : }
8053 : 31218914 : }
8054 : :
8055 : :
8056 : : /*
8057 : : ForeachSymbolDo - foreach symbol, call, P(sym).
8058 : : */
8059 : :
8060 : 16704 : static void ForeachSymbolDo (SymbolKey_PerformOperation P)
8061 : : {
8062 : 16704 : unsigned int i;
8063 : 16704 : unsigned int n;
8064 : :
8065 : 16704 : i = Indexing_LowIndice (Symbols);
8066 : 16704 : n = Indexing_HighIndice (Symbols);
8067 : 25104156 : while (i <= n)
8068 : : {
8069 : 25070748 : (*P.proc) (i);
8070 : 25070748 : i += 1;
8071 : : }
8072 : 16704 : }
8073 : :
8074 : :
8075 : : /*
8076 : : SanityCheckProcedure - check to see that procedure parameters do not use constants
8077 : : instead of types in their formal parameter section.
8078 : : */
8079 : :
8080 : 3345342 : static void SanityCheckProcedure (unsigned int sym)
8081 : : {
8082 : 3345342 : SanityCheckParameters (sym);
8083 : 3345342 : }
8084 : :
8085 : :
8086 : : /*
8087 : : SanityCheckModule -
8088 : : */
8089 : :
8090 : 152487 : static void SanityCheckModule (unsigned int sym)
8091 : : {
8092 : 152487 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
8093 : 152487 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckProcedure});
8094 : 152487 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
8095 : 152487 : }
8096 : :
8097 : :
8098 : : /*
8099 : : AddNameTo - adds Name, n, to tree, s.
8100 : : */
8101 : :
8102 : 4668874 : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o)
8103 : : {
8104 : 4668874 : if ((SymbolKey_GetSymKey (s, SymbolTable_GetSymName (o))) == SymbolKey_NulKey)
8105 : : {
8106 : 4085948 : SymbolKey_PutSymKey (s, SymbolTable_GetSymName (o), o);
8107 : : }
8108 : 4668874 : }
8109 : :
8110 : :
8111 : : /*
8112 : : CollectSymbolFrom -
8113 : : */
8114 : :
8115 : 126 : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n)
8116 : : {
8117 : 126 : NameKey_Name n1;
8118 : 126 : unsigned int sym;
8119 : :
8120 : 126 : n1 = SymbolTable_GetSymName (scope);
8121 : 126 : if (DebugUnknowns)
8122 : : {
8123 : : M2Printf_printf2 ((const char *) "declaring %a in %a", 18, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n1, (sizeof (n1)-1));
8124 : : }
8125 : 126 : sym = CheckScopeForSym (scope, n);
8126 : 126 : if (sym == SymbolTable_NulSym)
8127 : : {
8128 : 54 : sym = FetchUnknownFrom (tok, scope, n);
8129 : : }
8130 : 126 : if (DebugUnknowns)
8131 : : {
8132 : : M2Printf_printf1 ((const char *) " symbol created (%d)\\n", 22, (const unsigned char *) &sym, (sizeof (sym)-1));
8133 : : }
8134 : 126 : return sym;
8135 : : /* static analysis guarentees a RETURN statement will be used before here. */
8136 : : __builtin_unreachable ();
8137 : : }
8138 : :
8139 : :
8140 : : /*
8141 : : CollectUnknown -
8142 : : */
8143 : :
8144 : 162 : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n)
8145 : : {
8146 : 222 : SymbolTable_PtrToSymbol pSym;
8147 : 222 : unsigned int s;
8148 : :
8149 : 222 : s = SymbolTable_NulSym;
8150 : 222 : if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
8151 : : {
8152 : 108 : return CollectSymbolFrom (tok, sym, n);
8153 : : }
8154 : 114 : else if (SymbolTable_IsProcedure (sym))
8155 : : {
8156 : : /* avoid dangling else. */
8157 : 114 : s = CheckScopeForSym (sym, n);
8158 : 114 : if (s == SymbolTable_NulSym)
8159 : : {
8160 : 78 : pSym = GetPsym (sym);
8161 : 78 : switch (pSym->SymbolType)
8162 : : {
8163 : 78 : case SymbolTable_ProcedureSym:
8164 : 78 : if ((SymbolKey_GetSymKey (pSym->Procedure.NamedObjects, n)) != SymbolKey_NulKey)
8165 : : {
8166 : 18 : return CollectSymbolFrom (tok, sym, n);
8167 : : }
8168 : 60 : break;
8169 : :
8170 : :
8171 : 0 : default:
8172 : 0 : M2Error_InternalError ((const char *) "expecting - Procedure symbol", 28);
8173 : 60 : break;
8174 : : }
8175 : 60 : s = CollectUnknown (tok, SymbolTable_GetScope (sym), n);
8176 : : }
8177 : : }
8178 : : return s;
8179 : : /* static analysis guarentees a RETURN statement will be used before here. */
8180 : : __builtin_unreachable ();
8181 : : }
8182 : :
8183 : :
8184 : : /*
8185 : : ResolveImport -
8186 : : */
8187 : :
8188 : 162 : static void ResolveImport (unsigned int o)
8189 : : {
8190 : 162 : NameKey_Name n1;
8191 : 162 : NameKey_Name n2;
8192 : 162 : unsigned int tok;
8193 : 162 : unsigned int sym;
8194 : :
8195 : 162 : if (DebugUnknowns)
8196 : : {
8197 : : n1 = SymbolTable_GetSymName (o);
8198 : : M2Printf_printf1 ((const char *) "attempting to find out where %a was declared\\n", 46, (const unsigned char *) &n1, (sizeof (n1)-1));
8199 : : n1 = SymbolTable_GetSymName (ResolveModule);
8200 : : n2 = SymbolTable_GetSymName (SymbolTable_GetScope (ResolveModule));
8201 : : 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));
8202 : : }
8203 : 162 : tok = SymbolTable_GetFirstUsed (o);
8204 : 162 : sym = CollectUnknown (tok, SymbolTable_GetScope (ResolveModule), SymbolTable_GetSymName (o));
8205 : 162 : if (sym == SymbolTable_NulSym)
8206 : : {
8207 : 0 : M2MetaError_MetaError2 ((const char *) "unknown symbol {%1Uad} found in import list of module {%2a}", 59, o, ResolveModule);
8208 : : }
8209 : : else
8210 : : {
8211 : 162 : SymbolTable_AddSymToModuleScope (ResolveModule, sym);
8212 : : }
8213 : 162 : }
8214 : :
8215 : :
8216 : : /*
8217 : : ResolveRelativeImport -
8218 : : */
8219 : :
8220 : 926973 : static void ResolveRelativeImport (unsigned int sym)
8221 : : {
8222 : 926973 : SymbolTable_PtrToSymbol pSym;
8223 : :
8224 : 926973 : if (SymbolTable_IsModule (sym))
8225 : : {
8226 : 420 : ResolveModule = sym;
8227 : 420 : pSym = GetPsym (sym);
8228 : 420 : switch (pSym->SymbolType)
8229 : : {
8230 : 420 : case SymbolTable_ModuleSym:
8231 : 420 : SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveImport});
8232 : 420 : break;
8233 : :
8234 : :
8235 : 0 : default:
8236 : 0 : M2Error_InternalError ((const char *) "expecting - Module symbol", 25);
8237 : 420 : break;
8238 : : }
8239 : : }
8240 : 926973 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
8241 : 926973 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
8242 : 926973 : }
8243 : :
8244 : :
8245 : : /*
8246 : : Max -
8247 : : */
8248 : :
8249 : 0 : static unsigned int Max (unsigned int a, unsigned int b)
8250 : : {
8251 : 0 : if (a > b)
8252 : : {
8253 : : return a;
8254 : : }
8255 : : else
8256 : : {
8257 : 0 : return b;
8258 : : }
8259 : : /* static analysis guarentees a RETURN statement will be used before here. */
8260 : : __builtin_unreachable ();
8261 : : }
8262 : :
8263 : :
8264 : : /*
8265 : : Min -
8266 : : */
8267 : :
8268 : 0 : static unsigned int Min (unsigned int a, unsigned int b)
8269 : : {
8270 : 0 : if (a < b)
8271 : : {
8272 : : return a;
8273 : : }
8274 : : else
8275 : : {
8276 : 0 : return b;
8277 : : }
8278 : : /* static analysis guarentees a RETURN statement will be used before here. */
8279 : : __builtin_unreachable ();
8280 : : }
8281 : :
8282 : :
8283 : : /*
8284 : : DoFindLimits - assigns, Start, and, End, to the start and end
8285 : : limits contained in the list, l. It ensures that
8286 : : Start and End are within StartLimit..EndLimit.
8287 : : If StartLimit or EndLimit are 0 then Start is
8288 : : is set to the first value and End to the last.
8289 : : */
8290 : :
8291 : 0 : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l)
8292 : : {
8293 : 0 : unsigned int i;
8294 : 0 : unsigned int j;
8295 : 0 : unsigned int n;
8296 : :
8297 : 0 : (*End) = 0;
8298 : 0 : (*Start) = 0;
8299 : 0 : i = 1;
8300 : 0 : n = Lists_NoOfItemsInList (l);
8301 : 0 : while (i <= n)
8302 : : {
8303 : 0 : j = static_cast<unsigned int> (Lists_GetItemFromList (l, i));
8304 : 0 : if (((j > (*End)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
8305 : : {
8306 : 0 : (*End) = j;
8307 : : }
8308 : 0 : if ((((((*Start) == 0) || (j < (*Start))) && (j != 0)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
8309 : : {
8310 : 0 : (*Start) = j;
8311 : : }
8312 : 0 : i += 1;
8313 : : }
8314 : 0 : }
8315 : :
8316 : :
8317 : : /*
8318 : : PutDeclaredDefinition - associates the current tokenno with
8319 : : the symbols declaration in the definition
8320 : : module.
8321 : : */
8322 : :
8323 : 11374161 : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym)
8324 : : {
8325 : 11374161 : SymbolTable_PtrToSymbol pSym;
8326 : :
8327 : 11374161 : pSym = GetPsym (Sym);
8328 : 11374161 : switch (pSym->SymbolType)
8329 : : {
8330 : 0 : case SymbolTable_ErrorSym:
8331 : 0 : pSym->Error.At.DefDeclared = tok;
8332 : 0 : break;
8333 : :
8334 : 0 : case SymbolTable_ObjectSym:
8335 : 0 : pSym->Object.At.DefDeclared = tok;
8336 : 0 : break;
8337 : :
8338 : 0 : case SymbolTable_VarientSym:
8339 : 0 : pSym->Varient.At.DefDeclared = tok;
8340 : 0 : break;
8341 : :
8342 : 0 : case SymbolTable_RecordSym:
8343 : 0 : pSym->Record.At.DefDeclared = tok;
8344 : 0 : break;
8345 : :
8346 : 0 : case SymbolTable_SubrangeSym:
8347 : 0 : pSym->Subrange.At.DefDeclared = tok;
8348 : 0 : break;
8349 : :
8350 : 0 : case SymbolTable_EnumerationSym:
8351 : 0 : pSym->Enumeration.At.DefDeclared = tok;
8352 : 0 : break;
8353 : :
8354 : 0 : case SymbolTable_ArraySym:
8355 : 0 : pSym->Array.At.DefDeclared = tok;
8356 : 0 : break;
8357 : :
8358 : 0 : case SymbolTable_SubscriptSym:
8359 : 0 : pSym->Subscript.At.DefDeclared = tok;
8360 : 0 : break;
8361 : :
8362 : 0 : case SymbolTable_UnboundedSym:
8363 : 0 : pSym->Unbounded.At.DefDeclared = tok;
8364 : 0 : break;
8365 : :
8366 : 2016275 : case SymbolTable_ProcedureSym:
8367 : 2016275 : pSym->Procedure.At.DefDeclared = tok;
8368 : 2016275 : break;
8369 : :
8370 : 0 : case SymbolTable_ProcTypeSym:
8371 : 0 : pSym->ProcType.At.DefDeclared = tok;
8372 : 0 : break;
8373 : :
8374 : 0 : case SymbolTable_ParamSym:
8375 : 0 : pSym->Param.At.DefDeclared = tok;
8376 : 0 : break;
8377 : :
8378 : 0 : case SymbolTable_VarParamSym:
8379 : 0 : pSym->VarParam.At.DefDeclared = tok;
8380 : 0 : break;
8381 : :
8382 : 0 : case SymbolTable_ConstStringSym:
8383 : 0 : pSym->ConstString.At.DefDeclared = tok;
8384 : 0 : break;
8385 : :
8386 : 0 : case SymbolTable_ConstLitSym:
8387 : 0 : pSym->ConstLit.At.DefDeclared = tok;
8388 : 0 : break;
8389 : :
8390 : 3126 : case SymbolTable_ConstVarSym:
8391 : 3126 : pSym->ConstVar.At.DefDeclared = tok;
8392 : 3126 : break;
8393 : :
8394 : 4876949 : case SymbolTable_VarSym:
8395 : 4876949 : pSym->Var.At.DefDeclared = tok;
8396 : 4876949 : break;
8397 : :
8398 : 0 : case SymbolTable_TypeSym:
8399 : 0 : pSym->Type.At.DefDeclared = tok;
8400 : 0 : break;
8401 : :
8402 : 0 : case SymbolTable_PointerSym:
8403 : 0 : pSym->Pointer.At.DefDeclared = tok;
8404 : 0 : break;
8405 : :
8406 : 93679 : case SymbolTable_RecordFieldSym:
8407 : 93679 : pSym->RecordField.At.DefDeclared = tok;
8408 : 93679 : break;
8409 : :
8410 : 0 : case SymbolTable_VarientFieldSym:
8411 : 0 : pSym->VarientField.At.DefDeclared = tok;
8412 : 0 : break;
8413 : :
8414 : 0 : case SymbolTable_EnumerationFieldSym:
8415 : 0 : pSym->EnumerationField.At.DefDeclared = tok;
8416 : 0 : break;
8417 : :
8418 : 0 : case SymbolTable_SetSym:
8419 : 0 : pSym->Set.At.DefDeclared = tok;
8420 : 0 : break;
8421 : :
8422 : 4384132 : case SymbolTable_DefImpSym:
8423 : 4384132 : pSym->DefImp.At.DefDeclared = tok;
8424 : 4384132 : break;
8425 : :
8426 : 0 : case SymbolTable_ModuleSym:
8427 : 0 : pSym->Module.At.DefDeclared = tok;
8428 : 0 : break;
8429 : :
8430 : : case SymbolTable_UndefinedSym:
8431 : : break;
8432 : :
8433 : 0 : case SymbolTable_PartialUnboundedSym:
8434 : 0 : PutDeclaredDefinition (tok, pSym->PartialUnbounded.Type);
8435 : 0 : break;
8436 : :
8437 : :
8438 : 0 : default:
8439 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
8440 : 11374161 : break;
8441 : : }
8442 : 11374161 : }
8443 : :
8444 : :
8445 : : /*
8446 : : PutDeclaredModule - returns the token where this symbol was declared
8447 : : in an implementation or program module.
8448 : : */
8449 : :
8450 : 8416889 : static void PutDeclaredModule (unsigned int tok, unsigned int Sym)
8451 : : {
8452 : 8416889 : SymbolTable_PtrToSymbol pSym;
8453 : :
8454 : 8416889 : pSym = GetPsym (Sym);
8455 : 8416889 : switch (pSym->SymbolType)
8456 : : {
8457 : 0 : case SymbolTable_ErrorSym:
8458 : 0 : pSym->Error.At.ModDeclared = tok;
8459 : 0 : break;
8460 : :
8461 : 0 : case SymbolTable_ObjectSym:
8462 : 0 : pSym->Object.At.ModDeclared = tok;
8463 : 0 : break;
8464 : :
8465 : 0 : case SymbolTable_VarientSym:
8466 : 0 : pSym->Varient.At.ModDeclared = tok;
8467 : 0 : break;
8468 : :
8469 : 0 : case SymbolTable_RecordSym:
8470 : 0 : pSym->Record.At.ModDeclared = tok;
8471 : 0 : break;
8472 : :
8473 : 0 : case SymbolTable_SubrangeSym:
8474 : 0 : pSym->Subrange.At.ModDeclared = tok;
8475 : 0 : break;
8476 : :
8477 : 0 : case SymbolTable_EnumerationSym:
8478 : 0 : pSym->Enumeration.At.ModDeclared = tok;
8479 : 0 : break;
8480 : :
8481 : 0 : case SymbolTable_ArraySym:
8482 : 0 : pSym->Array.At.ModDeclared = tok;
8483 : 0 : break;
8484 : :
8485 : 0 : case SymbolTable_SubscriptSym:
8486 : 0 : pSym->Subscript.At.ModDeclared = tok;
8487 : 0 : break;
8488 : :
8489 : 0 : case SymbolTable_UnboundedSym:
8490 : 0 : pSym->Unbounded.At.ModDeclared = tok;
8491 : 0 : break;
8492 : :
8493 : 1467027 : case SymbolTable_ProcedureSym:
8494 : 1467027 : pSym->Procedure.At.ModDeclared = tok;
8495 : 1467027 : break;
8496 : :
8497 : 0 : case SymbolTable_ProcTypeSym:
8498 : 0 : pSym->ProcType.At.ModDeclared = tok;
8499 : 0 : break;
8500 : :
8501 : 0 : case SymbolTable_ParamSym:
8502 : 0 : pSym->Param.At.ModDeclared = tok;
8503 : 0 : break;
8504 : :
8505 : 0 : case SymbolTable_VarParamSym:
8506 : 0 : pSym->VarParam.At.ModDeclared = tok;
8507 : 0 : break;
8508 : :
8509 : 0 : case SymbolTable_ConstStringSym:
8510 : 0 : pSym->ConstString.At.ModDeclared = tok;
8511 : 0 : break;
8512 : :
8513 : 0 : case SymbolTable_ConstLitSym:
8514 : 0 : pSym->ConstLit.At.ModDeclared = tok;
8515 : 0 : break;
8516 : :
8517 : 6953 : case SymbolTable_ConstVarSym:
8518 : 6953 : pSym->ConstVar.At.ModDeclared = tok;
8519 : 6953 : break;
8520 : :
8521 : 3275873 : case SymbolTable_VarSym:
8522 : 3275873 : pSym->Var.At.ModDeclared = tok;
8523 : 3275873 : break;
8524 : :
8525 : 0 : case SymbolTable_TypeSym:
8526 : 0 : pSym->Type.At.ModDeclared = tok;
8527 : 0 : break;
8528 : :
8529 : 0 : case SymbolTable_PointerSym:
8530 : 0 : pSym->Pointer.At.ModDeclared = tok;
8531 : 0 : break;
8532 : :
8533 : 156393 : case SymbolTable_RecordFieldSym:
8534 : 156393 : pSym->RecordField.At.ModDeclared = tok;
8535 : 156393 : break;
8536 : :
8537 : 0 : case SymbolTable_VarientFieldSym:
8538 : 0 : pSym->VarientField.At.ModDeclared = tok;
8539 : 0 : break;
8540 : :
8541 : 0 : case SymbolTable_EnumerationFieldSym:
8542 : 0 : pSym->EnumerationField.At.ModDeclared = tok;
8543 : 0 : break;
8544 : :
8545 : 0 : case SymbolTable_SetSym:
8546 : 0 : pSym->Set.At.ModDeclared = tok;
8547 : 0 : break;
8548 : :
8549 : 3458747 : case SymbolTable_DefImpSym:
8550 : 3458747 : pSym->DefImp.At.ModDeclared = tok;
8551 : 3458747 : break;
8552 : :
8553 : 51896 : case SymbolTable_ModuleSym:
8554 : 51896 : pSym->Module.At.ModDeclared = tok;
8555 : 51896 : break;
8556 : :
8557 : : case SymbolTable_UndefinedSym:
8558 : : break;
8559 : :
8560 : 0 : case SymbolTable_PartialUnboundedSym:
8561 : 0 : PutDeclaredModule (tok, pSym->PartialUnbounded.Type);
8562 : 0 : break;
8563 : :
8564 : :
8565 : 0 : default:
8566 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
8567 : 8416889 : break;
8568 : : }
8569 : 8416889 : }
8570 : :
8571 : :
8572 : : /*
8573 : : DoIsConst - returns TRUE if Sym is defined as a constant
8574 : : or is an enumeration field or string.
8575 : : */
8576 : :
8577 : 100094666 : static bool DoIsConst (unsigned int Sym)
8578 : : {
8579 : 100094666 : SymbolTable_PtrToSymbol pSym;
8580 : :
8581 : 100094666 : pSym = GetPsym (Sym);
8582 : 100094666 : 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);
8583 : : /* static analysis guarentees a RETURN statement will be used before here. */
8584 : : __builtin_unreachable ();
8585 : : }
8586 : :
8587 : :
8588 : : /*
8589 : : GetFromIndex - return a value from list, i, at position, n.
8590 : : */
8591 : :
8592 : 3658248 : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n)
8593 : : {
8594 : 3658248 : typedef unsigned int *GetFromIndex__T2;
8595 : :
8596 : 3658248 : GetFromIndex__T2 p;
8597 : :
8598 : 3298453 : p = static_cast<GetFromIndex__T2> (Indexing_GetIndice (i, n));
8599 : 3298453 : return (*p);
8600 : : /* static analysis guarentees a RETURN statement will be used before here. */
8601 : : __builtin_unreachable ();
8602 : : }
8603 : :
8604 : :
8605 : : /*
8606 : : PutIntoIndex - places value, v, into list, i, at position, n.
8607 : : */
8608 : :
8609 : 340647 : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v)
8610 : : {
8611 : 340647 : typedef unsigned int *PutIntoIndex__T3;
8612 : :
8613 : 340647 : PutIntoIndex__T3 p;
8614 : :
8615 : 340647 : Storage_ALLOCATE ((void **) &p, sizeof (unsigned int));
8616 : 340647 : (*p) = v;
8617 : 340647 : Indexing_PutIndice ((*i), n, reinterpret_cast<void *> (p));
8618 : 340647 : }
8619 : :
8620 : :
8621 : : /*
8622 : : PushConstString - pushes the character string onto the ALU stack.
8623 : : It assumes that the character string is only
8624 : : one character long.
8625 : : */
8626 : :
8627 : 12028 : static void PushConstString (unsigned int Sym)
8628 : : {
8629 : 12028 : typedef struct PushConstString__T6_a PushConstString__T6;
8630 : :
8631 : 12028 : struct PushConstString__T6_a { char array[10+1]; };
8632 : 12028 : SymbolTable_PtrToSymbol pSym;
8633 : 12028 : PushConstString__T6 a;
8634 : :
8635 : 12028 : CheckLegal (Sym);
8636 : 12028 : pSym = GetPsym (Sym);
8637 : 12028 : switch (pSym->SymbolType)
8638 : : {
8639 : 12028 : case SymbolTable_ConstStringSym:
8640 : 12028 : if (pSym->ConstString.Length == 1)
8641 : : {
8642 : 12028 : NameKey_GetKey (pSym->ConstString.Contents, (char *) &a.array[0], 10);
8643 : 12028 : M2ALU_PushChar (a.array[0]);
8644 : : }
8645 : : else
8646 : : {
8647 : 0 : M2Error_WriteFormat0 ((const char *) "ConstString must be length 1", 28);
8648 : : }
8649 : 12028 : break;
8650 : :
8651 : :
8652 : 0 : default:
8653 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
8654 : 12028 : break;
8655 : : }
8656 : 12028 : }
8657 : :
8658 : :
8659 : : /*
8660 : : FinalSymbol - returns the highest number symbol used.
8661 : : */
8662 : :
8663 : 1545149882 : extern "C" unsigned int SymbolTable_FinalSymbol (void)
8664 : : {
8665 : 1545149882 : return FreeSymbol-1;
8666 : : /* static analysis guarentees a RETURN statement will be used before here. */
8667 : : __builtin_unreachable ();
8668 : : }
8669 : :
8670 : :
8671 : : /*
8672 : : MakeComponentRecord - make a temporary which will be used to reference and field
8673 : : (or sub field) of record.
8674 : : */
8675 : :
8676 : 151543 : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record)
8677 : : {
8678 : 151543 : return buildTemporary (tok, Mode, true, record);
8679 : : /* static analysis guarentees a RETURN statement will be used before here. */
8680 : : __builtin_unreachable ();
8681 : : }
8682 : :
8683 : :
8684 : : /*
8685 : : MakeComponentRef - use, sym, to reference, field, sym is returned.
8686 : : */
8687 : :
8688 : 151543 : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field)
8689 : : {
8690 : 151543 : SymbolTable_PtrToSymbol pSym;
8691 : 151543 : unsigned int high;
8692 : :
8693 : 151543 : pSym = GetPsym (sym);
8694 : 151543 : switch (pSym->SymbolType)
8695 : : {
8696 : 151543 : case SymbolTable_VarSym:
8697 : 151543 : if (! pSym->Var.IsTemp)
8698 : : {
8699 : 0 : M2Error_InternalError ((const char *) "variable must be a temporary", 28);
8700 : : }
8701 : 151543 : else if (pSym->Var.IsComponentRef)
8702 : : {
8703 : : /* avoid dangling else. */
8704 : 151543 : high = Indexing_HighIndice (pSym->Var.list);
8705 : 151543 : PutIntoIndex (&pSym->Var.list, high+1, field);
8706 : : }
8707 : : else
8708 : : {
8709 : : /* avoid dangling else. */
8710 : 0 : M2Error_InternalError ((const char *) "temporary is not a component reference", 38);
8711 : : }
8712 : 151543 : break;
8713 : :
8714 : :
8715 : 0 : default:
8716 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
8717 : 151543 : break;
8718 : : }
8719 : 151543 : return sym;
8720 : : /* static analysis guarentees a RETURN statement will be used before here. */
8721 : : __builtin_unreachable ();
8722 : : }
8723 : :
8724 : :
8725 : : /*
8726 : : IsComponent - returns TRUE if symbol, sym, is a temporary and a component
8727 : : reference.
8728 : : */
8729 : :
8730 : 88057463 : extern "C" bool SymbolTable_IsComponent (unsigned int sym)
8731 : : {
8732 : 88057463 : SymbolTable_PtrToSymbol pSym;
8733 : :
8734 : 88057463 : pSym = GetPsym (sym);
8735 : 88057463 : switch (pSym->SymbolType)
8736 : : {
8737 : 3555093 : case SymbolTable_VarSym:
8738 : 3555093 : return pSym->Var.IsComponentRef;
8739 : : break;
8740 : :
8741 : :
8742 : : default:
8743 : : return false;
8744 : : break;
8745 : : }
8746 : : /* static analysis guarentees a RETURN statement will be used before here. */
8747 : : __builtin_unreachable ();
8748 : : }
8749 : :
8750 : :
8751 : : /*
8752 : : MakeTemporary - Makes a new temporary variable at the highest real scope.
8753 : : The addressing mode of the temporary is set to NoValue.
8754 : : */
8755 : :
8756 : 965817 : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode)
8757 : : {
8758 : 965817 : tok = CheckTok (tok, (const char *) "temporary", 9);
8759 : 965817 : return buildTemporary (tok, Mode, false, SymbolTable_NulSym);
8760 : : /* static analysis guarentees a RETURN statement will be used before here. */
8761 : : __builtin_unreachable ();
8762 : : }
8763 : :
8764 : :
8765 : : /*
8766 : : MakeTemporaryFromExpression - makes a new temporary variable at the
8767 : : highest real scope. The addressing
8768 : : mode of the temporary is set and the
8769 : : type is determined by expressions, e.
8770 : : */
8771 : :
8772 : 0 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode)
8773 : : {
8774 : 0 : return SymbolTable_MakeTemporaryFromExpressions (tok, e, e, mode);
8775 : : /* static analysis guarentees a RETURN statement will be used before here. */
8776 : : __builtin_unreachable ();
8777 : : }
8778 : :
8779 : :
8780 : : /*
8781 : : MakeTemporaryFromExpressions - makes a new temporary variable at the
8782 : : highest real scope. The addressing
8783 : : mode of the temporary is set and the
8784 : : type is determined by expressions,
8785 : : e1 and e2.
8786 : : */
8787 : :
8788 : 71507 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode)
8789 : : {
8790 : 71507 : SymbolTable_PtrToSymbol pSym;
8791 : 71507 : DynamicStrings_String s;
8792 : 71507 : unsigned int t;
8793 : 71507 : unsigned int Sym;
8794 : :
8795 : 71507 : TemporaryNo += 1;
8796 : : /* Make the name */
8797 : 71507 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
8798 : 71507 : if (mode == SymbolTable_ImmediateValue)
8799 : : {
8800 : 26108 : Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
8801 : 26108 : if (SymbolTable_IsConstructor (e1))
8802 : : {
8803 : 206 : SymbolTable_PutConstructor (Sym);
8804 : 206 : SymbolTable_PutConstructorFrom (Sym, e1);
8805 : : }
8806 : 25902 : else if (SymbolTable_IsConstructor (e2))
8807 : : {
8808 : : /* avoid dangling else. */
8809 : 12 : SymbolTable_PutConstructor (Sym);
8810 : 12 : SymbolTable_PutConstructorFrom (Sym, e2);
8811 : : }
8812 : : else
8813 : : {
8814 : : /* avoid dangling else. */
8815 : 25890 : SymbolTable_PutVar (Sym, M2Base_MixTypes (SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok));
8816 : : }
8817 : 26108 : PutConstVarTemporary (Sym);
8818 : : }
8819 : : else
8820 : : {
8821 : 45399 : Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
8822 : 45399 : pSym = GetPsym (Sym);
8823 : 45399 : switch (pSym->SymbolType)
8824 : : {
8825 : 45399 : case SymbolTable_VarSym:
8826 : 45399 : pSym->Var.AddrMode = mode;
8827 : 45399 : pSym->Var.IsComponentRef = false;
8828 : 45399 : pSym->Var.IsTemp = true; /* Variable is a temporary var */
8829 : : /* Declared here */
8830 : 45399 : InitWhereDeclaredTok (tok, &pSym->Var.At);
8831 : 45399 : break;
8832 : :
8833 : :
8834 : 0 : default:
8835 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
8836 : 45399 : break;
8837 : : }
8838 : 45399 : t = M2Base_MixTypes (SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok);
8839 : 45327 : if (t != SymbolTable_NulSym)
8840 : : {
8841 : 45315 : M2Debug_Assert (! (SymbolTable_IsConstructor (t)));
8842 : 45315 : SymbolTable_PutVar (Sym, t);
8843 : : }
8844 : : }
8845 : 71435 : s = DynamicStrings_KillString (s);
8846 : 71435 : return Sym;
8847 : : /* static analysis guarentees a RETURN statement will be used before here. */
8848 : : __builtin_unreachable ();
8849 : : }
8850 : :
8851 : :
8852 : : /*
8853 : : PutMode - Puts the addressing mode, SymMode, into symbol Sym.
8854 : : The mode may only be altered if the mode
8855 : : is None.
8856 : : */
8857 : :
8858 : 6082049 : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode)
8859 : : {
8860 : 6082049 : SymbolTable_PtrToSymbol pSym;
8861 : :
8862 : 6082049 : pSym = GetPsym (Sym);
8863 : 6082049 : switch (pSym->SymbolType)
8864 : : {
8865 : : case SymbolTable_ErrorSym:
8866 : : break;
8867 : :
8868 : 6082049 : case SymbolTable_VarSym:
8869 : 6082049 : pSym->Var.AddrMode = SymMode;
8870 : 6082049 : break;
8871 : :
8872 : :
8873 : 0 : default:
8874 : 0 : M2Error_InternalError ((const char *) "Expecting VarSym", 16);
8875 : 6082049 : break;
8876 : : }
8877 : 6082049 : }
8878 : :
8879 : :
8880 : : /*
8881 : : GetMode - Returns the addressing mode of a symbol.
8882 : : */
8883 : :
8884 : 10913727 : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym)
8885 : : {
8886 : 10913727 : SymbolTable_PtrToSymbol pSym;
8887 : :
8888 : 10913727 : pSym = GetPsym (Sym);
8889 : 10913727 : switch (pSym->SymbolType)
8890 : : {
8891 : 0 : case SymbolTable_ErrorSym:
8892 : 0 : M2Error_ErrorAbort0 ((const char *) "", 0);
8893 : 9377910 : break;
8894 : :
8895 : 9377910 : case SymbolTable_VarSym:
8896 : 9377910 : return pSym->Var.AddrMode;
8897 : : break;
8898 : :
8899 : : case SymbolTable_ConstLitSym:
8900 : : return SymbolTable_ImmediateValue;
8901 : : break;
8902 : :
8903 : : case SymbolTable_ConstVarSym:
8904 : : return SymbolTable_ImmediateValue;
8905 : : break;
8906 : :
8907 : : case SymbolTable_ConstStringSym:
8908 : : return SymbolTable_ImmediateValue;
8909 : : break;
8910 : :
8911 : : case SymbolTable_EnumerationFieldSym:
8912 : : return SymbolTable_ImmediateValue;
8913 : : break;
8914 : :
8915 : : case SymbolTable_ProcedureSym:
8916 : : return SymbolTable_ImmediateValue;
8917 : : break;
8918 : :
8919 : : case SymbolTable_RecordFieldSym:
8920 : : return SymbolTable_ImmediateValue;
8921 : : break;
8922 : :
8923 : : case SymbolTable_VarientFieldSym:
8924 : : return SymbolTable_ImmediateValue;
8925 : : break;
8926 : :
8927 : : case SymbolTable_TypeSym:
8928 : : return SymbolTable_NoValue;
8929 : : break;
8930 : :
8931 : : case SymbolTable_ArraySym:
8932 : : return SymbolTable_NoValue;
8933 : : break;
8934 : :
8935 : : case SymbolTable_SubrangeSym:
8936 : : return SymbolTable_NoValue;
8937 : : break;
8938 : :
8939 : : case SymbolTable_EnumerationSym:
8940 : : return SymbolTable_NoValue;
8941 : : break;
8942 : :
8943 : : case SymbolTable_RecordSym:
8944 : : return SymbolTable_NoValue;
8945 : : break;
8946 : :
8947 : : case SymbolTable_PointerSym:
8948 : : return SymbolTable_NoValue;
8949 : : break;
8950 : :
8951 : : case SymbolTable_SetSym:
8952 : : return SymbolTable_NoValue;
8953 : : break;
8954 : :
8955 : : case SymbolTable_ProcTypeSym:
8956 : : return SymbolTable_NoValue;
8957 : : break;
8958 : :
8959 : : case SymbolTable_UnboundedSym:
8960 : : return SymbolTable_NoValue;
8961 : : break;
8962 : :
8963 : : case SymbolTable_UndefinedSym:
8964 : : return SymbolTable_NoValue;
8965 : 0 : break;
8966 : :
8967 : :
8968 : 0 : default:
8969 : 0 : M2Error_InternalError ((const char *) "not expecting this type", 23);
8970 : : break;
8971 : : }
8972 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8973 : : __builtin_unreachable ();
8974 : : }
8975 : :
8976 : :
8977 : : /*
8978 : : StartScope - starts a block scope at Sym. Transparent determines
8979 : : whether the search for a symbol will look at the
8980 : : previous ScopeCallFrame if Sym does not contain the
8981 : : symbol that GetSym is searching.
8982 : :
8983 : : WITH statements are partially implemented by calling
8984 : : StartScope. Therefore we must retain the old Main from
8985 : : the previous ScopePtr when a record is added to the scope
8986 : : stack. (Main contains the symbol where all identifiers
8987 : : should be added.)
8988 : : */
8989 : :
8990 : 18158878 : extern "C" void SymbolTable_StartScope (unsigned int Sym)
8991 : : {
8992 : 18158878 : SymbolTable_PtrToCallFrame oCall;
8993 : 18158878 : SymbolTable_PtrToCallFrame pCall;
8994 : :
8995 : 18158878 : Sym = SymbolTable_SkipType (Sym);
8996 : : /*
8997 : : WriteString('New scope is: ') ; WriteKey(GetSymName(Sym)) ; WriteLn ;
8998 : : */
8999 : 18158878 : ScopePtr += 1;
9000 : 18158878 : if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
9001 : : {
9002 : 18086569 : pCall = GetPcall (ScopePtr);
9003 : : }
9004 : : else
9005 : : {
9006 : 72309 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
9007 : 72309 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast<void *> (pCall));
9008 : : }
9009 : 18158878 : pCall->Start = ScopePtr-1; /* Previous ScopePtr value before StartScope */
9010 : 18158878 : pCall->Search = Sym;
9011 : : /* new symbols to ie temporary variables. */
9012 : 18158878 : if (SymbolTable_IsRecord (Sym))
9013 : : {
9014 : 30411 : oCall = GetPcall (ScopePtr-1);
9015 : 30411 : pCall->Main = oCall->Main;
9016 : : }
9017 : : else
9018 : : {
9019 : 18128467 : pCall->Main = Sym;
9020 : 18128467 : PlaceMajorScopesEnumerationListOntoStack (Sym);
9021 : : }
9022 : 18158878 : }
9023 : :
9024 : :
9025 : : /*
9026 : : EndScope - ends a block scope started by StartScope. The current
9027 : : head of the symbol scope reverts back to the symbol
9028 : : which was the Head of the symbol scope before the
9029 : : last StartScope was called.
9030 : : */
9031 : :
9032 : 18141905 : extern "C" void SymbolTable_EndScope (void)
9033 : : {
9034 : 18141905 : SymbolTable_PtrToCallFrame pCall;
9035 : :
9036 : : /*
9037 : : ; WriteString('EndScope - ending scope: ') ;
9038 : : pCall := GetPcall(ScopePtr) ;
9039 : : ; WriteKey(GetSymName(pCall^.Search)) ; WriteLn ;
9040 : : */
9041 : 18141905 : pCall = GetPcall (ScopePtr);
9042 : : /* ; DisplayScopes */
9043 : 18141905 : ScopePtr = pCall->Start;
9044 : 18141905 : }
9045 : :
9046 : :
9047 : : /*
9048 : : PseudoScope - starts a pseudo scope at Sym.
9049 : : We always connect parent up to the last scope,
9050 : : to determine the transparancy of a scope we call
9051 : : TransparentScope.
9052 : :
9053 : : A Pseudo scope has no end block,
9054 : : but is terminated when the next EndScope is used.
9055 : : The function of the pseudo scope is to provide an
9056 : : automatic mechanism to solve enumeration types.
9057 : : A declared enumeration type is a Pseudo scope and
9058 : : identifiers used with the name of an enumeration
9059 : : type field will find the enumeration symbol by
9060 : : the scoping algorithm.
9061 : : */
9062 : :
9063 : 404318 : extern "C" void SymbolTable_PseudoScope (unsigned int Sym)
9064 : : {
9065 : 404318 : SymbolTable_PtrToCallFrame oCall;
9066 : 404318 : SymbolTable_PtrToCallFrame pCall;
9067 : :
9068 : 404318 : if (SymbolTable_IsEnumeration (Sym))
9069 : : {
9070 : 404318 : ScopePtr += 1;
9071 : 404318 : if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
9072 : : {
9073 : 385245 : pCall = GetPcall (ScopePtr);
9074 : : }
9075 : : else
9076 : : {
9077 : 19073 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
9078 : 19073 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast<void *> (pCall));
9079 : : }
9080 : 404318 : oCall = GetPcall (ScopePtr-1);
9081 : 404318 : pCall->Main = oCall->Main;
9082 : 404318 : pCall->Start = oCall->Start;
9083 : 404318 : pCall->Search = Sym;
9084 : : }
9085 : : else
9086 : : {
9087 : 0 : M2Error_InternalError ((const char *) "expecting EnumerationSym", 24);
9088 : : }
9089 : 404318 : }
9090 : :
9091 : :
9092 : : /*
9093 : : GetCurrentScope - returns the symbol who is responsible for the current
9094 : : scope. Note that it ignore pseudo scopes.
9095 : : */
9096 : :
9097 : 23978263 : extern "C" unsigned int SymbolTable_GetCurrentScope (void)
9098 : : {
9099 : 23978263 : SymbolTable_PtrToCallFrame pCall;
9100 : :
9101 : 23978263 : pCall = GetPcall (ScopePtr);
9102 : 23978263 : return pCall->Main;
9103 : : /* static analysis guarentees a RETURN statement will be used before here. */
9104 : : __builtin_unreachable ();
9105 : : }
9106 : :
9107 : :
9108 : : /*
9109 : : IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
9110 : : */
9111 : :
9112 : 189705 : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym)
9113 : : {
9114 : 189705 : unsigned int s;
9115 : :
9116 : 189705 : s = SymbolTable_GetScope (sym);
9117 : 379410 : while (s != scope)
9118 : : {
9119 : 1184 : if ((((s == SymbolTable_NulSym) || (SymbolTable_IsProcedure (s))) || (SymbolTable_IsModule (s))) || (SymbolTable_IsDefImp (s)))
9120 : : {
9121 : 1184 : return false;
9122 : : }
9123 : : else
9124 : : {
9125 : 0 : s = SymbolTable_GetScope (s);
9126 : : }
9127 : : }
9128 : : return true;
9129 : : /* static analysis guarentees a RETURN statement will be used before here. */
9130 : : __builtin_unreachable ();
9131 : : }
9132 : :
9133 : :
9134 : : /*
9135 : : SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
9136 : : This Sym must represent the module name of the
9137 : : file currently being compiled.
9138 : : */
9139 : :
9140 : 994614 : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym)
9141 : : {
9142 : 994614 : CurrentModule = Sym;
9143 : 994614 : }
9144 : :
9145 : :
9146 : : /*
9147 : : SetFileModule - Used to set the FileModule to a symbol, Sym.
9148 : : This Sym must represent the current program module
9149 : : file which is being parsed.
9150 : : */
9151 : :
9152 : 942495 : extern "C" void SymbolTable_SetFileModule (unsigned int Sym)
9153 : : {
9154 : 942495 : FileModule = Sym;
9155 : 942495 : }
9156 : :
9157 : :
9158 : : /*
9159 : : SetMainModule - Used to set the MainModule to a symbol, Sym.
9160 : : This Sym must represent the main module which was
9161 : : envoked by the user to be compiled.
9162 : : */
9163 : :
9164 : 16810 : extern "C" void SymbolTable_SetMainModule (unsigned int Sym)
9165 : : {
9166 : 16810 : MainModule = Sym;
9167 : 16810 : }
9168 : :
9169 : :
9170 : : /*
9171 : : CheckAnonymous - checks to see whether the name is NulName and if so
9172 : : it creates a unique anonymous name.
9173 : : */
9174 : :
9175 : 1244395 : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name)
9176 : : {
9177 : 1244395 : if (name == NameKey_NulName)
9178 : : {
9179 : 48154 : AnonymousName += 1;
9180 : 48154 : 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)))));
9181 : : }
9182 : 1244395 : return name;
9183 : : /* static analysis guarentees a RETURN statement will be used before here. */
9184 : : __builtin_unreachable ();
9185 : : }
9186 : :
9187 : :
9188 : : /*
9189 : : IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
9190 : : or no name.
9191 : : */
9192 : :
9193 : 48626 : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym)
9194 : : {
9195 : 48626 : typedef struct IsNameAnonymous__T7_a IsNameAnonymous__T7;
9196 : :
9197 : 48626 : struct IsNameAnonymous__T7_a { char array[5+1]; };
9198 : 48626 : IsNameAnonymous__T7 a;
9199 : 48626 : NameKey_Name n;
9200 : :
9201 : 48626 : n = SymbolTable_GetSymName (sym);
9202 : 48626 : if (n == NameKey_NulName)
9203 : : {
9204 : : return true;
9205 : : }
9206 : : else
9207 : : {
9208 : 47726 : NameKey_GetKey (n, (char *) &a.array[0], 5);
9209 : 47726 : return StrLib_StrEqual ((const char *) &a.array[0], 5, (const char *) "__anon", 6);
9210 : : }
9211 : : /* static analysis guarentees a RETURN statement will be used before here. */
9212 : : __builtin_unreachable ();
9213 : : }
9214 : :
9215 : :
9216 : : /*
9217 : : NoOfVariables - returns the number of variables in scope. The scope maybe
9218 : : a procedure, module or defimp scope.
9219 : : */
9220 : :
9221 : 30 : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope)
9222 : : {
9223 : 30 : SymbolTable_PtrToSymbol pSym;
9224 : :
9225 : 30 : if (SymbolTable_IsProcedure (scope))
9226 : : {
9227 : 30 : return SymbolTable_NoOfLocalVar (scope);
9228 : : }
9229 : 0 : else if (SymbolTable_IsModule (scope))
9230 : : {
9231 : : /* avoid dangling else. */
9232 : 0 : pSym = GetPsym (scope);
9233 : 0 : switch (pSym->SymbolType)
9234 : : {
9235 : 0 : case SymbolTable_ModuleSym:
9236 : 0 : return Lists_NoOfItemsInList (pSym->Module.ListOfVars);
9237 : 0 : break;
9238 : :
9239 : :
9240 : 0 : default:
9241 : 0 : M2Error_InternalError ((const char *) "expecting module symbol", 23);
9242 : 0 : break;
9243 : : }
9244 : : }
9245 : 0 : else if (SymbolTable_IsDefImp (scope))
9246 : : {
9247 : : /* avoid dangling else. */
9248 : 0 : pSym = GetPsym (scope);
9249 : 0 : switch (pSym->SymbolType)
9250 : : {
9251 : 0 : case SymbolTable_DefImpSym:
9252 : 0 : return Lists_NoOfItemsInList (pSym->DefImp.ListOfVars);
9253 : 0 : break;
9254 : :
9255 : :
9256 : 0 : default:
9257 : 0 : M2Error_InternalError ((const char *) "expecting defimp symbol", 23);
9258 : 0 : break;
9259 : : }
9260 : : }
9261 : : else
9262 : : {
9263 : : /* avoid dangling else. */
9264 : 0 : M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
9265 : : }
9266 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9267 : : __builtin_unreachable ();
9268 : : }
9269 : :
9270 : :
9271 : : /*
9272 : : MakeModule - creates a module sym with ModuleName. It returns the
9273 : : symbol index.
9274 : : */
9275 : :
9276 : 27243 : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName)
9277 : : {
9278 : 27243 : SymbolTable_PtrToSymbol pSym;
9279 : 27243 : SymbolTable_PtrToCallFrame pCall;
9280 : 27243 : unsigned int Sym;
9281 : :
9282 : : /*
9283 : : Make a new symbol since we are at the outer scope level.
9284 : : DeclareSym examines the current scope level for any symbols
9285 : : that have the correct name, but are yet undefined.
9286 : : Therefore we must not call DeclareSym but create a symbol
9287 : : directly.
9288 : : */
9289 : 27243 : NewSym (&Sym);
9290 : 27243 : pSym = GetPsym (Sym);
9291 : 27243 : pSym->SymbolType = SymbolTable_ModuleSym;
9292 : 27243 : pSym->Module.name = ModuleName; /* Index into name array, name */
9293 : : /* of record field. */
9294 : 27243 : pSym->Module.libname = NameKey_NulName; /* Library association. */
9295 : 27243 : InitCtor (&pSym->Module.ctors); /* Init all ctor functions. */
9296 : 27243 : Lists_InitList (&pSym->Module.ModListOfDep); /* Vector of SymDependency. */
9297 : 27243 : SymbolKey_InitTree (&pSym->Module.LocalSymbols); /* The LocalSymbols hold all the */
9298 : : /* END WeAreHere. */
9299 : 27243 : SymbolKey_InitTree (&pSym->Module.ExportTree); /* Holds all the exported */
9300 : : /* deleted at the end of Pass 1. */
9301 : 27243 : SymbolKey_InitTree (&pSym->Module.ImportTree); /* Contains all IMPORTed */
9302 : : /* identifiers. */
9303 : 27243 : Lists_InitList (&pSym->Module.IncludeList); /* Contains all included symbols */
9304 : : /* modulename.Symbol */
9305 : 27243 : SymbolKey_InitTree (&pSym->Module.ExportUndeclared); /* ExportUndeclared contains all */
9306 : : /* been declared. */
9307 : 27243 : Lists_InitList (&pSym->Module.EnumerationScopeList); /* Enumeration scope list which */
9308 : : /* Outer Module. */
9309 : 27243 : SymbolKey_InitTree (&pSym->Module.NamedObjects); /* Names of all items declared. */
9310 : 27243 : SymbolKey_InitTree (&pSym->Module.NamedImports); /* Names of items imported. */
9311 : 27243 : SymbolKey_InitTree (&pSym->Module.WhereImported); /* Sym to TokenNo where import */
9312 : : /* occurs. Error message use. */
9313 : 27243 : pSym->Module.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9314 : : /* is an index to a constant. */
9315 : 27243 : SymbolKey_InitTree (&pSym->Module.Unresolved); /* All symbols currently */
9316 : : /* unresolved in this module. */
9317 : 27243 : pSym->Module.StartQuad = 0;
9318 : : /* code. */
9319 : 27243 : pSym->Module.EndQuad = 0; /* EndQuad should point to a */
9320 : : /* goto quad. */
9321 : 27243 : pSym->Module.StartFinishQuad = 0; /* Signify the finalization */
9322 : : /* code. */
9323 : 27243 : pSym->Module.EndFinishQuad = 0; /* should point to a finish */
9324 : 27243 : pSym->Module.FinallyFunction = NULL; /* The GCC function for finally */
9325 : 27243 : pSym->Module.ExceptionFinally = false; /* does it have an exception? */
9326 : 27243 : pSym->Module.ExceptionBlock = false; /* does it have an exception? */
9327 : 27243 : pSym->Module.ModLink = GetLink (); /* Is this parsed for linkage? */
9328 : 27243 : pSym->Module.Builtin = false; /* Is the module builtin? */
9329 : 27243 : Lists_InitList (&pSym->Module.ListOfVars); /* List of variables in this */
9330 : : /* scope. */
9331 : 27243 : Lists_InitList (&pSym->Module.ListOfProcs); /* List of all procedures */
9332 : : /* declared within this module. */
9333 : 27243 : Lists_InitList (&pSym->Module.ListOfModules); /* List of all inner modules. */
9334 : 27243 : InitWhereDeclaredTok (tok, &pSym->Module.At); /* Where symbol declared. */
9335 : 27243 : InitWhereFirstUsedTok (tok, &pSym->Module.At); /* Where symbol first used. */
9336 : 27243 : pCall = GetPcall (ScopePtr); /* Where symbol first used. */
9337 : 27243 : if (pCall->Main == (SymbolTable_GetBaseModule ()))
9338 : : {
9339 : 27243 : pSym->Module.Scope = SymbolTable_NulSym;
9340 : : }
9341 : : else
9342 : : {
9343 : 0 : pSym->Module.Scope = pCall->Main;
9344 : : }
9345 : 27243 : pSym->Module.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9346 : 27243 : SymbolKey_PutSymKey (ModuleTree, ModuleName, Sym); /* Title error scope. */
9347 : 27243 : return Sym;
9348 : : /* static analysis guarentees a RETURN statement will be used before here. */
9349 : : __builtin_unreachable ();
9350 : : }
9351 : :
9352 : :
9353 : : /*
9354 : : MakeDefImp - creates a definition and implementation module sym
9355 : : with name DefImpName. It returns the symbol index.
9356 : : */
9357 : :
9358 : 141700 : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName)
9359 : : {
9360 : 141700 : SymbolTable_PtrToSymbol pSym;
9361 : 141700 : unsigned int Sym;
9362 : :
9363 : : /* tok := CheckTok (tok, 'defimp') ; */
9364 : 141700 : NewSym (&Sym);
9365 : 141700 : pSym = GetPsym (Sym);
9366 : 141700 : pSym->SymbolType = SymbolTable_DefImpSym;
9367 : 141700 : pSym->DefImp.name = DefImpName; /* Index into name array, name */
9368 : : /* of record field. */
9369 : 141700 : pSym->DefImp.libname = NameKey_NulName; /* Library association. */
9370 : 141700 : InitCtor (&pSym->DefImp.ctors);
9371 : : /* Init all ctor functions. */
9372 : 141700 : Lists_InitList (&pSym->DefImp.DefListOfDep); /* Vector of SymDependency. */
9373 : 141700 : Lists_InitList (&pSym->DefImp.ModListOfDep); /* Vector of SymDependency. */
9374 : 141700 : SymbolKey_InitTree (&pSym->DefImp.ExportQualifiedTree);
9375 : : /* deleted at the end of Pass 1. */
9376 : 141700 : SymbolKey_InitTree (&pSym->DefImp.ExportUnQualifiedTree);
9377 : : /* deleted at the end of Pass 1. */
9378 : 141700 : SymbolKey_InitTree (&pSym->DefImp.ExportRequest); /* Contains all identifiers that */
9379 : : /* this list. */
9380 : 141700 : SymbolKey_InitTree (&pSym->DefImp.ImportTree); /* Contains all IMPORTed */
9381 : : /* identifiers. */
9382 : 141700 : Lists_InitList (&pSym->DefImp.IncludeList); /* Contains all included symbols */
9383 : : /* modulename.Symbol */
9384 : 141700 : Lists_InitList (&pSym->DefImp.DefIncludeList); /* Contains all included symbols */
9385 : : /* in the definition module only */
9386 : 141700 : SymbolKey_InitTree (&pSym->DefImp.ExportUndeclared); /* ExportUndeclared contains all */
9387 : : /* been declared. */
9388 : 141700 : SymbolKey_InitTree (&pSym->DefImp.NeedToBeImplemented);
9389 : : /* implemented. */
9390 : 141700 : SymbolKey_InitTree (&pSym->DefImp.LocalSymbols); /* The LocalSymbols hold all the */
9391 : : /* END WeAreHere. */
9392 : 141700 : Lists_InitList (&pSym->DefImp.EnumerationScopeList);
9393 : : /* visable within this scope. */
9394 : 141700 : SymbolKey_InitTree (&pSym->DefImp.NamedObjects); /* names of all items declared. */
9395 : 141700 : SymbolKey_InitTree (&pSym->DefImp.NamedImports); /* Names of items imported. */
9396 : 141700 : SymbolKey_InitTree (&pSym->DefImp.WhereImported); /* Sym to TokenNo where import */
9397 : : /* occurs. Error message use. */
9398 : 141700 : pSym->DefImp.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9399 : : /* is an index to a constant. */
9400 : 141700 : SymbolKey_InitTree (&pSym->DefImp.Unresolved); /* All symbols currently */
9401 : : /* unresolved in this module. */
9402 : 141700 : pSym->DefImp.StartQuad = 0; /* Signify the initialization */
9403 : : /* code. */
9404 : 141700 : pSym->DefImp.EndQuad = 0; /* EndQuad should point to a */
9405 : : /* goto quad. */
9406 : 141700 : pSym->DefImp.StartFinishQuad = 0; /* Signify the finalization */
9407 : : /* code. */
9408 : 141700 : pSym->DefImp.EndFinishQuad = 0; /* should point to a finish */
9409 : 141700 : pSym->DefImp.FinallyFunction = NULL; /* The GCC function for finally */
9410 : 141700 : pSym->DefImp.ExceptionFinally = false; /* does it have an exception? */
9411 : 141700 : pSym->DefImp.ExceptionBlock = false; /* does it have an exception? */
9412 : 141700 : pSym->DefImp.ContainsHiddenType = false; /* True if this module */
9413 : : /* implements a hidden type. */
9414 : 141700 : pSym->DefImp.ContainsBuiltin = false; /* Does module define a builtin */
9415 : : /* procedure? */
9416 : 141700 : pSym->DefImp.ForC = false; /* Is it a definition for "C" */
9417 : 141700 : pSym->DefImp.NeedExportList = false; /* Must user supply export list? */
9418 : 141700 : pSym->DefImp.DefLink = GetLink (); /* Is the def/mod file only */
9419 : 141700 : pSym->DefImp.ModLink = GetLink (); /* parsed for linkage? */
9420 : 141700 : pSym->DefImp.Builtin = false; /* Is the module builtin? */
9421 : 141700 : Lists_InitList (&pSym->DefImp.ListOfVars); /* List of variables in this */
9422 : : /* scope. */
9423 : 141700 : Lists_InitList (&pSym->DefImp.ListOfProcs); /* List of all procedures */
9424 : : /* declared within this module. */
9425 : 141700 : Lists_InitList (&pSym->DefImp.ListOfModules); /* List of all inner modules. */
9426 : 141700 : InitWhereDeclaredTok (tok, &pSym->DefImp.At); /* Where symbol declared. */
9427 : 141700 : InitWhereFirstUsedTok (tok, &pSym->DefImp.At); /* Where symbol first used. */
9428 : 141700 : pSym->DefImp.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9429 : 141700 : SymbolKey_PutSymKey (ModuleTree, DefImpName, Sym); /* Title error scope. */
9430 : 141700 : return Sym;
9431 : : /* static analysis guarentees a RETURN statement will be used before here. */
9432 : : __builtin_unreachable ();
9433 : : }
9434 : :
9435 : :
9436 : : /*
9437 : : MakeInnerModule - creates an inner module sym with ModuleName. It returns the
9438 : : symbol index.
9439 : : */
9440 : :
9441 : 420 : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName)
9442 : : {
9443 : 420 : SymbolTable_PtrToSymbol pSym;
9444 : 420 : unsigned int Sym;
9445 : :
9446 : 420 : Sym = DeclareSym (tok, ModuleName);
9447 : 420 : if (! (SymbolTable_IsError (Sym)))
9448 : : {
9449 : 420 : pSym = GetPsym (Sym);
9450 : 420 : pSym->SymbolType = SymbolTable_ModuleSym;
9451 : 420 : pSym->Module.name = ModuleName; /* Index into name array, name */
9452 : : /* of record field. */
9453 : 420 : pSym->Module.libname = NameKey_NulName; /* Library association. */
9454 : 420 : InitCtor (&pSym->Module.ctors); /* Init all ctor functions. */
9455 : 420 : SymbolKey_InitTree (&pSym->Module.LocalSymbols); /* The LocalSymbols hold all the */
9456 : : /* END WeAreHere. */
9457 : 420 : SymbolKey_InitTree (&pSym->Module.ExportTree); /* Holds all the exported */
9458 : : /* deleted at the end of Pass 1. */
9459 : 420 : SymbolKey_InitTree (&pSym->Module.ImportTree); /* Contains all IMPORTed */
9460 : : /* identifiers. */
9461 : 420 : Lists_InitList (&pSym->Module.IncludeList); /* Contains all included symbols */
9462 : : /* modulename.Symbol */
9463 : 420 : SymbolKey_InitTree (&pSym->Module.ExportUndeclared); /* ExportUndeclared contains all */
9464 : : /* been declared. */
9465 : 420 : Lists_InitList (&pSym->Module.EnumerationScopeList); /* Enumeration scope list which */
9466 : : /* visable within this scope. */
9467 : 420 : SymbolKey_InitTree (&pSym->Module.NamedObjects); /* Names of all items declared. */
9468 : 420 : SymbolKey_InitTree (&pSym->Module.NamedImports); /* Names of items imported. */
9469 : 420 : SymbolKey_InitTree (&pSym->Module.WhereImported); /* Sym to TokenNo where import */
9470 : : /* occurs. Error message use. */
9471 : 420 : pSym->Module.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9472 : : /* is an index to a constant. */
9473 : 420 : SymbolKey_InitTree (&pSym->Module.Unresolved); /* All symbols currently */
9474 : : /* unresolved in this module. */
9475 : 420 : pSym->Module.StartQuad = 0; /* Signify the initialization */
9476 : : /* code. */
9477 : 420 : pSym->Module.EndQuad = 0; /* EndQuad should point to a */
9478 : : /* goto quad. */
9479 : 420 : pSym->Module.StartFinishQuad = 0; /* Signify the finalization */
9480 : : /* code. */
9481 : 420 : pSym->Module.EndFinishQuad = 0; /* should point to a finish */
9482 : 420 : pSym->Module.FinallyFunction = NULL; /* The GCC function for finally */
9483 : 420 : pSym->Module.ExceptionFinally = false; /* does it have an exception? */
9484 : 420 : pSym->Module.ExceptionBlock = false; /* does it have an exception? */
9485 : 420 : pSym->Module.ModLink = GetLink (); /* Is this parsed for linkage? */
9486 : 420 : Lists_InitList (&pSym->Module.ListOfVars); /* List of variables in this */
9487 : : /* scope. */
9488 : 420 : Lists_InitList (&pSym->Module.ListOfProcs); /* List of all procedures */
9489 : : /* declared within this module. */
9490 : 420 : Lists_InitList (&pSym->Module.ListOfModules); /* List of all inner modules. */
9491 : 420 : InitWhereDeclaredTok (tok, &pSym->Module.At); /* Where symbol declared. */
9492 : 420 : InitWhereFirstUsedTok (tok, &pSym->Module.At); /* Where symbol first used. */
9493 : 420 : if ((SymbolTable_GetCurrentScope ()) == (SymbolTable_GetBaseModule ())) /* Where symbol first used. */
9494 : : {
9495 : 0 : pSym->Module.Scope = SymbolTable_NulSym;
9496 : : }
9497 : : else
9498 : : {
9499 : 420 : pSym->Module.Scope = SymbolTable_GetCurrentScope ();
9500 : 420 : AddModuleToParent (Sym, pSym->Module.Scope);
9501 : : }
9502 : 420 : pSym->Module.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9503 : 420 : AddSymToScope (Sym, ModuleName); /* Title error scope. */
9504 : : }
9505 : 420 : return Sym;
9506 : : /* static analysis guarentees a RETURN statement will be used before here. */
9507 : : __builtin_unreachable ();
9508 : : }
9509 : :
9510 : :
9511 : : /*
9512 : : MakeProcedure - creates a procedure sym with name. It returns
9513 : : the symbol index.
9514 : : */
9515 : :
9516 : 3451105 : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName)
9517 : : {
9518 : 3451105 : SymbolTable_PtrToSymbol pSym;
9519 : 3451105 : unsigned int Sym;
9520 : :
9521 : 3451105 : tok = CheckTok (tok, (const char *) "procedure", 9);
9522 : 3451105 : Sym = DeclareSym (tok, ProcedureName);
9523 : 3451105 : if (! (SymbolTable_IsError (Sym)))
9524 : : {
9525 : 3451105 : pSym = GetPsym (Sym);
9526 : 3451105 : pSym->SymbolType = SymbolTable_ProcedureSym;
9527 : 3451105 : pSym->Procedure.name = ProcedureName;
9528 : 3451105 : Lists_InitList (&pSym->Procedure.ListOfParam); /* Contains a list of all the */
9529 : : /* parameters in this procedure. */
9530 : 3451105 : pSym->Procedure.ParamDefined = false; /* Have the parameters been */
9531 : : /* defined yet? */
9532 : 3451105 : pSym->Procedure.DefinedInDef = false; /* Were the parameters defined */
9533 : : /* compared to the first. */
9534 : 3451105 : pSym->Procedure.DefinedInImp = false; /* Were the parameters defined */
9535 : : /* compared to the first. */
9536 : 3451105 : pSym->Procedure.HasVarArgs = false; /* Does the procedure use ... ? */
9537 : 3451105 : pSym->Procedure.HasOptArg = false; /* Does this procedure use [ ] ? */
9538 : 3451105 : pSym->Procedure.OptArgInit = SymbolTable_NulSym; /* The optarg initial value. */
9539 : 3451105 : pSym->Procedure.IsBuiltin = false; /* Was it declared __BUILTIN__ ? */
9540 : 3451105 : pSym->Procedure.BuiltinName = NameKey_NulName; /* name of equivalent builtin */
9541 : 3451105 : pSym->Procedure.IsInline = false; /* Was is declared __INLINE__ ? */
9542 : 3451105 : pSym->Procedure.IsNoReturn = false; /* Declared attribute noreturn ? */
9543 : 3451105 : pSym->Procedure.ReturnOptional = false; /* Is the return value optional? */
9544 : 3451105 : pSym->Procedure.IsExtern = false; /* Make this procedure external. */
9545 : 3451105 : pSym->Procedure.IsPublic = false; /* Make this procedure visible. */
9546 : 3451105 : pSym->Procedure.IsCtor = false; /* Is this procedure a ctor? */
9547 : 3451105 : pSym->Procedure.IsMonoName = false; /* Overrides module name prefix. */
9548 : 3451105 : pSym->Procedure.Scope = SymbolTable_GetCurrentScope (); /* Scope of procedure. */
9549 : 3451105 : SymbolKey_InitTree (&pSym->Procedure.Unresolved); /* All symbols currently */
9550 : : /* unresolved in this procedure. */
9551 : 3451105 : pSym->Procedure.ScopeQuad = 0; /* Index into list of quads, */
9552 : 3451105 : pSym->Procedure.StartQuad = 0; /* defining the scope, start and */
9553 : 3451105 : pSym->Procedure.EndQuad = 0; /* end of the procedure. */
9554 : 3451105 : pSym->Procedure.Reachable = false; /* Procedure not known to be */
9555 : : /* reachable. */
9556 : 3451105 : pSym->Procedure.SavePriority = false; /* Does procedure need to save */
9557 : : /* and restore interrupts? */
9558 : 3451105 : pSym->Procedure.ReturnType = SymbolTable_NulSym; /* Not a function yet! */
9559 : 3451105 : pSym->Procedure.Offset = 0; /* Location of procedure. */
9560 : 3451105 : SymbolKey_InitTree (&pSym->Procedure.LocalSymbols); /* Location of procedure. */
9561 : 3451105 : Lists_InitList (&pSym->Procedure.EnumerationScopeList);
9562 : : /* visable within this scope. */
9563 : 3451105 : SymbolKey_InitTree (&pSym->Procedure.NamedObjects); /* Names of all items declared. */
9564 : 3451105 : Lists_InitList (&pSym->Procedure.ListOfVars); /* List of variables in this */
9565 : : /* scope. */
9566 : 3451105 : Lists_InitList (&pSym->Procedure.ListOfProcs); /* List of all procedures */
9567 : : /* procedure. */
9568 : 3451105 : Lists_InitList (&pSym->Procedure.ListOfModules); /* List of all inner modules. */
9569 : 3451105 : pSym->Procedure.ExceptionFinally = false; /* does it have an exception? */
9570 : 3451105 : pSym->Procedure.ExceptionBlock = false; /* does it have an exception? */
9571 : 3451105 : pSym->Procedure.Size = M2ALU_InitValue (); /* Activation record size. */
9572 : 3451105 : pSym->Procedure.TotalParamSize = M2ALU_InitValue (); /* size of all parameters. */
9573 : 3451105 : pSym->Procedure.Begin = 0; /* token number for BEGIN */
9574 : 3451105 : pSym->Procedure.End = 0; /* token number for END */
9575 : 3451105 : InitWhereDeclaredTok (tok, &pSym->Procedure.At); /* Where symbol declared. */
9576 : 3451105 : pSym->Procedure.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9577 : : /* Now add this procedure to the symbol table of the current scope */
9578 : 3451105 : AddSymToScope (Sym, ProcedureName);
9579 : 3451105 : AddProcedureToList (SymbolTable_GetCurrentScope (), Sym);
9580 : : }
9581 : 3451105 : return Sym;
9582 : : /* static analysis guarentees a RETURN statement will be used before here. */
9583 : : __builtin_unreachable ();
9584 : : }
9585 : :
9586 : :
9587 : : /*
9588 : : MakeProcedureCtorExtern - creates an extern ctor procedure
9589 : : */
9590 : :
9591 : 0 : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename)
9592 : : {
9593 : 0 : unsigned int ctor;
9594 : :
9595 : 0 : ctor = SymbolTable_MakeProcedure (tokenno, GenName (libname, (const char *) "_M2_", 4, modulename, (const char *) "_ctor", 5));
9596 : 0 : SymbolTable_PutExtern (ctor, true);
9597 : 0 : return ctor;
9598 : : /* static analysis guarentees a RETURN statement will be used before here. */
9599 : : __builtin_unreachable ();
9600 : : }
9601 : :
9602 : :
9603 : : /*
9604 : : PutLibName - places libname into defimp or module sym.
9605 : : */
9606 : :
9607 : 188961 : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname)
9608 : : {
9609 : 188961 : SymbolTable_PtrToSymbol pSym;
9610 : :
9611 : 377922 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
9612 : 188961 : pSym = GetPsym (sym);
9613 : 188961 : switch (pSym->SymbolType)
9614 : : {
9615 : 178535 : case SymbolTable_DefImpSym:
9616 : 178535 : pSym->DefImp.libname = libname;
9617 : 178535 : break;
9618 : :
9619 : 10426 : case SymbolTable_ModuleSym:
9620 : 10426 : pSym->Module.libname = libname;
9621 : 10426 : break;
9622 : :
9623 : :
9624 : 0 : default:
9625 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
9626 : 188961 : break;
9627 : : }
9628 : 188961 : }
9629 : :
9630 : :
9631 : : /*
9632 : : GetLibName - returns libname associated with a defimp or module sym.
9633 : : */
9634 : :
9635 : 3643574 : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym)
9636 : : {
9637 : 3643574 : SymbolTable_PtrToSymbol pSym;
9638 : :
9639 : 7287148 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
9640 : 3643574 : pSym = GetPsym (sym);
9641 : 3643574 : switch (pSym->SymbolType)
9642 : : {
9643 : 3560626 : case SymbolTable_DefImpSym:
9644 : 3560626 : return pSym->DefImp.libname;
9645 : 82948 : break;
9646 : :
9647 : 82948 : case SymbolTable_ModuleSym:
9648 : 82948 : return pSym->Module.libname;
9649 : 0 : break;
9650 : :
9651 : :
9652 : 0 : default:
9653 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
9654 : : break;
9655 : : }
9656 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9657 : : __builtin_unreachable ();
9658 : : }
9659 : :
9660 : :
9661 : : /*
9662 : : PutMonoName - changes the IsMonoName boolean inside the procedure.
9663 : : */
9664 : :
9665 : 347480 : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value)
9666 : : {
9667 : 347480 : SymbolTable_PtrToSymbol pSym;
9668 : :
9669 : 347480 : pSym = GetPsym (sym);
9670 : 347480 : switch (pSym->SymbolType)
9671 : : {
9672 : 347480 : case SymbolTable_ProcedureSym:
9673 : 347480 : pSym->Procedure.IsMonoName = value;
9674 : 347480 : break;
9675 : :
9676 : :
9677 : 0 : default:
9678 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
9679 : 347480 : break;
9680 : : }
9681 : 347480 : }
9682 : :
9683 : :
9684 : : /*
9685 : : IsMonoName - returns the public boolean associated with a procedure.
9686 : : */
9687 : :
9688 : 2271568 : extern "C" bool SymbolTable_IsMonoName (unsigned int sym)
9689 : : {
9690 : 2271568 : SymbolTable_PtrToSymbol pSym;
9691 : :
9692 : 2271568 : pSym = GetPsym (sym);
9693 : 2271568 : switch (pSym->SymbolType)
9694 : : {
9695 : 2271568 : case SymbolTable_ProcedureSym:
9696 : 2271568 : return pSym->Procedure.IsMonoName;
9697 : 0 : break;
9698 : :
9699 : :
9700 : 0 : default:
9701 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
9702 : : break;
9703 : : }
9704 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9705 : : __builtin_unreachable ();
9706 : : }
9707 : :
9708 : :
9709 : : /*
9710 : : PutExtern - changes the extern boolean inside the procedure.
9711 : : */
9712 : :
9713 : 493402 : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value)
9714 : : {
9715 : 493402 : SymbolTable_PtrToSymbol pSym;
9716 : :
9717 : 493402 : pSym = GetPsym (sym);
9718 : 493402 : switch (pSym->SymbolType)
9719 : : {
9720 : 493402 : case SymbolTable_ProcedureSym:
9721 : 493402 : pSym->Procedure.IsExtern = value;
9722 : 493402 : break;
9723 : :
9724 : :
9725 : 0 : default:
9726 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
9727 : 493402 : break;
9728 : : }
9729 : 493402 : }
9730 : :
9731 : :
9732 : : /*
9733 : : IsExtern - returns the public boolean associated with a procedure.
9734 : : */
9735 : :
9736 : 3346873 : extern "C" bool SymbolTable_IsExtern (unsigned int sym)
9737 : : {
9738 : 3346873 : SymbolTable_PtrToSymbol pSym;
9739 : :
9740 : 3346873 : pSym = GetPsym (sym);
9741 : 3346873 : switch (pSym->SymbolType)
9742 : : {
9743 : 3346873 : case SymbolTable_ProcedureSym:
9744 : 3346873 : return pSym->Procedure.IsExtern;
9745 : 0 : break;
9746 : :
9747 : :
9748 : 0 : default:
9749 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
9750 : : break;
9751 : : }
9752 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9753 : : __builtin_unreachable ();
9754 : : }
9755 : :
9756 : :
9757 : : /*
9758 : : PutPublic - changes the public boolean inside the procedure.
9759 : : */
9760 : :
9761 : 510052 : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value)
9762 : : {
9763 : 510052 : SymbolTable_PtrToSymbol pSym;
9764 : :
9765 : 510052 : pSym = GetPsym (sym);
9766 : 510052 : switch (pSym->SymbolType)
9767 : : {
9768 : 510052 : case SymbolTable_ProcedureSym:
9769 : 510052 : pSym->Procedure.IsPublic = value;
9770 : 510052 : break;
9771 : :
9772 : :
9773 : 0 : default:
9774 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
9775 : 510052 : break;
9776 : : }
9777 : 510052 : }
9778 : :
9779 : :
9780 : : /*
9781 : : IsPublic - returns the public boolean associated with a procedure.
9782 : : */
9783 : :
9784 : 111445 : extern "C" bool SymbolTable_IsPublic (unsigned int sym)
9785 : : {
9786 : 111445 : SymbolTable_PtrToSymbol pSym;
9787 : :
9788 : 111445 : pSym = GetPsym (sym);
9789 : 111445 : switch (pSym->SymbolType)
9790 : : {
9791 : 111445 : case SymbolTable_ProcedureSym:
9792 : 111445 : return pSym->Procedure.IsPublic;
9793 : 0 : break;
9794 : :
9795 : :
9796 : 0 : default:
9797 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
9798 : : break;
9799 : : }
9800 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9801 : : __builtin_unreachable ();
9802 : : }
9803 : :
9804 : :
9805 : : /*
9806 : : PutCtor - changes the ctor boolean inside the procedure.
9807 : : */
9808 : :
9809 : 138752 : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value)
9810 : : {
9811 : 138752 : SymbolTable_PtrToSymbol pSym;
9812 : :
9813 : 138752 : pSym = GetPsym (sym);
9814 : 138752 : switch (pSym->SymbolType)
9815 : : {
9816 : 138752 : case SymbolTable_ProcedureSym:
9817 : 138752 : pSym->Procedure.IsCtor = value;
9818 : 138752 : break;
9819 : :
9820 : :
9821 : 0 : default:
9822 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
9823 : 138752 : break;
9824 : : }
9825 : 138752 : }
9826 : :
9827 : :
9828 : : /*
9829 : : IsCtor - returns the ctor boolean associated with a procedure.
9830 : : */
9831 : :
9832 : 154958 : extern "C" bool SymbolTable_IsCtor (unsigned int sym)
9833 : : {
9834 : 154958 : SymbolTable_PtrToSymbol pSym;
9835 : :
9836 : 154958 : pSym = GetPsym (sym);
9837 : 154958 : switch (pSym->SymbolType)
9838 : : {
9839 : 154958 : case SymbolTable_ProcedureSym:
9840 : 154958 : return pSym->Procedure.IsCtor;
9841 : 0 : break;
9842 : :
9843 : :
9844 : 0 : default:
9845 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
9846 : : break;
9847 : : }
9848 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9849 : : __builtin_unreachable ();
9850 : : }
9851 : :
9852 : :
9853 : : /*
9854 : : GetModuleCtors - mod can be a DefImp or Module symbol. ctor, init and fini
9855 : : are assigned for this module. An inner module ctor value will
9856 : : be NulSym.
9857 : : */
9858 : :
9859 : 152774 : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep)
9860 : : {
9861 : 152774 : SymbolTable_PtrToSymbol pSym;
9862 : :
9863 : 152774 : pSym = GetPsym (mod);
9864 : 152774 : switch (pSym->SymbolType)
9865 : : {
9866 : 75810 : case SymbolTable_ModuleSym:
9867 : 75810 : (*ctor) = pSym->Module.ctors.ctor;
9868 : 75810 : (*init) = pSym->Module.ctors.init;
9869 : 75810 : (*fini) = pSym->Module.ctors.fini;
9870 : 75810 : (*dep) = pSym->Module.ctors.dep;
9871 : 75810 : break;
9872 : :
9873 : 76964 : case SymbolTable_DefImpSym:
9874 : 76964 : (*ctor) = pSym->DefImp.ctors.ctor;
9875 : 76964 : (*init) = pSym->DefImp.ctors.init;
9876 : 76964 : (*fini) = pSym->DefImp.ctors.fini;
9877 : 76964 : (*dep) = pSym->DefImp.ctors.dep;
9878 : 76964 : break;
9879 : :
9880 : :
9881 : 0 : default:
9882 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
9883 : 152774 : break;
9884 : : }
9885 : 152774 : }
9886 : :
9887 : :
9888 : : /*
9889 : : MakeModuleCtor - for a defimp or module symbol create all the ctor
9890 : : related procedures.
9891 : : */
9892 : :
9893 : 63568 : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym)
9894 : : {
9895 : 63568 : SymbolTable_PtrToSymbol pSym;
9896 : :
9897 : 127136 : M2Debug_Assert ((SymbolTable_IsDefImp (moduleSym)) || (SymbolTable_IsModule (moduleSym)));
9898 : 63568 : pSym = GetPsym (moduleSym);
9899 : 63568 : if (SymbolTable_IsDefImp (moduleSym))
9900 : : {
9901 : 52770 : InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->DefImp.ctors, SymbolTable_GetSymName (moduleSym), false, true);
9902 : : }
9903 : : else
9904 : : {
9905 : 10798 : InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->Module.ctors, SymbolTable_GetSymName (moduleSym), SymbolTable_IsInnerModule (moduleSym), true);
9906 : : }
9907 : 63568 : }
9908 : :
9909 : :
9910 : : /*
9911 : : PutModuleCtorExtern - for every ctor related procedure in module sym.
9912 : : Make it external. It will create any missing
9913 : : init/fini procedures but not any missing dep/ctor
9914 : : procedures.
9915 : : */
9916 : :
9917 : 75838 : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external)
9918 : : {
9919 : 75838 : SymbolTable_PtrToSymbol pSym;
9920 : :
9921 : 151676 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
9922 : 75838 : pSym = GetPsym (sym);
9923 : 75838 : switch (pSym->SymbolType)
9924 : : {
9925 : 75838 : case SymbolTable_DefImpSym:
9926 : 75838 : PutCtorExtern (tok, sym, &pSym->DefImp.ctors, external);
9927 : 75838 : break;
9928 : :
9929 : 0 : case SymbolTable_ModuleSym:
9930 : 0 : PutCtorExtern (tok, sym, &pSym->Module.ctors, external);
9931 : 0 : break;
9932 : :
9933 : :
9934 : 0 : default:
9935 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
9936 : 75838 : break;
9937 : : }
9938 : 75838 : }
9939 : :
9940 : :
9941 : : /*
9942 : : PutVarHeap - assigns ArrayRef field with value.
9943 : : */
9944 : :
9945 : 25904 : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value)
9946 : : {
9947 : 25904 : SymbolTable_PtrToSymbol pSym;
9948 : :
9949 : 25904 : pSym = GetPsym (sym);
9950 : 25904 : switch (pSym->SymbolType)
9951 : : {
9952 : 25904 : case SymbolTable_VarSym:
9953 : 25904 : pSym->Var.Heap = value;
9954 : 25904 : break;
9955 : :
9956 : :
9957 : 0 : default:
9958 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
9959 : 25904 : break;
9960 : : }
9961 : 25904 : }
9962 : :
9963 : :
9964 : : /*
9965 : : IsVarHeap - returns ArrayRef field value.
9966 : : */
9967 : :
9968 : 610198 : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym)
9969 : : {
9970 : 610198 : SymbolTable_PtrToSymbol pSym;
9971 : :
9972 : 610198 : pSym = GetPsym (sym);
9973 : 610198 : switch (pSym->SymbolType)
9974 : : {
9975 : 610198 : case SymbolTable_VarSym:
9976 : 610198 : return pSym->Var.Heap;
9977 : 0 : break;
9978 : :
9979 : :
9980 : 0 : default:
9981 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
9982 : : break;
9983 : : }
9984 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9985 : : __builtin_unreachable ();
9986 : : }
9987 : :
9988 : :
9989 : : /*
9990 : : MakeVar - creates a variable sym with VarName. It returns the
9991 : : symbol index.
9992 : : */
9993 : :
9994 : 7719785 : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName)
9995 : : {
9996 : 7719785 : SymbolTable_PtrToSymbol pSym;
9997 : 7719785 : unsigned int Sym;
9998 : :
9999 : 7719785 : Sym = DeclareSym (tok, VarName);
10000 : 7719785 : if (! (SymbolTable_IsError (Sym)))
10001 : : {
10002 : 7719779 : pSym = GetPsym (Sym);
10003 : 7719779 : pSym->SymbolType = SymbolTable_VarSym;
10004 : 7719779 : pSym->Var.name = VarName;
10005 : 7719779 : pSym->Var.Type = SymbolTable_NulSym;
10006 : 7719779 : pSym->Var.BackType = SymbolTable_NulSym;
10007 : 7719779 : pSym->Var.Size = M2ALU_InitValue ();
10008 : 7719779 : pSym->Var.Offset = M2ALU_InitValue ();
10009 : 7719779 : pSym->Var.AddrMode = SymbolTable_RightValue;
10010 : 7719779 : pSym->Var.Scope = SymbolTable_GetCurrentScope (); /* Procedure or Module? */
10011 : 7719779 : pSym->Var.AtAddress = false; /* Procedure or Module? */
10012 : 7719779 : pSym->Var.Address = SymbolTable_NulSym; /* Address at which declared. */
10013 : 7719779 : pSym->Var.IsTemp = false; /* Address at which declared. */
10014 : 7719779 : pSym->Var.IsComponentRef = false;
10015 : 7719779 : pSym->Var.IsParam = false;
10016 : 7719779 : pSym->Var.IsPointerCheck = false;
10017 : 7719779 : pSym->Var.IsWritten = false;
10018 : 7719779 : pSym->Var.IsSSA = false;
10019 : 7719779 : pSym->Var.IsConst = false;
10020 : 7719779 : pSym->Var.ArrayRef = false;
10021 : 7719779 : pSym->Var.Heap = false;
10022 : 7719779 : InitWhereDeclaredTok (tok, &pSym->Var.At);
10023 : 7719779 : InitWhereFirstUsedTok (tok, &pSym->Var.At); /* Where symbol first used. */
10024 : 7719779 : Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]); /* Where symbol first used. */
10025 : 7719779 : Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]);
10026 : 7719779 : Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
10027 : 7719779 : Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
10028 : 7719779 : pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
10029 : 7719779 : pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
10030 : : /* Add Var to Procedure or Module variable list. */
10031 : 7719779 : AddVarToList (Sym);
10032 : : /* Now add this Var to the symbol table of the current scope. */
10033 : 7719779 : AddSymToScope (Sym, VarName);
10034 : : }
10035 : 7719785 : return Sym;
10036 : : /* static analysis guarentees a RETURN statement will be used before here. */
10037 : : __builtin_unreachable ();
10038 : : }
10039 : :
10040 : :
10041 : : /*
10042 : : MakeRecord - makes a Record symbol with name RecordName.
10043 : : */
10044 : :
10045 : 47714 : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName)
10046 : : {
10047 : 47714 : unsigned int oaf;
10048 : 47714 : unsigned int sym;
10049 : :
10050 : 47714 : tok = CheckTok (tok, (const char *) "record", 6);
10051 : 47714 : sym = HandleHiddenOrDeclare (tok, RecordName, &oaf);
10052 : 47714 : FillInRecordFields (tok, sym, RecordName, SymbolTable_GetCurrentScope (), oaf);
10053 : 47714 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10054 : 47714 : return sym;
10055 : : /* static analysis guarentees a RETURN statement will be used before here. */
10056 : : __builtin_unreachable ();
10057 : : }
10058 : :
10059 : :
10060 : : /*
10061 : : MakeVarient - creates a new symbol, a varient symbol for record or varient field
10062 : : symbol, RecOrVarFieldSym.
10063 : : */
10064 : :
10065 : 276 : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym)
10066 : : {
10067 : 276 : SymbolTable_PtrToSymbol pSym;
10068 : 276 : unsigned int Sym;
10069 : :
10070 : 276 : tok = CheckTok (tok, (const char *) "varient", 7);
10071 : 276 : NewSym (&Sym);
10072 : 276 : pSym = GetPsym (Sym);
10073 : 276 : pSym->SymbolType = SymbolTable_VarientSym;
10074 : 276 : pSym->Varient.Size = M2ALU_InitValue ();
10075 : 276 : pSym->Varient.Parent = RecOrVarFieldSym; /* GetRecord(RecOrVarFieldSym) ; */
10076 : 276 : if (SymbolTable_IsRecord (RecOrVarFieldSym)) /* GetRecord(RecOrVarFieldSym) ; */
10077 : : {
10078 : 240 : pSym->Varient.Varient = SymbolTable_NulSym;
10079 : : }
10080 : : else
10081 : : {
10082 : 36 : pSym->Varient.Varient = RecOrVarFieldSym;
10083 : : }
10084 : 276 : pSym->Varient.tag = SymbolTable_NulSym;
10085 : 276 : pSym->Varient.DeclPacked = false;
10086 : 276 : pSym->Varient.Scope = SymbolTable_GetCurrentScope ();
10087 : 276 : Lists_InitList (&pSym->Varient.ListOfSons);
10088 : 276 : InitWhereDeclaredTok (tok, &pSym->Varient.At);
10089 : : /* Now add Sym to the record RecSym field list */
10090 : 276 : pSym = GetPsym (RecOrVarFieldSym);
10091 : 276 : switch (pSym->SymbolType)
10092 : : {
10093 : 240 : case SymbolTable_RecordSym:
10094 : 240 : Lists_PutItemIntoList (pSym->Record.ListOfSons, Sym);
10095 : 240 : break;
10096 : :
10097 : 36 : case SymbolTable_VarientFieldSym:
10098 : 36 : Lists_PutItemIntoList (pSym->VarientField.ListOfSons, Sym);
10099 : 36 : break;
10100 : :
10101 : :
10102 : 0 : default:
10103 : 0 : M2Error_InternalError ((const char *) "expecting Record or VarientField symbol", 39);
10104 : 276 : break;
10105 : : }
10106 : 276 : return Sym;
10107 : : /* static analysis guarentees a RETURN statement will be used before here. */
10108 : : __builtin_unreachable ();
10109 : : }
10110 : :
10111 : :
10112 : : /*
10113 : : MakeFieldVarient - returns a FieldVarient symbol which has been
10114 : : assigned to the Varient symbol, Sym.
10115 : : */
10116 : :
10117 : 666 : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym)
10118 : : {
10119 : 666 : SymbolTable_PtrToSymbol pSym;
10120 : 666 : unsigned int SonSym;
10121 : :
10122 : 666 : NewSym (&SonSym);
10123 : : /* Fill in Sym */
10124 : 666 : pSym = GetPsym (SonSym);
10125 : 666 : pSym->SymbolType = SymbolTable_VarientFieldSym;
10126 : 666 : pSym->VarientField.name = n;
10127 : 666 : Lists_InitList (&pSym->VarientField.ListOfSons);
10128 : 666 : pSym->VarientField.Parent = SymbolTable_GetRecord (Sym);
10129 : 666 : pSym->VarientField.Varient = SymbolTable_NulSym;
10130 : 666 : pSym->VarientField.Size = M2ALU_InitValue ();
10131 : 666 : pSym->VarientField.Offset = M2ALU_InitValue ();
10132 : 666 : pSym->VarientField.DeclPacked = false;
10133 : 666 : pSym->VarientField.DeclResolved = false;
10134 : 666 : pSym->VarientField.Scope = SymbolTable_GetCurrentScope ();
10135 : 666 : InitWhereDeclared (&pSym->VarientField.At);
10136 : 666 : return SonSym;
10137 : : /* static analysis guarentees a RETURN statement will be used before here. */
10138 : : __builtin_unreachable ();
10139 : : }
10140 : :
10141 : :
10142 : : /*
10143 : : MakeEnumeration - places a new symbol in the current scope, the symbol
10144 : : is an enumeration symbol. The symbol index is returned.
10145 : : */
10146 : :
10147 : 38776 : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName)
10148 : : {
10149 : 38776 : SymbolTable_PtrToSymbol pSym;
10150 : 38776 : unsigned int sym;
10151 : 38776 : unsigned int oaf;
10152 : :
10153 : 38776 : tok = CheckTok (tok, (const char *) "enumeration", 11);
10154 : 38776 : sym = CheckForHiddenType (EnumerationName);
10155 : 38776 : if (sym == SymbolTable_NulSym)
10156 : : {
10157 : : /* avoid dangling else. */
10158 : 38776 : sym = DeclareSym (tok, EnumerationName);
10159 : 38776 : oaf = SymbolTable_GetOAFamily (sym);
10160 : 38776 : if (! (SymbolTable_IsError (sym)))
10161 : : {
10162 : 38776 : pSym = GetPsym (sym);
10163 : 38776 : pSym->SymbolType = SymbolTable_EnumerationSym; /* To satisfy AddSymToScope */
10164 : : /* Now add this type to the symbol table of the current scope */
10165 : 38776 : AddSymToScope (sym, EnumerationName);
10166 : : }
10167 : : }
10168 : : else
10169 : : {
10170 : 0 : oaf = SymbolTable_GetOAFamily (sym);
10171 : : }
10172 : 38776 : if (! (SymbolTable_IsError (sym)))
10173 : : {
10174 : 38776 : pSym = GetPsym (sym);
10175 : 38776 : pSym->SymbolType = SymbolTable_EnumerationSym;
10176 : 38776 : pSym->Enumeration.name = EnumerationName; /* Name of enumeration. */
10177 : 38776 : pSym->Enumeration.NoOfElements = 0; /* No of elements in the */
10178 : : /* enumeration type. */
10179 : 38776 : pSym->Enumeration.Size = M2ALU_InitValue (); /* Size at runtime of sym */
10180 : 38776 : SymbolKey_InitTree (&pSym->Enumeration.LocalSymbols); /* Enumeration fields. */
10181 : 38776 : Lists_InitList (&pSym->Enumeration.ListOfFields); /* Ordered as declared. */
10182 : 38776 : InitPacked (&pSym->Enumeration.packedInfo); /* not packed and no */
10183 : : /* equivalent (yet). */
10184 : 38776 : pSym->Enumeration.oafamily = oaf; /* The open array family */
10185 : 38776 : pSym->Enumeration.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10186 : 38776 : InitWhereDeclaredTok (tok, &pSym->Enumeration.At); /* Declared here */
10187 : 38776 : CheckIfEnumerationExported (sym, ScopePtr);
10188 : : }
10189 : 38776 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10190 : 38776 : return sym;
10191 : : /* static analysis guarentees a RETURN statement will be used before here. */
10192 : : __builtin_unreachable ();
10193 : : }
10194 : :
10195 : :
10196 : : /*
10197 : : MakeType - makes a type symbol with name TypeName.
10198 : : */
10199 : :
10200 : 654257 : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName)
10201 : : {
10202 : 654257 : SymbolTable_PtrToSymbol pSym;
10203 : 654257 : unsigned int sym;
10204 : 654257 : unsigned int oaf;
10205 : :
10206 : 654257 : sym = HandleHiddenOrDeclare (tok, TypeName, &oaf);
10207 : 654257 : if (! (SymbolTable_IsError (sym)))
10208 : : {
10209 : 654251 : pSym = GetPsym (sym);
10210 : 654251 : pSym->SymbolType = SymbolTable_TypeSym;
10211 : 654251 : pSym->Type.name = TypeName; /* Index into name array, name */
10212 : : /* of type. */
10213 : 654251 : pSym->Type.Type = SymbolTable_NulSym; /* Index to a type symbol. */
10214 : 654251 : pSym->Type.IsHidden = false; /* Was it declared as hidden? */
10215 : 654251 : SymbolKey_InitTree (&pSym->Type.ConstLitTree); /* constants of this type. */
10216 : 654251 : pSym->Type.Size = M2ALU_InitValue (); /* Runtime size of symbol. */
10217 : 654251 : pSym->Type.Align = SymbolTable_NulSym; /* Alignment of this type. */
10218 : 654251 : InitPacked (&pSym->Type.packedInfo); /* not packed and no */
10219 : : /* equivalent yet. */
10220 : 654251 : pSym->Type.oafamily = oaf; /* The open array family. */
10221 : 654251 : pSym->Type.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10222 : 654251 : InitWhereDeclaredTok (tok, &pSym->Type.At); /* Declared here */
10223 : : }
10224 : 654257 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10225 : 654257 : return sym;
10226 : : /* static analysis guarentees a RETURN statement will be used before here. */
10227 : : __builtin_unreachable ();
10228 : : }
10229 : :
10230 : :
10231 : : /*
10232 : : MakeHiddenType - makes a type symbol that is hidden from the
10233 : : definition module.
10234 : : This symbol is placed into the UnImplemented list of
10235 : : the definition/implementation module.
10236 : : The type will be filled in when the implementation module
10237 : : is reached.
10238 : : */
10239 : :
10240 : 24970 : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName)
10241 : : {
10242 : 24970 : SymbolTable_PtrToSymbol pSym;
10243 : 24970 : unsigned int Sym;
10244 : :
10245 : 24970 : tok = CheckTok (tok, (const char *) "hidden", 6);
10246 : 24970 : Sym = DeclareSym (tok, TypeName);
10247 : 24970 : if (! (SymbolTable_IsError (Sym)))
10248 : : {
10249 : 24970 : pSym = GetPsym (Sym);
10250 : 24970 : pSym->SymbolType = SymbolTable_TypeSym;
10251 : 24970 : pSym->Type.name = TypeName; /* Index into name array, name */
10252 : : /* of type. */
10253 : 24970 : pSym->Type.IsHidden = (SymbolTable_GetMainModule ()) != (SymbolTable_GetCurrentScope ());
10254 : 24970 : if (M2Options_ExtendedOpaque || ! pSym->Type.IsHidden)
10255 : : {
10256 : 1484 : pSym->Type.Type = SymbolTable_NulSym; /* will be filled in later */
10257 : : }
10258 : : else
10259 : : {
10260 : 23486 : pSym->Type.Type = M2System_Address;
10261 : : }
10262 : 24970 : pSym->Type.Align = SymbolTable_NulSym; /* Alignment of this type. */
10263 : 24970 : pSym->Type.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10264 : 24970 : pSym->Type.oafamily = SymbolTable_NulSym; /* Which scope created it */
10265 : 24970 : if (! M2Options_ExtendedOpaque)
10266 : : {
10267 : 23602 : Lists_IncludeItemIntoList (AddressTypes, Sym);
10268 : : }
10269 : 24970 : pSym->Type.Size = M2ALU_InitValue (); /* Runtime size of symbol. */
10270 : 24970 : InitWhereDeclaredTok (tok, &pSym->Type.At); /* Declared here */
10271 : 24970 : SymbolTable_PutExportUnImplemented (tok, Sym);
10272 : 24970 : if (M2Options_ExtendedOpaque || ((SymbolTable_GetMainModule ()) == (SymbolTable_GetCurrentScope ())))
10273 : : {
10274 : 1484 : SymbolTable_PutHiddenTypeDeclared ();
10275 : : }
10276 : : /* Now add this type to the symbol table of the current scope */
10277 : 24970 : AddSymToScope (Sym, TypeName);
10278 : : }
10279 : 24970 : return Sym;
10280 : : /* static analysis guarentees a RETURN statement will be used before here. */
10281 : : __builtin_unreachable ();
10282 : : }
10283 : :
10284 : :
10285 : : /*
10286 : : MakeConstant - create a constant cardinal and return the symbol.
10287 : : */
10288 : :
10289 : 28128 : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value)
10290 : : {
10291 : 28128 : DynamicStrings_String str;
10292 : 28128 : unsigned int sym;
10293 : :
10294 : 28128 : tok = CheckTok (tok, (const char *) "constant", 8);
10295 : 28128 : str = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%d", 2)), (const unsigned char *) &value, (sizeof (value)-1));
10296 : 28128 : sym = SymbolTable_MakeConstLit (tok, NameKey_makekey (DynamicStrings_string (str)), M2Base_Cardinal);
10297 : 28128 : str = DynamicStrings_KillString (str);
10298 : 28128 : return sym;
10299 : : /* static analysis guarentees a RETURN statement will be used before here. */
10300 : : __builtin_unreachable ();
10301 : : }
10302 : :
10303 : :
10304 : : /*
10305 : : MakeConstLit - returns a constant literal of type, constType, with a constName,
10306 : : at location, tok.
10307 : : */
10308 : :
10309 : 1098455 : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
10310 : : {
10311 : 1098455 : unsigned int sym;
10312 : :
10313 : 1098455 : tok = CheckTok (tok, (const char *) "constlit", 8);
10314 : 1098455 : sym = LookupConstLitPoolEntry (tok, constName, constType);
10315 : 1098455 : if (sym == SymbolTable_NulSym)
10316 : : {
10317 : 546807 : sym = CreateConstLit (tok, constName, constType);
10318 : 546807 : AddConstLitPoolEntry (sym, tok, constName, constType);
10319 : : }
10320 : 1098455 : return sym;
10321 : : /* static analysis guarentees a RETURN statement will be used before here. */
10322 : : __builtin_unreachable ();
10323 : : }
10324 : :
10325 : :
10326 : : /*
10327 : : MakeConstVar - makes a ConstVar type with
10328 : : name ConstVarName.
10329 : : */
10330 : :
10331 : 1121806 : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName)
10332 : : {
10333 : 1121806 : SymbolTable_PtrToSymbol pSym;
10334 : 1121806 : unsigned int Sym;
10335 : 1121806 : bool temp;
10336 : :
10337 : 1121806 : temp = ConstVarName == NameKey_NulName;
10338 : 1121806 : ConstVarName = SymbolTable_CheckAnonymous (ConstVarName);
10339 : 1121806 : Sym = DeclareSym (tok, ConstVarName);
10340 : 1121806 : if (! (SymbolTable_IsError (Sym)))
10341 : : {
10342 : 1121800 : pSym = GetPsym (Sym);
10343 : 1121800 : pSym->SymbolType = SymbolTable_ConstVarSym;
10344 : 1121800 : pSym->ConstVar.name = ConstVarName;
10345 : 1121800 : pSym->ConstVar.Value = M2ALU_InitValue ();
10346 : 1121800 : pSym->ConstVar.Type = SymbolTable_NulSym;
10347 : 1121800 : pSym->ConstVar.IsSet = false;
10348 : 1121800 : pSym->ConstVar.IsConstructor = false;
10349 : 1121800 : pSym->ConstVar.FromType = SymbolTable_NulSym; /* type is determined FromType */
10350 : 1121800 : pSym->ConstVar.UnresFromType = false; /* is Type resolved? */
10351 : 1121800 : pSym->ConstVar.IsTemp = temp; /* is Type resolved? */
10352 : 1121800 : pSym->ConstVar.Scope = SymbolTable_GetCurrentScope ();
10353 : 1121800 : InitWhereDeclaredTok (tok, &pSym->ConstVar.At);
10354 : : /* Now add this constant to the symbol table of the current scope */
10355 : 1121800 : AddSymToScope (Sym, ConstVarName);
10356 : : }
10357 : 1121806 : return Sym;
10358 : : /* static analysis guarentees a RETURN statement will be used before here. */
10359 : : __builtin_unreachable ();
10360 : : }
10361 : :
10362 : :
10363 : : /*
10364 : : MakeConstString - create a string constant in the symboltable.
10365 : : */
10366 : :
10367 : 273386 : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName)
10368 : : {
10369 : 273386 : unsigned int newstr;
10370 : :
10371 : 273386 : NewSym (&newstr);
10372 : 273386 : InitConstString (tok, newstr, ConstName, ConstName, SymbolTable_m2nulstr, false, true);
10373 : 273386 : return newstr;
10374 : : /* static analysis guarentees a RETURN statement will be used before here. */
10375 : : __builtin_unreachable ();
10376 : : }
10377 : :
10378 : :
10379 : : /*
10380 : : MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
10381 : : If known is TRUE then name is assigned to the contents
10382 : : and the escape sequences will be converted into characters.
10383 : : */
10384 : :
10385 : 7357 : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known)
10386 : : {
10387 : 7357 : unsigned int newstr;
10388 : :
10389 : 7357 : tok = CheckTok (tok, (const char *) "conststringcnul", 15);
10390 : 7357 : NewSym (&newstr);
10391 : 7357 : InitConstString (tok, newstr, name, name, SymbolTable_cnulstr, true, known);
10392 : 7357 : return newstr;
10393 : : /* static analysis guarentees a RETURN statement will be used before here. */
10394 : : __builtin_unreachable ();
10395 : : }
10396 : :
10397 : :
10398 : : /*
10399 : : MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
10400 : : If known is TRUE then name is assigned to the contents
10401 : : however the escape sequences are not converted into characters.
10402 : : */
10403 : :
10404 : 34470 : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known)
10405 : : {
10406 : 34470 : unsigned int newstr;
10407 : :
10408 : 34470 : NewSym (&newstr);
10409 : 34470 : InitConstString (tok, newstr, name, name, SymbolTable_m2nulstr, false, known);
10410 : 34470 : return newstr;
10411 : : /* static analysis guarentees a RETURN statement will be used before here. */
10412 : : __builtin_unreachable ();
10413 : : }
10414 : :
10415 : :
10416 : : /*
10417 : : PutConstStringKnown - if sym is a constvar then convert it into a conststring.
10418 : : If known is FALSE then contents is ignored and NulName is
10419 : : stored. If escape is TRUE then the contents will have
10420 : : any escape sequences converted into single characters.
10421 : : */
10422 : :
10423 : 372208 : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known)
10424 : : {
10425 : 372208 : SymbolTable_PtrToSymbol pSym;
10426 : 372208 : DynamicStrings_String s;
10427 : :
10428 : 372208 : pSym = GetPsym (sym);
10429 : 372208 : switch (pSym->SymbolType)
10430 : : {
10431 : 369706 : case SymbolTable_ConstStringSym:
10432 : 369706 : if (known)
10433 : : {
10434 : 325101 : if (escape)
10435 : : {
10436 : 7339 : s = FormatStrings_HandleEscape (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (contents)));
10437 : 7339 : contents = NameKey_makekey (DynamicStrings_string (s));
10438 : 7339 : s = DynamicStrings_KillString (s);
10439 : : }
10440 : 325101 : pSym->ConstString.Length = NameKey_LengthKey (contents);
10441 : 325101 : pSym->ConstString.Contents = contents;
10442 : : }
10443 : : else
10444 : : {
10445 : 44605 : pSym->ConstString.Length = 0;
10446 : 44605 : pSym->ConstString.Contents = NameKey_NulName;
10447 : : }
10448 : 369706 : pSym->ConstString.Known = known;
10449 : 369706 : InitWhereDeclaredTok (tok, &pSym->ConstString.At);
10450 : 369706 : InitWhereFirstUsedTok (tok, &pSym->ConstString.At);
10451 : 369706 : break;
10452 : :
10453 : 2502 : case SymbolTable_ConstVarSym:
10454 : 2502 : InitConstString (tok, sym, pSym->ConstVar.name, contents, SymbolTable_m2str, escape, known); /* Change a ConstVar to a ConstString copy name
10455 : : and alter symboltype. */
10456 : 2502 : break;
10457 : :
10458 : :
10459 : 0 : default:
10460 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
10461 : 372208 : break;
10462 : : }
10463 : 372208 : }
10464 : :
10465 : :
10466 : : /*
10467 : : CopyConstString - copies string contents from expr to des
10468 : : and retain the kind of string.
10469 : : */
10470 : :
10471 : 2502 : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr)
10472 : : {
10473 : 2502 : SymbolTable_PtrToSymbol pSym;
10474 : :
10475 : 2502 : M2Debug_Assert (SymbolTable_IsConstStringKnown (expr));
10476 : 2490 : pSym = GetPsym (des);
10477 : 2490 : switch (pSym->SymbolType)
10478 : : {
10479 : 2490 : case SymbolTable_ConstStringSym:
10480 : 2490 : InitConstString (tok, des, pSym->ConstString.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true);
10481 : 2490 : break;
10482 : :
10483 : 0 : case SymbolTable_ConstVarSym:
10484 : 0 : InitConstString (tok, des, pSym->ConstVar.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true); /* Change a ConstVar to a ConstString copy name
10485 : : and alter symboltype. */
10486 : 0 : break;
10487 : :
10488 : :
10489 : 0 : default:
10490 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
10491 : 2490 : break;
10492 : : }
10493 : 2490 : }
10494 : :
10495 : :
10496 : : /*
10497 : : IsConstStringKnown - returns TRUE if sym is a const string
10498 : : and the contents are known.
10499 : : */
10500 : :
10501 : 924119 : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym)
10502 : : {
10503 : 924119 : SymbolTable_PtrToSymbol pSym;
10504 : :
10505 : 924119 : pSym = GetPsym (sym);
10506 : 924119 : switch (pSym->SymbolType)
10507 : : {
10508 : 924119 : case SymbolTable_ConstStringSym:
10509 : 924119 : return pSym->ConstString.Known;
10510 : : break;
10511 : :
10512 : :
10513 : : default:
10514 : : return false;
10515 : : break;
10516 : : }
10517 : : /* static analysis guarentees a RETURN statement will be used before here. */
10518 : : __builtin_unreachable ();
10519 : : }
10520 : :
10521 : :
10522 : : /*
10523 : : IsConstStringM2 - returns whether this conststring is a
10524 : : Modula-2 string.
10525 : : */
10526 : :
10527 : 0 : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym)
10528 : : {
10529 : 0 : return (GetConstStringKind (sym)) == SymbolTable_m2str;
10530 : : /* static analysis guarentees a RETURN statement will be used before here. */
10531 : : __builtin_unreachable ();
10532 : : }
10533 : :
10534 : :
10535 : : /*
10536 : : IsConstStringC - returns whether this conststring is a C style string
10537 : : which will have any escape translated.
10538 : : */
10539 : :
10540 : 0 : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym)
10541 : : {
10542 : 0 : return (GetConstStringKind (sym)) == SymbolTable_cstr;
10543 : : /* static analysis guarentees a RETURN statement will be used before here. */
10544 : : __builtin_unreachable ();
10545 : : }
10546 : :
10547 : :
10548 : : /*
10549 : : IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
10550 : : contains a nul terminator.
10551 : : */
10552 : :
10553 : 262363 : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym)
10554 : : {
10555 : 262363 : return (GetConstStringKind (sym)) == SymbolTable_m2nulstr;
10556 : : /* static analysis guarentees a RETURN statement will be used before here. */
10557 : : __builtin_unreachable ();
10558 : : }
10559 : :
10560 : :
10561 : : /*
10562 : : IsConstStringCnul - returns whether this conststring is a C style string
10563 : : which will have any escape translated and also contains
10564 : : a nul terminator.
10565 : : */
10566 : :
10567 : 7159 : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym)
10568 : : {
10569 : 7159 : return (GetConstStringKind (sym)) == SymbolTable_cnulstr;
10570 : : /* static analysis guarentees a RETURN statement will be used before here. */
10571 : : __builtin_unreachable ();
10572 : : }
10573 : :
10574 : :
10575 : : /*
10576 : : MakeSubrange - makes a new symbol into a subrange type with
10577 : : name SubrangeName.
10578 : : */
10579 : :
10580 : 149679 : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName)
10581 : : {
10582 : 149679 : SymbolTable_PtrToSymbol pSym;
10583 : 149679 : unsigned int sym;
10584 : 149679 : unsigned int oaf;
10585 : :
10586 : 149679 : tok = CheckTok (tok, (const char *) "subrange", 8);
10587 : 149679 : sym = HandleHiddenOrDeclare (tok, SubrangeName, &oaf);
10588 : 149679 : if (! (SymbolTable_IsError (sym)))
10589 : : {
10590 : 149679 : pSym = GetPsym (sym);
10591 : 149679 : pSym->SymbolType = SymbolTable_SubrangeSym;
10592 : 149679 : pSym->Subrange.name = SubrangeName;
10593 : 149679 : pSym->Subrange.Low = SymbolTable_NulSym; /* Index to a symbol determining */
10594 : : /* ConstExpression. */
10595 : 149679 : pSym->Subrange.High = SymbolTable_NulSym; /* Index to a symbol determining */
10596 : : /* ConstExpression. */
10597 : 149679 : pSym->Subrange.Type = SymbolTable_NulSym; /* Index to a type. Determines */
10598 : : /* the type of subrange. */
10599 : 149679 : pSym->Subrange.Align = SymbolTable_NulSym; /* The alignment of this type. */
10600 : 149679 : InitPacked (&pSym->Subrange.packedInfo); /* not packed and no equivalent */
10601 : 149679 : SymbolKey_InitTree (&pSym->Subrange.ConstLitTree); /* constants of this type. */
10602 : 149679 : pSym->Subrange.Size = M2ALU_InitValue (); /* Size determines the type size */
10603 : 149679 : pSym->Subrange.oafamily = oaf; /* The unbounded sym for this */
10604 : 149679 : pSym->Subrange.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10605 : 149679 : InitWhereDeclaredTok (tok, &pSym->Subrange.At); /* Declared here */
10606 : : }
10607 : 149679 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10608 : 149679 : return sym;
10609 : : /* static analysis guarentees a RETURN statement will be used before here. */
10610 : : __builtin_unreachable ();
10611 : : }
10612 : :
10613 : :
10614 : : /*
10615 : : MakeSet - makes a set Symbol with name, SetName.
10616 : : */
10617 : :
10618 : 69147 : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName)
10619 : : {
10620 : 69147 : SymbolTable_PtrToSymbol pSym;
10621 : 69147 : unsigned int oaf;
10622 : 69147 : unsigned int sym;
10623 : :
10624 : 69147 : tok = CheckTok (tok, (const char *) "set", 3);
10625 : 69147 : sym = HandleHiddenOrDeclare (tok, SetName, &oaf);
10626 : 69147 : if (! (SymbolTable_IsError (sym)))
10627 : : {
10628 : 69147 : pSym = GetPsym (sym);
10629 : 69147 : pSym->SymbolType = SymbolTable_SetSym;
10630 : 69147 : pSym->Set.name = SetName; /* The name of the set. */
10631 : 69147 : pSym->Set.Type = SymbolTable_NulSym; /* Index to a subrange symbol. */
10632 : 69147 : pSym->Set.Size = M2ALU_InitValue (); /* Size of this set */
10633 : 69147 : InitPacked (&pSym->Set.packedInfo); /* not packed and no */
10634 : : /* equivalent (yet). */
10635 : 69147 : pSym->Set.ispacked = false; /* Not yet known to be packed. */
10636 : 69147 : pSym->Set.oafamily = oaf; /* The unbounded sym for this */
10637 : 69147 : pSym->Set.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10638 : 69147 : InitWhereDeclaredTok (tok, &pSym->Set.At); /* Declared here */
10639 : : }
10640 : 69147 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10641 : 69147 : return sym;
10642 : : /* static analysis guarentees a RETURN statement will be used before here. */
10643 : : __builtin_unreachable ();
10644 : : }
10645 : :
10646 : :
10647 : : /*
10648 : : MakeArray - makes an Array symbol with name ArrayName.
10649 : : */
10650 : :
10651 : 82680 : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName)
10652 : : {
10653 : 82680 : SymbolTable_PtrToSymbol pSym;
10654 : 82680 : unsigned int sym;
10655 : 82680 : unsigned int oaf;
10656 : :
10657 : 82680 : sym = HandleHiddenOrDeclare (tok, ArrayName, &oaf);
10658 : 82680 : if (! (SymbolTable_IsError (sym)))
10659 : : {
10660 : 82680 : pSym = GetPsym (sym);
10661 : 82680 : pSym->SymbolType = SymbolTable_ArraySym;
10662 : 82680 : pSym->Array.name = ArrayName;
10663 : 82680 : pSym->Array.Subscript = SymbolTable_NulSym; /* Contains the array subscripts. */
10664 : 82680 : pSym->Array.Size = M2ALU_InitValue (); /* Size of array. */
10665 : 82680 : pSym->Array.Offset = M2ALU_InitValue (); /* Offset of array. */
10666 : 82680 : pSym->Array.Type = SymbolTable_NulSym; /* The Array Type. ARRAY OF Type. */
10667 : 82680 : pSym->Array.Large = false; /* is this array large? */
10668 : 82680 : pSym->Array.Align = SymbolTable_NulSym; /* The alignment of this type. */
10669 : 82680 : pSym->Array.oafamily = oaf; /* The unbounded for this array */
10670 : 82680 : pSym->Array.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10671 : 82680 : InitWhereDeclaredTok (tok, &pSym->Array.At); /* Declared here */
10672 : : }
10673 : 82680 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10674 : 82680 : return sym;
10675 : : /* static analysis guarentees a RETURN statement will be used before here. */
10676 : : __builtin_unreachable ();
10677 : : }
10678 : :
10679 : :
10680 : : /*
10681 : : PutArrayLarge - indicates that this is a large array in which case
10682 : : the interface to gcc maps this array from 0..high-low,
10683 : : using an integer indice.
10684 : : */
10685 : :
10686 : 24 : extern "C" void SymbolTable_PutArrayLarge (unsigned int array)
10687 : : {
10688 : 24 : SymbolTable_PtrToSymbol pSym;
10689 : :
10690 : 24 : if (! (SymbolTable_IsError (array)))
10691 : : {
10692 : 24 : M2Debug_Assert (SymbolTable_IsArray (array));
10693 : 24 : pSym = GetPsym (array);
10694 : 24 : pSym->Array.Large = true;
10695 : : }
10696 : 24 : }
10697 : :
10698 : :
10699 : : /*
10700 : : IsArrayLarge - returns TRUE if we need to treat this as a large array.
10701 : : */
10702 : :
10703 : 44396 : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array)
10704 : : {
10705 : 44396 : SymbolTable_PtrToSymbol pSym;
10706 : :
10707 : 44396 : M2Debug_Assert (SymbolTable_IsArray (array));
10708 : 44396 : pSym = GetPsym (array);
10709 : 44396 : return pSym->Array.Large;
10710 : : /* static analysis guarentees a RETURN statement will be used before here. */
10711 : : __builtin_unreachable ();
10712 : : }
10713 : :
10714 : :
10715 : : /*
10716 : : PutPriority - places a interrupt, priority, value into module, module.
10717 : : */
10718 : :
10719 : 38 : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority)
10720 : : {
10721 : 38 : SymbolTable_PtrToSymbol pSym;
10722 : :
10723 : 38 : M2Debug_Assert (module != SymbolTable_NulSym);
10724 : 38 : pSym = GetPsym (module);
10725 : 38 : switch (pSym->SymbolType)
10726 : : {
10727 : 14 : case SymbolTable_DefImpSym:
10728 : 14 : pSym->DefImp.Priority = priority;
10729 : 14 : break;
10730 : :
10731 : 24 : case SymbolTable_ModuleSym:
10732 : 24 : pSym->Module.Priority = priority;
10733 : 24 : break;
10734 : :
10735 : :
10736 : 0 : default:
10737 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10738 : 38 : break;
10739 : : }
10740 : 38 : }
10741 : :
10742 : :
10743 : : /*
10744 : : GetPriority - returns the interrupt priority which was assigned to
10745 : : module, module.
10746 : : */
10747 : :
10748 : 395779 : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module)
10749 : : {
10750 : 395779 : SymbolTable_PtrToSymbol pSym;
10751 : :
10752 : 395779 : M2Debug_Assert (module != SymbolTable_NulSym);
10753 : 395779 : pSym = GetPsym (module);
10754 : 395779 : switch (pSym->SymbolType)
10755 : : {
10756 : 273837 : case SymbolTable_DefImpSym:
10757 : 273837 : return pSym->DefImp.Priority;
10758 : 121942 : break;
10759 : :
10760 : 121942 : case SymbolTable_ModuleSym:
10761 : 121942 : return pSym->Module.Priority;
10762 : 0 : break;
10763 : :
10764 : :
10765 : 0 : default:
10766 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10767 : : break;
10768 : : }
10769 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10770 : : __builtin_unreachable ();
10771 : : }
10772 : :
10773 : :
10774 : : /*
10775 : : PutNeedSavePriority - set a boolean flag indicating that this procedure
10776 : : needs to save and restore interrupts.
10777 : : */
10778 : :
10779 : 162 : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym)
10780 : : {
10781 : 162 : SymbolTable_PtrToSymbol pSym;
10782 : :
10783 : 162 : pSym = GetPsym (sym);
10784 : 162 : switch (pSym->SymbolType)
10785 : : {
10786 : 162 : case SymbolTable_ProcedureSym:
10787 : 162 : pSym->Procedure.SavePriority = true;
10788 : 162 : break;
10789 : :
10790 : :
10791 : 0 : default:
10792 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
10793 : 162 : break;
10794 : : }
10795 : 162 : }
10796 : :
10797 : :
10798 : : /*
10799 : : GetNeedSavePriority - returns the boolean flag indicating whether this procedure
10800 : : needs to save and restore interrupts.
10801 : : */
10802 : :
10803 : 680 : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym)
10804 : : {
10805 : 680 : SymbolTable_PtrToSymbol pSym;
10806 : :
10807 : 680 : pSym = GetPsym (sym);
10808 : 680 : switch (pSym->SymbolType)
10809 : : {
10810 : 680 : case SymbolTable_ProcedureSym:
10811 : 680 : return pSym->Procedure.SavePriority;
10812 : 0 : break;
10813 : :
10814 : :
10815 : 0 : default:
10816 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
10817 : : break;
10818 : : }
10819 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10820 : : __builtin_unreachable ();
10821 : : }
10822 : :
10823 : :
10824 : : /*
10825 : : PutVariableAtAddress - determines that a variable, sym, is declared at
10826 : : a specific address.
10827 : : */
10828 : :
10829 : 108 : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address)
10830 : : {
10831 : 108 : SymbolTable_PtrToSymbol pSym;
10832 : :
10833 : 108 : M2Debug_Assert (sym != SymbolTable_NulSym);
10834 : 108 : pSym = GetPsym (sym);
10835 : 108 : switch (pSym->SymbolType)
10836 : : {
10837 : 108 : case SymbolTable_VarSym:
10838 : 108 : pSym->Var.AtAddress = true;
10839 : 108 : pSym->Var.Address = address;
10840 : 108 : break;
10841 : :
10842 : :
10843 : 0 : default:
10844 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
10845 : 108 : break;
10846 : : }
10847 : 108 : }
10848 : :
10849 : :
10850 : : /*
10851 : : GetVariableAtAddress - returns the address at which variable, sym, is declared.
10852 : : */
10853 : :
10854 : 54 : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym)
10855 : : {
10856 : 54 : SymbolTable_PtrToSymbol pSym;
10857 : :
10858 : 54 : M2Debug_Assert (sym != SymbolTable_NulSym);
10859 : 54 : pSym = GetPsym (sym);
10860 : 54 : switch (pSym->SymbolType)
10861 : : {
10862 : 54 : case SymbolTable_VarSym:
10863 : 54 : return pSym->Var.Address;
10864 : 0 : break;
10865 : :
10866 : :
10867 : 0 : default:
10868 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
10869 : : break;
10870 : : }
10871 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10872 : : __builtin_unreachable ();
10873 : : }
10874 : :
10875 : :
10876 : : /*
10877 : : IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
10878 : : a specific address.
10879 : : */
10880 : :
10881 : 287319 : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym)
10882 : : {
10883 : 287319 : SymbolTable_PtrToSymbol pSym;
10884 : :
10885 : 287319 : M2Debug_Assert (sym != SymbolTable_NulSym);
10886 : 287319 : pSym = GetPsym (sym);
10887 : 287319 : switch (pSym->SymbolType)
10888 : : {
10889 : 287319 : case SymbolTable_VarSym:
10890 : 287319 : return pSym->Var.AtAddress;
10891 : 0 : break;
10892 : :
10893 : :
10894 : 0 : default:
10895 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
10896 : : break;
10897 : : }
10898 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10899 : : __builtin_unreachable ();
10900 : : }
10901 : :
10902 : :
10903 : : /*
10904 : : PutVariableSSA - assigns value to the SSA field within variable sym.
10905 : : */
10906 : :
10907 : 0 : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value)
10908 : : {
10909 : 0 : SymbolTable_PtrToSymbol pSym;
10910 : :
10911 : 0 : M2Debug_Assert (sym != SymbolTable_NulSym);
10912 : 0 : pSym = GetPsym (sym);
10913 : 0 : switch (pSym->SymbolType)
10914 : : {
10915 : 0 : case SymbolTable_VarSym:
10916 : 0 : pSym->Var.IsSSA = value;
10917 : 0 : break;
10918 : :
10919 : :
10920 : 0 : default:
10921 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
10922 : 0 : break;
10923 : : }
10924 : 0 : }
10925 : :
10926 : :
10927 : : /*
10928 : : IsVariableSSA - returns TRUE if variable is known to be a SSA.
10929 : : */
10930 : :
10931 : 198735 : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym)
10932 : : {
10933 : 198735 : SymbolTable_PtrToSymbol pSym;
10934 : :
10935 : 198735 : M2Debug_Assert (sym != SymbolTable_NulSym);
10936 : 198735 : pSym = GetPsym (sym);
10937 : 198735 : switch (pSym->SymbolType)
10938 : : {
10939 : 198735 : case SymbolTable_VarSym:
10940 : 198735 : return pSym->Var.IsSSA;
10941 : 0 : break;
10942 : :
10943 : :
10944 : 0 : default:
10945 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
10946 : : break;
10947 : : }
10948 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10949 : : __builtin_unreachable ();
10950 : : }
10951 : :
10952 : :
10953 : : /*
10954 : : PutVarConst - sets the IsConst field to value indicating the variable is read only.
10955 : : */
10956 : :
10957 : 196173 : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value)
10958 : : {
10959 : 196173 : SymbolTable_PtrToSymbol pSym;
10960 : :
10961 : 196173 : if (SymbolTable_IsVar (sym))
10962 : : {
10963 : 196173 : pSym = GetPsym (sym);
10964 : 196173 : pSym->Var.IsConst = value;
10965 : : }
10966 : 196173 : }
10967 : :
10968 : :
10969 : : /*
10970 : : MakeGnuAsm - create a GnuAsm symbol.
10971 : : */
10972 : :
10973 : 18 : extern "C" unsigned int SymbolTable_MakeGnuAsm (void)
10974 : : {
10975 : 18 : SymbolTable_PtrToSymbol pSym;
10976 : 18 : unsigned int Sym;
10977 : :
10978 : 18 : NewSym (&Sym);
10979 : 18 : pSym = GetPsym (Sym);
10980 : 18 : pSym->SymbolType = SymbolTable_GnuAsmSym;
10981 : 18 : pSym->GnuAsm.String = SymbolTable_NulSym;
10982 : 18 : InitWhereDeclared (&pSym->GnuAsm.At);
10983 : 18 : pSym->GnuAsm.Inputs = SymbolTable_NulSym;
10984 : 18 : pSym->GnuAsm.Outputs = SymbolTable_NulSym;
10985 : 18 : pSym->GnuAsm.Trashed = SymbolTable_NulSym;
10986 : 18 : pSym->GnuAsm.Volatile = false;
10987 : 18 : pSym->GnuAsm.Simple = false;
10988 : 18 : return Sym;
10989 : : /* static analysis guarentees a RETURN statement will be used before here. */
10990 : : __builtin_unreachable ();
10991 : : }
10992 : :
10993 : :
10994 : : /*
10995 : : PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
10996 : : */
10997 : :
10998 : 18 : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string)
10999 : : {
11000 : 18 : SymbolTable_PtrToSymbol pSym;
11001 : :
11002 : 18 : M2Debug_Assert (SymbolTable_IsConstString (string));
11003 : 18 : pSym = GetPsym (sym);
11004 : 18 : switch (pSym->SymbolType)
11005 : : {
11006 : 18 : case SymbolTable_GnuAsmSym:
11007 : 18 : pSym->GnuAsm.String = string;
11008 : 18 : break;
11009 : :
11010 : :
11011 : 0 : default:
11012 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11013 : 18 : break;
11014 : : }
11015 : 18 : }
11016 : :
11017 : :
11018 : : /*
11019 : : PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
11020 : : */
11021 : :
11022 : 18 : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out)
11023 : : {
11024 : 18 : SymbolTable_PtrToSymbol pSym;
11025 : :
11026 : 18 : pSym = GetPsym (sym);
11027 : 18 : switch (pSym->SymbolType)
11028 : : {
11029 : 18 : case SymbolTable_GnuAsmSym:
11030 : 18 : pSym->GnuAsm.Outputs = out;
11031 : 18 : break;
11032 : :
11033 : :
11034 : 0 : default:
11035 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11036 : 18 : break;
11037 : : }
11038 : 18 : }
11039 : :
11040 : :
11041 : : /*
11042 : : PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
11043 : : */
11044 : :
11045 : 12 : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in)
11046 : : {
11047 : 12 : SymbolTable_PtrToSymbol pSym;
11048 : :
11049 : 12 : pSym = GetPsym (sym);
11050 : 12 : switch (pSym->SymbolType)
11051 : : {
11052 : 12 : case SymbolTable_GnuAsmSym:
11053 : 12 : pSym->GnuAsm.Inputs = in;
11054 : 12 : break;
11055 : :
11056 : :
11057 : 0 : default:
11058 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11059 : 12 : break;
11060 : : }
11061 : 12 : }
11062 : :
11063 : :
11064 : : /*
11065 : : PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
11066 : : */
11067 : :
11068 : 6 : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash)
11069 : : {
11070 : 6 : SymbolTable_PtrToSymbol pSym;
11071 : :
11072 : 6 : pSym = GetPsym (sym);
11073 : 6 : switch (pSym->SymbolType)
11074 : : {
11075 : 6 : case SymbolTable_GnuAsmSym:
11076 : 6 : pSym->GnuAsm.Trashed = trash;
11077 : 6 : break;
11078 : :
11079 : :
11080 : 0 : default:
11081 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11082 : 6 : break;
11083 : : }
11084 : 6 : }
11085 : :
11086 : :
11087 : : /*
11088 : : GetGnuAsm - returns the string symbol, representing the instruction textual
11089 : : of the GnuAsm symbol. It will return a ConstString.
11090 : : */
11091 : :
11092 : 18 : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym)
11093 : : {
11094 : 18 : SymbolTable_PtrToSymbol pSym;
11095 : :
11096 : 18 : pSym = GetPsym (sym);
11097 : 18 : switch (pSym->SymbolType)
11098 : : {
11099 : 18 : case SymbolTable_GnuAsmSym:
11100 : 18 : return pSym->GnuAsm.String;
11101 : 0 : break;
11102 : :
11103 : :
11104 : 0 : default:
11105 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11106 : : break;
11107 : : }
11108 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11109 : : __builtin_unreachable ();
11110 : : }
11111 : :
11112 : :
11113 : : /*
11114 : : GetGnuAsmInput - returns the input list of registers.
11115 : : */
11116 : :
11117 : 18 : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym)
11118 : : {
11119 : 18 : SymbolTable_PtrToSymbol pSym;
11120 : :
11121 : 18 : pSym = GetPsym (sym);
11122 : 18 : switch (pSym->SymbolType)
11123 : : {
11124 : 18 : case SymbolTable_GnuAsmSym:
11125 : 18 : return pSym->GnuAsm.Inputs;
11126 : 0 : break;
11127 : :
11128 : :
11129 : 0 : default:
11130 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11131 : : break;
11132 : : }
11133 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11134 : : __builtin_unreachable ();
11135 : : }
11136 : :
11137 : :
11138 : : /*
11139 : : GetGnuAsmOutput - returns the output list of registers.
11140 : : */
11141 : :
11142 : 18 : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym)
11143 : : {
11144 : 18 : SymbolTable_PtrToSymbol pSym;
11145 : :
11146 : 18 : pSym = GetPsym (sym);
11147 : 18 : switch (pSym->SymbolType)
11148 : : {
11149 : 18 : case SymbolTable_GnuAsmSym:
11150 : 18 : return pSym->GnuAsm.Outputs;
11151 : 0 : break;
11152 : :
11153 : :
11154 : 0 : default:
11155 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11156 : : break;
11157 : : }
11158 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11159 : : __builtin_unreachable ();
11160 : : }
11161 : :
11162 : :
11163 : : /*
11164 : : GetGnuAsmTrash - returns the list of trashed registers.
11165 : : */
11166 : :
11167 : 18 : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym)
11168 : : {
11169 : 18 : SymbolTable_PtrToSymbol pSym;
11170 : :
11171 : 18 : pSym = GetPsym (sym);
11172 : 18 : switch (pSym->SymbolType)
11173 : : {
11174 : 18 : case SymbolTable_GnuAsmSym:
11175 : 18 : return pSym->GnuAsm.Trashed;
11176 : 0 : break;
11177 : :
11178 : :
11179 : 0 : default:
11180 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11181 : : break;
11182 : : }
11183 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11184 : : __builtin_unreachable ();
11185 : : }
11186 : :
11187 : :
11188 : : /*
11189 : : PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
11190 : : */
11191 : :
11192 : 6 : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym)
11193 : : {
11194 : 6 : SymbolTable_PtrToSymbol pSym;
11195 : :
11196 : 6 : pSym = GetPsym (Sym);
11197 : 6 : switch (pSym->SymbolType)
11198 : : {
11199 : 6 : case SymbolTable_GnuAsmSym:
11200 : 6 : pSym->GnuAsm.Volatile = true;
11201 : 6 : break;
11202 : :
11203 : :
11204 : 0 : default:
11205 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11206 : 6 : break;
11207 : : }
11208 : 6 : }
11209 : :
11210 : :
11211 : : /*
11212 : : PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
11213 : : */
11214 : :
11215 : 0 : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym)
11216 : : {
11217 : 0 : SymbolTable_PtrToSymbol pSym;
11218 : :
11219 : 0 : pSym = GetPsym (Sym);
11220 : 0 : switch (pSym->SymbolType)
11221 : : {
11222 : 0 : case SymbolTable_GnuAsmSym:
11223 : 0 : pSym->GnuAsm.Simple = true;
11224 : 0 : break;
11225 : :
11226 : :
11227 : 0 : default:
11228 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11229 : 0 : break;
11230 : : }
11231 : 0 : }
11232 : :
11233 : :
11234 : : /*
11235 : : MakeRegInterface - creates and returns a register interface symbol.
11236 : : */
11237 : :
11238 : 24 : extern "C" unsigned int SymbolTable_MakeRegInterface (void)
11239 : : {
11240 : 24 : SymbolTable_PtrToSymbol pSym;
11241 : 24 : unsigned int Sym;
11242 : :
11243 : 24 : NewSym (&Sym);
11244 : 24 : pSym = GetPsym (Sym);
11245 : 24 : pSym->SymbolType = SymbolTable_InterfaceSym;
11246 : 24 : pSym->Interface.Parameters = Indexing_InitIndex (1);
11247 : 24 : InitWhereDeclared (&pSym->Interface.At);
11248 : 24 : return Sym;
11249 : : /* static analysis guarentees a RETURN statement will be used before here. */
11250 : : __builtin_unreachable ();
11251 : : }
11252 : :
11253 : :
11254 : : /*
11255 : : PutRegInterface - places a, name, string, and, object, into the interface array,
11256 : : sym, at position, i.
11257 : : The string symbol will either be a register name or a constraint.
11258 : : The object is an optional Modula-2 variable or constant symbol.
11259 : : read and write are the quadruple numbers representing any read
11260 : : or write operation.
11261 : : */
11262 : :
11263 : 24 : 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_)
11264 : : {
11265 : 24 : SymbolTable_PtrToSymbol pSym;
11266 : 24 : SymbolTable_PtrToAsmConstraint p;
11267 : :
11268 : 24 : pSym = GetPsym (sym);
11269 : 24 : switch (pSym->SymbolType)
11270 : : {
11271 : 24 : case SymbolTable_InterfaceSym:
11272 : 24 : if (Indexing_InBounds (pSym->Interface.Parameters, i))
11273 : : {
11274 : 0 : p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
11275 : : }
11276 : 24 : else if (i == ((Indexing_HighIndice (pSym->Interface.Parameters))+1))
11277 : : {
11278 : : /* avoid dangling else. */
11279 : 24 : Storage_ALLOCATE ((void **) &p, sizeof (SymbolTable__T5));
11280 : 24 : Indexing_PutIndice (pSym->Interface.Parameters, i, reinterpret_cast<void *> (p));
11281 : : }
11282 : : else
11283 : : {
11284 : : /* avoid dangling else. */
11285 : 0 : M2Error_InternalError ((const char *) "expecting to add parameters sequentially", 40);
11286 : : }
11287 : 24 : p->tokpos = tok;
11288 : 24 : p->name = n;
11289 : 24 : p->str = string;
11290 : 24 : p->obj = object;
11291 : 24 : PutFirstUsed (object, tok, read_, write_);
11292 : 24 : break;
11293 : :
11294 : :
11295 : 0 : default:
11296 : 0 : M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
11297 : 24 : break;
11298 : : }
11299 : 24 : }
11300 : :
11301 : :
11302 : : /*
11303 : : GetRegInterface - gets a, name, string, and, object, from the interface array,
11304 : : sym, from position, i.
11305 : : */
11306 : :
11307 : 48 : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object)
11308 : : {
11309 : 48 : SymbolTable_PtrToSymbol pSym;
11310 : 48 : SymbolTable_PtrToAsmConstraint p;
11311 : :
11312 : 48 : pSym = GetPsym (sym);
11313 : 48 : switch (pSym->SymbolType)
11314 : : {
11315 : 48 : case SymbolTable_InterfaceSym:
11316 : 48 : if (Indexing_InBounds (pSym->Interface.Parameters, i))
11317 : : {
11318 : 24 : p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
11319 : 24 : (*tok) = p->tokpos;
11320 : 24 : (*n) = p->name;
11321 : 24 : (*string) = p->str;
11322 : 24 : (*object) = p->obj;
11323 : : }
11324 : : else
11325 : : {
11326 : 24 : (*tok) = M2LexBuf_UnknownTokenNo;
11327 : 24 : (*n) = NameKey_NulName;
11328 : 24 : (*string) = SymbolTable_NulSym;
11329 : 24 : (*object) = SymbolTable_NulSym;
11330 : : }
11331 : 48 : break;
11332 : :
11333 : :
11334 : 0 : default:
11335 : 0 : M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
11336 : 48 : break;
11337 : : }
11338 : 48 : }
11339 : :
11340 : :
11341 : : /*
11342 : : GetModule - Returns the Module symbol for the module with name, name.
11343 : : */
11344 : :
11345 : 312746 : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name)
11346 : : {
11347 : 312746 : return static_cast<unsigned int> (SymbolKey_GetSymKey (ModuleTree, name));
11348 : : /* static analysis guarentees a RETURN statement will be used before here. */
11349 : : __builtin_unreachable ();
11350 : : }
11351 : :
11352 : :
11353 : : /*
11354 : : GetCurrentModule - returns the current module Sym that is being
11355 : : compiled.
11356 : : */
11357 : :
11358 : 25795863 : extern "C" unsigned int SymbolTable_GetCurrentModule (void)
11359 : : {
11360 : 25795863 : return CurrentModule;
11361 : : /* static analysis guarentees a RETURN statement will be used before here. */
11362 : : __builtin_unreachable ();
11363 : : }
11364 : :
11365 : :
11366 : : /*
11367 : : GetFileModule - returns the FileModule symbol that was requested by
11368 : : the user to be compiled.
11369 : : */
11370 : :
11371 : 224544 : extern "C" unsigned int SymbolTable_GetFileModule (void)
11372 : : {
11373 : 224544 : return FileModule;
11374 : : /* static analysis guarentees a RETURN statement will be used before here. */
11375 : : __builtin_unreachable ();
11376 : : }
11377 : :
11378 : :
11379 : : /*
11380 : : GetBaseModule - returns the base module symbol that contains Modula-2
11381 : : base types, procedures and functions.
11382 : : */
11383 : :
11384 : 5193513 : extern "C" unsigned int SymbolTable_GetBaseModule (void)
11385 : : {
11386 : 5193513 : return BaseModule;
11387 : : /* static analysis guarentees a RETURN statement will be used before here. */
11388 : : __builtin_unreachable ();
11389 : : }
11390 : :
11391 : :
11392 : : /*
11393 : : GetMainModule - returns the main module symbol that was requested by
11394 : : the user to be compiled.
11395 : : */
11396 : :
11397 : 13604545 : extern "C" unsigned int SymbolTable_GetMainModule (void)
11398 : : {
11399 : 13604545 : return MainModule;
11400 : : /* static analysis guarentees a RETURN statement will be used before here. */
11401 : : __builtin_unreachable ();
11402 : : }
11403 : :
11404 : :
11405 : : /*
11406 : : GetCurrentModuleScope - returns the module symbol which forms the
11407 : : current (possibly inner most) module.
11408 : : */
11409 : :
11410 : 1394863 : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void)
11411 : : {
11412 : 1394863 : SymbolTable_PtrToCallFrame pCall;
11413 : 1394863 : unsigned int i;
11414 : :
11415 : 1394863 : i = ScopePtr;
11416 : 1394863 : pCall = GetPcall (i);
11417 : 3293162 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
11418 : : {
11419 : 503436 : M2Debug_Assert (i > 0);
11420 : 503436 : i -= 1;
11421 : 503436 : pCall = GetPcall (i);
11422 : : }
11423 : 1394863 : return pCall->Search;
11424 : : /* static analysis guarentees a RETURN statement will be used before here. */
11425 : : __builtin_unreachable ();
11426 : : }
11427 : :
11428 : :
11429 : : /*
11430 : : GetLastModuleScope - returns the last module scope encountered,
11431 : : the module scope before the Current Module Scope.
11432 : : */
11433 : :
11434 : 0 : extern "C" unsigned int SymbolTable_GetLastModuleScope (void)
11435 : : {
11436 : 0 : SymbolTable_PtrToCallFrame pCall;
11437 : 0 : unsigned int i;
11438 : :
11439 : 0 : i = ScopePtr;
11440 : 0 : pCall = GetPcall (i);
11441 : 0 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
11442 : : {
11443 : 0 : M2Debug_Assert (i > 0);
11444 : 0 : i -= 1;
11445 : 0 : pCall = GetPcall (i);
11446 : : }
11447 : : /* Found module at position, i. */
11448 : 0 : i -= 1; /* Move to an outer level module scope */
11449 : 0 : pCall = GetPcall (i); /* Move to an outer level module scope */
11450 : 0 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
11451 : : {
11452 : 0 : M2Debug_Assert (i > 0);
11453 : 0 : i -= 1;
11454 : 0 : pCall = GetPcall (i);
11455 : : }
11456 : : /* Found module at position, i. */
11457 : 0 : return pCall->Search;
11458 : : /* static analysis guarentees a RETURN statement will be used before here. */
11459 : : __builtin_unreachable ();
11460 : : }
11461 : :
11462 : :
11463 : : /*
11464 : : AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
11465 : : ModSym.
11466 : : */
11467 : :
11468 : 708094 : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym)
11469 : : {
11470 : 708094 : SymbolTable_PtrToSymbol pSym;
11471 : :
11472 : 708094 : pSym = GetPsym (ModSym);
11473 : 708094 : switch (pSym->SymbolType)
11474 : : {
11475 : 593390 : case SymbolTable_DefImpSym:
11476 : 593390 : if ((SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
11477 : : {
11478 : 593390 : SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
11479 : : }
11480 : : else
11481 : : {
11482 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
11483 : : }
11484 : : break;
11485 : :
11486 : 114644 : case SymbolTable_ModuleSym:
11487 : 114644 : if ((SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
11488 : : {
11489 : 114644 : SymbolKey_PutSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
11490 : : }
11491 : : else
11492 : : {
11493 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
11494 : : }
11495 : : break;
11496 : :
11497 : 60 : case SymbolTable_ProcedureSym:
11498 : 60 : if ((SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
11499 : : {
11500 : 60 : SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
11501 : : }
11502 : : else
11503 : : {
11504 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
11505 : : }
11506 : : break;
11507 : :
11508 : :
11509 : 0 : default:
11510 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
11511 : 708094 : break;
11512 : : }
11513 : 708094 : }
11514 : :
11515 : :
11516 : : /*
11517 : : GetType - Returns the symbol that is the TYPE symbol to Sym.
11518 : : If zero is returned then we assume type unknown.
11519 : : */
11520 : :
11521 : 211174550 : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym)
11522 : : {
11523 : 211174550 : SymbolTable_PtrToSymbol pSym;
11524 : 211174550 : unsigned int type;
11525 : :
11526 : 211174550 : M2Debug_Assert (Sym != SymbolTable_NulSym);
11527 : 211174550 : pSym = GetPsym (Sym);
11528 : 211174550 : switch (pSym->SymbolType)
11529 : : {
11530 : 0 : case SymbolTable_OAFamilySym:
11531 : 0 : type = pSym->OAFamily.SimpleType;
11532 : 0 : break;
11533 : :
11534 : 39384075 : case SymbolTable_VarSym:
11535 : 39384075 : type = GetTypeOfVar (Sym);
11536 : 39384075 : break;
11537 : :
11538 : 9057226 : case SymbolTable_ConstLitSym:
11539 : 9057226 : type = pSym->ConstLit.Type;
11540 : 9057226 : break;
11541 : :
11542 : 9725543 : case SymbolTable_ConstVarSym:
11543 : 9725543 : type = pSym->ConstVar.Type;
11544 : 9725543 : break;
11545 : :
11546 : 2253564 : case SymbolTable_ConstStringSym:
11547 : 2253564 : if (pSym->ConstString.Length == 1)
11548 : : {
11549 : 333332 : type = M2Base_Char;
11550 : : }
11551 : : else
11552 : : {
11553 : : type = SymbolTable_NulSym; /* No type for a string */
11554 : : }
11555 : : break;
11556 : :
11557 : 31757683 : case SymbolTable_TypeSym:
11558 : 31757683 : type = pSym->Type.Type;
11559 : 31757683 : break;
11560 : :
11561 : 44962601 : case SymbolTable_RecordFieldSym:
11562 : 44962601 : type = pSym->RecordField.Type;
11563 : 44962601 : break;
11564 : :
11565 : : case SymbolTable_RecordSym:
11566 : : type = SymbolTable_NulSym; /* No type for a record */
11567 : : break;
11568 : :
11569 : : case SymbolTable_VarientSym:
11570 : : type = SymbolTable_NulSym; /* No type for a record */
11571 : : break;
11572 : :
11573 : 13517883 : case SymbolTable_EnumerationFieldSym:
11574 : 13517883 : type = pSym->EnumerationField.Type; /* No type for a record */
11575 : 13517883 : break;
11576 : :
11577 : : case SymbolTable_EnumerationSym:
11578 : : type = SymbolTable_NulSym; /* No type for enumeration */
11579 : : break;
11580 : :
11581 : 14677845 : case SymbolTable_PointerSym:
11582 : 14677845 : type = pSym->Pointer.Type; /* No type for enumeration */
11583 : 14677845 : break;
11584 : :
11585 : 7233527 : case SymbolTable_ProcedureSym:
11586 : 7233527 : type = pSym->Procedure.ReturnType;
11587 : 7233527 : break;
11588 : :
11589 : 2572286 : case SymbolTable_ProcTypeSym:
11590 : 2572286 : type = pSym->ProcType.ReturnType;
11591 : 2572286 : break;
11592 : :
11593 : 19654115 : case SymbolTable_ParamSym:
11594 : 19654115 : type = pSym->Param.Type;
11595 : 19654115 : break;
11596 : :
11597 : 2271391 : case SymbolTable_VarParamSym:
11598 : 2271391 : type = pSym->VarParam.Type;
11599 : 2271391 : break;
11600 : :
11601 : 4523511 : case SymbolTable_SubrangeSym:
11602 : 4523511 : type = pSym->Subrange.Type;
11603 : 4523511 : break;
11604 : :
11605 : 1918091 : case SymbolTable_ArraySym:
11606 : 1918091 : type = pSym->Array.Type;
11607 : 1918091 : break;
11608 : :
11609 : 1913004 : case SymbolTable_SubscriptSym:
11610 : 1913004 : type = pSym->Subscript.Type;
11611 : 1913004 : break;
11612 : :
11613 : 524740 : case SymbolTable_SetSym:
11614 : 524740 : type = pSym->Set.Type;
11615 : 524740 : break;
11616 : :
11617 : 4579811 : case SymbolTable_UnboundedSym:
11618 : 4579811 : type = pSym->Unbounded.Type;
11619 : 4579811 : break;
11620 : :
11621 : : case SymbolTable_UndefinedSym:
11622 : : type = SymbolTable_NulSym;
11623 : : break;
11624 : :
11625 : 0 : case SymbolTable_PartialUnboundedSym:
11626 : 0 : type = pSym->PartialUnbounded.Type;
11627 : 0 : break;
11628 : :
11629 : : case SymbolTable_ObjectSym:
11630 : : type = SymbolTable_NulSym;
11631 : : break;
11632 : :
11633 : :
11634 : 0 : default:
11635 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
11636 : 211174550 : break;
11637 : : }
11638 : 211174550 : return type;
11639 : : /* static analysis guarentees a RETURN statement will be used before here. */
11640 : : __builtin_unreachable ();
11641 : : }
11642 : :
11643 : :
11644 : : /*
11645 : : SkipType - if sym is a TYPE foo = bar
11646 : : then call SkipType(bar)
11647 : : else return sym
11648 : :
11649 : : it does not skip over hidden types.
11650 : : */
11651 : :
11652 : 35544214 : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym)
11653 : : {
11654 : 35758530 : if ((((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
11655 : : {
11656 : 214316 : return SymbolTable_SkipType (SymbolTable_GetType (Sym));
11657 : : }
11658 : : else
11659 : : {
11660 : 35544214 : return Sym;
11661 : : }
11662 : : /* static analysis guarentees a RETURN statement will be used before here. */
11663 : : __builtin_unreachable ();
11664 : : }
11665 : :
11666 : :
11667 : : /*
11668 : : SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
11669 : : sym is declared as a subrange of bar
11670 : : then call SkipTypeAndSubrange(bar)
11671 : : else return sym
11672 : :
11673 : : it does not skip over hidden types.
11674 : : */
11675 : :
11676 : 4385 : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym)
11677 : : {
11678 : 4433 : if ((((Sym != SymbolTable_NulSym) && ((SymbolTable_IsType (Sym)) || (SymbolTable_IsSubrange (Sym)))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
11679 : : {
11680 : 48 : return SymbolTable_SkipTypeAndSubrange (SymbolTable_GetType (Sym));
11681 : : }
11682 : : else
11683 : : {
11684 : 4385 : return Sym;
11685 : : }
11686 : : /* static analysis guarentees a RETURN statement will be used before here. */
11687 : : __builtin_unreachable ();
11688 : : }
11689 : :
11690 : :
11691 : : /*
11692 : : GetLowestType - Returns the lowest type in the type chain of
11693 : : symbol Sym.
11694 : : If NulSym is returned then we assume type unknown or
11695 : : you have reqested the type of a base type.
11696 : : */
11697 : :
11698 : 1392476 : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym)
11699 : : {
11700 : 2414918 : SymbolTable_PtrToSymbol pSym;
11701 : 2414918 : unsigned int type;
11702 : :
11703 : 2414918 : M2Debug_Assert (Sym != SymbolTable_NulSym);
11704 : 2414918 : pSym = GetPsym (Sym);
11705 : 2414918 : switch (pSym->SymbolType)
11706 : : {
11707 : 477104 : case SymbolTable_VarSym:
11708 : 477104 : type = pSym->Var.Type;
11709 : 477104 : break;
11710 : :
11711 : 253809 : case SymbolTable_ConstLitSym:
11712 : 253809 : type = pSym->ConstLit.Type;
11713 : 253809 : break;
11714 : :
11715 : 333825 : case SymbolTable_ConstVarSym:
11716 : 333825 : type = pSym->ConstVar.Type;
11717 : 333825 : break;
11718 : :
11719 : : case SymbolTable_ConstStringSym:
11720 : : type = SymbolTable_NulSym; /* No type for a string */
11721 : : break;
11722 : :
11723 : 1048568 : case SymbolTable_TypeSym:
11724 : 1048568 : type = pSym->Type.Type; /* No type for a string */
11725 : 1048568 : break;
11726 : :
11727 : 0 : case SymbolTable_RecordFieldSym:
11728 : 0 : type = pSym->RecordField.Type;
11729 : 0 : break;
11730 : :
11731 : : case SymbolTable_RecordSym:
11732 : : type = SymbolTable_NulSym; /* No type for a record */
11733 : : break;
11734 : :
11735 : 33914 : case SymbolTable_EnumerationFieldSym:
11736 : 33914 : type = pSym->EnumerationField.Type; /* No type for a record */
11737 : 33914 : break;
11738 : :
11739 : : case SymbolTable_EnumerationSym:
11740 : : type = SymbolTable_NulSym; /* No type for enumeration */
11741 : : break;
11742 : :
11743 : : case SymbolTable_PointerSym:
11744 : 23484 : type = Sym; /* we don't go to Pointer.Type */
11745 : : break;
11746 : :
11747 : 44259 : case SymbolTable_ProcedureSym:
11748 : 44259 : type = pSym->Procedure.ReturnType; /* we don't go to Pointer.Type */
11749 : 44259 : break;
11750 : :
11751 : 0 : case SymbolTable_ProcTypeSym:
11752 : 0 : type = pSym->ProcType.ReturnType;
11753 : 0 : break;
11754 : :
11755 : 142721 : case SymbolTable_ParamSym:
11756 : 142721 : type = pSym->Param.Type;
11757 : 142721 : break;
11758 : :
11759 : 8793 : case SymbolTable_VarParamSym:
11760 : 8793 : type = pSym->VarParam.Type;
11761 : 8793 : break;
11762 : :
11763 : 48 : case SymbolTable_SubrangeSym:
11764 : 48 : type = pSym->Subrange.Type;
11765 : 48 : break;
11766 : :
11767 : 24 : case SymbolTable_ArraySym:
11768 : 24 : type = pSym->Array.Type;
11769 : 24 : break;
11770 : :
11771 : 44456 : case SymbolTable_SubscriptSym:
11772 : 44456 : type = pSym->Subscript.Type;
11773 : 44456 : break;
11774 : :
11775 : : case SymbolTable_SetSym:
11776 : 23484 : type = Sym; /* Stop at the set type. */
11777 : : break;
11778 : :
11779 : 0 : case SymbolTable_UnboundedSym:
11780 : 0 : type = pSym->Unbounded.Type; /* Stop at the set type. */
11781 : 0 : break;
11782 : :
11783 : : case SymbolTable_UndefinedSym:
11784 : : type = SymbolTable_NulSym;
11785 : : break;
11786 : :
11787 : : case SymbolTable_DummySym:
11788 : : type = SymbolTable_NulSym;
11789 : : break;
11790 : :
11791 : :
11792 : 0 : default:
11793 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
11794 : 2414918 : break;
11795 : : }
11796 : 2414918 : pSym = GetPsym (Sym);
11797 : 2414918 : if ((pSym->SymbolType == SymbolTable_TypeSym) && (type == SymbolTable_NulSym))
11798 : : {
11799 : : type = Sym; /* Base Type */
11800 : : }
11801 : 1388484 : else if (((type != SymbolTable_NulSym) && (SymbolTable_IsType (type))) && ((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym))
11802 : : {
11803 : : /* avoid dangling else. */
11804 : : type = SymbolTable_GetLowestType (type); /* Type def */
11805 : : }
11806 : 1392476 : return type;
11807 : : /* static analysis guarentees a RETURN statement will be used before here. */
11808 : : __builtin_unreachable ();
11809 : : }
11810 : :
11811 : :
11812 : : /*
11813 : : GetLType - get lowest type. It returns the lowest type
11814 : : of symbol, sym. It skips over type equivalences.
11815 : : It will not skip over base types.
11816 : : */
11817 : :
11818 : 6049785 : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym)
11819 : : {
11820 : : /*
11821 : : Assert (doGetType (sym, TRUE, TRUE, TRUE, FALSE) = GetLowestType (sym)) ;
11822 : : */
11823 : 6049785 : return doGetType (sym, true, true, true, false);
11824 : : /* static analysis guarentees a RETURN statement will be used before here. */
11825 : : __builtin_unreachable ();
11826 : : }
11827 : :
11828 : :
11829 : : /*
11830 : : GetSType - get source type. It returns the type closest
11831 : : to the object. It does not skip over type
11832 : : equivalences. It will skip over base types.
11833 : : */
11834 : :
11835 : 152482623 : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym)
11836 : : {
11837 : 152482623 : M2Debug_Assert ((doGetType (sym, false, false, false, true)) == (SymbolTable_GetType (sym)));
11838 : 152482623 : return doGetType (sym, false, false, false, true);
11839 : : /* static analysis guarentees a RETURN statement will be used before here. */
11840 : : __builtin_unreachable ();
11841 : : }
11842 : :
11843 : :
11844 : : /*
11845 : : GetDType - get gcc declared type. It returns the type
11846 : : of the object which is declared to GCC.
11847 : : It does skip over type equivalences but only
11848 : : if they do not contain a user alignment.
11849 : : It does not skip over hidden types.
11850 : : It does not skip over base types.
11851 : : */
11852 : :
11853 : 12042509 : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym)
11854 : : {
11855 : : /*
11856 : : Assert (doGetType (sym, TRUE, FALSE, FALSE, FALSE) = SkipType(GetType(sym))) ;
11857 : : */
11858 : 12042509 : return doGetType (sym, true, false, false, false);
11859 : : /* static analysis guarentees a RETURN statement will be used before here. */
11860 : : __builtin_unreachable ();
11861 : : }
11862 : :
11863 : :
11864 : : /*
11865 : : GetTypeMode - return the type of sym, it returns Address is the
11866 : : symbol is a LValue.
11867 : : */
11868 : :
11869 : 23396 : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym)
11870 : : {
11871 : 23396 : if ((SymbolTable_GetMode (sym)) == SymbolTable_LeftValue)
11872 : : {
11873 : 90 : return M2System_Address;
11874 : : }
11875 : : else
11876 : : {
11877 : 23306 : return SymbolTable_GetType (sym);
11878 : : }
11879 : : /* static analysis guarentees a RETURN statement will be used before here. */
11880 : : __builtin_unreachable ();
11881 : : }
11882 : :
11883 : :
11884 : : /*
11885 : : GetSym - searches the current scope (and previous scopes if the
11886 : : scope tranparent allows) for a symbol with name.
11887 : : */
11888 : :
11889 : 34797794 : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name)
11890 : : {
11891 : 34797794 : unsigned int Sym;
11892 : 34797794 : unsigned int OldScopePtr;
11893 : :
11894 : 34797794 : Sym = GetScopeSym (name, true);
11895 : 34797794 : if (Sym == SymbolTable_NulSym)
11896 : : {
11897 : : /* Check default base types for symbol */
11898 : 11340355 : OldScopePtr = ScopePtr; /* Save ScopePtr */
11899 : 11340355 : ScopePtr = BaseScopePtr; /* Alter ScopePtr to point to top of BaseModule */
11900 : 11340355 : Sym = GetScopeSym (name, false); /* Search BaseModule for name */
11901 : 11340355 : ScopePtr = OldScopePtr; /* Restored ScopePtr */
11902 : : }
11903 : 34797794 : return Sym;
11904 : : /* static analysis guarentees a RETURN statement will be used before here. */
11905 : : __builtin_unreachable ();
11906 : : }
11907 : :
11908 : :
11909 : : /*
11910 : : GetDeclareSym - searches for a symbol with a name SymName in the
11911 : : current and previous scopes.
11912 : : If the symbol is found then it is returned
11913 : : else an unknown symbol is returned.
11914 : : This procedure assumes that SymName is being
11915 : : declared at this point and therefore it does
11916 : : not examine the base scope (for pervasive
11917 : : identifiers).
11918 : : */
11919 : :
11920 : 5784822 : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName)
11921 : : {
11922 : 5784822 : unsigned int Sym;
11923 : :
11924 : 5784822 : Sym = GetScopeSym (SymName, false); /* must not be allowed to fetch a symbol through a procedure scope */
11925 : 5784822 : if (Sym == SymbolTable_NulSym) /* must not be allowed to fetch a symbol through a procedure scope */
11926 : : {
11927 : 2302769 : Sym = GetSymFromUnknownTree (SymName);
11928 : 2302769 : if (Sym == SymbolTable_NulSym)
11929 : : {
11930 : : /* Make unknown */
11931 : 2302769 : NewSym (&Sym);
11932 : 2302769 : FillInUnknownFields (tok, Sym, SymName);
11933 : : /*
11934 : : ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
11935 : : */
11936 : 2302769 : AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
11937 : : }
11938 : : }
11939 : 5784822 : return Sym;
11940 : : /* static analysis guarentees a RETURN statement will be used before here. */
11941 : : __builtin_unreachable ();
11942 : : }
11943 : :
11944 : :
11945 : : /*
11946 : : GetLocalSym - only searches the scope Sym for a symbol with name
11947 : : and returns the index to the symbol.
11948 : : */
11949 : :
11950 : 103139023 : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name)
11951 : : {
11952 : 103139023 : SymbolTable_PtrToSymbol pSym;
11953 : 103139023 : unsigned int LocalSym;
11954 : :
11955 : : /*
11956 : : WriteString('Attempting to retrieve symbol from ') ; WriteKey(GetSymName(Sym)) ;
11957 : : WriteString(' local symbol table') ; WriteLn ;
11958 : : */
11959 : 103139023 : pSym = GetPsym (Sym);
11960 : 103139023 : switch (pSym->SymbolType)
11961 : : {
11962 : 25640767 : case SymbolTable_EnumerationSym:
11963 : 25640767 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, name));
11964 : 25640767 : break;
11965 : :
11966 : 623434 : case SymbolTable_RecordSym:
11967 : 623434 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, name));
11968 : 623434 : break;
11969 : :
11970 : 25986889 : case SymbolTable_ProcedureSym:
11971 : 25986889 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, name));
11972 : 25986889 : break;
11973 : :
11974 : 12858879 : case SymbolTable_ModuleSym:
11975 : 12858879 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, name));
11976 : 12858879 : break;
11977 : :
11978 : 38029054 : case SymbolTable_DefImpSym:
11979 : 38029054 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, name));
11980 : 38029054 : break;
11981 : :
11982 : :
11983 : 0 : default:
11984 : 0 : M2Error_InternalError ((const char *) "symbol does not have a LocalSymbols field", 41);
11985 : 103139023 : break;
11986 : : }
11987 : 103139023 : return LocalSym;
11988 : : /* static analysis guarentees a RETURN statement will be used before here. */
11989 : : __builtin_unreachable ();
11990 : : }
11991 : :
11992 : :
11993 : : /*
11994 : : GetRecord - fetches the record symbol from the parent of Sym.
11995 : : Sym maybe a varient symbol in which case its parent is searched
11996 : : etc.
11997 : : */
11998 : :
11999 : 42862 : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym)
12000 : : {
12001 : 43642 : SymbolTable_PtrToSymbol pSym;
12002 : :
12003 : 43642 : pSym = GetPsym (Sym);
12004 : 43642 : switch (pSym->SymbolType)
12005 : : {
12006 : : case SymbolTable_RecordSym:
12007 : : return Sym;
12008 : 666 : break;
12009 : :
12010 : 666 : case SymbolTable_VarientSym:
12011 : 666 : return SymbolTable_GetRecord (pSym->Varient.Parent);
12012 : 114 : break;
12013 : :
12014 : 114 : case SymbolTable_VarientFieldSym:
12015 : 114 : return SymbolTable_GetRecord (pSym->VarientField.Parent);
12016 : 0 : break;
12017 : :
12018 : :
12019 : 0 : default:
12020 : 0 : M2Error_InternalError ((const char *) "expecting Record or Varient symbol", 34);
12021 : : break;
12022 : : }
12023 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12024 : : __builtin_unreachable ();
12025 : : }
12026 : :
12027 : :
12028 : : /*
12029 : : FromModuleGetSym - attempts to find a symbol of name, n, in the
12030 : : module, mod, scope. An unknown symbol is created
12031 : : at token position tok if necessary.
12032 : : */
12033 : :
12034 : 4825722 : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod)
12035 : : {
12036 : 4825722 : NameKey_Name n1;
12037 : 4825722 : unsigned int sym;
12038 : 4825722 : unsigned int OldScopePtr;
12039 : :
12040 : 4825722 : OldScopePtr = ScopePtr;
12041 : 4825722 : SymbolTable_StartScope (mod);
12042 : 4825722 : sym = SymbolTable_RequestSym (tok, n);
12043 : 4825722 : SymbolTable_EndScope ();
12044 : 4825722 : if (sym == SymbolTable_NulSym)
12045 : : {
12046 : : /* --fixme-- can sym ever be NulSym? */
12047 : 0 : n1 = SymbolTable_GetSymName (mod);
12048 : 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));
12049 : : }
12050 : 4825722 : ScopePtr = OldScopePtr;
12051 : 4825722 : return sym;
12052 : : /* static analysis guarentees a RETURN statement will be used before here. */
12053 : : __builtin_unreachable ();
12054 : : }
12055 : :
12056 : :
12057 : : /*
12058 : : GetNth - returns the n th symbol in the list associated with the scope
12059 : : of Sym. Sym may be a Module, DefImp, Procedure, Record or
12060 : : Enumeration symbol.
12061 : : */
12062 : :
12063 : 70505229 : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n)
12064 : : {
12065 : 70505229 : SymbolTable_PtrToSymbol pSym;
12066 : 70505229 : unsigned int i;
12067 : :
12068 : 70505229 : pSym = GetPsym (Sym);
12069 : 70505229 : switch (pSym->SymbolType)
12070 : : {
12071 : 52978590 : case SymbolTable_RecordSym:
12072 : 52978590 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, n));
12073 : 52978590 : break;
12074 : :
12075 : 83934 : case SymbolTable_VarientSym:
12076 : 83934 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Varient.ListOfSons, n));
12077 : 83934 : break;
12078 : :
12079 : 161586 : case SymbolTable_VarientFieldSym:
12080 : 161586 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->VarientField.ListOfSons, n));
12081 : 161586 : break;
12082 : :
12083 : 15787554 : case SymbolTable_ProcedureSym:
12084 : 15787554 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.ListOfVars, n));
12085 : 15787554 : break;
12086 : :
12087 : 198087 : case SymbolTable_DefImpSym:
12088 : 198087 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfVars, n));
12089 : 198087 : break;
12090 : :
12091 : 530682 : case SymbolTable_ModuleSym:
12092 : 530682 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfVars, n));
12093 : 530682 : break;
12094 : :
12095 : 6048 : case SymbolTable_TupleSym:
12096 : 6048 : i = GetFromIndex (pSym->Tuple.list, n);
12097 : 6048 : break;
12098 : :
12099 : 758730 : case SymbolTable_VarSym:
12100 : 758730 : i = GetNthFromComponent (Sym, n);
12101 : 758730 : break;
12102 : :
12103 : 18 : case SymbolTable_EnumerationSym:
12104 : 18 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Enumeration.ListOfFields, n));
12105 : 18 : break;
12106 : :
12107 : :
12108 : 0 : default:
12109 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
12110 : 70505229 : break;
12111 : : }
12112 : 70505229 : return i;
12113 : : /* static analysis guarentees a RETURN statement will be used before here. */
12114 : : __builtin_unreachable ();
12115 : : }
12116 : :
12117 : :
12118 : : /*
12119 : : GetNthParam - returns the n th parameter of a procedure Sym.
12120 : : */
12121 : :
12122 : 37825839 : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, unsigned int ParamNo)
12123 : : {
12124 : 37825839 : SymbolTable_PtrToSymbol pSym;
12125 : 37825839 : unsigned int i;
12126 : :
12127 : 37825839 : if (ParamNo == 0)
12128 : : {
12129 : : /* Demands the return type of the function */
12130 : 0 : i = SymbolTable_GetType (Sym);
12131 : : }
12132 : : else
12133 : : {
12134 : 37825839 : pSym = GetPsym (Sym);
12135 : 37825839 : switch (pSym->SymbolType)
12136 : : {
12137 : 33919687 : case SymbolTable_ProcedureSym:
12138 : 33919687 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.ListOfParam, ParamNo));
12139 : 33919687 : break;
12140 : :
12141 : 3906152 : case SymbolTable_ProcTypeSym:
12142 : 3906152 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, ParamNo));
12143 : 3906152 : break;
12144 : :
12145 : :
12146 : 0 : default:
12147 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym or ProcTypeSym", 37);
12148 : 37825839 : break;
12149 : : }
12150 : : }
12151 : 37825839 : return i;
12152 : : /* static analysis guarentees a RETURN statement will be used before here. */
12153 : : __builtin_unreachable ();
12154 : : }
12155 : :
12156 : :
12157 : : /*
12158 : : GetVarScope - returns the symbol which is the scope of variable Sym.
12159 : : ie a Module, DefImp or Procedure Symbol.
12160 : : */
12161 : :
12162 : 3034 : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym)
12163 : : {
12164 : 3034 : SymbolTable_PtrToSymbol pSym;
12165 : :
12166 : 3034 : pSym = GetPsym (Sym);
12167 : 3034 : switch (pSym->SymbolType)
12168 : : {
12169 : : case SymbolTable_ErrorSym:
12170 : : return SymbolTable_NulSym;
12171 : 3034 : break;
12172 : :
12173 : 3034 : case SymbolTable_VarSym:
12174 : 3034 : return pSym->Var.Scope;
12175 : 0 : break;
12176 : :
12177 : :
12178 : 0 : default:
12179 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
12180 : : break;
12181 : : }
12182 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12183 : : __builtin_unreachable ();
12184 : : }
12185 : :
12186 : :
12187 : : /*
12188 : : GetSubrange - returns HighSym and LowSym - two constants which make up the
12189 : : subrange.
12190 : : */
12191 : :
12192 : 11183532 : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym)
12193 : : {
12194 : 11183532 : SymbolTable_PtrToSymbol pSym;
12195 : :
12196 : 11183532 : pSym = GetPsym (Sym);
12197 : 11183532 : switch (pSym->SymbolType)
12198 : : {
12199 : 11183532 : case SymbolTable_SubrangeSym:
12200 : 11183532 : (*HighSym) = pSym->Subrange.High;
12201 : 11183532 : (*LowSym) = pSym->Subrange.Low;
12202 : 11183532 : break;
12203 : :
12204 : :
12205 : 0 : default:
12206 : 0 : M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
12207 : 11183532 : break;
12208 : : }
12209 : 11183532 : }
12210 : :
12211 : :
12212 : : /*
12213 : : GetParam - returns the ParamNo parameter from procedure ProcSym
12214 : : */
12215 : :
12216 : 8369743 : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo)
12217 : : {
12218 : 8369743 : CheckLegal (Sym);
12219 : 8369743 : if (ParamNo == 0)
12220 : : {
12221 : : /* Parameter Zero is the return argument for the Function */
12222 : 0 : return SymbolTable_GetType (Sym);
12223 : : }
12224 : : else
12225 : : {
12226 : 8369743 : return SymbolTable_GetNthParam (Sym, ParamNo);
12227 : : }
12228 : : /* static analysis guarentees a RETURN statement will be used before here. */
12229 : : __builtin_unreachable ();
12230 : : }
12231 : :
12232 : :
12233 : : /*
12234 : : GetString - returns the contents of the string symbol sym, note that
12235 : : this is not the same as GetName (unless it was a literal).
12236 : : */
12237 : :
12238 : 503004 : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym)
12239 : : {
12240 : 503004 : SymbolTable_PtrToSymbol pSym;
12241 : :
12242 : 503004 : pSym = GetPsym (Sym);
12243 : 503004 : switch (pSym->SymbolType)
12244 : : {
12245 : 503004 : case SymbolTable_ConstStringSym:
12246 : 503004 : if (pSym->ConstString.Known)
12247 : : {
12248 : 503004 : return pSym->ConstString.Contents;
12249 : : }
12250 : : else
12251 : : {
12252 : 0 : M2Error_InternalError ((const char *) "const string contents are unknown", 33);
12253 : : }
12254 : 0 : break;
12255 : :
12256 : :
12257 : 0 : default:
12258 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
12259 : : break;
12260 : : }
12261 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12262 : : __builtin_unreachable ();
12263 : : }
12264 : :
12265 : :
12266 : : /*
12267 : : GetStringLength - returns the length of the string symbol Sym.
12268 : : */
12269 : :
12270 : 1014551 : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym)
12271 : : {
12272 : 1014551 : SymbolTable_PtrToSymbol pSym;
12273 : :
12274 : 1014551 : pSym = GetPsym (sym);
12275 : 1014551 : switch (pSym->SymbolType)
12276 : : {
12277 : 1014551 : case SymbolTable_ConstStringSym:
12278 : 1014551 : if (pSym->ConstString.Known)
12279 : : {
12280 : 1014551 : return pSym->ConstString.Length;
12281 : : }
12282 : : else
12283 : : {
12284 : 0 : M2MetaError_MetaErrorT0 (tok, (const char *) "const string contents are unknown", 33);
12285 : 0 : return 0;
12286 : : }
12287 : 0 : break;
12288 : :
12289 : :
12290 : 0 : default:
12291 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
12292 : : break;
12293 : : }
12294 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12295 : : __builtin_unreachable ();
12296 : : }
12297 : :
12298 : :
12299 : : /*
12300 : : GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
12301 : : */
12302 : :
12303 : 8886 : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym)
12304 : : {
12305 : 8886 : SymbolTable_PtrToSymbol pSym;
12306 : :
12307 : 8886 : pSym = GetPsym (Sym);
12308 : 8886 : switch (pSym->SymbolType)
12309 : : {
12310 : 8886 : case SymbolTable_ProcedureSym:
12311 : 8886 : return pSym->Procedure.BuiltinName;
12312 : 0 : break;
12313 : :
12314 : :
12315 : 0 : default:
12316 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12317 : : break;
12318 : : }
12319 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12320 : : __builtin_unreachable ();
12321 : : }
12322 : :
12323 : :
12324 : : /*
12325 : : PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
12326 : : */
12327 : :
12328 : 92452 : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name)
12329 : : {
12330 : 92452 : SymbolTable_PtrToSymbol pSym;
12331 : :
12332 : 92452 : pSym = GetPsym (Sym);
12333 : 92452 : switch (pSym->SymbolType)
12334 : : {
12335 : 92452 : case SymbolTable_ProcedureSym:
12336 : 92452 : pSym->Procedure.BuiltinName = name;
12337 : 92452 : pSym->Procedure.IsBuiltin = true;
12338 : : /* we use the same extra pass method as hidden types for builtins */
12339 : 92452 : SymbolTable_PutHiddenTypeDeclared ();
12340 : 92452 : break;
12341 : :
12342 : :
12343 : 0 : default:
12344 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12345 : 92452 : break;
12346 : : }
12347 : 92452 : }
12348 : :
12349 : :
12350 : : /*
12351 : : IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
12352 : : */
12353 : :
12354 : 620063 : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym)
12355 : : {
12356 : 620063 : SymbolTable_PtrToSymbol pSym;
12357 : :
12358 : 620063 : pSym = GetPsym (Sym);
12359 : 620063 : switch (pSym->SymbolType)
12360 : : {
12361 : 620063 : case SymbolTable_ProcedureSym:
12362 : 620063 : return pSym->Procedure.IsBuiltin;
12363 : 0 : break;
12364 : :
12365 : :
12366 : 0 : default:
12367 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12368 : : break;
12369 : : }
12370 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12371 : : __builtin_unreachable ();
12372 : : }
12373 : :
12374 : :
12375 : : /*
12376 : : PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
12377 : : */
12378 : :
12379 : 0 : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym)
12380 : : {
12381 : 0 : SymbolTable_PtrToSymbol pSym;
12382 : :
12383 : 0 : pSym = GetPsym (Sym);
12384 : 0 : switch (pSym->SymbolType)
12385 : : {
12386 : 0 : case SymbolTable_ProcedureSym:
12387 : 0 : pSym->Procedure.IsInline = true;
12388 : 0 : break;
12389 : :
12390 : :
12391 : 0 : default:
12392 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12393 : 0 : break;
12394 : : }
12395 : 0 : }
12396 : :
12397 : 77479 : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym)
12398 : : {
12399 : 77479 : SymbolTable_PtrToSymbol pSym;
12400 : :
12401 : : /*
12402 : : IsProcedureBuiltin - returns TRUE if this procedure was declared as inlined.
12403 : : */
12404 : 77479 : pSym = GetPsym (Sym);
12405 : 77479 : switch (pSym->SymbolType)
12406 : : {
12407 : 77479 : case SymbolTable_ProcedureSym:
12408 : 77479 : return pSym->Procedure.IsInline;
12409 : 0 : break;
12410 : :
12411 : :
12412 : 0 : default:
12413 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12414 : : break;
12415 : : }
12416 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12417 : : __builtin_unreachable ();
12418 : : }
12419 : :
12420 : :
12421 : : /*
12422 : : PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
12423 : : sym, indicating that this block as an EXCEPT
12424 : : statement sequence.
12425 : : */
12426 : :
12427 : 180 : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym)
12428 : : {
12429 : 180 : SymbolTable_PtrToSymbol pSym;
12430 : :
12431 : 180 : pSym = GetPsym (sym);
12432 : 180 : switch (pSym->SymbolType)
12433 : : {
12434 : 132 : case SymbolTable_ProcedureSym:
12435 : 132 : pSym->Procedure.ExceptionBlock = true;
12436 : 132 : break;
12437 : :
12438 : 48 : case SymbolTable_ModuleSym:
12439 : 48 : pSym->Module.ExceptionBlock = true;
12440 : 48 : break;
12441 : :
12442 : 0 : case SymbolTable_DefImpSym:
12443 : 0 : pSym->DefImp.ExceptionBlock = true;
12444 : 0 : break;
12445 : :
12446 : :
12447 : 0 : default:
12448 : 0 : M2Error_InternalError ((const char *) "expecting Procedure", 19);
12449 : 180 : break;
12450 : : }
12451 : 180 : }
12452 : :
12453 : :
12454 : : /*
12455 : : HasExceptionBlock - returns a BOOLEAN determining whether
12456 : : module/procedure/defimp, sym, has
12457 : : an EXCEPT statement sequence.
12458 : : */
12459 : :
12460 : 283888 : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym)
12461 : : {
12462 : 283888 : SymbolTable_PtrToSymbol pSym;
12463 : :
12464 : 283888 : pSym = GetPsym (sym);
12465 : 283888 : switch (pSym->SymbolType)
12466 : : {
12467 : 157100 : case SymbolTable_ProcedureSym:
12468 : 157100 : return pSym->Procedure.ExceptionBlock;
12469 : 21308 : break;
12470 : :
12471 : 21308 : case SymbolTable_ModuleSym:
12472 : 21308 : return pSym->Module.ExceptionBlock;
12473 : 105480 : break;
12474 : :
12475 : 105480 : case SymbolTable_DefImpSym:
12476 : 105480 : return pSym->DefImp.ExceptionBlock;
12477 : 0 : break;
12478 : :
12479 : :
12480 : 0 : default:
12481 : 0 : M2Error_InternalError ((const char *) "expecting Procedure", 19);
12482 : : break;
12483 : : }
12484 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12485 : : __builtin_unreachable ();
12486 : : }
12487 : :
12488 : :
12489 : : /*
12490 : : PutExceptionFinally - sets a BOOLEAN in block module/defimp,
12491 : : sym, indicating that this FINALLY block
12492 : : as an EXCEPT statement sequence.
12493 : : */
12494 : :
12495 : 0 : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym)
12496 : : {
12497 : 0 : SymbolTable_PtrToSymbol pSym;
12498 : :
12499 : 0 : pSym = GetPsym (sym);
12500 : 0 : switch (pSym->SymbolType)
12501 : : {
12502 : 0 : case SymbolTable_ProcedureSym:
12503 : 0 : pSym->Procedure.ExceptionFinally = true;
12504 : 0 : break;
12505 : :
12506 : 0 : case SymbolTable_ModuleSym:
12507 : 0 : pSym->Module.ExceptionFinally = true;
12508 : 0 : break;
12509 : :
12510 : 0 : case SymbolTable_DefImpSym:
12511 : 0 : pSym->DefImp.ExceptionFinally = true;
12512 : 0 : break;
12513 : :
12514 : :
12515 : 0 : default:
12516 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
12517 : 0 : break;
12518 : : }
12519 : 0 : }
12520 : :
12521 : :
12522 : : /*
12523 : : HasExceptionFinally - returns a BOOLEAN determining whether
12524 : : module/defimp, sym, has
12525 : : an EXCEPT statement sequence.
12526 : : */
12527 : :
12528 : 34704 : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym)
12529 : : {
12530 : 34704 : SymbolTable_PtrToSymbol pSym;
12531 : :
12532 : 34704 : pSym = GetPsym (sym);
12533 : 34704 : switch (pSym->SymbolType)
12534 : : {
12535 : 0 : case SymbolTable_ProcedureSym:
12536 : 0 : return pSym->Procedure.ExceptionFinally;
12537 : 21260 : break;
12538 : :
12539 : 21260 : case SymbolTable_ModuleSym:
12540 : 21260 : return pSym->Module.ExceptionFinally;
12541 : 13444 : break;
12542 : :
12543 : 13444 : case SymbolTable_DefImpSym:
12544 : 13444 : return pSym->DefImp.ExceptionFinally;
12545 : 0 : break;
12546 : :
12547 : :
12548 : 0 : default:
12549 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
12550 : : break;
12551 : : }
12552 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12553 : : __builtin_unreachable ();
12554 : : }
12555 : :
12556 : :
12557 : : /*
12558 : : PutVar - gives the VarSym symbol Sym a type Type.
12559 : : */
12560 : :
12561 : 8338459 : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType)
12562 : : {
12563 : 8338459 : SymbolTable_PtrToSymbol pSym;
12564 : :
12565 : 8338459 : pSym = GetPsym (Sym);
12566 : 8338459 : switch (pSym->SymbolType)
12567 : : {
12568 : 7500935 : case SymbolTable_VarSym:
12569 : 7500935 : pSym->Var.Type = VarType;
12570 : 7500935 : M2SymInit_ConfigSymInit (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue], Sym);
12571 : 7500935 : M2SymInit_ConfigSymInit (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue], Sym);
12572 : 7500935 : break;
12573 : :
12574 : 837518 : case SymbolTable_ConstVarSym:
12575 : 837518 : pSym->ConstVar.Type = VarType;
12576 : 837518 : break;
12577 : :
12578 : :
12579 : 6 : default:
12580 : 6 : M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
12581 : 8338453 : break;
12582 : : }
12583 : 8338453 : }
12584 : :
12585 : :
12586 : : /*
12587 : : PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
12588 : : The variable must be a LeftValue.
12589 : : */
12590 : :
12591 : 67750 : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType)
12592 : : {
12593 : 67750 : SymbolTable_PtrToSymbol pSym;
12594 : :
12595 : 67750 : M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue);
12596 : 67750 : pSym = GetPsym (Sym);
12597 : 67750 : switch (pSym->SymbolType)
12598 : : {
12599 : 67750 : case SymbolTable_VarSym:
12600 : 67750 : pSym->Var.Type = FrontType;
12601 : 67750 : pSym->Var.BackType = BackType;
12602 : 67750 : SymbolTable_PushSize (M2System_Address);
12603 : 67750 : M2ALU_PopInto (pSym->Var.Size);
12604 : 67750 : break;
12605 : :
12606 : :
12607 : 0 : default:
12608 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
12609 : 67750 : break;
12610 : : }
12611 : 67750 : }
12612 : :
12613 : :
12614 : : /*
12615 : : GetVarBackEndType - returns the back end type if specified.
12616 : : */
12617 : :
12618 : 1642722 : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym)
12619 : : {
12620 : 1642722 : SymbolTable_PtrToSymbol pSym;
12621 : :
12622 : 1642722 : M2Debug_Assert (Sym != SymbolTable_NulSym);
12623 : 1642722 : pSym = GetPsym (Sym);
12624 : 1642722 : switch (pSym->SymbolType)
12625 : : {
12626 : 1642722 : case SymbolTable_VarSym:
12627 : 1642722 : return pSym->Var.BackType;
12628 : : break;
12629 : :
12630 : :
12631 : : default:
12632 : : return SymbolTable_NulSym;
12633 : : break;
12634 : : }
12635 : : /* static analysis guarentees a RETURN statement will be used before here. */
12636 : : __builtin_unreachable ();
12637 : : }
12638 : :
12639 : :
12640 : : /*
12641 : : PutVarPointerCheck - marks variable, sym, as requiring (or not
12642 : : depending upon the, value), a NIL pointer check
12643 : : when this symbol is dereferenced.
12644 : : */
12645 : :
12646 : 31048 : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value)
12647 : : {
12648 : 31048 : SymbolTable_PtrToSymbol pSym;
12649 : :
12650 : 31048 : if (SymbolTable_IsVar (sym))
12651 : : {
12652 : 31042 : pSym = GetPsym (sym);
12653 : 31042 : pSym->Var.IsPointerCheck = value;
12654 : : }
12655 : 31048 : }
12656 : :
12657 : :
12658 : : /*
12659 : : GetVarPointerCheck - returns TRUE if this symbol is a variable and
12660 : : has been marked as needing a pointer via NIL check.
12661 : : */
12662 : :
12663 : 67910 : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym)
12664 : : {
12665 : 67910 : SymbolTable_PtrToSymbol pSym;
12666 : :
12667 : 67910 : if (SymbolTable_IsVar (sym))
12668 : : {
12669 : 67910 : pSym = GetPsym (sym);
12670 : 67910 : return pSym->Var.IsPointerCheck;
12671 : : }
12672 : : return false;
12673 : : /* static analysis guarentees a RETURN statement will be used before here. */
12674 : : __builtin_unreachable ();
12675 : : }
12676 : :
12677 : :
12678 : : /*
12679 : : PutVarWritten - marks variable, sym, as being written to (or not
12680 : : depending upon the, value).
12681 : : */
12682 : :
12683 : 12385 : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value)
12684 : : {
12685 : 12385 : SymbolTable_PtrToSymbol pSym;
12686 : :
12687 : 12385 : if (SymbolTable_IsVar (sym))
12688 : : {
12689 : 12385 : pSym = GetPsym (sym);
12690 : 12385 : pSym->Var.IsWritten = value;
12691 : : }
12692 : 12385 : }
12693 : :
12694 : :
12695 : : /*
12696 : : GetVarWritten - returns TRUE if this symbol is a variable and
12697 : : has been marked as being written.
12698 : : */
12699 : :
12700 : 81498 : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym)
12701 : : {
12702 : 81498 : SymbolTable_PtrToSymbol pSym;
12703 : :
12704 : 81498 : pSym = GetPsym (sym);
12705 : 81498 : switch (pSym->SymbolType)
12706 : : {
12707 : 81498 : case SymbolTable_VarSym:
12708 : 81498 : return pSym->Var.IsWritten;
12709 : 0 : break;
12710 : :
12711 : :
12712 : 0 : default:
12713 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
12714 : : break;
12715 : : }
12716 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12717 : : __builtin_unreachable ();
12718 : : }
12719 : :
12720 : :
12721 : : /*
12722 : : PutConst - gives the constant symbol Sym a type ConstType.
12723 : : */
12724 : :
12725 : 308090 : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType)
12726 : : {
12727 : 308090 : SymbolTable_PtrToSymbol pSym;
12728 : :
12729 : 308090 : pSym = GetPsym (Sym);
12730 : 308090 : switch (pSym->SymbolType)
12731 : : {
12732 : 308090 : case SymbolTable_ConstVarSym:
12733 : 308090 : pSym->ConstVar.Type = ConstType;
12734 : 308090 : break;
12735 : :
12736 : :
12737 : 0 : default:
12738 : 0 : M2Error_InternalError ((const char *) "expecting ConstVarSym", 21);
12739 : 308090 : break;
12740 : : }
12741 : 308090 : }
12742 : :
12743 : :
12744 : : /*
12745 : : PutConstSet - informs the const var symbol, sym, that it is or will contain
12746 : : a set value.
12747 : : */
12748 : :
12749 : 31396 : extern "C" void SymbolTable_PutConstSet (unsigned int Sym)
12750 : : {
12751 : 31396 : SymbolTable_PtrToSymbol pSym;
12752 : :
12753 : 31396 : pSym = GetPsym (Sym);
12754 : 31396 : switch (pSym->SymbolType)
12755 : : {
12756 : 31396 : case SymbolTable_ConstVarSym:
12757 : 31396 : pSym->ConstVar.IsSet = true;
12758 : 31396 : break;
12759 : :
12760 : 0 : case SymbolTable_ConstLitSym:
12761 : 0 : pSym->ConstLit.IsSet = true;
12762 : 0 : break;
12763 : :
12764 : :
12765 : 0 : default:
12766 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar symbol", 25);
12767 : 31396 : break;
12768 : : }
12769 : 31396 : }
12770 : :
12771 : :
12772 : : /*
12773 : : IsConstSet - returns TRUE if the constant is declared as a set.
12774 : : */
12775 : :
12776 : 24288356 : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym)
12777 : : {
12778 : 24288356 : SymbolTable_PtrToSymbol pSym;
12779 : :
12780 : 24288356 : pSym = GetPsym (Sym);
12781 : 24288356 : switch (pSym->SymbolType)
12782 : : {
12783 : 4107017 : case SymbolTable_ConstVarSym:
12784 : 4107017 : return pSym->ConstVar.IsSet;
12785 : 6411940 : break;
12786 : :
12787 : 6411940 : case SymbolTable_ConstLitSym:
12788 : 6411940 : return pSym->ConstLit.IsSet;
12789 : : break;
12790 : :
12791 : :
12792 : : default:
12793 : : return false;
12794 : : break;
12795 : : }
12796 : : /* static analysis guarentees a RETURN statement will be used before here. */
12797 : : __builtin_unreachable ();
12798 : : }
12799 : :
12800 : :
12801 : : /*
12802 : : PutConstructor - informs the const var symbol, sym, that it is or
12803 : : will contain a constructor (record, set or array)
12804 : : value.
12805 : : */
12806 : :
12807 : 24620 : extern "C" void SymbolTable_PutConstructor (unsigned int Sym)
12808 : : {
12809 : 24620 : SymbolTable_PtrToSymbol pSym;
12810 : :
12811 : 24620 : pSym = GetPsym (Sym);
12812 : 24620 : switch (pSym->SymbolType)
12813 : : {
12814 : 24620 : case SymbolTable_ConstVarSym:
12815 : 24620 : pSym->ConstVar.IsConstructor = true;
12816 : 24620 : break;
12817 : :
12818 : 0 : case SymbolTable_ConstLitSym:
12819 : 0 : pSym->ConstLit.IsConstructor = true;
12820 : 0 : break;
12821 : :
12822 : :
12823 : 0 : default:
12824 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
12825 : 24620 : break;
12826 : : }
12827 : 24620 : }
12828 : :
12829 : :
12830 : : /*
12831 : : PutConstructorFrom - sets the from type field in constructor,
12832 : : Sym, to, from.
12833 : : */
12834 : :
12835 : 20686 : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from)
12836 : : {
12837 : 20686 : SymbolTable_PtrToSymbol pSym;
12838 : :
12839 : 20686 : pSym = GetPsym (Sym);
12840 : 20686 : switch (pSym->SymbolType)
12841 : : {
12842 : 20686 : case SymbolTable_ConstVarSym:
12843 : 20686 : pSym->ConstVar.FromType = from;
12844 : 20686 : pSym->ConstVar.UnresFromType = true;
12845 : 20686 : break;
12846 : :
12847 : 0 : case SymbolTable_ConstLitSym:
12848 : 0 : pSym->ConstLit.FromType = from;
12849 : 0 : pSym->ConstLit.UnresFromType = true;
12850 : 0 : break;
12851 : :
12852 : :
12853 : 0 : default:
12854 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
12855 : 20686 : break;
12856 : : }
12857 : 20686 : Lists_IncludeItemIntoList (UnresolvedConstructorType, Sym);
12858 : 20686 : }
12859 : :
12860 : :
12861 : : /*
12862 : : PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
12863 : : VarSym is a optional varient symbol which can be returned
12864 : : by a call to GetVarient(fieldsymbol). The created field
12865 : : is returned.
12866 : : */
12867 : :
12868 : 323514 : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym)
12869 : : {
12870 : 323514 : SymbolTable_PtrToSymbol oSym;
12871 : 323514 : SymbolTable_PtrToSymbol pSym;
12872 : 323514 : unsigned int esym;
12873 : 323514 : unsigned int ParSym;
12874 : 323514 : unsigned int SonSym;
12875 : :
12876 : 323514 : NewSym (&SonSym); /* Cannot be used before declared since use occurs */
12877 : : /* ensure that it is connected its parent. */
12878 : 323514 : pSym = GetPsym (Sym);
12879 : 323514 : switch (pSym->SymbolType)
12880 : : {
12881 : 322848 : case SymbolTable_RecordSym:
12882 : 322848 : Lists_PutItemIntoList (pSym->Record.ListOfSons, SonSym);
12883 : 322848 : M2Debug_Assert (Lists_IsItemInList (pSym->Record.ListOfSons, SonSym));
12884 : : /* Ensure that the Field is in the Parents Local Symbols */
12885 : 322848 : if (FieldName != NameKey_NulName)
12886 : : {
12887 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
12888 : 322818 : if ((SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName)) == SymbolKey_NulKey)
12889 : : {
12890 : 322818 : SymbolKey_PutSymKey (pSym->Record.LocalSymbols, FieldName, SonSym);
12891 : : }
12892 : : else
12893 : : {
12894 : 0 : esym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName));
12895 : 0 : M2MetaError_MetaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, esym);
12896 : : }
12897 : : }
12898 : : CheckRecordConsistency (Sym);
12899 : : break;
12900 : :
12901 : 666 : case SymbolTable_VarientFieldSym:
12902 : 666 : Lists_PutItemIntoList (pSym->VarientField.ListOfSons, SonSym);
12903 : 666 : ParSym = SymbolTable_GetRecord (pSym->VarientField.Parent);
12904 : 666 : oSym = GetPsym (ParSym);
12905 : 666 : M2Debug_Assert (oSym->SymbolType == SymbolTable_RecordSym);
12906 : 666 : if (FieldName != NameKey_NulName)
12907 : : {
12908 : 654 : oSym = GetPsym (ParSym);
12909 : 654 : SymbolKey_PutSymKey (oSym->Record.LocalSymbols, FieldName, SonSym);
12910 : : }
12911 : : break;
12912 : :
12913 : :
12914 : 0 : default:
12915 : 0 : M2Error_InternalError ((const char *) "expecting Record symbol", 23);
12916 : 323514 : break;
12917 : : }
12918 : : /* Fill in SonSym */
12919 : 323514 : oSym = GetPsym (SonSym);
12920 : 323514 : oSym->SymbolType = SymbolTable_RecordFieldSym;
12921 : 323514 : oSym->RecordField.Type = FieldType;
12922 : 323514 : oSym->RecordField.name = FieldName;
12923 : 323514 : oSym->RecordField.Tag = false;
12924 : 323514 : oSym->RecordField.Parent = Sym;
12925 : 323514 : oSym->RecordField.Varient = VarSym;
12926 : 323514 : oSym->RecordField.Align = SymbolTable_NulSym;
12927 : 323514 : oSym->RecordField.Used = true;
12928 : 323514 : oSym->RecordField.DeclPacked = false; /* not known as packed (yet). */
12929 : 323514 : oSym->RecordField.DeclResolved = false; /* not known as packed (yet). */
12930 : 323514 : oSym->RecordField.Scope = SymbolTable_GetScope (Sym);
12931 : 323514 : oSym->RecordField.Size = M2ALU_InitValue ();
12932 : 323514 : oSym->RecordField.Offset = M2ALU_InitValue ();
12933 : 323514 : InitWhereDeclared (&oSym->RecordField.At);
12934 : 323514 : return SonSym;
12935 : : /* static analysis guarentees a RETURN statement will be used before here. */
12936 : : __builtin_unreachable ();
12937 : : }
12938 : :
12939 : :
12940 : : /*
12941 : : PutFieldVarient - places the field varient, Field, as a brother to, the
12942 : : varient symbol, sym, and also tells Field that its varient
12943 : : parent is Sym.
12944 : : */
12945 : :
12946 : 1236 : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym)
12947 : : {
12948 : 1236 : SymbolTable_PtrToSymbol pSym;
12949 : :
12950 : 1236 : M2Debug_Assert (SymbolTable_IsVarient (Sym));
12951 : 1236 : M2Debug_Assert (SymbolTable_IsFieldVarient (Field));
12952 : 1236 : pSym = GetPsym (Sym);
12953 : 1236 : switch (pSym->SymbolType)
12954 : : {
12955 : 1236 : case SymbolTable_VarientSym:
12956 : 1236 : Lists_IncludeItemIntoList (pSym->Varient.ListOfSons, Field);
12957 : 1236 : break;
12958 : :
12959 : :
12960 : 0 : default:
12961 : 0 : M2Error_InternalError ((const char *) "expecting Varient symbol", 24);
12962 : 1236 : break;
12963 : : }
12964 : 1236 : pSym = GetPsym (Field);
12965 : 1236 : switch (pSym->SymbolType)
12966 : : {
12967 : 1236 : case SymbolTable_VarientFieldSym:
12968 : 1236 : pSym->VarientField.Varient = Sym;
12969 : 1236 : break;
12970 : :
12971 : :
12972 : 0 : default:
12973 : 0 : M2Error_InternalError ((const char *) "expecting VarientField symbol", 29);
12974 : 1236 : break;
12975 : : }
12976 : 1236 : }
12977 : :
12978 : :
12979 : : /*
12980 : : GetVarient - returns the varient symbol associated with the
12981 : : record or varient field symbol, Field.
12982 : : */
12983 : :
12984 : 40160666 : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field)
12985 : : {
12986 : 40160666 : SymbolTable_PtrToSymbol pSym;
12987 : :
12988 : 40160666 : pSym = GetPsym (Field);
12989 : 40160666 : switch (pSym->SymbolType)
12990 : : {
12991 : 0 : case SymbolTable_VarientFieldSym:
12992 : 0 : return pSym->VarientField.Varient;
12993 : 40149254 : break;
12994 : :
12995 : 40149254 : case SymbolTable_RecordFieldSym:
12996 : 40149254 : return pSym->RecordField.Varient;
12997 : 11412 : break;
12998 : :
12999 : 11412 : case SymbolTable_VarientSym:
13000 : 11412 : return pSym->Varient.Varient;
13001 : : break;
13002 : :
13003 : :
13004 : : default:
13005 : : return SymbolTable_NulSym;
13006 : : break;
13007 : : }
13008 : : /* static analysis guarentees a RETURN statement will be used before here. */
13009 : : __builtin_unreachable ();
13010 : : }
13011 : :
13012 : :
13013 : : /*
13014 : : IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
13015 : : a varient tag.
13016 : : */
13017 : :
13018 : 4419291 : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym)
13019 : : {
13020 : 4419291 : SymbolTable_PtrToSymbol pSym;
13021 : :
13022 : 4419291 : if (SymbolTable_IsRecordField (sym))
13023 : : {
13024 : 4419291 : pSym = GetPsym (sym);
13025 : 4419291 : return pSym->RecordField.Tag;
13026 : : }
13027 : : else
13028 : : {
13029 : 0 : M2Error_InternalError ((const char *) "record field symbol expected", 28);
13030 : : }
13031 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13032 : : __builtin_unreachable ();
13033 : : }
13034 : :
13035 : :
13036 : : /*
13037 : : IsEmptyFieldVarient - returns TRUE if the field variant has
13038 : : no fields. This will occur then the
13039 : : compiler constructs 'else end' variants.
13040 : : */
13041 : :
13042 : 0 : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym)
13043 : : {
13044 : 0 : SymbolTable_PtrToSymbol pSym;
13045 : :
13046 : 0 : pSym = GetPsym (sym);
13047 : 0 : switch (pSym->SymbolType)
13048 : : {
13049 : 0 : case SymbolTable_VarientFieldSym:
13050 : 0 : return (Lists_NoOfItemsInList (pSym->VarientField.ListOfSons)) == 0;
13051 : 0 : break;
13052 : :
13053 : :
13054 : 0 : default:
13055 : 0 : M2Error_InternalError ((const char *) "varient field symbol expected", 29);
13056 : : break;
13057 : : }
13058 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13059 : : __builtin_unreachable ();
13060 : : }
13061 : :
13062 : :
13063 : : /*
13064 : : GetVarientTag - returns the varient tag from, Sym.
13065 : : */
13066 : :
13067 : 654 : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym)
13068 : : {
13069 : 654 : SymbolTable_PtrToSymbol pSym;
13070 : :
13071 : 654 : pSym = GetPsym (Sym);
13072 : 654 : switch (pSym->SymbolType)
13073 : : {
13074 : 654 : case SymbolTable_VarientSym:
13075 : 654 : return pSym->Varient.tag;
13076 : 0 : break;
13077 : :
13078 : :
13079 : 0 : default:
13080 : 0 : M2Error_InternalError ((const char *) "varient symbol expected", 23);
13081 : : break;
13082 : : }
13083 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13084 : : __builtin_unreachable ();
13085 : : }
13086 : :
13087 : :
13088 : : /*
13089 : : PutVarientTag - places, Tag, into varient, Sym.
13090 : : */
13091 : :
13092 : 276 : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag)
13093 : : {
13094 : 276 : SymbolTable_PtrToSymbol pSym;
13095 : 276 : unsigned int parent;
13096 : :
13097 : 276 : pSym = GetPsym (Sym);
13098 : 276 : switch (pSym->SymbolType)
13099 : : {
13100 : 276 : case SymbolTable_VarientSym:
13101 : 276 : pSym->Varient.tag = Tag;
13102 : 276 : break;
13103 : :
13104 : :
13105 : 0 : default:
13106 : 0 : M2Error_InternalError ((const char *) "varient symbol expected", 23);
13107 : 276 : break;
13108 : : }
13109 : : /* now ensure that if Tag is a RecordField then it must be
13110 : : placed before the varient symbol in its parent ListOfSons.
13111 : : This allows M2GCCDeclare to declare record fields in order
13112 : : and preserve the order of fields. Otherwise it will add the
13113 : : tag field after the C union. */
13114 : 276 : if (SymbolTable_IsRecordField (Tag))
13115 : : {
13116 : 264 : pSym = GetPsym (Tag);
13117 : 264 : pSym->RecordField.Tag = true;
13118 : 264 : parent = SymbolTable_GetParent (Sym);
13119 : 264 : pSym = GetPsym (parent);
13120 : 264 : switch (pSym->SymbolType)
13121 : : {
13122 : : case SymbolTable_ErrorSym:
13123 : : break;
13124 : :
13125 : 0 : case SymbolTable_VarientSym:
13126 : 0 : EnsureOrder (pSym->Varient.ListOfSons, Tag, Sym);
13127 : 0 : break;
13128 : :
13129 : 36 : case SymbolTable_VarientFieldSym:
13130 : 36 : EnsureOrder (pSym->VarientField.ListOfSons, Tag, Sym);
13131 : 36 : break;
13132 : :
13133 : 228 : case SymbolTable_RecordSym:
13134 : 228 : EnsureOrder (pSym->Record.ListOfSons, Tag, Sym);
13135 : 228 : CheckRecordConsistency (parent);
13136 : 228 : break;
13137 : :
13138 : :
13139 : 0 : default:
13140 : 0 : M2Error_InternalError ((const char *) "not expecting this symbol type", 30);
13141 : : break;
13142 : : }
13143 : : }
13144 : 276 : }
13145 : :
13146 : :
13147 : : /*
13148 : : PutFieldEnumeration - places a field into the enumeration type
13149 : : Sym. The field has a name FieldName and a
13150 : : value FieldVal.
13151 : : */
13152 : :
13153 : 427347 : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName)
13154 : : {
13155 : 427347 : SymbolTable_PtrToSymbol oSym;
13156 : 427347 : SymbolTable_PtrToSymbol pSym;
13157 : 427347 : DynamicStrings_String s;
13158 : 427347 : unsigned int Field;
13159 : :
13160 : 427347 : Field = CheckForHiddenType (FieldName);
13161 : 427347 : if (Field == SymbolTable_NulSym)
13162 : : {
13163 : 427347 : Field = DeclareSym (tok, FieldName);
13164 : : }
13165 : 427347 : if (! (SymbolTable_IsError (Field)))
13166 : : {
13167 : 427341 : pSym = GetPsym (Field);
13168 : 427341 : pSym->SymbolType = SymbolTable_EnumerationFieldSym;
13169 : 427341 : pSym->EnumerationField.name = FieldName; /* Index into name array, name */
13170 : : /* of type. */
13171 : 427341 : oSym = GetPsym (Sym);
13172 : 427341 : M2ALU_PushCard (oSym->Enumeration.NoOfElements);
13173 : 427341 : pSym->EnumerationField.Value = M2ALU_InitValue ();
13174 : 427341 : M2ALU_PopInto (pSym->EnumerationField.Value);
13175 : 427341 : pSym->EnumerationField.Type = Sym;
13176 : 427341 : pSym->EnumerationField.Scope = SymbolTable_GetCurrentScope ();
13177 : 427341 : InitWhereDeclaredTok (tok, &pSym->EnumerationField.At); /* Declared here */
13178 : 427341 : pSym = GetPsym (Sym);
13179 : 427341 : switch (pSym->SymbolType)
13180 : : {
13181 : 427341 : case SymbolTable_EnumerationSym:
13182 : 427341 : pSym->Enumeration.NoOfElements += 1;
13183 : 427341 : if ((SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, FieldName)) != SymbolTable_NulSym)
13184 : : {
13185 : 0 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (FieldName)));
13186 : 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)));
13187 : : }
13188 : : else
13189 : : {
13190 : 427341 : SymbolKey_PutSymKey (pSym->Enumeration.LocalSymbols, FieldName, Field);
13191 : 427341 : Lists_IncludeItemIntoList (pSym->Enumeration.ListOfFields, Field);
13192 : : }
13193 : : break;
13194 : :
13195 : :
13196 : 0 : default:
13197 : 0 : M2Error_InternalError ((const char *) "expecting Sym=Enumeration", 25);
13198 : : break;
13199 : : }
13200 : : }
13201 : 427347 : }
13202 : :
13203 : :
13204 : : /*
13205 : : PutSubrange - places LowSym and HighSym as two symbols
13206 : : which provide the limits of the range.
13207 : : */
13208 : :
13209 : 172150 : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol)
13210 : : {
13211 : 172150 : SymbolTable_PtrToSymbol pSym;
13212 : :
13213 : 172150 : pSym = GetPsym (Sym);
13214 : 172150 : switch (pSym->SymbolType)
13215 : : {
13216 : 172150 : case SymbolTable_SubrangeSym:
13217 : 172150 : pSym->Subrange.Low = LowSym; /* Index to symbol for lower */
13218 : 172150 : pSym->Subrange.High = HighSym; /* Index to symbol for higher */
13219 : 172150 : pSym->Subrange.Type = TypeSymbol; /* Index to type symbol for */
13220 : 172150 : break;
13221 : :
13222 : :
13223 : 0 : default:
13224 : : /* the type of subrange. */
13225 : 0 : M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
13226 : 172150 : break;
13227 : : }
13228 : 172150 : }
13229 : :
13230 : :
13231 : : /*
13232 : : PutSet - places SimpleType as the type for set, Sym.
13233 : : */
13234 : :
13235 : 69147 : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed)
13236 : : {
13237 : 69147 : SymbolTable_PtrToSymbol pSym;
13238 : :
13239 : 69147 : pSym = GetPsym (Sym);
13240 : 69147 : switch (pSym->SymbolType)
13241 : : {
13242 : : case SymbolTable_ErrorSym:
13243 : : break;
13244 : :
13245 : 69147 : case SymbolTable_SetSym:
13246 : 69147 : pSym->Set.Type = SimpleType; /* Index to a subrange symbol */
13247 : : /* or an enumeration type. */
13248 : 69147 : pSym->Set.ispacked = packed;
13249 : 69147 : break;
13250 : :
13251 : :
13252 : 0 : default:
13253 : 0 : M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
13254 : 69147 : break;
13255 : : }
13256 : 69147 : }
13257 : :
13258 : :
13259 : : /*
13260 : : IsSetPacked - returns TRUE if Sym is packed.
13261 : : */
13262 : :
13263 : 1831 : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym)
13264 : : {
13265 : 1831 : SymbolTable_PtrToSymbol pSym;
13266 : :
13267 : 1831 : CheckLegal (Sym);
13268 : 1831 : pSym = GetPsym (Sym);
13269 : 1831 : return (pSym->SymbolType == SymbolTable_SetSym) && pSym->Set.ispacked;
13270 : : /* static analysis guarentees a RETURN statement will be used before here. */
13271 : : __builtin_unreachable ();
13272 : : }
13273 : :
13274 : :
13275 : : /*
13276 : : GetArraySubscript - returns the subscript symbol for array, Sym.
13277 : : */
13278 : :
13279 : 2939701 : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym)
13280 : : {
13281 : 2939701 : SymbolTable_PtrToSymbol pSym;
13282 : :
13283 : 2939701 : pSym = GetPsym (Sym);
13284 : 2939701 : switch (pSym->SymbolType)
13285 : : {
13286 : : case SymbolTable_ErrorSym:
13287 : : return SymbolTable_NulSym;
13288 : 2939701 : break;
13289 : :
13290 : 2939701 : case SymbolTable_ArraySym:
13291 : 2939701 : return pSym->Array.Subscript;
13292 : 0 : break;
13293 : :
13294 : :
13295 : 0 : default:
13296 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
13297 : : break;
13298 : : }
13299 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13300 : : __builtin_unreachable ();
13301 : : }
13302 : :
13303 : :
13304 : : /*
13305 : : PutArraySubscript - places an index field into the array Sym. The
13306 : : index field is a subscript sym.
13307 : : */
13308 : :
13309 : 82680 : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol)
13310 : : {
13311 : 82680 : SymbolTable_PtrToSymbol pSym;
13312 : :
13313 : 82680 : pSym = GetPsym (Sym);
13314 : 82680 : switch (pSym->SymbolType)
13315 : : {
13316 : : case SymbolTable_ErrorSym:
13317 : : break;
13318 : :
13319 : 82680 : case SymbolTable_ArraySym:
13320 : 82680 : pSym->Array.Subscript = SubscriptSymbol;
13321 : 82680 : break;
13322 : :
13323 : :
13324 : 0 : default:
13325 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
13326 : 82680 : break;
13327 : : }
13328 : 82680 : }
13329 : :
13330 : :
13331 : : /*
13332 : : PutType - gives a type symbol Sym type TypeSymbol.
13333 : : */
13334 : :
13335 : 654251 : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol)
13336 : : {
13337 : 654251 : SymbolTable_PtrToSymbol pSym;
13338 : :
13339 : 654251 : if (TypeSymbol == Sym)
13340 : : {
13341 : 0 : M2Error_InternalError ((const char *) "not expecting a type to be declared as itself", 45);
13342 : : }
13343 : 654251 : pSym = GetPsym (Sym);
13344 : 654251 : switch (pSym->SymbolType)
13345 : : {
13346 : : case SymbolTable_ErrorSym:
13347 : : break;
13348 : :
13349 : 654251 : case SymbolTable_TypeSym:
13350 : 654251 : pSym->Type.Type = TypeSymbol;
13351 : 654251 : break;
13352 : :
13353 : :
13354 : 0 : default:
13355 : 0 : M2Error_InternalError ((const char *) "expecting a Type symbol", 23);
13356 : 654251 : break;
13357 : : }
13358 : 654251 : }
13359 : :
13360 : :
13361 : : /*
13362 : : PutFunction - Places a TypeSym as the return type to a procedure Sym.
13363 : : */
13364 : :
13365 : 1602923 : extern "C" void SymbolTable_PutFunction (unsigned int Sym, unsigned int TypeSym)
13366 : : {
13367 : 1602923 : SymbolTable_PtrToSymbol pSym;
13368 : :
13369 : 1602923 : pSym = GetPsym (Sym);
13370 : 1602923 : switch (pSym->SymbolType)
13371 : : {
13372 : : case SymbolTable_ErrorSym:
13373 : : break;
13374 : :
13375 : 1596001 : case SymbolTable_ProcedureSym:
13376 : 1596001 : CheckOptFunction (Sym, false);
13377 : 1596001 : pSym->Procedure.ReturnType = TypeSym;
13378 : 1596001 : break;
13379 : :
13380 : 6922 : case SymbolTable_ProcTypeSym:
13381 : 6922 : CheckOptFunction (Sym, false);
13382 : 6922 : pSym->ProcType.ReturnType = TypeSym;
13383 : 6922 : break;
13384 : :
13385 : :
13386 : 0 : default:
13387 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
13388 : 1602923 : break;
13389 : : }
13390 : 1602923 : }
13391 : :
13392 : :
13393 : : /*
13394 : : PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
13395 : : */
13396 : :
13397 : 117420 : extern "C" void SymbolTable_PutOptFunction (unsigned int Sym, unsigned int TypeSym)
13398 : : {
13399 : 117420 : SymbolTable_PtrToSymbol pSym;
13400 : :
13401 : 117420 : pSym = GetPsym (Sym);
13402 : 117420 : switch (pSym->SymbolType)
13403 : : {
13404 : : case SymbolTable_ErrorSym:
13405 : : break;
13406 : :
13407 : 117420 : case SymbolTable_ProcedureSym:
13408 : 117420 : CheckOptFunction (Sym, true);
13409 : 117420 : pSym->Procedure.ReturnType = TypeSym;
13410 : 117420 : break;
13411 : :
13412 : 0 : case SymbolTable_ProcTypeSym:
13413 : 0 : CheckOptFunction (Sym, true);
13414 : 0 : pSym->ProcType.ReturnType = TypeSym;
13415 : 0 : break;
13416 : :
13417 : :
13418 : 0 : default:
13419 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
13420 : 117420 : break;
13421 : : }
13422 : 117420 : }
13423 : :
13424 : :
13425 : : /*
13426 : : IsReturnOptional - returns TRUE if the return value for, sym, is
13427 : : optional.
13428 : : */
13429 : :
13430 : 473899 : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym)
13431 : : {
13432 : 473899 : SymbolTable_PtrToSymbol pSym;
13433 : :
13434 : 473899 : pSym = GetPsym (sym);
13435 : 473899 : switch (pSym->SymbolType)
13436 : : {
13437 : 473899 : case SymbolTable_ProcedureSym:
13438 : 473899 : return pSym->Procedure.ReturnOptional;
13439 : 0 : break;
13440 : :
13441 : 0 : case SymbolTable_ProcTypeSym:
13442 : 0 : return pSym->ProcType.ReturnOptional;
13443 : 0 : break;
13444 : :
13445 : :
13446 : 0 : default:
13447 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
13448 : : break;
13449 : : }
13450 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13451 : : __builtin_unreachable ();
13452 : : }
13453 : :
13454 : :
13455 : : /*
13456 : : PutParam - Places a Non VAR parameter ParamName with type ParamType into
13457 : : procedure Sym. The parameter number is ParamNo.
13458 : : If the procedure Sym already has this parameter then
13459 : : the parameter is checked for consistancy and the
13460 : : consistancy test is returned.
13461 : : */
13462 : :
13463 : 5644766 : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded)
13464 : : {
13465 : 5644766 : SymbolTable_PtrToSymbol pSym;
13466 : 5644766 : unsigned int ParSym;
13467 : 5644766 : unsigned int VariableSym;
13468 : :
13469 : 5644766 : if (ParamNo <= (SymbolTable_NoOfParam (Sym)))
13470 : : {
13471 : 0 : M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
13472 : : }
13473 : : else
13474 : : {
13475 : : /* Add a new parameter */
13476 : 5644766 : NewSym (&ParSym);
13477 : 5644766 : pSym = GetPsym (ParSym);
13478 : 5644766 : pSym->SymbolType = SymbolTable_ParamSym;
13479 : 5644766 : pSym->Param.name = ParamName;
13480 : 5644766 : pSym->Param.Type = ParamType;
13481 : 5644766 : pSym->Param.IsUnbounded = isUnbounded;
13482 : 5644766 : pSym->Param.ShadowVar = SymbolTable_NulSym;
13483 : 5644766 : InitWhereDeclaredTok (tok, &pSym->Param.At);
13484 : 5644766 : AddParameter (Sym, ParSym);
13485 : 5644766 : if (ParamName != NameKey_NulName)
13486 : : {
13487 : 5601438 : VariableSym = MakeVariableForParam (tok, ParamName, Sym, ParamNo);
13488 : 5601438 : if (VariableSym == SymbolTable_NulSym)
13489 : : {
13490 : : return false;
13491 : : }
13492 : : else
13493 : : {
13494 : 5601438 : pSym = GetPsym (ParSym);
13495 : 5601438 : pSym->Param.ShadowVar = VariableSym;
13496 : : }
13497 : : }
13498 : : }
13499 : : return true;
13500 : : /* static analysis guarentees a RETURN statement will be used before here. */
13501 : : __builtin_unreachable ();
13502 : : }
13503 : :
13504 : :
13505 : : /*
13506 : : PutVarParam - Places a Non VAR parameter ParamName with type
13507 : : ParamType into procedure Sym.
13508 : : The parameter number is ParamNo.
13509 : : If the procedure Sym already has this parameter then
13510 : : the parameter is checked for consistancy and the
13511 : : consistancy test is returned.
13512 : : */
13513 : :
13514 : 437229 : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded)
13515 : : {
13516 : 437229 : SymbolTable_PtrToSymbol pSym;
13517 : 437229 : unsigned int ParSym;
13518 : 437229 : unsigned int VariableSym;
13519 : :
13520 : 437229 : if (ParamNo <= (SymbolTable_NoOfParam (Sym)))
13521 : : {
13522 : 0 : M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
13523 : : }
13524 : : else
13525 : : {
13526 : : /* Add a new parameter */
13527 : 437229 : NewSym (&ParSym);
13528 : 437229 : pSym = GetPsym (ParSym);
13529 : 437229 : pSym->SymbolType = SymbolTable_VarParamSym;
13530 : 437229 : pSym->VarParam.name = ParamName;
13531 : 437229 : pSym->VarParam.Type = ParamType;
13532 : 437229 : pSym->VarParam.IsUnbounded = isUnbounded;
13533 : 437229 : pSym->VarParam.ShadowVar = SymbolTable_NulSym;
13534 : 437229 : pSym->VarParam.HeapVar = SymbolTable_NulSym; /* Will contain a pointer value. */
13535 : 437229 : InitWhereDeclaredTok (tok, &pSym->VarParam.At); /* Will contain a pointer value. */
13536 : 437229 : AddParameter (Sym, ParSym);
13537 : 437229 : if (ParamName != NameKey_NulName)
13538 : : {
13539 : 431752 : VariableSym = MakeVariableForParam (tok, ParamName, Sym, ParamNo);
13540 : 431752 : if (VariableSym == SymbolTable_NulSym)
13541 : : {
13542 : : return false;
13543 : : }
13544 : : else
13545 : : {
13546 : 431752 : pSym = GetPsym (ParSym);
13547 : 431752 : pSym->VarParam.ShadowVar = VariableSym;
13548 : : }
13549 : : }
13550 : 437229 : return true;
13551 : : }
13552 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13553 : : __builtin_unreachable ();
13554 : : }
13555 : :
13556 : :
13557 : : /*
13558 : : PutParamName - assigns a name, name, to paramater, no, of procedure,
13559 : : ProcSym.
13560 : : */
13561 : :
13562 : 48805 : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, unsigned int no, NameKey_Name name)
13563 : : {
13564 : 48805 : SymbolTable_PtrToSymbol pSym;
13565 : 48805 : unsigned int ParSym;
13566 : :
13567 : 48805 : pSym = GetPsym (ProcSym);
13568 : 48805 : ParSym = SymbolTable_NulSym;
13569 : 48805 : switch (pSym->SymbolType)
13570 : : {
13571 : : case SymbolTable_ErrorSym:
13572 : : return ;
13573 : 48805 : break;
13574 : :
13575 : 48805 : case SymbolTable_ProcedureSym:
13576 : 48805 : ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.ListOfParam, no));
13577 : 48805 : break;
13578 : :
13579 : 0 : case SymbolTable_ProcTypeSym:
13580 : 0 : ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, no));
13581 : 0 : break;
13582 : :
13583 : :
13584 : 0 : default:
13585 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
13586 : 48805 : break;
13587 : : }
13588 : 48805 : pSym = GetPsym (ParSym);
13589 : 48805 : switch (pSym->SymbolType)
13590 : : {
13591 : 43328 : case SymbolTable_ParamSym:
13592 : 43328 : if (pSym->Param.name == NameKey_NulName)
13593 : : {
13594 : 43328 : pSym->Param.name = name;
13595 : 43328 : pSym->Param.ShadowVar = MakeVariableForParam (tok, name, ProcSym, no);
13596 : : }
13597 : : else
13598 : : {
13599 : 0 : M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
13600 : : }
13601 : 43328 : break;
13602 : :
13603 : 5477 : case SymbolTable_VarParamSym:
13604 : 5477 : if (pSym->VarParam.name == NameKey_NulName)
13605 : : {
13606 : 5477 : pSym->VarParam.name = name;
13607 : 5477 : pSym->VarParam.ShadowVar = MakeVariableForParam (tok, name, ProcSym, no);
13608 : : }
13609 : : else
13610 : : {
13611 : 0 : M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
13612 : : }
13613 : 5477 : break;
13614 : :
13615 : :
13616 : 0 : default:
13617 : 0 : M2Error_InternalError ((const char *) "expecting a VarParam or Param symbol", 36);
13618 : 48805 : break;
13619 : : }
13620 : : }
13621 : :
13622 : :
13623 : : /*
13624 : : PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
13625 : : main Module.
13626 : : */
13627 : :
13628 : 67229 : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym)
13629 : : {
13630 : 67229 : SymbolTable_PtrToSymbol pSym;
13631 : :
13632 : 67229 : pSym = GetPsym (Sym);
13633 : 67229 : switch (pSym->SymbolType)
13634 : : {
13635 : : case SymbolTable_ErrorSym:
13636 : : break;
13637 : :
13638 : 67229 : case SymbolTable_ProcedureSym:
13639 : 67229 : pSym->Procedure.Reachable = true;
13640 : 67229 : break;
13641 : :
13642 : :
13643 : 0 : default:
13644 : 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
13645 : 67229 : break;
13646 : : }
13647 : 67229 : }
13648 : :
13649 : :
13650 : : /*
13651 : : IsProcedureReachable - Returns true if the procedure, Sym, is
13652 : : reachable from the main Module.
13653 : : */
13654 : :
13655 : 214359 : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym)
13656 : : {
13657 : 214359 : SymbolTable_PtrToSymbol pSym;
13658 : :
13659 : 214359 : pSym = GetPsym (Sym);
13660 : 214359 : switch (pSym->SymbolType)
13661 : : {
13662 : 214359 : case SymbolTable_ProcedureSym:
13663 : 214359 : return pSym->Procedure.Reachable;
13664 : 0 : break;
13665 : :
13666 : :
13667 : 0 : default:
13668 : 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
13669 : : break;
13670 : : }
13671 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13672 : : __builtin_unreachable ();
13673 : : }
13674 : :
13675 : :
13676 : : /*
13677 : : PutProcedureNoReturn - places value into the no return attribute
13678 : : field of procedure sym.
13679 : : */
13680 : :
13681 : 539867 : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, bool value)
13682 : : {
13683 : 539867 : SymbolTable_PtrToSymbol pSym;
13684 : :
13685 : 539867 : pSym = GetPsym (Sym);
13686 : 539867 : switch (pSym->SymbolType)
13687 : : {
13688 : 539867 : case SymbolTable_ProcedureSym:
13689 : 539867 : pSym->Procedure.IsNoReturn = value;
13690 : 539867 : break;
13691 : :
13692 : :
13693 : 0 : default:
13694 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
13695 : 539867 : break;
13696 : : }
13697 : 539867 : }
13698 : :
13699 : :
13700 : : /*
13701 : : IsProcedureNoReturn - returns TRUE if this procedure never returns.
13702 : : */
13703 : :
13704 : 2271568 : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym)
13705 : : {
13706 : 2271568 : SymbolTable_PtrToSymbol pSym;
13707 : :
13708 : 2271568 : pSym = GetPsym (Sym);
13709 : 2271568 : switch (pSym->SymbolType)
13710 : : {
13711 : 2271568 : case SymbolTable_ProcedureSym:
13712 : 2271568 : return pSym->Procedure.IsNoReturn;
13713 : 0 : break;
13714 : :
13715 : :
13716 : 0 : default:
13717 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
13718 : : break;
13719 : : }
13720 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13721 : : __builtin_unreachable ();
13722 : : }
13723 : :
13724 : :
13725 : : /*
13726 : : PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
13727 : : QuadNumber is the start quad of Module,
13728 : : Sym.
13729 : : */
13730 : :
13731 : 63418 : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber)
13732 : : {
13733 : 63418 : SymbolTable_PtrToSymbol pSym;
13734 : :
13735 : 63418 : pSym = GetPsym (Sym);
13736 : 63418 : switch (pSym->SymbolType)
13737 : : {
13738 : 10678 : case SymbolTable_ModuleSym:
13739 : 10678 : pSym->Module.StartQuad = QuadNumber;
13740 : 10678 : break;
13741 : :
13742 : 52740 : case SymbolTable_DefImpSym:
13743 : 52740 : pSym->DefImp.StartQuad = QuadNumber;
13744 : 52740 : break;
13745 : :
13746 : :
13747 : 0 : default:
13748 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
13749 : 63418 : break;
13750 : : }
13751 : 63418 : }
13752 : :
13753 : :
13754 : : /*
13755 : : PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
13756 : : QuadNumber is the end quad of Module,
13757 : : Sym.
13758 : : */
13759 : :
13760 : 63370 : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber)
13761 : : {
13762 : 63370 : SymbolTable_PtrToSymbol pSym;
13763 : :
13764 : 63370 : pSym = GetPsym (Sym);
13765 : 63370 : switch (pSym->SymbolType)
13766 : : {
13767 : 10630 : case SymbolTable_ModuleSym:
13768 : 10630 : pSym->Module.EndQuad = QuadNumber;
13769 : 10630 : break;
13770 : :
13771 : 52740 : case SymbolTable_DefImpSym:
13772 : 52740 : pSym->DefImp.EndQuad = QuadNumber;
13773 : 52740 : break;
13774 : :
13775 : :
13776 : 0 : default:
13777 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
13778 : 63370 : break;
13779 : : }
13780 : 63370 : }
13781 : :
13782 : :
13783 : : /*
13784 : : PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
13785 : : QuadNumber is the finally start quad of
13786 : : Module, Sym.
13787 : : */
13788 : :
13789 : 17352 : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber)
13790 : : {
13791 : 17352 : SymbolTable_PtrToSymbol pSym;
13792 : :
13793 : 17352 : pSym = GetPsym (Sym);
13794 : 17352 : switch (pSym->SymbolType)
13795 : : {
13796 : 10630 : case SymbolTable_ModuleSym:
13797 : 10630 : pSym->Module.StartFinishQuad = QuadNumber;
13798 : 10630 : break;
13799 : :
13800 : 6722 : case SymbolTable_DefImpSym:
13801 : 6722 : pSym->DefImp.StartFinishQuad = QuadNumber;
13802 : 6722 : break;
13803 : :
13804 : :
13805 : 0 : default:
13806 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
13807 : 17352 : break;
13808 : : }
13809 : 17352 : }
13810 : :
13811 : :
13812 : : /*
13813 : : PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
13814 : : QuadNumber is the end quad of the finally block
13815 : : in Module, Sym.
13816 : : */
13817 : :
13818 : 17352 : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber)
13819 : : {
13820 : 17352 : SymbolTable_PtrToSymbol pSym;
13821 : :
13822 : 17352 : pSym = GetPsym (Sym);
13823 : 17352 : switch (pSym->SymbolType)
13824 : : {
13825 : 10630 : case SymbolTable_ModuleSym:
13826 : 10630 : pSym->Module.EndFinishQuad = QuadNumber;
13827 : 10630 : break;
13828 : :
13829 : 6722 : case SymbolTable_DefImpSym:
13830 : 6722 : pSym->DefImp.EndFinishQuad = QuadNumber;
13831 : 6722 : break;
13832 : :
13833 : :
13834 : 0 : default:
13835 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
13836 : 17352 : break;
13837 : : }
13838 : 17352 : }
13839 : :
13840 : :
13841 : : /*
13842 : : GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
13843 : : Quads of a Module, Sym.
13844 : : Start and End represent the initialization code
13845 : : of the Module, Sym.
13846 : : */
13847 : :
13848 : 0 : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish)
13849 : : {
13850 : 0 : SymbolTable_PtrToSymbol pSym;
13851 : :
13852 : 0 : pSym = GetPsym (Sym);
13853 : 0 : switch (pSym->SymbolType)
13854 : : {
13855 : 0 : case SymbolTable_ModuleSym:
13856 : 0 : (*StartInit) = pSym->Module.StartQuad;
13857 : 0 : (*EndInit) = pSym->Module.EndQuad;
13858 : 0 : (*StartFinish) = pSym->Module.StartFinishQuad;
13859 : 0 : (*EndFinish) = pSym->Module.EndFinishQuad;
13860 : 0 : break;
13861 : :
13862 : 0 : case SymbolTable_DefImpSym:
13863 : 0 : (*StartInit) = pSym->DefImp.StartQuad;
13864 : 0 : (*EndInit) = pSym->DefImp.EndQuad;
13865 : 0 : (*StartFinish) = pSym->DefImp.StartFinishQuad;
13866 : 0 : (*EndFinish) = pSym->DefImp.EndFinishQuad;
13867 : 0 : break;
13868 : :
13869 : :
13870 : 0 : default:
13871 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
13872 : 0 : break;
13873 : : }
13874 : 0 : }
13875 : :
13876 : :
13877 : : /*
13878 : : PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
13879 : : */
13880 : :
13881 : 0 : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, m2tree_Tree finally)
13882 : : {
13883 : 0 : SymbolTable_PtrToSymbol pSym;
13884 : :
13885 : 0 : pSym = GetPsym (Sym);
13886 : 0 : switch (pSym->SymbolType)
13887 : : {
13888 : 0 : case SymbolTable_ModuleSym:
13889 : 0 : pSym->Module.FinallyFunction = finally;
13890 : 0 : break;
13891 : :
13892 : 0 : case SymbolTable_DefImpSym:
13893 : 0 : pSym->DefImp.FinallyFunction = finally;
13894 : 0 : break;
13895 : :
13896 : :
13897 : 0 : default:
13898 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
13899 : 0 : break;
13900 : : }
13901 : 0 : }
13902 : :
13903 : :
13904 : : /*
13905 : : GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
13906 : : */
13907 : :
13908 : 0 : extern "C" m2tree_Tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym)
13909 : : {
13910 : 0 : SymbolTable_PtrToSymbol pSym;
13911 : :
13912 : 0 : pSym = GetPsym (Sym);
13913 : 0 : switch (pSym->SymbolType)
13914 : : {
13915 : 0 : case SymbolTable_ModuleSym:
13916 : 0 : return pSym->Module.FinallyFunction;
13917 : 0 : break;
13918 : :
13919 : 0 : case SymbolTable_DefImpSym:
13920 : 0 : return pSym->DefImp.FinallyFunction;
13921 : 0 : break;
13922 : :
13923 : :
13924 : 0 : default:
13925 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
13926 : : break;
13927 : : }
13928 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13929 : : __builtin_unreachable ();
13930 : : }
13931 : :
13932 : :
13933 : : /*
13934 : : PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
13935 : : QuadNumber is the start quad of scope for procedure,
13936 : : Sym.
13937 : : */
13938 : :
13939 : 78565 : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber)
13940 : : {
13941 : 78565 : SymbolTable_PtrToSymbol pSym;
13942 : :
13943 : 78565 : pSym = GetPsym (Sym);
13944 : 78565 : switch (pSym->SymbolType)
13945 : : {
13946 : 78565 : case SymbolTable_ProcedureSym:
13947 : 78565 : pSym->Procedure.ScopeQuad = QuadNumber;
13948 : 78565 : break;
13949 : :
13950 : :
13951 : 0 : default:
13952 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
13953 : 78565 : break;
13954 : : }
13955 : 78565 : }
13956 : :
13957 : :
13958 : : /*
13959 : : PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
13960 : : QuadNumber is the start quad of procedure,
13961 : : Sym.
13962 : : */
13963 : :
13964 : 78565 : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber)
13965 : : {
13966 : 78565 : SymbolTable_PtrToSymbol pSym;
13967 : :
13968 : 78565 : pSym = GetPsym (Sym);
13969 : 78565 : switch (pSym->SymbolType)
13970 : : {
13971 : 78565 : case SymbolTable_ProcedureSym:
13972 : 78565 : pSym->Procedure.StartQuad = QuadNumber;
13973 : 78565 : break;
13974 : :
13975 : :
13976 : 0 : default:
13977 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
13978 : 78565 : break;
13979 : : }
13980 : 78565 : }
13981 : :
13982 : :
13983 : : /*
13984 : : PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
13985 : : QuadNumber is the end quad of procedure,
13986 : : Sym.
13987 : : */
13988 : :
13989 : 78535 : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber)
13990 : : {
13991 : 78535 : SymbolTable_PtrToSymbol pSym;
13992 : :
13993 : 78535 : pSym = GetPsym (Sym);
13994 : 78535 : switch (pSym->SymbolType)
13995 : : {
13996 : 78535 : case SymbolTable_ProcedureSym:
13997 : 78535 : pSym->Procedure.EndQuad = QuadNumber;
13998 : 78535 : break;
13999 : :
14000 : :
14001 : 0 : default:
14002 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14003 : 78535 : break;
14004 : : }
14005 : 78535 : }
14006 : :
14007 : :
14008 : : /*
14009 : : GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
14010 : : */
14011 : :
14012 : 550802 : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end)
14013 : : {
14014 : 550802 : SymbolTable_PtrToSymbol pSym;
14015 : :
14016 : 550802 : pSym = GetPsym (Sym);
14017 : 550802 : switch (pSym->SymbolType)
14018 : : {
14019 : 550802 : case SymbolTable_ProcedureSym:
14020 : 550802 : (*scope) = pSym->Procedure.ScopeQuad;
14021 : 550802 : (*start) = pSym->Procedure.StartQuad;
14022 : 550802 : (*end) = pSym->Procedure.EndQuad;
14023 : 550802 : break;
14024 : :
14025 : :
14026 : 0 : default:
14027 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14028 : 550802 : break;
14029 : : }
14030 : 550802 : }
14031 : :
14032 : :
14033 : : /*
14034 : : GetQuads - assigns Start and End to the beginning and end of
14035 : : symbol, Sym, usage.
14036 : : */
14037 : :
14038 : 0 : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14039 : : {
14040 : 0 : unsigned int StartRead;
14041 : 0 : unsigned int EndRead;
14042 : 0 : unsigned int StartWrite;
14043 : 0 : unsigned int EndWrite;
14044 : :
14045 : 0 : SymbolTable_GetReadQuads (Sym, m, &StartRead, &EndRead);
14046 : 0 : SymbolTable_GetWriteQuads (Sym, m, &StartWrite, &EndWrite);
14047 : 0 : if (StartRead == 0)
14048 : : {
14049 : 0 : (*Start) = StartWrite;
14050 : : }
14051 : 0 : else if (StartWrite == 0)
14052 : : {
14053 : : /* avoid dangling else. */
14054 : 0 : (*Start) = StartRead;
14055 : : }
14056 : : else
14057 : : {
14058 : : /* avoid dangling else. */
14059 : 0 : (*Start) = Min (StartRead, StartWrite);
14060 : : }
14061 : 0 : if (EndRead == 0)
14062 : : {
14063 : 0 : (*End) = EndWrite;
14064 : : }
14065 : 0 : else if (EndWrite == 0)
14066 : : {
14067 : : /* avoid dangling else. */
14068 : 0 : (*End) = EndRead;
14069 : : }
14070 : : else
14071 : : {
14072 : : /* avoid dangling else. */
14073 : 0 : (*End) = Max (EndRead, EndWrite);
14074 : : }
14075 : 0 : }
14076 : :
14077 : :
14078 : : /*
14079 : : GetReadQuads - assigns Start and End to the beginning and end of
14080 : : symbol, Sym, read history usage.
14081 : : */
14082 : :
14083 : 0 : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14084 : : {
14085 : 0 : SymbolTable_GetReadLimitQuads (Sym, m, 0, 0, Start, End);
14086 : 0 : }
14087 : :
14088 : :
14089 : : /*
14090 : : GetWriteQuads - assigns Start and End to the beginning and end of
14091 : : symbol, Sym, usage.
14092 : : */
14093 : :
14094 : 0 : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14095 : : {
14096 : 0 : SymbolTable_GetWriteLimitQuads (Sym, m, 0, 0, Start, End);
14097 : 0 : }
14098 : :
14099 : :
14100 : : /*
14101 : : PutReadQuad - places Quad into the list of symbol usage.
14102 : : */
14103 : :
14104 : 1598175 : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14105 : : {
14106 : 1598175 : SymbolTable_PtrToSymbol pSym;
14107 : :
14108 : 1598175 : pSym = GetPsym (Sym);
14109 : 1598175 : switch (pSym->SymbolType)
14110 : : {
14111 : 1598175 : case SymbolTable_VarSym:
14112 : 1598175 : Lists_IncludeItemIntoList (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue], Quad);
14113 : 1598175 : break;
14114 : :
14115 : :
14116 : 0 : default:
14117 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14118 : 1598175 : break;
14119 : : }
14120 : 1598175 : }
14121 : :
14122 : :
14123 : : /*
14124 : : RemoveReadQuad - places Quad into the list of symbol usage.
14125 : : */
14126 : :
14127 : 122652 : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14128 : : {
14129 : 122652 : SymbolTable_PtrToSymbol pSym;
14130 : :
14131 : 122652 : pSym = GetPsym (Sym);
14132 : 122652 : switch (pSym->SymbolType)
14133 : : {
14134 : 122652 : case SymbolTable_VarSym:
14135 : 122652 : Lists_RemoveItemFromList (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue], Quad);
14136 : 122652 : break;
14137 : :
14138 : :
14139 : 0 : default:
14140 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14141 : 122652 : break;
14142 : : }
14143 : 122652 : }
14144 : :
14145 : :
14146 : : /*
14147 : : PutWriteQuad - places Quad into the list of symbol usage.
14148 : : */
14149 : :
14150 : 1018507 : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14151 : : {
14152 : 1018507 : SymbolTable_PtrToSymbol pSym;
14153 : :
14154 : 1018507 : pSym = GetPsym (Sym);
14155 : 1018507 : switch (pSym->SymbolType)
14156 : : {
14157 : 1018507 : case SymbolTable_VarSym:
14158 : 1018507 : Lists_IncludeItemIntoList (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue], Quad);
14159 : 1018507 : break;
14160 : :
14161 : :
14162 : 0 : default:
14163 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14164 : 1018507 : break;
14165 : : }
14166 : 1018507 : }
14167 : :
14168 : :
14169 : : /*
14170 : : RemoveWriteQuad - places Quad into the list of symbol usage.
14171 : : */
14172 : :
14173 : 209627 : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14174 : : {
14175 : 209627 : SymbolTable_PtrToSymbol pSym;
14176 : :
14177 : 209627 : pSym = GetPsym (Sym);
14178 : 209627 : switch (pSym->SymbolType)
14179 : : {
14180 : 209627 : case SymbolTable_VarSym:
14181 : 209627 : Lists_RemoveItemFromList (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue], Quad);
14182 : 209627 : break;
14183 : :
14184 : :
14185 : 0 : default:
14186 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14187 : 209627 : break;
14188 : : }
14189 : 209627 : }
14190 : :
14191 : :
14192 : : /*
14193 : : GetReadLimitQuads - returns Start and End which have been assigned
14194 : : the start and end of when the symbol was read
14195 : : to within: StartLimit..EndLimit.
14196 : : */
14197 : :
14198 : 0 : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
14199 : : {
14200 : 0 : SymbolTable_PtrToSymbol pSym;
14201 : :
14202 : 0 : pSym = GetPsym (Sym);
14203 : 0 : switch (pSym->SymbolType)
14204 : : {
14205 : 0 : case SymbolTable_VarSym:
14206 : 0 : DoFindLimits (StartLimit, EndLimit, Start, End, pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]);
14207 : 0 : break;
14208 : :
14209 : :
14210 : 0 : default:
14211 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14212 : 0 : break;
14213 : : }
14214 : 0 : }
14215 : :
14216 : :
14217 : : /*
14218 : : GetWriteLimitQuads - returns Start and End which have been assigned
14219 : : the start and end of when the symbol was written
14220 : : to within: StartLimit..EndLimit.
14221 : : */
14222 : :
14223 : 0 : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
14224 : : {
14225 : 0 : SymbolTable_PtrToSymbol pSym;
14226 : :
14227 : 0 : pSym = GetPsym (Sym);
14228 : 0 : switch (pSym->SymbolType)
14229 : : {
14230 : 0 : case SymbolTable_VarSym:
14231 : 0 : DoFindLimits (StartLimit, EndLimit, Start, End, pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]);
14232 : 0 : break;
14233 : :
14234 : :
14235 : 0 : default:
14236 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14237 : 0 : break;
14238 : : }
14239 : 0 : }
14240 : :
14241 : :
14242 : : /*
14243 : : GetNthProcedure - Returns the Nth procedure in Module, Sym.
14244 : : */
14245 : :
14246 : 0 : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n)
14247 : : {
14248 : 0 : SymbolTable_PtrToSymbol pSym;
14249 : :
14250 : 0 : pSym = GetPsym (Sym);
14251 : 0 : switch (pSym->SymbolType)
14252 : : {
14253 : 0 : case SymbolTable_DefImpSym:
14254 : 0 : return static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfProcs, n));
14255 : 0 : break;
14256 : :
14257 : 0 : case SymbolTable_ModuleSym:
14258 : 0 : return static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfProcs, n));
14259 : 0 : break;
14260 : :
14261 : :
14262 : 0 : default:
14263 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
14264 : : break;
14265 : : }
14266 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14267 : : __builtin_unreachable ();
14268 : : }
14269 : :
14270 : :
14271 : : /*
14272 : : GetDeclaredDef - returns the tokenno where the symbol was declared.
14273 : : The priority of declaration is definition, implementation
14274 : : and program module.
14275 : : */
14276 : :
14277 : 174 : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym)
14278 : : {
14279 : 174 : unsigned int declared;
14280 : :
14281 : 174 : declared = SymbolTable_GetDeclaredDefinition (Sym);
14282 : 174 : if (declared == M2LexBuf_UnknownTokenNo)
14283 : : {
14284 : 174 : return SymbolTable_GetDeclaredModule (Sym);
14285 : : }
14286 : : return declared;
14287 : : /* static analysis guarentees a RETURN statement will be used before here. */
14288 : : __builtin_unreachable ();
14289 : : }
14290 : :
14291 : :
14292 : : /*
14293 : : GetDeclaredMod - returns the tokenno where the symbol was declared.
14294 : : The priority of declaration is program,
14295 : : implementation and definition module.
14296 : : */
14297 : :
14298 : 20020321 : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym)
14299 : : {
14300 : 20020321 : unsigned int declared;
14301 : :
14302 : 20020321 : declared = SymbolTable_GetDeclaredModule (Sym);
14303 : 20020321 : if (declared == M2LexBuf_UnknownTokenNo)
14304 : : {
14305 : 10794906 : return SymbolTable_GetDeclaredDefinition (Sym);
14306 : : }
14307 : : return declared;
14308 : : /* static analysis guarentees a RETURN statement will be used before here. */
14309 : : __builtin_unreachable ();
14310 : : }
14311 : :
14312 : :
14313 : : /*
14314 : : GetDeclaredDefinition - returns the token where this symbol
14315 : : was declared in the definition module.
14316 : : */
14317 : :
14318 : 10818960 : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym)
14319 : : {
14320 : 10818960 : SymbolTable_PtrToSymbol pSym;
14321 : :
14322 : 10818960 : pSym = GetPsym (Sym);
14323 : 10818960 : switch (pSym->SymbolType)
14324 : : {
14325 : 0 : case SymbolTable_ErrorSym:
14326 : 0 : return pSym->Error.At.DefDeclared;
14327 : 0 : break;
14328 : :
14329 : 0 : case SymbolTable_ObjectSym:
14330 : 0 : return pSym->Object.At.DefDeclared;
14331 : 48 : break;
14332 : :
14333 : 48 : case SymbolTable_VarientSym:
14334 : 48 : return pSym->Varient.At.DefDeclared;
14335 : 143682 : break;
14336 : :
14337 : 143682 : case SymbolTable_RecordSym:
14338 : 143682 : return pSym->Record.At.DefDeclared;
14339 : 147699 : break;
14340 : :
14341 : 147699 : case SymbolTable_SubrangeSym:
14342 : 147699 : return pSym->Subrange.At.DefDeclared;
14343 : 13163 : break;
14344 : :
14345 : 13163 : case SymbolTable_EnumerationSym:
14346 : 13163 : return pSym->Enumeration.At.DefDeclared;
14347 : 2713 : break;
14348 : :
14349 : 2713 : case SymbolTable_ArraySym:
14350 : 2713 : return pSym->Array.At.DefDeclared;
14351 : 0 : break;
14352 : :
14353 : 0 : case SymbolTable_SubscriptSym:
14354 : 0 : return pSym->Subscript.At.DefDeclared;
14355 : 46434 : break;
14356 : :
14357 : 46434 : case SymbolTable_UnboundedSym:
14358 : 46434 : return pSym->Unbounded.At.DefDeclared;
14359 : 1408205 : break;
14360 : :
14361 : 1408205 : case SymbolTable_ProcedureSym:
14362 : 1408205 : return pSym->Procedure.At.DefDeclared;
14363 : 56362 : break;
14364 : :
14365 : 56362 : case SymbolTable_ProcTypeSym:
14366 : 56362 : return pSym->ProcType.At.DefDeclared;
14367 : 74720 : break;
14368 : :
14369 : 74720 : case SymbolTable_ParamSym:
14370 : 74720 : return pSym->Param.At.DefDeclared;
14371 : 131511 : break;
14372 : :
14373 : 131511 : case SymbolTable_VarParamSym:
14374 : 131511 : return pSym->VarParam.At.DefDeclared;
14375 : 2303 : break;
14376 : :
14377 : 2303 : case SymbolTable_ConstStringSym:
14378 : 2303 : return pSym->ConstString.At.DefDeclared;
14379 : 286638 : break;
14380 : :
14381 : 286638 : case SymbolTable_ConstLitSym:
14382 : 286638 : return pSym->ConstLit.At.DefDeclared;
14383 : 348949 : break;
14384 : :
14385 : 348949 : case SymbolTable_ConstVarSym:
14386 : 348949 : return pSym->ConstVar.At.DefDeclared;
14387 : 3382265 : break;
14388 : :
14389 : 3382265 : case SymbolTable_VarSym:
14390 : 3382265 : return pSym->Var.At.DefDeclared;
14391 : 29641 : break;
14392 : :
14393 : 29641 : case SymbolTable_TypeSym:
14394 : 29641 : return pSym->Type.At.DefDeclared;
14395 : 12 : break;
14396 : :
14397 : 12 : case SymbolTable_PointerSym:
14398 : 12 : return pSym->Pointer.At.DefDeclared;
14399 : 163917 : break;
14400 : :
14401 : 163917 : case SymbolTable_RecordFieldSym:
14402 : 163917 : return pSym->RecordField.At.DefDeclared;
14403 : 120 : break;
14404 : :
14405 : 120 : case SymbolTable_VarientFieldSym:
14406 : 120 : return pSym->VarientField.At.DefDeclared;
14407 : 4556312 : break;
14408 : :
14409 : 4556312 : case SymbolTable_EnumerationFieldSym:
14410 : 4556312 : return pSym->EnumerationField.At.DefDeclared;
14411 : 386 : break;
14412 : :
14413 : 386 : case SymbolTable_SetSym:
14414 : 386 : return pSym->Set.At.DefDeclared;
14415 : 0 : break;
14416 : :
14417 : 0 : case SymbolTable_DefImpSym:
14418 : 0 : return pSym->DefImp.At.DefDeclared;
14419 : 0 : break;
14420 : :
14421 : 0 : case SymbolTable_ModuleSym:
14422 : 0 : return pSym->Module.At.DefDeclared;
14423 : 0 : break;
14424 : :
14425 : 0 : case SymbolTable_UndefinedSym:
14426 : 0 : return SymbolTable_GetFirstUsed (Sym);
14427 : 23880 : break;
14428 : :
14429 : 23880 : case SymbolTable_ImportSym:
14430 : 23880 : return pSym->Import.at.DefDeclared;
14431 : 0 : break;
14432 : :
14433 : 0 : case SymbolTable_ImportStatementSym:
14434 : 0 : return pSym->ImportStatement.at.DefDeclared;
14435 : 0 : break;
14436 : :
14437 : 0 : case SymbolTable_PartialUnboundedSym:
14438 : 0 : return SymbolTable_GetDeclaredDefinition (pSym->PartialUnbounded.Type);
14439 : 0 : break;
14440 : :
14441 : :
14442 : 0 : default:
14443 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
14444 : : break;
14445 : : }
14446 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14447 : : __builtin_unreachable ();
14448 : : }
14449 : :
14450 : :
14451 : : /*
14452 : : GetDeclaredModule - returns the token where this symbol was declared
14453 : : in an implementation or program module.
14454 : : */
14455 : :
14456 : 20041265 : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym)
14457 : : {
14458 : 20041265 : SymbolTable_PtrToSymbol pSym;
14459 : :
14460 : 20041265 : pSym = GetPsym (Sym);
14461 : 20041265 : switch (pSym->SymbolType)
14462 : : {
14463 : 0 : case SymbolTable_ErrorSym:
14464 : 0 : return pSym->Error.At.ModDeclared;
14465 : 0 : break;
14466 : :
14467 : 0 : case SymbolTable_ObjectSym:
14468 : 0 : return pSym->Object.At.ModDeclared;
14469 : 552 : break;
14470 : :
14471 : 552 : case SymbolTable_VarientSym:
14472 : 552 : return pSym->Varient.At.ModDeclared;
14473 : 249759 : break;
14474 : :
14475 : 249759 : case SymbolTable_RecordSym:
14476 : 249759 : return pSym->Record.At.ModDeclared;
14477 : 2324529 : break;
14478 : :
14479 : 2324529 : case SymbolTable_SubrangeSym:
14480 : 2324529 : return pSym->Subrange.At.ModDeclared;
14481 : 22888 : break;
14482 : :
14483 : 22888 : case SymbolTable_EnumerationSym:
14484 : 22888 : return pSym->Enumeration.At.ModDeclared;
14485 : 29423 : break;
14486 : :
14487 : 29423 : case SymbolTable_ArraySym:
14488 : 29423 : return pSym->Array.At.ModDeclared;
14489 : 0 : break;
14490 : :
14491 : 0 : case SymbolTable_SubscriptSym:
14492 : 0 : return pSym->Subscript.At.ModDeclared;
14493 : 46818 : break;
14494 : :
14495 : 46818 : case SymbolTable_UnboundedSym:
14496 : 46818 : return pSym->Unbounded.At.ModDeclared;
14497 : 3793302 : break;
14498 : :
14499 : 3793302 : case SymbolTable_ProcedureSym:
14500 : 3793302 : return pSym->Procedure.At.ModDeclared;
14501 : 56584 : break;
14502 : :
14503 : 56584 : case SymbolTable_ProcTypeSym:
14504 : 56584 : return pSym->ProcType.At.ModDeclared;
14505 : 74948 : break;
14506 : :
14507 : 74948 : case SymbolTable_ParamSym:
14508 : 74948 : return pSym->Param.At.ModDeclared;
14509 : 189291 : break;
14510 : :
14511 : 189291 : case SymbolTable_VarParamSym:
14512 : 189291 : return pSym->VarParam.At.ModDeclared;
14513 : 289369 : break;
14514 : :
14515 : 289369 : case SymbolTable_ConstStringSym:
14516 : 289369 : return pSym->ConstString.At.ModDeclared;
14517 : 684096 : break;
14518 : :
14519 : 684096 : case SymbolTable_ConstLitSym:
14520 : 684096 : return pSym->ConstLit.At.ModDeclared;
14521 : 518894 : break;
14522 : :
14523 : 518894 : case SymbolTable_ConstVarSym:
14524 : 518894 : return pSym->ConstVar.At.ModDeclared;
14525 : 5736419 : break;
14526 : :
14527 : 5736419 : case SymbolTable_VarSym:
14528 : 5736419 : return pSym->Var.At.ModDeclared;
14529 : 84617 : break;
14530 : :
14531 : 84617 : case SymbolTable_TypeSym:
14532 : 84617 : return pSym->Type.At.ModDeclared;
14533 : 12 : break;
14534 : :
14535 : 12 : case SymbolTable_PointerSym:
14536 : 12 : return pSym->Pointer.At.ModDeclared;
14537 : 321372 : break;
14538 : :
14539 : 321372 : case SymbolTable_RecordFieldSym:
14540 : 321372 : return pSym->RecordField.At.ModDeclared;
14541 : 1332 : break;
14542 : :
14543 : 1332 : case SymbolTable_VarientFieldSym:
14544 : 1332 : return pSym->VarientField.At.ModDeclared;
14545 : 5333019 : break;
14546 : :
14547 : 5333019 : case SymbolTable_EnumerationFieldSym:
14548 : 5333019 : return pSym->EnumerationField.At.ModDeclared;
14549 : 229301 : break;
14550 : :
14551 : 229301 : case SymbolTable_SetSym:
14552 : 229301 : return pSym->Set.At.ModDeclared;
14553 : 13442 : break;
14554 : :
14555 : 13442 : case SymbolTable_DefImpSym:
14556 : 13442 : return pSym->DefImp.At.ModDeclared;
14557 : 20528 : break;
14558 : :
14559 : 20528 : case SymbolTable_ModuleSym:
14560 : 20528 : return pSym->Module.At.ModDeclared;
14561 : 0 : break;
14562 : :
14563 : 0 : case SymbolTable_UndefinedSym:
14564 : 0 : return SymbolTable_GetFirstUsed (Sym);
14565 : 20770 : break;
14566 : :
14567 : 20770 : case SymbolTable_ImportSym:
14568 : 20770 : return pSym->Import.at.ModDeclared;
14569 : 0 : break;
14570 : :
14571 : 0 : case SymbolTable_ImportStatementSym:
14572 : 0 : return pSym->ImportStatement.at.ModDeclared;
14573 : 0 : break;
14574 : :
14575 : 0 : case SymbolTable_PartialUnboundedSym:
14576 : 0 : return SymbolTable_GetDeclaredModule (pSym->PartialUnbounded.Type);
14577 : 0 : break;
14578 : :
14579 : :
14580 : 0 : default:
14581 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
14582 : : break;
14583 : : }
14584 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14585 : : __builtin_unreachable ();
14586 : : }
14587 : :
14588 : :
14589 : : /*
14590 : : PutDeclared - adds an entry to symbol, Sym, indicating that it
14591 : : was declared at, tok. This routine
14592 : : may be called twice, once for definition module
14593 : : partial declaration and once when parsing the
14594 : : implementation module.
14595 : : */
14596 : :
14597 : 19791050 : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym)
14598 : : {
14599 : 19791050 : if (M2Comp_CompilingDefinitionModule ())
14600 : : {
14601 : 11374161 : PutDeclaredDefinition (tok, Sym);
14602 : : }
14603 : : else
14604 : : {
14605 : 8416889 : PutDeclaredModule (tok, Sym);
14606 : : }
14607 : 19791050 : }
14608 : :
14609 : :
14610 : : /*
14611 : : GetFirstUsed - returns the token where this symbol was first used.
14612 : : */
14613 : :
14614 : 348 : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym)
14615 : : {
14616 : 348 : SymbolTable_PtrToSymbol pSym;
14617 : :
14618 : 348 : pSym = GetPsym (Sym);
14619 : 348 : switch (pSym->SymbolType)
14620 : : {
14621 : 0 : case SymbolTable_ErrorSym:
14622 : 0 : return pSym->Error.At.FirstUsed;
14623 : 162 : break;
14624 : :
14625 : 162 : case SymbolTable_ObjectSym:
14626 : 162 : return pSym->Object.At.FirstUsed;
14627 : 180 : break;
14628 : :
14629 : 180 : case SymbolTable_UndefinedSym:
14630 : 180 : return pSym->Undefined.At.FirstUsed;
14631 : 0 : break;
14632 : :
14633 : 0 : case SymbolTable_VarientSym:
14634 : 0 : return pSym->Varient.At.FirstUsed;
14635 : 0 : break;
14636 : :
14637 : 0 : case SymbolTable_RecordSym:
14638 : 0 : return pSym->Record.At.FirstUsed;
14639 : 0 : break;
14640 : :
14641 : 0 : case SymbolTable_SubrangeSym:
14642 : 0 : return pSym->Subrange.At.FirstUsed;
14643 : 0 : break;
14644 : :
14645 : 0 : case SymbolTable_EnumerationSym:
14646 : 0 : return pSym->Enumeration.At.FirstUsed;
14647 : 6 : break;
14648 : :
14649 : 6 : case SymbolTable_ArraySym:
14650 : 6 : return pSym->Array.At.FirstUsed;
14651 : 0 : break;
14652 : :
14653 : 0 : case SymbolTable_SubscriptSym:
14654 : 0 : return pSym->Subscript.At.FirstUsed;
14655 : 0 : break;
14656 : :
14657 : 0 : case SymbolTable_UnboundedSym:
14658 : 0 : return pSym->Unbounded.At.FirstUsed;
14659 : 0 : break;
14660 : :
14661 : 0 : case SymbolTable_ProcedureSym:
14662 : 0 : return pSym->Procedure.At.FirstUsed;
14663 : 0 : break;
14664 : :
14665 : 0 : case SymbolTable_ProcTypeSym:
14666 : 0 : return pSym->ProcType.At.FirstUsed;
14667 : 0 : break;
14668 : :
14669 : 0 : case SymbolTable_ParamSym:
14670 : 0 : return pSym->Param.At.FirstUsed;
14671 : 0 : break;
14672 : :
14673 : 0 : case SymbolTable_VarParamSym:
14674 : 0 : return pSym->VarParam.At.FirstUsed;
14675 : 0 : break;
14676 : :
14677 : 0 : case SymbolTable_ConstStringSym:
14678 : 0 : return pSym->ConstString.At.FirstUsed;
14679 : 0 : break;
14680 : :
14681 : 0 : case SymbolTable_ConstLitSym:
14682 : 0 : return pSym->ConstLit.At.FirstUsed;
14683 : 0 : break;
14684 : :
14685 : 0 : case SymbolTable_ConstVarSym:
14686 : 0 : return pSym->ConstVar.At.FirstUsed;
14687 : 0 : break;
14688 : :
14689 : 0 : case SymbolTable_VarSym:
14690 : 0 : return pSym->Var.At.FirstUsed;
14691 : 0 : break;
14692 : :
14693 : 0 : case SymbolTable_TypeSym:
14694 : 0 : return pSym->Type.At.FirstUsed;
14695 : 0 : break;
14696 : :
14697 : 0 : case SymbolTable_PointerSym:
14698 : 0 : return pSym->Pointer.At.FirstUsed;
14699 : 0 : break;
14700 : :
14701 : 0 : case SymbolTable_RecordFieldSym:
14702 : 0 : return pSym->RecordField.At.FirstUsed;
14703 : 0 : break;
14704 : :
14705 : 0 : case SymbolTable_VarientFieldSym:
14706 : 0 : return pSym->VarientField.At.FirstUsed;
14707 : 0 : break;
14708 : :
14709 : 0 : case SymbolTable_EnumerationFieldSym:
14710 : 0 : return pSym->EnumerationField.At.FirstUsed;
14711 : 0 : break;
14712 : :
14713 : 0 : case SymbolTable_SetSym:
14714 : 0 : return pSym->Set.At.FirstUsed;
14715 : 0 : break;
14716 : :
14717 : 0 : case SymbolTable_DefImpSym:
14718 : 0 : return pSym->DefImp.At.FirstUsed;
14719 : 0 : break;
14720 : :
14721 : 0 : case SymbolTable_ModuleSym:
14722 : 0 : return pSym->Module.At.FirstUsed;
14723 : 0 : break;
14724 : :
14725 : :
14726 : 0 : default:
14727 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
14728 : : break;
14729 : : }
14730 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14731 : : __builtin_unreachable ();
14732 : : }
14733 : :
14734 : :
14735 : : /*
14736 : : PutProcedureBegin - assigns begin as the token number matching the
14737 : : procedure BEGIN.
14738 : : */
14739 : :
14740 : 78565 : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin)
14741 : : {
14742 : 78565 : SymbolTable_PtrToSymbol pSym;
14743 : :
14744 : 78565 : pSym = GetPsym (Sym);
14745 : 78565 : switch (pSym->SymbolType)
14746 : : {
14747 : 78565 : case SymbolTable_ProcedureSym:
14748 : 78565 : pSym->Procedure.Begin = begin;
14749 : 78565 : break;
14750 : :
14751 : :
14752 : 0 : default:
14753 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14754 : 78565 : break;
14755 : : }
14756 : 78565 : }
14757 : :
14758 : :
14759 : : /*
14760 : : PutProcedureEnd - assigns end as the token number matching the
14761 : : procedure END.
14762 : : */
14763 : :
14764 : 78535 : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end)
14765 : : {
14766 : 78535 : SymbolTable_PtrToSymbol pSym;
14767 : :
14768 : 78535 : pSym = GetPsym (Sym);
14769 : 78535 : switch (pSym->SymbolType)
14770 : : {
14771 : 78535 : case SymbolTable_ProcedureSym:
14772 : 78535 : pSym->Procedure.End = end;
14773 : 78535 : break;
14774 : :
14775 : :
14776 : 0 : default:
14777 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14778 : 78535 : break;
14779 : : }
14780 : 78535 : }
14781 : :
14782 : :
14783 : : /*
14784 : : GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
14785 : : */
14786 : :
14787 : 2504005 : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end)
14788 : : {
14789 : 2504005 : SymbolTable_PtrToSymbol pSym;
14790 : :
14791 : 2504005 : pSym = GetPsym (Sym);
14792 : 2504005 : switch (pSym->SymbolType)
14793 : : {
14794 : 2504005 : case SymbolTable_ProcedureSym:
14795 : 2504005 : (*begin) = pSym->Procedure.Begin;
14796 : 2504005 : (*end) = pSym->Procedure.End;
14797 : 2504005 : break;
14798 : :
14799 : :
14800 : 0 : default:
14801 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14802 : 2504005 : break;
14803 : : }
14804 : 2504005 : }
14805 : :
14806 : :
14807 : : /*
14808 : : ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
14809 : : */
14810 : :
14811 : 1737358 : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P)
14812 : : {
14813 : 1737358 : SymbolTable_PtrToSymbol pSym;
14814 : :
14815 : 1737358 : pSym = GetPsym (Sym);
14816 : 1737358 : switch (pSym->SymbolType)
14817 : : {
14818 : 352912 : case SymbolTable_DefImpSym:
14819 : 352912 : Lists_ForeachItemInListDo (pSym->DefImp.ListOfProcs, P);
14820 : 352912 : break;
14821 : :
14822 : 106252 : case SymbolTable_ModuleSym:
14823 : 106252 : Lists_ForeachItemInListDo (pSym->Module.ListOfProcs, P);
14824 : 106252 : break;
14825 : :
14826 : 1278194 : case SymbolTable_ProcedureSym:
14827 : 1278194 : Lists_ForeachItemInListDo (pSym->Procedure.ListOfProcs, P);
14828 : 1278194 : break;
14829 : :
14830 : :
14831 : 0 : default:
14832 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
14833 : 1737352 : break;
14834 : : }
14835 : 1737352 : }
14836 : :
14837 : :
14838 : : /*
14839 : : ForeachModuleDo - for each module do procedure, P.
14840 : : */
14841 : :
14842 : 52832 : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P)
14843 : : {
14844 : 52832 : SymbolKey_ForeachNodeDo (ModuleTree, P);
14845 : 52832 : }
14846 : :
14847 : :
14848 : : /*
14849 : : ForeachInnerModuleDo - for each inner module in module, Sym,
14850 : : do procedure, P.
14851 : : */
14852 : :
14853 : 2182869 : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P)
14854 : : {
14855 : 2182869 : SymbolTable_PtrToSymbol pSym;
14856 : :
14857 : 2182869 : pSym = GetPsym (Sym);
14858 : 2182869 : switch (pSym->SymbolType)
14859 : : {
14860 : 370366 : case SymbolTable_DefImpSym:
14861 : 370366 : Lists_ForeachItemInListDo (pSym->DefImp.ListOfModules, P);
14862 : 370366 : break;
14863 : :
14864 : 157164 : case SymbolTable_ModuleSym:
14865 : 157164 : Lists_ForeachItemInListDo (pSym->Module.ListOfModules, P);
14866 : 157164 : break;
14867 : :
14868 : 1655339 : case SymbolTable_ProcedureSym:
14869 : 1655339 : Lists_ForeachItemInListDo (pSym->Procedure.ListOfModules, P);
14870 : 1655339 : break;
14871 : :
14872 : :
14873 : 0 : default:
14874 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
14875 : 2182869 : break;
14876 : : }
14877 : 2182869 : }
14878 : :
14879 : :
14880 : : /*
14881 : : IsVarParam - Returns a conditional depending whether parameter ParamNo
14882 : : is a VAR parameter.
14883 : : */
14884 : :
14885 : 15678903 : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, unsigned int ParamNo)
14886 : : {
14887 : 15678903 : SymbolTable_PtrToSymbol pSym;
14888 : 15678903 : bool IsVar;
14889 : :
14890 : 15678903 : IsVar = false;
14891 : 15678903 : pSym = GetPsym (Sym);
14892 : 15678903 : switch (pSym->SymbolType)
14893 : : {
14894 : : case SymbolTable_ErrorSym:
14895 : : break;
14896 : :
14897 : 15485205 : case SymbolTable_ProcedureSym:
14898 : 15485205 : IsVar = IsNthParamVar (pSym->Procedure.ListOfParam, ParamNo);
14899 : 15485205 : break;
14900 : :
14901 : 193698 : case SymbolTable_ProcTypeSym:
14902 : 193698 : IsVar = IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
14903 : 193698 : break;
14904 : :
14905 : :
14906 : 0 : default:
14907 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14908 : 15678903 : break;
14909 : : }
14910 : 15678903 : return IsVar;
14911 : : /* static analysis guarentees a RETURN statement will be used before here. */
14912 : : __builtin_unreachable ();
14913 : : }
14914 : :
14915 : :
14916 : : /*
14917 : : IsUnboundedParam - Returns a conditional depending whether parameter
14918 : : ParamNo is an unbounded array procedure parameter.
14919 : : */
14920 : :
14921 : 15239240 : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, unsigned int ParamNo)
14922 : : {
14923 : 15239240 : unsigned int param;
14924 : :
14925 : 30478480 : M2Debug_Assert ((SymbolTable_IsProcedure (Sym)) || (SymbolTable_IsProcType (Sym)));
14926 : 15239240 : param = SymbolTable_GetNthParam (Sym, ParamNo);
14927 : 15239240 : return SymbolTable_IsParameterUnbounded (param);
14928 : : /* static analysis guarentees a RETURN statement will be used before here. */
14929 : : __builtin_unreachable ();
14930 : : }
14931 : :
14932 : :
14933 : : /*
14934 : : IsParameterUnbounded - returns TRUE if parameter, Sym, is
14935 : : unbounded.
14936 : : */
14937 : :
14938 : 15239252 : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym)
14939 : : {
14940 : 15239252 : SymbolTable_PtrToSymbol pSym;
14941 : :
14942 : 15239252 : pSym = GetPsym (Sym);
14943 : 15239252 : switch (pSym->SymbolType)
14944 : : {
14945 : 13862029 : case SymbolTable_ParamSym:
14946 : 13862029 : return pSym->Param.IsUnbounded;
14947 : 1377223 : break;
14948 : :
14949 : 1377223 : case SymbolTable_VarParamSym:
14950 : 1377223 : return pSym->VarParam.IsUnbounded;
14951 : 0 : break;
14952 : :
14953 : :
14954 : 0 : default:
14955 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
14956 : : break;
14957 : : }
14958 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14959 : : __builtin_unreachable ();
14960 : : }
14961 : :
14962 : :
14963 : : /*
14964 : : IsParameterVar - returns true if parameter symbol Sym
14965 : : was declared as a VAR.
14966 : : */
14967 : :
14968 : 18 : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym)
14969 : : {
14970 : 18 : SymbolTable_PtrToSymbol pSym;
14971 : :
14972 : 18 : pSym = GetPsym (Sym);
14973 : 18 : switch (pSym->SymbolType)
14974 : : {
14975 : : case SymbolTable_ParamSym:
14976 : : return false;
14977 : 0 : break;
14978 : :
14979 : 0 : case SymbolTable_VarParamSym:
14980 : 0 : return true;
14981 : 0 : break;
14982 : :
14983 : :
14984 : 0 : default:
14985 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
14986 : : break;
14987 : : }
14988 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14989 : : __builtin_unreachable ();
14990 : : }
14991 : :
14992 : :
14993 : : /*
14994 : : GetParameterShadowVar - returns the local variable associated with the
14995 : : parameter symbol, sym.
14996 : : */
14997 : :
14998 : 1177787 : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym)
14999 : : {
15000 : 1177787 : SymbolTable_PtrToSymbol pSym;
15001 : :
15002 : 1177787 : pSym = GetPsym (sym);
15003 : 1177787 : switch (pSym->SymbolType)
15004 : : {
15005 : 1046228 : case SymbolTable_ParamSym:
15006 : 1046228 : return pSym->Param.ShadowVar;
15007 : 131559 : break;
15008 : :
15009 : 131559 : case SymbolTable_VarParamSym:
15010 : 131559 : return pSym->VarParam.ShadowVar;
15011 : 0 : break;
15012 : :
15013 : :
15014 : 0 : default:
15015 : 0 : M2Error_InternalError ((const char *) "expecting a ParamSym or VarParamSym", 35);
15016 : : break;
15017 : : }
15018 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15019 : : __builtin_unreachable ();
15020 : : }
15021 : :
15022 : :
15023 : : /*
15024 : : NoOfParam - Returns the number of parameters that procedure Sym contains.
15025 : : */
15026 : :
15027 : 27425067 : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym)
15028 : : {
15029 : 27425067 : SymbolTable_PtrToSymbol pSym;
15030 : 27425067 : unsigned int n;
15031 : :
15032 : 27425067 : CheckLegal (Sym);
15033 : 27425067 : pSym = GetPsym (Sym);
15034 : 27425067 : switch (pSym->SymbolType)
15035 : : {
15036 : : case SymbolTable_ErrorSym:
15037 : : n = 0;
15038 : : break;
15039 : :
15040 : 25018762 : case SymbolTable_ProcedureSym:
15041 : 25018762 : n = Lists_NoOfItemsInList (pSym->Procedure.ListOfParam);
15042 : 25018762 : break;
15043 : :
15044 : 2406305 : case SymbolTable_ProcTypeSym:
15045 : 2406305 : n = Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
15046 : 2406305 : break;
15047 : :
15048 : :
15049 : 0 : default:
15050 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15051 : 27425067 : break;
15052 : : }
15053 : 27425067 : return n;
15054 : : /* static analysis guarentees a RETURN statement will be used before here. */
15055 : : __builtin_unreachable ();
15056 : : }
15057 : :
15058 : :
15059 : : /*
15060 : : HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
15061 : : */
15062 : :
15063 : 0 : extern "C" bool SymbolTable_HasVarParameters (unsigned int p)
15064 : : {
15065 : 0 : unsigned int i;
15066 : 0 : unsigned int n;
15067 : :
15068 : 0 : n = SymbolTable_NoOfParam (p);
15069 : 0 : i = 1;
15070 : 0 : while (i <= n)
15071 : : {
15072 : 0 : if (SymbolTable_IsVarParam (p, i))
15073 : : {
15074 : : return true;
15075 : : }
15076 : 0 : i += 1;
15077 : : }
15078 : : return false;
15079 : : /* static analysis guarentees a RETURN statement will be used before here. */
15080 : : __builtin_unreachable ();
15081 : : }
15082 : :
15083 : :
15084 : : /*
15085 : : NoOfLocalVar - returns the number of local variables that exist in
15086 : : procedure Sym. Parameters are NOT included in the
15087 : : count.
15088 : : */
15089 : :
15090 : 30 : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym)
15091 : : {
15092 : 30 : SymbolTable_PtrToSymbol pSym;
15093 : 30 : unsigned int n;
15094 : :
15095 : 30 : pSym = GetPsym (Sym);
15096 : 30 : switch (pSym->SymbolType)
15097 : : {
15098 : : case SymbolTable_ErrorSym:
15099 : : n = 0;
15100 : : break;
15101 : :
15102 : 30 : case SymbolTable_ProcedureSym:
15103 : 30 : n = Lists_NoOfItemsInList (pSym->Procedure.ListOfVars);
15104 : 30 : break;
15105 : :
15106 : :
15107 : 0 : default:
15108 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15109 : 30 : break;
15110 : : }
15111 : : /*
15112 : : Parameters are actually included in the list of local varaibles,
15113 : : therefore we must subtract the Parameter Number from local variable
15114 : : total.
15115 : : */
15116 : 30 : return n-(SymbolTable_NoOfParam (Sym));
15117 : : /* static analysis guarentees a RETURN statement will be used before here. */
15118 : : __builtin_unreachable ();
15119 : : }
15120 : :
15121 : :
15122 : : /*
15123 : : IsDefImp - returns true is the Sym is a DefImp symbol.
15124 : : Definition/Implementation module symbol.
15125 : : */
15126 : :
15127 : 177950353 : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym)
15128 : : {
15129 : 177950353 : SymbolTable_PtrToSymbol pSym;
15130 : :
15131 : 177950353 : pSym = GetPsym (Sym);
15132 : 177950353 : return pSym->SymbolType == SymbolTable_DefImpSym;
15133 : : /* static analysis guarentees a RETURN statement will be used before here. */
15134 : : __builtin_unreachable ();
15135 : : }
15136 : :
15137 : :
15138 : : /*
15139 : : IsModule - returns true is the Sym is a Module symbol.
15140 : : Program module symbol.
15141 : : */
15142 : :
15143 : 164926427 : extern "C" bool SymbolTable_IsModule (unsigned int Sym)
15144 : : {
15145 : 164926427 : SymbolTable_PtrToSymbol pSym;
15146 : :
15147 : 164926427 : pSym = GetPsym (Sym);
15148 : 164926427 : return pSym->SymbolType == SymbolTable_ModuleSym;
15149 : : /* static analysis guarentees a RETURN statement will be used before here. */
15150 : : __builtin_unreachable ();
15151 : : }
15152 : :
15153 : :
15154 : : /*
15155 : : IsInnerModule - returns true if the symbol, Sym, is an inner module.
15156 : : */
15157 : :
15158 : 6856915 : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym)
15159 : : {
15160 : 6856915 : if (SymbolTable_IsModule (Sym))
15161 : : {
15162 : 198500 : return (SymbolTable_GetScope (Sym)) != SymbolTable_NulSym;
15163 : : }
15164 : : else
15165 : : {
15166 : : return false;
15167 : : }
15168 : : /* static analysis guarentees a RETURN statement will be used before here. */
15169 : : __builtin_unreachable ();
15170 : : }
15171 : :
15172 : :
15173 : : /*
15174 : : GetSymName - returns the symbol name.
15175 : : */
15176 : :
15177 : 806312157 : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym)
15178 : : {
15179 : 806312157 : SymbolTable_PtrToSymbol pSym;
15180 : 806312157 : NameKey_Name n;
15181 : :
15182 : 806312157 : if (Sym == SymbolTable_NulSym)
15183 : : {
15184 : : n = SymbolKey_NulKey;
15185 : : }
15186 : : else
15187 : : {
15188 : 806312157 : pSym = GetPsym (Sym);
15189 : 806312157 : switch (pSym->SymbolType)
15190 : : {
15191 : 72 : case SymbolTable_ErrorSym:
15192 : 72 : n = pSym->Error.name;
15193 : 72 : break;
15194 : :
15195 : 8754984 : case SymbolTable_ObjectSym:
15196 : 8754984 : n = pSym->Object.name;
15197 : 8754984 : break;
15198 : :
15199 : 5326131 : case SymbolTable_DefImpSym:
15200 : 5326131 : n = pSym->DefImp.name;
15201 : 5326131 : break;
15202 : :
15203 : 448910 : case SymbolTable_ModuleSym:
15204 : 448910 : n = pSym->Module.name;
15205 : 448910 : break;
15206 : :
15207 : 629446932 : case SymbolTable_TypeSym:
15208 : 629446932 : n = pSym->Type.name;
15209 : 629446932 : break;
15210 : :
15211 : 6535805 : case SymbolTable_VarSym:
15212 : 6535805 : n = pSym->Var.name;
15213 : 6535805 : break;
15214 : :
15215 : 13713 : case SymbolTable_ConstLitSym:
15216 : 13713 : n = pSym->ConstLit.name;
15217 : 13713 : break;
15218 : :
15219 : 13829 : case SymbolTable_ConstVarSym:
15220 : 13829 : n = pSym->ConstVar.name;
15221 : 13829 : break;
15222 : :
15223 : 7810 : case SymbolTable_ConstStringSym:
15224 : 7810 : n = pSym->ConstString.name;
15225 : 7810 : break;
15226 : :
15227 : 161151 : case SymbolTable_EnumerationSym:
15228 : 161151 : n = pSym->Enumeration.name;
15229 : 161151 : break;
15230 : :
15231 : 1244620 : case SymbolTable_EnumerationFieldSym:
15232 : 1244620 : n = pSym->EnumerationField.name;
15233 : 1244620 : break;
15234 : :
15235 : 9632807 : case SymbolTable_UndefinedSym:
15236 : 9632807 : n = pSym->Undefined.name;
15237 : 9632807 : break;
15238 : :
15239 : 30429775 : case SymbolTable_ProcedureSym:
15240 : 30429775 : n = pSym->Procedure.name;
15241 : 30429775 : break;
15242 : :
15243 : 226798 : case SymbolTable_ProcTypeSym:
15244 : 226798 : n = pSym->ProcType.name;
15245 : 226798 : break;
15246 : :
15247 : 821930 : case SymbolTable_RecordFieldSym:
15248 : 821930 : n = pSym->RecordField.name;
15249 : 821930 : break;
15250 : :
15251 : 234582 : case SymbolTable_RecordSym:
15252 : 234582 : n = pSym->Record.name;
15253 : 234582 : break;
15254 : :
15255 : : case SymbolTable_VarientSym:
15256 : : n = NameKey_NulName;
15257 : : break;
15258 : :
15259 : 810 : case SymbolTable_VarientFieldSym:
15260 : 810 : n = pSym->VarientField.name;
15261 : 810 : break;
15262 : :
15263 : 139498 : case SymbolTable_VarParamSym:
15264 : 139498 : n = pSym->VarParam.name;
15265 : 139498 : break;
15266 : :
15267 : 1120999 : case SymbolTable_ParamSym:
15268 : 1120999 : n = pSym->Param.name;
15269 : 1120999 : break;
15270 : :
15271 : 42627130 : case SymbolTable_PointerSym:
15272 : 42627130 : n = pSym->Pointer.name;
15273 : 42627130 : break;
15274 : :
15275 : 75980 : case SymbolTable_ArraySym:
15276 : 75980 : n = pSym->Array.name;
15277 : 75980 : break;
15278 : :
15279 : : case SymbolTable_UnboundedSym:
15280 : : n = NameKey_NulName;
15281 : : break;
15282 : :
15283 : 279891 : case SymbolTable_SubrangeSym:
15284 : 279891 : n = pSym->Subrange.name;
15285 : 279891 : break;
15286 : :
15287 : 63812898 : case SymbolTable_SetSym:
15288 : 63812898 : n = pSym->Set.name;
15289 : 63812898 : break;
15290 : :
15291 : : case SymbolTable_SubscriptSym:
15292 : : n = NameKey_NulName;
15293 : : break;
15294 : :
15295 : : case SymbolTable_DummySym:
15296 : : n = NameKey_NulName;
15297 : : break;
15298 : :
15299 : 0 : case SymbolTable_PartialUnboundedSym:
15300 : 0 : n = SymbolTable_GetSymName (pSym->PartialUnbounded.Type);
15301 : 0 : break;
15302 : :
15303 : : case SymbolTable_TupleSym:
15304 : : n = NameKey_NulName;
15305 : : break;
15306 : :
15307 : : case SymbolTable_GnuAsmSym:
15308 : : n = NameKey_NulName;
15309 : : break;
15310 : :
15311 : : case SymbolTable_InterfaceSym:
15312 : : n = NameKey_NulName;
15313 : : break;
15314 : :
15315 : : case SymbolTable_ImportSym:
15316 : : n = NameKey_NulName;
15317 : : break;
15318 : :
15319 : : case SymbolTable_ImportStatementSym:
15320 : : n = NameKey_NulName;
15321 : : break;
15322 : :
15323 : :
15324 : 0 : default:
15325 : 0 : M2Error_InternalError ((const char *) "unexpected symbol type", 22);
15326 : 806312157 : break;
15327 : : }
15328 : : }
15329 : 806312157 : return n;
15330 : : /* static analysis guarentees a RETURN statement will be used before here. */
15331 : : __builtin_unreachable ();
15332 : : }
15333 : :
15334 : :
15335 : : /*
15336 : : RenameSym - renames a symbol, Sym, with SymName.
15337 : : It also checks the unknown tree for a symbol
15338 : : with this new name. Must only be renamed in
15339 : : the same scope of being declared.
15340 : : */
15341 : :
15342 : 0 : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName)
15343 : : {
15344 : 0 : SymbolTable_PtrToSymbol pSym;
15345 : :
15346 : 0 : if ((SymbolTable_GetSymName (Sym)) == NameKey_NulName)
15347 : : {
15348 : 0 : pSym = GetPsym (Sym);
15349 : 0 : switch (pSym->SymbolType)
15350 : : {
15351 : 0 : case SymbolTable_ErrorSym:
15352 : 0 : M2Error_ErrorAbort0 ((const char *) "", 0);
15353 : 0 : break;
15354 : :
15355 : 0 : case SymbolTable_TypeSym:
15356 : 0 : pSym->Type.name = SymName;
15357 : 0 : break;
15358 : :
15359 : 0 : case SymbolTable_VarSym:
15360 : 0 : pSym->Var.name = SymName;
15361 : 0 : break;
15362 : :
15363 : 0 : case SymbolTable_ConstLitSym:
15364 : 0 : pSym->ConstLit.name = SymName;
15365 : 0 : break;
15366 : :
15367 : 0 : case SymbolTable_ConstVarSym:
15368 : 0 : pSym->ConstVar.name = SymName;
15369 : 0 : break;
15370 : :
15371 : 0 : case SymbolTable_UndefinedSym:
15372 : 0 : pSym->Undefined.name = SymName;
15373 : 0 : break;
15374 : :
15375 : 0 : case SymbolTable_RecordSym:
15376 : 0 : pSym->Record.name = SymName;
15377 : 0 : break;
15378 : :
15379 : 0 : case SymbolTable_PointerSym:
15380 : 0 : pSym->Pointer.name = SymName;
15381 : 0 : break;
15382 : :
15383 : :
15384 : 0 : default:
15385 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
15386 : 0 : break;
15387 : : }
15388 : 0 : AddSymToScope (Sym, SymName);
15389 : : }
15390 : : else
15391 : : {
15392 : 0 : M2Error_InternalError ((const char *) "old name of symbol must be nul", 30);
15393 : : }
15394 : 0 : }
15395 : :
15396 : :
15397 : : /*
15398 : : IsUnknown - returns true is the symbol Sym is unknown.
15399 : : */
15400 : :
15401 : 31907752 : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym)
15402 : : {
15403 : 31907752 : SymbolTable_PtrToSymbol pSym;
15404 : :
15405 : 31907752 : CheckLegal (Sym);
15406 : 31907752 : pSym = GetPsym (Sym);
15407 : 31907752 : return pSym->SymbolType == SymbolTable_UndefinedSym;
15408 : : /* static analysis guarentees a RETURN statement will be used before here. */
15409 : : __builtin_unreachable ();
15410 : : }
15411 : :
15412 : :
15413 : : /*
15414 : : IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
15415 : : */
15416 : :
15417 : 1667489 : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym)
15418 : : {
15419 : 1667489 : SymbolTable_PtrToSymbol pSym;
15420 : :
15421 : 1667489 : if (sym > 0)
15422 : : {
15423 : 1667489 : pSym = GetPsym (sym);
15424 : 1667489 : switch (pSym->SymbolType)
15425 : : {
15426 : : case SymbolTable_PartialUnboundedSym:
15427 : : return true;
15428 : : break;
15429 : :
15430 : :
15431 : : default:
15432 : : return false;
15433 : : break;
15434 : : }
15435 : : }
15436 : : else
15437 : : {
15438 : : return false;
15439 : : }
15440 : : /* static analysis guarentees a RETURN statement will be used before here. */
15441 : : __builtin_unreachable ();
15442 : : }
15443 : :
15444 : :
15445 : : /*
15446 : : RequestSym - searches for a symbol with a name SymName in the
15447 : : current and previous scopes.
15448 : : If the symbol is found then it is returned
15449 : : else an unknown symbol is returned create at token
15450 : : position, tok.
15451 : : This procedure does search the base scope (for
15452 : : pervasive identifiers).
15453 : : */
15454 : :
15455 : 22340199 : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName)
15456 : : {
15457 : 22340199 : unsigned int Sym;
15458 : :
15459 : : /*
15460 : : WriteString('RequestSym for: ') ; WriteKey(SymName) ; WriteLn ;
15461 : : */
15462 : 22340199 : Sym = SymbolTable_GetSym (SymName);
15463 : 22340199 : if (Sym == SymbolTable_NulSym)
15464 : : {
15465 : 4050925 : Sym = GetSymFromUnknownTree (SymName);
15466 : 4050925 : if (Sym == SymbolTable_NulSym)
15467 : : {
15468 : : /* Make unknown */
15469 : 4050925 : NewSym (&Sym);
15470 : 4050925 : FillInUnknownFields (tok, Sym, SymName);
15471 : : /*
15472 : : ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
15473 : : */
15474 : 4050925 : AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
15475 : : }
15476 : : }
15477 : 22340199 : return Sym;
15478 : : /* static analysis guarentees a RETURN statement will be used before here. */
15479 : : __builtin_unreachable ();
15480 : : }
15481 : :
15482 : :
15483 : : /*
15484 : : PutImported - places a symbol, Sym, into the current main scope.
15485 : : */
15486 : :
15487 : 691174 : extern "C" void SymbolTable_PutImported (unsigned int Sym)
15488 : : {
15489 : 691174 : SymbolTable_PtrToSymbol pSym;
15490 : 691174 : unsigned int ModSym;
15491 : 691174 : NameKey_Name n;
15492 : :
15493 : : /*
15494 : : We have currently imported Sym, now place it into the current module.
15495 : : */
15496 : 691174 : ModSym = SymbolTable_GetCurrentModuleScope ();
15497 : 1382348 : M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
15498 : 691174 : pSym = GetPsym (ModSym);
15499 : 691174 : switch (pSym->SymbolType)
15500 : : {
15501 : 97595 : case SymbolTable_ModuleSym:
15502 : 97595 : if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
15503 : : {
15504 : : /* avoid dangling else. */
15505 : 84 : if (M2Options_Pedantic)
15506 : : {
15507 : 0 : n = SymbolTable_GetSymName (Sym);
15508 : 0 : M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
15509 : : }
15510 : : }
15511 : 97511 : else if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
15512 : : {
15513 : : /* avoid dangling else. */
15514 : 97511 : if ((SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym)) == SymbolKey_NulKey)
15515 : : {
15516 : 97511 : SymbolKey_PutSymKey (pSym->Module.WhereImported, Sym, M2LexBuf_GetTokenNo ());
15517 : : }
15518 : 97511 : SymbolKey_PutSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym), Sym);
15519 : 97511 : SymbolTable_AddSymToModuleScope (ModSym, Sym);
15520 : : }
15521 : : else
15522 : : {
15523 : : /* avoid dangling else. */
15524 : 0 : n = SymbolTable_GetSymName (Sym);
15525 : 0 : M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
15526 : : }
15527 : : break;
15528 : :
15529 : 593579 : case SymbolTable_DefImpSym:
15530 : 593579 : if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
15531 : : {
15532 : : /* avoid dangling else. */
15533 : 195 : if (M2Options_Pedantic)
15534 : : {
15535 : 0 : n = SymbolTable_GetSymName (Sym);
15536 : 0 : M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
15537 : : }
15538 : : }
15539 : 593384 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
15540 : : {
15541 : : /* avoid dangling else. */
15542 : 593384 : if ((SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym)) == SymbolKey_NulKey)
15543 : : {
15544 : 593384 : SymbolKey_PutSymKey (pSym->DefImp.WhereImported, Sym, M2LexBuf_GetTokenNo ());
15545 : : }
15546 : 593384 : SymbolKey_PutSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym), Sym);
15547 : 593384 : SymbolTable_AddSymToModuleScope (ModSym, Sym);
15548 : : }
15549 : : else
15550 : : {
15551 : : /* avoid dangling else. */
15552 : 0 : n = SymbolTable_GetSymName (Sym);
15553 : 0 : M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
15554 : : }
15555 : : break;
15556 : :
15557 : :
15558 : 0 : default:
15559 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
15560 : 691174 : break;
15561 : : }
15562 : 691174 : }
15563 : :
15564 : :
15565 : : /*
15566 : : PutIncluded - places a symbol, Sym, into the included list of the
15567 : : current module.
15568 : : Symbols that are placed in this list are indirectly declared
15569 : : by:
15570 : :
15571 : : IMPORT modulename ;
15572 : :
15573 : : modulename.identifier
15574 : : */
15575 : :
15576 : 306059 : extern "C" void SymbolTable_PutIncluded (unsigned int Sym)
15577 : : {
15578 : 306059 : SymbolTable_PtrToSymbol pSym;
15579 : 306059 : unsigned int ModSym;
15580 : 306059 : NameKey_Name n1;
15581 : 306059 : NameKey_Name n2;
15582 : :
15583 : : /*
15584 : : We have referenced Sym, via modulename.Sym
15585 : : now place it into the current module include list.
15586 : : */
15587 : 306059 : ModSym = SymbolTable_GetCurrentModuleScope ();
15588 : 612118 : M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
15589 : 306059 : if (DebugUnknowns)
15590 : : {
15591 : : n1 = SymbolTable_GetSymName (Sym);
15592 : : n2 = SymbolTable_GetSymName (ModSym);
15593 : : 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));
15594 : : }
15595 : 306059 : pSym = GetPsym (ModSym);
15596 : 306059 : switch (pSym->SymbolType)
15597 : : {
15598 : 468 : case SymbolTable_ModuleSym:
15599 : 468 : Lists_IncludeItemIntoList (pSym->Module.IncludeList, Sym);
15600 : 468 : break;
15601 : :
15602 : 305591 : case SymbolTable_DefImpSym:
15603 : 305591 : Lists_IncludeItemIntoList (pSym->DefImp.IncludeList, Sym);
15604 : 305591 : break;
15605 : :
15606 : :
15607 : 0 : default:
15608 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
15609 : 306059 : break;
15610 : : }
15611 : 306059 : }
15612 : :
15613 : :
15614 : : /*
15615 : : PutExported - places a symbol, Sym into the next level out module.
15616 : : Sym is also placed in the ExportTree of the current inner
15617 : : module.
15618 : : */
15619 : :
15620 : 276 : extern "C" void SymbolTable_PutExported (unsigned int Sym)
15621 : : {
15622 : 276 : SymbolTable_PtrToSymbol pSym;
15623 : :
15624 : : /*
15625 : : WriteString('PutExported') ; WriteLn ;
15626 : : */
15627 : 276 : SymbolTable_AddSymToModuleScope (GetLastModuleOrProcedureScope (), Sym);
15628 : 276 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
15629 : 276 : switch (pSym->SymbolType)
15630 : : {
15631 : 276 : case SymbolTable_ModuleSym:
15632 : 276 : SymbolKey_PutSymKey (pSym->Module.ExportTree, SymbolTable_GetSymName (Sym), Sym);
15633 : 276 : if (SymbolTable_IsUnknown (Sym))
15634 : : {
15635 : 276 : PutExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
15636 : : }
15637 : : /*
15638 : : ; WriteKey(Module.name) ; WriteString(' exports ') ;
15639 : : ; WriteKey(GetSymName(Sym)) ; WriteLn ;
15640 : : */
15641 : 276 : break;
15642 : :
15643 : :
15644 : 0 : default:
15645 : 0 : M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
15646 : 276 : break;
15647 : : }
15648 : 276 : }
15649 : :
15650 : :
15651 : : /*
15652 : : PutExportQualified - places a symbol with the name, SymName,
15653 : : into the export tree of the
15654 : : Definition module being compiled.
15655 : : The symbol with name has been EXPORT QUALIFIED
15656 : : by the definition module and therefore any reference
15657 : : to this symbol in the code generation phase
15658 : : will be in the form _Module_Name.
15659 : : */
15660 : :
15661 : 2828532 : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName)
15662 : : {
15663 : 2828532 : SymbolTable_PtrToSymbol pSym;
15664 : 2828532 : NameKey_Name n;
15665 : 2828532 : unsigned int Sym;
15666 : 2828532 : unsigned int ModSym;
15667 : :
15668 : 2828532 : ModSym = SymbolTable_GetCurrentModule ();
15669 : 2828532 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
15670 : 5657064 : M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
15671 : : /*
15672 : : WriteString('1st MODULE ') ; WriteKey(GetSymName(ModSym)) ;
15673 : : WriteString(' identifier ') ; WriteKey(SymName) ; WriteLn ;
15674 : : */
15675 : 2828532 : pSym = GetPsym (ModSym);
15676 : 2828532 : switch (pSym->SymbolType)
15677 : : {
15678 : 2828532 : case SymbolTable_DefImpSym:
15679 : 2828532 : if (((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
15680 : : {
15681 : 0 : n = SymbolTable_GetSymName (ModSym);
15682 : 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));
15683 : : }
15684 : 2828532 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
15685 : : {
15686 : : /* avoid dangling else. */
15687 : 251683 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
15688 : 251683 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
15689 : 251683 : SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
15690 : 251683 : PutExportUndeclared (ModSym, Sym);
15691 : : }
15692 : : else
15693 : : {
15694 : : /* avoid dangling else. */
15695 : 2576849 : Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
15696 : 2576849 : SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
15697 : 2576849 : PutExportUndeclared (ModSym, Sym);
15698 : : }
15699 : 2828532 : break;
15700 : :
15701 : :
15702 : 0 : default:
15703 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
15704 : 2828532 : break;
15705 : : }
15706 : 2828532 : }
15707 : :
15708 : :
15709 : : /*
15710 : : PutExportUnQualified - places a symbol with the name, SymName,
15711 : : into the export tree of the
15712 : : Definition module being compiled.
15713 : : The symbol with Name has been EXPORT UNQUALIFIED
15714 : : by the definition module and therefore any reference
15715 : : to this symbol in the code generation phase
15716 : : will be in the form _Name.
15717 : : */
15718 : :
15719 : 319738 : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName)
15720 : : {
15721 : 319738 : SymbolTable_PtrToSymbol pSym;
15722 : 319738 : NameKey_Name n;
15723 : 319738 : unsigned int Sym;
15724 : 319738 : unsigned int ModSym;
15725 : :
15726 : 319738 : ModSym = SymbolTable_GetCurrentModule ();
15727 : 319738 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
15728 : 639476 : M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
15729 : 319738 : pSym = GetPsym (ModSym);
15730 : 319738 : switch (pSym->SymbolType)
15731 : : {
15732 : 319738 : case SymbolTable_DefImpSym:
15733 : 319738 : if (((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
15734 : : {
15735 : 0 : n = SymbolTable_GetSymName (ModSym);
15736 : 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));
15737 : : }
15738 : 319738 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
15739 : : {
15740 : : /* avoid dangling else. */
15741 : 24419 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
15742 : 24419 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
15743 : 24419 : SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
15744 : 24419 : PutExportUndeclared (ModSym, Sym);
15745 : : }
15746 : : else
15747 : : {
15748 : : /* avoid dangling else. */
15749 : 295319 : Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
15750 : 295319 : SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
15751 : 295319 : PutExportUndeclared (ModSym, Sym);
15752 : : }
15753 : 319738 : break;
15754 : :
15755 : :
15756 : 0 : default:
15757 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
15758 : 319738 : break;
15759 : : }
15760 : 319738 : }
15761 : :
15762 : :
15763 : : /*
15764 : : PutExportUnImplemented - places a symbol, Sym, into the currently compiled
15765 : : DefImp module NeedToBeImplemented list.
15766 : : */
15767 : :
15768 : 2041245 : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym)
15769 : : {
15770 : 2041245 : SymbolTable_PtrToSymbol pSym;
15771 : :
15772 : 2041245 : pSym = GetPsym (CurrentModule);
15773 : 2041245 : switch (pSym->SymbolType)
15774 : : {
15775 : 2041245 : case SymbolTable_DefImpSym:
15776 : 2041245 : if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
15777 : : {
15778 : : /*
15779 : : n1 := GetSymName (Sym) ;
15780 : : n2 := GetSymName (CurrentModule) ;
15781 : : WriteFormat2 ('symbol (%a) already exported from module (%a)', n1, n2)
15782 : : */
15783 : 0 : M2MetaError_MetaErrorT2 (tokenno, (const char *) "symbol {%1a} is already exported from module {%2a}", 50, Sym, CurrentModule);
15784 : : }
15785 : : else
15786 : : {
15787 : 2041245 : SymbolKey_PutSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym), Sym);
15788 : : }
15789 : 2041245 : break;
15790 : :
15791 : :
15792 : 0 : default:
15793 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
15794 : 2041245 : break;
15795 : : }
15796 : 2041245 : }
15797 : :
15798 : :
15799 : : /*
15800 : : GetExported - returns the symbol which has a name SymName,
15801 : : and is exported from the definition module ModSym.
15802 : :
15803 : : */
15804 : :
15805 : 1949843 : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName)
15806 : : {
15807 : 1949843 : SymbolTable_PtrToSymbol pSym;
15808 : 1949843 : unsigned int Sym;
15809 : :
15810 : 1949843 : pSym = GetPsym (ModSym);
15811 : 1949843 : switch (pSym->SymbolType)
15812 : : {
15813 : 1949735 : case SymbolTable_DefImpSym:
15814 : 1949735 : Sym = RequestFromDefinition (tokenno, ModSym, SymName);
15815 : 1949735 : break;
15816 : :
15817 : 108 : case SymbolTable_ModuleSym:
15818 : 108 : Sym = RequestFromModule (tokenno, ModSym, SymName);
15819 : 108 : break;
15820 : :
15821 : :
15822 : 0 : default:
15823 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
15824 : 1949843 : break;
15825 : : }
15826 : 1949843 : return Sym;
15827 : : /* static analysis guarentees a RETURN statement will be used before here. */
15828 : : __builtin_unreachable ();
15829 : : }
15830 : :
15831 : :
15832 : : /*
15833 : : GetFromOuterModule - returns a symbol with name, SymName, which comes
15834 : : from outside the current module.
15835 : : */
15836 : :
15837 : 324 : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName)
15838 : : {
15839 : 324 : SymbolTable_PtrToCallFrame pCall;
15840 : 324 : unsigned int ScopeId;
15841 : 324 : unsigned int Sym;
15842 : 324 : unsigned int ScopeSym;
15843 : :
15844 : 324 : ScopeId = ScopePtr;
15845 : 324 : pCall = GetPcall (ScopeId);
15846 : 672 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
15847 : : {
15848 : 24 : M2Debug_Assert (ScopeId > 0);
15849 : 24 : ScopeId -= 1;
15850 : 24 : pCall = GetPcall (ScopeId);
15851 : : }
15852 : 324 : ScopeId -= 1;
15853 : : /* we are now below the current module */
15854 : 480 : while (ScopeId > 0)
15855 : : {
15856 : 480 : pCall = GetPcall (ScopeId);
15857 : 480 : ScopeSym = pCall->Search;
15858 : 480 : if (ScopeSym != SymbolTable_NulSym)
15859 : : {
15860 : 480 : Sym = SymbolTable_GetLocalSym (ScopeSym, SymName);
15861 : 480 : if (Sym == SymbolTable_NulSym)
15862 : : {
15863 : : /* avoid dangling else. */
15864 : 168 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsProcedure (ScopeSym))) || (SymbolTable_IsDefImp (ScopeSym)))
15865 : : {
15866 : 132 : if (Sym == SymbolTable_NulSym)
15867 : : {
15868 : 132 : Sym = ExamineUnresolvedTree (ScopeSym, SymName);
15869 : 132 : if (Sym != SymbolTable_NulSym)
15870 : : {
15871 : 12 : return Sym;
15872 : : }
15873 : : }
15874 : : }
15875 : : }
15876 : : else
15877 : : {
15878 : 312 : return Sym;
15879 : : }
15880 : : }
15881 : 156 : ScopeId -= 1;
15882 : 156 : pCall = GetPcall (ScopeId);
15883 : : }
15884 : : /* at this point we force an unknown from the last module scope */
15885 : 0 : return RequestFromModule (tokenno, SymbolTable_GetLastModuleScope (), SymName);
15886 : : /* static analysis guarentees a RETURN statement will be used before here. */
15887 : : __builtin_unreachable ();
15888 : : }
15889 : :
15890 : :
15891 : : /*
15892 : : TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
15893 : : name, name, which is
15894 : : currently undefined in the
15895 : : outer scope to the inner scope.
15896 : : If successful then the symbol is
15897 : : returned otherwise NulSym is
15898 : : returned.
15899 : : */
15900 : :
15901 : 234 : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name)
15902 : : {
15903 : 234 : SymbolTable_PtrToSymbol pSym;
15904 : 234 : unsigned int sym;
15905 : :
15906 : : /* assume this should not be called if OuterScope was a procedure
15907 : : as this case is handled by the caller (P1SymBuild)
15908 : : */
15909 : 468 : M2Debug_Assert ((SymbolTable_IsModule (OuterScope)) || (SymbolTable_IsDefImp (OuterScope)));
15910 : 234 : sym = GetExportUndeclared (OuterScope, name);
15911 : 234 : if (sym != SymbolTable_NulSym)
15912 : : {
15913 : 18 : M2Debug_Assert (SymbolTable_IsUnknown (sym));
15914 : 18 : RemoveExportUndeclared (OuterScope, sym);
15915 : 18 : SymbolTable_AddSymToModuleScope (OuterScope, sym);
15916 : 18 : AddVarToScopeList (OuterScope, sym);
15917 : 18 : pSym = GetPsym (OuterScope);
15918 : 18 : switch (pSym->SymbolType)
15919 : : {
15920 : 0 : case SymbolTable_DefImpSym:
15921 : 0 : if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) == sym)
15922 : : {
15923 : 0 : SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
15924 : : }
15925 : : break;
15926 : :
15927 : 18 : case SymbolTable_ModuleSym:
15928 : 18 : if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) == sym)
15929 : : {
15930 : 18 : SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
15931 : : }
15932 : : break;
15933 : :
15934 : :
15935 : 0 : default:
15936 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module symbol", 31);
15937 : 18 : break;
15938 : : }
15939 : 18 : AddSymToUnknown (InnerScope, name, sym);
15940 : 18 : PutExportUndeclared (InnerScope, sym);
15941 : : }
15942 : 234 : return sym;
15943 : : /* static analysis guarentees a RETURN statement will be used before here. */
15944 : : __builtin_unreachable ();
15945 : : }
15946 : :
15947 : :
15948 : : /*
15949 : : IsExportQualified - returns true if a symbol, Sym, was defined as
15950 : : being EXPORT QUALIFIED.
15951 : : Sym is expected to be either a procedure or a
15952 : : variable.
15953 : : */
15954 : :
15955 : 6135699 : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym)
15956 : : {
15957 : 6135699 : SymbolTable_PtrToSymbol pSym;
15958 : 6135699 : unsigned int OuterModule;
15959 : :
15960 : 6135699 : OuterModule = Sym;
15961 : 6799254 : do {
15962 : 6799254 : OuterModule = SymbolTable_GetScope (OuterModule);
15963 : 6799254 : } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
15964 : 6135699 : pSym = GetPsym (OuterModule);
15965 : 6135699 : switch (pSym->SymbolType)
15966 : : {
15967 : : case SymbolTable_ModuleSym:
15968 : : return false;
15969 : 5701526 : break;
15970 : :
15971 : 5701526 : case SymbolTable_DefImpSym:
15972 : 5701526 : return (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
15973 : 0 : break;
15974 : :
15975 : :
15976 : 0 : default:
15977 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
15978 : : break;
15979 : : }
15980 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15981 : : __builtin_unreachable ();
15982 : : }
15983 : :
15984 : :
15985 : : /*
15986 : : IsExportUnQualified - returns true if a symbol, Sym, was defined as
15987 : : being EXPORT UNQUALIFIED.
15988 : : */
15989 : :
15990 : 2696496 : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym)
15991 : : {
15992 : 2696496 : SymbolTable_PtrToSymbol pSym;
15993 : 2696496 : unsigned int OuterModule;
15994 : :
15995 : 2696496 : OuterModule = Sym;
15996 : 2696496 : do {
15997 : 2696496 : OuterModule = SymbolTable_GetScope (OuterModule);
15998 : 2696496 : } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
15999 : 2696496 : pSym = GetPsym (OuterModule);
16000 : 2696496 : switch (pSym->SymbolType)
16001 : : {
16002 : : case SymbolTable_ModuleSym:
16003 : : return false;
16004 : 2601246 : break;
16005 : :
16006 : 2601246 : case SymbolTable_DefImpSym:
16007 : 2601246 : return (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
16008 : 0 : break;
16009 : :
16010 : :
16011 : 0 : default:
16012 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16013 : : break;
16014 : : }
16015 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16016 : : __builtin_unreachable ();
16017 : : }
16018 : :
16019 : :
16020 : : /*
16021 : : IsExported - returns true if a symbol, Sym, is exported
16022 : : from module, ModSym.
16023 : : If ModSym is a DefImp symbol then its
16024 : : ExportQualified and ExportUnQualified lists are examined.
16025 : : */
16026 : :
16027 : 4924212 : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym)
16028 : : {
16029 : 4924212 : SymbolTable_PtrToSymbol pSym;
16030 : 4924212 : NameKey_Name SymName;
16031 : :
16032 : 4924212 : SymName = SymbolTable_GetSymName (Sym);
16033 : 4924212 : pSym = GetPsym (ModSym);
16034 : 4924212 : switch (pSym->SymbolType)
16035 : : {
16036 : 4463840 : case SymbolTable_DefImpSym:
16037 : 4463840 : return ((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) == Sym) || ((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) == Sym);
16038 : 460372 : break;
16039 : :
16040 : 460372 : case SymbolTable_ModuleSym:
16041 : 460372 : return (SymbolKey_GetSymKey (pSym->Module.ExportTree, SymName)) == Sym;
16042 : 0 : break;
16043 : :
16044 : :
16045 : 0 : default:
16046 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16047 : : break;
16048 : : }
16049 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16050 : : __builtin_unreachable ();
16051 : : }
16052 : :
16053 : :
16054 : : /*
16055 : : IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
16056 : : ModSym must be a defimp symbol.
16057 : : */
16058 : :
16059 : 78 : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym)
16060 : : {
16061 : 78 : unsigned int type;
16062 : 78 : SymbolTable_PtrToSymbol pSym;
16063 : :
16064 : 78 : if ((SymbolTable_IsDefImp (ModSym)) && (SymbolTable_IsFieldEnumeration (Sym)))
16065 : : {
16066 : 66 : pSym = GetPsym (ModSym);
16067 : 66 : type = SymbolTable_SkipType (SymbolTable_GetType (Sym));
16068 : 66 : return Lists_IsItemInList (pSym->DefImp.EnumerationScopeList, type);
16069 : : }
16070 : : return false;
16071 : : /* static analysis guarentees a RETURN statement will be used before here. */
16072 : : __builtin_unreachable ();
16073 : : }
16074 : :
16075 : :
16076 : : /*
16077 : : IsImported - returns true if a symbol, Sym, in module, ModSym,
16078 : : was imported.
16079 : : */
16080 : :
16081 : 7682398 : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym)
16082 : : {
16083 : 7682398 : SymbolTable_PtrToSymbol pSym;
16084 : 7682398 : NameKey_Name SymName;
16085 : :
16086 : 7682398 : SymName = SymbolTable_GetSymName (Sym);
16087 : 7682398 : pSym = GetPsym (ModSym);
16088 : 7682398 : switch (pSym->SymbolType)
16089 : : {
16090 : 1395444 : case SymbolTable_DefImpSym:
16091 : 1395444 : return ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->DefImp.IncludeList, Sym));
16092 : 6286954 : break;
16093 : :
16094 : 6286954 : case SymbolTable_ModuleSym:
16095 : 6286954 : return ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->Module.IncludeList, Sym));
16096 : 0 : break;
16097 : :
16098 : :
16099 : 0 : default:
16100 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16101 : : break;
16102 : : }
16103 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16104 : : __builtin_unreachable ();
16105 : : }
16106 : :
16107 : :
16108 : : /*
16109 : : PutIncludedByDefinition - places a module symbol, Sym, into the
16110 : : included list of the current definition module.
16111 : : */
16112 : :
16113 : 8392 : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym)
16114 : : {
16115 : 8392 : SymbolTable_PtrToSymbol pSym;
16116 : 8392 : unsigned int ModSym;
16117 : :
16118 : 8392 : ModSym = SymbolTable_GetCurrentModuleScope ();
16119 : 8392 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16120 : 8392 : M2Debug_Assert (SymbolTable_IsDefImp (Sym));
16121 : 8392 : pSym = GetPsym (ModSym);
16122 : 8392 : switch (pSym->SymbolType)
16123 : : {
16124 : 8392 : case SymbolTable_DefImpSym:
16125 : 8392 : Lists_IncludeItemIntoList (pSym->DefImp.DefIncludeList, Sym);
16126 : 8392 : break;
16127 : :
16128 : :
16129 : 0 : default:
16130 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16131 : 8392 : break;
16132 : : }
16133 : 8392 : }
16134 : :
16135 : :
16136 : : /*
16137 : : IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
16138 : : by ModSym's definition module.
16139 : : */
16140 : :
16141 : 12 : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym)
16142 : : {
16143 : 12 : SymbolTable_PtrToSymbol pSym;
16144 : :
16145 : 12 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16146 : 12 : M2Debug_Assert (SymbolTable_IsDefImp (Sym));
16147 : 12 : pSym = GetPsym (ModSym);
16148 : 12 : switch (pSym->SymbolType)
16149 : : {
16150 : 12 : case SymbolTable_DefImpSym:
16151 : 12 : return Lists_IsItemInList (pSym->DefImp.DefIncludeList, Sym);
16152 : 0 : break;
16153 : :
16154 : :
16155 : 0 : default:
16156 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16157 : : break;
16158 : : }
16159 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16160 : : __builtin_unreachable ();
16161 : : }
16162 : :
16163 : :
16164 : : /*
16165 : : ForeachImportedDo - calls a procedure, P, foreach imported symbol
16166 : : in module, ModSym.
16167 : : */
16168 : :
16169 : 16632 : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
16170 : : {
16171 : 16632 : SymbolTable_PtrToSymbol pSym;
16172 : :
16173 : 16632 : pSym = GetPsym (ModSym);
16174 : 16632 : switch (pSym->SymbolType)
16175 : : {
16176 : 6722 : case SymbolTable_DefImpSym:
16177 : 6722 : SymbolKey_ForeachNodeDo (pSym->DefImp.ImportTree, P);
16178 : 6722 : Lists_ForeachItemInListDo (pSym->DefImp.IncludeList, P);
16179 : 6722 : break;
16180 : :
16181 : 9910 : case SymbolTable_ModuleSym:
16182 : 9910 : SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, P);
16183 : 9910 : Lists_ForeachItemInListDo (pSym->Module.IncludeList, P);
16184 : 9910 : break;
16185 : :
16186 : :
16187 : 0 : default:
16188 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16189 : 16632 : break;
16190 : : }
16191 : 16632 : }
16192 : :
16193 : :
16194 : : /*
16195 : : ForeachExportedDo - calls a procedure, P, foreach imported symbol
16196 : : in module, ModSym.
16197 : : */
16198 : :
16199 : 7876 : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
16200 : : {
16201 : 7876 : SymbolTable_PtrToSymbol pSym;
16202 : :
16203 : 7876 : pSym = GetPsym (ModSym);
16204 : 7876 : switch (pSym->SymbolType)
16205 : : {
16206 : 2839 : case SymbolTable_DefImpSym:
16207 : 2839 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, P);
16208 : 2839 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, P);
16209 : 2839 : break;
16210 : :
16211 : 5037 : case SymbolTable_ModuleSym:
16212 : 5037 : SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, P);
16213 : 5037 : break;
16214 : :
16215 : :
16216 : 0 : default:
16217 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16218 : 7876 : break;
16219 : : }
16220 : 7876 : }
16221 : :
16222 : :
16223 : : /*
16224 : : CheckForExportedImplementation - checks to see whether an implementation
16225 : : module is currently being compiled, if so,
16226 : : symbol, Sym, is removed from the
16227 : : NeedToBeImplemented list.
16228 : : This procedure is called whenever a symbol
16229 : : is declared, thus attempting to reduce
16230 : : the NeedToBeImplemented list.
16231 : : Only needs to be called when a TYPE or
16232 : : PROCEDURE is built since the implementation
16233 : : module can only implement these objects
16234 : : declared in the definition module.
16235 : :
16236 : : It also checks whether a definition module
16237 : : is currently being compiled and, if so,
16238 : : it will ensure that symbol, Sym, is removed
16239 : : from the ExportRequest list. If Sym is an
16240 : : enumerated type it ensures that its fields
16241 : : are also removed.
16242 : : */
16243 : :
16244 : 1274690 : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym)
16245 : : {
16246 : 1274690 : if (M2Comp_CompilingImplementationModule ())
16247 : : {
16248 : 1143942 : RemoveExportUnImplemented (SymbolTable_GetCurrentModule (), Sym);
16249 : : }
16250 : 1274690 : if ((M2Comp_CompilingDefinitionModule ()) && (SymbolTable_IsEnumeration (Sym)))
16251 : : {
16252 : 12722 : RemoveEnumerationFromExportRequest (SymbolTable_GetCurrentModule (), Sym);
16253 : : }
16254 : 1274690 : }
16255 : :
16256 : :
16257 : : /*
16258 : : CheckForUnImplementedExports - displays an error and the offending symbols
16259 : : which have been exported but not implemented
16260 : : from the current compiled module.
16261 : : */
16262 : :
16263 : 52770 : extern "C" void SymbolTable_CheckForUnImplementedExports (void)
16264 : : {
16265 : 52770 : SymbolTable_PtrToSymbol pSym;
16266 : :
16267 : : /* WriteString('Inside CheckForImplementedExports') ; WriteLn ; */
16268 : 52770 : pSym = GetPsym (CurrentModule);
16269 : 52770 : switch (pSym->SymbolType)
16270 : : {
16271 : 52770 : case SymbolTable_DefImpSym:
16272 : 52770 : if (! (SymbolKey_IsEmptyTree (pSym->DefImp.NeedToBeImplemented)))
16273 : : {
16274 : 0 : CurrentError = M2Error_NewError (M2LexBuf_GetTokenNo ());
16275 : 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));
16276 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NeedToBeImplemented, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnImplementedSymbolError});
16277 : : }
16278 : 52770 : break;
16279 : :
16280 : :
16281 : 0 : default:
16282 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16283 : 52770 : break;
16284 : : }
16285 : 52770 : }
16286 : :
16287 : :
16288 : : /*
16289 : : CheckForUndeclaredExports - displays an error and the offending symbols
16290 : : which have been exported but not declared
16291 : : from module, ModSym.
16292 : : */
16293 : :
16294 : 136167 : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym)
16295 : : {
16296 : 136167 : SymbolTable_PtrToSymbol pSym;
16297 : :
16298 : : /* WriteString('Inside CheckForUndeclaredExports') ; WriteLn ; */
16299 : 136167 : pSym = GetPsym (ModSym);
16300 : 136167 : switch (pSym->SymbolType)
16301 : : {
16302 : 10774 : case SymbolTable_ModuleSym:
16303 : 10774 : if (! (SymbolKey_IsEmptyTree (pSym->Module.ExportUndeclared)))
16304 : : {
16305 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in EXPORT list of {%1ERd} {%1a}", 56, ModSym);
16306 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
16307 : : }
16308 : : break;
16309 : :
16310 : 125393 : case SymbolTable_DefImpSym:
16311 : 125393 : if (! (SymbolKey_IsEmptyTree (pSym->DefImp.ExportUndeclared)))
16312 : : {
16313 : 0 : if (SymbolTable_DoesNotNeedExportList (ModSym))
16314 : : {
16315 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in {%1ERd} {%1a}", 41, ModSym);
16316 : : }
16317 : : else
16318 : : {
16319 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in export list of {%1ERd} {%1a}", 56, ModSym);
16320 : : }
16321 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
16322 : : }
16323 : : break;
16324 : :
16325 : :
16326 : 0 : default:
16327 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16328 : 136167 : break;
16329 : : }
16330 : 136167 : }
16331 : :
16332 : :
16333 : : /*
16334 : : CheckForUnknownInModule - checks for any unknown symbols in the
16335 : : current module.
16336 : : If any unknown symbols are found then
16337 : : an error message is displayed.
16338 : : */
16339 : :
16340 : 377034 : extern "C" void SymbolTable_CheckForUnknownInModule (void)
16341 : : {
16342 : 377034 : SymbolTable_PtrToSymbol pSym;
16343 : :
16344 : 377034 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
16345 : 377034 : switch (pSym->SymbolType)
16346 : : {
16347 : 355618 : case SymbolTable_DefImpSym:
16348 : 355618 : CheckForUnknowns (pSym->DefImp.name, pSym->DefImp.ExportQualifiedTree, (const char *) "EXPORT QUALIFIED", 16);
16349 : 355618 : CheckForUnknowns (pSym->DefImp.name, pSym->DefImp.ExportUnQualifiedTree, (const char *) "EXPORT UNQUALIFIED", 18);
16350 : 355618 : CheckForSymbols (pSym->DefImp.ExportRequest, (const char *) "requested by another modules import (symbols have not been exported by the appropriate definition module)", 105);
16351 : 355618 : CheckForUnknowns (pSym->DefImp.name, pSym->DefImp.Unresolved, (const char *) "unresolved", 10);
16352 : 355618 : CheckForUnknowns (pSym->DefImp.name, pSym->DefImp.LocalSymbols, (const char *) "locally used", 12);
16353 : 355618 : break;
16354 : :
16355 : 21416 : case SymbolTable_ModuleSym:
16356 : 21416 : CheckForUnknowns (pSym->Module.name, pSym->Module.Unresolved, (const char *) "unresolved", 10);
16357 : 21416 : CheckForUnknowns (pSym->Module.name, pSym->Module.ExportUndeclared, (const char *) "exported but undeclared", 23);
16358 : 21416 : CheckForUnknowns (pSym->Module.name, pSym->Module.ExportTree, (const char *) "exported but undeclared", 23);
16359 : 21416 : CheckForUnknowns (pSym->Module.name, pSym->Module.LocalSymbols, (const char *) "locally used", 12);
16360 : 21416 : break;
16361 : :
16362 : :
16363 : 0 : default:
16364 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16365 : 377034 : break;
16366 : : }
16367 : 377034 : }
16368 : :
16369 : :
16370 : : /*
16371 : : UnknownReported - if sym is an unknown symbol and has not been reported
16372 : : then include it into the set of reported unknowns.
16373 : : */
16374 : :
16375 : 0 : extern "C" void SymbolTable_UnknownReported (unsigned int sym)
16376 : : {
16377 : 0 : if (IsUnreportedUnknown (sym))
16378 : : {
16379 : 0 : Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
16380 : : }
16381 : 0 : }
16382 : :
16383 : :
16384 : : /*
16385 : : IsReallyPointer - returns TRUE is sym is a pointer, address or a
16386 : : type declared as a pointer or address.
16387 : : */
16388 : :
16389 : 240300 : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym)
16390 : : {
16391 : 240300 : if (SymbolTable_IsVar (Sym))
16392 : : {
16393 : 8650 : Sym = SymbolTable_GetType (Sym);
16394 : : }
16395 : 240300 : Sym = SymbolTable_SkipType (Sym);
16396 : 240300 : return (SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address);
16397 : : /* static analysis guarentees a RETURN statement will be used before here. */
16398 : : __builtin_unreachable ();
16399 : : }
16400 : :
16401 : :
16402 : : /*
16403 : : CheckHiddenTypeAreAddress - checks to see that any hidden types
16404 : : which we have declared are actually
16405 : : of type ADDRESS or map onto a POINTER type.
16406 : : */
16407 : :
16408 : 16308 : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void)
16409 : : {
16410 : 16308 : NameKey_Name name;
16411 : 16308 : M2Error_Error e;
16412 : 16308 : unsigned int sym;
16413 : 16308 : unsigned int i;
16414 : 16308 : unsigned int n;
16415 : :
16416 : 16308 : i = 1;
16417 : 16308 : n = Lists_NoOfItemsInList (AddressTypes);
16418 : 55726 : while (i <= n)
16419 : : {
16420 : 23110 : sym = static_cast<unsigned int> (Lists_GetItemFromList (AddressTypes, i));
16421 : 23110 : if (! (IsHiddenReallyPointer (sym)))
16422 : : {
16423 : 6 : name = SymbolTable_GetSymName (sym);
16424 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredDef (sym));
16425 : 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));
16426 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredMod (sym));
16427 : 6 : M2Error_ErrorFormat0 (e, (const char *) "if you really need a non POINTER type use the -fextended-opaque switch", 70);
16428 : : }
16429 : 23110 : i += 1;
16430 : : }
16431 : 16308 : }
16432 : :
16433 : :
16434 : : /*
16435 : : PutDefinitionForC - sets a flag in the current compiled module which
16436 : : indicates that this module is a wrapper for a C
16437 : : file. Parameters passes to procedures in this module
16438 : : will adopt the C calling convention.
16439 : : */
16440 : :
16441 : 15404 : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym)
16442 : : {
16443 : 15404 : SymbolTable_PtrToSymbol pSym;
16444 : :
16445 : 15404 : pSym = GetPsym (Sym);
16446 : 15404 : switch (pSym->SymbolType)
16447 : : {
16448 : 15404 : case SymbolTable_DefImpSym:
16449 : 15404 : pSym->DefImp.ForC = true;
16450 : 15404 : break;
16451 : :
16452 : :
16453 : 0 : default:
16454 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16455 : 15404 : break;
16456 : : }
16457 : 15404 : }
16458 : :
16459 : :
16460 : : /*
16461 : : IsDefinitionForC - returns true if this definition module was declared
16462 : : as a DEFINITION MODULE FOR "C".
16463 : : */
16464 : :
16465 : 868298 : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym)
16466 : : {
16467 : 868298 : SymbolTable_PtrToSymbol pSym;
16468 : :
16469 : 868298 : pSym = GetPsym (Sym);
16470 : 868298 : switch (pSym->SymbolType)
16471 : : {
16472 : 868298 : case SymbolTable_DefImpSym:
16473 : 868298 : return pSym->DefImp.ForC;
16474 : 0 : break;
16475 : :
16476 : :
16477 : 0 : default:
16478 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16479 : : break;
16480 : : }
16481 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16482 : : __builtin_unreachable ();
16483 : : }
16484 : :
16485 : :
16486 : : /*
16487 : : PutDoesNeedExportList - sets a flag in module, Sym, which
16488 : : indicates that this module requires an explicit
16489 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
16490 : : */
16491 : :
16492 : 73615 : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym)
16493 : : {
16494 : 73615 : SymbolTable_PtrToSymbol pSym;
16495 : :
16496 : 73615 : pSym = GetPsym (Sym);
16497 : 73615 : switch (pSym->SymbolType)
16498 : : {
16499 : 73615 : case SymbolTable_DefImpSym:
16500 : 73615 : pSym->DefImp.NeedExportList = true;
16501 : 73615 : break;
16502 : :
16503 : :
16504 : 0 : default:
16505 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16506 : 73615 : break;
16507 : : }
16508 : 73615 : }
16509 : :
16510 : :
16511 : : /*
16512 : : PutDoesNotNeedExportList - sets a flag in module, Sym, which
16513 : : indicates that this module does not require an explicit
16514 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
16515 : : */
16516 : :
16517 : 125459 : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym)
16518 : : {
16519 : 125459 : SymbolTable_PtrToSymbol pSym;
16520 : :
16521 : 125459 : pSym = GetPsym (Sym);
16522 : 125459 : switch (pSym->SymbolType)
16523 : : {
16524 : 125459 : case SymbolTable_DefImpSym:
16525 : 125459 : pSym->DefImp.NeedExportList = false;
16526 : 125459 : break;
16527 : :
16528 : :
16529 : 0 : default:
16530 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16531 : 125459 : break;
16532 : : }
16533 : 125459 : }
16534 : :
16535 : :
16536 : : /*
16537 : : DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
16538 : : EXPORT QUALIFIED list.
16539 : : */
16540 : :
16541 : 2695287 : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym)
16542 : : {
16543 : 2695287 : SymbolTable_PtrToSymbol pSym;
16544 : :
16545 : 2695287 : pSym = GetPsym (Sym);
16546 : 2695287 : switch (pSym->SymbolType)
16547 : : {
16548 : 2695287 : case SymbolTable_DefImpSym:
16549 : 2695287 : return ! pSym->DefImp.NeedExportList;
16550 : 0 : break;
16551 : :
16552 : :
16553 : 0 : default:
16554 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16555 : : break;
16556 : : }
16557 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16558 : : __builtin_unreachable ();
16559 : : }
16560 : :
16561 : :
16562 : : /*
16563 : : CheckForEnumerationInCurrentModule - checks to see whether the enumeration
16564 : : type symbol, Sym, has been entered into
16565 : : the current modules scope list.
16566 : : */
16567 : :
16568 : 1155980 : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym)
16569 : : {
16570 : 1155980 : SymbolTable_PtrToSymbol pSym;
16571 : 1155980 : unsigned int ModSym;
16572 : :
16573 : 1155980 : if (((SymbolTable_SkipType (Sym)) != SymbolTable_NulSym) && (SymbolTable_IsEnumeration (SymbolTable_SkipType (Sym))))
16574 : : {
16575 : 11610 : Sym = SymbolTable_SkipType (Sym);
16576 : : }
16577 : 1155980 : if (SymbolTable_IsEnumeration (Sym))
16578 : : {
16579 : 11610 : ModSym = SymbolTable_GetCurrentModuleScope ();
16580 : 11610 : pSym = GetPsym (ModSym);
16581 : 11610 : switch (pSym->SymbolType)
16582 : : {
16583 : 11244 : case SymbolTable_DefImpSym:
16584 : 11244 : CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
16585 : 11244 : break;
16586 : :
16587 : 366 : case SymbolTable_ModuleSym:
16588 : 366 : CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
16589 : 366 : break;
16590 : :
16591 : :
16592 : 0 : default:
16593 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16594 : : break;
16595 : : }
16596 : : }
16597 : 1155980 : }
16598 : :
16599 : :
16600 : : /*
16601 : : SanityCheckConstants - must only be called once all constants, types, procedures
16602 : : have been declared. It checks to see that constants are
16603 : : not used as procedure parameter types.
16604 : : */
16605 : :
16606 : 16704 : extern "C" void SymbolTable_SanityCheckConstants (void)
16607 : : {
16608 : 16704 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
16609 : 16704 : ForeachSymbolDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
16610 : 16704 : }
16611 : :
16612 : :
16613 : : /*
16614 : : ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
16615 : : perform the procedure, P.
16616 : : */
16617 : :
16618 : 3563351 : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
16619 : : {
16620 : 3563351 : SymbolTable_PtrToSymbol pSym;
16621 : :
16622 : 3563351 : pSym = GetPsym (Sym);
16623 : 3563351 : switch (pSym->SymbolType)
16624 : : {
16625 : 443352 : case SymbolTable_DefImpSym:
16626 : 443352 : SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, P);
16627 : 443352 : break;
16628 : :
16629 : 93948 : case SymbolTable_ModuleSym:
16630 : 93948 : SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, P);
16631 : 93948 : break;
16632 : :
16633 : 234412 : case SymbolTable_ProcedureSym:
16634 : 234412 : SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, P);
16635 : 234412 : break;
16636 : :
16637 : 0 : case SymbolTable_RecordSym:
16638 : 0 : SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, P);
16639 : 0 : break;
16640 : :
16641 : 2791639 : case SymbolTable_EnumerationSym:
16642 : 2791639 : SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
16643 : 2791639 : break;
16644 : :
16645 : :
16646 : 0 : default:
16647 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp, Module or Procedure symbol", 46);
16648 : 3563351 : break;
16649 : : }
16650 : 3563351 : }
16651 : :
16652 : :
16653 : : /*
16654 : : ForeachParamSymDo - foreach parameter symbol in procedure, Sym,
16655 : : perform the procedure, P. Each symbol
16656 : : looked up will be VarParam or Param
16657 : : (not the shadow variable).
16658 : : */
16659 : :
16660 : 898293 : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
16661 : : {
16662 : 898293 : unsigned int param;
16663 : 898293 : unsigned int p;
16664 : 898293 : unsigned int i;
16665 : :
16666 : 898293 : if (SymbolTable_IsProcedure (Sym))
16667 : : {
16668 : 896848 : p = SymbolTable_NoOfParam (Sym);
16669 : 896848 : i = p;
16670 : 3545654 : while (i > 0)
16671 : : {
16672 : 1751958 : param = SymbolTable_GetNthParam (Sym, i);
16673 : 1751958 : (*P.proc) (param);
16674 : 1751958 : i -= 1;
16675 : : }
16676 : : }
16677 : 898293 : }
16678 : :
16679 : :
16680 : : /*
16681 : : ForeachFieldEnumerationDo - for each field in enumeration, Sym,
16682 : : do procedure, P. Each call to P contains
16683 : : an enumeration field, the order is alphabetical.
16684 : : Use ForeachLocalSymDo for declaration order.
16685 : : */
16686 : :
16687 : 68879 : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P)
16688 : : {
16689 : 68879 : SymbolTable_PtrToSymbol pSym;
16690 : :
16691 : 68879 : pSym = GetPsym (Sym);
16692 : 68879 : switch (pSym->SymbolType)
16693 : : {
16694 : 68879 : case SymbolTable_EnumerationSym:
16695 : 68879 : SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
16696 : 68879 : break;
16697 : :
16698 : :
16699 : 0 : default:
16700 : 0 : M2Error_InternalError ((const char *) "expecting Enumeration symbol", 28);
16701 : 68879 : break;
16702 : : }
16703 : 68879 : }
16704 : :
16705 : :
16706 : : /*
16707 : : IsType - returns true if the Sym is a type symbol.
16708 : : */
16709 : :
16710 : 441565605 : extern "C" bool SymbolTable_IsType (unsigned int Sym)
16711 : : {
16712 : 441565605 : SymbolTable_PtrToSymbol pSym;
16713 : :
16714 : 441565605 : pSym = GetPsym (Sym);
16715 : 441565605 : return pSym->SymbolType == SymbolTable_TypeSym;
16716 : : /* static analysis guarentees a RETURN statement will be used before here. */
16717 : : __builtin_unreachable ();
16718 : : }
16719 : :
16720 : :
16721 : : /*
16722 : : IsProcedure - returns true if Sym is a procedure symbol.
16723 : : */
16724 : :
16725 : 208041584 : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym)
16726 : : {
16727 : 208041584 : SymbolTable_PtrToSymbol pSym;
16728 : :
16729 : 208041584 : CheckLegal (Sym);
16730 : 208041584 : pSym = GetPsym (Sym);
16731 : 208041584 : return pSym->SymbolType == SymbolTable_ProcedureSym;
16732 : : /* static analysis guarentees a RETURN statement will be used before here. */
16733 : : __builtin_unreachable ();
16734 : : }
16735 : :
16736 : :
16737 : : /*
16738 : : IsParameter - returns true if Sym is a parameter symbol.
16739 : : */
16740 : :
16741 : 51716646 : extern "C" bool SymbolTable_IsParameter (unsigned int Sym)
16742 : : {
16743 : 51716646 : SymbolTable_PtrToSymbol pSym;
16744 : :
16745 : 51716646 : pSym = GetPsym (Sym);
16746 : 51716646 : switch (pSym->SymbolType)
16747 : : {
16748 : : case SymbolTable_ParamSym:
16749 : : case SymbolTable_VarParamSym:
16750 : : return true;
16751 : 44964690 : break;
16752 : :
16753 : :
16754 : 44964690 : default:
16755 : 44964690 : return false;
16756 : : break;
16757 : : }
16758 : : /* static analysis guarentees a RETURN statement will be used before here. */
16759 : : __builtin_unreachable ();
16760 : : }
16761 : :
16762 : :
16763 : : /*
16764 : : ProcedureParametersDefined - dictates to procedure symbol, Sym,
16765 : : that its parameters have been defined.
16766 : : */
16767 : :
16768 : 2015539 : extern "C" void SymbolTable_ProcedureParametersDefined (unsigned int Sym)
16769 : : {
16770 : 2015539 : SymbolTable_PtrToSymbol pSym;
16771 : :
16772 : 2015539 : CheckLegal (Sym);
16773 : 2015539 : pSym = GetPsym (Sym);
16774 : 2015539 : switch (pSym->SymbolType)
16775 : : {
16776 : : case SymbolTable_ErrorSym:
16777 : : break;
16778 : :
16779 : 2015539 : case SymbolTable_ProcedureSym:
16780 : 2015539 : M2Debug_Assert (! pSym->Procedure.ParamDefined);
16781 : 2015539 : pSym->Procedure.ParamDefined = true;
16782 : 2015539 : break;
16783 : :
16784 : :
16785 : 0 : default:
16786 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
16787 : 2015539 : break;
16788 : : }
16789 : 2015539 : }
16790 : :
16791 : :
16792 : : /*
16793 : : AreProcedureParametersDefined - returns true if the parameters to procedure
16794 : : symbol, Sym, have been defined.
16795 : : */
16796 : :
16797 : 1081710 : extern "C" bool SymbolTable_AreProcedureParametersDefined (unsigned int Sym)
16798 : : {
16799 : 1081710 : SymbolTable_PtrToSymbol pSym;
16800 : :
16801 : 1081710 : CheckLegal (Sym);
16802 : 1081710 : pSym = GetPsym (Sym);
16803 : 1081710 : switch (pSym->SymbolType)
16804 : : {
16805 : : case SymbolTable_ErrorSym:
16806 : : return false;
16807 : 1081710 : break;
16808 : :
16809 : 1081710 : case SymbolTable_ProcedureSym:
16810 : 1081710 : return pSym->Procedure.ParamDefined;
16811 : 0 : break;
16812 : :
16813 : :
16814 : 0 : default:
16815 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
16816 : : break;
16817 : : }
16818 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16819 : : __builtin_unreachable ();
16820 : : }
16821 : :
16822 : :
16823 : : /*
16824 : : ParametersDefinedInDefinition - dictates to procedure symbol, Sym,
16825 : : that its parameters have been defined in
16826 : : a definition module.
16827 : : */
16828 : :
16829 : 1744719 : extern "C" void SymbolTable_ParametersDefinedInDefinition (unsigned int Sym)
16830 : : {
16831 : 1744719 : SymbolTable_PtrToSymbol pSym;
16832 : :
16833 : 1744719 : CheckLegal (Sym);
16834 : 1744719 : pSym = GetPsym (Sym);
16835 : 1744719 : switch (pSym->SymbolType)
16836 : : {
16837 : : case SymbolTable_ErrorSym:
16838 : : break;
16839 : :
16840 : 1744719 : case SymbolTable_ProcedureSym:
16841 : 1744719 : M2Debug_Assert (! pSym->Procedure.DefinedInDef);
16842 : 1744719 : pSym->Procedure.DefinedInDef = true;
16843 : 1744719 : break;
16844 : :
16845 : :
16846 : 0 : default:
16847 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
16848 : 1744719 : break;
16849 : : }
16850 : 1744719 : }
16851 : :
16852 : :
16853 : : /*
16854 : : AreParametersDefinedInDefinition - returns true if procedure symbol, Sym,
16855 : : has had its parameters been defined in
16856 : : a definition module.
16857 : : */
16858 : :
16859 : 4996739 : extern "C" bool SymbolTable_AreParametersDefinedInDefinition (unsigned int Sym)
16860 : : {
16861 : 4996739 : SymbolTable_PtrToSymbol pSym;
16862 : :
16863 : 4996739 : CheckLegal (Sym);
16864 : 4996739 : pSym = GetPsym (Sym);
16865 : 4996739 : switch (pSym->SymbolType)
16866 : : {
16867 : : case SymbolTable_ErrorSym:
16868 : : return false;
16869 : 4996739 : break;
16870 : :
16871 : 4996739 : case SymbolTable_ProcedureSym:
16872 : 4996739 : return pSym->Procedure.DefinedInDef;
16873 : 0 : break;
16874 : :
16875 : :
16876 : 0 : default:
16877 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
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 : : ParametersDefinedInImplementation - dictates to procedure symbol, Sym,
16887 : : that its parameters have been defined in
16888 : : a implemtation module.
16889 : : */
16890 : :
16891 : 265547 : extern "C" void SymbolTable_ParametersDefinedInImplementation (unsigned int Sym)
16892 : : {
16893 : 265547 : SymbolTable_PtrToSymbol pSym;
16894 : :
16895 : 265547 : CheckLegal (Sym);
16896 : 265547 : pSym = GetPsym (Sym);
16897 : 265547 : switch (pSym->SymbolType)
16898 : : {
16899 : : case SymbolTable_ErrorSym:
16900 : : break;
16901 : :
16902 : 265547 : case SymbolTable_ProcedureSym:
16903 : 265547 : M2Debug_Assert (! pSym->Procedure.DefinedInImp);
16904 : 265547 : pSym->Procedure.DefinedInImp = true;
16905 : 265547 : break;
16906 : :
16907 : :
16908 : 0 : default:
16909 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
16910 : 265547 : break;
16911 : : }
16912 : 265547 : }
16913 : :
16914 : :
16915 : : /*
16916 : : AreParametersDefinedInImplementation - returns true if procedure symbol, Sym,
16917 : : has had its parameters been defined in
16918 : : an implementation module.
16919 : : */
16920 : :
16921 : 4996739 : extern "C" bool SymbolTable_AreParametersDefinedInImplementation (unsigned int Sym)
16922 : : {
16923 : 4996739 : SymbolTable_PtrToSymbol pSym;
16924 : :
16925 : 4996739 : CheckLegal (Sym);
16926 : 4996739 : pSym = GetPsym (Sym);
16927 : 4996739 : switch (pSym->SymbolType)
16928 : : {
16929 : : case SymbolTable_ErrorSym:
16930 : : return false;
16931 : 4996739 : break;
16932 : :
16933 : 4996739 : case SymbolTable_ProcedureSym:
16934 : 4996739 : return pSym->Procedure.DefinedInImp;
16935 : 0 : break;
16936 : :
16937 : :
16938 : 0 : default:
16939 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
16940 : : break;
16941 : : }
16942 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16943 : : __builtin_unreachable ();
16944 : : }
16945 : :
16946 : :
16947 : : /*
16948 : : PutUseVarArgs - tell the symbol table that this procedure, Sym,
16949 : : uses varargs.
16950 : : The procedure _must_ be declared inside a
16951 : : DEFINITION FOR "C"
16952 : :
16953 : : */
16954 : :
16955 : 15520 : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym)
16956 : : {
16957 : 15520 : SymbolTable_PtrToSymbol pSym;
16958 : :
16959 : 15520 : CheckLegal (Sym);
16960 : 15520 : pSym = GetPsym (Sym);
16961 : 15520 : switch (pSym->SymbolType)
16962 : : {
16963 : : case SymbolTable_ErrorSym:
16964 : : break;
16965 : :
16966 : 15520 : case SymbolTable_ProcedureSym:
16967 : 15520 : pSym->Procedure.HasVarArgs = true;
16968 : 15520 : break;
16969 : :
16970 : 0 : case SymbolTable_ProcTypeSym:
16971 : 0 : pSym->ProcType.HasVarArgs = true;
16972 : 0 : break;
16973 : :
16974 : :
16975 : 0 : default:
16976 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
16977 : 15520 : break;
16978 : : }
16979 : 15520 : }
16980 : :
16981 : :
16982 : : /*
16983 : : UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
16984 : : The procedure _must_ be declared inside a
16985 : : DEFINITION FOR "C"
16986 : : */
16987 : :
16988 : 2391257 : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym)
16989 : : {
16990 : 2391257 : SymbolTable_PtrToSymbol pSym;
16991 : :
16992 : 2391257 : CheckLegal (Sym);
16993 : 2391257 : pSym = GetPsym (Sym);
16994 : 2391257 : switch (pSym->SymbolType)
16995 : : {
16996 : : case SymbolTable_ErrorSym:
16997 : : return false;
16998 : 2334673 : break;
16999 : :
17000 : 2334673 : case SymbolTable_ProcedureSym:
17001 : 2334673 : return pSym->Procedure.HasVarArgs;
17002 : 56584 : break;
17003 : :
17004 : 56584 : case SymbolTable_ProcTypeSym:
17005 : 56584 : return pSym->ProcType.HasVarArgs;
17006 : 0 : break;
17007 : :
17008 : :
17009 : 0 : default:
17010 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17011 : : break;
17012 : : }
17013 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17014 : : __builtin_unreachable ();
17015 : : }
17016 : :
17017 : :
17018 : : /*
17019 : : PutUseOptArg - tell the symbol table that this procedure, Sym,
17020 : : uses an optarg.
17021 : : */
17022 : :
17023 : 19292 : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym)
17024 : : {
17025 : 19292 : SymbolTable_PtrToSymbol pSym;
17026 : :
17027 : 19292 : CheckLegal (Sym);
17028 : 19292 : pSym = GetPsym (Sym);
17029 : 19292 : switch (pSym->SymbolType)
17030 : : {
17031 : : case SymbolTable_ErrorSym:
17032 : : break;
17033 : :
17034 : 19292 : case SymbolTable_ProcedureSym:
17035 : 19292 : pSym->Procedure.HasOptArg = true;
17036 : 19292 : break;
17037 : :
17038 : 0 : case SymbolTable_ProcTypeSym:
17039 : 0 : pSym->ProcType.HasOptArg = true;
17040 : 0 : break;
17041 : :
17042 : :
17043 : 0 : default:
17044 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17045 : 19292 : break;
17046 : : }
17047 : 19292 : }
17048 : :
17049 : :
17050 : : /*
17051 : : UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
17052 : : */
17053 : :
17054 : 248078 : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym)
17055 : : {
17056 : 248078 : SymbolTable_PtrToSymbol pSym;
17057 : :
17058 : 248078 : CheckLegal (Sym);
17059 : 248078 : pSym = GetPsym (Sym);
17060 : 248078 : switch (pSym->SymbolType)
17061 : : {
17062 : : case SymbolTable_ErrorSym:
17063 : : return false;
17064 : 247406 : break;
17065 : :
17066 : 247406 : case SymbolTable_ProcedureSym:
17067 : 247406 : return pSym->Procedure.HasOptArg;
17068 : 672 : break;
17069 : :
17070 : 672 : case SymbolTable_ProcTypeSym:
17071 : 672 : return pSym->ProcType.HasOptArg;
17072 : 0 : break;
17073 : :
17074 : :
17075 : 0 : default:
17076 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17077 : : break;
17078 : : }
17079 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17080 : : __builtin_unreachable ();
17081 : : }
17082 : :
17083 : :
17084 : : /*
17085 : : PutOptArgInit - makes symbol, Sym, the initializer value to
17086 : : procedure, ProcSym.
17087 : : */
17088 : :
17089 : 16748 : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym)
17090 : : {
17091 : 16748 : SymbolTable_PtrToSymbol pSym;
17092 : :
17093 : 16748 : CheckLegal (Sym);
17094 : 16748 : if (! (SymbolTable_IsError (ProcSym)))
17095 : : {
17096 : 16748 : if (SymbolTable_UsesOptArg (ProcSym))
17097 : : {
17098 : 16748 : pSym = GetPsym (ProcSym);
17099 : 16748 : switch (pSym->SymbolType)
17100 : : {
17101 : : case SymbolTable_ErrorSym:
17102 : : break;
17103 : :
17104 : 16748 : case SymbolTable_ProcedureSym:
17105 : 16748 : pSym->Procedure.OptArgInit = Sym;
17106 : 16748 : break;
17107 : :
17108 : 0 : case SymbolTable_ProcTypeSym:
17109 : 0 : pSym->ProcType.OptArgInit = Sym;
17110 : 0 : break;
17111 : :
17112 : :
17113 : 0 : default:
17114 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17115 : : break;
17116 : : }
17117 : : }
17118 : : }
17119 : 16748 : }
17120 : :
17121 : :
17122 : : /*
17123 : : GetOptArgInit - returns the initializer value to the optional parameter in
17124 : : procedure, ProcSym.
17125 : : */
17126 : :
17127 : 4272 : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym)
17128 : : {
17129 : 4272 : SymbolTable_PtrToSymbol pSym;
17130 : :
17131 : 4272 : if (! (SymbolTable_IsError (ProcSym)))
17132 : : {
17133 : 4272 : if (SymbolTable_UsesOptArg (ProcSym))
17134 : : {
17135 : 4272 : pSym = GetPsym (ProcSym);
17136 : 4272 : switch (pSym->SymbolType)
17137 : : {
17138 : : case SymbolTable_ErrorSym:
17139 : : break;
17140 : :
17141 : 4272 : case SymbolTable_ProcedureSym:
17142 : 4272 : return pSym->Procedure.OptArgInit;
17143 : 0 : break;
17144 : :
17145 : 0 : case SymbolTable_ProcTypeSym:
17146 : 0 : return pSym->ProcType.OptArgInit;
17147 : 0 : break;
17148 : :
17149 : :
17150 : 0 : default:
17151 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17152 : : break;
17153 : : }
17154 : : }
17155 : : }
17156 : : return SymbolTable_NulSym;
17157 : : /* static analysis guarentees a RETURN statement will be used before here. */
17158 : : __builtin_unreachable ();
17159 : : }
17160 : :
17161 : :
17162 : : /*
17163 : : MakePointer - returns a pointer symbol with PointerName.
17164 : : */
17165 : :
17166 : 143234 : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName)
17167 : : {
17168 : 143234 : unsigned int oaf;
17169 : 143234 : unsigned int sym;
17170 : :
17171 : 143234 : tok = CheckTok (tok, (const char *) "pointer", 7);
17172 : 143234 : sym = HandleHiddenOrDeclare (tok, PointerName, &oaf);
17173 : 143234 : FillInPointerFields (sym, PointerName, SymbolTable_GetCurrentScope (), oaf);
17174 : 143234 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
17175 : 143234 : return sym;
17176 : : /* static analysis guarentees a RETURN statement will be used before here. */
17177 : : __builtin_unreachable ();
17178 : : }
17179 : :
17180 : :
17181 : : /*
17182 : : PutPointer - gives a pointer symbol a type, PointerType.
17183 : : */
17184 : :
17185 : 179763 : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType)
17186 : : {
17187 : 179763 : SymbolTable_PtrToSymbol pSym;
17188 : :
17189 : 179763 : pSym = GetPsym (Sym);
17190 : 179763 : switch (pSym->SymbolType)
17191 : : {
17192 : : case SymbolTable_ErrorSym:
17193 : : break;
17194 : :
17195 : 179763 : case SymbolTable_PointerSym:
17196 : 179763 : pSym->Pointer.Type = PointerType;
17197 : 179763 : break;
17198 : :
17199 : :
17200 : 0 : default:
17201 : 0 : M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26);
17202 : 179763 : break;
17203 : : }
17204 : 179763 : }
17205 : :
17206 : :
17207 : : /*
17208 : : IsPointer - returns true is Sym is a pointer type symbol.
17209 : : */
17210 : :
17211 : 129837145 : extern "C" bool SymbolTable_IsPointer (unsigned int Sym)
17212 : : {
17213 : 129837145 : SymbolTable_PtrToSymbol pSym;
17214 : :
17215 : 129837145 : CheckLegal (Sym);
17216 : 129837145 : pSym = GetPsym (Sym);
17217 : 129837145 : return pSym->SymbolType == SymbolTable_PointerSym;
17218 : : /* static analysis guarentees a RETURN statement will be used before here. */
17219 : : __builtin_unreachable ();
17220 : : }
17221 : :
17222 : :
17223 : : /*
17224 : : IsRecord - returns true is Sym is a record type symbol.
17225 : : */
17226 : :
17227 : 147823705 : extern "C" bool SymbolTable_IsRecord (unsigned int Sym)
17228 : : {
17229 : 147823705 : SymbolTable_PtrToSymbol pSym;
17230 : :
17231 : 147823705 : CheckLegal (Sym);
17232 : 147823705 : pSym = GetPsym (Sym);
17233 : 147823705 : return pSym->SymbolType == SymbolTable_RecordSym;
17234 : : /* static analysis guarentees a RETURN statement will be used before here. */
17235 : : __builtin_unreachable ();
17236 : : }
17237 : :
17238 : :
17239 : : /*
17240 : : IsVarient - returns true if the symbol, Sym, is a
17241 : : varient symbol.
17242 : : */
17243 : :
17244 : 100048529 : extern "C" bool SymbolTable_IsVarient (unsigned int Sym)
17245 : : {
17246 : 100048529 : SymbolTable_PtrToSymbol pSym;
17247 : :
17248 : 100048529 : pSym = GetPsym (Sym);
17249 : 100048529 : return pSym->SymbolType == SymbolTable_VarientSym;
17250 : : /* static analysis guarentees a RETURN statement will be used before here. */
17251 : : __builtin_unreachable ();
17252 : : }
17253 : :
17254 : :
17255 : : /*
17256 : : IsFieldVarient - returns true if the symbol, Sym, is a
17257 : : varient field.
17258 : : */
17259 : :
17260 : 65862998 : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym)
17261 : : {
17262 : 65862998 : SymbolTable_PtrToSymbol pSym;
17263 : :
17264 : 65862998 : pSym = GetPsym (Sym);
17265 : 65862998 : return pSym->SymbolType == SymbolTable_VarientFieldSym;
17266 : : /* static analysis guarentees a RETURN statement will be used before here. */
17267 : : __builtin_unreachable ();
17268 : : }
17269 : :
17270 : :
17271 : : /*
17272 : : IsFieldEnumeration - returns true if the symbol, Sym, is an
17273 : : enumeration field.
17274 : : */
17275 : :
17276 : 9297324 : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym)
17277 : : {
17278 : 9297324 : SymbolTable_PtrToSymbol pSym;
17279 : :
17280 : 9297324 : pSym = GetPsym (Sym);
17281 : 9297324 : return pSym->SymbolType == SymbolTable_EnumerationFieldSym;
17282 : : /* static analysis guarentees a RETURN statement will be used before here. */
17283 : : __builtin_unreachable ();
17284 : : }
17285 : :
17286 : :
17287 : : /*
17288 : : IsArray - returns true is Sym is an array type symbol.
17289 : : */
17290 : :
17291 : 125332679 : extern "C" bool SymbolTable_IsArray (unsigned int Sym)
17292 : : {
17293 : 125332679 : SymbolTable_PtrToSymbol pSym;
17294 : :
17295 : 125332679 : CheckLegal (Sym);
17296 : 125332679 : pSym = GetPsym (Sym);
17297 : 125332679 : return pSym->SymbolType == SymbolTable_ArraySym;
17298 : : /* static analysis guarentees a RETURN statement will be used before here. */
17299 : : __builtin_unreachable ();
17300 : : }
17301 : :
17302 : :
17303 : : /*
17304 : : IsEnumeration - returns true if Sym is an enumeration symbol.
17305 : : */
17306 : :
17307 : 123401406 : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym)
17308 : : {
17309 : 123401406 : SymbolTable_PtrToSymbol pSym;
17310 : :
17311 : 123401406 : CheckLegal (Sym);
17312 : 123401406 : pSym = GetPsym (Sym);
17313 : 123401406 : return pSym->SymbolType == SymbolTable_EnumerationSym;
17314 : : /* static analysis guarentees a RETURN statement will be used before here. */
17315 : : __builtin_unreachable ();
17316 : : }
17317 : :
17318 : :
17319 : : /*
17320 : : IsSet - returns TRUE if Sym is a set symbol.
17321 : : */
17322 : :
17323 : 52603972 : extern "C" bool SymbolTable_IsSet (unsigned int Sym)
17324 : : {
17325 : 52603972 : SymbolTable_PtrToSymbol pSym;
17326 : :
17327 : 52603972 : CheckLegal (Sym);
17328 : 52603972 : pSym = GetPsym (Sym);
17329 : 52603972 : return pSym->SymbolType == SymbolTable_SetSym;
17330 : : /* static analysis guarentees a RETURN statement will be used before here. */
17331 : : __builtin_unreachable ();
17332 : : }
17333 : :
17334 : :
17335 : : /*
17336 : : IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
17337 : : */
17338 : :
17339 : 16713945 : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym)
17340 : : {
17341 : 16713945 : SymbolTable_PtrToSymbol pSym;
17342 : :
17343 : 16713945 : pSym = GetPsym (Sym);
17344 : 16713945 : switch (pSym->SymbolType)
17345 : : {
17346 : 16553678 : case SymbolTable_TypeSym:
17347 : 16553678 : return pSym->Type.IsHidden;
17348 : : break;
17349 : :
17350 : :
17351 : : default:
17352 : : return false;
17353 : : break;
17354 : : }
17355 : : /* static analysis guarentees a RETURN statement will be used before here. */
17356 : : __builtin_unreachable ();
17357 : : }
17358 : :
17359 : :
17360 : : /*
17361 : : IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
17362 : : */
17363 : :
17364 : 0 : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym)
17365 : : {
17366 : 0 : SymbolTable_PtrToSymbol pSym;
17367 : :
17368 : 0 : CheckLegal (Sym);
17369 : 0 : pSym = GetPsym (Sym);
17370 : 0 : return pSym->SymbolType == SymbolTable_OAFamilySym;
17371 : : /* static analysis guarentees a RETURN statement will be used before here. */
17372 : : __builtin_unreachable ();
17373 : : }
17374 : :
17375 : :
17376 : : /*
17377 : : GetDimension - return the number of dimensions associated with
17378 : : this unbounded ARRAY parameter.
17379 : : */
17380 : :
17381 : 240923 : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym)
17382 : : {
17383 : 409213 : SymbolTable_PtrToSymbol pSym;
17384 : :
17385 : 409213 : pSym = GetPsym (sym);
17386 : 409213 : switch (pSym->SymbolType)
17387 : : {
17388 : 0 : case SymbolTable_PartialUnboundedSym:
17389 : 0 : return pSym->PartialUnbounded.NDim;
17390 : 233036 : break;
17391 : :
17392 : 233036 : case SymbolTable_UnboundedSym:
17393 : 233036 : return pSym->Unbounded.Dimensions;
17394 : 0 : break;
17395 : :
17396 : 0 : case SymbolTable_OAFamilySym:
17397 : 0 : return pSym->OAFamily.MaxDimensions;
17398 : 99918 : break;
17399 : :
17400 : 99918 : case SymbolTable_ParamSym:
17401 : 99918 : if (pSym->Param.IsUnbounded)
17402 : : {
17403 : 99918 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
17404 : : }
17405 : : else
17406 : : {
17407 : 0 : M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
17408 : : }
17409 : 68348 : break;
17410 : :
17411 : 68348 : case SymbolTable_VarParamSym:
17412 : 68348 : if (pSym->VarParam.IsUnbounded)
17413 : : {
17414 : 68348 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
17415 : : }
17416 : : else
17417 : : {
17418 : 0 : M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
17419 : : }
17420 : 7887 : break;
17421 : :
17422 : 7887 : case SymbolTable_ArraySym:
17423 : 7887 : return GetArrayDimension (sym);
17424 : 0 : break;
17425 : :
17426 : 0 : case SymbolTable_TypeSym:
17427 : 0 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
17428 : 24 : break;
17429 : :
17430 : 24 : case SymbolTable_VarSym:
17431 : 24 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
17432 : 0 : break;
17433 : :
17434 : :
17435 : 0 : default:
17436 : 0 : M2Error_InternalError ((const char *) "expecting PartialUnbounded", 26);
17437 : : break;
17438 : : }
17439 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17440 : : __builtin_unreachable ();
17441 : : }
17442 : :
17443 : :
17444 : : /*
17445 : : MakeOAFamily - makes an OAFamily symbol based on SimpleType.
17446 : : It returns the OAFamily symbol. A new symbol
17447 : : is created if one does not already exist for
17448 : : SimpleType.
17449 : : */
17450 : :
17451 : 390276 : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType)
17452 : : {
17453 : 390276 : SymbolTable_PtrToSymbol pSym;
17454 : 390276 : unsigned int sym;
17455 : :
17456 : 390276 : sym = SymbolTable_GetOAFamily (SimpleType);
17457 : 390276 : if (sym == SymbolTable_NulSym)
17458 : : {
17459 : 36469 : NewSym (&sym);
17460 : 36469 : pSym = GetPsym (sym);
17461 : 36469 : pSym->SymbolType = SymbolTable_OAFamilySym;
17462 : 36469 : pSym->OAFamily.MaxDimensions = 0;
17463 : 36469 : pSym->OAFamily.SimpleType = SimpleType;
17464 : 36469 : pSym->OAFamily.Dimensions = Indexing_InitIndex (1);
17465 : 36469 : PutOAFamily (SimpleType, sym);
17466 : : }
17467 : 390276 : return sym;
17468 : : /* static analysis guarentees a RETURN statement will be used before here. */
17469 : : __builtin_unreachable ();
17470 : : }
17471 : :
17472 : :
17473 : : /*
17474 : : GetOAFamily - returns the oafamily symbol associated with
17475 : : SimpleType.
17476 : : */
17477 : :
17478 : 87646647 : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType)
17479 : : {
17480 : 87646647 : SymbolTable_PtrToSymbol pSym;
17481 : :
17482 : 87646647 : pSym = GetPsym (SimpleType);
17483 : 87646647 : switch (pSym->SymbolType)
17484 : : {
17485 : : case SymbolTable_ErrorSym:
17486 : : return SymbolTable_NulSym;
17487 : 6316300 : break;
17488 : :
17489 : 6316300 : case SymbolTable_RecordSym:
17490 : 6316300 : return pSym->Record.oafamily;
17491 : 1285372 : break;
17492 : :
17493 : 1285372 : case SymbolTable_SubrangeSym:
17494 : 1285372 : return pSym->Subrange.oafamily;
17495 : 2313247 : break;
17496 : :
17497 : 2313247 : case SymbolTable_EnumerationSym:
17498 : 2313247 : return pSym->Enumeration.oafamily;
17499 : 698107 : break;
17500 : :
17501 : 698107 : case SymbolTable_ArraySym:
17502 : 698107 : return pSym->Array.oafamily;
17503 : 2110882 : break;
17504 : :
17505 : 2110882 : case SymbolTable_ProcTypeSym:
17506 : 2110882 : return pSym->ProcType.oafamily;
17507 : 20143775 : break;
17508 : :
17509 : 20143775 : case SymbolTable_TypeSym:
17510 : 20143775 : return pSym->Type.oafamily;
17511 : 10364577 : break;
17512 : :
17513 : 10364577 : case SymbolTable_PointerSym:
17514 : 10364577 : return pSym->Pointer.oafamily;
17515 : 841287 : break;
17516 : :
17517 : 841287 : case SymbolTable_SetSym:
17518 : 841287 : return pSym->Set.oafamily;
17519 : 96439 : break;
17520 : :
17521 : 96439 : case SymbolTable_UndefinedSym:
17522 : 96439 : return pSym->Undefined.oafamily;
17523 : : break;
17524 : :
17525 : :
17526 : : default:
17527 : : return SymbolTable_NulSym;
17528 : : break;
17529 : : }
17530 : : /* static analysis guarentees a RETURN statement will be used before here. */
17531 : : __builtin_unreachable ();
17532 : : }
17533 : :
17534 : :
17535 : : /*
17536 : : ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
17537 : : sym, in the oaf.
17538 : : */
17539 : :
17540 : 87256371 : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p)
17541 : : {
17542 : 87256371 : typedef unsigned int *ForeachOAFamily__T1;
17543 : :
17544 : 87256371 : SymbolTable_PtrToSymbol pSym;
17545 : 87256371 : unsigned int h;
17546 : 87256371 : unsigned int i;
17547 : 87256371 : ForeachOAFamily__T1 pc;
17548 : :
17549 : 87256371 : if (sym != SymbolTable_NulSym)
17550 : : {
17551 : 4059703 : pSym = GetPsym (sym);
17552 : 4059703 : switch (pSym->SymbolType)
17553 : : {
17554 : 4059703 : case SymbolTable_OAFamilySym:
17555 : 4059703 : h = Indexing_HighIndice (pSym->OAFamily.Dimensions);
17556 : 4059703 : i = 1;
17557 : 12215727 : while (i <= h)
17558 : : {
17559 : 4096321 : pc = static_cast<ForeachOAFamily__T1> (Indexing_GetIndice (pSym->OAFamily.Dimensions, i));
17560 : 4096321 : if (pc != NULL)
17561 : : {
17562 : 4096321 : (*p.proc) (sym, i, (*pc));
17563 : : }
17564 : 4096321 : i += 1;
17565 : : }
17566 : : break;
17567 : :
17568 : :
17569 : 0 : default:
17570 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
17571 : : break;
17572 : : }
17573 : : }
17574 : 87256371 : }
17575 : :
17576 : :
17577 : : /*
17578 : : IsUnbounded - returns true if Sym is an unbounded symbol.
17579 : : */
17580 : :
17581 : 57326128 : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym)
17582 : : {
17583 : 57326128 : SymbolTable_PtrToSymbol pSym;
17584 : :
17585 : 57326128 : CheckLegal (Sym);
17586 : 57326128 : pSym = GetPsym (Sym);
17587 : 57326128 : return pSym->SymbolType == SymbolTable_UnboundedSym;
17588 : : /* static analysis guarentees a RETURN statement will be used before here. */
17589 : : __builtin_unreachable ();
17590 : : }
17591 : :
17592 : :
17593 : : /*
17594 : : GetUnbounded - returns the unbounded symbol associated with
17595 : : the OAFamily symbol, oaf, and the number of
17596 : : dimensions, ndim, of the open array.
17597 : : */
17598 : :
17599 : 390276 : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim)
17600 : : {
17601 : 390276 : SymbolTable_PtrToSymbol pSym;
17602 : :
17603 : 390276 : pSym = GetPsym (oaf);
17604 : 390276 : switch (pSym->SymbolType)
17605 : : {
17606 : 390276 : case SymbolTable_OAFamilySym:
17607 : 390276 : if (ndim > pSym->OAFamily.MaxDimensions)
17608 : : {
17609 : : return SymbolTable_NulSym;
17610 : : }
17611 : : else
17612 : : {
17613 : 353747 : return GetFromIndex (pSym->OAFamily.Dimensions, ndim);
17614 : : }
17615 : 0 : break;
17616 : :
17617 : :
17618 : 0 : default:
17619 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
17620 : : break;
17621 : : }
17622 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17623 : : __builtin_unreachable ();
17624 : : }
17625 : :
17626 : :
17627 : : /*
17628 : : GetUnboundedRecordType - returns the record type used to
17629 : : implement the unbounded array.
17630 : : */
17631 : :
17632 : 4482908 : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym)
17633 : : {
17634 : 4482908 : SymbolTable_PtrToSymbol pSym;
17635 : :
17636 : 4482908 : pSym = GetPsym (Sym);
17637 : 4482908 : switch (pSym->SymbolType)
17638 : : {
17639 : 4482908 : case SymbolTable_UnboundedSym:
17640 : 4482908 : return pSym->Unbounded.RecordType;
17641 : 0 : break;
17642 : :
17643 : :
17644 : 0 : default:
17645 : 0 : M2Error_InternalError ((const char *) "expecting an UnBounded symbol", 29);
17646 : : break;
17647 : : }
17648 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17649 : : __builtin_unreachable ();
17650 : : }
17651 : :
17652 : :
17653 : : /*
17654 : : GetUnboundedAddressOffset - returns the offset of the address field
17655 : : inside the record used to implement the
17656 : : unbounded type.
17657 : : */
17658 : :
17659 : 69856 : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym)
17660 : : {
17661 : 69856 : unsigned int field;
17662 : 69856 : unsigned int rec;
17663 : :
17664 : 69856 : rec = SymbolTable_GetUnboundedRecordType (sym);
17665 : 69856 : if (rec == SymbolTable_NulSym)
17666 : : {
17667 : 0 : M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
17668 : : }
17669 : : else
17670 : : {
17671 : 69856 : field = SymbolTable_GetLocalSym (rec, NameKey_MakeKey ((const char *) "_m2_contents", 12));
17672 : 69856 : if (field == SymbolTable_NulSym)
17673 : : {
17674 : 0 : M2Error_InternalError ((const char *) "expecting address field to be present inside unbounded record", 61);
17675 : : }
17676 : : else
17677 : : {
17678 : 69856 : return field;
17679 : : }
17680 : : }
17681 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17682 : : __builtin_unreachable ();
17683 : : }
17684 : :
17685 : :
17686 : : /*
17687 : : GetUnboundedHighOffset - returns the offset of the high field
17688 : : inside the record used to implement the
17689 : : unbounded type.
17690 : : */
17691 : :
17692 : 111548 : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim)
17693 : : {
17694 : 111548 : unsigned int rec;
17695 : :
17696 : 111548 : rec = SymbolTable_GetUnboundedRecordType (sym);
17697 : 111548 : if (rec == SymbolTable_NulSym)
17698 : : {
17699 : 0 : M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
17700 : : }
17701 : : else
17702 : : {
17703 : 111548 : 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))))));
17704 : : }
17705 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17706 : : __builtin_unreachable ();
17707 : : }
17708 : :
17709 : :
17710 : : /*
17711 : : MakeSubscript - makes a subscript Symbol.
17712 : : No name is required.
17713 : : */
17714 : :
17715 : 82680 : extern "C" unsigned int SymbolTable_MakeSubscript (void)
17716 : : {
17717 : 82680 : SymbolTable_PtrToSymbol pSym;
17718 : 82680 : unsigned int Sym;
17719 : :
17720 : 82680 : NewSym (&Sym);
17721 : 82680 : pSym = GetPsym (Sym);
17722 : 82680 : pSym->SymbolType = SymbolTable_SubscriptSym;
17723 : 82680 : pSym->Subscript.Type = SymbolTable_NulSym; /* Index to a subrange symbol. */
17724 : 82680 : pSym->Subscript.Size = M2ALU_InitValue (); /* Size of this indice in*Size */
17725 : 82680 : pSym->Subscript.Offset = M2ALU_InitValue (); /* Offset at runtime of symbol */
17726 : 82680 : InitWhereDeclared (&pSym->Subscript.At); /* Declared here */
17727 : 82680 : return Sym;
17728 : : /* static analysis guarentees a RETURN statement will be used before here. */
17729 : : __builtin_unreachable ();
17730 : : }
17731 : :
17732 : :
17733 : : /*
17734 : : PutSubscript - gives a subscript symbol a type, SimpleType.
17735 : : */
17736 : :
17737 : 82680 : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType)
17738 : : {
17739 : 82680 : SymbolTable_PtrToSymbol pSym;
17740 : :
17741 : 82680 : pSym = GetPsym (Sym);
17742 : 82680 : switch (pSym->SymbolType)
17743 : : {
17744 : : case SymbolTable_ErrorSym:
17745 : : break;
17746 : :
17747 : 82680 : case SymbolTable_SubscriptSym:
17748 : 82680 : pSym->Subscript.Type = SimpleType;
17749 : 82680 : break;
17750 : :
17751 : :
17752 : 0 : default:
17753 : 0 : M2Error_InternalError ((const char *) "expecting a SubScript symbol", 28);
17754 : 82680 : break;
17755 : : }
17756 : 82680 : }
17757 : :
17758 : :
17759 : : /*
17760 : : MakeUnbounded - makes an unbounded array Symbol.
17761 : : ndim is the number of dimensions required.
17762 : : No name is required.
17763 : : */
17764 : :
17765 : 390276 : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim)
17766 : : {
17767 : 390276 : unsigned int sym;
17768 : 390276 : unsigned int oaf;
17769 : :
17770 : 390276 : tok = CheckTok (tok, (const char *) "unbounded", 9);
17771 : 390276 : oaf = SymbolTable_MakeOAFamily (SimpleType);
17772 : 390276 : sym = SymbolTable_GetUnbounded (oaf, ndim);
17773 : 390276 : if (sym == SymbolTable_NulSym)
17774 : : {
17775 : 36529 : NewSym (&sym);
17776 : 36529 : if (SymbolTable_IsUnknown (SimpleType))
17777 : : {
17778 : 0 : PutPartialUnbounded (sym, SimpleType, ndim);
17779 : : }
17780 : : else
17781 : : {
17782 : 36529 : FillInUnboundedFields (tok, sym, SimpleType, ndim);
17783 : : }
17784 : 36529 : PutUnbounded (oaf, sym, ndim);
17785 : : }
17786 : 390276 : return sym;
17787 : : /* static analysis guarentees a RETURN statement will be used before here. */
17788 : : __builtin_unreachable ();
17789 : : }
17790 : :
17791 : :
17792 : : /*
17793 : : NoOfElements - Returns the number of elements in array Sym,
17794 : : or the number of elements in an enumeration Sym or
17795 : : the number of interface symbols in an Interface list.
17796 : : */
17797 : :
17798 : 244 : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym)
17799 : : {
17800 : 244 : SymbolTable_PtrToSymbol pSym;
17801 : 244 : unsigned int n;
17802 : :
17803 : 244 : pSym = GetPsym (Sym);
17804 : 244 : switch (pSym->SymbolType)
17805 : : {
17806 : : case SymbolTable_ErrorSym:
17807 : : n = 0;
17808 : : break;
17809 : :
17810 : 244 : case SymbolTable_EnumerationSym:
17811 : : /*
17812 : : ArraySym ,
17813 : : UnboundedSym : n := 1 | Standard language limitation
17814 : : */
17815 : 244 : n = pSym->Enumeration.NoOfElements;
17816 : 244 : break;
17817 : :
17818 : 0 : case SymbolTable_InterfaceSym:
17819 : 0 : n = Indexing_HighIndice (pSym->Interface.Parameters);
17820 : 0 : break;
17821 : :
17822 : :
17823 : 0 : default:
17824 : 0 : M2Error_InternalError ((const char *) "expecting an Array or UnBounded symbol", 38);
17825 : 244 : break;
17826 : : }
17827 : 244 : return n;
17828 : : /* static analysis guarentees a RETURN statement will be used before here. */
17829 : : __builtin_unreachable ();
17830 : : }
17831 : :
17832 : :
17833 : : /*
17834 : : PutArray - places a type symbol into an Array.
17835 : : */
17836 : :
17837 : 82680 : extern "C" void SymbolTable_PutArray (unsigned int Sym, unsigned int TypeSymbol)
17838 : : {
17839 : 82680 : SymbolTable_PtrToSymbol pSym;
17840 : :
17841 : 82680 : pSym = GetPsym (Sym);
17842 : 82680 : switch (pSym->SymbolType)
17843 : : {
17844 : : case SymbolTable_ErrorSym:
17845 : : break;
17846 : :
17847 : 82680 : case SymbolTable_ArraySym:
17848 : 82680 : pSym->Array.Type = TypeSymbol; /* The Array Type. ARRAY OF Type. */
17849 : 82680 : break;
17850 : :
17851 : :
17852 : 0 : default:
17853 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
17854 : 82680 : break;
17855 : : }
17856 : 82680 : }
17857 : :
17858 : :
17859 : : /*
17860 : : ResolveImports - it examines the import list of all inner modules
17861 : : and resolves all relative imports.
17862 : : */
17863 : :
17864 : 63232 : extern "C" void SymbolTable_ResolveImports (void)
17865 : : {
17866 : 63232 : unsigned int scope;
17867 : :
17868 : 63232 : scope = SymbolTable_GetCurrentScope ();
17869 : 63232 : if (DebugUnknowns)
17870 : : {
17871 : : SymbolTable_DisplayTrees (scope);
17872 : : }
17873 : 63232 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
17874 : 63232 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
17875 : 63232 : }
17876 : :
17877 : :
17878 : : /*
17879 : : ResolveConstructorTypes - to be called at the end of pass three. Its
17880 : : purpose is to fix up all constructors whose
17881 : : types are unknown.
17882 : : */
17883 : :
17884 : 16710 : extern "C" void SymbolTable_ResolveConstructorTypes (void)
17885 : : {
17886 : 37172 : bool finished;
17887 : 37172 : unsigned int i;
17888 : 37172 : unsigned int n;
17889 : 37172 : unsigned int s;
17890 : :
17891 : 37172 : do {
17892 : 37172 : n = Lists_NoOfItemsInList (UnresolvedConstructorType);
17893 : 37172 : finished = true;
17894 : 37172 : i = 1;
17895 : 94812 : while (i <= n)
17896 : : {
17897 : 20468 : s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
17898 : 20468 : M2Debug_Assert (SymbolTable_IsConstructor (s));
17899 : 20468 : if (CanResolveConstructor (s))
17900 : : {
17901 : 20462 : finished = false;
17902 : 20462 : Lists_RemoveItemFromList (UnresolvedConstructorType, s);
17903 : 20462 : i = n;
17904 : : }
17905 : 20468 : i += 1;
17906 : : }
17907 : 37172 : } while (! (finished));
17908 : 16710 : CheckAllConstructorsResolved ();
17909 : 16704 : }
17910 : :
17911 : :
17912 : : /*
17913 : : AddNameToScope - adds a Name, n, to the list of objects declared at the
17914 : : current scope.
17915 : : */
17916 : :
17917 : 4668712 : extern "C" void SymbolTable_AddNameToScope (NameKey_Name n)
17918 : : {
17919 : 4668712 : SymbolTable_PtrToSymbol pSym;
17920 : 4668712 : unsigned int scope;
17921 : :
17922 : 4668712 : scope = SymbolTable_GetCurrentScope ();
17923 : 4668712 : pSym = GetPsym (scope);
17924 : 4668712 : switch (pSym->SymbolType)
17925 : : {
17926 : 793511 : case SymbolTable_ProcedureSym:
17927 : 793511 : AddNameTo (pSym->Procedure.NamedObjects, MakeObject (n));
17928 : 793511 : break;
17929 : :
17930 : 41856 : case SymbolTable_ModuleSym:
17931 : 41856 : AddNameTo (pSym->Module.NamedObjects, MakeObject (n));
17932 : 41856 : break;
17933 : :
17934 : 3833345 : case SymbolTable_DefImpSym:
17935 : 3833345 : AddNameTo (pSym->DefImp.NamedObjects, MakeObject (n));
17936 : 3833345 : break;
17937 : :
17938 : :
17939 : 0 : default:
17940 : 0 : M2Error_InternalError ((const char *) "expecting - DefImp", 18);
17941 : 4668712 : break;
17942 : : }
17943 : 4668712 : }
17944 : :
17945 : :
17946 : : /*
17947 : : AddNameToImportList - adds a Name, n, to the import list of the current
17948 : : module.
17949 : : */
17950 : :
17951 : 162 : extern "C" void SymbolTable_AddNameToImportList (NameKey_Name n)
17952 : : {
17953 : 162 : SymbolTable_PtrToSymbol pSym;
17954 : 162 : unsigned int scope;
17955 : :
17956 : 162 : scope = SymbolTable_GetCurrentScope ();
17957 : 162 : pSym = GetPsym (scope);
17958 : 162 : switch (pSym->SymbolType)
17959 : : {
17960 : 162 : case SymbolTable_ModuleSym:
17961 : 162 : AddNameTo (pSym->Module.NamedImports, MakeObject (n));
17962 : 162 : break;
17963 : :
17964 : 0 : case SymbolTable_DefImpSym:
17965 : 0 : AddNameTo (pSym->DefImp.NamedImports, MakeObject (n));
17966 : 0 : break;
17967 : :
17968 : :
17969 : 0 : default:
17970 : 0 : M2Error_InternalError ((const char *) "expecting - DefImp or Module symbol", 35);
17971 : 162 : break;
17972 : : }
17973 : 162 : }
17974 : :
17975 : :
17976 : : /*
17977 : : GetScope - returns the declaration scope of the symbol.
17978 : : */
17979 : :
17980 : 52665643 : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym)
17981 : : {
17982 : 52665643 : SymbolTable_PtrToSymbol pSym;
17983 : :
17984 : 52665643 : pSym = GetPsym (Sym);
17985 : 52665643 : switch (pSym->SymbolType)
17986 : : {
17987 : 0 : case SymbolTable_ErrorSym:
17988 : 0 : M2Error_ErrorAbort0 ((const char *) "", 0);
17989 : : break;
17990 : :
17991 : : case SymbolTable_DefImpSym:
17992 : : return SymbolTable_NulSym;
17993 : 2496605 : break;
17994 : :
17995 : 2496605 : case SymbolTable_ModuleSym:
17996 : 2496605 : return pSym->Module.Scope;
17997 : 3155747 : break;
17998 : :
17999 : 3155747 : case SymbolTable_VarSym:
18000 : 3155747 : return pSym->Var.Scope;
18001 : 30466009 : break;
18002 : :
18003 : 30466009 : case SymbolTable_ProcedureSym:
18004 : 30466009 : return pSym->Procedure.Scope;
18005 : 227768 : break;
18006 : :
18007 : 227768 : case SymbolTable_ProcTypeSym:
18008 : 227768 : return pSym->ProcType.Scope;
18009 : 819680 : break;
18010 : :
18011 : 819680 : case SymbolTable_RecordFieldSym:
18012 : 819680 : return pSym->RecordField.Scope;
18013 : 336 : break;
18014 : :
18015 : 336 : case SymbolTable_VarientSym:
18016 : 336 : return pSym->Varient.Scope;
18017 : 1476 : break;
18018 : :
18019 : 1476 : case SymbolTable_VarientFieldSym:
18020 : 1476 : return pSym->VarientField.Scope;
18021 : 85885 : break;
18022 : :
18023 : 85885 : case SymbolTable_EnumerationSym:
18024 : 85885 : return pSym->Enumeration.Scope;
18025 : 1552858 : break;
18026 : :
18027 : 1552858 : case SymbolTable_EnumerationFieldSym:
18028 : 1552858 : return pSym->EnumerationField.Scope;
18029 : 206836 : break;
18030 : :
18031 : 206836 : case SymbolTable_SubrangeSym:
18032 : 206836 : return pSym->Subrange.Scope;
18033 : 1233 : break;
18034 : :
18035 : 1233 : case SymbolTable_ArraySym:
18036 : 1233 : return pSym->Array.Scope;
18037 : 145034 : break;
18038 : :
18039 : 145034 : case SymbolTable_TypeSym:
18040 : 145034 : return pSym->Type.Scope;
18041 : 74199 : break;
18042 : :
18043 : 74199 : case SymbolTable_PointerSym:
18044 : 74199 : return pSym->Pointer.Scope;
18045 : 523820 : break;
18046 : :
18047 : 523820 : case SymbolTable_RecordSym:
18048 : 523820 : return pSym->Record.Scope;
18049 : 55232 : break;
18050 : :
18051 : 55232 : case SymbolTable_SetSym:
18052 : 55232 : return pSym->Set.Scope;
18053 : 0 : break;
18054 : :
18055 : 0 : case SymbolTable_UnboundedSym:
18056 : 0 : return pSym->Unbounded.Scope;
18057 : 0 : break;
18058 : :
18059 : 0 : case SymbolTable_ConstLitSym:
18060 : 0 : return pSym->ConstLit.Scope;
18061 : 12 : break;
18062 : :
18063 : 12 : case SymbolTable_ConstStringSym:
18064 : 12 : return pSym->ConstString.Scope;
18065 : 108 : break;
18066 : :
18067 : 108 : case SymbolTable_ConstVarSym:
18068 : 108 : return pSym->ConstVar.Scope;
18069 : 0 : break;
18070 : :
18071 : 0 : case SymbolTable_PartialUnboundedSym:
18072 : 0 : M2Error_InternalError ((const char *) "should not be requesting the scope of a PartialUnbounded symbol", 63);
18073 : 0 : break;
18074 : :
18075 : :
18076 : 0 : default:
18077 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
18078 : : break;
18079 : : }
18080 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18081 : : __builtin_unreachable ();
18082 : : }
18083 : :
18084 : :
18085 : : /*
18086 : : GetModuleScope - returns the module scope of symbol, sym.
18087 : : If sym was declared within a nested procedure
18088 : : then return the module which defines the
18089 : : procedure.
18090 : : */
18091 : :
18092 : 368852 : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym)
18093 : : {
18094 : 368852 : unsigned int mod;
18095 : :
18096 : 368852 : mod = SymbolTable_GetScope (sym);
18097 : 738760 : while (((mod != SymbolTable_NulSym) && (! (SymbolTable_IsDefImp (mod)))) && (! (SymbolTable_IsModule (mod))))
18098 : : {
18099 : 1056 : mod = SymbolTable_GetScope (mod);
18100 : : }
18101 : 368852 : return mod;
18102 : : /* static analysis guarentees a RETURN statement will be used before here. */
18103 : : __builtin_unreachable ();
18104 : : }
18105 : :
18106 : :
18107 : : /*
18108 : : GetProcedureScope - returns the innermost procedure (if any)
18109 : : in which the symbol, sym, resides.
18110 : : A module inside the procedure is skipped
18111 : : over.
18112 : : */
18113 : :
18114 : 328082 : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym)
18115 : : {
18116 : 659134 : while ((sym != SymbolTable_NulSym) && (! (SymbolTable_IsProcedure (sym))))
18117 : : {
18118 : 331052 : sym = SymbolTable_GetScope (sym);
18119 : : }
18120 : 328082 : if ((sym != SymbolTable_NulSym) && (SymbolTable_IsProcedure (sym)))
18121 : : {
18122 : : return sym;
18123 : : }
18124 : : else
18125 : : {
18126 : 326414 : return SymbolTable_NulSym;
18127 : : }
18128 : : /* static analysis guarentees a RETURN statement will be used before here. */
18129 : : __builtin_unreachable ();
18130 : : }
18131 : :
18132 : :
18133 : : /*
18134 : : IsModuleWithinProcedure - returns TRUE if module, sym, is
18135 : : inside a procedure.
18136 : : */
18137 : :
18138 : 226488 : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym)
18139 : : {
18140 : 226488 : return (SymbolTable_GetProcedureScope (sym)) != SymbolTable_NulSym;
18141 : : /* static analysis guarentees a RETURN statement will be used before here. */
18142 : : __builtin_unreachable ();
18143 : : }
18144 : :
18145 : :
18146 : : /*
18147 : : GetParent - returns the parent of symbol, Sym.
18148 : : */
18149 : :
18150 : 110242 : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym)
18151 : : {
18152 : 110242 : SymbolTable_PtrToSymbol pSym;
18153 : :
18154 : 110242 : pSym = GetPsym (Sym);
18155 : 110242 : switch (pSym->SymbolType)
18156 : : {
18157 : 6 : case SymbolTable_ErrorSym:
18158 : 6 : M2Error_ErrorAbort0 ((const char *) "", 0);
18159 : 14406 : break;
18160 : :
18161 : 14406 : case SymbolTable_VarientSym:
18162 : 14406 : return pSym->Varient.Parent;
18163 : 54870 : break;
18164 : :
18165 : 54870 : case SymbolTable_VarientFieldSym:
18166 : 54870 : return pSym->VarientField.Parent;
18167 : 40960 : break;
18168 : :
18169 : 40960 : case SymbolTable_RecordFieldSym:
18170 : 40960 : return pSym->RecordField.Parent;
18171 : 0 : break;
18172 : :
18173 : 0 : case SymbolTable_EnumerationFieldSym:
18174 : 0 : return pSym->EnumerationField.Type;
18175 : 0 : break;
18176 : :
18177 : :
18178 : 0 : default:
18179 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
18180 : : break;
18181 : : }
18182 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18183 : : __builtin_unreachable ();
18184 : : }
18185 : :
18186 : :
18187 : : /*
18188 : : IsRecordField - returns true if Sym is a record field.
18189 : : */
18190 : :
18191 : 140425879 : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym)
18192 : : {
18193 : 140425879 : SymbolTable_PtrToSymbol pSym;
18194 : :
18195 : 140425879 : pSym = GetPsym (Sym);
18196 : 140425879 : return pSym->SymbolType == SymbolTable_RecordFieldSym;
18197 : : /* static analysis guarentees a RETURN statement will be used before here. */
18198 : : __builtin_unreachable ();
18199 : : }
18200 : :
18201 : :
18202 : : /*
18203 : : MakeProcType - returns a procedure type symbol with ProcTypeName.
18204 : : */
18205 : :
18206 : 74343 : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName)
18207 : : {
18208 : 74343 : SymbolTable_PtrToSymbol pSym;
18209 : 74343 : unsigned int oaf;
18210 : 74343 : unsigned int sym;
18211 : :
18212 : 74343 : tok = CheckTok (tok, (const char *) "proctype", 8);
18213 : 74343 : sym = HandleHiddenOrDeclare (tok, ProcTypeName, &oaf);
18214 : 74343 : if (! (SymbolTable_IsError (sym)))
18215 : : {
18216 : 74343 : pSym = GetPsym (sym);
18217 : 74343 : pSym->SymbolType = SymbolTable_ProcTypeSym;
18218 : 74343 : switch (pSym->SymbolType)
18219 : : {
18220 : 74343 : case SymbolTable_ProcTypeSym:
18221 : 74343 : pSym->ProcType.ReturnType = SymbolTable_NulSym;
18222 : 74343 : pSym->ProcType.name = ProcTypeName;
18223 : 74343 : Lists_InitList (&pSym->ProcType.ListOfParam);
18224 : 74343 : pSym->ProcType.HasVarArgs = false; /* Does this proc type use ... ? */
18225 : 74343 : pSym->ProcType.HasOptArg = false; /* Does this proc type use [ ] ? */
18226 : 74343 : pSym->ProcType.OptArgInit = SymbolTable_NulSym; /* The optarg initial value. */
18227 : 74343 : pSym->ProcType.ReturnOptional = false; /* Is the return value optional? */
18228 : 74343 : pSym->ProcType.Scope = SymbolTable_GetCurrentScope ();
18229 : : /* scope of procedure. */
18230 : 74343 : pSym->ProcType.Size = M2ALU_InitValue ();
18231 : 74343 : pSym->ProcType.TotalParamSize = M2ALU_InitValue (); /* size of all parameters */
18232 : 74343 : pSym->ProcType.oafamily = oaf; /* The oa family for this symbol */
18233 : 74343 : InitWhereDeclaredTok (tok, &pSym->ProcType.At); /* Declared here */
18234 : 74343 : break;
18235 : :
18236 : :
18237 : : default:
18238 : : M2Error_InternalError ((const char *) "expecting ProcType symbol", 25);
18239 : 74343 : break;
18240 : : }
18241 : : }
18242 : 74343 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
18243 : 74343 : return sym;
18244 : : /* static analysis guarentees a RETURN statement will be used before here. */
18245 : : __builtin_unreachable ();
18246 : : }
18247 : :
18248 : :
18249 : : /*
18250 : : PutProcTypeParam - Places a Non VAR parameter ParamName with type
18251 : : ParamType into ProcType Sym.
18252 : : */
18253 : :
18254 : 76256 : extern "C" void SymbolTable_PutProcTypeParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded)
18255 : : {
18256 : 76256 : SymbolTable_PtrToSymbol pSym;
18257 : 76256 : unsigned int ParSym;
18258 : :
18259 : 76256 : NewSym (&ParSym);
18260 : 76256 : pSym = GetPsym (ParSym);
18261 : 76256 : pSym->SymbolType = SymbolTable_ParamSym;
18262 : 76256 : pSym->Param.name = NameKey_NulName;
18263 : 76256 : pSym->Param.Type = ParamType;
18264 : 76256 : pSym->Param.IsUnbounded = isUnbounded;
18265 : 76256 : pSym->Param.ShadowVar = SymbolTable_NulSym;
18266 : 76256 : InitWhereDeclared (&pSym->Param.At);
18267 : 76256 : AddParameter (Sym, ParSym);
18268 : 76256 : }
18269 : :
18270 : :
18271 : : /*
18272 : : PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
18273 : : ParamType into ProcType Sym.
18274 : : */
18275 : :
18276 : 5662 : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded)
18277 : : {
18278 : 5662 : SymbolTable_PtrToSymbol pSym;
18279 : 5662 : unsigned int ParSym;
18280 : :
18281 : 5662 : NewSym (&ParSym);
18282 : 5662 : pSym = GetPsym (ParSym);
18283 : 5662 : pSym->SymbolType = SymbolTable_VarParamSym;
18284 : 5662 : pSym->Param.name = NameKey_NulName;
18285 : 5662 : pSym->Param.Type = ParamType;
18286 : 5662 : pSym->Param.IsUnbounded = isUnbounded;
18287 : 5662 : pSym->Param.ShadowVar = SymbolTable_NulSym;
18288 : 5662 : InitWhereDeclared (&pSym->Param.At);
18289 : 5662 : AddParameter (Sym, ParSym);
18290 : 5662 : }
18291 : :
18292 : :
18293 : : /*
18294 : : IsProcType - returns true if Sym is a ProcType Symbol.
18295 : : */
18296 : :
18297 : 96133310 : extern "C" bool SymbolTable_IsProcType (unsigned int Sym)
18298 : : {
18299 : 96133310 : SymbolTable_PtrToSymbol pSym;
18300 : :
18301 : 96133310 : pSym = GetPsym (Sym);
18302 : 96133310 : return pSym->SymbolType == SymbolTable_ProcTypeSym;
18303 : : /* static analysis guarentees a RETURN statement will be used before here. */
18304 : : __builtin_unreachable ();
18305 : : }
18306 : :
18307 : :
18308 : : /*
18309 : : IsVar - returns true if Sym is a Var Symbol.
18310 : : */
18311 : :
18312 : 86903480 : extern "C" bool SymbolTable_IsVar (unsigned int Sym)
18313 : : {
18314 : 86903480 : SymbolTable_PtrToSymbol pSym;
18315 : :
18316 : 86903480 : pSym = GetPsym (Sym);
18317 : 86903480 : return pSym->SymbolType == SymbolTable_VarSym;
18318 : : /* static analysis guarentees a RETURN statement will be used before here. */
18319 : : __builtin_unreachable ();
18320 : : }
18321 : :
18322 : :
18323 : : /*
18324 : : IsVarConst - returns the IsConst field indicating the variable is read only.
18325 : : */
18326 : :
18327 : 314349 : extern "C" bool SymbolTable_IsVarConst (unsigned int sym)
18328 : : {
18329 : 314349 : SymbolTable_PtrToSymbol pSym;
18330 : :
18331 : 314349 : pSym = GetPsym (sym);
18332 : 314349 : switch (pSym->SymbolType)
18333 : : {
18334 : 314349 : case SymbolTable_VarSym:
18335 : 314349 : return pSym->Var.IsConst;
18336 : 0 : break;
18337 : :
18338 : :
18339 : 0 : default:
18340 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
18341 : : break;
18342 : : }
18343 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18344 : : __builtin_unreachable ();
18345 : : }
18346 : :
18347 : :
18348 : : /*
18349 : : IsConst - returns true if Sym contains a constant value.
18350 : : */
18351 : :
18352 : 100678819 : extern "C" bool SymbolTable_IsConst (unsigned int Sym)
18353 : : {
18354 : 100678819 : if (SymbolTable_IsConstructor (Sym))
18355 : : {
18356 : 584153 : return SymbolTable_IsConstructorConstant (Sym);
18357 : : }
18358 : : else
18359 : : {
18360 : 100094666 : return DoIsConst (Sym);
18361 : : }
18362 : : /* static analysis guarentees a RETURN statement will be used before here. */
18363 : : __builtin_unreachable ();
18364 : : }
18365 : :
18366 : :
18367 : : /*
18368 : : IsConstString - returns whether sym is a conststring of any variant.
18369 : : */
18370 : :
18371 : 7339564 : extern "C" bool SymbolTable_IsConstString (unsigned int sym)
18372 : : {
18373 : 7339564 : SymbolTable_PtrToSymbol pSym;
18374 : :
18375 : 7339564 : pSym = GetPsym (sym);
18376 : 7339564 : return pSym->SymbolType == SymbolTable_ConstStringSym;
18377 : : /* static analysis guarentees a RETURN statement will be used before here. */
18378 : : __builtin_unreachable ();
18379 : : }
18380 : :
18381 : :
18382 : : /*
18383 : : IsConstStringNulTerminated - returns TRUE if the constant string, sym,
18384 : : should be created with a nul terminator.
18385 : : */
18386 : :
18387 : 0 : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym)
18388 : : {
18389 : 0 : SymbolTable_PtrToSymbol pSym;
18390 : :
18391 : 0 : pSym = GetPsym (sym);
18392 : 0 : switch (pSym->SymbolType)
18393 : : {
18394 : 0 : case SymbolTable_ConstStringSym:
18395 : 0 : return (pSym->ConstString.StringVariant == SymbolTable_m2nulstr) || (pSym->ConstString.StringVariant == SymbolTable_cnulstr);
18396 : 0 : break;
18397 : :
18398 : :
18399 : 0 : default:
18400 : 0 : M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
18401 : : break;
18402 : : }
18403 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18404 : : __builtin_unreachable ();
18405 : : }
18406 : :
18407 : :
18408 : : /*
18409 : : IsConstLit - returns true if Sym is a literal constant.
18410 : : */
18411 : :
18412 : 6080436 : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym)
18413 : : {
18414 : 6080436 : SymbolTable_PtrToSymbol pSym;
18415 : :
18416 : 6080436 : pSym = GetPsym (Sym);
18417 : 6080424 : return pSym->SymbolType == SymbolTable_ConstLitSym;
18418 : : /* static analysis guarentees a RETURN statement will be used before here. */
18419 : : __builtin_unreachable ();
18420 : : }
18421 : :
18422 : :
18423 : : /*
18424 : : IsConstructor - returns TRUE if the constant is declared as a
18425 : : constant set, array or record.
18426 : : */
18427 : :
18428 : 155319214 : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym)
18429 : : {
18430 : 155319214 : SymbolTable_PtrToSymbol pSym;
18431 : :
18432 : 155319214 : pSym = GetPsym (Sym);
18433 : 155319214 : switch (pSym->SymbolType)
18434 : : {
18435 : 23912283 : case SymbolTable_ConstVarSym:
18436 : 23912283 : return pSym->ConstVar.IsConstructor;
18437 : 24307010 : break;
18438 : :
18439 : 24307010 : case SymbolTable_ConstLitSym:
18440 : 24307010 : return pSym->ConstLit.IsConstructor;
18441 : : break;
18442 : :
18443 : :
18444 : : default:
18445 : : return false;
18446 : : break;
18447 : : }
18448 : : /* static analysis guarentees a RETURN statement will be used before here. */
18449 : : __builtin_unreachable ();
18450 : : }
18451 : :
18452 : :
18453 : : /*
18454 : : IsDummy - returns true if Sym is a Dummy symbol.
18455 : : */
18456 : :
18457 : 0 : extern "C" bool SymbolTable_IsDummy (unsigned int Sym)
18458 : : {
18459 : 0 : SymbolTable_PtrToSymbol pSym;
18460 : :
18461 : 0 : pSym = GetPsym (Sym);
18462 : 0 : return pSym->SymbolType == SymbolTable_DummySym;
18463 : : /* static analysis guarentees a RETURN statement will be used before here. */
18464 : : __builtin_unreachable ();
18465 : : }
18466 : :
18467 : :
18468 : : /*
18469 : : IsTemporary - returns true if Sym is a Temporary symbol.
18470 : : */
18471 : :
18472 : 1913794 : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym)
18473 : : {
18474 : 1913794 : SymbolTable_PtrToSymbol pSym;
18475 : :
18476 : 1913794 : pSym = GetPsym (Sym);
18477 : 1913794 : switch (pSym->SymbolType)
18478 : : {
18479 : 1830575 : case SymbolTable_VarSym:
18480 : 1830575 : return pSym->Var.IsTemp;
18481 : 2800 : break;
18482 : :
18483 : 2800 : case SymbolTable_ConstVarSym:
18484 : 2800 : return pSym->ConstVar.IsTemp;
18485 : : break;
18486 : :
18487 : :
18488 : : default:
18489 : : return false;
18490 : : break;
18491 : : }
18492 : : /* static analysis guarentees a RETURN statement will be used before here. */
18493 : : __builtin_unreachable ();
18494 : : }
18495 : :
18496 : :
18497 : : /*
18498 : : IsVarAParam - returns true if Sym is a variable declared as a parameter.
18499 : : */
18500 : :
18501 : 36439 : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym)
18502 : : {
18503 : 36439 : SymbolTable_PtrToSymbol pSym;
18504 : :
18505 : 36439 : pSym = GetPsym (Sym);
18506 : 36439 : switch (pSym->SymbolType)
18507 : : {
18508 : 36439 : case SymbolTable_VarSym:
18509 : 36439 : return pSym->Var.IsParam;
18510 : : break;
18511 : :
18512 : :
18513 : : default:
18514 : : return false;
18515 : : break;
18516 : : }
18517 : : /* static analysis guarentees a RETURN statement will be used before here. */
18518 : : __builtin_unreachable ();
18519 : : }
18520 : :
18521 : :
18522 : : /*
18523 : : IsSubscript - returns true if Sym is a subscript symbol.
18524 : : */
18525 : :
18526 : 2667847 : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym)
18527 : : {
18528 : 2667847 : SymbolTable_PtrToSymbol pSym;
18529 : :
18530 : 2667847 : pSym = GetPsym (Sym);
18531 : 2667847 : return pSym->SymbolType == SymbolTable_SubscriptSym;
18532 : : /* static analysis guarentees a RETURN statement will be used before here. */
18533 : : __builtin_unreachable ();
18534 : : }
18535 : :
18536 : :
18537 : : /*
18538 : : IsSubrange - returns true if Sym is a subrange symbol.
18539 : : */
18540 : :
18541 : 109690482 : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym)
18542 : : {
18543 : 109690482 : SymbolTable_PtrToSymbol pSym;
18544 : :
18545 : 109690482 : pSym = GetPsym (Sym);
18546 : 109690482 : return pSym->SymbolType == SymbolTable_SubrangeSym;
18547 : : /* static analysis guarentees a RETURN statement will be used before here. */
18548 : : __builtin_unreachable ();
18549 : : }
18550 : :
18551 : :
18552 : : /*
18553 : : IsProcedureVariable - returns true if a Sym is a variable and
18554 : : it was declared within a procedure.
18555 : : */
18556 : :
18557 : 0 : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym)
18558 : : {
18559 : 0 : CheckLegal (Sym);
18560 : 0 : return (SymbolTable_IsVar (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetVarScope (Sym)));
18561 : : /* static analysis guarentees a RETURN statement will be used before here. */
18562 : : __builtin_unreachable ();
18563 : : }
18564 : :
18565 : :
18566 : : /*
18567 : : IsProcedureNested - returns TRUE if procedure, Sym, was
18568 : : declared as a nested procedure.
18569 : : */
18570 : :
18571 : 3049198 : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym)
18572 : : {
18573 : 3049198 : return (SymbolTable_IsProcedure (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetScope (Sym)));
18574 : : /* static analysis guarentees a RETURN statement will be used before here. */
18575 : : __builtin_unreachable ();
18576 : : }
18577 : :
18578 : :
18579 : : /*
18580 : : IsAModula2Type - returns true if Sym, is a:
18581 : : IsType, IsPointer, IsRecord, IsEnumeration,
18582 : : IsSubrange, IsArray, IsUnbounded, IsProcType.
18583 : : NOTE that it different from IsType.
18584 : : */
18585 : :
18586 : 15685941 : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym)
18587 : : {
18588 : 15685941 : CheckLegal (Sym);
18589 : 15685941 : 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));
18590 : : /* static analysis guarentees a RETURN statement will be used before here. */
18591 : : __builtin_unreachable ();
18592 : : }
18593 : :
18594 : :
18595 : : /*
18596 : : IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
18597 : : */
18598 : :
18599 : 18 : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym)
18600 : : {
18601 : 18 : SymbolTable_PtrToSymbol pSym;
18602 : :
18603 : 18 : pSym = GetPsym (Sym);
18604 : 18 : switch (pSym->SymbolType)
18605 : : {
18606 : 18 : case SymbolTable_GnuAsmSym:
18607 : 18 : return pSym->GnuAsm.Volatile;
18608 : 0 : break;
18609 : :
18610 : :
18611 : 0 : default:
18612 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
18613 : : break;
18614 : : }
18615 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18616 : : __builtin_unreachable ();
18617 : : }
18618 : :
18619 : :
18620 : : /*
18621 : : IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
18622 : : */
18623 : :
18624 : 18 : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym)
18625 : : {
18626 : 18 : SymbolTable_PtrToSymbol pSym;
18627 : :
18628 : 18 : pSym = GetPsym (Sym);
18629 : 18 : switch (pSym->SymbolType)
18630 : : {
18631 : 18 : case SymbolTable_GnuAsmSym:
18632 : 18 : return pSym->GnuAsm.Simple;
18633 : 0 : break;
18634 : :
18635 : :
18636 : 0 : default:
18637 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
18638 : : break;
18639 : : }
18640 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18641 : : __builtin_unreachable ();
18642 : : }
18643 : :
18644 : :
18645 : : /*
18646 : : IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
18647 : : */
18648 : :
18649 : 78 : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym)
18650 : : {
18651 : 78 : SymbolTable_PtrToSymbol pSym;
18652 : :
18653 : 78 : pSym = GetPsym (Sym);
18654 : 78 : return pSym->SymbolType == SymbolTable_GnuAsmSym;
18655 : : /* static analysis guarentees a RETURN statement will be used before here. */
18656 : : __builtin_unreachable ();
18657 : : }
18658 : :
18659 : :
18660 : : /*
18661 : : IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
18662 : : */
18663 : :
18664 : 0 : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym)
18665 : : {
18666 : 0 : SymbolTable_PtrToSymbol pSym;
18667 : :
18668 : 0 : pSym = GetPsym (Sym);
18669 : 0 : return pSym->SymbolType == SymbolTable_InterfaceSym;
18670 : : /* static analysis guarentees a RETURN statement will be used before here. */
18671 : : __builtin_unreachable ();
18672 : : }
18673 : :
18674 : :
18675 : : /*
18676 : : IsSizeSolved - returns true if the size of Sym is solved.
18677 : : */
18678 : :
18679 : 19795 : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym)
18680 : : {
18681 : 19795 : SymbolTable_PtrToSymbol pSym;
18682 : :
18683 : 19795 : CheckLegal (Sym);
18684 : 19795 : pSym = GetPsym (Sym);
18685 : 19795 : switch (pSym->SymbolType)
18686 : : {
18687 : 0 : case SymbolTable_ProcedureSym:
18688 : 0 : return M2ALU_IsSolved (pSym->Procedure.Size);
18689 : 1364 : break;
18690 : :
18691 : 1364 : case SymbolTable_VarSym:
18692 : 1364 : return M2ALU_IsSolved (pSym->Var.Size);
18693 : 12600 : break;
18694 : :
18695 : 12600 : case SymbolTable_TypeSym:
18696 : 12600 : return M2ALU_IsSolved (pSym->Type.Size);
18697 : 2293 : break;
18698 : :
18699 : 2293 : case SymbolTable_SetSym:
18700 : 2293 : return M2ALU_IsSolved (pSym->Set.Size);
18701 : 12 : break;
18702 : :
18703 : 12 : case SymbolTable_RecordSym:
18704 : 12 : return M2ALU_IsSolved (pSym->Record.Size);
18705 : 0 : break;
18706 : :
18707 : 0 : case SymbolTable_VarientSym:
18708 : 0 : return M2ALU_IsSolved (pSym->Varient.Size);
18709 : 0 : break;
18710 : :
18711 : 0 : case SymbolTable_EnumerationSym:
18712 : 0 : return M2ALU_IsSolved (pSym->Enumeration.Size);
18713 : 52 : break;
18714 : :
18715 : 52 : case SymbolTable_PointerSym:
18716 : 52 : return M2ALU_IsSolved (pSym->Pointer.Size);
18717 : 3462 : break;
18718 : :
18719 : 3462 : case SymbolTable_ArraySym:
18720 : 3462 : return M2ALU_IsSolved (pSym->Array.Size);
18721 : 0 : break;
18722 : :
18723 : 0 : case SymbolTable_RecordFieldSym:
18724 : 0 : return M2ALU_IsSolved (pSym->RecordField.Size);
18725 : 0 : break;
18726 : :
18727 : 0 : case SymbolTable_VarientFieldSym:
18728 : 0 : return M2ALU_IsSolved (pSym->VarientField.Size);
18729 : 0 : break;
18730 : :
18731 : 0 : case SymbolTable_SubrangeSym:
18732 : 0 : return M2ALU_IsSolved (pSym->Subrange.Size);
18733 : 0 : break;
18734 : :
18735 : 0 : case SymbolTable_SubscriptSym:
18736 : 0 : return M2ALU_IsSolved (pSym->Subscript.Size);
18737 : 12 : break;
18738 : :
18739 : 12 : case SymbolTable_ProcTypeSym:
18740 : 12 : return M2ALU_IsSolved (pSym->ProcType.Size);
18741 : 0 : break;
18742 : :
18743 : 0 : case SymbolTable_UnboundedSym:
18744 : 0 : return M2ALU_IsSolved (pSym->Unbounded.Size);
18745 : 0 : break;
18746 : :
18747 : :
18748 : 0 : default:
18749 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
18750 : : break;
18751 : : }
18752 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18753 : : __builtin_unreachable ();
18754 : : }
18755 : :
18756 : :
18757 : : /*
18758 : : IsOffsetSolved - returns true if the Offset of Sym is solved.
18759 : : */
18760 : :
18761 : 0 : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym)
18762 : : {
18763 : 0 : SymbolTable_PtrToSymbol pSym;
18764 : :
18765 : 0 : CheckLegal (Sym);
18766 : 0 : pSym = GetPsym (Sym);
18767 : 0 : switch (pSym->SymbolType)
18768 : : {
18769 : 0 : case SymbolTable_VarSym:
18770 : 0 : return M2ALU_IsSolved (pSym->Var.Offset);
18771 : 0 : break;
18772 : :
18773 : 0 : case SymbolTable_RecordFieldSym:
18774 : 0 : return M2ALU_IsSolved (pSym->RecordField.Offset);
18775 : 0 : break;
18776 : :
18777 : 0 : case SymbolTable_VarientFieldSym:
18778 : 0 : return M2ALU_IsSolved (pSym->VarientField.Offset);
18779 : 0 : break;
18780 : :
18781 : :
18782 : 0 : default:
18783 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
18784 : : break;
18785 : : }
18786 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18787 : : __builtin_unreachable ();
18788 : : }
18789 : :
18790 : :
18791 : : /*
18792 : : IsValueSolved - returns true if the value of Sym is solved.
18793 : : */
18794 : :
18795 : 3443473 : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym)
18796 : : {
18797 : 3443473 : SymbolTable_PtrToSymbol pSym;
18798 : :
18799 : 3443473 : CheckLegal (Sym);
18800 : 3443473 : pSym = GetPsym (Sym);
18801 : 3443473 : switch (pSym->SymbolType)
18802 : : {
18803 : 1392437 : case SymbolTable_ConstLitSym:
18804 : 1392437 : return M2ALU_IsSolved (pSym->ConstLit.Value);
18805 : 1320575 : break;
18806 : :
18807 : 1320575 : case SymbolTable_ConstVarSym:
18808 : 1320575 : return M2ALU_IsSolved (pSym->ConstVar.Value);
18809 : 453469 : break;
18810 : :
18811 : 453469 : case SymbolTable_EnumerationFieldSym:
18812 : 453469 : return M2ALU_IsSolved (pSym->EnumerationField.Value);
18813 : : break;
18814 : :
18815 : : case SymbolTable_ConstStringSym:
18816 : : return true;
18817 : 6 : break;
18818 : :
18819 : :
18820 : 6 : default:
18821 : 6 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
18822 : : break;
18823 : : }
18824 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18825 : : __builtin_unreachable ();
18826 : : }
18827 : :
18828 : :
18829 : : /*
18830 : : IsConstructorConstant - returns TRUE if constructor, Sym, is
18831 : : defined by only constants.
18832 : : */
18833 : :
18834 : 661127 : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym)
18835 : : {
18836 : 661127 : SymbolTable_PtrToSymbol pSym;
18837 : :
18838 : 661127 : if ((SymbolTable_IsConstructor (Sym)) || (SymbolTable_IsConstSet (Sym)))
18839 : : {
18840 : 661127 : pSym = GetPsym (Sym);
18841 : 661127 : switch (pSym->SymbolType)
18842 : : {
18843 : 661127 : case SymbolTable_ConstVarSym:
18844 : 661127 : return M2ALU_IsValueConst (pSym->ConstVar.Value);
18845 : 0 : break;
18846 : :
18847 : 0 : case SymbolTable_ConstLitSym:
18848 : 0 : return M2ALU_IsValueConst (pSym->ConstLit.Value);
18849 : 0 : break;
18850 : :
18851 : :
18852 : 0 : default:
18853 : 0 : M2Error_InternalError ((const char *) "expecting Constructor", 21);
18854 : 0 : break;
18855 : : }
18856 : : }
18857 : : else
18858 : : {
18859 : 0 : M2Error_InternalError ((const char *) "expecting Constructor", 21);
18860 : : }
18861 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18862 : : __builtin_unreachable ();
18863 : : }
18864 : :
18865 : :
18866 : : /*
18867 : : IsComposite - returns TRUE if symbol, sym, is a composite
18868 : : type: ie an ARRAY or RECORD.
18869 : : */
18870 : :
18871 : 157700 : extern "C" bool SymbolTable_IsComposite (unsigned int sym)
18872 : : {
18873 : 157700 : if (sym == SymbolTable_NulSym)
18874 : : {
18875 : : return false;
18876 : : }
18877 : : else
18878 : : {
18879 : 157694 : sym = SymbolTable_SkipType (sym);
18880 : 157694 : return (SymbolTable_IsArray (sym)) || (SymbolTable_IsRecord (sym));
18881 : : }
18882 : : /* static analysis guarentees a RETURN statement will be used before here. */
18883 : : __builtin_unreachable ();
18884 : : }
18885 : :
18886 : :
18887 : : /*
18888 : : IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
18889 : : */
18890 : :
18891 : 0 : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym)
18892 : : {
18893 : 0 : SymbolTable_PtrToSymbol pSym;
18894 : :
18895 : 0 : CheckLegal (Sym);
18896 : 0 : pSym = GetPsym (Sym);
18897 : 0 : switch (pSym->SymbolType)
18898 : : {
18899 : 0 : case SymbolTable_ProcedureSym:
18900 : 0 : return M2ALU_IsSolved (pSym->Procedure.TotalParamSize);
18901 : 0 : break;
18902 : :
18903 : 0 : case SymbolTable_ProcTypeSym:
18904 : 0 : return M2ALU_IsSolved (pSym->ProcType.TotalParamSize);
18905 : 0 : break;
18906 : :
18907 : :
18908 : 0 : default:
18909 : 0 : M2Error_InternalError ((const char *) "expecting Procedure or ProcType symbol", 38);
18910 : : break;
18911 : : }
18912 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18913 : : __builtin_unreachable ();
18914 : : }
18915 : :
18916 : :
18917 : : /*
18918 : : PutAlignment - assigns the alignment constant associated with,
18919 : : type, with, align.
18920 : : */
18921 : :
18922 : 192 : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align)
18923 : : {
18924 : 192 : SymbolTable_PtrToSymbol pSym;
18925 : :
18926 : 192 : pSym = GetPsym (type);
18927 : 192 : switch (pSym->SymbolType)
18928 : : {
18929 : 0 : case SymbolTable_RecordSym:
18930 : 0 : pSym->Record.Align = align;
18931 : 0 : break;
18932 : :
18933 : 120 : case SymbolTable_RecordFieldSym:
18934 : 120 : pSym->RecordField.Align = align;
18935 : 120 : break;
18936 : :
18937 : 18 : case SymbolTable_TypeSym:
18938 : 18 : pSym->Type.Align = align;
18939 : 18 : break;
18940 : :
18941 : 30 : case SymbolTable_ArraySym:
18942 : 30 : pSym->Array.Align = align;
18943 : 30 : break;
18944 : :
18945 : 12 : case SymbolTable_PointerSym:
18946 : 12 : pSym->Pointer.Align = align;
18947 : 12 : break;
18948 : :
18949 : 12 : case SymbolTable_SubrangeSym:
18950 : 12 : pSym->Subrange.Align = align;
18951 : 12 : break;
18952 : :
18953 : :
18954 : 0 : default:
18955 : 0 : M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
18956 : 192 : break;
18957 : : }
18958 : 192 : }
18959 : :
18960 : :
18961 : : /*
18962 : : GetAlignment - returns the alignment constant associated with,
18963 : : type.
18964 : : */
18965 : :
18966 : 87917727 : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type)
18967 : : {
18968 : 87918465 : SymbolTable_PtrToSymbol pSym;
18969 : :
18970 : 87918465 : pSym = GetPsym (type);
18971 : 87918465 : switch (pSym->SymbolType)
18972 : : {
18973 : 83949 : case SymbolTable_RecordSym:
18974 : 83949 : return pSym->Record.Align;
18975 : 41813658 : break;
18976 : :
18977 : 41813658 : case SymbolTable_RecordFieldSym:
18978 : 41813658 : return pSym->RecordField.Align;
18979 : 30204165 : break;
18980 : :
18981 : 30204165 : case SymbolTable_TypeSym:
18982 : 30204165 : return pSym->Type.Align;
18983 : 1736040 : break;
18984 : :
18985 : 1736040 : case SymbolTable_ArraySym:
18986 : 1736040 : return pSym->Array.Align;
18987 : 11859131 : break;
18988 : :
18989 : 11859131 : case SymbolTable_PointerSym:
18990 : 11859131 : return pSym->Pointer.Align;
18991 : 702 : break;
18992 : :
18993 : 702 : case SymbolTable_VarientFieldSym:
18994 : 702 : return SymbolTable_GetAlignment (pSym->VarientField.Parent);
18995 : 36 : break;
18996 : :
18997 : 36 : case SymbolTable_VarientSym:
18998 : 36 : return SymbolTable_GetAlignment (pSym->Varient.Parent);
18999 : 2220784 : break;
19000 : :
19001 : 2220784 : case SymbolTable_SubrangeSym:
19002 : 2220784 : return pSym->Subrange.Align;
19003 : 0 : break;
19004 : :
19005 : :
19006 : 0 : default:
19007 : 0 : M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
19008 : : break;
19009 : : }
19010 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19011 : : __builtin_unreachable ();
19012 : : }
19013 : :
19014 : :
19015 : : /*
19016 : : GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
19017 : : to record, sym.
19018 : : */
19019 : :
19020 : 7678382 : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym)
19021 : : {
19022 : 7679012 : SymbolTable_PtrToSymbol pSym;
19023 : :
19024 : 7679012 : pSym = GetPsym (sym);
19025 : 7679012 : switch (pSym->SymbolType)
19026 : : {
19027 : 7678382 : case SymbolTable_RecordSym:
19028 : 7678382 : return pSym->Record.DefaultAlign;
19029 : 630 : break;
19030 : :
19031 : 630 : case SymbolTable_VarientFieldSym:
19032 : 630 : return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
19033 : 0 : break;
19034 : :
19035 : 0 : case SymbolTable_VarientSym:
19036 : 0 : return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
19037 : 0 : break;
19038 : :
19039 : :
19040 : 0 : default:
19041 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
19042 : : break;
19043 : : }
19044 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19045 : : __builtin_unreachable ();
19046 : : }
19047 : :
19048 : :
19049 : : /*
19050 : : PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
19051 : : to record, sym.
19052 : : */
19053 : :
19054 : 36 : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align)
19055 : : {
19056 : 36 : SymbolTable_PtrToSymbol pSym;
19057 : :
19058 : 36 : pSym = GetPsym (sym);
19059 : 36 : switch (pSym->SymbolType)
19060 : : {
19061 : 36 : case SymbolTable_RecordSym:
19062 : 36 : pSym->Record.DefaultAlign = align;
19063 : 36 : break;
19064 : :
19065 : :
19066 : 0 : default:
19067 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
19068 : 36 : break;
19069 : : }
19070 : 36 : }
19071 : :
19072 : :
19073 : : /*
19074 : : PutUnused - sets, sym, as unused. This is a gm2 pragma.
19075 : : */
19076 : :
19077 : 0 : extern "C" void SymbolTable_PutUnused (unsigned int sym)
19078 : : {
19079 : 0 : SymbolTable_PtrToSymbol pSym;
19080 : :
19081 : 0 : pSym = GetPsym (sym);
19082 : 0 : switch (pSym->SymbolType)
19083 : : {
19084 : 0 : case SymbolTable_RecordFieldSym:
19085 : 0 : pSym->RecordField.Used = false;
19086 : 0 : break;
19087 : :
19088 : :
19089 : 0 : default:
19090 : 0 : M2MetaError_MetaError1 ((const char *) "cannot use pragma 'unused' on symbol {%1ad}", 43, sym);
19091 : 0 : break;
19092 : : }
19093 : 0 : }
19094 : :
19095 : :
19096 : : /*
19097 : : IsUnused - returns TRUE if the symbol was declared as unused with a
19098 : : gm2 pragma.
19099 : : */
19100 : :
19101 : 151543 : extern "C" bool SymbolTable_IsUnused (unsigned int sym)
19102 : : {
19103 : 151543 : SymbolTable_PtrToSymbol pSym;
19104 : :
19105 : 151543 : pSym = GetPsym (sym);
19106 : 151543 : switch (pSym->SymbolType)
19107 : : {
19108 : 151543 : case SymbolTable_RecordFieldSym:
19109 : 151543 : return ! pSym->RecordField.Used;
19110 : 0 : break;
19111 : :
19112 : :
19113 : 0 : default:
19114 : 0 : M2Error_InternalError ((const char *) "expecting a record field symbol", 31);
19115 : : break;
19116 : : }
19117 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19118 : : __builtin_unreachable ();
19119 : : }
19120 : :
19121 : :
19122 : : /*
19123 : : PutDeclaredPacked - sets the Packed field of the record or record field symbol.
19124 : : */
19125 : :
19126 : 405399 : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b)
19127 : : {
19128 : 405399 : SymbolTable_PtrToSymbol pSym;
19129 : :
19130 : 405399 : pSym = GetPsym (sym);
19131 : 405399 : switch (pSym->SymbolType)
19132 : : {
19133 : 83247 : case SymbolTable_RecordSym:
19134 : 83247 : pSym->Record.DeclPacked = b;
19135 : 83247 : pSym->Record.DeclResolved = true;
19136 : 83247 : break;
19137 : :
19138 : 321048 : case SymbolTable_RecordFieldSym:
19139 : 321048 : pSym->RecordField.DeclPacked = b;
19140 : 321048 : pSym->RecordField.DeclResolved = true;
19141 : 321048 : break;
19142 : :
19143 : 600 : case SymbolTable_VarientFieldSym:
19144 : 600 : pSym->VarientField.DeclPacked = b;
19145 : 600 : pSym->VarientField.DeclResolved = true;
19146 : 600 : break;
19147 : :
19148 : 504 : case SymbolTable_VarientSym:
19149 : 504 : pSym->Varient.DeclPacked = b;
19150 : 504 : pSym->Varient.DeclResolved = true;
19151 : 504 : break;
19152 : :
19153 : :
19154 : 0 : default:
19155 : 0 : M2Error_InternalError ((const char *) "expecting a record or field record symbol", 41);
19156 : 405399 : break;
19157 : : }
19158 : 405399 : }
19159 : :
19160 : :
19161 : : /*
19162 : : IsDeclaredPacked - was the record symbol or record field, sym,
19163 : : declared as packed?
19164 : : */
19165 : :
19166 : 1131744 : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym)
19167 : : {
19168 : 1131744 : SymbolTable_PtrToSymbol pSym;
19169 : :
19170 : 1131744 : pSym = GetPsym (sym);
19171 : 1131744 : switch (pSym->SymbolType)
19172 : : {
19173 : 166494 : case SymbolTable_RecordSym:
19174 : 166494 : return pSym->Record.DeclPacked;
19175 : 963366 : break;
19176 : :
19177 : 963366 : case SymbolTable_RecordFieldSym:
19178 : 963366 : return pSym->RecordField.DeclPacked;
19179 : 1332 : break;
19180 : :
19181 : 1332 : case SymbolTable_VarientFieldSym:
19182 : 1332 : return pSym->VarientField.DeclPacked;
19183 : 552 : break;
19184 : :
19185 : 552 : case SymbolTable_VarientSym:
19186 : 552 : return pSym->Varient.DeclPacked;
19187 : 0 : break;
19188 : :
19189 : :
19190 : 0 : default:
19191 : 0 : M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
19192 : : break;
19193 : : }
19194 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19195 : : __builtin_unreachable ();
19196 : : }
19197 : :
19198 : :
19199 : : /*
19200 : : IsDeclaredPackedResolved - do we know if the record symbol or record
19201 : : field, sym, declared as packed or not packed?
19202 : : */
19203 : :
19204 : 0 : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym)
19205 : : {
19206 : 0 : SymbolTable_PtrToSymbol pSym;
19207 : :
19208 : 0 : pSym = GetPsym (sym);
19209 : 0 : switch (pSym->SymbolType)
19210 : : {
19211 : 0 : case SymbolTable_RecordSym:
19212 : 0 : return pSym->Record.DeclResolved;
19213 : 0 : break;
19214 : :
19215 : 0 : case SymbolTable_RecordFieldSym:
19216 : 0 : return pSym->RecordField.DeclResolved;
19217 : 0 : break;
19218 : :
19219 : 0 : case SymbolTable_VarientFieldSym:
19220 : 0 : return pSym->VarientField.DeclResolved;
19221 : 0 : break;
19222 : :
19223 : 0 : case SymbolTable_VarientSym:
19224 : 0 : return pSym->Varient.DeclResolved;
19225 : 0 : break;
19226 : :
19227 : :
19228 : 0 : default:
19229 : 0 : M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
19230 : : break;
19231 : : }
19232 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19233 : : __builtin_unreachable ();
19234 : : }
19235 : :
19236 : :
19237 : : /*
19238 : : GetPackedEquivalent - returns the packed equivalent of type, sym.
19239 : : sym must be a type, subrange or enumerated type.
19240 : : */
19241 : :
19242 : 16644 : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym)
19243 : : {
19244 : 16644 : SymbolTable_PtrToSymbol pSym;
19245 : :
19246 : 16644 : pSym = GetPsym (sym);
19247 : 16644 : switch (pSym->SymbolType)
19248 : : {
19249 : 16524 : case SymbolTable_EnumerationSym:
19250 : 16524 : return GetEquivalent (&pSym->Enumeration.packedInfo, sym);
19251 : 120 : break;
19252 : :
19253 : 120 : case SymbolTable_SubrangeSym:
19254 : 120 : return GetEquivalent (&pSym->Subrange.packedInfo, sym);
19255 : 0 : break;
19256 : :
19257 : 0 : case SymbolTable_TypeSym:
19258 : 0 : return GetEquivalent (&pSym->Type.packedInfo, sym);
19259 : 0 : break;
19260 : :
19261 : 0 : case SymbolTable_SetSym:
19262 : 0 : return GetEquivalent (&pSym->Set.packedInfo, sym);
19263 : 0 : break;
19264 : :
19265 : :
19266 : 0 : default:
19267 : 0 : M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
19268 : : break;
19269 : : }
19270 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19271 : : __builtin_unreachable ();
19272 : : }
19273 : :
19274 : :
19275 : : /*
19276 : : GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
19277 : : */
19278 : :
19279 : 0 : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym)
19280 : : {
19281 : 0 : SymbolTable_PtrToSymbol pSym;
19282 : :
19283 : 0 : pSym = GetPsym (sym);
19284 : 0 : switch (pSym->SymbolType)
19285 : : {
19286 : 0 : case SymbolTable_EquivSym:
19287 : 0 : return pSym->Equiv.nonPacked;
19288 : 0 : break;
19289 : :
19290 : :
19291 : 0 : default:
19292 : 0 : M2Error_InternalError ((const char *) "expecting equivalent symbol", 27);
19293 : : break;
19294 : : }
19295 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19296 : : __builtin_unreachable ();
19297 : : }
19298 : :
19299 : :
19300 : : /*
19301 : : IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
19302 : : */
19303 : :
19304 : 0 : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym)
19305 : : {
19306 : 0 : SymbolTable_PtrToSymbol pSym;
19307 : :
19308 : 0 : pSym = GetPsym (sym);
19309 : 0 : switch (pSym->SymbolType)
19310 : : {
19311 : : case SymbolTable_EquivSym:
19312 : : return true;
19313 : 0 : break;
19314 : :
19315 : :
19316 : 0 : default:
19317 : 0 : return false;
19318 : : break;
19319 : : }
19320 : : /* static analysis guarentees a RETURN statement will be used before here. */
19321 : : __builtin_unreachable ();
19322 : : }
19323 : :
19324 : :
19325 : : /*
19326 : : PushSize - pushes the size of Sym.
19327 : : */
19328 : :
19329 : 87545 : extern "C" void SymbolTable_PushSize (unsigned int Sym)
19330 : : {
19331 : 87545 : SymbolTable_PtrToSymbol pSym;
19332 : :
19333 : 87545 : CheckLegal (Sym);
19334 : 87545 : pSym = GetPsym (Sym);
19335 : 87545 : switch (pSym->SymbolType)
19336 : : {
19337 : 0 : case SymbolTable_ProcedureSym:
19338 : 0 : M2ALU_PushFrom (pSym->Procedure.Size);
19339 : 0 : break;
19340 : :
19341 : 1364 : case SymbolTable_VarSym:
19342 : 1364 : M2ALU_PushFrom (pSym->Var.Size);
19343 : 1364 : break;
19344 : :
19345 : 12600 : case SymbolTable_TypeSym:
19346 : 12600 : M2ALU_PushFrom (pSym->Type.Size);
19347 : 12600 : break;
19348 : :
19349 : 2293 : case SymbolTable_SetSym:
19350 : 2293 : M2ALU_PushFrom (pSym->Set.Size);
19351 : 2293 : break;
19352 : :
19353 : 0 : case SymbolTable_VarientSym:
19354 : 0 : M2ALU_PushFrom (pSym->Varient.Size);
19355 : 0 : break;
19356 : :
19357 : 12 : case SymbolTable_RecordSym:
19358 : 12 : M2ALU_PushFrom (pSym->Record.Size);
19359 : 12 : break;
19360 : :
19361 : 0 : case SymbolTable_EnumerationSym:
19362 : 0 : M2ALU_PushFrom (pSym->Enumeration.Size);
19363 : 0 : break;
19364 : :
19365 : 67802 : case SymbolTable_PointerSym:
19366 : 67802 : M2ALU_PushFrom (pSym->Pointer.Size);
19367 : 67802 : break;
19368 : :
19369 : 3462 : case SymbolTable_ArraySym:
19370 : 3462 : M2ALU_PushFrom (pSym->Array.Size);
19371 : 3462 : break;
19372 : :
19373 : 0 : case SymbolTable_RecordFieldSym:
19374 : 0 : M2ALU_PushFrom (pSym->RecordField.Size);
19375 : 0 : break;
19376 : :
19377 : 0 : case SymbolTable_VarientFieldSym:
19378 : 0 : M2ALU_PushFrom (pSym->VarientField.Size);
19379 : 0 : break;
19380 : :
19381 : 0 : case SymbolTable_SubrangeSym:
19382 : 0 : M2ALU_PushFrom (pSym->Subrange.Size);
19383 : 0 : break;
19384 : :
19385 : 0 : case SymbolTable_SubscriptSym:
19386 : 0 : M2ALU_PushFrom (pSym->Subscript.Size);
19387 : 0 : break;
19388 : :
19389 : 12 : case SymbolTable_ProcTypeSym:
19390 : 12 : M2ALU_PushFrom (pSym->ProcType.Size);
19391 : 12 : break;
19392 : :
19393 : 0 : case SymbolTable_UnboundedSym:
19394 : 0 : M2ALU_PushFrom (pSym->Unbounded.Size);
19395 : 0 : break;
19396 : :
19397 : :
19398 : 0 : default:
19399 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19400 : 87545 : break;
19401 : : }
19402 : 87545 : }
19403 : :
19404 : :
19405 : : /*
19406 : : PushOffset - pushes the Offset of Sym.
19407 : : */
19408 : :
19409 : 0 : extern "C" void SymbolTable_PushOffset (unsigned int Sym)
19410 : : {
19411 : 0 : SymbolTable_PtrToSymbol pSym;
19412 : :
19413 : 0 : CheckLegal (Sym);
19414 : 0 : pSym = GetPsym (Sym);
19415 : 0 : switch (pSym->SymbolType)
19416 : : {
19417 : 0 : case SymbolTable_VarSym:
19418 : 0 : M2ALU_PushFrom (pSym->Var.Offset);
19419 : 0 : break;
19420 : :
19421 : 0 : case SymbolTable_RecordFieldSym:
19422 : 0 : M2ALU_PushFrom (pSym->RecordField.Offset);
19423 : 0 : break;
19424 : :
19425 : 0 : case SymbolTable_VarientFieldSym:
19426 : 0 : M2ALU_PushFrom (pSym->VarientField.Offset);
19427 : 0 : break;
19428 : :
19429 : :
19430 : 0 : default:
19431 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19432 : 0 : break;
19433 : : }
19434 : 0 : }
19435 : :
19436 : :
19437 : : /*
19438 : : PushValue - pushes the Value of Sym onto the ALU stack.
19439 : : */
19440 : :
19441 : 13480068 : extern "C" void SymbolTable_PushValue (unsigned int Sym)
19442 : : {
19443 : 13480068 : SymbolTable_PtrToSymbol pSym;
19444 : :
19445 : 13480068 : CheckLegal (Sym);
19446 : 13480068 : pSym = GetPsym (Sym);
19447 : 13480068 : switch (pSym->SymbolType)
19448 : : {
19449 : 1909589 : case SymbolTable_ConstLitSym:
19450 : 1909589 : M2ALU_PushFrom (pSym->ConstLit.Value);
19451 : 1909589 : break;
19452 : :
19453 : 485075 : case SymbolTable_ConstVarSym:
19454 : 485075 : M2ALU_PushFrom (pSym->ConstVar.Value);
19455 : 485075 : break;
19456 : :
19457 : 11073376 : case SymbolTable_EnumerationFieldSym:
19458 : 11073376 : M2ALU_PushFrom (pSym->EnumerationField.Value);
19459 : 11073376 : break;
19460 : :
19461 : 12028 : case SymbolTable_ConstStringSym:
19462 : 12028 : PushConstString (Sym);
19463 : 12028 : break;
19464 : :
19465 : :
19466 : 0 : default:
19467 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19468 : 13480068 : break;
19469 : : }
19470 : 13480068 : }
19471 : :
19472 : :
19473 : : /*
19474 : : PushParamSize - push the size of parameter, ParamNo,
19475 : : of procedure Sym onto the ALU stack.
19476 : : */
19477 : :
19478 : 0 : extern "C" void SymbolTable_PushParamSize (unsigned int Sym, unsigned int ParamNo)
19479 : : {
19480 : 0 : unsigned int p;
19481 : 0 : unsigned int Type;
19482 : :
19483 : 0 : CheckLegal (Sym);
19484 : 0 : M2Debug_Assert ((SymbolTable_IsProcedure (Sym)) || (SymbolTable_IsProcType (Sym)));
19485 : 0 : if (ParamNo == 0)
19486 : : {
19487 : 0 : SymbolTable_PushSize (SymbolTable_GetType (Sym));
19488 : : }
19489 : : else
19490 : : {
19491 : : /*
19492 : : can use GetNthParam but 1..n returns parameter.
19493 : : But 0 yields the function return type.
19494 : :
19495 : : Note that VAR Unbounded parameters and non VAR Unbounded parameters
19496 : : contain the unbounded descriptor. VAR unbounded parameters
19497 : : do NOT JUST contain an address re: other VAR parameters.
19498 : : */
19499 : 0 : if ((SymbolTable_IsVarParam (Sym, ParamNo)) && (! (SymbolTable_IsUnboundedParam (Sym, ParamNo))))
19500 : : {
19501 : 0 : SymbolTable_PushSize (M2System_Address); /* VAR parameters point to the variable */
19502 : : }
19503 : : else
19504 : : {
19505 : 0 : p = SymbolTable_GetNthParam (Sym, ParamNo); /* nth Parameter */
19506 : : /*
19507 : : N.B. chose to get the Type of the parameter rather than the Var
19508 : : because ProcType's have Type but no Var associated with them.
19509 : : */
19510 : 0 : Type = SymbolTable_GetType (p); /* ie Variable from Procedure Sym */
19511 : 0 : M2Debug_Assert (p != SymbolTable_NulSym); /* If this fails then ParamNo is out of range */
19512 : 0 : SymbolTable_PushSize (Type); /* If this fails then ParamNo is out of range */
19513 : : }
19514 : : }
19515 : 0 : }
19516 : :
19517 : :
19518 : : /*
19519 : : PushSumOfLocalVarSize - push the total size of all local variables
19520 : : onto the ALU stack.
19521 : : */
19522 : :
19523 : 0 : extern "C" void SymbolTable_PushSumOfLocalVarSize (unsigned int Sym)
19524 : : {
19525 : 0 : SymbolTable_PtrToSymbol pSym;
19526 : :
19527 : 0 : CheckLegal (Sym);
19528 : 0 : pSym = GetPsym (Sym);
19529 : 0 : switch (pSym->SymbolType)
19530 : : {
19531 : 0 : case SymbolTable_ProcedureSym:
19532 : 0 : case SymbolTable_DefImpSym:
19533 : 0 : case SymbolTable_ModuleSym:
19534 : 0 : SymbolTable_PushSize (Sym);
19535 : 0 : break;
19536 : :
19537 : :
19538 : 0 : default:
19539 : 0 : M2Error_InternalError ((const char *) "expecting Procedure, DefImp or Module symbol", 44);
19540 : 0 : break;
19541 : : }
19542 : 0 : }
19543 : :
19544 : :
19545 : : /*
19546 : : PushSumOfParamSize - push the total size of all parameters onto
19547 : : the ALU stack.
19548 : : */
19549 : :
19550 : 0 : extern "C" void SymbolTable_PushSumOfParamSize (unsigned int Sym)
19551 : : {
19552 : 0 : SymbolTable_PtrToSymbol pSym;
19553 : :
19554 : 0 : CheckLegal (Sym);
19555 : 0 : pSym = GetPsym (Sym);
19556 : 0 : switch (pSym->SymbolType)
19557 : : {
19558 : 0 : case SymbolTable_ProcedureSym:
19559 : 0 : M2ALU_PushFrom (pSym->Procedure.TotalParamSize);
19560 : 0 : break;
19561 : :
19562 : 0 : case SymbolTable_ProcTypeSym:
19563 : 0 : M2ALU_PushFrom (pSym->ProcType.TotalParamSize);
19564 : 0 : break;
19565 : :
19566 : :
19567 : 0 : default:
19568 : 0 : M2Error_InternalError ((const char *) "expecting Procedure or ProcType symbol", 38);
19569 : 0 : break;
19570 : : }
19571 : 0 : }
19572 : :
19573 : :
19574 : : /*
19575 : : PushVarSize - pushes the size of a variable, Sym.
19576 : : The runtime size of Sym will depend upon its addressing mode,
19577 : : RightValue has size PushSize(GetType(Sym)) and
19578 : : LeftValue has size PushSize(Address) since it points to a
19579 : : variable.
19580 : : */
19581 : :
19582 : 0 : extern "C" void SymbolTable_PushVarSize (unsigned int Sym)
19583 : : {
19584 : 0 : CheckLegal (Sym);
19585 : 0 : M2Debug_Assert (SymbolTable_IsVar (Sym));
19586 : 0 : if ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue)
19587 : : {
19588 : 0 : SymbolTable_PushSize (M2System_Address);
19589 : : }
19590 : : else
19591 : : {
19592 : 0 : M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_RightValue);
19593 : 0 : SymbolTable_PushSize (SymbolTable_GetType (Sym));
19594 : : }
19595 : 0 : }
19596 : :
19597 : :
19598 : : /*
19599 : : PopValue - pops the ALU stack into Value of Sym.
19600 : : */
19601 : :
19602 : 1159899 : extern "C" void SymbolTable_PopValue (unsigned int Sym)
19603 : : {
19604 : 1159899 : SymbolTable_PtrToSymbol pSym;
19605 : :
19606 : 1159899 : CheckLegal (Sym);
19607 : 1159899 : pSym = GetPsym (Sym);
19608 : 1159899 : switch (pSym->SymbolType)
19609 : : {
19610 : 0 : case SymbolTable_ConstLitSym:
19611 : 0 : M2ALU_PopInto (pSym->ConstLit.Value);
19612 : 0 : break;
19613 : :
19614 : 1159899 : case SymbolTable_ConstVarSym:
19615 : 1159899 : M2ALU_PopInto (pSym->ConstVar.Value);
19616 : 1159899 : break;
19617 : :
19618 : 0 : case SymbolTable_EnumerationFieldSym:
19619 : 0 : M2Error_InternalError ((const char *) "cannot pop into an enumeration field", 36);
19620 : 0 : break;
19621 : :
19622 : :
19623 : 0 : default:
19624 : 0 : M2Error_InternalError ((const char *) "symbol type not expected", 24);
19625 : 1159899 : break;
19626 : : }
19627 : 1159899 : }
19628 : :
19629 : :
19630 : : /*
19631 : : PopSize - pops the ALU stack into Size of Sym.
19632 : : */
19633 : :
19634 : 767278 : extern "C" void SymbolTable_PopSize (unsigned int Sym)
19635 : : {
19636 : 767278 : SymbolTable_PtrToSymbol pSym;
19637 : :
19638 : 767278 : CheckLegal (Sym);
19639 : 767278 : pSym = GetPsym (Sym);
19640 : 767278 : switch (pSym->SymbolType)
19641 : : {
19642 : 0 : case SymbolTable_ProcedureSym:
19643 : 0 : M2ALU_PopInto (pSym->Procedure.Size);
19644 : 0 : break;
19645 : :
19646 : 1096 : case SymbolTable_VarSym:
19647 : 1096 : M2ALU_PopInto (pSym->Var.Size);
19648 : 1096 : break;
19649 : :
19650 : 639060 : case SymbolTable_TypeSym:
19651 : 639060 : M2ALU_PopInto (pSym->Type.Size);
19652 : 639060 : break;
19653 : :
19654 : 12 : case SymbolTable_RecordSym:
19655 : 12 : M2ALU_PopInto (pSym->Record.Size);
19656 : 12 : break;
19657 : :
19658 : 0 : case SymbolTable_VarientSym:
19659 : 0 : M2ALU_PopInto (pSym->Varient.Size);
19660 : 0 : break;
19661 : :
19662 : 0 : case SymbolTable_EnumerationSym:
19663 : 0 : M2ALU_PopInto (pSym->Enumeration.Size);
19664 : 0 : break;
19665 : :
19666 : 16845 : case SymbolTable_PointerSym:
19667 : 16845 : M2ALU_PopInto (pSym->Pointer.Size);
19668 : 16845 : break;
19669 : :
19670 : 618 : case SymbolTable_ArraySym:
19671 : 618 : M2ALU_PopInto (pSym->Array.Size);
19672 : 618 : break;
19673 : :
19674 : 0 : case SymbolTable_RecordFieldSym:
19675 : 0 : M2ALU_PopInto (pSym->RecordField.Size);
19676 : 0 : break;
19677 : :
19678 : 0 : case SymbolTable_VarientFieldSym:
19679 : 0 : M2ALU_PopInto (pSym->VarientField.Size);
19680 : 0 : break;
19681 : :
19682 : 0 : case SymbolTable_SubrangeSym:
19683 : 0 : M2ALU_PopInto (pSym->Subrange.Size);
19684 : 0 : break;
19685 : :
19686 : 25202 : case SymbolTable_SubscriptSym:
19687 : 25202 : M2ALU_PopInto (pSym->Subscript.Size);
19688 : 25202 : break;
19689 : :
19690 : 16829 : case SymbolTable_ProcTypeSym:
19691 : 16829 : M2ALU_PopInto (pSym->ProcType.Size);
19692 : 16829 : break;
19693 : :
19694 : 0 : case SymbolTable_UnboundedSym:
19695 : 0 : M2ALU_PopInto (pSym->Unbounded.Size);
19696 : 0 : break;
19697 : :
19698 : 67616 : case SymbolTable_SetSym:
19699 : 67616 : M2ALU_PopInto (pSym->Set.Size);
19700 : 67616 : break;
19701 : :
19702 : :
19703 : 0 : default:
19704 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19705 : 767278 : break;
19706 : : }
19707 : 767278 : }
19708 : :
19709 : :
19710 : : /*
19711 : : PopOffset - pops the ALU stack into Offset of Sym.
19712 : : */
19713 : :
19714 : 0 : extern "C" void SymbolTable_PopOffset (unsigned int Sym)
19715 : : {
19716 : 0 : SymbolTable_PtrToSymbol pSym;
19717 : :
19718 : 0 : CheckLegal (Sym);
19719 : 0 : pSym = GetPsym (Sym);
19720 : 0 : switch (pSym->SymbolType)
19721 : : {
19722 : 0 : case SymbolTable_VarSym:
19723 : 0 : M2ALU_PopInto (pSym->Var.Offset);
19724 : 0 : break;
19725 : :
19726 : 0 : case SymbolTable_RecordFieldSym:
19727 : 0 : M2ALU_PopInto (pSym->RecordField.Offset);
19728 : 0 : break;
19729 : :
19730 : 0 : case SymbolTable_VarientFieldSym:
19731 : 0 : M2ALU_PopInto (pSym->VarientField.Offset);
19732 : 0 : break;
19733 : :
19734 : :
19735 : 0 : default:
19736 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19737 : 0 : break;
19738 : : }
19739 : 0 : }
19740 : :
19741 : :
19742 : : /*
19743 : : PopSumOfParamSize - pop the total value on the ALU stack as the
19744 : : sum of all parameters.
19745 : : */
19746 : :
19747 : 0 : extern "C" void SymbolTable_PopSumOfParamSize (unsigned int Sym)
19748 : : {
19749 : 0 : SymbolTable_PtrToSymbol pSym;
19750 : :
19751 : 0 : CheckLegal (Sym);
19752 : 0 : pSym = GetPsym (Sym);
19753 : 0 : switch (pSym->SymbolType)
19754 : : {
19755 : 0 : case SymbolTable_ProcedureSym:
19756 : 0 : M2ALU_PopInto (pSym->Procedure.TotalParamSize);
19757 : 0 : break;
19758 : :
19759 : 0 : case SymbolTable_ProcTypeSym:
19760 : 0 : M2ALU_PopInto (pSym->ProcType.TotalParamSize);
19761 : 0 : break;
19762 : :
19763 : :
19764 : 0 : default:
19765 : 0 : M2Error_InternalError ((const char *) "expecting Procedure or ProcType symbol", 38);
19766 : 0 : break;
19767 : : }
19768 : 0 : }
19769 : :
19770 : :
19771 : : /*
19772 : : IsObject - returns TRUE if the symbol is an object symbol.
19773 : : */
19774 : :
19775 : 0 : extern "C" bool SymbolTable_IsObject (unsigned int Sym)
19776 : : {
19777 : 0 : SymbolTable_PtrToSymbol pSym;
19778 : :
19779 : 0 : CheckLegal (Sym);
19780 : 0 : pSym = GetPsym (Sym);
19781 : 0 : return pSym->SymbolType == SymbolTable_ObjectSym;
19782 : : /* static analysis guarentees a RETURN statement will be used before here. */
19783 : : __builtin_unreachable ();
19784 : : }
19785 : :
19786 : :
19787 : : /*
19788 : : IsTuple - returns TRUE if the symbol is a tuple symbol.
19789 : : */
19790 : :
19791 : 0 : extern "C" bool SymbolTable_IsTuple (unsigned int Sym)
19792 : : {
19793 : 0 : SymbolTable_PtrToSymbol pSym;
19794 : :
19795 : 0 : CheckLegal (Sym);
19796 : 0 : pSym = GetPsym (Sym);
19797 : 0 : return pSym->SymbolType == SymbolTable_TupleSym;
19798 : : /* static analysis guarentees a RETURN statement will be used before here. */
19799 : : __builtin_unreachable ();
19800 : : }
19801 : :
19802 : :
19803 : : /*
19804 : : Make2Tuple - creates and returns a 2 tuple from, a, and, b.
19805 : : */
19806 : :
19807 : 486 : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b)
19808 : : {
19809 : 486 : SymbolTable_PtrToSymbol pSym;
19810 : 486 : unsigned int Sym;
19811 : :
19812 : 486 : NewSym (&Sym);
19813 : 486 : pSym = GetPsym (Sym);
19814 : 486 : pSym->SymbolType = SymbolTable_TupleSym;
19815 : 486 : pSym->Tuple.nTuple = 2;
19816 : 486 : pSym->Tuple.list = Indexing_InitIndex (1);
19817 : 486 : PutIntoIndex (&pSym->Tuple.list, 1, a);
19818 : 486 : PutIntoIndex (&pSym->Tuple.list, 2, b);
19819 : 486 : InitWhereDeclared (&pSym->Tuple.At);
19820 : 486 : InitWhereFirstUsed (&pSym->Tuple.At);
19821 : 486 : return Sym;
19822 : : /* static analysis guarentees a RETURN statement will be used before here. */
19823 : : __builtin_unreachable ();
19824 : : }
19825 : :
19826 : :
19827 : : /*
19828 : : MakeError - creates an error node, which can be used in MetaError messages.
19829 : : It will be removed from ExportUndeclared and Unknown trees.
19830 : : */
19831 : :
19832 : 72 : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name)
19833 : : {
19834 : 72 : SymbolTable_PtrToSymbol pSym;
19835 : 72 : unsigned int Sym;
19836 : :
19837 : : /* if Sym is present on the unknown tree then remove it */
19838 : 72 : Sym = FetchUnknownSym (name);
19839 : 72 : if (Sym == SymbolTable_NulSym)
19840 : : {
19841 : 66 : NewSym (&Sym);
19842 : : }
19843 : : else
19844 : : {
19845 : : /*
19846 : : remove symbol from this tree as we have already generated
19847 : : a meaningful error message
19848 : : */
19849 : 6 : RemoveExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
19850 : : }
19851 : 72 : pSym = GetPsym (Sym);
19852 : 72 : pSym->SymbolType = SymbolTable_ErrorSym;
19853 : 72 : pSym->Error.name = name;
19854 : 72 : InitWhereDeclaredTok (tok, &pSym->Error.At);
19855 : 72 : InitWhereFirstUsedTok (tok, &pSym->Error.At);
19856 : 72 : return Sym;
19857 : : /* static analysis guarentees a RETURN statement will be used before here. */
19858 : : __builtin_unreachable ();
19859 : : }
19860 : :
19861 : :
19862 : : /*
19863 : : MakeErrorS - creates an error node from a string, which can be used
19864 : : in MetaError messages.
19865 : : It will be removed from ExportUndeclared and Unknown trees.
19866 : : */
19867 : :
19868 : 0 : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name)
19869 : : {
19870 : 0 : return SymbolTable_MakeError (tok, NameKey_makekey (DynamicStrings_string (name)));
19871 : : /* static analysis guarentees a RETURN statement will be used before here. */
19872 : : __builtin_unreachable ();
19873 : : }
19874 : :
19875 : :
19876 : : /*
19877 : : IsError - returns TRUE if the symbol is an error symbol.
19878 : : */
19879 : :
19880 : 15673183 : extern "C" bool SymbolTable_IsError (unsigned int Sym)
19881 : : {
19882 : 15673183 : SymbolTable_PtrToSymbol pSym;
19883 : :
19884 : 15673183 : CheckLegal (Sym);
19885 : 15673183 : pSym = GetPsym (Sym);
19886 : 15673183 : return pSym->SymbolType == SymbolTable_ErrorSym;
19887 : : /* static analysis guarentees a RETURN statement will be used before here. */
19888 : : __builtin_unreachable ();
19889 : : }
19890 : :
19891 : :
19892 : : /*
19893 : : IsLegal - returns TRUE if, sym, is a legal symbol.
19894 : : */
19895 : :
19896 : 1081464 : extern "C" bool SymbolTable_IsLegal (unsigned int sym)
19897 : : {
19898 : 1081464 : return sym < FreeSymbol;
19899 : : /* static analysis guarentees a RETURN statement will be used before here. */
19900 : : __builtin_unreachable ();
19901 : : }
19902 : :
19903 : :
19904 : : /*
19905 : : PutModuleContainsBuiltin - sets a flag in the current compiled module which
19906 : : indicates that a builtin procedure is being declared.
19907 : : This is only expected to be called when we are
19908 : : parsing the definition module.
19909 : : */
19910 : :
19911 : 46000 : extern "C" void SymbolTable_PutModuleContainsBuiltin (void)
19912 : : {
19913 : 46000 : SymbolTable_PtrToSymbol pSym;
19914 : :
19915 : 46000 : SymbolTable_PutHiddenTypeDeclared ();
19916 : 46000 : pSym = GetPsym (CurrentModule);
19917 : 46000 : switch (pSym->SymbolType)
19918 : : {
19919 : 46000 : case SymbolTable_DefImpSym:
19920 : 46000 : pSym->DefImp.ContainsBuiltin = true;
19921 : 46000 : break;
19922 : :
19923 : :
19924 : 0 : default:
19925 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
19926 : 46000 : break;
19927 : : }
19928 : 46000 : }
19929 : :
19930 : :
19931 : : /*
19932 : : IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
19933 : : */
19934 : :
19935 : 117931 : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym)
19936 : : {
19937 : 117931 : SymbolTable_PtrToSymbol pSym;
19938 : :
19939 : 117931 : pSym = GetPsym (Sym);
19940 : 117931 : switch (pSym->SymbolType)
19941 : : {
19942 : 117931 : case SymbolTable_DefImpSym:
19943 : 117931 : return pSym->DefImp.ContainsBuiltin;
19944 : 0 : break;
19945 : :
19946 : :
19947 : 0 : default:
19948 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
19949 : : break;
19950 : : }
19951 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19952 : : __builtin_unreachable ();
19953 : : }
19954 : :
19955 : :
19956 : : /*
19957 : : PutHiddenTypeDeclared - sets a flag in the current compiled module which
19958 : : indicates that a Hidden Type is declared within
19959 : : the implementation part of the module.
19960 : : This procedure is expected to be called while
19961 : : compiling the associated definition module.
19962 : : */
19963 : :
19964 : 164952 : extern "C" void SymbolTable_PutHiddenTypeDeclared (void)
19965 : : {
19966 : 164952 : SymbolTable_PtrToSymbol pSym;
19967 : :
19968 : 164952 : pSym = GetPsym (CurrentModule);
19969 : 164952 : switch (pSym->SymbolType)
19970 : : {
19971 : 164952 : case SymbolTable_DefImpSym:
19972 : 164952 : pSym->DefImp.ContainsHiddenType = true;
19973 : 164952 : break;
19974 : :
19975 : :
19976 : 0 : default:
19977 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
19978 : 164952 : break;
19979 : : }
19980 : 164952 : }
19981 : :
19982 : :
19983 : : /*
19984 : : IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
19985 : : the module, Sym.
19986 : : */
19987 : :
19988 : 5332986 : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym)
19989 : : {
19990 : 5332986 : SymbolTable_PtrToSymbol pSym;
19991 : :
19992 : 5332986 : pSym = GetPsym (Sym);
19993 : 5332986 : switch (pSym->SymbolType)
19994 : : {
19995 : 5332986 : case SymbolTable_DefImpSym:
19996 : 5332986 : return pSym->DefImp.ContainsHiddenType;
19997 : 0 : break;
19998 : :
19999 : :
20000 : 0 : default:
20001 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20002 : : break;
20003 : : }
20004 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20005 : : __builtin_unreachable ();
20006 : : }
20007 : :
20008 : :
20009 : : /*
20010 : : DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
20011 : : */
20012 : :
20013 : 0 : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym)
20014 : : {
20015 : 0 : SymbolTable_PtrToSymbol pSym;
20016 : 0 : NameKey_Name n;
20017 : :
20018 : 0 : n = SymbolTable_GetSymName (ModSym);
20019 : 0 : M2Printf_printf1 ((const char *) "Symbol trees for module/procedure: %a\\n", 39, (const unsigned char *) &n, (sizeof (n)-1));
20020 : 0 : pSym = GetPsym (ModSym);
20021 : 0 : switch (pSym->SymbolType)
20022 : : {
20023 : 0 : case SymbolTable_DefImpSym:
20024 : 0 : n = SymbolTable_GetSymName (ModSym);
20025 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20026 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20027 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20028 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20029 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20030 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20031 : 0 : M2Printf_printf1 ((const char *) "%a ExportRequest", 17, (const unsigned char *) &n, (sizeof (n)-1));
20032 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportRequest, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20033 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20034 : 0 : M2Printf_printf1 ((const char *) "%a ExportQualified", 19, (const unsigned char *) &n, (sizeof (n)-1));
20035 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20036 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20037 : 0 : M2Printf_printf1 ((const char *) "%a ExportUnQualified", 21, (const unsigned char *) &n, (sizeof (n)-1));
20038 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20039 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20040 : 0 : M2Printf_printf1 ((const char *) "%a ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
20041 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20042 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20043 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20044 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20045 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20046 : 0 : M2Printf_printf1 ((const char *) "%a ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20047 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20048 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20049 : 0 : break;
20050 : :
20051 : 0 : case SymbolTable_ModuleSym:
20052 : 0 : n = SymbolTable_GetSymName (ModSym);
20053 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20054 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20055 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20056 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20057 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20058 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20059 : 0 : M2Printf_printf1 ((const char *) "%a ImportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
20060 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20061 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20062 : 0 : M2Printf_printf1 ((const char *) "%a ExportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
20063 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20064 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20065 : 0 : M2Printf_printf1 ((const char *) "%a ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
20066 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20067 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20068 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20069 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20070 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20071 : 0 : M2Printf_printf1 ((const char *) "%a ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20072 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20073 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20074 : 0 : break;
20075 : :
20076 : 0 : case SymbolTable_ProcedureSym:
20077 : 0 : n = SymbolTable_GetSymName (ModSym);
20078 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20079 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20080 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20081 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20082 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20083 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20084 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20085 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20086 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20087 : 0 : break;
20088 : :
20089 : :
20090 : 0 : default:
20091 : 0 : M2Error_InternalError ((const char *) "expecting DefImp symbol", 23);
20092 : 0 : break;
20093 : : }
20094 : 0 : }
20095 : :
20096 : :
20097 : : /*
20098 : : DebugLineNumbers - internal debugging, emit all procedure names in this module
20099 : : together with the line numbers for the corresponding begin/end
20100 : : tokens.
20101 : : */
20102 : :
20103 : 16182 : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym)
20104 : : {
20105 : 16182 : if (M2Options_GetDebugFunctionLineNumbers ())
20106 : : {
20107 : 0 : M2Printf_printf0 ((const char *) "<lines>\\n", 9);
20108 : 0 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DebugProcedureLineNumber});
20109 : 0 : M2Printf_printf0 ((const char *) "</lines>\\n", 10);
20110 : : }
20111 : 16182 : }
20112 : :
20113 : :
20114 : : /*
20115 : : GetErrorScope - returns the error scope for a symbol.
20116 : : The error scope is the title scope which is used to
20117 : : announce the symbol in the GCC error message.
20118 : : */
20119 : :
20120 : 3495921 : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym)
20121 : : {
20122 : 3495921 : SymbolTable_PtrToSymbol pSym;
20123 : :
20124 : 3495921 : pSym = GetPsym (sym);
20125 : 3495921 : switch (pSym->SymbolType)
20126 : : {
20127 : 1211905 : case SymbolTable_ProcedureSym:
20128 : 1211905 : return pSym->Procedure.errorScope;
20129 : 193252 : break;
20130 : :
20131 : 193252 : case SymbolTable_ModuleSym:
20132 : 193252 : return pSym->Module.errorScope;
20133 : 2090764 : break;
20134 : :
20135 : 2090764 : case SymbolTable_DefImpSym:
20136 : 2090764 : return pSym->DefImp.errorScope;
20137 : 0 : break;
20138 : :
20139 : 0 : case SymbolTable_UndefinedSym:
20140 : 0 : return pSym->Undefined.errorScope;
20141 : 0 : break;
20142 : :
20143 : :
20144 : 0 : default:
20145 : 0 : M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
20146 : : break;
20147 : : }
20148 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20149 : : __builtin_unreachable ();
20150 : : }
20151 : :
20152 : :
20153 : : /*
20154 : : MakeImport - create and return an import symbol.
20155 : : moduleSym is the symbol being imported.
20156 : : isqualified is FALSE if it were IMPORT modulename and
20157 : : TRUE for the qualified FROM modulename IMPORT etc.
20158 : : listno is the import list count for this module.
20159 : : tok should match this modulename position.
20160 : : */
20161 : :
20162 : 284239 : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified)
20163 : : {
20164 : 284239 : unsigned int importSym;
20165 : 284239 : SymbolTable_PtrToSymbol pSym;
20166 : :
20167 : 284239 : NewSym (&importSym);
20168 : 284239 : pSym = GetPsym (importSym);
20169 : 284239 : pSym->SymbolType = SymbolTable_ImportSym;
20170 : 284239 : pSym->Import.module = moduleSym;
20171 : 284239 : pSym->Import.listNo = listno;
20172 : 284239 : pSym->Import.qualified = isqualified;
20173 : 284239 : InitWhereDeclaredTok (tok, &pSym->Import.at);
20174 : 284239 : return importSym;
20175 : : /* static analysis guarentees a RETURN statement will be used before here. */
20176 : : __builtin_unreachable ();
20177 : : }
20178 : :
20179 : :
20180 : : /*
20181 : : MakeImportStatement - return a dependent symbol which represents an import statement
20182 : : or a qualified import statement. The tok should either match
20183 : : the FROM token or the IMPORT token. listno is the import list
20184 : : count for the module.
20185 : : */
20186 : :
20187 : 276403 : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno)
20188 : : {
20189 : 276403 : unsigned int dependentSym;
20190 : 276403 : SymbolTable_PtrToSymbol pSym;
20191 : :
20192 : 276403 : NewSym (&dependentSym);
20193 : 276403 : pSym = GetPsym (dependentSym);
20194 : 276403 : pSym->SymbolType = SymbolTable_ImportStatementSym;
20195 : 276403 : pSym->ImportStatement.listNo = listno;
20196 : 276403 : Lists_InitList (&pSym->ImportStatement.ListOfImports);
20197 : 276403 : InitWhereDeclaredTok (tok, &pSym->ImportStatement.at);
20198 : 276403 : return dependentSym;
20199 : : /* static analysis guarentees a RETURN statement will be used before here. */
20200 : : __builtin_unreachable ();
20201 : : }
20202 : :
20203 : :
20204 : : /*
20205 : : IsImport - returns TRUE if sym is an import symbol.
20206 : : */
20207 : :
20208 : 779583 : extern "C" bool SymbolTable_IsImport (unsigned int sym)
20209 : : {
20210 : 779583 : SymbolTable_PtrToSymbol pSym;
20211 : :
20212 : 779583 : pSym = GetPsym (sym);
20213 : 779583 : return pSym->SymbolType == SymbolTable_ImportSym;
20214 : : /* static analysis guarentees a RETURN statement will be used before here. */
20215 : : __builtin_unreachable ();
20216 : : }
20217 : :
20218 : :
20219 : : /*
20220 : : IsImportStatement - returns TRUE if sym is a dependent symbol.
20221 : : */
20222 : :
20223 : 1030226 : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym)
20224 : : {
20225 : 1030226 : SymbolTable_PtrToSymbol pSym;
20226 : :
20227 : 1030226 : pSym = GetPsym (sym);
20228 : 1030226 : return pSym->SymbolType == SymbolTable_ImportStatementSym;
20229 : : /* static analysis guarentees a RETURN statement will be used before here. */
20230 : : __builtin_unreachable ();
20231 : : }
20232 : :
20233 : :
20234 : : /*
20235 : : GetImportModule - returns the module associated with the import symbol.
20236 : : */
20237 : :
20238 : 235732 : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym)
20239 : : {
20240 : 235732 : SymbolTable_PtrToSymbol pSym;
20241 : :
20242 : 235732 : M2Debug_Assert (SymbolTable_IsImport (sym));
20243 : 235732 : pSym = GetPsym (sym);
20244 : 235732 : return pSym->Import.module;
20245 : : /* static analysis guarentees a RETURN statement will be used before here. */
20246 : : __builtin_unreachable ();
20247 : : }
20248 : :
20249 : :
20250 : : /*
20251 : : GetImportDeclared - returns the token associated with the import symbol.
20252 : : */
20253 : :
20254 : 23880 : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym)
20255 : : {
20256 : 23880 : unsigned int tok;
20257 : :
20258 : 23880 : M2Debug_Assert (SymbolTable_IsImport (sym));
20259 : 23880 : tok = SymbolTable_GetDeclaredDefinition (sym);
20260 : 23880 : if (tok == M2LexBuf_UnknownTokenNo)
20261 : : {
20262 : 20770 : return SymbolTable_GetDeclaredModule (sym);
20263 : : }
20264 : : return tok;
20265 : : /* static analysis guarentees a RETURN statement will be used before here. */
20266 : : __builtin_unreachable ();
20267 : : }
20268 : :
20269 : :
20270 : : /*
20271 : : GetImportStatementList - returns the list of imports for this dependent.
20272 : : Each import symbol corresponds to a module.
20273 : : */
20274 : :
20275 : 515113 : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym)
20276 : : {
20277 : 515113 : SymbolTable_PtrToSymbol pSym;
20278 : :
20279 : 515113 : M2Debug_Assert (SymbolTable_IsImportStatement (sym));
20280 : 515113 : pSym = GetPsym (sym);
20281 : 515113 : return pSym->ImportStatement.ListOfImports;
20282 : : /* static analysis guarentees a RETURN statement will be used before here. */
20283 : : __builtin_unreachable ();
20284 : : }
20285 : :
20286 : :
20287 : : /*
20288 : : GetModuleDefImportStatementList - returns the list of dependents associated with
20289 : : the definition module.
20290 : : */
20291 : :
20292 : 152299 : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym)
20293 : : {
20294 : 152299 : SymbolTable_PtrToSymbol pSym;
20295 : :
20296 : 304598 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
20297 : 152299 : if (SymbolTable_IsDefImp (sym))
20298 : : {
20299 : 139657 : pSym = GetPsym (sym);
20300 : 139657 : return pSym->DefImp.DefListOfDep;
20301 : : }
20302 : : return static_cast<Lists_List> (NULL);
20303 : : /* static analysis guarentees a RETURN statement will be used before here. */
20304 : : __builtin_unreachable ();
20305 : : }
20306 : :
20307 : :
20308 : : /*
20309 : : GetModuleModImportStatementList - returns the list of dependents associated with
20310 : : the implementation or program module.
20311 : : */
20312 : :
20313 : 280440 : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym)
20314 : : {
20315 : 280440 : SymbolTable_PtrToSymbol pSym;
20316 : :
20317 : 560880 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
20318 : 280440 : pSym = GetPsym (sym);
20319 : 280440 : if (SymbolTable_IsDefImp (sym))
20320 : : {
20321 : 254750 : return pSym->DefImp.ModListOfDep;
20322 : : }
20323 : : else
20324 : : {
20325 : 25690 : return pSym->Module.ModListOfDep;
20326 : : }
20327 : : /* static analysis guarentees a RETURN statement will be used before here. */
20328 : : __builtin_unreachable ();
20329 : : }
20330 : :
20331 : :
20332 : : /*
20333 : : AppendModuleImportStatement - appends the ImportStatement symbol onto the
20334 : : module import list.
20335 : :
20336 : : For example:
20337 : :
20338 : : FROM x IMPORT y, z ;
20339 : : ^^^^
20340 : :
20341 : : also:
20342 : :
20343 : : IMPORT p, q, r;
20344 : : ^^^^^^
20345 : : will result in a new ImportStatement symbol added
20346 : : to the current module import list.
20347 : : The statement symbol is expected to be created
20348 : : by MakeImportStatement using the token positions
20349 : : outlined above.
20350 : : */
20351 : :
20352 : 276403 : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement)
20353 : : {
20354 : 276403 : SymbolTable_PtrToSymbol pSym;
20355 : :
20356 : 276403 : if (SymbolTable_IsDefImp (module))
20357 : : {
20358 : 263535 : pSym = GetPsym (module);
20359 : 263535 : if (M2Comp_CompilingDefinitionModule ())
20360 : : {
20361 : 76085 : Lists_IncludeItemIntoList (pSym->DefImp.DefListOfDep, statement);
20362 : : }
20363 : : else
20364 : : {
20365 : 187450 : Lists_IncludeItemIntoList (pSym->DefImp.ModListOfDep, statement);
20366 : : }
20367 : : }
20368 : 12868 : else if (SymbolTable_IsModule (module))
20369 : : {
20370 : : /* avoid dangling else. */
20371 : 12868 : pSym = GetPsym (module);
20372 : 12868 : Lists_IncludeItemIntoList (pSym->Module.ModListOfDep, statement);
20373 : : }
20374 : : else
20375 : : {
20376 : : /* avoid dangling else. */
20377 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
20378 : : }
20379 : 276403 : }
20380 : :
20381 : :
20382 : : /*
20383 : : AppendModuleOnImportStatement - appends the import symbol onto the
20384 : : dependent list (chain).
20385 : :
20386 : : For example each:
20387 : :
20388 : : FROM x IMPORT y, z ;
20389 : : ^
20390 : : x are added to the dependent list.
20391 : :
20392 : : also:
20393 : :
20394 : : IMPORT p, q, r;
20395 : : ^ ^ ^
20396 : : will result in p, q and r added to
20397 : : to the dependent list.
20398 : :
20399 : : The import symbol is created by MakeImport
20400 : : and the token is expected to match the module
20401 : : name position outlined above.
20402 : : */
20403 : :
20404 : 284239 : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import)
20405 : : {
20406 : 284239 : Lists_List l;
20407 : 284239 : unsigned int lastImportStatement;
20408 : :
20409 : 284239 : M2Debug_Assert (SymbolTable_IsImport (import));
20410 : 284239 : if (M2Comp_CompilingDefinitionModule ())
20411 : : {
20412 : 78049 : l = SymbolTable_GetModuleDefImportStatementList (module);
20413 : : }
20414 : : else
20415 : : {
20416 : 206190 : l = SymbolTable_GetModuleModImportStatementList (module);
20417 : : }
20418 : 284239 : M2Debug_Assert (l != NULL);
20419 : 284239 : M2Debug_Assert ((Lists_NoOfItemsInList (l)) > 0); /* There should always be one on the list. */
20420 : 284239 : lastImportStatement = static_cast<unsigned int> (Lists_GetItemFromList (l, Lists_NoOfItemsInList (l))); /* There should always be one on the list. */
20421 : 284239 : M2Debug_Assert (SymbolTable_IsImportStatement (lastImportStatement));
20422 : 284239 : l = SymbolTable_GetImportStatementList (lastImportStatement);
20423 : 284239 : Lists_IncludeItemIntoList (l, import);
20424 : 284239 : }
20425 : :
20426 : :
20427 : : /*
20428 : : PutModLink - assigns link to module sym.
20429 : : */
20430 : :
20431 : 44360 : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link)
20432 : : {
20433 : 44360 : SymbolTable_PtrToSymbol pSym;
20434 : :
20435 : 44360 : if (SymbolTable_IsModule (sym))
20436 : : {
20437 : 0 : pSym = GetPsym (sym);
20438 : 0 : pSym->Module.ModLink = link;
20439 : : }
20440 : 44360 : else if (SymbolTable_IsDefImp (sym))
20441 : : {
20442 : : /* avoid dangling else. */
20443 : 44360 : pSym = GetPsym (sym);
20444 : 44360 : pSym->DefImp.ModLink = link;
20445 : : }
20446 : : else
20447 : : {
20448 : : /* avoid dangling else. */
20449 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
20450 : : }
20451 : 44360 : }
20452 : :
20453 : :
20454 : : /*
20455 : : IsModLink - returns the ModLink value associated with the module symbol.
20456 : : */
20457 : :
20458 : 308724 : extern "C" bool SymbolTable_IsModLink (unsigned int sym)
20459 : : {
20460 : 308724 : SymbolTable_PtrToSymbol pSym;
20461 : :
20462 : 308724 : if (SymbolTable_IsModule (sym))
20463 : : {
20464 : 158772 : pSym = GetPsym (sym);
20465 : 158772 : return pSym->Module.ModLink;
20466 : : }
20467 : 149952 : else if (SymbolTable_IsDefImp (sym))
20468 : : {
20469 : : /* avoid dangling else. */
20470 : 149952 : pSym = GetPsym (sym);
20471 : 149952 : return pSym->DefImp.ModLink;
20472 : : }
20473 : : else
20474 : : {
20475 : : /* avoid dangling else. */
20476 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
20477 : : }
20478 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20479 : : __builtin_unreachable ();
20480 : : }
20481 : :
20482 : :
20483 : : /*
20484 : : PutDefLink - assigns link to the definition module sym.
20485 : : */
20486 : :
20487 : 0 : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link)
20488 : : {
20489 : 0 : SymbolTable_PtrToSymbol pSym;
20490 : :
20491 : 0 : if (SymbolTable_IsDefImp (sym))
20492 : : {
20493 : 0 : pSym = GetPsym (sym);
20494 : 0 : pSym->DefImp.DefLink = link;
20495 : : }
20496 : : else
20497 : : {
20498 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20499 : : }
20500 : 0 : }
20501 : :
20502 : :
20503 : : /*
20504 : : IsDefLink - returns the DefLink value associated with the definition module symbol.
20505 : : */
20506 : :
20507 : 130105 : extern "C" bool SymbolTable_IsDefLink (unsigned int sym)
20508 : : {
20509 : 130105 : SymbolTable_PtrToSymbol pSym;
20510 : :
20511 : 130105 : if (SymbolTable_IsDefImp (sym))
20512 : : {
20513 : 130105 : pSym = GetPsym (sym);
20514 : 130105 : return pSym->DefImp.DefLink;
20515 : : }
20516 : : else
20517 : : {
20518 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20519 : : }
20520 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20521 : : __builtin_unreachable ();
20522 : : }
20523 : :
20524 : :
20525 : : /*
20526 : : IsModuleBuiltin - returns TRUE if the module is a builtin module.
20527 : : (For example _BaseTypes).
20528 : : */
20529 : :
20530 : 57258 : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym)
20531 : : {
20532 : 57258 : SymbolTable_PtrToSymbol pSym;
20533 : :
20534 : 57258 : if (SymbolTable_IsDefImp (sym))
20535 : : {
20536 : 54868 : pSym = GetPsym (sym);
20537 : 54868 : return pSym->DefImp.Builtin;
20538 : : }
20539 : 2390 : else if (SymbolTable_IsModule (sym))
20540 : : {
20541 : : /* avoid dangling else. */
20542 : 2390 : pSym = GetPsym (sym);
20543 : 2390 : return pSym->Module.Builtin;
20544 : : }
20545 : : return false;
20546 : : /* static analysis guarentees a RETURN statement will be used before here. */
20547 : : __builtin_unreachable ();
20548 : : }
20549 : :
20550 : :
20551 : : /*
20552 : : PutModuleBuiltin - sets the Builtin flag to value.
20553 : : Currently the procedure expects sym to be a DefImp
20554 : : module only.
20555 : : */
20556 : :
20557 : 16817 : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value)
20558 : : {
20559 : 16817 : SymbolTable_PtrToSymbol pSym;
20560 : :
20561 : 16817 : if (SymbolTable_IsDefImp (sym))
20562 : : {
20563 : 0 : pSym = GetPsym (sym);
20564 : 0 : pSym->DefImp.Builtin = value;
20565 : : }
20566 : 16817 : else if (SymbolTable_IsModule (sym))
20567 : : {
20568 : : /* avoid dangling else. */
20569 : 16817 : pSym = GetPsym (sym);
20570 : 16817 : pSym->Module.Builtin = value;
20571 : : }
20572 : : else
20573 : : {
20574 : : /* avoid dangling else. */
20575 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
20576 : : }
20577 : 16817 : }
20578 : :
20579 : :
20580 : : /*
20581 : : PutVarArrayRef - assigns ArrayRef field with value.
20582 : : */
20583 : :
20584 : 52226 : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value)
20585 : : {
20586 : 52226 : SymbolTable_PtrToSymbol pSym;
20587 : :
20588 : 52226 : pSym = GetPsym (sym);
20589 : 52226 : switch (pSym->SymbolType)
20590 : : {
20591 : 52226 : case SymbolTable_VarSym:
20592 : 52226 : pSym->Var.ArrayRef = value;
20593 : 52226 : break;
20594 : :
20595 : :
20596 : 0 : default:
20597 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
20598 : 52226 : break;
20599 : : }
20600 : 52226 : }
20601 : :
20602 : :
20603 : : /*
20604 : : IsVarArrayRef - returns ArrayRef field value.
20605 : : */
20606 : :
20607 : 2926 : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym)
20608 : : {
20609 : 2926 : SymbolTable_PtrToSymbol pSym;
20610 : :
20611 : 2926 : pSym = GetPsym (sym);
20612 : 2926 : switch (pSym->SymbolType)
20613 : : {
20614 : 2926 : case SymbolTable_VarSym:
20615 : 2926 : return pSym->Var.ArrayRef;
20616 : 0 : break;
20617 : :
20618 : :
20619 : 0 : default:
20620 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
20621 : : break;
20622 : : }
20623 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20624 : : __builtin_unreachable ();
20625 : : }
20626 : :
20627 : :
20628 : : /*
20629 : : VarCheckReadInit - returns TRUE if sym has been initialized.
20630 : : */
20631 : :
20632 : 2440 : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode)
20633 : : {
20634 : 2440 : SymbolTable_PtrToSymbol pSym;
20635 : :
20636 : 2440 : if (SymbolTable_IsVar (sym))
20637 : : {
20638 : 2440 : pSym = GetPsym (sym);
20639 : 2440 : switch (pSym->SymbolType)
20640 : : {
20641 : 2440 : case SymbolTable_VarSym:
20642 : 2440 : return M2SymInit_GetInitialized (pSym->Var.InitState.array[mode-SymbolTable_RightValue]);
20643 : : break;
20644 : :
20645 : :
20646 : : default:
20647 : : break;
20648 : : }
20649 : : }
20650 : : return false;
20651 : : /* static analysis guarentees a RETURN statement will be used before here. */
20652 : : __builtin_unreachable ();
20653 : : }
20654 : :
20655 : :
20656 : : /*
20657 : : VarInitState - initializes the init state for variable sym.
20658 : : */
20659 : :
20660 : 4076 : extern "C" void SymbolTable_VarInitState (unsigned int sym)
20661 : : {
20662 : 4076 : SymbolTable_PtrToSymbol pSym;
20663 : :
20664 : 4076 : if (SymbolTable_IsVar (sym))
20665 : : {
20666 : 4076 : pSym = GetPsym (sym);
20667 : 4076 : switch (pSym->SymbolType)
20668 : : {
20669 : 4076 : case SymbolTable_VarSym:
20670 : 4076 : M2SymInit_ConfigSymInit (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue], sym);
20671 : 4076 : M2SymInit_ConfigSymInit (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue], sym);
20672 : 4076 : break;
20673 : :
20674 : :
20675 : : default:
20676 : : break;
20677 : : }
20678 : : }
20679 : 4076 : }
20680 : :
20681 : :
20682 : : /*
20683 : : PutVarInitialized - set sym as initialized.
20684 : : */
20685 : :
20686 : 4245 : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode)
20687 : : {
20688 : 4245 : SymbolTable_PtrToSymbol pSym;
20689 : :
20690 : 4245 : if (SymbolTable_IsVar (sym))
20691 : : {
20692 : 4245 : pSym = GetPsym (sym);
20693 : 4245 : switch (pSym->SymbolType)
20694 : : {
20695 : 4245 : case SymbolTable_VarSym:
20696 : 4245 : M2SymInit_SetInitialized (pSym->Var.InitState.array[mode-SymbolTable_RightValue]);
20697 : 4245 : break;
20698 : :
20699 : :
20700 : : default:
20701 : : break;
20702 : : }
20703 : : }
20704 : 4245 : }
20705 : :
20706 : :
20707 : : /*
20708 : : PutVarFieldInitialized - records that field has been initialized with
20709 : : variable sym. TRUE is returned if the field
20710 : : is detected and changed to initialized.
20711 : : */
20712 : :
20713 : 612 : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
20714 : : {
20715 : 612 : SymbolTable_PtrToSymbol pSym;
20716 : :
20717 : 612 : if (SymbolTable_IsVar (sym))
20718 : : {
20719 : 612 : pSym = GetPsym (sym);
20720 : 612 : switch (pSym->SymbolType)
20721 : : {
20722 : 612 : case SymbolTable_VarSym:
20723 : 612 : return M2SymInit_SetFieldInitialized (pSym->Var.InitState.array[mode-SymbolTable_RightValue], fieldlist);
20724 : : break;
20725 : :
20726 : :
20727 : : default:
20728 : : break;
20729 : : }
20730 : : }
20731 : : return false;
20732 : : /* static analysis guarentees a RETURN statement will be used before here. */
20733 : : __builtin_unreachable ();
20734 : : }
20735 : :
20736 : :
20737 : : /*
20738 : : GetVarFieldInitialized - return TRUE if fieldlist has been initialized
20739 : : within variable sym.
20740 : : */
20741 : :
20742 : 204 : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
20743 : : {
20744 : 204 : SymbolTable_PtrToSymbol pSym;
20745 : :
20746 : 204 : if (SymbolTable_IsVar (sym))
20747 : : {
20748 : 204 : pSym = GetPsym (sym);
20749 : 204 : switch (pSym->SymbolType)
20750 : : {
20751 : 204 : case SymbolTable_VarSym:
20752 : 204 : return M2SymInit_GetFieldInitialized (pSym->Var.InitState.array[mode-SymbolTable_RightValue], fieldlist);
20753 : : break;
20754 : :
20755 : :
20756 : : default:
20757 : : break;
20758 : : }
20759 : : }
20760 : : return false;
20761 : : /* static analysis guarentees a RETURN statement will be used before here. */
20762 : : __builtin_unreachable ();
20763 : : }
20764 : :
20765 : :
20766 : : /*
20767 : : PrintInitialized - display variable sym initialization state.
20768 : : */
20769 : :
20770 : 0 : extern "C" void SymbolTable_PrintInitialized (unsigned int sym)
20771 : : {
20772 : 0 : SymbolTable_PtrToSymbol pSym;
20773 : :
20774 : 0 : if (SymbolTable_IsVar (sym))
20775 : : {
20776 : 0 : pSym = GetPsym (sym);
20777 : 0 : switch (pSym->SymbolType)
20778 : : {
20779 : 0 : case SymbolTable_VarSym:
20780 : 0 : M2Printf_printf0 ((const char *) "LeftMode init: ", 15);
20781 : 0 : M2SymInit_PrintSymInit (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
20782 : 0 : M2Printf_printf0 ((const char *) "RightMode init: ", 16);
20783 : 0 : M2SymInit_PrintSymInit (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]);
20784 : 0 : break;
20785 : :
20786 : :
20787 : : default:
20788 : : break;
20789 : : }
20790 : : }
20791 : 0 : }
20792 : :
20793 : :
20794 : : /*
20795 : : GetParameterHeapVar - return the heap variable associated with the
20796 : : parameter or NulSym.
20797 : : */
20798 : :
20799 : 114 : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym)
20800 : : {
20801 : 114 : SymbolTable_PtrToSymbol pSym;
20802 : :
20803 : 114 : pSym = GetPsym (ParSym);
20804 : 114 : switch (pSym->SymbolType)
20805 : : {
20806 : : case SymbolTable_ParamSym:
20807 : : return SymbolTable_NulSym; /* Only VarParam has the pointer. */
20808 : 48 : break;
20809 : :
20810 : 48 : case SymbolTable_VarParamSym:
20811 : 48 : return pSym->VarParam.HeapVar; /* Only VarParam has the pointer. */
20812 : 0 : break;
20813 : :
20814 : :
20815 : 0 : default:
20816 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
20817 : : break;
20818 : : }
20819 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20820 : : __builtin_unreachable ();
20821 : : }
20822 : :
20823 : :
20824 : : /*
20825 : : PutProcedureParameterHeapVars - creates heap variables for parameter sym.
20826 : : */
20827 : :
20828 : 895959 : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym)
20829 : : {
20830 : 895959 : M2Debug_Assert (SymbolTable_IsProcedure (sym));
20831 : 895959 : SymbolTable_ForeachParamSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PutParameterHeapVar});
20832 : 895959 : }
20833 : :
20834 : :
20835 : : /*
20836 : : IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
20837 : : for the target architecture.
20838 : : */
20839 : :
20840 : 620039 : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure)
20841 : : {
20842 : 620039 : return (SymbolTable_IsProcedureBuiltin (procedure)) && (CanUseBuiltin (procedure));
20843 : : /* static analysis guarentees a RETURN statement will be used before here. */
20844 : : __builtin_unreachable ();
20845 : : }
20846 : :
20847 : :
20848 : : /*
20849 : : PutConstLitInternal - marks the sym as being an internal constant.
20850 : : Currently this is used when generating a default
20851 : : BY constant expression during a FOR loop.
20852 : : A constant marked as internal will always pass
20853 : : an expression type check.
20854 : : */
20855 : :
20856 : 18513 : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value)
20857 : : {
20858 : 18513 : SymbolTable_PtrToSymbol pSym;
20859 : :
20860 : 18513 : pSym = GetPsym (sym);
20861 : 18513 : switch (pSym->SymbolType)
20862 : : {
20863 : 18513 : case SymbolTable_ConstLitSym:
20864 : 18513 : pSym->ConstLit.IsInternal = value;
20865 : 18513 : break;
20866 : :
20867 : :
20868 : 0 : default:
20869 : 0 : M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
20870 : 18513 : break;
20871 : : }
20872 : 18513 : }
20873 : :
20874 : :
20875 : : /*
20876 : : IsConstLitInternal - returns the value of the IsInternal field within
20877 : : a constant expression.
20878 : : */
20879 : :
20880 : 521296 : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym)
20881 : : {
20882 : 521296 : SymbolTable_PtrToSymbol pSym;
20883 : :
20884 : 521296 : pSym = GetPsym (sym);
20885 : 521296 : switch (pSym->SymbolType)
20886 : : {
20887 : 521296 : case SymbolTable_ConstLitSym:
20888 : 521296 : return pSym->ConstLit.IsInternal;
20889 : 0 : break;
20890 : :
20891 : :
20892 : 0 : default:
20893 : 0 : M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
20894 : : break;
20895 : : }
20896 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20897 : : __builtin_unreachable ();
20898 : : }
20899 : :
20900 : 16817 : extern "C" void _M2_SymbolTable_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
20901 : : {
20902 : 16817 : Init ();
20903 : 16817 : }
20904 : :
20905 : 0 : extern "C" void _M2_SymbolTable_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
20906 : : {
20907 : 0 : }
|