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-2025 Free Software Foundation, Inc.
5 : : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 : :
7 : : This file is part of GNU Modula-2.
8 : :
9 : : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : : it under the terms of the GNU General Public License as published by
11 : : the Free Software Foundation; either version 3, or (at your option)
12 : : any later version.
13 : :
14 : : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include "gcc-consolidation.h"
26 : :
27 : : #include <stdbool.h>
28 : : # if !defined (PROC_D)
29 : : # define PROC_D
30 : : typedef void (*PROC_t) (void);
31 : : typedef struct { PROC_t proc; } PROC;
32 : : # endif
33 : :
34 : : # if !defined (TRUE)
35 : : # define TRUE (1==1)
36 : : # endif
37 : :
38 : : # if !defined (FALSE)
39 : : # define FALSE (1==0)
40 : : # endif
41 : :
42 : : # include "GStorage.h"
43 : : # include "Gmcrts.h"
44 : : #if defined(__cplusplus)
45 : : # undef NULL
46 : : # define NULL 0
47 : : #endif
48 : : #define _SymbolTable_C
49 : :
50 : : #include "GSymbolTable.h"
51 : : # include "GSYSTEM.h"
52 : : # include "GStorage.h"
53 : : # include "GM2Debug.h"
54 : : # include "Glibc.h"
55 : : # include "GASCII.h"
56 : : # include "GIndexing.h"
57 : : # include "GSets.h"
58 : : # include "Ggcctypes.h"
59 : : # include "GM2Options.h"
60 : : # include "GM2LexBuf.h"
61 : : # include "GM2ALU.h"
62 : : # include "GM2Error.h"
63 : : # include "GM2MetaError.h"
64 : : # include "GFormatStrings.h"
65 : : # include "GM2Printf.h"
66 : : # include "GDynamicStrings.h"
67 : : # include "GLists.h"
68 : : # include "GNameKey.h"
69 : : # include "GSymbolKey.h"
70 : : # include "GM2Base.h"
71 : : # include "GM2System.h"
72 : : # include "Gm2expr.h"
73 : : # include "Gm2linemap.h"
74 : : # include "GStrLib.h"
75 : : # include "Gm2builtins.h"
76 : : # include "GM2Comp.h"
77 : : # include "GM2Scaffold.h"
78 : : # include "GM2Diagnostic.h"
79 : : # include "GM2SymInit.h"
80 : : # include "GM2RTS.h"
81 : :
82 : : # define SymbolTable_NulSym 0
83 : : typedef struct SymbolTable_FamilyOperation_p SymbolTable_FamilyOperation;
84 : :
85 : : # define DebugUnknowns false
86 : : # define DebugUnknownToken false
87 : : # define BreakNew 97
88 : : # define UnboundedAddressName "_m2_contents"
89 : : # define UnboundedHighName "_m2_high_%d"
90 : : typedef struct SymbolTable_ProcAnyBoolean_p SymbolTable_ProcAnyBoolean;
91 : :
92 : : typedef struct SymbolTable_ProcAnyCardinal_p SymbolTable_ProcAnyCardinal;
93 : :
94 : : typedef struct SymbolTable_LRLists_a SymbolTable_LRLists;
95 : :
96 : : typedef struct SymbolTable_LRInitDesc_a SymbolTable_LRInitDesc;
97 : :
98 : : typedef struct SymbolTable_Where_r SymbolTable_Where;
99 : :
100 : : typedef struct SymbolTable_VarDecl_r SymbolTable_VarDecl;
101 : :
102 : : typedef struct SymbolTable_PackedInfo_r SymbolTable_PackedInfo;
103 : :
104 : : typedef struct SymbolTable_ModuleCtor_r SymbolTable_ModuleCtor;
105 : :
106 : : typedef struct SymbolTable_SymImportStatement_r SymbolTable_SymImportStatement;
107 : :
108 : : typedef struct SymbolTable_SymImport_r SymbolTable_SymImport;
109 : :
110 : : typedef struct SymbolTable_SymEquiv_r SymbolTable_SymEquiv;
111 : :
112 : : typedef struct SymbolTable_SymOAFamily_r SymbolTable_SymOAFamily;
113 : :
114 : : typedef struct SymbolTable_SymTuple_r SymbolTable_SymTuple;
115 : :
116 : : typedef struct SymbolTable_SymError_r SymbolTable_SymError;
117 : :
118 : : typedef struct SymbolTable_SymObject_r SymbolTable_SymObject;
119 : :
120 : : typedef struct SymbolTable_SymUndefined_r SymbolTable_SymUndefined;
121 : :
122 : : typedef struct SymbolTable_SymGnuAsm_r SymbolTable_SymGnuAsm;
123 : :
124 : : typedef struct SymbolTable_SymInterface_r SymbolTable_SymInterface;
125 : :
126 : : typedef struct SymbolTable_SymVarient_r SymbolTable_SymVarient;
127 : :
128 : : typedef struct SymbolTable_SymRecord_r SymbolTable_SymRecord;
129 : :
130 : : typedef struct SymbolTable_SymSubrange_r SymbolTable_SymSubrange;
131 : :
132 : : typedef struct SymbolTable_SymEnumeration_r SymbolTable_SymEnumeration;
133 : :
134 : : typedef struct SymbolTable_SymArray_r SymbolTable_SymArray;
135 : :
136 : : typedef struct SymbolTable_SymSubscript_r SymbolTable_SymSubscript;
137 : :
138 : : typedef struct SymbolTable_SymUnbounded_r SymbolTable_SymUnbounded;
139 : :
140 : : typedef struct SymbolTable_SymPartialUnbounded_r SymbolTable_SymPartialUnbounded;
141 : :
142 : : typedef struct SymbolTable_ProcedureDeclaration_r SymbolTable_ProcedureDeclaration;
143 : :
144 : : typedef struct SymbolTable_SymProcedure_r SymbolTable_SymProcedure;
145 : :
146 : : typedef struct SymbolTable_SymProcType_r SymbolTable_SymProcType;
147 : :
148 : : typedef struct SymbolTable_SymParam_r SymbolTable_SymParam;
149 : :
150 : : typedef struct SymbolTable_SymVarParam_r SymbolTable_SymVarParam;
151 : :
152 : : typedef struct SymbolTable_SymConstString_r SymbolTable_SymConstString;
153 : :
154 : : typedef struct SymbolTable_SymConstLit_r SymbolTable_SymConstLit;
155 : :
156 : : typedef struct SymbolTable_SymConstVar_r SymbolTable_SymConstVar;
157 : :
158 : : typedef struct SymbolTable_SymVar_r SymbolTable_SymVar;
159 : :
160 : : typedef struct SymbolTable_SymType_r SymbolTable_SymType;
161 : :
162 : : typedef struct SymbolTable_SymPointer_r SymbolTable_SymPointer;
163 : :
164 : : typedef struct SymbolTable_SymRecordField_r SymbolTable_SymRecordField;
165 : :
166 : : typedef struct SymbolTable_SymVarientField_r SymbolTable_SymVarientField;
167 : :
168 : : typedef struct SymbolTable_SymEnumerationField_r SymbolTable_SymEnumerationField;
169 : :
170 : : typedef struct SymbolTable_SymSet_r SymbolTable_SymSet;
171 : :
172 : : typedef struct SymbolTable_SymDefImp_r SymbolTable_SymDefImp;
173 : :
174 : : typedef struct SymbolTable_SymModule_r SymbolTable_SymModule;
175 : :
176 : : typedef struct SymbolTable_SymDummy_r SymbolTable_SymDummy;
177 : :
178 : : typedef struct SymbolTable_Symbol_r SymbolTable_Symbol;
179 : :
180 : : typedef struct SymbolTable_CallFrame_r SymbolTable_CallFrame;
181 : :
182 : : typedef struct SymbolTable_CheckProcedure_p SymbolTable_CheckProcedure;
183 : :
184 : : typedef SymbolTable_Symbol *SymbolTable_PtrToSymbol;
185 : :
186 : : typedef SymbolTable_CallFrame *SymbolTable_PtrToCallFrame;
187 : :
188 : : typedef struct SymbolTable__T4_r SymbolTable__T4;
189 : :
190 : : typedef SymbolTable__T4 *SymbolTable_ConstLitPoolEntry;
191 : :
192 : : typedef struct SymbolTable__T5_r SymbolTable__T5;
193 : :
194 : : typedef SymbolTable__T5 *SymbolTable_PtrToAsmConstraint;
195 : :
196 : : typedef struct SymbolTable__T6_a SymbolTable__T6;
197 : :
198 : : typedef enum {SymbolTable_m2str, SymbolTable_cstr, SymbolTable_m2nulstr, SymbolTable_cnulstr} SymbolTable_ConstStringVariant;
199 : :
200 : : typedef enum {SymbolTable_RecordSym, SymbolTable_VarientSym, SymbolTable_DummySym, SymbolTable_VarSym, SymbolTable_EnumerationSym, SymbolTable_SubrangeSym, SymbolTable_ArraySym, SymbolTable_ConstStringSym, SymbolTable_ConstVarSym, SymbolTable_ConstLitSym, SymbolTable_VarParamSym, SymbolTable_ParamSym, SymbolTable_PointerSym, SymbolTable_UndefinedSym, SymbolTable_TypeSym, SymbolTable_RecordFieldSym, SymbolTable_VarientFieldSym, SymbolTable_EnumerationFieldSym, SymbolTable_DefImpSym, SymbolTable_ModuleSym, SymbolTable_SetSym, SymbolTable_ProcedureSym, SymbolTable_ProcTypeSym, SymbolTable_SubscriptSym, SymbolTable_UnboundedSym, SymbolTable_GnuAsmSym, SymbolTable_InterfaceSym, SymbolTable_ObjectSym, SymbolTable_PartialUnboundedSym, SymbolTable_TupleSym, SymbolTable_OAFamilySym, SymbolTable_ImportSym, SymbolTable_ImportStatementSym, SymbolTable_EquivSym, SymbolTable_ErrorSym} SymbolTable_TypeOfSymbol;
201 : :
202 : : typedef bool (*SymbolTable_ProcAnyBoolean_t) (unsigned int, SymbolTable_ProcedureKind);
203 : : struct SymbolTable_ProcAnyBoolean_p { SymbolTable_ProcAnyBoolean_t proc; };
204 : :
205 : : typedef unsigned int (*SymbolTable_ProcAnyCardinal_t) (unsigned int, SymbolTable_ProcedureKind);
206 : : struct SymbolTable_ProcAnyCardinal_p { SymbolTable_ProcAnyCardinal_t proc; };
207 : :
208 : : struct SymbolTable_LRLists_a { Lists_List array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
209 : : struct SymbolTable_LRInitDesc_a { M2SymInit_InitDesc array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
210 : : struct SymbolTable_Where_r {
211 : : unsigned int DefDeclared;
212 : : unsigned int FirstUsed;
213 : : unsigned int ModDeclared;
214 : : };
215 : :
216 : : struct SymbolTable_VarDecl_r {
217 : : unsigned int FullTok;
218 : : unsigned int VarTok;
219 : : unsigned int TypeTok;
220 : : };
221 : :
222 : : struct SymbolTable_PackedInfo_r {
223 : : bool IsPacked;
224 : : unsigned int PackedEquiv;
225 : : };
226 : :
227 : : struct SymbolTable_ModuleCtor_r {
228 : : unsigned int ctor;
229 : : unsigned int init;
230 : : unsigned int fini;
231 : : unsigned int dep;
232 : : };
233 : :
234 : : struct SymbolTable_SymOAFamily_r {
235 : : unsigned int MaxDimensions;
236 : : unsigned int SimpleType;
237 : : Indexing_Index Dimensions;
238 : : };
239 : :
240 : : struct SymbolTable_SymPartialUnbounded_r {
241 : : unsigned int Type;
242 : : unsigned int NDim;
243 : : };
244 : :
245 : : struct SymbolTable_ProcedureDeclaration_r {
246 : : Lists_List ListOfParam;
247 : : bool Defined;
248 : : bool ParamDefined;
249 : : bool HasVarArgs;
250 : : bool HasOptArg;
251 : : bool IsNoReturn;
252 : : bool ReturnOptional;
253 : : unsigned int ReturnTypeTok;
254 : : unsigned int ProcedureTok;
255 : : };
256 : :
257 : : struct SymbolTable_SymParam_r {
258 : : NameKey_Name name;
259 : : unsigned int Type;
260 : : bool IsUnbounded;
261 : : unsigned int Scope;
262 : : unsigned int ShadowVar;
263 : : unsigned int FullTok;
264 : : unsigned int At;
265 : : };
266 : :
267 : : struct SymbolTable_SymVarParam_r {
268 : : NameKey_Name name;
269 : : unsigned int Type;
270 : : bool IsUnbounded;
271 : : unsigned int HeapVar;
272 : : unsigned int Scope;
273 : : unsigned int ShadowVar;
274 : : unsigned int FullTok;
275 : : unsigned int At;
276 : : };
277 : :
278 : : struct SymbolTable_SymDummy_r {
279 : : unsigned int NextFree;
280 : : };
281 : :
282 : : struct SymbolTable_CallFrame_r {
283 : : unsigned int Main;
284 : : unsigned int Search;
285 : : unsigned int Start;
286 : : };
287 : :
288 : : typedef void (*SymbolTable_CheckProcedure_t) (unsigned int);
289 : : struct SymbolTable_CheckProcedure_p { SymbolTable_CheckProcedure_t proc; };
290 : :
291 : : struct SymbolTable__T4_r {
292 : : unsigned int sym;
293 : : unsigned int tok;
294 : : NameKey_Name constName;
295 : : unsigned int constType;
296 : : SymbolTable_ConstLitPoolEntry next;
297 : : };
298 : :
299 : : struct SymbolTable__T5_r {
300 : : unsigned int tokpos;
301 : : NameKey_Name name;
302 : : unsigned int str;
303 : : unsigned int obj;
304 : : };
305 : :
306 : : struct SymbolTable_SymImportStatement_r {
307 : : unsigned int listNo;
308 : : Lists_List ListOfImports;
309 : : SymbolTable_Where at;
310 : : };
311 : :
312 : : struct SymbolTable_SymImport_r {
313 : : unsigned int module;
314 : : unsigned int listNo;
315 : : bool qualified;
316 : : SymbolTable_Where at;
317 : : };
318 : :
319 : : struct SymbolTable_SymEquiv_r {
320 : : SymbolTable_PackedInfo packedInfo;
321 : : unsigned int nonPacked;
322 : : };
323 : :
324 : : struct SymbolTable_SymTuple_r {
325 : : SymbolTable_Where At;
326 : : unsigned int nTuple;
327 : : Indexing_Index list;
328 : : };
329 : :
330 : : struct SymbolTable_SymError_r {
331 : : NameKey_Name name;
332 : : unsigned int Scope;
333 : : SymbolTable_Where At;
334 : : };
335 : :
336 : : struct SymbolTable_SymObject_r {
337 : : NameKey_Name name;
338 : : SymbolTable_Where At;
339 : : };
340 : :
341 : : struct SymbolTable_SymUndefined_r {
342 : : NameKey_Name name;
343 : : unsigned int declScope;
344 : : bool onImport;
345 : : unsigned int oafamily;
346 : : M2Error_ErrorScope errorScope;
347 : : SymbolTable_Where At;
348 : : };
349 : :
350 : : struct SymbolTable_SymGnuAsm_r {
351 : : unsigned int String;
352 : : SymbolTable_Where At;
353 : : unsigned int Inputs;
354 : : unsigned int Outputs;
355 : : unsigned int Trashed;
356 : : bool Volatile;
357 : : bool Simple;
358 : : };
359 : :
360 : : struct SymbolTable_SymInterface_r {
361 : : Indexing_Index Parameters;
362 : : SymbolTable_Where At;
363 : : };
364 : :
365 : : struct SymbolTable_SymVarient_r {
366 : : M2ALU_PtrToValue Size;
367 : : Lists_List ListOfSons;
368 : : bool DeclPacked;
369 : : bool DeclResolved;
370 : : unsigned int Parent;
371 : : unsigned int Varient;
372 : : unsigned int tag;
373 : : unsigned int Scope;
374 : : SymbolTable_Where At;
375 : : };
376 : :
377 : : struct SymbolTable_SymRecord_r {
378 : : NameKey_Name name;
379 : : SymbolKey_SymbolTree LocalSymbols;
380 : : M2ALU_PtrToValue Size;
381 : : Lists_List ListOfSons;
382 : : unsigned int Align;
383 : : unsigned int DefaultAlign;
384 : : bool DeclPacked;
385 : : bool DeclResolved;
386 : : unsigned int oafamily;
387 : : unsigned int Parent;
388 : : unsigned int Scope;
389 : : SymbolTable_Where At;
390 : : };
391 : :
392 : : struct SymbolTable_SymSubrange_r {
393 : : NameKey_Name name;
394 : : unsigned int Low;
395 : : unsigned int High;
396 : : M2ALU_PtrToValue Size;
397 : : unsigned int Type;
398 : : unsigned int Align;
399 : : SymbolKey_SymbolTree ConstLitTree;
400 : : SymbolTable_PackedInfo packedInfo;
401 : : unsigned int oafamily;
402 : : unsigned int Scope;
403 : : SymbolTable_Where At;
404 : : };
405 : :
406 : : struct SymbolTable_SymEnumeration_r {
407 : : NameKey_Name name;
408 : : unsigned int NoOfElements;
409 : : SymbolKey_SymbolTree LocalSymbols;
410 : : Lists_List ListOfFields;
411 : : M2ALU_PtrToValue Size;
412 : : SymbolTable_PackedInfo packedInfo;
413 : : unsigned int oafamily;
414 : : unsigned int Scope;
415 : : SymbolTable_Where At;
416 : : };
417 : :
418 : : struct SymbolTable_SymArray_r {
419 : : NameKey_Name name;
420 : : unsigned int Subscript;
421 : : M2ALU_PtrToValue Size;
422 : : M2ALU_PtrToValue Offset;
423 : : unsigned int Type;
424 : : unsigned int Align;
425 : : bool Large;
426 : : unsigned int oafamily;
427 : : unsigned int Scope;
428 : : SymbolTable_Where At;
429 : : };
430 : :
431 : : struct SymbolTable_SymSubscript_r {
432 : : unsigned int Type;
433 : : M2ALU_PtrToValue Size;
434 : : M2ALU_PtrToValue Offset;
435 : : SymbolTable_Where At;
436 : : };
437 : :
438 : : struct SymbolTable_SymUnbounded_r {
439 : : unsigned int Type;
440 : : M2ALU_PtrToValue Size;
441 : : unsigned int RecordType;
442 : : unsigned int Dimensions;
443 : : unsigned int Scope;
444 : : SymbolTable_Where At;
445 : : };
446 : :
447 : : struct SymbolTable_SymProcType_r {
448 : : NameKey_Name name;
449 : : Lists_List ListOfParam;
450 : : bool HasVarArgs;
451 : : bool HasOptArg;
452 : : unsigned int OptArgInit;
453 : : unsigned int ReturnType;
454 : : bool ReturnOptional;
455 : : unsigned int ReturnTypeTok;
456 : : unsigned int Scope;
457 : : M2ALU_PtrToValue Size;
458 : : M2ALU_PtrToValue TotalParamSize;
459 : : unsigned int oafamily;
460 : : SymbolTable_Where At;
461 : : };
462 : :
463 : : struct SymbolTable_SymConstString_r {
464 : : NameKey_Name name;
465 : : NameKey_Name Contents;
466 : : unsigned int Length;
467 : : SymbolTable_ConstStringVariant StringVariant;
468 : : bool Known;
469 : : unsigned int Scope;
470 : : SymbolTable_Where At;
471 : : };
472 : :
473 : : struct SymbolTable_SymConstLit_r {
474 : : NameKey_Name name;
475 : : M2ALU_PtrToValue Value;
476 : : unsigned int Type;
477 : : bool IsSet;
478 : : bool IsConstructor;
479 : : bool IsInternal;
480 : : unsigned int FromType;
481 : : bool RangeError;
482 : : bool UnresFromType;
483 : : unsigned int Scope;
484 : : SymbolTable_Where At;
485 : : };
486 : :
487 : : struct SymbolTable_SymConstVar_r {
488 : : NameKey_Name name;
489 : : M2ALU_PtrToValue Value;
490 : : unsigned int Type;
491 : : bool IsConditional;
492 : : bool IsSet;
493 : : bool IsConstructor;
494 : : unsigned int FromType;
495 : : bool UnresFromType;
496 : : bool IsTemp;
497 : : unsigned int Scope;
498 : : SymbolTable_Where At;
499 : : };
500 : :
501 : : struct SymbolTable_SymVar_r {
502 : : NameKey_Name name;
503 : : unsigned int Type;
504 : : unsigned int BackType;
505 : : M2ALU_PtrToValue Size;
506 : : M2ALU_PtrToValue Offset;
507 : : SymbolTable_ModeOfAddr AddrMode;
508 : : unsigned int Scope;
509 : : bool AtAddress;
510 : : unsigned int Address;
511 : : bool IsComponentRef;
512 : : Indexing_Index list;
513 : : bool IsConditional;
514 : : bool IsTemp;
515 : : bool IsParam;
516 : : bool IsPointerCheck;
517 : : bool IsWritten;
518 : : bool IsSSA;
519 : : bool IsConst;
520 : : bool ArrayRef;
521 : : bool Heap;
522 : : SymbolTable_LRInitDesc InitState;
523 : : SymbolTable_VarDecl Declared;
524 : : SymbolTable_Where At;
525 : : SymbolTable_LRLists ReadUsageList;
526 : : SymbolTable_LRLists WriteUsageList;
527 : : };
528 : :
529 : : struct SymbolTable_SymType_r {
530 : : NameKey_Name name;
531 : : unsigned int Type;
532 : : bool IsHidden;
533 : : SymbolKey_SymbolTree ConstLitTree;
534 : : M2ALU_PtrToValue Size;
535 : : SymbolTable_PackedInfo packedInfo;
536 : : unsigned int oafamily;
537 : : unsigned int Align;
538 : : unsigned int Scope;
539 : : SymbolTable_Where At;
540 : : };
541 : :
542 : : struct SymbolTable_SymPointer_r {
543 : : NameKey_Name name;
544 : : unsigned int Type;
545 : : M2ALU_PtrToValue Size;
546 : : unsigned int Align;
547 : : SymbolKey_SymbolTree ConstLitTree;
548 : : unsigned int oafamily;
549 : : unsigned int Scope;
550 : : SymbolTable_Where At;
551 : : };
552 : :
553 : : struct SymbolTable_SymRecordField_r {
554 : : NameKey_Name name;
555 : : unsigned int Type;
556 : : bool Tag;
557 : : M2ALU_PtrToValue Size;
558 : : M2ALU_PtrToValue Offset;
559 : : unsigned int Parent;
560 : : unsigned int Varient;
561 : : unsigned int Align;
562 : : bool Used;
563 : : bool DeclPacked;
564 : : bool DeclResolved;
565 : : unsigned int Scope;
566 : : SymbolTable_Where At;
567 : : };
568 : :
569 : : struct SymbolTable_SymVarientField_r {
570 : : NameKey_Name name;
571 : : M2ALU_PtrToValue Size;
572 : : M2ALU_PtrToValue Offset;
573 : : unsigned int Parent;
574 : : unsigned int Varient;
575 : : Lists_List ListOfSons;
576 : : bool DeclPacked;
577 : : bool DeclResolved;
578 : : unsigned int Scope;
579 : : SymbolTable_Where At;
580 : : };
581 : :
582 : : struct SymbolTable_SymEnumerationField_r {
583 : : NameKey_Name name;
584 : : M2ALU_PtrToValue Value;
585 : : unsigned int Type;
586 : : unsigned int Scope;
587 : : SymbolTable_Where At;
588 : : };
589 : :
590 : : struct SymbolTable_SymSet_r {
591 : : NameKey_Name name;
592 : : unsigned int Type;
593 : : SymbolTable_PackedInfo packedInfo;
594 : : bool ispacked;
595 : : bool SetInWord;
596 : : unsigned int SetArray;
597 : : unsigned int Align;
598 : : M2ALU_PtrToValue Size;
599 : : unsigned int oafamily;
600 : : unsigned int Scope;
601 : : SymbolTable_Where At;
602 : : };
603 : :
604 : : struct SymbolTable_SymDefImp_r {
605 : : NameKey_Name name;
606 : : NameKey_Name libname;
607 : : SymbolTable_ModuleCtor ctors;
608 : : Lists_List DefListOfDep;
609 : : Lists_List ModListOfDep;
610 : : SymbolKey_SymbolTree ExportQualifiedTree;
611 : : SymbolKey_SymbolTree ExportUnQualifiedTree;
612 : : SymbolKey_SymbolTree ExportRequest;
613 : : Lists_List IncludeList;
614 : : Lists_List DefIncludeList;
615 : : SymbolKey_SymbolTree ImportTree;
616 : : SymbolKey_SymbolTree ExportUndeclared;
617 : : SymbolKey_SymbolTree NeedToBeImplemented;
618 : : SymbolKey_SymbolTree LocalSymbols;
619 : : Lists_List EnumerationScopeList;
620 : : SymbolKey_SymbolTree NamedObjects;
621 : : SymbolKey_SymbolTree NamedImports;
622 : : SymbolKey_SymbolTree WhereImported;
623 : : unsigned int Priority;
624 : : SymbolKey_SymbolTree Unresolved;
625 : : unsigned int StartQuad;
626 : : unsigned int EndQuad;
627 : : unsigned int StartFinishQuad;
628 : : unsigned int EndFinishQuad;
629 : : tree FinallyFunction;
630 : : bool ExceptionFinally;
631 : : bool ExceptionBlock;
632 : : bool ContainsHiddenType;
633 : : bool ContainsBuiltin;
634 : : bool ForC;
635 : : bool NeedExportList;
636 : : bool ModLink;
637 : : bool DefLink;
638 : : bool Builtin;
639 : : Lists_List ListOfVars;
640 : : Lists_List ListOfProcs;
641 : : Lists_List ListOfModules;
642 : : M2Error_ErrorScope errorScope;
643 : : SymbolTable_Where At;
644 : : };
645 : :
646 : : struct SymbolTable_SymModule_r {
647 : : NameKey_Name name;
648 : : NameKey_Name libname;
649 : : SymbolTable_ModuleCtor ctors;
650 : : Lists_List ModListOfDep;
651 : : SymbolKey_SymbolTree LocalSymbols;
652 : : SymbolKey_SymbolTree ExportTree;
653 : : Lists_List IncludeList;
654 : : SymbolKey_SymbolTree ImportTree;
655 : : SymbolKey_SymbolTree ExportUndeclared;
656 : : Lists_List EnumerationScopeList;
657 : : SymbolKey_SymbolTree NamedObjects;
658 : : SymbolKey_SymbolTree NamedImports;
659 : : SymbolKey_SymbolTree WhereImported;
660 : : unsigned int Scope;
661 : : unsigned int Priority;
662 : : SymbolKey_SymbolTree Unresolved;
663 : : unsigned int StartQuad;
664 : : unsigned int EndQuad;
665 : : unsigned int StartFinishQuad;
666 : : unsigned int EndFinishQuad;
667 : : tree FinallyFunction;
668 : : bool ExceptionFinally;
669 : : bool ExceptionBlock;
670 : : bool ModLink;
671 : : bool Builtin;
672 : : Lists_List ListOfVars;
673 : : Lists_List ListOfProcs;
674 : : Lists_List ListOfModules;
675 : : M2Error_ErrorScope errorScope;
676 : : SymbolTable_Where At;
677 : : };
678 : :
679 : : struct SymbolTable__T6_a { SymbolTable_ProcedureDeclaration array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure+1]; };
680 : : struct SymbolTable_SymProcedure_r {
681 : : NameKey_Name name;
682 : : SymbolTable__T6 Decl;
683 : : unsigned int OptArgInit;
684 : : bool IsExtern;
685 : : bool IsPublic;
686 : : bool IsCtor;
687 : : bool IsMonoName;
688 : : bool BuildProcType;
689 : : SymbolKey_SymbolTree Unresolved;
690 : : unsigned int ScopeQuad;
691 : : unsigned int StartQuad;
692 : : unsigned int EndQuad;
693 : : bool Reachable;
694 : : bool SavePriority;
695 : : unsigned int ReturnType;
696 : : unsigned int ProcedureType;
697 : : bool IsBuiltin;
698 : : NameKey_Name BuiltinName;
699 : : bool IsInline;
700 : : SymbolKey_SymbolTree LocalSymbols;
701 : : Lists_List EnumerationScopeList;
702 : : Lists_List ListOfVars;
703 : : Lists_List ListOfProcs;
704 : : SymbolKey_SymbolTree NamedObjects;
705 : : M2ALU_PtrToValue Size;
706 : : M2ALU_PtrToValue TotalParamSize;
707 : : bool ExceptionFinally;
708 : : bool ExceptionBlock;
709 : : unsigned int Scope;
710 : : M2Error_ErrorScope errorScope;
711 : : Lists_List ListOfModules;
712 : : unsigned int Begin;
713 : : unsigned int End;
714 : : SymbolTable_Where At;
715 : : };
716 : :
717 : : struct SymbolTable_Symbol_r {
718 : : SymbolTable_TypeOfSymbol SymbolType; /* case tag */
719 : : union {
720 : : SymbolTable_SymOAFamily OAFamily;
721 : : SymbolTable_SymObject Object;
722 : : SymbolTable_SymEquiv Equiv;
723 : : SymbolTable_SymRecord Record;
724 : : SymbolTable_SymVarient Varient;
725 : : SymbolTable_SymVar Var;
726 : : SymbolTable_SymEnumeration Enumeration;
727 : : SymbolTable_SymSubrange Subrange;
728 : : SymbolTable_SymSubscript Subscript;
729 : : SymbolTable_SymArray Array;
730 : : SymbolTable_SymUnbounded Unbounded;
731 : : SymbolTable_SymPartialUnbounded PartialUnbounded;
732 : : SymbolTable_SymConstVar ConstVar;
733 : : SymbolTable_SymConstLit ConstLit;
734 : : SymbolTable_SymConstString ConstString;
735 : : SymbolTable_SymVarParam VarParam;
736 : : SymbolTable_SymParam Param;
737 : : SymbolTable_SymError Error;
738 : : SymbolTable_SymUndefined Undefined;
739 : : SymbolTable_SymType Type;
740 : : SymbolTable_SymPointer Pointer;
741 : : SymbolTable_SymRecordField RecordField;
742 : : SymbolTable_SymVarientField VarientField;
743 : : SymbolTable_SymEnumerationField EnumerationField;
744 : : SymbolTable_SymDefImp DefImp;
745 : : SymbolTable_SymModule Module;
746 : : SymbolTable_SymSet Set;
747 : : SymbolTable_SymProcedure Procedure;
748 : : SymbolTable_SymProcType ProcType;
749 : : SymbolTable_SymImportStatement ImportStatement;
750 : : SymbolTable_SymImport Import;
751 : : SymbolTable_SymGnuAsm GnuAsm;
752 : : SymbolTable_SymInterface Interface;
753 : : SymbolTable_SymTuple Tuple;
754 : : SymbolTable_SymDummy Dummy;
755 : : };
756 : : };
757 : :
758 : : static Indexing_Index Symbols;
759 : : static Indexing_Index ScopeCallFrame;
760 : : static unsigned int FreeSymbol;
761 : : static SymbolKey_SymbolTree DefModuleTree;
762 : : static SymbolKey_SymbolTree ModuleTree;
763 : : static unsigned int CurrentModule;
764 : : static unsigned int MainModule;
765 : : static unsigned int FileModule;
766 : : static unsigned int ScopePtr;
767 : : static unsigned int BaseScopePtr;
768 : : static unsigned int BaseModule;
769 : : static unsigned int TemporaryNo;
770 : : static M2Error_Error CurrentError;
771 : : static Lists_List AddressTypes;
772 : : static Lists_List UnresolvedConstructorType;
773 : : static unsigned int AnonymousName;
774 : : static Sets_Set ReportedUnknowns;
775 : : static SymbolKey_SymbolTree ConstLitPoolTree;
776 : : static Indexing_Index ConstLitArray;
777 : : static unsigned int BreakSym;
778 : : static M2Diagnostic_Diagnostic SymMemDiag;
779 : : static unsigned int recordConsist;
780 : : static DynamicStrings_String ListifySentance;
781 : : static unsigned int ListifyTotal;
782 : : static unsigned int ListifyWordCount;
783 : : static unsigned int ExportRequestModule;
784 : : static unsigned int ResolveModule;
785 : :
786 : : /*
787 : : FinalSymbol - returns the highest number symbol used.
788 : : */
789 : :
790 : : extern "C" unsigned int SymbolTable_FinalSymbol (void);
791 : :
792 : : /*
793 : : MakeComponentRecord - make a temporary which will be used to reference and field
794 : : (or sub field) of record.
795 : : */
796 : :
797 : : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record);
798 : :
799 : : /*
800 : : MakeComponentRef - use, sym, to reference, field, sym is returned.
801 : : */
802 : :
803 : : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field);
804 : :
805 : : /*
806 : : IsComponent - returns TRUE if symbol, sym, is a temporary and a component
807 : : reference.
808 : : */
809 : :
810 : : extern "C" bool SymbolTable_IsComponent (unsigned int sym);
811 : :
812 : : /*
813 : : MakeTemporary - Makes a new temporary variable at the highest real scope.
814 : : The addressing mode of the temporary is set to NoValue.
815 : : */
816 : :
817 : : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode);
818 : :
819 : : /*
820 : : MakeTemporaryFromExpression - makes a new temporary variable at the
821 : : highest real scope. The addressing
822 : : mode of the temporary is set and the
823 : : type is determined by expressions, e.
824 : : */
825 : :
826 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode);
827 : :
828 : : /*
829 : : MakeTemporaryFromExpressions - makes a new temporary variable at the
830 : : highest real scope. The addressing
831 : : mode of the temporary is set and the
832 : : type is determined by expressions,
833 : : e1 and e2.
834 : : */
835 : :
836 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode);
837 : :
838 : : /*
839 : : PutMode - Puts the addressing mode, SymMode, into symbol Sym.
840 : : The mode may only be altered if the mode
841 : : is None.
842 : : */
843 : :
844 : : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode);
845 : :
846 : : /*
847 : : GetMode - Returns the addressing mode of a symbol.
848 : : */
849 : :
850 : : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym);
851 : :
852 : : /*
853 : : StartScope - starts a block scope at Sym. Transparent determines
854 : : whether the search for a symbol will look at the
855 : : previous ScopeCallFrame if Sym does not contain the
856 : : symbol that GetSym is searching.
857 : :
858 : : WITH statements are partially implemented by calling
859 : : StartScope. Therefore we must retain the old Main from
860 : : the previous ScopePtr when a record is added to the scope
861 : : stack. (Main contains the symbol where all identifiers
862 : : should be added.)
863 : : */
864 : :
865 : : extern "C" void SymbolTable_StartScope (unsigned int Sym);
866 : :
867 : : /*
868 : : EndScope - ends a block scope started by StartScope. The current
869 : : head of the symbol scope reverts back to the symbol
870 : : which was the Head of the symbol scope before the
871 : : last StartScope was called.
872 : : */
873 : :
874 : : extern "C" void SymbolTable_EndScope (void);
875 : :
876 : : /*
877 : : PseudoScope - starts a pseudo scope at Sym.
878 : : We always connect parent up to the last scope,
879 : : to determine the transparancy of a scope we call
880 : : TransparentScope.
881 : :
882 : : A Pseudo scope has no end block,
883 : : but is terminated when the next EndScope is used.
884 : : The function of the pseudo scope is to provide an
885 : : automatic mechanism to solve enumeration types.
886 : : A declared enumeration type is a Pseudo scope and
887 : : identifiers used with the name of an enumeration
888 : : type field will find the enumeration symbol by
889 : : the scoping algorithm.
890 : : */
891 : :
892 : : extern "C" void SymbolTable_PseudoScope (unsigned int Sym);
893 : :
894 : : /*
895 : : GetCurrentScope - returns the symbol who is responsible for the current
896 : : scope. Note that it ignore pseudo scopes.
897 : : */
898 : :
899 : : extern "C" unsigned int SymbolTable_GetCurrentScope (void);
900 : :
901 : : /*
902 : : IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
903 : : */
904 : :
905 : : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym);
906 : :
907 : : /*
908 : : SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
909 : : This Sym must represent the module name of the
910 : : file currently being compiled.
911 : : */
912 : :
913 : : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym);
914 : :
915 : : /*
916 : : SetFileModule - Used to set the FileModule to a symbol, Sym.
917 : : This Sym must represent the current program module
918 : : file which is being parsed.
919 : : */
920 : :
921 : : extern "C" void SymbolTable_SetFileModule (unsigned int Sym);
922 : :
923 : : /*
924 : : SetMainModule - Used to set the MainModule to a symbol, Sym.
925 : : This Sym must represent the main module which was
926 : : envoked by the user to be compiled.
927 : : */
928 : :
929 : : extern "C" void SymbolTable_SetMainModule (unsigned int Sym);
930 : :
931 : : /*
932 : : CheckAnonymous - checks to see whether the name is NulName and if so
933 : : it creates a unique anonymous name.
934 : : */
935 : :
936 : : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name);
937 : :
938 : : /*
939 : : IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
940 : : or no name.
941 : : */
942 : :
943 : : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym);
944 : :
945 : : /*
946 : : NoOfVariables - returns the number of variables in scope. The scope maybe
947 : : a procedure, module or defimp scope.
948 : : */
949 : :
950 : : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope);
951 : :
952 : : /*
953 : : MakeModule - creates a module sym with ModuleName. It returns the
954 : : symbol index.
955 : : */
956 : :
957 : : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName);
958 : :
959 : : /*
960 : : MakeDefImp - creates a definition and implementation module sym
961 : : with name DefImpName. It returns the symbol index.
962 : : */
963 : :
964 : : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName);
965 : :
966 : : /*
967 : : MakeInnerModule - creates an inner module sym with ModuleName. It returns the
968 : : symbol index.
969 : : */
970 : :
971 : : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName);
972 : :
973 : : /*
974 : : MakeProcedure - creates a procedure sym with name. It returns
975 : : the symbol index.
976 : : */
977 : :
978 : : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName);
979 : :
980 : : /*
981 : : MakeProcedureCtorExtern - creates an extern ctor procedure
982 : : */
983 : :
984 : : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename);
985 : :
986 : : /*
987 : : PutLibName - places libname into defimp or module sym.
988 : : */
989 : :
990 : : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname);
991 : :
992 : : /*
993 : : GetLibName - returns libname associated with a defimp or module sym.
994 : : */
995 : :
996 : : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym);
997 : :
998 : : /*
999 : : PutMonoName - changes the IsMonoName boolean inside the procedure.
1000 : : */
1001 : :
1002 : : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value);
1003 : :
1004 : : /*
1005 : : IsMonoName - returns the public boolean associated with a procedure.
1006 : : */
1007 : :
1008 : : extern "C" bool SymbolTable_IsMonoName (unsigned int sym);
1009 : :
1010 : : /*
1011 : : PutExtern - changes the extern boolean inside the procedure.
1012 : : */
1013 : :
1014 : : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value);
1015 : :
1016 : : /*
1017 : : IsExtern - returns the public boolean associated with a procedure.
1018 : : */
1019 : :
1020 : : extern "C" bool SymbolTable_IsExtern (unsigned int sym);
1021 : :
1022 : : /*
1023 : : PutPublic - changes the public boolean inside the procedure.
1024 : : */
1025 : :
1026 : : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value);
1027 : :
1028 : : /*
1029 : : IsPublic - returns the public boolean associated with a procedure.
1030 : : */
1031 : :
1032 : : extern "C" bool SymbolTable_IsPublic (unsigned int sym);
1033 : :
1034 : : /*
1035 : : PutCtor - changes the ctor boolean inside the procedure.
1036 : : */
1037 : :
1038 : : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value);
1039 : :
1040 : : /*
1041 : : IsCtor - returns the ctor boolean associated with a procedure.
1042 : : */
1043 : :
1044 : : extern "C" bool SymbolTable_IsCtor (unsigned int sym);
1045 : :
1046 : : /*
1047 : : GetModuleCtors - mod can be a DefImp or Module symbol. ctor, init and fini
1048 : : are assigned for this module. An inner module ctor value will
1049 : : be NulSym.
1050 : : */
1051 : :
1052 : : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep);
1053 : :
1054 : : /*
1055 : : MakeModuleCtor - for a defimp or module symbol create all the ctor
1056 : : related procedures.
1057 : : */
1058 : :
1059 : : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym);
1060 : :
1061 : : /*
1062 : : PutModuleCtorExtern - for every ctor related procedure in module sym.
1063 : : Make it external. It will create any missing
1064 : : init/fini procedures but not any missing dep/ctor
1065 : : procedures.
1066 : : */
1067 : :
1068 : : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external);
1069 : :
1070 : : /*
1071 : : PutVarHeap - assigns ArrayRef field with value.
1072 : : */
1073 : :
1074 : : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value);
1075 : :
1076 : : /*
1077 : : IsVarHeap - returns ArrayRef field value.
1078 : : */
1079 : :
1080 : : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym);
1081 : :
1082 : : /*
1083 : : MakeVar - creates a variable sym with VarName. It returns the
1084 : : symbol index.
1085 : : */
1086 : :
1087 : : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName);
1088 : :
1089 : : /*
1090 : : PutVarConditional - assign IsConditional to value.
1091 : : */
1092 : :
1093 : : extern "C" void SymbolTable_PutVarConditional (unsigned int sym, bool value);
1094 : :
1095 : : /*
1096 : : IsVarConditional - return TRUE if the symbol is a var symbol
1097 : : containing the result of a boolean conditional.
1098 : : */
1099 : :
1100 : : extern "C" bool SymbolTable_IsVarConditional (unsigned int sym);
1101 : :
1102 : : /*
1103 : : MakeRecord - makes a Record symbol with name RecordName.
1104 : : */
1105 : :
1106 : : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName);
1107 : :
1108 : : /*
1109 : : MakeVarient - creates a new symbol, a varient symbol for record or varient field
1110 : : symbol, RecOrVarFieldSym.
1111 : : */
1112 : :
1113 : : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym);
1114 : :
1115 : : /*
1116 : : MakeFieldVarient - returns a FieldVarient symbol which has been
1117 : : assigned to the Varient symbol, Sym.
1118 : : */
1119 : :
1120 : : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym);
1121 : :
1122 : : /*
1123 : : MakeEnumeration - places a new symbol in the current scope, the symbol
1124 : : is an enumeration symbol. The symbol index is returned.
1125 : : */
1126 : :
1127 : : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName);
1128 : :
1129 : : /*
1130 : : MakeType - makes a type symbol with name TypeName.
1131 : : */
1132 : :
1133 : : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName);
1134 : :
1135 : : /*
1136 : : MakeHiddenType - makes a type symbol that is hidden from the
1137 : : definition module.
1138 : : This symbol is placed into the UnImplemented list of
1139 : : the definition/implementation module.
1140 : : The type will be filled in when the implementation module
1141 : : is reached.
1142 : : */
1143 : :
1144 : : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName);
1145 : :
1146 : : /*
1147 : : MakeConstant - create a constant cardinal and return the symbol.
1148 : : */
1149 : :
1150 : : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value);
1151 : :
1152 : : /*
1153 : : MakeConstLit - returns a constant literal of type, constType, with a constName,
1154 : : at location, tok.
1155 : : */
1156 : :
1157 : : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
1158 : :
1159 : : /*
1160 : : MakeConstVar - makes a ConstVar type with
1161 : : name ConstVarName.
1162 : : */
1163 : :
1164 : : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName);
1165 : :
1166 : : /*
1167 : : MakeConstString - create a string constant in the symboltable.
1168 : : */
1169 : :
1170 : : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName);
1171 : :
1172 : : /*
1173 : : MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
1174 : : If known is TRUE then name is assigned to the contents
1175 : : and the escape sequences will be converted into characters.
1176 : : */
1177 : :
1178 : : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known);
1179 : :
1180 : : /*
1181 : : MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
1182 : : If known is TRUE then name is assigned to the contents
1183 : : however the escape sequences are not converted into characters.
1184 : : */
1185 : :
1186 : : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known);
1187 : :
1188 : : /*
1189 : : PutConstStringKnown - if sym is a constvar then convert it into a conststring.
1190 : : If known is FALSE then contents is ignored and NulName is
1191 : : stored. If escape is TRUE then the contents will have
1192 : : any escape sequences converted into single characters.
1193 : : */
1194 : :
1195 : : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known);
1196 : :
1197 : : /*
1198 : : CopyConstString - copies string contents from expr to des
1199 : : and retain the kind of string.
1200 : : */
1201 : :
1202 : : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr);
1203 : :
1204 : : /*
1205 : : IsConstStringKnown - returns TRUE if sym is a const string
1206 : : and the contents are known.
1207 : : */
1208 : :
1209 : : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym);
1210 : :
1211 : : /*
1212 : : IsConstStringM2 - returns whether this conststring is a
1213 : : Modula-2 string.
1214 : : */
1215 : :
1216 : : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym);
1217 : :
1218 : : /*
1219 : : IsConstStringC - returns whether this conststring is a C style string
1220 : : which will have any escape translated.
1221 : : */
1222 : :
1223 : : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym);
1224 : :
1225 : : /*
1226 : : IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
1227 : : contains a nul terminator.
1228 : : */
1229 : :
1230 : : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym);
1231 : :
1232 : : /*
1233 : : IsConstStringCnul - returns whether this conststring is a C style string
1234 : : which will have any escape translated and also contains
1235 : : a nul terminator.
1236 : : */
1237 : :
1238 : : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym);
1239 : :
1240 : : /*
1241 : : MakeSubrange - makes a new symbol into a subrange type with
1242 : : name SubrangeName.
1243 : : */
1244 : :
1245 : : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName);
1246 : :
1247 : : /*
1248 : : MakeSet - makes a set Symbol with name, SetName.
1249 : : */
1250 : :
1251 : : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName);
1252 : :
1253 : : /*
1254 : : GetSetArray - return the set array for a large set.
1255 : : */
1256 : :
1257 : : extern "C" unsigned int SymbolTable_GetSetArray (unsigned int sym);
1258 : :
1259 : : /*
1260 : : PutSetArray - places array into the setarray field.
1261 : : */
1262 : :
1263 : : extern "C" void SymbolTable_PutSetArray (unsigned int Sym, unsigned int array);
1264 : :
1265 : : /*
1266 : : MakeSetArray - create an ARRAY simpletype OF BOOLEAN.
1267 : : */
1268 : :
1269 : : extern "C" unsigned int SymbolTable_MakeSetArray (unsigned int token, unsigned int subrangetype);
1270 : :
1271 : : /*
1272 : : PutSetInWord - set the SetInWord boolean to value.
1273 : : */
1274 : :
1275 : : extern "C" void SymbolTable_PutSetInWord (unsigned int sym, bool value);
1276 : :
1277 : : /*
1278 : : GetSetInWord - return SetInWord.
1279 : : */
1280 : :
1281 : : extern "C" bool SymbolTable_GetSetInWord (unsigned int sym);
1282 : :
1283 : : /*
1284 : : MakeArray - makes an Array symbol with name ArrayName.
1285 : : */
1286 : :
1287 : : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName);
1288 : :
1289 : : /*
1290 : : PutArrayLarge - indicates that this is a large array in which case
1291 : : the interface to gcc maps this array from 0..high-low,
1292 : : using an integer indice.
1293 : : */
1294 : :
1295 : : extern "C" void SymbolTable_PutArrayLarge (unsigned int array);
1296 : :
1297 : : /*
1298 : : IsArrayLarge - returns TRUE if we need to treat this as a large array.
1299 : : */
1300 : :
1301 : : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array);
1302 : :
1303 : : /*
1304 : : PutPriority - places a interrupt, priority, value into module, module.
1305 : : */
1306 : :
1307 : : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority);
1308 : :
1309 : : /*
1310 : : GetPriority - returns the interrupt priority which was assigned to
1311 : : module, module.
1312 : : */
1313 : :
1314 : : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module);
1315 : :
1316 : : /*
1317 : : PutNeedSavePriority - set a boolean flag indicating that this procedure
1318 : : needs to save and restore interrupts.
1319 : : */
1320 : :
1321 : : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym);
1322 : :
1323 : : /*
1324 : : GetNeedSavePriority - returns the boolean flag indicating whether this procedure
1325 : : needs to save and restore interrupts.
1326 : : */
1327 : :
1328 : : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym);
1329 : :
1330 : : /*
1331 : : PutVariableAtAddress - determines that a variable, sym, is declared at
1332 : : a specific address.
1333 : : */
1334 : :
1335 : : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address);
1336 : :
1337 : : /*
1338 : : GetVariableAtAddress - returns the address at which variable, sym, is declared.
1339 : : */
1340 : :
1341 : : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym);
1342 : :
1343 : : /*
1344 : : IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
1345 : : a specific address.
1346 : : */
1347 : :
1348 : : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym);
1349 : :
1350 : : /*
1351 : : PutVariableSSA - assigns value to the SSA field within variable sym.
1352 : : */
1353 : :
1354 : : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value);
1355 : :
1356 : : /*
1357 : : IsVariableSSA - returns TRUE if variable is known to be a SSA.
1358 : : */
1359 : :
1360 : : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym);
1361 : :
1362 : : /*
1363 : : PutVarConst - sets the IsConst field to value indicating the variable is read only.
1364 : : */
1365 : :
1366 : : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value);
1367 : :
1368 : : /*
1369 : : MakeGnuAsm - create a GnuAsm symbol.
1370 : : */
1371 : :
1372 : : extern "C" unsigned int SymbolTable_MakeGnuAsm (void);
1373 : :
1374 : : /*
1375 : : PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
1376 : : */
1377 : :
1378 : : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string);
1379 : :
1380 : : /*
1381 : : PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
1382 : : */
1383 : :
1384 : : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out);
1385 : :
1386 : : /*
1387 : : PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
1388 : : */
1389 : :
1390 : : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in);
1391 : :
1392 : : /*
1393 : : PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
1394 : : */
1395 : :
1396 : : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash);
1397 : :
1398 : : /*
1399 : : GetGnuAsm - returns the string symbol, representing the instruction textual
1400 : : of the GnuAsm symbol. It will return a ConstString.
1401 : : */
1402 : :
1403 : : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym);
1404 : :
1405 : : /*
1406 : : GetGnuAsmInput - returns the input list of registers.
1407 : : */
1408 : :
1409 : : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym);
1410 : :
1411 : : /*
1412 : : GetGnuAsmOutput - returns the output list of registers.
1413 : : */
1414 : :
1415 : : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym);
1416 : :
1417 : : /*
1418 : : GetGnuAsmTrash - returns the list of trashed registers.
1419 : : */
1420 : :
1421 : : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym);
1422 : :
1423 : : /*
1424 : : PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
1425 : : */
1426 : :
1427 : : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym);
1428 : :
1429 : : /*
1430 : : PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
1431 : : */
1432 : :
1433 : : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym);
1434 : :
1435 : : /*
1436 : : MakeRegInterface - creates and returns a register interface symbol.
1437 : : */
1438 : :
1439 : : extern "C" unsigned int SymbolTable_MakeRegInterface (void);
1440 : :
1441 : : /*
1442 : : PutRegInterface - places a, name, string, and, object, into the interface array,
1443 : : sym, at position, i.
1444 : : The string symbol will either be a register name or a constraint.
1445 : : The object is an optional Modula-2 variable or constant symbol.
1446 : : read and write are the quadruple numbers representing any read
1447 : : or write operation.
1448 : : */
1449 : :
1450 : : extern "C" void SymbolTable_PutRegInterface (unsigned int tok, unsigned int sym, unsigned int i, NameKey_Name n, unsigned int string, unsigned int object, unsigned int read_, unsigned int write_);
1451 : :
1452 : : /*
1453 : : GetRegInterface - gets a, name, string, and, object, from the interface array,
1454 : : sym, from position, i.
1455 : : */
1456 : :
1457 : : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object);
1458 : :
1459 : : /*
1460 : : GetModule - Returns the Module symbol for the module with name, name.
1461 : : */
1462 : :
1463 : : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name);
1464 : :
1465 : : /*
1466 : : GetCurrentModule - returns the current module Sym that is being
1467 : : compiled.
1468 : : */
1469 : :
1470 : : extern "C" unsigned int SymbolTable_GetCurrentModule (void);
1471 : :
1472 : : /*
1473 : : GetFileModule - returns the FileModule symbol that was requested by
1474 : : the user to be compiled.
1475 : : */
1476 : :
1477 : : extern "C" unsigned int SymbolTable_GetFileModule (void);
1478 : :
1479 : : /*
1480 : : GetBaseModule - returns the base module symbol that contains Modula-2
1481 : : base types, procedures and functions.
1482 : : */
1483 : :
1484 : : extern "C" unsigned int SymbolTable_GetBaseModule (void);
1485 : :
1486 : : /*
1487 : : GetMainModule - returns the main module symbol that was requested by
1488 : : the user to be compiled.
1489 : : */
1490 : :
1491 : : extern "C" unsigned int SymbolTable_GetMainModule (void);
1492 : :
1493 : : /*
1494 : : GetCurrentModuleScope - returns the module symbol which forms the
1495 : : current (possibly inner most) module.
1496 : : */
1497 : :
1498 : : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void);
1499 : :
1500 : : /*
1501 : : GetLastModuleScope - returns the last module scope encountered,
1502 : : the module scope before the Current Module Scope.
1503 : : */
1504 : :
1505 : : extern "C" unsigned int SymbolTable_GetLastModuleScope (void);
1506 : :
1507 : : /*
1508 : : AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
1509 : : ModSym.
1510 : : */
1511 : :
1512 : : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym);
1513 : :
1514 : : /*
1515 : : GetType - Returns the symbol that is the TYPE symbol to Sym.
1516 : : If zero is returned then we assume type unknown.
1517 : : */
1518 : :
1519 : : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym);
1520 : :
1521 : : /*
1522 : : SkipType - if sym is a TYPE foo = bar
1523 : : then call SkipType(bar)
1524 : : else return sym
1525 : :
1526 : : it does not skip over hidden types.
1527 : : */
1528 : :
1529 : : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym);
1530 : :
1531 : : /*
1532 : : SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
1533 : : sym is declared as a subrange of bar
1534 : : then call SkipTypeAndSubrange(bar)
1535 : : else return sym
1536 : :
1537 : : it does not skip over hidden types.
1538 : : */
1539 : :
1540 : : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym);
1541 : :
1542 : : /*
1543 : : GetLowestType - Returns the lowest type in the type chain of
1544 : : symbol Sym.
1545 : : If NulSym is returned then we assume type unknown or
1546 : : you have reqested the type of a base type.
1547 : : */
1548 : :
1549 : : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym);
1550 : :
1551 : : /*
1552 : : GetLType - get lowest type. It returns the lowest type
1553 : : of symbol, sym. It skips over type equivalences.
1554 : : It will not skip over base types.
1555 : : */
1556 : :
1557 : : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym);
1558 : :
1559 : : /*
1560 : : GetSType - get source type. It returns the type closest
1561 : : to the object. It does not skip over type
1562 : : equivalences. It will skip over base types.
1563 : : */
1564 : :
1565 : : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym);
1566 : :
1567 : : /*
1568 : : GetDType - get gcc declared type. It returns the type
1569 : : of the object which is declared to GCC.
1570 : : It does skip over type equivalences but only
1571 : : if they do not contain a user alignment.
1572 : : It does not skip over hidden types.
1573 : : It does not skip over base types.
1574 : : */
1575 : :
1576 : : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym);
1577 : :
1578 : : /*
1579 : : GetTypeMode - return the type of sym, it returns Address is the
1580 : : symbol is a LValue.
1581 : : */
1582 : :
1583 : : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym);
1584 : :
1585 : : /*
1586 : : GetSym - searches the current scope (and previous scopes if the
1587 : : scope tranparent allows) for a symbol with name.
1588 : : */
1589 : :
1590 : : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name);
1591 : :
1592 : : /*
1593 : : GetDeclareSym - searches for a symbol with a name SymName in the
1594 : : current and previous scopes.
1595 : : If the symbol is found then it is returned
1596 : : else an unknown symbol is returned.
1597 : : This procedure assumes that SymName is being
1598 : : declared at this point and therefore it does
1599 : : not examine the base scope (for pervasive
1600 : : identifiers).
1601 : : */
1602 : :
1603 : : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName);
1604 : :
1605 : : /*
1606 : : GetLocalSym - only searches the scope Sym for a symbol with name
1607 : : and returns the index to the symbol.
1608 : : */
1609 : :
1610 : : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name);
1611 : :
1612 : : /*
1613 : : GetRecord - fetches the record symbol from the parent of Sym.
1614 : : Sym maybe a varient symbol in which case its parent is searched
1615 : : etc.
1616 : : */
1617 : :
1618 : : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym);
1619 : :
1620 : : /*
1621 : : FromModuleGetSym - attempts to find a symbol of name, n, in the
1622 : : module, mod, scope. An unknown symbol is created
1623 : : at token position tok if necessary.
1624 : : */
1625 : :
1626 : : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod);
1627 : :
1628 : : /*
1629 : : GetNth - returns the n th symbol in the list associated with the scope
1630 : : of Sym. Sym may be a Module, DefImp, Procedure, Record or
1631 : : Enumeration symbol.
1632 : : */
1633 : :
1634 : : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n);
1635 : :
1636 : : /*
1637 : : GetNthParam - returns the n th parameter of a procedure Sym.
1638 : : */
1639 : :
1640 : : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
1641 : :
1642 : : /*
1643 : : GetVarScope - returns the symbol which is the scope of variable Sym.
1644 : : ie a Module, DefImp or Procedure Symbol.
1645 : : */
1646 : :
1647 : : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym);
1648 : :
1649 : : /*
1650 : : GetSubrange - returns HighSym and LowSym - two constants which make up the
1651 : : subrange.
1652 : : */
1653 : :
1654 : : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym);
1655 : :
1656 : : /*
1657 : : GetParam - returns the ParamNo parameter from procedure ProcSym
1658 : : */
1659 : :
1660 : : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo);
1661 : :
1662 : : /*
1663 : : GetString - returns the contents of the string symbol sym, note that
1664 : : this is not the same as GetName (unless it was a literal).
1665 : : */
1666 : :
1667 : : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym);
1668 : :
1669 : : /*
1670 : : GetStringLength - returns the length of the string symbol Sym.
1671 : : */
1672 : :
1673 : : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym);
1674 : :
1675 : : /*
1676 : : GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
1677 : : */
1678 : :
1679 : : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym);
1680 : :
1681 : : /*
1682 : : PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
1683 : : */
1684 : :
1685 : : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name);
1686 : :
1687 : : /*
1688 : : IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
1689 : : */
1690 : :
1691 : : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym);
1692 : :
1693 : : /*
1694 : : PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
1695 : : */
1696 : :
1697 : : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym);
1698 : : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym);
1699 : :
1700 : : /*
1701 : : PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
1702 : : sym, indicating that this block as an EXCEPT
1703 : : statement sequence.
1704 : : */
1705 : :
1706 : : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym);
1707 : :
1708 : : /*
1709 : : HasExceptionBlock - returns a BOOLEAN determining whether
1710 : : module/procedure/defimp, sym, has
1711 : : an EXCEPT statement sequence.
1712 : : */
1713 : :
1714 : : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym);
1715 : :
1716 : : /*
1717 : : PutExceptionFinally - sets a BOOLEAN in block module/defimp,
1718 : : sym, indicating that this FINALLY block
1719 : : as an EXCEPT statement sequence.
1720 : : */
1721 : :
1722 : : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym);
1723 : :
1724 : : /*
1725 : : HasExceptionFinally - returns a BOOLEAN determining whether
1726 : : module/defimp, sym, has
1727 : : an EXCEPT statement sequence.
1728 : : */
1729 : :
1730 : : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym);
1731 : :
1732 : : /*
1733 : : PutVar - gives the VarSym symbol Sym a type Type.
1734 : : */
1735 : :
1736 : : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType);
1737 : :
1738 : : /*
1739 : : PutVarTok - gives the VarSym symbol Sym a type Type at typetok.
1740 : : */
1741 : :
1742 : : extern "C" void SymbolTable_PutVarTok (unsigned int Sym, unsigned int VarType, unsigned int typetok);
1743 : :
1744 : : /*
1745 : : PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
1746 : : The variable must be a LeftValue.
1747 : : */
1748 : :
1749 : : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType);
1750 : :
1751 : : /*
1752 : : GetVarBackEndType - returns the back end type if specified.
1753 : : */
1754 : :
1755 : : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym);
1756 : :
1757 : : /*
1758 : : PutVarPointerCheck - marks variable, sym, as requiring (or not
1759 : : depending upon the, value), a NIL pointer check
1760 : : when this symbol is dereferenced.
1761 : : */
1762 : :
1763 : : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value);
1764 : :
1765 : : /*
1766 : : GetVarPointerCheck - returns TRUE if this symbol is a variable and
1767 : : has been marked as needing a pointer via NIL check.
1768 : : */
1769 : :
1770 : : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym);
1771 : :
1772 : : /*
1773 : : PutVarWritten - marks variable, sym, as being written to (or not
1774 : : depending upon the, value).
1775 : : */
1776 : :
1777 : : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value);
1778 : :
1779 : : /*
1780 : : GetVarWritten - returns TRUE if this symbol is a variable and
1781 : : has been marked as being written.
1782 : : */
1783 : :
1784 : : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym);
1785 : :
1786 : : /*
1787 : : PutConst - gives the constant symbol Sym a type ConstType.
1788 : : */
1789 : :
1790 : : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType);
1791 : :
1792 : : /*
1793 : : PutConstSet - informs the const var symbol, sym, that it is or will contain
1794 : : a set value.
1795 : : */
1796 : :
1797 : : extern "C" void SymbolTable_PutConstSet (unsigned int Sym);
1798 : :
1799 : : /*
1800 : : IsConstSet - returns TRUE if the constant is declared as a set.
1801 : : */
1802 : :
1803 : : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym);
1804 : :
1805 : : /*
1806 : : PutConstructor - informs the const var symbol, sym, that it is or
1807 : : will contain a constructor (record, set or array)
1808 : : value.
1809 : : */
1810 : :
1811 : : extern "C" void SymbolTable_PutConstructor (unsigned int Sym);
1812 : :
1813 : : /*
1814 : : PutConstructorFrom - sets the from type field in constructor,
1815 : : Sym, to, from.
1816 : : */
1817 : :
1818 : : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from);
1819 : :
1820 : : /*
1821 : : PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
1822 : : VarSym is a optional varient symbol which can be returned
1823 : : by a call to GetVarient(fieldsymbol). The created field
1824 : : is returned.
1825 : : */
1826 : :
1827 : : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym);
1828 : :
1829 : : /*
1830 : : PutFieldVarient - places the field varient, Field, as a brother to, the
1831 : : varient symbol, sym, and also tells Field that its varient
1832 : : parent is Sym.
1833 : : */
1834 : :
1835 : : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym);
1836 : :
1837 : : /*
1838 : : GetVarient - returns the varient symbol associated with the
1839 : : record or varient field symbol, Field.
1840 : : */
1841 : :
1842 : : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field);
1843 : :
1844 : : /*
1845 : : IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
1846 : : a varient tag.
1847 : : */
1848 : :
1849 : : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym);
1850 : :
1851 : : /*
1852 : : IsEmptyFieldVarient - returns TRUE if the field variant has
1853 : : no fields. This will occur then the
1854 : : compiler constructs 'else end' variants.
1855 : : */
1856 : :
1857 : : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym);
1858 : :
1859 : : /*
1860 : : GetVarientTag - returns the varient tag from, Sym.
1861 : : */
1862 : :
1863 : : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym);
1864 : :
1865 : : /*
1866 : : PutVarientTag - places, Tag, into varient, Sym.
1867 : : */
1868 : :
1869 : : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag);
1870 : :
1871 : : /*
1872 : : PutFieldEnumeration - places a field into the enumeration type
1873 : : Sym. The field has a name FieldName and a
1874 : : value FieldVal.
1875 : : */
1876 : :
1877 : : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName);
1878 : :
1879 : : /*
1880 : : PutSubrange - places LowSym and HighSym as two symbols
1881 : : which provide the limits of the range.
1882 : : */
1883 : :
1884 : : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol);
1885 : :
1886 : : /*
1887 : : PutSet - places SimpleType as the type for set, Sym.
1888 : : */
1889 : :
1890 : : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed);
1891 : :
1892 : : /*
1893 : : IsSetPacked - returns TRUE if Sym is packed.
1894 : : */
1895 : :
1896 : : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym);
1897 : :
1898 : : /*
1899 : : GetArraySubscript - returns the subscript symbol for array, Sym.
1900 : : */
1901 : :
1902 : : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym);
1903 : :
1904 : : /*
1905 : : PutArraySubscript - places an index field into the array Sym. The
1906 : : index field is a subscript sym.
1907 : : */
1908 : :
1909 : : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol);
1910 : :
1911 : : /*
1912 : : PutType - gives a type symbol Sym type TypeSymbol.
1913 : : */
1914 : :
1915 : : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol);
1916 : :
1917 : : /*
1918 : : PutFunction - Places a TypeSym as the return type to a procedure Sym.
1919 : : */
1920 : :
1921 : : extern "C" void SymbolTable_PutFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym);
1922 : :
1923 : : /*
1924 : : PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
1925 : : */
1926 : :
1927 : : extern "C" void SymbolTable_PutOptFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym);
1928 : :
1929 : : /*
1930 : : IsReturnOptional - returns TRUE if the return value for, sym, is
1931 : : optional.
1932 : : */
1933 : :
1934 : : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind);
1935 : :
1936 : : /*
1937 : : IsReturnOptionalAny - returns TRUE if the return value for sym is
1938 : : optional.
1939 : : */
1940 : :
1941 : : extern "C" bool SymbolTable_IsReturnOptionalAny (unsigned int sym);
1942 : :
1943 : : /*
1944 : : PutParam - Places a Non VAR parameter ParamName with type ParamType into
1945 : : procedure Sym:kind. The parameter number is ParamNo.
1946 : : If the procedure Sym already has this parameter then
1947 : : the parameter is checked for consistancy and the
1948 : : consistancy test is returned.
1949 : : */
1950 : :
1951 : : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok);
1952 : :
1953 : : /*
1954 : : PutVarParam - Places a Non VAR parameter ParamName with type
1955 : : ParamType into procedure Sym:kind.
1956 : : The parameter number is ParamNo.
1957 : : If the procedure Sym already has this parameter then
1958 : : the parameter is checked for consistancy and the
1959 : : consistancy test is returned.
1960 : : */
1961 : :
1962 : : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok);
1963 : :
1964 : : /*
1965 : : PutParamName - assigns a name to paramater no of procedure ProcSym:kind.
1966 : : */
1967 : :
1968 : : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, NameKey_Name name, unsigned int ParamType, unsigned int typetok);
1969 : :
1970 : : /*
1971 : : PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
1972 : : main Module.
1973 : : */
1974 : :
1975 : : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym);
1976 : :
1977 : : /*
1978 : : IsProcedureReachable - Returns true if the procedure, Sym, is
1979 : : reachable from the main Module.
1980 : : */
1981 : :
1982 : : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym);
1983 : :
1984 : : /*
1985 : : PutProcedureNoReturn - places value into the no return attribute
1986 : : field of procedure sym.
1987 : : */
1988 : :
1989 : : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind, bool value);
1990 : :
1991 : : /*
1992 : : IsProcedureNoReturn - returns TRUE if this procedure never returns.
1993 : : */
1994 : :
1995 : : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind);
1996 : :
1997 : : /*
1998 : : GetProcedureProcType - returns the proctype matching procedure sym.
1999 : : */
2000 : :
2001 : : extern "C" unsigned int SymbolTable_GetProcedureProcType (unsigned int sym);
2002 : :
2003 : : /*
2004 : : PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
2005 : : QuadNumber is the start quad of Module,
2006 : : Sym.
2007 : : */
2008 : :
2009 : : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber);
2010 : :
2011 : : /*
2012 : : PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
2013 : : QuadNumber is the end quad of Module,
2014 : : Sym.
2015 : : */
2016 : :
2017 : : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber);
2018 : :
2019 : : /*
2020 : : PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
2021 : : QuadNumber is the finally start quad of
2022 : : Module, Sym.
2023 : : */
2024 : :
2025 : : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber);
2026 : :
2027 : : /*
2028 : : PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
2029 : : QuadNumber is the end quad of the finally block
2030 : : in Module, Sym.
2031 : : */
2032 : :
2033 : : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber);
2034 : :
2035 : : /*
2036 : : GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
2037 : : Quads of a Module, Sym.
2038 : : Start and End represent the initialization code
2039 : : of the Module, Sym.
2040 : : */
2041 : :
2042 : : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish);
2043 : :
2044 : : /*
2045 : : PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
2046 : : */
2047 : :
2048 : : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, tree finally);
2049 : :
2050 : : /*
2051 : : GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
2052 : : */
2053 : :
2054 : : extern "C" tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym);
2055 : :
2056 : : /*
2057 : : PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
2058 : : QuadNumber is the start quad of scope for procedure,
2059 : : Sym.
2060 : : */
2061 : :
2062 : : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber);
2063 : :
2064 : : /*
2065 : : PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
2066 : : QuadNumber is the start quad of procedure,
2067 : : Sym.
2068 : : */
2069 : :
2070 : : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber);
2071 : :
2072 : : /*
2073 : : PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
2074 : : QuadNumber is the end quad of procedure,
2075 : : Sym.
2076 : : */
2077 : :
2078 : : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber);
2079 : :
2080 : : /*
2081 : : GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
2082 : : */
2083 : :
2084 : : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end);
2085 : :
2086 : : /*
2087 : : GetQuads - assigns Start and End to the beginning and end of
2088 : : symbol, Sym, usage.
2089 : : */
2090 : :
2091 : : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2092 : :
2093 : : /*
2094 : : GetReadQuads - assigns Start and End to the beginning and end of
2095 : : symbol, Sym, read history usage.
2096 : : */
2097 : :
2098 : : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2099 : :
2100 : : /*
2101 : : GetWriteQuads - assigns Start and End to the beginning and end of
2102 : : symbol, Sym, usage.
2103 : : */
2104 : :
2105 : : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2106 : :
2107 : : /*
2108 : : PutReadQuad - places Quad into the list of symbol usage.
2109 : : */
2110 : :
2111 : : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2112 : :
2113 : : /*
2114 : : RemoveReadQuad - places Quad into the list of symbol usage.
2115 : : */
2116 : :
2117 : : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2118 : :
2119 : : /*
2120 : : PutWriteQuad - places Quad into the list of symbol usage.
2121 : : */
2122 : :
2123 : : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2124 : :
2125 : : /*
2126 : : RemoveWriteQuad - places Quad into the list of symbol usage.
2127 : : */
2128 : :
2129 : : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2130 : :
2131 : : /*
2132 : : GetReadLimitQuads - returns Start and End which have been assigned
2133 : : the start and end of when the symbol was read
2134 : : to within: StartLimit..EndLimit.
2135 : : */
2136 : :
2137 : : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2138 : :
2139 : : /*
2140 : : GetWriteLimitQuads - returns Start and End which have been assigned
2141 : : the start and end of when the symbol was written
2142 : : to within: StartLimit..EndLimit.
2143 : : */
2144 : :
2145 : : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2146 : :
2147 : : /*
2148 : : GetNthProcedure - Returns the Nth procedure in Module, Sym.
2149 : : */
2150 : :
2151 : : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n);
2152 : :
2153 : : /*
2154 : : GetDeclaredDef - returns the tokenno where the symbol was declared
2155 : : in the definition module. UnknownTokenNo is returned
2156 : : if no declaration occurred.
2157 : : */
2158 : :
2159 : : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym);
2160 : :
2161 : : /*
2162 : : GetDeclaredMod - returns the tokenno where the symbol was declared.
2163 : : in the program or implementation module.
2164 : : UnknownTokenNo is returned if no declaration occurred.
2165 : : */
2166 : :
2167 : : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym);
2168 : :
2169 : : /*
2170 : : GetDeclaredFor - returns the token where this forward procedure symbol
2171 : : was declared in the program or implementation module.
2172 : : UnknownTokenNo is returned if no declaration occurred.
2173 : : */
2174 : :
2175 : : extern "C" unsigned int SymbolTable_GetDeclaredFor (unsigned int Sym);
2176 : :
2177 : : /*
2178 : : GetDeclaredDefinition - returns the token where this symbol
2179 : : was declared in the definition module.
2180 : : */
2181 : :
2182 : : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym);
2183 : :
2184 : : /*
2185 : : GetDeclaredModule - returns the token where this symbol was declared
2186 : : in an implementation or program module.
2187 : : */
2188 : :
2189 : : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym);
2190 : :
2191 : : /*
2192 : : PutDeclared - adds an entry to symbol, Sym, indicating that it
2193 : : was declared at, tok. This routine
2194 : : may be called twice, once for definition module
2195 : : partial declaration and once when parsing the
2196 : : implementation module.
2197 : : */
2198 : :
2199 : : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym);
2200 : :
2201 : : /*
2202 : : GetFirstUsed - returns the token where this symbol was first used.
2203 : : */
2204 : :
2205 : : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym);
2206 : :
2207 : : /*
2208 : : PutProcedureBegin - assigns begin as the token number matching the
2209 : : procedure BEGIN.
2210 : : */
2211 : :
2212 : : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin);
2213 : :
2214 : : /*
2215 : : PutProcedureEnd - assigns end as the token number matching the
2216 : : procedure END.
2217 : : */
2218 : :
2219 : : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end);
2220 : :
2221 : : /*
2222 : : GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
2223 : : */
2224 : :
2225 : : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end);
2226 : :
2227 : : /*
2228 : : ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
2229 : : */
2230 : :
2231 : : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P);
2232 : :
2233 : : /*
2234 : : ForeachModuleDo - for each module do procedure, P.
2235 : : */
2236 : :
2237 : : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P);
2238 : :
2239 : : /*
2240 : : ForeachInnerModuleDo - for each inner module in module, Sym,
2241 : : do procedure, P.
2242 : : */
2243 : :
2244 : : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P);
2245 : :
2246 : : /*
2247 : : IsVarParam - Returns a conditional depending whether parameter ParamNo
2248 : : is a VAR parameter.
2249 : : */
2250 : :
2251 : : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
2252 : :
2253 : : /*
2254 : : IsVarParamAny - Returns a conditional depending whether parameter ParamNo
2255 : : is a VAR parameter.
2256 : : */
2257 : :
2258 : : extern "C" bool SymbolTable_IsVarParamAny (unsigned int Sym, unsigned int ParamNo);
2259 : :
2260 : : /*
2261 : : IsUnboundedParam - Returns a conditional depending whether parameter
2262 : : ParamNo is an unbounded array procedure parameter.
2263 : : */
2264 : :
2265 : : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
2266 : : extern "C" bool SymbolTable_IsUnboundedParamAny (unsigned int Sym, unsigned int ParamNo);
2267 : :
2268 : : /*
2269 : : IsParameterUnbounded - returns TRUE if parameter, Sym, is
2270 : : unbounded.
2271 : : */
2272 : :
2273 : : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym);
2274 : :
2275 : : /*
2276 : : IsParameterVar - returns true if parameter symbol Sym
2277 : : was declared as a VAR.
2278 : : */
2279 : :
2280 : : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym);
2281 : :
2282 : : /*
2283 : : GetParameterShadowVar - returns the local variable associated with the
2284 : : parameter symbol, sym.
2285 : : */
2286 : :
2287 : : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym);
2288 : :
2289 : : /*
2290 : : NoOfParam - Returns the number of parameters that procedure Sym contains.
2291 : : */
2292 : :
2293 : : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym, SymbolTable_ProcedureKind kind);
2294 : :
2295 : : /*
2296 : : HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
2297 : : */
2298 : :
2299 : : extern "C" bool SymbolTable_HasVarParameters (unsigned int p);
2300 : :
2301 : : /*
2302 : : NoOfLocalVar - returns the number of local variables that exist in
2303 : : procedure Sym. Parameters are NOT included in the
2304 : : count.
2305 : : */
2306 : :
2307 : : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym);
2308 : :
2309 : : /*
2310 : : IsDefImp - returns true is the Sym is a DefImp symbol.
2311 : : Definition/Implementation module symbol.
2312 : : */
2313 : :
2314 : : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym);
2315 : :
2316 : : /*
2317 : : IsModule - returns true is the Sym is a Module symbol.
2318 : : Program module symbol.
2319 : : */
2320 : :
2321 : : extern "C" bool SymbolTable_IsModule (unsigned int Sym);
2322 : :
2323 : : /*
2324 : : IsInnerModule - returns true if the symbol, Sym, is an inner module.
2325 : : */
2326 : :
2327 : : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym);
2328 : :
2329 : : /*
2330 : : GetSymName - returns the symbol name.
2331 : : */
2332 : :
2333 : : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym);
2334 : :
2335 : : /*
2336 : : RenameSym - renames a symbol, Sym, with SymName.
2337 : : It also checks the unknown tree for a symbol
2338 : : with this new name. Must only be renamed in
2339 : : the same scope of being declared.
2340 : : */
2341 : :
2342 : : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName);
2343 : :
2344 : : /*
2345 : : IsUnknown - returns true is the symbol Sym is unknown.
2346 : : */
2347 : :
2348 : : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym);
2349 : :
2350 : : /*
2351 : : IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
2352 : : */
2353 : :
2354 : : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym);
2355 : :
2356 : : /*
2357 : : RequestSym - searches for a symbol with a name SymName in the
2358 : : current and previous scopes.
2359 : : If the symbol is found then it is returned
2360 : : else an unknown symbol is returned create at token
2361 : : position, tok.
2362 : : This procedure does search the base scope (for
2363 : : pervasive identifiers).
2364 : : */
2365 : :
2366 : : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName);
2367 : :
2368 : : /*
2369 : : PutImported - places a symbol, Sym, into the current main scope.
2370 : : */
2371 : :
2372 : : extern "C" void SymbolTable_PutImported (unsigned int Sym);
2373 : :
2374 : : /*
2375 : : PutIncluded - places a symbol, Sym, into the included list of the
2376 : : current module.
2377 : : Symbols that are placed in this list are indirectly declared
2378 : : by:
2379 : :
2380 : : IMPORT modulename ;
2381 : :
2382 : : modulename.identifier
2383 : : */
2384 : :
2385 : : extern "C" void SymbolTable_PutIncluded (unsigned int Sym);
2386 : :
2387 : : /*
2388 : : PutExported - places a symbol, Sym into the next level out module.
2389 : : Sym is also placed in the ExportTree of the current inner
2390 : : module.
2391 : : */
2392 : :
2393 : : extern "C" void SymbolTable_PutExported (unsigned int Sym);
2394 : :
2395 : : /*
2396 : : PutExportQualified - places a symbol with the name, SymName,
2397 : : into the export tree of the
2398 : : Definition module being compiled.
2399 : : The symbol with name has been EXPORT QUALIFIED
2400 : : by the definition module and therefore any reference
2401 : : to this symbol in the code generation phase
2402 : : will be in the form _Module_Name.
2403 : : */
2404 : :
2405 : : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName);
2406 : :
2407 : : /*
2408 : : PutExportUnQualified - places a symbol with the name, SymName,
2409 : : into the export tree of the
2410 : : Definition module being compiled.
2411 : : The symbol with Name has been EXPORT UNQUALIFIED
2412 : : by the definition module and therefore any reference
2413 : : to this symbol in the code generation phase
2414 : : will be in the form _Name.
2415 : : */
2416 : :
2417 : : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName);
2418 : :
2419 : : /*
2420 : : PutExportUnImplemented - places a symbol, Sym, into the currently compiled
2421 : : DefImp module NeedToBeImplemented list.
2422 : : */
2423 : :
2424 : : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym);
2425 : :
2426 : : /*
2427 : : GetExported - returns the symbol which has a name SymName,
2428 : : and is exported from the definition module ModSym.
2429 : :
2430 : : */
2431 : :
2432 : : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName);
2433 : :
2434 : : /*
2435 : : GetFromOuterModule - returns a symbol with name, SymName, which comes
2436 : : from outside the current module.
2437 : : */
2438 : :
2439 : : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName);
2440 : :
2441 : : /*
2442 : : TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
2443 : : name, name, which is
2444 : : currently undefined in the
2445 : : outer scope to the inner scope.
2446 : : If successful then the symbol is
2447 : : returned otherwise NulSym is
2448 : : returned.
2449 : : */
2450 : :
2451 : : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name);
2452 : :
2453 : : /*
2454 : : IsExportQualified - returns true if a symbol, Sym, was defined as
2455 : : being EXPORT QUALIFIED.
2456 : : Sym is expected to be either a procedure or a
2457 : : variable.
2458 : : */
2459 : :
2460 : : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym);
2461 : :
2462 : : /*
2463 : : IsExportUnQualified - returns true if a symbol, Sym, was defined as
2464 : : being EXPORT UNQUALIFIED.
2465 : : */
2466 : :
2467 : : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym);
2468 : :
2469 : : /*
2470 : : IsExported - returns true if a symbol, Sym, is exported
2471 : : from module, ModSym.
2472 : : If ModSym is a DefImp symbol then its
2473 : : ExportQualified and ExportUnQualified lists are examined.
2474 : : */
2475 : :
2476 : : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym);
2477 : :
2478 : : /*
2479 : : IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
2480 : : ModSym must be a defimp symbol.
2481 : : */
2482 : :
2483 : : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym);
2484 : :
2485 : : /*
2486 : : IsImported - returns true if a symbol, Sym, in module, ModSym,
2487 : : was imported.
2488 : : */
2489 : :
2490 : : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym);
2491 : :
2492 : : /*
2493 : : PutIncludedByDefinition - places a module symbol, Sym, into the
2494 : : included list of the current definition module.
2495 : : */
2496 : :
2497 : : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym);
2498 : :
2499 : : /*
2500 : : IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
2501 : : by ModSym's definition module.
2502 : : */
2503 : :
2504 : : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym);
2505 : :
2506 : : /*
2507 : : ForeachImportedDo - calls a procedure, P, foreach imported symbol
2508 : : in module, ModSym.
2509 : : */
2510 : :
2511 : : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2512 : :
2513 : : /*
2514 : : ForeachExportedDo - calls a procedure, P, foreach imported symbol
2515 : : in module, ModSym.
2516 : : */
2517 : :
2518 : : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2519 : :
2520 : : /*
2521 : : CheckForExportedImplementation - checks to see whether an implementation
2522 : : module is currently being compiled, if so,
2523 : : symbol, Sym, is removed from the
2524 : : NeedToBeImplemented list.
2525 : : This procedure is called whenever a symbol
2526 : : is declared, thus attempting to reduce
2527 : : the NeedToBeImplemented list.
2528 : : Only needs to be called when a TYPE or
2529 : : PROCEDURE is built since the implementation
2530 : : module can only implement these objects
2531 : : declared in the definition module.
2532 : :
2533 : : It also checks whether a definition module
2534 : : is currently being compiled and, if so,
2535 : : it will ensure that symbol, Sym, is removed
2536 : : from the ExportRequest list. If Sym is an
2537 : : enumerated type it ensures that its fields
2538 : : are also removed.
2539 : : */
2540 : :
2541 : : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym);
2542 : :
2543 : : /*
2544 : : CheckForUnImplementedExports - displays an error and the offending symbols
2545 : : which have been exported but not implemented
2546 : : from the current compiled module.
2547 : : */
2548 : :
2549 : : extern "C" void SymbolTable_CheckForUnImplementedExports (void);
2550 : :
2551 : : /*
2552 : : CheckForUndeclaredExports - displays an error and the offending symbols
2553 : : which have been exported but not declared
2554 : : from module, ModSym.
2555 : : */
2556 : :
2557 : : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym);
2558 : :
2559 : : /*
2560 : : CheckForUnknownInModule - checks for any unknown symbols in the
2561 : : current module.
2562 : : If any unknown symbols are found then
2563 : : an error message is displayed.
2564 : : */
2565 : :
2566 : : extern "C" void SymbolTable_CheckForUnknownInModule (unsigned int tokno);
2567 : :
2568 : : /*
2569 : : UnknownReported - if sym is an unknown symbol and has not been reported
2570 : : then include it into the set of reported unknowns.
2571 : : */
2572 : :
2573 : : extern "C" void SymbolTable_UnknownReported (unsigned int sym);
2574 : :
2575 : : /*
2576 : : GetUnknownOnImport - returns the onimport field of unknown sym.
2577 : : */
2578 : :
2579 : : extern "C" bool SymbolTable_GetUnknownOnImport (unsigned int sym);
2580 : :
2581 : : /*
2582 : : GetUnknownDeclScope - returns the decl scope of unknown sym.
2583 : : */
2584 : :
2585 : : extern "C" unsigned int SymbolTable_GetUnknownDeclScope (unsigned int sym);
2586 : :
2587 : : /*
2588 : : IsReallyPointer - returns TRUE is sym is a pointer, address or a
2589 : : type declared as a pointer or address.
2590 : : */
2591 : :
2592 : : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym);
2593 : :
2594 : : /*
2595 : : CheckHiddenTypeAreAddress - checks to see that any hidden types
2596 : : which we have declared are actually
2597 : : of type ADDRESS or map onto a POINTER type.
2598 : : */
2599 : :
2600 : : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void);
2601 : :
2602 : : /*
2603 : : PutDefinitionForC - sets a flag in the current compiled module which
2604 : : indicates that this module is a wrapper for a C
2605 : : file. Parameters passes to procedures in this module
2606 : : will adopt the C calling convention.
2607 : : */
2608 : :
2609 : : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym);
2610 : :
2611 : : /*
2612 : : IsDefinitionForC - returns true if this definition module was declared
2613 : : as a DEFINITION MODULE FOR "C".
2614 : : */
2615 : :
2616 : : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym);
2617 : :
2618 : : /*
2619 : : PutDoesNeedExportList - sets a flag in module, Sym, which
2620 : : indicates that this module requires an explicit
2621 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
2622 : : */
2623 : :
2624 : : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym);
2625 : :
2626 : : /*
2627 : : PutDoesNotNeedExportList - sets a flag in module, Sym, which
2628 : : indicates that this module does not require an explicit
2629 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
2630 : : */
2631 : :
2632 : : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym);
2633 : :
2634 : : /*
2635 : : DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
2636 : : EXPORT QUALIFIED list.
2637 : : */
2638 : :
2639 : : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym);
2640 : :
2641 : : /*
2642 : : CheckForEnumerationInCurrentModule - checks to see whether the enumeration
2643 : : type symbol, Sym, has been entered into
2644 : : the current modules scope list.
2645 : : */
2646 : :
2647 : : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym);
2648 : :
2649 : : /*
2650 : : SanityCheckConstants - must only be called once all constants, types, procedures
2651 : : have been declared. It checks to see that constants are
2652 : : not used as procedure parameter types.
2653 : : */
2654 : :
2655 : : extern "C" void SymbolTable_SanityCheckConstants (void);
2656 : :
2657 : : /*
2658 : : ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
2659 : : perform the procedure, P.
2660 : : */
2661 : :
2662 : : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2663 : :
2664 : : /*
2665 : : ForeachParamSymDo - foreach parameter symbol in procedure Sym
2666 : : perform the procedure P. Each symbol
2667 : : looked up will be VarParam or Param
2668 : : (not the shadow variable). Every parameter
2669 : : from each KindProcedure is iterated over.
2670 : : */
2671 : :
2672 : : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2673 : :
2674 : : /*
2675 : : ForeachFieldEnumerationDo - for each field in enumeration, Sym,
2676 : : do procedure, P. Each call to P contains
2677 : : an enumeration field, the order is alphabetical.
2678 : : Use ForeachLocalSymDo for declaration order.
2679 : : */
2680 : :
2681 : : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P);
2682 : :
2683 : : /*
2684 : : IsType - returns true if the Sym is a type symbol.
2685 : : */
2686 : :
2687 : : extern "C" bool SymbolTable_IsType (unsigned int Sym);
2688 : :
2689 : : /*
2690 : : IsProcedure - returns true if Sym is a procedure symbol.
2691 : : */
2692 : :
2693 : : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym);
2694 : :
2695 : : /*
2696 : : IsParameter - returns true if Sym is a parameter symbol.
2697 : : */
2698 : :
2699 : : extern "C" bool SymbolTable_IsParameter (unsigned int Sym);
2700 : :
2701 : : /*
2702 : : GetProcedureKind - returns the procedure kind given the declaration tok.
2703 : : The declaration tok must match the ident tok in the
2704 : : procedure name. It is only safe to call this
2705 : : procedure function during pass 2 onwards.
2706 : : */
2707 : :
2708 : : extern "C" SymbolTable_ProcedureKind SymbolTable_GetProcedureKind (unsigned int sym, unsigned int tok);
2709 : :
2710 : : /*
2711 : : GetProcedureDeclaredTok - return the token where the
2712 : : declaration of procedure sym:kind
2713 : : occurred.
2714 : : */
2715 : :
2716 : : extern "C" unsigned int SymbolTable_GetProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind);
2717 : :
2718 : : /*
2719 : : PutProcedureDeclaredTok - places the tok where the
2720 : : declaration of procedure sym:kind
2721 : : occurred.
2722 : : */
2723 : :
2724 : : extern "C" void SymbolTable_PutProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok);
2725 : :
2726 : : /*
2727 : : GetReturnTypeTok - return the token where the
2728 : : return type procedure sym:kind or proctype
2729 : : was defined.
2730 : : */
2731 : :
2732 : : extern "C" unsigned int SymbolTable_GetReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind);
2733 : :
2734 : : /*
2735 : : PutReturnTypeTok - places the tok where the
2736 : : return type of procedure sym:kind or proctype
2737 : : was defined.
2738 : : */
2739 : :
2740 : : extern "C" void SymbolTable_PutReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok);
2741 : :
2742 : : /*
2743 : : PutProcedureParametersDefined - the procedure symbol sym:kind
2744 : : parameters have been defined.
2745 : : */
2746 : :
2747 : : extern "C" void SymbolTable_PutProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2748 : :
2749 : : /*
2750 : : GetProcedureParametersDefined - returns true if procedure symbol sym:kind
2751 : : parameters are defined.
2752 : : */
2753 : :
2754 : : extern "C" bool SymbolTable_GetProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2755 : :
2756 : : /*
2757 : : PutProcedureDefined - the procedure symbol sym:kind is defined.
2758 : : */
2759 : :
2760 : : extern "C" void SymbolTable_PutProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2761 : :
2762 : : /*
2763 : : GetProcedureDefined - returns true if procedure symbol sym:kind
2764 : : is defined.
2765 : : */
2766 : :
2767 : : extern "C" bool SymbolTable_GetProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2768 : :
2769 : : /*
2770 : : PutUseVarArgs - tell the symbol table that this procedure, Sym,
2771 : : uses varargs.
2772 : : The procedure _must_ be declared inside a
2773 : : DEFINITION FOR "C"
2774 : :
2775 : : */
2776 : :
2777 : : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym);
2778 : :
2779 : : /*
2780 : : UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
2781 : : The procedure _must_ be declared inside a
2782 : : DEFINITION FOR "C"
2783 : : */
2784 : :
2785 : : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym);
2786 : :
2787 : : /*
2788 : : PutUseOptArg - tell the symbol table that this procedure, Sym,
2789 : : uses an optarg.
2790 : : */
2791 : :
2792 : : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind);
2793 : :
2794 : : /*
2795 : : UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
2796 : : */
2797 : :
2798 : : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind);
2799 : :
2800 : : /*
2801 : : PutOptArgInit - makes symbol, Sym, the initializer value to
2802 : : procedure, ProcSym.
2803 : : */
2804 : :
2805 : : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym);
2806 : :
2807 : : /*
2808 : : GetOptArgInit - returns the initializer value to the optional parameter in
2809 : : procedure, ProcSym.
2810 : : */
2811 : :
2812 : : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym);
2813 : :
2814 : : /*
2815 : : MakePointer - returns a pointer symbol with PointerName.
2816 : : */
2817 : :
2818 : : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName);
2819 : :
2820 : : /*
2821 : : PutPointer - gives a pointer symbol a type, PointerType.
2822 : : */
2823 : :
2824 : : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType);
2825 : :
2826 : : /*
2827 : : IsPointer - returns true is Sym is a pointer type symbol.
2828 : : */
2829 : :
2830 : : extern "C" bool SymbolTable_IsPointer (unsigned int Sym);
2831 : :
2832 : : /*
2833 : : IsRecord - returns true is Sym is a record type symbol.
2834 : : */
2835 : :
2836 : : extern "C" bool SymbolTable_IsRecord (unsigned int Sym);
2837 : :
2838 : : /*
2839 : : IsVarient - returns true if the symbol, Sym, is a
2840 : : varient symbol.
2841 : : */
2842 : :
2843 : : extern "C" bool SymbolTable_IsVarient (unsigned int Sym);
2844 : :
2845 : : /*
2846 : : IsFieldVarient - returns true if the symbol, Sym, is a
2847 : : varient field.
2848 : : */
2849 : :
2850 : : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym);
2851 : :
2852 : : /*
2853 : : IsFieldEnumeration - returns true if the symbol, Sym, is an
2854 : : enumeration field.
2855 : : */
2856 : :
2857 : : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym);
2858 : :
2859 : : /*
2860 : : IsArray - returns true is Sym is an array type symbol.
2861 : : */
2862 : :
2863 : : extern "C" bool SymbolTable_IsArray (unsigned int Sym);
2864 : :
2865 : : /*
2866 : : IsEnumeration - returns true if Sym is an enumeration symbol.
2867 : : */
2868 : :
2869 : : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym);
2870 : :
2871 : : /*
2872 : : IsSet - returns TRUE if Sym is a set symbol.
2873 : : */
2874 : :
2875 : : extern "C" bool SymbolTable_IsSet (unsigned int Sym);
2876 : :
2877 : : /*
2878 : : IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
2879 : : */
2880 : :
2881 : : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym);
2882 : :
2883 : : /*
2884 : : IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
2885 : : */
2886 : :
2887 : : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym);
2888 : :
2889 : : /*
2890 : : GetDimension - return the number of dimensions associated with
2891 : : this unbounded ARRAY parameter.
2892 : : */
2893 : :
2894 : : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym);
2895 : :
2896 : : /*
2897 : : MakeOAFamily - makes an OAFamily symbol based on SimpleType.
2898 : : It returns the OAFamily symbol. A new symbol
2899 : : is created if one does not already exist for
2900 : : SimpleType.
2901 : : */
2902 : :
2903 : : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType);
2904 : :
2905 : : /*
2906 : : GetOAFamily - returns the oafamily symbol associated with
2907 : : SimpleType.
2908 : : */
2909 : :
2910 : : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType);
2911 : :
2912 : : /*
2913 : : ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
2914 : : sym, in the oaf.
2915 : : */
2916 : :
2917 : : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p);
2918 : :
2919 : : /*
2920 : : IsUnbounded - returns true if Sym is an unbounded symbol.
2921 : : */
2922 : :
2923 : : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym);
2924 : :
2925 : : /*
2926 : : GetUnbounded - returns the unbounded symbol associated with
2927 : : the OAFamily symbol, oaf, and the number of
2928 : : dimensions, ndim, of the open array.
2929 : : */
2930 : :
2931 : : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim);
2932 : :
2933 : : /*
2934 : : GetUnboundedRecordType - returns the record type used to
2935 : : implement the unbounded array.
2936 : : */
2937 : :
2938 : : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym);
2939 : :
2940 : : /*
2941 : : GetUnboundedAddressOffset - returns the offset of the address field
2942 : : inside the record used to implement the
2943 : : unbounded type.
2944 : : */
2945 : :
2946 : : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym);
2947 : :
2948 : : /*
2949 : : GetUnboundedHighOffset - returns the offset of the high field
2950 : : inside the record used to implement the
2951 : : unbounded type.
2952 : : */
2953 : :
2954 : : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim);
2955 : :
2956 : : /*
2957 : : MakeSubscript - makes a subscript Symbol.
2958 : : No name is required.
2959 : : */
2960 : :
2961 : : extern "C" unsigned int SymbolTable_MakeSubscript (void);
2962 : :
2963 : : /*
2964 : : PutSubscript - gives a subscript symbol a type, SimpleType.
2965 : : */
2966 : :
2967 : : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType);
2968 : :
2969 : : /*
2970 : : MakeUnbounded - makes an unbounded array Symbol.
2971 : : ndim is the number of dimensions required.
2972 : : No name is required.
2973 : : */
2974 : :
2975 : : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim);
2976 : :
2977 : : /*
2978 : : NoOfElements - Returns the number of elements in array Sym,
2979 : : or the number of elements in an enumeration Sym or
2980 : : the number of interface symbols in an Interface list.
2981 : : */
2982 : :
2983 : : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym);
2984 : :
2985 : : /*
2986 : : PutArray - places a type symbol into an arraysym.
2987 : : */
2988 : :
2989 : : extern "C" void SymbolTable_PutArray (unsigned int arraysym, unsigned int typesym);
2990 : :
2991 : : /*
2992 : : ResolveImports - it examines the import list of all inner modules
2993 : : and resolves all relative imports.
2994 : : */
2995 : :
2996 : : extern "C" void SymbolTable_ResolveImports (void);
2997 : :
2998 : : /*
2999 : : ResolveConstructorTypes - to be called at the end of pass three. Its
3000 : : purpose is to fix up all constructors whose
3001 : : types are unknown.
3002 : : */
3003 : :
3004 : : extern "C" void SymbolTable_ResolveConstructorTypes (void);
3005 : :
3006 : : /*
3007 : : AddNameToScope - adds a Name, n, to the list of objects declared at the
3008 : : current scope.
3009 : : */
3010 : :
3011 : : extern "C" void SymbolTable_AddNameToScope (unsigned int tok, NameKey_Name n);
3012 : :
3013 : : /*
3014 : : AddNameToImportList - adds a Name, n, to the import list of the current
3015 : : module.
3016 : : */
3017 : :
3018 : : extern "C" void SymbolTable_AddNameToImportList (unsigned int tok, NameKey_Name n);
3019 : :
3020 : : /*
3021 : : GetScope - returns the declaration scope of the symbol.
3022 : : */
3023 : :
3024 : : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym);
3025 : :
3026 : : /*
3027 : : GetModuleScope - returns the module scope of symbol, sym.
3028 : : If sym was declared within a nested procedure
3029 : : then return the module which defines the
3030 : : procedure.
3031 : : */
3032 : :
3033 : : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym);
3034 : :
3035 : : /*
3036 : : GetProcedureScope - returns the innermost procedure (if any)
3037 : : in which the symbol, sym, resides.
3038 : : A module inside the procedure is skipped
3039 : : over.
3040 : : */
3041 : :
3042 : : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym);
3043 : :
3044 : : /*
3045 : : IsModuleWithinProcedure - returns TRUE if module, sym, is
3046 : : inside a procedure.
3047 : : */
3048 : :
3049 : : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym);
3050 : :
3051 : : /*
3052 : : GetParent - returns the parent of symbol, Sym.
3053 : : */
3054 : :
3055 : : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym);
3056 : :
3057 : : /*
3058 : : IsRecordField - returns true if Sym is a record field.
3059 : : */
3060 : :
3061 : : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym);
3062 : :
3063 : : /*
3064 : : MakeProcType - returns a procedure type symbol with ProcTypeName.
3065 : : */
3066 : :
3067 : : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName);
3068 : :
3069 : : /*
3070 : : PutProcTypeParam - Places a Non VAR parameter ParamName with type
3071 : : ParamType into ProcType Sym.
3072 : : */
3073 : :
3074 : : extern "C" void SymbolTable_PutProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded);
3075 : :
3076 : : /*
3077 : : PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
3078 : : ParamType into ProcType Sym.
3079 : : */
3080 : :
3081 : : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded);
3082 : :
3083 : : /*
3084 : : IsProcType - returns true if Sym is a ProcType Symbol.
3085 : : */
3086 : :
3087 : : extern "C" bool SymbolTable_IsProcType (unsigned int Sym);
3088 : :
3089 : : /*
3090 : : IsVar - returns true if Sym is a Var Symbol.
3091 : : */
3092 : :
3093 : : extern "C" bool SymbolTable_IsVar (unsigned int Sym);
3094 : :
3095 : : /*
3096 : : IsVarConst - returns the IsConst field indicating the variable is read only.
3097 : : */
3098 : :
3099 : : extern "C" bool SymbolTable_IsVarConst (unsigned int sym);
3100 : :
3101 : : /*
3102 : : IsConst - returns true if Sym contains a constant value.
3103 : : */
3104 : :
3105 : : extern "C" bool SymbolTable_IsConst (unsigned int Sym);
3106 : :
3107 : : /*
3108 : : IsConstString - returns whether sym is a conststring of any variant.
3109 : : */
3110 : :
3111 : : extern "C" bool SymbolTable_IsConstString (unsigned int sym);
3112 : :
3113 : : /*
3114 : : IsConstStringNulTerminated - returns TRUE if the constant string, sym,
3115 : : should be created with a nul terminator.
3116 : : */
3117 : :
3118 : : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym);
3119 : :
3120 : : /*
3121 : : IsConstLit - returns true if Sym is a literal constant.
3122 : : */
3123 : :
3124 : : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym);
3125 : :
3126 : : /*
3127 : : IsConstructor - returns TRUE if the constant is declared as a
3128 : : constant set, array or record.
3129 : : */
3130 : :
3131 : : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym);
3132 : :
3133 : : /*
3134 : : IsDummy - returns true if Sym is a Dummy symbol.
3135 : : */
3136 : :
3137 : : extern "C" bool SymbolTable_IsDummy (unsigned int Sym);
3138 : :
3139 : : /*
3140 : : IsTemporary - returns true if Sym is a Temporary symbol.
3141 : : */
3142 : :
3143 : : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym);
3144 : :
3145 : : /*
3146 : : IsVarAParam - returns true if Sym is a variable declared as a parameter.
3147 : : */
3148 : :
3149 : : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym);
3150 : :
3151 : : /*
3152 : : IsSubscript - returns true if Sym is a subscript symbol.
3153 : : */
3154 : :
3155 : : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym);
3156 : :
3157 : : /*
3158 : : IsSubrange - returns true if Sym is a subrange symbol.
3159 : : */
3160 : :
3161 : : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym);
3162 : :
3163 : : /*
3164 : : IsProcedureVariable - returns true if a Sym is a variable and
3165 : : it was declared within a procedure.
3166 : : */
3167 : :
3168 : : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym);
3169 : :
3170 : : /*
3171 : : IsProcedureNested - returns TRUE if procedure, Sym, was
3172 : : declared as a nested procedure.
3173 : : */
3174 : :
3175 : : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym);
3176 : :
3177 : : /*
3178 : : IsAModula2Type - returns true if Sym, is a:
3179 : : IsType, IsPointer, IsRecord, IsEnumeration,
3180 : : IsSubrange, IsArray, IsUnbounded, IsProcType.
3181 : : NOTE that it different from IsType.
3182 : : */
3183 : :
3184 : : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym);
3185 : :
3186 : : /*
3187 : : IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
3188 : : */
3189 : :
3190 : : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym);
3191 : :
3192 : : /*
3193 : : IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
3194 : : */
3195 : :
3196 : : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym);
3197 : :
3198 : : /*
3199 : : IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
3200 : : */
3201 : :
3202 : : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym);
3203 : :
3204 : : /*
3205 : : IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
3206 : : */
3207 : :
3208 : : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym);
3209 : :
3210 : : /*
3211 : : IsSizeSolved - returns true if the size of Sym is solved.
3212 : : */
3213 : :
3214 : : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym);
3215 : :
3216 : : /*
3217 : : IsOffsetSolved - returns true if the Offset of Sym is solved.
3218 : : */
3219 : :
3220 : : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym);
3221 : :
3222 : : /*
3223 : : IsValueSolved - returns true if the value of Sym is solved.
3224 : : */
3225 : :
3226 : : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym);
3227 : :
3228 : : /*
3229 : : IsConstructorConstant - returns TRUE if constructor, Sym, is
3230 : : defined by only constants.
3231 : : */
3232 : :
3233 : : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym);
3234 : :
3235 : : /*
3236 : : IsComposite - returns TRUE if symbol, sym, is a composite
3237 : : type: ie an ARRAY or RECORD.
3238 : : */
3239 : :
3240 : : extern "C" bool SymbolTable_IsComposite (unsigned int sym);
3241 : :
3242 : : /*
3243 : : IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
3244 : : */
3245 : :
3246 : : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym);
3247 : :
3248 : : /*
3249 : : PutAlignment - assigns the alignment constant associated with,
3250 : : type, with, align.
3251 : : */
3252 : :
3253 : : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align);
3254 : :
3255 : : /*
3256 : : GetAlignment - returns the alignment constant associated with,
3257 : : type.
3258 : : */
3259 : :
3260 : : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type);
3261 : :
3262 : : /*
3263 : : GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
3264 : : to record, sym.
3265 : : */
3266 : :
3267 : : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym);
3268 : :
3269 : : /*
3270 : : PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
3271 : : to record, sym.
3272 : : */
3273 : :
3274 : : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align);
3275 : :
3276 : : /*
3277 : : PutUnused - sets, sym, as unused. This is a gm2 pragma.
3278 : : */
3279 : :
3280 : : extern "C" void SymbolTable_PutUnused (unsigned int sym);
3281 : :
3282 : : /*
3283 : : IsUnused - returns TRUE if the symbol was declared as unused with a
3284 : : gm2 pragma.
3285 : : */
3286 : :
3287 : : extern "C" bool SymbolTable_IsUnused (unsigned int sym);
3288 : :
3289 : : /*
3290 : : PutDeclaredPacked - sets the Packed field of the record or record field symbol.
3291 : : */
3292 : :
3293 : : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b);
3294 : :
3295 : : /*
3296 : : IsDeclaredPacked - was the record symbol or record field, sym,
3297 : : declared as packed?
3298 : : */
3299 : :
3300 : : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym);
3301 : :
3302 : : /*
3303 : : IsDeclaredPackedResolved - do we know if the record symbol or record
3304 : : field, sym, declared as packed or not packed?
3305 : : */
3306 : :
3307 : : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym);
3308 : :
3309 : : /*
3310 : : GetPackedEquivalent - returns the packed equivalent of type, sym.
3311 : : sym must be a type, subrange or enumerated type.
3312 : : */
3313 : :
3314 : : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym);
3315 : :
3316 : : /*
3317 : : GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
3318 : : */
3319 : :
3320 : : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym);
3321 : :
3322 : : /*
3323 : : IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
3324 : : */
3325 : :
3326 : : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym);
3327 : :
3328 : : /*
3329 : : PushSize - pushes the size of Sym.
3330 : : */
3331 : :
3332 : : extern "C" void SymbolTable_PushSize (unsigned int Sym);
3333 : :
3334 : : /*
3335 : : PopSize - pops the ALU stack into Size of Sym.
3336 : : */
3337 : :
3338 : : extern "C" void SymbolTable_PopSize (unsigned int Sym);
3339 : :
3340 : : /*
3341 : : PushValue - pushes the Value of Sym onto the ALU stack.
3342 : : */
3343 : :
3344 : : extern "C" void SymbolTable_PushValue (unsigned int Sym);
3345 : :
3346 : : /*
3347 : : PushVarSize - pushes the size of a variable, Sym.
3348 : : The runtime size of Sym will depend upon its addressing mode,
3349 : : RightValue has size PushSize(GetType(Sym)) and
3350 : : LeftValue has size PushSize(Address) since it points to a
3351 : : variable.
3352 : : */
3353 : :
3354 : : extern "C" void SymbolTable_PushVarSize (unsigned int Sym);
3355 : :
3356 : : /*
3357 : : PopValue - pops the ALU stack into Value of Sym.
3358 : : */
3359 : :
3360 : : extern "C" void SymbolTable_PopValue (unsigned int Sym);
3361 : :
3362 : : /*
3363 : : IsObject - returns TRUE if the symbol is an object symbol.
3364 : : */
3365 : :
3366 : : extern "C" bool SymbolTable_IsObject (unsigned int Sym);
3367 : :
3368 : : /*
3369 : : IsTuple - returns TRUE if the symbol is a tuple symbol.
3370 : : */
3371 : :
3372 : : extern "C" bool SymbolTable_IsTuple (unsigned int Sym);
3373 : :
3374 : : /*
3375 : : Make2Tuple - creates and returns a 2 tuple from, a, and, b.
3376 : : */
3377 : :
3378 : : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b);
3379 : :
3380 : : /*
3381 : : MakeError - creates an error node, which can be used in MetaError messages.
3382 : : It will be removed from ExportUndeclared and Unknown trees.
3383 : : */
3384 : :
3385 : : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name);
3386 : :
3387 : : /*
3388 : : MakeErrorS - creates an error node from a string, which can be used
3389 : : in MetaError messages.
3390 : : It will be removed from ExportUndeclared and Unknown trees.
3391 : : */
3392 : :
3393 : : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name);
3394 : :
3395 : : /*
3396 : : IsError - returns TRUE if the symbol is an error symbol.
3397 : : */
3398 : :
3399 : : extern "C" bool SymbolTable_IsError (unsigned int Sym);
3400 : :
3401 : : /*
3402 : : IsLegal - returns TRUE if, sym, is a legal symbol.
3403 : : */
3404 : :
3405 : : extern "C" bool SymbolTable_IsLegal (unsigned int sym);
3406 : :
3407 : : /*
3408 : : PutModuleContainsBuiltin - sets a flag in the current compiled module which
3409 : : indicates that a builtin procedure is being declared.
3410 : : This is only expected to be called when we are
3411 : : parsing the definition module.
3412 : : */
3413 : :
3414 : : extern "C" void SymbolTable_PutModuleContainsBuiltin (void);
3415 : :
3416 : : /*
3417 : : IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
3418 : : */
3419 : :
3420 : : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym);
3421 : :
3422 : : /*
3423 : : PutHiddenTypeDeclared - sets a flag in the current compiled module which
3424 : : indicates that a Hidden Type is declared within
3425 : : the implementation part of the module.
3426 : : This procedure is expected to be called while
3427 : : compiling the associated definition module.
3428 : : */
3429 : :
3430 : : extern "C" void SymbolTable_PutHiddenTypeDeclared (void);
3431 : :
3432 : : /*
3433 : : IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
3434 : : the module, Sym.
3435 : : */
3436 : :
3437 : : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym);
3438 : :
3439 : : /*
3440 : : IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
3441 : : type declared as a pointer or address.
3442 : : */
3443 : :
3444 : : extern "C" bool SymbolTable_IsHiddenReallyPointer (unsigned int Sym);
3445 : :
3446 : : /*
3447 : : DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
3448 : : */
3449 : :
3450 : : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym);
3451 : :
3452 : : /*
3453 : : DebugLineNumbers - internal debugging, emit all procedure names in this module
3454 : : together with the line numbers for the corresponding begin/end
3455 : : tokens.
3456 : : */
3457 : :
3458 : : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym);
3459 : :
3460 : : /*
3461 : : GetErrorScope - returns the error scope for a symbol.
3462 : : The error scope is the title scope which is used to
3463 : : announce the symbol in the GCC error message.
3464 : : */
3465 : :
3466 : : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym);
3467 : :
3468 : : /*
3469 : : MakeImport - create and return an import symbol.
3470 : : moduleSym is the symbol being imported.
3471 : : isqualified is FALSE if it were IMPORT modulename and
3472 : : TRUE for the qualified FROM modulename IMPORT etc.
3473 : : listno is the import list count for this module.
3474 : : tok should match this modulename position.
3475 : : */
3476 : :
3477 : : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified);
3478 : :
3479 : : /*
3480 : : MakeImportStatement - return a dependent symbol which represents an import statement
3481 : : or a qualified import statement. The tok should either match
3482 : : the FROM token or the IMPORT token. listno is the import list
3483 : : count for the module.
3484 : : */
3485 : :
3486 : : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno);
3487 : :
3488 : : /*
3489 : : IsImport - returns TRUE if sym is an import symbol.
3490 : : */
3491 : :
3492 : : extern "C" bool SymbolTable_IsImport (unsigned int sym);
3493 : :
3494 : : /*
3495 : : IsImportStatement - returns TRUE if sym is a dependent symbol.
3496 : : */
3497 : :
3498 : : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym);
3499 : :
3500 : : /*
3501 : : GetImportModule - returns the module associated with the import symbol.
3502 : : */
3503 : :
3504 : : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym);
3505 : :
3506 : : /*
3507 : : GetImportDeclared - returns the token associated with the import symbol.
3508 : : */
3509 : :
3510 : : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym);
3511 : :
3512 : : /*
3513 : : GetImportStatementList - returns the list of imports for this dependent.
3514 : : Each import symbol corresponds to a module.
3515 : : */
3516 : :
3517 : : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym);
3518 : :
3519 : : /*
3520 : : GetModuleDefImportStatementList - returns the list of dependents associated with
3521 : : the definition module.
3522 : : */
3523 : :
3524 : : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym);
3525 : :
3526 : : /*
3527 : : GetModuleModImportStatementList - returns the list of dependents associated with
3528 : : the implementation or program module.
3529 : : */
3530 : :
3531 : : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym);
3532 : :
3533 : : /*
3534 : : AppendModuleImportStatement - appends the ImportStatement symbol onto the
3535 : : module import list.
3536 : :
3537 : : For example:
3538 : :
3539 : : FROM x IMPORT y, z ;
3540 : : ^^^^
3541 : :
3542 : : also:
3543 : :
3544 : : IMPORT p, q, r;
3545 : : ^^^^^^
3546 : : will result in a new ImportStatement symbol added
3547 : : to the current module import list.
3548 : : The statement symbol is expected to be created
3549 : : by MakeImportStatement using the token positions
3550 : : outlined above.
3551 : : */
3552 : :
3553 : : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement);
3554 : :
3555 : : /*
3556 : : AppendModuleOnImportStatement - appends the import symbol onto the
3557 : : dependent list (chain).
3558 : :
3559 : : For example each:
3560 : :
3561 : : FROM x IMPORT y, z ;
3562 : : ^
3563 : : x are added to the dependent list.
3564 : :
3565 : : also:
3566 : :
3567 : : IMPORT p, q, r;
3568 : : ^ ^ ^
3569 : : will result in p, q and r added to
3570 : : to the dependent list.
3571 : :
3572 : : The import symbol is created by MakeImport
3573 : : and the token is expected to match the module
3574 : : name position outlined above.
3575 : : */
3576 : :
3577 : : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import);
3578 : :
3579 : : /*
3580 : : PutModLink - assigns link to module sym.
3581 : : */
3582 : :
3583 : : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link);
3584 : :
3585 : : /*
3586 : : IsModLink - returns the ModLink value associated with the module symbol.
3587 : : */
3588 : :
3589 : : extern "C" bool SymbolTable_IsModLink (unsigned int sym);
3590 : :
3591 : : /*
3592 : : PutDefLink - assigns link to the definition module sym.
3593 : : */
3594 : :
3595 : : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link);
3596 : :
3597 : : /*
3598 : : IsDefLink - returns the DefLink value associated with the definition module symbol.
3599 : : */
3600 : :
3601 : : extern "C" bool SymbolTable_IsDefLink (unsigned int sym);
3602 : :
3603 : : /*
3604 : : IsModuleBuiltin - returns TRUE if the module is a builtin module.
3605 : : (For example _BaseTypes).
3606 : : */
3607 : :
3608 : : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym);
3609 : :
3610 : : /*
3611 : : PutModuleBuiltin - sets the Builtin flag to value.
3612 : : Currently the procedure expects sym to be a DefImp
3613 : : module only.
3614 : : */
3615 : :
3616 : : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value);
3617 : :
3618 : : /*
3619 : : PutVarArrayRef - assigns ArrayRef field with value.
3620 : : */
3621 : :
3622 : : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value);
3623 : :
3624 : : /*
3625 : : IsVarArrayRef - returns ArrayRef field value.
3626 : : */
3627 : :
3628 : : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym);
3629 : :
3630 : : /*
3631 : : VarCheckReadInit - returns TRUE if sym has been initialized.
3632 : : */
3633 : :
3634 : : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode);
3635 : :
3636 : : /*
3637 : : VarInitState - initializes the init state for variable sym.
3638 : : */
3639 : :
3640 : : extern "C" void SymbolTable_VarInitState (unsigned int sym);
3641 : :
3642 : : /*
3643 : : PutVarInitialized - set sym as initialized.
3644 : : */
3645 : :
3646 : : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode);
3647 : :
3648 : : /*
3649 : : PutVarFieldInitialized - records that field has been initialized with
3650 : : variable sym. TRUE is returned if the field
3651 : : is detected and changed to initialized.
3652 : : */
3653 : :
3654 : : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
3655 : :
3656 : : /*
3657 : : GetVarFieldInitialized - return TRUE if fieldlist has been initialized
3658 : : within variable sym.
3659 : : */
3660 : :
3661 : : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
3662 : :
3663 : : /*
3664 : : PrintInitialized - display variable sym initialization state.
3665 : : */
3666 : :
3667 : : extern "C" void SymbolTable_PrintInitialized (unsigned int sym);
3668 : :
3669 : : /*
3670 : : GetParameterHeapVar - return the heap variable associated with the
3671 : : parameter or NulSym.
3672 : : */
3673 : :
3674 : : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym);
3675 : :
3676 : : /*
3677 : : PutProcedureParameterHeapVars - creates heap variables for parameter sym.
3678 : : */
3679 : :
3680 : : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym);
3681 : :
3682 : : /*
3683 : : IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
3684 : : for the target architecture.
3685 : : */
3686 : :
3687 : : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure);
3688 : :
3689 : : /*
3690 : : PutConstLitInternal - marks the sym as being an internal constant.
3691 : : Currently this is used when generating a default
3692 : : BY constant expression during a FOR loop.
3693 : : A constant marked as internal will always pass
3694 : : an expression type check.
3695 : : */
3696 : :
3697 : : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value);
3698 : :
3699 : : /*
3700 : : IsConstLitInternal - returns the value of the IsInternal field within
3701 : : a constant expression.
3702 : : */
3703 : :
3704 : : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym);
3705 : :
3706 : : /*
3707 : : GetVarDeclTypeTok - returns the TypeTok field associate with variable sym.
3708 : : */
3709 : :
3710 : : extern "C" unsigned int SymbolTable_GetVarDeclTypeTok (unsigned int sym);
3711 : :
3712 : : /*
3713 : : PutVarDeclTypeTok - assigns the TypeTok field to typetok.
3714 : : sym can be a variable or parameter.
3715 : : */
3716 : :
3717 : : extern "C" void SymbolTable_PutVarDeclTypeTok (unsigned int sym, unsigned int typetok);
3718 : :
3719 : : /*
3720 : : GetVarDeclTok - returns the TypeTok field associate with variable sym.
3721 : : */
3722 : :
3723 : : extern "C" unsigned int SymbolTable_GetVarDeclTok (unsigned int sym);
3724 : :
3725 : : /*
3726 : : PutVarDeclTok - assigns the VarTok field to typetok.
3727 : : sym can be a variable or parameter.
3728 : : */
3729 : :
3730 : : extern "C" void SymbolTable_PutVarDeclTok (unsigned int sym, unsigned int vartok);
3731 : :
3732 : : /*
3733 : : GetVarDeclFullTok - returns the full virtual token containing var: type.
3734 : : */
3735 : :
3736 : : extern "C" unsigned int SymbolTable_GetVarDeclFullTok (unsigned int sym);
3737 : :
3738 : : /*
3739 : : IsProcedureAnyNoReturn - return TRUE if any of the defined kinds
3740 : : of procedure sym is declared no return.
3741 : : */
3742 : :
3743 : : extern "C" bool SymbolTable_IsProcedureAnyNoReturn (unsigned int sym);
3744 : :
3745 : : /*
3746 : : GetNthParamAny - returns the nth parameter from the order
3747 : : proper procedure, forward declaration
3748 : : or definition module procedure.
3749 : : */
3750 : :
3751 : : extern "C" unsigned int SymbolTable_GetNthParamAny (unsigned int sym, unsigned int ParamNo);
3752 : :
3753 : : /*
3754 : : NoOfParamAny - return the number of parameters for sym.
3755 : : */
3756 : :
3757 : : extern "C" unsigned int SymbolTable_NoOfParamAny (unsigned int sym);
3758 : :
3759 : : /*
3760 : : SetReturnOptional - sets the ReturnOptional field in the Procedure:kind or
3761 : : ProcType symboltable entry.
3762 : : */
3763 : :
3764 : : extern "C" void SymbolTable_SetReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind, bool isopt);
3765 : :
3766 : : /*
3767 : : UsesOptArgAny - returns TRUE if procedure Sym:kind uses an optional argument.
3768 : : */
3769 : :
3770 : : extern "C" bool SymbolTable_UsesOptArgAny (unsigned int Sym);
3771 : :
3772 : : /*
3773 : : GetProcedureKindDesc - return a string describing kind.
3774 : : */
3775 : :
3776 : : extern "C" DynamicStrings_String SymbolTable_GetProcedureKindDesc (SymbolTable_ProcedureKind kind);
3777 : :
3778 : : /*
3779 : : GetNthParamAnyClosest - returns the nth parameter from the order
3780 : : proper procedure, forward declaration
3781 : : or definition module procedure.
3782 : : It chooses the parameter which is closest
3783 : : in source terms to currentmodule.
3784 : : The same module will return using the order
3785 : : proper procedure, forward procedure, definition module.
3786 : : Whereas an imported procedure will choose from
3787 : : DefProcedure, ProperProcedure, ForwardProcedure.
3788 : : */
3789 : :
3790 : : extern "C" unsigned int SymbolTable_GetNthParamAnyClosest (unsigned int sym, unsigned int ParamNo, unsigned int currentmodule);
3791 : :
3792 : : /*
3793 : : IsConstVar - returns TRUE if sym is a const var. This is a
3794 : : constant which might be assigned to TRUE or FALSE
3795 : : depending upon the result of the quad stack control flow.
3796 : : Typically used in CONST foo = (a AND b) or similar.
3797 : : This symbol will only be assigned once with a value, but
3798 : : will appear more than once as a designator to an assignment
3799 : : in the quad table. However as the quad table is reduced
3800 : : only one assignment will remain. If after reducing quads
3801 : : two or more assignments remain, then there is an error
3802 : : as sym should not have been declared a constant.
3803 : : */
3804 : :
3805 : : extern "C" bool SymbolTable_IsConstVar (unsigned int sym);
3806 : : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at);
3807 : :
3808 : : /*
3809 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
3810 : : */
3811 : :
3812 : : static void InitWhereDeclared (SymbolTable_Where *at);
3813 : :
3814 : : /*
3815 : : InitWhereFirstUsed - sets the FirstUsed field of record, at.
3816 : : */
3817 : :
3818 : : static void InitWhereFirstUsed (SymbolTable_Where *at);
3819 : :
3820 : : /*
3821 : : InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
3822 : : */
3823 : :
3824 : : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at);
3825 : :
3826 : : /*
3827 : : gdbhook - a debugger convenience hook.
3828 : : */
3829 : :
3830 : : static void gdbhook (void);
3831 : :
3832 : : /*
3833 : : BreakWhenSymCreated - to be called interactively by gdb.
3834 : : */
3835 : :
3836 : : static void BreakWhenSymCreated (unsigned int sym);
3837 : :
3838 : : /*
3839 : : CheckBreak - if sym = BreakSym then call gdbhook.
3840 : : */
3841 : :
3842 : : static void CheckBreak (unsigned int sym);
3843 : :
3844 : : /*
3845 : : NewSym - Sets Sym to a new symbol index.
3846 : : */
3847 : :
3848 : : static void NewSym (unsigned int *sym);
3849 : :
3850 : : /*
3851 : : GetPsym - returns the pointer to, sym.
3852 : : */
3853 : :
3854 : : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym);
3855 : :
3856 : : /*
3857 : : GetPcall - returns the pointer to the CallFrame.
3858 : : */
3859 : :
3860 : : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call);
3861 : :
3862 : : /*
3863 : : DebugProcedureLineNumber -
3864 : : */
3865 : :
3866 : : static void DebugProcedureLineNumber (unsigned int sym);
3867 : :
3868 : : /*
3869 : : PutPartialUnbounded -
3870 : : */
3871 : :
3872 : : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim);
3873 : :
3874 : : /*
3875 : : AlreadyDeclaredError - generate an error message, a, and two areas of code showing
3876 : : the places where the symbols were declared.
3877 : : */
3878 : :
3879 : : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance);
3880 : :
3881 : : /*
3882 : : MakeObject - creates an object node.
3883 : : */
3884 : :
3885 : : static unsigned int MakeObject (unsigned int tok, NameKey_Name name);
3886 : :
3887 : : /*
3888 : : DeclareSym - returns a symbol which was either in the unknown tree or
3889 : : a New symbol, since name is about to be declared.
3890 : : */
3891 : :
3892 : : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name);
3893 : :
3894 : : /*
3895 : : Init - Initializes the data structures and variables in this module.
3896 : : Initialize the trees.
3897 : : */
3898 : :
3899 : : static void Init (void);
3900 : :
3901 : : /*
3902 : : AddSymToUnknown -
3903 : : */
3904 : :
3905 : : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym);
3906 : :
3907 : : /*
3908 : : AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
3909 : : unknown tree.
3910 : : */
3911 : :
3912 : : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym);
3913 : :
3914 : : /*
3915 : : SubSymFromUnknownTree - removes a symbol with name, name, from the
3916 : : unknown tree.
3917 : : */
3918 : :
3919 : : static void SubSymFromUnknownTree (NameKey_Name name);
3920 : :
3921 : : /*
3922 : : GetSymFromUnknownTree - returns a symbol with name, name, from the
3923 : : unknown tree.
3924 : : If no symbol with name is found then NulSym
3925 : : is returned.
3926 : : */
3927 : :
3928 : : static unsigned int GetSymFromUnknownTree (NameKey_Name name);
3929 : :
3930 : : /*
3931 : : ExamineUnresolvedTree - returns a symbol with name, name, from the
3932 : : unresolved tree of module, ModSym.
3933 : : If no symbol with name is found then NulSym
3934 : : is returned.
3935 : : */
3936 : :
3937 : : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
3938 : :
3939 : : /*
3940 : : RemoveFromUnresolvedTree - removes a symbol with name, name, from the
3941 : : unresolved tree of symbol, ScopeSym.
3942 : : */
3943 : :
3944 : : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
3945 : :
3946 : : /*
3947 : : FetchUnknownSym - returns a symbol from the unknown tree if one is
3948 : : available. It also updates the unknown tree.
3949 : : */
3950 : :
3951 : : static unsigned int FetchUnknownSym (NameKey_Name name);
3952 : :
3953 : : /*
3954 : : TransparentScope - returns true is the scope symbol Sym is allowed
3955 : : to look to an outer level for a symbol.
3956 : : ie is the symbol allowed to look to the parent
3957 : : scope for a symbol.
3958 : : */
3959 : :
3960 : : static bool TransparentScope (unsigned int Sym);
3961 : :
3962 : : /*
3963 : : GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
3964 : : the scope before the current module scope.
3965 : : */
3966 : :
3967 : : static unsigned int GetLastModuleOrProcedureScope (void);
3968 : :
3969 : : /*
3970 : : AddSymToScope - adds a symbol Sym with name name to
3971 : : the current scope symbol tree.
3972 : : */
3973 : :
3974 : : static void AddSymToScope (unsigned int Sym, NameKey_Name name);
3975 : :
3976 : : /*
3977 : : PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
3978 : : Procedure symbols enumeration
3979 : : list onto the scope stack.
3980 : : */
3981 : :
3982 : : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym);
3983 : :
3984 : : /*
3985 : : PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
3986 : : scope stack. This list will automatically
3987 : : removed via one call to EndScope which
3988 : : matches the StartScope by which this
3989 : : procedure is invoked.
3990 : : */
3991 : :
3992 : : static void PlaceEnumerationListOntoScope (Lists_List l);
3993 : :
3994 : : /*
3995 : : SetFirstUsed - assigns the FirstUsed field in at to tok providing
3996 : : it has not already been set.
3997 : : */
3998 : :
3999 : : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at);
4000 : :
4001 : : /*
4002 : : PutFirstUsed - sets tok to the first used providing it has not already been set.
4003 : : It also includes the read and write quad into the usage list
4004 : : providing the quad numbers are not 0.
4005 : : */
4006 : :
4007 : : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_);
4008 : :
4009 : : /*
4010 : : CanLookThroughScope - by default this procedure returns TRUE. It only returns
4011 : : FALSE if, throughProcedure, is FALSE and the ScopeSym is
4012 : : a procedure.
4013 : : */
4014 : :
4015 : : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure);
4016 : :
4017 : : /*
4018 : : GetScopeSym - searches the current scope and below, providing that the
4019 : : scopes are transparent, for a symbol with name, name.
4020 : : It only passes over procedure scopes if, throughProcedure,
4021 : : is TRUE.
4022 : : */
4023 : :
4024 : : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure);
4025 : :
4026 : : /*
4027 : : CheckScopeForSym - checks the scope, ScopeSym, for an identifier
4028 : : of name, name. CheckScopeForSym checks for
4029 : : the symbol by the GetLocalSym and also
4030 : : ExamineUnresolvedTree.
4031 : : */
4032 : :
4033 : : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name);
4034 : :
4035 : : /*
4036 : : GetModuleScopeId - returns the scope index to the next module starting
4037 : : at index, Id.
4038 : : Id will either point to a null scope (NulSym) or
4039 : : alternatively point to a Module or DefImp symbol.
4040 : : */
4041 : :
4042 : : static unsigned int GetModuleScopeId (unsigned int Id);
4043 : :
4044 : : /*
4045 : : GetVisibleSym -
4046 : : */
4047 : :
4048 : : static unsigned int GetVisibleSym (NameKey_Name name);
4049 : :
4050 : : /*
4051 : : IsAlreadyDeclaredSym - returns true if Sym has already been declared
4052 : : in the current main scope.
4053 : : */
4054 : :
4055 : : static bool IsAlreadyDeclaredSym (NameKey_Name name);
4056 : :
4057 : : /*
4058 : : GenName - returns a new name consisting of pre, name, post concatenation.
4059 : : */
4060 : :
4061 : : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high);
4062 : :
4063 : : /*
4064 : : InitCtor - initialize the ModuleCtor fields to NulSym.
4065 : : */
4066 : :
4067 : : static void InitCtor (SymbolTable_ModuleCtor *ctor);
4068 : :
4069 : : /*
4070 : : InitCtorFields - initialize the ModuleCtor fields. An inner module has no
4071 : : ctor procedure.
4072 : : */
4073 : :
4074 : : static void InitCtorFields (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym, SymbolTable_ModuleCtor *ctor, NameKey_Name name, bool inner, bool pub);
4075 : :
4076 : : /*
4077 : : CheckTok - checks to see that tok is at a known location. If not
4078 : : it uses GetTokenNo as a fall back.
4079 : : */
4080 : :
4081 : : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high);
4082 : :
4083 : : /*
4084 : : GetLink - returns TRUE if the current module is only used for linkage.
4085 : : */
4086 : :
4087 : : static bool GetLink (void);
4088 : :
4089 : : /*
4090 : : AddModuleToParent - adds symbol, Sym, to module, Parent.
4091 : : */
4092 : :
4093 : : static void AddModuleToParent (unsigned int Sym, unsigned int Parent);
4094 : :
4095 : : /*
4096 : : PutProcedureExternPublic - if procedure is not NulSym set extern
4097 : : and public booleans.
4098 : : */
4099 : :
4100 : : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub);
4101 : :
4102 : : /*
4103 : : PutCtorExtern -
4104 : : */
4105 : :
4106 : : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_);
4107 : :
4108 : : /*
4109 : : InitProcedureDeclaration - initialize all the ProcedureDeclaration
4110 : : fields.
4111 : : */
4112 : :
4113 : : static void InitProcedureDeclaration (SymbolTable_ProcedureDeclaration *decl);
4114 : :
4115 : : /*
4116 : : AddProcedureToList - adds a procedure, Proc, to the list of procedures
4117 : : in module, Mod.
4118 : : */
4119 : :
4120 : : static void AddProcedureToList (unsigned int Mod, unsigned int Proc);
4121 : :
4122 : : /*
4123 : : AddVarToScopeList - adds symbol, sym, to, scope.
4124 : : */
4125 : :
4126 : : static void AddVarToScopeList (unsigned int scope, unsigned int sym);
4127 : :
4128 : : /*
4129 : : AddVarToList - add a variable symbol to the list of variables maintained
4130 : : by the inner most scope. (Procedure or Module).
4131 : : */
4132 : :
4133 : : static void AddVarToList (unsigned int Sym);
4134 : :
4135 : : /*
4136 : : InitVarDecl - initialize the variable and type token location positions.
4137 : : */
4138 : :
4139 : : static void InitVarDecl (SymbolTable_VarDecl *decl, unsigned int vartok);
4140 : :
4141 : : /*
4142 : : doPutVarDeclTypeTok - places typetok into decl.TypeTok.
4143 : : sym must be a variable.
4144 : : */
4145 : :
4146 : : static void doPutVarDeclTypeTok (unsigned int sym, unsigned int typetok);
4147 : :
4148 : : /*
4149 : : doPutVarDeclTok - places vartok into decl.VarTok.
4150 : : sym must be a variable.
4151 : : */
4152 : :
4153 : : static void doPutVarDeclTok (unsigned int sym, unsigned int vartok);
4154 : :
4155 : : /*
4156 : : doGetVarDeclTok - return decl.VarTok for a variable.
4157 : : */
4158 : :
4159 : : static unsigned int doGetVarDeclTok (unsigned int sym);
4160 : :
4161 : : /*
4162 : : doGetVarDeclTypeTok - return decl.TypeTok for a variable.
4163 : : */
4164 : :
4165 : : static unsigned int doGetVarDeclTypeTok (unsigned int sym);
4166 : :
4167 : : /*
4168 : : doGetVarDeclFullTok - return the full declaration of var: type.
4169 : : */
4170 : :
4171 : : static unsigned int doGetVarDeclFullTok (unsigned int sym);
4172 : :
4173 : : /*
4174 : : FillInRecordFields - given a new symbol, sym, make it a record symbol
4175 : : and initialize its fields.
4176 : : */
4177 : :
4178 : : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf);
4179 : :
4180 : : /*
4181 : : HandleHiddenOrDeclare -
4182 : : */
4183 : :
4184 : : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf);
4185 : :
4186 : : /*
4187 : : CreateConstLit -
4188 : : */
4189 : :
4190 : : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
4191 : :
4192 : : /*
4193 : : LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
4194 : : matches tok, constName and constType.
4195 : : */
4196 : :
4197 : : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType);
4198 : :
4199 : : /*
4200 : : AddConstLitPoolEntry - adds sym to the constlit pool.
4201 : : */
4202 : :
4203 : : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType);
4204 : :
4205 : : /*
4206 : : InitConstString - initialize the constant string.
4207 : : */
4208 : :
4209 : : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known);
4210 : :
4211 : : /*
4212 : : GetConstStringKind - return the StringVariant field associated with sym.
4213 : : */
4214 : :
4215 : : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym);
4216 : :
4217 : : /*
4218 : : CanUseBuiltin - returns TRUE if the procedure, Sym, can be
4219 : : inlined via a builtin function.
4220 : : */
4221 : :
4222 : : static bool CanUseBuiltin (unsigned int Sym);
4223 : :
4224 : : /*
4225 : : InitPacked - initialise packedInfo to FALSE and NulSym.
4226 : : */
4227 : :
4228 : : static void InitPacked (SymbolTable_PackedInfo *packedInfo);
4229 : :
4230 : : /*
4231 : : doEquivalent - create a packed equivalent symbol for, sym, and return the
4232 : : new symbol. It sets both fields in packedInfo to FALSE
4233 : : and the new symbol.
4234 : : */
4235 : :
4236 : : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
4237 : :
4238 : : /*
4239 : : MakeEquivalent - return the equivalent packed symbol for, sym.
4240 : : */
4241 : :
4242 : : static unsigned int MakeEquivalent (unsigned int sym);
4243 : :
4244 : : /*
4245 : : GetEquivalent -
4246 : : */
4247 : :
4248 : : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
4249 : :
4250 : : /*
4251 : : doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
4252 : : */
4253 : :
4254 : : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase);
4255 : :
4256 : : /*
4257 : : GetTypeOfVar - returns the type of symbol, var.
4258 : : */
4259 : :
4260 : : static unsigned int GetTypeOfVar (unsigned int var);
4261 : :
4262 : : /*
4263 : : GetConstLitType - returns the type of the constant of, name.
4264 : : All floating point constants have type LONGREAL.
4265 : : Character constants are type CHAR.
4266 : : Integer values are INTEGER, LONGINT or LONGCARD
4267 : : depending upon their value.
4268 : : */
4269 : :
4270 : : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError);
4271 : :
4272 : : /*
4273 : : GetNthFromComponent -
4274 : : */
4275 : :
4276 : : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n);
4277 : :
4278 : : /*
4279 : : GetNthParamChoice - returns the parameter definition from
4280 : : sym:ParamNo:kind or NulSym.
4281 : : */
4282 : :
4283 : : static unsigned int GetNthParamChoice (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind kind);
4284 : :
4285 : : /*
4286 : : GetNthParamOrdered - returns the parameter definition from list {a, b, c}
4287 : : in order.
4288 : : sym:ParamNo:{a,b,c} or NulSym.
4289 : : */
4290 : :
4291 : : static unsigned int GetNthParamOrdered (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind a, SymbolTable_ProcedureKind b, SymbolTable_ProcedureKind c);
4292 : :
4293 : : /*
4294 : : GetOuterModuleScope - returns the outer module symbol scope for sym.
4295 : : */
4296 : :
4297 : : static unsigned int GetOuterModuleScope (unsigned int sym);
4298 : :
4299 : : /*
4300 : : EnsureOrder - providing that both symbols, a, and, b, exist in
4301 : : list, l. Ensure that, b, is placed after a.
4302 : : */
4303 : :
4304 : : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b);
4305 : :
4306 : : /*
4307 : : DumpSons -
4308 : : */
4309 : :
4310 : : static void DumpSons (unsigned int sym);
4311 : :
4312 : : /*
4313 : : CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
4314 : : */
4315 : :
4316 : : static void CheckListOfSons (unsigned int sym);
4317 : :
4318 : : /*
4319 : : CheckRecordConsistency -
4320 : : */
4321 : :
4322 : : static void CheckRecordConsistency (unsigned int sym);
4323 : :
4324 : : /*
4325 : : PutConstVarTemporary - indicates that constant, sym, is a temporary.
4326 : : */
4327 : :
4328 : : static void PutConstVarTemporary (unsigned int sym);
4329 : :
4330 : : /*
4331 : : buildTemporary - builds the temporary filling in componentRef, record and sets mode.
4332 : : */
4333 : :
4334 : : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record);
4335 : :
4336 : : /*
4337 : : AssertInRange - determines whether the Sym is a legal symbol.
4338 : : */
4339 : :
4340 : : static void AssertInRange (unsigned int Sym);
4341 : :
4342 : : /*
4343 : : CheckForHiddenType - scans the NeedToBeImplemented tree providing
4344 : : that we are currently compiling an implementation
4345 : : module. If a symbol is found with TypeName
4346 : : then its Sym is returned.
4347 : : Otherwise NulSym is returned.
4348 : : CheckForHiddenType is called before any type is
4349 : : created, therefore the compiler allows hidden
4350 : : types to be implemented using any type.
4351 : : */
4352 : :
4353 : : static unsigned int CheckForHiddenType (NameKey_Name TypeName);
4354 : :
4355 : : /*
4356 : : RequestFromModule - returns a symbol from module ModSym with name, SymName.
4357 : : */
4358 : :
4359 : : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4360 : :
4361 : : /*
4362 : : RequestFromDefinition - returns a symbol from module ModSym with name,
4363 : : SymName.
4364 : : */
4365 : :
4366 : : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4367 : :
4368 : : /*
4369 : : GetWhereImported - returns the token number where this symbol
4370 : : was imported into the current module.
4371 : : */
4372 : :
4373 : : static unsigned int GetWhereImported (unsigned int Sym);
4374 : :
4375 : : /*
4376 : : DisplayName - displays the name.
4377 : : */
4378 : :
4379 : : static void DisplayName (unsigned int sym);
4380 : :
4381 : : /*
4382 : : DisplaySymbol - displays the name of a symbol
4383 : : */
4384 : :
4385 : : static void DisplaySymbol (unsigned int sym);
4386 : :
4387 : : /*
4388 : : FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
4389 : : */
4390 : :
4391 : : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4392 : :
4393 : : /*
4394 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
4395 : : */
4396 : :
4397 : : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4398 : :
4399 : : /*
4400 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
4401 : : */
4402 : :
4403 : : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName);
4404 : :
4405 : : /*
4406 : : UnknownSymbolError - displays symbol name for symbol, sym.
4407 : : */
4408 : :
4409 : : static void UnknownSymbolError (unsigned int sym);
4410 : :
4411 : : /*
4412 : : IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
4413 : : reported and is an unknown symbol.
4414 : : */
4415 : :
4416 : : static bool IsUnreportedUnknown (unsigned int sym);
4417 : :
4418 : : /*
4419 : : AddListify -
4420 : : */
4421 : :
4422 : : static void AddListify (unsigned int sym);
4423 : :
4424 : : /*
4425 : : Listify - convert tree into a string list and return the result.
4426 : : */
4427 : :
4428 : : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition);
4429 : :
4430 : : /*
4431 : : CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
4432 : : an unknown symbol. All unknown symbols are displayed
4433 : : together with an error message.
4434 : : */
4435 : :
4436 : : static void CheckForUnknowns (unsigned int tokno, NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
4437 : :
4438 : : /*
4439 : : SymbolError - displays symbol name for symbol, Sym.
4440 : : */
4441 : :
4442 : : static void SymbolError (unsigned int Sym);
4443 : :
4444 : : /*
4445 : : CheckForSymbols - checks a binary tree, Tree, to see whether it contains
4446 : : any symbol. The tree is expected to be empty, if not
4447 : : then an error has occurred.
4448 : : */
4449 : :
4450 : : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
4451 : :
4452 : : /*
4453 : : PutExportUndeclared - places a symbol, Sym, into module, ModSym,
4454 : : ExportUndeclared list provided that Sym
4455 : : is unknown.
4456 : : */
4457 : :
4458 : : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym);
4459 : :
4460 : : /*
4461 : : GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
4462 : : which is in the ExportUndeclared list.
4463 : : */
4464 : :
4465 : : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name);
4466 : :
4467 : : /*
4468 : : RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
4469 : : ExportUndeclaredTree.
4470 : : */
4471 : :
4472 : : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym);
4473 : :
4474 : : /*
4475 : : CheckForExportedDeclaration - checks to see whether a definition module
4476 : : is currently being compiled, if so,
4477 : : symbol, Sym, is removed from the
4478 : : ExportUndeclared list.
4479 : : This procedure is called whenever a symbol
4480 : : is declared, thus attempting to reduce
4481 : : the ExportUndeclared list.
4482 : : */
4483 : :
4484 : : static void CheckForExportedDeclaration (unsigned int Sym);
4485 : :
4486 : : /*
4487 : : UndeclaredSymbolError - displays symbol name for symbol, Sym.
4488 : : */
4489 : :
4490 : : static void UndeclaredSymbolError (unsigned int Sym);
4491 : :
4492 : : /*
4493 : : RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
4494 : : NeedToBeImplemented list.
4495 : : */
4496 : :
4497 : : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym);
4498 : :
4499 : : /*
4500 : : RemoveFromExportRequest -
4501 : : */
4502 : :
4503 : : static void RemoveFromExportRequest (unsigned int Sym);
4504 : :
4505 : : /*
4506 : : RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
4507 : : (and its fields) from the ExportRequest tree.
4508 : : */
4509 : :
4510 : : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym);
4511 : :
4512 : : /*
4513 : : UnImplementedSymbolError - displays symbol name for symbol, Sym.
4514 : : */
4515 : :
4516 : : static void UnImplementedSymbolError (unsigned int Sym);
4517 : :
4518 : : /*
4519 : : CheckEnumerationInList - places symbol, Sym, in the list, l,
4520 : : providing it does not already exist.
4521 : : PseudoScope(Sym) is called if Sym needs to
4522 : : be added to the enumeration list, l.
4523 : : */
4524 : :
4525 : : static void CheckEnumerationInList (Lists_List l, unsigned int Sym);
4526 : :
4527 : : /*
4528 : : CheckIfEnumerationExported - An outer module may use an enumeration that
4529 : : is declared inside an inner module. The usage
4530 : : may occur before definition. The first pass
4531 : : exports a symbol, later the symbol is declared
4532 : : as an emumeration type. At this stage the
4533 : : CheckIfEnumerationExported procedure should be
4534 : : called. This procedure ripples from the current
4535 : : (inner) module to outer module and every time
4536 : : it is exported it must be added to the outer
4537 : : module EnumerationScopeList.
4538 : : */
4539 : :
4540 : : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId);
4541 : :
4542 : : /*
4543 : : CheckForEnumerationInOuterModule - checks to see whether the enumeration
4544 : : type symbol, Sym, has been entered into
4545 : : the outer module, OuterModule, scope list.
4546 : : OuterModule may be internal to the
4547 : : program module.
4548 : : */
4549 : :
4550 : : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule);
4551 : :
4552 : : /*
4553 : : MakeVariableForParam -
4554 : : */
4555 : :
4556 : : static unsigned int MakeVariableForParam (unsigned int tok, NameKey_Name ParamName, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, unsigned int ParmType, unsigned int typetok);
4557 : :
4558 : : /*
4559 : : AddParameter - adds a parameter ParSym to a procedure Sym.
4560 : : */
4561 : :
4562 : : static void AddParameter (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParSym);
4563 : :
4564 : : /*
4565 : : AddProcedureProcTypeParam - adds ParamType to the parameter ProcType
4566 : : associated with procedure Sym.
4567 : : */
4568 : :
4569 : : static void AddProcedureProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded, bool isVarParam);
4570 : :
4571 : : /*
4572 : : IsNthParamVar - returns true if the n th parameter of the parameter list,
4573 : : List, is a VAR parameter.
4574 : : */
4575 : :
4576 : : static bool IsNthParamVar (Lists_List Head, unsigned int n);
4577 : :
4578 : : /*
4579 : : MakeParameterHeapVar - create a heap variable if sym is a pointer.
4580 : : */
4581 : :
4582 : : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode);
4583 : :
4584 : : /*
4585 : : PutParameterHeapVar - creates a heap variable associated with parameter sym.
4586 : : */
4587 : :
4588 : : static void PutParameterHeapVar (unsigned int sym);
4589 : :
4590 : : /*
4591 : : IsProcedureAnyBoolean - returns the boolean result from p
4592 : : for any of procedure kind which is defined.
4593 : : */
4594 : :
4595 : : static bool IsProcedureAnyBoolean (unsigned int sym, SymbolTable_ProcAnyBoolean p);
4596 : :
4597 : : /*
4598 : : IsProcedureAnyDefaultBoolean - returns the boolean result from p
4599 : : for any of procedure kind which is defined.
4600 : : */
4601 : :
4602 : : static bool IsProcedureAnyDefaultBoolean (unsigned int sym, bool default_, SymbolTable_ProcAnyBoolean p);
4603 : :
4604 : : /*
4605 : : FillInUnknownFields - fills in all fields for the undefined sym.
4606 : : */
4607 : :
4608 : : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName, unsigned int descscope, bool onimport);
4609 : :
4610 : : /*
4611 : : FillInPointerFields - given a new symbol, sym, make it a pointer symbol
4612 : : and initialize its fields.
4613 : : */
4614 : :
4615 : : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf);
4616 : :
4617 : : /*
4618 : : ForeachParameterDo -
4619 : : */
4620 : :
4621 : : static void ForeachParameterDo (SymbolTable_CheckProcedure p);
4622 : :
4623 : : /*
4624 : : CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
4625 : : */
4626 : :
4627 : : static void CheckUnbounded (unsigned int Sym);
4628 : :
4629 : : /*
4630 : : PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
4631 : : */
4632 : :
4633 : : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf);
4634 : :
4635 : : /*
4636 : : doFillInOAFamily -
4637 : : */
4638 : :
4639 : : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded);
4640 : :
4641 : : /*
4642 : : FillInUnboundedFields -
4643 : : */
4644 : :
4645 : : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim);
4646 : :
4647 : : /*
4648 : : PutUnbounded - associates the unbounded symbol, open, with
4649 : : SimpleType.
4650 : : */
4651 : :
4652 : : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim);
4653 : :
4654 : : /*
4655 : : GetArrayDimension - returns the number of dimensions defined.
4656 : : */
4657 : :
4658 : : static unsigned int GetArrayDimension (unsigned int sym);
4659 : :
4660 : : /*
4661 : : ResolveConstructorType - if, sym, has an unresolved constructor type
4662 : : then attempt to resolve it by examining the
4663 : : from, type.
4664 : : */
4665 : :
4666 : : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres);
4667 : :
4668 : : /*
4669 : : IsConstructorResolved - returns TRUE if the constructor does not
4670 : : have an unresolved type.
4671 : : */
4672 : :
4673 : : static bool IsConstructorResolved (unsigned int sym);
4674 : :
4675 : : /*
4676 : : CanResolveConstructor - returns TRUE if the type of the constructor,
4677 : : sym, is known.
4678 : : */
4679 : :
4680 : : static bool CanResolveConstructor (unsigned int sym);
4681 : :
4682 : : /*
4683 : : CheckAllConstructorsResolved - checks to see that the
4684 : : UnresolvedConstructorType list is
4685 : : empty and if it is not then it
4686 : : generates error messages.
4687 : : */
4688 : :
4689 : : static void CheckAllConstructorsResolved (void);
4690 : :
4691 : : /*
4692 : : SanityCheckParameters -
4693 : : */
4694 : :
4695 : : static void SanityCheckParameters (unsigned int sym);
4696 : :
4697 : : /*
4698 : : SanityCheckArray - checks to see that an array has a correct subrange type.
4699 : : */
4700 : :
4701 : : static void SanityCheckArray (unsigned int sym);
4702 : :
4703 : : /*
4704 : : ForeachSymbolDo - foreach symbol, call, P(sym).
4705 : : */
4706 : :
4707 : : static void ForeachSymbolDo (SymbolKey_PerformOperation P);
4708 : :
4709 : : /*
4710 : : SanityCheckProcedure - check to see that procedure parameters do not use constants
4711 : : instead of types in their formal parameter section.
4712 : : */
4713 : :
4714 : : static void SanityCheckProcedure (unsigned int sym);
4715 : :
4716 : : /*
4717 : : SanityCheckModule -
4718 : : */
4719 : :
4720 : : static void SanityCheckModule (unsigned int sym);
4721 : :
4722 : : /*
4723 : : AddNameTo - adds Name, n, to tree, s.
4724 : : */
4725 : :
4726 : : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o);
4727 : :
4728 : : /*
4729 : : CollectSymbolFrom -
4730 : : */
4731 : :
4732 : : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n);
4733 : :
4734 : : /*
4735 : : CollectUnknown -
4736 : : */
4737 : :
4738 : : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n);
4739 : :
4740 : : /*
4741 : : ResolveImport -
4742 : : */
4743 : :
4744 : : static void ResolveImport (unsigned int o);
4745 : :
4746 : : /*
4747 : : ResolveRelativeImport -
4748 : : */
4749 : :
4750 : : static void ResolveRelativeImport (unsigned int sym);
4751 : :
4752 : : /*
4753 : : Max -
4754 : : */
4755 : :
4756 : : static unsigned int Max (unsigned int a, unsigned int b);
4757 : :
4758 : : /*
4759 : : Min -
4760 : : */
4761 : :
4762 : : static unsigned int Min (unsigned int a, unsigned int b);
4763 : :
4764 : : /*
4765 : : DoFindLimits - assigns, Start, and, End, to the start and end
4766 : : limits contained in the list, l. It ensures that
4767 : : Start and End are within StartLimit..EndLimit.
4768 : : If StartLimit or EndLimit are 0 then Start is
4769 : : is set to the first value and End to the last.
4770 : : */
4771 : :
4772 : : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l);
4773 : :
4774 : : /*
4775 : : PutDeclaredDefinition - associates the current tokenno with
4776 : : the symbols declaration in the definition
4777 : : module.
4778 : : */
4779 : :
4780 : : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym);
4781 : :
4782 : : /*
4783 : : PutDeclaredModule - returns the token where this symbol was declared
4784 : : in an implementation or program module.
4785 : : */
4786 : :
4787 : : static void PutDeclaredModule (unsigned int tok, unsigned int Sym);
4788 : :
4789 : : /*
4790 : : DoIsConst - returns TRUE if Sym is defined as a constant
4791 : : or is an enumeration field or string.
4792 : : */
4793 : :
4794 : : static bool DoIsConst (unsigned int Sym);
4795 : :
4796 : : /*
4797 : : GetFromIndex - return a value from list, i, at position, n.
4798 : : */
4799 : :
4800 : : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n);
4801 : :
4802 : : /*
4803 : : PutIntoIndex - places value, v, into list, i, at position, n.
4804 : : */
4805 : :
4806 : : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v);
4807 : :
4808 : : /*
4809 : : PushConstString - pushes the character string onto the ALU stack.
4810 : : It assumes that the character string is only
4811 : : one character long.
4812 : : */
4813 : :
4814 : : static void PushConstString (unsigned int Sym);
4815 : :
4816 : 36262419 : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at)
4817 : : {
4818 : : /*
4819 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
4820 : : */
4821 : 36262419 : if (M2Comp_CompilingDefinitionModule ())
4822 : : {
4823 : 19131620 : (*at).DefDeclared = tok;
4824 : 19131620 : (*at).ModDeclared = M2LexBuf_UnknownTokenNo;
4825 : : }
4826 : : else
4827 : : {
4828 : 17130799 : (*at).DefDeclared = M2LexBuf_UnknownTokenNo;
4829 : 17130799 : (*at).ModDeclared = tok;
4830 : : }
4831 : 36262419 : (*at).FirstUsed = tok; /* we assign this field to something legal */
4832 : 36262419 : }
4833 : :
4834 : :
4835 : : /*
4836 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
4837 : : */
4838 : :
4839 : 581219 : static void InitWhereDeclared (SymbolTable_Where *at)
4840 : : {
4841 : 581219 : InitWhereDeclaredTok (M2LexBuf_GetTokenNo (), at);
4842 : 581219 : }
4843 : :
4844 : :
4845 : : /*
4846 : : InitWhereFirstUsed - sets the FirstUsed field of record, at.
4847 : : */
4848 : :
4849 : 3038 : static void InitWhereFirstUsed (SymbolTable_Where *at)
4850 : : {
4851 : 0 : InitWhereFirstUsedTok (M2LexBuf_GetTokenNo (), at);
4852 : 0 : }
4853 : :
4854 : :
4855 : : /*
4856 : : InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
4857 : : */
4858 : :
4859 : 32160308 : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at)
4860 : : {
4861 : 32160308 : (*at).FirstUsed = tok;
4862 : 1155558 : }
4863 : :
4864 : :
4865 : : /*
4866 : : gdbhook - a debugger convenience hook.
4867 : : */
4868 : :
4869 : 0 : static void gdbhook (void)
4870 : : {
4871 : 0 : }
4872 : :
4873 : :
4874 : : /*
4875 : : BreakWhenSymCreated - to be called interactively by gdb.
4876 : : */
4877 : :
4878 : 15229 : static void BreakWhenSymCreated (unsigned int sym)
4879 : : {
4880 : 15229 : BreakSym = sym;
4881 : 0 : }
4882 : :
4883 : :
4884 : : /*
4885 : : CheckBreak - if sym = BreakSym then call gdbhook.
4886 : : */
4887 : :
4888 : 0 : static void CheckBreak (unsigned int sym)
4889 : : {
4890 : 0 : if (sym == BreakSym)
4891 : : {
4892 : 0 : gdbhook ();
4893 : : }
4894 : 0 : }
4895 : :
4896 : :
4897 : : /*
4898 : : NewSym - Sets Sym to a new symbol index.
4899 : : */
4900 : :
4901 : 61765352 : static void NewSym (unsigned int *sym)
4902 : : {
4903 : 61765352 : SymbolTable_PtrToSymbol pSym;
4904 : :
4905 : 61765352 : (*sym) = FreeSymbol;
4906 : 61765352 : Storage_ALLOCATE ((void **) &pSym, sizeof (SymbolTable_Symbol));
4907 : 61765352 : pSym->SymbolType = SymbolTable_DummySym;
4908 : 61765352 : Indexing_PutIndice (Symbols, (*sym), reinterpret_cast <void *> (pSym));
4909 : 61765352 : CheckBreak ((*sym));
4910 : 61765352 : FreeSymbol += 1;
4911 : 61765352 : M2Diagnostic_MemSet (SymMemDiag, 1, FreeSymbol-1);
4912 : 61765352 : M2Diagnostic_MemIncr (SymMemDiag, 2, sizeof ((*pSym)));
4913 : 61765352 : }
4914 : :
4915 : :
4916 : : /*
4917 : : GetPsym - returns the pointer to, sym.
4918 : : */
4919 : :
4920 : 15149580249 : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym)
4921 : : {
4922 : 15149580249 : SymbolTable_PtrToSymbol pSym;
4923 : :
4924 : 15149580249 : if (Indexing_InBounds (Symbols, sym))
4925 : : {
4926 : 15149580249 : pSym = static_cast<SymbolTable_PtrToSymbol> (Indexing_GetIndice (Symbols, sym));
4927 : 15149580249 : return pSym;
4928 : : }
4929 : : else
4930 : : {
4931 : 0 : M2Error_InternalError ((const char *) "symbol out of bounds", 20);
4932 : : }
4933 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
4934 : : __builtin_unreachable ();
4935 : : }
4936 : :
4937 : :
4938 : : /*
4939 : : GetPcall - returns the pointer to the CallFrame.
4940 : : */
4941 : :
4942 : 411150612 : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call)
4943 : : {
4944 : 411150612 : SymbolTable_PtrToCallFrame pCall;
4945 : :
4946 : 411150612 : if (Indexing_InBounds (ScopeCallFrame, call))
4947 : : {
4948 : 411150612 : pCall = static_cast<SymbolTable_PtrToCallFrame> (Indexing_GetIndice (ScopeCallFrame, call));
4949 : 411150612 : return pCall;
4950 : : }
4951 : : else
4952 : : {
4953 : 0 : M2Error_InternalError ((const char *) "symbol out of bounds", 20);
4954 : : }
4955 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
4956 : : __builtin_unreachable ();
4957 : : }
4958 : :
4959 : :
4960 : : /*
4961 : : DebugProcedureLineNumber -
4962 : : */
4963 : :
4964 : 0 : static void DebugProcedureLineNumber (unsigned int sym)
4965 : : {
4966 : 0 : unsigned int begin;
4967 : 0 : unsigned int end;
4968 : 0 : NameKey_Name n;
4969 : 0 : DynamicStrings_String f;
4970 : 0 : unsigned int l;
4971 : :
4972 : 0 : SymbolTable_GetProcedureBeginEnd (sym, &begin, &end);
4973 : 0 : n = SymbolTable_GetSymName (sym);
4974 : 0 : if (begin != 0)
4975 : : {
4976 : 0 : f = M2LexBuf_FindFileNameFromToken (begin, 0);
4977 : 0 : l = M2LexBuf_TokenToLineNo (begin, 0);
4978 : 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));
4979 : : }
4980 : 0 : if (end != 0)
4981 : : {
4982 : 0 : f = M2LexBuf_FindFileNameFromToken (end, 0);
4983 : 0 : l = M2LexBuf_TokenToLineNo (end, 0);
4984 : 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));
4985 : : }
4986 : 0 : }
4987 : :
4988 : :
4989 : : /*
4990 : : PutPartialUnbounded -
4991 : : */
4992 : :
4993 : 0 : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim)
4994 : : {
4995 : 0 : SymbolTable_PtrToSymbol pSym;
4996 : :
4997 : 0 : pSym = GetPsym (sym);
4998 : 0 : if (SymbolTable_IsDummy (sym))
4999 : : {
5000 : 0 : pSym->SymbolType = SymbolTable_PartialUnboundedSym;
5001 : : }
5002 : 0 : switch (pSym->SymbolType)
5003 : : {
5004 : 0 : case SymbolTable_PartialUnboundedSym:
5005 : 0 : pSym->PartialUnbounded.Type = type;
5006 : 0 : pSym->PartialUnbounded.NDim = ndim;
5007 : 0 : break;
5008 : :
5009 : :
5010 : 0 : default:
5011 : 0 : M2Error_InternalError ((const char *) "not expecting this type", 23);
5012 : 0 : break;
5013 : : }
5014 : 0 : }
5015 : :
5016 : :
5017 : : /*
5018 : : AlreadyDeclaredError - generate an error message, a, and two areas of code showing
5019 : : the places where the symbols were declared.
5020 : : */
5021 : :
5022 : 0 : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance)
5023 : : {
5024 : 0 : M2Error_Error e;
5025 : :
5026 : 0 : if ((OtherOccurance == 0) || (OtherOccurance == (M2LexBuf_GetTokenNo ())))
5027 : : {
5028 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
5029 : 0 : M2Error_ErrorString (e, s);
5030 : : }
5031 : : else
5032 : : {
5033 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
5034 : 0 : M2Error_ErrorString (e, s);
5035 : 0 : e = M2Error_ChainError (OtherOccurance, e);
5036 : 0 : M2Error_ErrorFormat1 (e, (const char *) "and symbol (%a) is also declared here", 37, (const unsigned char *) &name, (sizeof (name)-1));
5037 : : }
5038 : 0 : }
5039 : :
5040 : :
5041 : : /*
5042 : : MakeObject - creates an object node.
5043 : : */
5044 : :
5045 : 7904742 : static unsigned int MakeObject (unsigned int tok, NameKey_Name name)
5046 : : {
5047 : 7904742 : SymbolTable_PtrToSymbol pSym;
5048 : 7904742 : unsigned int Sym;
5049 : :
5050 : 7904742 : NewSym (&Sym);
5051 : 7904742 : pSym = GetPsym (Sym);
5052 : 7904742 : pSym->SymbolType = SymbolTable_ObjectSym;
5053 : 7904742 : pSym->Object.name = name;
5054 : 7904742 : InitWhereDeclaredTok (tok, &pSym->Object.At);
5055 : 7904742 : InitWhereFirstUsedTok (tok, &pSym->Object.At);
5056 : 7904742 : return Sym;
5057 : : /* static analysis guarentees a RETURN statement will be used before here. */
5058 : : __builtin_unreachable ();
5059 : : }
5060 : :
5061 : :
5062 : : /*
5063 : : DeclareSym - returns a symbol which was either in the unknown tree or
5064 : : a New symbol, since name is about to be declared.
5065 : : */
5066 : :
5067 : 24665141 : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name)
5068 : : {
5069 : 24665141 : unsigned int Sym;
5070 : :
5071 : 24665141 : if (name == NameKey_NulName)
5072 : : {
5073 : 5480188 : NewSym (&Sym);
5074 : : }
5075 : 19184953 : else if (IsAlreadyDeclaredSym (name))
5076 : : {
5077 : : /* avoid dangling else. */
5078 : 36 : Sym = SymbolTable_GetSym (name);
5079 : 36 : if (SymbolTable_IsImported (SymbolTable_GetCurrentModuleScope (), Sym))
5080 : : {
5081 : : /* avoid dangling else. */
5082 : 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);
5083 : 6 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
5084 : 6 : if (Sym != (GetVisibleSym (name)))
5085 : : {
5086 : 0 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
5087 : : }
5088 : : }
5089 : : else
5090 : : {
5091 : 30 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1RMad} is already declared in this scope, use a different name or remove the declaration", 97, Sym);
5092 : 30 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
5093 : 30 : if (Sym != (GetVisibleSym (name)))
5094 : : {
5095 : 0 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
5096 : : }
5097 : : }
5098 : 36 : Sym = SymbolTable_MakeError (tok, name);
5099 : : }
5100 : : else
5101 : : {
5102 : : /* avoid dangling else. */
5103 : 19184917 : Sym = FetchUnknownSym (name);
5104 : 19184917 : if (Sym == SymbolTable_NulSym)
5105 : : {
5106 : 14533608 : NewSym (&Sym);
5107 : : }
5108 : 19184917 : CheckForExportedDeclaration (Sym);
5109 : : }
5110 : 24665141 : return Sym;
5111 : : /* static analysis guarentees a RETURN statement will be used before here. */
5112 : : __builtin_unreachable ();
5113 : : }
5114 : :
5115 : :
5116 : : /*
5117 : : Init - Initializes the data structures and variables in this module.
5118 : : Initialize the trees.
5119 : : */
5120 : :
5121 : 15229 : static void Init (void)
5122 : : {
5123 : 15229 : SymbolTable_PtrToCallFrame pCall;
5124 : :
5125 : 15229 : SymMemDiag = M2Diagnostic_InitMemDiagnostic ((const char *) "SymbolTable:Symbols", 19, (const char *) "{0N} total symbols {1d} consuming {2M} ram {0M} ({2P})", 54);
5126 : 15229 : BreakWhenSymCreated (SymbolTable_NulSym); /* Disable the intereactive sym watch. */
5127 : : /* To examine the symbol table when a symbol is created run cc1gm2 from gdb
5128 : : and set a break point on gdbhook.
5129 : : (gdb) break gdbhook
5130 : : (gdb) run
5131 : : Now below interactively call BreakWhenSymCreated with the symbol
5132 : : under investigation. */
5133 : 15229 : gdbhook ();
5134 : : /* Now is the time to interactively call gdb, for example:
5135 : : (gdb) print BreakWhenSymCreated (1234)
5136 : : (gdb) cont
5137 : : and you will arrive at gdbhook when this symbol is created. */
5138 : 15229 : AnonymousName = 0;
5139 : 15229 : CurrentError = static_cast<M2Error_Error> (NULL);
5140 : 15229 : SymbolKey_InitTree (&ConstLitPoolTree);
5141 : 15229 : SymbolKey_InitTree (&DefModuleTree);
5142 : 15229 : SymbolKey_InitTree (&ModuleTree);
5143 : 15229 : Symbols = Indexing_InitIndexTuned (1, (1024*1024) / 16, 16);
5144 : 15229 : ConstLitArray = Indexing_InitIndex (1);
5145 : 15229 : FreeSymbol = 1;
5146 : 15229 : ScopePtr = 1;
5147 : 15229 : ScopeCallFrame = Indexing_InitIndex (1);
5148 : 15229 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
5149 : 15229 : pCall->Main = SymbolTable_NulSym;
5150 : 15229 : pCall->Search = SymbolTable_NulSym;
5151 : 15229 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
5152 : 15229 : CurrentModule = SymbolTable_NulSym;
5153 : 15229 : MainModule = SymbolTable_NulSym;
5154 : 15229 : FileModule = SymbolTable_NulSym;
5155 : 15229 : TemporaryNo = 0;
5156 : : /*
5157 : : InitList(FreeFVarientList) ; Lists used to maintain GC of field
5158 : : InitList(UsedFVarientList) ; varients.
5159 : : */
5160 : 15229 : Lists_InitList (&UnresolvedConstructorType);
5161 : 15229 : M2Base_InitBase (m2linemap_BuiltinsLocation (), &BaseModule);
5162 : 15229 : SymbolTable_StartScope (BaseModule); /* BaseModule scope placed at the bottom of the stack */
5163 : 15229 : BaseScopePtr = ScopePtr; /* BaseScopePtr points to the top of the BaseModule scope */
5164 : 15229 : Lists_InitList (&AddressTypes); /* BaseScopePtr points to the top of the BaseModule scope */
5165 : 15229 : ReportedUnknowns = Sets_InitSet (1);
5166 : 15229 : }
5167 : :
5168 : :
5169 : : /*
5170 : : AddSymToUnknown -
5171 : : */
5172 : :
5173 : 10624502 : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym)
5174 : : {
5175 : 10624502 : SymbolTable_PtrToSymbol pSym;
5176 : 10624502 : NameKey_Name n;
5177 : :
5178 : 10624502 : if (DebugUnknowns)
5179 : : {
5180 : : n = SymbolTable_GetSymName (scope);
5181 : : 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));
5182 : : }
5183 : : /* Add symbol to unknown tree */
5184 : 10624502 : pSym = GetPsym (scope);
5185 : 10624502 : switch (pSym->SymbolType)
5186 : : {
5187 : 10614437 : case SymbolTable_DefImpSym:
5188 : 10614437 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, name, Sym);
5189 : 10614437 : break;
5190 : :
5191 : 10065 : case SymbolTable_ModuleSym:
5192 : 10065 : SymbolKey_PutSymKey (pSym->Module.Unresolved, name, Sym);
5193 : 10065 : break;
5194 : :
5195 : 0 : case SymbolTable_ProcedureSym:
5196 : 0 : SymbolKey_PutSymKey (pSym->Procedure.Unresolved, name, Sym);
5197 : 0 : break;
5198 : :
5199 : :
5200 : 0 : default:
5201 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5202 : 10624502 : break;
5203 : : }
5204 : 10624502 : }
5205 : :
5206 : :
5207 : : /*
5208 : : AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
5209 : : unknown tree.
5210 : : */
5211 : :
5212 : 10624484 : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym)
5213 : : {
5214 : 10624484 : SymbolTable_PtrToCallFrame pCall;
5215 : 10624484 : unsigned int ScopeSym;
5216 : :
5217 : 10624484 : if (ScopeId > 0)
5218 : : {
5219 : : /* choose to place the unknown symbol in the first module scope
5220 : : outside the current scope */
5221 : 10625174 : do {
5222 : 10625174 : pCall = GetPcall (static_cast<unsigned int> (ScopeId));
5223 : 10625174 : ScopeSym = pCall->Main;
5224 : 10625174 : if ((ScopeSym > 0) && ((SymbolTable_IsDefImp (ScopeSym)) || (SymbolTable_IsModule (ScopeSym))))
5225 : : {
5226 : 10624484 : AddSymToUnknown (ScopeSym, name, Sym);
5227 : 10624484 : return;
5228 : : }
5229 : 690 : ScopeId -= 1;
5230 : 690 : } while (! (ScopeId == 0));
5231 : : }
5232 : 0 : AddSymToUnknown (CurrentModule, name, Sym);
5233 : : }
5234 : :
5235 : :
5236 : : /*
5237 : : SubSymFromUnknownTree - removes a symbol with name, name, from the
5238 : : unknown tree.
5239 : : */
5240 : :
5241 : 4651315 : static void SubSymFromUnknownTree (NameKey_Name name)
5242 : : {
5243 : 4651315 : SymbolTable_PtrToCallFrame pCall;
5244 : 4651315 : unsigned int ScopeSym;
5245 : 4651315 : unsigned int ScopeId;
5246 : :
5247 : 4651315 : if (ScopePtr > 0)
5248 : : {
5249 : : ScopeId = ScopePtr;
5250 : 5988710 : do {
5251 : 5988710 : pCall = GetPcall (ScopeId);
5252 : 5988710 : ScopeSym = pCall->Search;
5253 : 5988710 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
5254 : : {
5255 : 4651933 : if (RemoveFromUnresolvedTree (ScopeSym, name))
5256 : : {
5257 : : return;
5258 : : }
5259 : : }
5260 : 1337395 : ScopeId -= 1;
5261 : 2674790 : } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
5262 : : }
5263 : 0 : if (RemoveFromUnresolvedTree (CurrentModule, name))
5264 : : {} /* empty. */
5265 : : }
5266 : :
5267 : :
5268 : : /*
5269 : : GetSymFromUnknownTree - returns a symbol with name, name, from the
5270 : : unknown tree.
5271 : : If no symbol with name is found then NulSym
5272 : : is returned.
5273 : : */
5274 : :
5275 : 29809601 : static unsigned int GetSymFromUnknownTree (NameKey_Name name)
5276 : : {
5277 : 29809601 : SymbolTable_PtrToCallFrame pCall;
5278 : 29809601 : unsigned int ScopeSym;
5279 : 29809601 : unsigned int ScopeId;
5280 : 29809601 : unsigned int Sym;
5281 : :
5282 : 29809601 : if (ScopePtr > 0)
5283 : : {
5284 : : ScopeId = ScopePtr;
5285 : 48582648 : do {
5286 : 48582648 : pCall = GetPcall (ScopeId);
5287 : 48582648 : ScopeSym = pCall->Search;
5288 : 48582648 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
5289 : : {
5290 : 41077155 : Sym = ExamineUnresolvedTree (ScopeSym, name);
5291 : 41077155 : if (Sym != SymbolTable_NulSym)
5292 : : {
5293 : : return Sym;
5294 : : }
5295 : : }
5296 : 43931333 : ScopeId -= 1;
5297 : 87862666 : } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
5298 : : }
5299 : : /* Get symbol from unknown tree */
5300 : 25158286 : return ExamineUnresolvedTree (CurrentModule, name);
5301 : : /* static analysis guarentees a RETURN statement will be used before here. */
5302 : : __builtin_unreachable ();
5303 : : }
5304 : :
5305 : :
5306 : : /*
5307 : : ExamineUnresolvedTree - returns a symbol with name, name, from the
5308 : : unresolved tree of module, ModSym.
5309 : : If no symbol with name is found then NulSym
5310 : : is returned.
5311 : : */
5312 : :
5313 : 138620213 : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
5314 : : {
5315 : 138620213 : SymbolTable_PtrToSymbol pSym;
5316 : 138620213 : unsigned int Sym;
5317 : :
5318 : : /* Get symbol from unknown tree */
5319 : 138620213 : pSym = GetPsym (ScopeSym);
5320 : 138620213 : switch (pSym->SymbolType)
5321 : : {
5322 : 83318386 : case SymbolTable_DefImpSym:
5323 : 83318386 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name));
5324 : 83318386 : break;
5325 : :
5326 : 14137999 : case SymbolTable_ModuleSym:
5327 : 14137999 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, name));
5328 : 14137999 : break;
5329 : :
5330 : 41163828 : case SymbolTable_ProcedureSym:
5331 : 41163828 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name));
5332 : 41163828 : break;
5333 : :
5334 : :
5335 : 0 : default:
5336 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5337 : 138620213 : break;
5338 : : }
5339 : 138620213 : return Sym;
5340 : : /* static analysis guarentees a RETURN statement will be used before here. */
5341 : : __builtin_unreachable ();
5342 : : }
5343 : :
5344 : :
5345 : : /*
5346 : : RemoveFromUnresolvedTree - removes a symbol with name, name, from the
5347 : : unresolved tree of symbol, ScopeSym.
5348 : : */
5349 : :
5350 : 4651933 : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
5351 : : {
5352 : 4651933 : SymbolTable_PtrToSymbol pSym;
5353 : :
5354 : : /* Get symbol from unknown tree */
5355 : 4651933 : pSym = GetPsym (ScopeSym);
5356 : 4651933 : switch (pSym->SymbolType)
5357 : : {
5358 : 4641405 : case SymbolTable_DefImpSym:
5359 : 4641405 : if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) != SymbolKey_NulKey)
5360 : : {
5361 : 4641405 : SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
5362 : 4641405 : return true;
5363 : : }
5364 : : break;
5365 : :
5366 : 9892 : case SymbolTable_ModuleSym:
5367 : 9892 : if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) != SymbolKey_NulKey)
5368 : : {
5369 : 9892 : SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
5370 : 9892 : return true;
5371 : : }
5372 : : break;
5373 : :
5374 : 636 : case SymbolTable_ProcedureSym:
5375 : 636 : if ((SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name)) != SymbolKey_NulKey)
5376 : : {
5377 : 18 : SymbolKey_DelSymKey (pSym->Procedure.Unresolved, name);
5378 : 18 : return true;
5379 : : }
5380 : : break;
5381 : :
5382 : :
5383 : 0 : default:
5384 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5385 : : break;
5386 : : }
5387 : : return false;
5388 : : /* static analysis guarentees a RETURN statement will be used before here. */
5389 : : __builtin_unreachable ();
5390 : : }
5391 : :
5392 : :
5393 : : /*
5394 : : FetchUnknownSym - returns a symbol from the unknown tree if one is
5395 : : available. It also updates the unknown tree.
5396 : : */
5397 : :
5398 : 19185117 : static unsigned int FetchUnknownSym (NameKey_Name name)
5399 : : {
5400 : 19185117 : unsigned int Sym;
5401 : :
5402 : 19185117 : Sym = GetSymFromUnknownTree (name);
5403 : 19185117 : if (Sym != SymbolTable_NulSym)
5404 : : {
5405 : 4651315 : SubSymFromUnknownTree (name);
5406 : : }
5407 : 19185117 : return Sym;
5408 : : /* static analysis guarentees a RETURN statement will be used before here. */
5409 : : __builtin_unreachable ();
5410 : : }
5411 : :
5412 : :
5413 : : /*
5414 : : TransparentScope - returns true is the scope symbol Sym is allowed
5415 : : to look to an outer level for a symbol.
5416 : : ie is the symbol allowed to look to the parent
5417 : : scope for a symbol.
5418 : : */
5419 : :
5420 : 114232679 : static bool TransparentScope (unsigned int Sym)
5421 : : {
5422 : 114232679 : SymbolTable_PtrToSymbol pSym;
5423 : :
5424 : 114232679 : pSym = GetPsym (Sym);
5425 : 114232679 : return (pSym->SymbolType != SymbolTable_DefImpSym) && (pSym->SymbolType != SymbolTable_ModuleSym);
5426 : : /* static analysis guarentees a RETURN statement will be used before here. */
5427 : : __builtin_unreachable ();
5428 : : }
5429 : :
5430 : :
5431 : : /*
5432 : : GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
5433 : : the scope before the current module scope.
5434 : : */
5435 : :
5436 : 276 : static unsigned int GetLastModuleOrProcedureScope (void)
5437 : : {
5438 : 276 : SymbolTable_PtrToCallFrame pCall;
5439 : 276 : unsigned int i;
5440 : :
5441 : : /* find current inner module */
5442 : 276 : i = ScopePtr;
5443 : 276 : pCall = GetPcall (i);
5444 : 552 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
5445 : : {
5446 : 0 : M2Debug_Assert (i > 0);
5447 : 0 : i -= 1;
5448 : 0 : pCall = GetPcall (i);
5449 : : }
5450 : : /* found module at position, i. */
5451 : 276 : i -= 1; /* Move to an outer level module or procedure scope */
5452 : 276 : pCall = GetPcall (i); /* Move to an outer level module or procedure scope */
5453 : 552 : while (((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search)))) && (! (SymbolTable_IsProcedure (pCall->Search))))
5454 : : {
5455 : 0 : M2Debug_Assert (i > 0);
5456 : 0 : i -= 1;
5457 : 0 : pCall = GetPcall (i);
5458 : : }
5459 : : /* Found module at position, i. */
5460 : 276 : return pCall->Search;
5461 : : /* static analysis guarentees a RETURN statement will be used before here. */
5462 : : __builtin_unreachable ();
5463 : : }
5464 : :
5465 : :
5466 : : /*
5467 : : AddSymToScope - adds a symbol Sym with name name to
5468 : : the current scope symbol tree.
5469 : : */
5470 : :
5471 : 24171849 : static void AddSymToScope (unsigned int Sym, NameKey_Name name)
5472 : : {
5473 : 24171849 : SymbolTable_PtrToSymbol pSym;
5474 : 24171849 : SymbolTable_PtrToCallFrame pCall;
5475 : 24171849 : unsigned int ScopeId;
5476 : :
5477 : 24171849 : pCall = GetPcall (ScopePtr);
5478 : 24171849 : ScopeId = pCall->Main;
5479 : : /*
5480 : : WriteString('Adding ') ; WriteKey(name) ; WriteString(' :') ; WriteCard(Sym, 4) ; WriteString(' to scope: ') ;
5481 : : WriteKey(GetSymName(ScopeId)) ; WriteLn ;
5482 : : */
5483 : 24171849 : pSym = GetPsym (ScopeId);
5484 : 24171849 : switch (pSym->SymbolType)
5485 : : {
5486 : 10429888 : case SymbolTable_DefImpSym:
5487 : 10429888 : if (name != NameKey_NulName)
5488 : : {
5489 : 5960071 : SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, name, Sym);
5490 : : }
5491 : 10429888 : if (SymbolTable_IsEnumeration (Sym))
5492 : : {
5493 : 33160 : CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
5494 : : }
5495 : : break;
5496 : :
5497 : 2321473 : case SymbolTable_ModuleSym:
5498 : 2321473 : if (name != NameKey_NulName)
5499 : : {
5500 : 1510170 : SymbolKey_PutSymKey (pSym->Module.LocalSymbols, name, Sym);
5501 : : }
5502 : 2321473 : if (SymbolTable_IsEnumeration (Sym))
5503 : : {
5504 : 16207 : CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
5505 : : }
5506 : : break;
5507 : :
5508 : 11420488 : case SymbolTable_ProcedureSym:
5509 : 11420488 : if (name != NameKey_NulName)
5510 : : {
5511 : 11221420 : SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, name, Sym);
5512 : : }
5513 : 11420488 : if (SymbolTable_IsEnumeration (Sym))
5514 : : {
5515 : 0 : CheckEnumerationInList (pSym->Procedure.EnumerationScopeList, Sym);
5516 : : }
5517 : : break;
5518 : :
5519 : :
5520 : 0 : default:
5521 : 0 : M2Error_InternalError ((const char *) "should never get here", 21);
5522 : 24171849 : break;
5523 : : }
5524 : 24171849 : }
5525 : :
5526 : :
5527 : : /*
5528 : : PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
5529 : : Procedure symbols enumeration
5530 : : list onto the scope stack.
5531 : : */
5532 : :
5533 : 31179003 : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym)
5534 : : {
5535 : 31179003 : SymbolTable_PtrToSymbol pSym;
5536 : :
5537 : 31179003 : pSym = GetPsym (Sym);
5538 : 31179003 : switch (pSym->SymbolType)
5539 : : {
5540 : 10134179 : case SymbolTable_DefImpSym:
5541 : 10134179 : PlaceEnumerationListOntoScope (pSym->DefImp.EnumerationScopeList);
5542 : 10134179 : break;
5543 : :
5544 : 78919 : case SymbolTable_ModuleSym:
5545 : 78919 : PlaceEnumerationListOntoScope (pSym->Module.EnumerationScopeList);
5546 : 78919 : break;
5547 : :
5548 : 20965904 : case SymbolTable_ProcedureSym:
5549 : 20965904 : PlaceEnumerationListOntoScope (pSym->Procedure.EnumerationScopeList);
5550 : 20965904 : break;
5551 : :
5552 : :
5553 : 1 : default:
5554 : 1 : M2Error_InternalError ((const char *) "expecting - DefImp, Module or Procedure symbol", 46);
5555 : 31179002 : break;
5556 : : }
5557 : 31179002 : }
5558 : :
5559 : :
5560 : : /*
5561 : : PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
5562 : : scope stack. This list will automatically
5563 : : removed via one call to EndScope which
5564 : : matches the StartScope by which this
5565 : : procedure is invoked.
5566 : : */
5567 : :
5568 : 31179002 : static void PlaceEnumerationListOntoScope (Lists_List l)
5569 : : {
5570 : 31179002 : unsigned int i;
5571 : 31179002 : unsigned int n;
5572 : :
5573 : 31179002 : n = Lists_NoOfItemsInList (l);
5574 : 31179002 : i = 1;
5575 : 62932666 : while (i <= n)
5576 : : {
5577 : 574662 : SymbolTable_PseudoScope (Lists_GetItemFromList (l, i));
5578 : 574662 : i += 1;
5579 : : }
5580 : 31179002 : }
5581 : :
5582 : :
5583 : : /*
5584 : : SetFirstUsed - assigns the FirstUsed field in at to tok providing
5585 : : it has not already been set.
5586 : : */
5587 : :
5588 : 33 : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at)
5589 : : {
5590 : 0 : if ((*at).FirstUsed == M2LexBuf_UnknownTokenNo)
5591 : : {
5592 : 0 : (*at).FirstUsed = tok;
5593 : : }
5594 : 0 : }
5595 : :
5596 : :
5597 : : /*
5598 : : PutFirstUsed - sets tok to the first used providing it has not already been set.
5599 : : It also includes the read and write quad into the usage list
5600 : : providing the quad numbers are not 0.
5601 : : */
5602 : :
5603 : 36 : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_)
5604 : : {
5605 : 36 : SymbolTable_PtrToSymbol pSym;
5606 : :
5607 : 36 : if (SymbolTable_IsVar (object))
5608 : : {
5609 : 33 : pSym = GetPsym (object);
5610 : 33 : SetFirstUsed (tok, &pSym->Var.At);
5611 : 33 : if (read_ != 0)
5612 : : {
5613 : 18 : SymbolTable_PutReadQuad (object, SymbolTable_GetMode (object), read_);
5614 : : }
5615 : 33 : if (write_ != 0)
5616 : : {
5617 : 15 : SymbolTable_PutWriteQuad (object, SymbolTable_GetMode (object), write_);
5618 : : }
5619 : : }
5620 : 36 : }
5621 : :
5622 : :
5623 : : /*
5624 : : CanLookThroughScope - by default this procedure returns TRUE. It only returns
5625 : : FALSE if, throughProcedure, is FALSE and the ScopeSym is
5626 : : a procedure.
5627 : : */
5628 : :
5629 : 76008687 : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure)
5630 : : {
5631 : 76008687 : if (SymbolTable_IsProcedure (ScopeSym))
5632 : : {
5633 : : return throughProcedure;
5634 : : }
5635 : : else
5636 : : {
5637 : 0 : return true;
5638 : : }
5639 : : /* static analysis guarentees a RETURN statement will be used before here. */
5640 : : __builtin_unreachable ();
5641 : : }
5642 : :
5643 : :
5644 : : /*
5645 : : GetScopeSym - searches the current scope and below, providing that the
5646 : : scopes are transparent, for a symbol with name, name.
5647 : : It only passes over procedure scopes if, throughProcedure,
5648 : : is TRUE.
5649 : : */
5650 : :
5651 : 105299264 : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure)
5652 : : {
5653 : 105299264 : SymbolTable_PtrToCallFrame pCall;
5654 : 105299264 : unsigned int ScopeSym;
5655 : 105299264 : unsigned int ScopeId;
5656 : 105299264 : unsigned int Sym;
5657 : :
5658 : : /* DisplayScopes ; */
5659 : 105299264 : ScopeId = ScopePtr;
5660 : 105299264 : pCall = GetPcall (ScopeId);
5661 : 105299264 : ScopeSym = pCall->Search;
5662 : : /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) ; */
5663 : 105299264 : Sym = CheckScopeForSym (ScopeSym, name);
5664 : 430735928 : while ((((ScopeId > 0) && (Sym == SymbolTable_NulSym)) && (TransparentScope (ScopeSym))) && (CanLookThroughScope (ScopeSym, throughProcedure)))
5665 : : {
5666 : 76008687 : ScopeId -= 1;
5667 : 76008687 : pCall = GetPcall (ScopeId);
5668 : 76008687 : ScopeSym = pCall->Search;
5669 : 76008687 : Sym = CheckScopeForSym (ScopeSym, name);
5670 : : }
5671 : : /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) */
5672 : : /* IF Sym#NulSym THEN WriteKey(GetSymName(Sym)) END ; WriteLn ; */
5673 : 105299264 : return Sym;
5674 : : /* static analysis guarentees a RETURN statement will be used before here. */
5675 : : __builtin_unreachable ();
5676 : : }
5677 : :
5678 : :
5679 : : /*
5680 : : CheckScopeForSym - checks the scope, ScopeSym, for an identifier
5681 : : of name, name. CheckScopeForSym checks for
5682 : : the symbol by the GetLocalSym and also
5683 : : ExamineUnresolvedTree.
5684 : : */
5685 : :
5686 : 181308199 : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name)
5687 : : {
5688 : 181308199 : unsigned int Sym;
5689 : :
5690 : 181308199 : Sym = SymbolTable_GetLocalSym (ScopeSym, name);
5691 : 181308199 : if ((Sym == SymbolTable_NulSym) && (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym))))
5692 : : {
5693 : 72384636 : Sym = ExamineUnresolvedTree (ScopeSym, name);
5694 : : }
5695 : 181308199 : return Sym;
5696 : : /* static analysis guarentees a RETURN statement will be used before here. */
5697 : : __builtin_unreachable ();
5698 : : }
5699 : :
5700 : :
5701 : : /*
5702 : : GetModuleScopeId - returns the scope index to the next module starting
5703 : : at index, Id.
5704 : : Id will either point to a null scope (NulSym) or
5705 : : alternatively point to a Module or DefImp symbol.
5706 : : */
5707 : :
5708 : 136336 : static unsigned int GetModuleScopeId (unsigned int Id)
5709 : : {
5710 : 136336 : SymbolTable_PtrToCallFrame pCall;
5711 : 136336 : unsigned int s;
5712 : :
5713 : 136336 : pCall = GetPcall (Id);
5714 : 136336 : s = pCall->Search;
5715 : 226339 : while (((Id > 0) && (s != SymbolTable_NulSym)) && ((! (SymbolTable_IsModule (s))) && (! (SymbolTable_IsDefImp (s)))))
5716 : : {
5717 : 90003 : Id -= 1;
5718 : 90003 : pCall = GetPcall (Id);
5719 : 90003 : s = pCall->Search;
5720 : : }
5721 : 136336 : return Id;
5722 : : /* static analysis guarentees a RETURN statement will be used before here. */
5723 : : __builtin_unreachable ();
5724 : : }
5725 : :
5726 : :
5727 : : /*
5728 : : GetVisibleSym -
5729 : : */
5730 : :
5731 : 36 : static unsigned int GetVisibleSym (NameKey_Name name)
5732 : : {
5733 : 36 : SymbolTable_PtrToCallFrame pCall;
5734 : 36 : unsigned int Sym;
5735 : 36 : unsigned int i;
5736 : :
5737 : 36 : i = ScopePtr;
5738 : 42 : while (i >= 1)
5739 : : {
5740 : 42 : pCall = GetPcall (i);
5741 : 42 : if (pCall->Search == pCall->Main)
5742 : : {
5743 : 30 : return SymbolTable_GetLocalSym (pCall->Main, name);
5744 : : }
5745 : : else
5746 : : {
5747 : 12 : if (SymbolTable_IsEnumeration (pCall->Search))
5748 : : {
5749 : 12 : Sym = SymbolTable_GetLocalSym (pCall->Search, name);
5750 : 12 : if (Sym != SymbolTable_NulSym)
5751 : : {
5752 : : return Sym;
5753 : : }
5754 : : }
5755 : : }
5756 : 6 : i -= 1;
5757 : : }
5758 : : return SymbolTable_NulSym;
5759 : : /* static analysis guarentees a RETURN statement will be used before here. */
5760 : : __builtin_unreachable ();
5761 : : }
5762 : :
5763 : :
5764 : : /*
5765 : : IsAlreadyDeclaredSym - returns true if Sym has already been declared
5766 : : in the current main scope.
5767 : : */
5768 : :
5769 : 19184953 : static bool IsAlreadyDeclaredSym (NameKey_Name name)
5770 : : {
5771 : 19184953 : SymbolTable_PtrToCallFrame pCall;
5772 : 19184953 : unsigned int i;
5773 : :
5774 : 19184953 : i = ScopePtr;
5775 : 22098461 : while (i >= 1)
5776 : : {
5777 : 22098461 : pCall = GetPcall (i);
5778 : 22098461 : if (pCall->Search == pCall->Main)
5779 : : {
5780 : 19184947 : return (SymbolTable_GetLocalSym (pCall->Main, name)) != SymbolTable_NulSym;
5781 : : }
5782 : : else
5783 : : {
5784 : 2913514 : if ((SymbolTable_IsEnumeration (pCall->Search)) && ((SymbolTable_GetLocalSym (pCall->Search, name)) != SymbolTable_NulSym))
5785 : : {
5786 : : return true;
5787 : : }
5788 : : }
5789 : 2913508 : i -= 1;
5790 : : }
5791 : : return false;
5792 : : /* static analysis guarentees a RETURN statement will be used before here. */
5793 : : __builtin_unreachable ();
5794 : : }
5795 : :
5796 : :
5797 : : /*
5798 : : GenName - returns a new name consisting of pre, name, post concatenation.
5799 : : */
5800 : :
5801 : 407532 : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high)
5802 : : {
5803 : 407532 : DynamicStrings_String str;
5804 : 407532 : NameKey_Name result;
5805 : 407532 : char pre[_pre_high+1];
5806 : 407532 : char post[_post_high+1];
5807 : :
5808 : : /* make a local copy of each unbounded array. */
5809 : 407532 : memcpy (pre, pre_, _pre_high+1);
5810 : 407532 : memcpy (post, post_, _post_high+1);
5811 : :
5812 : 407532 : str = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (libname));
5813 : 407532 : str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) pre, _pre_high)));
5814 : 407532 : str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
5815 : 407532 : str = DynamicStrings_ConCat (str, DynamicStrings_InitString ((const char *) post, _post_high));
5816 : 407532 : result = NameKey_makekey (DynamicStrings_string (str));
5817 : 407532 : str = DynamicStrings_KillString (str);
5818 : 407532 : return result;
5819 : : /* static analysis guarentees a RETURN statement will be used before here. */
5820 : : __builtin_unreachable ();
5821 : 407532 : }
5822 : :
5823 : :
5824 : : /*
5825 : : InitCtor - initialize the ModuleCtor fields to NulSym.
5826 : : */
5827 : :
5828 : 202413 : static void InitCtor (SymbolTable_ModuleCtor *ctor)
5829 : : {
5830 : 202413 : (*ctor).ctor = SymbolTable_NulSym;
5831 : 202413 : (*ctor).dep = SymbolTable_NulSym;
5832 : 202413 : (*ctor).init = SymbolTable_NulSym;
5833 : 202413 : (*ctor).fini = SymbolTable_NulSym;
5834 : 0 : }
5835 : :
5836 : :
5837 : : /*
5838 : : InitCtorFields - initialize the ModuleCtor fields. An inner module has no
5839 : : ctor procedure.
5840 : : */
5841 : :
5842 : 83079 : 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)
5843 : : {
5844 : 83079 : if (M2Options_ScaffoldDynamic && ! inner)
5845 : : {
5846 : : /* The ctor procedure must be public. */
5847 : 82343 : (*ctor).ctor = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_ctor", 5));
5848 : 82343 : SymbolTable_PutCtor ((*ctor).ctor, true);
5849 : 82343 : M2Debug_Assert (pub);
5850 : 82343 : SymbolTable_PutPublic ((*ctor).ctor, pub);
5851 : 82343 : SymbolTable_PutExtern ((*ctor).ctor, ! pub);
5852 : 82343 : SymbolTable_PutMonoName ((*ctor).ctor, true);
5853 : : /* The dep procedure is local to the module. */
5854 : 82343 : (*ctor).dep = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_dep", 4));
5855 : 82343 : SymbolTable_PutMonoName ((*ctor).dep, true);
5856 : : }
5857 : : else
5858 : : {
5859 : 736 : (*ctor).ctor = SymbolTable_NulSym;
5860 : 736 : (*ctor).dep = SymbolTable_NulSym;
5861 : : }
5862 : : /* The init/fini procedures must be public. */
5863 : 83079 : (*ctor).init = SymbolTable_MakeProcedure (beginTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_init", 5));
5864 : 83079 : SymbolTable_PutPublic ((*ctor).init, pub);
5865 : 83079 : SymbolTable_PutExtern ((*ctor).init, ! pub);
5866 : 83079 : SymbolTable_PutMonoName ((*ctor).init, ! inner);
5867 : 83079 : M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).init);
5868 : 83079 : (*ctor).fini = SymbolTable_MakeProcedure (finallyTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_fini", 5));
5869 : 83079 : SymbolTable_PutPublic ((*ctor).fini, pub);
5870 : 83079 : SymbolTable_PutExtern ((*ctor).fini, ! pub);
5871 : 83079 : SymbolTable_PutMonoName ((*ctor).fini, ! inner);
5872 : 83079 : M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).fini);
5873 : 83079 : }
5874 : :
5875 : :
5876 : : /*
5877 : : CheckTok - checks to see that tok is at a known location. If not
5878 : : it uses GetTokenNo as a fall back.
5879 : : */
5880 : :
5881 : 23970547 : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high)
5882 : : {
5883 : 23970547 : DynamicStrings_String s;
5884 : 23970547 : char name[_name_high+1];
5885 : :
5886 : : /* make a local copy of each unbounded array. */
5887 : 23970547 : memcpy (name, name_, _name_high+1);
5888 : :
5889 : 23970547 : if (tok == M2LexBuf_UnknownTokenNo)
5890 : : {
5891 : 45024 : tok = M2LexBuf_GetTokenNo ();
5892 : 45024 : if (DebugUnknownToken)
5893 : : {
5894 : : s = DynamicStrings_InitString ((const char *) name, _name_high);
5895 : : s = DynamicStrings_ConCat (s, DynamicStrings_InitString ((const char *) " symbol {%W} has been created with an unknown token location", 60));
5896 : : M2MetaError_MetaErrorStringT0 (M2LexBuf_GetTokenNo (), s);
5897 : : }
5898 : : }
5899 : 23970547 : return tok;
5900 : : /* static analysis guarentees a RETURN statement will be used before here. */
5901 : : __builtin_unreachable ();
5902 : 0 : }
5903 : :
5904 : :
5905 : : /*
5906 : : GetLink - returns TRUE if the current module is only used for linkage.
5907 : : */
5908 : :
5909 : 377322 : static bool GetLink (void)
5910 : : {
5911 : 377322 : unsigned int OuterModule;
5912 : :
5913 : 377322 : OuterModule = SymbolTable_GetCurrentModule ();
5914 : 377322 : if (OuterModule != SymbolTable_NulSym)
5915 : : {
5916 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
5917 : 362093 : if (M2Comp_CompilingDefinitionModule ())
5918 : : {
5919 : 8566 : return SymbolTable_IsDefLink (OuterModule);
5920 : : }
5921 : : else
5922 : : {
5923 : 353527 : return SymbolTable_IsModLink (OuterModule);
5924 : : }
5925 : : }
5926 : : /* Default is that the module is for compiling. */
5927 : : return false;
5928 : : /* static analysis guarentees a RETURN statement will be used before here. */
5929 : : __builtin_unreachable ();
5930 : : }
5931 : :
5932 : :
5933 : : /*
5934 : : AddModuleToParent - adds symbol, Sym, to module, Parent.
5935 : : */
5936 : :
5937 : 428 : static void AddModuleToParent (unsigned int Sym, unsigned int Parent)
5938 : : {
5939 : 428 : SymbolTable_PtrToSymbol pSym;
5940 : :
5941 : 428 : pSym = GetPsym (Parent);
5942 : 428 : switch (pSym->SymbolType)
5943 : : {
5944 : 18 : case SymbolTable_DefImpSym:
5945 : 18 : Lists_PutItemIntoList (pSym->DefImp.ListOfModules, Sym);
5946 : 18 : break;
5947 : :
5948 : 254 : case SymbolTable_ModuleSym:
5949 : 254 : Lists_PutItemIntoList (pSym->Module.ListOfModules, Sym);
5950 : 254 : break;
5951 : :
5952 : 156 : case SymbolTable_ProcedureSym:
5953 : 156 : Lists_PutItemIntoList (pSym->Procedure.ListOfModules, Sym);
5954 : 156 : break;
5955 : :
5956 : :
5957 : 0 : default:
5958 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
5959 : 428 : break;
5960 : : }
5961 : 428 : }
5962 : :
5963 : :
5964 : : /*
5965 : : PutProcedureExternPublic - if procedure is not NulSym set extern
5966 : : and public booleans.
5967 : : */
5968 : :
5969 : 452272 : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub)
5970 : : {
5971 : 452272 : if (procedure != SymbolTable_NulSym)
5972 : : {
5973 : 452272 : SymbolTable_PutExtern (procedure, extern_);
5974 : 452272 : SymbolTable_PutPublic (procedure, pub);
5975 : : }
5976 : 452272 : }
5977 : :
5978 : :
5979 : : /*
5980 : : PutCtorExtern -
5981 : : */
5982 : :
5983 : 113068 : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_)
5984 : : {
5985 : : /* If the ctor does not exist then make it extern/ (~extern) public. */
5986 : 113068 : if ((*ctor).ctor == SymbolTable_NulSym)
5987 : : {
5988 : 19304 : (*ctor).ctor = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_ctor", 5));
5989 : 19304 : SymbolTable_PutMonoName ((*ctor).ctor, true);
5990 : : }
5991 : 113068 : PutProcedureExternPublic ((*ctor).ctor, extern_, ! extern_);
5992 : 113068 : SymbolTable_PutCtor ((*ctor).ctor, true);
5993 : : /* If the ctor does not exist then make it extern/ (~extern) public. */
5994 : 113068 : if ((*ctor).dep == SymbolTable_NulSym)
5995 : : {
5996 : 19304 : (*ctor).dep = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_dep", 4));
5997 : 19304 : SymbolTable_PutMonoName ((*ctor).dep, true);
5998 : : }
5999 : 113068 : PutProcedureExternPublic ((*ctor).dep, extern_, ! extern_);
6000 : : /* If init/fini do not exist then create them. */
6001 : 113068 : if ((*ctor).init == SymbolTable_NulSym)
6002 : : {
6003 : 19040 : (*ctor).init = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_init", 5));
6004 : 19040 : M2Scaffold_DeclareArgEnvParams (tok, (*ctor).init);
6005 : 19040 : SymbolTable_PutMonoName ((*ctor).init, ! (SymbolTable_IsInnerModule (sym)));
6006 : : }
6007 : 113068 : PutProcedureExternPublic ((*ctor).init, extern_, ! extern_);
6008 : 113068 : if ((*ctor).fini == SymbolTable_NulSym)
6009 : : {
6010 : 19040 : (*ctor).fini = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_fini", 5));
6011 : 19040 : M2Scaffold_DeclareArgEnvParams (tok, (*ctor).fini);
6012 : 19040 : SymbolTable_PutMonoName ((*ctor).fini, ! (SymbolTable_IsInnerModule (sym)));
6013 : : }
6014 : 113068 : PutProcedureExternPublic ((*ctor).fini, extern_, ! extern_);
6015 : 113068 : }
6016 : :
6017 : :
6018 : : /*
6019 : : InitProcedureDeclaration - initialize all the ProcedureDeclaration
6020 : : fields.
6021 : : */
6022 : :
6023 : 15158379 : static void InitProcedureDeclaration (SymbolTable_ProcedureDeclaration *decl)
6024 : : {
6025 : 15158379 : (*decl).Defined = false; /* Has the procedure been */
6026 : : /* declared yet? */
6027 : 15158379 : (*decl).ParamDefined = false; /* Have the parameters been */
6028 : : /* defined yet? */
6029 : 15158379 : (*decl).HasVarArgs = false; /* Does the procedure use ... ? */
6030 : 15158379 : (*decl).HasOptArg = false; /* Does this procedure use [ ] ? */
6031 : 15158379 : (*decl).IsNoReturn = false; /* Declared attribute noreturn ? */
6032 : 15158379 : (*decl).ReturnOptional = false; /* Is the return value optional? */
6033 : 15158379 : (*decl).ProcedureTok = M2LexBuf_UnknownTokenNo; /* Is the return value optional? */
6034 : 0 : }
6035 : :
6036 : :
6037 : : /*
6038 : : AddProcedureToList - adds a procedure, Proc, to the list of procedures
6039 : : in module, Mod.
6040 : : */
6041 : :
6042 : 5052793 : static void AddProcedureToList (unsigned int Mod, unsigned int Proc)
6043 : : {
6044 : 5052793 : SymbolTable_PtrToSymbol pSym;
6045 : :
6046 : 5052793 : pSym = GetPsym (Mod);
6047 : 5052793 : switch (pSym->SymbolType)
6048 : : {
6049 : 4376824 : case SymbolTable_DefImpSym:
6050 : 4376824 : Lists_PutItemIntoList (pSym->DefImp.ListOfProcs, Proc);
6051 : 4376824 : break;
6052 : :
6053 : 675537 : case SymbolTable_ModuleSym:
6054 : 675537 : Lists_PutItemIntoList (pSym->Module.ListOfProcs, Proc);
6055 : 675537 : break;
6056 : :
6057 : 432 : case SymbolTable_ProcedureSym:
6058 : 432 : Lists_PutItemIntoList (pSym->Procedure.ListOfProcs, Proc);
6059 : 432 : break;
6060 : :
6061 : :
6062 : 0 : default:
6063 : 0 : M2Error_InternalError ((const char *) "expecting ModuleSym, DefImpSym or ProcedureSym symbol", 53);
6064 : 5052793 : break;
6065 : : }
6066 : 5052793 : }
6067 : :
6068 : :
6069 : : /*
6070 : : AddVarToScopeList - adds symbol, sym, to, scope.
6071 : : */
6072 : :
6073 : 11330065 : static void AddVarToScopeList (unsigned int scope, unsigned int sym)
6074 : : {
6075 : 11330065 : SymbolTable_PtrToSymbol pSym;
6076 : :
6077 : 11330065 : pSym = GetPsym (scope);
6078 : 11330065 : switch (pSym->SymbolType)
6079 : : {
6080 : 11081660 : case SymbolTable_ProcedureSym:
6081 : 11081660 : Lists_PutItemIntoList (pSym->Procedure.ListOfVars, sym);
6082 : 11081660 : break;
6083 : :
6084 : 102395 : case SymbolTable_ModuleSym:
6085 : 102395 : Lists_PutItemIntoList (pSym->Module.ListOfVars, sym);
6086 : 102395 : break;
6087 : :
6088 : 146010 : case SymbolTable_DefImpSym:
6089 : 146010 : Lists_PutItemIntoList (pSym->DefImp.ListOfVars, sym);
6090 : 146010 : break;
6091 : :
6092 : :
6093 : 0 : default:
6094 : 0 : M2Error_InternalError ((const char *) "expecting Procedure or Module symbol", 36);
6095 : 11330065 : break;
6096 : : }
6097 : 11330065 : }
6098 : :
6099 : :
6100 : : /*
6101 : : AddVarToList - add a variable symbol to the list of variables maintained
6102 : : by the inner most scope. (Procedure or Module).
6103 : : */
6104 : :
6105 : 11330047 : static void AddVarToList (unsigned int Sym)
6106 : : {
6107 : 11330047 : SymbolTable_PtrToCallFrame pCall;
6108 : :
6109 : 11330047 : pCall = GetPcall (ScopePtr);
6110 : 11330047 : AddVarToScopeList (pCall->Main, Sym);
6111 : 11330047 : }
6112 : :
6113 : :
6114 : : /*
6115 : : InitVarDecl - initialize the variable and type token location positions.
6116 : : */
6117 : :
6118 : 11330047 : static void InitVarDecl (SymbolTable_VarDecl *decl, unsigned int vartok)
6119 : : {
6120 : 11330047 : (*decl).FullTok = M2LexBuf_UnknownTokenNo;
6121 : 11330047 : (*decl).VarTok = vartok;
6122 : 11330047 : (*decl).TypeTok = M2LexBuf_UnknownTokenNo;
6123 : 0 : }
6124 : :
6125 : :
6126 : : /*
6127 : : doPutVarDeclTypeTok - places typetok into decl.TypeTok.
6128 : : sym must be a variable.
6129 : : */
6130 : :
6131 : 0 : static void doPutVarDeclTypeTok (unsigned int sym, unsigned int typetok)
6132 : : {
6133 : 0 : SymbolTable_PtrToSymbol pSym;
6134 : :
6135 : 0 : M2Debug_Assert (SymbolTable_IsVar (sym));
6136 : 0 : pSym = GetPsym (sym);
6137 : 0 : pSym->Var.Declared.TypeTok = typetok;
6138 : 0 : }
6139 : :
6140 : :
6141 : : /*
6142 : : doPutVarDeclTok - places vartok into decl.VarTok.
6143 : : sym must be a variable.
6144 : : */
6145 : :
6146 : 1689828 : static void doPutVarDeclTok (unsigned int sym, unsigned int vartok)
6147 : : {
6148 : 1689828 : SymbolTable_PtrToSymbol pSym;
6149 : :
6150 : 1689828 : M2Debug_Assert (SymbolTable_IsVar (sym));
6151 : 1689828 : pSym = GetPsym (sym);
6152 : 1689828 : pSym->Var.Declared.VarTok = vartok;
6153 : 1689828 : }
6154 : :
6155 : :
6156 : : /*
6157 : : doGetVarDeclTok - return decl.VarTok for a variable.
6158 : : */
6159 : :
6160 : 60 : static unsigned int doGetVarDeclTok (unsigned int sym)
6161 : : {
6162 : 60 : SymbolTable_PtrToSymbol pSym;
6163 : :
6164 : 60 : pSym = GetPsym (sym);
6165 : 60 : M2Debug_Assert (SymbolTable_IsVar (sym));
6166 : 60 : return pSym->Var.Declared.VarTok;
6167 : : /* static analysis guarentees a RETURN statement will be used before here. */
6168 : : __builtin_unreachable ();
6169 : : }
6170 : :
6171 : :
6172 : : /*
6173 : : doGetVarDeclTypeTok - return decl.TypeTok for a variable.
6174 : : */
6175 : :
6176 : 0 : static unsigned int doGetVarDeclTypeTok (unsigned int sym)
6177 : : {
6178 : 0 : SymbolTable_PtrToSymbol pSym;
6179 : :
6180 : 0 : pSym = GetPsym (sym);
6181 : 0 : M2Debug_Assert (SymbolTable_IsVar (sym));
6182 : 0 : return pSym->Var.Declared.TypeTok;
6183 : : /* static analysis guarentees a RETURN statement will be used before here. */
6184 : : __builtin_unreachable ();
6185 : : }
6186 : :
6187 : :
6188 : : /*
6189 : : doGetVarDeclFullTok - return the full declaration of var: type.
6190 : : */
6191 : :
6192 : 282 : static unsigned int doGetVarDeclFullTok (unsigned int sym)
6193 : : {
6194 : 282 : SymbolTable_PtrToSymbol pSym;
6195 : :
6196 : 282 : pSym = GetPsym (sym);
6197 : 282 : M2Debug_Assert (SymbolTable_IsVar (sym));
6198 : 282 : if (pSym->Var.Declared.FullTok == M2LexBuf_UnknownTokenNo)
6199 : : {
6200 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
6201 : 282 : if (pSym->Var.Declared.TypeTok == M2LexBuf_UnknownTokenNo)
6202 : : {
6203 : 66 : return pSym->Var.Declared.VarTok;
6204 : : }
6205 : : else
6206 : : {
6207 : 216 : pSym->Var.Declared.FullTok = M2LexBuf_MakeVirtual2Tok (pSym->Var.Declared.VarTok, pSym->Var.Declared.TypeTok);
6208 : : }
6209 : : }
6210 : 216 : return pSym->Var.Declared.FullTok;
6211 : : /* static analysis guarentees a RETURN statement will be used before here. */
6212 : : __builtin_unreachable ();
6213 : : }
6214 : :
6215 : :
6216 : : /*
6217 : : FillInRecordFields - given a new symbol, sym, make it a record symbol
6218 : : and initialize its fields.
6219 : : */
6220 : :
6221 : 101859 : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf)
6222 : : {
6223 : 101859 : SymbolTable_PtrToSymbol pSym;
6224 : :
6225 : 101859 : if (! (SymbolTable_IsError (sym)))
6226 : : {
6227 : 101853 : pSym = GetPsym (sym);
6228 : 101853 : pSym->SymbolType = SymbolTable_RecordSym;
6229 : 101853 : pSym->Record.name = RecordName;
6230 : 101853 : SymbolKey_InitTree (&pSym->Record.LocalSymbols);
6231 : 101853 : pSym->Record.Size = M2ALU_InitValue ();
6232 : 101853 : Lists_InitList (&pSym->Record.ListOfSons); /* List of RecordFieldSym and VarientSym */
6233 : 101853 : pSym->Record.oafamily = oaf; /* List of RecordFieldSym and VarientSym */
6234 : 101853 : pSym->Record.Parent = SymbolTable_NulSym;
6235 : 101853 : pSym->Record.Align = SymbolTable_NulSym;
6236 : 101853 : pSym->Record.DefaultAlign = SymbolTable_NulSym;
6237 : 101853 : pSym->Record.DeclPacked = false;
6238 : 101853 : pSym->Record.DeclResolved = false;
6239 : 101853 : pSym->Record.Scope = scope;
6240 : 101853 : InitWhereDeclaredTok (tok, &pSym->Record.At);
6241 : : }
6242 : 101859 : }
6243 : :
6244 : :
6245 : : /*
6246 : : HandleHiddenOrDeclare -
6247 : : */
6248 : :
6249 : 6444593 : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf)
6250 : : {
6251 : 6444593 : unsigned int sym;
6252 : :
6253 : 6444593 : sym = CheckForHiddenType (name);
6254 : 6444593 : if (sym == SymbolTable_NulSym)
6255 : : {
6256 : 6428935 : sym = DeclareSym (tok, name);
6257 : 6428935 : if (! (SymbolTable_IsError (sym)))
6258 : : {
6259 : : /* Now add this type to the symbol table of the current scope */
6260 : 6428923 : AddSymToScope (sym, name);
6261 : : }
6262 : : }
6263 : 6444593 : (*oaf) = SymbolTable_GetOAFamily (sym);
6264 : 6444593 : return sym;
6265 : : /* static analysis guarentees a RETURN statement will be used before here. */
6266 : : __builtin_unreachable ();
6267 : : }
6268 : :
6269 : :
6270 : : /*
6271 : : CreateConstLit -
6272 : : */
6273 : :
6274 : 613898 : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
6275 : : {
6276 : 613898 : SymbolTable_PtrToSymbol pSym;
6277 : 613898 : unsigned int Sym;
6278 : 613898 : bool overflow;
6279 : :
6280 : 613898 : overflow = false;
6281 : 613898 : if (constType == SymbolTable_NulSym)
6282 : : {
6283 : 468240 : constType = GetConstLitType (tok, constName, &overflow, true);
6284 : : }
6285 : 613898 : NewSym (&Sym);
6286 : 613898 : pSym = GetPsym (Sym);
6287 : 613898 : pSym->SymbolType = SymbolTable_ConstLitSym;
6288 : 613898 : switch (pSym->SymbolType)
6289 : : {
6290 : 613898 : case SymbolTable_ConstLitSym:
6291 : 613898 : pSym->ConstLit.name = constName;
6292 : 613898 : pSym->ConstLit.Value = M2ALU_InitValue ();
6293 : 613898 : M2ALU_PushString (tok, constName, ! overflow);
6294 : 613898 : M2ALU_PopInto (pSym->ConstLit.Value);
6295 : 613898 : pSym->ConstLit.Type = constType;
6296 : 613898 : pSym->ConstLit.IsSet = false;
6297 : 613898 : pSym->ConstLit.IsInternal = false; /* Is it a default BY constant
6298 : : expression? */
6299 : 613898 : pSym->ConstLit.IsConstructor = false; /* Is it a default BY constant
6300 : : expression? */
6301 : 613898 : pSym->ConstLit.FromType = SymbolTable_NulSym; /* type is determined FromType */
6302 : 613898 : pSym->ConstLit.RangeError = overflow; /* type is determined FromType */
6303 : 613898 : pSym->ConstLit.UnresFromType = false; /* is Type resolved? */
6304 : 613898 : pSym->ConstLit.Scope = SymbolTable_GetCurrentScope (); /* is Type resolved? */
6305 : 613898 : InitWhereDeclaredTok (tok, &pSym->ConstLit.At);
6306 : 613898 : InitWhereFirstUsedTok (tok, &pSym->ConstLit.At);
6307 : 613898 : break;
6308 : :
6309 : :
6310 : : default:
6311 : : M2Error_InternalError ((const char *) "expecting ConstLit symbol", 25);
6312 : 613898 : break;
6313 : : }
6314 : 613898 : return Sym;
6315 : : /* static analysis guarentees a RETURN statement will be used before here. */
6316 : : __builtin_unreachable ();
6317 : : }
6318 : :
6319 : :
6320 : : /*
6321 : : LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
6322 : : matches tok, constName and constType.
6323 : : */
6324 : :
6325 : 1642567 : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType)
6326 : : {
6327 : 1642567 : SymbolTable_ConstLitPoolEntry pe;
6328 : 1642567 : unsigned int rootIndex;
6329 : :
6330 : 1642567 : rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
6331 : 1642567 : if (rootIndex != 0)
6332 : : {
6333 : 1341701 : pe = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
6334 : 16882942 : while (pe != NULL)
6335 : : {
6336 : 15228209 : if (((pe->tok == tok) && (pe->constName == constName)) && (pe->constType == constType))
6337 : : {
6338 : 1028669 : return pe->sym;
6339 : : }
6340 : 14199540 : pe = pe->next;
6341 : : }
6342 : : }
6343 : : return SymbolTable_NulSym;
6344 : : /* static analysis guarentees a RETURN statement will be used before here. */
6345 : : __builtin_unreachable ();
6346 : : }
6347 : :
6348 : :
6349 : : /*
6350 : : AddConstLitPoolEntry - adds sym to the constlit pool.
6351 : : */
6352 : :
6353 : 613898 : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType)
6354 : : {
6355 : 613898 : SymbolTable_ConstLitPoolEntry pe;
6356 : 613898 : SymbolTable_ConstLitPoolEntry old;
6357 : 613898 : unsigned int rootIndex;
6358 : 613898 : unsigned int high;
6359 : :
6360 : 613898 : rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
6361 : 613898 : if (rootIndex == SymbolKey_NulKey)
6362 : : {
6363 : 300866 : high = Indexing_HighIndice (ConstLitArray);
6364 : 300866 : Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
6365 : 300866 : if (pe == NULL)
6366 : : {
6367 : 0 : M2Error_InternalError ((const char *) "out of memory", 13);
6368 : : }
6369 : : else
6370 : : {
6371 : 300866 : pe->sym = sym;
6372 : 300866 : pe->tok = tok;
6373 : 300866 : pe->constName = constName;
6374 : 300866 : pe->constType = constType;
6375 : 300866 : pe->next = NULL;
6376 : 300866 : SymbolKey_PutSymKey (ConstLitPoolTree, constName, high+1);
6377 : 300866 : Indexing_PutIndice (ConstLitArray, high+1, reinterpret_cast <void *> (pe));
6378 : : }
6379 : : }
6380 : : else
6381 : : {
6382 : 313032 : Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
6383 : 313032 : if (pe == NULL)
6384 : : {
6385 : 0 : M2Error_InternalError ((const char *) "out of memory", 13);
6386 : : }
6387 : : else
6388 : : {
6389 : 313032 : old = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
6390 : 313032 : pe->sym = sym;
6391 : 313032 : pe->tok = tok;
6392 : 313032 : pe->constName = constName;
6393 : 313032 : pe->constType = constType;
6394 : 313032 : pe->next = old;
6395 : 313032 : Indexing_PutIndice (ConstLitArray, rootIndex, reinterpret_cast <void *> (pe));
6396 : : }
6397 : : }
6398 : 613898 : }
6399 : :
6400 : :
6401 : : /*
6402 : : InitConstString - initialize the constant string.
6403 : : */
6404 : :
6405 : 372188 : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known)
6406 : : {
6407 : 372188 : SymbolTable_PtrToSymbol pSym;
6408 : :
6409 : 372188 : pSym = GetPsym (sym);
6410 : 372188 : pSym->SymbolType = SymbolTable_ConstStringSym;
6411 : 372188 : switch (pSym->SymbolType)
6412 : : {
6413 : 372188 : case SymbolTable_ConstStringSym:
6414 : 372188 : pSym->ConstString.name = name;
6415 : 372188 : pSym->ConstString.StringVariant = kind;
6416 : 372188 : pSym->ConstString.Scope = SymbolTable_GetCurrentScope ();
6417 : 372188 : InitWhereDeclaredTok (tok, &pSym->ConstString.At);
6418 : 372188 : SymbolTable_PutConstStringKnown (tok, sym, contents, escape, known);
6419 : 372188 : break;
6420 : :
6421 : :
6422 : : default:
6423 : : M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
6424 : 372188 : break;
6425 : : }
6426 : 372188 : }
6427 : :
6428 : :
6429 : : /*
6430 : : GetConstStringKind - return the StringVariant field associated with sym.
6431 : : */
6432 : :
6433 : 295175 : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym)
6434 : : {
6435 : 295175 : SymbolTable_PtrToSymbol pSym;
6436 : :
6437 : 295175 : pSym = GetPsym (sym);
6438 : 295175 : switch (pSym->SymbolType)
6439 : : {
6440 : 295175 : case SymbolTable_ConstStringSym:
6441 : 295175 : return pSym->ConstString.StringVariant;
6442 : 0 : break;
6443 : :
6444 : :
6445 : 0 : default:
6446 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
6447 : : break;
6448 : : }
6449 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6450 : : __builtin_unreachable ();
6451 : : }
6452 : :
6453 : :
6454 : : /*
6455 : : CanUseBuiltin - returns TRUE if the procedure, Sym, can be
6456 : : inlined via a builtin function.
6457 : : */
6458 : :
6459 : 19162 : static bool CanUseBuiltin (unsigned int Sym)
6460 : : {
6461 : 19162 : return ! M2Options_DebugBuiltins && ((m2builtins_BuiltinExists (reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetProcedureBuiltin (Sym))))) || (m2builtins_BuiltinExists (reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (Sym))))));
6462 : : /* static analysis guarentees a RETURN statement will be used before here. */
6463 : : __builtin_unreachable ();
6464 : : }
6465 : :
6466 : :
6467 : : /*
6468 : : InitPacked - initialise packedInfo to FALSE and NulSym.
6469 : : */
6470 : :
6471 : 958050 : static void InitPacked (SymbolTable_PackedInfo *packedInfo)
6472 : : {
6473 : 958050 : (*packedInfo).IsPacked = false;
6474 : 958050 : (*packedInfo).PackedEquiv = SymbolTable_NulSym;
6475 : 0 : }
6476 : :
6477 : :
6478 : : /*
6479 : : doEquivalent - create a packed equivalent symbol for, sym, and return the
6480 : : new symbol. It sets both fields in packedInfo to FALSE
6481 : : and the new symbol.
6482 : : */
6483 : :
6484 : 14319 : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
6485 : : {
6486 : 14319 : unsigned int nSym;
6487 : 14319 : SymbolTable_PtrToSymbol pSym;
6488 : :
6489 : 14319 : NewSym (&nSym);
6490 : 14319 : pSym = GetPsym (nSym);
6491 : 14319 : pSym->SymbolType = SymbolTable_EquivSym;
6492 : 14319 : pSym->Equiv.nonPacked = sym;
6493 : 14319 : pSym->Equiv.packedInfo.IsPacked = true;
6494 : 14319 : pSym->Equiv.packedInfo.PackedEquiv = SymbolTable_NulSym;
6495 : 14319 : (*packedInfo).IsPacked = false;
6496 : 14319 : (*packedInfo).PackedEquiv = nSym;
6497 : 14319 : return nSym;
6498 : : /* static analysis guarentees a RETURN statement will be used before here. */
6499 : : __builtin_unreachable ();
6500 : : }
6501 : :
6502 : :
6503 : : /*
6504 : : MakeEquivalent - return the equivalent packed symbol for, sym.
6505 : : */
6506 : :
6507 : 14319 : static unsigned int MakeEquivalent (unsigned int sym)
6508 : : {
6509 : 14319 : SymbolTable_PtrToSymbol pSym;
6510 : :
6511 : 14319 : pSym = GetPsym (sym);
6512 : 14319 : switch (pSym->SymbolType)
6513 : : {
6514 : 14259 : case SymbolTable_EnumerationSym:
6515 : 14259 : return doEquivalent (&pSym->Enumeration.packedInfo, sym);
6516 : 60 : break;
6517 : :
6518 : 60 : case SymbolTable_SubrangeSym:
6519 : 60 : return doEquivalent (&pSym->Subrange.packedInfo, sym);
6520 : 0 : break;
6521 : :
6522 : 0 : case SymbolTable_TypeSym:
6523 : 0 : return doEquivalent (&pSym->Type.packedInfo, sym);
6524 : 0 : break;
6525 : :
6526 : 0 : case SymbolTable_SetSym:
6527 : 0 : return doEquivalent (&pSym->Set.packedInfo, sym);
6528 : 0 : break;
6529 : :
6530 : :
6531 : 0 : default:
6532 : 0 : M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
6533 : : break;
6534 : : }
6535 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6536 : : __builtin_unreachable ();
6537 : : }
6538 : :
6539 : :
6540 : : /*
6541 : : GetEquivalent -
6542 : : */
6543 : :
6544 : 14559 : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
6545 : : {
6546 : 14559 : if ((*packedInfo).IsPacked)
6547 : : {
6548 : : return sym;
6549 : : }
6550 : 14559 : else if ((*packedInfo).PackedEquiv == SymbolTable_NulSym)
6551 : : {
6552 : : /* avoid dangling else. */
6553 : 14319 : (*packedInfo).PackedEquiv = MakeEquivalent (sym);
6554 : : }
6555 : 14559 : return (*packedInfo).PackedEquiv;
6556 : : /* static analysis guarentees a RETURN statement will be used before here. */
6557 : : __builtin_unreachable ();
6558 : : }
6559 : :
6560 : :
6561 : : /*
6562 : : doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
6563 : : */
6564 : :
6565 : 1361621354 : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase)
6566 : : {
6567 : 1361621354 : SymbolTable_PtrToSymbol pSym;
6568 : 1361621354 : unsigned int type;
6569 : :
6570 : 1361621354 : type = SymbolTable_NulSym;
6571 : 1361621354 : M2Debug_Assert (sym != SymbolTable_NulSym);
6572 : 1361621354 : pSym = GetPsym (sym);
6573 : 1361621354 : switch (pSym->SymbolType)
6574 : : {
6575 : 0 : case SymbolTable_OAFamilySym:
6576 : 0 : type = pSym->OAFamily.SimpleType;
6577 : 0 : break;
6578 : :
6579 : 156934537 : case SymbolTable_VarSym:
6580 : 156934537 : type = GetTypeOfVar (sym);
6581 : 156934537 : break;
6582 : :
6583 : 43916816 : case SymbolTable_ConstLitSym:
6584 : 43916816 : type = pSym->ConstLit.Type;
6585 : 43916816 : break;
6586 : :
6587 : 38536608 : case SymbolTable_ConstVarSym:
6588 : 38536608 : type = pSym->ConstVar.Type;
6589 : 38536608 : break;
6590 : :
6591 : 9857683 : case SymbolTable_ConstStringSym:
6592 : 9857683 : if (pSym->ConstString.Length == 1)
6593 : : {
6594 : 2012819 : type = M2Base_Char;
6595 : : }
6596 : : else
6597 : : {
6598 : : type = SymbolTable_NulSym; /* No type for a string */
6599 : : }
6600 : : break;
6601 : :
6602 : 186283123 : case SymbolTable_TypeSym:
6603 : 186283123 : type = pSym->Type.Type;
6604 : 186283123 : break;
6605 : :
6606 : 473842902 : case SymbolTable_RecordFieldSym:
6607 : 473842902 : type = pSym->RecordField.Type;
6608 : 473842902 : break;
6609 : :
6610 : : case SymbolTable_RecordSym:
6611 : : type = SymbolTable_NulSym; /* No type for a record */
6612 : : break;
6613 : :
6614 : : case SymbolTable_VarientSym:
6615 : : type = SymbolTable_NulSym; /* No type for a record */
6616 : : break;
6617 : :
6618 : 86419127 : case SymbolTable_EnumerationFieldSym:
6619 : 86419127 : type = pSym->EnumerationField.Type; /* No type for a record */
6620 : 86419127 : break;
6621 : :
6622 : : case SymbolTable_EnumerationSym:
6623 : : type = SymbolTable_NulSym; /* No type for enumeration */
6624 : : break;
6625 : :
6626 : 197382361 : case SymbolTable_PointerSym:
6627 : 197382361 : type = pSym->Pointer.Type; /* No type for enumeration */
6628 : 197382361 : break;
6629 : :
6630 : 26161911 : case SymbolTable_ProcedureSym:
6631 : 26161911 : type = pSym->Procedure.ReturnType;
6632 : 26161911 : break;
6633 : :
6634 : 11065884 : case SymbolTable_ProcTypeSym:
6635 : 11065884 : type = pSym->ProcType.ReturnType;
6636 : 11065884 : break;
6637 : :
6638 : 19280811 : case SymbolTable_ParamSym:
6639 : 19280811 : type = pSym->Param.Type;
6640 : 19280811 : break;
6641 : :
6642 : 4306384 : case SymbolTable_VarParamSym:
6643 : 4306384 : type = pSym->VarParam.Type;
6644 : 4306384 : break;
6645 : :
6646 : 24096140 : case SymbolTable_SubrangeSym:
6647 : 24096140 : type = pSym->Subrange.Type;
6648 : 24096140 : break;
6649 : :
6650 : 10800052 : case SymbolTable_ArraySym:
6651 : 10800052 : type = pSym->Array.Type;
6652 : 10800052 : break;
6653 : :
6654 : 10978712 : case SymbolTable_SubscriptSym:
6655 : 10978712 : type = pSym->Subscript.Type;
6656 : 10978712 : break;
6657 : :
6658 : 2249381 : case SymbolTable_SetSym:
6659 : 2249381 : type = pSym->Set.Type;
6660 : 2249381 : break;
6661 : :
6662 : 58428103 : case SymbolTable_UnboundedSym:
6663 : 58428103 : type = pSym->Unbounded.Type;
6664 : 58428103 : break;
6665 : :
6666 : : case SymbolTable_UndefinedSym:
6667 : : type = SymbolTable_NulSym;
6668 : : break;
6669 : :
6670 : 0 : case SymbolTable_PartialUnboundedSym:
6671 : 0 : type = pSym->PartialUnbounded.Type;
6672 : 0 : break;
6673 : :
6674 : : case SymbolTable_ObjectSym:
6675 : : type = SymbolTable_NulSym;
6676 : : break;
6677 : :
6678 : :
6679 : 6 : default:
6680 : 6 : M2Error_InternalError ((const char *) "not implemented yet", 19);
6681 : 1352695671 : break;
6682 : : }
6683 : 1361621348 : if (((type == SymbolTable_NulSym) && (SymbolTable_IsType (sym))) && ! skipBase)
6684 : : {
6685 : : return sym; /* sym is a base type */
6686 : : }
6687 : 1346317086 : else if (type != SymbolTable_NulSym)
6688 : : {
6689 : : /* avoid dangling else. */
6690 : 1142183722 : if ((SymbolTable_IsType (type)) && skipEquiv)
6691 : : {
6692 : 15959883 : if ((! (SymbolTable_IsHiddenType (type))) || skipHidden)
6693 : : {
6694 : 15789658 : if (((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym) || skipAlign)
6695 : : {
6696 : 15789640 : return doGetType (type, skipEquiv, skipAlign, skipHidden, skipBase);
6697 : : }
6698 : : }
6699 : : }
6700 : : }
6701 : : return type;
6702 : : /* static analysis guarentees a RETURN statement will be used before here. */
6703 : : __builtin_unreachable ();
6704 : : }
6705 : :
6706 : :
6707 : : /*
6708 : : GetTypeOfVar - returns the type of symbol, var.
6709 : : */
6710 : :
6711 : 246322176 : static unsigned int GetTypeOfVar (unsigned int var)
6712 : : {
6713 : 246322176 : SymbolTable_PtrToSymbol pSym;
6714 : 246322176 : unsigned int high;
6715 : :
6716 : 246322176 : pSym = GetPsym (var);
6717 : 246322176 : switch (pSym->SymbolType)
6718 : : {
6719 : 246322176 : case SymbolTable_VarSym:
6720 : 246322176 : if (pSym->Var.IsTemp && pSym->Var.IsComponentRef)
6721 : : {
6722 : 6339160 : high = Indexing_HighIndice (pSym->Var.list);
6723 : 12678320 : return SymbolTable_GetType (GetFromIndex (pSym->Var.list, high));
6724 : : }
6725 : : else
6726 : : {
6727 : 239983016 : return pSym->Var.Type;
6728 : : }
6729 : 0 : break;
6730 : :
6731 : :
6732 : 0 : default:
6733 : 0 : M2Error_InternalError ((const char *) "expecting a var symbol", 22);
6734 : : break;
6735 : : }
6736 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6737 : : __builtin_unreachable ();
6738 : : }
6739 : :
6740 : :
6741 : : /*
6742 : : GetConstLitType - returns the type of the constant of, name.
6743 : : All floating point constants have type LONGREAL.
6744 : : Character constants are type CHAR.
6745 : : Integer values are INTEGER, LONGINT or LONGCARD
6746 : : depending upon their value.
6747 : : */
6748 : :
6749 : 468240 : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError)
6750 : : {
6751 : 468240 : location_t loc;
6752 : 468240 : DynamicStrings_String s;
6753 : :
6754 : 468240 : s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name));
6755 : 468240 : if ((DynamicStrings_char (s, -1)) == 'C')
6756 : : {
6757 : 119667 : s = DynamicStrings_KillString (s);
6758 : 119667 : return M2Base_Char;
6759 : : }
6760 : : else
6761 : : {
6762 : 348573 : if ((DynamicStrings_Index (s, '.', 0)) != -1) /* found a '.' in our constant */
6763 : : {
6764 : 6676 : s = DynamicStrings_KillString (s);
6765 : 6676 : return M2Base_RType;
6766 : : }
6767 : 341897 : loc = M2LexBuf_TokenToLocation (tok);
6768 : 341897 : switch (DynamicStrings_char (s, -1))
6769 : : {
6770 : 694 : case 'H':
6771 : 694 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 16, issueError);
6772 : 694 : break;
6773 : :
6774 : 2734 : case 'B':
6775 : 2734 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 8, issueError);
6776 : 2734 : break;
6777 : :
6778 : 24 : case 'A':
6779 : 24 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 2, issueError);
6780 : 24 : break;
6781 : :
6782 : :
6783 : 338445 : default:
6784 : 338445 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 10, issueError);
6785 : 338445 : break;
6786 : : }
6787 : 341897 : s = DynamicStrings_KillString (s);
6788 : 341897 : return M2Base_ZType;
6789 : : }
6790 : : /* static analysis guarentees a RETURN statement will be used before here. */
6791 : : __builtin_unreachable ();
6792 : : }
6793 : :
6794 : :
6795 : : /*
6796 : : GetNthFromComponent -
6797 : : */
6798 : :
6799 : 372415 : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n)
6800 : : {
6801 : 372415 : SymbolTable_PtrToSymbol pSym;
6802 : :
6803 : 372415 : pSym = GetPsym (Sym);
6804 : 372415 : switch (pSym->SymbolType)
6805 : : {
6806 : 372415 : case SymbolTable_VarSym:
6807 : 372415 : if (SymbolTable_IsComponent (Sym))
6808 : : {
6809 : 372415 : if (Indexing_InBounds (pSym->Var.list, n))
6810 : : {
6811 : 499948 : return GetFromIndex (pSym->Var.list, n);
6812 : : }
6813 : : else
6814 : : {
6815 : : return SymbolTable_NulSym;
6816 : : }
6817 : : }
6818 : : else
6819 : : {
6820 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
6821 : : }
6822 : 0 : break;
6823 : :
6824 : :
6825 : 0 : default:
6826 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
6827 : : break;
6828 : : }
6829 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6830 : : __builtin_unreachable ();
6831 : : }
6832 : :
6833 : :
6834 : : /*
6835 : : GetNthParamChoice - returns the parameter definition from
6836 : : sym:ParamNo:kind or NulSym.
6837 : : */
6838 : :
6839 : 625283 : static unsigned int GetNthParamChoice (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind kind)
6840 : : {
6841 : 625283 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
6842 : : {
6843 : 625283 : return SymbolTable_GetNthParam (sym, kind, ParamNo);
6844 : : }
6845 : : else
6846 : : {
6847 : : return SymbolTable_NulSym;
6848 : : }
6849 : : /* static analysis guarentees a RETURN statement will be used before here. */
6850 : : __builtin_unreachable ();
6851 : : }
6852 : :
6853 : :
6854 : : /*
6855 : : GetNthParamOrdered - returns the parameter definition from list {a, b, c}
6856 : : in order.
6857 : : sym:ParamNo:{a,b,c} or NulSym.
6858 : : */
6859 : :
6860 : 625283 : static unsigned int GetNthParamOrdered (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind a, SymbolTable_ProcedureKind b, SymbolTable_ProcedureKind c)
6861 : : {
6862 : 625283 : if (SymbolTable_GetProcedureParametersDefined (sym, a))
6863 : : {
6864 : 625283 : return GetNthParamChoice (sym, ParamNo, a);
6865 : : }
6866 : 0 : else if (SymbolTable_GetProcedureParametersDefined (sym, b))
6867 : : {
6868 : : /* avoid dangling else. */
6869 : 0 : return GetNthParamChoice (sym, ParamNo, b);
6870 : : }
6871 : 0 : else if (SymbolTable_GetProcedureParametersDefined (sym, c))
6872 : : {
6873 : : /* avoid dangling else. */
6874 : 0 : return GetNthParamChoice (sym, ParamNo, c);
6875 : : }
6876 : : else
6877 : : {
6878 : : /* avoid dangling else. */
6879 : : return SymbolTable_NulSym;
6880 : : }
6881 : : /* static analysis guarentees a RETURN statement will be used before here. */
6882 : : __builtin_unreachable ();
6883 : : }
6884 : :
6885 : :
6886 : : /*
6887 : : GetOuterModuleScope - returns the outer module symbol scope for sym.
6888 : : */
6889 : :
6890 : 1250566 : static unsigned int GetOuterModuleScope (unsigned int sym)
6891 : : {
6892 : 1876035 : do {
6893 : 1876035 : if (SymbolTable_IsDefImp (sym))
6894 : : {
6895 : : /* Definition/implementation module. */
6896 : : return sym;
6897 : : }
6898 : 1131158 : else if (SymbolTable_IsModule (sym))
6899 : : {
6900 : : /* avoid dangling else. */
6901 : 505773 : if ((SymbolTable_GetScope (sym)) == SymbolTable_NulSym)
6902 : : {
6903 : : /* Outer module. */
6904 : : return sym;
6905 : : }
6906 : : }
6907 : 625469 : sym = SymbolTable_GetScope (sym);
6908 : 625469 : } while (! (sym == SymbolTable_NulSym));
6909 : 0 : M2Error_InternalError ((const char *) "not expecting to reach an outer scope", 37);
6910 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6911 : : __builtin_unreachable ();
6912 : : }
6913 : :
6914 : :
6915 : : /*
6916 : : EnsureOrder - providing that both symbols, a, and, b, exist in
6917 : : list, l. Ensure that, b, is placed after a.
6918 : : */
6919 : :
6920 : 2970 : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b)
6921 : : {
6922 : 2970 : unsigned int n;
6923 : :
6924 : 2970 : n = Lists_NoOfItemsInList (l);
6925 : 2970 : if ((Lists_IsItemInList (l, a)) && (Lists_IsItemInList (l, b)))
6926 : : {
6927 : 2970 : Lists_RemoveItemFromList (l, b);
6928 : 2970 : Lists_IncludeItemIntoList (l, b);
6929 : : }
6930 : 2970 : M2Debug_Assert (n == (Lists_NoOfItemsInList (l)));
6931 : 2970 : }
6932 : :
6933 : :
6934 : : /*
6935 : : DumpSons -
6936 : : */
6937 : :
6938 : 0 : static void DumpSons (unsigned int sym)
6939 : : {
6940 : 0 : SymbolTable_PtrToSymbol pSym;
6941 : 0 : unsigned int f;
6942 : 0 : unsigned int n;
6943 : 0 : unsigned int i;
6944 : :
6945 : 0 : pSym = GetPsym (sym);
6946 : 0 : switch (pSym->SymbolType)
6947 : : {
6948 : 0 : case SymbolTable_RecordSym:
6949 : 0 : n = Lists_NoOfItemsInList (pSym->Record.ListOfSons);
6950 : 0 : i = 1;
6951 : 0 : while (i <= n)
6952 : : {
6953 : 0 : f = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, i));
6954 : 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));
6955 : 0 : i += 1;
6956 : : }
6957 : 0 : break;
6958 : :
6959 : :
6960 : 0 : default:
6961 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
6962 : 0 : break;
6963 : : }
6964 : 0 : }
6965 : :
6966 : :
6967 : : /*
6968 : : CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
6969 : : */
6970 : :
6971 : 0 : static void CheckListOfSons (unsigned int sym)
6972 : : {
6973 : 0 : SymbolTable_PtrToSymbol pSym;
6974 : :
6975 : 0 : pSym = GetPsym (recordConsist);
6976 : 0 : switch (pSym->SymbolType)
6977 : : {
6978 : 0 : case SymbolTable_RecordSym:
6979 : 0 : if (! (Lists_IsItemInList (pSym->Record.ListOfSons, sym)))
6980 : : {
6981 : 0 : DumpSons (recordConsist);
6982 : 0 : M2MetaError_MetaError1 ((const char *) "internal error: expecting {%1ad} to exist in record ListOfSons", 63, sym);
6983 : : }
6984 : 0 : break;
6985 : :
6986 : :
6987 : 0 : default:
6988 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
6989 : 0 : break;
6990 : : }
6991 : 0 : }
6992 : :
6993 : :
6994 : : /*
6995 : : CheckRecordConsistency -
6996 : : */
6997 : :
6998 : 0 : static void CheckRecordConsistency (unsigned int sym)
6999 : : {
7000 : 0 : SymbolTable_PtrToSymbol pSym;
7001 : :
7002 : 0 : return;
7003 : : pSym = GetPsym (sym);
7004 : : switch (pSym->SymbolType)
7005 : : {
7006 : : case SymbolTable_RecordSym:
7007 : : recordConsist = sym;
7008 : : SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) CheckListOfSons});
7009 : : break;
7010 : :
7011 : :
7012 : : default:
7013 : : M2Error_InternalError ((const char *) "record symbol expected", 22);
7014 : 0 : break;
7015 : : }
7016 : : }
7017 : :
7018 : :
7019 : : /*
7020 : : PutConstVarTemporary - indicates that constant, sym, is a temporary.
7021 : : */
7022 : :
7023 : 461117 : static void PutConstVarTemporary (unsigned int sym)
7024 : : {
7025 : 461117 : SymbolTable_PtrToSymbol pSym;
7026 : :
7027 : 461117 : pSym = GetPsym (sym);
7028 : 461117 : switch (pSym->SymbolType)
7029 : : {
7030 : 461117 : case SymbolTable_ConstVarSym:
7031 : 461117 : pSym->ConstVar.IsTemp = true;
7032 : 461117 : break;
7033 : :
7034 : :
7035 : 0 : default:
7036 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
7037 : 461117 : break;
7038 : : }
7039 : 461117 : }
7040 : :
7041 : :
7042 : : /*
7043 : : buildTemporary - builds the temporary filling in componentRef, record and sets mode.
7044 : : */
7045 : :
7046 : 1157176 : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record)
7047 : : {
7048 : 1157176 : SymbolTable_PtrToSymbol pSym;
7049 : 1157176 : DynamicStrings_String s;
7050 : 1157176 : unsigned int Sym;
7051 : :
7052 : 1157176 : TemporaryNo += 1;
7053 : : /* Make the name */
7054 : 1157176 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
7055 : 1157176 : if (Mode == SymbolTable_ImmediateValue)
7056 : : {
7057 : 426676 : Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
7058 : 426676 : PutConstVarTemporary (Sym);
7059 : : }
7060 : : else
7061 : : {
7062 : 730500 : Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
7063 : 730500 : pSym = GetPsym (Sym);
7064 : 730500 : switch (pSym->SymbolType)
7065 : : {
7066 : 730500 : case SymbolTable_VarSym:
7067 : 730500 : pSym->Var.AddrMode = Mode;
7068 : 730500 : pSym->Var.IsComponentRef = componentRef;
7069 : 730500 : pSym->Var.IsTemp = true; /* Variable is a temporary var */
7070 : 730500 : if (componentRef) /* Variable is a temporary var */
7071 : : {
7072 : 145595 : pSym->Var.list = Indexing_InitIndex (1);
7073 : 145595 : PutIntoIndex (&pSym->Var.list, 1, record);
7074 : : }
7075 : 730500 : InitWhereDeclaredTok (tok, &pSym->Var.At); /* Declared here */
7076 : 730500 : InitWhereFirstUsedTok (tok, &pSym->Var.At); /* Where symbol first used. */
7077 : 730500 : break;
7078 : :
7079 : :
7080 : 0 : default:
7081 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22); /* Where symbol first used. */
7082 : 1157176 : break;
7083 : : }
7084 : : }
7085 : 1157176 : s = DynamicStrings_KillString (s);
7086 : 1157176 : return Sym;
7087 : : /* static analysis guarentees a RETURN statement will be used before here. */
7088 : : __builtin_unreachable ();
7089 : : }
7090 : :
7091 : :
7092 : : /*
7093 : : AssertInRange - determines whether the Sym is a legal symbol.
7094 : : */
7095 : :
7096 : 3089891587 : static void AssertInRange (unsigned int Sym)
7097 : : {
7098 : 3089891587 : if ((Sym < 1) || (Sym > (SymbolTable_FinalSymbol ())))
7099 : : {
7100 : 6 : M2Error_InternalError ((const char *) "illegal symbol", 14);
7101 : : }
7102 : 3089891581 : }
7103 : :
7104 : :
7105 : : /*
7106 : : CheckForHiddenType - scans the NeedToBeImplemented tree providing
7107 : : that we are currently compiling an implementation
7108 : : module. If a symbol is found with TypeName
7109 : : then its Sym is returned.
7110 : : Otherwise NulSym is returned.
7111 : : CheckForHiddenType is called before any type is
7112 : : created, therefore the compiler allows hidden
7113 : : types to be implemented using any type.
7114 : : */
7115 : :
7116 : 6987222 : static unsigned int CheckForHiddenType (NameKey_Name TypeName)
7117 : : {
7118 : 6987222 : SymbolTable_PtrToSymbol pSym;
7119 : 6987222 : unsigned int Sym;
7120 : :
7121 : 6987222 : Sym = SymbolTable_NulSym;
7122 : 6987222 : if ((((M2Comp_CompilingImplementationModule ()) && (SymbolTable_IsDefImp (CurrentModule))) && (SymbolTable_IsHiddenTypeDeclared (CurrentModule))) && (TypeName != NameKey_NulName))
7123 : : {
7124 : : /* Check to see whether we are declaring a HiddenType. */
7125 : 104305 : pSym = GetPsym (CurrentModule);
7126 : 104305 : switch (pSym->SymbolType)
7127 : : {
7128 : 104305 : case SymbolTable_DefImpSym:
7129 : 104305 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, TypeName));
7130 : 104305 : break;
7131 : :
7132 : :
7133 : 0 : default:
7134 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7135 : 104305 : break;
7136 : : }
7137 : : }
7138 : 6987222 : return Sym;
7139 : : /* static analysis guarentees a RETURN statement will be used before here. */
7140 : : __builtin_unreachable ();
7141 : : }
7142 : :
7143 : :
7144 : : /*
7145 : : RequestFromModule - returns a symbol from module ModSym with name, SymName.
7146 : : */
7147 : :
7148 : 108 : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7149 : : {
7150 : 108 : SymbolTable_PtrToSymbol pSym;
7151 : 108 : unsigned int Sym;
7152 : :
7153 : 108 : pSym = GetPsym (ModSym);
7154 : 108 : switch (pSym->SymbolType)
7155 : : {
7156 : 0 : case SymbolTable_DefImpSym:
7157 : 0 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymName));
7158 : 0 : if (Sym == SymbolTable_NulSym)
7159 : : {
7160 : 0 : Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
7161 : : }
7162 : : break;
7163 : :
7164 : 108 : case SymbolTable_ModuleSym:
7165 : 108 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymName));
7166 : 108 : if (Sym == SymbolTable_NulSym)
7167 : : {
7168 : 12 : Sym = FetchUnknownFromModule (tok, ModSym, SymName);
7169 : : }
7170 : : break;
7171 : :
7172 : :
7173 : 0 : default:
7174 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7175 : 108 : break;
7176 : : }
7177 : 108 : return Sym;
7178 : : /* static analysis guarentees a RETURN statement will be used before here. */
7179 : : __builtin_unreachable ();
7180 : : }
7181 : :
7182 : :
7183 : : /*
7184 : : RequestFromDefinition - returns a symbol from module ModSym with name,
7185 : : SymName.
7186 : : */
7187 : :
7188 : 2758837 : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7189 : : {
7190 : 2758837 : SymbolTable_PtrToSymbol pSym;
7191 : 2758837 : unsigned int Sym;
7192 : 2758837 : unsigned int OldScopePtr;
7193 : :
7194 : 2758837 : pSym = GetPsym (ModSym);
7195 : 2758837 : switch (pSym->SymbolType)
7196 : : {
7197 : 2758837 : case SymbolTable_DefImpSym:
7198 : 2758837 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName));
7199 : 2758837 : if (Sym == SymbolTable_NulSym)
7200 : : {
7201 : 761642 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName));
7202 : 761642 : if (Sym == SymbolTable_NulSym)
7203 : : {
7204 : 363022 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
7205 : 363022 : if (Sym == SymbolTable_NulSym)
7206 : : {
7207 : 325892 : OldScopePtr = ScopePtr;
7208 : 325892 : SymbolTable_StartScope (ModSym);
7209 : 325892 : Sym = GetScopeSym (SymName, true);
7210 : 325892 : SymbolTable_EndScope ();
7211 : 325892 : M2Debug_Assert (OldScopePtr == ScopePtr);
7212 : 325892 : if (Sym == SymbolTable_NulSym)
7213 : : {
7214 : 325860 : Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
7215 : : }
7216 : : else
7217 : : {
7218 : 32 : if (SymbolTable_IsFieldEnumeration (Sym))
7219 : : {
7220 : 6 : if (SymbolTable_IsExported (ModSym, SymbolTable_GetType (Sym)))
7221 : : {
7222 : : return Sym;
7223 : : }
7224 : : }
7225 : : }
7226 : 325886 : SymbolKey_PutSymKey (pSym->DefImp.ExportRequest, SymName, Sym);
7227 : : }
7228 : : }
7229 : : }
7230 : : break;
7231 : :
7232 : :
7233 : 0 : default:
7234 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7235 : : break;
7236 : : }
7237 : : return Sym;
7238 : : /* static analysis guarentees a RETURN statement will be used before here. */
7239 : : __builtin_unreachable ();
7240 : : }
7241 : :
7242 : :
7243 : : /*
7244 : : GetWhereImported - returns the token number where this symbol
7245 : : was imported into the current module.
7246 : : */
7247 : :
7248 : 6 : static unsigned int GetWhereImported (unsigned int Sym)
7249 : : {
7250 : 6 : SymbolTable_PtrToSymbol pSym;
7251 : :
7252 : 6 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
7253 : 6 : switch (pSym->SymbolType)
7254 : : {
7255 : 6 : case SymbolTable_DefImpSym:
7256 : 6 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym));
7257 : 0 : break;
7258 : :
7259 : 0 : case SymbolTable_ModuleSym:
7260 : 0 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym));
7261 : 0 : break;
7262 : :
7263 : :
7264 : 0 : default:
7265 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
7266 : : break;
7267 : : }
7268 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7269 : : __builtin_unreachable ();
7270 : : }
7271 : :
7272 : :
7273 : : /*
7274 : : DisplayName - displays the name.
7275 : : */
7276 : :
7277 : 0 : static void DisplayName (unsigned int sym)
7278 : : {
7279 : 0 : M2Printf_printf1 ((const char *) " %a", 5, (const unsigned char *) &sym, (sizeof (sym)-1));
7280 : 0 : }
7281 : :
7282 : :
7283 : : /*
7284 : : DisplaySymbol - displays the name of a symbol
7285 : : */
7286 : :
7287 : 0 : static void DisplaySymbol (unsigned int sym)
7288 : : {
7289 : 0 : DynamicStrings_String s;
7290 : :
7291 : 0 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym))));
7292 : 0 : M2Printf_printf2 ((const char *) " %s (%d)", 10, (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &sym, (sizeof (sym)-1));
7293 : 0 : }
7294 : :
7295 : :
7296 : : /*
7297 : : FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
7298 : : */
7299 : :
7300 : 12 : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7301 : : {
7302 : 12 : SymbolTable_PtrToSymbol pSym;
7303 : 12 : unsigned int Sym;
7304 : :
7305 : 12 : pSym = GetPsym (ModSym);
7306 : 12 : switch (pSym->SymbolType)
7307 : : {
7308 : 12 : case SymbolTable_ModuleSym:
7309 : 12 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
7310 : 12 : if (Sym == SymbolTable_NulSym)
7311 : : {
7312 : 12 : NewSym (&Sym);
7313 : 12 : FillInUnknownFields (tok, Sym, SymName, ModSym, true);
7314 : 12 : SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
7315 : : }
7316 : 12 : break;
7317 : :
7318 : :
7319 : 0 : default:
7320 : 0 : M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
7321 : 12 : break;
7322 : : }
7323 : 12 : return Sym;
7324 : : /* static analysis guarentees a RETURN statement will be used before here. */
7325 : : __builtin_unreachable ();
7326 : : }
7327 : :
7328 : :
7329 : : /*
7330 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
7331 : : */
7332 : :
7333 : 325860 : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7334 : : {
7335 : 325860 : SymbolTable_PtrToSymbol pSym;
7336 : 325860 : unsigned int Sym;
7337 : :
7338 : 325860 : pSym = GetPsym (ModSym);
7339 : 325860 : switch (pSym->SymbolType)
7340 : : {
7341 : 325860 : case SymbolTable_DefImpSym:
7342 : 325860 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
7343 : 325860 : if (Sym == SymbolTable_NulSym)
7344 : : {
7345 : 325860 : NewSym (&Sym);
7346 : 325860 : FillInUnknownFields (tok, Sym, SymName, ModSym, true);
7347 : 325860 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
7348 : : }
7349 : 325860 : break;
7350 : :
7351 : :
7352 : 0 : default:
7353 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7354 : 325860 : break;
7355 : : }
7356 : 325860 : return Sym;
7357 : : /* static analysis guarentees a RETURN statement will be used before here. */
7358 : : __builtin_unreachable ();
7359 : : }
7360 : :
7361 : :
7362 : : /*
7363 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
7364 : : */
7365 : :
7366 : 56 : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName)
7367 : : {
7368 : 56 : SymbolTable_PtrToSymbol pSym;
7369 : 56 : unsigned int Sym;
7370 : :
7371 : 56 : pSym = GetPsym (scope);
7372 : 56 : switch (pSym->SymbolType)
7373 : : {
7374 : 0 : case SymbolTable_DefImpSym:
7375 : 0 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
7376 : 0 : if (Sym == SymbolTable_NulSym)
7377 : : {
7378 : 0 : NewSym (&Sym);
7379 : 0 : FillInUnknownFields (tok, Sym, SymName, scope, true);
7380 : 0 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
7381 : : }
7382 : : break;
7383 : :
7384 : 38 : case SymbolTable_ModuleSym:
7385 : 38 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
7386 : 38 : if (Sym == SymbolTable_NulSym)
7387 : : {
7388 : 38 : NewSym (&Sym);
7389 : 38 : FillInUnknownFields (tok, Sym, SymName, scope, true);
7390 : 38 : SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
7391 : : }
7392 : : break;
7393 : :
7394 : 18 : case SymbolTable_ProcedureSym:
7395 : 18 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, SymName));
7396 : 18 : if (Sym == SymbolTable_NulSym)
7397 : : {
7398 : 18 : NewSym (&Sym);
7399 : 18 : FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
7400 : 18 : SymbolKey_PutSymKey (pSym->Procedure.Unresolved, SymName, Sym);
7401 : : }
7402 : : break;
7403 : :
7404 : :
7405 : 0 : default:
7406 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module or Procedure symbol", 48);
7407 : 56 : break;
7408 : : }
7409 : 56 : return Sym;
7410 : : /* static analysis guarentees a RETURN statement will be used before here. */
7411 : : __builtin_unreachable ();
7412 : : }
7413 : :
7414 : :
7415 : : /*
7416 : : UnknownSymbolError - displays symbol name for symbol, sym.
7417 : : */
7418 : :
7419 : 151 : static void UnknownSymbolError (unsigned int sym)
7420 : : {
7421 : 151 : if (IsUnreportedUnknown (sym))
7422 : : {
7423 : 143 : Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
7424 : 143 : M2MetaError_MetaErrorStringT1 (SymbolTable_GetFirstUsed (sym), DynamicStrings_InitString ((const char *) "unknown symbol {%1EUad} {%1&s}", 30), sym);
7425 : : }
7426 : 151 : }
7427 : :
7428 : :
7429 : : /*
7430 : : IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
7431 : : reported and is an unknown symbol.
7432 : : */
7433 : :
7434 : 33491492 : static bool IsUnreportedUnknown (unsigned int sym)
7435 : : {
7436 : 33491492 : return (SymbolTable_IsUnknown (sym)) && (! (Sets_IsElementInSet (ReportedUnknowns, sym)));
7437 : : /* static analysis guarentees a RETURN statement will be used before here. */
7438 : : __builtin_unreachable ();
7439 : : }
7440 : :
7441 : :
7442 : : /*
7443 : : AddListify -
7444 : : */
7445 : :
7446 : 0 : static void AddListify (unsigned int sym)
7447 : : {
7448 : 0 : ListifyWordCount += 1;
7449 : : /* printf ("AddListify: ListifyWordCount = %d, ListifyTotal = %d
7450 : : ",
7451 : : ListifyWordCount, ListifyTotal) ; */
7452 : 0 : if (ListifyWordCount > 1)
7453 : : {
7454 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7455 : 0 : if (ListifyWordCount == ListifyTotal)
7456 : : {
7457 : 0 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) " and ", 5)));
7458 : : }
7459 : : else
7460 : : {
7461 : 0 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ", ", 2)));
7462 : : }
7463 : : }
7464 : 0 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym)))));
7465 : 0 : }
7466 : :
7467 : :
7468 : : /*
7469 : : Listify - convert tree into a string list and return the result.
7470 : : */
7471 : :
7472 : 0 : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition)
7473 : : {
7474 : 0 : ListifyTotal = SymbolKey_NoOfNodes (tree, isCondition);
7475 : 0 : ListifyWordCount = 0;
7476 : 0 : ListifySentance = DynamicStrings_InitString ((const char *) "", 0);
7477 : 0 : SymbolKey_ForeachNodeConditionDo (tree, isCondition, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) AddListify});
7478 : 0 : return ListifySentance;
7479 : : /* static analysis guarentees a RETURN statement will be used before here. */
7480 : : __builtin_unreachable ();
7481 : : }
7482 : :
7483 : :
7484 : : /*
7485 : : CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
7486 : : an unknown symbol. All unknown symbols are displayed
7487 : : together with an error message.
7488 : : */
7489 : :
7490 : 1957668 : static void CheckForUnknowns (unsigned int tokno, NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
7491 : : {
7492 : 1957668 : DynamicStrings_String s;
7493 : 1957668 : char a[_a_high+1];
7494 : :
7495 : : /* make a local copy of each unbounded array. */
7496 : 1957668 : memcpy (a, a_, _a_high+1);
7497 : :
7498 : 1957668 : if (SymbolKey_DoesTreeContainAny (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown}))
7499 : : {
7500 : 119 : SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnknownSymbolError});
7501 : 119 : if ((SymbolKey_NoOfNodes (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown})) > 0)
7502 : : {
7503 : 0 : s = DynamicStrings_InitString ((const char *) "{%E} the following unknown symbols in module %<", 47);
7504 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
7505 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%> were ", 8)));
7506 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
7507 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ": ", 2)));
7508 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (Listify (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown})));
7509 : 0 : M2MetaError_MetaErrorStringT0 (tokno, s);
7510 : : }
7511 : : }
7512 : 1957668 : }
7513 : :
7514 : :
7515 : : /*
7516 : : SymbolError - displays symbol name for symbol, Sym.
7517 : : */
7518 : :
7519 : 0 : static void SymbolError (unsigned int Sym)
7520 : : {
7521 : 0 : M2Error_Error e;
7522 : 0 : NameKey_Name n;
7523 : :
7524 : 0 : n = SymbolTable_GetSymName (Sym);
7525 : 0 : e = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
7526 : 0 : M2Error_ErrorFormat1 (e, (const char *) "unknown symbol '%a' found", 25, (const unsigned char *) &n, (sizeof (n)-1));
7527 : 0 : }
7528 : :
7529 : :
7530 : : /*
7531 : : CheckForSymbols - checks a binary tree, Tree, to see whether it contains
7532 : : any symbol. The tree is expected to be empty, if not
7533 : : then an error has occurred.
7534 : : */
7535 : :
7536 : 465556 : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
7537 : : {
7538 : 465556 : DynamicStrings_String s;
7539 : 465556 : char a[_a_high+1];
7540 : :
7541 : : /* make a local copy of each unbounded array. */
7542 : 465556 : memcpy (a, a_, _a_high+1);
7543 : :
7544 : 465556 : if (SymbolKey_DoesTreeContainAny (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown}))
7545 : : {
7546 : 0 : s = DynamicStrings_InitString ((const char *) "the symbols are unknown at the end of module {%1Ea} when ", 57);
7547 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
7548 : 0 : M2MetaError_MetaErrorString1 (s, MainModule);
7549 : 0 : SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SymbolError});
7550 : : }
7551 : 465556 : }
7552 : :
7553 : :
7554 : : /*
7555 : : PutExportUndeclared - places a symbol, Sym, into module, ModSym,
7556 : : ExportUndeclared list provided that Sym
7557 : : is unknown.
7558 : : */
7559 : :
7560 : 4532695 : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym)
7561 : : {
7562 : 4532695 : SymbolTable_PtrToSymbol pSym;
7563 : :
7564 : 4532695 : if (SymbolTable_IsUnknown (Sym))
7565 : : {
7566 : 3998707 : pSym = GetPsym (ModSym);
7567 : 3998707 : switch (pSym->SymbolType)
7568 : : {
7569 : 294 : case SymbolTable_ModuleSym:
7570 : 294 : SymbolKey_PutSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
7571 : 294 : break;
7572 : :
7573 : 3998413 : case SymbolTable_DefImpSym:
7574 : 3998413 : SymbolKey_PutSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
7575 : 3998413 : break;
7576 : :
7577 : :
7578 : 0 : default:
7579 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7580 : : break;
7581 : : }
7582 : : }
7583 : 4532695 : }
7584 : :
7585 : :
7586 : : /*
7587 : : GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
7588 : : which is in the ExportUndeclared list.
7589 : : */
7590 : :
7591 : 234 : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name)
7592 : : {
7593 : 234 : SymbolTable_PtrToSymbol pSym;
7594 : :
7595 : 234 : pSym = GetPsym (ModSym);
7596 : 234 : switch (pSym->SymbolType)
7597 : : {
7598 : 228 : case SymbolTable_ModuleSym:
7599 : 228 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, name));
7600 : 6 : break;
7601 : :
7602 : 6 : case SymbolTable_DefImpSym:
7603 : 6 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, name));
7604 : 0 : break;
7605 : :
7606 : :
7607 : 0 : default:
7608 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7609 : : break;
7610 : : }
7611 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7612 : : __builtin_unreachable ();
7613 : : }
7614 : :
7615 : :
7616 : : /*
7617 : : RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
7618 : : ExportUndeclaredTree.
7619 : : */
7620 : :
7621 : 11082189 : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym)
7622 : : {
7623 : 11082189 : SymbolTable_PtrToSymbol pSym;
7624 : :
7625 : 11082189 : pSym = GetPsym (ModSym);
7626 : 11082189 : switch (pSym->SymbolType)
7627 : : {
7628 : 18 : case SymbolTable_ModuleSym:
7629 : 18 : if ((SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
7630 : : {
7631 : 18 : SymbolKey_DelSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym));
7632 : : }
7633 : : break;
7634 : :
7635 : 11082171 : case SymbolTable_DefImpSym:
7636 : 11082171 : if ((SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
7637 : : {
7638 : 3998053 : SymbolKey_DelSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym));
7639 : : }
7640 : : break;
7641 : :
7642 : :
7643 : 0 : default:
7644 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7645 : 11082189 : break;
7646 : : }
7647 : 11082189 : }
7648 : :
7649 : :
7650 : : /*
7651 : : CheckForExportedDeclaration - checks to see whether a definition module
7652 : : is currently being compiled, if so,
7653 : : symbol, Sym, is removed from the
7654 : : ExportUndeclared list.
7655 : : This procedure is called whenever a symbol
7656 : : is declared, thus attempting to reduce
7657 : : the ExportUndeclared list.
7658 : : */
7659 : :
7660 : 19184917 : static void CheckForExportedDeclaration (unsigned int Sym)
7661 : : {
7662 : 19184917 : if (M2Comp_CompilingDefinitionModule ())
7663 : : {
7664 : 11082165 : RemoveExportUndeclared (SymbolTable_GetCurrentModule (), Sym);
7665 : : }
7666 : 19184917 : }
7667 : :
7668 : :
7669 : : /*
7670 : : UndeclaredSymbolError - displays symbol name for symbol, Sym.
7671 : : */
7672 : :
7673 : 0 : static void UndeclaredSymbolError (unsigned int Sym)
7674 : : {
7675 : 0 : if (DebugUnknowns)
7676 : : {
7677 : : M2Printf_printf1 ((const char *) "undeclared symbol (%d)\\n", 24, (const unsigned char *) &Sym, (sizeof (Sym)-1));
7678 : : }
7679 : 0 : M2MetaError_MetaError1 ((const char *) "{%1UC} undeclared symbol {%1a}", 30, Sym);
7680 : 0 : }
7681 : :
7682 : :
7683 : : /*
7684 : : RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
7685 : : NeedToBeImplemented list.
7686 : : */
7687 : :
7688 : 2227037 : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym)
7689 : : {
7690 : 2227037 : SymbolTable_PtrToSymbol pSym;
7691 : :
7692 : 2227037 : pSym = GetPsym (ModSym);
7693 : 2227037 : switch (pSym->SymbolType)
7694 : : {
7695 : 2227037 : case SymbolTable_DefImpSym:
7696 : 2227037 : if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
7697 : : {
7698 : 1278609 : SymbolKey_DelSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym));
7699 : : }
7700 : 2227037 : break;
7701 : :
7702 : :
7703 : 0 : default:
7704 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7705 : 2227037 : break;
7706 : : }
7707 : 2227037 : }
7708 : :
7709 : :
7710 : : /*
7711 : : RemoveFromExportRequest -
7712 : : */
7713 : :
7714 : 411194 : static void RemoveFromExportRequest (unsigned int Sym)
7715 : : {
7716 : 411194 : SymbolTable_PtrToSymbol pSym;
7717 : :
7718 : 411194 : pSym = GetPsym (ExportRequestModule);
7719 : 411194 : switch (pSym->SymbolType)
7720 : : {
7721 : 411194 : case SymbolTable_DefImpSym:
7722 : 411194 : if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym))) == Sym)
7723 : : {
7724 : 6 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym));
7725 : : }
7726 : 411194 : break;
7727 : :
7728 : :
7729 : 0 : default:
7730 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7731 : 411194 : break;
7732 : : }
7733 : 411194 : }
7734 : :
7735 : :
7736 : : /*
7737 : : RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
7738 : : (and its fields) from the ExportRequest tree.
7739 : : */
7740 : :
7741 : 18783 : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym)
7742 : : {
7743 : 18783 : if (SymbolTable_IsEnumeration (Sym))
7744 : : {
7745 : 18783 : ExportRequestModule = ModSym;
7746 : 18783 : RemoveFromExportRequest (Sym);
7747 : 18783 : SymbolTable_ForeachLocalSymDo (Sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) RemoveFromExportRequest});
7748 : : }
7749 : 18783 : }
7750 : :
7751 : :
7752 : : /*
7753 : : UnImplementedSymbolError - displays symbol name for symbol, Sym.
7754 : : */
7755 : :
7756 : 0 : static void UnImplementedSymbolError (unsigned int Sym)
7757 : : {
7758 : 0 : NameKey_Name n;
7759 : :
7760 : 0 : CurrentError = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
7761 : 0 : if (SymbolTable_IsType (Sym))
7762 : : {
7763 : 0 : n = SymbolTable_GetSymName (Sym);
7764 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "hidden type is undeclared (%a)", 30, (const unsigned char *) &n, (sizeof (n)-1));
7765 : : }
7766 : 0 : else if (SymbolTable_IsProcedure (Sym))
7767 : : {
7768 : : /* avoid dangling else. */
7769 : 0 : n = SymbolTable_GetSymName (Sym);
7770 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure is undeclared (%a)", 28, (const unsigned char *) &n, (sizeof (n)-1));
7771 : : }
7772 : 0 : else if (SymbolTable_IsProcType (Sym))
7773 : : {
7774 : : /* avoid dangling else. */
7775 : 0 : n = SymbolTable_GetSymName (Sym);
7776 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure type is undeclared (%a)", 33, (const unsigned char *) &n, (sizeof (n)-1));
7777 : : }
7778 : : else
7779 : : {
7780 : : /* avoid dangling else. */
7781 : 0 : M2Error_ErrorFormat0 (CurrentError, (const char *) "undeclared symbol", 17);
7782 : : }
7783 : 0 : }
7784 : :
7785 : :
7786 : : /*
7787 : : CheckEnumerationInList - places symbol, Sym, in the list, l,
7788 : : providing it does not already exist.
7789 : : PseudoScope(Sym) is called if Sym needs to
7790 : : be added to the enumeration list, l.
7791 : : */
7792 : :
7793 : 67059 : static void CheckEnumerationInList (Lists_List l, unsigned int Sym)
7794 : : {
7795 : 67059 : if (! (Lists_IsItemInList (l, Sym)))
7796 : : {
7797 : 58538 : Lists_PutItemIntoList (l, Sym);
7798 : 58538 : SymbolTable_PseudoScope (Sym);
7799 : : }
7800 : 67059 : }
7801 : :
7802 : :
7803 : : /*
7804 : : CheckIfEnumerationExported - An outer module may use an enumeration that
7805 : : is declared inside an inner module. The usage
7806 : : may occur before definition. The first pass
7807 : : exports a symbol, later the symbol is declared
7808 : : as an emumeration type. At this stage the
7809 : : CheckIfEnumerationExported procedure should be
7810 : : called. This procedure ripples from the current
7811 : : (inner) module to outer module and every time
7812 : : it is exported it must be added to the outer
7813 : : module EnumerationScopeList.
7814 : : */
7815 : :
7816 : 49367 : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId)
7817 : : {
7818 : 68168 : SymbolTable_PtrToCallFrame pCall;
7819 : 68168 : unsigned int InnerModId;
7820 : 68168 : unsigned int OuterModId;
7821 : 68168 : unsigned int InnerModSym;
7822 : 68168 : unsigned int OuterModSym;
7823 : :
7824 : 68168 : InnerModId = GetModuleScopeId (ScopeId);
7825 : 68168 : if (InnerModId > 0)
7826 : : {
7827 : 68168 : OuterModId = GetModuleScopeId (InnerModId-1);
7828 : 68168 : if (OuterModId > 0)
7829 : : {
7830 : 68168 : pCall = GetPcall (InnerModId);
7831 : 68168 : InnerModSym = pCall->Search;
7832 : 68168 : pCall = GetPcall (OuterModId);
7833 : 68168 : OuterModSym = pCall->Search;
7834 : 68168 : if ((InnerModSym != SymbolTable_NulSym) && (OuterModSym != SymbolTable_NulSym))
7835 : : {
7836 : 34162 : if (SymbolTable_IsExported (InnerModSym, Sym))
7837 : : {
7838 : 18801 : CheckForEnumerationInOuterModule (Sym, OuterModSym);
7839 : 18801 : CheckIfEnumerationExported (Sym, OuterModId);
7840 : : }
7841 : : }
7842 : : }
7843 : : }
7844 : 49367 : }
7845 : :
7846 : :
7847 : : /*
7848 : : CheckForEnumerationInOuterModule - checks to see whether the enumeration
7849 : : type symbol, Sym, has been entered into
7850 : : the outer module, OuterModule, scope list.
7851 : : OuterModule may be internal to the
7852 : : program module.
7853 : : */
7854 : :
7855 : 18801 : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule)
7856 : : {
7857 : 18801 : SymbolTable_PtrToSymbol pSym;
7858 : :
7859 : 18801 : pSym = GetPsym (OuterModule);
7860 : 18801 : switch (pSym->SymbolType)
7861 : : {
7862 : 0 : case SymbolTable_DefImpSym:
7863 : 0 : Lists_IncludeItemIntoList (pSym->DefImp.EnumerationScopeList, Sym);
7864 : 0 : break;
7865 : :
7866 : 18801 : case SymbolTable_ModuleSym:
7867 : 18801 : Lists_IncludeItemIntoList (pSym->Module.EnumerationScopeList, Sym);
7868 : 18801 : break;
7869 : :
7870 : :
7871 : 0 : default:
7872 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7873 : 18801 : break;
7874 : : }
7875 : 18801 : }
7876 : :
7877 : :
7878 : : /*
7879 : : MakeVariableForParam -
7880 : : */
7881 : :
7882 : 8849244 : static unsigned int MakeVariableForParam (unsigned int tok, NameKey_Name ParamName, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, unsigned int ParmType, unsigned int typetok)
7883 : : {
7884 : 8849244 : SymbolTable_PtrToSymbol pSym;
7885 : 8849244 : unsigned int VariableSym;
7886 : :
7887 : 8849244 : tok = CheckTok (tok, (const char *) "parameter", 9);
7888 : 8849244 : VariableSym = SymbolTable_MakeVar (tok, ParamName);
7889 : 8849244 : pSym = GetPsym (VariableSym);
7890 : 8849244 : switch (pSym->SymbolType)
7891 : : {
7892 : : case SymbolTable_ErrorSym:
7893 : : return SymbolTable_NulSym;
7894 : 8849244 : break;
7895 : :
7896 : 8849244 : case SymbolTable_VarSym:
7897 : 8849244 : pSym->Var.IsParam = true; /* Variable is really a parameter. */
7898 : 8849244 : break;
7899 : :
7900 : :
7901 : 0 : default:
7902 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
7903 : 8849244 : break;
7904 : : }
7905 : : /* Note that the parameter is now treated as a local variable. */
7906 : 8849244 : SymbolTable_PutVarTok (VariableSym, ParmType, typetok);
7907 : 8849244 : SymbolTable_PutDeclared (tok, VariableSym);
7908 : : /*
7909 : : Normal VAR parameters have LeftValue,
7910 : : however Unbounded VAR parameters have RightValue.
7911 : : Non VAR parameters always have RightValue.
7912 : : */
7913 : 8849244 : if ((SymbolTable_IsVarParam (ProcSym, kind, no)) && (! (SymbolTable_IsUnboundedParam (ProcSym, kind, no))))
7914 : : {
7915 : 266185 : SymbolTable_PutMode (VariableSym, SymbolTable_LeftValue);
7916 : : }
7917 : : else
7918 : : {
7919 : 8583059 : SymbolTable_PutMode (VariableSym, SymbolTable_RightValue);
7920 : : }
7921 : : return VariableSym;
7922 : : /* static analysis guarentees a RETURN statement will be used before here. */
7923 : : __builtin_unreachable ();
7924 : : }
7925 : :
7926 : :
7927 : : /*
7928 : : AddParameter - adds a parameter ParSym to a procedure Sym.
7929 : : */
7930 : :
7931 : 20172877 : static void AddParameter (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParSym)
7932 : : {
7933 : 20172877 : SymbolTable_PtrToSymbol pSym;
7934 : :
7935 : 20172877 : pSym = GetPsym (Sym);
7936 : 20172877 : switch (pSym->SymbolType)
7937 : : {
7938 : : case SymbolTable_ErrorSym:
7939 : : break;
7940 : :
7941 : 11239140 : case SymbolTable_ProcedureSym:
7942 : 11239140 : Lists_PutItemIntoList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParSym);
7943 : 11239140 : break;
7944 : :
7945 : 8933737 : case SymbolTable_ProcTypeSym:
7946 : 8933737 : Lists_PutItemIntoList (pSym->ProcType.ListOfParam, ParSym);
7947 : 8933737 : break;
7948 : :
7949 : :
7950 : 0 : default:
7951 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
7952 : 20172877 : break;
7953 : : }
7954 : 20172877 : }
7955 : :
7956 : :
7957 : : /*
7958 : : AddProcedureProcTypeParam - adds ParamType to the parameter ProcType
7959 : : associated with procedure Sym.
7960 : : */
7961 : :
7962 : 11239140 : static void AddProcedureProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded, bool isVarParam)
7963 : : {
7964 : 11239140 : SymbolTable_PtrToSymbol pSym;
7965 : :
7966 : 11239140 : pSym = GetPsym (Sym);
7967 : 11239140 : switch (pSym->SymbolType)
7968 : : {
7969 : 11239140 : case SymbolTable_ProcedureSym:
7970 : 11239140 : if (pSym->Procedure.BuildProcType)
7971 : : {
7972 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7973 : 8849244 : if (isVarParam)
7974 : : {
7975 : 752625 : SymbolTable_PutProcTypeVarParam (tok, pSym->Procedure.ProcedureType, ParamType, isUnbounded);
7976 : : }
7977 : : else
7978 : : {
7979 : 8096619 : SymbolTable_PutProcTypeParam (tok, pSym->Procedure.ProcedureType, ParamType, isUnbounded);
7980 : : }
7981 : : }
7982 : 11239140 : break;
7983 : :
7984 : :
7985 : 0 : default:
7986 : 0 : M2Error_InternalError ((const char *) "expecting Sym to be a procedure", 31);
7987 : 11239140 : break;
7988 : : }
7989 : 11239140 : }
7990 : :
7991 : :
7992 : : /*
7993 : : IsNthParamVar - returns true if the n th parameter of the parameter list,
7994 : : List, is a VAR parameter.
7995 : : */
7996 : :
7997 : 21034700 : static bool IsNthParamVar (Lists_List Head, unsigned int n)
7998 : : {
7999 : 21034700 : SymbolTable_PtrToSymbol pSym;
8000 : 21034700 : unsigned int p;
8001 : :
8002 : 21034700 : p = static_cast<unsigned int> (Lists_GetItemFromList (Head, n));
8003 : 21034700 : if (p == SymbolTable_NulSym)
8004 : : {
8005 : 0 : M2Error_InternalError ((const char *) "parameter does not exist", 24);
8006 : : }
8007 : : else
8008 : : {
8009 : 21034700 : pSym = GetPsym (p);
8010 : 21034700 : switch (pSym->SymbolType)
8011 : : {
8012 : : case SymbolTable_ErrorSym:
8013 : : return false;
8014 : 1284227 : break;
8015 : :
8016 : 1284227 : case SymbolTable_VarParamSym:
8017 : 1284227 : return true;
8018 : : break;
8019 : :
8020 : : case SymbolTable_ParamSym:
8021 : : return false;
8022 : 0 : break;
8023 : :
8024 : :
8025 : 0 : default:
8026 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
8027 : : break;
8028 : : }
8029 : : }
8030 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8031 : : __builtin_unreachable ();
8032 : : }
8033 : :
8034 : :
8035 : : /*
8036 : : MakeParameterHeapVar - create a heap variable if sym is a pointer.
8037 : : */
8038 : :
8039 : 533830 : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode)
8040 : : {
8041 : 533830 : unsigned int heapvar;
8042 : :
8043 : 533830 : tok = CheckTok (tok, (const char *) "parameter heap var", 18);
8044 : 533830 : heapvar = SymbolTable_NulSym;
8045 : 533830 : type = SymbolTable_SkipType (type);
8046 : 533830 : if (SymbolTable_IsPointer (type))
8047 : : {
8048 : 51152 : heapvar = SymbolTable_MakeTemporary (tok, mode);
8049 : 51152 : SymbolTable_PutVar (heapvar, type);
8050 : 51152 : SymbolTable_PutVarHeap (heapvar, true);
8051 : : }
8052 : 533830 : return heapvar;
8053 : : /* static analysis guarentees a RETURN statement will be used before here. */
8054 : : __builtin_unreachable ();
8055 : : }
8056 : :
8057 : :
8058 : : /*
8059 : : PutParameterHeapVar - creates a heap variable associated with parameter sym.
8060 : : */
8061 : :
8062 : 5883433 : static void PutParameterHeapVar (unsigned int sym)
8063 : : {
8064 : 5883433 : SymbolTable_PtrToSymbol pSym;
8065 : :
8066 : 5883433 : pSym = GetPsym (sym);
8067 : 5883433 : switch (pSym->SymbolType)
8068 : : {
8069 : : case SymbolTable_ParamSym:
8070 : : break;
8071 : :
8072 : 533830 : case SymbolTable_VarParamSym:
8073 : 533830 : pSym->VarParam.HeapVar = MakeParameterHeapVar (SymbolTable_GetDeclaredMod (sym), pSym->VarParam.Type, SymbolTable_LeftValue); /* Nothing to do for the non var parameter. */
8074 : 533830 : break;
8075 : :
8076 : :
8077 : 0 : default:
8078 : 0 : M2Error_InternalError ((const char *) "Param or VarParam symbol expected", 33);
8079 : 5883433 : break;
8080 : : }
8081 : 5883433 : }
8082 : :
8083 : :
8084 : : /*
8085 : : IsProcedureAnyBoolean - returns the boolean result from p
8086 : : for any of procedure kind which is defined.
8087 : : */
8088 : :
8089 : 8602 : static bool IsProcedureAnyBoolean (unsigned int sym, SymbolTable_ProcAnyBoolean p)
8090 : : {
8091 : 8602 : SymbolTable_ProcedureKind kind;
8092 : :
8093 : 25794 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
8094 : : {
8095 : 25794 : if (SymbolTable_GetProcedureDefined (sym, kind))
8096 : : {
8097 : 8602 : return (*p.proc) (sym, kind);
8098 : : }
8099 : : }
8100 : 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
8101 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8102 : : __builtin_unreachable ();
8103 : : }
8104 : :
8105 : :
8106 : : /*
8107 : : IsProcedureAnyDefaultBoolean - returns the boolean result from p
8108 : : for any of procedure kind which is defined.
8109 : : */
8110 : :
8111 : 3892685 : static bool IsProcedureAnyDefaultBoolean (unsigned int sym, bool default_, SymbolTable_ProcAnyBoolean p)
8112 : : {
8113 : 3892685 : SymbolTable_ProcedureKind kind;
8114 : :
8115 : 9174476 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
8116 : : {
8117 : 8777609 : if (SymbolTable_GetProcedureDefined (sym, kind))
8118 : : {
8119 : 3495818 : return (*p.proc) (sym, kind);
8120 : : }
8121 : : }
8122 : : return default_;
8123 : : /* static analysis guarentees a RETURN statement will be used before here. */
8124 : : __builtin_unreachable ();
8125 : : }
8126 : :
8127 : :
8128 : : /*
8129 : : FillInUnknownFields - fills in all fields for the undefined sym.
8130 : : */
8131 : :
8132 : 10950412 : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName, unsigned int descscope, bool onimport)
8133 : : {
8134 : 10950412 : SymbolTable_PtrToSymbol pSym;
8135 : :
8136 : 10950412 : pSym = GetPsym (sym);
8137 : 10950412 : pSym->SymbolType = SymbolTable_UndefinedSym;
8138 : 10950412 : pSym->Undefined.name = SymName;
8139 : 10950412 : pSym->Undefined.oafamily = SymbolTable_NulSym;
8140 : 10950412 : pSym->Undefined.errorScope = M2Error_GetCurrentErrorScope ();
8141 : 10950412 : pSym->Undefined.declScope = descscope;
8142 : 10950412 : pSym->Undefined.onImport = onimport;
8143 : 10950412 : InitWhereFirstUsedTok (tok, &pSym->Undefined.At);
8144 : 10950412 : }
8145 : :
8146 : :
8147 : : /*
8148 : : FillInPointerFields - given a new symbol, sym, make it a pointer symbol
8149 : : and initialize its fields.
8150 : : */
8151 : :
8152 : 202652 : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf)
8153 : : {
8154 : 202652 : SymbolTable_PtrToSymbol pSym;
8155 : :
8156 : 202652 : if (! (SymbolTable_IsError (Sym)))
8157 : : {
8158 : 202652 : pSym = GetPsym (Sym);
8159 : 202652 : pSym->SymbolType = SymbolTable_PointerSym;
8160 : 202652 : switch (pSym->SymbolType)
8161 : : {
8162 : 202652 : case SymbolTable_PointerSym:
8163 : 202652 : pSym->Pointer.Type = SymbolTable_NulSym;
8164 : 202652 : pSym->Pointer.name = PointerName;
8165 : 202652 : pSym->Pointer.oafamily = oaf; /* The unbounded for this */
8166 : 202652 : SymbolKey_InitTree (&pSym->Pointer.ConstLitTree); /* constants of this type */
8167 : 202652 : pSym->Pointer.Scope = scope; /* Which scope created it */
8168 : 202652 : pSym->Pointer.Size = M2ALU_InitValue (); /* Which scope created it */
8169 : 202652 : pSym->Pointer.Align = SymbolTable_NulSym; /* Alignment of this type */
8170 : 202652 : break;
8171 : :
8172 : :
8173 : : default:
8174 : : M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26); /* Alignment of this type */
8175 : 202652 : break;
8176 : : }
8177 : : }
8178 : 202652 : }
8179 : :
8180 : :
8181 : : /*
8182 : : ForeachParameterDo -
8183 : : */
8184 : :
8185 : 30392 : static void ForeachParameterDo (SymbolTable_CheckProcedure p)
8186 : : {
8187 : 30392 : unsigned int l;
8188 : 30392 : unsigned int h;
8189 : :
8190 : 30392 : l = Indexing_LowIndice (Symbols);
8191 : 30392 : h = Indexing_HighIndice (Symbols);
8192 : 47169258 : while (l <= h)
8193 : : {
8194 : 47108474 : if (SymbolTable_IsParameter (l))
8195 : : {
8196 : 3286923 : (*p.proc) (l);
8197 : : }
8198 : 47108474 : l += 1;
8199 : : }
8200 : 30392 : }
8201 : :
8202 : :
8203 : : /*
8204 : : CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
8205 : : */
8206 : :
8207 : 3286923 : static void CheckUnbounded (unsigned int Sym)
8208 : : {
8209 : 3286923 : SymbolTable_PtrToSymbol pSym;
8210 : :
8211 : 3286923 : AssertInRange (Sym);
8212 : 3286923 : pSym = GetPsym (Sym);
8213 : 3286923 : switch (pSym->SymbolType)
8214 : : {
8215 : 2341551 : case SymbolTable_ParamSym:
8216 : 2341551 : if (SymbolTable_IsUnbounded (pSym->Param.Type))
8217 : : {
8218 : 424188 : pSym->Param.IsUnbounded = true;
8219 : : }
8220 : : break;
8221 : :
8222 : 945372 : case SymbolTable_VarParamSym:
8223 : 945372 : if (SymbolTable_IsUnbounded (pSym->VarParam.Type))
8224 : : {
8225 : 931612 : pSym->VarParam.IsUnbounded = true;
8226 : : }
8227 : : break;
8228 : :
8229 : :
8230 : 0 : default:
8231 : 0 : M2RTS_HALT (-1);
8232 : : __builtin_unreachable ();
8233 : 3286923 : break;
8234 : : }
8235 : 3286923 : }
8236 : :
8237 : :
8238 : : /*
8239 : : PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
8240 : : */
8241 : :
8242 : 30332 : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf)
8243 : : {
8244 : 30332 : SymbolTable_PtrToSymbol pSym;
8245 : :
8246 : 30332 : pSym = GetPsym (SimpleType);
8247 : 30332 : switch (pSym->SymbolType)
8248 : : {
8249 : : case SymbolTable_ErrorSym:
8250 : : break;
8251 : :
8252 : 12 : case SymbolTable_RecordSym:
8253 : 12 : pSym->Record.oafamily = oaf;
8254 : 12 : break;
8255 : :
8256 : 0 : case SymbolTable_SubrangeSym:
8257 : 0 : pSym->Subrange.oafamily = oaf;
8258 : 0 : break;
8259 : :
8260 : 18 : case SymbolTable_EnumerationSym:
8261 : 18 : pSym->Enumeration.oafamily = oaf;
8262 : 18 : break;
8263 : :
8264 : 6 : case SymbolTable_ArraySym:
8265 : 6 : pSym->Array.oafamily = oaf;
8266 : 6 : break;
8267 : :
8268 : 0 : case SymbolTable_ProcTypeSym:
8269 : 0 : pSym->ProcType.oafamily = oaf;
8270 : 0 : break;
8271 : :
8272 : 30296 : case SymbolTable_TypeSym:
8273 : 30296 : pSym->Type.oafamily = oaf;
8274 : 30296 : break;
8275 : :
8276 : 0 : case SymbolTable_PointerSym:
8277 : 0 : pSym->Pointer.oafamily = oaf;
8278 : 0 : break;
8279 : :
8280 : 0 : case SymbolTable_SetSym:
8281 : 0 : pSym->Set.oafamily = oaf;
8282 : 0 : break;
8283 : :
8284 : 0 : case SymbolTable_UndefinedSym:
8285 : 0 : pSym->Undefined.oafamily = oaf;
8286 : 0 : break;
8287 : :
8288 : :
8289 : 0 : default:
8290 : 0 : M2Error_InternalError ((const char *) "not expecting this SimpleType", 29);
8291 : 30332 : break;
8292 : : }
8293 : 30332 : }
8294 : :
8295 : :
8296 : : /*
8297 : : doFillInOAFamily -
8298 : : */
8299 : :
8300 : 0 : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded)
8301 : : {
8302 : 0 : unsigned int SimpleType;
8303 : :
8304 : 0 : SimpleType = SymbolTable_GetType (oaf);
8305 : 0 : if (unbounded != SymbolTable_NulSym)
8306 : : {
8307 : 0 : FillInUnboundedFields (M2LexBuf_GetTokenNo (), unbounded, SimpleType, i);
8308 : : }
8309 : 0 : }
8310 : :
8311 : :
8312 : : /*
8313 : : FillInUnboundedFields -
8314 : : */
8315 : :
8316 : 30392 : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim)
8317 : : {
8318 : 30392 : SymbolTable_PtrToSymbol pSym;
8319 : 30392 : unsigned int Contents;
8320 : 30392 : unsigned int i;
8321 : :
8322 : 30392 : if (sym != SymbolTable_NulSym)
8323 : : {
8324 : 30392 : pSym = GetPsym (sym);
8325 : 30392 : pSym->SymbolType = SymbolTable_UnboundedSym;
8326 : 30392 : pSym->Unbounded.Type = SimpleType; /* Index to a simple type. */
8327 : 30392 : pSym->Unbounded.Size = M2ALU_InitValue (); /* Size in bytes for this sym */
8328 : 30392 : pSym->Unbounded.Scope = SymbolTable_GetScope (SimpleType); /* Which scope will create it */
8329 : 30392 : InitWhereDeclaredTok (tok, &pSym->Unbounded.At); /* Declared here */
8330 : 30392 : NewSym (&pSym->Unbounded.RecordType); /* Declared here */
8331 : 30392 : FillInRecordFields (tok, pSym->Unbounded.RecordType, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
8332 : 30392 : NewSym (&Contents);
8333 : 30392 : FillInPointerFields (Contents, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
8334 : 30392 : SymbolTable_PutPointer (Contents, SimpleType);
8335 : : /* create the contents field for the unbounded array. */
8336 : 30392 : M2Debug_Assert ((SymbolTable_PutFieldRecord (pSym->Unbounded.RecordType, NameKey_MakeKey ((const char *) "_m2_contents", 12), Contents, SymbolTable_NulSym)) != SymbolTable_NulSym);
8337 : : /* create all the high fields for the unbounded array. */
8338 : 30392 : i = 1;
8339 : 60928 : while (i <= ndim)
8340 : : {
8341 : 30536 : 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);
8342 : 30536 : i += 1;
8343 : : }
8344 : 30392 : pSym->Unbounded.Dimensions = ndim;
8345 : 30392 : ForeachParameterDo ((SymbolTable_CheckProcedure) {(SymbolTable_CheckProcedure_t) CheckUnbounded});
8346 : : }
8347 : 30392 : }
8348 : :
8349 : :
8350 : : /*
8351 : : PutUnbounded - associates the unbounded symbol, open, with
8352 : : SimpleType.
8353 : : */
8354 : :
8355 : 30392 : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim)
8356 : : {
8357 : 30392 : SymbolTable_PtrToSymbol pSym;
8358 : :
8359 : 30392 : pSym = GetPsym (oaf);
8360 : 30392 : switch (pSym->SymbolType)
8361 : : {
8362 : : case SymbolTable_OAFamilySym:
8363 : : /* need to check to see if we need to add NulSym for all dimensions < ndim
8364 : : which have not been used. */
8365 : 60868 : while (pSym->OAFamily.MaxDimensions < ndim)
8366 : : {
8367 : 30476 : pSym->OAFamily.MaxDimensions += 1;
8368 : 30476 : if (pSym->OAFamily.MaxDimensions < ndim)
8369 : : {
8370 : : /* add NulSym to an unused dimension. */
8371 : 84 : PutIntoIndex (&pSym->OAFamily.Dimensions, pSym->OAFamily.MaxDimensions, SymbolTable_NulSym);
8372 : : }
8373 : : }
8374 : : /* and finally add the known sym. */
8375 : 30392 : PutIntoIndex (&pSym->OAFamily.Dimensions, ndim, sym);
8376 : 30392 : break;
8377 : :
8378 : :
8379 : 0 : default:
8380 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
8381 : 30392 : break;
8382 : : }
8383 : 30392 : }
8384 : :
8385 : :
8386 : : /*
8387 : : GetArrayDimension - returns the number of dimensions defined.
8388 : : */
8389 : :
8390 : 6759 : static unsigned int GetArrayDimension (unsigned int sym)
8391 : : {
8392 : 6759 : unsigned int n;
8393 : :
8394 : 6759 : n = 0;
8395 : 13692 : while (SymbolTable_IsArray (sym))
8396 : : {
8397 : 6933 : sym = SymbolTable_SkipType (SymbolTable_GetType (sym));
8398 : 6933 : n += 1;
8399 : : }
8400 : 6759 : return n;
8401 : : /* static analysis guarentees a RETURN statement will be used before here. */
8402 : : __builtin_unreachable ();
8403 : : }
8404 : :
8405 : :
8406 : : /*
8407 : : ResolveConstructorType - if, sym, has an unresolved constructor type
8408 : : then attempt to resolve it by examining the
8409 : : from, type.
8410 : : */
8411 : :
8412 : 36458 : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres)
8413 : : {
8414 : 36458 : if ((*unres))
8415 : : {
8416 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
8417 : 36458 : if (SymbolTable_IsConstructor ((*from)))
8418 : : {
8419 : : /* avoid dangling else. */
8420 : 0 : if (IsConstructorResolved ((*from)))
8421 : : {
8422 : 0 : (*unres) = false;
8423 : 0 : (*type) = SymbolTable_GetType ((*from));
8424 : 0 : if (((*type) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*type)))))
8425 : : {
8426 : 0 : SymbolTable_PutConstSet (sym);
8427 : : }
8428 : : }
8429 : : }
8430 : 36458 : else if (((*from) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*from)))))
8431 : : {
8432 : : /* avoid dangling else. */
8433 : 33226 : (*unres) = false;
8434 : 33226 : (*type) = (*from);
8435 : 33226 : SymbolTable_PutConstSet (sym);
8436 : : }
8437 : 3232 : else if (((*from) != SymbolTable_NulSym) && ((SymbolTable_IsRecord (SymbolTable_SkipType ((*from)))) || (SymbolTable_IsArray (SymbolTable_SkipType ((*from))))))
8438 : : {
8439 : : /* avoid dangling else. */
8440 : 3226 : (*unres) = false;
8441 : 3226 : (*type) = (*from);
8442 : : }
8443 : : }
8444 : 36458 : }
8445 : :
8446 : :
8447 : : /*
8448 : : IsConstructorResolved - returns TRUE if the constructor does not
8449 : : have an unresolved type.
8450 : : */
8451 : :
8452 : 72916 : static bool IsConstructorResolved (unsigned int sym)
8453 : : {
8454 : 72916 : SymbolTable_PtrToSymbol pSym;
8455 : :
8456 : 72916 : pSym = GetPsym (sym);
8457 : 72916 : switch (pSym->SymbolType)
8458 : : {
8459 : 72916 : case SymbolTable_ConstVarSym:
8460 : 72916 : return ! pSym->ConstVar.UnresFromType;
8461 : 0 : break;
8462 : :
8463 : 0 : case SymbolTable_ConstLitSym:
8464 : 0 : return ! pSym->ConstLit.UnresFromType;
8465 : 0 : break;
8466 : :
8467 : :
8468 : 0 : default:
8469 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
8470 : : break;
8471 : : }
8472 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8473 : : __builtin_unreachable ();
8474 : : }
8475 : :
8476 : :
8477 : : /*
8478 : : CanResolveConstructor - returns TRUE if the type of the constructor,
8479 : : sym, is known.
8480 : : */
8481 : :
8482 : 36458 : static bool CanResolveConstructor (unsigned int sym)
8483 : : {
8484 : 36458 : SymbolTable_PtrToSymbol pSym;
8485 : :
8486 : 36458 : if (! (IsConstructorResolved (sym)))
8487 : : {
8488 : 36458 : pSym = GetPsym (sym);
8489 : 36458 : switch (pSym->SymbolType)
8490 : : {
8491 : 36458 : case SymbolTable_ConstVarSym:
8492 : 36458 : ResolveConstructorType (sym, &pSym->ConstVar.Type, &pSym->ConstVar.FromType, &pSym->ConstVar.UnresFromType);
8493 : 36458 : break;
8494 : :
8495 : 0 : case SymbolTable_ConstLitSym:
8496 : 0 : ResolveConstructorType (sym, &pSym->ConstLit.Type, &pSym->ConstLit.FromType, &pSym->ConstLit.UnresFromType);
8497 : 0 : break;
8498 : :
8499 : :
8500 : 0 : default:
8501 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
8502 : : break;
8503 : : }
8504 : : }
8505 : 36458 : return IsConstructorResolved (sym);
8506 : : /* static analysis guarentees a RETURN statement will be used before here. */
8507 : : __builtin_unreachable ();
8508 : : }
8509 : :
8510 : :
8511 : : /*
8512 : : CheckAllConstructorsResolved - checks to see that the
8513 : : UnresolvedConstructorType list is
8514 : : empty and if it is not then it
8515 : : generates error messages.
8516 : : */
8517 : :
8518 : 14941 : static void CheckAllConstructorsResolved (void)
8519 : : {
8520 : 14941 : unsigned int i;
8521 : 14941 : unsigned int n;
8522 : 14941 : unsigned int s;
8523 : 14941 : M2Error_Error e;
8524 : :
8525 : 14941 : n = Lists_NoOfItemsInList (UnresolvedConstructorType);
8526 : 14941 : if (n > 0)
8527 : : {
8528 : 12 : for (i=1; i<=n; i++)
8529 : : {
8530 : 6 : s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
8531 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredMod (s));
8532 : 6 : M2Error_ErrorFormat0 (e, (const char *) "constructor has an unknown type", 31);
8533 : : }
8534 : 6 : M2Error_FlushErrors ();
8535 : : }
8536 : 14935 : }
8537 : :
8538 : :
8539 : : /*
8540 : : SanityCheckParameters -
8541 : : */
8542 : :
8543 : 4899332 : static void SanityCheckParameters (unsigned int sym)
8544 : : {
8545 : 4899332 : unsigned int p;
8546 : 4899332 : unsigned int i;
8547 : 4899332 : unsigned int n;
8548 : :
8549 : 4899332 : i = 1;
8550 : 4899332 : n = SymbolTable_NoOfParamAny (sym);
8551 : 18366304 : while (i <= n)
8552 : : {
8553 : 8567640 : p = SymbolTable_GetType (SymbolTable_GetParam (sym, i));
8554 : 8567640 : if (SymbolTable_IsConst (p))
8555 : : {
8556 : 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);
8557 : : }
8558 : 8567640 : i += 1;
8559 : : }
8560 : 4899332 : }
8561 : :
8562 : :
8563 : : /*
8564 : : SanityCheckArray - checks to see that an array has a correct subrange type.
8565 : : */
8566 : :
8567 : 60697537 : static void SanityCheckArray (unsigned int sym)
8568 : : {
8569 : 60697537 : unsigned int type;
8570 : 60697537 : unsigned int subscript;
8571 : :
8572 : 60697537 : if (SymbolTable_IsArray (sym))
8573 : : {
8574 : 101321 : subscript = SymbolTable_GetArraySubscript (sym);
8575 : 101321 : if (subscript != SymbolTable_NulSym)
8576 : : {
8577 : 101321 : type = SymbolTable_SkipType (SymbolTable_GetType (subscript));
8578 : 101321 : if (SymbolTable_IsAModula2Type (type))
8579 : : {} /* empty. */
8580 : : else
8581 : : {
8582 : : /* Ok all is good. */
8583 : 0 : M2MetaError_MetaError2 ((const char *) "the array {%1Dad} must be declared with a simpletype in the [..] component rather than a {%2dv}", 95, sym, type);
8584 : : }
8585 : : }
8586 : : }
8587 : 60697537 : }
8588 : :
8589 : :
8590 : : /*
8591 : : ForeachSymbolDo - foreach symbol, call, P(sym).
8592 : : */
8593 : :
8594 : 14935 : static void ForeachSymbolDo (SymbolKey_PerformOperation P)
8595 : : {
8596 : 14935 : unsigned int i;
8597 : 14935 : unsigned int n;
8598 : :
8599 : 14935 : i = Indexing_LowIndice (Symbols);
8600 : 14935 : n = Indexing_HighIndice (Symbols);
8601 : 52644989 : while (i <= n)
8602 : : {
8603 : 52615119 : (*P.proc) (i);
8604 : 52615119 : i += 1;
8605 : : }
8606 : 14935 : }
8607 : :
8608 : :
8609 : : /*
8610 : : SanityCheckProcedure - check to see that procedure parameters do not use constants
8611 : : instead of types in their formal parameter section.
8612 : : */
8613 : :
8614 : 4899332 : static void SanityCheckProcedure (unsigned int sym)
8615 : : {
8616 : 4899332 : SanityCheckParameters (sym);
8617 : 4899332 : }
8618 : :
8619 : :
8620 : : /*
8621 : : SanityCheckModule -
8622 : : */
8623 : :
8624 : 188904 : static void SanityCheckModule (unsigned int sym)
8625 : : {
8626 : 188904 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
8627 : 188904 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckProcedure});
8628 : 188904 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
8629 : 188904 : }
8630 : :
8631 : :
8632 : : /*
8633 : : AddNameTo - adds Name, n, to tree, s.
8634 : : */
8635 : :
8636 : 7904742 : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o)
8637 : : {
8638 : 7904742 : if ((SymbolKey_GetSymKey (s, SymbolTable_GetSymName (o))) == SymbolKey_NulKey)
8639 : : {
8640 : 6621649 : SymbolKey_PutSymKey (s, SymbolTable_GetSymName (o), o);
8641 : : }
8642 : 7904742 : }
8643 : :
8644 : :
8645 : : /*
8646 : : CollectSymbolFrom -
8647 : : */
8648 : :
8649 : 134 : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n)
8650 : : {
8651 : 134 : NameKey_Name n1;
8652 : 134 : unsigned int sym;
8653 : :
8654 : 134 : n1 = SymbolTable_GetSymName (scope);
8655 : 134 : if (DebugUnknowns)
8656 : : {
8657 : : M2Printf_printf2 ((const char *) "declaring %a in %a", 18, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n1, (sizeof (n1)-1));
8658 : : }
8659 : 134 : sym = CheckScopeForSym (scope, n);
8660 : 134 : if (sym == SymbolTable_NulSym)
8661 : : {
8662 : 56 : sym = FetchUnknownFrom (tok, scope, n);
8663 : : }
8664 : 134 : if (DebugUnknowns)
8665 : : {
8666 : : M2Printf_printf1 ((const char *) " symbol created (%d)\\n", 22, (const unsigned char *) &sym, (sizeof (sym)-1));
8667 : : }
8668 : 134 : return sym;
8669 : : /* static analysis guarentees a RETURN statement will be used before here. */
8670 : : __builtin_unreachable ();
8671 : : }
8672 : :
8673 : :
8674 : : /*
8675 : : CollectUnknown -
8676 : : */
8677 : :
8678 : 170 : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n)
8679 : : {
8680 : 230 : SymbolTable_PtrToSymbol pSym;
8681 : 230 : unsigned int s;
8682 : :
8683 : 230 : s = SymbolTable_NulSym;
8684 : 230 : if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
8685 : : {
8686 : 116 : return CollectSymbolFrom (tok, sym, n);
8687 : : }
8688 : 114 : else if (SymbolTable_IsProcedure (sym))
8689 : : {
8690 : : /* avoid dangling else. */
8691 : 114 : s = CheckScopeForSym (sym, n);
8692 : 114 : if (s == SymbolTable_NulSym)
8693 : : {
8694 : 78 : pSym = GetPsym (sym);
8695 : 78 : switch (pSym->SymbolType)
8696 : : {
8697 : 78 : case SymbolTable_ProcedureSym:
8698 : 78 : if ((SymbolKey_GetSymKey (pSym->Procedure.NamedObjects, n)) != SymbolKey_NulKey)
8699 : : {
8700 : 18 : return CollectSymbolFrom (tok, sym, n);
8701 : : }
8702 : 60 : break;
8703 : :
8704 : :
8705 : 0 : default:
8706 : 0 : M2Error_InternalError ((const char *) "expecting - Procedure symbol", 28);
8707 : 60 : break;
8708 : : }
8709 : 60 : s = CollectUnknown (tok, SymbolTable_GetScope (sym), n);
8710 : : }
8711 : : }
8712 : : return s;
8713 : : /* static analysis guarentees a RETURN statement will be used before here. */
8714 : : __builtin_unreachable ();
8715 : : }
8716 : :
8717 : :
8718 : : /*
8719 : : ResolveImport -
8720 : : */
8721 : :
8722 : 170 : static void ResolveImport (unsigned int o)
8723 : : {
8724 : 170 : NameKey_Name n1;
8725 : 170 : NameKey_Name n2;
8726 : 170 : unsigned int tok;
8727 : 170 : unsigned int sym;
8728 : :
8729 : 170 : if (DebugUnknowns)
8730 : : {
8731 : : n1 = SymbolTable_GetSymName (o);
8732 : : M2Printf_printf1 ((const char *) "attempting to find out where %a was declared\\n", 46, (const unsigned char *) &n1, (sizeof (n1)-1));
8733 : : n1 = SymbolTable_GetSymName (ResolveModule);
8734 : : n2 = SymbolTable_GetSymName (SymbolTable_GetScope (ResolveModule));
8735 : : 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));
8736 : : }
8737 : 170 : tok = SymbolTable_GetFirstUsed (o);
8738 : 170 : sym = CollectUnknown (tok, SymbolTable_GetScope (ResolveModule), SymbolTable_GetSymName (o));
8739 : 170 : if (sym == SymbolTable_NulSym)
8740 : : {
8741 : 0 : M2MetaError_MetaError2 ((const char *) "unknown symbol {%1Uad} found in import list of module {%2a}", 59, o, ResolveModule);
8742 : : }
8743 : : else
8744 : : {
8745 : 170 : SymbolTable_AddSymToModuleScope (ResolveModule, sym);
8746 : : }
8747 : 170 : }
8748 : :
8749 : :
8750 : : /*
8751 : : ResolveRelativeImport -
8752 : : */
8753 : :
8754 : 1913340 : static void ResolveRelativeImport (unsigned int sym)
8755 : : {
8756 : 1913340 : SymbolTable_PtrToSymbol pSym;
8757 : :
8758 : 1913340 : if (SymbolTable_IsModule (sym))
8759 : : {
8760 : 428 : ResolveModule = sym;
8761 : 428 : pSym = GetPsym (sym);
8762 : 428 : switch (pSym->SymbolType)
8763 : : {
8764 : 428 : case SymbolTable_ModuleSym:
8765 : 428 : SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveImport});
8766 : 428 : break;
8767 : :
8768 : :
8769 : 0 : default:
8770 : 0 : M2Error_InternalError ((const char *) "expecting - Module symbol", 25);
8771 : 428 : break;
8772 : : }
8773 : : }
8774 : 1913340 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
8775 : 1913340 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
8776 : 1913340 : }
8777 : :
8778 : :
8779 : : /*
8780 : : Max -
8781 : : */
8782 : :
8783 : 0 : static unsigned int Max (unsigned int a, unsigned int b)
8784 : : {
8785 : 0 : if (a > b)
8786 : : {
8787 : : return a;
8788 : : }
8789 : : else
8790 : : {
8791 : : return b;
8792 : : }
8793 : : /* static analysis guarentees a RETURN statement will be used before here. */
8794 : : __builtin_unreachable ();
8795 : : }
8796 : :
8797 : :
8798 : : /*
8799 : : Min -
8800 : : */
8801 : :
8802 : 0 : static unsigned int Min (unsigned int a, unsigned int b)
8803 : : {
8804 : 0 : if (a < b)
8805 : : {
8806 : : return a;
8807 : : }
8808 : : else
8809 : : {
8810 : : return b;
8811 : : }
8812 : : /* static analysis guarentees a RETURN statement will be used before here. */
8813 : : __builtin_unreachable ();
8814 : : }
8815 : :
8816 : :
8817 : : /*
8818 : : DoFindLimits - assigns, Start, and, End, to the start and end
8819 : : limits contained in the list, l. It ensures that
8820 : : Start and End are within StartLimit..EndLimit.
8821 : : If StartLimit or EndLimit are 0 then Start is
8822 : : is set to the first value and End to the last.
8823 : : */
8824 : :
8825 : 30 : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l)
8826 : : {
8827 : 30 : unsigned int i;
8828 : 30 : unsigned int j;
8829 : 30 : unsigned int n;
8830 : :
8831 : 30 : (*End) = 0;
8832 : 30 : (*Start) = 0;
8833 : 30 : i = 1;
8834 : 30 : n = Lists_NoOfItemsInList (l);
8835 : 90 : while (i <= n)
8836 : : {
8837 : 30 : j = static_cast<unsigned int> (Lists_GetItemFromList (l, i));
8838 : 30 : if (((j > (*End)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
8839 : : {
8840 : 24 : (*End) = j;
8841 : : }
8842 : 30 : if ((((((*Start) == 0) || (j < (*Start))) && (j != 0)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
8843 : : {
8844 : 24 : (*Start) = j;
8845 : : }
8846 : 30 : i += 1;
8847 : : }
8848 : 30 : }
8849 : :
8850 : :
8851 : : /*
8852 : : PutDeclaredDefinition - associates the current tokenno with
8853 : : the symbols declaration in the definition
8854 : : module.
8855 : : */
8856 : :
8857 : 18565648 : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym)
8858 : : {
8859 : 18565648 : SymbolTable_PtrToSymbol pSym;
8860 : :
8861 : 18565648 : pSym = GetPsym (Sym);
8862 : 18565648 : switch (pSym->SymbolType)
8863 : : {
8864 : 0 : case SymbolTable_ErrorSym:
8865 : 0 : pSym->Error.At.DefDeclared = tok;
8866 : 0 : break;
8867 : :
8868 : 0 : case SymbolTable_ObjectSym:
8869 : 0 : pSym->Object.At.DefDeclared = tok;
8870 : 0 : break;
8871 : :
8872 : 0 : case SymbolTable_VarientSym:
8873 : 0 : pSym->Varient.At.DefDeclared = tok;
8874 : 0 : break;
8875 : :
8876 : 0 : case SymbolTable_RecordSym:
8877 : 0 : pSym->Record.At.DefDeclared = tok;
8878 : 0 : break;
8879 : :
8880 : 0 : case SymbolTable_SubrangeSym:
8881 : 0 : pSym->Subrange.At.DefDeclared = tok;
8882 : 0 : break;
8883 : :
8884 : 0 : case SymbolTable_EnumerationSym:
8885 : 0 : pSym->Enumeration.At.DefDeclared = tok;
8886 : 0 : break;
8887 : :
8888 : 1097 : case SymbolTable_ArraySym:
8889 : 1097 : pSym->Array.At.DefDeclared = tok;
8890 : 1097 : break;
8891 : :
8892 : 0 : case SymbolTable_SubscriptSym:
8893 : 0 : pSym->Subscript.At.DefDeclared = tok;
8894 : 0 : break;
8895 : :
8896 : 0 : case SymbolTable_UnboundedSym:
8897 : 0 : pSym->Unbounded.At.DefDeclared = tok;
8898 : 0 : break;
8899 : :
8900 : 3289216 : case SymbolTable_ProcedureSym:
8901 : 3289216 : pSym->Procedure.At.DefDeclared = tok;
8902 : 3289216 : break;
8903 : :
8904 : 0 : case SymbolTable_ProcTypeSym:
8905 : 0 : pSym->ProcType.At.DefDeclared = tok;
8906 : 0 : break;
8907 : :
8908 : 0 : case SymbolTable_ConstStringSym:
8909 : 0 : pSym->ConstString.At.DefDeclared = tok;
8910 : 0 : break;
8911 : :
8912 : 0 : case SymbolTable_ConstLitSym:
8913 : 0 : pSym->ConstLit.At.DefDeclared = tok;
8914 : 0 : break;
8915 : :
8916 : 3940 : case SymbolTable_ConstVarSym:
8917 : 3940 : pSym->ConstVar.At.DefDeclared = tok;
8918 : 3940 : break;
8919 : :
8920 : 7005251 : case SymbolTable_VarSym:
8921 : 7005251 : pSym->Var.At.DefDeclared = tok;
8922 : 7005251 : break;
8923 : :
8924 : 0 : case SymbolTable_TypeSym:
8925 : 0 : pSym->Type.At.DefDeclared = tok;
8926 : 0 : break;
8927 : :
8928 : 0 : case SymbolTable_PointerSym:
8929 : 0 : pSym->Pointer.At.DefDeclared = tok;
8930 : 0 : break;
8931 : :
8932 : 94975 : case SymbolTable_RecordFieldSym:
8933 : 94975 : pSym->RecordField.At.DefDeclared = tok;
8934 : 94975 : break;
8935 : :
8936 : 0 : case SymbolTable_VarientFieldSym:
8937 : 0 : pSym->VarientField.At.DefDeclared = tok;
8938 : 0 : break;
8939 : :
8940 : 0 : case SymbolTable_EnumerationFieldSym:
8941 : 0 : pSym->EnumerationField.At.DefDeclared = tok;
8942 : 0 : break;
8943 : :
8944 : 0 : case SymbolTable_SetSym:
8945 : 0 : pSym->Set.At.DefDeclared = tok;
8946 : 0 : break;
8947 : :
8948 : 8170983 : case SymbolTable_DefImpSym:
8949 : 8170983 : pSym->DefImp.At.DefDeclared = tok;
8950 : 8170983 : break;
8951 : :
8952 : 186 : case SymbolTable_ModuleSym:
8953 : 186 : pSym->Module.At.DefDeclared = tok;
8954 : 186 : break;
8955 : :
8956 : : case SymbolTable_UndefinedSym:
8957 : : break;
8958 : :
8959 : 0 : case SymbolTable_PartialUnboundedSym:
8960 : 0 : PutDeclaredDefinition (tok, pSym->PartialUnbounded.Type);
8961 : 0 : break;
8962 : :
8963 : :
8964 : 0 : default:
8965 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
8966 : 18565648 : break;
8967 : : }
8968 : 18565648 : }
8969 : :
8970 : :
8971 : : /*
8972 : : PutDeclaredModule - returns the token where this symbol was declared
8973 : : in an implementation or program module.
8974 : : */
8975 : :
8976 : 12895776 : static void PutDeclaredModule (unsigned int tok, unsigned int Sym)
8977 : : {
8978 : 12895776 : SymbolTable_PtrToSymbol pSym;
8979 : :
8980 : 12895776 : pSym = GetPsym (Sym);
8981 : 12895776 : switch (pSym->SymbolType)
8982 : : {
8983 : 0 : case SymbolTable_ErrorSym:
8984 : 0 : pSym->Error.At.ModDeclared = tok;
8985 : 0 : break;
8986 : :
8987 : 0 : case SymbolTable_ObjectSym:
8988 : 0 : pSym->Object.At.ModDeclared = tok;
8989 : 0 : break;
8990 : :
8991 : 0 : case SymbolTable_VarientSym:
8992 : 0 : pSym->Varient.At.ModDeclared = tok;
8993 : 0 : break;
8994 : :
8995 : 0 : case SymbolTable_RecordSym:
8996 : 0 : pSym->Record.At.ModDeclared = tok;
8997 : 0 : break;
8998 : :
8999 : 0 : case SymbolTable_SubrangeSym:
9000 : 0 : pSym->Subrange.At.ModDeclared = tok;
9001 : 0 : break;
9002 : :
9003 : 0 : case SymbolTable_EnumerationSym:
9004 : 0 : pSym->Enumeration.At.ModDeclared = tok;
9005 : 0 : break;
9006 : :
9007 : 98949 : case SymbolTable_ArraySym:
9008 : 98949 : pSym->Array.At.ModDeclared = tok;
9009 : 98949 : break;
9010 : :
9011 : 0 : case SymbolTable_SubscriptSym:
9012 : 0 : pSym->Subscript.At.ModDeclared = tok;
9013 : 0 : break;
9014 : :
9015 : 0 : case SymbolTable_UnboundedSym:
9016 : 0 : pSym->Unbounded.At.ModDeclared = tok;
9017 : 0 : break;
9018 : :
9019 : 3142479 : case SymbolTable_ProcedureSym:
9020 : 3142479 : pSym->Procedure.At.ModDeclared = tok;
9021 : 3142479 : break;
9022 : :
9023 : 0 : case SymbolTable_ProcTypeSym:
9024 : 0 : pSym->ProcType.At.ModDeclared = tok;
9025 : 0 : break;
9026 : :
9027 : 0 : case SymbolTable_ConstStringSym:
9028 : 0 : pSym->ConstString.At.ModDeclared = tok;
9029 : 0 : break;
9030 : :
9031 : 0 : case SymbolTable_ConstLitSym:
9032 : 0 : pSym->ConstLit.At.ModDeclared = tok;
9033 : 0 : break;
9034 : :
9035 : 7049 : case SymbolTable_ConstVarSym:
9036 : 7049 : pSym->ConstVar.At.ModDeclared = tok;
9037 : 7049 : break;
9038 : :
9039 : 3533894 : case SymbolTable_VarSym:
9040 : 3533894 : pSym->Var.At.ModDeclared = tok;
9041 : 3533894 : break;
9042 : :
9043 : 0 : case SymbolTable_TypeSym:
9044 : 0 : pSym->Type.At.ModDeclared = tok;
9045 : 0 : break;
9046 : :
9047 : 0 : case SymbolTable_PointerSym:
9048 : 0 : pSym->Pointer.At.ModDeclared = tok;
9049 : 0 : break;
9050 : :
9051 : 248885 : case SymbolTable_RecordFieldSym:
9052 : 248885 : pSym->RecordField.At.ModDeclared = tok;
9053 : 248885 : break;
9054 : :
9055 : 0 : case SymbolTable_VarientFieldSym:
9056 : 0 : pSym->VarientField.At.ModDeclared = tok;
9057 : 0 : break;
9058 : :
9059 : 0 : case SymbolTable_EnumerationFieldSym:
9060 : 0 : pSym->EnumerationField.At.ModDeclared = tok;
9061 : 0 : break;
9062 : :
9063 : 0 : case SymbolTable_SetSym:
9064 : 0 : pSym->Set.At.ModDeclared = tok;
9065 : 0 : break;
9066 : :
9067 : 5805808 : case SymbolTable_DefImpSym:
9068 : 5805808 : pSym->DefImp.At.ModDeclared = tok;
9069 : 5805808 : break;
9070 : :
9071 : 58712 : case SymbolTable_ModuleSym:
9072 : 58712 : pSym->Module.At.ModDeclared = tok;
9073 : 58712 : break;
9074 : :
9075 : : case SymbolTable_UndefinedSym:
9076 : : break;
9077 : :
9078 : 0 : case SymbolTable_PartialUnboundedSym:
9079 : 0 : PutDeclaredModule (tok, pSym->PartialUnbounded.Type);
9080 : 0 : break;
9081 : :
9082 : :
9083 : 0 : default:
9084 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
9085 : 12895776 : break;
9086 : : }
9087 : 12895776 : }
9088 : :
9089 : :
9090 : : /*
9091 : : DoIsConst - returns TRUE if Sym is defined as a constant
9092 : : or is an enumeration field or string.
9093 : : */
9094 : :
9095 : 232625607 : static bool DoIsConst (unsigned int Sym)
9096 : : {
9097 : 232625607 : SymbolTable_PtrToSymbol pSym;
9098 : :
9099 : 232625607 : pSym = GetPsym (Sym);
9100 : 232625607 : 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);
9101 : : /* static analysis guarentees a RETURN statement will be used before here. */
9102 : : __builtin_unreachable ();
9103 : : }
9104 : :
9105 : :
9106 : : /*
9107 : : GetFromIndex - return a value from list, i, at position, n.
9108 : : */
9109 : :
9110 : 7630642 : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n)
9111 : : {
9112 : 7630642 : typedef unsigned int *GetFromIndex__T2;
9113 : :
9114 : 7630642 : GetFromIndex__T2 p;
9115 : :
9116 : 6589134 : p = static_cast<GetFromIndex__T2> (Indexing_GetIndice (i, n));
9117 : 6589134 : return (*p);
9118 : : /* static analysis guarentees a RETURN statement will be used before here. */
9119 : : __builtin_unreachable ();
9120 : : }
9121 : :
9122 : :
9123 : : /*
9124 : : PutIntoIndex - places value, v, into list, i, at position, n.
9125 : : */
9126 : :
9127 : 327742 : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v)
9128 : : {
9129 : 327742 : typedef unsigned int *PutIntoIndex__T3;
9130 : :
9131 : 327742 : PutIntoIndex__T3 p;
9132 : :
9133 : 327742 : Storage_ALLOCATE ((void **) &p, sizeof (unsigned int));
9134 : 327742 : (*p) = v;
9135 : 327742 : Indexing_PutIndice ((*i), n, reinterpret_cast <void *> (p));
9136 : 327742 : }
9137 : :
9138 : :
9139 : : /*
9140 : : PushConstString - pushes the character string onto the ALU stack.
9141 : : It assumes that the character string is only
9142 : : one character long.
9143 : : */
9144 : :
9145 : 32938 : static void PushConstString (unsigned int Sym)
9146 : : {
9147 : 32938 : typedef struct PushConstString__T7_a PushConstString__T7;
9148 : :
9149 : 32938 : struct PushConstString__T7_a { char array[10+1]; };
9150 : 32938 : SymbolTable_PtrToSymbol pSym;
9151 : 32938 : PushConstString__T7 a;
9152 : :
9153 : 32938 : AssertInRange (Sym);
9154 : 32938 : pSym = GetPsym (Sym);
9155 : 32938 : switch (pSym->SymbolType)
9156 : : {
9157 : 32938 : case SymbolTable_ConstStringSym:
9158 : 32938 : if (pSym->ConstString.Length == 0)
9159 : : {
9160 : 6 : M2ALU_PushChar (ASCII_nul);
9161 : : }
9162 : 32932 : else if (pSym->ConstString.Length == 1)
9163 : : {
9164 : : /* avoid dangling else. */
9165 : 32932 : NameKey_GetKey (pSym->ConstString.Contents, (char *) &a.array[0], 10);
9166 : 32932 : M2ALU_PushChar (a.array[0]);
9167 : : }
9168 : : else
9169 : : {
9170 : : /* avoid dangling else. */
9171 : 0 : M2Error_WriteFormat0 ((const char *) "ConstString must be length 0 or 1", 33);
9172 : : }
9173 : 32938 : break;
9174 : :
9175 : :
9176 : 0 : default:
9177 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
9178 : 32938 : break;
9179 : : }
9180 : 32938 : }
9181 : :
9182 : :
9183 : : /*
9184 : : FinalSymbol - returns the highest number symbol used.
9185 : : */
9186 : :
9187 : 5412821572 : extern "C" unsigned int SymbolTable_FinalSymbol (void)
9188 : : {
9189 : 5412821572 : return FreeSymbol-1;
9190 : : /* static analysis guarentees a RETURN statement will be used before here. */
9191 : : __builtin_unreachable ();
9192 : : }
9193 : :
9194 : :
9195 : : /*
9196 : : MakeComponentRecord - make a temporary which will be used to reference and field
9197 : : (or sub field) of record.
9198 : : */
9199 : :
9200 : 145595 : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record)
9201 : : {
9202 : 145595 : return buildTemporary (tok, Mode, true, record);
9203 : : /* static analysis guarentees a RETURN statement will be used before here. */
9204 : : __builtin_unreachable ();
9205 : : }
9206 : :
9207 : :
9208 : : /*
9209 : : MakeComponentRef - use, sym, to reference, field, sym is returned.
9210 : : */
9211 : :
9212 : 145595 : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field)
9213 : : {
9214 : 145595 : SymbolTable_PtrToSymbol pSym;
9215 : 145595 : unsigned int high;
9216 : :
9217 : 145595 : pSym = GetPsym (sym);
9218 : 145595 : switch (pSym->SymbolType)
9219 : : {
9220 : 145595 : case SymbolTable_VarSym:
9221 : 145595 : if (! pSym->Var.IsTemp)
9222 : : {
9223 : 0 : M2Error_InternalError ((const char *) "variable must be a temporary", 28);
9224 : : }
9225 : 145595 : else if (pSym->Var.IsComponentRef)
9226 : : {
9227 : : /* avoid dangling else. */
9228 : 145595 : high = Indexing_HighIndice (pSym->Var.list);
9229 : 145595 : PutIntoIndex (&pSym->Var.list, high+1, field);
9230 : : }
9231 : : else
9232 : : {
9233 : : /* avoid dangling else. */
9234 : 0 : M2Error_InternalError ((const char *) "temporary is not a component reference", 38);
9235 : : }
9236 : 145595 : break;
9237 : :
9238 : :
9239 : 0 : default:
9240 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
9241 : 145595 : break;
9242 : : }
9243 : 145595 : return sym;
9244 : : /* static analysis guarentees a RETURN statement will be used before here. */
9245 : : __builtin_unreachable ();
9246 : : }
9247 : :
9248 : :
9249 : : /*
9250 : : IsComponent - returns TRUE if symbol, sym, is a temporary and a component
9251 : : reference.
9252 : : */
9253 : :
9254 : 414471612 : extern "C" bool SymbolTable_IsComponent (unsigned int sym)
9255 : : {
9256 : 414471612 : SymbolTable_PtrToSymbol pSym;
9257 : :
9258 : 414471612 : pSym = GetPsym (sym);
9259 : 414471612 : switch (pSym->SymbolType)
9260 : : {
9261 : 2677943 : case SymbolTable_VarSym:
9262 : 2677943 : return pSym->Var.IsComponentRef;
9263 : : break;
9264 : :
9265 : :
9266 : : default:
9267 : : return false;
9268 : : break;
9269 : : }
9270 : : /* static analysis guarentees a RETURN statement will be used before here. */
9271 : : __builtin_unreachable ();
9272 : : }
9273 : :
9274 : :
9275 : : /*
9276 : : MakeTemporary - Makes a new temporary variable at the highest real scope.
9277 : : The addressing mode of the temporary is set to NoValue.
9278 : : */
9279 : :
9280 : 1011581 : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode)
9281 : : {
9282 : 1011581 : tok = CheckTok (tok, (const char *) "temporary", 9);
9283 : 1011581 : return buildTemporary (tok, Mode, false, SymbolTable_NulSym);
9284 : : /* static analysis guarentees a RETURN statement will be used before here. */
9285 : : __builtin_unreachable ();
9286 : : }
9287 : :
9288 : :
9289 : : /*
9290 : : MakeTemporaryFromExpression - makes a new temporary variable at the
9291 : : highest real scope. The addressing
9292 : : mode of the temporary is set and the
9293 : : type is determined by expressions, e.
9294 : : */
9295 : :
9296 : 0 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode)
9297 : : {
9298 : 0 : return SymbolTable_MakeTemporaryFromExpressions (tok, e, e, mode);
9299 : : /* static analysis guarentees a RETURN statement will be used before here. */
9300 : : __builtin_unreachable ();
9301 : : }
9302 : :
9303 : :
9304 : : /*
9305 : : MakeTemporaryFromExpressions - makes a new temporary variable at the
9306 : : highest real scope. The addressing
9307 : : mode of the temporary is set and the
9308 : : type is determined by expressions,
9309 : : e1 and e2.
9310 : : */
9311 : :
9312 : 77009 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode)
9313 : : {
9314 : 77009 : SymbolTable_PtrToSymbol pSym;
9315 : 77009 : DynamicStrings_String s;
9316 : 77009 : unsigned int t;
9317 : 77009 : unsigned int Sym;
9318 : :
9319 : 77009 : TemporaryNo += 1;
9320 : : /* Make the name */
9321 : 77009 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
9322 : 77009 : if (mode == SymbolTable_ImmediateValue)
9323 : : {
9324 : 34441 : Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
9325 : 34441 : if (SymbolTable_IsConstructor (e1))
9326 : : {
9327 : 218 : SymbolTable_PutConstructor (Sym);
9328 : 218 : SymbolTable_PutConstructorFrom (Sym, e1);
9329 : : }
9330 : 34223 : else if (SymbolTable_IsConstructor (e2))
9331 : : {
9332 : : /* avoid dangling else. */
9333 : 12 : SymbolTable_PutConstructor (Sym);
9334 : 12 : SymbolTable_PutConstructorFrom (Sym, e2);
9335 : : }
9336 : : else
9337 : : {
9338 : : /* avoid dangling else. */
9339 : 34211 : SymbolTable_PutVar (Sym, M2Base_MixTypes (SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok));
9340 : : }
9341 : 34441 : PutConstVarTemporary (Sym);
9342 : : }
9343 : : else
9344 : : {
9345 : 42568 : Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
9346 : 42568 : pSym = GetPsym (Sym);
9347 : 42568 : switch (pSym->SymbolType)
9348 : : {
9349 : 42568 : case SymbolTable_VarSym:
9350 : 42568 : pSym->Var.AddrMode = mode;
9351 : 42568 : pSym->Var.IsComponentRef = false;
9352 : 42568 : pSym->Var.IsTemp = true; /* Variable is a temporary var */
9353 : : /* Declared here */
9354 : 42568 : InitWhereDeclaredTok (tok, &pSym->Var.At);
9355 : 42568 : break;
9356 : :
9357 : :
9358 : 0 : default:
9359 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
9360 : 42568 : break;
9361 : : }
9362 : 42568 : t = M2Base_MixTypesDecl (e1, e2, SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok);
9363 : 42460 : if (t != SymbolTable_NulSym)
9364 : : {
9365 : 42448 : M2Debug_Assert (! (SymbolTable_IsConstructor (t)));
9366 : 42448 : SymbolTable_PutVar (Sym, t);
9367 : : }
9368 : : }
9369 : 76901 : s = DynamicStrings_KillString (s);
9370 : 76901 : return Sym;
9371 : : /* static analysis guarentees a RETURN statement will be used before here. */
9372 : : __builtin_unreachable ();
9373 : : }
9374 : :
9375 : :
9376 : : /*
9377 : : PutMode - Puts the addressing mode, SymMode, into symbol Sym.
9378 : : The mode may only be altered if the mode
9379 : : is None.
9380 : : */
9381 : :
9382 : 8849298 : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode)
9383 : : {
9384 : 8849298 : SymbolTable_PtrToSymbol pSym;
9385 : :
9386 : 8849298 : pSym = GetPsym (Sym);
9387 : 8849298 : switch (pSym->SymbolType)
9388 : : {
9389 : : case SymbolTable_ErrorSym:
9390 : : break;
9391 : :
9392 : 8849298 : case SymbolTable_VarSym:
9393 : 8849298 : pSym->Var.AddrMode = SymMode;
9394 : 8849298 : break;
9395 : :
9396 : :
9397 : 0 : default:
9398 : 0 : M2Error_InternalError ((const char *) "Expecting VarSym", 16);
9399 : 8849298 : break;
9400 : : }
9401 : 8849298 : }
9402 : :
9403 : :
9404 : : /*
9405 : : GetMode - Returns the addressing mode of a symbol.
9406 : : */
9407 : :
9408 : 10443472 : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym)
9409 : : {
9410 : 10443472 : SymbolTable_PtrToSymbol pSym;
9411 : :
9412 : 10443472 : pSym = GetPsym (Sym);
9413 : 10443472 : switch (pSym->SymbolType)
9414 : : {
9415 : 6 : case SymbolTable_ErrorSym:
9416 : 6 : M2Error_ErrorAbort0 ((const char *) "", 0);
9417 : 8450999 : break;
9418 : :
9419 : 8450999 : case SymbolTable_VarSym:
9420 : 8450999 : return pSym->Var.AddrMode;
9421 : : break;
9422 : :
9423 : : case SymbolTable_ConstLitSym:
9424 : : return SymbolTable_ImmediateValue;
9425 : : break;
9426 : :
9427 : : case SymbolTable_ConstVarSym:
9428 : : return SymbolTable_ImmediateValue;
9429 : : break;
9430 : :
9431 : : case SymbolTable_ConstStringSym:
9432 : : return SymbolTable_ImmediateValue;
9433 : : break;
9434 : :
9435 : : case SymbolTable_EnumerationFieldSym:
9436 : : return SymbolTable_ImmediateValue;
9437 : : break;
9438 : :
9439 : : case SymbolTable_ProcedureSym:
9440 : : return SymbolTable_ImmediateValue;
9441 : : break;
9442 : :
9443 : : case SymbolTable_RecordFieldSym:
9444 : : return SymbolTable_ImmediateValue;
9445 : : break;
9446 : :
9447 : : case SymbolTable_VarientFieldSym:
9448 : : return SymbolTable_ImmediateValue;
9449 : : break;
9450 : :
9451 : : case SymbolTable_TypeSym:
9452 : : return SymbolTable_NoValue;
9453 : : break;
9454 : :
9455 : : case SymbolTable_ArraySym:
9456 : : return SymbolTable_NoValue;
9457 : : break;
9458 : :
9459 : : case SymbolTable_SubrangeSym:
9460 : : return SymbolTable_NoValue;
9461 : : break;
9462 : :
9463 : : case SymbolTable_EnumerationSym:
9464 : : return SymbolTable_NoValue;
9465 : : break;
9466 : :
9467 : : case SymbolTable_RecordSym:
9468 : : return SymbolTable_NoValue;
9469 : : break;
9470 : :
9471 : : case SymbolTable_PointerSym:
9472 : : return SymbolTable_NoValue;
9473 : : break;
9474 : :
9475 : : case SymbolTable_SetSym:
9476 : : return SymbolTable_NoValue;
9477 : : break;
9478 : :
9479 : : case SymbolTable_ProcTypeSym:
9480 : : return SymbolTable_NoValue;
9481 : : break;
9482 : :
9483 : : case SymbolTable_UnboundedSym:
9484 : : return SymbolTable_NoValue;
9485 : : break;
9486 : :
9487 : : case SymbolTable_UndefinedSym:
9488 : : return SymbolTable_NoValue;
9489 : 0 : break;
9490 : :
9491 : :
9492 : 0 : default:
9493 : 0 : M2Error_InternalError ((const char *) "not expecting this type", 23);
9494 : : break;
9495 : : }
9496 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9497 : : __builtin_unreachable ();
9498 : : }
9499 : :
9500 : :
9501 : : /*
9502 : : StartScope - starts a block scope at Sym. Transparent determines
9503 : : whether the search for a symbol will look at the
9504 : : previous ScopeCallFrame if Sym does not contain the
9505 : : symbol that GetSym is searching.
9506 : :
9507 : : WITH statements are partially implemented by calling
9508 : : StartScope. Therefore we must retain the old Main from
9509 : : the previous ScopePtr when a record is added to the scope
9510 : : stack. (Main contains the symbol where all identifiers
9511 : : should be added.)
9512 : : */
9513 : :
9514 : 31211570 : extern "C" void SymbolTable_StartScope (unsigned int Sym)
9515 : : {
9516 : 31211570 : SymbolTable_PtrToCallFrame oCall;
9517 : 31211570 : SymbolTable_PtrToCallFrame pCall;
9518 : :
9519 : 31211570 : Sym = SymbolTable_SkipType (Sym);
9520 : : /*
9521 : : WriteString('New scope is: ') ; WriteKey(GetSymName(Sym)) ; WriteLn ;
9522 : : */
9523 : 31211570 : ScopePtr += 1;
9524 : 31211570 : if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
9525 : : {
9526 : 31145741 : pCall = GetPcall (ScopePtr);
9527 : : }
9528 : : else
9529 : : {
9530 : 65829 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
9531 : 65829 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
9532 : : }
9533 : 31211570 : pCall->Start = ScopePtr-1; /* Previous ScopePtr value before StartScope */
9534 : 31211570 : pCall->Search = Sym;
9535 : : /* new symbols to ie temporary variables. */
9536 : 31211570 : if (SymbolTable_IsRecord (Sym))
9537 : : {
9538 : 32561 : oCall = GetPcall (ScopePtr-1);
9539 : 32561 : pCall->Main = oCall->Main;
9540 : : }
9541 : : else
9542 : : {
9543 : 31179003 : pCall->Main = Sym;
9544 : 31179003 : PlaceMajorScopesEnumerationListOntoStack (Sym);
9545 : : }
9546 : 31211563 : }
9547 : :
9548 : :
9549 : : /*
9550 : : EndScope - ends a block scope started by StartScope. The current
9551 : : head of the symbol scope reverts back to the symbol
9552 : : which was the Head of the symbol scope before the
9553 : : last StartScope was called.
9554 : : */
9555 : :
9556 : 31195994 : extern "C" void SymbolTable_EndScope (void)
9557 : : {
9558 : 31195994 : SymbolTable_PtrToCallFrame pCall;
9559 : :
9560 : : /*
9561 : : ; WriteString('EndScope - ending scope: ') ;
9562 : : pCall := GetPcall(ScopePtr) ;
9563 : : ; WriteKey(GetSymName(pCall^.Search)) ; WriteLn ;
9564 : : */
9565 : 31195994 : pCall = GetPcall (ScopePtr);
9566 : : /* ; DisplayScopes */
9567 : 31195994 : ScopePtr = pCall->Start;
9568 : 31195994 : }
9569 : :
9570 : :
9571 : : /*
9572 : : PseudoScope - starts a pseudo scope at Sym.
9573 : : We always connect parent up to the last scope,
9574 : : to determine the transparancy of a scope we call
9575 : : TransparentScope.
9576 : :
9577 : : A Pseudo scope has no end block,
9578 : : but is terminated when the next EndScope is used.
9579 : : The function of the pseudo scope is to provide an
9580 : : automatic mechanism to solve enumeration types.
9581 : : A declared enumeration type is a Pseudo scope and
9582 : : identifiers used with the name of an enumeration
9583 : : type field will find the enumeration symbol by
9584 : : the scoping algorithm.
9585 : : */
9586 : :
9587 : 633200 : extern "C" void SymbolTable_PseudoScope (unsigned int Sym)
9588 : : {
9589 : 633200 : SymbolTable_PtrToCallFrame oCall;
9590 : 633200 : SymbolTable_PtrToCallFrame pCall;
9591 : :
9592 : 633200 : if (SymbolTable_IsEnumeration (Sym))
9593 : : {
9594 : 633200 : ScopePtr += 1;
9595 : 633200 : if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
9596 : : {
9597 : 614089 : pCall = GetPcall (ScopePtr);
9598 : : }
9599 : : else
9600 : : {
9601 : 19111 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
9602 : 19111 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
9603 : : }
9604 : 633200 : oCall = GetPcall (ScopePtr-1);
9605 : 633200 : pCall->Main = oCall->Main;
9606 : 633200 : pCall->Start = oCall->Start;
9607 : 633200 : pCall->Search = Sym;
9608 : : }
9609 : : else
9610 : : {
9611 : 0 : M2Error_InternalError ((const char *) "expecting EnumerationSym", 24);
9612 : : }
9613 : 633200 : }
9614 : :
9615 : :
9616 : : /*
9617 : : GetCurrentScope - returns the symbol who is responsible for the current
9618 : : scope. Note that it ignore pseudo scopes.
9619 : : */
9620 : :
9621 : 39990103 : extern "C" unsigned int SymbolTable_GetCurrentScope (void)
9622 : : {
9623 : 39990103 : SymbolTable_PtrToCallFrame pCall;
9624 : :
9625 : 39990103 : pCall = GetPcall (ScopePtr);
9626 : 39990103 : return pCall->Main;
9627 : : /* static analysis guarentees a RETURN statement will be used before here. */
9628 : : __builtin_unreachable ();
9629 : : }
9630 : :
9631 : :
9632 : : /*
9633 : : IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
9634 : : */
9635 : :
9636 : 252996 : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym)
9637 : : {
9638 : 252996 : unsigned int s;
9639 : :
9640 : 252996 : s = SymbolTable_GetScope (sym);
9641 : 505992 : while (s != scope)
9642 : : {
9643 : 1462 : if ((((s == SymbolTable_NulSym) || (SymbolTable_IsProcedure (s))) || (SymbolTable_IsModule (s))) || (SymbolTable_IsDefImp (s)))
9644 : : {
9645 : 1462 : return false;
9646 : : }
9647 : : else
9648 : : {
9649 : 0 : s = SymbolTable_GetScope (s);
9650 : : }
9651 : : }
9652 : : return true;
9653 : : /* static analysis guarentees a RETURN statement will be used before here. */
9654 : : __builtin_unreachable ();
9655 : : }
9656 : :
9657 : :
9658 : : /*
9659 : : SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
9660 : : This Sym must represent the module name of the
9661 : : file currently being compiled.
9662 : : */
9663 : :
9664 : 1273649 : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym)
9665 : : {
9666 : 1273649 : CurrentModule = Sym;
9667 : 1273649 : }
9668 : :
9669 : :
9670 : : /*
9671 : : SetFileModule - Used to set the FileModule to a symbol, Sym.
9672 : : This Sym must represent the current program module
9673 : : file which is being parsed.
9674 : : */
9675 : :
9676 : 1226266 : extern "C" void SymbolTable_SetFileModule (unsigned int Sym)
9677 : : {
9678 : 1226266 : FileModule = Sym;
9679 : 1226266 : }
9680 : :
9681 : :
9682 : : /*
9683 : : SetMainModule - Used to set the MainModule to a symbol, Sym.
9684 : : This Sym must represent the main module which was
9685 : : envoked by the user to be compiled.
9686 : : */
9687 : :
9688 : 15222 : extern "C" void SymbolTable_SetMainModule (unsigned int Sym)
9689 : : {
9690 : 15222 : MainModule = Sym;
9691 : 15222 : }
9692 : :
9693 : :
9694 : : /*
9695 : : CheckAnonymous - checks to see whether the name is NulName and if so
9696 : : it creates a unique anonymous name.
9697 : : */
9698 : :
9699 : 1459952 : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name)
9700 : : {
9701 : 1459952 : if (name == NameKey_NulName)
9702 : : {
9703 : 64807 : AnonymousName += 1;
9704 : 64807 : 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)))));
9705 : : }
9706 : 1459952 : return name;
9707 : : /* static analysis guarentees a RETURN statement will be used before here. */
9708 : : __builtin_unreachable ();
9709 : : }
9710 : :
9711 : :
9712 : : /*
9713 : : IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
9714 : : or no name.
9715 : : */
9716 : :
9717 : 56278 : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym)
9718 : : {
9719 : 56278 : typedef struct IsNameAnonymous__T8_a IsNameAnonymous__T8;
9720 : :
9721 : 56278 : struct IsNameAnonymous__T8_a { char array[5+1]; };
9722 : 56278 : IsNameAnonymous__T8 a;
9723 : 56278 : NameKey_Name n;
9724 : :
9725 : 56278 : n = SymbolTable_GetSymName (sym);
9726 : 56278 : if (n == NameKey_NulName)
9727 : : {
9728 : : return true;
9729 : : }
9730 : : else
9731 : : {
9732 : 55030 : NameKey_GetKey (n, (char *) &a.array[0], 5);
9733 : 55030 : return StrLib_StrEqual ((const char *) &a.array[0], 5, (const char *) "__anon", 6);
9734 : : }
9735 : : /* static analysis guarentees a RETURN statement will be used before here. */
9736 : : __builtin_unreachable ();
9737 : : }
9738 : :
9739 : :
9740 : : /*
9741 : : NoOfVariables - returns the number of variables in scope. The scope maybe
9742 : : a procedure, module or defimp scope.
9743 : : */
9744 : :
9745 : 30 : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope)
9746 : : {
9747 : 30 : SymbolTable_PtrToSymbol pSym;
9748 : :
9749 : 30 : if (SymbolTable_IsProcedure (scope))
9750 : : {
9751 : 30 : return SymbolTable_NoOfLocalVar (scope);
9752 : : }
9753 : 0 : else if (SymbolTable_IsModule (scope))
9754 : : {
9755 : : /* avoid dangling else. */
9756 : 0 : pSym = GetPsym (scope);
9757 : 0 : switch (pSym->SymbolType)
9758 : : {
9759 : 0 : case SymbolTable_ModuleSym:
9760 : 0 : return Lists_NoOfItemsInList (pSym->Module.ListOfVars);
9761 : 0 : break;
9762 : :
9763 : :
9764 : 0 : default:
9765 : 0 : M2Error_InternalError ((const char *) "expecting module symbol", 23);
9766 : 0 : break;
9767 : : }
9768 : : }
9769 : 0 : else if (SymbolTable_IsDefImp (scope))
9770 : : {
9771 : : /* avoid dangling else. */
9772 : 0 : pSym = GetPsym (scope);
9773 : 0 : switch (pSym->SymbolType)
9774 : : {
9775 : 0 : case SymbolTable_DefImpSym:
9776 : 0 : return Lists_NoOfItemsInList (pSym->DefImp.ListOfVars);
9777 : 0 : break;
9778 : :
9779 : :
9780 : 0 : default:
9781 : 0 : M2Error_InternalError ((const char *) "expecting defimp symbol", 23);
9782 : 0 : break;
9783 : : }
9784 : : }
9785 : : else
9786 : : {
9787 : : /* avoid dangling else. */
9788 : 0 : M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
9789 : : }
9790 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9791 : : __builtin_unreachable ();
9792 : : }
9793 : :
9794 : :
9795 : : /*
9796 : : MakeModule - creates a module sym with ModuleName. It returns the
9797 : : symbol index.
9798 : : */
9799 : :
9800 : 27076 : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName)
9801 : : {
9802 : 27076 : SymbolTable_PtrToSymbol pSym;
9803 : 27076 : SymbolTable_PtrToCallFrame pCall;
9804 : 27076 : unsigned int Sym;
9805 : :
9806 : : /*
9807 : : Make a new symbol since we are at the outer scope level.
9808 : : DeclareSym examines the current scope level for any symbols
9809 : : that have the correct name, but are yet undefined.
9810 : : Therefore we must not call DeclareSym but create a symbol
9811 : : directly.
9812 : : */
9813 : 27076 : NewSym (&Sym);
9814 : 27076 : pSym = GetPsym (Sym);
9815 : 27076 : pSym->SymbolType = SymbolTable_ModuleSym;
9816 : 27076 : pSym->Module.name = ModuleName; /* Index into name array, name */
9817 : : /* of record field. */
9818 : 27076 : pSym->Module.libname = NameKey_NulName; /* Library association. */
9819 : 27076 : InitCtor (&pSym->Module.ctors); /* Init all ctor functions. */
9820 : 27076 : Lists_InitList (&pSym->Module.ModListOfDep); /* Vector of SymDependency. */
9821 : 27076 : SymbolKey_InitTree (&pSym->Module.LocalSymbols); /* The LocalSymbols hold all the */
9822 : : /* END WeAreHere. */
9823 : 27076 : SymbolKey_InitTree (&pSym->Module.ExportTree); /* Holds all the exported */
9824 : : /* deleted at the end of Pass 1. */
9825 : 27076 : SymbolKey_InitTree (&pSym->Module.ImportTree); /* Contains all IMPORTed */
9826 : : /* identifiers. */
9827 : 27076 : Lists_InitList (&pSym->Module.IncludeList); /* Contains all included symbols */
9828 : : /* modulename.Symbol */
9829 : 27076 : SymbolKey_InitTree (&pSym->Module.ExportUndeclared); /* ExportUndeclared contains all */
9830 : : /* been declared. */
9831 : 27076 : Lists_InitList (&pSym->Module.EnumerationScopeList); /* Enumeration scope list which */
9832 : : /* Outer Module. */
9833 : 27076 : SymbolKey_InitTree (&pSym->Module.NamedObjects); /* Names of all items declared. */
9834 : 27076 : SymbolKey_InitTree (&pSym->Module.NamedImports); /* Names of items imported. */
9835 : 27076 : SymbolKey_InitTree (&pSym->Module.WhereImported); /* Sym to TokenNo where import */
9836 : : /* occurs. Error message use. */
9837 : 27076 : pSym->Module.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9838 : : /* is an index to a constant. */
9839 : 27076 : SymbolKey_InitTree (&pSym->Module.Unresolved); /* All symbols currently */
9840 : : /* unresolved in this module. */
9841 : 27076 : pSym->Module.StartQuad = 0; /* Signify the initialization */
9842 : : /* code. */
9843 : 27076 : pSym->Module.EndQuad = 0; /* EndQuad should point to a */
9844 : : /* goto quad. */
9845 : 27076 : pSym->Module.StartFinishQuad = 0; /* Signify the finalization */
9846 : : /* code. */
9847 : 27076 : pSym->Module.EndFinishQuad = 0; /* should point to a finish */
9848 : 27076 : pSym->Module.FinallyFunction = NULL; /* The GCC function for finally */
9849 : 27076 : pSym->Module.ExceptionFinally = false; /* does it have an exception? */
9850 : 27076 : pSym->Module.ExceptionBlock = false; /* does it have an exception? */
9851 : 27076 : pSym->Module.ModLink = GetLink (); /* Is this parsed for linkage? */
9852 : 27076 : pSym->Module.Builtin = false; /* Is the module builtin? */
9853 : 27076 : Lists_InitList (&pSym->Module.ListOfVars); /* List of variables in this */
9854 : : /* scope. */
9855 : 27076 : Lists_InitList (&pSym->Module.ListOfProcs); /* List of all procedures */
9856 : : /* declared within this module. */
9857 : 27076 : Lists_InitList (&pSym->Module.ListOfModules); /* List of all inner modules. */
9858 : 27076 : InitWhereDeclaredTok (tok, &pSym->Module.At); /* Where symbol declared. */
9859 : 27076 : InitWhereFirstUsedTok (tok, &pSym->Module.At); /* Where symbol first used. */
9860 : 27076 : pCall = GetPcall (ScopePtr); /* Where symbol first used. */
9861 : 27076 : if (pCall->Main == (SymbolTable_GetBaseModule ()))
9862 : : {
9863 : 27076 : pSym->Module.Scope = SymbolTable_NulSym;
9864 : : }
9865 : : else
9866 : : {
9867 : 0 : pSym->Module.Scope = pCall->Main;
9868 : : }
9869 : 27076 : pSym->Module.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9870 : 27076 : SymbolKey_PutSymKey (ModuleTree, ModuleName, Sym); /* Title error scope. */
9871 : 27076 : return Sym;
9872 : : /* static analysis guarentees a RETURN statement will be used before here. */
9873 : : __builtin_unreachable ();
9874 : : }
9875 : :
9876 : :
9877 : : /*
9878 : : MakeDefImp - creates a definition and implementation module sym
9879 : : with name DefImpName. It returns the symbol index.
9880 : : */
9881 : :
9882 : 174909 : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName)
9883 : : {
9884 : 174909 : SymbolTable_PtrToSymbol pSym;
9885 : 174909 : unsigned int Sym;
9886 : :
9887 : : /* tok := CheckTok (tok, 'defimp') ; */
9888 : 174909 : NewSym (&Sym);
9889 : 174909 : pSym = GetPsym (Sym);
9890 : 174909 : pSym->SymbolType = SymbolTable_DefImpSym;
9891 : 174909 : pSym->DefImp.name = DefImpName; /* Index into name array, name */
9892 : : /* of record field. */
9893 : 174909 : pSym->DefImp.libname = NameKey_NulName; /* Library association. */
9894 : 174909 : InitCtor (&pSym->DefImp.ctors);
9895 : : /* Init all ctor functions. */
9896 : 174909 : Lists_InitList (&pSym->DefImp.DefListOfDep); /* Vector of SymDependency. */
9897 : 174909 : Lists_InitList (&pSym->DefImp.ModListOfDep); /* Vector of SymDependency. */
9898 : 174909 : SymbolKey_InitTree (&pSym->DefImp.ExportQualifiedTree);
9899 : : /* deleted at the end of Pass 1. */
9900 : 174909 : SymbolKey_InitTree (&pSym->DefImp.ExportUnQualifiedTree);
9901 : : /* deleted at the end of Pass 1. */
9902 : 174909 : SymbolKey_InitTree (&pSym->DefImp.ExportRequest); /* Contains all identifiers that */
9903 : : /* this list. */
9904 : 174909 : SymbolKey_InitTree (&pSym->DefImp.ImportTree); /* Contains all IMPORTed */
9905 : : /* identifiers. */
9906 : 174909 : Lists_InitList (&pSym->DefImp.IncludeList); /* Contains all included symbols */
9907 : : /* modulename.Symbol */
9908 : 174909 : Lists_InitList (&pSym->DefImp.DefIncludeList); /* Contains all included symbols */
9909 : : /* in the definition module only */
9910 : 174909 : SymbolKey_InitTree (&pSym->DefImp.ExportUndeclared); /* ExportUndeclared contains all */
9911 : : /* been declared. */
9912 : 174909 : SymbolKey_InitTree (&pSym->DefImp.NeedToBeImplemented);
9913 : : /* implemented. */
9914 : 174909 : SymbolKey_InitTree (&pSym->DefImp.LocalSymbols); /* The LocalSymbols hold all the */
9915 : : /* END WeAreHere. */
9916 : 174909 : Lists_InitList (&pSym->DefImp.EnumerationScopeList);
9917 : : /* visable within this scope. */
9918 : 174909 : SymbolKey_InitTree (&pSym->DefImp.NamedObjects); /* names of all items declared. */
9919 : 174909 : SymbolKey_InitTree (&pSym->DefImp.NamedImports); /* Names of items imported. */
9920 : 174909 : SymbolKey_InitTree (&pSym->DefImp.WhereImported); /* Sym to TokenNo where import */
9921 : : /* occurs. Error message use. */
9922 : 174909 : pSym->DefImp.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9923 : : /* is an index to a constant. */
9924 : 174909 : SymbolKey_InitTree (&pSym->DefImp.Unresolved); /* All symbols currently */
9925 : : /* unresolved in this module. */
9926 : 174909 : pSym->DefImp.StartQuad = 0; /* Signify the initialization */
9927 : : /* code. */
9928 : 174909 : pSym->DefImp.EndQuad = 0; /* EndQuad should point to a */
9929 : : /* goto quad. */
9930 : 174909 : pSym->DefImp.StartFinishQuad = 0; /* Signify the finalization */
9931 : : /* code. */
9932 : 174909 : pSym->DefImp.EndFinishQuad = 0; /* should point to a finish */
9933 : 174909 : pSym->DefImp.FinallyFunction = NULL; /* The GCC function for finally */
9934 : 174909 : pSym->DefImp.ExceptionFinally = false; /* does it have an exception? */
9935 : 174909 : pSym->DefImp.ExceptionBlock = false; /* does it have an exception? */
9936 : 174909 : pSym->DefImp.ContainsHiddenType = false; /* True if this module */
9937 : : /* implements a hidden type. */
9938 : 174909 : pSym->DefImp.ContainsBuiltin = false; /* Does module define a builtin */
9939 : : /* procedure? */
9940 : 174909 : pSym->DefImp.ForC = false; /* Is it a definition for "C" */
9941 : 174909 : pSym->DefImp.NeedExportList = false; /* Must user supply export list? */
9942 : 174909 : pSym->DefImp.DefLink = GetLink (); /* Is the def/mod file only */
9943 : 174909 : pSym->DefImp.ModLink = GetLink (); /* parsed for linkage? */
9944 : 174909 : pSym->DefImp.Builtin = false; /* Is the module builtin? */
9945 : 174909 : Lists_InitList (&pSym->DefImp.ListOfVars); /* List of variables in this */
9946 : : /* scope. */
9947 : 174909 : Lists_InitList (&pSym->DefImp.ListOfProcs); /* List of all procedures */
9948 : : /* declared within this module. */
9949 : 174909 : Lists_InitList (&pSym->DefImp.ListOfModules); /* List of all inner modules. */
9950 : 174909 : InitWhereDeclaredTok (tok, &pSym->DefImp.At); /* Where symbol declared. */
9951 : 174909 : InitWhereFirstUsedTok (tok, &pSym->DefImp.At); /* Where symbol first used. */
9952 : 174909 : pSym->DefImp.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9953 : 174909 : SymbolKey_PutSymKey (ModuleTree, DefImpName, Sym); /* Title error scope. */
9954 : 174909 : return Sym;
9955 : : /* static analysis guarentees a RETURN statement will be used before here. */
9956 : : __builtin_unreachable ();
9957 : : }
9958 : :
9959 : :
9960 : : /*
9961 : : MakeInnerModule - creates an inner module sym with ModuleName. It returns the
9962 : : symbol index.
9963 : : */
9964 : :
9965 : 428 : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName)
9966 : : {
9967 : 428 : SymbolTable_PtrToSymbol pSym;
9968 : 428 : unsigned int Sym;
9969 : :
9970 : 428 : Sym = DeclareSym (tok, ModuleName);
9971 : 428 : if (! (SymbolTable_IsError (Sym)))
9972 : : {
9973 : 428 : pSym = GetPsym (Sym);
9974 : 428 : pSym->SymbolType = SymbolTable_ModuleSym;
9975 : 428 : pSym->Module.name = ModuleName; /* Index into name array, name */
9976 : : /* of record field. */
9977 : 428 : pSym->Module.libname = NameKey_NulName; /* Library association. */
9978 : 428 : InitCtor (&pSym->Module.ctors); /* Init all ctor functions. */
9979 : 428 : SymbolKey_InitTree (&pSym->Module.LocalSymbols); /* The LocalSymbols hold all the */
9980 : : /* END WeAreHere. */
9981 : 428 : SymbolKey_InitTree (&pSym->Module.ExportTree); /* Holds all the exported */
9982 : : /* deleted at the end of Pass 1. */
9983 : 428 : SymbolKey_InitTree (&pSym->Module.ImportTree); /* Contains all IMPORTed */
9984 : : /* identifiers. */
9985 : 428 : Lists_InitList (&pSym->Module.IncludeList); /* Contains all included symbols */
9986 : : /* modulename.Symbol */
9987 : 428 : SymbolKey_InitTree (&pSym->Module.ExportUndeclared); /* ExportUndeclared contains all */
9988 : : /* been declared. */
9989 : 428 : Lists_InitList (&pSym->Module.EnumerationScopeList); /* Enumeration scope list which */
9990 : : /* visable within this scope. */
9991 : 428 : SymbolKey_InitTree (&pSym->Module.NamedObjects); /* Names of all items declared. */
9992 : 428 : SymbolKey_InitTree (&pSym->Module.NamedImports); /* Names of items imported. */
9993 : 428 : SymbolKey_InitTree (&pSym->Module.WhereImported); /* Sym to TokenNo where import */
9994 : : /* occurs. Error message use. */
9995 : 428 : pSym->Module.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9996 : : /* is an index to a constant. */
9997 : 428 : SymbolKey_InitTree (&pSym->Module.Unresolved); /* All symbols currently */
9998 : : /* unresolved in this module. */
9999 : 428 : pSym->Module.StartQuad = 0; /* Signify the initialization */
10000 : : /* code. */
10001 : 428 : pSym->Module.EndQuad = 0; /* EndQuad should point to a */
10002 : : /* goto quad. */
10003 : 428 : pSym->Module.StartFinishQuad = 0; /* Signify the finalization */
10004 : : /* code. */
10005 : 428 : pSym->Module.EndFinishQuad = 0; /* should point to a finish */
10006 : 428 : pSym->Module.FinallyFunction = NULL; /* The GCC function for finally */
10007 : 428 : pSym->Module.ExceptionFinally = false; /* does it have an exception? */
10008 : 428 : pSym->Module.ExceptionBlock = false; /* does it have an exception? */
10009 : 428 : pSym->Module.ModLink = GetLink (); /* Is this parsed for linkage? */
10010 : 428 : Lists_InitList (&pSym->Module.ListOfVars); /* List of variables in this */
10011 : : /* scope. */
10012 : 428 : Lists_InitList (&pSym->Module.ListOfProcs); /* List of all procedures */
10013 : : /* declared within this module. */
10014 : 428 : Lists_InitList (&pSym->Module.ListOfModules); /* List of all inner modules. */
10015 : 428 : InitWhereDeclaredTok (tok, &pSym->Module.At); /* Where symbol declared. */
10016 : 428 : InitWhereFirstUsedTok (tok, &pSym->Module.At); /* Where symbol first used. */
10017 : 428 : if ((SymbolTable_GetCurrentScope ()) == (SymbolTable_GetBaseModule ())) /* Where symbol first used. */
10018 : : {
10019 : 0 : pSym->Module.Scope = SymbolTable_NulSym;
10020 : : }
10021 : : else
10022 : : {
10023 : 428 : pSym->Module.Scope = SymbolTable_GetCurrentScope ();
10024 : 428 : AddModuleToParent (Sym, pSym->Module.Scope);
10025 : : }
10026 : 428 : pSym->Module.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
10027 : 428 : AddSymToScope (Sym, ModuleName); /* Title error scope. */
10028 : : }
10029 : 428 : return Sym;
10030 : : /* static analysis guarentees a RETURN statement will be used before here. */
10031 : : __builtin_unreachable ();
10032 : : }
10033 : :
10034 : :
10035 : : /*
10036 : : MakeProcedure - creates a procedure sym with name. It returns
10037 : : the symbol index.
10038 : : */
10039 : :
10040 : 5052793 : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName)
10041 : : {
10042 : 5052793 : SymbolTable_PtrToSymbol pSym;
10043 : 5052793 : unsigned int Sym;
10044 : 5052793 : SymbolTable_ProcedureKind kind;
10045 : :
10046 : 5052793 : tok = CheckTok (tok, (const char *) "procedure", 9);
10047 : 5052793 : Sym = DeclareSym (tok, ProcedureName);
10048 : 5052793 : CheckBreak (Sym);
10049 : 5052793 : if (! (SymbolTable_IsError (Sym)))
10050 : : {
10051 : 5052793 : pSym = GetPsym (Sym);
10052 : 5052793 : pSym->SymbolType = SymbolTable_ProcedureSym;
10053 : 5052793 : pSym->Procedure.name = ProcedureName;
10054 : 20211172 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
10055 : : {
10056 : 15158379 : InitProcedureDeclaration (&pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure]);
10057 : 15158379 : Lists_InitList (&pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam);
10058 : : }
10059 : 5052793 : pSym->Procedure.OptArgInit = SymbolTable_NulSym; /* The optional arg default */
10060 : : /* value. */
10061 : 5052793 : pSym->Procedure.IsExtern = false; /* Make this procedure external. */
10062 : 5052793 : pSym->Procedure.IsPublic = false; /* Make this procedure visible. */
10063 : 5052793 : pSym->Procedure.IsCtor = false; /* Is this procedure a ctor? */
10064 : 5052793 : pSym->Procedure.IsMonoName = false; /* Overrides module name prefix. */
10065 : 5052793 : pSym->Procedure.BuildProcType = true; /* Are we building the */
10066 : : /* proctype associated with sym? */
10067 : 5052793 : pSym->Procedure.Scope = SymbolTable_GetCurrentScope (); /* Scope of procedure. */
10068 : 5052793 : SymbolKey_InitTree (&pSym->Procedure.Unresolved); /* All symbols currently */
10069 : : /* unresolved in this procedure. */
10070 : 5052793 : pSym->Procedure.ScopeQuad = 0; /* Index into list of quads, */
10071 : 5052793 : pSym->Procedure.StartQuad = 0; /* defining the scope, start and */
10072 : 5052793 : pSym->Procedure.EndQuad = 0; /* end of the procedure. */
10073 : 5052793 : pSym->Procedure.Reachable = false; /* Procedure not known to be */
10074 : : /* reachable. */
10075 : 5052793 : pSym->Procedure.SavePriority = false; /* Does procedure need to save */
10076 : : /* and restore interrupts? */
10077 : 5052793 : pSym->Procedure.ReturnType = SymbolTable_NulSym; /* Not a function yet! */
10078 : : /* The ProcType equivalent. */
10079 : 5052793 : pSym->Procedure.ProcedureType = SymbolTable_MakeProcType (tok, NameKey_NulName);
10080 : 5052793 : SymbolKey_InitTree (&pSym->Procedure.LocalSymbols);
10081 : 5052793 : Lists_InitList (&pSym->Procedure.EnumerationScopeList);
10082 : : /* visable within this scope. */
10083 : 5052793 : SymbolKey_InitTree (&pSym->Procedure.NamedObjects); /* Names of all items declared. */
10084 : 5052793 : Lists_InitList (&pSym->Procedure.ListOfVars); /* List of variables in this */
10085 : : /* scope. */
10086 : 5052793 : Lists_InitList (&pSym->Procedure.ListOfProcs); /* List of all procedures */
10087 : : /* procedure. */
10088 : 5052793 : Lists_InitList (&pSym->Procedure.ListOfModules); /* List of all inner modules. */
10089 : 5052793 : pSym->Procedure.ExceptionFinally = false; /* does it have an exception? */
10090 : 5052793 : pSym->Procedure.ExceptionBlock = false; /* does it have an exception? */
10091 : 5052793 : pSym->Procedure.IsBuiltin = false; /* Was it declared __BUILTIN__ ? */
10092 : 5052793 : pSym->Procedure.BuiltinName = NameKey_NulName; /* name of equivalent builtin */
10093 : 5052793 : pSym->Procedure.IsInline = false; /* Was is declared __INLINE__ ? */
10094 : 5052793 : pSym->Procedure.Size = M2ALU_InitValue (); /* Activation record size. */
10095 : 5052793 : pSym->Procedure.TotalParamSize = M2ALU_InitValue (); /* size of all parameters. */
10096 : 5052793 : pSym->Procedure.Begin = 0; /* token number for BEGIN */
10097 : 5052793 : pSym->Procedure.End = 0; /* token number for END */
10098 : 5052793 : InitWhereDeclaredTok (tok, &pSym->Procedure.At); /* Where the symbol was declared. */
10099 : 5052793 : pSym->Procedure.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
10100 : : /* Now add this procedure to the symbol table of the current scope */
10101 : 5052793 : AddSymToScope (Sym, ProcedureName);
10102 : 5052793 : AddProcedureToList (SymbolTable_GetCurrentScope (), Sym);
10103 : : }
10104 : 5052793 : return Sym;
10105 : : /* static analysis guarentees a RETURN statement will be used before here. */
10106 : : __builtin_unreachable ();
10107 : : }
10108 : :
10109 : :
10110 : : /*
10111 : : MakeProcedureCtorExtern - creates an extern ctor procedure
10112 : : */
10113 : :
10114 : 0 : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename)
10115 : : {
10116 : 0 : unsigned int ctor;
10117 : :
10118 : 0 : ctor = SymbolTable_MakeProcedure (tokenno, GenName (libname, (const char *) "_M2_", 4, modulename, (const char *) "_ctor", 5));
10119 : 0 : SymbolTable_PutExtern (ctor, true);
10120 : 0 : return ctor;
10121 : : /* static analysis guarentees a RETURN statement will be used before here. */
10122 : : __builtin_unreachable ();
10123 : : }
10124 : :
10125 : :
10126 : : /*
10127 : : PutLibName - places libname into defimp or module sym.
10128 : : */
10129 : :
10130 : 246463 : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname)
10131 : : {
10132 : 246463 : SymbolTable_PtrToSymbol pSym;
10133 : :
10134 : 492926 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10135 : 246463 : pSym = GetPsym (sym);
10136 : 246463 : switch (pSym->SymbolType)
10137 : : {
10138 : 234616 : case SymbolTable_DefImpSym:
10139 : 234616 : pSym->DefImp.libname = libname;
10140 : 234616 : break;
10141 : :
10142 : 11847 : case SymbolTable_ModuleSym:
10143 : 11847 : pSym->Module.libname = libname;
10144 : 11847 : break;
10145 : :
10146 : :
10147 : 0 : default:
10148 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10149 : 246463 : break;
10150 : : }
10151 : 246463 : }
10152 : :
10153 : :
10154 : : /*
10155 : : GetLibName - returns libname associated with a defimp or module sym.
10156 : : */
10157 : :
10158 : 5386582 : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym)
10159 : : {
10160 : 5386582 : SymbolTable_PtrToSymbol pSym;
10161 : :
10162 : 10773164 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10163 : 5386582 : pSym = GetPsym (sym);
10164 : 5386582 : switch (pSym->SymbolType)
10165 : : {
10166 : 5293443 : case SymbolTable_DefImpSym:
10167 : 5293443 : return pSym->DefImp.libname;
10168 : 93139 : break;
10169 : :
10170 : 93139 : case SymbolTable_ModuleSym:
10171 : 93139 : return pSym->Module.libname;
10172 : 0 : break;
10173 : :
10174 : :
10175 : 0 : default:
10176 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10177 : : break;
10178 : : }
10179 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10180 : : __builtin_unreachable ();
10181 : : }
10182 : :
10183 : :
10184 : : /*
10185 : : PutMonoName - changes the IsMonoName boolean inside the procedure.
10186 : : */
10187 : :
10188 : 454772 : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value)
10189 : : {
10190 : 454772 : SymbolTable_PtrToSymbol pSym;
10191 : :
10192 : 454772 : pSym = GetPsym (sym);
10193 : 454772 : switch (pSym->SymbolType)
10194 : : {
10195 : 454772 : case SymbolTable_ProcedureSym:
10196 : 454772 : pSym->Procedure.IsMonoName = value;
10197 : 454772 : break;
10198 : :
10199 : :
10200 : 0 : default:
10201 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10202 : 454772 : break;
10203 : : }
10204 : 454772 : }
10205 : :
10206 : :
10207 : : /*
10208 : : IsMonoName - returns the public boolean associated with a procedure.
10209 : : */
10210 : :
10211 : 3683631 : extern "C" bool SymbolTable_IsMonoName (unsigned int sym)
10212 : : {
10213 : 3683631 : SymbolTable_PtrToSymbol pSym;
10214 : :
10215 : 3683631 : pSym = GetPsym (sym);
10216 : 3683631 : switch (pSym->SymbolType)
10217 : : {
10218 : 3683631 : case SymbolTable_ProcedureSym:
10219 : 3683631 : return pSym->Procedure.IsMonoName;
10220 : 0 : break;
10221 : :
10222 : :
10223 : 0 : default:
10224 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10225 : : break;
10226 : : }
10227 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10228 : : __builtin_unreachable ();
10229 : : }
10230 : :
10231 : :
10232 : : /*
10233 : : PutExtern - changes the extern boolean inside the procedure.
10234 : : */
10235 : :
10236 : 700773 : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value)
10237 : : {
10238 : 700773 : SymbolTable_PtrToSymbol pSym;
10239 : :
10240 : 700773 : pSym = GetPsym (sym);
10241 : 700773 : switch (pSym->SymbolType)
10242 : : {
10243 : 700773 : case SymbolTable_ProcedureSym:
10244 : 700773 : pSym->Procedure.IsExtern = value;
10245 : 700773 : break;
10246 : :
10247 : :
10248 : 0 : default:
10249 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10250 : 700773 : break;
10251 : : }
10252 : 700773 : }
10253 : :
10254 : :
10255 : : /*
10256 : : IsExtern - returns the public boolean associated with a procedure.
10257 : : */
10258 : :
10259 : 5116001 : extern "C" bool SymbolTable_IsExtern (unsigned int sym)
10260 : : {
10261 : 5116001 : SymbolTable_PtrToSymbol pSym;
10262 : :
10263 : 5116001 : pSym = GetPsym (sym);
10264 : 5116001 : switch (pSym->SymbolType)
10265 : : {
10266 : 5116001 : case SymbolTable_ProcedureSym:
10267 : 5116001 : return pSym->Procedure.IsExtern;
10268 : 0 : break;
10269 : :
10270 : :
10271 : 0 : default:
10272 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10273 : : break;
10274 : : }
10275 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10276 : : __builtin_unreachable ();
10277 : : }
10278 : :
10279 : :
10280 : : /*
10281 : : PutPublic - changes the public boolean inside the procedure.
10282 : : */
10283 : :
10284 : 715627 : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value)
10285 : : {
10286 : 715627 : SymbolTable_PtrToSymbol pSym;
10287 : :
10288 : 715627 : pSym = GetPsym (sym);
10289 : 715627 : switch (pSym->SymbolType)
10290 : : {
10291 : 715627 : case SymbolTable_ProcedureSym:
10292 : 715627 : pSym->Procedure.IsPublic = value;
10293 : 715627 : break;
10294 : :
10295 : :
10296 : 0 : default:
10297 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10298 : 715627 : break;
10299 : : }
10300 : 715627 : }
10301 : :
10302 : :
10303 : : /*
10304 : : IsPublic - returns the public boolean associated with a procedure.
10305 : : */
10306 : :
10307 : 107548 : extern "C" bool SymbolTable_IsPublic (unsigned int sym)
10308 : : {
10309 : 107548 : SymbolTable_PtrToSymbol pSym;
10310 : :
10311 : 107548 : pSym = GetPsym (sym);
10312 : 107548 : switch (pSym->SymbolType)
10313 : : {
10314 : 107548 : case SymbolTable_ProcedureSym:
10315 : 107548 : return pSym->Procedure.IsPublic;
10316 : 0 : break;
10317 : :
10318 : :
10319 : 0 : default:
10320 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10321 : : break;
10322 : : }
10323 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10324 : : __builtin_unreachable ();
10325 : : }
10326 : :
10327 : :
10328 : : /*
10329 : : PutCtor - changes the ctor boolean inside the procedure.
10330 : : */
10331 : :
10332 : 195411 : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value)
10333 : : {
10334 : 195411 : SymbolTable_PtrToSymbol pSym;
10335 : :
10336 : 195411 : pSym = GetPsym (sym);
10337 : 195411 : switch (pSym->SymbolType)
10338 : : {
10339 : 195411 : case SymbolTable_ProcedureSym:
10340 : 195411 : pSym->Procedure.IsCtor = value;
10341 : 195411 : break;
10342 : :
10343 : :
10344 : 0 : default:
10345 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10346 : 195411 : break;
10347 : : }
10348 : 195411 : }
10349 : :
10350 : :
10351 : : /*
10352 : : IsCtor - returns the ctor boolean associated with a procedure.
10353 : : */
10354 : :
10355 : 155516 : extern "C" bool SymbolTable_IsCtor (unsigned int sym)
10356 : : {
10357 : 155516 : SymbolTable_PtrToSymbol pSym;
10358 : :
10359 : 155516 : pSym = GetPsym (sym);
10360 : 155516 : switch (pSym->SymbolType)
10361 : : {
10362 : 155516 : case SymbolTable_ProcedureSym:
10363 : 155516 : return pSym->Procedure.IsCtor;
10364 : 0 : break;
10365 : :
10366 : :
10367 : 0 : default:
10368 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10369 : : break;
10370 : : }
10371 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10372 : : __builtin_unreachable ();
10373 : : }
10374 : :
10375 : :
10376 : : /*
10377 : : GetModuleCtors - mod can be a DefImp or Module symbol. ctor, init and fini
10378 : : are assigned for this module. An inner module ctor value will
10379 : : be NulSym.
10380 : : */
10381 : :
10382 : 156057 : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep)
10383 : : {
10384 : 156057 : SymbolTable_PtrToSymbol pSym;
10385 : :
10386 : 156057 : pSym = GetPsym (mod);
10387 : 156057 : switch (pSym->SymbolType)
10388 : : {
10389 : 83146 : case SymbolTable_ModuleSym:
10390 : 83146 : (*ctor) = pSym->Module.ctors.ctor;
10391 : 83146 : (*init) = pSym->Module.ctors.init;
10392 : 83146 : (*fini) = pSym->Module.ctors.fini;
10393 : 83146 : (*dep) = pSym->Module.ctors.dep;
10394 : 83146 : break;
10395 : :
10396 : 72911 : case SymbolTable_DefImpSym:
10397 : 72911 : (*ctor) = pSym->DefImp.ctors.ctor;
10398 : 72911 : (*init) = pSym->DefImp.ctors.init;
10399 : 72911 : (*fini) = pSym->DefImp.ctors.fini;
10400 : 72911 : (*dep) = pSym->DefImp.ctors.dep;
10401 : 72911 : break;
10402 : :
10403 : :
10404 : 0 : default:
10405 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
10406 : 156057 : break;
10407 : : }
10408 : 156057 : }
10409 : :
10410 : :
10411 : : /*
10412 : : MakeModuleCtor - for a defimp or module symbol create all the ctor
10413 : : related procedures.
10414 : : */
10415 : :
10416 : 83079 : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym)
10417 : : {
10418 : 83079 : SymbolTable_PtrToSymbol pSym;
10419 : :
10420 : 166158 : M2Debug_Assert ((SymbolTable_IsDefImp (moduleSym)) || (SymbolTable_IsModule (moduleSym)));
10421 : 83079 : pSym = GetPsym (moduleSym);
10422 : 83079 : if (SymbolTable_IsDefImp (moduleSym))
10423 : : {
10424 : 70949 : InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->DefImp.ctors, SymbolTable_GetSymName (moduleSym), false, true);
10425 : : }
10426 : : else
10427 : : {
10428 : 12130 : InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->Module.ctors, SymbolTable_GetSymName (moduleSym), SymbolTable_IsInnerModule (moduleSym), true);
10429 : : }
10430 : 83079 : }
10431 : :
10432 : :
10433 : : /*
10434 : : PutModuleCtorExtern - for every ctor related procedure in module sym.
10435 : : Make it external. It will create any missing
10436 : : init/fini procedures but not any missing dep/ctor
10437 : : procedures.
10438 : : */
10439 : :
10440 : 113068 : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external)
10441 : : {
10442 : 113068 : SymbolTable_PtrToSymbol pSym;
10443 : :
10444 : 226136 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10445 : 113068 : pSym = GetPsym (sym);
10446 : 113068 : switch (pSym->SymbolType)
10447 : : {
10448 : 113068 : case SymbolTable_DefImpSym:
10449 : 113068 : PutCtorExtern (tok, sym, &pSym->DefImp.ctors, external);
10450 : 113068 : break;
10451 : :
10452 : 0 : case SymbolTable_ModuleSym:
10453 : 0 : PutCtorExtern (tok, sym, &pSym->Module.ctors, external);
10454 : 0 : break;
10455 : :
10456 : :
10457 : 0 : default:
10458 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10459 : 113068 : break;
10460 : : }
10461 : 113068 : }
10462 : :
10463 : :
10464 : : /*
10465 : : PutVarHeap - assigns ArrayRef field with value.
10466 : : */
10467 : :
10468 : 52428 : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value)
10469 : : {
10470 : 52428 : SymbolTable_PtrToSymbol pSym;
10471 : :
10472 : 52428 : pSym = GetPsym (sym);
10473 : 52428 : switch (pSym->SymbolType)
10474 : : {
10475 : 52428 : case SymbolTable_VarSym:
10476 : 52428 : pSym->Var.Heap = value;
10477 : 52428 : break;
10478 : :
10479 : :
10480 : 0 : default:
10481 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
10482 : 52428 : break;
10483 : : }
10484 : 52428 : }
10485 : :
10486 : :
10487 : : /*
10488 : : IsVarHeap - returns ArrayRef field value.
10489 : : */
10490 : :
10491 : 631650 : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym)
10492 : : {
10493 : 631650 : SymbolTable_PtrToSymbol pSym;
10494 : :
10495 : 631650 : pSym = GetPsym (sym);
10496 : 631650 : switch (pSym->SymbolType)
10497 : : {
10498 : 631650 : case SymbolTable_VarSym:
10499 : 631650 : return pSym->Var.Heap;
10500 : 0 : break;
10501 : :
10502 : :
10503 : 0 : default:
10504 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
10505 : : break;
10506 : : }
10507 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10508 : : __builtin_unreachable ();
10509 : : }
10510 : :
10511 : :
10512 : : /*
10513 : : MakeVar - creates a variable sym with VarName. It returns the
10514 : : symbol index.
10515 : : */
10516 : :
10517 : 11330059 : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName)
10518 : : {
10519 : 11330059 : SymbolTable_PtrToSymbol pSym;
10520 : 11330059 : unsigned int Sym;
10521 : :
10522 : 11330059 : Sym = DeclareSym (tok, VarName);
10523 : 11330059 : if (! (SymbolTable_IsError (Sym)))
10524 : : {
10525 : 11330047 : pSym = GetPsym (Sym);
10526 : 11330047 : pSym->SymbolType = SymbolTable_VarSym;
10527 : 11330047 : pSym->Var.name = VarName;
10528 : 11330047 : pSym->Var.Type = SymbolTable_NulSym;
10529 : 11330047 : pSym->Var.BackType = SymbolTable_NulSym;
10530 : 11330047 : pSym->Var.Size = M2ALU_InitValue ();
10531 : 11330047 : pSym->Var.Offset = M2ALU_InitValue ();
10532 : 11330047 : pSym->Var.AddrMode = SymbolTable_RightValue;
10533 : 11330047 : pSym->Var.Scope = SymbolTable_GetCurrentScope (); /* Procedure or Module? */
10534 : 11330047 : pSym->Var.AtAddress = false; /* Procedure or Module? */
10535 : 11330047 : pSym->Var.Address = SymbolTable_NulSym; /* Address at which declared. */
10536 : 11330047 : pSym->Var.IsConditional = false; /* Address at which declared. */
10537 : 11330047 : pSym->Var.IsTemp = false;
10538 : 11330047 : pSym->Var.IsComponentRef = false;
10539 : 11330047 : pSym->Var.IsParam = false;
10540 : 11330047 : pSym->Var.IsPointerCheck = false;
10541 : 11330047 : pSym->Var.IsWritten = false;
10542 : 11330047 : pSym->Var.IsSSA = false;
10543 : 11330047 : pSym->Var.IsConst = false;
10544 : 11330047 : pSym->Var.ArrayRef = false;
10545 : 11330047 : pSym->Var.Heap = false;
10546 : 11330047 : InitVarDecl (&pSym->Var.Declared, tok);
10547 : 11330047 : InitWhereDeclaredTok (tok, &pSym->Var.At);
10548 : 11330047 : InitWhereFirstUsedTok (tok, &pSym->Var.At); /* Where symbol first used. */
10549 : 11330047 : Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]); /* Where symbol first used. */
10550 : 11330047 : Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]);
10551 : 11330047 : Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
10552 : 11330047 : Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
10553 : 11330047 : pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
10554 : 11330047 : pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
10555 : : /* Add Var to Procedure or Module variable list. */
10556 : 11330047 : AddVarToList (Sym);
10557 : : /* Now add this Var to the symbol table of the current scope. */
10558 : 11330047 : AddSymToScope (Sym, VarName);
10559 : : }
10560 : 11330059 : return Sym;
10561 : : /* static analysis guarentees a RETURN statement will be used before here. */
10562 : : __builtin_unreachable ();
10563 : : }
10564 : :
10565 : :
10566 : : /*
10567 : : PutVarConditional - assign IsConditional to value.
10568 : : */
10569 : :
10570 : 17211 : extern "C" void SymbolTable_PutVarConditional (unsigned int sym, bool value)
10571 : : {
10572 : 17211 : SymbolTable_PtrToSymbol pSym;
10573 : :
10574 : 17211 : pSym = GetPsym (sym);
10575 : 17211 : switch (pSym->SymbolType)
10576 : : {
10577 : 16929 : case SymbolTable_VarSym:
10578 : 16929 : pSym->Var.IsConditional = value;
10579 : 16929 : break;
10580 : :
10581 : 282 : case SymbolTable_ConstVarSym:
10582 : 282 : pSym->ConstVar.IsConditional = value;
10583 : 282 : break;
10584 : :
10585 : :
10586 : 0 : default:
10587 : 0 : M2Error_InternalError ((const char *) "expecting Var", 13);
10588 : 17211 : break;
10589 : : }
10590 : 17211 : }
10591 : :
10592 : :
10593 : : /*
10594 : : IsVarConditional - return TRUE if the symbol is a var symbol
10595 : : containing the result of a boolean conditional.
10596 : : */
10597 : :
10598 : 317690 : extern "C" bool SymbolTable_IsVarConditional (unsigned int sym)
10599 : : {
10600 : 317690 : SymbolTable_PtrToSymbol pSym;
10601 : :
10602 : 317690 : pSym = GetPsym (sym);
10603 : 317690 : switch (pSym->SymbolType)
10604 : : {
10605 : 19814 : case SymbolTable_VarSym:
10606 : 19814 : return pSym->Var.IsConditional;
10607 : 296623 : break;
10608 : :
10609 : 296623 : case SymbolTable_ConstVarSym:
10610 : 296623 : return pSym->ConstVar.IsConditional;
10611 : : break;
10612 : :
10613 : :
10614 : : default:
10615 : : return false;
10616 : : break;
10617 : : }
10618 : : return false;
10619 : : /* static analysis guarentees a RETURN statement will be used before here. */
10620 : : __builtin_unreachable ();
10621 : : }
10622 : :
10623 : :
10624 : : /*
10625 : : MakeRecord - makes a Record symbol with name RecordName.
10626 : : */
10627 : :
10628 : 71467 : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName)
10629 : : {
10630 : 71467 : unsigned int oaf;
10631 : 71467 : unsigned int sym;
10632 : :
10633 : 71467 : tok = CheckTok (tok, (const char *) "record", 6);
10634 : 71467 : sym = HandleHiddenOrDeclare (tok, RecordName, &oaf);
10635 : 71467 : FillInRecordFields (tok, sym, RecordName, SymbolTable_GetCurrentScope (), oaf);
10636 : 71467 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10637 : 71467 : return sym;
10638 : : /* static analysis guarentees a RETURN statement will be used before here. */
10639 : : __builtin_unreachable ();
10640 : : }
10641 : :
10642 : :
10643 : : /*
10644 : : MakeVarient - creates a new symbol, a varient symbol for record or varient field
10645 : : symbol, RecOrVarFieldSym.
10646 : : */
10647 : :
10648 : 2982 : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym)
10649 : : {
10650 : 2982 : SymbolTable_PtrToSymbol pSym;
10651 : 2982 : unsigned int Sym;
10652 : :
10653 : 2982 : tok = CheckTok (tok, (const char *) "varient", 7);
10654 : 2982 : NewSym (&Sym);
10655 : 2982 : pSym = GetPsym (Sym);
10656 : 2982 : pSym->SymbolType = SymbolTable_VarientSym;
10657 : 2982 : pSym->Varient.Size = M2ALU_InitValue ();
10658 : 2982 : pSym->Varient.Parent = RecOrVarFieldSym; /* GetRecord(RecOrVarFieldSym) ; */
10659 : 2982 : if (SymbolTable_IsRecord (RecOrVarFieldSym)) /* GetRecord(RecOrVarFieldSym) ; */
10660 : : {
10661 : 2946 : pSym->Varient.Varient = SymbolTable_NulSym;
10662 : : }
10663 : : else
10664 : : {
10665 : 36 : pSym->Varient.Varient = RecOrVarFieldSym;
10666 : : }
10667 : 2982 : pSym->Varient.tag = SymbolTable_NulSym;
10668 : 2982 : pSym->Varient.DeclPacked = false;
10669 : 2982 : pSym->Varient.Scope = SymbolTable_GetCurrentScope ();
10670 : 2982 : Lists_InitList (&pSym->Varient.ListOfSons);
10671 : 2982 : InitWhereDeclaredTok (tok, &pSym->Varient.At);
10672 : : /* Now add Sym to the record RecSym field list */
10673 : 2982 : pSym = GetPsym (RecOrVarFieldSym);
10674 : 2982 : switch (pSym->SymbolType)
10675 : : {
10676 : 2946 : case SymbolTable_RecordSym:
10677 : 2946 : Lists_PutItemIntoList (pSym->Record.ListOfSons, Sym);
10678 : 2946 : break;
10679 : :
10680 : 36 : case SymbolTable_VarientFieldSym:
10681 : 36 : Lists_PutItemIntoList (pSym->VarientField.ListOfSons, Sym);
10682 : 36 : break;
10683 : :
10684 : :
10685 : 0 : default:
10686 : 0 : M2Error_InternalError ((const char *) "expecting Record or VarientField symbol", 39);
10687 : 2982 : break;
10688 : : }
10689 : 2982 : return Sym;
10690 : : /* static analysis guarentees a RETURN statement will be used before here. */
10691 : : __builtin_unreachable ();
10692 : : }
10693 : :
10694 : :
10695 : : /*
10696 : : MakeFieldVarient - returns a FieldVarient symbol which has been
10697 : : assigned to the Varient symbol, Sym.
10698 : : */
10699 : :
10700 : 6078 : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym)
10701 : : {
10702 : 6078 : SymbolTable_PtrToSymbol pSym;
10703 : 6078 : unsigned int SonSym;
10704 : :
10705 : 6078 : NewSym (&SonSym);
10706 : : /* Fill in Sym */
10707 : 6078 : pSym = GetPsym (SonSym);
10708 : 6078 : pSym->SymbolType = SymbolTable_VarientFieldSym;
10709 : 6078 : pSym->VarientField.name = n;
10710 : 6078 : Lists_InitList (&pSym->VarientField.ListOfSons);
10711 : 6078 : pSym->VarientField.Parent = SymbolTable_GetRecord (Sym);
10712 : 6078 : pSym->VarientField.Varient = SymbolTable_NulSym;
10713 : 6078 : pSym->VarientField.Size = M2ALU_InitValue ();
10714 : 6078 : pSym->VarientField.Offset = M2ALU_InitValue ();
10715 : 6078 : pSym->VarientField.DeclPacked = false;
10716 : 6078 : pSym->VarientField.DeclResolved = false;
10717 : 6078 : pSym->VarientField.Scope = SymbolTable_GetCurrentScope ();
10718 : 6078 : InitWhereDeclared (&pSym->VarientField.At);
10719 : 6078 : return SonSym;
10720 : : /* static analysis guarentees a RETURN statement will be used before here. */
10721 : : __builtin_unreachable ();
10722 : : }
10723 : :
10724 : :
10725 : : /*
10726 : : MakeEnumeration - places a new symbol in the current scope, the symbol
10727 : : is an enumeration symbol. The symbol index is returned.
10728 : : */
10729 : :
10730 : 49367 : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName)
10731 : : {
10732 : 49367 : SymbolTable_PtrToSymbol pSym;
10733 : 49367 : unsigned int sym;
10734 : 49367 : unsigned int oaf;
10735 : :
10736 : 49367 : tok = CheckTok (tok, (const char *) "enumeration", 11);
10737 : 49367 : sym = CheckForHiddenType (EnumerationName);
10738 : 49367 : if (sym == SymbolTable_NulSym)
10739 : : {
10740 : : /* avoid dangling else. */
10741 : 49367 : sym = DeclareSym (tok, EnumerationName);
10742 : 49367 : oaf = SymbolTable_GetOAFamily (sym);
10743 : 49367 : if (! (SymbolTable_IsError (sym)))
10744 : : {
10745 : 49367 : pSym = GetPsym (sym);
10746 : 49367 : pSym->SymbolType = SymbolTable_EnumerationSym; /* To satisfy AddSymToScope */
10747 : : /* Now add this type to the symbol table of the current scope */
10748 : 49367 : AddSymToScope (sym, EnumerationName);
10749 : : }
10750 : : }
10751 : : else
10752 : : {
10753 : 0 : oaf = SymbolTable_GetOAFamily (sym);
10754 : : }
10755 : 49367 : if (! (SymbolTable_IsError (sym)))
10756 : : {
10757 : 49367 : pSym = GetPsym (sym);
10758 : 49367 : pSym->SymbolType = SymbolTable_EnumerationSym;
10759 : 49367 : pSym->Enumeration.name = EnumerationName; /* Name of enumeration. */
10760 : 49367 : pSym->Enumeration.NoOfElements = 0; /* No of elements in the */
10761 : : /* enumeration type. */
10762 : 49367 : pSym->Enumeration.Size = M2ALU_InitValue (); /* Size at runtime of sym */
10763 : 49367 : SymbolKey_InitTree (&pSym->Enumeration.LocalSymbols); /* Enumeration fields. */
10764 : 49367 : Lists_InitList (&pSym->Enumeration.ListOfFields); /* Ordered as declared. */
10765 : 49367 : InitPacked (&pSym->Enumeration.packedInfo); /* not packed and no */
10766 : : /* equivalent (yet). */
10767 : 49367 : pSym->Enumeration.oafamily = oaf; /* The open array family */
10768 : 49367 : pSym->Enumeration.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10769 : 49367 : InitWhereDeclaredTok (tok, &pSym->Enumeration.At); /* Declared here */
10770 : 49367 : CheckIfEnumerationExported (sym, ScopePtr);
10771 : : }
10772 : 49367 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10773 : 49367 : return sym;
10774 : : /* static analysis guarentees a RETURN statement will be used before here. */
10775 : : __builtin_unreachable ();
10776 : : }
10777 : :
10778 : :
10779 : : /*
10780 : : MakeType - makes a type symbol with name TypeName.
10781 : : */
10782 : :
10783 : 616048 : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName)
10784 : : {
10785 : 616048 : SymbolTable_PtrToSymbol pSym;
10786 : 616048 : unsigned int sym;
10787 : 616048 : unsigned int oaf;
10788 : :
10789 : 616048 : sym = HandleHiddenOrDeclare (tok, TypeName, &oaf);
10790 : 616048 : if (! (SymbolTable_IsError (sym)))
10791 : : {
10792 : 616042 : pSym = GetPsym (sym);
10793 : 616042 : pSym->SymbolType = SymbolTable_TypeSym;
10794 : 616042 : pSym->Type.name = TypeName; /* Index into name array, name */
10795 : : /* of type. */
10796 : 616042 : pSym->Type.Type = SymbolTable_NulSym; /* Index to a type symbol. */
10797 : 616042 : pSym->Type.IsHidden = false; /* Was it declared as hidden? */
10798 : 616042 : SymbolKey_InitTree (&pSym->Type.ConstLitTree); /* constants of this type. */
10799 : 616042 : pSym->Type.Size = M2ALU_InitValue (); /* Runtime size of symbol. */
10800 : 616042 : pSym->Type.Align = SymbolTable_NulSym; /* Alignment of this type. */
10801 : 616042 : InitPacked (&pSym->Type.packedInfo); /* not packed and no */
10802 : : /* equivalent yet. */
10803 : 616042 : pSym->Type.oafamily = oaf; /* The open array family. */
10804 : 616042 : pSym->Type.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10805 : 616042 : InitWhereDeclaredTok (tok, &pSym->Type.At); /* Declared here */
10806 : : }
10807 : 616048 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10808 : 616048 : return sym;
10809 : : /* static analysis guarentees a RETURN statement will be used before here. */
10810 : : __builtin_unreachable ();
10811 : : }
10812 : :
10813 : :
10814 : : /*
10815 : : MakeHiddenType - makes a type symbol that is hidden from the
10816 : : definition module.
10817 : : This symbol is placed into the UnImplemented list of
10818 : : the definition/implementation module.
10819 : : The type will be filled in when the implementation module
10820 : : is reached.
10821 : : */
10822 : :
10823 : 28771 : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName)
10824 : : {
10825 : 28771 : SymbolTable_PtrToSymbol pSym;
10826 : 28771 : unsigned int Sym;
10827 : :
10828 : 28771 : tok = CheckTok (tok, (const char *) "hidden", 6);
10829 : 28771 : Sym = DeclareSym (tok, TypeName);
10830 : 28771 : if (! (SymbolTable_IsError (Sym)))
10831 : : {
10832 : 28771 : pSym = GetPsym (Sym);
10833 : 28771 : pSym->SymbolType = SymbolTable_TypeSym;
10834 : 28771 : pSym->Type.name = TypeName; /* Index into name array, name */
10835 : : /* of type. */
10836 : 28771 : pSym->Type.IsHidden = (SymbolTable_GetMainModule ()) != (SymbolTable_GetCurrentScope ());
10837 : 28771 : if (M2Options_ExtendedOpaque || ! pSym->Type.IsHidden)
10838 : : {
10839 : 1502 : pSym->Type.Type = SymbolTable_NulSym; /* will be filled in later */
10840 : : }
10841 : : else
10842 : : {
10843 : 27269 : pSym->Type.Type = M2System_Address;
10844 : : }
10845 : 28771 : pSym->Type.Align = SymbolTable_NulSym; /* Alignment of this type. */
10846 : 28771 : pSym->Type.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10847 : 28771 : pSym->Type.oafamily = SymbolTable_NulSym; /* Which scope created it */
10848 : 28771 : if (! M2Options_ExtendedOpaque)
10849 : : {
10850 : 27375 : Lists_IncludeItemIntoList (AddressTypes, Sym);
10851 : : }
10852 : 28771 : pSym->Type.Size = M2ALU_InitValue (); /* Runtime size of symbol. */
10853 : 28771 : InitWhereDeclaredTok (tok, &pSym->Type.At); /* Declared here */
10854 : 28771 : SymbolTable_PutExportUnImplemented (tok, Sym);
10855 : 28771 : if (M2Options_ExtendedOpaque || ((SymbolTable_GetMainModule ()) == (SymbolTable_GetCurrentScope ())))
10856 : : {
10857 : 1502 : SymbolTable_PutHiddenTypeDeclared ();
10858 : : }
10859 : : /* Now add this type to the symbol table of the current scope */
10860 : 28771 : AddSymToScope (Sym, TypeName);
10861 : : }
10862 : 28771 : return Sym;
10863 : : /* static analysis guarentees a RETURN statement will be used before here. */
10864 : : __builtin_unreachable ();
10865 : : }
10866 : :
10867 : :
10868 : : /*
10869 : : MakeConstant - create a constant cardinal and return the symbol.
10870 : : */
10871 : :
10872 : 101302 : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value)
10873 : : {
10874 : 101302 : DynamicStrings_String str;
10875 : 101302 : unsigned int sym;
10876 : :
10877 : 101302 : tok = CheckTok (tok, (const char *) "constant", 8);
10878 : 101302 : str = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%d", 2)), (const unsigned char *) &value, (sizeof (value)-1));
10879 : 101302 : sym = SymbolTable_MakeConstLit (tok, NameKey_makekey (DynamicStrings_string (str)), M2Base_Cardinal);
10880 : 101302 : str = DynamicStrings_KillString (str);
10881 : 101302 : return sym;
10882 : : /* static analysis guarentees a RETURN statement will be used before here. */
10883 : : __builtin_unreachable ();
10884 : : }
10885 : :
10886 : :
10887 : : /*
10888 : : MakeConstLit - returns a constant literal of type, constType, with a constName,
10889 : : at location, tok.
10890 : : */
10891 : :
10892 : 1642567 : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
10893 : : {
10894 : 1642567 : unsigned int sym;
10895 : :
10896 : 1642567 : tok = CheckTok (tok, (const char *) "constlit", 8);
10897 : 1642567 : sym = LookupConstLitPoolEntry (tok, constName, constType);
10898 : 1642567 : if (sym == SymbolTable_NulSym)
10899 : : {
10900 : 613898 : sym = CreateConstLit (tok, constName, constType);
10901 : 613898 : AddConstLitPoolEntry (sym, tok, constName, constType);
10902 : : }
10903 : 1642567 : return sym;
10904 : : /* static analysis guarentees a RETURN statement will be used before here. */
10905 : : __builtin_unreachable ();
10906 : : }
10907 : :
10908 : :
10909 : : /*
10910 : : MakeConstVar - makes a ConstVar type with
10911 : : name ConstVarName.
10912 : : */
10913 : :
10914 : 1281526 : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName)
10915 : : {
10916 : 1281526 : SymbolTable_PtrToSymbol pSym;
10917 : 1281526 : unsigned int Sym;
10918 : 1281526 : bool temp;
10919 : :
10920 : 1281526 : temp = ConstVarName == NameKey_NulName;
10921 : 1281526 : ConstVarName = SymbolTable_CheckAnonymous (ConstVarName);
10922 : 1281526 : Sym = DeclareSym (tok, ConstVarName);
10923 : 1281526 : if (! (SymbolTable_IsError (Sym)))
10924 : : {
10925 : 1281520 : pSym = GetPsym (Sym);
10926 : 1281520 : pSym->SymbolType = SymbolTable_ConstVarSym;
10927 : 1281520 : pSym->ConstVar.name = ConstVarName;
10928 : 1281520 : pSym->ConstVar.Value = M2ALU_InitValue ();
10929 : 1281520 : pSym->ConstVar.Type = SymbolTable_NulSym;
10930 : 1281520 : pSym->ConstVar.IsSet = false;
10931 : 1281520 : pSym->ConstVar.IsConditional = false;
10932 : 1281520 : pSym->ConstVar.IsConstructor = false;
10933 : 1281520 : pSym->ConstVar.FromType = SymbolTable_NulSym; /* type is determined FromType */
10934 : 1281520 : pSym->ConstVar.UnresFromType = false; /* is Type resolved? */
10935 : 1281520 : pSym->ConstVar.IsTemp = temp; /* is Type resolved? */
10936 : 1281520 : pSym->ConstVar.Scope = SymbolTable_GetCurrentScope ();
10937 : 1281520 : InitWhereDeclaredTok (tok, &pSym->ConstVar.At);
10938 : : /* Now add this constant to the symbol table of the current scope */
10939 : 1281520 : AddSymToScope (Sym, ConstVarName);
10940 : : }
10941 : 1281526 : return Sym;
10942 : : /* static analysis guarentees a RETURN statement will be used before here. */
10943 : : __builtin_unreachable ();
10944 : : }
10945 : :
10946 : :
10947 : : /*
10948 : : MakeConstString - create a string constant in the symboltable.
10949 : : */
10950 : :
10951 : 325698 : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName)
10952 : : {
10953 : 325698 : unsigned int newstr;
10954 : :
10955 : 325698 : NewSym (&newstr);
10956 : 325698 : InitConstString (tok, newstr, ConstName, ConstName, SymbolTable_m2nulstr, false, true);
10957 : 325698 : return newstr;
10958 : : /* static analysis guarentees a RETURN statement will be used before here. */
10959 : : __builtin_unreachable ();
10960 : : }
10961 : :
10962 : :
10963 : : /*
10964 : : MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
10965 : : If known is TRUE then name is assigned to the contents
10966 : : and the escape sequences will be converted into characters.
10967 : : */
10968 : :
10969 : 9586 : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known)
10970 : : {
10971 : 9586 : unsigned int newstr;
10972 : :
10973 : 9586 : tok = CheckTok (tok, (const char *) "conststringcnul", 15);
10974 : 9586 : NewSym (&newstr);
10975 : 9586 : InitConstString (tok, newstr, name, name, SymbolTable_cnulstr, true, known);
10976 : 9586 : return newstr;
10977 : : /* static analysis guarentees a RETURN statement will be used before here. */
10978 : : __builtin_unreachable ();
10979 : : }
10980 : :
10981 : :
10982 : : /*
10983 : : MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
10984 : : If known is TRUE then name is assigned to the contents
10985 : : however the escape sequences are not converted into characters.
10986 : : */
10987 : :
10988 : 34344 : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known)
10989 : : {
10990 : 34344 : unsigned int newstr;
10991 : :
10992 : 34344 : NewSym (&newstr);
10993 : 34344 : InitConstString (tok, newstr, name, name, SymbolTable_m2nulstr, false, known);
10994 : 34344 : return newstr;
10995 : : /* static analysis guarentees a RETURN statement will be used before here. */
10996 : : __builtin_unreachable ();
10997 : : }
10998 : :
10999 : :
11000 : : /*
11001 : : PutConstStringKnown - if sym is a constvar then convert it into a conststring.
11002 : : If known is FALSE then contents is ignored and NulName is
11003 : : stored. If escape is TRUE then the contents will have
11004 : : any escape sequences converted into single characters.
11005 : : */
11006 : :
11007 : 426341 : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known)
11008 : : {
11009 : 426341 : SymbolTable_PtrToSymbol pSym;
11010 : 426341 : DynamicStrings_String s;
11011 : :
11012 : 426341 : pSym = GetPsym (sym);
11013 : 426341 : switch (pSym->SymbolType)
11014 : : {
11015 : 425058 : case SymbolTable_ConstStringSym:
11016 : 425058 : if (known)
11017 : : {
11018 : 379365 : if (escape)
11019 : : {
11020 : 9562 : s = FormatStrings_HandleEscape (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (contents)));
11021 : 9562 : contents = NameKey_makekey (DynamicStrings_string (s));
11022 : 9562 : s = DynamicStrings_KillString (s);
11023 : : }
11024 : 379365 : pSym->ConstString.Length = NameKey_LengthKey (contents);
11025 : 379365 : pSym->ConstString.Contents = contents;
11026 : : }
11027 : : else
11028 : : {
11029 : 45693 : pSym->ConstString.Length = 0;
11030 : 45693 : pSym->ConstString.Contents = NameKey_NulName;
11031 : : }
11032 : 425058 : pSym->ConstString.Known = known;
11033 : 425058 : InitWhereDeclaredTok (tok, &pSym->ConstString.At);
11034 : 425058 : InitWhereFirstUsedTok (tok, &pSym->ConstString.At);
11035 : 425058 : break;
11036 : :
11037 : 1283 : case SymbolTable_ConstVarSym:
11038 : 1283 : InitConstString (tok, sym, pSym->ConstVar.name, contents, SymbolTable_m2str, escape, known); /* Change a ConstVar to a ConstString copy name
11039 : : and alter symboltype. */
11040 : 1283 : break;
11041 : :
11042 : :
11043 : 0 : default:
11044 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
11045 : 426341 : break;
11046 : : }
11047 : 426341 : }
11048 : :
11049 : :
11050 : : /*
11051 : : CopyConstString - copies string contents from expr to des
11052 : : and retain the kind of string.
11053 : : */
11054 : :
11055 : 1277 : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr)
11056 : : {
11057 : 1277 : SymbolTable_PtrToSymbol pSym;
11058 : :
11059 : 1277 : M2Debug_Assert (SymbolTable_IsConstStringKnown (expr));
11060 : 1277 : pSym = GetPsym (des);
11061 : 1277 : switch (pSym->SymbolType)
11062 : : {
11063 : 1253 : case SymbolTable_ConstStringSym:
11064 : 1253 : InitConstString (tok, des, pSym->ConstString.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true);
11065 : 1253 : break;
11066 : :
11067 : 24 : case SymbolTable_ConstVarSym:
11068 : 24 : InitConstString (tok, des, pSym->ConstVar.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true); /* Change a ConstVar to a ConstString copy name
11069 : : and alter symboltype. */
11070 : 24 : break;
11071 : :
11072 : :
11073 : 0 : default:
11074 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
11075 : 1277 : break;
11076 : : }
11077 : 1277 : }
11078 : :
11079 : :
11080 : : /*
11081 : : IsConstStringKnown - returns TRUE if sym is a const string
11082 : : and the contents are known.
11083 : : */
11084 : :
11085 : 908824 : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym)
11086 : : {
11087 : 908824 : SymbolTable_PtrToSymbol pSym;
11088 : :
11089 : 908824 : pSym = GetPsym (sym);
11090 : 908824 : switch (pSym->SymbolType)
11091 : : {
11092 : 908800 : case SymbolTable_ConstStringSym:
11093 : 908800 : return pSym->ConstString.Known;
11094 : : break;
11095 : :
11096 : :
11097 : : default:
11098 : : return false;
11099 : : break;
11100 : : }
11101 : : /* static analysis guarentees a RETURN statement will be used before here. */
11102 : : __builtin_unreachable ();
11103 : : }
11104 : :
11105 : :
11106 : : /*
11107 : : IsConstStringM2 - returns whether this conststring is a
11108 : : Modula-2 string.
11109 : : */
11110 : :
11111 : 0 : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym)
11112 : : {
11113 : 0 : return (GetConstStringKind (sym)) == SymbolTable_m2str;
11114 : : /* static analysis guarentees a RETURN statement will be used before here. */
11115 : : __builtin_unreachable ();
11116 : : }
11117 : :
11118 : :
11119 : : /*
11120 : : IsConstStringC - returns whether this conststring is a C style string
11121 : : which will have any escape translated.
11122 : : */
11123 : :
11124 : 0 : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym)
11125 : : {
11126 : 0 : return (GetConstStringKind (sym)) == SymbolTable_cstr;
11127 : : /* static analysis guarentees a RETURN statement will be used before here. */
11128 : : __builtin_unreachable ();
11129 : : }
11130 : :
11131 : :
11132 : : /*
11133 : : IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
11134 : : contains a nul terminator.
11135 : : */
11136 : :
11137 : 284676 : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym)
11138 : : {
11139 : 284676 : return (GetConstStringKind (sym)) == SymbolTable_m2nulstr;
11140 : : /* static analysis guarentees a RETURN statement will be used before here. */
11141 : : __builtin_unreachable ();
11142 : : }
11143 : :
11144 : :
11145 : : /*
11146 : : IsConstStringCnul - returns whether this conststring is a C style string
11147 : : which will have any escape translated and also contains
11148 : : a nul terminator.
11149 : : */
11150 : :
11151 : 9222 : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym)
11152 : : {
11153 : 9222 : return (GetConstStringKind (sym)) == SymbolTable_cnulstr;
11154 : : /* static analysis guarentees a RETURN statement will be used before here. */
11155 : : __builtin_unreachable ();
11156 : : }
11157 : :
11158 : :
11159 : : /*
11160 : : MakeSubrange - makes a new symbol into a subrange type with
11161 : : name SubrangeName.
11162 : : */
11163 : :
11164 : 226978 : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName)
11165 : : {
11166 : 226978 : SymbolTable_PtrToSymbol pSym;
11167 : 226978 : unsigned int sym;
11168 : 226978 : unsigned int oaf;
11169 : :
11170 : 226978 : tok = CheckTok (tok, (const char *) "subrange", 8);
11171 : 226978 : sym = HandleHiddenOrDeclare (tok, SubrangeName, &oaf);
11172 : 226978 : if (! (SymbolTable_IsError (sym)))
11173 : : {
11174 : 226978 : pSym = GetPsym (sym);
11175 : 226978 : pSym->SymbolType = SymbolTable_SubrangeSym;
11176 : 226978 : pSym->Subrange.name = SubrangeName;
11177 : 226978 : pSym->Subrange.Low = SymbolTable_NulSym; /* Index to a symbol determining */
11178 : : /* ConstExpression. */
11179 : 226978 : pSym->Subrange.High = SymbolTable_NulSym; /* Index to a symbol determining */
11180 : : /* ConstExpression. */
11181 : 226978 : pSym->Subrange.Type = SymbolTable_NulSym; /* Index to a type. Determines */
11182 : : /* the type of subrange. */
11183 : 226978 : pSym->Subrange.Align = SymbolTable_NulSym; /* The alignment of this type. */
11184 : 226978 : InitPacked (&pSym->Subrange.packedInfo); /* not packed and no equivalent */
11185 : 226978 : SymbolKey_InitTree (&pSym->Subrange.ConstLitTree); /* constants of this type. */
11186 : 226978 : pSym->Subrange.Size = M2ALU_InitValue (); /* Size determines the type size */
11187 : 226978 : pSym->Subrange.oafamily = oaf; /* The unbounded sym for this */
11188 : 226978 : pSym->Subrange.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11189 : 226978 : InitWhereDeclaredTok (tok, &pSym->Subrange.At); /* Declared here */
11190 : : }
11191 : 226978 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11192 : 226978 : return sym;
11193 : : /* static analysis guarentees a RETURN statement will be used before here. */
11194 : : __builtin_unreachable ();
11195 : : }
11196 : :
11197 : :
11198 : : /*
11199 : : MakeSet - makes a set Symbol with name, SetName.
11200 : : */
11201 : :
11202 : 65663 : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName)
11203 : : {
11204 : 65663 : SymbolTable_PtrToSymbol pSym;
11205 : 65663 : unsigned int oaf;
11206 : 65663 : unsigned int sym;
11207 : :
11208 : 65663 : tok = CheckTok (tok, (const char *) "set", 3);
11209 : 65663 : sym = HandleHiddenOrDeclare (tok, SetName, &oaf);
11210 : 65663 : if (! (SymbolTable_IsError (sym)))
11211 : : {
11212 : 65663 : pSym = GetPsym (sym);
11213 : 65663 : pSym->SymbolType = SymbolTable_SetSym;
11214 : 65663 : pSym->Set.name = SetName; /* The name of the set. */
11215 : 65663 : pSym->Set.Type = SymbolTable_NulSym; /* Index to a subrange symbol. */
11216 : 65663 : pSym->Set.Size = M2ALU_InitValue (); /* Size of this set */
11217 : 65663 : InitPacked (&pSym->Set.packedInfo); /* not packed and no */
11218 : : /* equivalent (yet). */
11219 : 65663 : pSym->Set.ispacked = false; /* Not yet known to be packed. */
11220 : 65663 : pSym->Set.SetInWord = true; /* Can the set be stored in a */
11221 : : /* single word? */
11222 : 65663 : pSym->Set.SetArray = SymbolTable_NulSym; /* Set used for large sets. */
11223 : 65663 : pSym->Set.Align = SymbolTable_NulSym; /* Set used for large sets. */
11224 : 65663 : pSym->Set.oafamily = oaf; /* The unbounded sym for this */
11225 : 65663 : pSym->Set.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11226 : 65663 : InitWhereDeclaredTok (tok, &pSym->Set.At); /* Declared here */
11227 : : }
11228 : 65663 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11229 : 65663 : return sym;
11230 : : /* static analysis guarentees a RETURN statement will be used before here. */
11231 : : __builtin_unreachable ();
11232 : : }
11233 : :
11234 : :
11235 : : /*
11236 : : GetSetArray - return the set array for a large set.
11237 : : */
11238 : :
11239 : 1673775 : extern "C" unsigned int SymbolTable_GetSetArray (unsigned int sym)
11240 : : {
11241 : 1673775 : SymbolTable_PtrToSymbol pSym;
11242 : :
11243 : 1673775 : AssertInRange (sym);
11244 : 1673775 : pSym = GetPsym (sym);
11245 : 1673775 : switch (pSym->SymbolType)
11246 : : {
11247 : 1673775 : case SymbolTable_SetSym:
11248 : 1673775 : return pSym->Set.SetArray;
11249 : : break;
11250 : :
11251 : :
11252 : : default:
11253 : : return SymbolTable_NulSym;
11254 : : break;
11255 : : }
11256 : : /* static analysis guarentees a RETURN statement will be used before here. */
11257 : : __builtin_unreachable ();
11258 : : }
11259 : :
11260 : :
11261 : : /*
11262 : : PutSetArray - places array into the setarray field.
11263 : : */
11264 : :
11265 : 61561 : extern "C" void SymbolTable_PutSetArray (unsigned int Sym, unsigned int array)
11266 : : {
11267 : 61561 : SymbolTable_PtrToSymbol pSym;
11268 : :
11269 : 61561 : pSym = GetPsym (Sym);
11270 : 61561 : switch (pSym->SymbolType)
11271 : : {
11272 : : case SymbolTable_ErrorSym:
11273 : : break;
11274 : :
11275 : 61561 : case SymbolTable_SetSym:
11276 : 61561 : pSym->Set.SetArray = array;
11277 : 61561 : break;
11278 : :
11279 : :
11280 : 0 : default:
11281 : 0 : M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
11282 : 61561 : break;
11283 : : }
11284 : 61561 : }
11285 : :
11286 : :
11287 : : /*
11288 : : MakeSetArray - create an ARRAY simpletype OF BOOLEAN.
11289 : : */
11290 : :
11291 : 61561 : extern "C" unsigned int SymbolTable_MakeSetArray (unsigned int token, unsigned int subrangetype)
11292 : : {
11293 : 61561 : unsigned int array;
11294 : 61561 : unsigned int subscript;
11295 : :
11296 : 61561 : array = SymbolTable_MakeArray (token, SymbolTable_NulSym);
11297 : 61561 : SymbolTable_PutArray (array, M2System_Byte);
11298 : 61561 : subscript = SymbolTable_MakeSubscript ();
11299 : 61561 : SymbolTable_PutSubscript (subscript, subrangetype);
11300 : 61561 : SymbolTable_PutArraySubscript (array, subscript);
11301 : 61561 : return array;
11302 : : /* static analysis guarentees a RETURN statement will be used before here. */
11303 : : __builtin_unreachable ();
11304 : : }
11305 : :
11306 : :
11307 : : /*
11308 : : PutSetInWord - set the SetInWord boolean to value.
11309 : : */
11310 : :
11311 : 66230 : extern "C" void SymbolTable_PutSetInWord (unsigned int sym, bool value)
11312 : : {
11313 : 66230 : SymbolTable_PtrToSymbol pSym;
11314 : :
11315 : 66230 : AssertInRange (sym);
11316 : 66230 : pSym = GetPsym (sym);
11317 : 66230 : switch (pSym->SymbolType)
11318 : : {
11319 : 66230 : case SymbolTable_SetSym:
11320 : 66230 : pSym->Set.SetInWord = value;
11321 : 66230 : if (value)
11322 : : {
11323 : 64672 : pSym->Set.Align = SymbolTable_MakeConstant (SymbolTable_GetDeclaredMod (sym), 0);
11324 : 64672 : pSym->Set.ispacked = true;
11325 : : }
11326 : 66230 : break;
11327 : :
11328 : :
11329 : 0 : default:
11330 : 0 : M2Error_InternalError ((const char *) "expecting a set symbol", 22);
11331 : 66230 : break;
11332 : : }
11333 : 66230 : }
11334 : :
11335 : :
11336 : : /*
11337 : : GetSetInWord - return SetInWord.
11338 : : */
11339 : :
11340 : 20266 : extern "C" bool SymbolTable_GetSetInWord (unsigned int sym)
11341 : : {
11342 : 20266 : SymbolTable_PtrToSymbol pSym;
11343 : :
11344 : 20266 : AssertInRange (sym);
11345 : 20266 : pSym = GetPsym (sym);
11346 : 20266 : switch (pSym->SymbolType)
11347 : : {
11348 : 20266 : case SymbolTable_SetSym:
11349 : 20266 : return pSym->Set.SetInWord;
11350 : 0 : break;
11351 : :
11352 : :
11353 : 0 : default:
11354 : 0 : M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
11355 : : break;
11356 : : }
11357 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11358 : : __builtin_unreachable ();
11359 : : }
11360 : :
11361 : :
11362 : : /*
11363 : : MakeArray - makes an Array symbol with name ArrayName.
11364 : : */
11365 : :
11366 : 164285 : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName)
11367 : : {
11368 : 164285 : SymbolTable_PtrToSymbol pSym;
11369 : 164285 : unsigned int sym;
11370 : 164285 : unsigned int oaf;
11371 : :
11372 : 164285 : sym = HandleHiddenOrDeclare (tok, ArrayName, &oaf);
11373 : 164285 : if (! (SymbolTable_IsError (sym)))
11374 : : {
11375 : 164285 : pSym = GetPsym (sym);
11376 : 164285 : pSym->SymbolType = SymbolTable_ArraySym;
11377 : 164285 : pSym->Array.name = ArrayName;
11378 : 164285 : pSym->Array.Subscript = SymbolTable_NulSym; /* Contains the array subscripts. */
11379 : 164285 : pSym->Array.Size = M2ALU_InitValue (); /* Size of array. */
11380 : 164285 : pSym->Array.Offset = M2ALU_InitValue (); /* Offset of array. */
11381 : 164285 : pSym->Array.Type = SymbolTable_NulSym; /* The Array Type. ARRAY OF Type. */
11382 : 164285 : pSym->Array.Align = SymbolTable_NulSym; /* Alignment of this type. */
11383 : 164285 : pSym->Array.Large = false; /* is this array large? */
11384 : 164285 : pSym->Array.oafamily = oaf; /* The unbounded for this array */
11385 : 164285 : pSym->Array.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11386 : 164285 : InitWhereDeclaredTok (tok, &pSym->Array.At); /* Declared here */
11387 : : }
11388 : 164285 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11389 : 164285 : return sym;
11390 : : /* static analysis guarentees a RETURN statement will be used before here. */
11391 : : __builtin_unreachable ();
11392 : : }
11393 : :
11394 : :
11395 : : /*
11396 : : PutArrayLarge - indicates that this is a large array in which case
11397 : : the interface to gcc maps this array from 0..high-low,
11398 : : using an integer indice.
11399 : : */
11400 : :
11401 : 24 : extern "C" void SymbolTable_PutArrayLarge (unsigned int array)
11402 : : {
11403 : 24 : SymbolTable_PtrToSymbol pSym;
11404 : :
11405 : 24 : if (! (SymbolTable_IsError (array)))
11406 : : {
11407 : 24 : M2Debug_Assert (SymbolTable_IsArray (array));
11408 : 24 : pSym = GetPsym (array);
11409 : 24 : pSym->Array.Large = true;
11410 : : }
11411 : 24 : }
11412 : :
11413 : :
11414 : : /*
11415 : : IsArrayLarge - returns TRUE if we need to treat this as a large array.
11416 : : */
11417 : :
11418 : 47098 : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array)
11419 : : {
11420 : 47098 : SymbolTable_PtrToSymbol pSym;
11421 : :
11422 : 47098 : M2Debug_Assert (SymbolTable_IsArray (array));
11423 : 47098 : pSym = GetPsym (array);
11424 : 47098 : return pSym->Array.Large;
11425 : : /* static analysis guarentees a RETURN statement will be used before here. */
11426 : : __builtin_unreachable ();
11427 : : }
11428 : :
11429 : :
11430 : : /*
11431 : : PutPriority - places a interrupt, priority, value into module, module.
11432 : : */
11433 : :
11434 : 38 : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority)
11435 : : {
11436 : 38 : SymbolTable_PtrToSymbol pSym;
11437 : :
11438 : 38 : M2Debug_Assert (module != SymbolTable_NulSym);
11439 : 38 : pSym = GetPsym (module);
11440 : 38 : switch (pSym->SymbolType)
11441 : : {
11442 : 14 : case SymbolTable_DefImpSym:
11443 : 14 : pSym->DefImp.Priority = priority;
11444 : 14 : break;
11445 : :
11446 : 24 : case SymbolTable_ModuleSym:
11447 : 24 : pSym->Module.Priority = priority;
11448 : 24 : break;
11449 : :
11450 : :
11451 : 0 : default:
11452 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
11453 : 38 : break;
11454 : : }
11455 : 38 : }
11456 : :
11457 : :
11458 : : /*
11459 : : GetPriority - returns the interrupt priority which was assigned to
11460 : : module, module.
11461 : : */
11462 : :
11463 : 454867 : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module)
11464 : : {
11465 : 454867 : SymbolTable_PtrToSymbol pSym;
11466 : :
11467 : 454867 : M2Debug_Assert (module != SymbolTable_NulSym);
11468 : 454867 : pSym = GetPsym (module);
11469 : 454867 : switch (pSym->SymbolType)
11470 : : {
11471 : 318747 : case SymbolTable_DefImpSym:
11472 : 318747 : return pSym->DefImp.Priority;
11473 : 136120 : break;
11474 : :
11475 : 136120 : case SymbolTable_ModuleSym:
11476 : 136120 : return pSym->Module.Priority;
11477 : 0 : break;
11478 : :
11479 : :
11480 : 0 : default:
11481 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
11482 : : break;
11483 : : }
11484 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11485 : : __builtin_unreachable ();
11486 : : }
11487 : :
11488 : :
11489 : : /*
11490 : : PutNeedSavePriority - set a boolean flag indicating that this procedure
11491 : : needs to save and restore interrupts.
11492 : : */
11493 : :
11494 : 162 : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym)
11495 : : {
11496 : 162 : SymbolTable_PtrToSymbol pSym;
11497 : :
11498 : 162 : pSym = GetPsym (sym);
11499 : 162 : switch (pSym->SymbolType)
11500 : : {
11501 : 162 : case SymbolTable_ProcedureSym:
11502 : 162 : pSym->Procedure.SavePriority = true;
11503 : 162 : break;
11504 : :
11505 : :
11506 : 0 : default:
11507 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
11508 : 162 : break;
11509 : : }
11510 : 162 : }
11511 : :
11512 : :
11513 : : /*
11514 : : GetNeedSavePriority - returns the boolean flag indicating whether this procedure
11515 : : needs to save and restore interrupts.
11516 : : */
11517 : :
11518 : 680 : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym)
11519 : : {
11520 : 680 : SymbolTable_PtrToSymbol pSym;
11521 : :
11522 : 680 : pSym = GetPsym (sym);
11523 : 680 : switch (pSym->SymbolType)
11524 : : {
11525 : 680 : case SymbolTable_ProcedureSym:
11526 : 680 : return pSym->Procedure.SavePriority;
11527 : 0 : break;
11528 : :
11529 : :
11530 : 0 : default:
11531 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
11532 : : break;
11533 : : }
11534 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11535 : : __builtin_unreachable ();
11536 : : }
11537 : :
11538 : :
11539 : : /*
11540 : : PutVariableAtAddress - determines that a variable, sym, is declared at
11541 : : a specific address.
11542 : : */
11543 : :
11544 : 108 : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address)
11545 : : {
11546 : 108 : SymbolTable_PtrToSymbol pSym;
11547 : :
11548 : 108 : M2Debug_Assert (sym != SymbolTable_NulSym);
11549 : 108 : pSym = GetPsym (sym);
11550 : 108 : switch (pSym->SymbolType)
11551 : : {
11552 : 108 : case SymbolTable_VarSym:
11553 : 108 : pSym->Var.AtAddress = true;
11554 : 108 : pSym->Var.Address = address;
11555 : 108 : break;
11556 : :
11557 : :
11558 : 0 : default:
11559 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11560 : 108 : break;
11561 : : }
11562 : 108 : }
11563 : :
11564 : :
11565 : : /*
11566 : : GetVariableAtAddress - returns the address at which variable, sym, is declared.
11567 : : */
11568 : :
11569 : 54 : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym)
11570 : : {
11571 : 54 : SymbolTable_PtrToSymbol pSym;
11572 : :
11573 : 54 : M2Debug_Assert (sym != SymbolTable_NulSym);
11574 : 54 : pSym = GetPsym (sym);
11575 : 54 : switch (pSym->SymbolType)
11576 : : {
11577 : 54 : case SymbolTable_VarSym:
11578 : 54 : return pSym->Var.Address;
11579 : 0 : break;
11580 : :
11581 : :
11582 : 0 : default:
11583 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11584 : : break;
11585 : : }
11586 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11587 : : __builtin_unreachable ();
11588 : : }
11589 : :
11590 : :
11591 : : /*
11592 : : IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
11593 : : a specific address.
11594 : : */
11595 : :
11596 : 336169 : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym)
11597 : : {
11598 : 336169 : SymbolTable_PtrToSymbol pSym;
11599 : :
11600 : 336169 : M2Debug_Assert (sym != SymbolTable_NulSym);
11601 : 336169 : pSym = GetPsym (sym);
11602 : 336169 : switch (pSym->SymbolType)
11603 : : {
11604 : 336169 : case SymbolTable_VarSym:
11605 : 336169 : return pSym->Var.AtAddress;
11606 : 0 : break;
11607 : :
11608 : :
11609 : 0 : default:
11610 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11611 : : break;
11612 : : }
11613 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11614 : : __builtin_unreachable ();
11615 : : }
11616 : :
11617 : :
11618 : : /*
11619 : : PutVariableSSA - assigns value to the SSA field within variable sym.
11620 : : */
11621 : :
11622 : 0 : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value)
11623 : : {
11624 : 0 : SymbolTable_PtrToSymbol pSym;
11625 : :
11626 : 0 : M2Debug_Assert (sym != SymbolTable_NulSym);
11627 : 0 : pSym = GetPsym (sym);
11628 : 0 : switch (pSym->SymbolType)
11629 : : {
11630 : 0 : case SymbolTable_VarSym:
11631 : 0 : pSym->Var.IsSSA = value;
11632 : 0 : break;
11633 : :
11634 : :
11635 : 0 : default:
11636 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11637 : 0 : break;
11638 : : }
11639 : 0 : }
11640 : :
11641 : :
11642 : : /*
11643 : : IsVariableSSA - returns TRUE if variable is known to be a SSA.
11644 : : */
11645 : :
11646 : 194266 : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym)
11647 : : {
11648 : 194266 : SymbolTable_PtrToSymbol pSym;
11649 : :
11650 : 194266 : M2Debug_Assert (sym != SymbolTable_NulSym);
11651 : 194266 : pSym = GetPsym (sym);
11652 : 194266 : switch (pSym->SymbolType)
11653 : : {
11654 : 194266 : case SymbolTable_VarSym:
11655 : 194266 : return pSym->Var.IsSSA;
11656 : : break;
11657 : :
11658 : :
11659 : : default:
11660 : : return false;
11661 : : break;
11662 : : }
11663 : : /* static analysis guarentees a RETURN statement will be used before here. */
11664 : : __builtin_unreachable ();
11665 : : }
11666 : :
11667 : :
11668 : : /*
11669 : : PutVarConst - sets the IsConst field to value indicating the variable is read only.
11670 : : */
11671 : :
11672 : 192987 : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value)
11673 : : {
11674 : 192987 : SymbolTable_PtrToSymbol pSym;
11675 : :
11676 : 192987 : if (SymbolTable_IsVar (sym))
11677 : : {
11678 : 192987 : pSym = GetPsym (sym);
11679 : 192987 : pSym->Var.IsConst = value;
11680 : : }
11681 : 192987 : }
11682 : :
11683 : :
11684 : : /*
11685 : : MakeGnuAsm - create a GnuAsm symbol.
11686 : : */
11687 : :
11688 : 27 : extern "C" unsigned int SymbolTable_MakeGnuAsm (void)
11689 : : {
11690 : 27 : SymbolTable_PtrToSymbol pSym;
11691 : 27 : unsigned int Sym;
11692 : :
11693 : 27 : NewSym (&Sym);
11694 : 27 : pSym = GetPsym (Sym);
11695 : 27 : pSym->SymbolType = SymbolTable_GnuAsmSym;
11696 : 27 : pSym->GnuAsm.String = SymbolTable_NulSym;
11697 : 27 : InitWhereDeclared (&pSym->GnuAsm.At);
11698 : 27 : pSym->GnuAsm.Inputs = SymbolTable_NulSym;
11699 : 27 : pSym->GnuAsm.Outputs = SymbolTable_NulSym;
11700 : 27 : pSym->GnuAsm.Trashed = SymbolTable_NulSym;
11701 : 27 : pSym->GnuAsm.Volatile = false;
11702 : 27 : pSym->GnuAsm.Simple = false;
11703 : 27 : return Sym;
11704 : : /* static analysis guarentees a RETURN statement will be used before here. */
11705 : : __builtin_unreachable ();
11706 : : }
11707 : :
11708 : :
11709 : : /*
11710 : : PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
11711 : : */
11712 : :
11713 : 27 : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string)
11714 : : {
11715 : 27 : SymbolTable_PtrToSymbol pSym;
11716 : :
11717 : 27 : M2Debug_Assert (SymbolTable_IsConstString (string));
11718 : 27 : pSym = GetPsym (sym);
11719 : 27 : switch (pSym->SymbolType)
11720 : : {
11721 : 27 : case SymbolTable_GnuAsmSym:
11722 : 27 : pSym->GnuAsm.String = string;
11723 : 27 : break;
11724 : :
11725 : :
11726 : 0 : default:
11727 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11728 : 27 : break;
11729 : : }
11730 : 27 : }
11731 : :
11732 : :
11733 : : /*
11734 : : PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
11735 : : */
11736 : :
11737 : 21 : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out)
11738 : : {
11739 : 21 : SymbolTable_PtrToSymbol pSym;
11740 : :
11741 : 21 : pSym = GetPsym (sym);
11742 : 21 : switch (pSym->SymbolType)
11743 : : {
11744 : 21 : case SymbolTable_GnuAsmSym:
11745 : 21 : pSym->GnuAsm.Outputs = out;
11746 : 21 : break;
11747 : :
11748 : :
11749 : 0 : default:
11750 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11751 : 21 : break;
11752 : : }
11753 : 21 : }
11754 : :
11755 : :
11756 : : /*
11757 : : PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
11758 : : */
11759 : :
11760 : 15 : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in)
11761 : : {
11762 : 15 : SymbolTable_PtrToSymbol pSym;
11763 : :
11764 : 15 : pSym = GetPsym (sym);
11765 : 15 : switch (pSym->SymbolType)
11766 : : {
11767 : 15 : case SymbolTable_GnuAsmSym:
11768 : 15 : pSym->GnuAsm.Inputs = in;
11769 : 15 : break;
11770 : :
11771 : :
11772 : 0 : default:
11773 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11774 : 15 : break;
11775 : : }
11776 : 15 : }
11777 : :
11778 : :
11779 : : /*
11780 : : PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
11781 : : */
11782 : :
11783 : 9 : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash)
11784 : : {
11785 : 9 : SymbolTable_PtrToSymbol pSym;
11786 : :
11787 : 9 : pSym = GetPsym (sym);
11788 : 9 : switch (pSym->SymbolType)
11789 : : {
11790 : 9 : case SymbolTable_GnuAsmSym:
11791 : 9 : pSym->GnuAsm.Trashed = trash;
11792 : 9 : break;
11793 : :
11794 : :
11795 : 0 : default:
11796 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11797 : 9 : break;
11798 : : }
11799 : 9 : }
11800 : :
11801 : :
11802 : : /*
11803 : : GetGnuAsm - returns the string symbol, representing the instruction textual
11804 : : of the GnuAsm symbol. It will return a ConstString.
11805 : : */
11806 : :
11807 : 27 : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym)
11808 : : {
11809 : 27 : SymbolTable_PtrToSymbol pSym;
11810 : :
11811 : 27 : pSym = GetPsym (sym);
11812 : 27 : switch (pSym->SymbolType)
11813 : : {
11814 : 27 : case SymbolTable_GnuAsmSym:
11815 : 27 : return pSym->GnuAsm.String;
11816 : 0 : break;
11817 : :
11818 : :
11819 : 0 : default:
11820 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11821 : : break;
11822 : : }
11823 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11824 : : __builtin_unreachable ();
11825 : : }
11826 : :
11827 : :
11828 : : /*
11829 : : GetGnuAsmInput - returns the input list of registers.
11830 : : */
11831 : :
11832 : 27 : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym)
11833 : : {
11834 : 27 : SymbolTable_PtrToSymbol pSym;
11835 : :
11836 : 27 : pSym = GetPsym (sym);
11837 : 27 : switch (pSym->SymbolType)
11838 : : {
11839 : 27 : case SymbolTable_GnuAsmSym:
11840 : 27 : return pSym->GnuAsm.Inputs;
11841 : 0 : break;
11842 : :
11843 : :
11844 : 0 : default:
11845 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11846 : : break;
11847 : : }
11848 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11849 : : __builtin_unreachable ();
11850 : : }
11851 : :
11852 : :
11853 : : /*
11854 : : GetGnuAsmOutput - returns the output list of registers.
11855 : : */
11856 : :
11857 : 27 : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym)
11858 : : {
11859 : 27 : SymbolTable_PtrToSymbol pSym;
11860 : :
11861 : 27 : pSym = GetPsym (sym);
11862 : 27 : switch (pSym->SymbolType)
11863 : : {
11864 : 27 : case SymbolTable_GnuAsmSym:
11865 : 27 : return pSym->GnuAsm.Outputs;
11866 : 0 : break;
11867 : :
11868 : :
11869 : 0 : default:
11870 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11871 : : break;
11872 : : }
11873 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11874 : : __builtin_unreachable ();
11875 : : }
11876 : :
11877 : :
11878 : : /*
11879 : : GetGnuAsmTrash - returns the list of trashed registers.
11880 : : */
11881 : :
11882 : 27 : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym)
11883 : : {
11884 : 27 : SymbolTable_PtrToSymbol pSym;
11885 : :
11886 : 27 : pSym = GetPsym (sym);
11887 : 27 : switch (pSym->SymbolType)
11888 : : {
11889 : 27 : case SymbolTable_GnuAsmSym:
11890 : 27 : return pSym->GnuAsm.Trashed;
11891 : 0 : break;
11892 : :
11893 : :
11894 : 0 : default:
11895 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11896 : : break;
11897 : : }
11898 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11899 : : __builtin_unreachable ();
11900 : : }
11901 : :
11902 : :
11903 : : /*
11904 : : PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
11905 : : */
11906 : :
11907 : 15 : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym)
11908 : : {
11909 : 15 : SymbolTable_PtrToSymbol pSym;
11910 : :
11911 : 15 : pSym = GetPsym (Sym);
11912 : 15 : switch (pSym->SymbolType)
11913 : : {
11914 : 15 : case SymbolTable_GnuAsmSym:
11915 : 15 : pSym->GnuAsm.Volatile = true;
11916 : 15 : break;
11917 : :
11918 : :
11919 : 0 : default:
11920 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11921 : 15 : break;
11922 : : }
11923 : 15 : }
11924 : :
11925 : :
11926 : : /*
11927 : : PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
11928 : : */
11929 : :
11930 : 6 : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym)
11931 : : {
11932 : 6 : SymbolTable_PtrToSymbol pSym;
11933 : :
11934 : 6 : pSym = GetPsym (Sym);
11935 : 6 : switch (pSym->SymbolType)
11936 : : {
11937 : 6 : case SymbolTable_GnuAsmSym:
11938 : 6 : pSym->GnuAsm.Simple = true;
11939 : 6 : break;
11940 : :
11941 : :
11942 : 0 : default:
11943 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11944 : 6 : break;
11945 : : }
11946 : 6 : }
11947 : :
11948 : :
11949 : : /*
11950 : : MakeRegInterface - creates and returns a register interface symbol.
11951 : : */
11952 : :
11953 : 33 : extern "C" unsigned int SymbolTable_MakeRegInterface (void)
11954 : : {
11955 : 33 : SymbolTable_PtrToSymbol pSym;
11956 : 33 : unsigned int Sym;
11957 : :
11958 : 33 : NewSym (&Sym);
11959 : 33 : pSym = GetPsym (Sym);
11960 : 33 : pSym->SymbolType = SymbolTable_InterfaceSym;
11961 : 33 : pSym->Interface.Parameters = Indexing_InitIndex (1);
11962 : 33 : InitWhereDeclared (&pSym->Interface.At);
11963 : 33 : return Sym;
11964 : : /* static analysis guarentees a RETURN statement will be used before here. */
11965 : : __builtin_unreachable ();
11966 : : }
11967 : :
11968 : :
11969 : : /*
11970 : : PutRegInterface - places a, name, string, and, object, into the interface array,
11971 : : sym, at position, i.
11972 : : The string symbol will either be a register name or a constraint.
11973 : : The object is an optional Modula-2 variable or constant symbol.
11974 : : read and write are the quadruple numbers representing any read
11975 : : or write operation.
11976 : : */
11977 : :
11978 : 36 : extern "C" void SymbolTable_PutRegInterface (unsigned int tok, unsigned int sym, unsigned int i, NameKey_Name n, unsigned int string, unsigned int object, unsigned int read_, unsigned int write_)
11979 : : {
11980 : 36 : SymbolTable_PtrToSymbol pSym;
11981 : 36 : SymbolTable_PtrToAsmConstraint p;
11982 : :
11983 : 36 : pSym = GetPsym (sym);
11984 : 36 : switch (pSym->SymbolType)
11985 : : {
11986 : 36 : case SymbolTable_InterfaceSym:
11987 : 36 : if (Indexing_InBounds (pSym->Interface.Parameters, i))
11988 : : {
11989 : 0 : p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
11990 : : }
11991 : 36 : else if (i == ((Indexing_HighIndice (pSym->Interface.Parameters))+1))
11992 : : {
11993 : : /* avoid dangling else. */
11994 : 36 : Storage_ALLOCATE ((void **) &p, sizeof (SymbolTable__T5));
11995 : 36 : Indexing_PutIndice (pSym->Interface.Parameters, i, reinterpret_cast <void *> (p));
11996 : : }
11997 : : else
11998 : : {
11999 : : /* avoid dangling else. */
12000 : 0 : M2Error_InternalError ((const char *) "expecting to add parameters sequentially", 40);
12001 : : }
12002 : 36 : p->tokpos = tok;
12003 : 36 : p->name = n;
12004 : 36 : p->str = string;
12005 : 36 : p->obj = object;
12006 : 36 : PutFirstUsed (object, tok, read_, write_);
12007 : 36 : break;
12008 : :
12009 : :
12010 : 0 : default:
12011 : 0 : M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
12012 : 36 : break;
12013 : : }
12014 : 36 : }
12015 : :
12016 : :
12017 : : /*
12018 : : GetRegInterface - gets a, name, string, and, object, from the interface array,
12019 : : sym, from position, i.
12020 : : */
12021 : :
12022 : 69 : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object)
12023 : : {
12024 : 69 : SymbolTable_PtrToSymbol pSym;
12025 : 69 : SymbolTable_PtrToAsmConstraint p;
12026 : :
12027 : 69 : pSym = GetPsym (sym);
12028 : 69 : switch (pSym->SymbolType)
12029 : : {
12030 : 69 : case SymbolTable_InterfaceSym:
12031 : 69 : if (Indexing_InBounds (pSym->Interface.Parameters, i))
12032 : : {
12033 : 36 : p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
12034 : 36 : (*tok) = p->tokpos;
12035 : 36 : (*n) = p->name;
12036 : 36 : (*string) = p->str;
12037 : 36 : (*object) = p->obj;
12038 : : }
12039 : : else
12040 : : {
12041 : 33 : (*tok) = M2LexBuf_UnknownTokenNo;
12042 : 33 : (*n) = NameKey_NulName;
12043 : 33 : (*string) = SymbolTable_NulSym;
12044 : 33 : (*object) = SymbolTable_NulSym;
12045 : : }
12046 : 69 : break;
12047 : :
12048 : :
12049 : 0 : default:
12050 : 0 : M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
12051 : 69 : break;
12052 : : }
12053 : 69 : }
12054 : :
12055 : :
12056 : : /*
12057 : : GetModule - Returns the Module symbol for the module with name, name.
12058 : : */
12059 : :
12060 : 405424 : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name)
12061 : : {
12062 : 405424 : return static_cast<unsigned int> (SymbolKey_GetSymKey (ModuleTree, name));
12063 : : /* static analysis guarentees a RETURN statement will be used before here. */
12064 : : __builtin_unreachable ();
12065 : : }
12066 : :
12067 : :
12068 : : /*
12069 : : GetCurrentModule - returns the current module Sym that is being
12070 : : compiled.
12071 : : */
12072 : :
12073 : 59363198 : extern "C" unsigned int SymbolTable_GetCurrentModule (void)
12074 : : {
12075 : 59363198 : return CurrentModule;
12076 : : /* static analysis guarentees a RETURN statement will be used before here. */
12077 : : __builtin_unreachable ();
12078 : : }
12079 : :
12080 : :
12081 : : /*
12082 : : GetFileModule - returns the FileModule symbol that was requested by
12083 : : the user to be compiled.
12084 : : */
12085 : :
12086 : 279116 : extern "C" unsigned int SymbolTable_GetFileModule (void)
12087 : : {
12088 : 279116 : return FileModule;
12089 : : /* static analysis guarentees a RETURN statement will be used before here. */
12090 : : __builtin_unreachable ();
12091 : : }
12092 : :
12093 : :
12094 : : /*
12095 : : GetBaseModule - returns the base module symbol that contains Modula-2
12096 : : base types, procedures and functions.
12097 : : */
12098 : :
12099 : 8447257 : extern "C" unsigned int SymbolTable_GetBaseModule (void)
12100 : : {
12101 : 8447257 : return BaseModule;
12102 : : /* static analysis guarentees a RETURN statement will be used before here. */
12103 : : __builtin_unreachable ();
12104 : : }
12105 : :
12106 : :
12107 : : /*
12108 : : GetMainModule - returns the main module symbol that was requested by
12109 : : the user to be compiled.
12110 : : */
12111 : :
12112 : 20048511 : extern "C" unsigned int SymbolTable_GetMainModule (void)
12113 : : {
12114 : 20048511 : return MainModule;
12115 : : /* static analysis guarentees a RETURN statement will be used before here. */
12116 : : __builtin_unreachable ();
12117 : : }
12118 : :
12119 : :
12120 : : /*
12121 : : GetCurrentModuleScope - returns the module symbol which forms the
12122 : : current (possibly inner most) module.
12123 : : */
12124 : :
12125 : 2273726 : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void)
12126 : : {
12127 : 2273726 : SymbolTable_PtrToCallFrame pCall;
12128 : 2273726 : unsigned int i;
12129 : :
12130 : 2273726 : i = ScopePtr;
12131 : 2273726 : pCall = GetPcall (i);
12132 : 5316449 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
12133 : : {
12134 : 768997 : M2Debug_Assert (i > 0);
12135 : 768997 : i -= 1;
12136 : 768997 : pCall = GetPcall (i);
12137 : : }
12138 : 2273726 : return pCall->Search;
12139 : : /* static analysis guarentees a RETURN statement will be used before here. */
12140 : : __builtin_unreachable ();
12141 : : }
12142 : :
12143 : :
12144 : : /*
12145 : : GetLastModuleScope - returns the last module scope encountered,
12146 : : the module scope before the Current Module Scope.
12147 : : */
12148 : :
12149 : 0 : extern "C" unsigned int SymbolTable_GetLastModuleScope (void)
12150 : : {
12151 : 0 : SymbolTable_PtrToCallFrame pCall;
12152 : 0 : unsigned int i;
12153 : :
12154 : 0 : i = ScopePtr;
12155 : 0 : pCall = GetPcall (i);
12156 : 0 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
12157 : : {
12158 : 0 : M2Debug_Assert (i > 0);
12159 : 0 : i -= 1;
12160 : 0 : pCall = GetPcall (i);
12161 : : }
12162 : : /* Found module at position, i. */
12163 : 0 : i -= 1; /* Move to an outer level module scope */
12164 : 0 : pCall = GetPcall (i); /* Move to an outer level module scope */
12165 : 0 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
12166 : : {
12167 : 0 : M2Debug_Assert (i > 0);
12168 : 0 : i -= 1;
12169 : 0 : pCall = GetPcall (i);
12170 : : }
12171 : : /* Found module at position, i. */
12172 : 0 : return pCall->Search;
12173 : : /* static analysis guarentees a RETURN statement will be used before here. */
12174 : : __builtin_unreachable ();
12175 : : }
12176 : :
12177 : :
12178 : : /*
12179 : : AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
12180 : : ModSym.
12181 : : */
12182 : :
12183 : 1003858 : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym)
12184 : : {
12185 : 1003858 : SymbolTable_PtrToSymbol pSym;
12186 : :
12187 : 1003858 : pSym = GetPsym (ModSym);
12188 : 1003858 : switch (pSym->SymbolType)
12189 : : {
12190 : 886767 : case SymbolTable_DefImpSym:
12191 : 886767 : if ((SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
12192 : : {
12193 : 886767 : SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
12194 : : }
12195 : : else
12196 : : {
12197 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
12198 : : }
12199 : : break;
12200 : :
12201 : 117031 : case SymbolTable_ModuleSym:
12202 : 117031 : if ((SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
12203 : : {
12204 : 117031 : SymbolKey_PutSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
12205 : : }
12206 : : else
12207 : : {
12208 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
12209 : : }
12210 : : break;
12211 : :
12212 : 60 : case SymbolTable_ProcedureSym:
12213 : 60 : if ((SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
12214 : : {
12215 : 60 : SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
12216 : : }
12217 : : else
12218 : : {
12219 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
12220 : : }
12221 : : break;
12222 : :
12223 : :
12224 : 0 : default:
12225 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
12226 : 1003858 : break;
12227 : : }
12228 : 1003858 : }
12229 : :
12230 : :
12231 : : /*
12232 : : GetType - Returns the symbol that is the TYPE symbol to Sym.
12233 : : If zero is returned then we assume type unknown.
12234 : : */
12235 : :
12236 : 744670064 : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym)
12237 : : {
12238 : 744670064 : SymbolTable_PtrToSymbol pSym;
12239 : 744670064 : unsigned int type;
12240 : :
12241 : 744670064 : M2Debug_Assert (Sym != SymbolTable_NulSym);
12242 : 744670058 : pSym = GetPsym (Sym);
12243 : 744670058 : switch (pSym->SymbolType)
12244 : : {
12245 : 0 : case SymbolTable_OAFamilySym:
12246 : 0 : type = pSym->OAFamily.SimpleType;
12247 : 0 : break;
12248 : :
12249 : 89387639 : case SymbolTable_VarSym:
12250 : 89387639 : type = GetTypeOfVar (Sym);
12251 : 89387639 : break;
12252 : :
12253 : 22269979 : case SymbolTable_ConstLitSym:
12254 : 22269979 : type = pSym->ConstLit.Type;
12255 : 22269979 : break;
12256 : :
12257 : 21751335 : case SymbolTable_ConstVarSym:
12258 : 21751335 : type = pSym->ConstVar.Type;
12259 : 21751335 : break;
12260 : :
12261 : 5898910 : case SymbolTable_ConstStringSym:
12262 : 5898910 : if (pSym->ConstString.Length == 1)
12263 : : {
12264 : 1035235 : type = M2Base_Char;
12265 : : }
12266 : : else
12267 : : {
12268 : : type = SymbolTable_NulSym; /* No type for a string */
12269 : : }
12270 : : break;
12271 : :
12272 : 109937414 : case SymbolTable_TypeSym:
12273 : 109937414 : type = pSym->Type.Type;
12274 : 109937414 : break;
12275 : :
12276 : 243495828 : case SymbolTable_RecordFieldSym:
12277 : 243495828 : type = pSym->RecordField.Type;
12278 : 243495828 : break;
12279 : :
12280 : : case SymbolTable_RecordSym:
12281 : : type = SymbolTable_NulSym; /* No type for a record */
12282 : : break;
12283 : :
12284 : : case SymbolTable_VarientSym:
12285 : : type = SymbolTable_NulSym; /* No type for a record */
12286 : : break;
12287 : :
12288 : 44889960 : case SymbolTable_EnumerationFieldSym:
12289 : 44889960 : type = pSym->EnumerationField.Type; /* No type for a record */
12290 : 44889960 : break;
12291 : :
12292 : : case SymbolTable_EnumerationSym:
12293 : : type = SymbolTable_NulSym; /* No type for enumeration */
12294 : : break;
12295 : :
12296 : 103933286 : case SymbolTable_PointerSym:
12297 : 103933286 : type = pSym->Pointer.Type; /* No type for enumeration */
12298 : 103933286 : break;
12299 : :
12300 : 17933531 : case SymbolTable_ProcedureSym:
12301 : 17933531 : type = pSym->Procedure.ReturnType;
12302 : 17933531 : break;
12303 : :
12304 : 5295852 : case SymbolTable_ProcTypeSym:
12305 : 5295852 : type = pSym->ProcType.ReturnType;
12306 : 5295852 : break;
12307 : :
12308 : 21181444 : case SymbolTable_ParamSym:
12309 : 21181444 : type = pSym->Param.Type;
12310 : 21181444 : break;
12311 : :
12312 : 3488545 : case SymbolTable_VarParamSym:
12313 : 3488545 : type = pSym->VarParam.Type;
12314 : 3488545 : break;
12315 : :
12316 : 12091571 : case SymbolTable_SubrangeSym:
12317 : 12091571 : type = pSym->Subrange.Type;
12318 : 12091571 : break;
12319 : :
12320 : 5421728 : case SymbolTable_ArraySym:
12321 : 5421728 : type = pSym->Array.Type;
12322 : 5421728 : break;
12323 : :
12324 : 5426840 : case SymbolTable_SubscriptSym:
12325 : 5426840 : type = pSym->Subscript.Type;
12326 : 5426840 : break;
12327 : :
12328 : 568422 : case SymbolTable_SetSym:
12329 : 568422 : type = pSym->Set.Type;
12330 : 568422 : break;
12331 : :
12332 : 29508063 : case SymbolTable_UnboundedSym:
12333 : 29508063 : type = pSym->Unbounded.Type;
12334 : 29508063 : break;
12335 : :
12336 : : case SymbolTable_UndefinedSym:
12337 : : type = SymbolTable_NulSym;
12338 : : break;
12339 : :
12340 : 0 : case SymbolTable_PartialUnboundedSym:
12341 : 0 : type = pSym->PartialUnbounded.Type;
12342 : 0 : break;
12343 : :
12344 : : case SymbolTable_ObjectSym:
12345 : : type = SymbolTable_NulSym;
12346 : : break;
12347 : :
12348 : :
12349 : 0 : default:
12350 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
12351 : 744670058 : break;
12352 : : }
12353 : 744670058 : return type;
12354 : : /* static analysis guarentees a RETURN statement will be used before here. */
12355 : : __builtin_unreachable ();
12356 : : }
12357 : :
12358 : :
12359 : : /*
12360 : : SkipType - if sym is a TYPE foo = bar
12361 : : then call SkipType(bar)
12362 : : else return sym
12363 : :
12364 : : it does not skip over hidden types.
12365 : : */
12366 : :
12367 : 58327776 : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym)
12368 : : {
12369 : 58584974 : if ((((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
12370 : : {
12371 : 257198 : return SymbolTable_SkipType (SymbolTable_GetType (Sym));
12372 : : }
12373 : : else
12374 : : {
12375 : 58327776 : return Sym;
12376 : : }
12377 : : /* static analysis guarentees a RETURN statement will be used before here. */
12378 : : __builtin_unreachable ();
12379 : : }
12380 : :
12381 : :
12382 : : /*
12383 : : SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
12384 : : sym is declared as a subrange of bar
12385 : : then call SkipTypeAndSubrange(bar)
12386 : : else return sym
12387 : :
12388 : : it does not skip over hidden types.
12389 : : */
12390 : :
12391 : 4301 : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym)
12392 : : {
12393 : 4349 : if ((((Sym != SymbolTable_NulSym) && ((SymbolTable_IsType (Sym)) || (SymbolTable_IsSubrange (Sym)))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
12394 : : {
12395 : 48 : return SymbolTable_SkipTypeAndSubrange (SymbolTable_GetType (Sym));
12396 : : }
12397 : : else
12398 : : {
12399 : 4301 : return Sym;
12400 : : }
12401 : : /* static analysis guarentees a RETURN statement will be used before here. */
12402 : : __builtin_unreachable ();
12403 : : }
12404 : :
12405 : :
12406 : : /*
12407 : : GetLowestType - Returns the lowest type in the type chain of
12408 : : symbol Sym.
12409 : : If NulSym is returned then we assume type unknown or
12410 : : you have reqested the type of a base type.
12411 : : */
12412 : :
12413 : 1488018 : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym)
12414 : : {
12415 : 2528930 : SymbolTable_PtrToSymbol pSym;
12416 : 2528930 : unsigned int type;
12417 : :
12418 : 2528930 : M2Debug_Assert (Sym != SymbolTable_NulSym);
12419 : 2528930 : pSym = GetPsym (Sym);
12420 : 2528930 : switch (pSym->SymbolType)
12421 : : {
12422 : 461334 : case SymbolTable_VarSym:
12423 : 461334 : type = pSym->Var.Type;
12424 : 461334 : break;
12425 : :
12426 : 277711 : case SymbolTable_ConstLitSym:
12427 : 277711 : type = pSym->ConstLit.Type;
12428 : 277711 : break;
12429 : :
12430 : 384693 : case SymbolTable_ConstVarSym:
12431 : 384693 : type = pSym->ConstVar.Type;
12432 : 384693 : break;
12433 : :
12434 : : case SymbolTable_ConstStringSym:
12435 : : type = SymbolTable_NulSym; /* No type for a string */
12436 : : break;
12437 : :
12438 : 1064492 : case SymbolTable_TypeSym:
12439 : 1064492 : type = pSym->Type.Type; /* No type for a string */
12440 : 1064492 : break;
12441 : :
12442 : 0 : case SymbolTable_RecordFieldSym:
12443 : 0 : type = pSym->RecordField.Type;
12444 : 0 : break;
12445 : :
12446 : : case SymbolTable_RecordSym:
12447 : : type = SymbolTable_NulSym; /* No type for a record */
12448 : : break;
12449 : :
12450 : 57786 : case SymbolTable_EnumerationFieldSym:
12451 : 57786 : type = pSym->EnumerationField.Type; /* No type for a record */
12452 : 57786 : break;
12453 : :
12454 : : case SymbolTable_EnumerationSym:
12455 : : type = SymbolTable_NulSym; /* No type for enumeration */
12456 : : break;
12457 : :
12458 : : case SymbolTable_PointerSym:
12459 : 31309 : type = Sym; /* we don't go to Pointer.Type */
12460 : : break;
12461 : :
12462 : 59987 : case SymbolTable_ProcedureSym:
12463 : 59987 : type = pSym->Procedure.ReturnType; /* we don't go to Pointer.Type */
12464 : 59987 : break;
12465 : :
12466 : 12 : case SymbolTable_ProcTypeSym:
12467 : 12 : type = pSym->ProcType.ReturnType;
12468 : 12 : break;
12469 : :
12470 : 132242 : case SymbolTable_ParamSym:
12471 : 132242 : type = pSym->Param.Type;
12472 : 132242 : break;
12473 : :
12474 : 6941 : case SymbolTable_VarParamSym:
12475 : 6941 : type = pSym->VarParam.Type;
12476 : 6941 : break;
12477 : :
12478 : 48 : case SymbolTable_SubrangeSym:
12479 : 48 : type = pSym->Subrange.Type;
12480 : 48 : break;
12481 : :
12482 : 24 : case SymbolTable_ArraySym:
12483 : 24 : type = pSym->Array.Type;
12484 : 24 : break;
12485 : :
12486 : 47188 : case SymbolTable_SubscriptSym:
12487 : 47188 : type = pSym->Subscript.Type;
12488 : 47188 : break;
12489 : :
12490 : : case SymbolTable_SetSym:
12491 : 31309 : type = Sym; /* Stop at the set type. */
12492 : : break;
12493 : :
12494 : 0 : case SymbolTable_UnboundedSym:
12495 : 0 : type = pSym->Unbounded.Type; /* Stop at the set type. */
12496 : 0 : break;
12497 : :
12498 : : case SymbolTable_UndefinedSym:
12499 : : type = SymbolTable_NulSym;
12500 : : break;
12501 : :
12502 : : case SymbolTable_DummySym:
12503 : : type = SymbolTable_NulSym;
12504 : : break;
12505 : :
12506 : :
12507 : 6 : default:
12508 : 6 : M2Error_InternalError ((const char *) "not implemented yet", 19);
12509 : 2528924 : break;
12510 : : }
12511 : 2528924 : pSym = GetPsym (Sym);
12512 : 2528924 : if ((pSym->SymbolType == SymbolTable_TypeSym) && (type == SymbolTable_NulSym))
12513 : : {
12514 : : type = Sym; /* Base Type */
12515 : : }
12516 : 1486548 : else if (((type != SymbolTable_NulSym) && (SymbolTable_IsType (type))) && ((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym))
12517 : : {
12518 : : /* avoid dangling else. */
12519 : : type = SymbolTable_GetLowestType (type); /* Type def */
12520 : : }
12521 : 1488012 : return type;
12522 : : /* static analysis guarentees a RETURN statement will be used before here. */
12523 : : __builtin_unreachable ();
12524 : : }
12525 : :
12526 : :
12527 : : /*
12528 : : GetLType - get lowest type. It returns the lowest type
12529 : : of symbol, sym. It skips over type equivalences.
12530 : : It will not skip over base types.
12531 : : */
12532 : :
12533 : 8527714 : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym)
12534 : : {
12535 : : /*
12536 : : Assert (doGetType (sym, TRUE, TRUE, TRUE, FALSE) = GetLowestType (sym)) ;
12537 : : */
12538 : 8527714 : return doGetType (sym, true, true, true, false);
12539 : : /* static analysis guarentees a RETURN statement will be used before here. */
12540 : : __builtin_unreachable ();
12541 : : }
12542 : :
12543 : :
12544 : : /*
12545 : : GetSType - get source type. It returns the type closest
12546 : : to the object. It does not skip over type
12547 : : equivalences. It will skip over base types.
12548 : : */
12549 : :
12550 : 656692251 : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym)
12551 : : {
12552 : 656692251 : M2Debug_Assert ((doGetType (sym, false, false, false, true)) == (SymbolTable_GetType (sym)));
12553 : 656692251 : return doGetType (sym, false, false, false, true);
12554 : : /* static analysis guarentees a RETURN statement will be used before here. */
12555 : : __builtin_unreachable ();
12556 : : }
12557 : :
12558 : :
12559 : : /*
12560 : : GetDType - get gcc declared type. It returns the type
12561 : : of the object which is declared to GCC.
12562 : : It does skip over type equivalences but only
12563 : : if they do not contain a user alignment.
12564 : : It does not skip over hidden types.
12565 : : It does not skip over base types.
12566 : : */
12567 : :
12568 : 23919498 : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym)
12569 : : {
12570 : : /*
12571 : : Assert (doGetType (sym, TRUE, FALSE, FALSE, FALSE) = SkipType(GetType(sym))) ;
12572 : : */
12573 : 23919498 : return doGetType (sym, true, false, false, false);
12574 : : /* static analysis guarentees a RETURN statement will be used before here. */
12575 : : __builtin_unreachable ();
12576 : : }
12577 : :
12578 : :
12579 : : /*
12580 : : GetTypeMode - return the type of sym, it returns Address is the
12581 : : symbol is a LValue.
12582 : : */
12583 : :
12584 : 20742 : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym)
12585 : : {
12586 : 20742 : if ((SymbolTable_GetMode (sym)) == SymbolTable_LeftValue)
12587 : : {
12588 : 90 : return M2System_Address;
12589 : : }
12590 : : else
12591 : : {
12592 : 20652 : return SymbolTable_GetType (sym);
12593 : : }
12594 : : /* static analysis guarentees a RETURN statement will be used before here. */
12595 : : __builtin_unreachable ();
12596 : : }
12597 : :
12598 : :
12599 : : /*
12600 : : GetSym - searches the current scope (and previous scopes if the
12601 : : scope tranparent allows) for a symbol with name.
12602 : : */
12603 : :
12604 : 70580250 : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name)
12605 : : {
12606 : 70580250 : unsigned int Sym;
12607 : 70580250 : unsigned int OldScopePtr;
12608 : :
12609 : 70580250 : Sym = GetScopeSym (name, true);
12610 : 70580250 : if (Sym == SymbolTable_NulSym)
12611 : : {
12612 : : /* Check default base types for symbol */
12613 : 25018726 : OldScopePtr = ScopePtr; /* Save ScopePtr */
12614 : 25018726 : ScopePtr = BaseScopePtr; /* Alter ScopePtr to point to top of BaseModule */
12615 : 25018726 : Sym = GetScopeSym (name, false); /* Search BaseModule for name */
12616 : 25018726 : ScopePtr = OldScopePtr; /* Restored ScopePtr */
12617 : : }
12618 : 70580250 : return Sym;
12619 : : /* static analysis guarentees a RETURN statement will be used before here. */
12620 : : __builtin_unreachable ();
12621 : : }
12622 : :
12623 : :
12624 : : /*
12625 : : GetDeclareSym - searches for a symbol with a name SymName in the
12626 : : current and previous scopes.
12627 : : If the symbol is found then it is returned
12628 : : else an unknown symbol is returned.
12629 : : This procedure assumes that SymName is being
12630 : : declared at this point and therefore it does
12631 : : not examine the base scope (for pervasive
12632 : : identifiers).
12633 : : */
12634 : :
12635 : 9374396 : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName)
12636 : : {
12637 : 9374396 : unsigned int Sym;
12638 : :
12639 : 9374396 : Sym = GetScopeSym (SymName, false); /* must not be allowed to fetch a symbol through a procedure scope */
12640 : 9374396 : if (Sym == SymbolTable_NulSym) /* must not be allowed to fetch a symbol through a procedure scope */
12641 : : {
12642 : 3672934 : Sym = GetSymFromUnknownTree (SymName);
12643 : 3672934 : if (Sym == SymbolTable_NulSym)
12644 : : {
12645 : : /* Make unknown */
12646 : 3672934 : NewSym (&Sym);
12647 : 3672934 : FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
12648 : : /*
12649 : : ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
12650 : : */
12651 : 3672934 : AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
12652 : : }
12653 : : }
12654 : 9374396 : return Sym;
12655 : : /* static analysis guarentees a RETURN statement will be used before here. */
12656 : : __builtin_unreachable ();
12657 : : }
12658 : :
12659 : :
12660 : : /*
12661 : : GetLocalSym - only searches the scope Sym for a symbol with name
12662 : : and returns the index to the symbol.
12663 : : */
12664 : :
12665 : 203923380 : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name)
12666 : : {
12667 : 203923380 : SymbolTable_PtrToSymbol pSym;
12668 : 203923380 : unsigned int LocalSym;
12669 : :
12670 : : /*
12671 : : WriteString('Attempting to retrieve symbol from ') ; WriteKey(GetSymName(Sym)) ;
12672 : : WriteString(' local symbol table') ; WriteLn ;
12673 : : */
12674 : 203923380 : pSym = GetPsym (Sym);
12675 : 203923380 : switch (pSym->SymbolType)
12676 : : {
12677 : 50355012 : case SymbolTable_EnumerationSym:
12678 : 50355012 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, name));
12679 : 50355012 : break;
12680 : :
12681 : 628035 : case SymbolTable_RecordSym:
12682 : 628035 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, name));
12683 : 628035 : break;
12684 : :
12685 : 53831316 : case SymbolTable_ProcedureSym:
12686 : 53831316 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, name));
12687 : 53831316 : break;
12688 : :
12689 : 26280259 : case SymbolTable_ModuleSym:
12690 : 26280259 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, name));
12691 : 26280259 : break;
12692 : :
12693 : 72828758 : case SymbolTable_DefImpSym:
12694 : 72828758 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, name));
12695 : 72828758 : break;
12696 : :
12697 : :
12698 : 0 : default:
12699 : 0 : M2Error_InternalError ((const char *) "symbol does not have a LocalSymbols field", 41);
12700 : 203923380 : break;
12701 : : }
12702 : 203923380 : return LocalSym;
12703 : : /* static analysis guarentees a RETURN statement will be used before here. */
12704 : : __builtin_unreachable ();
12705 : : }
12706 : :
12707 : :
12708 : : /*
12709 : : GetRecord - fetches the record symbol from the parent of Sym.
12710 : : Sym maybe a varient symbol in which case its parent is searched
12711 : : etc.
12712 : : */
12713 : :
12714 : 49138 : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym)
12715 : : {
12716 : 55470 : SymbolTable_PtrToSymbol pSym;
12717 : :
12718 : 55470 : pSym = GetPsym (Sym);
12719 : 55470 : switch (pSym->SymbolType)
12720 : : {
12721 : : case SymbolTable_RecordSym:
12722 : : return Sym;
12723 : 6078 : break;
12724 : :
12725 : 6078 : case SymbolTable_VarientSym:
12726 : 6078 : return SymbolTable_GetRecord (pSym->Varient.Parent);
12727 : 254 : break;
12728 : :
12729 : 254 : case SymbolTable_VarientFieldSym:
12730 : 254 : return SymbolTable_GetRecord (pSym->VarientField.Parent);
12731 : 0 : break;
12732 : :
12733 : :
12734 : 0 : default:
12735 : 0 : M2Error_InternalError ((const char *) "expecting Record or Varient symbol", 34);
12736 : : break;
12737 : : }
12738 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12739 : : __builtin_unreachable ();
12740 : : }
12741 : :
12742 : :
12743 : : /*
12744 : : FromModuleGetSym - attempts to find a symbol of name, n, in the
12745 : : module, mod, scope. An unknown symbol is created
12746 : : at token position tok if necessary.
12747 : : */
12748 : :
12749 : 8092412 : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod)
12750 : : {
12751 : 8092412 : NameKey_Name n1;
12752 : 8092412 : unsigned int sym;
12753 : 8092412 : unsigned int OldScopePtr;
12754 : :
12755 : 8092412 : OldScopePtr = ScopePtr;
12756 : 8092412 : SymbolTable_StartScope (mod);
12757 : 8092412 : sym = SymbolTable_RequestSym (tok, n);
12758 : 8092412 : SymbolTable_EndScope ();
12759 : 8092412 : if (sym == SymbolTable_NulSym)
12760 : : {
12761 : : /* --fixme-- can sym ever be NulSym? */
12762 : 0 : n1 = SymbolTable_GetSymName (mod);
12763 : 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));
12764 : : }
12765 : 8092412 : ScopePtr = OldScopePtr;
12766 : 8092412 : return sym;
12767 : : /* static analysis guarentees a RETURN statement will be used before here. */
12768 : : __builtin_unreachable ();
12769 : : }
12770 : :
12771 : :
12772 : : /*
12773 : : GetNth - returns the n th symbol in the list associated with the scope
12774 : : of Sym. Sym may be a Module, DefImp, Procedure, Record or
12775 : : Enumeration symbol.
12776 : : */
12777 : :
12778 : 368630371 : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n)
12779 : : {
12780 : 368630371 : SymbolTable_PtrToSymbol pSym;
12781 : 368630371 : unsigned int i;
12782 : :
12783 : 368630371 : pSym = GetPsym (Sym);
12784 : 368630371 : switch (pSym->SymbolType)
12785 : : {
12786 : 282328878 : case SymbolTable_RecordSym:
12787 : 282328878 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, n));
12788 : 282328878 : break;
12789 : :
12790 : 2869694 : case SymbolTable_VarientSym:
12791 : 2869694 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Varient.ListOfSons, n));
12792 : 2869694 : break;
12793 : :
12794 : 5167890 : case SymbolTable_VarientFieldSym:
12795 : 5167890 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->VarientField.ListOfSons, n));
12796 : 5167890 : break;
12797 : :
12798 : 76636328 : case SymbolTable_ProcedureSym:
12799 : 76636328 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.ListOfVars, n));
12800 : 76636328 : break;
12801 : :
12802 : 642928 : case SymbolTable_DefImpSym:
12803 : 642928 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfVars, n));
12804 : 642928 : break;
12805 : :
12806 : 564584 : case SymbolTable_ModuleSym:
12807 : 564584 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfVars, n));
12808 : 564584 : break;
12809 : :
12810 : 47636 : case SymbolTable_TupleSym:
12811 : 47636 : i = GetFromIndex (pSym->Tuple.list, n);
12812 : 47636 : break;
12813 : :
12814 : 372415 : case SymbolTable_VarSym:
12815 : 372415 : i = GetNthFromComponent (Sym, n);
12816 : 372415 : break;
12817 : :
12818 : 18 : case SymbolTable_EnumerationSym:
12819 : 18 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Enumeration.ListOfFields, n));
12820 : 18 : break;
12821 : :
12822 : :
12823 : 0 : default:
12824 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
12825 : 368630371 : break;
12826 : : }
12827 : 368630371 : return i;
12828 : : /* static analysis guarentees a RETURN statement will be used before here. */
12829 : : __builtin_unreachable ();
12830 : : }
12831 : :
12832 : :
12833 : : /*
12834 : : GetNthParam - returns the n th parameter of a procedure Sym.
12835 : : */
12836 : :
12837 : 53168341 : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
12838 : : {
12839 : 53168341 : SymbolTable_PtrToSymbol pSym;
12840 : 53168341 : unsigned int i;
12841 : :
12842 : 53168341 : if (ParamNo == 0)
12843 : : {
12844 : : /* The return type of the function */
12845 : 0 : i = SymbolTable_GetType (Sym);
12846 : : }
12847 : : else
12848 : : {
12849 : 53168341 : pSym = GetPsym (Sym);
12850 : 53168341 : switch (pSym->SymbolType)
12851 : : {
12852 : 44250177 : case SymbolTable_ProcedureSym:
12853 : 44250177 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo));
12854 : 44250177 : break;
12855 : :
12856 : 8918164 : case SymbolTable_ProcTypeSym:
12857 : 8918164 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, ParamNo));
12858 : 8918164 : break;
12859 : :
12860 : :
12861 : 0 : default:
12862 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym or ProcTypeSym", 37);
12863 : 53168341 : break;
12864 : : }
12865 : : }
12866 : 53168341 : return i;
12867 : : /* static analysis guarentees a RETURN statement will be used before here. */
12868 : : __builtin_unreachable ();
12869 : : }
12870 : :
12871 : :
12872 : : /*
12873 : : GetVarScope - returns the symbol which is the scope of variable Sym.
12874 : : ie a Module, DefImp or Procedure Symbol.
12875 : : */
12876 : :
12877 : 20794 : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym)
12878 : : {
12879 : 20794 : SymbolTable_PtrToSymbol pSym;
12880 : :
12881 : 20794 : pSym = GetPsym (Sym);
12882 : 20794 : switch (pSym->SymbolType)
12883 : : {
12884 : : case SymbolTable_ErrorSym:
12885 : : return SymbolTable_NulSym;
12886 : 20794 : break;
12887 : :
12888 : 20794 : case SymbolTable_VarSym:
12889 : 20794 : return pSym->Var.Scope;
12890 : 0 : break;
12891 : :
12892 : :
12893 : 0 : default:
12894 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
12895 : : break;
12896 : : }
12897 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12898 : : __builtin_unreachable ();
12899 : : }
12900 : :
12901 : :
12902 : : /*
12903 : : GetSubrange - returns HighSym and LowSym - two constants which make up the
12904 : : subrange.
12905 : : */
12906 : :
12907 : 26240758 : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym)
12908 : : {
12909 : 26240758 : SymbolTable_PtrToSymbol pSym;
12910 : :
12911 : 26240758 : pSym = GetPsym (Sym);
12912 : 26240758 : switch (pSym->SymbolType)
12913 : : {
12914 : 26240758 : case SymbolTable_SubrangeSym:
12915 : 26240758 : (*HighSym) = pSym->Subrange.High;
12916 : 26240758 : (*LowSym) = pSym->Subrange.Low;
12917 : 26240758 : break;
12918 : :
12919 : :
12920 : 0 : default:
12921 : 0 : M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
12922 : 26240758 : break;
12923 : : }
12924 : 26240758 : }
12925 : :
12926 : :
12927 : : /*
12928 : : GetParam - returns the ParamNo parameter from procedure ProcSym
12929 : : */
12930 : :
12931 : 9245609 : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo)
12932 : : {
12933 : 9245609 : AssertInRange (Sym);
12934 : 9245609 : if (ParamNo == 0)
12935 : : {
12936 : : /* Parameter Zero is the return argument for the Function */
12937 : 0 : return SymbolTable_GetType (Sym);
12938 : : }
12939 : : else
12940 : : {
12941 : 9245609 : return SymbolTable_GetNthParamAny (Sym, ParamNo);
12942 : : }
12943 : : /* static analysis guarentees a RETURN statement will be used before here. */
12944 : : __builtin_unreachable ();
12945 : : }
12946 : :
12947 : :
12948 : : /*
12949 : : GetString - returns the contents of the string symbol sym, note that
12950 : : this is not the same as GetName (unless it was a literal).
12951 : : */
12952 : :
12953 : 490759 : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym)
12954 : : {
12955 : 490759 : SymbolTable_PtrToSymbol pSym;
12956 : :
12957 : 490759 : pSym = GetPsym (Sym);
12958 : 490759 : switch (pSym->SymbolType)
12959 : : {
12960 : 490759 : case SymbolTable_ConstStringSym:
12961 : 490759 : if (pSym->ConstString.Known)
12962 : : {
12963 : 490759 : return pSym->ConstString.Contents;
12964 : : }
12965 : : else
12966 : : {
12967 : 0 : M2Error_InternalError ((const char *) "const string contents are unknown", 33);
12968 : : }
12969 : 0 : break;
12970 : :
12971 : :
12972 : 0 : default:
12973 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
12974 : : break;
12975 : : }
12976 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12977 : : __builtin_unreachable ();
12978 : : }
12979 : :
12980 : :
12981 : : /*
12982 : : GetStringLength - returns the length of the string symbol Sym.
12983 : : */
12984 : :
12985 : 984240 : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym)
12986 : : {
12987 : 984240 : SymbolTable_PtrToSymbol pSym;
12988 : :
12989 : 984240 : pSym = GetPsym (sym);
12990 : 984240 : switch (pSym->SymbolType)
12991 : : {
12992 : 984240 : case SymbolTable_ConstStringSym:
12993 : 984240 : if (pSym->ConstString.Known)
12994 : : {
12995 : 984240 : return pSym->ConstString.Length;
12996 : : }
12997 : : else
12998 : : {
12999 : 0 : M2MetaError_MetaErrorT0 (tok, (const char *) "const string contents are unknown", 33);
13000 : 0 : return 0;
13001 : : }
13002 : 0 : break;
13003 : :
13004 : :
13005 : 0 : default:
13006 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
13007 : : break;
13008 : : }
13009 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13010 : : __builtin_unreachable ();
13011 : : }
13012 : :
13013 : :
13014 : : /*
13015 : : GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
13016 : : */
13017 : :
13018 : 21466 : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym)
13019 : : {
13020 : 21466 : SymbolTable_PtrToSymbol pSym;
13021 : :
13022 : 21466 : pSym = GetPsym (Sym);
13023 : 21466 : switch (pSym->SymbolType)
13024 : : {
13025 : 21466 : case SymbolTable_ProcedureSym:
13026 : 21466 : return pSym->Procedure.BuiltinName;
13027 : 0 : break;
13028 : :
13029 : :
13030 : 0 : default:
13031 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13032 : : break;
13033 : : }
13034 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13035 : : __builtin_unreachable ();
13036 : : }
13037 : :
13038 : :
13039 : : /*
13040 : : PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
13041 : : */
13042 : :
13043 : 879692 : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name)
13044 : : {
13045 : 879692 : SymbolTable_PtrToSymbol pSym;
13046 : :
13047 : 879692 : pSym = GetPsym (Sym);
13048 : 879692 : switch (pSym->SymbolType)
13049 : : {
13050 : 879692 : case SymbolTable_ProcedureSym:
13051 : 879692 : pSym->Procedure.BuiltinName = name;
13052 : 879692 : pSym->Procedure.IsBuiltin = true;
13053 : : /* we use the same extra pass method as hidden types for builtins */
13054 : 879692 : SymbolTable_PutHiddenTypeDeclared ();
13055 : 879692 : break;
13056 : :
13057 : :
13058 : 0 : default:
13059 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13060 : 879692 : break;
13061 : : }
13062 : 879692 : }
13063 : :
13064 : :
13065 : : /*
13066 : : IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
13067 : : */
13068 : :
13069 : 1208225 : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym)
13070 : : {
13071 : 1208225 : SymbolTable_PtrToSymbol pSym;
13072 : :
13073 : 1208225 : pSym = GetPsym (Sym);
13074 : 1208225 : switch (pSym->SymbolType)
13075 : : {
13076 : 1208225 : case SymbolTable_ProcedureSym:
13077 : 1208225 : return pSym->Procedure.IsBuiltin;
13078 : 0 : break;
13079 : :
13080 : :
13081 : 0 : default:
13082 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13083 : : break;
13084 : : }
13085 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13086 : : __builtin_unreachable ();
13087 : : }
13088 : :
13089 : :
13090 : : /*
13091 : : PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
13092 : : */
13093 : :
13094 : 0 : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym)
13095 : : {
13096 : 0 : SymbolTable_PtrToSymbol pSym;
13097 : :
13098 : 0 : pSym = GetPsym (Sym);
13099 : 0 : switch (pSym->SymbolType)
13100 : : {
13101 : 0 : case SymbolTable_ProcedureSym:
13102 : 0 : pSym->Procedure.IsInline = true;
13103 : 0 : break;
13104 : :
13105 : :
13106 : 0 : default:
13107 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13108 : 0 : break;
13109 : : }
13110 : 0 : }
13111 : :
13112 : 77770 : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym)
13113 : : {
13114 : 77770 : SymbolTable_PtrToSymbol pSym;
13115 : :
13116 : : /*
13117 : : IsProcedureBuiltin - returns TRUE if this procedure was declared as inlined.
13118 : : */
13119 : 77770 : pSym = GetPsym (Sym);
13120 : 77770 : switch (pSym->SymbolType)
13121 : : {
13122 : 77770 : case SymbolTable_ProcedureSym:
13123 : 77770 : return pSym->Procedure.IsInline;
13124 : 0 : break;
13125 : :
13126 : :
13127 : 0 : default:
13128 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
13129 : : break;
13130 : : }
13131 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13132 : : __builtin_unreachable ();
13133 : : }
13134 : :
13135 : :
13136 : : /*
13137 : : PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
13138 : : sym, indicating that this block as an EXCEPT
13139 : : statement sequence.
13140 : : */
13141 : :
13142 : 222 : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym)
13143 : : {
13144 : 222 : SymbolTable_PtrToSymbol pSym;
13145 : :
13146 : 222 : pSym = GetPsym (sym);
13147 : 222 : switch (pSym->SymbolType)
13148 : : {
13149 : 168 : case SymbolTable_ProcedureSym:
13150 : 168 : pSym->Procedure.ExceptionBlock = true;
13151 : 168 : break;
13152 : :
13153 : 54 : case SymbolTable_ModuleSym:
13154 : 54 : pSym->Module.ExceptionBlock = true;
13155 : 54 : break;
13156 : :
13157 : 0 : case SymbolTable_DefImpSym:
13158 : 0 : pSym->DefImp.ExceptionBlock = true;
13159 : 0 : break;
13160 : :
13161 : :
13162 : 0 : default:
13163 : 0 : M2Error_InternalError ((const char *) "expecting Procedure", 19);
13164 : 222 : break;
13165 : : }
13166 : 222 : }
13167 : :
13168 : :
13169 : : /*
13170 : : HasExceptionBlock - returns a BOOLEAN determining whether
13171 : : module/procedure/defimp, sym, has
13172 : : an EXCEPT statement sequence.
13173 : : */
13174 : :
13175 : 325360 : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym)
13176 : : {
13177 : 325360 : SymbolTable_PtrToSymbol pSym;
13178 : :
13179 : 325360 : pSym = GetPsym (sym);
13180 : 325360 : switch (pSym->SymbolType)
13181 : : {
13182 : 159876 : case SymbolTable_ProcedureSym:
13183 : 159876 : return pSym->Procedure.ExceptionBlock;
13184 : 23718 : break;
13185 : :
13186 : 23718 : case SymbolTable_ModuleSym:
13187 : 23718 : return pSym->Module.ExceptionBlock;
13188 : 141766 : break;
13189 : :
13190 : 141766 : case SymbolTable_DefImpSym:
13191 : 141766 : return pSym->DefImp.ExceptionBlock;
13192 : 0 : break;
13193 : :
13194 : :
13195 : 0 : default:
13196 : 0 : M2Error_InternalError ((const char *) "expecting Procedure", 19);
13197 : : break;
13198 : : }
13199 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13200 : : __builtin_unreachable ();
13201 : : }
13202 : :
13203 : :
13204 : : /*
13205 : : PutExceptionFinally - sets a BOOLEAN in block module/defimp,
13206 : : sym, indicating that this FINALLY block
13207 : : as an EXCEPT statement sequence.
13208 : : */
13209 : :
13210 : 0 : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym)
13211 : : {
13212 : 0 : SymbolTable_PtrToSymbol pSym;
13213 : :
13214 : 0 : pSym = GetPsym (sym);
13215 : 0 : switch (pSym->SymbolType)
13216 : : {
13217 : 0 : case SymbolTable_ProcedureSym:
13218 : 0 : pSym->Procedure.ExceptionFinally = true;
13219 : 0 : break;
13220 : :
13221 : 0 : case SymbolTable_ModuleSym:
13222 : 0 : pSym->Module.ExceptionFinally = true;
13223 : 0 : break;
13224 : :
13225 : 0 : case SymbolTable_DefImpSym:
13226 : 0 : pSym->DefImp.ExceptionFinally = true;
13227 : 0 : break;
13228 : :
13229 : :
13230 : 0 : default:
13231 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
13232 : 0 : break;
13233 : : }
13234 : 0 : }
13235 : :
13236 : :
13237 : : /*
13238 : : HasExceptionFinally - returns a BOOLEAN determining whether
13239 : : module/defimp, sym, has
13240 : : an EXCEPT statement sequence.
13241 : : */
13242 : :
13243 : 31176 : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym)
13244 : : {
13245 : 31176 : SymbolTable_PtrToSymbol pSym;
13246 : :
13247 : 31176 : pSym = GetPsym (sym);
13248 : 31176 : switch (pSym->SymbolType)
13249 : : {
13250 : 0 : case SymbolTable_ProcedureSym:
13251 : 0 : return pSym->Procedure.ExceptionFinally;
13252 : 23558 : break;
13253 : :
13254 : 23558 : case SymbolTable_ModuleSym:
13255 : 23558 : return pSym->Module.ExceptionFinally;
13256 : 7618 : break;
13257 : :
13258 : 7618 : case SymbolTable_DefImpSym:
13259 : 7618 : return pSym->DefImp.ExceptionFinally;
13260 : 0 : break;
13261 : :
13262 : :
13263 : 0 : default:
13264 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
13265 : : break;
13266 : : }
13267 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13268 : : __builtin_unreachable ();
13269 : : }
13270 : :
13271 : :
13272 : : /*
13273 : : PutVar - gives the VarSym symbol Sym a type Type.
13274 : : */
13275 : :
13276 : 1457034 : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType)
13277 : : {
13278 : 1457034 : SymbolTable_PtrToSymbol pSym;
13279 : :
13280 : 1457034 : pSym = GetPsym (Sym);
13281 : 1457034 : switch (pSym->SymbolType)
13282 : : {
13283 : 569724 : case SymbolTable_VarSym:
13284 : 569724 : pSym->Var.Type = VarType;
13285 : 569724 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), Sym);
13286 : 569724 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), Sym);
13287 : 569724 : break;
13288 : :
13289 : 887310 : case SymbolTable_ConstVarSym:
13290 : 887310 : pSym->ConstVar.Type = VarType;
13291 : 887310 : break;
13292 : :
13293 : :
13294 : 0 : default:
13295 : 0 : M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
13296 : 1457034 : break;
13297 : : }
13298 : 1457034 : }
13299 : :
13300 : :
13301 : : /*
13302 : : PutVarTok - gives the VarSym symbol Sym a type Type at typetok.
13303 : : */
13304 : :
13305 : 10539084 : extern "C" void SymbolTable_PutVarTok (unsigned int Sym, unsigned int VarType, unsigned int typetok)
13306 : : {
13307 : 10539084 : SymbolTable_PtrToSymbol pSym;
13308 : :
13309 : 10539084 : pSym = GetPsym (Sym);
13310 : 10539084 : switch (pSym->SymbolType)
13311 : : {
13312 : 10539072 : case SymbolTable_VarSym:
13313 : 10539072 : pSym->Var.Type = VarType;
13314 : 10539072 : pSym->Var.Declared.TypeTok = typetok;
13315 : 10539072 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), Sym);
13316 : 10539072 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), Sym);
13317 : 10539072 : break;
13318 : :
13319 : 0 : case SymbolTable_ConstVarSym:
13320 : 0 : pSym->ConstVar.Type = VarType;
13321 : 0 : break;
13322 : :
13323 : :
13324 : 12 : default:
13325 : 12 : M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
13326 : 10539072 : break;
13327 : : }
13328 : 10539072 : }
13329 : :
13330 : :
13331 : : /*
13332 : : PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
13333 : : The variable must be a LeftValue.
13334 : : */
13335 : :
13336 : 75975 : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType)
13337 : : {
13338 : 75975 : SymbolTable_PtrToSymbol pSym;
13339 : :
13340 : 75975 : M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue);
13341 : 75975 : pSym = GetPsym (Sym);
13342 : 75975 : switch (pSym->SymbolType)
13343 : : {
13344 : 75975 : case SymbolTable_VarSym:
13345 : 75975 : pSym->Var.Type = FrontType;
13346 : 75975 : pSym->Var.BackType = BackType;
13347 : 75975 : SymbolTable_PushSize (M2System_Address);
13348 : 75975 : M2ALU_PopInto (pSym->Var.Size);
13349 : 75975 : break;
13350 : :
13351 : :
13352 : 0 : default:
13353 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
13354 : 75975 : break;
13355 : : }
13356 : 75975 : }
13357 : :
13358 : :
13359 : : /*
13360 : : GetVarBackEndType - returns the back end type if specified.
13361 : : */
13362 : :
13363 : 1111975 : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym)
13364 : : {
13365 : 1111975 : SymbolTable_PtrToSymbol pSym;
13366 : :
13367 : 1111975 : M2Debug_Assert (Sym != SymbolTable_NulSym);
13368 : 1111975 : pSym = GetPsym (Sym);
13369 : 1111975 : switch (pSym->SymbolType)
13370 : : {
13371 : 1111975 : case SymbolTable_VarSym:
13372 : 1111975 : return pSym->Var.BackType;
13373 : : break;
13374 : :
13375 : :
13376 : : default:
13377 : : return SymbolTable_NulSym;
13378 : : break;
13379 : : }
13380 : : /* static analysis guarentees a RETURN statement will be used before here. */
13381 : : __builtin_unreachable ();
13382 : : }
13383 : :
13384 : :
13385 : : /*
13386 : : PutVarPointerCheck - marks variable, sym, as requiring (or not
13387 : : depending upon the, value), a NIL pointer check
13388 : : when this symbol is dereferenced.
13389 : : */
13390 : :
13391 : 39614 : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value)
13392 : : {
13393 : 39614 : SymbolTable_PtrToSymbol pSym;
13394 : :
13395 : 39614 : if (SymbolTable_IsVar (sym))
13396 : : {
13397 : 39608 : pSym = GetPsym (sym);
13398 : 39608 : pSym->Var.IsPointerCheck = value;
13399 : : }
13400 : 39614 : }
13401 : :
13402 : :
13403 : : /*
13404 : : GetVarPointerCheck - returns TRUE if this symbol is a variable and
13405 : : has been marked as needing a pointer via NIL check.
13406 : : */
13407 : :
13408 : 79714 : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym)
13409 : : {
13410 : 79714 : SymbolTable_PtrToSymbol pSym;
13411 : :
13412 : 79714 : if (SymbolTable_IsVar (sym))
13413 : : {
13414 : 79714 : pSym = GetPsym (sym);
13415 : 79714 : return pSym->Var.IsPointerCheck;
13416 : : }
13417 : : return false;
13418 : : /* static analysis guarentees a RETURN statement will be used before here. */
13419 : : __builtin_unreachable ();
13420 : : }
13421 : :
13422 : :
13423 : : /*
13424 : : PutVarWritten - marks variable, sym, as being written to (or not
13425 : : depending upon the, value).
13426 : : */
13427 : :
13428 : 12577 : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value)
13429 : : {
13430 : 12577 : SymbolTable_PtrToSymbol pSym;
13431 : :
13432 : 12577 : if (SymbolTable_IsVar (sym))
13433 : : {
13434 : 12577 : pSym = GetPsym (sym);
13435 : 12577 : pSym->Var.IsWritten = value;
13436 : : }
13437 : 12577 : }
13438 : :
13439 : :
13440 : : /*
13441 : : GetVarWritten - returns TRUE if this symbol is a variable and
13442 : : has been marked as being written.
13443 : : */
13444 : :
13445 : 89975 : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym)
13446 : : {
13447 : 89975 : SymbolTable_PtrToSymbol pSym;
13448 : :
13449 : 89975 : pSym = GetPsym (sym);
13450 : 89975 : switch (pSym->SymbolType)
13451 : : {
13452 : 89975 : case SymbolTable_VarSym:
13453 : 89975 : return pSym->Var.IsWritten;
13454 : 0 : break;
13455 : :
13456 : :
13457 : 0 : default:
13458 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
13459 : : break;
13460 : : }
13461 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13462 : : __builtin_unreachable ();
13463 : : }
13464 : :
13465 : :
13466 : : /*
13467 : : PutConst - gives the constant symbol Sym a type ConstType.
13468 : : */
13469 : :
13470 : 427057 : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType)
13471 : : {
13472 : 427057 : SymbolTable_PtrToSymbol pSym;
13473 : :
13474 : 427057 : pSym = GetPsym (Sym);
13475 : 427057 : CheckBreak (Sym);
13476 : 427057 : switch (pSym->SymbolType)
13477 : : {
13478 : 427057 : case SymbolTable_ConstVarSym:
13479 : 427057 : pSym->ConstVar.Type = ConstType;
13480 : 427057 : break;
13481 : :
13482 : :
13483 : 0 : default:
13484 : 0 : M2Error_InternalError ((const char *) "expecting ConstVarSym", 21);
13485 : 427057 : break;
13486 : : }
13487 : 427057 : }
13488 : :
13489 : :
13490 : : /*
13491 : : PutConstSet - informs the const var symbol, sym, that it is or will contain
13492 : : a set value.
13493 : : */
13494 : :
13495 : 49376 : extern "C" void SymbolTable_PutConstSet (unsigned int Sym)
13496 : : {
13497 : 49376 : SymbolTable_PtrToSymbol pSym;
13498 : :
13499 : 49376 : pSym = GetPsym (Sym);
13500 : 49376 : switch (pSym->SymbolType)
13501 : : {
13502 : 49376 : case SymbolTable_ConstVarSym:
13503 : 49376 : pSym->ConstVar.IsSet = true;
13504 : 49376 : break;
13505 : :
13506 : 0 : case SymbolTable_ConstLitSym:
13507 : 0 : pSym->ConstLit.IsSet = true;
13508 : 0 : break;
13509 : :
13510 : :
13511 : 0 : default:
13512 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar symbol", 25);
13513 : 49376 : break;
13514 : : }
13515 : 49376 : }
13516 : :
13517 : :
13518 : : /*
13519 : : IsConstSet - returns TRUE if the constant is declared as a set.
13520 : : */
13521 : :
13522 : 81576013 : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym)
13523 : : {
13524 : 81576013 : SymbolTable_PtrToSymbol pSym;
13525 : :
13526 : 81576013 : pSym = GetPsym (Sym);
13527 : 81576013 : switch (pSym->SymbolType)
13528 : : {
13529 : 13915120 : case SymbolTable_ConstVarSym:
13530 : 13915120 : return pSym->ConstVar.IsSet;
13531 : 19940330 : break;
13532 : :
13533 : 19940330 : case SymbolTable_ConstLitSym:
13534 : 19940330 : return pSym->ConstLit.IsSet;
13535 : : break;
13536 : :
13537 : :
13538 : : default:
13539 : : return false;
13540 : : break;
13541 : : }
13542 : : /* static analysis guarentees a RETURN statement will be used before here. */
13543 : : __builtin_unreachable ();
13544 : : }
13545 : :
13546 : :
13547 : : /*
13548 : : PutConstructor - informs the const var symbol, sym, that it is or
13549 : : will contain a constructor (record, set or array)
13550 : : value.
13551 : : */
13552 : :
13553 : 41544 : extern "C" void SymbolTable_PutConstructor (unsigned int Sym)
13554 : : {
13555 : 41544 : SymbolTable_PtrToSymbol pSym;
13556 : :
13557 : 41544 : pSym = GetPsym (Sym);
13558 : 41544 : switch (pSym->SymbolType)
13559 : : {
13560 : 41544 : case SymbolTable_ConstVarSym:
13561 : 41544 : pSym->ConstVar.IsConstructor = true;
13562 : 41544 : break;
13563 : :
13564 : 0 : case SymbolTable_ConstLitSym:
13565 : 0 : pSym->ConstLit.IsConstructor = true;
13566 : 0 : break;
13567 : :
13568 : :
13569 : 0 : default:
13570 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
13571 : 41544 : break;
13572 : : }
13573 : 41544 : }
13574 : :
13575 : :
13576 : : /*
13577 : : PutConstructorFrom - sets the from type field in constructor,
13578 : : Sym, to, from.
13579 : : */
13580 : :
13581 : 36688 : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from)
13582 : : {
13583 : 36688 : SymbolTable_PtrToSymbol pSym;
13584 : :
13585 : 36688 : pSym = GetPsym (Sym);
13586 : 36688 : switch (pSym->SymbolType)
13587 : : {
13588 : 36688 : case SymbolTable_ConstVarSym:
13589 : 36688 : pSym->ConstVar.FromType = from;
13590 : 36688 : pSym->ConstVar.UnresFromType = true;
13591 : 36688 : break;
13592 : :
13593 : 0 : case SymbolTable_ConstLitSym:
13594 : 0 : pSym->ConstLit.FromType = from;
13595 : 0 : pSym->ConstLit.UnresFromType = true;
13596 : 0 : break;
13597 : :
13598 : :
13599 : 0 : default:
13600 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
13601 : 36688 : break;
13602 : : }
13603 : 36688 : Lists_IncludeItemIntoList (UnresolvedConstructorType, Sym);
13604 : 36688 : }
13605 : :
13606 : :
13607 : : /*
13608 : : PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
13609 : : VarSym is a optional varient symbol which can be returned
13610 : : by a call to GetVarient(fieldsymbol). The created field
13611 : : is returned.
13612 : : */
13613 : :
13614 : 407758 : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym)
13615 : : {
13616 : 407758 : SymbolTable_PtrToSymbol oSym;
13617 : 407758 : SymbolTable_PtrToSymbol pSym;
13618 : 407758 : unsigned int esym;
13619 : 407758 : unsigned int ParSym;
13620 : 407758 : unsigned int SonSym;
13621 : :
13622 : 407758 : NewSym (&SonSym); /* Cannot be used before declared since use occurs */
13623 : : /* ensure that it is connected its parent. */
13624 : 407758 : pSym = GetPsym (Sym);
13625 : 407758 : switch (pSym->SymbolType)
13626 : : {
13627 : 401680 : case SymbolTable_RecordSym:
13628 : 401680 : Lists_PutItemIntoList (pSym->Record.ListOfSons, SonSym);
13629 : 401680 : M2Debug_Assert (Lists_IsItemInList (pSym->Record.ListOfSons, SonSym));
13630 : : /* Ensure that the Field is in the Parents Local Symbols */
13631 : 401680 : if (FieldName != NameKey_NulName)
13632 : : {
13633 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
13634 : 401650 : if ((SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName)) == SymbolKey_NulKey)
13635 : : {
13636 : 401650 : SymbolKey_PutSymKey (pSym->Record.LocalSymbols, FieldName, SonSym);
13637 : : }
13638 : : else
13639 : : {
13640 : 0 : esym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName));
13641 : 0 : M2MetaError_MetaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, esym);
13642 : : }
13643 : : }
13644 : : CheckRecordConsistency (Sym);
13645 : : break;
13646 : :
13647 : 6078 : case SymbolTable_VarientFieldSym:
13648 : 6078 : Lists_PutItemIntoList (pSym->VarientField.ListOfSons, SonSym);
13649 : 6078 : ParSym = SymbolTable_GetRecord (pSym->VarientField.Parent);
13650 : 6078 : oSym = GetPsym (ParSym);
13651 : 6078 : M2Debug_Assert (oSym->SymbolType == SymbolTable_RecordSym);
13652 : 6078 : if (FieldName != NameKey_NulName)
13653 : : {
13654 : 6066 : oSym = GetPsym (ParSym);
13655 : 6066 : SymbolKey_PutSymKey (oSym->Record.LocalSymbols, FieldName, SonSym);
13656 : : }
13657 : : break;
13658 : :
13659 : :
13660 : 0 : default:
13661 : 0 : M2Error_InternalError ((const char *) "expecting Record symbol", 23);
13662 : 407758 : break;
13663 : : }
13664 : : /* Fill in SonSym */
13665 : 407758 : oSym = GetPsym (SonSym);
13666 : 407758 : oSym->SymbolType = SymbolTable_RecordFieldSym;
13667 : 407758 : oSym->RecordField.Type = FieldType;
13668 : 407758 : oSym->RecordField.name = FieldName;
13669 : 407758 : oSym->RecordField.Tag = false;
13670 : 407758 : oSym->RecordField.Parent = Sym;
13671 : 407758 : oSym->RecordField.Varient = VarSym;
13672 : 407758 : oSym->RecordField.Align = SymbolTable_NulSym;
13673 : 407758 : oSym->RecordField.Used = true;
13674 : 407758 : oSym->RecordField.DeclPacked = false; /* not known as packed (yet). */
13675 : 407758 : oSym->RecordField.DeclResolved = false; /* not known as packed (yet). */
13676 : 407758 : oSym->RecordField.Scope = SymbolTable_GetScope (Sym);
13677 : 407758 : oSym->RecordField.Size = M2ALU_InitValue ();
13678 : 407758 : oSym->RecordField.Offset = M2ALU_InitValue ();
13679 : 407758 : InitWhereDeclared (&oSym->RecordField.At);
13680 : 407758 : return SonSym;
13681 : : /* static analysis guarentees a RETURN statement will be used before here. */
13682 : : __builtin_unreachable ();
13683 : : }
13684 : :
13685 : :
13686 : : /*
13687 : : PutFieldVarient - places the field varient, Field, as a brother to, the
13688 : : varient symbol, sym, and also tells Field that its varient
13689 : : parent is Sym.
13690 : : */
13691 : :
13692 : 12060 : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym)
13693 : : {
13694 : 12060 : SymbolTable_PtrToSymbol pSym;
13695 : :
13696 : 12060 : M2Debug_Assert (SymbolTable_IsVarient (Sym));
13697 : 12060 : M2Debug_Assert (SymbolTable_IsFieldVarient (Field));
13698 : 12060 : pSym = GetPsym (Sym);
13699 : 12060 : switch (pSym->SymbolType)
13700 : : {
13701 : 12060 : case SymbolTable_VarientSym:
13702 : 12060 : Lists_IncludeItemIntoList (pSym->Varient.ListOfSons, Field);
13703 : 12060 : break;
13704 : :
13705 : :
13706 : 0 : default:
13707 : 0 : M2Error_InternalError ((const char *) "expecting Varient symbol", 24);
13708 : 12060 : break;
13709 : : }
13710 : 12060 : pSym = GetPsym (Field);
13711 : 12060 : switch (pSym->SymbolType)
13712 : : {
13713 : 12060 : case SymbolTable_VarientFieldSym:
13714 : 12060 : pSym->VarientField.Varient = Sym;
13715 : 12060 : break;
13716 : :
13717 : :
13718 : 0 : default:
13719 : 0 : M2Error_InternalError ((const char *) "expecting VarientField symbol", 29);
13720 : 12060 : break;
13721 : : }
13722 : 12060 : }
13723 : :
13724 : :
13725 : : /*
13726 : : GetVarient - returns the varient symbol associated with the
13727 : : record or varient field symbol, Field.
13728 : : */
13729 : :
13730 : 233385744 : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field)
13731 : : {
13732 : 233385744 : SymbolTable_PtrToSymbol pSym;
13733 : :
13734 : 233385744 : pSym = GetPsym (Field);
13735 : 233385744 : switch (pSym->SymbolType)
13736 : : {
13737 : 0 : case SymbolTable_VarientFieldSym:
13738 : 0 : return pSym->VarientField.Varient;
13739 : 232852544 : break;
13740 : :
13741 : 232852544 : case SymbolTable_RecordFieldSym:
13742 : 232852544 : return pSym->RecordField.Varient;
13743 : 533200 : break;
13744 : :
13745 : 533200 : case SymbolTable_VarientSym:
13746 : 533200 : return pSym->Varient.Varient;
13747 : : break;
13748 : :
13749 : :
13750 : : default:
13751 : : return SymbolTable_NulSym;
13752 : : break;
13753 : : }
13754 : : /* static analysis guarentees a RETURN statement will be used before here. */
13755 : : __builtin_unreachable ();
13756 : : }
13757 : :
13758 : :
13759 : : /*
13760 : : IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
13761 : : a varient tag.
13762 : : */
13763 : :
13764 : 3400250 : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym)
13765 : : {
13766 : 3400250 : SymbolTable_PtrToSymbol pSym;
13767 : :
13768 : 3400250 : if (SymbolTable_IsRecordField (sym))
13769 : : {
13770 : 3400250 : pSym = GetPsym (sym);
13771 : 3400250 : return pSym->RecordField.Tag;
13772 : : }
13773 : : else
13774 : : {
13775 : 0 : M2Error_InternalError ((const char *) "record field symbol expected", 28);
13776 : : }
13777 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13778 : : __builtin_unreachable ();
13779 : : }
13780 : :
13781 : :
13782 : : /*
13783 : : IsEmptyFieldVarient - returns TRUE if the field variant has
13784 : : no fields. This will occur then the
13785 : : compiler constructs 'else end' variants.
13786 : : */
13787 : :
13788 : 0 : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym)
13789 : : {
13790 : 0 : SymbolTable_PtrToSymbol pSym;
13791 : :
13792 : 0 : pSym = GetPsym (sym);
13793 : 0 : switch (pSym->SymbolType)
13794 : : {
13795 : 0 : case SymbolTable_VarientFieldSym:
13796 : 0 : return (Lists_NoOfItemsInList (pSym->VarientField.ListOfSons)) == 0;
13797 : 0 : break;
13798 : :
13799 : :
13800 : 0 : default:
13801 : 0 : M2Error_InternalError ((const char *) "varient field symbol expected", 29);
13802 : : break;
13803 : : }
13804 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13805 : : __builtin_unreachable ();
13806 : : }
13807 : :
13808 : :
13809 : : /*
13810 : : GetVarientTag - returns the varient tag from, Sym.
13811 : : */
13812 : :
13813 : 12726 : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym)
13814 : : {
13815 : 12726 : SymbolTable_PtrToSymbol pSym;
13816 : :
13817 : 12726 : pSym = GetPsym (Sym);
13818 : 12726 : switch (pSym->SymbolType)
13819 : : {
13820 : 12726 : case SymbolTable_VarientSym:
13821 : 12726 : return pSym->Varient.tag;
13822 : 0 : break;
13823 : :
13824 : :
13825 : 0 : default:
13826 : 0 : M2Error_InternalError ((const char *) "varient symbol expected", 23);
13827 : : break;
13828 : : }
13829 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13830 : : __builtin_unreachable ();
13831 : : }
13832 : :
13833 : :
13834 : : /*
13835 : : PutVarientTag - places, Tag, into varient, Sym.
13836 : : */
13837 : :
13838 : 2982 : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag)
13839 : : {
13840 : 2982 : SymbolTable_PtrToSymbol pSym;
13841 : 2982 : unsigned int parent;
13842 : :
13843 : 2982 : pSym = GetPsym (Sym);
13844 : 2982 : switch (pSym->SymbolType)
13845 : : {
13846 : 2982 : case SymbolTable_VarientSym:
13847 : 2982 : pSym->Varient.tag = Tag;
13848 : 2982 : break;
13849 : :
13850 : :
13851 : 0 : default:
13852 : 0 : M2Error_InternalError ((const char *) "varient symbol expected", 23);
13853 : 2982 : break;
13854 : : }
13855 : : /* now ensure that if Tag is a RecordField then it must be
13856 : : placed before the varient symbol in its parent ListOfSons.
13857 : : This allows M2GCCDeclare to declare record fields in order
13858 : : and preserve the order of fields. Otherwise it will add the
13859 : : tag field after the C union. */
13860 : 2982 : if (SymbolTable_IsRecordField (Tag))
13861 : : {
13862 : 2970 : pSym = GetPsym (Tag);
13863 : 2970 : pSym->RecordField.Tag = true;
13864 : 2970 : parent = SymbolTable_GetParent (Sym);
13865 : 2970 : pSym = GetPsym (parent);
13866 : 2970 : switch (pSym->SymbolType)
13867 : : {
13868 : : case SymbolTable_ErrorSym:
13869 : : break;
13870 : :
13871 : 0 : case SymbolTable_VarientSym:
13872 : 0 : EnsureOrder (pSym->Varient.ListOfSons, Tag, Sym);
13873 : 0 : break;
13874 : :
13875 : 36 : case SymbolTable_VarientFieldSym:
13876 : 36 : EnsureOrder (pSym->VarientField.ListOfSons, Tag, Sym);
13877 : 36 : break;
13878 : :
13879 : 2934 : case SymbolTable_RecordSym:
13880 : 2934 : EnsureOrder (pSym->Record.ListOfSons, Tag, Sym);
13881 : 2934 : CheckRecordConsistency (parent);
13882 : 2934 : break;
13883 : :
13884 : :
13885 : 0 : default:
13886 : 0 : M2Error_InternalError ((const char *) "not expecting this symbol type", 30);
13887 : : break;
13888 : : }
13889 : : }
13890 : 2982 : }
13891 : :
13892 : :
13893 : : /*
13894 : : PutFieldEnumeration - places a field into the enumeration type
13895 : : Sym. The field has a name FieldName and a
13896 : : value FieldVal.
13897 : : */
13898 : :
13899 : 493262 : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName)
13900 : : {
13901 : 493262 : SymbolTable_PtrToSymbol oSym;
13902 : 493262 : SymbolTable_PtrToSymbol pSym;
13903 : 493262 : DynamicStrings_String s;
13904 : 493262 : unsigned int Field;
13905 : :
13906 : 493262 : Field = CheckForHiddenType (FieldName);
13907 : 493262 : if (Field == SymbolTable_NulSym)
13908 : : {
13909 : 493262 : Field = DeclareSym (tok, FieldName);
13910 : : }
13911 : 493262 : if (! (SymbolTable_IsError (Field)))
13912 : : {
13913 : 493256 : pSym = GetPsym (Field);
13914 : 493256 : pSym->SymbolType = SymbolTable_EnumerationFieldSym;
13915 : 493256 : pSym->EnumerationField.name = FieldName; /* Index into name array, name */
13916 : : /* of type. */
13917 : 493256 : oSym = GetPsym (Sym);
13918 : 493256 : M2ALU_PushCard (oSym->Enumeration.NoOfElements);
13919 : 493256 : pSym->EnumerationField.Value = M2ALU_InitValue ();
13920 : 493256 : M2ALU_PopInto (pSym->EnumerationField.Value);
13921 : 493256 : pSym->EnumerationField.Type = Sym;
13922 : 493256 : pSym->EnumerationField.Scope = SymbolTable_GetCurrentScope ();
13923 : 493256 : InitWhereDeclaredTok (tok, &pSym->EnumerationField.At); /* Declared here */
13924 : 493256 : pSym = GetPsym (Sym);
13925 : 493256 : switch (pSym->SymbolType)
13926 : : {
13927 : 493256 : case SymbolTable_EnumerationSym:
13928 : 493256 : pSym->Enumeration.NoOfElements += 1;
13929 : 493256 : if ((SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, FieldName)) != SymbolTable_NulSym)
13930 : : {
13931 : 0 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (FieldName)));
13932 : 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)));
13933 : : }
13934 : : else
13935 : : {
13936 : 493256 : SymbolKey_PutSymKey (pSym->Enumeration.LocalSymbols, FieldName, Field);
13937 : 493256 : Lists_IncludeItemIntoList (pSym->Enumeration.ListOfFields, Field);
13938 : : }
13939 : : break;
13940 : :
13941 : :
13942 : 0 : default:
13943 : 0 : M2Error_InternalError ((const char *) "expecting Sym=Enumeration", 25);
13944 : : break;
13945 : : }
13946 : : }
13947 : 493262 : }
13948 : :
13949 : :
13950 : : /*
13951 : : PutSubrange - places LowSym and HighSym as two symbols
13952 : : which provide the limits of the range.
13953 : : */
13954 : :
13955 : 328615 : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol)
13956 : : {
13957 : 328615 : SymbolTable_PtrToSymbol pSym;
13958 : :
13959 : 328615 : pSym = GetPsym (Sym);
13960 : 328615 : switch (pSym->SymbolType)
13961 : : {
13962 : 328615 : case SymbolTable_SubrangeSym:
13963 : 328615 : pSym->Subrange.Low = LowSym; /* Index to symbol for lower */
13964 : 328615 : pSym->Subrange.High = HighSym; /* Index to symbol for higher */
13965 : 328615 : pSym->Subrange.Type = TypeSymbol; /* Index to type symbol for */
13966 : 328615 : break;
13967 : :
13968 : :
13969 : 0 : default:
13970 : : /* the type of subrange. */
13971 : 0 : M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
13972 : 328615 : break;
13973 : : }
13974 : 328615 : }
13975 : :
13976 : :
13977 : : /*
13978 : : PutSet - places SimpleType as the type for set, Sym.
13979 : : */
13980 : :
13981 : 65663 : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed)
13982 : : {
13983 : 65663 : SymbolTable_PtrToSymbol pSym;
13984 : :
13985 : 65663 : pSym = GetPsym (Sym);
13986 : 65663 : switch (pSym->SymbolType)
13987 : : {
13988 : : case SymbolTable_ErrorSym:
13989 : : break;
13990 : :
13991 : 65663 : case SymbolTable_SetSym:
13992 : 65663 : pSym->Set.Type = SimpleType; /* Index to a subrange symbol */
13993 : : /* or an enumeration type. */
13994 : 65663 : pSym->Set.ispacked = packed;
13995 : 65663 : break;
13996 : :
13997 : :
13998 : 0 : default:
13999 : 0 : M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
14000 : 65663 : break;
14001 : : }
14002 : 65663 : }
14003 : :
14004 : :
14005 : : /*
14006 : : IsSetPacked - returns TRUE if Sym is packed.
14007 : : */
14008 : :
14009 : 0 : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym)
14010 : : {
14011 : 0 : SymbolTable_PtrToSymbol pSym;
14012 : :
14013 : 0 : AssertInRange (Sym);
14014 : 0 : pSym = GetPsym (Sym);
14015 : 0 : return (pSym->SymbolType == SymbolTable_SetSym) && pSym->Set.ispacked;
14016 : : /* static analysis guarentees a RETURN statement will be used before here. */
14017 : : __builtin_unreachable ();
14018 : : }
14019 : :
14020 : :
14021 : : /*
14022 : : GetArraySubscript - returns the subscript symbol for array, Sym.
14023 : : */
14024 : :
14025 : 6202982 : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym)
14026 : : {
14027 : 6202982 : SymbolTable_PtrToSymbol pSym;
14028 : :
14029 : 6202982 : pSym = GetPsym (Sym);
14030 : 6202982 : switch (pSym->SymbolType)
14031 : : {
14032 : : case SymbolTable_ErrorSym:
14033 : : return SymbolTable_NulSym;
14034 : 6202982 : break;
14035 : :
14036 : 6202982 : case SymbolTable_ArraySym:
14037 : 6202982 : return pSym->Array.Subscript;
14038 : 0 : break;
14039 : :
14040 : :
14041 : 0 : default:
14042 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
14043 : : break;
14044 : : }
14045 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14046 : : __builtin_unreachable ();
14047 : : }
14048 : :
14049 : :
14050 : : /*
14051 : : PutArraySubscript - places an index field into the array Sym. The
14052 : : index field is a subscript sym.
14053 : : */
14054 : :
14055 : 164285 : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol)
14056 : : {
14057 : 164285 : SymbolTable_PtrToSymbol pSym;
14058 : :
14059 : 164285 : pSym = GetPsym (Sym);
14060 : 164285 : switch (pSym->SymbolType)
14061 : : {
14062 : : case SymbolTable_ErrorSym:
14063 : : break;
14064 : :
14065 : 164285 : case SymbolTable_ArraySym:
14066 : 164285 : pSym->Array.Subscript = SubscriptSymbol;
14067 : 164285 : break;
14068 : :
14069 : :
14070 : 0 : default:
14071 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
14072 : 164285 : break;
14073 : : }
14074 : 164285 : }
14075 : :
14076 : :
14077 : : /*
14078 : : PutType - gives a type symbol Sym type TypeSymbol.
14079 : : */
14080 : :
14081 : 616042 : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol)
14082 : : {
14083 : 616042 : SymbolTable_PtrToSymbol pSym;
14084 : :
14085 : 616042 : if (TypeSymbol == Sym)
14086 : : {
14087 : 0 : M2Error_InternalError ((const char *) "not expecting a type to be declared as itself", 45);
14088 : : }
14089 : 616042 : pSym = GetPsym (Sym);
14090 : 616042 : switch (pSym->SymbolType)
14091 : : {
14092 : : case SymbolTable_ErrorSym:
14093 : : break;
14094 : :
14095 : 616042 : case SymbolTable_TypeSym:
14096 : 616042 : pSym->Type.Type = TypeSymbol;
14097 : 616042 : break;
14098 : :
14099 : :
14100 : 0 : default:
14101 : 0 : M2Error_InternalError ((const char *) "expecting a Type symbol", 23);
14102 : 616042 : break;
14103 : : }
14104 : 616042 : }
14105 : :
14106 : :
14107 : : /*
14108 : : PutFunction - Places a TypeSym as the return type to a procedure Sym.
14109 : : */
14110 : :
14111 : 8308672 : extern "C" void SymbolTable_PutFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym)
14112 : : {
14113 : 16609468 : SymbolTable_PtrToSymbol pSym;
14114 : :
14115 : 16609468 : pSym = GetPsym (Sym);
14116 : 16609468 : switch (pSym->SymbolType)
14117 : : {
14118 : : case SymbolTable_ErrorSym:
14119 : : break;
14120 : :
14121 : 8300796 : case SymbolTable_ProcedureSym:
14122 : 8300796 : pSym->Procedure.ReturnType = TypeSym;
14123 : 8300796 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
14124 : 8300796 : SymbolTable_PutFunction (tok, pSym->Procedure.ProcedureType, kind, TypeSym);
14125 : 8300796 : break;
14126 : :
14127 : 8308672 : case SymbolTable_ProcTypeSym:
14128 : 8308672 : pSym->ProcType.ReturnType = TypeSym;
14129 : 8308672 : pSym->ProcType.ReturnTypeTok = tok;
14130 : 8308672 : break;
14131 : :
14132 : :
14133 : 0 : default:
14134 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14135 : 8308672 : break;
14136 : : }
14137 : 8308672 : }
14138 : :
14139 : :
14140 : : /*
14141 : : PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
14142 : : */
14143 : :
14144 : 127816 : extern "C" void SymbolTable_PutOptFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym)
14145 : : {
14146 : 255632 : SymbolTable_PtrToSymbol pSym;
14147 : :
14148 : 255632 : pSym = GetPsym (Sym);
14149 : 255632 : switch (pSym->SymbolType)
14150 : : {
14151 : : case SymbolTable_ErrorSym:
14152 : : break;
14153 : :
14154 : 127816 : case SymbolTable_ProcedureSym:
14155 : 127816 : pSym->Procedure.ReturnType = TypeSym;
14156 : 127816 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional = true;
14157 : 127816 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
14158 : 127816 : SymbolTable_PutOptFunction (tok, pSym->Procedure.ProcedureType, kind, TypeSym);
14159 : 127816 : break;
14160 : :
14161 : 127816 : case SymbolTable_ProcTypeSym:
14162 : 127816 : pSym->ProcType.ReturnType = TypeSym;
14163 : 127816 : pSym->ProcType.ReturnTypeTok = tok;
14164 : 127816 : break;
14165 : :
14166 : :
14167 : 0 : default:
14168 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14169 : 127816 : break;
14170 : : }
14171 : 127816 : }
14172 : :
14173 : :
14174 : : /*
14175 : : IsReturnOptional - returns TRUE if the return value for, sym, is
14176 : : optional.
14177 : : */
14178 : :
14179 : 1701906 : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind)
14180 : : {
14181 : 1701906 : SymbolTable_PtrToSymbol pSym;
14182 : :
14183 : 1701906 : pSym = GetPsym (sym);
14184 : 1701906 : switch (pSym->SymbolType)
14185 : : {
14186 : 1670474 : case SymbolTable_ProcedureSym:
14187 : 1670474 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional;
14188 : 31432 : break;
14189 : :
14190 : 31432 : case SymbolTable_ProcTypeSym:
14191 : 31432 : return pSym->ProcType.ReturnOptional;
14192 : 0 : break;
14193 : :
14194 : :
14195 : 0 : default:
14196 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14197 : : break;
14198 : : }
14199 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14200 : : __builtin_unreachable ();
14201 : : }
14202 : :
14203 : :
14204 : : /*
14205 : : IsReturnOptionalAny - returns TRUE if the return value for sym is
14206 : : optional.
14207 : : */
14208 : :
14209 : 8602 : extern "C" bool SymbolTable_IsReturnOptionalAny (unsigned int sym)
14210 : : {
14211 : 8602 : SymbolTable_PtrToSymbol pSym;
14212 : :
14213 : 8602 : pSym = GetPsym (sym);
14214 : 8602 : switch (pSym->SymbolType)
14215 : : {
14216 : 8602 : case SymbolTable_ProcedureSym:
14217 : 8602 : return IsProcedureAnyBoolean (sym, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_IsReturnOptional});
14218 : 0 : break;
14219 : :
14220 : 0 : case SymbolTable_ProcTypeSym:
14221 : 0 : return pSym->ProcType.ReturnOptional;
14222 : 0 : break;
14223 : :
14224 : :
14225 : 0 : default:
14226 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14227 : : break;
14228 : : }
14229 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14230 : : __builtin_unreachable ();
14231 : : }
14232 : :
14233 : :
14234 : : /*
14235 : : PutParam - Places a Non VAR parameter ParamName with type ParamType into
14236 : : procedure Sym:kind. The parameter number is ParamNo.
14237 : : If the procedure Sym already has this parameter then
14238 : : the parameter is checked for consistancy and the
14239 : : consistancy test is returned.
14240 : : */
14241 : :
14242 : 10276924 : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok)
14243 : : {
14244 : 10276924 : SymbolTable_PtrToSymbol pSym;
14245 : 10276924 : unsigned int ParSym;
14246 : 10276924 : unsigned int VariableSym;
14247 : :
14248 : 10276924 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
14249 : : {
14250 : : /* ParamNo <= NoOfParamAny (Sym) */
14251 : 0 : M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
14252 : : }
14253 : : else
14254 : : {
14255 : : /* Add a new parameter */
14256 : 10276924 : NewSym (&ParSym);
14257 : 10276924 : pSym = GetPsym (ParSym);
14258 : 10276924 : pSym->SymbolType = SymbolTable_ParamSym;
14259 : 10276924 : pSym->Param.name = ParamName;
14260 : 10276924 : pSym->Param.Type = ParamType;
14261 : 10276924 : pSym->Param.IsUnbounded = isUnbounded;
14262 : 10276924 : pSym->Param.Scope = Sym;
14263 : 10276924 : pSym->Param.ShadowVar = SymbolTable_NulSym;
14264 : 10276924 : pSym->Param.FullTok = M2LexBuf_MakeVirtual2Tok (tok, typetok);
14265 : 10276924 : pSym->Param.At = tok;
14266 : 10276924 : AddParameter (Sym, kind, ParSym);
14267 : : /* Only declare a parameter as a local variable if it has not been done before.
14268 : : It might be declared during the definition module, forward declaration or
14269 : : proper procedure. Name mismatches are checked in P2SymBuild.mod. */
14270 : 10276924 : if ((ParamName != NameKey_NulName) && ((SymbolTable_GetNth (Sym, ParamNo)) == SymbolTable_NulSym))
14271 : : {
14272 : 8096619 : VariableSym = MakeVariableForParam (tok, ParamName, Sym, kind, ParamNo, ParamType, typetok);
14273 : 8096619 : if (VariableSym == SymbolTable_NulSym)
14274 : : {
14275 : : return false;
14276 : : }
14277 : : else
14278 : : {
14279 : 8096619 : pSym = GetPsym (ParSym);
14280 : 8096619 : pSym->Param.ShadowVar = VariableSym;
14281 : : }
14282 : : }
14283 : 10276924 : AddProcedureProcTypeParam (tok, Sym, ParamType, isUnbounded, false);
14284 : : }
14285 : 10276924 : return true;
14286 : : /* static analysis guarentees a RETURN statement will be used before here. */
14287 : : __builtin_unreachable ();
14288 : : }
14289 : :
14290 : :
14291 : : /*
14292 : : PutVarParam - Places a Non VAR parameter ParamName with type
14293 : : ParamType into procedure Sym:kind.
14294 : : The parameter number is ParamNo.
14295 : : If the procedure Sym already has this parameter then
14296 : : the parameter is checked for consistancy and the
14297 : : consistancy test is returned.
14298 : : */
14299 : :
14300 : 962216 : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok)
14301 : : {
14302 : 962216 : SymbolTable_PtrToSymbol pSym;
14303 : 962216 : unsigned int ParSym;
14304 : 962216 : unsigned int VariableSym;
14305 : :
14306 : 962216 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
14307 : : {
14308 : 0 : M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
14309 : : }
14310 : : else
14311 : : {
14312 : : /* Add a new parameter */
14313 : 962216 : NewSym (&ParSym);
14314 : 962216 : pSym = GetPsym (ParSym);
14315 : 962216 : pSym->SymbolType = SymbolTable_VarParamSym;
14316 : 962216 : pSym->VarParam.name = ParamName;
14317 : 962216 : pSym->VarParam.Type = ParamType;
14318 : 962216 : pSym->VarParam.IsUnbounded = isUnbounded;
14319 : 962216 : pSym->VarParam.Scope = Sym;
14320 : 962216 : pSym->VarParam.ShadowVar = SymbolTable_NulSym;
14321 : 962216 : pSym->VarParam.HeapVar = SymbolTable_NulSym; /* Will contain a pointer value. */
14322 : 962216 : pSym->VarParam.FullTok = M2LexBuf_MakeVirtual2Tok (tok, typetok); /* Will contain a pointer value. */
14323 : 962216 : pSym->VarParam.At = tok;
14324 : 962216 : AddParameter (Sym, kind, ParSym);
14325 : : /* Only declare a parameter as a local variable if it has not been done before.
14326 : : It might be declared during the definition module, forward declaration or
14327 : : proper procedure. Name mismatches are checked in P2SymBuild.mod. */
14328 : 962216 : if ((ParamName != NameKey_NulName) && ((SymbolTable_GetNth (Sym, ParamNo)) == SymbolTable_NulSym))
14329 : : {
14330 : 752625 : VariableSym = MakeVariableForParam (tok, ParamName, Sym, kind, ParamNo, ParamType, typetok);
14331 : 752625 : if (VariableSym == SymbolTable_NulSym)
14332 : : {
14333 : : return false;
14334 : : }
14335 : : else
14336 : : {
14337 : 752625 : pSym = GetPsym (ParSym);
14338 : 752625 : pSym->VarParam.ShadowVar = VariableSym;
14339 : : }
14340 : : }
14341 : 962216 : AddProcedureProcTypeParam (tok, Sym, ParamType, isUnbounded, true);
14342 : : }
14343 : 962216 : return true;
14344 : : /* static analysis guarentees a RETURN statement will be used before here. */
14345 : : __builtin_unreachable ();
14346 : : }
14347 : :
14348 : :
14349 : : /*
14350 : : PutParamName - assigns a name to paramater no of procedure ProcSym:kind.
14351 : : */
14352 : :
14353 : 0 : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, NameKey_Name name, unsigned int ParamType, unsigned int typetok)
14354 : : {
14355 : 0 : SymbolTable_PtrToSymbol pSym;
14356 : 0 : unsigned int ParSym;
14357 : :
14358 : 0 : pSym = GetPsym (ProcSym);
14359 : 0 : ParSym = SymbolTable_NulSym;
14360 : 0 : switch (pSym->SymbolType)
14361 : : {
14362 : : case SymbolTable_ErrorSym:
14363 : : return;
14364 : 0 : break;
14365 : :
14366 : 0 : case SymbolTable_ProcedureSym:
14367 : 0 : ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, no));
14368 : 0 : break;
14369 : :
14370 : 0 : case SymbolTable_ProcTypeSym:
14371 : 0 : ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, no));
14372 : 0 : break;
14373 : :
14374 : :
14375 : 0 : default:
14376 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14377 : 0 : break;
14378 : : }
14379 : 0 : pSym = GetPsym (ParSym);
14380 : 0 : switch (pSym->SymbolType)
14381 : : {
14382 : 0 : case SymbolTable_ParamSym:
14383 : 0 : if (pSym->Param.name == NameKey_NulName)
14384 : : {
14385 : 0 : pSym->Param.name = name;
14386 : 0 : pSym->Param.ShadowVar = MakeVariableForParam (tok, name, ProcSym, kind, no, ParamType, typetok);
14387 : : }
14388 : : else
14389 : : {
14390 : 0 : M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
14391 : : }
14392 : 0 : break;
14393 : :
14394 : 0 : case SymbolTable_VarParamSym:
14395 : 0 : if (pSym->VarParam.name == NameKey_NulName)
14396 : : {
14397 : 0 : pSym->VarParam.name = name;
14398 : 0 : pSym->VarParam.ShadowVar = MakeVariableForParam (tok, name, ProcSym, kind, no, ParamType, typetok);
14399 : : }
14400 : : else
14401 : : {
14402 : 0 : M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
14403 : : }
14404 : 0 : break;
14405 : :
14406 : :
14407 : 0 : default:
14408 : 0 : M2Error_InternalError ((const char *) "expecting a VarParam or Param symbol", 36);
14409 : 0 : break;
14410 : : }
14411 : : }
14412 : :
14413 : :
14414 : : /*
14415 : : PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
14416 : : main Module.
14417 : : */
14418 : :
14419 : 70074 : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym)
14420 : : {
14421 : 70074 : SymbolTable_PtrToSymbol pSym;
14422 : :
14423 : 70074 : pSym = GetPsym (Sym);
14424 : 70074 : switch (pSym->SymbolType)
14425 : : {
14426 : : case SymbolTable_ErrorSym:
14427 : : break;
14428 : :
14429 : 70074 : case SymbolTable_ProcedureSym:
14430 : 70074 : pSym->Procedure.Reachable = true;
14431 : 70074 : break;
14432 : :
14433 : :
14434 : 0 : default:
14435 : 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14436 : 70074 : break;
14437 : : }
14438 : 70074 : }
14439 : :
14440 : :
14441 : : /*
14442 : : IsProcedureReachable - Returns true if the procedure, Sym, is
14443 : : reachable from the main Module.
14444 : : */
14445 : :
14446 : 240827 : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym)
14447 : : {
14448 : 240827 : SymbolTable_PtrToSymbol pSym;
14449 : :
14450 : 240827 : pSym = GetPsym (Sym);
14451 : 240827 : switch (pSym->SymbolType)
14452 : : {
14453 : 240827 : case SymbolTable_ProcedureSym:
14454 : 240827 : return pSym->Procedure.Reachable;
14455 : 0 : break;
14456 : :
14457 : :
14458 : 0 : default:
14459 : 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14460 : : break;
14461 : : }
14462 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14463 : : __builtin_unreachable ();
14464 : : }
14465 : :
14466 : :
14467 : : /*
14468 : : PutProcedureNoReturn - places value into the no return attribute
14469 : : field of procedure sym.
14470 : : */
14471 : :
14472 : 492361 : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind, bool value)
14473 : : {
14474 : 492361 : SymbolTable_PtrToSymbol pSym;
14475 : :
14476 : 492361 : pSym = GetPsym (Sym);
14477 : 492361 : switch (pSym->SymbolType)
14478 : : {
14479 : 492361 : case SymbolTable_ProcedureSym:
14480 : 492361 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].IsNoReturn = value;
14481 : 492361 : break;
14482 : :
14483 : :
14484 : 0 : default:
14485 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
14486 : 492361 : break;
14487 : : }
14488 : 492361 : }
14489 : :
14490 : :
14491 : : /*
14492 : : IsProcedureNoReturn - returns TRUE if this procedure never returns.
14493 : : */
14494 : :
14495 : 3289445 : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind)
14496 : : {
14497 : 3289445 : SymbolTable_PtrToSymbol pSym;
14498 : :
14499 : 3289445 : pSym = GetPsym (Sym);
14500 : 3289445 : switch (pSym->SymbolType)
14501 : : {
14502 : 3289445 : case SymbolTable_ProcedureSym:
14503 : 3289445 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].IsNoReturn;
14504 : 0 : break;
14505 : :
14506 : :
14507 : 0 : default:
14508 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
14509 : : break;
14510 : : }
14511 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14512 : : __builtin_unreachable ();
14513 : : }
14514 : :
14515 : :
14516 : : /*
14517 : : GetProcedureProcType - returns the proctype matching procedure sym.
14518 : : */
14519 : :
14520 : 758520 : extern "C" unsigned int SymbolTable_GetProcedureProcType (unsigned int sym)
14521 : : {
14522 : 758520 : SymbolTable_PtrToSymbol pSym;
14523 : :
14524 : 758520 : pSym = GetPsym (sym);
14525 : 758520 : switch (pSym->SymbolType)
14526 : : {
14527 : 758520 : case SymbolTable_ProcedureSym:
14528 : 758520 : return pSym->Procedure.ProcedureType;
14529 : 0 : break;
14530 : :
14531 : :
14532 : 0 : default:
14533 : 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14534 : : break;
14535 : : }
14536 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14537 : : __builtin_unreachable ();
14538 : : }
14539 : :
14540 : :
14541 : : /*
14542 : : PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
14543 : : QuadNumber is the start quad of Module,
14544 : : Sym.
14545 : : */
14546 : :
14547 : 82816 : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber)
14548 : : {
14549 : 82816 : SymbolTable_PtrToSymbol pSym;
14550 : :
14551 : 82816 : pSym = GetPsym (Sym);
14552 : 82816 : switch (pSym->SymbolType)
14553 : : {
14554 : 11933 : case SymbolTable_ModuleSym:
14555 : 11933 : pSym->Module.StartQuad = QuadNumber;
14556 : 11933 : break;
14557 : :
14558 : 70883 : case SymbolTable_DefImpSym:
14559 : 70883 : pSym->DefImp.StartQuad = QuadNumber;
14560 : 70883 : break;
14561 : :
14562 : :
14563 : 0 : default:
14564 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14565 : 82816 : break;
14566 : : }
14567 : 82816 : }
14568 : :
14569 : :
14570 : : /*
14571 : : PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
14572 : : QuadNumber is the end quad of Module,
14573 : : Sym.
14574 : : */
14575 : :
14576 : 82668 : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber)
14577 : : {
14578 : 82668 : SymbolTable_PtrToSymbol pSym;
14579 : :
14580 : 82668 : pSym = GetPsym (Sym);
14581 : 82668 : switch (pSym->SymbolType)
14582 : : {
14583 : 11785 : case SymbolTable_ModuleSym:
14584 : 11785 : pSym->Module.EndQuad = QuadNumber;
14585 : 11785 : break;
14586 : :
14587 : 70883 : case SymbolTable_DefImpSym:
14588 : 70883 : pSym->DefImp.EndQuad = QuadNumber;
14589 : 70883 : break;
14590 : :
14591 : :
14592 : 0 : default:
14593 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14594 : 82668 : break;
14595 : : }
14596 : 82668 : }
14597 : :
14598 : :
14599 : : /*
14600 : : PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
14601 : : QuadNumber is the finally start quad of
14602 : : Module, Sym.
14603 : : */
14604 : :
14605 : 15588 : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber)
14606 : : {
14607 : 15588 : SymbolTable_PtrToSymbol pSym;
14608 : :
14609 : 15588 : pSym = GetPsym (Sym);
14610 : 15588 : switch (pSym->SymbolType)
14611 : : {
14612 : 11779 : case SymbolTable_ModuleSym:
14613 : 11779 : pSym->Module.StartFinishQuad = QuadNumber;
14614 : 11779 : break;
14615 : :
14616 : 3809 : case SymbolTable_DefImpSym:
14617 : 3809 : pSym->DefImp.StartFinishQuad = QuadNumber;
14618 : 3809 : break;
14619 : :
14620 : :
14621 : 0 : default:
14622 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14623 : 15588 : break;
14624 : : }
14625 : 15588 : }
14626 : :
14627 : :
14628 : : /*
14629 : : PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
14630 : : QuadNumber is the end quad of the finally block
14631 : : in Module, Sym.
14632 : : */
14633 : :
14634 : 15588 : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber)
14635 : : {
14636 : 15588 : SymbolTable_PtrToSymbol pSym;
14637 : :
14638 : 15588 : pSym = GetPsym (Sym);
14639 : 15588 : switch (pSym->SymbolType)
14640 : : {
14641 : 11779 : case SymbolTable_ModuleSym:
14642 : 11779 : pSym->Module.EndFinishQuad = QuadNumber;
14643 : 11779 : break;
14644 : :
14645 : 3809 : case SymbolTable_DefImpSym:
14646 : 3809 : pSym->DefImp.EndFinishQuad = QuadNumber;
14647 : 3809 : break;
14648 : :
14649 : :
14650 : 0 : default:
14651 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14652 : 15588 : break;
14653 : : }
14654 : 15588 : }
14655 : :
14656 : :
14657 : : /*
14658 : : GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
14659 : : Quads of a Module, Sym.
14660 : : Start and End represent the initialization code
14661 : : of the Module, Sym.
14662 : : */
14663 : :
14664 : 0 : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish)
14665 : : {
14666 : 0 : SymbolTable_PtrToSymbol pSym;
14667 : :
14668 : 0 : pSym = GetPsym (Sym);
14669 : 0 : switch (pSym->SymbolType)
14670 : : {
14671 : 0 : case SymbolTable_ModuleSym:
14672 : 0 : (*StartInit) = pSym->Module.StartQuad;
14673 : 0 : (*EndInit) = pSym->Module.EndQuad;
14674 : 0 : (*StartFinish) = pSym->Module.StartFinishQuad;
14675 : 0 : (*EndFinish) = pSym->Module.EndFinishQuad;
14676 : 0 : break;
14677 : :
14678 : 0 : case SymbolTable_DefImpSym:
14679 : 0 : (*StartInit) = pSym->DefImp.StartQuad;
14680 : 0 : (*EndInit) = pSym->DefImp.EndQuad;
14681 : 0 : (*StartFinish) = pSym->DefImp.StartFinishQuad;
14682 : 0 : (*EndFinish) = pSym->DefImp.EndFinishQuad;
14683 : 0 : break;
14684 : :
14685 : :
14686 : 0 : default:
14687 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14688 : 0 : break;
14689 : : }
14690 : 0 : }
14691 : :
14692 : :
14693 : : /*
14694 : : PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
14695 : : */
14696 : :
14697 : 0 : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, tree finally)
14698 : : {
14699 : 0 : SymbolTable_PtrToSymbol pSym;
14700 : :
14701 : 0 : pSym = GetPsym (Sym);
14702 : 0 : switch (pSym->SymbolType)
14703 : : {
14704 : 0 : case SymbolTable_ModuleSym:
14705 : 0 : pSym->Module.FinallyFunction = finally;
14706 : 0 : break;
14707 : :
14708 : 0 : case SymbolTable_DefImpSym:
14709 : 0 : pSym->DefImp.FinallyFunction = finally;
14710 : 0 : break;
14711 : :
14712 : :
14713 : 0 : default:
14714 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14715 : 0 : break;
14716 : : }
14717 : 0 : }
14718 : :
14719 : :
14720 : : /*
14721 : : GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
14722 : : */
14723 : :
14724 : 0 : extern "C" tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym)
14725 : : {
14726 : 0 : SymbolTable_PtrToSymbol pSym;
14727 : :
14728 : 0 : pSym = GetPsym (Sym);
14729 : 0 : switch (pSym->SymbolType)
14730 : : {
14731 : 0 : case SymbolTable_ModuleSym:
14732 : 0 : return pSym->Module.FinallyFunction;
14733 : 0 : break;
14734 : :
14735 : 0 : case SymbolTable_DefImpSym:
14736 : 0 : return pSym->DefImp.FinallyFunction;
14737 : 0 : break;
14738 : :
14739 : :
14740 : 0 : default:
14741 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14742 : : break;
14743 : : }
14744 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14745 : : __builtin_unreachable ();
14746 : : }
14747 : :
14748 : :
14749 : : /*
14750 : : PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
14751 : : QuadNumber is the start quad of scope for procedure,
14752 : : Sym.
14753 : : */
14754 : :
14755 : 79965 : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber)
14756 : : {
14757 : 79965 : SymbolTable_PtrToSymbol pSym;
14758 : :
14759 : 79965 : pSym = GetPsym (Sym);
14760 : 79965 : switch (pSym->SymbolType)
14761 : : {
14762 : 79965 : case SymbolTable_ProcedureSym:
14763 : 79965 : pSym->Procedure.ScopeQuad = QuadNumber;
14764 : 79965 : break;
14765 : :
14766 : :
14767 : 0 : default:
14768 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14769 : 79965 : break;
14770 : : }
14771 : 79965 : }
14772 : :
14773 : :
14774 : : /*
14775 : : PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
14776 : : QuadNumber is the start quad of procedure,
14777 : : Sym.
14778 : : */
14779 : :
14780 : 79953 : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber)
14781 : : {
14782 : 79953 : SymbolTable_PtrToSymbol pSym;
14783 : :
14784 : 79953 : pSym = GetPsym (Sym);
14785 : 79953 : switch (pSym->SymbolType)
14786 : : {
14787 : 79953 : case SymbolTable_ProcedureSym:
14788 : 79953 : pSym->Procedure.StartQuad = QuadNumber;
14789 : 79953 : break;
14790 : :
14791 : :
14792 : 0 : default:
14793 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14794 : 79953 : break;
14795 : : }
14796 : 79953 : }
14797 : :
14798 : :
14799 : : /*
14800 : : PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
14801 : : QuadNumber is the end quad of procedure,
14802 : : Sym.
14803 : : */
14804 : :
14805 : 79923 : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber)
14806 : : {
14807 : 79923 : SymbolTable_PtrToSymbol pSym;
14808 : :
14809 : 79923 : pSym = GetPsym (Sym);
14810 : 79923 : switch (pSym->SymbolType)
14811 : : {
14812 : 79923 : case SymbolTable_ProcedureSym:
14813 : 79923 : pSym->Procedure.EndQuad = QuadNumber;
14814 : 79923 : break;
14815 : :
14816 : :
14817 : 0 : default:
14818 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14819 : 79923 : break;
14820 : : }
14821 : 79923 : }
14822 : :
14823 : :
14824 : : /*
14825 : : GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
14826 : : */
14827 : :
14828 : 695492 : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end)
14829 : : {
14830 : 695492 : SymbolTable_PtrToSymbol pSym;
14831 : :
14832 : 695492 : pSym = GetPsym (Sym);
14833 : 695492 : switch (pSym->SymbolType)
14834 : : {
14835 : 695492 : case SymbolTable_ProcedureSym:
14836 : 695492 : (*scope) = pSym->Procedure.ScopeQuad;
14837 : 695492 : (*start) = pSym->Procedure.StartQuad;
14838 : 695492 : (*end) = pSym->Procedure.EndQuad;
14839 : 695492 : break;
14840 : :
14841 : :
14842 : 0 : default:
14843 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14844 : 695492 : break;
14845 : : }
14846 : 695492 : }
14847 : :
14848 : :
14849 : : /*
14850 : : GetQuads - assigns Start and End to the beginning and end of
14851 : : symbol, Sym, usage.
14852 : : */
14853 : :
14854 : 0 : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14855 : : {
14856 : 0 : unsigned int StartRead;
14857 : 0 : unsigned int EndRead;
14858 : 0 : unsigned int StartWrite;
14859 : 0 : unsigned int EndWrite;
14860 : :
14861 : 0 : SymbolTable_GetReadQuads (Sym, m, &StartRead, &EndRead);
14862 : 0 : SymbolTable_GetWriteQuads (Sym, m, &StartWrite, &EndWrite);
14863 : 0 : if (StartRead == 0)
14864 : : {
14865 : 0 : (*Start) = StartWrite;
14866 : : }
14867 : 0 : else if (StartWrite == 0)
14868 : : {
14869 : : /* avoid dangling else. */
14870 : 0 : (*Start) = StartRead;
14871 : : }
14872 : : else
14873 : : {
14874 : : /* avoid dangling else. */
14875 : 0 : (*Start) = Min (StartRead, StartWrite);
14876 : : }
14877 : 0 : if (EndRead == 0)
14878 : : {
14879 : 0 : (*End) = EndWrite;
14880 : : }
14881 : 0 : else if (EndWrite == 0)
14882 : : {
14883 : : /* avoid dangling else. */
14884 : 0 : (*End) = EndRead;
14885 : : }
14886 : : else
14887 : : {
14888 : : /* avoid dangling else. */
14889 : 0 : (*End) = Max (EndRead, EndWrite);
14890 : : }
14891 : 0 : }
14892 : :
14893 : :
14894 : : /*
14895 : : GetReadQuads - assigns Start and End to the beginning and end of
14896 : : symbol, Sym, read history usage.
14897 : : */
14898 : :
14899 : 0 : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14900 : : {
14901 : 0 : SymbolTable_GetReadLimitQuads (Sym, m, 0, 0, Start, End);
14902 : 0 : }
14903 : :
14904 : :
14905 : : /*
14906 : : GetWriteQuads - assigns Start and End to the beginning and end of
14907 : : symbol, Sym, usage.
14908 : : */
14909 : :
14910 : 0 : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14911 : : {
14912 : 0 : SymbolTable_GetWriteLimitQuads (Sym, m, 0, 0, Start, End);
14913 : 0 : }
14914 : :
14915 : :
14916 : : /*
14917 : : PutReadQuad - places Quad into the list of symbol usage.
14918 : : */
14919 : :
14920 : 1610931 : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14921 : : {
14922 : 1610931 : SymbolTable_PtrToSymbol pSym;
14923 : :
14924 : 1610931 : pSym = GetPsym (Sym);
14925 : 1610931 : switch (pSym->SymbolType)
14926 : : {
14927 : 1610931 : case SymbolTable_VarSym:
14928 : 1610931 : Lists_IncludeItemIntoList (static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]), Quad);
14929 : 1610931 : break;
14930 : :
14931 : :
14932 : 0 : default:
14933 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14934 : 1610931 : break;
14935 : : }
14936 : 1610931 : }
14937 : :
14938 : :
14939 : : /*
14940 : : RemoveReadQuad - places Quad into the list of symbol usage.
14941 : : */
14942 : :
14943 : 133471 : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14944 : : {
14945 : 133471 : SymbolTable_PtrToSymbol pSym;
14946 : :
14947 : 133471 : pSym = GetPsym (Sym);
14948 : 133471 : switch (pSym->SymbolType)
14949 : : {
14950 : 133471 : case SymbolTable_VarSym:
14951 : 133471 : Lists_RemoveItemFromList (static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]), Quad);
14952 : 133471 : break;
14953 : :
14954 : :
14955 : 0 : default:
14956 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14957 : 133471 : break;
14958 : : }
14959 : 133471 : }
14960 : :
14961 : :
14962 : : /*
14963 : : PutWriteQuad - places Quad into the list of symbol usage.
14964 : : */
14965 : :
14966 : 1049179 : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14967 : : {
14968 : 1049179 : SymbolTable_PtrToSymbol pSym;
14969 : :
14970 : 1049179 : pSym = GetPsym (Sym);
14971 : 1049179 : switch (pSym->SymbolType)
14972 : : {
14973 : 1049179 : case SymbolTable_VarSym:
14974 : 1049179 : Lists_IncludeItemIntoList (static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]), Quad);
14975 : 1049179 : break;
14976 : :
14977 : :
14978 : 0 : default:
14979 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14980 : 1049179 : break;
14981 : : }
14982 : 1049179 : }
14983 : :
14984 : :
14985 : : /*
14986 : : RemoveWriteQuad - places Quad into the list of symbol usage.
14987 : : */
14988 : :
14989 : 215423 : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14990 : : {
14991 : 215423 : SymbolTable_PtrToSymbol pSym;
14992 : :
14993 : 215423 : pSym = GetPsym (Sym);
14994 : 215423 : switch (pSym->SymbolType)
14995 : : {
14996 : 215423 : case SymbolTable_VarSym:
14997 : 215423 : Lists_RemoveItemFromList (static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]), Quad);
14998 : 215423 : break;
14999 : :
15000 : :
15001 : 0 : default:
15002 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
15003 : 215423 : break;
15004 : : }
15005 : 215423 : }
15006 : :
15007 : :
15008 : : /*
15009 : : GetReadLimitQuads - returns Start and End which have been assigned
15010 : : the start and end of when the symbol was read
15011 : : to within: StartLimit..EndLimit.
15012 : : */
15013 : :
15014 : 0 : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
15015 : : {
15016 : 0 : SymbolTable_PtrToSymbol pSym;
15017 : :
15018 : 0 : pSym = GetPsym (Sym);
15019 : 0 : switch (pSym->SymbolType)
15020 : : {
15021 : 0 : case SymbolTable_VarSym:
15022 : 0 : DoFindLimits (StartLimit, EndLimit, Start, End, static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]));
15023 : 0 : break;
15024 : :
15025 : :
15026 : 0 : default:
15027 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
15028 : 0 : break;
15029 : : }
15030 : 0 : }
15031 : :
15032 : :
15033 : : /*
15034 : : GetWriteLimitQuads - returns Start and End which have been assigned
15035 : : the start and end of when the symbol was written
15036 : : to within: StartLimit..EndLimit.
15037 : : */
15038 : :
15039 : 30 : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
15040 : : {
15041 : 30 : SymbolTable_PtrToSymbol pSym;
15042 : :
15043 : 30 : pSym = GetPsym (Sym);
15044 : 30 : switch (pSym->SymbolType)
15045 : : {
15046 : 30 : case SymbolTable_VarSym:
15047 : 30 : DoFindLimits (StartLimit, EndLimit, Start, End, static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]));
15048 : 30 : break;
15049 : :
15050 : :
15051 : 0 : default:
15052 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
15053 : 30 : break;
15054 : : }
15055 : 30 : }
15056 : :
15057 : :
15058 : : /*
15059 : : GetNthProcedure - Returns the Nth procedure in Module, Sym.
15060 : : */
15061 : :
15062 : 12560 : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n)
15063 : : {
15064 : 12560 : SymbolTable_PtrToSymbol pSym;
15065 : :
15066 : 12560 : pSym = GetPsym (Sym);
15067 : 12560 : switch (pSym->SymbolType)
15068 : : {
15069 : 12560 : case SymbolTable_DefImpSym:
15070 : 12560 : return static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfProcs, n));
15071 : 0 : break;
15072 : :
15073 : 0 : case SymbolTable_ModuleSym:
15074 : 0 : return static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfProcs, n));
15075 : 0 : break;
15076 : :
15077 : :
15078 : 0 : default:
15079 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
15080 : : break;
15081 : : }
15082 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15083 : : __builtin_unreachable ();
15084 : : }
15085 : :
15086 : :
15087 : : /*
15088 : : GetDeclaredDef - returns the tokenno where the symbol was declared
15089 : : in the definition module. UnknownTokenNo is returned
15090 : : if no declaration occurred.
15091 : : */
15092 : :
15093 : 36 : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym)
15094 : : {
15095 : 36 : return SymbolTable_GetDeclaredDefinition (Sym);
15096 : : /* static analysis guarentees a RETURN statement will be used before here. */
15097 : : __builtin_unreachable ();
15098 : : }
15099 : :
15100 : :
15101 : : /*
15102 : : GetDeclaredMod - returns the tokenno where the symbol was declared.
15103 : : in the program or implementation module.
15104 : : UnknownTokenNo is returned if no declaration occurred.
15105 : : */
15106 : :
15107 : 35176030 : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym)
15108 : : {
15109 : 35176030 : return SymbolTable_GetDeclaredModule (Sym);
15110 : : /* static analysis guarentees a RETURN statement will be used before here. */
15111 : : __builtin_unreachable ();
15112 : : }
15113 : :
15114 : :
15115 : : /*
15116 : : GetDeclaredFor - returns the token where this forward procedure symbol
15117 : : was declared in the program or implementation module.
15118 : : UnknownTokenNo is returned if no declaration occurred.
15119 : : */
15120 : :
15121 : 0 : extern "C" unsigned int SymbolTable_GetDeclaredFor (unsigned int Sym)
15122 : : {
15123 : 0 : if (SymbolTable_IsProcedure (Sym))
15124 : : {
15125 : 0 : return SymbolTable_GetProcedureDeclaredTok (Sym, SymbolTable_ForwardProcedure);
15126 : : }
15127 : : else
15128 : : {
15129 : : return M2LexBuf_UnknownTokenNo;
15130 : : }
15131 : : /* static analysis guarentees a RETURN statement will be used before here. */
15132 : : __builtin_unreachable ();
15133 : : }
15134 : :
15135 : :
15136 : : /*
15137 : : GetDeclaredDefinition - returns the token where this symbol
15138 : : was declared in the definition module.
15139 : : */
15140 : :
15141 : 22882 : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym)
15142 : : {
15143 : 22882 : SymbolTable_PtrToSymbol pSym;
15144 : :
15145 : 22882 : pSym = GetPsym (Sym);
15146 : 22882 : switch (pSym->SymbolType)
15147 : : {
15148 : 0 : case SymbolTable_ErrorSym:
15149 : 0 : return pSym->Error.At.DefDeclared;
15150 : 0 : break;
15151 : :
15152 : 0 : case SymbolTable_ObjectSym:
15153 : 0 : return pSym->Object.At.DefDeclared;
15154 : 0 : break;
15155 : :
15156 : 0 : case SymbolTable_VarientSym:
15157 : 0 : return pSym->Varient.At.DefDeclared;
15158 : 6 : break;
15159 : :
15160 : 6 : case SymbolTable_RecordSym:
15161 : 6 : return pSym->Record.At.DefDeclared;
15162 : 0 : break;
15163 : :
15164 : 0 : case SymbolTable_SubrangeSym:
15165 : 0 : return pSym->Subrange.At.DefDeclared;
15166 : 0 : break;
15167 : :
15168 : 0 : case SymbolTable_EnumerationSym:
15169 : 0 : return pSym->Enumeration.At.DefDeclared;
15170 : 0 : break;
15171 : :
15172 : 0 : case SymbolTable_ArraySym:
15173 : 0 : return pSym->Array.At.DefDeclared;
15174 : 0 : break;
15175 : :
15176 : 0 : case SymbolTable_SubscriptSym:
15177 : 0 : return pSym->Subscript.At.DefDeclared;
15178 : 0 : break;
15179 : :
15180 : 0 : case SymbolTable_UnboundedSym:
15181 : 0 : return pSym->Unbounded.At.DefDeclared;
15182 : 0 : break;
15183 : :
15184 : 0 : case SymbolTable_ProcedureSym:
15185 : 0 : return pSym->Procedure.At.DefDeclared;
15186 : 0 : break;
15187 : :
15188 : 0 : case SymbolTable_ProcTypeSym:
15189 : 0 : return pSym->ProcType.At.DefDeclared;
15190 : 30 : break;
15191 : :
15192 : 30 : case SymbolTable_ParamSym:
15193 : 30 : return pSym->Param.At;
15194 : 0 : break;
15195 : :
15196 : 0 : case SymbolTable_VarParamSym:
15197 : 0 : return pSym->VarParam.At;
15198 : 0 : break;
15199 : :
15200 : 0 : case SymbolTable_ConstStringSym:
15201 : 0 : return pSym->ConstString.At.DefDeclared;
15202 : 0 : break;
15203 : :
15204 : 0 : case SymbolTable_ConstLitSym:
15205 : 0 : return pSym->ConstLit.At.DefDeclared;
15206 : 0 : break;
15207 : :
15208 : 0 : case SymbolTable_ConstVarSym:
15209 : 0 : return pSym->ConstVar.At.DefDeclared;
15210 : 0 : break;
15211 : :
15212 : 0 : case SymbolTable_VarSym:
15213 : 0 : return pSym->Var.At.DefDeclared;
15214 : 0 : break;
15215 : :
15216 : 0 : case SymbolTable_TypeSym:
15217 : 0 : return pSym->Type.At.DefDeclared;
15218 : 0 : break;
15219 : :
15220 : 0 : case SymbolTable_PointerSym:
15221 : 0 : return pSym->Pointer.At.DefDeclared;
15222 : 0 : break;
15223 : :
15224 : 0 : case SymbolTable_RecordFieldSym:
15225 : 0 : return pSym->RecordField.At.DefDeclared;
15226 : 0 : break;
15227 : :
15228 : 0 : case SymbolTable_VarientFieldSym:
15229 : 0 : return pSym->VarientField.At.DefDeclared;
15230 : 0 : break;
15231 : :
15232 : 0 : case SymbolTable_EnumerationFieldSym:
15233 : 0 : return pSym->EnumerationField.At.DefDeclared;
15234 : 0 : break;
15235 : :
15236 : 0 : case SymbolTable_SetSym:
15237 : 0 : return pSym->Set.At.DefDeclared;
15238 : 0 : break;
15239 : :
15240 : 0 : case SymbolTable_DefImpSym:
15241 : 0 : return pSym->DefImp.At.DefDeclared;
15242 : 0 : break;
15243 : :
15244 : 0 : case SymbolTable_ModuleSym:
15245 : 0 : return pSym->Module.At.DefDeclared;
15246 : 0 : break;
15247 : :
15248 : 0 : case SymbolTable_UndefinedSym:
15249 : 0 : return SymbolTable_GetFirstUsed (Sym);
15250 : 22846 : break;
15251 : :
15252 : 22846 : case SymbolTable_ImportSym:
15253 : 22846 : return pSym->Import.at.DefDeclared;
15254 : 0 : break;
15255 : :
15256 : 0 : case SymbolTable_ImportStatementSym:
15257 : 0 : return pSym->ImportStatement.at.DefDeclared;
15258 : 0 : break;
15259 : :
15260 : 0 : case SymbolTable_PartialUnboundedSym:
15261 : 0 : return SymbolTable_GetDeclaredDefinition (pSym->PartialUnbounded.Type);
15262 : 0 : break;
15263 : :
15264 : :
15265 : 0 : default:
15266 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15267 : : break;
15268 : : }
15269 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15270 : : __builtin_unreachable ();
15271 : : }
15272 : :
15273 : :
15274 : : /*
15275 : : GetDeclaredModule - returns the token where this symbol was declared
15276 : : in an implementation or program module.
15277 : : */
15278 : :
15279 : 35197083 : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym)
15280 : : {
15281 : 35197083 : SymbolTable_PtrToSymbol pSym;
15282 : :
15283 : 35197083 : pSym = GetPsym (Sym);
15284 : 35197083 : switch (pSym->SymbolType)
15285 : : {
15286 : 0 : case SymbolTable_ErrorSym:
15287 : 0 : return pSym->Error.At.ModDeclared;
15288 : 0 : break;
15289 : :
15290 : 0 : case SymbolTable_ObjectSym:
15291 : 0 : return pSym->Object.At.ModDeclared;
15292 : 5964 : break;
15293 : :
15294 : 5964 : case SymbolTable_VarientSym:
15295 : 5964 : return pSym->Varient.At.ModDeclared;
15296 : 299697 : break;
15297 : :
15298 : 299697 : case SymbolTable_RecordSym:
15299 : 299697 : return pSym->Record.At.ModDeclared;
15300 : 6170349 : break;
15301 : :
15302 : 6170349 : case SymbolTable_SubrangeSym:
15303 : 6170349 : return pSym->Subrange.At.ModDeclared;
15304 : 34964 : break;
15305 : :
15306 : 34964 : case SymbolTable_EnumerationSym:
15307 : 34964 : return pSym->Enumeration.At.ModDeclared;
15308 : 169327 : break;
15309 : :
15310 : 169327 : case SymbolTable_ArraySym:
15311 : 169327 : return pSym->Array.At.ModDeclared;
15312 : 0 : break;
15313 : :
15314 : 0 : case SymbolTable_SubscriptSym:
15315 : 0 : return pSym->Subscript.At.ModDeclared;
15316 : 46204 : break;
15317 : :
15318 : 46204 : case SymbolTable_UnboundedSym:
15319 : 46204 : return pSym->Unbounded.At.ModDeclared;
15320 : 5322939 : break;
15321 : :
15322 : 5322939 : case SymbolTable_ProcedureSym:
15323 : 5322939 : return pSym->Procedure.At.ModDeclared;
15324 : 58044 : break;
15325 : :
15326 : 58044 : case SymbolTable_ProcTypeSym:
15327 : 58044 : return pSym->ProcType.At.ModDeclared;
15328 : 75329 : break;
15329 : :
15330 : 75329 : case SymbolTable_ParamSym:
15331 : 75329 : return pSym->Param.At;
15332 : 540324 : break;
15333 : :
15334 : 540324 : case SymbolTable_VarParamSym:
15335 : 540324 : return pSym->VarParam.At;
15336 : 970113 : break;
15337 : :
15338 : 970113 : case SymbolTable_ConstStringSym:
15339 : 970113 : return pSym->ConstString.At.ModDeclared;
15340 : 1267633 : break;
15341 : :
15342 : 1267633 : case SymbolTable_ConstLitSym:
15343 : 1267633 : return pSym->ConstLit.At.ModDeclared;
15344 : 651972 : break;
15345 : :
15346 : 651972 : case SymbolTable_ConstVarSym:
15347 : 651972 : return pSym->ConstVar.At.ModDeclared;
15348 : 8184033 : break;
15349 : :
15350 : 8184033 : case SymbolTable_VarSym:
15351 : 8184033 : return pSym->Var.At.ModDeclared;
15352 : 38038 : break;
15353 : :
15354 : 38038 : case SymbolTable_TypeSym:
15355 : 38038 : return pSym->Type.At.ModDeclared;
15356 : 12 : break;
15357 : :
15358 : 12 : case SymbolTable_PointerSym:
15359 : 12 : return pSym->Pointer.At.ModDeclared;
15360 : 403530 : break;
15361 : :
15362 : 403530 : case SymbolTable_RecordFieldSym:
15363 : 403530 : return pSym->RecordField.At.ModDeclared;
15364 : 12156 : break;
15365 : :
15366 : 12156 : case SymbolTable_VarientFieldSym:
15367 : 12156 : return pSym->VarientField.At.ModDeclared;
15368 : 10556245 : break;
15369 : :
15370 : 10556245 : case SymbolTable_EnumerationFieldSym:
15371 : 10556245 : return pSym->EnumerationField.At.ModDeclared;
15372 : 339362 : break;
15373 : :
15374 : 339362 : case SymbolTable_SetSym:
15375 : 339362 : return pSym->Set.At.ModDeclared;
15376 : 7629 : break;
15377 : :
15378 : 7629 : case SymbolTable_DefImpSym:
15379 : 7629 : return pSym->DefImp.At.ModDeclared;
15380 : 22172 : break;
15381 : :
15382 : 22172 : case SymbolTable_ModuleSym:
15383 : 22172 : return pSym->Module.At.ModDeclared;
15384 : 0 : break;
15385 : :
15386 : 0 : case SymbolTable_UndefinedSym:
15387 : 0 : return SymbolTable_GetFirstUsed (Sym);
15388 : 21047 : break;
15389 : :
15390 : 21047 : case SymbolTable_ImportSym:
15391 : 21047 : return pSym->Import.at.ModDeclared;
15392 : 0 : break;
15393 : :
15394 : 0 : case SymbolTable_ImportStatementSym:
15395 : 0 : return pSym->ImportStatement.at.ModDeclared;
15396 : 0 : break;
15397 : :
15398 : 0 : case SymbolTable_PartialUnboundedSym:
15399 : 0 : return SymbolTable_GetDeclaredModule (pSym->PartialUnbounded.Type);
15400 : 0 : break;
15401 : :
15402 : :
15403 : 0 : default:
15404 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15405 : : break;
15406 : : }
15407 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15408 : : __builtin_unreachable ();
15409 : : }
15410 : :
15411 : :
15412 : : /*
15413 : : PutDeclared - adds an entry to symbol, Sym, indicating that it
15414 : : was declared at, tok. This routine
15415 : : may be called twice, once for definition module
15416 : : partial declaration and once when parsing the
15417 : : implementation module.
15418 : : */
15419 : :
15420 : 31461424 : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym)
15421 : : {
15422 : 31461424 : if (M2Comp_CompilingDefinitionModule ())
15423 : : {
15424 : 18565648 : PutDeclaredDefinition (tok, Sym);
15425 : : }
15426 : : else
15427 : : {
15428 : 12895776 : PutDeclaredModule (tok, Sym);
15429 : : }
15430 : 31461424 : }
15431 : :
15432 : :
15433 : : /*
15434 : : GetFirstUsed - returns the token where this symbol was first used.
15435 : : */
15436 : :
15437 : 504 : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym)
15438 : : {
15439 : 504 : SymbolTable_PtrToSymbol pSym;
15440 : :
15441 : 504 : pSym = GetPsym (Sym);
15442 : 504 : switch (pSym->SymbolType)
15443 : : {
15444 : 0 : case SymbolTable_ErrorSym:
15445 : 0 : return pSym->Error.At.FirstUsed;
15446 : 170 : break;
15447 : :
15448 : 170 : case SymbolTable_ObjectSym:
15449 : 170 : return pSym->Object.At.FirstUsed;
15450 : 322 : break;
15451 : :
15452 : 322 : case SymbolTable_UndefinedSym:
15453 : 322 : return pSym->Undefined.At.FirstUsed;
15454 : 0 : break;
15455 : :
15456 : 0 : case SymbolTable_VarientSym:
15457 : 0 : return pSym->Varient.At.FirstUsed;
15458 : 0 : break;
15459 : :
15460 : 0 : case SymbolTable_RecordSym:
15461 : 0 : return pSym->Record.At.FirstUsed;
15462 : 0 : break;
15463 : :
15464 : 0 : case SymbolTable_SubrangeSym:
15465 : 0 : return pSym->Subrange.At.FirstUsed;
15466 : 0 : break;
15467 : :
15468 : 0 : case SymbolTable_EnumerationSym:
15469 : 0 : return pSym->Enumeration.At.FirstUsed;
15470 : 0 : break;
15471 : :
15472 : 0 : case SymbolTable_ArraySym:
15473 : 0 : return pSym->Array.At.FirstUsed;
15474 : 0 : break;
15475 : :
15476 : 0 : case SymbolTable_SubscriptSym:
15477 : 0 : return pSym->Subscript.At.FirstUsed;
15478 : 0 : break;
15479 : :
15480 : 0 : case SymbolTable_UnboundedSym:
15481 : 0 : return pSym->Unbounded.At.FirstUsed;
15482 : 0 : break;
15483 : :
15484 : 0 : case SymbolTable_ProcedureSym:
15485 : 0 : return pSym->Procedure.At.FirstUsed;
15486 : 0 : break;
15487 : :
15488 : 0 : case SymbolTable_ProcTypeSym:
15489 : 0 : return pSym->ProcType.At.FirstUsed;
15490 : 0 : break;
15491 : :
15492 : 0 : case SymbolTable_ConstStringSym:
15493 : : /*
15494 : : ParamSym : RETURN( Param.At.FirstUsed ) |
15495 : : VarParamSym : RETURN( VarParam.At.FirstUsed ) |
15496 : : */
15497 : 0 : return pSym->ConstString.At.FirstUsed;
15498 : 0 : break;
15499 : :
15500 : 0 : case SymbolTable_ConstLitSym:
15501 : 0 : return pSym->ConstLit.At.FirstUsed;
15502 : 6 : break;
15503 : :
15504 : 6 : case SymbolTable_ConstVarSym:
15505 : 6 : return pSym->ConstVar.At.FirstUsed;
15506 : 6 : break;
15507 : :
15508 : 6 : case SymbolTable_VarSym:
15509 : 6 : return pSym->Var.At.FirstUsed;
15510 : 0 : break;
15511 : :
15512 : 0 : case SymbolTable_TypeSym:
15513 : 0 : return pSym->Type.At.FirstUsed;
15514 : 0 : break;
15515 : :
15516 : 0 : case SymbolTable_PointerSym:
15517 : 0 : return pSym->Pointer.At.FirstUsed;
15518 : 0 : break;
15519 : :
15520 : 0 : case SymbolTable_RecordFieldSym:
15521 : 0 : return pSym->RecordField.At.FirstUsed;
15522 : 0 : break;
15523 : :
15524 : 0 : case SymbolTable_VarientFieldSym:
15525 : 0 : return pSym->VarientField.At.FirstUsed;
15526 : 0 : break;
15527 : :
15528 : 0 : case SymbolTable_EnumerationFieldSym:
15529 : 0 : return pSym->EnumerationField.At.FirstUsed;
15530 : 0 : break;
15531 : :
15532 : 0 : case SymbolTable_SetSym:
15533 : 0 : return pSym->Set.At.FirstUsed;
15534 : 0 : break;
15535 : :
15536 : 0 : case SymbolTable_DefImpSym:
15537 : 0 : return pSym->DefImp.At.FirstUsed;
15538 : 0 : break;
15539 : :
15540 : 0 : case SymbolTable_ModuleSym:
15541 : 0 : return pSym->Module.At.FirstUsed;
15542 : 0 : break;
15543 : :
15544 : :
15545 : 0 : default:
15546 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15547 : : break;
15548 : : }
15549 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15550 : : __builtin_unreachable ();
15551 : : }
15552 : :
15553 : :
15554 : : /*
15555 : : PutProcedureBegin - assigns begin as the token number matching the
15556 : : procedure BEGIN.
15557 : : */
15558 : :
15559 : 79953 : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin)
15560 : : {
15561 : 79953 : SymbolTable_PtrToSymbol pSym;
15562 : :
15563 : 79953 : pSym = GetPsym (Sym);
15564 : 79953 : switch (pSym->SymbolType)
15565 : : {
15566 : 79953 : case SymbolTable_ProcedureSym:
15567 : 79953 : pSym->Procedure.Begin = begin;
15568 : 79953 : break;
15569 : :
15570 : :
15571 : 0 : default:
15572 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15573 : 79953 : break;
15574 : : }
15575 : 79953 : }
15576 : :
15577 : :
15578 : : /*
15579 : : PutProcedureEnd - assigns end as the token number matching the
15580 : : procedure END.
15581 : : */
15582 : :
15583 : 79923 : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end)
15584 : : {
15585 : 79923 : SymbolTable_PtrToSymbol pSym;
15586 : :
15587 : 79923 : pSym = GetPsym (Sym);
15588 : 79923 : switch (pSym->SymbolType)
15589 : : {
15590 : 79923 : case SymbolTable_ProcedureSym:
15591 : 79923 : pSym->Procedure.End = end;
15592 : 79923 : break;
15593 : :
15594 : :
15595 : 0 : default:
15596 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15597 : 79923 : break;
15598 : : }
15599 : 79923 : }
15600 : :
15601 : :
15602 : : /*
15603 : : GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
15604 : : */
15605 : :
15606 : 3916923 : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end)
15607 : : {
15608 : 3916923 : SymbolTable_PtrToSymbol pSym;
15609 : :
15610 : 3916923 : pSym = GetPsym (Sym);
15611 : 3916923 : switch (pSym->SymbolType)
15612 : : {
15613 : 3916923 : case SymbolTable_ProcedureSym:
15614 : 3916923 : (*begin) = pSym->Procedure.Begin;
15615 : 3916923 : (*end) = pSym->Procedure.End;
15616 : 3916923 : break;
15617 : :
15618 : :
15619 : 0 : default:
15620 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15621 : 3916923 : break;
15622 : : }
15623 : 3916923 : }
15624 : :
15625 : :
15626 : : /*
15627 : : ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
15628 : : */
15629 : :
15630 : 2834797 : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P)
15631 : : {
15632 : 2834797 : SymbolTable_PtrToSymbol pSym;
15633 : :
15634 : 2834797 : pSym = GetPsym (Sym);
15635 : 2834797 : switch (pSym->SymbolType)
15636 : : {
15637 : 435290 : case SymbolTable_DefImpSym:
15638 : 435290 : Lists_ForeachItemInListDo (pSym->DefImp.ListOfProcs, P);
15639 : 435290 : break;
15640 : :
15641 : 110240 : case SymbolTable_ModuleSym:
15642 : 110240 : Lists_ForeachItemInListDo (pSym->Module.ListOfProcs, P);
15643 : 110240 : break;
15644 : :
15645 : 2289267 : case SymbolTable_ProcedureSym:
15646 : 2289267 : Lists_ForeachItemInListDo (pSym->Procedure.ListOfProcs, P);
15647 : 2289267 : break;
15648 : :
15649 : :
15650 : 0 : default:
15651 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
15652 : 2834779 : break;
15653 : : }
15654 : 2834779 : }
15655 : :
15656 : :
15657 : : /*
15658 : : ForeachModuleDo - for each module do procedure, P.
15659 : : */
15660 : :
15661 : 47625 : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P)
15662 : : {
15663 : 47625 : SymbolKey_ForeachNodeDo (ModuleTree, P);
15664 : 47625 : }
15665 : :
15666 : :
15667 : : /*
15668 : : ForeachInnerModuleDo - for each inner module in module, Sym,
15669 : : do procedure, P.
15670 : : */
15671 : :
15672 : 3278611 : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P)
15673 : : {
15674 : 3278611 : SymbolTable_PtrToSymbol pSym;
15675 : :
15676 : 3278611 : pSym = GetPsym (Sym);
15677 : 3278611 : switch (pSym->SymbolType)
15678 : : {
15679 : 442706 : case SymbolTable_DefImpSym:
15680 : 442706 : Lists_ForeachItemInListDo (pSym->DefImp.ListOfModules, P);
15681 : 442706 : break;
15682 : :
15683 : 165490 : case SymbolTable_ModuleSym:
15684 : 165490 : Lists_ForeachItemInListDo (pSym->Module.ListOfModules, P);
15685 : 165490 : break;
15686 : :
15687 : 2670415 : case SymbolTable_ProcedureSym:
15688 : 2670415 : Lists_ForeachItemInListDo (pSym->Procedure.ListOfModules, P);
15689 : 2670415 : break;
15690 : :
15691 : :
15692 : 0 : default:
15693 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
15694 : 3278611 : break;
15695 : : }
15696 : 3278611 : }
15697 : :
15698 : :
15699 : : /*
15700 : : IsVarParam - Returns a conditional depending whether parameter ParamNo
15701 : : is a VAR parameter.
15702 : : */
15703 : :
15704 : 11239134 : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
15705 : : {
15706 : 11239134 : SymbolTable_PtrToSymbol pSym;
15707 : 11239134 : bool IsVar;
15708 : :
15709 : 11239134 : IsVar = false;
15710 : 11239134 : pSym = GetPsym (Sym);
15711 : 11239134 : switch (pSym->SymbolType)
15712 : : {
15713 : : case SymbolTable_ErrorSym:
15714 : : break;
15715 : :
15716 : 11239134 : case SymbolTable_ProcedureSym:
15717 : 11239134 : IsVar = IsNthParamVar (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo);
15718 : 11239134 : break;
15719 : :
15720 : 0 : case SymbolTable_ProcTypeSym:
15721 : 0 : IsVar = IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
15722 : 0 : break;
15723 : :
15724 : :
15725 : 0 : default:
15726 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15727 : 11239134 : break;
15728 : : }
15729 : 11239134 : return IsVar;
15730 : : /* static analysis guarentees a RETURN statement will be used before here. */
15731 : : __builtin_unreachable ();
15732 : : }
15733 : :
15734 : :
15735 : : /*
15736 : : IsVarParamAny - Returns a conditional depending whether parameter ParamNo
15737 : : is a VAR parameter.
15738 : : */
15739 : :
15740 : 10630238 : extern "C" bool SymbolTable_IsVarParamAny (unsigned int Sym, unsigned int ParamNo)
15741 : : {
15742 : 10630238 : SymbolTable_PtrToSymbol pSym;
15743 : 10630238 : SymbolTable_ProcedureKind kind;
15744 : :
15745 : 10630238 : pSym = GetPsym (Sym);
15746 : 10630238 : switch (pSym->SymbolType)
15747 : : {
15748 : : case SymbolTable_ErrorSym:
15749 : : break;
15750 : :
15751 : : case SymbolTable_ProcedureSym:
15752 : 23270459 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
15753 : : {
15754 : 22435787 : if (SymbolTable_GetProcedureDefined (Sym, kind))
15755 : : {
15756 : 9228879 : return IsNthParamVar (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo);
15757 : : }
15758 : : }
15759 : : break;
15760 : :
15761 : 566687 : case SymbolTable_ProcTypeSym:
15762 : 566687 : return IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
15763 : 0 : break;
15764 : :
15765 : :
15766 : 0 : default:
15767 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15768 : : break;
15769 : : }
15770 : : return false;
15771 : : /* static analysis guarentees a RETURN statement will be used before here. */
15772 : : __builtin_unreachable ();
15773 : : }
15774 : :
15775 : :
15776 : : /*
15777 : : IsUnboundedParam - Returns a conditional depending whether parameter
15778 : : ParamNo is an unbounded array procedure parameter.
15779 : : */
15780 : :
15781 : 22918188 : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
15782 : : {
15783 : 22918188 : unsigned int param;
15784 : :
15785 : 22918188 : param = SymbolTable_GetNthParam (Sym, kind, ParamNo);
15786 : 22918188 : return SymbolTable_IsParameterUnbounded (param);
15787 : : /* static analysis guarentees a RETURN statement will be used before here. */
15788 : : __builtin_unreachable ();
15789 : : }
15790 : :
15791 : 19775673 : extern "C" bool SymbolTable_IsUnboundedParamAny (unsigned int Sym, unsigned int ParamNo)
15792 : : {
15793 : 19775673 : SymbolTable_ProcedureKind kind;
15794 : :
15795 : 40282537 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
15796 : : {
15797 : : /*
15798 : : IsUnboundedParam - Returns a conditional depending whether parameter
15799 : : ParamNo is an unbounded array procedure parameter.
15800 : : */
15801 : 40282537 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
15802 : : {
15803 : 19775673 : return SymbolTable_IsUnboundedParam (Sym, kind, ParamNo);
15804 : : }
15805 : : }
15806 : 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
15807 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15808 : : __builtin_unreachable ();
15809 : : }
15810 : :
15811 : :
15812 : : /*
15813 : : IsParameterUnbounded - returns TRUE if parameter, Sym, is
15814 : : unbounded.
15815 : : */
15816 : :
15817 : 22918200 : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym)
15818 : : {
15819 : 22918200 : SymbolTable_PtrToSymbol pSym;
15820 : :
15821 : 22918200 : pSym = GetPsym (Sym);
15822 : 22918200 : switch (pSym->SymbolType)
15823 : : {
15824 : 20390003 : case SymbolTable_ParamSym:
15825 : 20390003 : return pSym->Param.IsUnbounded;
15826 : 2528197 : break;
15827 : :
15828 : 2528197 : case SymbolTable_VarParamSym:
15829 : 2528197 : return pSym->VarParam.IsUnbounded;
15830 : 0 : break;
15831 : :
15832 : :
15833 : 0 : default:
15834 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
15835 : : break;
15836 : : }
15837 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15838 : : __builtin_unreachable ();
15839 : : }
15840 : :
15841 : :
15842 : : /*
15843 : : IsParameterVar - returns true if parameter symbol Sym
15844 : : was declared as a VAR.
15845 : : */
15846 : :
15847 : 204 : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym)
15848 : : {
15849 : 204 : SymbolTable_PtrToSymbol pSym;
15850 : :
15851 : 204 : pSym = GetPsym (Sym);
15852 : 204 : switch (pSym->SymbolType)
15853 : : {
15854 : : case SymbolTable_ParamSym:
15855 : : return false;
15856 : 24 : break;
15857 : :
15858 : 24 : case SymbolTable_VarParamSym:
15859 : 24 : return true;
15860 : 0 : break;
15861 : :
15862 : :
15863 : 0 : default:
15864 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
15865 : : break;
15866 : : }
15867 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15868 : : __builtin_unreachable ();
15869 : : }
15870 : :
15871 : :
15872 : : /*
15873 : : GetParameterShadowVar - returns the local variable associated with the
15874 : : parameter symbol, sym.
15875 : : */
15876 : :
15877 : 46900 : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym)
15878 : : {
15879 : 46900 : SymbolTable_PtrToSymbol pSym;
15880 : :
15881 : 46900 : pSym = GetPsym (sym);
15882 : 46900 : switch (pSym->SymbolType)
15883 : : {
15884 : 39724 : case SymbolTable_ParamSym:
15885 : 39724 : return pSym->Param.ShadowVar;
15886 : 7176 : break;
15887 : :
15888 : 7176 : case SymbolTable_VarParamSym:
15889 : 7176 : return pSym->VarParam.ShadowVar;
15890 : 0 : break;
15891 : :
15892 : :
15893 : 0 : default:
15894 : 0 : M2Error_InternalError ((const char *) "expecting a ParamSym or VarParamSym", 35);
15895 : : break;
15896 : : }
15897 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15898 : : __builtin_unreachable ();
15899 : : }
15900 : :
15901 : :
15902 : : /*
15903 : : NoOfParam - Returns the number of parameters that procedure Sym contains.
15904 : : */
15905 : :
15906 : 26426298 : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym, SymbolTable_ProcedureKind kind)
15907 : : {
15908 : 26426298 : SymbolTable_PtrToSymbol pSym;
15909 : 26426298 : unsigned int n;
15910 : :
15911 : 26426298 : AssertInRange (Sym);
15912 : 26426298 : pSym = GetPsym (Sym);
15913 : 26426298 : switch (pSym->SymbolType)
15914 : : {
15915 : : case SymbolTable_ErrorSym:
15916 : : n = 0;
15917 : : break;
15918 : :
15919 : 26426298 : case SymbolTable_ProcedureSym:
15920 : 26426298 : n = Lists_NoOfItemsInList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam);
15921 : 26426298 : break;
15922 : :
15923 : 0 : case SymbolTable_ProcTypeSym:
15924 : 0 : n = Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
15925 : 0 : break;
15926 : :
15927 : :
15928 : 0 : default:
15929 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15930 : 26426298 : break;
15931 : : }
15932 : 26426298 : return n;
15933 : : /* static analysis guarentees a RETURN statement will be used before here. */
15934 : : __builtin_unreachable ();
15935 : : }
15936 : :
15937 : :
15938 : : /*
15939 : : HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
15940 : : */
15941 : :
15942 : 0 : extern "C" bool SymbolTable_HasVarParameters (unsigned int p)
15943 : : {
15944 : 0 : unsigned int i;
15945 : 0 : unsigned int n;
15946 : :
15947 : 0 : n = SymbolTable_NoOfParamAny (p);
15948 : 0 : i = 1;
15949 : 0 : while (i <= n)
15950 : : {
15951 : 0 : if (SymbolTable_IsParameterVar (SymbolTable_GetNthParamAny (p, i)))
15952 : : {
15953 : : return true;
15954 : : }
15955 : 0 : i += 1;
15956 : : }
15957 : : return false;
15958 : : /* static analysis guarentees a RETURN statement will be used before here. */
15959 : : __builtin_unreachable ();
15960 : : }
15961 : :
15962 : :
15963 : : /*
15964 : : NoOfLocalVar - returns the number of local variables that exist in
15965 : : procedure Sym. Parameters are NOT included in the
15966 : : count.
15967 : : */
15968 : :
15969 : 30 : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym)
15970 : : {
15971 : 30 : SymbolTable_PtrToSymbol pSym;
15972 : 30 : unsigned int n;
15973 : :
15974 : 30 : pSym = GetPsym (Sym);
15975 : 30 : switch (pSym->SymbolType)
15976 : : {
15977 : : case SymbolTable_ErrorSym:
15978 : : n = 0;
15979 : : break;
15980 : :
15981 : 30 : case SymbolTable_ProcedureSym:
15982 : 30 : n = Lists_NoOfItemsInList (pSym->Procedure.ListOfVars);
15983 : 30 : break;
15984 : :
15985 : :
15986 : 0 : default:
15987 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15988 : 30 : break;
15989 : : }
15990 : : /*
15991 : : Parameters are actually included in the list of local varaibles,
15992 : : therefore we must subtract the Parameter Number from local variable
15993 : : total.
15994 : : */
15995 : 30 : return n-(SymbolTable_NoOfParamAny (Sym));
15996 : : /* static analysis guarentees a RETURN statement will be used before here. */
15997 : : __builtin_unreachable ();
15998 : : }
15999 : :
16000 : :
16001 : : /*
16002 : : IsDefImp - returns true is the Sym is a DefImp symbol.
16003 : : Definition/Implementation module symbol.
16004 : : */
16005 : :
16006 : 353338130 : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym)
16007 : : {
16008 : 353338130 : SymbolTable_PtrToSymbol pSym;
16009 : :
16010 : 353338130 : pSym = GetPsym (Sym);
16011 : 353338130 : return pSym->SymbolType == SymbolTable_DefImpSym;
16012 : : /* static analysis guarentees a RETURN statement will be used before here. */
16013 : : __builtin_unreachable ();
16014 : : }
16015 : :
16016 : :
16017 : : /*
16018 : : IsModule - returns true is the Sym is a Module symbol.
16019 : : Program module symbol.
16020 : : */
16021 : :
16022 : 292835686 : extern "C" bool SymbolTable_IsModule (unsigned int Sym)
16023 : : {
16024 : 292835686 : SymbolTable_PtrToSymbol pSym;
16025 : :
16026 : 292835686 : pSym = GetPsym (Sym);
16027 : 292835686 : return pSym->SymbolType == SymbolTable_ModuleSym;
16028 : : /* static analysis guarentees a RETURN statement will be used before here. */
16029 : : __builtin_unreachable ();
16030 : : }
16031 : :
16032 : :
16033 : : /*
16034 : : IsInnerModule - returns true if the symbol, Sym, is an inner module.
16035 : : */
16036 : :
16037 : 10119341 : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym)
16038 : : {
16039 : 10119341 : if (SymbolTable_IsModule (Sym))
16040 : : {
16041 : 225258 : return (SymbolTable_GetScope (Sym)) != SymbolTable_NulSym;
16042 : : }
16043 : : else
16044 : : {
16045 : : return false;
16046 : : }
16047 : : /* static analysis guarentees a RETURN statement will be used before here. */
16048 : : __builtin_unreachable ();
16049 : : }
16050 : :
16051 : :
16052 : : /*
16053 : : GetSymName - returns the symbol name.
16054 : : */
16055 : :
16056 : 1129210702 : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym)
16057 : : {
16058 : 1129210702 : SymbolTable_PtrToSymbol pSym;
16059 : 1129210702 : NameKey_Name n;
16060 : :
16061 : 1129210702 : if (Sym == SymbolTable_NulSym)
16062 : : {
16063 : : n = SymbolKey_NulKey;
16064 : : }
16065 : : else
16066 : : {
16067 : 1129210702 : pSym = GetPsym (Sym);
16068 : 1129210702 : switch (pSym->SymbolType)
16069 : : {
16070 : 327 : case SymbolTable_ErrorSym:
16071 : 327 : n = pSym->Error.name;
16072 : 327 : break;
16073 : :
16074 : 14526561 : case SymbolTable_ObjectSym:
16075 : 14526561 : n = pSym->Object.name;
16076 : 14526561 : break;
16077 : :
16078 : 8162591 : case SymbolTable_DefImpSym:
16079 : 8162591 : n = pSym->DefImp.name;
16080 : 8162591 : break;
16081 : :
16082 : 505475 : case SymbolTable_ModuleSym:
16083 : 505475 : n = pSym->Module.name;
16084 : 505475 : break;
16085 : :
16086 : 871811970 : case SymbolTable_TypeSym:
16087 : 871811970 : n = pSym->Type.name;
16088 : 871811970 : break;
16089 : :
16090 : 9921664 : case SymbolTable_VarSym:
16091 : 9921664 : n = pSym->Var.name;
16092 : 9921664 : break;
16093 : :
16094 : 14937 : case SymbolTable_ConstLitSym:
16095 : 14937 : n = pSym->ConstLit.name;
16096 : 14937 : break;
16097 : :
16098 : 149938 : case SymbolTable_ConstVarSym:
16099 : 149938 : n = pSym->ConstVar.name;
16100 : 149938 : break;
16101 : :
16102 : 14025 : case SymbolTable_ConstStringSym:
16103 : 14025 : n = pSym->ConstString.name;
16104 : 14025 : break;
16105 : :
16106 : 1705379 : case SymbolTable_EnumerationSym:
16107 : 1705379 : n = pSym->Enumeration.name;
16108 : 1705379 : break;
16109 : :
16110 : 1525781 : case SymbolTable_EnumerationFieldSym:
16111 : 1525781 : n = pSym->EnumerationField.name;
16112 : 1525781 : break;
16113 : :
16114 : 14279636 : case SymbolTable_UndefinedSym:
16115 : 14279636 : n = pSym->Undefined.name;
16116 : 14279636 : break;
16117 : :
16118 : 50372631 : case SymbolTable_ProcedureSym:
16119 : 50372631 : n = pSym->Procedure.name;
16120 : 50372631 : break;
16121 : :
16122 : 552269 : case SymbolTable_ProcTypeSym:
16123 : 552269 : n = pSym->ProcType.name;
16124 : 552269 : break;
16125 : :
16126 : 1207870 : case SymbolTable_RecordFieldSym:
16127 : 1207870 : n = pSym->RecordField.name;
16128 : 1207870 : break;
16129 : :
16130 : 424688 : case SymbolTable_RecordSym:
16131 : 424688 : n = pSym->Record.name;
16132 : 424688 : break;
16133 : :
16134 : : case SymbolTable_VarientSym:
16135 : : n = NameKey_NulName;
16136 : : break;
16137 : :
16138 : 16998 : case SymbolTable_VarientFieldSym:
16139 : 16998 : n = pSym->VarientField.name;
16140 : 16998 : break;
16141 : :
16142 : 12223 : case SymbolTable_VarParamSym:
16143 : 12223 : n = pSym->VarParam.name;
16144 : 12223 : break;
16145 : :
16146 : 122742 : case SymbolTable_ParamSym:
16147 : 122742 : n = pSym->Param.name;
16148 : 122742 : break;
16149 : :
16150 : 62286626 : case SymbolTable_PointerSym:
16151 : 62286626 : n = pSym->Pointer.name;
16152 : 62286626 : break;
16153 : :
16154 : 99656 : case SymbolTable_ArraySym:
16155 : 99656 : n = pSym->Array.name;
16156 : 99656 : break;
16157 : :
16158 : : case SymbolTable_UnboundedSym:
16159 : : n = NameKey_NulName;
16160 : : break;
16161 : :
16162 : 440606 : case SymbolTable_SubrangeSym:
16163 : 440606 : n = pSym->Subrange.name;
16164 : 440606 : break;
16165 : :
16166 : 83971843 : case SymbolTable_SetSym:
16167 : 83971843 : n = pSym->Set.name;
16168 : 83971843 : break;
16169 : :
16170 : : case SymbolTable_SubscriptSym:
16171 : : n = NameKey_NulName;
16172 : : break;
16173 : :
16174 : : case SymbolTable_DummySym:
16175 : : n = NameKey_NulName;
16176 : : break;
16177 : :
16178 : 0 : case SymbolTable_PartialUnboundedSym:
16179 : 0 : n = SymbolTable_GetSymName (pSym->PartialUnbounded.Type);
16180 : 0 : break;
16181 : :
16182 : : case SymbolTable_TupleSym:
16183 : : n = NameKey_NulName;
16184 : : break;
16185 : :
16186 : : case SymbolTable_GnuAsmSym:
16187 : : n = NameKey_NulName;
16188 : : break;
16189 : :
16190 : : case SymbolTable_InterfaceSym:
16191 : : n = NameKey_NulName;
16192 : : break;
16193 : :
16194 : : case SymbolTable_ImportSym:
16195 : : n = NameKey_NulName;
16196 : : break;
16197 : :
16198 : : case SymbolTable_ImportStatementSym:
16199 : : n = NameKey_NulName;
16200 : : break;
16201 : :
16202 : :
16203 : 0 : default:
16204 : 0 : M2Error_InternalError ((const char *) "unexpected symbol type", 22);
16205 : 1129210702 : break;
16206 : : }
16207 : : }
16208 : 1129210702 : return n;
16209 : : /* static analysis guarentees a RETURN statement will be used before here. */
16210 : : __builtin_unreachable ();
16211 : : }
16212 : :
16213 : :
16214 : : /*
16215 : : RenameSym - renames a symbol, Sym, with SymName.
16216 : : It also checks the unknown tree for a symbol
16217 : : with this new name. Must only be renamed in
16218 : : the same scope of being declared.
16219 : : */
16220 : :
16221 : 0 : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName)
16222 : : {
16223 : 0 : SymbolTable_PtrToSymbol pSym;
16224 : :
16225 : 0 : if ((SymbolTable_GetSymName (Sym)) == NameKey_NulName)
16226 : : {
16227 : 0 : pSym = GetPsym (Sym);
16228 : 0 : switch (pSym->SymbolType)
16229 : : {
16230 : 0 : case SymbolTable_ErrorSym:
16231 : 0 : M2Error_ErrorAbort0 ((const char *) "", 0);
16232 : 0 : break;
16233 : :
16234 : 0 : case SymbolTable_TypeSym:
16235 : 0 : pSym->Type.name = SymName;
16236 : 0 : break;
16237 : :
16238 : 0 : case SymbolTable_VarSym:
16239 : 0 : pSym->Var.name = SymName;
16240 : 0 : break;
16241 : :
16242 : 0 : case SymbolTable_ConstLitSym:
16243 : 0 : pSym->ConstLit.name = SymName;
16244 : 0 : break;
16245 : :
16246 : 0 : case SymbolTable_ConstVarSym:
16247 : 0 : pSym->ConstVar.name = SymName;
16248 : 0 : break;
16249 : :
16250 : 0 : case SymbolTable_UndefinedSym:
16251 : 0 : pSym->Undefined.name = SymName;
16252 : 0 : break;
16253 : :
16254 : 0 : case SymbolTable_RecordSym:
16255 : 0 : pSym->Record.name = SymName;
16256 : 0 : break;
16257 : :
16258 : 0 : case SymbolTable_PointerSym:
16259 : 0 : pSym->Pointer.name = SymName;
16260 : 0 : break;
16261 : :
16262 : :
16263 : 0 : default:
16264 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
16265 : 0 : break;
16266 : : }
16267 : 0 : AddSymToScope (Sym, SymName);
16268 : : }
16269 : : else
16270 : : {
16271 : 0 : M2Error_InternalError ((const char *) "old name of symbol must be nul", 30);
16272 : : }
16273 : 0 : }
16274 : :
16275 : :
16276 : : /*
16277 : : IsUnknown - returns true is the symbol Sym is unknown.
16278 : : */
16279 : :
16280 : 50023565 : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym)
16281 : : {
16282 : 50023565 : SymbolTable_PtrToSymbol pSym;
16283 : :
16284 : 50023565 : AssertInRange (Sym);
16285 : 50023565 : pSym = GetPsym (Sym);
16286 : 50023565 : return pSym->SymbolType == SymbolTable_UndefinedSym;
16287 : : /* static analysis guarentees a RETURN statement will be used before here. */
16288 : : __builtin_unreachable ();
16289 : : }
16290 : :
16291 : :
16292 : : /*
16293 : : IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
16294 : : */
16295 : :
16296 : 1011934 : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym)
16297 : : {
16298 : 1011934 : SymbolTable_PtrToSymbol pSym;
16299 : :
16300 : 1011934 : if (sym > 0)
16301 : : {
16302 : 1011934 : pSym = GetPsym (sym);
16303 : 1011934 : switch (pSym->SymbolType)
16304 : : {
16305 : : case SymbolTable_PartialUnboundedSym:
16306 : : return true;
16307 : : break;
16308 : :
16309 : :
16310 : : default:
16311 : : return false;
16312 : : break;
16313 : : }
16314 : : }
16315 : : else
16316 : : {
16317 : : return false;
16318 : : }
16319 : : /* static analysis guarentees a RETURN statement will be used before here. */
16320 : : __builtin_unreachable ();
16321 : : }
16322 : :
16323 : :
16324 : : /*
16325 : : RequestSym - searches for a symbol with a name SymName in the
16326 : : current and previous scopes.
16327 : : If the symbol is found then it is returned
16328 : : else an unknown symbol is returned create at token
16329 : : position, tok.
16330 : : This procedure does search the base scope (for
16331 : : pervasive identifiers).
16332 : : */
16333 : :
16334 : 46303764 : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName)
16335 : : {
16336 : 46303764 : unsigned int Sym;
16337 : :
16338 : : /*
16339 : : WriteString('RequestSym for: ') ; WriteKey(SymName) ; WriteLn ;
16340 : : */
16341 : 46303764 : Sym = SymbolTable_GetSym (SymName);
16342 : 46303764 : if (Sym == SymbolTable_NulSym)
16343 : : {
16344 : 6951550 : Sym = GetSymFromUnknownTree (SymName);
16345 : 6951550 : if (Sym == SymbolTable_NulSym)
16346 : : {
16347 : : /* Make unknown. */
16348 : 6951550 : NewSym (&Sym);
16349 : 6951550 : FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
16350 : : /*
16351 : : ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
16352 : : */
16353 : 6951550 : AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
16354 : : }
16355 : : }
16356 : 46303764 : return Sym;
16357 : : /* static analysis guarentees a RETURN statement will be used before here. */
16358 : : __builtin_unreachable ();
16359 : : }
16360 : :
16361 : :
16362 : : /*
16363 : : PutImported - places a symbol, Sym, into the current main scope.
16364 : : */
16365 : :
16366 : 988426 : extern "C" void SymbolTable_PutImported (unsigned int Sym)
16367 : : {
16368 : 988426 : SymbolTable_PtrToSymbol pSym;
16369 : 988426 : unsigned int ModSym;
16370 : 988426 : NameKey_Name n;
16371 : :
16372 : : /*
16373 : : We have currently imported Sym, now place it into the current module.
16374 : : */
16375 : 988426 : ModSym = SymbolTable_GetCurrentModuleScope ();
16376 : 1976852 : M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
16377 : 988426 : pSym = GetPsym (ModSym);
16378 : 988426 : switch (pSym->SymbolType)
16379 : : {
16380 : 101568 : case SymbolTable_ModuleSym:
16381 : 101568 : if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
16382 : : {
16383 : : /* avoid dangling else. */
16384 : 90 : if (M2Options_Pedantic)
16385 : : {
16386 : 6 : n = SymbolTable_GetSymName (Sym);
16387 : 6 : M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
16388 : : }
16389 : : }
16390 : 101478 : else if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
16391 : : {
16392 : : /* avoid dangling else. */
16393 : 101478 : if ((SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym)) == SymbolKey_NulKey)
16394 : : {
16395 : 101478 : SymbolKey_PutSymKey (pSym->Module.WhereImported, Sym, M2LexBuf_GetTokenNo ());
16396 : : }
16397 : 101478 : SymbolKey_PutSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym), Sym);
16398 : 101478 : SymbolTable_AddSymToModuleScope (ModSym, Sym);
16399 : : }
16400 : : else
16401 : : {
16402 : : /* avoid dangling else. */
16403 : 0 : n = SymbolTable_GetSymName (Sym);
16404 : 0 : M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
16405 : : }
16406 : : break;
16407 : :
16408 : 886858 : case SymbolTable_DefImpSym:
16409 : 886858 : if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
16410 : : {
16411 : : /* avoid dangling else. */
16412 : 97 : if (M2Options_Pedantic)
16413 : : {
16414 : 0 : n = SymbolTable_GetSymName (Sym);
16415 : 0 : M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
16416 : : }
16417 : : }
16418 : 886761 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
16419 : : {
16420 : : /* avoid dangling else. */
16421 : 886761 : if ((SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym)) == SymbolKey_NulKey)
16422 : : {
16423 : 886761 : SymbolKey_PutSymKey (pSym->DefImp.WhereImported, Sym, M2LexBuf_GetTokenNo ());
16424 : : }
16425 : 886761 : SymbolKey_PutSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym), Sym);
16426 : 886761 : SymbolTable_AddSymToModuleScope (ModSym, Sym);
16427 : : }
16428 : : else
16429 : : {
16430 : : /* avoid dangling else. */
16431 : 0 : n = SymbolTable_GetSymName (Sym);
16432 : 0 : M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
16433 : : }
16434 : : break;
16435 : :
16436 : :
16437 : 0 : default:
16438 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
16439 : 988426 : break;
16440 : : }
16441 : 988426 : }
16442 : :
16443 : :
16444 : : /*
16445 : : PutIncluded - places a symbol, Sym, into the included list of the
16446 : : current module.
16447 : : Symbols that are placed in this list are indirectly declared
16448 : : by:
16449 : :
16450 : : IMPORT modulename ;
16451 : :
16452 : : modulename.identifier
16453 : : */
16454 : :
16455 : 767576 : extern "C" void SymbolTable_PutIncluded (unsigned int Sym)
16456 : : {
16457 : 767576 : SymbolTable_PtrToSymbol pSym;
16458 : 767576 : unsigned int ModSym;
16459 : 767576 : NameKey_Name n1;
16460 : 767576 : NameKey_Name n2;
16461 : :
16462 : : /*
16463 : : We have referenced Sym, via modulename.Sym
16464 : : now place it into the current module include list.
16465 : : */
16466 : 767576 : ModSym = SymbolTable_GetCurrentModuleScope ();
16467 : 1535152 : M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
16468 : 767576 : if (DebugUnknowns)
16469 : : {
16470 : : n1 = SymbolTable_GetSymName (Sym);
16471 : : n2 = SymbolTable_GetSymName (ModSym);
16472 : : 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));
16473 : : }
16474 : 767576 : pSym = GetPsym (ModSym);
16475 : 767576 : switch (pSym->SymbolType)
16476 : : {
16477 : 4634 : case SymbolTable_ModuleSym:
16478 : 4634 : Lists_IncludeItemIntoList (pSym->Module.IncludeList, Sym);
16479 : 4634 : break;
16480 : :
16481 : 762942 : case SymbolTable_DefImpSym:
16482 : 762942 : Lists_IncludeItemIntoList (pSym->DefImp.IncludeList, Sym);
16483 : 762942 : break;
16484 : :
16485 : :
16486 : 0 : default:
16487 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
16488 : 767576 : break;
16489 : : }
16490 : 767576 : }
16491 : :
16492 : :
16493 : : /*
16494 : : PutExported - places a symbol, Sym into the next level out module.
16495 : : Sym is also placed in the ExportTree of the current inner
16496 : : module.
16497 : : */
16498 : :
16499 : 276 : extern "C" void SymbolTable_PutExported (unsigned int Sym)
16500 : : {
16501 : 276 : SymbolTable_PtrToSymbol pSym;
16502 : :
16503 : : /*
16504 : : WriteString('PutExported') ; WriteLn ;
16505 : : */
16506 : 276 : SymbolTable_AddSymToModuleScope (GetLastModuleOrProcedureScope (), Sym);
16507 : 276 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
16508 : 276 : switch (pSym->SymbolType)
16509 : : {
16510 : 276 : case SymbolTable_ModuleSym:
16511 : 276 : SymbolKey_PutSymKey (pSym->Module.ExportTree, SymbolTable_GetSymName (Sym), Sym);
16512 : 276 : if (SymbolTable_IsUnknown (Sym))
16513 : : {
16514 : 276 : PutExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
16515 : : }
16516 : : /*
16517 : : ; WriteKey(Module.name) ; WriteString(' exports ') ;
16518 : : ; WriteKey(GetSymName(Sym)) ; WriteLn ;
16519 : : */
16520 : 276 : break;
16521 : :
16522 : :
16523 : 0 : default:
16524 : 0 : M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
16525 : 276 : break;
16526 : : }
16527 : 276 : }
16528 : :
16529 : :
16530 : : /*
16531 : : PutExportQualified - places a symbol with the name, SymName,
16532 : : into the export tree of the
16533 : : Definition module being compiled.
16534 : : The symbol with name has been EXPORT QUALIFIED
16535 : : by the definition module and therefore any reference
16536 : : to this symbol in the code generation phase
16537 : : will be in the form _Module_Name.
16538 : : */
16539 : :
16540 : 3717515 : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName)
16541 : : {
16542 : 3717515 : SymbolTable_PtrToSymbol pSym;
16543 : 3717515 : NameKey_Name n;
16544 : 3717515 : unsigned int Sym;
16545 : 3717515 : unsigned int ModSym;
16546 : :
16547 : 3717515 : ModSym = SymbolTable_GetCurrentModule ();
16548 : 3717515 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16549 : 7435030 : M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
16550 : : /*
16551 : : WriteString('1st MODULE ') ; WriteKey(GetSymName(ModSym)) ;
16552 : : WriteString(' identifier ') ; WriteKey(SymName) ; WriteLn ;
16553 : : */
16554 : 3717515 : pSym = GetPsym (ModSym);
16555 : 3717515 : switch (pSym->SymbolType)
16556 : : {
16557 : 3717515 : case SymbolTable_DefImpSym:
16558 : 3717515 : if (((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
16559 : : {
16560 : 6 : n = SymbolTable_GetSymName (ModSym);
16561 : 6 : M2Error_WriteFormat2 ((const char *) "identifier (%a) has already been exported from MODULE %a", 56, (const unsigned char *) &SymName, (sizeof (SymName)-1), (const unsigned char *) &n, (sizeof (n)-1));
16562 : : }
16563 : 3717509 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
16564 : : {
16565 : : /* avoid dangling else. */
16566 : 301425 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
16567 : 301425 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
16568 : 301425 : SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
16569 : 301425 : PutExportUndeclared (ModSym, Sym);
16570 : : }
16571 : : else
16572 : : {
16573 : : /* avoid dangling else. */
16574 : 3416084 : Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
16575 : 3416084 : SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
16576 : 3416084 : PutExportUndeclared (ModSym, Sym);
16577 : : }
16578 : 3717515 : break;
16579 : :
16580 : :
16581 : 0 : default:
16582 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16583 : 3717515 : break;
16584 : : }
16585 : 3717515 : }
16586 : :
16587 : :
16588 : : /*
16589 : : PutExportUnQualified - places a symbol with the name, SymName,
16590 : : into the export tree of the
16591 : : Definition module being compiled.
16592 : : The symbol with Name has been EXPORT UNQUALIFIED
16593 : : by the definition module and therefore any reference
16594 : : to this symbol in the code generation phase
16595 : : will be in the form _Name.
16596 : : */
16597 : :
16598 : 814892 : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName)
16599 : : {
16600 : 814892 : SymbolTable_PtrToSymbol pSym;
16601 : 814892 : NameKey_Name n;
16602 : 814892 : unsigned int Sym;
16603 : 814892 : unsigned int ModSym;
16604 : :
16605 : 814892 : ModSym = SymbolTable_GetCurrentModule ();
16606 : 814892 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16607 : 1629784 : M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
16608 : 814892 : pSym = GetPsym (ModSym);
16609 : 814892 : switch (pSym->SymbolType)
16610 : : {
16611 : 814892 : case SymbolTable_DefImpSym:
16612 : 814892 : if (((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
16613 : : {
16614 : 0 : n = SymbolTable_GetSymName (ModSym);
16615 : 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));
16616 : : }
16617 : 814892 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
16618 : : {
16619 : : /* avoid dangling else. */
16620 : 24054 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
16621 : 24054 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
16622 : 24054 : SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
16623 : 24054 : PutExportUndeclared (ModSym, Sym);
16624 : : }
16625 : : else
16626 : : {
16627 : : /* avoid dangling else. */
16628 : 790838 : Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
16629 : 790838 : SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
16630 : 790838 : PutExportUndeclared (ModSym, Sym);
16631 : : }
16632 : 814892 : break;
16633 : :
16634 : :
16635 : 0 : default:
16636 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16637 : 814892 : break;
16638 : : }
16639 : 814892 : }
16640 : :
16641 : :
16642 : : /*
16643 : : PutExportUnImplemented - places a symbol, Sym, into the currently compiled
16644 : : DefImp module NeedToBeImplemented list.
16645 : : */
16646 : :
16647 : 3317981 : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym)
16648 : : {
16649 : 3317981 : SymbolTable_PtrToSymbol pSym;
16650 : :
16651 : 3317981 : pSym = GetPsym (CurrentModule);
16652 : 3317981 : switch (pSym->SymbolType)
16653 : : {
16654 : 3317981 : case SymbolTable_DefImpSym:
16655 : 3317981 : if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
16656 : : {
16657 : : /*
16658 : : n1 := GetSymName (Sym) ;
16659 : : n2 := GetSymName (CurrentModule) ;
16660 : : WriteFormat2 ('symbol (%a) already exported from module (%a)', n1, n2)
16661 : : */
16662 : 0 : M2MetaError_MetaErrorT2 (tokenno, (const char *) "symbol {%1a} is already exported from module {%2a}", 50, Sym, CurrentModule);
16663 : : }
16664 : : else
16665 : : {
16666 : 3317981 : SymbolKey_PutSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym), Sym);
16667 : : }
16668 : 3317981 : break;
16669 : :
16670 : :
16671 : 0 : default:
16672 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16673 : 3317981 : break;
16674 : : }
16675 : 3317981 : }
16676 : :
16677 : :
16678 : : /*
16679 : : GetExported - returns the symbol which has a name SymName,
16680 : : and is exported from the definition module ModSym.
16681 : :
16682 : : */
16683 : :
16684 : 2758945 : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName)
16685 : : {
16686 : 2758945 : SymbolTable_PtrToSymbol pSym;
16687 : 2758945 : unsigned int Sym;
16688 : :
16689 : 2758945 : pSym = GetPsym (ModSym);
16690 : 2758945 : switch (pSym->SymbolType)
16691 : : {
16692 : 2758837 : case SymbolTable_DefImpSym:
16693 : 2758837 : Sym = RequestFromDefinition (tokenno, ModSym, SymName);
16694 : 2758837 : break;
16695 : :
16696 : 108 : case SymbolTable_ModuleSym:
16697 : 108 : Sym = RequestFromModule (tokenno, ModSym, SymName);
16698 : 108 : break;
16699 : :
16700 : :
16701 : 0 : default:
16702 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16703 : 2758945 : break;
16704 : : }
16705 : 2758945 : return Sym;
16706 : : /* static analysis guarentees a RETURN statement will be used before here. */
16707 : : __builtin_unreachable ();
16708 : : }
16709 : :
16710 : :
16711 : : /*
16712 : : GetFromOuterModule - returns a symbol with name, SymName, which comes
16713 : : from outside the current module.
16714 : : */
16715 : :
16716 : 340 : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName)
16717 : : {
16718 : 340 : SymbolTable_PtrToCallFrame pCall;
16719 : 340 : unsigned int ScopeId;
16720 : 340 : unsigned int Sym;
16721 : 340 : unsigned int ScopeSym;
16722 : :
16723 : 340 : ScopeId = ScopePtr;
16724 : 340 : pCall = GetPcall (ScopeId);
16725 : 704 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
16726 : : {
16727 : 24 : M2Debug_Assert (ScopeId > 0);
16728 : 24 : ScopeId -= 1;
16729 : 24 : pCall = GetPcall (ScopeId);
16730 : : }
16731 : 340 : ScopeId -= 1;
16732 : : /* we are now below the current module */
16733 : 496 : while (ScopeId > 0)
16734 : : {
16735 : 496 : pCall = GetPcall (ScopeId);
16736 : 496 : ScopeSym = pCall->Search;
16737 : 496 : if (ScopeSym != SymbolTable_NulSym)
16738 : : {
16739 : 496 : Sym = SymbolTable_GetLocalSym (ScopeSym, SymName);
16740 : 496 : if (Sym == SymbolTable_NulSym)
16741 : : {
16742 : : /* avoid dangling else. */
16743 : 172 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsProcedure (ScopeSym))) || (SymbolTable_IsDefImp (ScopeSym)))
16744 : : {
16745 : 136 : if (Sym == SymbolTable_NulSym)
16746 : : {
16747 : 136 : Sym = ExamineUnresolvedTree (ScopeSym, SymName);
16748 : 136 : if (Sym != SymbolTable_NulSym)
16749 : : {
16750 : : return Sym;
16751 : : }
16752 : : }
16753 : : }
16754 : : }
16755 : : else
16756 : : {
16757 : : return Sym;
16758 : : }
16759 : : }
16760 : 156 : ScopeId -= 1;
16761 : 156 : pCall = GetPcall (ScopeId);
16762 : : }
16763 : : /* at this point we force an unknown from the last module scope */
16764 : 0 : return RequestFromModule (tokenno, SymbolTable_GetLastModuleScope (), SymName);
16765 : : /* static analysis guarentees a RETURN statement will be used before here. */
16766 : : __builtin_unreachable ();
16767 : : }
16768 : :
16769 : :
16770 : : /*
16771 : : TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
16772 : : name, name, which is
16773 : : currently undefined in the
16774 : : outer scope to the inner scope.
16775 : : If successful then the symbol is
16776 : : returned otherwise NulSym is
16777 : : returned.
16778 : : */
16779 : :
16780 : 234 : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name)
16781 : : {
16782 : 234 : SymbolTable_PtrToSymbol pSym;
16783 : 234 : unsigned int sym;
16784 : :
16785 : : /* assume this should not be called if OuterScope was a procedure
16786 : : as this case is handled by the caller (P1SymBuild)
16787 : : */
16788 : 468 : M2Debug_Assert ((SymbolTable_IsModule (OuterScope)) || (SymbolTable_IsDefImp (OuterScope)));
16789 : 234 : sym = GetExportUndeclared (OuterScope, name);
16790 : 234 : if (sym != SymbolTable_NulSym)
16791 : : {
16792 : 18 : M2Debug_Assert (SymbolTable_IsUnknown (sym));
16793 : 18 : RemoveExportUndeclared (OuterScope, sym);
16794 : 18 : SymbolTable_AddSymToModuleScope (OuterScope, sym);
16795 : 18 : AddVarToScopeList (OuterScope, sym);
16796 : 18 : pSym = GetPsym (OuterScope);
16797 : 18 : switch (pSym->SymbolType)
16798 : : {
16799 : 0 : case SymbolTable_DefImpSym:
16800 : 0 : if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) == sym)
16801 : : {
16802 : 0 : SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
16803 : : }
16804 : : break;
16805 : :
16806 : 18 : case SymbolTable_ModuleSym:
16807 : 18 : if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) == sym)
16808 : : {
16809 : 18 : SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
16810 : : }
16811 : : break;
16812 : :
16813 : :
16814 : 0 : default:
16815 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module symbol", 31);
16816 : 18 : break;
16817 : : }
16818 : 18 : AddSymToUnknown (InnerScope, name, sym);
16819 : 18 : PutExportUndeclared (InnerScope, sym);
16820 : : }
16821 : 234 : return sym;
16822 : : /* static analysis guarentees a RETURN statement will be used before here. */
16823 : : __builtin_unreachable ();
16824 : : }
16825 : :
16826 : :
16827 : : /*
16828 : : IsExportQualified - returns true if a symbol, Sym, was defined as
16829 : : being EXPORT QUALIFIED.
16830 : : Sym is expected to be either a procedure or a
16831 : : variable.
16832 : : */
16833 : :
16834 : 8298962 : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym)
16835 : : {
16836 : 8298962 : SymbolTable_PtrToSymbol pSym;
16837 : 8298962 : unsigned int OuterModule;
16838 : :
16839 : 8298962 : OuterModule = Sym;
16840 : 8973155 : do {
16841 : 8973155 : OuterModule = SymbolTable_GetScope (OuterModule);
16842 : 8973155 : } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
16843 : 8298962 : pSym = GetPsym (OuterModule);
16844 : 8298962 : switch (pSym->SymbolType)
16845 : : {
16846 : : case SymbolTable_ModuleSym:
16847 : : return false;
16848 : 7841226 : break;
16849 : :
16850 : 7841226 : case SymbolTable_DefImpSym:
16851 : 7841226 : return (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
16852 : 0 : break;
16853 : :
16854 : :
16855 : 0 : default:
16856 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16857 : : break;
16858 : : }
16859 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16860 : : __builtin_unreachable ();
16861 : : }
16862 : :
16863 : :
16864 : : /*
16865 : : IsExportUnQualified - returns true if a symbol, Sym, was defined as
16866 : : being EXPORT UNQUALIFIED.
16867 : : */
16868 : :
16869 : 4074117 : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym)
16870 : : {
16871 : 4074117 : SymbolTable_PtrToSymbol pSym;
16872 : 4074117 : unsigned int OuterModule;
16873 : :
16874 : 4074117 : OuterModule = Sym;
16875 : 4074117 : do {
16876 : 4074117 : OuterModule = SymbolTable_GetScope (OuterModule);
16877 : 4074117 : } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
16878 : 4074117 : pSym = GetPsym (OuterModule);
16879 : 4074117 : switch (pSym->SymbolType)
16880 : : {
16881 : : case SymbolTable_ModuleSym:
16882 : : return false;
16883 : 3996594 : break;
16884 : :
16885 : 3996594 : case SymbolTable_DefImpSym:
16886 : 3996594 : return (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
16887 : 0 : break;
16888 : :
16889 : :
16890 : 0 : default:
16891 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16892 : : break;
16893 : : }
16894 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16895 : : __builtin_unreachable ();
16896 : : }
16897 : :
16898 : :
16899 : : /*
16900 : : IsExported - returns true if a symbol, Sym, is exported
16901 : : from module, ModSym.
16902 : : If ModSym is a DefImp symbol then its
16903 : : ExportQualified and ExportUnQualified lists are examined.
16904 : : */
16905 : :
16906 : 8537337 : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym)
16907 : : {
16908 : 8537337 : SymbolTable_PtrToSymbol pSym;
16909 : 8537337 : NameKey_Name SymName;
16910 : :
16911 : 8537337 : SymName = SymbolTable_GetSymName (Sym);
16912 : 8537337 : pSym = GetPsym (ModSym);
16913 : 8537337 : switch (pSym->SymbolType)
16914 : : {
16915 : 8002930 : case SymbolTable_DefImpSym:
16916 : 8002930 : return ((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) == Sym) || ((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) == Sym);
16917 : 534407 : break;
16918 : :
16919 : 534407 : case SymbolTable_ModuleSym:
16920 : 534407 : return (SymbolKey_GetSymKey (pSym->Module.ExportTree, SymName)) == Sym;
16921 : 0 : break;
16922 : :
16923 : :
16924 : 0 : default:
16925 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16926 : : break;
16927 : : }
16928 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16929 : : __builtin_unreachable ();
16930 : : }
16931 : :
16932 : :
16933 : : /*
16934 : : IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
16935 : : ModSym must be a defimp symbol.
16936 : : */
16937 : :
16938 : 84 : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym)
16939 : : {
16940 : 84 : unsigned int type;
16941 : 84 : SymbolTable_PtrToSymbol pSym;
16942 : :
16943 : 84 : if ((SymbolTable_IsDefImp (ModSym)) && (SymbolTable_IsFieldEnumeration (Sym)))
16944 : : {
16945 : 66 : pSym = GetPsym (ModSym);
16946 : 66 : type = SymbolTable_SkipType (SymbolTable_GetType (Sym));
16947 : 66 : return Lists_IsItemInList (pSym->DefImp.EnumerationScopeList, type);
16948 : : }
16949 : : return false;
16950 : : /* static analysis guarentees a RETURN statement will be used before here. */
16951 : : __builtin_unreachable ();
16952 : : }
16953 : :
16954 : :
16955 : : /*
16956 : : IsImported - returns true if a symbol, Sym, in module, ModSym,
16957 : : was imported.
16958 : : */
16959 : :
16960 : 34325642 : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym)
16961 : : {
16962 : 34325642 : SymbolTable_PtrToSymbol pSym;
16963 : 34325642 : NameKey_Name SymName;
16964 : :
16965 : 34325642 : SymName = SymbolTable_GetSymName (Sym);
16966 : 34325642 : pSym = GetPsym (ModSym);
16967 : 34325642 : switch (pSym->SymbolType)
16968 : : {
16969 : 22518061 : case SymbolTable_DefImpSym:
16970 : 22518061 : return ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->DefImp.IncludeList, Sym));
16971 : 11807581 : break;
16972 : :
16973 : 11807581 : case SymbolTable_ModuleSym:
16974 : 11807581 : return ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->Module.IncludeList, Sym));
16975 : 0 : break;
16976 : :
16977 : :
16978 : 0 : default:
16979 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16980 : : break;
16981 : : }
16982 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16983 : : __builtin_unreachable ();
16984 : : }
16985 : :
16986 : :
16987 : : /*
16988 : : PutIncludedByDefinition - places a module symbol, Sym, into the
16989 : : included list of the current definition module.
16990 : : */
16991 : :
16992 : 10013 : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym)
16993 : : {
16994 : 10013 : SymbolTable_PtrToSymbol pSym;
16995 : 10013 : unsigned int ModSym;
16996 : :
16997 : 10013 : ModSym = SymbolTable_GetCurrentModuleScope ();
16998 : 10013 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16999 : 10013 : M2Debug_Assert (SymbolTable_IsDefImp (Sym));
17000 : 10013 : pSym = GetPsym (ModSym);
17001 : 10013 : switch (pSym->SymbolType)
17002 : : {
17003 : 10013 : case SymbolTable_DefImpSym:
17004 : 10013 : Lists_IncludeItemIntoList (pSym->DefImp.DefIncludeList, Sym);
17005 : 10013 : break;
17006 : :
17007 : :
17008 : 0 : default:
17009 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17010 : 10013 : break;
17011 : : }
17012 : 10013 : }
17013 : :
17014 : :
17015 : : /*
17016 : : IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
17017 : : by ModSym's definition module.
17018 : : */
17019 : :
17020 : 12 : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym)
17021 : : {
17022 : 12 : SymbolTable_PtrToSymbol pSym;
17023 : :
17024 : 12 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
17025 : 12 : M2Debug_Assert (SymbolTable_IsDefImp (Sym));
17026 : 12 : pSym = GetPsym (ModSym);
17027 : 12 : switch (pSym->SymbolType)
17028 : : {
17029 : 12 : case SymbolTable_DefImpSym:
17030 : 12 : return Lists_IsItemInList (pSym->DefImp.DefIncludeList, Sym);
17031 : 0 : break;
17032 : :
17033 : :
17034 : 0 : default:
17035 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17036 : : break;
17037 : : }
17038 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17039 : : __builtin_unreachable ();
17040 : : }
17041 : :
17042 : :
17043 : : /*
17044 : : ForeachImportedDo - calls a procedure, P, foreach imported symbol
17045 : : in module, ModSym.
17046 : : */
17047 : :
17048 : 14691 : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
17049 : : {
17050 : 14691 : SymbolTable_PtrToSymbol pSym;
17051 : :
17052 : 14691 : pSym = GetPsym (ModSym);
17053 : 14691 : switch (pSym->SymbolType)
17054 : : {
17055 : 3809 : case SymbolTable_DefImpSym:
17056 : 3809 : SymbolKey_ForeachNodeDo (pSym->DefImp.ImportTree, P);
17057 : 3809 : Lists_ForeachItemInListDo (pSym->DefImp.IncludeList, P);
17058 : 3809 : break;
17059 : :
17060 : 10882 : case SymbolTable_ModuleSym:
17061 : 10882 : SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, P);
17062 : 10882 : Lists_ForeachItemInListDo (pSym->Module.IncludeList, P);
17063 : 10882 : break;
17064 : :
17065 : :
17066 : 0 : default:
17067 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17068 : 14691 : break;
17069 : : }
17070 : 14691 : }
17071 : :
17072 : :
17073 : : /*
17074 : : ForeachExportedDo - calls a procedure, P, foreach imported symbol
17075 : : in module, ModSym.
17076 : : */
17077 : :
17078 : 8736 : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
17079 : : {
17080 : 8736 : SymbolTable_PtrToSymbol pSym;
17081 : :
17082 : 8736 : pSym = GetPsym (ModSym);
17083 : 8736 : switch (pSym->SymbolType)
17084 : : {
17085 : 3344 : case SymbolTable_DefImpSym:
17086 : 3344 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, P);
17087 : 3344 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, P);
17088 : 3344 : break;
17089 : :
17090 : 5392 : case SymbolTable_ModuleSym:
17091 : 5392 : SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, P);
17092 : 5392 : break;
17093 : :
17094 : :
17095 : 0 : default:
17096 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17097 : 8736 : break;
17098 : : }
17099 : 8736 : }
17100 : :
17101 : :
17102 : : /*
17103 : : CheckForExportedImplementation - checks to see whether an implementation
17104 : : module is currently being compiled, if so,
17105 : : symbol, Sym, is removed from the
17106 : : NeedToBeImplemented list.
17107 : : This procedure is called whenever a symbol
17108 : : is declared, thus attempting to reduce
17109 : : the NeedToBeImplemented list.
17110 : : Only needs to be called when a TYPE or
17111 : : PROCEDURE is built since the implementation
17112 : : module can only implement these objects
17113 : : declared in the definition module.
17114 : :
17115 : : It also checks whether a definition module
17116 : : is currently being compiled and, if so,
17117 : : it will ensure that symbol, Sym, is removed
17118 : : from the ExportRequest list. If Sym is an
17119 : : enumerated type it ensures that its fields
17120 : : are also removed.
17121 : : */
17122 : :
17123 : 2372847 : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym)
17124 : : {
17125 : 2372847 : if (M2Comp_CompilingImplementationModule ())
17126 : : {
17127 : 2227037 : RemoveExportUnImplemented (SymbolTable_GetCurrentModule (), Sym);
17128 : : }
17129 : 2372847 : if ((M2Comp_CompilingDefinitionModule ()) && (SymbolTable_IsEnumeration (Sym)))
17130 : : {
17131 : 18783 : RemoveEnumerationFromExportRequest (SymbolTable_GetCurrentModule (), Sym);
17132 : : }
17133 : 2372847 : }
17134 : :
17135 : :
17136 : : /*
17137 : : CheckForUnImplementedExports - displays an error and the offending symbols
17138 : : which have been exported but not implemented
17139 : : from the current compiled module.
17140 : : */
17141 : :
17142 : 70949 : extern "C" void SymbolTable_CheckForUnImplementedExports (void)
17143 : : {
17144 : 70949 : SymbolTable_PtrToSymbol pSym;
17145 : :
17146 : : /* WriteString('Inside CheckForImplementedExports') ; WriteLn ; */
17147 : 70949 : pSym = GetPsym (CurrentModule);
17148 : 70949 : switch (pSym->SymbolType)
17149 : : {
17150 : 70949 : case SymbolTable_DefImpSym:
17151 : 70949 : if (! (SymbolKey_IsEmptyTree (pSym->DefImp.NeedToBeImplemented)))
17152 : : {
17153 : 0 : CurrentError = M2Error_NewError (M2LexBuf_GetTokenNo ());
17154 : 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));
17155 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NeedToBeImplemented, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnImplementedSymbolError});
17156 : : }
17157 : 70949 : break;
17158 : :
17159 : :
17160 : 0 : default:
17161 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17162 : 70949 : break;
17163 : : }
17164 : 70949 : }
17165 : :
17166 : :
17167 : : /*
17168 : : CheckForUndeclaredExports - displays an error and the offending symbols
17169 : : which have been exported but not declared
17170 : : from module, ModSym.
17171 : : */
17172 : :
17173 : 174809 : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym)
17174 : : {
17175 : 174809 : SymbolTable_PtrToSymbol pSym;
17176 : :
17177 : : /* WriteString('Inside CheckForUndeclaredExports') ; WriteLn ; */
17178 : 174809 : pSym = GetPsym (ModSym);
17179 : 174809 : switch (pSym->SymbolType)
17180 : : {
17181 : 12106 : case SymbolTable_ModuleSym:
17182 : 12106 : if (! (SymbolKey_IsEmptyTree (pSym->Module.ExportUndeclared)))
17183 : : {
17184 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in EXPORT list of {%1ERd} {%1a}", 56, ModSym);
17185 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
17186 : : }
17187 : : break;
17188 : :
17189 : 162703 : case SymbolTable_DefImpSym:
17190 : 162703 : if (! (SymbolKey_IsEmptyTree (pSym->DefImp.ExportUndeclared)))
17191 : : {
17192 : 0 : if (SymbolTable_DoesNotNeedExportList (ModSym))
17193 : : {
17194 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in {%1ERd} {%1a}", 41, ModSym);
17195 : : }
17196 : : else
17197 : : {
17198 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in export list of {%1ERd} {%1a}", 56, ModSym);
17199 : : }
17200 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
17201 : : }
17202 : : break;
17203 : :
17204 : :
17205 : 0 : default:
17206 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17207 : 174809 : break;
17208 : : }
17209 : 174809 : }
17210 : :
17211 : :
17212 : : /*
17213 : : CheckForUnknownInModule - checks for any unknown symbols in the
17214 : : current module.
17215 : : If any unknown symbols are found then
17216 : : an error message is displayed.
17217 : : */
17218 : :
17219 : 489417 : extern "C" void SymbolTable_CheckForUnknownInModule (unsigned int tokno)
17220 : : {
17221 : 489417 : SymbolTable_PtrToSymbol pSym;
17222 : :
17223 : 489417 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
17224 : 489417 : switch (pSym->SymbolType)
17225 : : {
17226 : 465556 : case SymbolTable_DefImpSym:
17227 : 465556 : CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.ExportQualifiedTree, (const char *) "EXPORT QUALIFIED", 16);
17228 : 465556 : CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.ExportUnQualifiedTree, (const char *) "EXPORT UNQUALIFIED", 18);
17229 : 465556 : CheckForSymbols (pSym->DefImp.ExportRequest, (const char *) "requested by another module import and the symbol has not been exported by the appropriate definition module", 108);
17230 : 465556 : CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.Unresolved, (const char *) "unresolved", 10);
17231 : 465556 : CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.LocalSymbols, (const char *) "locally used", 12);
17232 : 465556 : break;
17233 : :
17234 : 23861 : case SymbolTable_ModuleSym:
17235 : 23861 : CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.Unresolved, (const char *) "unresolved", 10);
17236 : 23861 : CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.ExportUndeclared, (const char *) "exported but undeclared", 23);
17237 : 23861 : CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.ExportTree, (const char *) "exported but undeclared", 23);
17238 : 23861 : CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.LocalSymbols, (const char *) "locally used", 12);
17239 : 23861 : break;
17240 : :
17241 : :
17242 : 0 : default:
17243 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17244 : 489417 : break;
17245 : : }
17246 : 489417 : }
17247 : :
17248 : :
17249 : : /*
17250 : : UnknownReported - if sym is an unknown symbol and has not been reported
17251 : : then include it into the set of reported unknowns.
17252 : : */
17253 : :
17254 : 48 : extern "C" void SymbolTable_UnknownReported (unsigned int sym)
17255 : : {
17256 : 48 : if (IsUnreportedUnknown (sym))
17257 : : {
17258 : 48 : Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
17259 : : }
17260 : 48 : }
17261 : :
17262 : :
17263 : : /*
17264 : : GetUnknownOnImport - returns the onimport field of unknown sym.
17265 : : */
17266 : :
17267 : 225 : extern "C" bool SymbolTable_GetUnknownOnImport (unsigned int sym)
17268 : : {
17269 : 225 : SymbolTable_PtrToSymbol pSym;
17270 : :
17271 : 225 : M2Debug_Assert (SymbolTable_IsUnknown (sym));
17272 : 225 : pSym = GetPsym (sym);
17273 : 225 : return pSym->Undefined.onImport;
17274 : : /* static analysis guarentees a RETURN statement will be used before here. */
17275 : : __builtin_unreachable ();
17276 : : }
17277 : :
17278 : :
17279 : : /*
17280 : : GetUnknownDeclScope - returns the decl scope of unknown sym.
17281 : : */
17282 : :
17283 : 6 : extern "C" unsigned int SymbolTable_GetUnknownDeclScope (unsigned int sym)
17284 : : {
17285 : 6 : SymbolTable_PtrToSymbol pSym;
17286 : :
17287 : 6 : M2Debug_Assert (SymbolTable_IsUnknown (sym));
17288 : 6 : pSym = GetPsym (sym);
17289 : 6 : return pSym->Undefined.declScope;
17290 : : /* static analysis guarentees a RETURN statement will be used before here. */
17291 : : __builtin_unreachable ();
17292 : : }
17293 : :
17294 : :
17295 : : /*
17296 : : IsReallyPointer - returns TRUE is sym is a pointer, address or a
17297 : : type declared as a pointer or address.
17298 : : */
17299 : :
17300 : 776044 : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym)
17301 : : {
17302 : 776044 : if (SymbolTable_IsVar (Sym))
17303 : : {
17304 : 229433 : Sym = SymbolTable_GetType (Sym);
17305 : : }
17306 : 776044 : Sym = SymbolTable_SkipType (Sym);
17307 : 776044 : return ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address)) || (SymbolTable_IsHiddenReallyPointer (Sym));
17308 : : /* static analysis guarentees a RETURN statement will be used before here. */
17309 : : __builtin_unreachable ();
17310 : : }
17311 : :
17312 : :
17313 : : /*
17314 : : CheckHiddenTypeAreAddress - checks to see that any hidden types
17315 : : which we have declared are actually
17316 : : of type ADDRESS or map onto a POINTER type.
17317 : : */
17318 : :
17319 : 14223 : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void)
17320 : : {
17321 : 14223 : NameKey_Name name;
17322 : 14223 : M2Error_Error e;
17323 : 14223 : unsigned int sym;
17324 : 14223 : unsigned int i;
17325 : 14223 : unsigned int n;
17326 : :
17327 : 14223 : i = 1;
17328 : 14223 : n = Lists_NoOfItemsInList (AddressTypes);
17329 : 54925 : while (i <= n)
17330 : : {
17331 : 26479 : sym = static_cast<unsigned int> (Lists_GetItemFromList (AddressTypes, i));
17332 : 26479 : if (! (SymbolTable_IsHiddenReallyPointer (sym)))
17333 : : {
17334 : 6 : name = SymbolTable_GetSymName (sym);
17335 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredDef (sym));
17336 : 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));
17337 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredMod (sym));
17338 : 6 : M2Error_ErrorFormat0 (e, (const char *) "if you really need a non POINTER type use the -fextended-opaque switch", 70);
17339 : : }
17340 : 26479 : i += 1;
17341 : : }
17342 : 14223 : }
17343 : :
17344 : :
17345 : : /*
17346 : : PutDefinitionForC - sets a flag in the current compiled module which
17347 : : indicates that this module is a wrapper for a C
17348 : : file. Parameters passes to procedures in this module
17349 : : will adopt the C calling convention.
17350 : : */
17351 : :
17352 : 26196 : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym)
17353 : : {
17354 : 26196 : SymbolTable_PtrToSymbol pSym;
17355 : :
17356 : 26196 : pSym = GetPsym (Sym);
17357 : 26196 : switch (pSym->SymbolType)
17358 : : {
17359 : 26196 : case SymbolTable_DefImpSym:
17360 : 26196 : pSym->DefImp.ForC = true;
17361 : 26196 : break;
17362 : :
17363 : :
17364 : 0 : default:
17365 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17366 : 26196 : break;
17367 : : }
17368 : 26196 : }
17369 : :
17370 : :
17371 : : /*
17372 : : IsDefinitionForC - returns true if this definition module was declared
17373 : : as a DEFINITION MODULE FOR "C".
17374 : : */
17375 : :
17376 : 1211788 : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym)
17377 : : {
17378 : 1211788 : SymbolTable_PtrToSymbol pSym;
17379 : :
17380 : 1211788 : pSym = GetPsym (Sym);
17381 : 1211788 : switch (pSym->SymbolType)
17382 : : {
17383 : 1211788 : case SymbolTable_DefImpSym:
17384 : 1211788 : return pSym->DefImp.ForC;
17385 : 0 : break;
17386 : :
17387 : :
17388 : 0 : default:
17389 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17390 : : break;
17391 : : }
17392 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17393 : : __builtin_unreachable ();
17394 : : }
17395 : :
17396 : :
17397 : : /*
17398 : : PutDoesNeedExportList - sets a flag in module, Sym, which
17399 : : indicates that this module requires an explicit
17400 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
17401 : : */
17402 : :
17403 : 86044 : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym)
17404 : : {
17405 : 86044 : SymbolTable_PtrToSymbol pSym;
17406 : :
17407 : 86044 : pSym = GetPsym (Sym);
17408 : 86044 : switch (pSym->SymbolType)
17409 : : {
17410 : 86044 : case SymbolTable_DefImpSym:
17411 : 86044 : pSym->DefImp.NeedExportList = true;
17412 : 86044 : break;
17413 : :
17414 : :
17415 : 0 : default:
17416 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17417 : 86044 : break;
17418 : : }
17419 : 86044 : }
17420 : :
17421 : :
17422 : : /*
17423 : : PutDoesNotNeedExportList - sets a flag in module, Sym, which
17424 : : indicates that this module does not require an explicit
17425 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
17426 : : */
17427 : :
17428 : 162871 : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym)
17429 : : {
17430 : 162871 : SymbolTable_PtrToSymbol pSym;
17431 : :
17432 : 162871 : pSym = GetPsym (Sym);
17433 : 162871 : switch (pSym->SymbolType)
17434 : : {
17435 : 162871 : case SymbolTable_DefImpSym:
17436 : 162871 : pSym->DefImp.NeedExportList = false;
17437 : 162871 : break;
17438 : :
17439 : :
17440 : 0 : default:
17441 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17442 : 162871 : break;
17443 : : }
17444 : 162871 : }
17445 : :
17446 : :
17447 : : /*
17448 : : DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
17449 : : EXPORT QUALIFIED list.
17450 : : */
17451 : :
17452 : 4036042 : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym)
17453 : : {
17454 : 4036042 : SymbolTable_PtrToSymbol pSym;
17455 : :
17456 : 4036042 : pSym = GetPsym (Sym);
17457 : 4036042 : switch (pSym->SymbolType)
17458 : : {
17459 : 4036042 : case SymbolTable_DefImpSym:
17460 : 4036042 : return ! pSym->DefImp.NeedExportList;
17461 : 0 : break;
17462 : :
17463 : :
17464 : 0 : default:
17465 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17466 : : break;
17467 : : }
17468 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17469 : : __builtin_unreachable ();
17470 : : }
17471 : :
17472 : :
17473 : : /*
17474 : : CheckForEnumerationInCurrentModule - checks to see whether the enumeration
17475 : : type symbol, Sym, has been entered into
17476 : : the current modules scope list.
17477 : : */
17478 : :
17479 : 1697946 : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym)
17480 : : {
17481 : 1697946 : SymbolTable_PtrToSymbol pSym;
17482 : 1697946 : unsigned int ModSym;
17483 : :
17484 : 1697946 : if (((SymbolTable_SkipType (Sym)) != SymbolTable_NulSym) && (SymbolTable_IsEnumeration (SymbolTable_SkipType (Sym))))
17485 : : {
17486 : 17692 : Sym = SymbolTable_SkipType (Sym);
17487 : : }
17488 : 1697946 : if (SymbolTable_IsEnumeration (Sym))
17489 : : {
17490 : 17692 : ModSym = SymbolTable_GetCurrentModuleScope ();
17491 : 17692 : pSym = GetPsym (ModSym);
17492 : 17692 : switch (pSym->SymbolType)
17493 : : {
17494 : 17290 : case SymbolTable_DefImpSym:
17495 : 17290 : CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
17496 : 17290 : break;
17497 : :
17498 : 402 : case SymbolTable_ModuleSym:
17499 : 402 : CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
17500 : 402 : break;
17501 : :
17502 : :
17503 : 0 : default:
17504 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17505 : : break;
17506 : : }
17507 : : }
17508 : 1697946 : }
17509 : :
17510 : :
17511 : : /*
17512 : : SanityCheckConstants - must only be called once all constants, types, procedures
17513 : : have been declared. It checks to see that constants are
17514 : : not used as procedure parameter types.
17515 : : */
17516 : :
17517 : 14935 : extern "C" void SymbolTable_SanityCheckConstants (void)
17518 : : {
17519 : 14935 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
17520 : 14935 : ForeachSymbolDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
17521 : 14935 : }
17522 : :
17523 : :
17524 : : /*
17525 : : ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
17526 : : perform the procedure, P.
17527 : : */
17528 : :
17529 : 13286638 : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
17530 : : {
17531 : 13286638 : SymbolTable_PtrToSymbol pSym;
17532 : :
17533 : 13286638 : pSym = GetPsym (Sym);
17534 : 13286638 : switch (pSym->SymbolType)
17535 : : {
17536 : 598583 : case SymbolTable_DefImpSym:
17537 : 598583 : SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, P);
17538 : 598583 : break;
17539 : :
17540 : 93442 : case SymbolTable_ModuleSym:
17541 : 93442 : SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, P);
17542 : 93442 : break;
17543 : :
17544 : 255131 : case SymbolTable_ProcedureSym:
17545 : 255131 : SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, P);
17546 : 255131 : break;
17547 : :
17548 : 0 : case SymbolTable_RecordSym:
17549 : 0 : SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, P);
17550 : 0 : break;
17551 : :
17552 : 12339482 : case SymbolTable_EnumerationSym:
17553 : 12339482 : SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
17554 : 12339482 : break;
17555 : :
17556 : :
17557 : 0 : default:
17558 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp, Module or Procedure symbol", 46);
17559 : 13286638 : break;
17560 : : }
17561 : 13286638 : }
17562 : :
17563 : :
17564 : : /*
17565 : : ForeachParamSymDo - foreach parameter symbol in procedure Sym
17566 : : perform the procedure P. Each symbol
17567 : : looked up will be VarParam or Param
17568 : : (not the shadow variable). Every parameter
17569 : : from each KindProcedure is iterated over.
17570 : : */
17571 : :
17572 : 1912044 : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
17573 : : {
17574 : 1912044 : SymbolTable_ProcedureKind kind;
17575 : 1912044 : unsigned int param;
17576 : 1912044 : unsigned int p;
17577 : 1912044 : unsigned int i;
17578 : :
17579 : 1912044 : if (SymbolTable_IsProcedure (Sym))
17580 : : {
17581 : 7589752 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
17582 : : {
17583 : 5692314 : p = SymbolTable_NoOfParam (Sym, kind);
17584 : 5692314 : i = p;
17585 : 17314961 : while (i > 0)
17586 : : {
17587 : 5930333 : param = SymbolTable_GetNthParam (Sym, kind, i);
17588 : 5930333 : (*P.proc) (param);
17589 : 5930333 : i -= 1;
17590 : : }
17591 : : }
17592 : : }
17593 : 1912044 : }
17594 : :
17595 : :
17596 : : /*
17597 : : ForeachFieldEnumerationDo - for each field in enumeration, Sym,
17598 : : do procedure, P. Each call to P contains
17599 : : an enumeration field, the order is alphabetical.
17600 : : Use ForeachLocalSymDo for declaration order.
17601 : : */
17602 : :
17603 : 92337 : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P)
17604 : : {
17605 : 92337 : SymbolTable_PtrToSymbol pSym;
17606 : :
17607 : 92337 : pSym = GetPsym (Sym);
17608 : 92337 : switch (pSym->SymbolType)
17609 : : {
17610 : 92337 : case SymbolTable_EnumerationSym:
17611 : 92337 : SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
17612 : 92337 : break;
17613 : :
17614 : :
17615 : 0 : default:
17616 : 0 : M2Error_InternalError ((const char *) "expecting Enumeration symbol", 28);
17617 : 92337 : break;
17618 : : }
17619 : 92337 : }
17620 : :
17621 : :
17622 : : /*
17623 : : IsType - returns true if the Sym is a type symbol.
17624 : : */
17625 : :
17626 : 1660446394 : extern "C" bool SymbolTable_IsType (unsigned int Sym)
17627 : : {
17628 : 1660446394 : SymbolTable_PtrToSymbol pSym;
17629 : :
17630 : 1660446394 : pSym = GetPsym (Sym);
17631 : 1660446394 : return pSym->SymbolType == SymbolTable_TypeSym;
17632 : : /* static analysis guarentees a RETURN statement will be used before here. */
17633 : : __builtin_unreachable ();
17634 : : }
17635 : :
17636 : :
17637 : : /*
17638 : : IsProcedure - returns true if Sym is a procedure symbol.
17639 : : */
17640 : :
17641 : 426468438 : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym)
17642 : : {
17643 : 426468438 : SymbolTable_PtrToSymbol pSym;
17644 : :
17645 : 426468438 : AssertInRange (Sym);
17646 : 426468438 : pSym = GetPsym (Sym);
17647 : 426468438 : return pSym->SymbolType == SymbolTable_ProcedureSym;
17648 : : /* static analysis guarentees a RETURN statement will be used before here. */
17649 : : __builtin_unreachable ();
17650 : : }
17651 : :
17652 : :
17653 : : /*
17654 : : IsParameter - returns true if Sym is a parameter symbol.
17655 : : */
17656 : :
17657 : 73755996 : extern "C" bool SymbolTable_IsParameter (unsigned int Sym)
17658 : : {
17659 : 73755996 : SymbolTable_PtrToSymbol pSym;
17660 : :
17661 : 73755996 : pSym = GetPsym (Sym);
17662 : 73755996 : switch (pSym->SymbolType)
17663 : : {
17664 : : case SymbolTable_ParamSym:
17665 : : case SymbolTable_VarParamSym:
17666 : : return true;
17667 : 65764617 : break;
17668 : :
17669 : :
17670 : 65764617 : default:
17671 : 65764617 : return false;
17672 : : break;
17673 : : }
17674 : : /* static analysis guarentees a RETURN statement will be used before here. */
17675 : : __builtin_unreachable ();
17676 : : }
17677 : :
17678 : :
17679 : : /*
17680 : : GetProcedureKind - returns the procedure kind given the declaration tok.
17681 : : The declaration tok must match the ident tok in the
17682 : : procedure name. It is only safe to call this
17683 : : procedure function during pass 2 onwards.
17684 : : */
17685 : :
17686 : 32191201 : extern "C" SymbolTable_ProcedureKind SymbolTable_GetProcedureKind (unsigned int sym, unsigned int tok)
17687 : : {
17688 : 32191201 : SymbolTable_ProcedureKind kind;
17689 : 32191201 : SymbolTable_PtrToSymbol pSym;
17690 : :
17691 : 32191201 : pSym = GetPsym (sym);
17692 : 32191201 : switch (pSym->SymbolType)
17693 : : {
17694 : : case SymbolTable_ProcedureSym:
17695 : 71554235 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
17696 : : {
17697 : 71554235 : if (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok == tok)
17698 : : {
17699 : : return kind;
17700 : : }
17701 : : }
17702 : 0 : break;
17703 : :
17704 : : case SymbolTable_ProcTypeSym:
17705 : : return SymbolTable_ProperProcedure;
17706 : 0 : break;
17707 : :
17708 : :
17709 : 0 : default:
17710 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
17711 : 0 : break;
17712 : : }
17713 : 0 : M2Error_InternalError ((const char *) "ProcedureSym kind has not yet been declared", 43);
17714 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17715 : : __builtin_unreachable ();
17716 : : }
17717 : :
17718 : :
17719 : : /*
17720 : : GetProcedureDeclaredTok - return the token where the
17721 : : declaration of procedure sym:kind
17722 : : occurred.
17723 : : */
17724 : :
17725 : 36 : extern "C" unsigned int SymbolTable_GetProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind)
17726 : : {
17727 : 36 : SymbolTable_PtrToSymbol pSym;
17728 : :
17729 : 36 : pSym = GetPsym (sym);
17730 : 36 : switch (pSym->SymbolType)
17731 : : {
17732 : 36 : case SymbolTable_ProcedureSym:
17733 : 36 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok;
17734 : 0 : break;
17735 : :
17736 : :
17737 : 0 : default:
17738 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17739 : : break;
17740 : : }
17741 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17742 : : __builtin_unreachable ();
17743 : : }
17744 : :
17745 : :
17746 : : /*
17747 : : PutProcedureDeclaredTok - places the tok where the
17748 : : declaration of procedure sym:kind
17749 : : occurred.
17750 : : */
17751 : :
17752 : 5421852 : extern "C" void SymbolTable_PutProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok)
17753 : : {
17754 : 5421852 : SymbolTable_PtrToSymbol pSym;
17755 : :
17756 : 5421852 : pSym = GetPsym (sym);
17757 : 5421852 : switch (pSym->SymbolType)
17758 : : {
17759 : 5421852 : case SymbolTable_ProcedureSym:
17760 : 5421852 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok = tok;
17761 : 5421852 : break;
17762 : :
17763 : :
17764 : 0 : default:
17765 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17766 : 5421852 : break;
17767 : : }
17768 : 5421852 : }
17769 : :
17770 : :
17771 : : /*
17772 : : GetReturnTypeTok - return the token where the
17773 : : return type procedure sym:kind or proctype
17774 : : was defined.
17775 : : */
17776 : :
17777 : 6 : extern "C" unsigned int SymbolTable_GetReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind)
17778 : : {
17779 : 6 : SymbolTable_PtrToSymbol pSym;
17780 : :
17781 : 6 : pSym = GetPsym (sym);
17782 : 6 : switch (pSym->SymbolType)
17783 : : {
17784 : 6 : case SymbolTable_ProcedureSym:
17785 : 6 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok;
17786 : 0 : break;
17787 : :
17788 : 0 : case SymbolTable_ProcTypeSym:
17789 : 0 : return pSym->ProcType.ReturnTypeTok;
17790 : 0 : break;
17791 : :
17792 : :
17793 : 0 : default:
17794 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17795 : : break;
17796 : : }
17797 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17798 : : __builtin_unreachable ();
17799 : : }
17800 : :
17801 : :
17802 : : /*
17803 : : PutReturnTypeTok - places the tok where the
17804 : : return type of procedure sym:kind or proctype
17805 : : was defined.
17806 : : */
17807 : :
17808 : 0 : extern "C" void SymbolTable_PutReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok)
17809 : : {
17810 : 0 : SymbolTable_PtrToSymbol pSym;
17811 : :
17812 : 0 : pSym = GetPsym (sym);
17813 : 0 : switch (pSym->SymbolType)
17814 : : {
17815 : 0 : case SymbolTable_ProcedureSym:
17816 : 0 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
17817 : 0 : break;
17818 : :
17819 : 0 : case SymbolTable_ProcTypeSym:
17820 : 0 : pSym->ProcType.ReturnTypeTok = tok;
17821 : 0 : break;
17822 : :
17823 : :
17824 : 0 : default:
17825 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17826 : 0 : break;
17827 : : }
17828 : 0 : }
17829 : :
17830 : :
17831 : : /*
17832 : : PutProcedureParametersDefined - the procedure symbol sym:kind
17833 : : parameters have been defined.
17834 : : */
17835 : :
17836 : 10662815 : extern "C" void SymbolTable_PutProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17837 : : {
17838 : 10662815 : SymbolTable_PtrToSymbol pSym;
17839 : :
17840 : 10662815 : AssertInRange (sym);
17841 : 10662815 : pSym = GetPsym (sym);
17842 : 10662815 : switch (pSym->SymbolType)
17843 : : {
17844 : : case SymbolTable_ErrorSym:
17845 : : break;
17846 : :
17847 : 10662815 : case SymbolTable_ProcedureSym:
17848 : 10662815 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ParamDefined = true;
17849 : 10662815 : pSym->Procedure.BuildProcType = false;
17850 : 10662815 : break;
17851 : :
17852 : : case SymbolTable_ProcTypeSym:
17853 : : break;
17854 : :
17855 : :
17856 : 0 : default:
17857 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17858 : 10662815 : break;
17859 : : }
17860 : 10662815 : }
17861 : :
17862 : :
17863 : : /*
17864 : : GetProcedureParametersDefined - returns true if procedure symbol sym:kind
17865 : : parameters are defined.
17866 : : */
17867 : :
17868 : 182800012 : extern "C" bool SymbolTable_GetProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17869 : : {
17870 : 182800012 : SymbolTable_PtrToSymbol pSym;
17871 : :
17872 : 182800012 : AssertInRange (sym);
17873 : 182800012 : pSym = GetPsym (sym);
17874 : 182800012 : switch (pSym->SymbolType)
17875 : : {
17876 : : case SymbolTable_ErrorSym:
17877 : : return false;
17878 : 173864720 : break;
17879 : :
17880 : 173864720 : case SymbolTable_ProcedureSym:
17881 : 173864720 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ParamDefined;
17882 : 8935292 : break;
17883 : :
17884 : 8935292 : case SymbolTable_ProcTypeSym:
17885 : 8935292 : return true;
17886 : 0 : break;
17887 : :
17888 : :
17889 : 0 : default:
17890 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17891 : : break;
17892 : : }
17893 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17894 : : __builtin_unreachable ();
17895 : : }
17896 : :
17897 : :
17898 : : /*
17899 : : PutProcedureDefined - the procedure symbol sym:kind is defined.
17900 : : */
17901 : :
17902 : 7178003 : extern "C" void SymbolTable_PutProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17903 : : {
17904 : 7178003 : SymbolTable_PtrToSymbol pSym;
17905 : :
17906 : 7178003 : AssertInRange (sym);
17907 : 7178003 : pSym = GetPsym (sym);
17908 : 7178003 : switch (pSym->SymbolType)
17909 : : {
17910 : : case SymbolTable_ErrorSym:
17911 : : break;
17912 : :
17913 : 7178003 : case SymbolTable_ProcedureSym:
17914 : 7178003 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].Defined = true;
17915 : 7178003 : break;
17916 : :
17917 : :
17918 : 0 : default:
17919 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17920 : 7178003 : break;
17921 : : }
17922 : 7178003 : }
17923 : :
17924 : :
17925 : : /*
17926 : : GetProcedureDefined - returns true if procedure symbol sym:kind
17927 : : is defined.
17928 : : */
17929 : :
17930 : 36412254 : extern "C" bool SymbolTable_GetProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17931 : : {
17932 : 36412254 : SymbolTable_PtrToSymbol pSym;
17933 : :
17934 : 36412254 : AssertInRange (sym);
17935 : 36412254 : pSym = GetPsym (sym);
17936 : 36412254 : switch (pSym->SymbolType)
17937 : : {
17938 : : case SymbolTable_ErrorSym:
17939 : : return false;
17940 : 36412254 : break;
17941 : :
17942 : 36412254 : case SymbolTable_ProcedureSym:
17943 : 36412254 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].Defined;
17944 : 0 : break;
17945 : :
17946 : :
17947 : 0 : default:
17948 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17949 : : break;
17950 : : }
17951 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17952 : : __builtin_unreachable ();
17953 : : }
17954 : :
17955 : :
17956 : : /*
17957 : : PutUseVarArgs - tell the symbol table that this procedure, Sym,
17958 : : uses varargs.
17959 : : The procedure _must_ be declared inside a
17960 : : DEFINITION FOR "C"
17961 : :
17962 : : */
17963 : :
17964 : 11320 : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym)
17965 : : {
17966 : 11320 : SymbolTable_PtrToSymbol pSym;
17967 : :
17968 : 11320 : AssertInRange (Sym);
17969 : 11320 : pSym = GetPsym (Sym);
17970 : 11320 : switch (pSym->SymbolType)
17971 : : {
17972 : : case SymbolTable_ErrorSym:
17973 : : break;
17974 : :
17975 : 11320 : case SymbolTable_ProcedureSym:
17976 : : /* Currently can only declare var args in a definition module. */
17977 : 11320 : pSym->Procedure.Decl.array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure].HasVarArgs = true;
17978 : 11320 : break;
17979 : :
17980 : 0 : case SymbolTable_ProcTypeSym:
17981 : 0 : pSym->ProcType.HasVarArgs = true;
17982 : 0 : break;
17983 : :
17984 : :
17985 : 0 : default:
17986 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17987 : 11320 : break;
17988 : : }
17989 : 11320 : }
17990 : :
17991 : :
17992 : : /*
17993 : : UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
17994 : : The procedure _must_ be declared inside a
17995 : : DEFINITION FOR "C"
17996 : : */
17997 : :
17998 : 3806165 : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym)
17999 : : {
18000 : 3806165 : SymbolTable_PtrToSymbol pSym;
18001 : :
18002 : 3806165 : AssertInRange (Sym);
18003 : 3806165 : pSym = GetPsym (Sym);
18004 : 3806165 : switch (pSym->SymbolType)
18005 : : {
18006 : : case SymbolTable_ErrorSym:
18007 : : return false;
18008 : 3748133 : break;
18009 : :
18010 : 3748133 : case SymbolTable_ProcedureSym:
18011 : : /* Currently can only declare var args in a definition module. */
18012 : 3748133 : return pSym->Procedure.Decl.array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure].HasVarArgs;
18013 : 58032 : break;
18014 : :
18015 : 58032 : case SymbolTable_ProcTypeSym:
18016 : 58032 : return pSym->ProcType.HasVarArgs;
18017 : 0 : break;
18018 : :
18019 : :
18020 : 0 : default:
18021 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18022 : : break;
18023 : : }
18024 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18025 : : __builtin_unreachable ();
18026 : : }
18027 : :
18028 : :
18029 : : /*
18030 : : PutUseOptArg - tell the symbol table that this procedure, Sym,
18031 : : uses an optarg.
18032 : : */
18033 : :
18034 : 17889 : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind)
18035 : : {
18036 : 17889 : SymbolTable_PtrToSymbol pSym;
18037 : :
18038 : 17889 : AssertInRange (Sym);
18039 : 17889 : pSym = GetPsym (Sym);
18040 : 17889 : switch (pSym->SymbolType)
18041 : : {
18042 : : case SymbolTable_ErrorSym:
18043 : : break;
18044 : :
18045 : 17889 : case SymbolTable_ProcedureSym:
18046 : 17889 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].HasOptArg = true;
18047 : 17889 : break;
18048 : :
18049 : 0 : case SymbolTable_ProcTypeSym:
18050 : 0 : pSym->ProcType.HasOptArg = true;
18051 : 0 : break;
18052 : :
18053 : :
18054 : 0 : default:
18055 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18056 : 17889 : break;
18057 : : }
18058 : 17889 : }
18059 : :
18060 : :
18061 : : /*
18062 : : UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
18063 : : */
18064 : :
18065 : 217693 : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind)
18066 : : {
18067 : 217693 : SymbolTable_PtrToSymbol pSym;
18068 : :
18069 : 217693 : AssertInRange (Sym);
18070 : 217693 : pSym = GetPsym (Sym);
18071 : 217693 : switch (pSym->SymbolType)
18072 : : {
18073 : : case SymbolTable_ErrorSym:
18074 : : return false;
18075 : 217693 : break;
18076 : :
18077 : 217693 : case SymbolTable_ProcedureSym:
18078 : 217693 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].HasOptArg;
18079 : 0 : break;
18080 : :
18081 : 0 : case SymbolTable_ProcTypeSym:
18082 : 0 : return pSym->ProcType.HasOptArg;
18083 : 0 : break;
18084 : :
18085 : :
18086 : 0 : default:
18087 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18088 : : break;
18089 : : }
18090 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18091 : : __builtin_unreachable ();
18092 : : }
18093 : :
18094 : :
18095 : : /*
18096 : : PutOptArgInit - makes symbol, Sym, the initializer value to
18097 : : procedure, ProcSym.
18098 : : */
18099 : :
18100 : 14952 : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym)
18101 : : {
18102 : 14952 : SymbolTable_PtrToSymbol pSym;
18103 : :
18104 : 14952 : AssertInRange (Sym);
18105 : 14952 : if (! (SymbolTable_IsError (ProcSym)))
18106 : : {
18107 : 14952 : pSym = GetPsym (ProcSym);
18108 : 14952 : switch (pSym->SymbolType)
18109 : : {
18110 : : case SymbolTable_ErrorSym:
18111 : : break;
18112 : :
18113 : 14952 : case SymbolTable_ProcedureSym:
18114 : 14952 : pSym->Procedure.OptArgInit = Sym;
18115 : 14952 : break;
18116 : :
18117 : 0 : case SymbolTable_ProcTypeSym:
18118 : 0 : pSym->ProcType.OptArgInit = Sym;
18119 : 0 : break;
18120 : :
18121 : :
18122 : 0 : default:
18123 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18124 : : break;
18125 : : }
18126 : : }
18127 : 14952 : }
18128 : :
18129 : :
18130 : : /*
18131 : : GetOptArgInit - returns the initializer value to the optional parameter in
18132 : : procedure, ProcSym.
18133 : : */
18134 : :
18135 : 3481 : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym)
18136 : : {
18137 : 3481 : SymbolTable_PtrToSymbol pSym;
18138 : :
18139 : 3481 : if (! (SymbolTable_IsError (ProcSym)))
18140 : : {
18141 : 3481 : pSym = GetPsym (ProcSym);
18142 : 3481 : switch (pSym->SymbolType)
18143 : : {
18144 : : case SymbolTable_ErrorSym:
18145 : : break;
18146 : :
18147 : 3481 : case SymbolTable_ProcedureSym:
18148 : 3481 : return pSym->Procedure.OptArgInit;
18149 : 0 : break;
18150 : :
18151 : 0 : case SymbolTable_ProcTypeSym:
18152 : 0 : return pSym->ProcType.OptArgInit;
18153 : 0 : break;
18154 : :
18155 : :
18156 : 0 : default:
18157 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
18158 : : break;
18159 : : }
18160 : : }
18161 : : return SymbolTable_NulSym;
18162 : : /* static analysis guarentees a RETURN statement will be used before here. */
18163 : : __builtin_unreachable ();
18164 : : }
18165 : :
18166 : :
18167 : : /*
18168 : : MakePointer - returns a pointer symbol with PointerName.
18169 : : */
18170 : :
18171 : 172260 : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName)
18172 : : {
18173 : 172260 : unsigned int oaf;
18174 : 172260 : unsigned int sym;
18175 : :
18176 : 172260 : tok = CheckTok (tok, (const char *) "pointer", 7);
18177 : 172260 : sym = HandleHiddenOrDeclare (tok, PointerName, &oaf);
18178 : 172260 : FillInPointerFields (sym, PointerName, SymbolTable_GetCurrentScope (), oaf);
18179 : 172260 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
18180 : 172260 : return sym;
18181 : : /* static analysis guarentees a RETURN statement will be used before here. */
18182 : : __builtin_unreachable ();
18183 : : }
18184 : :
18185 : :
18186 : : /*
18187 : : PutPointer - gives a pointer symbol a type, PointerType.
18188 : : */
18189 : :
18190 : 202652 : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType)
18191 : : {
18192 : 202652 : SymbolTable_PtrToSymbol pSym;
18193 : :
18194 : 202652 : pSym = GetPsym (Sym);
18195 : 202652 : switch (pSym->SymbolType)
18196 : : {
18197 : : case SymbolTable_ErrorSym:
18198 : : break;
18199 : :
18200 : 202652 : case SymbolTable_PointerSym:
18201 : 202652 : pSym->Pointer.Type = PointerType;
18202 : 202652 : break;
18203 : :
18204 : :
18205 : 0 : default:
18206 : 0 : M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26);
18207 : 202652 : break;
18208 : : }
18209 : 202652 : }
18210 : :
18211 : :
18212 : : /*
18213 : : IsPointer - returns true is Sym is a pointer type symbol.
18214 : : */
18215 : :
18216 : 472748973 : extern "C" bool SymbolTable_IsPointer (unsigned int Sym)
18217 : : {
18218 : 472748973 : SymbolTable_PtrToSymbol pSym;
18219 : :
18220 : 472748973 : AssertInRange (Sym);
18221 : 472748973 : pSym = GetPsym (Sym);
18222 : 472748973 : return pSym->SymbolType == SymbolTable_PointerSym;
18223 : : /* static analysis guarentees a RETURN statement will be used before here. */
18224 : : __builtin_unreachable ();
18225 : : }
18226 : :
18227 : :
18228 : : /*
18229 : : IsRecord - returns true is Sym is a record type symbol.
18230 : : */
18231 : :
18232 : 472957562 : extern "C" bool SymbolTable_IsRecord (unsigned int Sym)
18233 : : {
18234 : 472957562 : SymbolTable_PtrToSymbol pSym;
18235 : :
18236 : 472957562 : AssertInRange (Sym);
18237 : 472957556 : pSym = GetPsym (Sym);
18238 : 472957556 : return pSym->SymbolType == SymbolTable_RecordSym;
18239 : : /* static analysis guarentees a RETURN statement will be used before here. */
18240 : : __builtin_unreachable ();
18241 : : }
18242 : :
18243 : :
18244 : : /*
18245 : : IsVarient - returns true if the symbol, Sym, is a
18246 : : varient symbol.
18247 : : */
18248 : :
18249 : 386509965 : extern "C" bool SymbolTable_IsVarient (unsigned int Sym)
18250 : : {
18251 : 386509965 : SymbolTable_PtrToSymbol pSym;
18252 : :
18253 : 386509965 : pSym = GetPsym (Sym);
18254 : 386509965 : return pSym->SymbolType == SymbolTable_VarientSym;
18255 : : /* static analysis guarentees a RETURN statement will be used before here. */
18256 : : __builtin_unreachable ();
18257 : : }
18258 : :
18259 : :
18260 : : /*
18261 : : IsFieldVarient - returns true if the symbol, Sym, is a
18262 : : varient field.
18263 : : */
18264 : :
18265 : 222686337 : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym)
18266 : : {
18267 : 222686337 : SymbolTable_PtrToSymbol pSym;
18268 : :
18269 : 222686337 : pSym = GetPsym (Sym);
18270 : 222686337 : return pSym->SymbolType == SymbolTable_VarientFieldSym;
18271 : : /* static analysis guarentees a RETURN statement will be used before here. */
18272 : : __builtin_unreachable ();
18273 : : }
18274 : :
18275 : :
18276 : : /*
18277 : : IsFieldEnumeration - returns true if the symbol, Sym, is an
18278 : : enumeration field.
18279 : : */
18280 : :
18281 : 11534577 : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym)
18282 : : {
18283 : 11534577 : SymbolTable_PtrToSymbol pSym;
18284 : :
18285 : 11534577 : pSym = GetPsym (Sym);
18286 : 11534577 : return pSym->SymbolType == SymbolTable_EnumerationFieldSym;
18287 : : /* static analysis guarentees a RETURN statement will be used before here. */
18288 : : __builtin_unreachable ();
18289 : : }
18290 : :
18291 : :
18292 : : /*
18293 : : IsArray - returns true is Sym is an array type symbol.
18294 : : */
18295 : :
18296 : 326905933 : extern "C" bool SymbolTable_IsArray (unsigned int Sym)
18297 : : {
18298 : 326905933 : SymbolTable_PtrToSymbol pSym;
18299 : :
18300 : 326905933 : AssertInRange (Sym);
18301 : 326905933 : pSym = GetPsym (Sym);
18302 : 326905933 : return pSym->SymbolType == SymbolTable_ArraySym;
18303 : : /* static analysis guarentees a RETURN statement will be used before here. */
18304 : : __builtin_unreachable ();
18305 : : }
18306 : :
18307 : :
18308 : : /*
18309 : : IsEnumeration - returns true if Sym is an enumeration symbol.
18310 : : */
18311 : :
18312 : 467080336 : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym)
18313 : : {
18314 : 467080336 : SymbolTable_PtrToSymbol pSym;
18315 : :
18316 : 467080336 : AssertInRange (Sym);
18317 : 467080336 : pSym = GetPsym (Sym);
18318 : 467080336 : return pSym->SymbolType == SymbolTable_EnumerationSym;
18319 : : /* static analysis guarentees a RETURN statement will be used before here. */
18320 : : __builtin_unreachable ();
18321 : : }
18322 : :
18323 : :
18324 : : /*
18325 : : IsSet - returns TRUE if Sym is a set symbol.
18326 : : */
18327 : :
18328 : 201590197 : extern "C" bool SymbolTable_IsSet (unsigned int Sym)
18329 : : {
18330 : 201590197 : SymbolTable_PtrToSymbol pSym;
18331 : :
18332 : 201590197 : AssertInRange (Sym);
18333 : 201590197 : pSym = GetPsym (Sym);
18334 : 201590197 : return pSym->SymbolType == SymbolTable_SetSym;
18335 : : /* static analysis guarentees a RETURN statement will be used before here. */
18336 : : __builtin_unreachable ();
18337 : : }
18338 : :
18339 : :
18340 : : /*
18341 : : IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
18342 : : */
18343 : :
18344 : 26421838 : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym)
18345 : : {
18346 : 26421838 : SymbolTable_PtrToSymbol pSym;
18347 : :
18348 : 26421838 : pSym = GetPsym (Sym);
18349 : 26421838 : switch (pSym->SymbolType)
18350 : : {
18351 : 26391567 : case SymbolTable_TypeSym:
18352 : 26391567 : return pSym->Type.IsHidden;
18353 : : break;
18354 : :
18355 : :
18356 : : default:
18357 : : return false;
18358 : : break;
18359 : : }
18360 : : /* static analysis guarentees a RETURN statement will be used before here. */
18361 : : __builtin_unreachable ();
18362 : : }
18363 : :
18364 : :
18365 : : /*
18366 : : IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
18367 : : */
18368 : :
18369 : 0 : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym)
18370 : : {
18371 : 0 : SymbolTable_PtrToSymbol pSym;
18372 : :
18373 : 0 : AssertInRange (Sym);
18374 : 0 : pSym = GetPsym (Sym);
18375 : 0 : return pSym->SymbolType == SymbolTable_OAFamilySym;
18376 : : /* static analysis guarentees a RETURN statement will be used before here. */
18377 : : __builtin_unreachable ();
18378 : : }
18379 : :
18380 : :
18381 : : /*
18382 : : GetDimension - return the number of dimensions associated with
18383 : : this unbounded ARRAY parameter.
18384 : : */
18385 : :
18386 : 374871 : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym)
18387 : : {
18388 : 666121 : SymbolTable_PtrToSymbol pSym;
18389 : :
18390 : 666121 : pSym = GetPsym (sym);
18391 : 666121 : switch (pSym->SymbolType)
18392 : : {
18393 : 0 : case SymbolTable_PartialUnboundedSym:
18394 : 0 : return pSym->PartialUnbounded.NDim;
18395 : 368112 : break;
18396 : :
18397 : 368112 : case SymbolTable_UnboundedSym:
18398 : 368112 : return pSym->Unbounded.Dimensions;
18399 : 0 : break;
18400 : :
18401 : 0 : case SymbolTable_OAFamilySym:
18402 : 0 : return pSym->OAFamily.MaxDimensions;
18403 : 175722 : break;
18404 : :
18405 : 175722 : case SymbolTable_ParamSym:
18406 : 175722 : if (pSym->Param.IsUnbounded)
18407 : : {
18408 : 175722 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18409 : : }
18410 : : else
18411 : : {
18412 : 0 : M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
18413 : : }
18414 : 115492 : break;
18415 : :
18416 : 115492 : case SymbolTable_VarParamSym:
18417 : 115492 : if (pSym->VarParam.IsUnbounded)
18418 : : {
18419 : 115492 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18420 : : }
18421 : : else
18422 : : {
18423 : 0 : M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
18424 : : }
18425 : 6759 : break;
18426 : :
18427 : 6759 : case SymbolTable_ArraySym:
18428 : 6759 : return GetArrayDimension (sym);
18429 : 0 : break;
18430 : :
18431 : 0 : case SymbolTable_TypeSym:
18432 : 0 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18433 : 36 : break;
18434 : :
18435 : 36 : case SymbolTable_VarSym:
18436 : 36 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18437 : 0 : break;
18438 : :
18439 : :
18440 : 0 : default:
18441 : 0 : M2Error_InternalError ((const char *) "expecting PartialUnbounded", 26);
18442 : : break;
18443 : : }
18444 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18445 : : __builtin_unreachable ();
18446 : : }
18447 : :
18448 : :
18449 : : /*
18450 : : MakeOAFamily - makes an OAFamily symbol based on SimpleType.
18451 : : It returns the OAFamily symbol. A new symbol
18452 : : is created if one does not already exist for
18453 : : SimpleType.
18454 : : */
18455 : :
18456 : 1024264 : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType)
18457 : : {
18458 : 1024264 : SymbolTable_PtrToSymbol pSym;
18459 : 1024264 : unsigned int sym;
18460 : :
18461 : 1024264 : sym = SymbolTable_GetOAFamily (SimpleType);
18462 : 1024264 : if (sym == SymbolTable_NulSym)
18463 : : {
18464 : 30332 : NewSym (&sym);
18465 : 30332 : pSym = GetPsym (sym);
18466 : 30332 : pSym->SymbolType = SymbolTable_OAFamilySym;
18467 : 30332 : pSym->OAFamily.MaxDimensions = 0;
18468 : 30332 : pSym->OAFamily.SimpleType = SimpleType;
18469 : 30332 : pSym->OAFamily.Dimensions = Indexing_InitIndex (1);
18470 : 30332 : PutOAFamily (SimpleType, sym);
18471 : : }
18472 : 1024264 : return sym;
18473 : : /* static analysis guarentees a RETURN statement will be used before here. */
18474 : : __builtin_unreachable ();
18475 : : }
18476 : :
18477 : :
18478 : : /*
18479 : : GetOAFamily - returns the oafamily symbol associated with
18480 : : SimpleType.
18481 : : */
18482 : :
18483 : 420778288 : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType)
18484 : : {
18485 : 420778288 : SymbolTable_PtrToSymbol pSym;
18486 : :
18487 : 420778288 : pSym = GetPsym (SimpleType);
18488 : 420778288 : switch (pSym->SymbolType)
18489 : : {
18490 : : case SymbolTable_ErrorSym:
18491 : : return SymbolTable_NulSym;
18492 : 41220998 : break;
18493 : :
18494 : 41220998 : case SymbolTable_RecordSym:
18495 : 41220998 : return pSym->Record.oafamily;
18496 : 5552420 : break;
18497 : :
18498 : 5552420 : case SymbolTable_SubrangeSym:
18499 : 5552420 : return pSym->Subrange.oafamily;
18500 : 11335839 : break;
18501 : :
18502 : 11335839 : case SymbolTable_EnumerationSym:
18503 : 11335839 : return pSym->Enumeration.oafamily;
18504 : 4732855 : break;
18505 : :
18506 : 4732855 : case SymbolTable_ArraySym:
18507 : 4732855 : return pSym->Array.oafamily;
18508 : 4723108 : break;
18509 : :
18510 : 4723108 : case SymbolTable_ProcTypeSym:
18511 : 4723108 : return pSym->ProcType.oafamily;
18512 : 85981568 : break;
18513 : :
18514 : 85981568 : case SymbolTable_TypeSym:
18515 : 85981568 : return pSym->Type.oafamily;
18516 : 48382810 : break;
18517 : :
18518 : 48382810 : case SymbolTable_PointerSym:
18519 : 48382810 : return pSym->Pointer.oafamily;
18520 : 1682774 : break;
18521 : :
18522 : 1682774 : case SymbolTable_SetSym:
18523 : 1682774 : return pSym->Set.oafamily;
18524 : 127347 : break;
18525 : :
18526 : 127347 : case SymbolTable_UndefinedSym:
18527 : 127347 : return pSym->Undefined.oafamily;
18528 : : break;
18529 : :
18530 : :
18531 : : default:
18532 : : return SymbolTable_NulSym;
18533 : : break;
18534 : : }
18535 : : /* static analysis guarentees a RETURN statement will be used before here. */
18536 : : __builtin_unreachable ();
18537 : : }
18538 : :
18539 : :
18540 : : /*
18541 : : ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
18542 : : sym, in the oaf.
18543 : : */
18544 : :
18545 : 419754024 : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p)
18546 : : {
18547 : 419754024 : typedef unsigned int *ForeachOAFamily__T1;
18548 : :
18549 : 419754024 : SymbolTable_PtrToSymbol pSym;
18550 : 419754024 : unsigned int h;
18551 : 419754024 : unsigned int i;
18552 : 419754024 : ForeachOAFamily__T1 pc;
18553 : :
18554 : 419754024 : if (sym != SymbolTable_NulSym)
18555 : : {
18556 : 26031442 : pSym = GetPsym (sym);
18557 : 26031442 : switch (pSym->SymbolType)
18558 : : {
18559 : 26031442 : case SymbolTable_OAFamilySym:
18560 : 26031442 : h = Indexing_HighIndice (pSym->OAFamily.Dimensions);
18561 : 26031442 : i = 1;
18562 : 78257412 : while (i <= h)
18563 : : {
18564 : 26194528 : pc = static_cast<ForeachOAFamily__T1> (Indexing_GetIndice (pSym->OAFamily.Dimensions, i));
18565 : 26194528 : if (pc != NULL)
18566 : : {
18567 : 26194528 : (*p.proc) (sym, i, (*pc));
18568 : : }
18569 : 26194528 : i += 1;
18570 : : }
18571 : : break;
18572 : :
18573 : :
18574 : 0 : default:
18575 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
18576 : : break;
18577 : : }
18578 : : }
18579 : 419754024 : }
18580 : :
18581 : :
18582 : : /*
18583 : : IsUnbounded - returns true if Sym is an unbounded symbol.
18584 : : */
18585 : :
18586 : 253464876 : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym)
18587 : : {
18588 : 253464876 : SymbolTable_PtrToSymbol pSym;
18589 : :
18590 : 253464876 : AssertInRange (Sym);
18591 : 253464876 : pSym = GetPsym (Sym);
18592 : 253464876 : return pSym->SymbolType == SymbolTable_UnboundedSym;
18593 : : /* static analysis guarentees a RETURN statement will be used before here. */
18594 : : __builtin_unreachable ();
18595 : : }
18596 : :
18597 : :
18598 : : /*
18599 : : GetUnbounded - returns the unbounded symbol associated with
18600 : : the OAFamily symbol, oaf, and the number of
18601 : : dimensions, ndim, of the open array.
18602 : : */
18603 : :
18604 : 1024264 : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim)
18605 : : {
18606 : 1024264 : SymbolTable_PtrToSymbol pSym;
18607 : :
18608 : 1024264 : pSym = GetPsym (oaf);
18609 : 1024264 : switch (pSym->SymbolType)
18610 : : {
18611 : 1024264 : case SymbolTable_OAFamilySym:
18612 : 1024264 : if (ndim > pSym->OAFamily.MaxDimensions)
18613 : : {
18614 : : return SymbolTable_NulSym;
18615 : : }
18616 : : else
18617 : : {
18618 : 993872 : return GetFromIndex (pSym->OAFamily.Dimensions, ndim);
18619 : : }
18620 : 0 : break;
18621 : :
18622 : :
18623 : 0 : default:
18624 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
18625 : : break;
18626 : : }
18627 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18628 : : __builtin_unreachable ();
18629 : : }
18630 : :
18631 : :
18632 : : /*
18633 : : GetUnboundedRecordType - returns the record type used to
18634 : : implement the unbounded array.
18635 : : */
18636 : :
18637 : 29287824 : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym)
18638 : : {
18639 : 29287824 : SymbolTable_PtrToSymbol pSym;
18640 : :
18641 : 29287824 : pSym = GetPsym (Sym);
18642 : 29287824 : switch (pSym->SymbolType)
18643 : : {
18644 : 29287824 : case SymbolTable_UnboundedSym:
18645 : 29287824 : return pSym->Unbounded.RecordType;
18646 : 0 : break;
18647 : :
18648 : :
18649 : 0 : default:
18650 : 0 : M2Error_InternalError ((const char *) "expecting an UnBounded symbol", 29);
18651 : : break;
18652 : : }
18653 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18654 : : __builtin_unreachable ();
18655 : : }
18656 : :
18657 : :
18658 : : /*
18659 : : GetUnboundedAddressOffset - returns the offset of the address field
18660 : : inside the record used to implement the
18661 : : unbounded type.
18662 : : */
18663 : :
18664 : 77365 : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym)
18665 : : {
18666 : 77365 : unsigned int field;
18667 : 77365 : unsigned int rec;
18668 : :
18669 : 77365 : rec = SymbolTable_GetUnboundedRecordType (sym);
18670 : 77365 : if (rec == SymbolTable_NulSym)
18671 : : {
18672 : 0 : M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
18673 : : }
18674 : : else
18675 : : {
18676 : 77365 : field = SymbolTable_GetLocalSym (rec, NameKey_MakeKey ((const char *) "_m2_contents", 12));
18677 : 77365 : if (field == SymbolTable_NulSym)
18678 : : {
18679 : 0 : M2Error_InternalError ((const char *) "expecting address field to be present inside unbounded record", 61);
18680 : : }
18681 : : else
18682 : : {
18683 : 77365 : return field;
18684 : : }
18685 : : }
18686 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18687 : : __builtin_unreachable ();
18688 : : }
18689 : :
18690 : :
18691 : : /*
18692 : : GetUnboundedHighOffset - returns the offset of the high field
18693 : : inside the record used to implement the
18694 : : unbounded type.
18695 : : */
18696 : :
18697 : 63930 : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim)
18698 : : {
18699 : 63930 : unsigned int rec;
18700 : :
18701 : 63930 : rec = SymbolTable_GetUnboundedRecordType (sym);
18702 : 63930 : if (rec == SymbolTable_NulSym)
18703 : : {
18704 : 0 : M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
18705 : : }
18706 : : else
18707 : : {
18708 : 63930 : 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))))));
18709 : : }
18710 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18711 : : __builtin_unreachable ();
18712 : : }
18713 : :
18714 : :
18715 : : /*
18716 : : MakeSubscript - makes a subscript Symbol.
18717 : : No name is required.
18718 : : */
18719 : :
18720 : 164285 : extern "C" unsigned int SymbolTable_MakeSubscript (void)
18721 : : {
18722 : 164285 : SymbolTable_PtrToSymbol pSym;
18723 : 164285 : unsigned int Sym;
18724 : :
18725 : 164285 : NewSym (&Sym);
18726 : 164285 : pSym = GetPsym (Sym);
18727 : 164285 : pSym->SymbolType = SymbolTable_SubscriptSym;
18728 : 164285 : pSym->Subscript.Type = SymbolTable_NulSym; /* Index to a subrange symbol. */
18729 : 164285 : pSym->Subscript.Size = M2ALU_InitValue (); /* Size of this indice in*Size */
18730 : 164285 : pSym->Subscript.Offset = M2ALU_InitValue (); /* Offset at runtime of symbol */
18731 : 164285 : InitWhereDeclared (&pSym->Subscript.At); /* Declared here */
18732 : 164285 : return Sym;
18733 : : /* static analysis guarentees a RETURN statement will be used before here. */
18734 : : __builtin_unreachable ();
18735 : : }
18736 : :
18737 : :
18738 : : /*
18739 : : PutSubscript - gives a subscript symbol a type, SimpleType.
18740 : : */
18741 : :
18742 : 164285 : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType)
18743 : : {
18744 : 164285 : SymbolTable_PtrToSymbol pSym;
18745 : :
18746 : 164285 : pSym = GetPsym (Sym);
18747 : 164285 : switch (pSym->SymbolType)
18748 : : {
18749 : : case SymbolTable_ErrorSym:
18750 : : break;
18751 : :
18752 : 164285 : case SymbolTable_SubscriptSym:
18753 : 164285 : pSym->Subscript.Type = SimpleType;
18754 : 164285 : break;
18755 : :
18756 : :
18757 : 0 : default:
18758 : 0 : M2Error_InternalError ((const char *) "expecting a SubScript symbol", 28);
18759 : 164285 : break;
18760 : : }
18761 : 164285 : }
18762 : :
18763 : :
18764 : : /*
18765 : : MakeUnbounded - makes an unbounded array Symbol.
18766 : : ndim is the number of dimensions required.
18767 : : No name is required.
18768 : : */
18769 : :
18770 : 1024264 : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim)
18771 : : {
18772 : 1024264 : unsigned int sym;
18773 : 1024264 : unsigned int oaf;
18774 : :
18775 : 1024264 : tok = CheckTok (tok, (const char *) "unbounded", 9);
18776 : 1024264 : oaf = SymbolTable_MakeOAFamily (SimpleType);
18777 : 1024264 : sym = SymbolTable_GetUnbounded (oaf, ndim);
18778 : 1024264 : if (sym == SymbolTable_NulSym)
18779 : : {
18780 : 30392 : NewSym (&sym);
18781 : 30392 : if (SymbolTable_IsUnknown (SimpleType))
18782 : : {
18783 : 0 : PutPartialUnbounded (sym, SimpleType, ndim);
18784 : : }
18785 : : else
18786 : : {
18787 : 30392 : FillInUnboundedFields (tok, sym, SimpleType, ndim);
18788 : : }
18789 : 30392 : PutUnbounded (oaf, sym, ndim);
18790 : : }
18791 : 1024264 : return sym;
18792 : : /* static analysis guarentees a RETURN statement will be used before here. */
18793 : : __builtin_unreachable ();
18794 : : }
18795 : :
18796 : :
18797 : : /*
18798 : : NoOfElements - Returns the number of elements in array Sym,
18799 : : or the number of elements in an enumeration Sym or
18800 : : the number of interface symbols in an Interface list.
18801 : : */
18802 : :
18803 : 244 : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym)
18804 : : {
18805 : 244 : SymbolTable_PtrToSymbol pSym;
18806 : 244 : unsigned int n;
18807 : :
18808 : 244 : pSym = GetPsym (Sym);
18809 : 244 : switch (pSym->SymbolType)
18810 : : {
18811 : : case SymbolTable_ErrorSym:
18812 : : n = 0;
18813 : : break;
18814 : :
18815 : 244 : case SymbolTable_EnumerationSym:
18816 : 244 : n = pSym->Enumeration.NoOfElements;
18817 : 244 : break;
18818 : :
18819 : 0 : case SymbolTable_InterfaceSym:
18820 : 0 : n = Indexing_HighIndice (pSym->Interface.Parameters);
18821 : 0 : break;
18822 : :
18823 : :
18824 : 0 : default:
18825 : 0 : M2Error_InternalError ((const char *) "expecting an Array or UnBounded symbol", 38);
18826 : 244 : break;
18827 : : }
18828 : 244 : return n;
18829 : : /* static analysis guarentees a RETURN statement will be used before here. */
18830 : : __builtin_unreachable ();
18831 : : }
18832 : :
18833 : :
18834 : : /*
18835 : : PutArray - places a type symbol into an arraysym.
18836 : : */
18837 : :
18838 : 164285 : extern "C" void SymbolTable_PutArray (unsigned int arraysym, unsigned int typesym)
18839 : : {
18840 : 164285 : SymbolTable_PtrToSymbol pSym;
18841 : :
18842 : 164285 : pSym = GetPsym (arraysym);
18843 : 164285 : switch (pSym->SymbolType)
18844 : : {
18845 : : case SymbolTable_ErrorSym:
18846 : : break;
18847 : :
18848 : 164285 : case SymbolTable_ArraySym:
18849 : 164285 : pSym->Array.Type = typesym; /* The ARRAY OF typesym. */
18850 : 164285 : break;
18851 : :
18852 : :
18853 : 0 : default:
18854 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
18855 : 164285 : break;
18856 : : }
18857 : 164285 : }
18858 : :
18859 : :
18860 : : /*
18861 : : ResolveImports - it examines the import list of all inner modules
18862 : : and resolves all relative imports.
18863 : : */
18864 : :
18865 : 82771 : extern "C" void SymbolTable_ResolveImports (void)
18866 : : {
18867 : 82771 : unsigned int scope;
18868 : :
18869 : 82771 : scope = SymbolTable_GetCurrentScope ();
18870 : 82771 : if (DebugUnknowns)
18871 : : {
18872 : : SymbolTable_DisplayTrees (scope);
18873 : : }
18874 : 82771 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
18875 : 82771 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
18876 : 82771 : }
18877 : :
18878 : :
18879 : : /*
18880 : : ResolveConstructorTypes - to be called at the end of pass three. Its
18881 : : purpose is to fix up all constructors whose
18882 : : types are unknown.
18883 : : */
18884 : :
18885 : 14941 : extern "C" void SymbolTable_ResolveConstructorTypes (void)
18886 : : {
18887 : 51393 : bool finished;
18888 : 51393 : unsigned int i;
18889 : 51393 : unsigned int n;
18890 : 51393 : unsigned int s;
18891 : :
18892 : 51393 : do {
18893 : 51393 : n = Lists_NoOfItemsInList (UnresolvedConstructorType);
18894 : 51393 : finished = true;
18895 : 51393 : i = 1;
18896 : 139244 : while (i <= n)
18897 : : {
18898 : 36458 : s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
18899 : 36458 : M2Debug_Assert (SymbolTable_IsConstructor (s));
18900 : 36458 : if (CanResolveConstructor (s))
18901 : : {
18902 : 36452 : finished = false;
18903 : 36452 : Lists_RemoveItemFromList (UnresolvedConstructorType, s);
18904 : 36452 : i = n;
18905 : : }
18906 : 36458 : i += 1;
18907 : : }
18908 : 51393 : } while (! (finished));
18909 : 14941 : CheckAllConstructorsResolved ();
18910 : 14935 : }
18911 : :
18912 : :
18913 : : /*
18914 : : AddNameToScope - adds a Name, n, to the list of objects declared at the
18915 : : current scope.
18916 : : */
18917 : :
18918 : 7904572 : extern "C" void SymbolTable_AddNameToScope (unsigned int tok, NameKey_Name n)
18919 : : {
18920 : 7904572 : SymbolTable_PtrToSymbol pSym;
18921 : 7904572 : unsigned int scope;
18922 : :
18923 : 7904572 : scope = SymbolTable_GetCurrentScope ();
18924 : 7904572 : pSym = GetPsym (scope);
18925 : 7904572 : switch (pSym->SymbolType)
18926 : : {
18927 : 1562596 : case SymbolTable_ProcedureSym:
18928 : 1562596 : AddNameTo (pSym->Procedure.NamedObjects, MakeObject (tok, n));
18929 : 1562596 : break;
18930 : :
18931 : 45361 : case SymbolTable_ModuleSym:
18932 : 45361 : AddNameTo (pSym->Module.NamedObjects, MakeObject (tok, n));
18933 : 45361 : break;
18934 : :
18935 : 6296615 : case SymbolTable_DefImpSym:
18936 : 6296615 : AddNameTo (pSym->DefImp.NamedObjects, MakeObject (tok, n));
18937 : 6296615 : break;
18938 : :
18939 : :
18940 : 0 : default:
18941 : 0 : M2Error_InternalError ((const char *) "expecting - DefImp", 18);
18942 : 7904572 : break;
18943 : : }
18944 : 7904572 : }
18945 : :
18946 : :
18947 : : /*
18948 : : AddNameToImportList - adds a Name, n, to the import list of the current
18949 : : module.
18950 : : */
18951 : :
18952 : 170 : extern "C" void SymbolTable_AddNameToImportList (unsigned int tok, NameKey_Name n)
18953 : : {
18954 : 170 : SymbolTable_PtrToSymbol pSym;
18955 : 170 : unsigned int scope;
18956 : :
18957 : 170 : scope = SymbolTable_GetCurrentScope ();
18958 : 170 : pSym = GetPsym (scope);
18959 : 170 : switch (pSym->SymbolType)
18960 : : {
18961 : 170 : case SymbolTable_ModuleSym:
18962 : 170 : AddNameTo (pSym->Module.NamedImports, MakeObject (tok, n));
18963 : 170 : break;
18964 : :
18965 : 0 : case SymbolTable_DefImpSym:
18966 : 0 : AddNameTo (pSym->DefImp.NamedImports, MakeObject (tok, n));
18967 : 0 : break;
18968 : :
18969 : :
18970 : 0 : default:
18971 : 0 : M2Error_InternalError ((const char *) "expecting - DefImp or Module symbol", 35);
18972 : 170 : break;
18973 : : }
18974 : 170 : }
18975 : :
18976 : :
18977 : : /*
18978 : : GetScope - returns the declaration scope of the symbol.
18979 : : */
18980 : :
18981 : 78637521 : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym)
18982 : : {
18983 : 78637521 : SymbolTable_PtrToSymbol pSym;
18984 : :
18985 : 78637521 : pSym = GetPsym (Sym);
18986 : 78637521 : switch (pSym->SymbolType)
18987 : : {
18988 : 0 : case SymbolTable_ErrorSym:
18989 : 0 : return pSym->Error.Scope;
18990 : : break;
18991 : :
18992 : : case SymbolTable_DefImpSym:
18993 : : return SymbolTable_NulSym;
18994 : 3341524 : break;
18995 : :
18996 : 3341524 : case SymbolTable_ModuleSym:
18997 : 3341524 : return pSym->Module.Scope;
18998 : 3220255 : break;
18999 : :
19000 : 3220255 : case SymbolTable_VarSym:
19001 : 3220255 : return pSym->Var.Scope;
19002 : 47529241 : break;
19003 : :
19004 : 47529241 : case SymbolTable_ProcedureSym:
19005 : 47529241 : return pSym->Procedure.Scope;
19006 : 235960 : break;
19007 : :
19008 : 235960 : case SymbolTable_ProcTypeSym:
19009 : 235960 : return pSym->ProcType.Scope;
19010 : 1138754 : break;
19011 : :
19012 : 1138754 : case SymbolTable_RecordFieldSym:
19013 : 1138754 : return pSym->RecordField.Scope;
19014 : 8430 : break;
19015 : :
19016 : 8430 : case SymbolTable_VarientSym:
19017 : 8430 : return pSym->Varient.Scope;
19018 : 23076 : break;
19019 : :
19020 : 23076 : case SymbolTable_VarientFieldSym:
19021 : 23076 : return pSym->VarientField.Scope;
19022 : 134520 : break;
19023 : :
19024 : 134520 : case SymbolTable_EnumerationSym:
19025 : 134520 : return pSym->Enumeration.Scope;
19026 : 1829200 : break;
19027 : :
19028 : 1829200 : case SymbolTable_EnumerationFieldSym:
19029 : 1829200 : return pSym->EnumerationField.Scope;
19030 : 340509 : break;
19031 : :
19032 : 340509 : case SymbolTable_SubrangeSym:
19033 : 340509 : return pSym->Subrange.Scope;
19034 : 1401 : break;
19035 : :
19036 : 1401 : case SymbolTable_ArraySym:
19037 : 1401 : return pSym->Array.Scope;
19038 : 188200 : break;
19039 : :
19040 : 188200 : case SymbolTable_TypeSym:
19041 : 188200 : return pSym->Type.Scope;
19042 : 100871 : break;
19043 : :
19044 : 100871 : case SymbolTable_PointerSym:
19045 : 100871 : return pSym->Pointer.Scope;
19046 : 707344 : break;
19047 : :
19048 : 707344 : case SymbolTable_RecordSym:
19049 : 707344 : return pSym->Record.Scope;
19050 : 16136 : break;
19051 : :
19052 : 16136 : case SymbolTable_SetSym:
19053 : 16136 : return pSym->Set.Scope;
19054 : 24 : break;
19055 : :
19056 : 24 : case SymbolTable_UnboundedSym:
19057 : 24 : return pSym->Unbounded.Scope;
19058 : 12 : break;
19059 : :
19060 : 12 : case SymbolTable_ConstLitSym:
19061 : 12 : return pSym->ConstLit.Scope;
19062 : 48 : break;
19063 : :
19064 : 48 : case SymbolTable_ConstStringSym:
19065 : 48 : return pSym->ConstString.Scope;
19066 : 258 : break;
19067 : :
19068 : 258 : case SymbolTable_ConstVarSym:
19069 : 258 : return pSym->ConstVar.Scope;
19070 : 150 : break;
19071 : :
19072 : 150 : case SymbolTable_ParamSym:
19073 : 150 : return pSym->Param.Scope;
19074 : 12 : break;
19075 : :
19076 : 12 : case SymbolTable_VarParamSym:
19077 : 12 : return pSym->VarParam.Scope;
19078 : : break;
19079 : :
19080 : : case SymbolTable_UndefinedSym:
19081 : : return SymbolTable_NulSym;
19082 : 0 : break;
19083 : :
19084 : 0 : case SymbolTable_PartialUnboundedSym:
19085 : 0 : M2Error_InternalError ((const char *) "should not be requesting the scope of a PartialUnbounded symbol", 63);
19086 : 0 : break;
19087 : :
19088 : :
19089 : 0 : default:
19090 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
19091 : : break;
19092 : : }
19093 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19094 : : __builtin_unreachable ();
19095 : : }
19096 : :
19097 : :
19098 : : /*
19099 : : GetModuleScope - returns the module scope of symbol, sym.
19100 : : If sym was declared within a nested procedure
19101 : : then return the module which defines the
19102 : : procedure.
19103 : : */
19104 : :
19105 : 456844 : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym)
19106 : : {
19107 : 456844 : unsigned int mod;
19108 : :
19109 : 456844 : mod = SymbolTable_GetScope (sym);
19110 : 914744 : while (((mod != SymbolTable_NulSym) && (! (SymbolTable_IsDefImp (mod)))) && (! (SymbolTable_IsModule (mod))))
19111 : : {
19112 : 1056 : mod = SymbolTable_GetScope (mod);
19113 : : }
19114 : 456844 : return mod;
19115 : : /* static analysis guarentees a RETURN statement will be used before here. */
19116 : : __builtin_unreachable ();
19117 : : }
19118 : :
19119 : :
19120 : : /*
19121 : : GetProcedureScope - returns the innermost procedure (if any)
19122 : : in which the symbol, sym, resides.
19123 : : A module inside the procedure is skipped
19124 : : over.
19125 : : */
19126 : :
19127 : 371726 : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym)
19128 : : {
19129 : 748060 : while ((sym != SymbolTable_NulSym) && (! (SymbolTable_IsProcedure (sym))))
19130 : : {
19131 : 376334 : sym = SymbolTable_GetScope (sym);
19132 : : }
19133 : 371726 : if ((sym != SymbolTable_NulSym) && (SymbolTable_IsProcedure (sym)))
19134 : : {
19135 : : return sym;
19136 : : }
19137 : : else
19138 : : {
19139 : 369392 : return SymbolTable_NulSym;
19140 : : }
19141 : : /* static analysis guarentees a RETURN statement will be used before here. */
19142 : : __builtin_unreachable ();
19143 : : }
19144 : :
19145 : :
19146 : : /*
19147 : : IsModuleWithinProcedure - returns TRUE if module, sym, is
19148 : : inside a procedure.
19149 : : */
19150 : :
19151 : 264774 : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym)
19152 : : {
19153 : 264774 : return (SymbolTable_GetProcedureScope (sym)) != SymbolTable_NulSym;
19154 : : /* static analysis guarentees a RETURN statement will be used before here. */
19155 : : __builtin_unreachable ();
19156 : : }
19157 : :
19158 : :
19159 : : /*
19160 : : GetParent - returns the parent of symbol, Sym.
19161 : : */
19162 : :
19163 : 2342390 : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym)
19164 : : {
19165 : 2342390 : SymbolTable_PtrToSymbol pSym;
19166 : :
19167 : 2342390 : pSym = GetPsym (Sym);
19168 : 2342390 : switch (pSym->SymbolType)
19169 : : {
19170 : 6 : case SymbolTable_ErrorSym:
19171 : 6 : M2Error_ErrorAbort0 ((const char *) "", 0);
19172 : 576946 : break;
19173 : :
19174 : 576946 : case SymbolTable_VarientSym:
19175 : 576946 : return pSym->Varient.Parent;
19176 : 1734438 : break;
19177 : :
19178 : 1734438 : case SymbolTable_VarientFieldSym:
19179 : 1734438 : return pSym->VarientField.Parent;
19180 : 31000 : break;
19181 : :
19182 : 31000 : case SymbolTable_RecordFieldSym:
19183 : 31000 : return pSym->RecordField.Parent;
19184 : 0 : break;
19185 : :
19186 : 0 : case SymbolTable_EnumerationFieldSym:
19187 : 0 : return pSym->EnumerationField.Type;
19188 : 0 : break;
19189 : :
19190 : :
19191 : 0 : default:
19192 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
19193 : : break;
19194 : : }
19195 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19196 : : __builtin_unreachable ();
19197 : : }
19198 : :
19199 : :
19200 : : /*
19201 : : IsRecordField - returns true if Sym is a record field.
19202 : : */
19203 : :
19204 : 669603081 : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym)
19205 : : {
19206 : 669603081 : SymbolTable_PtrToSymbol pSym;
19207 : :
19208 : 669603081 : pSym = GetPsym (Sym);
19209 : 669603081 : return pSym->SymbolType == SymbolTable_RecordFieldSym;
19210 : : /* static analysis guarentees a RETURN statement will be used before here. */
19211 : : __builtin_unreachable ();
19212 : : }
19213 : :
19214 : :
19215 : : /*
19216 : : MakeProcType - returns a procedure type symbol with ProcTypeName.
19217 : : */
19218 : :
19219 : 5127892 : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName)
19220 : : {
19221 : 5127892 : SymbolTable_PtrToSymbol pSym;
19222 : 5127892 : unsigned int oaf;
19223 : 5127892 : unsigned int sym;
19224 : :
19225 : 5127892 : tok = CheckTok (tok, (const char *) "proctype", 8);
19226 : 5127892 : sym = HandleHiddenOrDeclare (tok, ProcTypeName, &oaf);
19227 : 5127892 : if (! (SymbolTable_IsError (sym)))
19228 : : {
19229 : 5127892 : pSym = GetPsym (sym);
19230 : 5127892 : pSym->SymbolType = SymbolTable_ProcTypeSym;
19231 : 5127892 : switch (pSym->SymbolType)
19232 : : {
19233 : 5127892 : case SymbolTable_ProcTypeSym:
19234 : 5127892 : pSym->ProcType.ReturnType = SymbolTable_NulSym;
19235 : 5127892 : pSym->ProcType.name = ProcTypeName;
19236 : 5127892 : Lists_InitList (&pSym->ProcType.ListOfParam);
19237 : 5127892 : pSym->ProcType.HasVarArgs = false; /* Does this proc type use ... ? */
19238 : 5127892 : pSym->ProcType.HasOptArg = false; /* Does this proc type use [ ] ? */
19239 : 5127892 : pSym->ProcType.OptArgInit = SymbolTable_NulSym; /* The optarg initial value. */
19240 : 5127892 : pSym->ProcType.ReturnOptional = false; /* Is the return value optional? */
19241 : 5127892 : pSym->ProcType.ReturnTypeTok = M2LexBuf_UnknownTokenNo; /* Is the return value optional? */
19242 : 5127892 : pSym->ProcType.Scope = SymbolTable_GetCurrentScope ();
19243 : : /* scope of procedure. */
19244 : 5127892 : pSym->ProcType.Size = M2ALU_InitValue ();
19245 : 5127892 : pSym->ProcType.TotalParamSize = M2ALU_InitValue (); /* size of all parameters */
19246 : 5127892 : pSym->ProcType.oafamily = oaf; /* The oa family for this symbol */
19247 : 5127892 : InitWhereDeclaredTok (tok, &pSym->ProcType.At); /* Declared here */
19248 : 5127892 : break;
19249 : :
19250 : :
19251 : : default:
19252 : : M2Error_InternalError ((const char *) "expecting ProcType symbol", 25);
19253 : 5127892 : break;
19254 : : }
19255 : : }
19256 : 5127892 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
19257 : 5127892 : return sym;
19258 : : /* static analysis guarentees a RETURN statement will be used before here. */
19259 : : __builtin_unreachable ();
19260 : : }
19261 : :
19262 : :
19263 : : /*
19264 : : PutProcTypeParam - Places a Non VAR parameter ParamName with type
19265 : : ParamType into ProcType Sym.
19266 : : */
19267 : :
19268 : 8174612 : extern "C" void SymbolTable_PutProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded)
19269 : : {
19270 : 8174612 : SymbolTable_PtrToSymbol pSym;
19271 : 8174612 : unsigned int ParSym;
19272 : :
19273 : 8174612 : NewSym (&ParSym);
19274 : 8174612 : pSym = GetPsym (ParSym);
19275 : 8174612 : pSym->SymbolType = SymbolTable_ParamSym;
19276 : 8174612 : pSym->Param.name = NameKey_NulName;
19277 : 8174612 : pSym->Param.Type = ParamType;
19278 : 8174612 : pSym->Param.IsUnbounded = isUnbounded;
19279 : 8174612 : pSym->Param.ShadowVar = SymbolTable_NulSym;
19280 : 8174612 : pSym->Param.FullTok = tok;
19281 : 8174612 : pSym->Param.At = tok;
19282 : 8174612 : AddParameter (Sym, SymbolTable_ProperProcedure, ParSym);
19283 : 8174612 : }
19284 : :
19285 : :
19286 : : /*
19287 : : PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
19288 : : ParamType into ProcType Sym.
19289 : : */
19290 : :
19291 : 759125 : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded)
19292 : : {
19293 : 759125 : SymbolTable_PtrToSymbol pSym;
19294 : 759125 : unsigned int ParSym;
19295 : :
19296 : 759125 : NewSym (&ParSym);
19297 : 759125 : pSym = GetPsym (ParSym);
19298 : 759125 : pSym->SymbolType = SymbolTable_VarParamSym;
19299 : 759125 : pSym->Param.name = NameKey_NulName;
19300 : 759125 : pSym->Param.Type = ParamType;
19301 : 759125 : pSym->Param.IsUnbounded = isUnbounded;
19302 : 759125 : pSym->Param.ShadowVar = SymbolTable_NulSym;
19303 : 759125 : pSym->Param.FullTok = tok;
19304 : 759125 : pSym->Param.At = tok;
19305 : 759125 : AddParameter (Sym, SymbolTable_ProperProcedure, ParSym);
19306 : 759125 : }
19307 : :
19308 : :
19309 : : /*
19310 : : IsProcType - returns true if Sym is a ProcType Symbol.
19311 : : */
19312 : :
19313 : 278746824 : extern "C" bool SymbolTable_IsProcType (unsigned int Sym)
19314 : : {
19315 : 278746824 : SymbolTable_PtrToSymbol pSym;
19316 : :
19317 : 278746824 : pSym = GetPsym (Sym);
19318 : 278746824 : return pSym->SymbolType == SymbolTable_ProcTypeSym;
19319 : : /* static analysis guarentees a RETURN statement will be used before here. */
19320 : : __builtin_unreachable ();
19321 : : }
19322 : :
19323 : :
19324 : : /*
19325 : : IsVar - returns true if Sym is a Var Symbol.
19326 : : */
19327 : :
19328 : 152378146 : extern "C" bool SymbolTable_IsVar (unsigned int Sym)
19329 : : {
19330 : 152378146 : SymbolTable_PtrToSymbol pSym;
19331 : :
19332 : 152378146 : pSym = GetPsym (Sym);
19333 : 152378146 : return pSym->SymbolType == SymbolTable_VarSym;
19334 : : /* static analysis guarentees a RETURN statement will be used before here. */
19335 : : __builtin_unreachable ();
19336 : : }
19337 : :
19338 : :
19339 : : /*
19340 : : IsVarConst - returns the IsConst field indicating the variable is read only.
19341 : : */
19342 : :
19343 : 318850 : extern "C" bool SymbolTable_IsVarConst (unsigned int sym)
19344 : : {
19345 : 318850 : SymbolTable_PtrToSymbol pSym;
19346 : :
19347 : 318850 : pSym = GetPsym (sym);
19348 : 318850 : switch (pSym->SymbolType)
19349 : : {
19350 : 318850 : case SymbolTable_VarSym:
19351 : 318850 : return pSym->Var.IsConst;
19352 : 0 : break;
19353 : :
19354 : :
19355 : 0 : default:
19356 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
19357 : : break;
19358 : : }
19359 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19360 : : __builtin_unreachable ();
19361 : : }
19362 : :
19363 : :
19364 : : /*
19365 : : IsConst - returns true if Sym contains a constant value.
19366 : : */
19367 : :
19368 : 236212420 : extern "C" bool SymbolTable_IsConst (unsigned int Sym)
19369 : : {
19370 : 236212420 : if (SymbolTable_IsConstructor (Sym))
19371 : : {
19372 : 3586813 : return SymbolTable_IsConstructorConstant (Sym);
19373 : : }
19374 : : else
19375 : : {
19376 : 232625607 : return DoIsConst (Sym);
19377 : : }
19378 : : /* static analysis guarentees a RETURN statement will be used before here. */
19379 : : __builtin_unreachable ();
19380 : : }
19381 : :
19382 : :
19383 : : /*
19384 : : IsConstString - returns whether sym is a conststring of any variant.
19385 : : */
19386 : :
19387 : 7495625 : extern "C" bool SymbolTable_IsConstString (unsigned int sym)
19388 : : {
19389 : 7495625 : SymbolTable_PtrToSymbol pSym;
19390 : :
19391 : 7495625 : pSym = GetPsym (sym);
19392 : 7495625 : return pSym->SymbolType == SymbolTable_ConstStringSym;
19393 : : /* static analysis guarentees a RETURN statement will be used before here. */
19394 : : __builtin_unreachable ();
19395 : : }
19396 : :
19397 : :
19398 : : /*
19399 : : IsConstStringNulTerminated - returns TRUE if the constant string, sym,
19400 : : should be created with a nul terminator.
19401 : : */
19402 : :
19403 : 0 : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym)
19404 : : {
19405 : 0 : SymbolTable_PtrToSymbol pSym;
19406 : :
19407 : 0 : pSym = GetPsym (sym);
19408 : 0 : switch (pSym->SymbolType)
19409 : : {
19410 : 0 : case SymbolTable_ConstStringSym:
19411 : 0 : return (pSym->ConstString.StringVariant == SymbolTable_m2nulstr) || (pSym->ConstString.StringVariant == SymbolTable_cnulstr);
19412 : 0 : break;
19413 : :
19414 : :
19415 : 0 : default:
19416 : 0 : M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
19417 : : break;
19418 : : }
19419 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19420 : : __builtin_unreachable ();
19421 : : }
19422 : :
19423 : :
19424 : : /*
19425 : : IsConstLit - returns true if Sym is a literal constant.
19426 : : */
19427 : :
19428 : 8957641 : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym)
19429 : : {
19430 : 8957641 : SymbolTable_PtrToSymbol pSym;
19431 : :
19432 : 8957641 : pSym = GetPsym (Sym);
19433 : 8957641 : return pSym->SymbolType == SymbolTable_ConstLitSym;
19434 : : /* static analysis guarentees a RETURN statement will be used before here. */
19435 : : __builtin_unreachable ();
19436 : : }
19437 : :
19438 : :
19439 : : /*
19440 : : IsConstructor - returns TRUE if the constant is declared as a
19441 : : constant set, array or record.
19442 : : */
19443 : :
19444 : 384756483 : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym)
19445 : : {
19446 : 384756483 : SymbolTable_PtrToSymbol pSym;
19447 : :
19448 : 384756483 : pSym = GetPsym (Sym);
19449 : 384756483 : switch (pSym->SymbolType)
19450 : : {
19451 : 62633023 : case SymbolTable_ConstVarSym:
19452 : 62633023 : return pSym->ConstVar.IsConstructor;
19453 : 67055929 : break;
19454 : :
19455 : 67055929 : case SymbolTable_ConstLitSym:
19456 : 67055929 : return pSym->ConstLit.IsConstructor;
19457 : : break;
19458 : :
19459 : :
19460 : : default:
19461 : : return false;
19462 : : break;
19463 : : }
19464 : : /* static analysis guarentees a RETURN statement will be used before here. */
19465 : : __builtin_unreachable ();
19466 : : }
19467 : :
19468 : :
19469 : : /*
19470 : : IsDummy - returns true if Sym is a Dummy symbol.
19471 : : */
19472 : :
19473 : 0 : extern "C" bool SymbolTable_IsDummy (unsigned int Sym)
19474 : : {
19475 : 0 : SymbolTable_PtrToSymbol pSym;
19476 : :
19477 : 0 : pSym = GetPsym (Sym);
19478 : 0 : return pSym->SymbolType == SymbolTable_DummySym;
19479 : : /* static analysis guarentees a RETURN statement will be used before here. */
19480 : : __builtin_unreachable ();
19481 : : }
19482 : :
19483 : :
19484 : : /*
19485 : : IsTemporary - returns true if Sym is a Temporary symbol.
19486 : : */
19487 : :
19488 : 2009706 : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym)
19489 : : {
19490 : 2009706 : SymbolTable_PtrToSymbol pSym;
19491 : :
19492 : 2009706 : pSym = GetPsym (Sym);
19493 : 2009706 : switch (pSym->SymbolType)
19494 : : {
19495 : 1925945 : case SymbolTable_VarSym:
19496 : 1925945 : return pSym->Var.IsTemp;
19497 : 3318 : break;
19498 : :
19499 : 3318 : case SymbolTable_ConstVarSym:
19500 : 3318 : return pSym->ConstVar.IsTemp;
19501 : : break;
19502 : :
19503 : :
19504 : : default:
19505 : : return false;
19506 : : break;
19507 : : }
19508 : : /* static analysis guarentees a RETURN statement will be used before here. */
19509 : : __builtin_unreachable ();
19510 : : }
19511 : :
19512 : :
19513 : : /*
19514 : : IsVarAParam - returns true if Sym is a variable declared as a parameter.
19515 : : */
19516 : :
19517 : 34243 : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym)
19518 : : {
19519 : 34243 : SymbolTable_PtrToSymbol pSym;
19520 : :
19521 : 34243 : pSym = GetPsym (Sym);
19522 : 34243 : switch (pSym->SymbolType)
19523 : : {
19524 : 34243 : case SymbolTable_VarSym:
19525 : 34243 : return pSym->Var.IsParam;
19526 : : break;
19527 : :
19528 : :
19529 : : default:
19530 : : return false;
19531 : : break;
19532 : : }
19533 : : /* static analysis guarentees a RETURN statement will be used before here. */
19534 : : __builtin_unreachable ();
19535 : : }
19536 : :
19537 : :
19538 : : /*
19539 : : IsSubscript - returns true if Sym is a subscript symbol.
19540 : : */
19541 : :
19542 : 5772582 : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym)
19543 : : {
19544 : 5772582 : SymbolTable_PtrToSymbol pSym;
19545 : :
19546 : 5772582 : pSym = GetPsym (Sym);
19547 : 5772582 : return pSym->SymbolType == SymbolTable_SubscriptSym;
19548 : : /* static analysis guarentees a RETURN statement will be used before here. */
19549 : : __builtin_unreachable ();
19550 : : }
19551 : :
19552 : :
19553 : : /*
19554 : : IsSubrange - returns true if Sym is a subrange symbol.
19555 : : */
19556 : :
19557 : 439729839 : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym)
19558 : : {
19559 : 439729839 : SymbolTable_PtrToSymbol pSym;
19560 : :
19561 : 439729839 : pSym = GetPsym (Sym);
19562 : 439729839 : return pSym->SymbolType == SymbolTable_SubrangeSym;
19563 : : /* static analysis guarentees a RETURN statement will be used before here. */
19564 : : __builtin_unreachable ();
19565 : : }
19566 : :
19567 : :
19568 : : /*
19569 : : IsProcedureVariable - returns true if a Sym is a variable and
19570 : : it was declared within a procedure.
19571 : : */
19572 : :
19573 : 0 : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym)
19574 : : {
19575 : 0 : AssertInRange (Sym);
19576 : 0 : return (SymbolTable_IsVar (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetVarScope (Sym)));
19577 : : /* static analysis guarentees a RETURN statement will be used before here. */
19578 : : __builtin_unreachable ();
19579 : : }
19580 : :
19581 : :
19582 : : /*
19583 : : IsProcedureNested - returns TRUE if procedure, Sym, was
19584 : : declared as a nested procedure.
19585 : : */
19586 : :
19587 : 4594391 : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym)
19588 : : {
19589 : 4594391 : return (SymbolTable_IsProcedure (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetScope (Sym)));
19590 : : /* static analysis guarentees a RETURN statement will be used before here. */
19591 : : __builtin_unreachable ();
19592 : : }
19593 : :
19594 : :
19595 : : /*
19596 : : IsAModula2Type - returns true if Sym, is a:
19597 : : IsType, IsPointer, IsRecord, IsEnumeration,
19598 : : IsSubrange, IsArray, IsUnbounded, IsProcType.
19599 : : NOTE that it different from IsType.
19600 : : */
19601 : :
19602 : 47587198 : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym)
19603 : : {
19604 : 47587198 : AssertInRange (Sym);
19605 : 47587198 : 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));
19606 : : /* static analysis guarentees a RETURN statement will be used before here. */
19607 : : __builtin_unreachable ();
19608 : : }
19609 : :
19610 : :
19611 : : /*
19612 : : IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
19613 : : */
19614 : :
19615 : 27 : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym)
19616 : : {
19617 : 27 : SymbolTable_PtrToSymbol pSym;
19618 : :
19619 : 27 : pSym = GetPsym (Sym);
19620 : 27 : switch (pSym->SymbolType)
19621 : : {
19622 : 27 : case SymbolTable_GnuAsmSym:
19623 : 27 : return pSym->GnuAsm.Volatile;
19624 : 0 : break;
19625 : :
19626 : :
19627 : 0 : default:
19628 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
19629 : : break;
19630 : : }
19631 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19632 : : __builtin_unreachable ();
19633 : : }
19634 : :
19635 : :
19636 : : /*
19637 : : IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
19638 : : */
19639 : :
19640 : 27 : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym)
19641 : : {
19642 : 27 : SymbolTable_PtrToSymbol pSym;
19643 : :
19644 : 27 : pSym = GetPsym (Sym);
19645 : 27 : switch (pSym->SymbolType)
19646 : : {
19647 : 27 : case SymbolTable_GnuAsmSym:
19648 : 27 : return pSym->GnuAsm.Simple;
19649 : 0 : break;
19650 : :
19651 : :
19652 : 0 : default:
19653 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
19654 : : break;
19655 : : }
19656 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19657 : : __builtin_unreachable ();
19658 : : }
19659 : :
19660 : :
19661 : : /*
19662 : : IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
19663 : : */
19664 : :
19665 : 108 : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym)
19666 : : {
19667 : 108 : SymbolTable_PtrToSymbol pSym;
19668 : :
19669 : 108 : pSym = GetPsym (Sym);
19670 : 108 : return pSym->SymbolType == SymbolTable_GnuAsmSym;
19671 : : /* static analysis guarentees a RETURN statement will be used before here. */
19672 : : __builtin_unreachable ();
19673 : : }
19674 : :
19675 : :
19676 : : /*
19677 : : IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
19678 : : */
19679 : :
19680 : 0 : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym)
19681 : : {
19682 : 0 : SymbolTable_PtrToSymbol pSym;
19683 : :
19684 : 0 : pSym = GetPsym (Sym);
19685 : 0 : return pSym->SymbolType == SymbolTable_InterfaceSym;
19686 : : /* static analysis guarentees a RETURN statement will be used before here. */
19687 : : __builtin_unreachable ();
19688 : : }
19689 : :
19690 : :
19691 : : /*
19692 : : IsSizeSolved - returns true if the size of Sym is solved.
19693 : : */
19694 : :
19695 : 23455 : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym)
19696 : : {
19697 : 23455 : SymbolTable_PtrToSymbol pSym;
19698 : :
19699 : 23455 : AssertInRange (Sym);
19700 : 23455 : pSym = GetPsym (Sym);
19701 : 23455 : switch (pSym->SymbolType)
19702 : : {
19703 : 0 : case SymbolTable_ProcedureSym:
19704 : 0 : return M2ALU_IsSolved (pSym->Procedure.Size);
19705 : 3036 : break;
19706 : :
19707 : 3036 : case SymbolTable_VarSym:
19708 : 3036 : return M2ALU_IsSolved (pSym->Var.Size);
19709 : 16057 : break;
19710 : :
19711 : 16057 : case SymbolTable_TypeSym:
19712 : 16057 : return M2ALU_IsSolved (pSym->Type.Size);
19713 : 788 : break;
19714 : :
19715 : 788 : case SymbolTable_SetSym:
19716 : 788 : return M2ALU_IsSolved (pSym->Set.Size);
19717 : 12 : break;
19718 : :
19719 : 12 : case SymbolTable_RecordSym:
19720 : 12 : return M2ALU_IsSolved (pSym->Record.Size);
19721 : 0 : break;
19722 : :
19723 : 0 : case SymbolTable_VarientSym:
19724 : 0 : return M2ALU_IsSolved (pSym->Varient.Size);
19725 : 12 : break;
19726 : :
19727 : 12 : case SymbolTable_EnumerationSym:
19728 : 12 : return M2ALU_IsSolved (pSym->Enumeration.Size);
19729 : 52 : break;
19730 : :
19731 : 52 : case SymbolTable_PointerSym:
19732 : 52 : return M2ALU_IsSolved (pSym->Pointer.Size);
19733 : 3486 : break;
19734 : :
19735 : 3486 : case SymbolTable_ArraySym:
19736 : 3486 : return M2ALU_IsSolved (pSym->Array.Size);
19737 : 0 : break;
19738 : :
19739 : 0 : case SymbolTable_RecordFieldSym:
19740 : 0 : return M2ALU_IsSolved (pSym->RecordField.Size);
19741 : 0 : break;
19742 : :
19743 : 0 : case SymbolTable_VarientFieldSym:
19744 : 0 : return M2ALU_IsSolved (pSym->VarientField.Size);
19745 : 0 : break;
19746 : :
19747 : 0 : case SymbolTable_SubrangeSym:
19748 : 0 : return M2ALU_IsSolved (pSym->Subrange.Size);
19749 : 0 : break;
19750 : :
19751 : 0 : case SymbolTable_SubscriptSym:
19752 : 0 : return M2ALU_IsSolved (pSym->Subscript.Size);
19753 : 12 : break;
19754 : :
19755 : 12 : case SymbolTable_ProcTypeSym:
19756 : 12 : return M2ALU_IsSolved (pSym->ProcType.Size);
19757 : 0 : break;
19758 : :
19759 : 0 : case SymbolTable_UnboundedSym:
19760 : 0 : return M2ALU_IsSolved (pSym->Unbounded.Size);
19761 : 0 : break;
19762 : :
19763 : :
19764 : 0 : default:
19765 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19766 : : break;
19767 : : }
19768 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19769 : : __builtin_unreachable ();
19770 : : }
19771 : :
19772 : :
19773 : : /*
19774 : : IsOffsetSolved - returns true if the Offset of Sym is solved.
19775 : : */
19776 : :
19777 : 0 : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym)
19778 : : {
19779 : 0 : SymbolTable_PtrToSymbol pSym;
19780 : :
19781 : 0 : AssertInRange (Sym);
19782 : 0 : pSym = GetPsym (Sym);
19783 : 0 : switch (pSym->SymbolType)
19784 : : {
19785 : 0 : case SymbolTable_VarSym:
19786 : 0 : return M2ALU_IsSolved (pSym->Var.Offset);
19787 : 0 : break;
19788 : :
19789 : 0 : case SymbolTable_RecordFieldSym:
19790 : 0 : return M2ALU_IsSolved (pSym->RecordField.Offset);
19791 : 0 : break;
19792 : :
19793 : 0 : case SymbolTable_VarientFieldSym:
19794 : 0 : return M2ALU_IsSolved (pSym->VarientField.Offset);
19795 : 0 : break;
19796 : :
19797 : :
19798 : 0 : default:
19799 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19800 : : break;
19801 : : }
19802 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19803 : : __builtin_unreachable ();
19804 : : }
19805 : :
19806 : :
19807 : : /*
19808 : : IsValueSolved - returns true if the value of Sym is solved.
19809 : : */
19810 : :
19811 : 3677093 : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym)
19812 : : {
19813 : 3677093 : SymbolTable_PtrToSymbol pSym;
19814 : :
19815 : 3677093 : AssertInRange (Sym);
19816 : 3677093 : pSym = GetPsym (Sym);
19817 : 3677093 : switch (pSym->SymbolType)
19818 : : {
19819 : 2067640 : case SymbolTable_ConstLitSym:
19820 : 2067640 : return M2ALU_IsSolved (pSym->ConstLit.Value);
19821 : 789278 : break;
19822 : :
19823 : 789278 : case SymbolTable_ConstVarSym:
19824 : 789278 : return M2ALU_IsSolved (pSym->ConstVar.Value);
19825 : 545211 : break;
19826 : :
19827 : 545211 : case SymbolTable_EnumerationFieldSym:
19828 : 545211 : return M2ALU_IsSolved (pSym->EnumerationField.Value);
19829 : : break;
19830 : :
19831 : : case SymbolTable_ConstStringSym:
19832 : : return true;
19833 : 6 : break;
19834 : :
19835 : :
19836 : 6 : default:
19837 : 6 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19838 : : break;
19839 : : }
19840 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19841 : : __builtin_unreachable ();
19842 : : }
19843 : :
19844 : :
19845 : : /*
19846 : : IsConstructorConstant - returns TRUE if constructor, Sym, is
19847 : : defined by only constants.
19848 : : */
19849 : :
19850 : 4193815 : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym)
19851 : : {
19852 : 4193815 : SymbolTable_PtrToSymbol pSym;
19853 : :
19854 : 4193815 : if ((SymbolTable_IsConstructor (Sym)) || (SymbolTable_IsConstSet (Sym)))
19855 : : {
19856 : 4193815 : pSym = GetPsym (Sym);
19857 : 4193815 : switch (pSym->SymbolType)
19858 : : {
19859 : 4193815 : case SymbolTable_ConstVarSym:
19860 : 4193815 : return M2ALU_IsValueConst (pSym->ConstVar.Value);
19861 : 0 : break;
19862 : :
19863 : 0 : case SymbolTable_ConstLitSym:
19864 : 0 : return M2ALU_IsValueConst (pSym->ConstLit.Value);
19865 : 0 : break;
19866 : :
19867 : :
19868 : 0 : default:
19869 : 0 : M2Error_InternalError ((const char *) "expecting Constructor", 21);
19870 : 0 : break;
19871 : : }
19872 : : }
19873 : : else
19874 : : {
19875 : 0 : M2Error_InternalError ((const char *) "expecting Constructor", 21);
19876 : : }
19877 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19878 : : __builtin_unreachable ();
19879 : : }
19880 : :
19881 : :
19882 : : /*
19883 : : IsComposite - returns TRUE if symbol, sym, is a composite
19884 : : type: ie an ARRAY or RECORD.
19885 : : */
19886 : :
19887 : 148050 : extern "C" bool SymbolTable_IsComposite (unsigned int sym)
19888 : : {
19889 : 148050 : if (sym == SymbolTable_NulSym)
19890 : : {
19891 : : return false;
19892 : : }
19893 : : else
19894 : : {
19895 : 148026 : sym = SymbolTable_SkipType (sym);
19896 : 148026 : return (SymbolTable_IsArray (sym)) || (SymbolTable_IsRecord (sym));
19897 : : }
19898 : : /* static analysis guarentees a RETURN statement will be used before here. */
19899 : : __builtin_unreachable ();
19900 : : }
19901 : :
19902 : :
19903 : : /*
19904 : : IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
19905 : : */
19906 : :
19907 : 0 : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym)
19908 : : {
19909 : 0 : SymbolTable_PtrToSymbol pSym;
19910 : :
19911 : 0 : AssertInRange (Sym);
19912 : 0 : pSym = GetPsym (Sym);
19913 : 0 : switch (pSym->SymbolType)
19914 : : {
19915 : 0 : case SymbolTable_ProcedureSym:
19916 : 0 : return M2ALU_IsSolved (pSym->Procedure.TotalParamSize);
19917 : 0 : break;
19918 : :
19919 : 0 : case SymbolTable_ProcTypeSym:
19920 : 0 : return M2ALU_IsSolved (pSym->ProcType.TotalParamSize);
19921 : 0 : break;
19922 : :
19923 : :
19924 : 0 : default:
19925 : 0 : M2Error_InternalError ((const char *) "expecting Procedure or ProcType symbol", 38);
19926 : : break;
19927 : : }
19928 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19929 : : __builtin_unreachable ();
19930 : : }
19931 : :
19932 : :
19933 : : /*
19934 : : PutAlignment - assigns the alignment constant associated with,
19935 : : type, with, align.
19936 : : */
19937 : :
19938 : 192 : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align)
19939 : : {
19940 : 192 : SymbolTable_PtrToSymbol pSym;
19941 : :
19942 : 192 : pSym = GetPsym (type);
19943 : 192 : switch (pSym->SymbolType)
19944 : : {
19945 : 0 : case SymbolTable_RecordSym:
19946 : 0 : pSym->Record.Align = align;
19947 : 0 : break;
19948 : :
19949 : 120 : case SymbolTable_RecordFieldSym:
19950 : 120 : pSym->RecordField.Align = align;
19951 : 120 : break;
19952 : :
19953 : 18 : case SymbolTable_TypeSym:
19954 : 18 : pSym->Type.Align = align;
19955 : 18 : break;
19956 : :
19957 : 12 : case SymbolTable_PointerSym:
19958 : 12 : pSym->Pointer.Align = align;
19959 : 12 : break;
19960 : :
19961 : 12 : case SymbolTable_SubrangeSym:
19962 : 12 : pSym->Subrange.Align = align;
19963 : 12 : break;
19964 : :
19965 : 0 : case SymbolTable_SetSym:
19966 : 0 : pSym->Set.Align = align;
19967 : 0 : break;
19968 : :
19969 : 30 : case SymbolTable_ArraySym:
19970 : 30 : pSym->Array.Align = align;
19971 : 30 : break;
19972 : :
19973 : :
19974 : 0 : default:
19975 : 0 : M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
19976 : 192 : break;
19977 : : }
19978 : 192 : }
19979 : :
19980 : :
19981 : : /*
19982 : : GetAlignment - returns the alignment constant associated with,
19983 : : type.
19984 : : */
19985 : :
19986 : 398033246 : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type)
19987 : : {
19988 : 398039396 : SymbolTable_PtrToSymbol pSym;
19989 : :
19990 : 398039396 : pSym = GetPsym (type);
19991 : 398039396 : switch (pSym->SymbolType)
19992 : : {
19993 : 106009 : case SymbolTable_RecordSym:
19994 : 106009 : return pSym->Record.Align;
19995 : 234963406 : break;
19996 : :
19997 : 234963406 : case SymbolTable_RecordFieldSym:
19998 : 234963406 : return pSym->RecordField.Align;
19999 : 101896284 : break;
20000 : :
20001 : 101896284 : case SymbolTable_TypeSym:
20002 : 101896284 : return pSym->Type.Align;
20003 : 49703070 : break;
20004 : :
20005 : 49703070 : case SymbolTable_PointerSym:
20006 : 49703070 : return pSym->Pointer.Align;
20007 : 6114 : break;
20008 : :
20009 : 6114 : case SymbolTable_VarientFieldSym:
20010 : 6114 : return SymbolTable_GetAlignment (pSym->VarientField.Parent);
20011 : 36 : break;
20012 : :
20013 : 36 : case SymbolTable_VarientSym:
20014 : 36 : return SymbolTable_GetAlignment (pSym->Varient.Parent);
20015 : 5997899 : break;
20016 : :
20017 : 5997899 : case SymbolTable_SubrangeSym:
20018 : 5997899 : return pSym->Subrange.Align;
20019 : 0 : break;
20020 : :
20021 : 0 : case SymbolTable_SetSym:
20022 : 0 : return pSym->Set.Align;
20023 : 5366578 : break;
20024 : :
20025 : 5366578 : case SymbolTable_ArraySym:
20026 : 5366578 : return pSym->Array.Align;
20027 : 0 : break;
20028 : :
20029 : :
20030 : 0 : default:
20031 : 0 : M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
20032 : : break;
20033 : : }
20034 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20035 : : __builtin_unreachable ();
20036 : : }
20037 : :
20038 : :
20039 : : /*
20040 : : GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
20041 : : to record, sym.
20042 : : */
20043 : :
20044 : 44877259 : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym)
20045 : : {
20046 : 44883301 : SymbolTable_PtrToSymbol pSym;
20047 : :
20048 : 44883301 : pSym = GetPsym (sym);
20049 : 44883301 : switch (pSym->SymbolType)
20050 : : {
20051 : 44877259 : case SymbolTable_RecordSym:
20052 : 44877259 : return pSym->Record.DefaultAlign;
20053 : 6042 : break;
20054 : :
20055 : 6042 : case SymbolTable_VarientFieldSym:
20056 : 6042 : return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
20057 : 0 : break;
20058 : :
20059 : 0 : case SymbolTable_VarientSym:
20060 : 0 : return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
20061 : 0 : break;
20062 : :
20063 : :
20064 : 0 : default:
20065 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
20066 : : break;
20067 : : }
20068 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20069 : : __builtin_unreachable ();
20070 : : }
20071 : :
20072 : :
20073 : : /*
20074 : : PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
20075 : : to record, sym.
20076 : : */
20077 : :
20078 : 36 : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align)
20079 : : {
20080 : 36 : SymbolTable_PtrToSymbol pSym;
20081 : :
20082 : 36 : pSym = GetPsym (sym);
20083 : 36 : switch (pSym->SymbolType)
20084 : : {
20085 : 36 : case SymbolTable_RecordSym:
20086 : 36 : pSym->Record.DefaultAlign = align;
20087 : 36 : break;
20088 : :
20089 : :
20090 : 0 : default:
20091 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
20092 : 36 : break;
20093 : : }
20094 : 36 : }
20095 : :
20096 : :
20097 : : /*
20098 : : PutUnused - sets, sym, as unused. This is a gm2 pragma.
20099 : : */
20100 : :
20101 : 0 : extern "C" void SymbolTable_PutUnused (unsigned int sym)
20102 : : {
20103 : 0 : SymbolTable_PtrToSymbol pSym;
20104 : :
20105 : 0 : pSym = GetPsym (sym);
20106 : 0 : switch (pSym->SymbolType)
20107 : : {
20108 : 0 : case SymbolTable_RecordFieldSym:
20109 : 0 : pSym->RecordField.Used = false;
20110 : 0 : break;
20111 : :
20112 : :
20113 : 0 : default:
20114 : 0 : M2MetaError_MetaError1 ((const char *) "cannot use pragma 'unused' on symbol {%1ad}", 43, sym);
20115 : 0 : break;
20116 : : }
20117 : 0 : }
20118 : :
20119 : :
20120 : : /*
20121 : : IsUnused - returns TRUE if the symbol was declared as unused with a
20122 : : gm2 pragma.
20123 : : */
20124 : :
20125 : 145595 : extern "C" bool SymbolTable_IsUnused (unsigned int sym)
20126 : : {
20127 : 145595 : SymbolTable_PtrToSymbol pSym;
20128 : :
20129 : 145595 : pSym = GetPsym (sym);
20130 : 145595 : switch (pSym->SymbolType)
20131 : : {
20132 : 145595 : case SymbolTable_RecordFieldSym:
20133 : 145595 : return ! pSym->RecordField.Used;
20134 : 0 : break;
20135 : :
20136 : :
20137 : 0 : default:
20138 : 0 : M2Error_InternalError ((const char *) "expecting a record field symbol", 31);
20139 : : break;
20140 : : }
20141 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20142 : : __builtin_unreachable ();
20143 : : }
20144 : :
20145 : :
20146 : : /*
20147 : : PutDeclaredPacked - sets the Packed field of the record or record field symbol.
20148 : : */
20149 : :
20150 : 515029 : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b)
20151 : : {
20152 : 515029 : SymbolTable_PtrToSymbol pSym;
20153 : :
20154 : 515029 : pSym = GetPsym (sym);
20155 : 515029 : switch (pSym->SymbolType)
20156 : : {
20157 : 99895 : case SymbolTable_RecordSym:
20158 : 99895 : pSym->Record.DeclPacked = b;
20159 : 99895 : pSym->Record.DeclResolved = true;
20160 : 99895 : break;
20161 : :
20162 : 403206 : case SymbolTable_RecordFieldSym:
20163 : 403206 : pSym->RecordField.DeclPacked = b;
20164 : 403206 : pSym->RecordField.DeclResolved = true;
20165 : 403206 : break;
20166 : :
20167 : 6012 : case SymbolTable_VarientFieldSym:
20168 : 6012 : pSym->VarientField.DeclPacked = b;
20169 : 6012 : pSym->VarientField.DeclResolved = true;
20170 : 6012 : break;
20171 : :
20172 : 5916 : case SymbolTable_VarientSym:
20173 : 5916 : pSym->Varient.DeclPacked = b;
20174 : 5916 : pSym->Varient.DeclResolved = true;
20175 : 5916 : break;
20176 : :
20177 : :
20178 : 0 : default:
20179 : 0 : M2Error_InternalError ((const char *) "expecting a record or field record symbol", 41);
20180 : 515029 : break;
20181 : : }
20182 : 515029 : }
20183 : :
20184 : :
20185 : : /*
20186 : : IsDeclaredPacked - was the record symbol or record field, sym,
20187 : : declared as packed?
20188 : : */
20189 : :
20190 : 1427750 : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym)
20191 : : {
20192 : 1427750 : SymbolTable_PtrToSymbol pSym;
20193 : :
20194 : 1427750 : pSym = GetPsym (sym);
20195 : 1427750 : switch (pSym->SymbolType)
20196 : : {
20197 : 199790 : case SymbolTable_RecordSym:
20198 : 199790 : return pSym->Record.DeclPacked;
20199 : 1209840 : break;
20200 : :
20201 : 1209840 : case SymbolTable_RecordFieldSym:
20202 : 1209840 : return pSym->RecordField.DeclPacked;
20203 : 12156 : break;
20204 : :
20205 : 12156 : case SymbolTable_VarientFieldSym:
20206 : 12156 : return pSym->VarientField.DeclPacked;
20207 : 5964 : break;
20208 : :
20209 : 5964 : case SymbolTable_VarientSym:
20210 : 5964 : return pSym->Varient.DeclPacked;
20211 : 0 : break;
20212 : :
20213 : :
20214 : 0 : default:
20215 : 0 : M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
20216 : : break;
20217 : : }
20218 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20219 : : __builtin_unreachable ();
20220 : : }
20221 : :
20222 : :
20223 : : /*
20224 : : IsDeclaredPackedResolved - do we know if the record symbol or record
20225 : : field, sym, declared as packed or not packed?
20226 : : */
20227 : :
20228 : 0 : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym)
20229 : : {
20230 : 0 : SymbolTable_PtrToSymbol pSym;
20231 : :
20232 : 0 : pSym = GetPsym (sym);
20233 : 0 : switch (pSym->SymbolType)
20234 : : {
20235 : 0 : case SymbolTable_RecordSym:
20236 : 0 : return pSym->Record.DeclResolved;
20237 : 0 : break;
20238 : :
20239 : 0 : case SymbolTable_RecordFieldSym:
20240 : 0 : return pSym->RecordField.DeclResolved;
20241 : 0 : break;
20242 : :
20243 : 0 : case SymbolTable_VarientFieldSym:
20244 : 0 : return pSym->VarientField.DeclResolved;
20245 : 0 : break;
20246 : :
20247 : 0 : case SymbolTable_VarientSym:
20248 : 0 : return pSym->Varient.DeclResolved;
20249 : 0 : break;
20250 : :
20251 : :
20252 : 0 : default:
20253 : 0 : M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
20254 : : break;
20255 : : }
20256 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20257 : : __builtin_unreachable ();
20258 : : }
20259 : :
20260 : :
20261 : : /*
20262 : : GetPackedEquivalent - returns the packed equivalent of type, sym.
20263 : : sym must be a type, subrange or enumerated type.
20264 : : */
20265 : :
20266 : 14559 : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym)
20267 : : {
20268 : 14559 : SymbolTable_PtrToSymbol pSym;
20269 : :
20270 : 14559 : pSym = GetPsym (sym);
20271 : 14559 : switch (pSym->SymbolType)
20272 : : {
20273 : 14439 : case SymbolTable_EnumerationSym:
20274 : 14439 : return GetEquivalent (&pSym->Enumeration.packedInfo, sym);
20275 : 120 : break;
20276 : :
20277 : 120 : case SymbolTable_SubrangeSym:
20278 : 120 : return GetEquivalent (&pSym->Subrange.packedInfo, sym);
20279 : 0 : break;
20280 : :
20281 : 0 : case SymbolTable_TypeSym:
20282 : 0 : return GetEquivalent (&pSym->Type.packedInfo, sym);
20283 : 0 : break;
20284 : :
20285 : 0 : case SymbolTable_SetSym:
20286 : 0 : return GetEquivalent (&pSym->Set.packedInfo, sym);
20287 : 0 : break;
20288 : :
20289 : :
20290 : 0 : default:
20291 : 0 : M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
20292 : : break;
20293 : : }
20294 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20295 : : __builtin_unreachable ();
20296 : : }
20297 : :
20298 : :
20299 : : /*
20300 : : GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
20301 : : */
20302 : :
20303 : 0 : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym)
20304 : : {
20305 : 0 : SymbolTable_PtrToSymbol pSym;
20306 : :
20307 : 0 : pSym = GetPsym (sym);
20308 : 0 : switch (pSym->SymbolType)
20309 : : {
20310 : 0 : case SymbolTable_EquivSym:
20311 : 0 : return pSym->Equiv.nonPacked;
20312 : 0 : break;
20313 : :
20314 : :
20315 : 0 : default:
20316 : 0 : M2Error_InternalError ((const char *) "expecting equivalent symbol", 27);
20317 : : break;
20318 : : }
20319 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20320 : : __builtin_unreachable ();
20321 : : }
20322 : :
20323 : :
20324 : : /*
20325 : : IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
20326 : : */
20327 : :
20328 : 0 : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym)
20329 : : {
20330 : 0 : SymbolTable_PtrToSymbol pSym;
20331 : :
20332 : 0 : pSym = GetPsym (sym);
20333 : 0 : switch (pSym->SymbolType)
20334 : : {
20335 : : case SymbolTable_EquivSym:
20336 : : return true;
20337 : 0 : break;
20338 : :
20339 : :
20340 : 0 : default:
20341 : 0 : return false;
20342 : : break;
20343 : : }
20344 : : /* static analysis guarentees a RETURN statement will be used before here. */
20345 : : __builtin_unreachable ();
20346 : : }
20347 : :
20348 : :
20349 : : /*
20350 : : PushSize - pushes the size of Sym.
20351 : : */
20352 : :
20353 : 99430 : extern "C" void SymbolTable_PushSize (unsigned int Sym)
20354 : : {
20355 : 99430 : SymbolTable_PtrToSymbol pSym;
20356 : :
20357 : 99430 : AssertInRange (Sym);
20358 : 99430 : pSym = GetPsym (Sym);
20359 : 99430 : switch (pSym->SymbolType)
20360 : : {
20361 : 0 : case SymbolTable_ProcedureSym:
20362 : 0 : M2ALU_PushFrom (pSym->Procedure.Size);
20363 : 0 : break;
20364 : :
20365 : 3036 : case SymbolTable_VarSym:
20366 : 3036 : M2ALU_PushFrom (pSym->Var.Size);
20367 : 3036 : break;
20368 : :
20369 : 16057 : case SymbolTable_TypeSym:
20370 : 16057 : M2ALU_PushFrom (pSym->Type.Size);
20371 : 16057 : break;
20372 : :
20373 : 788 : case SymbolTable_SetSym:
20374 : 788 : M2ALU_PushFrom (pSym->Set.Size);
20375 : 788 : break;
20376 : :
20377 : 0 : case SymbolTable_VarientSym:
20378 : 0 : M2ALU_PushFrom (pSym->Varient.Size);
20379 : 0 : break;
20380 : :
20381 : 12 : case SymbolTable_RecordSym:
20382 : 12 : M2ALU_PushFrom (pSym->Record.Size);
20383 : 12 : break;
20384 : :
20385 : 12 : case SymbolTable_EnumerationSym:
20386 : 12 : M2ALU_PushFrom (pSym->Enumeration.Size);
20387 : 12 : break;
20388 : :
20389 : 76027 : case SymbolTable_PointerSym:
20390 : 76027 : M2ALU_PushFrom (pSym->Pointer.Size);
20391 : 76027 : break;
20392 : :
20393 : 3486 : case SymbolTable_ArraySym:
20394 : 3486 : M2ALU_PushFrom (pSym->Array.Size);
20395 : 3486 : break;
20396 : :
20397 : 0 : case SymbolTable_RecordFieldSym:
20398 : 0 : M2ALU_PushFrom (pSym->RecordField.Size);
20399 : 0 : break;
20400 : :
20401 : 0 : case SymbolTable_VarientFieldSym:
20402 : 0 : M2ALU_PushFrom (pSym->VarientField.Size);
20403 : 0 : break;
20404 : :
20405 : 0 : case SymbolTable_SubrangeSym:
20406 : 0 : M2ALU_PushFrom (pSym->Subrange.Size);
20407 : 0 : break;
20408 : :
20409 : 0 : case SymbolTable_SubscriptSym:
20410 : 0 : M2ALU_PushFrom (pSym->Subscript.Size);
20411 : 0 : break;
20412 : :
20413 : 12 : case SymbolTable_ProcTypeSym:
20414 : 12 : M2ALU_PushFrom (pSym->ProcType.Size);
20415 : 12 : break;
20416 : :
20417 : 0 : case SymbolTable_UnboundedSym:
20418 : 0 : M2ALU_PushFrom (pSym->Unbounded.Size);
20419 : 0 : break;
20420 : :
20421 : :
20422 : 0 : default:
20423 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20424 : 99430 : break;
20425 : : }
20426 : 99430 : }
20427 : :
20428 : :
20429 : : /*
20430 : : PopSize - pops the ALU stack into Size of Sym.
20431 : : */
20432 : :
20433 : 850431 : extern "C" void SymbolTable_PopSize (unsigned int Sym)
20434 : : {
20435 : 850431 : SymbolTable_PtrToSymbol pSym;
20436 : :
20437 : 850431 : AssertInRange (Sym);
20438 : 850431 : pSym = GetPsym (Sym);
20439 : 850431 : switch (pSym->SymbolType)
20440 : : {
20441 : 0 : case SymbolTable_ProcedureSym:
20442 : 0 : M2ALU_PopInto (pSym->Procedure.Size);
20443 : 0 : break;
20444 : :
20445 : 2740 : case SymbolTable_VarSym:
20446 : 2740 : M2ALU_PopInto (pSym->Var.Size);
20447 : 2740 : break;
20448 : :
20449 : 593945 : case SymbolTable_TypeSym:
20450 : 593945 : M2ALU_PopInto (pSym->Type.Size);
20451 : 593945 : break;
20452 : :
20453 : 12 : case SymbolTable_RecordSym:
20454 : 12 : M2ALU_PopInto (pSym->Record.Size);
20455 : 12 : break;
20456 : :
20457 : 0 : case SymbolTable_VarientSym:
20458 : 0 : M2ALU_PopInto (pSym->Varient.Size);
20459 : 0 : break;
20460 : :
20461 : 6 : case SymbolTable_EnumerationSym:
20462 : 6 : M2ALU_PopInto (pSym->Enumeration.Size);
20463 : 6 : break;
20464 : :
20465 : 15257 : case SymbolTable_PointerSym:
20466 : 15257 : M2ALU_PopInto (pSym->Pointer.Size);
20467 : 15257 : break;
20468 : :
20469 : 636 : case SymbolTable_ArraySym:
20470 : 636 : M2ALU_PopInto (pSym->Array.Size);
20471 : 636 : break;
20472 : :
20473 : 0 : case SymbolTable_RecordFieldSym:
20474 : 0 : M2ALU_PopInto (pSym->RecordField.Size);
20475 : 0 : break;
20476 : :
20477 : 0 : case SymbolTable_VarientFieldSym:
20478 : 0 : M2ALU_PopInto (pSym->VarientField.Size);
20479 : 0 : break;
20480 : :
20481 : 0 : case SymbolTable_SubrangeSym:
20482 : 0 : M2ALU_PopInto (pSym->Subrange.Size);
20483 : 0 : break;
20484 : :
20485 : 161638 : case SymbolTable_SubscriptSym:
20486 : 161638 : M2ALU_PopInto (pSym->Subscript.Size);
20487 : 161638 : break;
20488 : :
20489 : 15241 : case SymbolTable_ProcTypeSym:
20490 : 15241 : M2ALU_PopInto (pSym->ProcType.Size);
20491 : 15241 : break;
20492 : :
20493 : 0 : case SymbolTable_UnboundedSym:
20494 : 0 : M2ALU_PopInto (pSym->Unbounded.Size);
20495 : 0 : break;
20496 : :
20497 : 60956 : case SymbolTable_SetSym:
20498 : 60956 : M2ALU_PopInto (pSym->Set.Size);
20499 : 60956 : break;
20500 : :
20501 : :
20502 : 0 : default:
20503 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20504 : 850431 : break;
20505 : : }
20506 : 850431 : }
20507 : :
20508 : :
20509 : : /*
20510 : : PushValue - pushes the Value of Sym onto the ALU stack.
20511 : : */
20512 : :
20513 : 25773334 : extern "C" void SymbolTable_PushValue (unsigned int Sym)
20514 : : {
20515 : 25773334 : SymbolTable_PtrToSymbol pSym;
20516 : :
20517 : 25773334 : AssertInRange (Sym);
20518 : 25773334 : pSym = GetPsym (Sym);
20519 : 25773334 : switch (pSym->SymbolType)
20520 : : {
20521 : 2479719 : case SymbolTable_ConstLitSym:
20522 : 2479719 : M2ALU_PushFrom (pSym->ConstLit.Value);
20523 : 2479719 : break;
20524 : :
20525 : 1863036 : case SymbolTable_ConstVarSym:
20526 : 1863036 : M2ALU_PushFrom (pSym->ConstVar.Value);
20527 : 1863036 : break;
20528 : :
20529 : 21397641 : case SymbolTable_EnumerationFieldSym:
20530 : 21397641 : M2ALU_PushFrom (pSym->EnumerationField.Value);
20531 : 21397641 : break;
20532 : :
20533 : 32938 : case SymbolTable_ConstStringSym:
20534 : 32938 : PushConstString (Sym);
20535 : 32938 : break;
20536 : :
20537 : :
20538 : 0 : default:
20539 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20540 : 25773334 : break;
20541 : : }
20542 : 25773334 : }
20543 : :
20544 : :
20545 : : /*
20546 : : PushVarSize - pushes the size of a variable, Sym.
20547 : : The runtime size of Sym will depend upon its addressing mode,
20548 : : RightValue has size PushSize(GetType(Sym)) and
20549 : : LeftValue has size PushSize(Address) since it points to a
20550 : : variable.
20551 : : */
20552 : :
20553 : 0 : extern "C" void SymbolTable_PushVarSize (unsigned int Sym)
20554 : : {
20555 : 0 : AssertInRange (Sym);
20556 : 0 : M2Debug_Assert (SymbolTable_IsVar (Sym));
20557 : 0 : if ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue)
20558 : : {
20559 : 0 : SymbolTable_PushSize (M2System_Address);
20560 : : }
20561 : : else
20562 : : {
20563 : 0 : M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_RightValue);
20564 : 0 : SymbolTable_PushSize (SymbolTable_GetType (Sym));
20565 : : }
20566 : 0 : }
20567 : :
20568 : :
20569 : : /*
20570 : : PopValue - pops the ALU stack into Value of Sym.
20571 : : */
20572 : :
20573 : 1362196 : extern "C" void SymbolTable_PopValue (unsigned int Sym)
20574 : : {
20575 : 1362196 : SymbolTable_PtrToSymbol pSym;
20576 : :
20577 : 1362196 : AssertInRange (Sym);
20578 : 1362196 : pSym = GetPsym (Sym);
20579 : 1362196 : switch (pSym->SymbolType)
20580 : : {
20581 : 0 : case SymbolTable_ConstLitSym:
20582 : 0 : M2ALU_PopInto (pSym->ConstLit.Value);
20583 : 0 : break;
20584 : :
20585 : 1362196 : case SymbolTable_ConstVarSym:
20586 : 1362196 : M2ALU_PopInto (pSym->ConstVar.Value);
20587 : 1362196 : break;
20588 : :
20589 : 0 : case SymbolTable_EnumerationFieldSym:
20590 : 0 : M2Error_InternalError ((const char *) "cannot pop into an enumeration field", 36);
20591 : 0 : break;
20592 : :
20593 : :
20594 : 0 : default:
20595 : 0 : M2Error_InternalError ((const char *) "symbol type not expected", 24);
20596 : 1362196 : break;
20597 : : }
20598 : 1362196 : }
20599 : :
20600 : :
20601 : : /*
20602 : : IsObject - returns TRUE if the symbol is an object symbol.
20603 : : */
20604 : :
20605 : 0 : extern "C" bool SymbolTable_IsObject (unsigned int Sym)
20606 : : {
20607 : 0 : SymbolTable_PtrToSymbol pSym;
20608 : :
20609 : 0 : AssertInRange (Sym);
20610 : 0 : pSym = GetPsym (Sym);
20611 : 0 : return pSym->SymbolType == SymbolTable_ObjectSym;
20612 : : /* static analysis guarentees a RETURN statement will be used before here. */
20613 : : __builtin_unreachable ();
20614 : : }
20615 : :
20616 : :
20617 : : /*
20618 : : IsTuple - returns TRUE if the symbol is a tuple symbol.
20619 : : */
20620 : :
20621 : 17726 : extern "C" bool SymbolTable_IsTuple (unsigned int Sym)
20622 : : {
20623 : 17726 : SymbolTable_PtrToSymbol pSym;
20624 : :
20625 : 17726 : AssertInRange (Sym);
20626 : 17726 : pSym = GetPsym (Sym);
20627 : 17726 : return pSym->SymbolType == SymbolTable_TupleSym;
20628 : : /* static analysis guarentees a RETURN statement will be used before here. */
20629 : : __builtin_unreachable ();
20630 : : }
20631 : :
20632 : :
20633 : : /*
20634 : : Make2Tuple - creates and returns a 2 tuple from, a, and, b.
20635 : : */
20636 : :
20637 : 3038 : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b)
20638 : : {
20639 : 3038 : SymbolTable_PtrToSymbol pSym;
20640 : 3038 : unsigned int Sym;
20641 : :
20642 : 3038 : NewSym (&Sym);
20643 : 3038 : pSym = GetPsym (Sym);
20644 : 3038 : pSym->SymbolType = SymbolTable_TupleSym;
20645 : 3038 : pSym->Tuple.nTuple = 2;
20646 : 3038 : pSym->Tuple.list = Indexing_InitIndex (1);
20647 : 3038 : PutIntoIndex (&pSym->Tuple.list, 1, a);
20648 : 3038 : PutIntoIndex (&pSym->Tuple.list, 2, b);
20649 : 3038 : InitWhereDeclared (&pSym->Tuple.At);
20650 : 3038 : InitWhereFirstUsed (&pSym->Tuple.At);
20651 : 3038 : return Sym;
20652 : : /* static analysis guarentees a RETURN statement will be used before here. */
20653 : : __builtin_unreachable ();
20654 : : }
20655 : :
20656 : :
20657 : : /*
20658 : : MakeError - creates an error node, which can be used in MetaError messages.
20659 : : It will be removed from ExportUndeclared and Unknown trees.
20660 : : */
20661 : :
20662 : 200 : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name)
20663 : : {
20664 : 200 : SymbolTable_PtrToSymbol pSym;
20665 : 200 : unsigned int Sym;
20666 : :
20667 : : /* if Sym is present on the unknown tree then remove it */
20668 : 200 : Sym = FetchUnknownSym (name);
20669 : 200 : if (Sym == SymbolTable_NulSym)
20670 : : {
20671 : 194 : NewSym (&Sym);
20672 : : }
20673 : : else
20674 : : {
20675 : : /*
20676 : : remove symbol from this tree as we have already generated
20677 : : a meaningful error message
20678 : : */
20679 : 6 : RemoveExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
20680 : : }
20681 : 200 : pSym = GetPsym (Sym);
20682 : 200 : pSym->SymbolType = SymbolTable_ErrorSym;
20683 : 200 : pSym->Error.name = name;
20684 : 200 : pSym->Error.Scope = SymbolTable_GetCurrentScope ();
20685 : 200 : InitWhereDeclaredTok (tok, &pSym->Error.At);
20686 : 200 : InitWhereFirstUsedTok (tok, &pSym->Error.At);
20687 : 200 : return Sym;
20688 : : /* static analysis guarentees a RETURN statement will be used before here. */
20689 : : __builtin_unreachable ();
20690 : : }
20691 : :
20692 : :
20693 : : /*
20694 : : MakeErrorS - creates an error node from a string, which can be used
20695 : : in MetaError messages.
20696 : : It will be removed from ExportUndeclared and Unknown trees.
20697 : : */
20698 : :
20699 : 0 : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name)
20700 : : {
20701 : 0 : return SymbolTable_MakeError (tok, NameKey_makekey (DynamicStrings_string (name)));
20702 : : /* static analysis guarentees a RETURN statement will be used before here. */
20703 : : __builtin_unreachable ();
20704 : : }
20705 : :
20706 : :
20707 : : /*
20708 : : IsError - returns TRUE if the symbol is an error symbol.
20709 : : */
20710 : :
20711 : 31639683 : extern "C" bool SymbolTable_IsError (unsigned int Sym)
20712 : : {
20713 : 31639683 : SymbolTable_PtrToSymbol pSym;
20714 : :
20715 : 31639683 : AssertInRange (Sym);
20716 : 31639683 : pSym = GetPsym (Sym);
20717 : 31639683 : return pSym->SymbolType == SymbolTable_ErrorSym;
20718 : : /* static analysis guarentees a RETURN statement will be used before here. */
20719 : : __builtin_unreachable ();
20720 : : }
20721 : :
20722 : :
20723 : : /*
20724 : : IsLegal - returns TRUE if, sym, is a legal symbol.
20725 : : */
20726 : :
20727 : 1048518 : extern "C" bool SymbolTable_IsLegal (unsigned int sym)
20728 : : {
20729 : 1048518 : return sym < FreeSymbol;
20730 : : /* static analysis guarentees a RETURN statement will be used before here. */
20731 : : __builtin_unreachable ();
20732 : : }
20733 : :
20734 : :
20735 : : /*
20736 : : PutModuleContainsBuiltin - sets a flag in the current compiled module which
20737 : : indicates that a builtin procedure is being declared.
20738 : : This is only expected to be called when we are
20739 : : parsing the definition module.
20740 : : */
20741 : :
20742 : 439620 : extern "C" void SymbolTable_PutModuleContainsBuiltin (void)
20743 : : {
20744 : 439620 : SymbolTable_PtrToSymbol pSym;
20745 : :
20746 : 439620 : SymbolTable_PutHiddenTypeDeclared ();
20747 : 439620 : pSym = GetPsym (CurrentModule);
20748 : 439620 : switch (pSym->SymbolType)
20749 : : {
20750 : 439620 : case SymbolTable_DefImpSym:
20751 : 439620 : pSym->DefImp.ContainsBuiltin = true;
20752 : 439620 : break;
20753 : :
20754 : :
20755 : 0 : default:
20756 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20757 : 439620 : break;
20758 : : }
20759 : 439620 : }
20760 : :
20761 : :
20762 : : /*
20763 : : IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
20764 : : */
20765 : :
20766 : 158766 : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym)
20767 : : {
20768 : 158766 : SymbolTable_PtrToSymbol pSym;
20769 : :
20770 : 158766 : pSym = GetPsym (Sym);
20771 : 158766 : switch (pSym->SymbolType)
20772 : : {
20773 : 158766 : case SymbolTable_DefImpSym:
20774 : 158766 : return pSym->DefImp.ContainsBuiltin;
20775 : 0 : break;
20776 : :
20777 : :
20778 : 0 : default:
20779 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20780 : : break;
20781 : : }
20782 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20783 : : __builtin_unreachable ();
20784 : : }
20785 : :
20786 : :
20787 : : /*
20788 : : PutHiddenTypeDeclared - sets a flag in the current compiled module which
20789 : : indicates that a Hidden Type is declared within
20790 : : the implementation part of the module.
20791 : : This procedure is expected to be called while
20792 : : compiling the associated definition module.
20793 : : */
20794 : :
20795 : 1349728 : extern "C" void SymbolTable_PutHiddenTypeDeclared (void)
20796 : : {
20797 : 1349728 : SymbolTable_PtrToSymbol pSym;
20798 : :
20799 : 1349728 : pSym = GetPsym (CurrentModule);
20800 : 1349728 : switch (pSym->SymbolType)
20801 : : {
20802 : 1349728 : case SymbolTable_DefImpSym:
20803 : 1349728 : pSym->DefImp.ContainsHiddenType = true;
20804 : 1349728 : break;
20805 : :
20806 : :
20807 : 0 : default:
20808 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20809 : 1349728 : break;
20810 : : }
20811 : 1349728 : }
20812 : :
20813 : :
20814 : : /*
20815 : : IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
20816 : : the module, Sym.
20817 : : */
20818 : :
20819 : 8294997 : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym)
20820 : : {
20821 : 8294997 : SymbolTable_PtrToSymbol pSym;
20822 : :
20823 : 8294997 : pSym = GetPsym (Sym);
20824 : 8294997 : switch (pSym->SymbolType)
20825 : : {
20826 : 8294997 : case SymbolTable_DefImpSym:
20827 : 8294997 : return pSym->DefImp.ContainsHiddenType;
20828 : 0 : break;
20829 : :
20830 : :
20831 : 0 : default:
20832 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20833 : : break;
20834 : : }
20835 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20836 : : __builtin_unreachable ();
20837 : : }
20838 : :
20839 : :
20840 : : /*
20841 : : IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
20842 : : type declared as a pointer or address.
20843 : : */
20844 : :
20845 : 436005 : extern "C" bool SymbolTable_IsHiddenReallyPointer (unsigned int Sym)
20846 : : {
20847 : 436005 : if (SymbolTable_IsVar (Sym))
20848 : : {
20849 : 0 : Sym = SymbolTable_GetType (Sym);
20850 : : }
20851 : 456684 : while ((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym)))
20852 : : {
20853 : 20679 : Sym = SymbolTable_SkipType (SymbolTable_GetType (Sym));
20854 : : }
20855 : 436005 : return (Sym != SymbolTable_NulSym) && ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address));
20856 : : /* static analysis guarentees a RETURN statement will be used before here. */
20857 : : __builtin_unreachable ();
20858 : : }
20859 : :
20860 : :
20861 : : /*
20862 : : DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
20863 : : */
20864 : :
20865 : 0 : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym)
20866 : : {
20867 : 0 : SymbolTable_PtrToSymbol pSym;
20868 : 0 : NameKey_Name n;
20869 : :
20870 : 0 : n = SymbolTable_GetSymName (ModSym);
20871 : 0 : M2Printf_printf1 ((const char *) "Symbol trees for module/procedure: %a\\n", 39, (const unsigned char *) &n, (sizeof (n)-1));
20872 : 0 : pSym = GetPsym (ModSym);
20873 : 0 : switch (pSym->SymbolType)
20874 : : {
20875 : 0 : case SymbolTable_DefImpSym:
20876 : 0 : n = SymbolTable_GetSymName (ModSym);
20877 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20878 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20879 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20880 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20881 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20882 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20883 : 0 : M2Printf_printf1 ((const char *) "%a ExportRequest", 17, (const unsigned char *) &n, (sizeof (n)-1));
20884 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportRequest, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20885 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20886 : 0 : M2Printf_printf1 ((const char *) "%a ExportQualified", 19, (const unsigned char *) &n, (sizeof (n)-1));
20887 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20888 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20889 : 0 : M2Printf_printf1 ((const char *) "%a ExportUnQualified", 21, (const unsigned char *) &n, (sizeof (n)-1));
20890 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20891 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20892 : 0 : M2Printf_printf1 ((const char *) "%a ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
20893 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20894 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20895 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20896 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20897 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20898 : 0 : M2Printf_printf1 ((const char *) "%a ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20899 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20900 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20901 : 0 : break;
20902 : :
20903 : 0 : case SymbolTable_ModuleSym:
20904 : 0 : n = SymbolTable_GetSymName (ModSym);
20905 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20906 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20907 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20908 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20909 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20910 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20911 : 0 : M2Printf_printf1 ((const char *) "%a ImportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
20912 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20913 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20914 : 0 : M2Printf_printf1 ((const char *) "%a ExportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
20915 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20916 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20917 : 0 : M2Printf_printf1 ((const char *) "%a ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
20918 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20919 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20920 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20921 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20922 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20923 : 0 : M2Printf_printf1 ((const char *) "%a ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20924 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20925 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20926 : 0 : break;
20927 : :
20928 : 0 : case SymbolTable_ProcedureSym:
20929 : 0 : n = SymbolTable_GetSymName (ModSym);
20930 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20931 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20932 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20933 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20934 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20935 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20936 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20937 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20938 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20939 : 0 : break;
20940 : :
20941 : :
20942 : 0 : default:
20943 : 0 : M2Error_InternalError ((const char *) "expecting DefImp symbol", 23);
20944 : 0 : break;
20945 : : }
20946 : 0 : }
20947 : :
20948 : :
20949 : : /*
20950 : : DebugLineNumbers - internal debugging, emit all procedure names in this module
20951 : : together with the line numbers for the corresponding begin/end
20952 : : tokens.
20953 : : */
20954 : :
20955 : 13935 : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym)
20956 : : {
20957 : 13935 : if (M2Options_GetDebugFunctionLineNumbers ())
20958 : : {
20959 : 0 : M2Printf_printf0 ((const char *) "<lines>\\n", 9);
20960 : 0 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DebugProcedureLineNumber});
20961 : 0 : M2Printf_printf0 ((const char *) "</lines>\\n", 10);
20962 : : }
20963 : 13935 : }
20964 : :
20965 : :
20966 : : /*
20967 : : GetErrorScope - returns the error scope for a symbol.
20968 : : The error scope is the title scope which is used to
20969 : : announce the symbol in the GCC error message.
20970 : : */
20971 : :
20972 : 147760352 : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym)
20973 : : {
20974 : 147760352 : SymbolTable_PtrToSymbol pSym;
20975 : :
20976 : 147760352 : pSym = GetPsym (sym);
20977 : 147760352 : switch (pSym->SymbolType)
20978 : : {
20979 : 1611102 : case SymbolTable_ProcedureSym:
20980 : 1611102 : return pSym->Procedure.errorScope;
20981 : 4366514 : break;
20982 : :
20983 : 4366514 : case SymbolTable_ModuleSym:
20984 : 4366514 : return pSym->Module.errorScope;
20985 : 141782736 : break;
20986 : :
20987 : 141782736 : case SymbolTable_DefImpSym:
20988 : 141782736 : return pSym->DefImp.errorScope;
20989 : 0 : break;
20990 : :
20991 : 0 : case SymbolTable_UndefinedSym:
20992 : 0 : return pSym->Undefined.errorScope;
20993 : 0 : break;
20994 : :
20995 : :
20996 : 0 : default:
20997 : 0 : M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
20998 : : break;
20999 : : }
21000 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21001 : : __builtin_unreachable ();
21002 : : }
21003 : :
21004 : :
21005 : : /*
21006 : : MakeImport - create and return an import symbol.
21007 : : moduleSym is the symbol being imported.
21008 : : isqualified is FALSE if it were IMPORT modulename and
21009 : : TRUE for the qualified FROM modulename IMPORT etc.
21010 : : listno is the import list count for this module.
21011 : : tok should match this modulename position.
21012 : : */
21013 : :
21014 : 416484 : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified)
21015 : : {
21016 : 416484 : unsigned int importSym;
21017 : 416484 : SymbolTable_PtrToSymbol pSym;
21018 : :
21019 : 416484 : NewSym (&importSym);
21020 : 416484 : pSym = GetPsym (importSym);
21021 : 416484 : pSym->SymbolType = SymbolTable_ImportSym;
21022 : 416484 : pSym->Import.module = moduleSym;
21023 : 416484 : pSym->Import.listNo = listno;
21024 : 416484 : pSym->Import.qualified = isqualified;
21025 : 416484 : InitWhereDeclaredTok (tok, &pSym->Import.at);
21026 : 416484 : return importSym;
21027 : : /* static analysis guarentees a RETURN statement will be used before here. */
21028 : : __builtin_unreachable ();
21029 : : }
21030 : :
21031 : :
21032 : : /*
21033 : : MakeImportStatement - return a dependent symbol which represents an import statement
21034 : : or a qualified import statement. The tok should either match
21035 : : the FROM token or the IMPORT token. listno is the import list
21036 : : count for the module.
21037 : : */
21038 : :
21039 : 401308 : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno)
21040 : : {
21041 : 401308 : unsigned int dependentSym;
21042 : 401308 : SymbolTable_PtrToSymbol pSym;
21043 : :
21044 : 401308 : NewSym (&dependentSym);
21045 : 401308 : pSym = GetPsym (dependentSym);
21046 : 401308 : pSym->SymbolType = SymbolTable_ImportStatementSym;
21047 : 401308 : pSym->ImportStatement.listNo = listno;
21048 : 401308 : Lists_InitList (&pSym->ImportStatement.ListOfImports);
21049 : 401308 : InitWhereDeclaredTok (tok, &pSym->ImportStatement.at);
21050 : 401308 : return dependentSym;
21051 : : /* static analysis guarentees a RETURN statement will be used before here. */
21052 : : __builtin_unreachable ();
21053 : : }
21054 : :
21055 : :
21056 : : /*
21057 : : IsImport - returns TRUE if sym is an import symbol.
21058 : : */
21059 : :
21060 : 1153122 : extern "C" bool SymbolTable_IsImport (unsigned int sym)
21061 : : {
21062 : 1153122 : SymbolTable_PtrToSymbol pSym;
21063 : :
21064 : 1153122 : pSym = GetPsym (sym);
21065 : 1153122 : return pSym->SymbolType == SymbolTable_ImportSym;
21066 : : /* static analysis guarentees a RETURN statement will be used before here. */
21067 : : __builtin_unreachable ();
21068 : : }
21069 : :
21070 : :
21071 : : /*
21072 : : IsImportStatement - returns TRUE if sym is a dependent symbol.
21073 : : */
21074 : :
21075 : 1522488 : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym)
21076 : : {
21077 : 1522488 : SymbolTable_PtrToSymbol pSym;
21078 : :
21079 : 1522488 : pSym = GetPsym (sym);
21080 : 1522488 : return pSym->SymbolType == SymbolTable_ImportStatementSym;
21081 : : /* static analysis guarentees a RETURN statement will be used before here. */
21082 : : __builtin_unreachable ();
21083 : : }
21084 : :
21085 : :
21086 : : /*
21087 : : GetImportModule - returns the module associated with the import symbol.
21088 : : */
21089 : :
21090 : 356896 : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym)
21091 : : {
21092 : 356896 : SymbolTable_PtrToSymbol pSym;
21093 : :
21094 : 356896 : M2Debug_Assert (SymbolTable_IsImport (sym));
21095 : 356896 : pSym = GetPsym (sym);
21096 : 356896 : return pSym->Import.module;
21097 : : /* static analysis guarentees a RETURN statement will be used before here. */
21098 : : __builtin_unreachable ();
21099 : : }
21100 : :
21101 : :
21102 : : /*
21103 : : GetImportDeclared - returns the token associated with the import symbol.
21104 : : */
21105 : :
21106 : 22846 : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym)
21107 : : {
21108 : 22846 : unsigned int tok;
21109 : :
21110 : 22846 : M2Debug_Assert (SymbolTable_IsImport (sym));
21111 : 22846 : tok = SymbolTable_GetDeclaredDefinition (sym);
21112 : 22846 : if (tok == M2LexBuf_UnknownTokenNo)
21113 : : {
21114 : 21047 : return SymbolTable_GetDeclaredModule (sym);
21115 : : }
21116 : : return tok;
21117 : : /* static analysis guarentees a RETURN statement will be used before here. */
21118 : : __builtin_unreachable ();
21119 : : }
21120 : :
21121 : :
21122 : : /*
21123 : : GetImportStatementList - returns the list of imports for this dependent.
21124 : : Each import symbol corresponds to a module.
21125 : : */
21126 : :
21127 : 761244 : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym)
21128 : : {
21129 : 761244 : SymbolTable_PtrToSymbol pSym;
21130 : :
21131 : 761244 : M2Debug_Assert (SymbolTable_IsImportStatement (sym));
21132 : 761244 : pSym = GetPsym (sym);
21133 : 761244 : return pSym->ImportStatement.ListOfImports;
21134 : : /* static analysis guarentees a RETURN statement will be used before here. */
21135 : : __builtin_unreachable ();
21136 : : }
21137 : :
21138 : :
21139 : : /*
21140 : : GetModuleDefImportStatementList - returns the list of dependents associated with
21141 : : the definition module.
21142 : : */
21143 : :
21144 : 215322 : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym)
21145 : : {
21146 : 215322 : SymbolTable_PtrToSymbol pSym;
21147 : :
21148 : 430644 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
21149 : 215322 : if (SymbolTable_IsDefImp (sym))
21150 : : {
21151 : 201145 : pSym = GetPsym (sym);
21152 : 201145 : return pSym->DefImp.DefListOfDep;
21153 : : }
21154 : : return static_cast<Lists_List> (NULL);
21155 : : /* static analysis guarentees a RETURN statement will be used before here. */
21156 : : __builtin_unreachable ();
21157 : : }
21158 : :
21159 : :
21160 : : /*
21161 : : GetModuleModImportStatementList - returns the list of dependents associated with
21162 : : the implementation or program module.
21163 : : */
21164 : :
21165 : 406114 : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym)
21166 : : {
21167 : 406114 : SymbolTable_PtrToSymbol pSym;
21168 : :
21169 : 812228 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
21170 : 406114 : pSym = GetPsym (sym);
21171 : 406114 : if (SymbolTable_IsDefImp (sym))
21172 : : {
21173 : 377349 : return pSym->DefImp.ModListOfDep;
21174 : : }
21175 : : else
21176 : : {
21177 : 28765 : return pSym->Module.ModListOfDep;
21178 : : }
21179 : : /* static analysis guarentees a RETURN statement will be used before here. */
21180 : : __builtin_unreachable ();
21181 : : }
21182 : :
21183 : :
21184 : : /*
21185 : : AppendModuleImportStatement - appends the ImportStatement symbol onto the
21186 : : module import list.
21187 : :
21188 : : For example:
21189 : :
21190 : : FROM x IMPORT y, z ;
21191 : : ^^^^
21192 : :
21193 : : also:
21194 : :
21195 : : IMPORT p, q, r;
21196 : : ^^^^^^
21197 : : will result in a new ImportStatement symbol added
21198 : : to the current module import list.
21199 : : The statement symbol is expected to be created
21200 : : by MakeImportStatement using the token positions
21201 : : outlined above.
21202 : : */
21203 : :
21204 : 401308 : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement)
21205 : : {
21206 : 401308 : SymbolTable_PtrToSymbol pSym;
21207 : :
21208 : 401308 : if (SymbolTable_IsDefImp (module))
21209 : : {
21210 : 387128 : pSym = GetPsym (module);
21211 : 387128 : if (M2Comp_CompilingDefinitionModule ())
21212 : : {
21213 : 110438 : Lists_IncludeItemIntoList (pSym->DefImp.DefListOfDep, statement);
21214 : : }
21215 : : else
21216 : : {
21217 : 276690 : Lists_IncludeItemIntoList (pSym->DefImp.ModListOfDep, statement);
21218 : : }
21219 : : }
21220 : 14180 : else if (SymbolTable_IsModule (module))
21221 : : {
21222 : : /* avoid dangling else. */
21223 : 14180 : pSym = GetPsym (module);
21224 : 14180 : Lists_IncludeItemIntoList (pSym->Module.ModListOfDep, statement);
21225 : : }
21226 : : else
21227 : : {
21228 : : /* avoid dangling else. */
21229 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
21230 : : }
21231 : 401308 : }
21232 : :
21233 : :
21234 : : /*
21235 : : AppendModuleOnImportStatement - appends the import symbol onto the
21236 : : dependent list (chain).
21237 : :
21238 : : For example each:
21239 : :
21240 : : FROM x IMPORT y, z ;
21241 : : ^
21242 : : x are added to the dependent list.
21243 : :
21244 : : also:
21245 : :
21246 : : IMPORT p, q, r;
21247 : : ^ ^ ^
21248 : : will result in p, q and r added to
21249 : : to the dependent list.
21250 : :
21251 : : The import symbol is created by MakeImport
21252 : : and the token is expected to match the module
21253 : : name position outlined above.
21254 : : */
21255 : :
21256 : 416484 : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import)
21257 : : {
21258 : 416484 : Lists_List l;
21259 : 416484 : unsigned int lastImportStatement;
21260 : :
21261 : 416484 : M2Debug_Assert (SymbolTable_IsImport (import));
21262 : 416484 : if (M2Comp_CompilingDefinitionModule ())
21263 : : {
21264 : 112846 : l = SymbolTable_GetModuleDefImportStatementList (module);
21265 : : }
21266 : : else
21267 : : {
21268 : 303638 : l = SymbolTable_GetModuleModImportStatementList (module);
21269 : : }
21270 : 416484 : M2Debug_Assert (l != NULL);
21271 : 416484 : M2Debug_Assert ((Lists_NoOfItemsInList (l)) > 0); /* There should always be one on the list. */
21272 : 416484 : lastImportStatement = static_cast<unsigned int> (Lists_GetItemFromList (l, Lists_NoOfItemsInList (l))); /* There should always be one on the list. */
21273 : 416484 : M2Debug_Assert (SymbolTable_IsImportStatement (lastImportStatement));
21274 : 416484 : l = SymbolTable_GetImportStatementList (lastImportStatement);
21275 : 416484 : Lists_IncludeItemIntoList (l, import);
21276 : 416484 : }
21277 : :
21278 : :
21279 : : /*
21280 : : PutModLink - assigns link to module sym.
21281 : : */
21282 : :
21283 : 62832 : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link)
21284 : : {
21285 : 62832 : SymbolTable_PtrToSymbol pSym;
21286 : :
21287 : 62832 : if (SymbolTable_IsModule (sym))
21288 : : {
21289 : 0 : pSym = GetPsym (sym);
21290 : 0 : pSym->Module.ModLink = link;
21291 : : }
21292 : 62832 : else if (SymbolTable_IsDefImp (sym))
21293 : : {
21294 : : /* avoid dangling else. */
21295 : 62832 : pSym = GetPsym (sym);
21296 : 62832 : pSym->DefImp.ModLink = link;
21297 : : }
21298 : : else
21299 : : {
21300 : : /* avoid dangling else. */
21301 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
21302 : : }
21303 : 62832 : }
21304 : :
21305 : :
21306 : : /*
21307 : : IsModLink - returns the ModLink value associated with the module symbol.
21308 : : */
21309 : :
21310 : 373593 : extern "C" bool SymbolTable_IsModLink (unsigned int sym)
21311 : : {
21312 : 373593 : SymbolTable_PtrToSymbol pSym;
21313 : :
21314 : 373593 : if (SymbolTable_IsModule (sym))
21315 : : {
21316 : 179198 : pSym = GetPsym (sym);
21317 : 179198 : return pSym->Module.ModLink;
21318 : : }
21319 : 194395 : else if (SymbolTable_IsDefImp (sym))
21320 : : {
21321 : : /* avoid dangling else. */
21322 : 194395 : pSym = GetPsym (sym);
21323 : 194395 : return pSym->DefImp.ModLink;
21324 : : }
21325 : : else
21326 : : {
21327 : : /* avoid dangling else. */
21328 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
21329 : : }
21330 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21331 : : __builtin_unreachable ();
21332 : : }
21333 : :
21334 : :
21335 : : /*
21336 : : PutDefLink - assigns link to the definition module sym.
21337 : : */
21338 : :
21339 : 0 : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link)
21340 : : {
21341 : 0 : SymbolTable_PtrToSymbol pSym;
21342 : :
21343 : 0 : if (SymbolTable_IsDefImp (sym))
21344 : : {
21345 : 0 : pSym = GetPsym (sym);
21346 : 0 : pSym->DefImp.DefLink = link;
21347 : : }
21348 : : else
21349 : : {
21350 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
21351 : : }
21352 : 0 : }
21353 : :
21354 : :
21355 : : /*
21356 : : IsDefLink - returns the DefLink value associated with the definition module symbol.
21357 : : */
21358 : :
21359 : 172071 : extern "C" bool SymbolTable_IsDefLink (unsigned int sym)
21360 : : {
21361 : 172071 : SymbolTable_PtrToSymbol pSym;
21362 : :
21363 : 172071 : if (SymbolTable_IsDefImp (sym))
21364 : : {
21365 : 172071 : pSym = GetPsym (sym);
21366 : 172071 : return pSym->DefImp.DefLink;
21367 : : }
21368 : : else
21369 : : {
21370 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
21371 : : }
21372 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21373 : : __builtin_unreachable ();
21374 : : }
21375 : :
21376 : :
21377 : : /*
21378 : : IsModuleBuiltin - returns TRUE if the module is a builtin module.
21379 : : (For example _BaseTypes).
21380 : : */
21381 : :
21382 : 87138 : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym)
21383 : : {
21384 : 87138 : SymbolTable_PtrToSymbol pSym;
21385 : :
21386 : 87138 : if (SymbolTable_IsDefImp (sym))
21387 : : {
21388 : 84460 : pSym = GetPsym (sym);
21389 : 84460 : return pSym->DefImp.Builtin;
21390 : : }
21391 : 2678 : else if (SymbolTable_IsModule (sym))
21392 : : {
21393 : : /* avoid dangling else. */
21394 : 2678 : pSym = GetPsym (sym);
21395 : 2678 : return pSym->Module.Builtin;
21396 : : }
21397 : : return false;
21398 : : /* static analysis guarentees a RETURN statement will be used before here. */
21399 : : __builtin_unreachable ();
21400 : : }
21401 : :
21402 : :
21403 : : /*
21404 : : PutModuleBuiltin - sets the Builtin flag to value.
21405 : : Currently the procedure expects sym to be a DefImp
21406 : : module only.
21407 : : */
21408 : :
21409 : 15229 : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value)
21410 : : {
21411 : 15229 : SymbolTable_PtrToSymbol pSym;
21412 : :
21413 : 15229 : if (SymbolTable_IsDefImp (sym))
21414 : : {
21415 : 0 : pSym = GetPsym (sym);
21416 : 0 : pSym->DefImp.Builtin = value;
21417 : : }
21418 : 15229 : else if (SymbolTable_IsModule (sym))
21419 : : {
21420 : : /* avoid dangling else. */
21421 : 15229 : pSym = GetPsym (sym);
21422 : 15229 : pSym->Module.Builtin = value;
21423 : : }
21424 : : else
21425 : : {
21426 : : /* avoid dangling else. */
21427 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
21428 : : }
21429 : 15229 : }
21430 : :
21431 : :
21432 : : /*
21433 : : PutVarArrayRef - assigns ArrayRef field with value.
21434 : : */
21435 : :
21436 : 56168 : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value)
21437 : : {
21438 : 56168 : SymbolTable_PtrToSymbol pSym;
21439 : :
21440 : 56168 : pSym = GetPsym (sym);
21441 : 56168 : switch (pSym->SymbolType)
21442 : : {
21443 : 56168 : case SymbolTable_VarSym:
21444 : 56168 : pSym->Var.ArrayRef = value;
21445 : 56168 : break;
21446 : :
21447 : :
21448 : 0 : default:
21449 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
21450 : 56168 : break;
21451 : : }
21452 : 56168 : }
21453 : :
21454 : :
21455 : : /*
21456 : : IsVarArrayRef - returns ArrayRef field value.
21457 : : */
21458 : :
21459 : 18162 : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym)
21460 : : {
21461 : 18162 : SymbolTable_PtrToSymbol pSym;
21462 : :
21463 : 18162 : pSym = GetPsym (sym);
21464 : 18162 : switch (pSym->SymbolType)
21465 : : {
21466 : 18162 : case SymbolTable_VarSym:
21467 : 18162 : return pSym->Var.ArrayRef;
21468 : 0 : break;
21469 : :
21470 : :
21471 : 0 : default:
21472 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
21473 : : break;
21474 : : }
21475 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21476 : : __builtin_unreachable ();
21477 : : }
21478 : :
21479 : :
21480 : : /*
21481 : : VarCheckReadInit - returns TRUE if sym has been initialized.
21482 : : */
21483 : :
21484 : 9790 : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode)
21485 : : {
21486 : 9790 : SymbolTable_PtrToSymbol pSym;
21487 : :
21488 : 9790 : if (SymbolTable_IsVar (sym))
21489 : : {
21490 : 9790 : pSym = GetPsym (sym);
21491 : 9790 : switch (pSym->SymbolType)
21492 : : {
21493 : 9790 : case SymbolTable_VarSym:
21494 : 9790 : return M2SymInit_GetInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]));
21495 : : break;
21496 : :
21497 : :
21498 : : default:
21499 : : break;
21500 : : }
21501 : : }
21502 : : return false;
21503 : : /* static analysis guarentees a RETURN statement will be used before here. */
21504 : : __builtin_unreachable ();
21505 : : }
21506 : :
21507 : :
21508 : : /*
21509 : : VarInitState - initializes the init state for variable sym.
21510 : : */
21511 : :
21512 : 210564 : extern "C" void SymbolTable_VarInitState (unsigned int sym)
21513 : : {
21514 : 210564 : SymbolTable_PtrToSymbol pSym;
21515 : :
21516 : 210564 : if (SymbolTable_IsVar (sym))
21517 : : {
21518 : 210564 : pSym = GetPsym (sym);
21519 : 210564 : switch (pSym->SymbolType)
21520 : : {
21521 : 210564 : case SymbolTable_VarSym:
21522 : 210564 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), sym);
21523 : 210564 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), sym);
21524 : 210564 : break;
21525 : :
21526 : :
21527 : : default:
21528 : : break;
21529 : : }
21530 : : }
21531 : 210564 : }
21532 : :
21533 : :
21534 : : /*
21535 : : PutVarInitialized - set sym as initialized.
21536 : : */
21537 : :
21538 : 40371 : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode)
21539 : : {
21540 : 40371 : SymbolTable_PtrToSymbol pSym;
21541 : :
21542 : 40371 : if (SymbolTable_IsVar (sym))
21543 : : {
21544 : 40371 : pSym = GetPsym (sym);
21545 : 40371 : switch (pSym->SymbolType)
21546 : : {
21547 : 40371 : case SymbolTable_VarSym:
21548 : 40371 : M2SymInit_SetInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]));
21549 : 40371 : break;
21550 : :
21551 : :
21552 : : default:
21553 : : break;
21554 : : }
21555 : : }
21556 : 40371 : }
21557 : :
21558 : :
21559 : : /*
21560 : : PutVarFieldInitialized - records that field has been initialized with
21561 : : variable sym. TRUE is returned if the field
21562 : : is detected and changed to initialized.
21563 : : */
21564 : :
21565 : 3364 : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
21566 : : {
21567 : 3364 : SymbolTable_PtrToSymbol pSym;
21568 : :
21569 : 3364 : if (SymbolTable_IsVar (sym))
21570 : : {
21571 : 3364 : pSym = GetPsym (sym);
21572 : 3364 : switch (pSym->SymbolType)
21573 : : {
21574 : 3364 : case SymbolTable_VarSym:
21575 : 3364 : return M2SymInit_SetFieldInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]), fieldlist);
21576 : : break;
21577 : :
21578 : :
21579 : : default:
21580 : : break;
21581 : : }
21582 : : }
21583 : : return false;
21584 : : /* static analysis guarentees a RETURN statement will be used before here. */
21585 : : __builtin_unreachable ();
21586 : : }
21587 : :
21588 : :
21589 : : /*
21590 : : GetVarFieldInitialized - return TRUE if fieldlist has been initialized
21591 : : within variable sym.
21592 : : */
21593 : :
21594 : 232 : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
21595 : : {
21596 : 232 : SymbolTable_PtrToSymbol pSym;
21597 : :
21598 : 232 : if (SymbolTable_IsVar (sym))
21599 : : {
21600 : 232 : pSym = GetPsym (sym);
21601 : 232 : switch (pSym->SymbolType)
21602 : : {
21603 : 232 : case SymbolTable_VarSym:
21604 : 232 : return M2SymInit_GetFieldInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]), fieldlist);
21605 : : break;
21606 : :
21607 : :
21608 : : default:
21609 : : break;
21610 : : }
21611 : : }
21612 : : return false;
21613 : : /* static analysis guarentees a RETURN statement will be used before here. */
21614 : : __builtin_unreachable ();
21615 : : }
21616 : :
21617 : :
21618 : : /*
21619 : : PrintInitialized - display variable sym initialization state.
21620 : : */
21621 : :
21622 : 0 : extern "C" void SymbolTable_PrintInitialized (unsigned int sym)
21623 : : {
21624 : 0 : SymbolTable_PtrToSymbol pSym;
21625 : :
21626 : 0 : if (SymbolTable_IsVar (sym))
21627 : : {
21628 : 0 : pSym = GetPsym (sym);
21629 : 0 : switch (pSym->SymbolType)
21630 : : {
21631 : 0 : case SymbolTable_VarSym:
21632 : 0 : M2Printf_printf0 ((const char *) "LeftMode init: ", 15);
21633 : 0 : M2SymInit_PrintSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]));
21634 : 0 : M2Printf_printf0 ((const char *) "RightMode init: ", 16);
21635 : 0 : M2SymInit_PrintSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]));
21636 : 0 : break;
21637 : :
21638 : :
21639 : : default:
21640 : : break;
21641 : : }
21642 : : }
21643 : 0 : }
21644 : :
21645 : :
21646 : : /*
21647 : : GetParameterHeapVar - return the heap variable associated with the
21648 : : parameter or NulSym.
21649 : : */
21650 : :
21651 : 46900 : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym)
21652 : : {
21653 : 46900 : SymbolTable_PtrToSymbol pSym;
21654 : :
21655 : 46900 : pSym = GetPsym (ParSym);
21656 : 46900 : switch (pSym->SymbolType)
21657 : : {
21658 : : case SymbolTable_ParamSym:
21659 : : return SymbolTable_NulSym; /* Only VarParam has the pointer. */
21660 : 7176 : break;
21661 : :
21662 : 7176 : case SymbolTable_VarParamSym:
21663 : 7176 : return pSym->VarParam.HeapVar; /* Only VarParam has the pointer. */
21664 : 0 : break;
21665 : :
21666 : :
21667 : 0 : default:
21668 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
21669 : : break;
21670 : : }
21671 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21672 : : __builtin_unreachable ();
21673 : : }
21674 : :
21675 : :
21676 : : /*
21677 : : PutProcedureParameterHeapVars - creates heap variables for parameter sym.
21678 : : */
21679 : :
21680 : 1877788 : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym)
21681 : : {
21682 : 1877788 : M2Debug_Assert (SymbolTable_IsProcedure (sym));
21683 : 1877788 : SymbolTable_ForeachParamSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PutParameterHeapVar});
21684 : 1877788 : }
21685 : :
21686 : :
21687 : : /*
21688 : : IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
21689 : : for the target architecture.
21690 : : */
21691 : :
21692 : 1208195 : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure)
21693 : : {
21694 : 1208195 : return (SymbolTable_IsProcedureBuiltin (procedure)) && (CanUseBuiltin (procedure));
21695 : : /* static analysis guarentees a RETURN statement will be used before here. */
21696 : : __builtin_unreachable ();
21697 : : }
21698 : :
21699 : :
21700 : : /*
21701 : : PutConstLitInternal - marks the sym as being an internal constant.
21702 : : Currently this is used when generating a default
21703 : : BY constant expression during a FOR loop.
21704 : : A constant marked as internal will always pass
21705 : : an expression type check.
21706 : : */
21707 : :
21708 : 15711 : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value)
21709 : : {
21710 : 15711 : SymbolTable_PtrToSymbol pSym;
21711 : :
21712 : 15711 : pSym = GetPsym (sym);
21713 : 15711 : switch (pSym->SymbolType)
21714 : : {
21715 : 15711 : case SymbolTable_ConstLitSym:
21716 : 15711 : pSym->ConstLit.IsInternal = value;
21717 : 15711 : break;
21718 : :
21719 : :
21720 : 0 : default:
21721 : 0 : M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
21722 : 15711 : break;
21723 : : }
21724 : 15711 : }
21725 : :
21726 : :
21727 : : /*
21728 : : IsConstLitInternal - returns the value of the IsInternal field within
21729 : : a constant expression.
21730 : : */
21731 : :
21732 : 826492 : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym)
21733 : : {
21734 : 826492 : SymbolTable_PtrToSymbol pSym;
21735 : :
21736 : 826492 : pSym = GetPsym (sym);
21737 : 826492 : switch (pSym->SymbolType)
21738 : : {
21739 : 826492 : case SymbolTable_ConstLitSym:
21740 : 826492 : return pSym->ConstLit.IsInternal;
21741 : 0 : break;
21742 : :
21743 : :
21744 : 0 : default:
21745 : 0 : M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
21746 : : break;
21747 : : }
21748 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21749 : : __builtin_unreachable ();
21750 : : }
21751 : :
21752 : :
21753 : : /*
21754 : : GetVarDeclTypeTok - returns the TypeTok field associate with variable sym.
21755 : : */
21756 : :
21757 : 0 : extern "C" unsigned int SymbolTable_GetVarDeclTypeTok (unsigned int sym)
21758 : : {
21759 : 0 : SymbolTable_PtrToSymbol pSym;
21760 : :
21761 : 0 : if (SymbolTable_IsParameter (sym))
21762 : : {
21763 : 0 : pSym = GetPsym (sym);
21764 : 0 : if (SymbolTable_IsParameterVar (sym))
21765 : : {
21766 : 0 : return SymbolTable_GetVarDeclTypeTok (pSym->VarParam.ShadowVar);
21767 : : }
21768 : : else
21769 : : {
21770 : 0 : return SymbolTable_GetVarDeclTypeTok (pSym->Param.ShadowVar);
21771 : : }
21772 : : }
21773 : 0 : else if (SymbolTable_IsVar (sym))
21774 : : {
21775 : : /* avoid dangling else. */
21776 : 0 : return doGetVarDeclTypeTok (sym);
21777 : : }
21778 : : else
21779 : : {
21780 : : /* avoid dangling else. */
21781 : : return M2LexBuf_UnknownTokenNo;
21782 : : }
21783 : : /* static analysis guarentees a RETURN statement will be used before here. */
21784 : : __builtin_unreachable ();
21785 : : }
21786 : :
21787 : :
21788 : : /*
21789 : : PutVarDeclTypeTok - assigns the TypeTok field to typetok.
21790 : : sym can be a variable or parameter.
21791 : : */
21792 : :
21793 : 0 : extern "C" void SymbolTable_PutVarDeclTypeTok (unsigned int sym, unsigned int typetok)
21794 : : {
21795 : 0 : SymbolTable_PtrToSymbol pSym;
21796 : :
21797 : 0 : if (SymbolTable_IsParameter (sym))
21798 : : {
21799 : 0 : pSym = GetPsym (sym);
21800 : 0 : if (SymbolTable_IsParameterVar (sym))
21801 : : {
21802 : 0 : SymbolTable_PutVarDeclTypeTok (pSym->VarParam.ShadowVar, typetok);
21803 : : }
21804 : : else
21805 : : {
21806 : 0 : SymbolTable_PutVarDeclTypeTok (pSym->Param.ShadowVar, typetok);
21807 : : }
21808 : : }
21809 : 0 : else if (SymbolTable_IsVar (sym))
21810 : : {
21811 : : /* avoid dangling else. */
21812 : 0 : doPutVarDeclTypeTok (sym, typetok);
21813 : : }
21814 : 0 : }
21815 : :
21816 : :
21817 : : /*
21818 : : GetVarDeclTok - returns the TypeTok field associate with variable sym.
21819 : : */
21820 : :
21821 : 96 : extern "C" unsigned int SymbolTable_GetVarDeclTok (unsigned int sym)
21822 : : {
21823 : 156 : SymbolTable_PtrToSymbol pSym;
21824 : :
21825 : 156 : if (SymbolTable_IsParameter (sym))
21826 : : {
21827 : 96 : pSym = GetPsym (sym);
21828 : 96 : if (SymbolTable_IsParameterVar (sym))
21829 : : {
21830 : 6 : if (pSym->VarParam.ShadowVar == SymbolTable_NulSym)
21831 : : {
21832 : 0 : return pSym->VarParam.At;
21833 : : }
21834 : : else
21835 : : {
21836 : : return SymbolTable_GetVarDeclTok (pSym->VarParam.ShadowVar);
21837 : : }
21838 : : }
21839 : : else
21840 : : {
21841 : 90 : if (pSym->Param.ShadowVar == SymbolTable_NulSym)
21842 : : {
21843 : 36 : return pSym->Param.At;
21844 : : }
21845 : : else
21846 : : {
21847 : : return SymbolTable_GetVarDeclTok (pSym->Param.ShadowVar);
21848 : : }
21849 : : }
21850 : : }
21851 : 60 : else if (SymbolTable_IsVar (sym))
21852 : : {
21853 : : /* avoid dangling else. */
21854 : 60 : return doGetVarDeclTok (sym);
21855 : : }
21856 : : else
21857 : : {
21858 : : /* avoid dangling else. */
21859 : : return M2LexBuf_UnknownTokenNo;
21860 : : }
21861 : : /* static analysis guarentees a RETURN statement will be used before here. */
21862 : : __builtin_unreachable ();
21863 : : }
21864 : :
21865 : :
21866 : : /*
21867 : : PutVarDeclTok - assigns the VarTok field to typetok.
21868 : : sym can be a variable or parameter.
21869 : : */
21870 : :
21871 : 1689828 : extern "C" void SymbolTable_PutVarDeclTok (unsigned int sym, unsigned int vartok)
21872 : : {
21873 : 1689828 : SymbolTable_PtrToSymbol pSym;
21874 : :
21875 : 1689828 : if (SymbolTable_IsParameter (sym))
21876 : : {
21877 : 0 : pSym = GetPsym (sym);
21878 : 0 : if (SymbolTable_IsParameterVar (sym))
21879 : : {
21880 : 0 : SymbolTable_PutVarDeclTok (pSym->VarParam.ShadowVar, vartok);
21881 : : }
21882 : : else
21883 : : {
21884 : 0 : SymbolTable_PutVarDeclTok (pSym->Param.ShadowVar, vartok);
21885 : : }
21886 : : }
21887 : 1689828 : else if (SymbolTable_IsVar (sym))
21888 : : {
21889 : : /* avoid dangling else. */
21890 : 1689828 : doPutVarDeclTok (sym, vartok);
21891 : : }
21892 : 1689828 : }
21893 : :
21894 : :
21895 : : /*
21896 : : GetVarDeclFullTok - returns the full virtual token containing var: type.
21897 : : */
21898 : :
21899 : 360 : extern "C" unsigned int SymbolTable_GetVarDeclFullTok (unsigned int sym)
21900 : : {
21901 : 360 : SymbolTable_PtrToSymbol pSym;
21902 : :
21903 : 360 : pSym = GetPsym (sym);
21904 : 360 : if (SymbolTable_IsParameter (sym))
21905 : : {
21906 : 78 : if (SymbolTable_IsParameterVar (sym))
21907 : : {
21908 : 6 : return pSym->VarParam.FullTok;
21909 : : }
21910 : : else
21911 : : {
21912 : 72 : return pSym->Param.FullTok;
21913 : : }
21914 : : }
21915 : 282 : else if (SymbolTable_IsVar (sym))
21916 : : {
21917 : : /* avoid dangling else. */
21918 : 282 : return doGetVarDeclFullTok (sym);
21919 : : }
21920 : : else
21921 : : {
21922 : : /* avoid dangling else. */
21923 : : return M2LexBuf_UnknownTokenNo;
21924 : : }
21925 : : /* static analysis guarentees a RETURN statement will be used before here. */
21926 : : __builtin_unreachable ();
21927 : : }
21928 : :
21929 : :
21930 : : /*
21931 : : IsProcedureAnyNoReturn - return TRUE if any of the defined kinds
21932 : : of procedure sym is declared no return.
21933 : : */
21934 : :
21935 : 3683631 : extern "C" bool SymbolTable_IsProcedureAnyNoReturn (unsigned int sym)
21936 : : {
21937 : 3683631 : return IsProcedureAnyDefaultBoolean (sym, false, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_IsProcedureNoReturn});
21938 : : /* static analysis guarentees a RETURN statement will be used before here. */
21939 : : __builtin_unreachable ();
21940 : : }
21941 : :
21942 : :
21943 : : /*
21944 : : GetNthParamAny - returns the nth parameter from the order
21945 : : proper procedure, forward declaration
21946 : : or definition module procedure.
21947 : : */
21948 : :
21949 : 21020096 : extern "C" unsigned int SymbolTable_GetNthParamAny (unsigned int sym, unsigned int ParamNo)
21950 : : {
21951 : 21020096 : SymbolTable_ProcedureKind kind;
21952 : :
21953 : 33404330 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
21954 : : {
21955 : 33404330 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
21956 : : {
21957 : 21020096 : return SymbolTable_GetNthParam (sym, kind, ParamNo);
21958 : : }
21959 : : }
21960 : 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
21961 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21962 : : __builtin_unreachable ();
21963 : : }
21964 : :
21965 : :
21966 : : /*
21967 : : NoOfParamAny - return the number of parameters for sym.
21968 : : */
21969 : :
21970 : 25748019 : extern "C" unsigned int SymbolTable_NoOfParamAny (unsigned int sym)
21971 : : {
21972 : 25748019 : SymbolTable_ProcedureKind kind;
21973 : 25748019 : SymbolTable_PtrToSymbol pSym;
21974 : :
21975 : 25748019 : AssertInRange (sym);
21976 : 25748019 : pSym = GetPsym (sym);
21977 : 25748019 : switch (pSym->SymbolType)
21978 : : {
21979 : : case SymbolTable_ErrorSym:
21980 : : return 0;
21981 : : break;
21982 : :
21983 : : case SymbolTable_ProcedureSym:
21984 : 42223565 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
21985 : : {
21986 : 40056827 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
21987 : : {
21988 : 17081053 : return SymbolTable_NoOfParam (sym, kind);
21989 : : }
21990 : : }
21991 : : break;
21992 : :
21993 : 6500216 : case SymbolTable_ProcTypeSym:
21994 : 6500216 : return Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
21995 : 12 : break;
21996 : :
21997 : :
21998 : 12 : default:
21999 : 12 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
22000 : : break;
22001 : : }
22002 : : return 0;
22003 : : /* static analysis guarentees a RETURN statement will be used before here. */
22004 : : __builtin_unreachable ();
22005 : : }
22006 : :
22007 : :
22008 : : /*
22009 : : SetReturnOptional - sets the ReturnOptional field in the Procedure:kind or
22010 : : ProcType symboltable entry.
22011 : : */
22012 : :
22013 : 3131007 : extern "C" void SymbolTable_SetReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind, bool isopt)
22014 : : {
22015 : 3131007 : SymbolTable_PtrToSymbol pSym;
22016 : :
22017 : 3131007 : pSym = GetPsym (sym);
22018 : 3131007 : switch (pSym->SymbolType)
22019 : : {
22020 : 3123149 : case SymbolTable_ProcedureSym:
22021 : 3123149 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional = isopt;
22022 : 3123149 : break;
22023 : :
22024 : 7858 : case SymbolTable_ProcTypeSym:
22025 : 7858 : pSym->ProcType.ReturnOptional = isopt;
22026 : 7858 : break;
22027 : :
22028 : :
22029 : 0 : default:
22030 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
22031 : 3131007 : break;
22032 : : }
22033 : 3131007 : }
22034 : :
22035 : :
22036 : : /*
22037 : : UsesOptArgAny - returns TRUE if procedure Sym:kind uses an optional argument.
22038 : : */
22039 : :
22040 : 209826 : extern "C" bool SymbolTable_UsesOptArgAny (unsigned int Sym)
22041 : : {
22042 : 209826 : SymbolTable_PtrToSymbol pSym;
22043 : :
22044 : 209826 : pSym = GetPsym (Sym);
22045 : 209826 : switch (pSym->SymbolType)
22046 : : {
22047 : : case SymbolTable_ErrorSym:
22048 : : return false;
22049 : 209054 : break;
22050 : :
22051 : 209054 : case SymbolTable_ProcedureSym:
22052 : 209054 : return IsProcedureAnyDefaultBoolean (Sym, false, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_UsesOptArg});
22053 : 772 : break;
22054 : :
22055 : 772 : case SymbolTable_ProcTypeSym:
22056 : 772 : return pSym->ProcType.HasOptArg;
22057 : 0 : break;
22058 : :
22059 : :
22060 : 0 : default:
22061 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
22062 : : break;
22063 : : }
22064 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
22065 : : __builtin_unreachable ();
22066 : : }
22067 : :
22068 : :
22069 : : /*
22070 : : GetProcedureKindDesc - return a string describing kind.
22071 : : */
22072 : :
22073 : 180 : extern "C" DynamicStrings_String SymbolTable_GetProcedureKindDesc (SymbolTable_ProcedureKind kind)
22074 : : {
22075 : 180 : if (kind == SymbolTable_ProperProcedure)
22076 : : {
22077 : 90 : return DynamicStrings_InitString ((const char *) "proper procedure", 16);
22078 : : }
22079 : 90 : else if (kind == SymbolTable_ForwardProcedure)
22080 : : {
22081 : : /* avoid dangling else. */
22082 : 24 : return DynamicStrings_InitString ((const char *) "forward procedure", 17);
22083 : : }
22084 : 66 : else if (kind == SymbolTable_DefProcedure)
22085 : : {
22086 : : /* avoid dangling else. */
22087 : 66 : return DynamicStrings_InitString ((const char *) "definition procedure", 20);
22088 : : }
22089 : 0 : M2Error_InternalError ((const char *) "unknown kind value", 18);
22090 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
22091 : : __builtin_unreachable ();
22092 : : }
22093 : :
22094 : :
22095 : : /*
22096 : : GetNthParamAnyClosest - returns the nth parameter from the order
22097 : : proper procedure, forward declaration
22098 : : or definition module procedure.
22099 : : It chooses the parameter which is closest
22100 : : in source terms to currentmodule.
22101 : : The same module will return using the order
22102 : : proper procedure, forward procedure, definition module.
22103 : : Whereas an imported procedure will choose from
22104 : : DefProcedure, ProperProcedure, ForwardProcedure.
22105 : : */
22106 : :
22107 : 625283 : extern "C" unsigned int SymbolTable_GetNthParamAnyClosest (unsigned int sym, unsigned int ParamNo, unsigned int currentmodule)
22108 : : {
22109 : 625283 : if (SymbolTable_IsUnknown (sym))
22110 : : {
22111 : 0 : M2Error_InternalError ((const char *) "/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.mod:GetNthParamAnyClosest:not expecting an unknown symbol", 131);
22112 : : }
22113 : 625283 : if ((GetOuterModuleScope (currentmodule)) == (GetOuterModuleScope (sym)))
22114 : : {
22115 : : /* Same module. */
22116 : 229691 : return GetNthParamOrdered (sym, ParamNo, SymbolTable_ProperProcedure, SymbolTable_ForwardProcedure, SymbolTable_DefProcedure);
22117 : : }
22118 : : else
22119 : : {
22120 : : /* Procedure is imported. */
22121 : 395592 : return GetNthParamOrdered (sym, ParamNo, SymbolTable_DefProcedure, SymbolTable_ProperProcedure, SymbolTable_ForwardProcedure);
22122 : : }
22123 : : /* static analysis guarentees a RETURN statement will be used before here. */
22124 : : __builtin_unreachable ();
22125 : : }
22126 : :
22127 : :
22128 : : /*
22129 : : IsConstVar - returns TRUE if sym is a const var. This is a
22130 : : constant which might be assigned to TRUE or FALSE
22131 : : depending upon the result of the quad stack control flow.
22132 : : Typically used in CONST foo = (a AND b) or similar.
22133 : : This symbol will only be assigned once with a value, but
22134 : : will appear more than once as a designator to an assignment
22135 : : in the quad table. However as the quad table is reduced
22136 : : only one assignment will remain. If after reducing quads
22137 : : two or more assignments remain, then there is an error
22138 : : as sym should not have been declared a constant.
22139 : : */
22140 : :
22141 : 150 : extern "C" bool SymbolTable_IsConstVar (unsigned int sym)
22142 : : {
22143 : 150 : SymbolTable_PtrToSymbol pSym;
22144 : :
22145 : 150 : pSym = GetPsym (sym);
22146 : 150 : return pSym->SymbolType == SymbolTable_ConstVarSym;
22147 : : /* static analysis guarentees a RETURN statement will be used before here. */
22148 : : __builtin_unreachable ();
22149 : : }
22150 : :
22151 : 15229 : extern "C" void _M2_SymbolTable_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
22152 : : {
22153 : 15229 : Init ();
22154 : 15229 : }
22155 : :
22156 : 0 : extern "C" void _M2_SymbolTable_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
22157 : : {
22158 : 0 : }
|