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 "GM2SymInit.h"
79 : : # include "GM2RTS.h"
80 : :
81 : : # define SymbolTable_NulSym 0
82 : : typedef struct SymbolTable_FamilyOperation_p SymbolTable_FamilyOperation;
83 : :
84 : : # define DebugUnknowns false
85 : : # define DebugUnknownToken false
86 : : # define UnboundedAddressName "_m2_contents"
87 : : # define UnboundedHighName "_m2_high_%d"
88 : : typedef struct SymbolTable_ProcAnyBoolean_p SymbolTable_ProcAnyBoolean;
89 : :
90 : : typedef struct SymbolTable_ProcAnyCardinal_p SymbolTable_ProcAnyCardinal;
91 : :
92 : : typedef struct SymbolTable_LRLists_a SymbolTable_LRLists;
93 : :
94 : : typedef struct SymbolTable_LRInitDesc_a SymbolTable_LRInitDesc;
95 : :
96 : : typedef struct SymbolTable_Where_r SymbolTable_Where;
97 : :
98 : : typedef struct SymbolTable_VarDecl_r SymbolTable_VarDecl;
99 : :
100 : : typedef struct SymbolTable_PackedInfo_r SymbolTable_PackedInfo;
101 : :
102 : : typedef struct SymbolTable_ModuleCtor_r SymbolTable_ModuleCtor;
103 : :
104 : : typedef struct SymbolTable_SymImportStatement_r SymbolTable_SymImportStatement;
105 : :
106 : : typedef struct SymbolTable_SymImport_r SymbolTable_SymImport;
107 : :
108 : : typedef struct SymbolTable_SymEquiv_r SymbolTable_SymEquiv;
109 : :
110 : : typedef struct SymbolTable_SymOAFamily_r SymbolTable_SymOAFamily;
111 : :
112 : : typedef struct SymbolTable_SymTuple_r SymbolTable_SymTuple;
113 : :
114 : : typedef struct SymbolTable_SymError_r SymbolTable_SymError;
115 : :
116 : : typedef struct SymbolTable_SymObject_r SymbolTable_SymObject;
117 : :
118 : : typedef struct SymbolTable_SymUndefined_r SymbolTable_SymUndefined;
119 : :
120 : : typedef struct SymbolTable_SymGnuAsm_r SymbolTable_SymGnuAsm;
121 : :
122 : : typedef struct SymbolTable_SymInterface_r SymbolTable_SymInterface;
123 : :
124 : : typedef struct SymbolTable_SymVarient_r SymbolTable_SymVarient;
125 : :
126 : : typedef struct SymbolTable_SymRecord_r SymbolTable_SymRecord;
127 : :
128 : : typedef struct SymbolTable_SymSubrange_r SymbolTable_SymSubrange;
129 : :
130 : : typedef struct SymbolTable_SymEnumeration_r SymbolTable_SymEnumeration;
131 : :
132 : : typedef struct SymbolTable_SymArray_r SymbolTable_SymArray;
133 : :
134 : : typedef struct SymbolTable_SymSubscript_r SymbolTable_SymSubscript;
135 : :
136 : : typedef struct SymbolTable_SymUnbounded_r SymbolTable_SymUnbounded;
137 : :
138 : : typedef struct SymbolTable_SymPartialUnbounded_r SymbolTable_SymPartialUnbounded;
139 : :
140 : : typedef struct SymbolTable_ProcedureDeclaration_r SymbolTable_ProcedureDeclaration;
141 : :
142 : : typedef struct SymbolTable_SymProcedure_r SymbolTable_SymProcedure;
143 : :
144 : : typedef struct SymbolTable_SymProcType_r SymbolTable_SymProcType;
145 : :
146 : : typedef struct SymbolTable_SymParam_r SymbolTable_SymParam;
147 : :
148 : : typedef struct SymbolTable_SymVarParam_r SymbolTable_SymVarParam;
149 : :
150 : : typedef struct SymbolTable_SymConstString_r SymbolTable_SymConstString;
151 : :
152 : : typedef struct SymbolTable_SymConstLit_r SymbolTable_SymConstLit;
153 : :
154 : : typedef struct SymbolTable_SymConstVar_r SymbolTable_SymConstVar;
155 : :
156 : : typedef struct SymbolTable_SymVar_r SymbolTable_SymVar;
157 : :
158 : : typedef struct SymbolTable_SymType_r SymbolTable_SymType;
159 : :
160 : : typedef struct SymbolTable_SymPointer_r SymbolTable_SymPointer;
161 : :
162 : : typedef struct SymbolTable_SymRecordField_r SymbolTable_SymRecordField;
163 : :
164 : : typedef struct SymbolTable_SymVarientField_r SymbolTable_SymVarientField;
165 : :
166 : : typedef struct SymbolTable_SymEnumerationField_r SymbolTable_SymEnumerationField;
167 : :
168 : : typedef struct SymbolTable_SymSet_r SymbolTable_SymSet;
169 : :
170 : : typedef struct SymbolTable_SymDefImp_r SymbolTable_SymDefImp;
171 : :
172 : : typedef struct SymbolTable_SymModule_r SymbolTable_SymModule;
173 : :
174 : : typedef struct SymbolTable_SymDummy_r SymbolTable_SymDummy;
175 : :
176 : : typedef struct SymbolTable_Symbol_r SymbolTable_Symbol;
177 : :
178 : : typedef struct SymbolTable_CallFrame_r SymbolTable_CallFrame;
179 : :
180 : : typedef struct SymbolTable_CheckProcedure_p SymbolTable_CheckProcedure;
181 : :
182 : : typedef SymbolTable_Symbol *SymbolTable_PtrToSymbol;
183 : :
184 : : typedef SymbolTable_CallFrame *SymbolTable_PtrToCallFrame;
185 : :
186 : : typedef struct SymbolTable__T4_r SymbolTable__T4;
187 : :
188 : : typedef SymbolTable__T4 *SymbolTable_ConstLitPoolEntry;
189 : :
190 : : typedef struct SymbolTable__T5_r SymbolTable__T5;
191 : :
192 : : typedef SymbolTable__T5 *SymbolTable_PtrToAsmConstraint;
193 : :
194 : : typedef struct SymbolTable__T6_a SymbolTable__T6;
195 : :
196 : : typedef enum {SymbolTable_m2str, SymbolTable_cstr, SymbolTable_m2nulstr, SymbolTable_cnulstr} SymbolTable_ConstStringVariant;
197 : :
198 : : 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;
199 : :
200 : : typedef bool (*SymbolTable_ProcAnyBoolean_t) (unsigned int, SymbolTable_ProcedureKind);
201 : : struct SymbolTable_ProcAnyBoolean_p { SymbolTable_ProcAnyBoolean_t proc; };
202 : :
203 : : typedef unsigned int (*SymbolTable_ProcAnyCardinal_t) (unsigned int, SymbolTable_ProcedureKind);
204 : : struct SymbolTable_ProcAnyCardinal_p { SymbolTable_ProcAnyCardinal_t proc; };
205 : :
206 : : struct SymbolTable_LRLists_a { Lists_List array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
207 : : struct SymbolTable_LRInitDesc_a { M2SymInit_InitDesc array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
208 : : struct SymbolTable_Where_r {
209 : : unsigned int DefDeclared;
210 : : unsigned int FirstUsed;
211 : : unsigned int ModDeclared;
212 : : };
213 : :
214 : : struct SymbolTable_VarDecl_r {
215 : : unsigned int FullTok;
216 : : unsigned int VarTok;
217 : : unsigned int TypeTok;
218 : : };
219 : :
220 : : struct SymbolTable_PackedInfo_r {
221 : : bool IsPacked;
222 : : unsigned int PackedEquiv;
223 : : };
224 : :
225 : : struct SymbolTable_ModuleCtor_r {
226 : : unsigned int ctor;
227 : : unsigned int init;
228 : : unsigned int fini;
229 : : unsigned int dep;
230 : : };
231 : :
232 : : struct SymbolTable_SymOAFamily_r {
233 : : unsigned int MaxDimensions;
234 : : unsigned int SimpleType;
235 : : Indexing_Index Dimensions;
236 : : };
237 : :
238 : : struct SymbolTable_SymPartialUnbounded_r {
239 : : unsigned int Type;
240 : : unsigned int NDim;
241 : : };
242 : :
243 : : struct SymbolTable_ProcedureDeclaration_r {
244 : : Lists_List ListOfParam;
245 : : bool Defined;
246 : : bool ParamDefined;
247 : : bool HasVarArgs;
248 : : bool HasOptArg;
249 : : bool IsNoReturn;
250 : : bool ReturnOptional;
251 : : unsigned int ReturnTypeTok;
252 : : unsigned int ProcedureTok;
253 : : };
254 : :
255 : : struct SymbolTable_SymDummy_r {
256 : : unsigned int NextFree;
257 : : };
258 : :
259 : : struct SymbolTable_CallFrame_r {
260 : : unsigned int Main;
261 : : unsigned int Search;
262 : : unsigned int Start;
263 : : };
264 : :
265 : : typedef void (*SymbolTable_CheckProcedure_t) (unsigned int);
266 : : struct SymbolTable_CheckProcedure_p { SymbolTable_CheckProcedure_t proc; };
267 : :
268 : : struct SymbolTable__T4_r {
269 : : unsigned int sym;
270 : : unsigned int tok;
271 : : NameKey_Name constName;
272 : : unsigned int constType;
273 : : SymbolTable_ConstLitPoolEntry next;
274 : : };
275 : :
276 : : struct SymbolTable__T5_r {
277 : : unsigned int tokpos;
278 : : NameKey_Name name;
279 : : unsigned int str;
280 : : unsigned int obj;
281 : : };
282 : :
283 : : struct SymbolTable_SymImportStatement_r {
284 : : unsigned int listNo;
285 : : Lists_List ListOfImports;
286 : : SymbolTable_Where at;
287 : : };
288 : :
289 : : struct SymbolTable_SymImport_r {
290 : : unsigned int module;
291 : : unsigned int listNo;
292 : : bool qualified;
293 : : SymbolTable_Where at;
294 : : };
295 : :
296 : : struct SymbolTable_SymEquiv_r {
297 : : SymbolTable_PackedInfo packedInfo;
298 : : unsigned int nonPacked;
299 : : };
300 : :
301 : : struct SymbolTable_SymTuple_r {
302 : : SymbolTable_Where At;
303 : : unsigned int nTuple;
304 : : Indexing_Index list;
305 : : };
306 : :
307 : : struct SymbolTable_SymError_r {
308 : : NameKey_Name name;
309 : : unsigned int Scope;
310 : : SymbolTable_Where At;
311 : : };
312 : :
313 : : struct SymbolTable_SymObject_r {
314 : : NameKey_Name name;
315 : : SymbolTable_Where At;
316 : : };
317 : :
318 : : struct SymbolTable_SymUndefined_r {
319 : : NameKey_Name name;
320 : : unsigned int oafamily;
321 : : M2Error_ErrorScope errorScope;
322 : : SymbolTable_Where At;
323 : : };
324 : :
325 : : struct SymbolTable_SymGnuAsm_r {
326 : : unsigned int String;
327 : : SymbolTable_Where At;
328 : : unsigned int Inputs;
329 : : unsigned int Outputs;
330 : : unsigned int Trashed;
331 : : bool Volatile;
332 : : bool Simple;
333 : : };
334 : :
335 : : struct SymbolTable_SymInterface_r {
336 : : Indexing_Index Parameters;
337 : : SymbolTable_Where At;
338 : : };
339 : :
340 : : struct SymbolTable_SymVarient_r {
341 : : M2ALU_PtrToValue Size;
342 : : Lists_List ListOfSons;
343 : : bool DeclPacked;
344 : : bool DeclResolved;
345 : : unsigned int Parent;
346 : : unsigned int Varient;
347 : : unsigned int tag;
348 : : unsigned int Scope;
349 : : SymbolTable_Where At;
350 : : };
351 : :
352 : : struct SymbolTable_SymRecord_r {
353 : : NameKey_Name name;
354 : : SymbolKey_SymbolTree LocalSymbols;
355 : : M2ALU_PtrToValue Size;
356 : : Lists_List ListOfSons;
357 : : unsigned int Align;
358 : : unsigned int DefaultAlign;
359 : : bool DeclPacked;
360 : : bool DeclResolved;
361 : : unsigned int oafamily;
362 : : unsigned int Parent;
363 : : unsigned int Scope;
364 : : SymbolTable_Where At;
365 : : };
366 : :
367 : : struct SymbolTable_SymSubrange_r {
368 : : NameKey_Name name;
369 : : unsigned int Low;
370 : : unsigned int High;
371 : : M2ALU_PtrToValue Size;
372 : : unsigned int Type;
373 : : unsigned int Align;
374 : : SymbolKey_SymbolTree ConstLitTree;
375 : : SymbolTable_PackedInfo packedInfo;
376 : : unsigned int oafamily;
377 : : unsigned int Scope;
378 : : SymbolTable_Where At;
379 : : };
380 : :
381 : : struct SymbolTable_SymEnumeration_r {
382 : : NameKey_Name name;
383 : : unsigned int NoOfElements;
384 : : SymbolKey_SymbolTree LocalSymbols;
385 : : Lists_List ListOfFields;
386 : : M2ALU_PtrToValue Size;
387 : : SymbolTable_PackedInfo packedInfo;
388 : : unsigned int oafamily;
389 : : unsigned int Scope;
390 : : SymbolTable_Where At;
391 : : };
392 : :
393 : : struct SymbolTable_SymArray_r {
394 : : NameKey_Name name;
395 : : unsigned int Subscript;
396 : : M2ALU_PtrToValue Size;
397 : : M2ALU_PtrToValue Offset;
398 : : unsigned int Type;
399 : : unsigned int Align;
400 : : bool Large;
401 : : unsigned int oafamily;
402 : : unsigned int Scope;
403 : : SymbolTable_Where At;
404 : : };
405 : :
406 : : struct SymbolTable_SymSubscript_r {
407 : : unsigned int Type;
408 : : M2ALU_PtrToValue Size;
409 : : M2ALU_PtrToValue Offset;
410 : : SymbolTable_Where At;
411 : : };
412 : :
413 : : struct SymbolTable_SymUnbounded_r {
414 : : unsigned int Type;
415 : : M2ALU_PtrToValue Size;
416 : : unsigned int RecordType;
417 : : unsigned int Dimensions;
418 : : unsigned int Scope;
419 : : SymbolTable_Where At;
420 : : };
421 : :
422 : : struct SymbolTable_SymProcType_r {
423 : : NameKey_Name name;
424 : : Lists_List ListOfParam;
425 : : bool HasVarArgs;
426 : : bool HasOptArg;
427 : : unsigned int OptArgInit;
428 : : unsigned int ReturnType;
429 : : bool ReturnOptional;
430 : : unsigned int ReturnTypeTok;
431 : : unsigned int Scope;
432 : : M2ALU_PtrToValue Size;
433 : : M2ALU_PtrToValue TotalParamSize;
434 : : unsigned int oafamily;
435 : : SymbolTable_Where At;
436 : : };
437 : :
438 : : struct SymbolTable_SymParam_r {
439 : : NameKey_Name name;
440 : : unsigned int Type;
441 : : bool IsUnbounded;
442 : : unsigned int ShadowVar;
443 : : SymbolTable_Where At;
444 : : };
445 : :
446 : : struct SymbolTable_SymVarParam_r {
447 : : NameKey_Name name;
448 : : unsigned int Type;
449 : : bool IsUnbounded;
450 : : unsigned int HeapVar;
451 : : unsigned int ShadowVar;
452 : : SymbolTable_Where At;
453 : : };
454 : :
455 : : struct SymbolTable_SymConstString_r {
456 : : NameKey_Name name;
457 : : NameKey_Name Contents;
458 : : unsigned int Length;
459 : : SymbolTable_ConstStringVariant StringVariant;
460 : : bool Known;
461 : : unsigned int Scope;
462 : : SymbolTable_Where At;
463 : : };
464 : :
465 : : struct SymbolTable_SymConstLit_r {
466 : : NameKey_Name name;
467 : : M2ALU_PtrToValue Value;
468 : : unsigned int Type;
469 : : bool IsSet;
470 : : bool IsConstructor;
471 : : bool IsInternal;
472 : : unsigned int FromType;
473 : : bool RangeError;
474 : : bool UnresFromType;
475 : : unsigned int Scope;
476 : : SymbolTable_Where At;
477 : : };
478 : :
479 : : struct SymbolTable_SymConstVar_r {
480 : : NameKey_Name name;
481 : : M2ALU_PtrToValue Value;
482 : : unsigned int Type;
483 : : bool IsConditional;
484 : : bool IsSet;
485 : : bool IsConstructor;
486 : : unsigned int FromType;
487 : : bool UnresFromType;
488 : : bool IsTemp;
489 : : unsigned int Scope;
490 : : SymbolTable_Where At;
491 : : };
492 : :
493 : : struct SymbolTable_SymVar_r {
494 : : NameKey_Name name;
495 : : unsigned int Type;
496 : : unsigned int BackType;
497 : : M2ALU_PtrToValue Size;
498 : : M2ALU_PtrToValue Offset;
499 : : SymbolTable_ModeOfAddr AddrMode;
500 : : unsigned int Scope;
501 : : bool AtAddress;
502 : : unsigned int Address;
503 : : bool IsComponentRef;
504 : : Indexing_Index list;
505 : : bool IsConditional;
506 : : bool IsTemp;
507 : : bool IsParam;
508 : : bool IsPointerCheck;
509 : : bool IsWritten;
510 : : bool IsSSA;
511 : : bool IsConst;
512 : : bool ArrayRef;
513 : : bool Heap;
514 : : SymbolTable_LRInitDesc InitState;
515 : : SymbolTable_VarDecl Declared;
516 : : SymbolTable_Where At;
517 : : SymbolTable_LRLists ReadUsageList;
518 : : SymbolTable_LRLists WriteUsageList;
519 : : };
520 : :
521 : : struct SymbolTable_SymType_r {
522 : : NameKey_Name name;
523 : : unsigned int Type;
524 : : bool IsHidden;
525 : : SymbolKey_SymbolTree ConstLitTree;
526 : : M2ALU_PtrToValue Size;
527 : : SymbolTable_PackedInfo packedInfo;
528 : : unsigned int oafamily;
529 : : unsigned int Align;
530 : : unsigned int Scope;
531 : : SymbolTable_Where At;
532 : : };
533 : :
534 : : struct SymbolTable_SymPointer_r {
535 : : NameKey_Name name;
536 : : unsigned int Type;
537 : : M2ALU_PtrToValue Size;
538 : : unsigned int Align;
539 : : SymbolKey_SymbolTree ConstLitTree;
540 : : unsigned int oafamily;
541 : : unsigned int Scope;
542 : : SymbolTable_Where At;
543 : : };
544 : :
545 : : struct SymbolTable_SymRecordField_r {
546 : : NameKey_Name name;
547 : : unsigned int Type;
548 : : bool Tag;
549 : : M2ALU_PtrToValue Size;
550 : : M2ALU_PtrToValue Offset;
551 : : unsigned int Parent;
552 : : unsigned int Varient;
553 : : unsigned int Align;
554 : : bool Used;
555 : : bool DeclPacked;
556 : : bool DeclResolved;
557 : : unsigned int Scope;
558 : : SymbolTable_Where At;
559 : : };
560 : :
561 : : struct SymbolTable_SymVarientField_r {
562 : : NameKey_Name name;
563 : : M2ALU_PtrToValue Size;
564 : : M2ALU_PtrToValue Offset;
565 : : unsigned int Parent;
566 : : unsigned int Varient;
567 : : Lists_List ListOfSons;
568 : : bool DeclPacked;
569 : : bool DeclResolved;
570 : : unsigned int Scope;
571 : : SymbolTable_Where At;
572 : : };
573 : :
574 : : struct SymbolTable_SymEnumerationField_r {
575 : : NameKey_Name name;
576 : : M2ALU_PtrToValue Value;
577 : : unsigned int Type;
578 : : unsigned int Scope;
579 : : SymbolTable_Where At;
580 : : };
581 : :
582 : : struct SymbolTable_SymSet_r {
583 : : NameKey_Name name;
584 : : unsigned int Type;
585 : : SymbolTable_PackedInfo packedInfo;
586 : : bool ispacked;
587 : : M2ALU_PtrToValue Size;
588 : : unsigned int oafamily;
589 : : unsigned int Scope;
590 : : SymbolTable_Where At;
591 : : };
592 : :
593 : : struct SymbolTable_SymDefImp_r {
594 : : NameKey_Name name;
595 : : NameKey_Name libname;
596 : : SymbolTable_ModuleCtor ctors;
597 : : Lists_List DefListOfDep;
598 : : Lists_List ModListOfDep;
599 : : SymbolKey_SymbolTree ExportQualifiedTree;
600 : : SymbolKey_SymbolTree ExportUnQualifiedTree;
601 : : SymbolKey_SymbolTree ExportRequest;
602 : : Lists_List IncludeList;
603 : : Lists_List DefIncludeList;
604 : : SymbolKey_SymbolTree ImportTree;
605 : : SymbolKey_SymbolTree ExportUndeclared;
606 : : SymbolKey_SymbolTree NeedToBeImplemented;
607 : : SymbolKey_SymbolTree LocalSymbols;
608 : : Lists_List EnumerationScopeList;
609 : : SymbolKey_SymbolTree NamedObjects;
610 : : SymbolKey_SymbolTree NamedImports;
611 : : SymbolKey_SymbolTree WhereImported;
612 : : unsigned int Priority;
613 : : SymbolKey_SymbolTree Unresolved;
614 : : unsigned int StartQuad;
615 : : unsigned int EndQuad;
616 : : unsigned int StartFinishQuad;
617 : : unsigned int EndFinishQuad;
618 : : tree FinallyFunction;
619 : : bool ExceptionFinally;
620 : : bool ExceptionBlock;
621 : : bool ContainsHiddenType;
622 : : bool ContainsBuiltin;
623 : : bool ForC;
624 : : bool NeedExportList;
625 : : bool ModLink;
626 : : bool DefLink;
627 : : bool Builtin;
628 : : Lists_List ListOfVars;
629 : : Lists_List ListOfProcs;
630 : : Lists_List ListOfModules;
631 : : M2Error_ErrorScope errorScope;
632 : : SymbolTable_Where At;
633 : : };
634 : :
635 : : struct SymbolTable_SymModule_r {
636 : : NameKey_Name name;
637 : : NameKey_Name libname;
638 : : SymbolTable_ModuleCtor ctors;
639 : : Lists_List ModListOfDep;
640 : : SymbolKey_SymbolTree LocalSymbols;
641 : : SymbolKey_SymbolTree ExportTree;
642 : : Lists_List IncludeList;
643 : : SymbolKey_SymbolTree ImportTree;
644 : : SymbolKey_SymbolTree ExportUndeclared;
645 : : Lists_List EnumerationScopeList;
646 : : SymbolKey_SymbolTree NamedObjects;
647 : : SymbolKey_SymbolTree NamedImports;
648 : : SymbolKey_SymbolTree WhereImported;
649 : : unsigned int Scope;
650 : : unsigned int Priority;
651 : : SymbolKey_SymbolTree Unresolved;
652 : : unsigned int StartQuad;
653 : : unsigned int EndQuad;
654 : : unsigned int StartFinishQuad;
655 : : unsigned int EndFinishQuad;
656 : : tree FinallyFunction;
657 : : bool ExceptionFinally;
658 : : bool ExceptionBlock;
659 : : bool ModLink;
660 : : bool Builtin;
661 : : Lists_List ListOfVars;
662 : : Lists_List ListOfProcs;
663 : : Lists_List ListOfModules;
664 : : M2Error_ErrorScope errorScope;
665 : : SymbolTable_Where At;
666 : : };
667 : :
668 : : struct SymbolTable__T6_a { SymbolTable_ProcedureDeclaration array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure+1]; };
669 : : struct SymbolTable_SymProcedure_r {
670 : : NameKey_Name name;
671 : : SymbolTable__T6 Decl;
672 : : unsigned int OptArgInit;
673 : : bool IsExtern;
674 : : bool IsPublic;
675 : : bool IsCtor;
676 : : bool IsMonoName;
677 : : bool BuildProcType;
678 : : SymbolKey_SymbolTree Unresolved;
679 : : unsigned int ScopeQuad;
680 : : unsigned int StartQuad;
681 : : unsigned int EndQuad;
682 : : bool Reachable;
683 : : bool SavePriority;
684 : : unsigned int ReturnType;
685 : : unsigned int ProcedureType;
686 : : bool IsBuiltin;
687 : : NameKey_Name BuiltinName;
688 : : bool IsInline;
689 : : SymbolKey_SymbolTree LocalSymbols;
690 : : Lists_List EnumerationScopeList;
691 : : Lists_List ListOfVars;
692 : : Lists_List ListOfProcs;
693 : : SymbolKey_SymbolTree NamedObjects;
694 : : M2ALU_PtrToValue Size;
695 : : M2ALU_PtrToValue TotalParamSize;
696 : : bool ExceptionFinally;
697 : : bool ExceptionBlock;
698 : : unsigned int Scope;
699 : : M2Error_ErrorScope errorScope;
700 : : Lists_List ListOfModules;
701 : : unsigned int Begin;
702 : : unsigned int End;
703 : : SymbolTable_Where At;
704 : : };
705 : :
706 : : struct SymbolTable_Symbol_r {
707 : : SymbolTable_TypeOfSymbol SymbolType; /* case tag */
708 : : union {
709 : : SymbolTable_SymOAFamily OAFamily;
710 : : SymbolTable_SymObject Object;
711 : : SymbolTable_SymEquiv Equiv;
712 : : SymbolTable_SymRecord Record;
713 : : SymbolTable_SymVarient Varient;
714 : : SymbolTable_SymVar Var;
715 : : SymbolTable_SymEnumeration Enumeration;
716 : : SymbolTable_SymSubrange Subrange;
717 : : SymbolTable_SymSubscript Subscript;
718 : : SymbolTable_SymArray Array;
719 : : SymbolTable_SymUnbounded Unbounded;
720 : : SymbolTable_SymPartialUnbounded PartialUnbounded;
721 : : SymbolTable_SymConstVar ConstVar;
722 : : SymbolTable_SymConstLit ConstLit;
723 : : SymbolTable_SymConstString ConstString;
724 : : SymbolTable_SymVarParam VarParam;
725 : : SymbolTable_SymParam Param;
726 : : SymbolTable_SymError Error;
727 : : SymbolTable_SymUndefined Undefined;
728 : : SymbolTable_SymType Type;
729 : : SymbolTable_SymPointer Pointer;
730 : : SymbolTable_SymRecordField RecordField;
731 : : SymbolTable_SymVarientField VarientField;
732 : : SymbolTable_SymEnumerationField EnumerationField;
733 : : SymbolTable_SymDefImp DefImp;
734 : : SymbolTable_SymModule Module;
735 : : SymbolTable_SymSet Set;
736 : : SymbolTable_SymProcedure Procedure;
737 : : SymbolTable_SymProcType ProcType;
738 : : SymbolTable_SymImportStatement ImportStatement;
739 : : SymbolTable_SymImport Import;
740 : : SymbolTable_SymGnuAsm GnuAsm;
741 : : SymbolTable_SymInterface Interface;
742 : : SymbolTable_SymTuple Tuple;
743 : : SymbolTable_SymDummy Dummy;
744 : : };
745 : : };
746 : :
747 : : static Indexing_Index Symbols;
748 : : static Indexing_Index ScopeCallFrame;
749 : : static unsigned int FreeSymbol;
750 : : static SymbolKey_SymbolTree DefModuleTree;
751 : : static SymbolKey_SymbolTree ModuleTree;
752 : : static unsigned int CurrentModule;
753 : : static unsigned int MainModule;
754 : : static unsigned int FileModule;
755 : : static unsigned int ScopePtr;
756 : : static unsigned int BaseScopePtr;
757 : : static unsigned int BaseModule;
758 : : static unsigned int TemporaryNo;
759 : : static M2Error_Error CurrentError;
760 : : static Lists_List AddressTypes;
761 : : static Lists_List UnresolvedConstructorType;
762 : : static unsigned int AnonymousName;
763 : : static Sets_Set ReportedUnknowns;
764 : : static SymbolKey_SymbolTree ConstLitPoolTree;
765 : : static Indexing_Index ConstLitArray;
766 : : static unsigned int BreakSym;
767 : : static unsigned int recordConsist;
768 : : static DynamicStrings_String ListifySentance;
769 : : static unsigned int ListifyTotal;
770 : : static unsigned int ListifyWordCount;
771 : : static unsigned int ExportRequestModule;
772 : : static unsigned int ResolveModule;
773 : :
774 : : /*
775 : : FinalSymbol - returns the highest number symbol used.
776 : : */
777 : :
778 : : extern "C" unsigned int SymbolTable_FinalSymbol (void);
779 : :
780 : : /*
781 : : MakeComponentRecord - make a temporary which will be used to reference and field
782 : : (or sub field) of record.
783 : : */
784 : :
785 : : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record);
786 : :
787 : : /*
788 : : MakeComponentRef - use, sym, to reference, field, sym is returned.
789 : : */
790 : :
791 : : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field);
792 : :
793 : : /*
794 : : IsComponent - returns TRUE if symbol, sym, is a temporary and a component
795 : : reference.
796 : : */
797 : :
798 : : extern "C" bool SymbolTable_IsComponent (unsigned int sym);
799 : :
800 : : /*
801 : : MakeTemporary - Makes a new temporary variable at the highest real scope.
802 : : The addressing mode of the temporary is set to NoValue.
803 : : */
804 : :
805 : : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode);
806 : :
807 : : /*
808 : : MakeTemporaryFromExpression - makes a new temporary variable at the
809 : : highest real scope. The addressing
810 : : mode of the temporary is set and the
811 : : type is determined by expressions, e.
812 : : */
813 : :
814 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode);
815 : :
816 : : /*
817 : : MakeTemporaryFromExpressions - makes a new temporary variable at the
818 : : highest real scope. The addressing
819 : : mode of the temporary is set and the
820 : : type is determined by expressions,
821 : : e1 and e2.
822 : : */
823 : :
824 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode);
825 : :
826 : : /*
827 : : PutMode - Puts the addressing mode, SymMode, into symbol Sym.
828 : : The mode may only be altered if the mode
829 : : is None.
830 : : */
831 : :
832 : : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode);
833 : :
834 : : /*
835 : : GetMode - Returns the addressing mode of a symbol.
836 : : */
837 : :
838 : : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym);
839 : :
840 : : /*
841 : : StartScope - starts a block scope at Sym. Transparent determines
842 : : whether the search for a symbol will look at the
843 : : previous ScopeCallFrame if Sym does not contain the
844 : : symbol that GetSym is searching.
845 : :
846 : : WITH statements are partially implemented by calling
847 : : StartScope. Therefore we must retain the old Main from
848 : : the previous ScopePtr when a record is added to the scope
849 : : stack. (Main contains the symbol where all identifiers
850 : : should be added.)
851 : : */
852 : :
853 : : extern "C" void SymbolTable_StartScope (unsigned int Sym);
854 : :
855 : : /*
856 : : EndScope - ends a block scope started by StartScope. The current
857 : : head of the symbol scope reverts back to the symbol
858 : : which was the Head of the symbol scope before the
859 : : last StartScope was called.
860 : : */
861 : :
862 : : extern "C" void SymbolTable_EndScope (void);
863 : :
864 : : /*
865 : : PseudoScope - starts a pseudo scope at Sym.
866 : : We always connect parent up to the last scope,
867 : : to determine the transparancy of a scope we call
868 : : TransparentScope.
869 : :
870 : : A Pseudo scope has no end block,
871 : : but is terminated when the next EndScope is used.
872 : : The function of the pseudo scope is to provide an
873 : : automatic mechanism to solve enumeration types.
874 : : A declared enumeration type is a Pseudo scope and
875 : : identifiers used with the name of an enumeration
876 : : type field will find the enumeration symbol by
877 : : the scoping algorithm.
878 : : */
879 : :
880 : : extern "C" void SymbolTable_PseudoScope (unsigned int Sym);
881 : :
882 : : /*
883 : : GetCurrentScope - returns the symbol who is responsible for the current
884 : : scope. Note that it ignore pseudo scopes.
885 : : */
886 : :
887 : : extern "C" unsigned int SymbolTable_GetCurrentScope (void);
888 : :
889 : : /*
890 : : IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
891 : : */
892 : :
893 : : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym);
894 : :
895 : : /*
896 : : SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
897 : : This Sym must represent the module name of the
898 : : file currently being compiled.
899 : : */
900 : :
901 : : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym);
902 : :
903 : : /*
904 : : SetFileModule - Used to set the FileModule to a symbol, Sym.
905 : : This Sym must represent the current program module
906 : : file which is being parsed.
907 : : */
908 : :
909 : : extern "C" void SymbolTable_SetFileModule (unsigned int Sym);
910 : :
911 : : /*
912 : : SetMainModule - Used to set the MainModule to a symbol, Sym.
913 : : This Sym must represent the main module which was
914 : : envoked by the user to be compiled.
915 : : */
916 : :
917 : : extern "C" void SymbolTable_SetMainModule (unsigned int Sym);
918 : :
919 : : /*
920 : : CheckAnonymous - checks to see whether the name is NulName and if so
921 : : it creates a unique anonymous name.
922 : : */
923 : :
924 : : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name);
925 : :
926 : : /*
927 : : IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
928 : : or no name.
929 : : */
930 : :
931 : : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym);
932 : :
933 : : /*
934 : : NoOfVariables - returns the number of variables in scope. The scope maybe
935 : : a procedure, module or defimp scope.
936 : : */
937 : :
938 : : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope);
939 : :
940 : : /*
941 : : MakeModule - creates a module sym with ModuleName. It returns the
942 : : symbol index.
943 : : */
944 : :
945 : : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName);
946 : :
947 : : /*
948 : : MakeDefImp - creates a definition and implementation module sym
949 : : with name DefImpName. It returns the symbol index.
950 : : */
951 : :
952 : : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName);
953 : :
954 : : /*
955 : : MakeInnerModule - creates an inner module sym with ModuleName. It returns the
956 : : symbol index.
957 : : */
958 : :
959 : : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName);
960 : :
961 : : /*
962 : : MakeProcedure - creates a procedure sym with name. It returns
963 : : the symbol index.
964 : : */
965 : :
966 : : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName);
967 : :
968 : : /*
969 : : MakeProcedureCtorExtern - creates an extern ctor procedure
970 : : */
971 : :
972 : : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename);
973 : :
974 : : /*
975 : : PutLibName - places libname into defimp or module sym.
976 : : */
977 : :
978 : : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname);
979 : :
980 : : /*
981 : : GetLibName - returns libname associated with a defimp or module sym.
982 : : */
983 : :
984 : : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym);
985 : :
986 : : /*
987 : : PutMonoName - changes the IsMonoName boolean inside the procedure.
988 : : */
989 : :
990 : : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value);
991 : :
992 : : /*
993 : : IsMonoName - returns the public boolean associated with a procedure.
994 : : */
995 : :
996 : : extern "C" bool SymbolTable_IsMonoName (unsigned int sym);
997 : :
998 : : /*
999 : : PutExtern - changes the extern boolean inside the procedure.
1000 : : */
1001 : :
1002 : : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value);
1003 : :
1004 : : /*
1005 : : IsExtern - returns the public boolean associated with a procedure.
1006 : : */
1007 : :
1008 : : extern "C" bool SymbolTable_IsExtern (unsigned int sym);
1009 : :
1010 : : /*
1011 : : PutPublic - changes the public boolean inside the procedure.
1012 : : */
1013 : :
1014 : : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value);
1015 : :
1016 : : /*
1017 : : IsPublic - returns the public boolean associated with a procedure.
1018 : : */
1019 : :
1020 : : extern "C" bool SymbolTable_IsPublic (unsigned int sym);
1021 : :
1022 : : /*
1023 : : PutCtor - changes the ctor boolean inside the procedure.
1024 : : */
1025 : :
1026 : : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value);
1027 : :
1028 : : /*
1029 : : IsCtor - returns the ctor boolean associated with a procedure.
1030 : : */
1031 : :
1032 : : extern "C" bool SymbolTable_IsCtor (unsigned int sym);
1033 : :
1034 : : /*
1035 : : GetModuleCtors - mod can be a DefImp or Module symbol. ctor, init and fini
1036 : : are assigned for this module. An inner module ctor value will
1037 : : be NulSym.
1038 : : */
1039 : :
1040 : : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep);
1041 : :
1042 : : /*
1043 : : MakeModuleCtor - for a defimp or module symbol create all the ctor
1044 : : related procedures.
1045 : : */
1046 : :
1047 : : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym);
1048 : :
1049 : : /*
1050 : : PutModuleCtorExtern - for every ctor related procedure in module sym.
1051 : : Make it external. It will create any missing
1052 : : init/fini procedures but not any missing dep/ctor
1053 : : procedures.
1054 : : */
1055 : :
1056 : : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external);
1057 : :
1058 : : /*
1059 : : PutVarHeap - assigns ArrayRef field with value.
1060 : : */
1061 : :
1062 : : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value);
1063 : :
1064 : : /*
1065 : : IsVarHeap - returns ArrayRef field value.
1066 : : */
1067 : :
1068 : : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym);
1069 : :
1070 : : /*
1071 : : MakeVar - creates a variable sym with VarName. It returns the
1072 : : symbol index.
1073 : : */
1074 : :
1075 : : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName);
1076 : :
1077 : : /*
1078 : : PutVarConditional - assign IsConditional to value.
1079 : : */
1080 : :
1081 : : extern "C" void SymbolTable_PutVarConditional (unsigned int sym, bool value);
1082 : :
1083 : : /*
1084 : : IsVarConditional - return TRUE if the symbol is a var symbol
1085 : : containing the result of a boolean conditional.
1086 : : */
1087 : :
1088 : : extern "C" bool SymbolTable_IsVarConditional (unsigned int sym);
1089 : :
1090 : : /*
1091 : : MakeRecord - makes a Record symbol with name RecordName.
1092 : : */
1093 : :
1094 : : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName);
1095 : :
1096 : : /*
1097 : : MakeVarient - creates a new symbol, a varient symbol for record or varient field
1098 : : symbol, RecOrVarFieldSym.
1099 : : */
1100 : :
1101 : : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym);
1102 : :
1103 : : /*
1104 : : MakeFieldVarient - returns a FieldVarient symbol which has been
1105 : : assigned to the Varient symbol, Sym.
1106 : : */
1107 : :
1108 : : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym);
1109 : :
1110 : : /*
1111 : : MakeEnumeration - places a new symbol in the current scope, the symbol
1112 : : is an enumeration symbol. The symbol index is returned.
1113 : : */
1114 : :
1115 : : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName);
1116 : :
1117 : : /*
1118 : : MakeType - makes a type symbol with name TypeName.
1119 : : */
1120 : :
1121 : : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName);
1122 : :
1123 : : /*
1124 : : MakeHiddenType - makes a type symbol that is hidden from the
1125 : : definition module.
1126 : : This symbol is placed into the UnImplemented list of
1127 : : the definition/implementation module.
1128 : : The type will be filled in when the implementation module
1129 : : is reached.
1130 : : */
1131 : :
1132 : : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName);
1133 : :
1134 : : /*
1135 : : MakeConstant - create a constant cardinal and return the symbol.
1136 : : */
1137 : :
1138 : : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value);
1139 : :
1140 : : /*
1141 : : MakeConstLit - returns a constant literal of type, constType, with a constName,
1142 : : at location, tok.
1143 : : */
1144 : :
1145 : : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
1146 : :
1147 : : /*
1148 : : MakeConstVar - makes a ConstVar type with
1149 : : name ConstVarName.
1150 : : */
1151 : :
1152 : : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName);
1153 : :
1154 : : /*
1155 : : MakeConstString - create a string constant in the symboltable.
1156 : : */
1157 : :
1158 : : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName);
1159 : :
1160 : : /*
1161 : : MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
1162 : : If known is TRUE then name is assigned to the contents
1163 : : and the escape sequences will be converted into characters.
1164 : : */
1165 : :
1166 : : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known);
1167 : :
1168 : : /*
1169 : : MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
1170 : : If known is TRUE then name is assigned to the contents
1171 : : however the escape sequences are not converted into characters.
1172 : : */
1173 : :
1174 : : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known);
1175 : :
1176 : : /*
1177 : : PutConstStringKnown - if sym is a constvar then convert it into a conststring.
1178 : : If known is FALSE then contents is ignored and NulName is
1179 : : stored. If escape is TRUE then the contents will have
1180 : : any escape sequences converted into single characters.
1181 : : */
1182 : :
1183 : : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known);
1184 : :
1185 : : /*
1186 : : CopyConstString - copies string contents from expr to des
1187 : : and retain the kind of string.
1188 : : */
1189 : :
1190 : : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr);
1191 : :
1192 : : /*
1193 : : IsConstStringKnown - returns TRUE if sym is a const string
1194 : : and the contents are known.
1195 : : */
1196 : :
1197 : : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym);
1198 : :
1199 : : /*
1200 : : IsConstStringM2 - returns whether this conststring is a
1201 : : Modula-2 string.
1202 : : */
1203 : :
1204 : : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym);
1205 : :
1206 : : /*
1207 : : IsConstStringC - returns whether this conststring is a C style string
1208 : : which will have any escape translated.
1209 : : */
1210 : :
1211 : : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym);
1212 : :
1213 : : /*
1214 : : IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
1215 : : contains a nul terminator.
1216 : : */
1217 : :
1218 : : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym);
1219 : :
1220 : : /*
1221 : : IsConstStringCnul - returns whether this conststring is a C style string
1222 : : which will have any escape translated and also contains
1223 : : a nul terminator.
1224 : : */
1225 : :
1226 : : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym);
1227 : :
1228 : : /*
1229 : : MakeSubrange - makes a new symbol into a subrange type with
1230 : : name SubrangeName.
1231 : : */
1232 : :
1233 : : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName);
1234 : :
1235 : : /*
1236 : : MakeSet - makes a set Symbol with name, SetName.
1237 : : */
1238 : :
1239 : : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName);
1240 : :
1241 : : /*
1242 : : MakeArray - makes an Array symbol with name ArrayName.
1243 : : */
1244 : :
1245 : : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName);
1246 : :
1247 : : /*
1248 : : PutArrayLarge - indicates that this is a large array in which case
1249 : : the interface to gcc maps this array from 0..high-low,
1250 : : using an integer indice.
1251 : : */
1252 : :
1253 : : extern "C" void SymbolTable_PutArrayLarge (unsigned int array);
1254 : :
1255 : : /*
1256 : : IsArrayLarge - returns TRUE if we need to treat this as a large array.
1257 : : */
1258 : :
1259 : : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array);
1260 : :
1261 : : /*
1262 : : PutPriority - places a interrupt, priority, value into module, module.
1263 : : */
1264 : :
1265 : : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority);
1266 : :
1267 : : /*
1268 : : GetPriority - returns the interrupt priority which was assigned to
1269 : : module, module.
1270 : : */
1271 : :
1272 : : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module);
1273 : :
1274 : : /*
1275 : : PutNeedSavePriority - set a boolean flag indicating that this procedure
1276 : : needs to save and restore interrupts.
1277 : : */
1278 : :
1279 : : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym);
1280 : :
1281 : : /*
1282 : : GetNeedSavePriority - returns the boolean flag indicating whether this procedure
1283 : : needs to save and restore interrupts.
1284 : : */
1285 : :
1286 : : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym);
1287 : :
1288 : : /*
1289 : : PutVariableAtAddress - determines that a variable, sym, is declared at
1290 : : a specific address.
1291 : : */
1292 : :
1293 : : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address);
1294 : :
1295 : : /*
1296 : : GetVariableAtAddress - returns the address at which variable, sym, is declared.
1297 : : */
1298 : :
1299 : : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym);
1300 : :
1301 : : /*
1302 : : IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
1303 : : a specific address.
1304 : : */
1305 : :
1306 : : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym);
1307 : :
1308 : : /*
1309 : : PutVariableSSA - assigns value to the SSA field within variable sym.
1310 : : */
1311 : :
1312 : : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value);
1313 : :
1314 : : /*
1315 : : IsVariableSSA - returns TRUE if variable is known to be a SSA.
1316 : : */
1317 : :
1318 : : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym);
1319 : :
1320 : : /*
1321 : : PutVarConst - sets the IsConst field to value indicating the variable is read only.
1322 : : */
1323 : :
1324 : : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value);
1325 : :
1326 : : /*
1327 : : MakeGnuAsm - create a GnuAsm symbol.
1328 : : */
1329 : :
1330 : : extern "C" unsigned int SymbolTable_MakeGnuAsm (void);
1331 : :
1332 : : /*
1333 : : PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
1334 : : */
1335 : :
1336 : : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string);
1337 : :
1338 : : /*
1339 : : PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
1340 : : */
1341 : :
1342 : : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out);
1343 : :
1344 : : /*
1345 : : PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
1346 : : */
1347 : :
1348 : : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in);
1349 : :
1350 : : /*
1351 : : PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
1352 : : */
1353 : :
1354 : : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash);
1355 : :
1356 : : /*
1357 : : GetGnuAsm - returns the string symbol, representing the instruction textual
1358 : : of the GnuAsm symbol. It will return a ConstString.
1359 : : */
1360 : :
1361 : : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym);
1362 : :
1363 : : /*
1364 : : GetGnuAsmInput - returns the input list of registers.
1365 : : */
1366 : :
1367 : : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym);
1368 : :
1369 : : /*
1370 : : GetGnuAsmOutput - returns the output list of registers.
1371 : : */
1372 : :
1373 : : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym);
1374 : :
1375 : : /*
1376 : : GetGnuAsmTrash - returns the list of trashed registers.
1377 : : */
1378 : :
1379 : : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym);
1380 : :
1381 : : /*
1382 : : PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
1383 : : */
1384 : :
1385 : : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym);
1386 : :
1387 : : /*
1388 : : PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
1389 : : */
1390 : :
1391 : : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym);
1392 : :
1393 : : /*
1394 : : MakeRegInterface - creates and returns a register interface symbol.
1395 : : */
1396 : :
1397 : : extern "C" unsigned int SymbolTable_MakeRegInterface (void);
1398 : :
1399 : : /*
1400 : : PutRegInterface - places a, name, string, and, object, into the interface array,
1401 : : sym, at position, i.
1402 : : The string symbol will either be a register name or a constraint.
1403 : : The object is an optional Modula-2 variable or constant symbol.
1404 : : read and write are the quadruple numbers representing any read
1405 : : or write operation.
1406 : : */
1407 : :
1408 : : 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_);
1409 : :
1410 : : /*
1411 : : GetRegInterface - gets a, name, string, and, object, from the interface array,
1412 : : sym, from position, i.
1413 : : */
1414 : :
1415 : : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object);
1416 : :
1417 : : /*
1418 : : GetModule - Returns the Module symbol for the module with name, name.
1419 : : */
1420 : :
1421 : : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name);
1422 : :
1423 : : /*
1424 : : GetCurrentModule - returns the current module Sym that is being
1425 : : compiled.
1426 : : */
1427 : :
1428 : : extern "C" unsigned int SymbolTable_GetCurrentModule (void);
1429 : :
1430 : : /*
1431 : : GetFileModule - returns the FileModule symbol that was requested by
1432 : : the user to be compiled.
1433 : : */
1434 : :
1435 : : extern "C" unsigned int SymbolTable_GetFileModule (void);
1436 : :
1437 : : /*
1438 : : GetBaseModule - returns the base module symbol that contains Modula-2
1439 : : base types, procedures and functions.
1440 : : */
1441 : :
1442 : : extern "C" unsigned int SymbolTable_GetBaseModule (void);
1443 : :
1444 : : /*
1445 : : GetMainModule - returns the main module symbol that was requested by
1446 : : the user to be compiled.
1447 : : */
1448 : :
1449 : : extern "C" unsigned int SymbolTable_GetMainModule (void);
1450 : :
1451 : : /*
1452 : : GetCurrentModuleScope - returns the module symbol which forms the
1453 : : current (possibly inner most) module.
1454 : : */
1455 : :
1456 : : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void);
1457 : :
1458 : : /*
1459 : : GetLastModuleScope - returns the last module scope encountered,
1460 : : the module scope before the Current Module Scope.
1461 : : */
1462 : :
1463 : : extern "C" unsigned int SymbolTable_GetLastModuleScope (void);
1464 : :
1465 : : /*
1466 : : AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
1467 : : ModSym.
1468 : : */
1469 : :
1470 : : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym);
1471 : :
1472 : : /*
1473 : : GetType - Returns the symbol that is the TYPE symbol to Sym.
1474 : : If zero is returned then we assume type unknown.
1475 : : */
1476 : :
1477 : : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym);
1478 : :
1479 : : /*
1480 : : SkipType - if sym is a TYPE foo = bar
1481 : : then call SkipType(bar)
1482 : : else return sym
1483 : :
1484 : : it does not skip over hidden types.
1485 : : */
1486 : :
1487 : : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym);
1488 : :
1489 : : /*
1490 : : SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
1491 : : sym is declared as a subrange of bar
1492 : : then call SkipTypeAndSubrange(bar)
1493 : : else return sym
1494 : :
1495 : : it does not skip over hidden types.
1496 : : */
1497 : :
1498 : : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym);
1499 : :
1500 : : /*
1501 : : GetLowestType - Returns the lowest type in the type chain of
1502 : : symbol Sym.
1503 : : If NulSym is returned then we assume type unknown or
1504 : : you have reqested the type of a base type.
1505 : : */
1506 : :
1507 : : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym);
1508 : :
1509 : : /*
1510 : : GetLType - get lowest type. It returns the lowest type
1511 : : of symbol, sym. It skips over type equivalences.
1512 : : It will not skip over base types.
1513 : : */
1514 : :
1515 : : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym);
1516 : :
1517 : : /*
1518 : : GetSType - get source type. It returns the type closest
1519 : : to the object. It does not skip over type
1520 : : equivalences. It will skip over base types.
1521 : : */
1522 : :
1523 : : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym);
1524 : :
1525 : : /*
1526 : : GetDType - get gcc declared type. It returns the type
1527 : : of the object which is declared to GCC.
1528 : : It does skip over type equivalences but only
1529 : : if they do not contain a user alignment.
1530 : : It does not skip over hidden types.
1531 : : It does not skip over base types.
1532 : : */
1533 : :
1534 : : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym);
1535 : :
1536 : : /*
1537 : : GetTypeMode - return the type of sym, it returns Address is the
1538 : : symbol is a LValue.
1539 : : */
1540 : :
1541 : : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym);
1542 : :
1543 : : /*
1544 : : GetSym - searches the current scope (and previous scopes if the
1545 : : scope tranparent allows) for a symbol with name.
1546 : : */
1547 : :
1548 : : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name);
1549 : :
1550 : : /*
1551 : : GetDeclareSym - searches for a symbol with a name SymName in the
1552 : : current and previous scopes.
1553 : : If the symbol is found then it is returned
1554 : : else an unknown symbol is returned.
1555 : : This procedure assumes that SymName is being
1556 : : declared at this point and therefore it does
1557 : : not examine the base scope (for pervasive
1558 : : identifiers).
1559 : : */
1560 : :
1561 : : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName);
1562 : :
1563 : : /*
1564 : : GetLocalSym - only searches the scope Sym for a symbol with name
1565 : : and returns the index to the symbol.
1566 : : */
1567 : :
1568 : : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name);
1569 : :
1570 : : /*
1571 : : GetRecord - fetches the record symbol from the parent of Sym.
1572 : : Sym maybe a varient symbol in which case its parent is searched
1573 : : etc.
1574 : : */
1575 : :
1576 : : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym);
1577 : :
1578 : : /*
1579 : : FromModuleGetSym - attempts to find a symbol of name, n, in the
1580 : : module, mod, scope. An unknown symbol is created
1581 : : at token position tok if necessary.
1582 : : */
1583 : :
1584 : : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod);
1585 : :
1586 : : /*
1587 : : GetNth - returns the n th symbol in the list associated with the scope
1588 : : of Sym. Sym may be a Module, DefImp, Procedure, Record or
1589 : : Enumeration symbol.
1590 : : */
1591 : :
1592 : : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n);
1593 : :
1594 : : /*
1595 : : GetNthParam - returns the n th parameter of a procedure Sym.
1596 : : */
1597 : :
1598 : : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
1599 : :
1600 : : /*
1601 : : GetVarScope - returns the symbol which is the scope of variable Sym.
1602 : : ie a Module, DefImp or Procedure Symbol.
1603 : : */
1604 : :
1605 : : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym);
1606 : :
1607 : : /*
1608 : : GetSubrange - returns HighSym and LowSym - two constants which make up the
1609 : : subrange.
1610 : : */
1611 : :
1612 : : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym);
1613 : :
1614 : : /*
1615 : : GetParam - returns the ParamNo parameter from procedure ProcSym
1616 : : */
1617 : :
1618 : : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo);
1619 : :
1620 : : /*
1621 : : GetString - returns the contents of the string symbol sym, note that
1622 : : this is not the same as GetName (unless it was a literal).
1623 : : */
1624 : :
1625 : : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym);
1626 : :
1627 : : /*
1628 : : GetStringLength - returns the length of the string symbol Sym.
1629 : : */
1630 : :
1631 : : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym);
1632 : :
1633 : : /*
1634 : : GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
1635 : : */
1636 : :
1637 : : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym);
1638 : :
1639 : : /*
1640 : : PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
1641 : : */
1642 : :
1643 : : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name);
1644 : :
1645 : : /*
1646 : : IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
1647 : : */
1648 : :
1649 : : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym);
1650 : :
1651 : : /*
1652 : : PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
1653 : : */
1654 : :
1655 : : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym);
1656 : : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym);
1657 : :
1658 : : /*
1659 : : PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
1660 : : sym, indicating that this block as an EXCEPT
1661 : : statement sequence.
1662 : : */
1663 : :
1664 : : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym);
1665 : :
1666 : : /*
1667 : : HasExceptionBlock - returns a BOOLEAN determining whether
1668 : : module/procedure/defimp, sym, has
1669 : : an EXCEPT statement sequence.
1670 : : */
1671 : :
1672 : : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym);
1673 : :
1674 : : /*
1675 : : PutExceptionFinally - sets a BOOLEAN in block module/defimp,
1676 : : sym, indicating that this FINALLY block
1677 : : as an EXCEPT statement sequence.
1678 : : */
1679 : :
1680 : : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym);
1681 : :
1682 : : /*
1683 : : HasExceptionFinally - returns a BOOLEAN determining whether
1684 : : module/defimp, sym, has
1685 : : an EXCEPT statement sequence.
1686 : : */
1687 : :
1688 : : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym);
1689 : :
1690 : : /*
1691 : : PutVar - gives the VarSym symbol Sym a type Type.
1692 : : */
1693 : :
1694 : : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType);
1695 : :
1696 : : /*
1697 : : PutVarTok - gives the VarSym symbol Sym a type Type at typetok.
1698 : : */
1699 : :
1700 : : extern "C" void SymbolTable_PutVarTok (unsigned int Sym, unsigned int VarType, unsigned int typetok);
1701 : :
1702 : : /*
1703 : : PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
1704 : : The variable must be a LeftValue.
1705 : : */
1706 : :
1707 : : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType);
1708 : :
1709 : : /*
1710 : : GetVarBackEndType - returns the back end type if specified.
1711 : : */
1712 : :
1713 : : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym);
1714 : :
1715 : : /*
1716 : : PutVarPointerCheck - marks variable, sym, as requiring (or not
1717 : : depending upon the, value), a NIL pointer check
1718 : : when this symbol is dereferenced.
1719 : : */
1720 : :
1721 : : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value);
1722 : :
1723 : : /*
1724 : : GetVarPointerCheck - returns TRUE if this symbol is a variable and
1725 : : has been marked as needing a pointer via NIL check.
1726 : : */
1727 : :
1728 : : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym);
1729 : :
1730 : : /*
1731 : : PutVarWritten - marks variable, sym, as being written to (or not
1732 : : depending upon the, value).
1733 : : */
1734 : :
1735 : : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value);
1736 : :
1737 : : /*
1738 : : GetVarWritten - returns TRUE if this symbol is a variable and
1739 : : has been marked as being written.
1740 : : */
1741 : :
1742 : : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym);
1743 : :
1744 : : /*
1745 : : PutConst - gives the constant symbol Sym a type ConstType.
1746 : : */
1747 : :
1748 : : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType);
1749 : :
1750 : : /*
1751 : : PutConstSet - informs the const var symbol, sym, that it is or will contain
1752 : : a set value.
1753 : : */
1754 : :
1755 : : extern "C" void SymbolTable_PutConstSet (unsigned int Sym);
1756 : :
1757 : : /*
1758 : : IsConstSet - returns TRUE if the constant is declared as a set.
1759 : : */
1760 : :
1761 : : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym);
1762 : :
1763 : : /*
1764 : : PutConstructor - informs the const var symbol, sym, that it is or
1765 : : will contain a constructor (record, set or array)
1766 : : value.
1767 : : */
1768 : :
1769 : : extern "C" void SymbolTable_PutConstructor (unsigned int Sym);
1770 : :
1771 : : /*
1772 : : PutConstructorFrom - sets the from type field in constructor,
1773 : : Sym, to, from.
1774 : : */
1775 : :
1776 : : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from);
1777 : :
1778 : : /*
1779 : : PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
1780 : : VarSym is a optional varient symbol which can be returned
1781 : : by a call to GetVarient(fieldsymbol). The created field
1782 : : is returned.
1783 : : */
1784 : :
1785 : : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym);
1786 : :
1787 : : /*
1788 : : PutFieldVarient - places the field varient, Field, as a brother to, the
1789 : : varient symbol, sym, and also tells Field that its varient
1790 : : parent is Sym.
1791 : : */
1792 : :
1793 : : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym);
1794 : :
1795 : : /*
1796 : : GetVarient - returns the varient symbol associated with the
1797 : : record or varient field symbol, Field.
1798 : : */
1799 : :
1800 : : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field);
1801 : :
1802 : : /*
1803 : : IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
1804 : : a varient tag.
1805 : : */
1806 : :
1807 : : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym);
1808 : :
1809 : : /*
1810 : : IsEmptyFieldVarient - returns TRUE if the field variant has
1811 : : no fields. This will occur then the
1812 : : compiler constructs 'else end' variants.
1813 : : */
1814 : :
1815 : : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym);
1816 : :
1817 : : /*
1818 : : GetVarientTag - returns the varient tag from, Sym.
1819 : : */
1820 : :
1821 : : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym);
1822 : :
1823 : : /*
1824 : : PutVarientTag - places, Tag, into varient, Sym.
1825 : : */
1826 : :
1827 : : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag);
1828 : :
1829 : : /*
1830 : : PutFieldEnumeration - places a field into the enumeration type
1831 : : Sym. The field has a name FieldName and a
1832 : : value FieldVal.
1833 : : */
1834 : :
1835 : : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName);
1836 : :
1837 : : /*
1838 : : PutSubrange - places LowSym and HighSym as two symbols
1839 : : which provide the limits of the range.
1840 : : */
1841 : :
1842 : : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol);
1843 : :
1844 : : /*
1845 : : PutSet - places SimpleType as the type for set, Sym.
1846 : : */
1847 : :
1848 : : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed);
1849 : :
1850 : : /*
1851 : : IsSetPacked - returns TRUE if Sym is packed.
1852 : : */
1853 : :
1854 : : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym);
1855 : :
1856 : : /*
1857 : : GetArraySubscript - returns the subscript symbol for array, Sym.
1858 : : */
1859 : :
1860 : : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym);
1861 : :
1862 : : /*
1863 : : PutArraySubscript - places an index field into the array Sym. The
1864 : : index field is a subscript sym.
1865 : : */
1866 : :
1867 : : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol);
1868 : :
1869 : : /*
1870 : : PutType - gives a type symbol Sym type TypeSymbol.
1871 : : */
1872 : :
1873 : : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol);
1874 : :
1875 : : /*
1876 : : PutFunction - Places a TypeSym as the return type to a procedure Sym.
1877 : : */
1878 : :
1879 : : extern "C" void SymbolTable_PutFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym);
1880 : :
1881 : : /*
1882 : : PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
1883 : : */
1884 : :
1885 : : extern "C" void SymbolTable_PutOptFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym);
1886 : :
1887 : : /*
1888 : : IsReturnOptional - returns TRUE if the return value for, sym, is
1889 : : optional.
1890 : : */
1891 : :
1892 : : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind);
1893 : :
1894 : : /*
1895 : : IsReturnOptionalAny - returns TRUE if the return value for sym is
1896 : : optional.
1897 : : */
1898 : :
1899 : : extern "C" bool SymbolTable_IsReturnOptionalAny (unsigned int sym);
1900 : :
1901 : : /*
1902 : : PutParam - Places a Non VAR parameter ParamName with type ParamType into
1903 : : procedure Sym:kind. The parameter number is ParamNo.
1904 : : If the procedure Sym already has this parameter then
1905 : : the parameter is checked for consistancy and the
1906 : : consistancy test is returned.
1907 : : */
1908 : :
1909 : : 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);
1910 : :
1911 : : /*
1912 : : PutVarParam - Places a Non VAR parameter ParamName with type
1913 : : ParamType into procedure Sym:kind.
1914 : : The parameter number is ParamNo.
1915 : : If the procedure Sym already has this parameter then
1916 : : the parameter is checked for consistancy and the
1917 : : consistancy test is returned.
1918 : : */
1919 : :
1920 : : 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);
1921 : :
1922 : : /*
1923 : : PutParamName - assigns a name to paramater no of procedure ProcSym:kind.
1924 : : */
1925 : :
1926 : : 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);
1927 : :
1928 : : /*
1929 : : PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
1930 : : main Module.
1931 : : */
1932 : :
1933 : : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym);
1934 : :
1935 : : /*
1936 : : IsProcedureReachable - Returns true if the procedure, Sym, is
1937 : : reachable from the main Module.
1938 : : */
1939 : :
1940 : : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym);
1941 : :
1942 : : /*
1943 : : PutProcedureNoReturn - places value into the no return attribute
1944 : : field of procedure sym.
1945 : : */
1946 : :
1947 : : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind, bool value);
1948 : :
1949 : : /*
1950 : : IsProcedureNoReturn - returns TRUE if this procedure never returns.
1951 : : */
1952 : :
1953 : : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind);
1954 : :
1955 : : /*
1956 : : GetProcedureProcType - returns the proctype matching procedure sym.
1957 : : */
1958 : :
1959 : : extern "C" unsigned int SymbolTable_GetProcedureProcType (unsigned int sym);
1960 : :
1961 : : /*
1962 : : PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
1963 : : QuadNumber is the start quad of Module,
1964 : : Sym.
1965 : : */
1966 : :
1967 : : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber);
1968 : :
1969 : : /*
1970 : : PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
1971 : : QuadNumber is the end quad of Module,
1972 : : Sym.
1973 : : */
1974 : :
1975 : : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber);
1976 : :
1977 : : /*
1978 : : PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
1979 : : QuadNumber is the finally start quad of
1980 : : Module, Sym.
1981 : : */
1982 : :
1983 : : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber);
1984 : :
1985 : : /*
1986 : : PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
1987 : : QuadNumber is the end quad of the finally block
1988 : : in Module, Sym.
1989 : : */
1990 : :
1991 : : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber);
1992 : :
1993 : : /*
1994 : : GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
1995 : : Quads of a Module, Sym.
1996 : : Start and End represent the initialization code
1997 : : of the Module, Sym.
1998 : : */
1999 : :
2000 : : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish);
2001 : :
2002 : : /*
2003 : : PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
2004 : : */
2005 : :
2006 : : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, tree finally);
2007 : :
2008 : : /*
2009 : : GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
2010 : : */
2011 : :
2012 : : extern "C" tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym);
2013 : :
2014 : : /*
2015 : : PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
2016 : : QuadNumber is the start quad of scope for procedure,
2017 : : Sym.
2018 : : */
2019 : :
2020 : : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber);
2021 : :
2022 : : /*
2023 : : PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
2024 : : QuadNumber is the start quad of procedure,
2025 : : Sym.
2026 : : */
2027 : :
2028 : : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber);
2029 : :
2030 : : /*
2031 : : PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
2032 : : QuadNumber is the end quad of procedure,
2033 : : Sym.
2034 : : */
2035 : :
2036 : : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber);
2037 : :
2038 : : /*
2039 : : GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
2040 : : */
2041 : :
2042 : : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end);
2043 : :
2044 : : /*
2045 : : GetQuads - assigns Start and End to the beginning and end of
2046 : : symbol, Sym, usage.
2047 : : */
2048 : :
2049 : : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2050 : :
2051 : : /*
2052 : : GetReadQuads - assigns Start and End to the beginning and end of
2053 : : symbol, Sym, read history usage.
2054 : : */
2055 : :
2056 : : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2057 : :
2058 : : /*
2059 : : GetWriteQuads - assigns Start and End to the beginning and end of
2060 : : symbol, Sym, usage.
2061 : : */
2062 : :
2063 : : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2064 : :
2065 : : /*
2066 : : PutReadQuad - places Quad into the list of symbol usage.
2067 : : */
2068 : :
2069 : : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2070 : :
2071 : : /*
2072 : : RemoveReadQuad - places Quad into the list of symbol usage.
2073 : : */
2074 : :
2075 : : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2076 : :
2077 : : /*
2078 : : PutWriteQuad - places Quad into the list of symbol usage.
2079 : : */
2080 : :
2081 : : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2082 : :
2083 : : /*
2084 : : RemoveWriteQuad - places Quad into the list of symbol usage.
2085 : : */
2086 : :
2087 : : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2088 : :
2089 : : /*
2090 : : GetReadLimitQuads - returns Start and End which have been assigned
2091 : : the start and end of when the symbol was read
2092 : : to within: StartLimit..EndLimit.
2093 : : */
2094 : :
2095 : : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2096 : :
2097 : : /*
2098 : : GetWriteLimitQuads - returns Start and End which have been assigned
2099 : : the start and end of when the symbol was written
2100 : : to within: StartLimit..EndLimit.
2101 : : */
2102 : :
2103 : : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2104 : :
2105 : : /*
2106 : : GetNthProcedure - Returns the Nth procedure in Module, Sym.
2107 : : */
2108 : :
2109 : : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n);
2110 : :
2111 : : /*
2112 : : GetDeclaredDef - returns the tokenno where the symbol was declared
2113 : : in the definition module. UnknownTokenNo is returned
2114 : : if no declaration occurred.
2115 : : */
2116 : :
2117 : : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym);
2118 : :
2119 : : /*
2120 : : GetDeclaredMod - returns the tokenno where the symbol was declared.
2121 : : in the program or implementation module.
2122 : : UnknownTokenNo is returned if no declaration occurred.
2123 : : */
2124 : :
2125 : : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym);
2126 : :
2127 : : /*
2128 : : GetDeclaredFor - returns the token where this forward procedure symbol
2129 : : was declared in the program or implementation module.
2130 : : UnknownTokenNo is returned if no declaration occurred.
2131 : : */
2132 : :
2133 : : extern "C" unsigned int SymbolTable_GetDeclaredFor (unsigned int Sym);
2134 : :
2135 : : /*
2136 : : GetDeclaredDefinition - returns the token where this symbol
2137 : : was declared in the definition module.
2138 : : */
2139 : :
2140 : : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym);
2141 : :
2142 : : /*
2143 : : GetDeclaredModule - returns the token where this symbol was declared
2144 : : in an implementation or program module.
2145 : : */
2146 : :
2147 : : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym);
2148 : :
2149 : : /*
2150 : : PutDeclared - adds an entry to symbol, Sym, indicating that it
2151 : : was declared at, tok. This routine
2152 : : may be called twice, once for definition module
2153 : : partial declaration and once when parsing the
2154 : : implementation module.
2155 : : */
2156 : :
2157 : : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym);
2158 : :
2159 : : /*
2160 : : GetFirstUsed - returns the token where this symbol was first used.
2161 : : */
2162 : :
2163 : : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym);
2164 : :
2165 : : /*
2166 : : PutProcedureBegin - assigns begin as the token number matching the
2167 : : procedure BEGIN.
2168 : : */
2169 : :
2170 : : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin);
2171 : :
2172 : : /*
2173 : : PutProcedureEnd - assigns end as the token number matching the
2174 : : procedure END.
2175 : : */
2176 : :
2177 : : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end);
2178 : :
2179 : : /*
2180 : : GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
2181 : : */
2182 : :
2183 : : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end);
2184 : :
2185 : : /*
2186 : : ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
2187 : : */
2188 : :
2189 : : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P);
2190 : :
2191 : : /*
2192 : : ForeachModuleDo - for each module do procedure, P.
2193 : : */
2194 : :
2195 : : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P);
2196 : :
2197 : : /*
2198 : : ForeachInnerModuleDo - for each inner module in module, Sym,
2199 : : do procedure, P.
2200 : : */
2201 : :
2202 : : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P);
2203 : :
2204 : : /*
2205 : : IsVarParam - Returns a conditional depending whether parameter ParamNo
2206 : : is a VAR parameter.
2207 : : */
2208 : :
2209 : : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
2210 : :
2211 : : /*
2212 : : IsVarParamAny - Returns a conditional depending whether parameter ParamNo
2213 : : is a VAR parameter.
2214 : : */
2215 : :
2216 : : extern "C" bool SymbolTable_IsVarParamAny (unsigned int Sym, unsigned int ParamNo);
2217 : :
2218 : : /*
2219 : : IsUnboundedParam - Returns a conditional depending whether parameter
2220 : : ParamNo is an unbounded array procedure parameter.
2221 : : */
2222 : :
2223 : : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
2224 : : extern "C" bool SymbolTable_IsUnboundedParamAny (unsigned int Sym, unsigned int ParamNo);
2225 : :
2226 : : /*
2227 : : IsParameterUnbounded - returns TRUE if parameter, Sym, is
2228 : : unbounded.
2229 : : */
2230 : :
2231 : : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym);
2232 : :
2233 : : /*
2234 : : IsParameterVar - returns true if parameter symbol Sym
2235 : : was declared as a VAR.
2236 : : */
2237 : :
2238 : : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym);
2239 : :
2240 : : /*
2241 : : GetParameterShadowVar - returns the local variable associated with the
2242 : : parameter symbol, sym.
2243 : : */
2244 : :
2245 : : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym);
2246 : :
2247 : : /*
2248 : : NoOfParam - Returns the number of parameters that procedure Sym contains.
2249 : : */
2250 : :
2251 : : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym, SymbolTable_ProcedureKind kind);
2252 : :
2253 : : /*
2254 : : HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
2255 : : */
2256 : :
2257 : : extern "C" bool SymbolTable_HasVarParameters (unsigned int p);
2258 : :
2259 : : /*
2260 : : NoOfLocalVar - returns the number of local variables that exist in
2261 : : procedure Sym. Parameters are NOT included in the
2262 : : count.
2263 : : */
2264 : :
2265 : : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym);
2266 : :
2267 : : /*
2268 : : IsDefImp - returns true is the Sym is a DefImp symbol.
2269 : : Definition/Implementation module symbol.
2270 : : */
2271 : :
2272 : : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym);
2273 : :
2274 : : /*
2275 : : IsModule - returns true is the Sym is a Module symbol.
2276 : : Program module symbol.
2277 : : */
2278 : :
2279 : : extern "C" bool SymbolTable_IsModule (unsigned int Sym);
2280 : :
2281 : : /*
2282 : : IsInnerModule - returns true if the symbol, Sym, is an inner module.
2283 : : */
2284 : :
2285 : : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym);
2286 : :
2287 : : /*
2288 : : GetSymName - returns the symbol name.
2289 : : */
2290 : :
2291 : : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym);
2292 : :
2293 : : /*
2294 : : RenameSym - renames a symbol, Sym, with SymName.
2295 : : It also checks the unknown tree for a symbol
2296 : : with this new name. Must only be renamed in
2297 : : the same scope of being declared.
2298 : : */
2299 : :
2300 : : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName);
2301 : :
2302 : : /*
2303 : : IsUnknown - returns true is the symbol Sym is unknown.
2304 : : */
2305 : :
2306 : : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym);
2307 : :
2308 : : /*
2309 : : IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
2310 : : */
2311 : :
2312 : : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym);
2313 : :
2314 : : /*
2315 : : RequestSym - searches for a symbol with a name SymName in the
2316 : : current and previous scopes.
2317 : : If the symbol is found then it is returned
2318 : : else an unknown symbol is returned create at token
2319 : : position, tok.
2320 : : This procedure does search the base scope (for
2321 : : pervasive identifiers).
2322 : : */
2323 : :
2324 : : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName);
2325 : :
2326 : : /*
2327 : : PutImported - places a symbol, Sym, into the current main scope.
2328 : : */
2329 : :
2330 : : extern "C" void SymbolTable_PutImported (unsigned int Sym);
2331 : :
2332 : : /*
2333 : : PutIncluded - places a symbol, Sym, into the included list of the
2334 : : current module.
2335 : : Symbols that are placed in this list are indirectly declared
2336 : : by:
2337 : :
2338 : : IMPORT modulename ;
2339 : :
2340 : : modulename.identifier
2341 : : */
2342 : :
2343 : : extern "C" void SymbolTable_PutIncluded (unsigned int Sym);
2344 : :
2345 : : /*
2346 : : PutExported - places a symbol, Sym into the next level out module.
2347 : : Sym is also placed in the ExportTree of the current inner
2348 : : module.
2349 : : */
2350 : :
2351 : : extern "C" void SymbolTable_PutExported (unsigned int Sym);
2352 : :
2353 : : /*
2354 : : PutExportQualified - places a symbol with the name, SymName,
2355 : : into the export tree of the
2356 : : Definition module being compiled.
2357 : : The symbol with name has been EXPORT QUALIFIED
2358 : : by the definition module and therefore any reference
2359 : : to this symbol in the code generation phase
2360 : : will be in the form _Module_Name.
2361 : : */
2362 : :
2363 : : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName);
2364 : :
2365 : : /*
2366 : : PutExportUnQualified - places a symbol with the name, SymName,
2367 : : into the export tree of the
2368 : : Definition module being compiled.
2369 : : The symbol with Name has been EXPORT UNQUALIFIED
2370 : : by the definition module and therefore any reference
2371 : : to this symbol in the code generation phase
2372 : : will be in the form _Name.
2373 : : */
2374 : :
2375 : : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName);
2376 : :
2377 : : /*
2378 : : PutExportUnImplemented - places a symbol, Sym, into the currently compiled
2379 : : DefImp module NeedToBeImplemented list.
2380 : : */
2381 : :
2382 : : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym);
2383 : :
2384 : : /*
2385 : : GetExported - returns the symbol which has a name SymName,
2386 : : and is exported from the definition module ModSym.
2387 : :
2388 : : */
2389 : :
2390 : : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName);
2391 : :
2392 : : /*
2393 : : GetFromOuterModule - returns a symbol with name, SymName, which comes
2394 : : from outside the current module.
2395 : : */
2396 : :
2397 : : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName);
2398 : :
2399 : : /*
2400 : : TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
2401 : : name, name, which is
2402 : : currently undefined in the
2403 : : outer scope to the inner scope.
2404 : : If successful then the symbol is
2405 : : returned otherwise NulSym is
2406 : : returned.
2407 : : */
2408 : :
2409 : : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name);
2410 : :
2411 : : /*
2412 : : IsExportQualified - returns true if a symbol, Sym, was defined as
2413 : : being EXPORT QUALIFIED.
2414 : : Sym is expected to be either a procedure or a
2415 : : variable.
2416 : : */
2417 : :
2418 : : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym);
2419 : :
2420 : : /*
2421 : : IsExportUnQualified - returns true if a symbol, Sym, was defined as
2422 : : being EXPORT UNQUALIFIED.
2423 : : */
2424 : :
2425 : : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym);
2426 : :
2427 : : /*
2428 : : IsExported - returns true if a symbol, Sym, is exported
2429 : : from module, ModSym.
2430 : : If ModSym is a DefImp symbol then its
2431 : : ExportQualified and ExportUnQualified lists are examined.
2432 : : */
2433 : :
2434 : : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym);
2435 : :
2436 : : /*
2437 : : IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
2438 : : ModSym must be a defimp symbol.
2439 : : */
2440 : :
2441 : : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym);
2442 : :
2443 : : /*
2444 : : IsImported - returns true if a symbol, Sym, in module, ModSym,
2445 : : was imported.
2446 : : */
2447 : :
2448 : : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym);
2449 : :
2450 : : /*
2451 : : PutIncludedByDefinition - places a module symbol, Sym, into the
2452 : : included list of the current definition module.
2453 : : */
2454 : :
2455 : : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym);
2456 : :
2457 : : /*
2458 : : IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
2459 : : by ModSym's definition module.
2460 : : */
2461 : :
2462 : : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym);
2463 : :
2464 : : /*
2465 : : ForeachImportedDo - calls a procedure, P, foreach imported symbol
2466 : : in module, ModSym.
2467 : : */
2468 : :
2469 : : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2470 : :
2471 : : /*
2472 : : ForeachExportedDo - calls a procedure, P, foreach imported symbol
2473 : : in module, ModSym.
2474 : : */
2475 : :
2476 : : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2477 : :
2478 : : /*
2479 : : CheckForExportedImplementation - checks to see whether an implementation
2480 : : module is currently being compiled, if so,
2481 : : symbol, Sym, is removed from the
2482 : : NeedToBeImplemented list.
2483 : : This procedure is called whenever a symbol
2484 : : is declared, thus attempting to reduce
2485 : : the NeedToBeImplemented list.
2486 : : Only needs to be called when a TYPE or
2487 : : PROCEDURE is built since the implementation
2488 : : module can only implement these objects
2489 : : declared in the definition module.
2490 : :
2491 : : It also checks whether a definition module
2492 : : is currently being compiled and, if so,
2493 : : it will ensure that symbol, Sym, is removed
2494 : : from the ExportRequest list. If Sym is an
2495 : : enumerated type it ensures that its fields
2496 : : are also removed.
2497 : : */
2498 : :
2499 : : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym);
2500 : :
2501 : : /*
2502 : : CheckForUnImplementedExports - displays an error and the offending symbols
2503 : : which have been exported but not implemented
2504 : : from the current compiled module.
2505 : : */
2506 : :
2507 : : extern "C" void SymbolTable_CheckForUnImplementedExports (void);
2508 : :
2509 : : /*
2510 : : CheckForUndeclaredExports - displays an error and the offending symbols
2511 : : which have been exported but not declared
2512 : : from module, ModSym.
2513 : : */
2514 : :
2515 : : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym);
2516 : :
2517 : : /*
2518 : : CheckForUnknownInModule - checks for any unknown symbols in the
2519 : : current module.
2520 : : If any unknown symbols are found then
2521 : : an error message is displayed.
2522 : : */
2523 : :
2524 : : extern "C" void SymbolTable_CheckForUnknownInModule (void);
2525 : :
2526 : : /*
2527 : : UnknownReported - if sym is an unknown symbol and has not been reported
2528 : : then include it into the set of reported unknowns.
2529 : : */
2530 : :
2531 : : extern "C" void SymbolTable_UnknownReported (unsigned int sym);
2532 : :
2533 : : /*
2534 : : IsReallyPointer - returns TRUE is sym is a pointer, address or a
2535 : : type declared as a pointer or address.
2536 : : */
2537 : :
2538 : : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym);
2539 : :
2540 : : /*
2541 : : CheckHiddenTypeAreAddress - checks to see that any hidden types
2542 : : which we have declared are actually
2543 : : of type ADDRESS or map onto a POINTER type.
2544 : : */
2545 : :
2546 : : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void);
2547 : :
2548 : : /*
2549 : : PutDefinitionForC - sets a flag in the current compiled module which
2550 : : indicates that this module is a wrapper for a C
2551 : : file. Parameters passes to procedures in this module
2552 : : will adopt the C calling convention.
2553 : : */
2554 : :
2555 : : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym);
2556 : :
2557 : : /*
2558 : : IsDefinitionForC - returns true if this definition module was declared
2559 : : as a DEFINITION MODULE FOR "C".
2560 : : */
2561 : :
2562 : : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym);
2563 : :
2564 : : /*
2565 : : PutDoesNeedExportList - sets a flag in module, Sym, which
2566 : : indicates that this module requires an explicit
2567 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
2568 : : */
2569 : :
2570 : : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym);
2571 : :
2572 : : /*
2573 : : PutDoesNotNeedExportList - sets a flag in module, Sym, which
2574 : : indicates that this module does not require an explicit
2575 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
2576 : : */
2577 : :
2578 : : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym);
2579 : :
2580 : : /*
2581 : : DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
2582 : : EXPORT QUALIFIED list.
2583 : : */
2584 : :
2585 : : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym);
2586 : :
2587 : : /*
2588 : : CheckForEnumerationInCurrentModule - checks to see whether the enumeration
2589 : : type symbol, Sym, has been entered into
2590 : : the current modules scope list.
2591 : : */
2592 : :
2593 : : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym);
2594 : :
2595 : : /*
2596 : : SanityCheckConstants - must only be called once all constants, types, procedures
2597 : : have been declared. It checks to see that constants are
2598 : : not used as procedure parameter types.
2599 : : */
2600 : :
2601 : : extern "C" void SymbolTable_SanityCheckConstants (void);
2602 : :
2603 : : /*
2604 : : ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
2605 : : perform the procedure, P.
2606 : : */
2607 : :
2608 : : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2609 : :
2610 : : /*
2611 : : ForeachParamSymDo - foreach parameter symbol in procedure Sym
2612 : : perform the procedure P. Each symbol
2613 : : looked up will be VarParam or Param
2614 : : (not the shadow variable). Every parameter
2615 : : from each KindProcedure is iterated over.
2616 : : */
2617 : :
2618 : : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2619 : :
2620 : : /*
2621 : : ForeachFieldEnumerationDo - for each field in enumeration, Sym,
2622 : : do procedure, P. Each call to P contains
2623 : : an enumeration field, the order is alphabetical.
2624 : : Use ForeachLocalSymDo for declaration order.
2625 : : */
2626 : :
2627 : : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P);
2628 : :
2629 : : /*
2630 : : IsType - returns true if the Sym is a type symbol.
2631 : : */
2632 : :
2633 : : extern "C" bool SymbolTable_IsType (unsigned int Sym);
2634 : :
2635 : : /*
2636 : : IsProcedure - returns true if Sym is a procedure symbol.
2637 : : */
2638 : :
2639 : : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym);
2640 : :
2641 : : /*
2642 : : IsParameter - returns true if Sym is a parameter symbol.
2643 : : */
2644 : :
2645 : : extern "C" bool SymbolTable_IsParameter (unsigned int Sym);
2646 : :
2647 : : /*
2648 : : GetProcedureKind - returns the procedure kind given the declaration tok.
2649 : : The declaration tok must match the ident tok in the
2650 : : procedure name. It is only safe to call this
2651 : : procedure function during pass 2 onwards.
2652 : : */
2653 : :
2654 : : extern "C" SymbolTable_ProcedureKind SymbolTable_GetProcedureKind (unsigned int sym, unsigned int tok);
2655 : :
2656 : : /*
2657 : : GetProcedureDeclaredTok - return the token where the
2658 : : declaration of procedure sym:kind
2659 : : occurred.
2660 : : */
2661 : :
2662 : : extern "C" unsigned int SymbolTable_GetProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind);
2663 : :
2664 : : /*
2665 : : PutProcedureDeclaredTok - places the tok where the
2666 : : declaration of procedure sym:kind
2667 : : occurred.
2668 : : */
2669 : :
2670 : : extern "C" void SymbolTable_PutProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok);
2671 : :
2672 : : /*
2673 : : GetReturnTypeTok - return the token where the
2674 : : return type procedure sym:kind or proctype
2675 : : was defined.
2676 : : */
2677 : :
2678 : : extern "C" unsigned int SymbolTable_GetReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind);
2679 : :
2680 : : /*
2681 : : PutReturnTypeTok - places the tok where the
2682 : : return type of procedure sym:kind or proctype
2683 : : was defined.
2684 : : */
2685 : :
2686 : : extern "C" void SymbolTable_PutReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok);
2687 : :
2688 : : /*
2689 : : PutProcedureParametersDefined - the procedure symbol sym:kind
2690 : : parameters have been defined.
2691 : : */
2692 : :
2693 : : extern "C" void SymbolTable_PutProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2694 : :
2695 : : /*
2696 : : GetProcedureParametersDefined - returns true if procedure symbol sym:kind
2697 : : parameters are defined.
2698 : : */
2699 : :
2700 : : extern "C" bool SymbolTable_GetProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2701 : :
2702 : : /*
2703 : : PutProcedureDefined - the procedure symbol sym:kind is defined.
2704 : : */
2705 : :
2706 : : extern "C" void SymbolTable_PutProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2707 : :
2708 : : /*
2709 : : GetProcedureDefined - returns true if procedure symbol sym:kind
2710 : : is defined.
2711 : : */
2712 : :
2713 : : extern "C" bool SymbolTable_GetProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
2714 : :
2715 : : /*
2716 : : PutUseVarArgs - tell the symbol table that this procedure, Sym,
2717 : : uses varargs.
2718 : : The procedure _must_ be declared inside a
2719 : : DEFINITION FOR "C"
2720 : :
2721 : : */
2722 : :
2723 : : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym);
2724 : :
2725 : : /*
2726 : : UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
2727 : : The procedure _must_ be declared inside a
2728 : : DEFINITION FOR "C"
2729 : : */
2730 : :
2731 : : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym);
2732 : :
2733 : : /*
2734 : : PutUseOptArg - tell the symbol table that this procedure, Sym,
2735 : : uses an optarg.
2736 : : */
2737 : :
2738 : : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind);
2739 : :
2740 : : /*
2741 : : UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
2742 : : */
2743 : :
2744 : : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind);
2745 : :
2746 : : /*
2747 : : PutOptArgInit - makes symbol, Sym, the initializer value to
2748 : : procedure, ProcSym.
2749 : : */
2750 : :
2751 : : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym);
2752 : :
2753 : : /*
2754 : : GetOptArgInit - returns the initializer value to the optional parameter in
2755 : : procedure, ProcSym.
2756 : : */
2757 : :
2758 : : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym);
2759 : :
2760 : : /*
2761 : : MakePointer - returns a pointer symbol with PointerName.
2762 : : */
2763 : :
2764 : : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName);
2765 : :
2766 : : /*
2767 : : PutPointer - gives a pointer symbol a type, PointerType.
2768 : : */
2769 : :
2770 : : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType);
2771 : :
2772 : : /*
2773 : : IsPointer - returns true is Sym is a pointer type symbol.
2774 : : */
2775 : :
2776 : : extern "C" bool SymbolTable_IsPointer (unsigned int Sym);
2777 : :
2778 : : /*
2779 : : IsRecord - returns true is Sym is a record type symbol.
2780 : : */
2781 : :
2782 : : extern "C" bool SymbolTable_IsRecord (unsigned int Sym);
2783 : :
2784 : : /*
2785 : : IsVarient - returns true if the symbol, Sym, is a
2786 : : varient symbol.
2787 : : */
2788 : :
2789 : : extern "C" bool SymbolTable_IsVarient (unsigned int Sym);
2790 : :
2791 : : /*
2792 : : IsFieldVarient - returns true if the symbol, Sym, is a
2793 : : varient field.
2794 : : */
2795 : :
2796 : : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym);
2797 : :
2798 : : /*
2799 : : IsFieldEnumeration - returns true if the symbol, Sym, is an
2800 : : enumeration field.
2801 : : */
2802 : :
2803 : : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym);
2804 : :
2805 : : /*
2806 : : IsArray - returns true is Sym is an array type symbol.
2807 : : */
2808 : :
2809 : : extern "C" bool SymbolTable_IsArray (unsigned int Sym);
2810 : :
2811 : : /*
2812 : : IsEnumeration - returns true if Sym is an enumeration symbol.
2813 : : */
2814 : :
2815 : : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym);
2816 : :
2817 : : /*
2818 : : IsSet - returns TRUE if Sym is a set symbol.
2819 : : */
2820 : :
2821 : : extern "C" bool SymbolTable_IsSet (unsigned int Sym);
2822 : :
2823 : : /*
2824 : : IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
2825 : : */
2826 : :
2827 : : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym);
2828 : :
2829 : : /*
2830 : : IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
2831 : : */
2832 : :
2833 : : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym);
2834 : :
2835 : : /*
2836 : : GetDimension - return the number of dimensions associated with
2837 : : this unbounded ARRAY parameter.
2838 : : */
2839 : :
2840 : : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym);
2841 : :
2842 : : /*
2843 : : MakeOAFamily - makes an OAFamily symbol based on SimpleType.
2844 : : It returns the OAFamily symbol. A new symbol
2845 : : is created if one does not already exist for
2846 : : SimpleType.
2847 : : */
2848 : :
2849 : : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType);
2850 : :
2851 : : /*
2852 : : GetOAFamily - returns the oafamily symbol associated with
2853 : : SimpleType.
2854 : : */
2855 : :
2856 : : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType);
2857 : :
2858 : : /*
2859 : : ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
2860 : : sym, in the oaf.
2861 : : */
2862 : :
2863 : : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p);
2864 : :
2865 : : /*
2866 : : IsUnbounded - returns true if Sym is an unbounded symbol.
2867 : : */
2868 : :
2869 : : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym);
2870 : :
2871 : : /*
2872 : : GetUnbounded - returns the unbounded symbol associated with
2873 : : the OAFamily symbol, oaf, and the number of
2874 : : dimensions, ndim, of the open array.
2875 : : */
2876 : :
2877 : : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim);
2878 : :
2879 : : /*
2880 : : GetUnboundedRecordType - returns the record type used to
2881 : : implement the unbounded array.
2882 : : */
2883 : :
2884 : : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym);
2885 : :
2886 : : /*
2887 : : GetUnboundedAddressOffset - returns the offset of the address field
2888 : : inside the record used to implement the
2889 : : unbounded type.
2890 : : */
2891 : :
2892 : : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym);
2893 : :
2894 : : /*
2895 : : GetUnboundedHighOffset - returns the offset of the high field
2896 : : inside the record used to implement the
2897 : : unbounded type.
2898 : : */
2899 : :
2900 : : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim);
2901 : :
2902 : : /*
2903 : : MakeSubscript - makes a subscript Symbol.
2904 : : No name is required.
2905 : : */
2906 : :
2907 : : extern "C" unsigned int SymbolTable_MakeSubscript (void);
2908 : :
2909 : : /*
2910 : : PutSubscript - gives a subscript symbol a type, SimpleType.
2911 : : */
2912 : :
2913 : : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType);
2914 : :
2915 : : /*
2916 : : MakeUnbounded - makes an unbounded array Symbol.
2917 : : ndim is the number of dimensions required.
2918 : : No name is required.
2919 : : */
2920 : :
2921 : : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim);
2922 : :
2923 : : /*
2924 : : NoOfElements - Returns the number of elements in array Sym,
2925 : : or the number of elements in an enumeration Sym or
2926 : : the number of interface symbols in an Interface list.
2927 : : */
2928 : :
2929 : : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym);
2930 : :
2931 : : /*
2932 : : PutArray - places a type symbol into an arraysym.
2933 : : */
2934 : :
2935 : : extern "C" void SymbolTable_PutArray (unsigned int arraysym, unsigned int typesym);
2936 : :
2937 : : /*
2938 : : ResolveImports - it examines the import list of all inner modules
2939 : : and resolves all relative imports.
2940 : : */
2941 : :
2942 : : extern "C" void SymbolTable_ResolveImports (void);
2943 : :
2944 : : /*
2945 : : ResolveConstructorTypes - to be called at the end of pass three. Its
2946 : : purpose is to fix up all constructors whose
2947 : : types are unknown.
2948 : : */
2949 : :
2950 : : extern "C" void SymbolTable_ResolveConstructorTypes (void);
2951 : :
2952 : : /*
2953 : : AddNameToScope - adds a Name, n, to the list of objects declared at the
2954 : : current scope.
2955 : : */
2956 : :
2957 : : extern "C" void SymbolTable_AddNameToScope (NameKey_Name n);
2958 : :
2959 : : /*
2960 : : AddNameToImportList - adds a Name, n, to the import list of the current
2961 : : module.
2962 : : */
2963 : :
2964 : : extern "C" void SymbolTable_AddNameToImportList (NameKey_Name n);
2965 : :
2966 : : /*
2967 : : GetScope - returns the declaration scope of the symbol.
2968 : : */
2969 : :
2970 : : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym);
2971 : :
2972 : : /*
2973 : : GetModuleScope - returns the module scope of symbol, sym.
2974 : : If sym was declared within a nested procedure
2975 : : then return the module which defines the
2976 : : procedure.
2977 : : */
2978 : :
2979 : : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym);
2980 : :
2981 : : /*
2982 : : GetProcedureScope - returns the innermost procedure (if any)
2983 : : in which the symbol, sym, resides.
2984 : : A module inside the procedure is skipped
2985 : : over.
2986 : : */
2987 : :
2988 : : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym);
2989 : :
2990 : : /*
2991 : : IsModuleWithinProcedure - returns TRUE if module, sym, is
2992 : : inside a procedure.
2993 : : */
2994 : :
2995 : : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym);
2996 : :
2997 : : /*
2998 : : GetParent - returns the parent of symbol, Sym.
2999 : : */
3000 : :
3001 : : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym);
3002 : :
3003 : : /*
3004 : : IsRecordField - returns true if Sym is a record field.
3005 : : */
3006 : :
3007 : : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym);
3008 : :
3009 : : /*
3010 : : MakeProcType - returns a procedure type symbol with ProcTypeName.
3011 : : */
3012 : :
3013 : : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName);
3014 : :
3015 : : /*
3016 : : PutProcTypeParam - Places a Non VAR parameter ParamName with type
3017 : : ParamType into ProcType Sym.
3018 : : */
3019 : :
3020 : : extern "C" void SymbolTable_PutProcTypeParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded);
3021 : :
3022 : : /*
3023 : : PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
3024 : : ParamType into ProcType Sym.
3025 : : */
3026 : :
3027 : : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded);
3028 : :
3029 : : /*
3030 : : IsProcType - returns true if Sym is a ProcType Symbol.
3031 : : */
3032 : :
3033 : : extern "C" bool SymbolTable_IsProcType (unsigned int Sym);
3034 : :
3035 : : /*
3036 : : IsVar - returns true if Sym is a Var Symbol.
3037 : : */
3038 : :
3039 : : extern "C" bool SymbolTable_IsVar (unsigned int Sym);
3040 : :
3041 : : /*
3042 : : IsVarConst - returns the IsConst field indicating the variable is read only.
3043 : : */
3044 : :
3045 : : extern "C" bool SymbolTable_IsVarConst (unsigned int sym);
3046 : :
3047 : : /*
3048 : : IsConst - returns true if Sym contains a constant value.
3049 : : */
3050 : :
3051 : : extern "C" bool SymbolTable_IsConst (unsigned int Sym);
3052 : :
3053 : : /*
3054 : : IsConstString - returns whether sym is a conststring of any variant.
3055 : : */
3056 : :
3057 : : extern "C" bool SymbolTable_IsConstString (unsigned int sym);
3058 : :
3059 : : /*
3060 : : IsConstStringNulTerminated - returns TRUE if the constant string, sym,
3061 : : should be created with a nul terminator.
3062 : : */
3063 : :
3064 : : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym);
3065 : :
3066 : : /*
3067 : : IsConstLit - returns true if Sym is a literal constant.
3068 : : */
3069 : :
3070 : : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym);
3071 : :
3072 : : /*
3073 : : IsConstructor - returns TRUE if the constant is declared as a
3074 : : constant set, array or record.
3075 : : */
3076 : :
3077 : : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym);
3078 : :
3079 : : /*
3080 : : IsDummy - returns true if Sym is a Dummy symbol.
3081 : : */
3082 : :
3083 : : extern "C" bool SymbolTable_IsDummy (unsigned int Sym);
3084 : :
3085 : : /*
3086 : : IsTemporary - returns true if Sym is a Temporary symbol.
3087 : : */
3088 : :
3089 : : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym);
3090 : :
3091 : : /*
3092 : : IsVarAParam - returns true if Sym is a variable declared as a parameter.
3093 : : */
3094 : :
3095 : : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym);
3096 : :
3097 : : /*
3098 : : IsSubscript - returns true if Sym is a subscript symbol.
3099 : : */
3100 : :
3101 : : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym);
3102 : :
3103 : : /*
3104 : : IsSubrange - returns true if Sym is a subrange symbol.
3105 : : */
3106 : :
3107 : : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym);
3108 : :
3109 : : /*
3110 : : IsProcedureVariable - returns true if a Sym is a variable and
3111 : : it was declared within a procedure.
3112 : : */
3113 : :
3114 : : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym);
3115 : :
3116 : : /*
3117 : : IsProcedureNested - returns TRUE if procedure, Sym, was
3118 : : declared as a nested procedure.
3119 : : */
3120 : :
3121 : : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym);
3122 : :
3123 : : /*
3124 : : IsAModula2Type - returns true if Sym, is a:
3125 : : IsType, IsPointer, IsRecord, IsEnumeration,
3126 : : IsSubrange, IsArray, IsUnbounded, IsProcType.
3127 : : NOTE that it different from IsType.
3128 : : */
3129 : :
3130 : : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym);
3131 : :
3132 : : /*
3133 : : IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
3134 : : */
3135 : :
3136 : : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym);
3137 : :
3138 : : /*
3139 : : IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
3140 : : */
3141 : :
3142 : : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym);
3143 : :
3144 : : /*
3145 : : IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
3146 : : */
3147 : :
3148 : : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym);
3149 : :
3150 : : /*
3151 : : IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
3152 : : */
3153 : :
3154 : : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym);
3155 : :
3156 : : /*
3157 : : IsSizeSolved - returns true if the size of Sym is solved.
3158 : : */
3159 : :
3160 : : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym);
3161 : :
3162 : : /*
3163 : : IsOffsetSolved - returns true if the Offset of Sym is solved.
3164 : : */
3165 : :
3166 : : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym);
3167 : :
3168 : : /*
3169 : : IsValueSolved - returns true if the value of Sym is solved.
3170 : : */
3171 : :
3172 : : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym);
3173 : :
3174 : : /*
3175 : : IsConstructorConstant - returns TRUE if constructor, Sym, is
3176 : : defined by only constants.
3177 : : */
3178 : :
3179 : : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym);
3180 : :
3181 : : /*
3182 : : IsComposite - returns TRUE if symbol, sym, is a composite
3183 : : type: ie an ARRAY or RECORD.
3184 : : */
3185 : :
3186 : : extern "C" bool SymbolTable_IsComposite (unsigned int sym);
3187 : :
3188 : : /*
3189 : : IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
3190 : : */
3191 : :
3192 : : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym);
3193 : :
3194 : : /*
3195 : : PutAlignment - assigns the alignment constant associated with,
3196 : : type, with, align.
3197 : : */
3198 : :
3199 : : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align);
3200 : :
3201 : : /*
3202 : : GetAlignment - returns the alignment constant associated with,
3203 : : type.
3204 : : */
3205 : :
3206 : : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type);
3207 : :
3208 : : /*
3209 : : GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
3210 : : to record, sym.
3211 : : */
3212 : :
3213 : : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym);
3214 : :
3215 : : /*
3216 : : PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
3217 : : to record, sym.
3218 : : */
3219 : :
3220 : : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align);
3221 : :
3222 : : /*
3223 : : PutUnused - sets, sym, as unused. This is a gm2 pragma.
3224 : : */
3225 : :
3226 : : extern "C" void SymbolTable_PutUnused (unsigned int sym);
3227 : :
3228 : : /*
3229 : : IsUnused - returns TRUE if the symbol was declared as unused with a
3230 : : gm2 pragma.
3231 : : */
3232 : :
3233 : : extern "C" bool SymbolTable_IsUnused (unsigned int sym);
3234 : :
3235 : : /*
3236 : : PutDeclaredPacked - sets the Packed field of the record or record field symbol.
3237 : : */
3238 : :
3239 : : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b);
3240 : :
3241 : : /*
3242 : : IsDeclaredPacked - was the record symbol or record field, sym,
3243 : : declared as packed?
3244 : : */
3245 : :
3246 : : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym);
3247 : :
3248 : : /*
3249 : : IsDeclaredPackedResolved - do we know if the record symbol or record
3250 : : field, sym, declared as packed or not packed?
3251 : : */
3252 : :
3253 : : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym);
3254 : :
3255 : : /*
3256 : : GetPackedEquivalent - returns the packed equivalent of type, sym.
3257 : : sym must be a type, subrange or enumerated type.
3258 : : */
3259 : :
3260 : : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym);
3261 : :
3262 : : /*
3263 : : GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
3264 : : */
3265 : :
3266 : : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym);
3267 : :
3268 : : /*
3269 : : IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
3270 : : */
3271 : :
3272 : : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym);
3273 : :
3274 : : /*
3275 : : PushSize - pushes the size of Sym.
3276 : : */
3277 : :
3278 : : extern "C" void SymbolTable_PushSize (unsigned int Sym);
3279 : :
3280 : : /*
3281 : : PopSize - pops the ALU stack into Size of Sym.
3282 : : */
3283 : :
3284 : : extern "C" void SymbolTable_PopSize (unsigned int Sym);
3285 : :
3286 : : /*
3287 : : PushValue - pushes the Value of Sym onto the ALU stack.
3288 : : */
3289 : :
3290 : : extern "C" void SymbolTable_PushValue (unsigned int Sym);
3291 : :
3292 : : /*
3293 : : PushVarSize - pushes the size of a variable, Sym.
3294 : : The runtime size of Sym will depend upon its addressing mode,
3295 : : RightValue has size PushSize(GetType(Sym)) and
3296 : : LeftValue has size PushSize(Address) since it points to a
3297 : : variable.
3298 : : */
3299 : :
3300 : : extern "C" void SymbolTable_PushVarSize (unsigned int Sym);
3301 : :
3302 : : /*
3303 : : PopValue - pops the ALU stack into Value of Sym.
3304 : : */
3305 : :
3306 : : extern "C" void SymbolTable_PopValue (unsigned int Sym);
3307 : :
3308 : : /*
3309 : : IsObject - returns TRUE if the symbol is an object symbol.
3310 : : */
3311 : :
3312 : : extern "C" bool SymbolTable_IsObject (unsigned int Sym);
3313 : :
3314 : : /*
3315 : : IsTuple - returns TRUE if the symbol is a tuple symbol.
3316 : : */
3317 : :
3318 : : extern "C" bool SymbolTable_IsTuple (unsigned int Sym);
3319 : :
3320 : : /*
3321 : : Make2Tuple - creates and returns a 2 tuple from, a, and, b.
3322 : : */
3323 : :
3324 : : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b);
3325 : :
3326 : : /*
3327 : : MakeError - creates an error node, which can be used in MetaError messages.
3328 : : It will be removed from ExportUndeclared and Unknown trees.
3329 : : */
3330 : :
3331 : : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name);
3332 : :
3333 : : /*
3334 : : MakeErrorS - creates an error node from a string, which can be used
3335 : : in MetaError messages.
3336 : : It will be removed from ExportUndeclared and Unknown trees.
3337 : : */
3338 : :
3339 : : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name);
3340 : :
3341 : : /*
3342 : : IsError - returns TRUE if the symbol is an error symbol.
3343 : : */
3344 : :
3345 : : extern "C" bool SymbolTable_IsError (unsigned int Sym);
3346 : :
3347 : : /*
3348 : : IsLegal - returns TRUE if, sym, is a legal symbol.
3349 : : */
3350 : :
3351 : : extern "C" bool SymbolTable_IsLegal (unsigned int sym);
3352 : :
3353 : : /*
3354 : : PutModuleContainsBuiltin - sets a flag in the current compiled module which
3355 : : indicates that a builtin procedure is being declared.
3356 : : This is only expected to be called when we are
3357 : : parsing the definition module.
3358 : : */
3359 : :
3360 : : extern "C" void SymbolTable_PutModuleContainsBuiltin (void);
3361 : :
3362 : : /*
3363 : : IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
3364 : : */
3365 : :
3366 : : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym);
3367 : :
3368 : : /*
3369 : : PutHiddenTypeDeclared - sets a flag in the current compiled module which
3370 : : indicates that a Hidden Type is declared within
3371 : : the implementation part of the module.
3372 : : This procedure is expected to be called while
3373 : : compiling the associated definition module.
3374 : : */
3375 : :
3376 : : extern "C" void SymbolTable_PutHiddenTypeDeclared (void);
3377 : :
3378 : : /*
3379 : : IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
3380 : : the module, Sym.
3381 : : */
3382 : :
3383 : : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym);
3384 : :
3385 : : /*
3386 : : IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
3387 : : type declared as a pointer or address.
3388 : : */
3389 : :
3390 : : extern "C" bool SymbolTable_IsHiddenReallyPointer (unsigned int Sym);
3391 : :
3392 : : /*
3393 : : DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
3394 : : */
3395 : :
3396 : : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym);
3397 : :
3398 : : /*
3399 : : DebugLineNumbers - internal debugging, emit all procedure names in this module
3400 : : together with the line numbers for the corresponding begin/end
3401 : : tokens.
3402 : : */
3403 : :
3404 : : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym);
3405 : :
3406 : : /*
3407 : : GetErrorScope - returns the error scope for a symbol.
3408 : : The error scope is the title scope which is used to
3409 : : announce the symbol in the GCC error message.
3410 : : */
3411 : :
3412 : : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym);
3413 : :
3414 : : /*
3415 : : MakeImport - create and return an import symbol.
3416 : : moduleSym is the symbol being imported.
3417 : : isqualified is FALSE if it were IMPORT modulename and
3418 : : TRUE for the qualified FROM modulename IMPORT etc.
3419 : : listno is the import list count for this module.
3420 : : tok should match this modulename position.
3421 : : */
3422 : :
3423 : : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified);
3424 : :
3425 : : /*
3426 : : MakeImportStatement - return a dependent symbol which represents an import statement
3427 : : or a qualified import statement. The tok should either match
3428 : : the FROM token or the IMPORT token. listno is the import list
3429 : : count for the module.
3430 : : */
3431 : :
3432 : : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno);
3433 : :
3434 : : /*
3435 : : IsImport - returns TRUE if sym is an import symbol.
3436 : : */
3437 : :
3438 : : extern "C" bool SymbolTable_IsImport (unsigned int sym);
3439 : :
3440 : : /*
3441 : : IsImportStatement - returns TRUE if sym is a dependent symbol.
3442 : : */
3443 : :
3444 : : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym);
3445 : :
3446 : : /*
3447 : : GetImportModule - returns the module associated with the import symbol.
3448 : : */
3449 : :
3450 : : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym);
3451 : :
3452 : : /*
3453 : : GetImportDeclared - returns the token associated with the import symbol.
3454 : : */
3455 : :
3456 : : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym);
3457 : :
3458 : : /*
3459 : : GetImportStatementList - returns the list of imports for this dependent.
3460 : : Each import symbol corresponds to a module.
3461 : : */
3462 : :
3463 : : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym);
3464 : :
3465 : : /*
3466 : : GetModuleDefImportStatementList - returns the list of dependents associated with
3467 : : the definition module.
3468 : : */
3469 : :
3470 : : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym);
3471 : :
3472 : : /*
3473 : : GetModuleModImportStatementList - returns the list of dependents associated with
3474 : : the implementation or program module.
3475 : : */
3476 : :
3477 : : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym);
3478 : :
3479 : : /*
3480 : : AppendModuleImportStatement - appends the ImportStatement symbol onto the
3481 : : module import list.
3482 : :
3483 : : For example:
3484 : :
3485 : : FROM x IMPORT y, z ;
3486 : : ^^^^
3487 : :
3488 : : also:
3489 : :
3490 : : IMPORT p, q, r;
3491 : : ^^^^^^
3492 : : will result in a new ImportStatement symbol added
3493 : : to the current module import list.
3494 : : The statement symbol is expected to be created
3495 : : by MakeImportStatement using the token positions
3496 : : outlined above.
3497 : : */
3498 : :
3499 : : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement);
3500 : :
3501 : : /*
3502 : : AppendModuleOnImportStatement - appends the import symbol onto the
3503 : : dependent list (chain).
3504 : :
3505 : : For example each:
3506 : :
3507 : : FROM x IMPORT y, z ;
3508 : : ^
3509 : : x are added to the dependent list.
3510 : :
3511 : : also:
3512 : :
3513 : : IMPORT p, q, r;
3514 : : ^ ^ ^
3515 : : will result in p, q and r added to
3516 : : to the dependent list.
3517 : :
3518 : : The import symbol is created by MakeImport
3519 : : and the token is expected to match the module
3520 : : name position outlined above.
3521 : : */
3522 : :
3523 : : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import);
3524 : :
3525 : : /*
3526 : : PutModLink - assigns link to module sym.
3527 : : */
3528 : :
3529 : : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link);
3530 : :
3531 : : /*
3532 : : IsModLink - returns the ModLink value associated with the module symbol.
3533 : : */
3534 : :
3535 : : extern "C" bool SymbolTable_IsModLink (unsigned int sym);
3536 : :
3537 : : /*
3538 : : PutDefLink - assigns link to the definition module sym.
3539 : : */
3540 : :
3541 : : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link);
3542 : :
3543 : : /*
3544 : : IsDefLink - returns the DefLink value associated with the definition module symbol.
3545 : : */
3546 : :
3547 : : extern "C" bool SymbolTable_IsDefLink (unsigned int sym);
3548 : :
3549 : : /*
3550 : : IsModuleBuiltin - returns TRUE if the module is a builtin module.
3551 : : (For example _BaseTypes).
3552 : : */
3553 : :
3554 : : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym);
3555 : :
3556 : : /*
3557 : : PutModuleBuiltin - sets the Builtin flag to value.
3558 : : Currently the procedure expects sym to be a DefImp
3559 : : module only.
3560 : : */
3561 : :
3562 : : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value);
3563 : :
3564 : : /*
3565 : : PutVarArrayRef - assigns ArrayRef field with value.
3566 : : */
3567 : :
3568 : : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value);
3569 : :
3570 : : /*
3571 : : IsVarArrayRef - returns ArrayRef field value.
3572 : : */
3573 : :
3574 : : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym);
3575 : :
3576 : : /*
3577 : : VarCheckReadInit - returns TRUE if sym has been initialized.
3578 : : */
3579 : :
3580 : : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode);
3581 : :
3582 : : /*
3583 : : VarInitState - initializes the init state for variable sym.
3584 : : */
3585 : :
3586 : : extern "C" void SymbolTable_VarInitState (unsigned int sym);
3587 : :
3588 : : /*
3589 : : PutVarInitialized - set sym as initialized.
3590 : : */
3591 : :
3592 : : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode);
3593 : :
3594 : : /*
3595 : : PutVarFieldInitialized - records that field has been initialized with
3596 : : variable sym. TRUE is returned if the field
3597 : : is detected and changed to initialized.
3598 : : */
3599 : :
3600 : : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
3601 : :
3602 : : /*
3603 : : GetVarFieldInitialized - return TRUE if fieldlist has been initialized
3604 : : within variable sym.
3605 : : */
3606 : :
3607 : : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
3608 : :
3609 : : /*
3610 : : PrintInitialized - display variable sym initialization state.
3611 : : */
3612 : :
3613 : : extern "C" void SymbolTable_PrintInitialized (unsigned int sym);
3614 : :
3615 : : /*
3616 : : GetParameterHeapVar - return the heap variable associated with the
3617 : : parameter or NulSym.
3618 : : */
3619 : :
3620 : : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym);
3621 : :
3622 : : /*
3623 : : PutProcedureParameterHeapVars - creates heap variables for parameter sym.
3624 : : */
3625 : :
3626 : : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym);
3627 : :
3628 : : /*
3629 : : IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
3630 : : for the target architecture.
3631 : : */
3632 : :
3633 : : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure);
3634 : :
3635 : : /*
3636 : : PutConstLitInternal - marks the sym as being an internal constant.
3637 : : Currently this is used when generating a default
3638 : : BY constant expression during a FOR loop.
3639 : : A constant marked as internal will always pass
3640 : : an expression type check.
3641 : : */
3642 : :
3643 : : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value);
3644 : :
3645 : : /*
3646 : : IsConstLitInternal - returns the value of the IsInternal field within
3647 : : a constant expression.
3648 : : */
3649 : :
3650 : : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym);
3651 : :
3652 : : /*
3653 : : GetVarDeclTypeTok - returns the TypeTok field associate with variable sym.
3654 : : */
3655 : :
3656 : : extern "C" unsigned int SymbolTable_GetVarDeclTypeTok (unsigned int sym);
3657 : :
3658 : : /*
3659 : : PutVarDeclTypeTok - assigns the TypeTok field to typetok.
3660 : : sym can be a variable or parameter.
3661 : : */
3662 : :
3663 : : extern "C" void SymbolTable_PutVarDeclTypeTok (unsigned int sym, unsigned int typetok);
3664 : :
3665 : : /*
3666 : : GetVarDeclTok - returns the TypeTok field associate with variable sym.
3667 : : */
3668 : :
3669 : : extern "C" unsigned int SymbolTable_GetVarDeclTok (unsigned int sym);
3670 : :
3671 : : /*
3672 : : PutVarDeclTok - assigns the VarTok field to typetok.
3673 : : sym can be a variable or parameter.
3674 : : */
3675 : :
3676 : : extern "C" void SymbolTable_PutVarDeclTok (unsigned int sym, unsigned int vartok);
3677 : :
3678 : : /*
3679 : : GetVarDeclFullTok - returns the full virtual token containing var: type.
3680 : : */
3681 : :
3682 : : extern "C" unsigned int SymbolTable_GetVarDeclFullTok (unsigned int sym);
3683 : :
3684 : : /*
3685 : : IsProcedureAnyNoReturn - return TRUE if any of the defined kinds
3686 : : of procedure sym is declared no return.
3687 : : */
3688 : :
3689 : : extern "C" bool SymbolTable_IsProcedureAnyNoReturn (unsigned int sym);
3690 : :
3691 : : /*
3692 : : GetNthParamAny - returns the nth parameter from the order
3693 : : proper procedure, forward declaration
3694 : : or definition module procedure.
3695 : : */
3696 : :
3697 : : extern "C" unsigned int SymbolTable_GetNthParamAny (unsigned int sym, unsigned int ParamNo);
3698 : :
3699 : : /*
3700 : : NoOfParamAny - return the number of parameters for sym.
3701 : : */
3702 : :
3703 : : extern "C" unsigned int SymbolTable_NoOfParamAny (unsigned int sym);
3704 : :
3705 : : /*
3706 : : SetReturnOptional - sets the ReturnOptional field in the Procedure:kind or
3707 : : ProcType symboltable entry.
3708 : : */
3709 : :
3710 : : extern "C" void SymbolTable_SetReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind, bool isopt);
3711 : :
3712 : : /*
3713 : : UsesOptArgAny - returns TRUE if procedure Sym:kind uses an optional argument.
3714 : : */
3715 : :
3716 : : extern "C" bool SymbolTable_UsesOptArgAny (unsigned int Sym);
3717 : :
3718 : : /*
3719 : : GetProcedureKindDesc - return a string describing kind.
3720 : : */
3721 : :
3722 : : extern "C" DynamicStrings_String SymbolTable_GetProcedureKindDesc (SymbolTable_ProcedureKind kind);
3723 : :
3724 : : /*
3725 : : GetNthParamAnyClosest - returns the nth parameter from the order
3726 : : proper procedure, forward declaration
3727 : : or definition module procedure.
3728 : : It chooses the parameter which is closest
3729 : : in source terms to currentmodule.
3730 : : The same module will return using the order
3731 : : proper procedure, forward procedure, definition module.
3732 : : Whereas an imported procedure will choose from
3733 : : DefProcedure, ProperProcedure, ForwardProcedure.
3734 : : */
3735 : :
3736 : : extern "C" unsigned int SymbolTable_GetNthParamAnyClosest (unsigned int sym, unsigned int ParamNo, unsigned int currentmodule);
3737 : : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at);
3738 : :
3739 : : /*
3740 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
3741 : : */
3742 : :
3743 : : static void InitWhereDeclared (SymbolTable_Where *at);
3744 : :
3745 : : /*
3746 : : InitWhereFirstUsed - sets the FirstUsed field of record, at.
3747 : : */
3748 : :
3749 : : static void InitWhereFirstUsed (SymbolTable_Where *at);
3750 : :
3751 : : /*
3752 : : InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
3753 : : */
3754 : :
3755 : : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at);
3756 : :
3757 : : /*
3758 : : gdbhook - a debugger convenience hook.
3759 : : */
3760 : :
3761 : : static void gdbhook (void);
3762 : :
3763 : : /*
3764 : : BreakWhenSymCreated - to be called interactively by gdb.
3765 : : */
3766 : :
3767 : : static void BreakWhenSymCreated (unsigned int sym);
3768 : :
3769 : : /*
3770 : : CheckBreak - if sym = BreakSym then call gdbhook.
3771 : : */
3772 : :
3773 : : static void CheckBreak (unsigned int sym);
3774 : :
3775 : : /*
3776 : : NewSym - Sets Sym to a new symbol index.
3777 : : */
3778 : :
3779 : : static void NewSym (unsigned int *sym);
3780 : :
3781 : : /*
3782 : : GetPsym - returns the pointer to, sym.
3783 : : */
3784 : :
3785 : : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym);
3786 : :
3787 : : /*
3788 : : GetPcall - returns the pointer to the CallFrame.
3789 : : */
3790 : :
3791 : : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call);
3792 : :
3793 : : /*
3794 : : DebugProcedureLineNumber -
3795 : : */
3796 : :
3797 : : static void DebugProcedureLineNumber (unsigned int sym);
3798 : :
3799 : : /*
3800 : : PutPartialUnbounded -
3801 : : */
3802 : :
3803 : : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim);
3804 : :
3805 : : /*
3806 : : AlreadyDeclaredError - generate an error message, a, and two areas of code showing
3807 : : the places where the symbols were declared.
3808 : : */
3809 : :
3810 : : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance);
3811 : :
3812 : : /*
3813 : : MakeObject - creates an object node.
3814 : : */
3815 : :
3816 : : static unsigned int MakeObject (NameKey_Name name);
3817 : :
3818 : : /*
3819 : : DeclareSym - returns a symbol which was either in the unknown tree or
3820 : : a New symbol, since name is about to be declared.
3821 : : */
3822 : :
3823 : : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name);
3824 : :
3825 : : /*
3826 : : Init - Initializes the data structures and variables in this module.
3827 : : Initialize the trees.
3828 : : */
3829 : :
3830 : : static void Init (void);
3831 : :
3832 : : /*
3833 : : AddSymToUnknown -
3834 : : */
3835 : :
3836 : : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym);
3837 : :
3838 : : /*
3839 : : AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
3840 : : unknown tree.
3841 : : */
3842 : :
3843 : : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym);
3844 : :
3845 : : /*
3846 : : SubSymFromUnknownTree - removes a symbol with name, name, from the
3847 : : unknown tree.
3848 : : */
3849 : :
3850 : : static void SubSymFromUnknownTree (NameKey_Name name);
3851 : :
3852 : : /*
3853 : : GetSymFromUnknownTree - returns a symbol with name, name, from the
3854 : : unknown tree.
3855 : : If no symbol with name is found then NulSym
3856 : : is returned.
3857 : : */
3858 : :
3859 : : static unsigned int GetSymFromUnknownTree (NameKey_Name name);
3860 : :
3861 : : /*
3862 : : ExamineUnresolvedTree - returns a symbol with name, name, from the
3863 : : unresolved tree of module, ModSym.
3864 : : If no symbol with name is found then NulSym
3865 : : is returned.
3866 : : */
3867 : :
3868 : : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
3869 : :
3870 : : /*
3871 : : RemoveFromUnresolvedTree - removes a symbol with name, name, from the
3872 : : unresolved tree of symbol, ScopeSym.
3873 : : */
3874 : :
3875 : : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
3876 : :
3877 : : /*
3878 : : FetchUnknownSym - returns a symbol from the unknown tree if one is
3879 : : available. It also updates the unknown tree.
3880 : : */
3881 : :
3882 : : static unsigned int FetchUnknownSym (NameKey_Name name);
3883 : :
3884 : : /*
3885 : : TransparentScope - returns true is the scope symbol Sym is allowed
3886 : : to look to an outer level for a symbol.
3887 : : ie is the symbol allowed to look to the parent
3888 : : scope for a symbol.
3889 : : */
3890 : :
3891 : : static bool TransparentScope (unsigned int Sym);
3892 : :
3893 : : /*
3894 : : GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
3895 : : the scope before the current module scope.
3896 : : */
3897 : :
3898 : : static unsigned int GetLastModuleOrProcedureScope (void);
3899 : :
3900 : : /*
3901 : : AddSymToScope - adds a symbol Sym with name name to
3902 : : the current scope symbol tree.
3903 : : */
3904 : :
3905 : : static void AddSymToScope (unsigned int Sym, NameKey_Name name);
3906 : :
3907 : : /*
3908 : : PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
3909 : : Procedure symbols enumeration
3910 : : list onto the scope stack.
3911 : : */
3912 : :
3913 : : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym);
3914 : :
3915 : : /*
3916 : : PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
3917 : : scope stack. This list will automatically
3918 : : removed via one call to EndScope which
3919 : : matches the StartScope by which this
3920 : : procedure is invoked.
3921 : : */
3922 : :
3923 : : static void PlaceEnumerationListOntoScope (Lists_List l);
3924 : :
3925 : : /*
3926 : : SetFirstUsed - assigns the FirstUsed field in at to tok providing
3927 : : it has not already been set.
3928 : : */
3929 : :
3930 : : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at);
3931 : :
3932 : : /*
3933 : : PutFirstUsed - sets tok to the first used providing it has not already been set.
3934 : : It also includes the read and write quad into the usage list
3935 : : providing the quad numbers are not 0.
3936 : : */
3937 : :
3938 : : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_);
3939 : :
3940 : : /*
3941 : : CanLookThroughScope - by default this procedure returns TRUE. It only returns
3942 : : FALSE if, throughProcedure, is FALSE and the ScopeSym is
3943 : : a procedure.
3944 : : */
3945 : :
3946 : : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure);
3947 : :
3948 : : /*
3949 : : GetScopeSym - searches the current scope and below, providing that the
3950 : : scopes are transparent, for a symbol with name, name.
3951 : : It only passes over procedure scopes if, throughProcedure,
3952 : : is TRUE.
3953 : : */
3954 : :
3955 : : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure);
3956 : :
3957 : : /*
3958 : : CheckScopeForSym - checks the scope, ScopeSym, for an identifier
3959 : : of name, name. CheckScopeForSym checks for
3960 : : the symbol by the GetLocalSym and also
3961 : : ExamineUnresolvedTree.
3962 : : */
3963 : :
3964 : : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name);
3965 : :
3966 : : /*
3967 : : GetModuleScopeId - returns the scope index to the next module starting
3968 : : at index, Id.
3969 : : Id will either point to a null scope (NulSym) or
3970 : : alternatively point to a Module or DefImp symbol.
3971 : : */
3972 : :
3973 : : static unsigned int GetModuleScopeId (unsigned int Id);
3974 : :
3975 : : /*
3976 : : GetVisibleSym -
3977 : : */
3978 : :
3979 : : static unsigned int GetVisibleSym (NameKey_Name name);
3980 : :
3981 : : /*
3982 : : IsAlreadyDeclaredSym - returns true if Sym has already been declared
3983 : : in the current main scope.
3984 : : */
3985 : :
3986 : : static bool IsAlreadyDeclaredSym (NameKey_Name name);
3987 : :
3988 : : /*
3989 : : GenName - returns a new name consisting of pre, name, post concatenation.
3990 : : */
3991 : :
3992 : : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high);
3993 : :
3994 : : /*
3995 : : InitCtor - initialize the ModuleCtor fields to NulSym.
3996 : : */
3997 : :
3998 : : static void InitCtor (SymbolTable_ModuleCtor *ctor);
3999 : :
4000 : : /*
4001 : : InitCtorFields - initialize the ModuleCtor fields. An inner module has no
4002 : : ctor procedure.
4003 : : */
4004 : :
4005 : : 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);
4006 : :
4007 : : /*
4008 : : CheckTok - checks to see that tok is at a known location. If not
4009 : : it uses GetTokenNo as a fall back.
4010 : : */
4011 : :
4012 : : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high);
4013 : :
4014 : : /*
4015 : : GetLink - returns TRUE if the current module is only used for linkage.
4016 : : */
4017 : :
4018 : : static bool GetLink (void);
4019 : :
4020 : : /*
4021 : : AddModuleToParent - adds symbol, Sym, to module, Parent.
4022 : : */
4023 : :
4024 : : static void AddModuleToParent (unsigned int Sym, unsigned int Parent);
4025 : :
4026 : : /*
4027 : : PutProcedureExternPublic - if procedure is not NulSym set extern
4028 : : and public booleans.
4029 : : */
4030 : :
4031 : : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub);
4032 : :
4033 : : /*
4034 : : PutCtorExtern -
4035 : : */
4036 : :
4037 : : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_);
4038 : :
4039 : : /*
4040 : : InitProcedureDeclaration - initialize all the ProcedureDeclaration
4041 : : fields.
4042 : : */
4043 : :
4044 : : static void InitProcedureDeclaration (SymbolTable_ProcedureDeclaration *decl);
4045 : :
4046 : : /*
4047 : : AddProcedureToList - adds a procedure, Proc, to the list of procedures
4048 : : in module, Mod.
4049 : : */
4050 : :
4051 : : static void AddProcedureToList (unsigned int Mod, unsigned int Proc);
4052 : :
4053 : : /*
4054 : : AddVarToScopeList - adds symbol, sym, to, scope.
4055 : : */
4056 : :
4057 : : static void AddVarToScopeList (unsigned int scope, unsigned int sym);
4058 : :
4059 : : /*
4060 : : AddVarToList - add a variable symbol to the list of variables maintained
4061 : : by the inner most scope. (Procedure or Module).
4062 : : */
4063 : :
4064 : : static void AddVarToList (unsigned int Sym);
4065 : :
4066 : : /*
4067 : : InitVarDecl - initialize the variable and type token location positions.
4068 : : */
4069 : :
4070 : : static void InitVarDecl (SymbolTable_VarDecl *decl, unsigned int vartok);
4071 : :
4072 : : /*
4073 : : doPutVarDeclTypeTok - places typetok into decl.TypeTok.
4074 : : sym must be a variable.
4075 : : */
4076 : :
4077 : : static void doPutVarDeclTypeTok (unsigned int sym, unsigned int typetok);
4078 : :
4079 : : /*
4080 : : doPutVarDeclTok - places vartok into decl.VarTok.
4081 : : sym must be a variable.
4082 : : */
4083 : :
4084 : : static void doPutVarDeclTok (unsigned int sym, unsigned int vartok);
4085 : :
4086 : : /*
4087 : : doGetVarDeclTok - return decl.VarTok for a variable.
4088 : : */
4089 : :
4090 : : static unsigned int doGetVarDeclTok (unsigned int sym);
4091 : :
4092 : : /*
4093 : : doGetVarDeclTypeTok - return decl.TypeTok for a variable.
4094 : : */
4095 : :
4096 : : static unsigned int doGetVarDeclTypeTok (unsigned int sym);
4097 : :
4098 : : /*
4099 : : doGetVarDeclFullTok - return the full declaration of var: type.
4100 : : */
4101 : :
4102 : : static unsigned int doGetVarDeclFullTok (unsigned int sym);
4103 : :
4104 : : /*
4105 : : FillInRecordFields - given a new symbol, sym, make it a record symbol
4106 : : and initialize its fields.
4107 : : */
4108 : :
4109 : : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf);
4110 : :
4111 : : /*
4112 : : HandleHiddenOrDeclare -
4113 : : */
4114 : :
4115 : : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf);
4116 : :
4117 : : /*
4118 : : CreateConstLit -
4119 : : */
4120 : :
4121 : : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
4122 : :
4123 : : /*
4124 : : LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
4125 : : matches tok, constName and constType.
4126 : : */
4127 : :
4128 : : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType);
4129 : :
4130 : : /*
4131 : : AddConstLitPoolEntry - adds sym to the constlit pool.
4132 : : */
4133 : :
4134 : : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType);
4135 : :
4136 : : /*
4137 : : InitConstString - initialize the constant string.
4138 : : */
4139 : :
4140 : : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known);
4141 : :
4142 : : /*
4143 : : GetConstStringKind - return the StringVariant field associated with sym.
4144 : : */
4145 : :
4146 : : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym);
4147 : :
4148 : : /*
4149 : : CanUseBuiltin - returns TRUE if the procedure, Sym, can be
4150 : : inlined via a builtin function.
4151 : : */
4152 : :
4153 : : static bool CanUseBuiltin (unsigned int Sym);
4154 : :
4155 : : /*
4156 : : InitPacked - initialise packedInfo to FALSE and NulSym.
4157 : : */
4158 : :
4159 : : static void InitPacked (SymbolTable_PackedInfo *packedInfo);
4160 : :
4161 : : /*
4162 : : doEquivalent - create a packed equivalent symbol for, sym, and return the
4163 : : new symbol. It sets both fields in packedInfo to FALSE
4164 : : and the new symbol.
4165 : : */
4166 : :
4167 : : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
4168 : :
4169 : : /*
4170 : : MakeEquivalent - return the equivalent packed symbol for, sym.
4171 : : */
4172 : :
4173 : : static unsigned int MakeEquivalent (unsigned int sym);
4174 : :
4175 : : /*
4176 : : GetEquivalent -
4177 : : */
4178 : :
4179 : : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
4180 : :
4181 : : /*
4182 : : doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
4183 : : */
4184 : :
4185 : : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase);
4186 : :
4187 : : /*
4188 : : GetTypeOfVar - returns the type of symbol, var.
4189 : : */
4190 : :
4191 : : static unsigned int GetTypeOfVar (unsigned int var);
4192 : :
4193 : : /*
4194 : : GetConstLitType - returns the type of the constant of, name.
4195 : : All floating point constants have type LONGREAL.
4196 : : Character constants are type CHAR.
4197 : : Integer values are INTEGER, LONGINT or LONGCARD
4198 : : depending upon their value.
4199 : : */
4200 : :
4201 : : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError);
4202 : :
4203 : : /*
4204 : : GetNthFromComponent -
4205 : : */
4206 : :
4207 : : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n);
4208 : :
4209 : : /*
4210 : : GetNthParamChoice - returns the parameter definition from
4211 : : sym:ParamNo:kind or NulSym.
4212 : : */
4213 : :
4214 : : static unsigned int GetNthParamChoice (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind kind);
4215 : :
4216 : : /*
4217 : : GetNthParamOrdered - returns the parameter definition from list {a, b, c}
4218 : : in order.
4219 : : sym:ParamNo:{a,b,c} or NulSym.
4220 : : */
4221 : :
4222 : : static unsigned int GetNthParamOrdered (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind a, SymbolTable_ProcedureKind b, SymbolTable_ProcedureKind c);
4223 : :
4224 : : /*
4225 : : GetOuterModuleScope - returns the outer module symbol scope for sym.
4226 : : */
4227 : :
4228 : : static unsigned int GetOuterModuleScope (unsigned int sym);
4229 : :
4230 : : /*
4231 : : EnsureOrder - providing that both symbols, a, and, b, exist in
4232 : : list, l. Ensure that, b, is placed after a.
4233 : : */
4234 : :
4235 : : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b);
4236 : :
4237 : : /*
4238 : : DumpSons -
4239 : : */
4240 : :
4241 : : static void DumpSons (unsigned int sym);
4242 : :
4243 : : /*
4244 : : CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
4245 : : */
4246 : :
4247 : : static void CheckListOfSons (unsigned int sym);
4248 : :
4249 : : /*
4250 : : CheckRecordConsistency -
4251 : : */
4252 : :
4253 : : static void CheckRecordConsistency (unsigned int sym);
4254 : :
4255 : : /*
4256 : : PutConstVarTemporary - indicates that constant, sym, is a temporary.
4257 : : */
4258 : :
4259 : : static void PutConstVarTemporary (unsigned int sym);
4260 : :
4261 : : /*
4262 : : buildTemporary - builds the temporary filling in componentRef, record and sets mode.
4263 : : */
4264 : :
4265 : : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record);
4266 : :
4267 : : /*
4268 : : AssertInRange - determines whether the Sym is a legal symbol.
4269 : : */
4270 : :
4271 : : static void AssertInRange (unsigned int Sym);
4272 : :
4273 : : /*
4274 : : CheckForHiddenType - scans the NeedToBeImplemented tree providing
4275 : : that we are currently compiling an implementation
4276 : : module. If a symbol is found with TypeName
4277 : : then its Sym is returned.
4278 : : Otherwise NulSym is returned.
4279 : : CheckForHiddenType is called before any type is
4280 : : created, therefore the compiler allows hidden
4281 : : types to be implemented using any type.
4282 : : */
4283 : :
4284 : : static unsigned int CheckForHiddenType (NameKey_Name TypeName);
4285 : :
4286 : : /*
4287 : : RequestFromModule - returns a symbol from module ModSym with name, SymName.
4288 : : */
4289 : :
4290 : : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4291 : :
4292 : : /*
4293 : : RequestFromDefinition - returns a symbol from module ModSym with name,
4294 : : SymName.
4295 : : */
4296 : :
4297 : : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4298 : :
4299 : : /*
4300 : : GetWhereImported - returns the token number where this symbol
4301 : : was imported into the current module.
4302 : : */
4303 : :
4304 : : static unsigned int GetWhereImported (unsigned int Sym);
4305 : :
4306 : : /*
4307 : : DisplayName - displays the name.
4308 : : */
4309 : :
4310 : : static void DisplayName (unsigned int sym);
4311 : :
4312 : : /*
4313 : : DisplaySymbol - displays the name of a symbol
4314 : : */
4315 : :
4316 : : static void DisplaySymbol (unsigned int sym);
4317 : :
4318 : : /*
4319 : : FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
4320 : : */
4321 : :
4322 : : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4323 : :
4324 : : /*
4325 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
4326 : : */
4327 : :
4328 : : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
4329 : :
4330 : : /*
4331 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
4332 : : */
4333 : :
4334 : : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName);
4335 : :
4336 : : /*
4337 : : UnknownSymbolError - displays symbol name for symbol, sym.
4338 : : */
4339 : :
4340 : : static void UnknownSymbolError (unsigned int sym);
4341 : :
4342 : : /*
4343 : : IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
4344 : : reported and is an unknown symbol.
4345 : : */
4346 : :
4347 : : static bool IsUnreportedUnknown (unsigned int sym);
4348 : :
4349 : : /*
4350 : : AddListify -
4351 : : */
4352 : :
4353 : : static void AddListify (unsigned int sym);
4354 : :
4355 : : /*
4356 : : Listify - convert tree into a string list and return the result.
4357 : : */
4358 : :
4359 : : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition);
4360 : :
4361 : : /*
4362 : : CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
4363 : : an unknown symbol. All unknown symbols are displayed
4364 : : together with an error message.
4365 : : */
4366 : :
4367 : : static void CheckForUnknowns (NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
4368 : :
4369 : : /*
4370 : : SymbolError - displays symbol name for symbol, Sym.
4371 : : */
4372 : :
4373 : : static void SymbolError (unsigned int Sym);
4374 : :
4375 : : /*
4376 : : CheckForSymbols - checks a binary tree, Tree, to see whether it contains
4377 : : any symbol. The tree is expected to be empty, if not
4378 : : then an error has occurred.
4379 : : */
4380 : :
4381 : : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
4382 : :
4383 : : /*
4384 : : PutExportUndeclared - places a symbol, Sym, into module, ModSym,
4385 : : ExportUndeclared list provided that Sym
4386 : : is unknown.
4387 : : */
4388 : :
4389 : : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym);
4390 : :
4391 : : /*
4392 : : GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
4393 : : which is in the ExportUndeclared list.
4394 : : */
4395 : :
4396 : : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name);
4397 : :
4398 : : /*
4399 : : RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
4400 : : ExportUndeclaredTree.
4401 : : */
4402 : :
4403 : : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym);
4404 : :
4405 : : /*
4406 : : CheckForExportedDeclaration - checks to see whether a definition module
4407 : : is currently being compiled, if so,
4408 : : symbol, Sym, is removed from the
4409 : : ExportUndeclared list.
4410 : : This procedure is called whenever a symbol
4411 : : is declared, thus attempting to reduce
4412 : : the ExportUndeclared list.
4413 : : */
4414 : :
4415 : : static void CheckForExportedDeclaration (unsigned int Sym);
4416 : :
4417 : : /*
4418 : : UndeclaredSymbolError - displays symbol name for symbol, Sym.
4419 : : */
4420 : :
4421 : : static void UndeclaredSymbolError (unsigned int Sym);
4422 : :
4423 : : /*
4424 : : RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
4425 : : NeedToBeImplemented list.
4426 : : */
4427 : :
4428 : : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym);
4429 : :
4430 : : /*
4431 : : RemoveFromExportRequest -
4432 : : */
4433 : :
4434 : : static void RemoveFromExportRequest (unsigned int Sym);
4435 : :
4436 : : /*
4437 : : RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
4438 : : (and its fields) from the ExportRequest tree.
4439 : : */
4440 : :
4441 : : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym);
4442 : :
4443 : : /*
4444 : : UnImplementedSymbolError - displays symbol name for symbol, Sym.
4445 : : */
4446 : :
4447 : : static void UnImplementedSymbolError (unsigned int Sym);
4448 : :
4449 : : /*
4450 : : CheckEnumerationInList - places symbol, Sym, in the list, l,
4451 : : providing it does not already exist.
4452 : : PseudoScope(Sym) is called if Sym needs to
4453 : : be added to the enumeration list, l.
4454 : : */
4455 : :
4456 : : static void CheckEnumerationInList (Lists_List l, unsigned int Sym);
4457 : :
4458 : : /*
4459 : : CheckIfEnumerationExported - An outer module may use an enumeration that
4460 : : is declared inside an inner module. The usage
4461 : : may occur before definition. The first pass
4462 : : exports a symbol, later the symbol is declared
4463 : : as an emumeration type. At this stage the
4464 : : CheckIfEnumerationExported procedure should be
4465 : : called. This procedure ripples from the current
4466 : : (inner) module to outer module and every time
4467 : : it is exported it must be added to the outer
4468 : : module EnumerationScopeList.
4469 : : */
4470 : :
4471 : : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId);
4472 : :
4473 : : /*
4474 : : CheckForEnumerationInOuterModule - checks to see whether the enumeration
4475 : : type symbol, Sym, has been entered into
4476 : : the outer module, OuterModule, scope list.
4477 : : OuterModule may be internal to the
4478 : : program module.
4479 : : */
4480 : :
4481 : : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule);
4482 : :
4483 : : /*
4484 : : MakeVariableForParam -
4485 : : */
4486 : :
4487 : : 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);
4488 : :
4489 : : /*
4490 : : AddParameter - adds a parameter ParSym to a procedure Sym.
4491 : : */
4492 : :
4493 : : static void AddParameter (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParSym);
4494 : :
4495 : : /*
4496 : : AddProcedureProcTypeParam - adds ParamType to the parameter ProcType
4497 : : associated with procedure Sym.
4498 : : */
4499 : :
4500 : : static void AddProcedureProcTypeParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded, bool isVarParam);
4501 : :
4502 : : /*
4503 : : IsNthParamVar - returns true if the n th parameter of the parameter list,
4504 : : List, is a VAR parameter.
4505 : : */
4506 : :
4507 : : static bool IsNthParamVar (Lists_List Head, unsigned int n);
4508 : :
4509 : : /*
4510 : : MakeParameterHeapVar - create a heap variable if sym is a pointer.
4511 : : */
4512 : :
4513 : : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode);
4514 : :
4515 : : /*
4516 : : PutParameterHeapVar - creates a heap variable associated with parameter sym.
4517 : : */
4518 : :
4519 : : static void PutParameterHeapVar (unsigned int sym);
4520 : :
4521 : : /*
4522 : : IsProcedureAnyBoolean - returns the boolean result from p
4523 : : for any of procedure kind which is defined.
4524 : : */
4525 : :
4526 : : static bool IsProcedureAnyBoolean (unsigned int sym, SymbolTable_ProcAnyBoolean p);
4527 : :
4528 : : /*
4529 : : IsProcedureAnyDefaultBoolean - returns the boolean result from p
4530 : : for any of procedure kind which is defined.
4531 : : */
4532 : :
4533 : : static bool IsProcedureAnyDefaultBoolean (unsigned int sym, bool default_, SymbolTable_ProcAnyBoolean p);
4534 : :
4535 : : /*
4536 : : FillInUnknownFields -
4537 : : */
4538 : :
4539 : : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName);
4540 : :
4541 : : /*
4542 : : FillInPointerFields - given a new symbol, sym, make it a pointer symbol
4543 : : and initialize its fields.
4544 : : */
4545 : :
4546 : : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf);
4547 : :
4548 : : /*
4549 : : ForeachParameterDo -
4550 : : */
4551 : :
4552 : : static void ForeachParameterDo (SymbolTable_CheckProcedure p);
4553 : :
4554 : : /*
4555 : : CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
4556 : : */
4557 : :
4558 : : static void CheckUnbounded (unsigned int Sym);
4559 : :
4560 : : /*
4561 : : PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
4562 : : */
4563 : :
4564 : : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf);
4565 : :
4566 : : /*
4567 : : doFillInOAFamily -
4568 : : */
4569 : :
4570 : : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded);
4571 : :
4572 : : /*
4573 : : FillInUnboundedFields -
4574 : : */
4575 : :
4576 : : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim);
4577 : :
4578 : : /*
4579 : : PutUnbounded - associates the unbounded symbol, open, with
4580 : : SimpleType.
4581 : : */
4582 : :
4583 : : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim);
4584 : :
4585 : : /*
4586 : : GetArrayDimension - returns the number of dimensions defined.
4587 : : */
4588 : :
4589 : : static unsigned int GetArrayDimension (unsigned int sym);
4590 : :
4591 : : /*
4592 : : ResolveConstructorType - if, sym, has an unresolved constructor type
4593 : : then attempt to resolve it by examining the
4594 : : from, type.
4595 : : */
4596 : :
4597 : : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres);
4598 : :
4599 : : /*
4600 : : IsConstructorResolved - returns TRUE if the constructor does not
4601 : : have an unresolved type.
4602 : : */
4603 : :
4604 : : static bool IsConstructorResolved (unsigned int sym);
4605 : :
4606 : : /*
4607 : : CanResolveConstructor - returns TRUE if the type of the constructor,
4608 : : sym, is known.
4609 : : */
4610 : :
4611 : : static bool CanResolveConstructor (unsigned int sym);
4612 : :
4613 : : /*
4614 : : CheckAllConstructorsResolved - checks to see that the
4615 : : UnresolvedConstructorType list is
4616 : : empty and if it is not then it
4617 : : generates error messages.
4618 : : */
4619 : :
4620 : : static void CheckAllConstructorsResolved (void);
4621 : :
4622 : : /*
4623 : : SanityCheckParameters -
4624 : : */
4625 : :
4626 : : static void SanityCheckParameters (unsigned int sym);
4627 : :
4628 : : /*
4629 : : SanityCheckArray - checks to see that an array has a correct subrange type.
4630 : : */
4631 : :
4632 : : static void SanityCheckArray (unsigned int sym);
4633 : :
4634 : : /*
4635 : : ForeachSymbolDo - foreach symbol, call, P(sym).
4636 : : */
4637 : :
4638 : : static void ForeachSymbolDo (SymbolKey_PerformOperation P);
4639 : :
4640 : : /*
4641 : : SanityCheckProcedure - check to see that procedure parameters do not use constants
4642 : : instead of types in their formal parameter section.
4643 : : */
4644 : :
4645 : : static void SanityCheckProcedure (unsigned int sym);
4646 : :
4647 : : /*
4648 : : SanityCheckModule -
4649 : : */
4650 : :
4651 : : static void SanityCheckModule (unsigned int sym);
4652 : :
4653 : : /*
4654 : : AddNameTo - adds Name, n, to tree, s.
4655 : : */
4656 : :
4657 : : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o);
4658 : :
4659 : : /*
4660 : : CollectSymbolFrom -
4661 : : */
4662 : :
4663 : : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n);
4664 : :
4665 : : /*
4666 : : CollectUnknown -
4667 : : */
4668 : :
4669 : : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n);
4670 : :
4671 : : /*
4672 : : ResolveImport -
4673 : : */
4674 : :
4675 : : static void ResolveImport (unsigned int o);
4676 : :
4677 : : /*
4678 : : ResolveRelativeImport -
4679 : : */
4680 : :
4681 : : static void ResolveRelativeImport (unsigned int sym);
4682 : :
4683 : : /*
4684 : : Max -
4685 : : */
4686 : :
4687 : : static unsigned int Max (unsigned int a, unsigned int b);
4688 : :
4689 : : /*
4690 : : Min -
4691 : : */
4692 : :
4693 : : static unsigned int Min (unsigned int a, unsigned int b);
4694 : :
4695 : : /*
4696 : : DoFindLimits - assigns, Start, and, End, to the start and end
4697 : : limits contained in the list, l. It ensures that
4698 : : Start and End are within StartLimit..EndLimit.
4699 : : If StartLimit or EndLimit are 0 then Start is
4700 : : is set to the first value and End to the last.
4701 : : */
4702 : :
4703 : : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l);
4704 : :
4705 : : /*
4706 : : PutDeclaredDefinition - associates the current tokenno with
4707 : : the symbols declaration in the definition
4708 : : module.
4709 : : */
4710 : :
4711 : : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym);
4712 : :
4713 : : /*
4714 : : PutDeclaredModule - returns the token where this symbol was declared
4715 : : in an implementation or program module.
4716 : : */
4717 : :
4718 : : static void PutDeclaredModule (unsigned int tok, unsigned int Sym);
4719 : :
4720 : : /*
4721 : : DoIsConst - returns TRUE if Sym is defined as a constant
4722 : : or is an enumeration field or string.
4723 : : */
4724 : :
4725 : : static bool DoIsConst (unsigned int Sym);
4726 : :
4727 : : /*
4728 : : GetFromIndex - return a value from list, i, at position, n.
4729 : : */
4730 : :
4731 : : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n);
4732 : :
4733 : : /*
4734 : : PutIntoIndex - places value, v, into list, i, at position, n.
4735 : : */
4736 : :
4737 : : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v);
4738 : :
4739 : : /*
4740 : : PushConstString - pushes the character string onto the ALU stack.
4741 : : It assumes that the character string is only
4742 : : one character long.
4743 : : */
4744 : :
4745 : : static void PushConstString (unsigned int Sym);
4746 : :
4747 : 38565679 : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at)
4748 : : {
4749 : : /*
4750 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
4751 : : */
4752 : 38565679 : if (M2Comp_CompilingDefinitionModule ())
4753 : : {
4754 : 22599749 : (*at).DefDeclared = tok;
4755 : 22599749 : (*at).ModDeclared = M2LexBuf_UnknownTokenNo;
4756 : : }
4757 : : else
4758 : : {
4759 : 15965930 : (*at).DefDeclared = M2LexBuf_UnknownTokenNo;
4760 : 15965930 : (*at).ModDeclared = tok;
4761 : : }
4762 : 38565679 : (*at).FirstUsed = tok; /* we assign this field to something legal */
4763 : 38565679 : }
4764 : :
4765 : :
4766 : : /*
4767 : : InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
4768 : : */
4769 : :
4770 : 11381552 : static void InitWhereDeclared (SymbolTable_Where *at)
4771 : : {
4772 : 11381552 : InitWhereDeclaredTok (M2LexBuf_GetTokenNo (), at);
4773 : 11381552 : }
4774 : :
4775 : :
4776 : : /*
4777 : : InitWhereFirstUsed - sets the FirstUsed field of record, at.
4778 : : */
4779 : :
4780 : 4865196 : static void InitWhereFirstUsed (SymbolTable_Where *at)
4781 : : {
4782 : 0 : InitWhereFirstUsedTok (M2LexBuf_GetTokenNo (), at);
4783 : 0 : }
4784 : :
4785 : :
4786 : : /*
4787 : : InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
4788 : : */
4789 : :
4790 : 21052490 : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at)
4791 : : {
4792 : 21052490 : (*at).FirstUsed = tok;
4793 : 979285 : }
4794 : :
4795 : :
4796 : : /*
4797 : : gdbhook - a debugger convenience hook.
4798 : : */
4799 : :
4800 : 0 : static void gdbhook (void)
4801 : : {
4802 : 0 : }
4803 : :
4804 : :
4805 : : /*
4806 : : BreakWhenSymCreated - to be called interactively by gdb.
4807 : : */
4808 : :
4809 : 15260 : static void BreakWhenSymCreated (unsigned int sym)
4810 : : {
4811 : 15260 : BreakSym = sym;
4812 : 0 : }
4813 : :
4814 : :
4815 : : /*
4816 : : CheckBreak - if sym = BreakSym then call gdbhook.
4817 : : */
4818 : :
4819 : 0 : static void CheckBreak (unsigned int sym)
4820 : : {
4821 : 0 : if (sym == BreakSym)
4822 : : {
4823 : 0 : gdbhook ();
4824 : : }
4825 : 0 : }
4826 : :
4827 : :
4828 : : /*
4829 : : NewSym - Sets Sym to a new symbol index.
4830 : : */
4831 : :
4832 : 41535635 : static void NewSym (unsigned int *sym)
4833 : : {
4834 : 41535635 : SymbolTable_PtrToSymbol pSym;
4835 : :
4836 : 41535635 : (*sym) = FreeSymbol;
4837 : 41535635 : Storage_ALLOCATE ((void **) &pSym, sizeof (SymbolTable_Symbol));
4838 : 41535635 : pSym->SymbolType = SymbolTable_DummySym;
4839 : 41535635 : Indexing_PutIndice (Symbols, (*sym), reinterpret_cast <void *> (pSym));
4840 : 41535635 : CheckBreak ((*sym));
4841 : 41535635 : FreeSymbol += 1;
4842 : 41535635 : }
4843 : :
4844 : :
4845 : : /*
4846 : : GetPsym - returns the pointer to, sym.
4847 : : */
4848 : :
4849 : 6233369471 : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym)
4850 : : {
4851 : 6233369471 : SymbolTable_PtrToSymbol pSym;
4852 : :
4853 : 6233369471 : if (Indexing_InBounds (Symbols, sym))
4854 : : {
4855 : 6233369471 : pSym = static_cast<SymbolTable_PtrToSymbol> (Indexing_GetIndice (Symbols, sym));
4856 : 6233369471 : return pSym;
4857 : : }
4858 : : else
4859 : : {
4860 : 0 : M2Error_InternalError ((const char *) "symbol out of bounds", 20);
4861 : : }
4862 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
4863 : : __builtin_unreachable ();
4864 : : }
4865 : :
4866 : :
4867 : : /*
4868 : : GetPcall - returns the pointer to the CallFrame.
4869 : : */
4870 : :
4871 : 258768233 : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call)
4872 : : {
4873 : 258768233 : SymbolTable_PtrToCallFrame pCall;
4874 : :
4875 : 258768233 : if (Indexing_InBounds (ScopeCallFrame, call))
4876 : : {
4877 : 258768233 : pCall = static_cast<SymbolTable_PtrToCallFrame> (Indexing_GetIndice (ScopeCallFrame, call));
4878 : 258768233 : return pCall;
4879 : : }
4880 : : else
4881 : : {
4882 : 0 : M2Error_InternalError ((const char *) "symbol out of bounds", 20);
4883 : : }
4884 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
4885 : : __builtin_unreachable ();
4886 : : }
4887 : :
4888 : :
4889 : : /*
4890 : : DebugProcedureLineNumber -
4891 : : */
4892 : :
4893 : 0 : static void DebugProcedureLineNumber (unsigned int sym)
4894 : : {
4895 : 0 : unsigned int begin;
4896 : 0 : unsigned int end;
4897 : 0 : NameKey_Name n;
4898 : 0 : DynamicStrings_String f;
4899 : 0 : unsigned int l;
4900 : :
4901 : 0 : SymbolTable_GetProcedureBeginEnd (sym, &begin, &end);
4902 : 0 : n = SymbolTable_GetSymName (sym);
4903 : 0 : if (begin != 0)
4904 : : {
4905 : 0 : f = M2LexBuf_FindFileNameFromToken (begin, 0);
4906 : 0 : l = M2LexBuf_TokenToLineNo (begin, 0);
4907 : 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));
4908 : : }
4909 : 0 : if (end != 0)
4910 : : {
4911 : 0 : f = M2LexBuf_FindFileNameFromToken (end, 0);
4912 : 0 : l = M2LexBuf_TokenToLineNo (end, 0);
4913 : 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));
4914 : : }
4915 : 0 : }
4916 : :
4917 : :
4918 : : /*
4919 : : PutPartialUnbounded -
4920 : : */
4921 : :
4922 : 0 : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim)
4923 : : {
4924 : 0 : SymbolTable_PtrToSymbol pSym;
4925 : :
4926 : 0 : pSym = GetPsym (sym);
4927 : 0 : if (SymbolTable_IsDummy (sym))
4928 : : {
4929 : 0 : pSym->SymbolType = SymbolTable_PartialUnboundedSym;
4930 : : }
4931 : 0 : switch (pSym->SymbolType)
4932 : : {
4933 : 0 : case SymbolTable_PartialUnboundedSym:
4934 : 0 : pSym->PartialUnbounded.Type = type;
4935 : 0 : pSym->PartialUnbounded.NDim = ndim;
4936 : 0 : break;
4937 : :
4938 : :
4939 : 0 : default:
4940 : 0 : M2Error_InternalError ((const char *) "not expecting this type", 23);
4941 : 0 : break;
4942 : : }
4943 : 0 : }
4944 : :
4945 : :
4946 : : /*
4947 : : AlreadyDeclaredError - generate an error message, a, and two areas of code showing
4948 : : the places where the symbols were declared.
4949 : : */
4950 : :
4951 : 0 : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance)
4952 : : {
4953 : 0 : M2Error_Error e;
4954 : :
4955 : 0 : if ((OtherOccurance == 0) || (OtherOccurance == (M2LexBuf_GetTokenNo ())))
4956 : : {
4957 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
4958 : 0 : M2Error_ErrorString (e, s);
4959 : : }
4960 : : else
4961 : : {
4962 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
4963 : 0 : M2Error_ErrorString (e, s);
4964 : 0 : e = M2Error_ChainError (OtherOccurance, e);
4965 : 0 : M2Error_ErrorFormat1 (e, (const char *) "and symbol (%a) is also declared here", 37, (const unsigned char *) &name, (sizeof (name)-1));
4966 : : }
4967 : 0 : }
4968 : :
4969 : :
4970 : : /*
4971 : : MakeObject - creates an object node.
4972 : : */
4973 : :
4974 : 4862624 : static unsigned int MakeObject (NameKey_Name name)
4975 : : {
4976 : 4862624 : SymbolTable_PtrToSymbol pSym;
4977 : 4862624 : unsigned int Sym;
4978 : :
4979 : 4862624 : NewSym (&Sym);
4980 : 4862624 : pSym = GetPsym (Sym);
4981 : 4862624 : pSym->SymbolType = SymbolTable_ObjectSym;
4982 : 4862624 : pSym->Object.name = name;
4983 : 4862624 : InitWhereDeclared (&pSym->Object.At);
4984 : 4862624 : InitWhereFirstUsed (&pSym->Object.At);
4985 : 4862624 : return Sym;
4986 : : /* static analysis guarentees a RETURN statement will be used before here. */
4987 : : __builtin_unreachable ();
4988 : : }
4989 : :
4990 : :
4991 : : /*
4992 : : DeclareSym - returns a symbol which was either in the unknown tree or
4993 : : a New symbol, since name is about to be declared.
4994 : : */
4995 : :
4996 : 17347840 : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name)
4997 : : {
4998 : 17347840 : unsigned int Sym;
4999 : :
5000 : 17347840 : if (name == NameKey_NulName)
5001 : : {
5002 : 3695169 : NewSym (&Sym);
5003 : : }
5004 : 13652671 : else if (IsAlreadyDeclaredSym (name))
5005 : : {
5006 : : /* avoid dangling else. */
5007 : 36 : Sym = SymbolTable_GetSym (name);
5008 : 36 : if (SymbolTable_IsImported (SymbolTable_GetCurrentModuleScope (), Sym))
5009 : : {
5010 : : /* avoid dangling else. */
5011 : 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);
5012 : 6 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
5013 : 6 : if (Sym != (GetVisibleSym (name)))
5014 : : {
5015 : 0 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
5016 : : }
5017 : : }
5018 : : else
5019 : : {
5020 : 30 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1RMad} is already declared in this scope, use a different name or remove the declaration", 97, Sym);
5021 : 30 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
5022 : 30 : if (Sym != (GetVisibleSym (name)))
5023 : : {
5024 : 0 : M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
5025 : : }
5026 : : }
5027 : 36 : Sym = SymbolTable_MakeError (tok, name);
5028 : : }
5029 : : else
5030 : : {
5031 : : /* avoid dangling else. */
5032 : 13652635 : Sym = FetchUnknownSym (name);
5033 : 13652635 : if (Sym == SymbolTable_NulSym)
5034 : : {
5035 : 10585879 : NewSym (&Sym);
5036 : : }
5037 : 13652635 : CheckForExportedDeclaration (Sym);
5038 : : }
5039 : 17347840 : return Sym;
5040 : : /* static analysis guarentees a RETURN statement will be used before here. */
5041 : : __builtin_unreachable ();
5042 : : }
5043 : :
5044 : :
5045 : : /*
5046 : : Init - Initializes the data structures and variables in this module.
5047 : : Initialize the trees.
5048 : : */
5049 : :
5050 : 15260 : static void Init (void)
5051 : : {
5052 : 15260 : SymbolTable_PtrToCallFrame pCall;
5053 : :
5054 : 15260 : BreakWhenSymCreated (SymbolTable_NulSym); /* Disable the intereactive sym watch. */
5055 : : /* To examine the symbol table when a symbol is created run cc1gm2 from gdb
5056 : : and set a break point on gdbhook.
5057 : : (gdb) break gdbhook
5058 : : (gdb) run
5059 : : Now below interactively call BreakWhenSymCreated with the symbol
5060 : : under investigation. */
5061 : 15260 : gdbhook ();
5062 : : /* Now is the time to interactively call gdb, for example:
5063 : : (gdb) print BreakWhenSymCreated (1234)
5064 : : (gdb) cont
5065 : : and you will arrive at gdbhook when this symbol is created. */
5066 : 15260 : AnonymousName = 0;
5067 : 15260 : CurrentError = static_cast<M2Error_Error> (NULL);
5068 : 15260 : SymbolKey_InitTree (&ConstLitPoolTree);
5069 : 15260 : SymbolKey_InitTree (&DefModuleTree);
5070 : 15260 : SymbolKey_InitTree (&ModuleTree);
5071 : 15260 : Symbols = Indexing_InitIndexTuned (1, (1024*1024) / 16, 16);
5072 : 15260 : ConstLitArray = Indexing_InitIndex (1);
5073 : 15260 : FreeSymbol = 1;
5074 : 15260 : ScopePtr = 1;
5075 : 15260 : ScopeCallFrame = Indexing_InitIndex (1);
5076 : 15260 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
5077 : 15260 : pCall->Main = SymbolTable_NulSym;
5078 : 15260 : pCall->Search = SymbolTable_NulSym;
5079 : 15260 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
5080 : 15260 : CurrentModule = SymbolTable_NulSym;
5081 : 15260 : MainModule = SymbolTable_NulSym;
5082 : 15260 : FileModule = SymbolTable_NulSym;
5083 : 15260 : TemporaryNo = 0;
5084 : : /*
5085 : : InitList(FreeFVarientList) ; Lists used to maintain GC of field
5086 : : InitList(UsedFVarientList) ; varients.
5087 : : */
5088 : 15260 : Lists_InitList (&UnresolvedConstructorType);
5089 : 15260 : M2Base_InitBase (m2linemap_BuiltinsLocation (), &BaseModule);
5090 : 15260 : SymbolTable_StartScope (BaseModule); /* BaseModule scope placed at the bottom of the stack */
5091 : 15260 : BaseScopePtr = ScopePtr; /* BaseScopePtr points to the top of the BaseModule scope */
5092 : 15260 : Lists_InitList (&AddressTypes); /* BaseScopePtr points to the top of the BaseModule scope */
5093 : 15260 : ReportedUnknowns = Sets_InitSet (1);
5094 : 15260 : }
5095 : :
5096 : :
5097 : : /*
5098 : : AddSymToUnknown -
5099 : : */
5100 : :
5101 : 6554754 : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym)
5102 : : {
5103 : 6554754 : SymbolTable_PtrToSymbol pSym;
5104 : 6554754 : NameKey_Name n;
5105 : :
5106 : 6554754 : if (DebugUnknowns)
5107 : : {
5108 : : n = SymbolTable_GetSymName (scope);
5109 : : 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));
5110 : : }
5111 : : /* Add symbol to unknown tree */
5112 : 6554754 : pSym = GetPsym (scope);
5113 : 6554754 : switch (pSym->SymbolType)
5114 : : {
5115 : 6545084 : case SymbolTable_DefImpSym:
5116 : 6545084 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, name, Sym);
5117 : 6545084 : break;
5118 : :
5119 : 9670 : case SymbolTable_ModuleSym:
5120 : 9670 : SymbolKey_PutSymKey (pSym->Module.Unresolved, name, Sym);
5121 : 9670 : break;
5122 : :
5123 : 0 : case SymbolTable_ProcedureSym:
5124 : 0 : SymbolKey_PutSymKey (pSym->Procedure.Unresolved, name, Sym);
5125 : 0 : break;
5126 : :
5127 : :
5128 : 0 : default:
5129 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5130 : 6554754 : break;
5131 : : }
5132 : 6554754 : }
5133 : :
5134 : :
5135 : : /*
5136 : : AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
5137 : : unknown tree.
5138 : : */
5139 : :
5140 : 6554736 : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym)
5141 : : {
5142 : 6554736 : SymbolTable_PtrToCallFrame pCall;
5143 : 6554736 : unsigned int ScopeSym;
5144 : :
5145 : 6554736 : if (ScopeId > 0)
5146 : : {
5147 : : /* choose to place the unknown symbol in the first module scope
5148 : : outside the current scope */
5149 : 6555426 : do {
5150 : 6555426 : pCall = GetPcall (static_cast<unsigned int> (ScopeId));
5151 : 6555426 : ScopeSym = pCall->Main;
5152 : 6555426 : if ((ScopeSym > 0) && ((SymbolTable_IsDefImp (ScopeSym)) || (SymbolTable_IsModule (ScopeSym))))
5153 : : {
5154 : 6554736 : AddSymToUnknown (ScopeSym, name, Sym);
5155 : 6554736 : return;
5156 : : }
5157 : 690 : ScopeId -= 1;
5158 : 690 : } while (! (ScopeId == 0));
5159 : : }
5160 : 0 : AddSymToUnknown (CurrentModule, name, Sym);
5161 : : }
5162 : :
5163 : :
5164 : : /*
5165 : : SubSymFromUnknownTree - removes a symbol with name, name, from the
5166 : : unknown tree.
5167 : : */
5168 : :
5169 : 3066762 : static void SubSymFromUnknownTree (NameKey_Name name)
5170 : : {
5171 : 3066762 : SymbolTable_PtrToCallFrame pCall;
5172 : 3066762 : unsigned int ScopeSym;
5173 : 3066762 : unsigned int ScopeId;
5174 : :
5175 : 3066762 : if (ScopePtr > 0)
5176 : : {
5177 : : ScopeId = ScopePtr;
5178 : 4153984 : do {
5179 : 4153984 : pCall = GetPcall (ScopeId);
5180 : 4153984 : ScopeSym = pCall->Search;
5181 : 4153984 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
5182 : : {
5183 : 3067380 : if (RemoveFromUnresolvedTree (ScopeSym, name))
5184 : : {
5185 : : return;
5186 : : }
5187 : : }
5188 : 1087222 : ScopeId -= 1;
5189 : 2174444 : } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
5190 : : }
5191 : 0 : if (RemoveFromUnresolvedTree (CurrentModule, name))
5192 : : {} /* empty. */
5193 : : }
5194 : :
5195 : :
5196 : : /*
5197 : : GetSymFromUnknownTree - returns a symbol with name, name, from the
5198 : : unknown tree.
5199 : : If no symbol with name is found then NulSym
5200 : : is returned.
5201 : : */
5202 : :
5203 : 20207571 : static unsigned int GetSymFromUnknownTree (NameKey_Name name)
5204 : : {
5205 : 20207571 : SymbolTable_PtrToCallFrame pCall;
5206 : 20207571 : unsigned int ScopeSym;
5207 : 20207571 : unsigned int ScopeId;
5208 : 20207571 : unsigned int Sym;
5209 : :
5210 : 20207571 : if (ScopePtr > 0)
5211 : : {
5212 : : ScopeId = ScopePtr;
5213 : 33399402 : do {
5214 : 33399402 : pCall = GetPcall (ScopeId);
5215 : 33399402 : ScopeSym = pCall->Search;
5216 : 33399402 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
5217 : : {
5218 : 27792090 : Sym = ExamineUnresolvedTree (ScopeSym, name);
5219 : 27792090 : if (Sym != SymbolTable_NulSym)
5220 : : {
5221 : : return Sym;
5222 : : }
5223 : : }
5224 : 30332640 : ScopeId -= 1;
5225 : 60665280 : } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
5226 : : }
5227 : : /* Get symbol from unknown tree */
5228 : 17140809 : return ExamineUnresolvedTree (CurrentModule, name);
5229 : : /* static analysis guarentees a RETURN statement will be used before here. */
5230 : : __builtin_unreachable ();
5231 : : }
5232 : :
5233 : :
5234 : : /*
5235 : : ExamineUnresolvedTree - returns a symbol with name, name, from the
5236 : : unresolved tree of module, ModSym.
5237 : : If no symbol with name is found then NulSym
5238 : : is returned.
5239 : : */
5240 : :
5241 : 87181719 : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
5242 : : {
5243 : 87181719 : SymbolTable_PtrToSymbol pSym;
5244 : 87181719 : unsigned int Sym;
5245 : :
5246 : : /* Get symbol from unknown tree */
5247 : 87181719 : pSym = GetPsym (ScopeSym);
5248 : 87181719 : switch (pSym->SymbolType)
5249 : : {
5250 : 52154366 : case SymbolTable_DefImpSym:
5251 : 52154366 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name));
5252 : 52154366 : break;
5253 : :
5254 : 10409132 : case SymbolTable_ModuleSym:
5255 : 10409132 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, name));
5256 : 10409132 : break;
5257 : :
5258 : 24618221 : case SymbolTable_ProcedureSym:
5259 : 24618221 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name));
5260 : 24618221 : break;
5261 : :
5262 : :
5263 : 0 : default:
5264 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5265 : 87181719 : break;
5266 : : }
5267 : 87181719 : return Sym;
5268 : : /* static analysis guarentees a RETURN statement will be used before here. */
5269 : : __builtin_unreachable ();
5270 : : }
5271 : :
5272 : :
5273 : : /*
5274 : : RemoveFromUnresolvedTree - removes a symbol with name, name, from the
5275 : : unresolved tree of symbol, ScopeSym.
5276 : : */
5277 : :
5278 : 3067380 : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
5279 : : {
5280 : 3067380 : SymbolTable_PtrToSymbol pSym;
5281 : :
5282 : : /* Get symbol from unknown tree */
5283 : 3067380 : pSym = GetPsym (ScopeSym);
5284 : 3067380 : switch (pSym->SymbolType)
5285 : : {
5286 : 3057194 : case SymbolTable_DefImpSym:
5287 : 3057194 : if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) != SymbolKey_NulKey)
5288 : : {
5289 : 3057194 : SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
5290 : 3057194 : return true;
5291 : : }
5292 : : break;
5293 : :
5294 : 9550 : case SymbolTable_ModuleSym:
5295 : 9550 : if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) != SymbolKey_NulKey)
5296 : : {
5297 : 9550 : SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
5298 : 9550 : return true;
5299 : : }
5300 : : break;
5301 : :
5302 : 636 : case SymbolTable_ProcedureSym:
5303 : 636 : if ((SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name)) != SymbolKey_NulKey)
5304 : : {
5305 : 18 : SymbolKey_DelSymKey (pSym->Procedure.Unresolved, name);
5306 : 18 : return true;
5307 : : }
5308 : : break;
5309 : :
5310 : :
5311 : 0 : default:
5312 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
5313 : : break;
5314 : : }
5315 : : return false;
5316 : : /* static analysis guarentees a RETURN statement will be used before here. */
5317 : : __builtin_unreachable ();
5318 : : }
5319 : :
5320 : :
5321 : : /*
5322 : : FetchUnknownSym - returns a symbol from the unknown tree if one is
5323 : : available. It also updates the unknown tree.
5324 : : */
5325 : :
5326 : 13652835 : static unsigned int FetchUnknownSym (NameKey_Name name)
5327 : : {
5328 : 13652835 : unsigned int Sym;
5329 : :
5330 : 13652835 : Sym = GetSymFromUnknownTree (name);
5331 : 13652835 : if (Sym != SymbolTable_NulSym)
5332 : : {
5333 : 3066762 : SubSymFromUnknownTree (name);
5334 : : }
5335 : 13652835 : return Sym;
5336 : : /* static analysis guarentees a RETURN statement will be used before here. */
5337 : : __builtin_unreachable ();
5338 : : }
5339 : :
5340 : :
5341 : : /*
5342 : : TransparentScope - returns true is the scope symbol Sym is allowed
5343 : : to look to an outer level for a symbol.
5344 : : ie is the symbol allowed to look to the parent
5345 : : scope for a symbol.
5346 : : */
5347 : :
5348 : 67403630 : static bool TransparentScope (unsigned int Sym)
5349 : : {
5350 : 67403630 : SymbolTable_PtrToSymbol pSym;
5351 : :
5352 : 67403630 : pSym = GetPsym (Sym);
5353 : 67403630 : return (pSym->SymbolType != SymbolTable_DefImpSym) && (pSym->SymbolType != SymbolTable_ModuleSym);
5354 : : /* static analysis guarentees a RETURN statement will be used before here. */
5355 : : __builtin_unreachable ();
5356 : : }
5357 : :
5358 : :
5359 : : /*
5360 : : GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
5361 : : the scope before the current module scope.
5362 : : */
5363 : :
5364 : 276 : static unsigned int GetLastModuleOrProcedureScope (void)
5365 : : {
5366 : 276 : SymbolTable_PtrToCallFrame pCall;
5367 : 276 : unsigned int i;
5368 : :
5369 : : /* find current inner module */
5370 : 276 : i = ScopePtr;
5371 : 276 : pCall = GetPcall (i);
5372 : 552 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
5373 : : {
5374 : 0 : M2Debug_Assert (i > 0);
5375 : 0 : i -= 1;
5376 : 0 : pCall = GetPcall (i);
5377 : : }
5378 : : /* found module at position, i. */
5379 : 276 : i -= 1; /* Move to an outer level module or procedure scope */
5380 : 276 : pCall = GetPcall (i); /* Move to an outer level module or procedure scope */
5381 : 552 : while (((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search)))) && (! (SymbolTable_IsProcedure (pCall->Search))))
5382 : : {
5383 : 0 : M2Debug_Assert (i > 0);
5384 : 0 : i -= 1;
5385 : 0 : pCall = GetPcall (i);
5386 : : }
5387 : : /* Found module at position, i. */
5388 : 276 : return pCall->Search;
5389 : : /* static analysis guarentees a RETURN statement will be used before here. */
5390 : : __builtin_unreachable ();
5391 : : }
5392 : :
5393 : :
5394 : : /*
5395 : : AddSymToScope - adds a symbol Sym with name name to
5396 : : the current scope symbol tree.
5397 : : */
5398 : :
5399 : 16892772 : static void AddSymToScope (unsigned int Sym, NameKey_Name name)
5400 : : {
5401 : 16892772 : SymbolTable_PtrToSymbol pSym;
5402 : 16892772 : SymbolTable_PtrToCallFrame pCall;
5403 : 16892772 : unsigned int ScopeId;
5404 : :
5405 : 16892772 : pCall = GetPcall (ScopePtr);
5406 : 16892772 : ScopeId = pCall->Main;
5407 : : /*
5408 : : WriteString('Adding ') ; WriteKey(name) ; WriteString(' :') ; WriteCard(Sym, 4) ; WriteString(' to scope: ') ;
5409 : : WriteKey(GetSymName(ScopeId)) ; WriteLn ;
5410 : : */
5411 : 16892772 : pSym = GetPsym (ScopeId);
5412 : 16892772 : switch (pSym->SymbolType)
5413 : : {
5414 : 7108426 : case SymbolTable_DefImpSym:
5415 : 7108426 : if (name != NameKey_NulName)
5416 : : {
5417 : 4243367 : SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, name, Sym);
5418 : : }
5419 : 7108426 : if (SymbolTable_IsEnumeration (Sym))
5420 : : {
5421 : 22404 : CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
5422 : : }
5423 : : break;
5424 : :
5425 : 2072450 : case SymbolTable_ModuleSym:
5426 : 2072450 : if (name != NameKey_NulName)
5427 : : {
5428 : 1416010 : SymbolKey_PutSymKey (pSym->Module.LocalSymbols, name, Sym);
5429 : : }
5430 : 2072450 : if (SymbolTable_IsEnumeration (Sym))
5431 : : {
5432 : 16202 : CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
5433 : : }
5434 : : break;
5435 : :
5436 : 7711896 : case SymbolTable_ProcedureSym:
5437 : 7711896 : if (name != NameKey_NulName)
5438 : : {
5439 : 7538226 : SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, name, Sym);
5440 : : }
5441 : 7711896 : if (SymbolTable_IsEnumeration (Sym))
5442 : : {
5443 : 0 : CheckEnumerationInList (pSym->Procedure.EnumerationScopeList, Sym);
5444 : : }
5445 : : break;
5446 : :
5447 : :
5448 : 0 : default:
5449 : 0 : M2Error_InternalError ((const char *) "should never get here", 21);
5450 : 16892772 : break;
5451 : : }
5452 : 16892772 : }
5453 : :
5454 : :
5455 : : /*
5456 : : PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
5457 : : Procedure symbols enumeration
5458 : : list onto the scope stack.
5459 : : */
5460 : :
5461 : 18593162 : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym)
5462 : : {
5463 : 18593162 : SymbolTable_PtrToSymbol pSym;
5464 : :
5465 : 18593162 : pSym = GetPsym (Sym);
5466 : 18593162 : switch (pSym->SymbolType)
5467 : : {
5468 : 6252311 : case SymbolTable_DefImpSym:
5469 : 6252311 : PlaceEnumerationListOntoScope (pSym->DefImp.EnumerationScopeList);
5470 : 6252311 : break;
5471 : :
5472 : 78040 : case SymbolTable_ModuleSym:
5473 : 78040 : PlaceEnumerationListOntoScope (pSym->Module.EnumerationScopeList);
5474 : 78040 : break;
5475 : :
5476 : 12262810 : case SymbolTable_ProcedureSym:
5477 : 12262810 : PlaceEnumerationListOntoScope (pSym->Procedure.EnumerationScopeList);
5478 : 12262810 : break;
5479 : :
5480 : :
5481 : 1 : default:
5482 : 1 : M2Error_InternalError ((const char *) "expecting - DefImp, Module or Procedure symbol", 46);
5483 : 18593161 : break;
5484 : : }
5485 : 18593161 : }
5486 : :
5487 : :
5488 : : /*
5489 : : PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
5490 : : scope stack. This list will automatically
5491 : : removed via one call to EndScope which
5492 : : matches the StartScope by which this
5493 : : procedure is invoked.
5494 : : */
5495 : :
5496 : 18593161 : static void PlaceEnumerationListOntoScope (Lists_List l)
5497 : : {
5498 : 18593161 : unsigned int i;
5499 : 18593161 : unsigned int n;
5500 : :
5501 : 18593161 : n = Lists_NoOfItemsInList (l);
5502 : 18593161 : i = 1;
5503 : 37595534 : while (i <= n)
5504 : : {
5505 : 409212 : SymbolTable_PseudoScope (Lists_GetItemFromList (l, i));
5506 : 409212 : i += 1;
5507 : : }
5508 : 18593161 : }
5509 : :
5510 : :
5511 : : /*
5512 : : SetFirstUsed - assigns the FirstUsed field in at to tok providing
5513 : : it has not already been set.
5514 : : */
5515 : :
5516 : 33 : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at)
5517 : : {
5518 : 0 : if ((*at).FirstUsed == M2LexBuf_UnknownTokenNo)
5519 : : {
5520 : 0 : (*at).FirstUsed = tok;
5521 : : }
5522 : 0 : }
5523 : :
5524 : :
5525 : : /*
5526 : : PutFirstUsed - sets tok to the first used providing it has not already been set.
5527 : : It also includes the read and write quad into the usage list
5528 : : providing the quad numbers are not 0.
5529 : : */
5530 : :
5531 : 36 : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_)
5532 : : {
5533 : 36 : SymbolTable_PtrToSymbol pSym;
5534 : :
5535 : 36 : if (SymbolTable_IsVar (object))
5536 : : {
5537 : 33 : pSym = GetPsym (object);
5538 : 33 : SetFirstUsed (tok, &pSym->Var.At);
5539 : 33 : if (read_ != 0)
5540 : : {
5541 : 18 : SymbolTable_PutReadQuad (object, SymbolTable_GetMode (object), read_);
5542 : : }
5543 : 33 : if (write_ != 0)
5544 : : {
5545 : 15 : SymbolTable_PutWriteQuad (object, SymbolTable_GetMode (object), write_);
5546 : : }
5547 : : }
5548 : 36 : }
5549 : :
5550 : :
5551 : : /*
5552 : : CanLookThroughScope - by default this procedure returns TRUE. It only returns
5553 : : FALSE if, throughProcedure, is FALSE and the ScopeSym is
5554 : : a procedure.
5555 : : */
5556 : :
5557 : 44356172 : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure)
5558 : : {
5559 : 44356172 : if (SymbolTable_IsProcedure (ScopeSym))
5560 : : {
5561 : : return throughProcedure;
5562 : : }
5563 : : else
5564 : : {
5565 : 0 : return true;
5566 : : }
5567 : : /* static analysis guarentees a RETURN statement will be used before here. */
5568 : : __builtin_unreachable ();
5569 : : }
5570 : :
5571 : :
5572 : : /*
5573 : : GetScopeSym - searches the current scope and below, providing that the
5574 : : scopes are transparent, for a symbol with name, name.
5575 : : It only passes over procedure scopes if, throughProcedure,
5576 : : is TRUE.
5577 : : */
5578 : :
5579 : 61659779 : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure)
5580 : : {
5581 : 61659779 : SymbolTable_PtrToCallFrame pCall;
5582 : 61659779 : unsigned int ScopeSym;
5583 : 61659779 : unsigned int ScopeId;
5584 : 61659779 : unsigned int Sym;
5585 : :
5586 : : /* DisplayScopes ; */
5587 : 61659779 : ScopeId = ScopePtr;
5588 : 61659779 : pCall = GetPcall (ScopeId);
5589 : 61659779 : ScopeSym = pCall->Search;
5590 : : /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) ; */
5591 : 61659779 : Sym = CheckScopeForSym (ScopeSym, name);
5592 : 252112822 : while ((((ScopeId > 0) && (Sym == SymbolTable_NulSym)) && (TransparentScope (ScopeSym))) && (CanLookThroughScope (ScopeSym, throughProcedure)))
5593 : : {
5594 : 44356172 : ScopeId -= 1;
5595 : 44356172 : pCall = GetPcall (ScopeId);
5596 : 44356172 : ScopeSym = pCall->Search;
5597 : 44356172 : Sym = CheckScopeForSym (ScopeSym, name);
5598 : : }
5599 : : /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) */
5600 : : /* IF Sym#NulSym THEN WriteKey(GetSymName(Sym)) END ; WriteLn ; */
5601 : 61659779 : return Sym;
5602 : : /* static analysis guarentees a RETURN statement will be used before here. */
5603 : : __builtin_unreachable ();
5604 : : }
5605 : :
5606 : :
5607 : : /*
5608 : : CheckScopeForSym - checks the scope, ScopeSym, for an identifier
5609 : : of name, name. CheckScopeForSym checks for
5610 : : the symbol by the GetLocalSym and also
5611 : : ExamineUnresolvedTree.
5612 : : */
5613 : :
5614 : 106016191 : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name)
5615 : : {
5616 : 106016191 : unsigned int Sym;
5617 : :
5618 : 106016191 : Sym = SymbolTable_GetLocalSym (ScopeSym, name);
5619 : 106016191 : if ((Sym == SymbolTable_NulSym) && (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym))))
5620 : : {
5621 : 42248688 : Sym = ExamineUnresolvedTree (ScopeSym, name);
5622 : : }
5623 : 106016191 : return Sym;
5624 : : /* static analysis guarentees a RETURN statement will be used before here. */
5625 : : __builtin_unreachable ();
5626 : : }
5627 : :
5628 : :
5629 : : /*
5630 : : GetModuleScopeId - returns the scope index to the next module starting
5631 : : at index, Id.
5632 : : Id will either point to a null scope (NulSym) or
5633 : : alternatively point to a Module or DefImp symbol.
5634 : : */
5635 : :
5636 : 104004 : static unsigned int GetModuleScopeId (unsigned int Id)
5637 : : {
5638 : 104004 : SymbolTable_PtrToCallFrame pCall;
5639 : 104004 : unsigned int s;
5640 : :
5641 : 104004 : pCall = GetPcall (Id);
5642 : 104004 : s = pCall->Search;
5643 : 172202 : while (((Id > 0) && (s != SymbolTable_NulSym)) && ((! (SymbolTable_IsModule (s))) && (! (SymbolTable_IsDefImp (s)))))
5644 : : {
5645 : 68198 : Id -= 1;
5646 : 68198 : pCall = GetPcall (Id);
5647 : 68198 : s = pCall->Search;
5648 : : }
5649 : 104004 : return Id;
5650 : : /* static analysis guarentees a RETURN statement will be used before here. */
5651 : : __builtin_unreachable ();
5652 : : }
5653 : :
5654 : :
5655 : : /*
5656 : : GetVisibleSym -
5657 : : */
5658 : :
5659 : 36 : static unsigned int GetVisibleSym (NameKey_Name name)
5660 : : {
5661 : 36 : SymbolTable_PtrToCallFrame pCall;
5662 : 36 : unsigned int Sym;
5663 : 36 : unsigned int i;
5664 : :
5665 : 36 : i = ScopePtr;
5666 : 42 : while (i >= 1)
5667 : : {
5668 : 42 : pCall = GetPcall (i);
5669 : 42 : if (pCall->Search == pCall->Main)
5670 : : {
5671 : 30 : return SymbolTable_GetLocalSym (pCall->Main, name);
5672 : : }
5673 : : else
5674 : : {
5675 : 12 : if (SymbolTable_IsEnumeration (pCall->Search))
5676 : : {
5677 : 12 : Sym = SymbolTable_GetLocalSym (pCall->Search, name);
5678 : 12 : if (Sym != SymbolTable_NulSym)
5679 : : {
5680 : : return Sym;
5681 : : }
5682 : : }
5683 : : }
5684 : 6 : i -= 1;
5685 : : }
5686 : : return SymbolTable_NulSym;
5687 : : /* static analysis guarentees a RETURN statement will be used before here. */
5688 : : __builtin_unreachable ();
5689 : : }
5690 : :
5691 : :
5692 : : /*
5693 : : IsAlreadyDeclaredSym - returns true if Sym has already been declared
5694 : : in the current main scope.
5695 : : */
5696 : :
5697 : 13652671 : static bool IsAlreadyDeclaredSym (NameKey_Name name)
5698 : : {
5699 : 13652671 : SymbolTable_PtrToCallFrame pCall;
5700 : 13652671 : unsigned int i;
5701 : :
5702 : 13652671 : i = ScopePtr;
5703 : 16120129 : while (i >= 1)
5704 : : {
5705 : 16120129 : pCall = GetPcall (i);
5706 : 16120129 : if (pCall->Search == pCall->Main)
5707 : : {
5708 : 13652665 : return (SymbolTable_GetLocalSym (pCall->Main, name)) != SymbolTable_NulSym;
5709 : : }
5710 : : else
5711 : : {
5712 : 2467464 : if ((SymbolTable_IsEnumeration (pCall->Search)) && ((SymbolTable_GetLocalSym (pCall->Search, name)) != SymbolTable_NulSym))
5713 : : {
5714 : : return true;
5715 : : }
5716 : : }
5717 : 2467458 : i -= 1;
5718 : : }
5719 : : return false;
5720 : : /* static analysis guarentees a RETURN statement will be used before here. */
5721 : : __builtin_unreachable ();
5722 : : }
5723 : :
5724 : :
5725 : : /*
5726 : : GenName - returns a new name consisting of pre, name, post concatenation.
5727 : : */
5728 : :
5729 : 308972 : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high)
5730 : : {
5731 : 308972 : DynamicStrings_String str;
5732 : 308972 : NameKey_Name result;
5733 : 308972 : char pre[_pre_high+1];
5734 : 308972 : char post[_post_high+1];
5735 : :
5736 : : /* make a local copy of each unbounded array. */
5737 : 308972 : memcpy (pre, pre_, _pre_high+1);
5738 : 308972 : memcpy (post, post_, _post_high+1);
5739 : :
5740 : 308972 : str = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (libname));
5741 : 308972 : str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) pre, _pre_high)));
5742 : 308972 : str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
5743 : 308972 : str = DynamicStrings_ConCat (str, DynamicStrings_InitString ((const char *) post, _post_high));
5744 : 308972 : result = NameKey_makekey (DynamicStrings_string (str));
5745 : 308972 : str = DynamicStrings_KillString (str);
5746 : 308972 : return result;
5747 : : /* static analysis guarentees a RETURN statement will be used before here. */
5748 : : __builtin_unreachable ();
5749 : 308972 : }
5750 : :
5751 : :
5752 : : /*
5753 : : InitCtor - initialize the ModuleCtor fields to NulSym.
5754 : : */
5755 : :
5756 : 162853 : static void InitCtor (SymbolTable_ModuleCtor *ctor)
5757 : : {
5758 : 162853 : (*ctor).ctor = SymbolTable_NulSym;
5759 : 162853 : (*ctor).dep = SymbolTable_NulSym;
5760 : 162853 : (*ctor).init = SymbolTable_NulSym;
5761 : 162853 : (*ctor).fini = SymbolTable_NulSym;
5762 : 0 : }
5763 : :
5764 : :
5765 : : /*
5766 : : InitCtorFields - initialize the ModuleCtor fields. An inner module has no
5767 : : ctor procedure.
5768 : : */
5769 : :
5770 : 66109 : 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)
5771 : : {
5772 : 66109 : if (M2Options_ScaffoldDynamic && ! inner)
5773 : : {
5774 : : /* The ctor procedure must be public. */
5775 : 65453 : (*ctor).ctor = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_ctor", 5));
5776 : 65453 : SymbolTable_PutCtor ((*ctor).ctor, true);
5777 : 65453 : M2Debug_Assert (pub);
5778 : 65453 : SymbolTable_PutPublic ((*ctor).ctor, pub);
5779 : 65453 : SymbolTable_PutExtern ((*ctor).ctor, ! pub);
5780 : 65453 : SymbolTable_PutMonoName ((*ctor).ctor, true);
5781 : : /* The dep procedure is local to the module. */
5782 : 65453 : (*ctor).dep = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_dep", 4));
5783 : 65453 : SymbolTable_PutMonoName ((*ctor).dep, true);
5784 : : }
5785 : : else
5786 : : {
5787 : 656 : (*ctor).ctor = SymbolTable_NulSym;
5788 : 656 : (*ctor).dep = SymbolTable_NulSym;
5789 : : }
5790 : : /* The init/fini procedures must be public. */
5791 : 66109 : (*ctor).init = SymbolTable_MakeProcedure (beginTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_init", 5));
5792 : 66109 : SymbolTable_PutPublic ((*ctor).init, pub);
5793 : 66109 : SymbolTable_PutExtern ((*ctor).init, ! pub);
5794 : 66109 : SymbolTable_PutMonoName ((*ctor).init, ! inner);
5795 : 66109 : M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).init);
5796 : 66109 : (*ctor).fini = SymbolTable_MakeProcedure (finallyTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_fini", 5));
5797 : 66109 : SymbolTable_PutPublic ((*ctor).fini, pub);
5798 : 66109 : SymbolTable_PutExtern ((*ctor).fini, ! pub);
5799 : 66109 : SymbolTable_PutMonoName ((*ctor).fini, ! inner);
5800 : 66109 : M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).fini);
5801 : 66109 : }
5802 : :
5803 : :
5804 : : /*
5805 : : CheckTok - checks to see that tok is at a known location. If not
5806 : : it uses GetTokenNo as a fall back.
5807 : : */
5808 : :
5809 : 16537358 : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high)
5810 : : {
5811 : 16537358 : DynamicStrings_String s;
5812 : 16537358 : char name[_name_high+1];
5813 : :
5814 : : /* make a local copy of each unbounded array. */
5815 : 16537358 : memcpy (name, name_, _name_high+1);
5816 : :
5817 : 16537358 : if (tok == M2LexBuf_UnknownTokenNo)
5818 : : {
5819 : 172692 : tok = M2LexBuf_GetTokenNo ();
5820 : 172692 : if (DebugUnknownToken)
5821 : : {
5822 : : s = DynamicStrings_InitString ((const char *) name, _name_high);
5823 : : s = DynamicStrings_ConCat (s, DynamicStrings_InitString ((const char *) " symbol {%W} has been created with an unknown token location", 60));
5824 : : M2MetaError_MetaErrorStringT0 (M2LexBuf_GetTokenNo (), s);
5825 : : }
5826 : : }
5827 : 16537358 : return tok;
5828 : : /* static analysis guarentees a RETURN statement will be used before here. */
5829 : : __builtin_unreachable ();
5830 : 0 : }
5831 : :
5832 : :
5833 : : /*
5834 : : GetLink - returns TRUE if the current module is only used for linkage.
5835 : : */
5836 : :
5837 : 298416 : static bool GetLink (void)
5838 : : {
5839 : 298416 : unsigned int OuterModule;
5840 : :
5841 : 298416 : OuterModule = SymbolTable_GetCurrentModule ();
5842 : 298416 : if (OuterModule != SymbolTable_NulSym)
5843 : : {
5844 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
5845 : 283156 : if (M2Comp_CompilingDefinitionModule ())
5846 : : {
5847 : 3624 : return SymbolTable_IsDefLink (OuterModule);
5848 : : }
5849 : : else
5850 : : {
5851 : 279532 : return SymbolTable_IsModLink (OuterModule);
5852 : : }
5853 : : }
5854 : : /* Default is that the module is for compiling. */
5855 : : return false;
5856 : : /* static analysis guarentees a RETURN statement will be used before here. */
5857 : : __builtin_unreachable ();
5858 : : }
5859 : :
5860 : :
5861 : : /*
5862 : : AddModuleToParent - adds symbol, Sym, to module, Parent.
5863 : : */
5864 : :
5865 : 420 : static void AddModuleToParent (unsigned int Sym, unsigned int Parent)
5866 : : {
5867 : 420 : SymbolTable_PtrToSymbol pSym;
5868 : :
5869 : 420 : pSym = GetPsym (Parent);
5870 : 420 : switch (pSym->SymbolType)
5871 : : {
5872 : 18 : case SymbolTable_DefImpSym:
5873 : 18 : Lists_PutItemIntoList (pSym->DefImp.ListOfModules, Sym);
5874 : 18 : break;
5875 : :
5876 : 246 : case SymbolTable_ModuleSym:
5877 : 246 : Lists_PutItemIntoList (pSym->Module.ListOfModules, Sym);
5878 : 246 : break;
5879 : :
5880 : 156 : case SymbolTable_ProcedureSym:
5881 : 156 : Lists_PutItemIntoList (pSym->Procedure.ListOfModules, Sym);
5882 : 156 : break;
5883 : :
5884 : :
5885 : 0 : default:
5886 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
5887 : 420 : break;
5888 : : }
5889 : 420 : }
5890 : :
5891 : :
5892 : : /*
5893 : : PutProcedureExternPublic - if procedure is not NulSym set extern
5894 : : and public booleans.
5895 : : */
5896 : :
5897 : 332368 : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub)
5898 : : {
5899 : 332368 : if (procedure != SymbolTable_NulSym)
5900 : : {
5901 : 332368 : SymbolTable_PutExtern (procedure, extern_);
5902 : 332368 : SymbolTable_PutPublic (procedure, pub);
5903 : : }
5904 : 332368 : }
5905 : :
5906 : :
5907 : : /*
5908 : : PutCtorExtern -
5909 : : */
5910 : :
5911 : 83092 : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_)
5912 : : {
5913 : : /* If the ctor does not exist then make it extern/ (~extern) public. */
5914 : 83092 : if ((*ctor).ctor == SymbolTable_NulSym)
5915 : : {
5916 : 11558 : (*ctor).ctor = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_ctor", 5));
5917 : 11558 : SymbolTable_PutMonoName ((*ctor).ctor, true);
5918 : : }
5919 : 83092 : PutProcedureExternPublic ((*ctor).ctor, extern_, ! extern_);
5920 : 83092 : SymbolTable_PutCtor ((*ctor).ctor, true);
5921 : : /* If the ctor does not exist then make it extern/ (~extern) public. */
5922 : 83092 : if ((*ctor).dep == SymbolTable_NulSym)
5923 : : {
5924 : 11558 : (*ctor).dep = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_dep", 4));
5925 : 11558 : SymbolTable_PutMonoName ((*ctor).dep, true);
5926 : : }
5927 : 83092 : PutProcedureExternPublic ((*ctor).dep, extern_, ! extern_);
5928 : : /* If init/fini do not exist then create them. */
5929 : 83092 : if ((*ctor).init == SymbolTable_NulSym)
5930 : : {
5931 : 11366 : (*ctor).init = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_init", 5));
5932 : 11366 : M2Scaffold_DeclareArgEnvParams (tok, (*ctor).init);
5933 : 11366 : SymbolTable_PutMonoName ((*ctor).init, ! (SymbolTable_IsInnerModule (sym)));
5934 : : }
5935 : 83092 : PutProcedureExternPublic ((*ctor).init, extern_, ! extern_);
5936 : 83092 : if ((*ctor).fini == SymbolTable_NulSym)
5937 : : {
5938 : 11366 : (*ctor).fini = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_fini", 5));
5939 : 11366 : M2Scaffold_DeclareArgEnvParams (tok, (*ctor).fini);
5940 : 11366 : SymbolTable_PutMonoName ((*ctor).fini, ! (SymbolTable_IsInnerModule (sym)));
5941 : : }
5942 : 83092 : PutProcedureExternPublic ((*ctor).fini, extern_, ! extern_);
5943 : 83092 : }
5944 : :
5945 : :
5946 : : /*
5947 : : InitProcedureDeclaration - initialize all the ProcedureDeclaration
5948 : : fields.
5949 : : */
5950 : :
5951 : 10290513 : static void InitProcedureDeclaration (SymbolTable_ProcedureDeclaration *decl)
5952 : : {
5953 : 10290513 : (*decl).Defined = false; /* Has the procedure been */
5954 : : /* declared yet? */
5955 : 10290513 : (*decl).ParamDefined = false; /* Have the parameters been */
5956 : : /* defined yet? */
5957 : 10290513 : (*decl).HasVarArgs = false; /* Does the procedure use ... ? */
5958 : 10290513 : (*decl).HasOptArg = false; /* Does this procedure use [ ] ? */
5959 : 10290513 : (*decl).IsNoReturn = false; /* Declared attribute noreturn ? */
5960 : 10290513 : (*decl).ReturnOptional = false; /* Is the return value optional? */
5961 : 10290513 : (*decl).ProcedureTok = M2LexBuf_UnknownTokenNo; /* Is the return value optional? */
5962 : 0 : }
5963 : :
5964 : :
5965 : : /*
5966 : : AddProcedureToList - adds a procedure, Proc, to the list of procedures
5967 : : in module, Mod.
5968 : : */
5969 : :
5970 : 3430171 : static void AddProcedureToList (unsigned int Mod, unsigned int Proc)
5971 : : {
5972 : 3430171 : SymbolTable_PtrToSymbol pSym;
5973 : :
5974 : 3430171 : pSym = GetPsym (Mod);
5975 : 3430171 : switch (pSym->SymbolType)
5976 : : {
5977 : 2785493 : case SymbolTable_DefImpSym:
5978 : 2785493 : Lists_PutItemIntoList (pSym->DefImp.ListOfProcs, Proc);
5979 : 2785493 : break;
5980 : :
5981 : 644246 : case SymbolTable_ModuleSym:
5982 : 644246 : Lists_PutItemIntoList (pSym->Module.ListOfProcs, Proc);
5983 : 644246 : break;
5984 : :
5985 : 432 : case SymbolTable_ProcedureSym:
5986 : 432 : Lists_PutItemIntoList (pSym->Procedure.ListOfProcs, Proc);
5987 : 432 : break;
5988 : :
5989 : :
5990 : 0 : default:
5991 : 0 : M2Error_InternalError ((const char *) "expecting ModuleSym, DefImpSym or ProcedureSym symbol", 53);
5992 : 3430171 : break;
5993 : : }
5994 : 3430171 : }
5995 : :
5996 : :
5997 : : /*
5998 : : AddVarToScopeList - adds symbol, sym, to, scope.
5999 : : */
6000 : :
6001 : 7668556 : static void AddVarToScopeList (unsigned int scope, unsigned int sym)
6002 : : {
6003 : 7668556 : SymbolTable_PtrToSymbol pSym;
6004 : :
6005 : 7668556 : pSym = GetPsym (scope);
6006 : 7668556 : switch (pSym->SymbolType)
6007 : : {
6008 : 7454240 : case SymbolTable_ProcedureSym:
6009 : 7454240 : Lists_PutItemIntoList (pSym->Procedure.ListOfVars, sym);
6010 : 7454240 : break;
6011 : :
6012 : 100714 : case SymbolTable_ModuleSym:
6013 : 100714 : Lists_PutItemIntoList (pSym->Module.ListOfVars, sym);
6014 : 100714 : break;
6015 : :
6016 : 113602 : case SymbolTable_DefImpSym:
6017 : 113602 : Lists_PutItemIntoList (pSym->DefImp.ListOfVars, sym);
6018 : 113602 : break;
6019 : :
6020 : :
6021 : 0 : default:
6022 : 0 : M2Error_InternalError ((const char *) "expecting Procedure or Module symbol", 36);
6023 : 7668556 : break;
6024 : : }
6025 : 7668556 : }
6026 : :
6027 : :
6028 : : /*
6029 : : AddVarToList - add a variable symbol to the list of variables maintained
6030 : : by the inner most scope. (Procedure or Module).
6031 : : */
6032 : :
6033 : 7668538 : static void AddVarToList (unsigned int Sym)
6034 : : {
6035 : 7668538 : SymbolTable_PtrToCallFrame pCall;
6036 : :
6037 : 7668538 : pCall = GetPcall (ScopePtr);
6038 : 7668538 : AddVarToScopeList (pCall->Main, Sym);
6039 : 7668538 : }
6040 : :
6041 : :
6042 : : /*
6043 : : InitVarDecl - initialize the variable and type token location positions.
6044 : : */
6045 : :
6046 : 7668538 : static void InitVarDecl (SymbolTable_VarDecl *decl, unsigned int vartok)
6047 : : {
6048 : 7668538 : (*decl).FullTok = M2LexBuf_UnknownTokenNo;
6049 : 7668538 : (*decl).VarTok = vartok;
6050 : 7668538 : (*decl).TypeTok = M2LexBuf_UnknownTokenNo;
6051 : 0 : }
6052 : :
6053 : :
6054 : : /*
6055 : : doPutVarDeclTypeTok - places typetok into decl.TypeTok.
6056 : : sym must be a variable.
6057 : : */
6058 : :
6059 : 0 : static void doPutVarDeclTypeTok (unsigned int sym, unsigned int typetok)
6060 : : {
6061 : 0 : SymbolTable_PtrToSymbol pSym;
6062 : :
6063 : 0 : M2Debug_Assert (SymbolTable_IsVar (sym));
6064 : 0 : pSym = GetPsym (sym);
6065 : 0 : pSym->Var.Declared.TypeTok = typetok;
6066 : 0 : }
6067 : :
6068 : :
6069 : : /*
6070 : : doPutVarDeclTok - places vartok into decl.VarTok.
6071 : : sym must be a variable.
6072 : : */
6073 : :
6074 : 963246 : static void doPutVarDeclTok (unsigned int sym, unsigned int vartok)
6075 : : {
6076 : 963246 : SymbolTable_PtrToSymbol pSym;
6077 : :
6078 : 963246 : M2Debug_Assert (SymbolTable_IsVar (sym));
6079 : 963246 : pSym = GetPsym (sym);
6080 : 963246 : pSym->Var.Declared.VarTok = vartok;
6081 : 963246 : }
6082 : :
6083 : :
6084 : : /*
6085 : : doGetVarDeclTok - return decl.VarTok for a variable.
6086 : : */
6087 : :
6088 : 54 : static unsigned int doGetVarDeclTok (unsigned int sym)
6089 : : {
6090 : 54 : SymbolTable_PtrToSymbol pSym;
6091 : :
6092 : 54 : pSym = GetPsym (sym);
6093 : 54 : M2Debug_Assert (SymbolTable_IsVar (sym));
6094 : 54 : return pSym->Var.Declared.VarTok;
6095 : : /* static analysis guarentees a RETURN statement will be used before here. */
6096 : : __builtin_unreachable ();
6097 : : }
6098 : :
6099 : :
6100 : : /*
6101 : : doGetVarDeclTypeTok - return decl.TypeTok for a variable.
6102 : : */
6103 : :
6104 : 0 : static unsigned int doGetVarDeclTypeTok (unsigned int sym)
6105 : : {
6106 : 0 : SymbolTable_PtrToSymbol pSym;
6107 : :
6108 : 0 : pSym = GetPsym (sym);
6109 : 0 : M2Debug_Assert (SymbolTable_IsVar (sym));
6110 : 0 : return pSym->Var.Declared.TypeTok;
6111 : : /* static analysis guarentees a RETURN statement will be used before here. */
6112 : : __builtin_unreachable ();
6113 : : }
6114 : :
6115 : :
6116 : : /*
6117 : : doGetVarDeclFullTok - return the full declaration of var: type.
6118 : : */
6119 : :
6120 : 330 : static unsigned int doGetVarDeclFullTok (unsigned int sym)
6121 : : {
6122 : 330 : SymbolTable_PtrToSymbol pSym;
6123 : :
6124 : 330 : pSym = GetPsym (sym);
6125 : 330 : M2Debug_Assert (SymbolTable_IsVar (sym));
6126 : 330 : if (pSym->Var.Declared.FullTok == M2LexBuf_UnknownTokenNo)
6127 : : {
6128 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
6129 : 330 : if (pSym->Var.Declared.TypeTok == M2LexBuf_UnknownTokenNo)
6130 : : {
6131 : 66 : return pSym->Var.Declared.VarTok;
6132 : : }
6133 : : else
6134 : : {
6135 : 264 : pSym->Var.Declared.FullTok = M2LexBuf_MakeVirtual2Tok (pSym->Var.Declared.VarTok, pSym->Var.Declared.TypeTok);
6136 : : }
6137 : : }
6138 : 264 : return pSym->Var.Declared.FullTok;
6139 : : /* static analysis guarentees a RETURN statement will be used before here. */
6140 : : __builtin_unreachable ();
6141 : : }
6142 : :
6143 : :
6144 : : /*
6145 : : FillInRecordFields - given a new symbol, sym, make it a record symbol
6146 : : and initialize its fields.
6147 : : */
6148 : :
6149 : 83641 : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf)
6150 : : {
6151 : 83641 : SymbolTable_PtrToSymbol pSym;
6152 : :
6153 : 83641 : if (! (SymbolTable_IsError (sym)))
6154 : : {
6155 : 83635 : pSym = GetPsym (sym);
6156 : 83635 : pSym->SymbolType = SymbolTable_RecordSym;
6157 : 83635 : pSym->Record.name = RecordName;
6158 : 83635 : SymbolKey_InitTree (&pSym->Record.LocalSymbols);
6159 : 83635 : pSym->Record.Size = M2ALU_InitValue ();
6160 : 83635 : Lists_InitList (&pSym->Record.ListOfSons); /* List of RecordFieldSym and VarientSym */
6161 : 83635 : pSym->Record.oafamily = oaf; /* List of RecordFieldSym and VarientSym */
6162 : 83635 : pSym->Record.Parent = SymbolTable_NulSym;
6163 : 83635 : pSym->Record.Align = SymbolTable_NulSym;
6164 : 83635 : pSym->Record.DefaultAlign = SymbolTable_NulSym;
6165 : 83635 : pSym->Record.DeclPacked = false;
6166 : 83635 : pSym->Record.DeclResolved = false;
6167 : 83635 : pSym->Record.Scope = scope;
6168 : 83635 : InitWhereDeclaredTok (tok, &pSym->Record.At);
6169 : : }
6170 : 83641 : }
6171 : :
6172 : :
6173 : : /*
6174 : : HandleHiddenOrDeclare -
6175 : : */
6176 : :
6177 : 4604932 : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf)
6178 : : {
6179 : 4604932 : unsigned int sym;
6180 : :
6181 : 4604932 : sym = CheckForHiddenType (name);
6182 : 4604932 : if (sym == SymbolTable_NulSym)
6183 : : {
6184 : 4594788 : sym = DeclareSym (tok, name);
6185 : 4594788 : if (! (SymbolTable_IsError (sym)))
6186 : : {
6187 : : /* Now add this type to the symbol table of the current scope */
6188 : 4594776 : AddSymToScope (sym, name);
6189 : : }
6190 : : }
6191 : 4604932 : (*oaf) = SymbolTable_GetOAFamily (sym);
6192 : 4604932 : return sym;
6193 : : /* static analysis guarentees a RETURN statement will be used before here. */
6194 : : __builtin_unreachable ();
6195 : : }
6196 : :
6197 : :
6198 : : /*
6199 : : CreateConstLit -
6200 : : */
6201 : :
6202 : 536536 : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
6203 : : {
6204 : 536536 : SymbolTable_PtrToSymbol pSym;
6205 : 536536 : unsigned int Sym;
6206 : 536536 : bool overflow;
6207 : :
6208 : 536536 : overflow = false;
6209 : 536536 : if (constType == SymbolTable_NulSym)
6210 : : {
6211 : 405082 : constType = GetConstLitType (tok, constName, &overflow, true);
6212 : : }
6213 : 536536 : NewSym (&Sym);
6214 : 536536 : pSym = GetPsym (Sym);
6215 : 536536 : pSym->SymbolType = SymbolTable_ConstLitSym;
6216 : 536536 : switch (pSym->SymbolType)
6217 : : {
6218 : 536536 : case SymbolTable_ConstLitSym:
6219 : 536536 : pSym->ConstLit.name = constName;
6220 : 536536 : pSym->ConstLit.Value = M2ALU_InitValue ();
6221 : 536536 : M2ALU_PushString (tok, constName, ! overflow);
6222 : 536536 : M2ALU_PopInto (pSym->ConstLit.Value);
6223 : 536536 : pSym->ConstLit.Type = constType;
6224 : 536536 : pSym->ConstLit.IsSet = false;
6225 : 536536 : pSym->ConstLit.IsInternal = false; /* Is it a default BY constant
6226 : : expression? */
6227 : 536536 : pSym->ConstLit.IsConstructor = false; /* Is it a default BY constant
6228 : : expression? */
6229 : 536536 : pSym->ConstLit.FromType = SymbolTable_NulSym; /* type is determined FromType */
6230 : 536536 : pSym->ConstLit.RangeError = overflow; /* type is determined FromType */
6231 : 536536 : pSym->ConstLit.UnresFromType = false; /* is Type resolved? */
6232 : 536536 : pSym->ConstLit.Scope = SymbolTable_GetCurrentScope (); /* is Type resolved? */
6233 : 536536 : InitWhereDeclaredTok (tok, &pSym->ConstLit.At);
6234 : 536536 : InitWhereFirstUsedTok (tok, &pSym->ConstLit.At);
6235 : 536536 : break;
6236 : :
6237 : :
6238 : : default:
6239 : : M2Error_InternalError ((const char *) "expecting ConstLit symbol", 25);
6240 : 536536 : break;
6241 : : }
6242 : 536536 : return Sym;
6243 : : /* static analysis guarentees a RETURN statement will be used before here. */
6244 : : __builtin_unreachable ();
6245 : : }
6246 : :
6247 : :
6248 : : /*
6249 : : LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
6250 : : matches tok, constName and constType.
6251 : : */
6252 : :
6253 : 1307739 : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType)
6254 : : {
6255 : 1307739 : SymbolTable_ConstLitPoolEntry pe;
6256 : 1307739 : unsigned int rootIndex;
6257 : :
6258 : 1307739 : rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
6259 : 1307739 : if (rootIndex != 0)
6260 : : {
6261 : 1023153 : pe = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
6262 : 8123462 : while (pe != NULL)
6263 : : {
6264 : 6848359 : if (((pe->tok == tok) && (pe->constName == constName)) && (pe->constType == constType))
6265 : : {
6266 : 771203 : return pe->sym;
6267 : : }
6268 : 6077156 : pe = pe->next;
6269 : : }
6270 : : }
6271 : : return SymbolTable_NulSym;
6272 : : /* static analysis guarentees a RETURN statement will be used before here. */
6273 : : __builtin_unreachable ();
6274 : : }
6275 : :
6276 : :
6277 : : /*
6278 : : AddConstLitPoolEntry - adds sym to the constlit pool.
6279 : : */
6280 : :
6281 : 536536 : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType)
6282 : : {
6283 : 536536 : SymbolTable_ConstLitPoolEntry pe;
6284 : 536536 : SymbolTable_ConstLitPoolEntry old;
6285 : 536536 : unsigned int rootIndex;
6286 : 536536 : unsigned int high;
6287 : :
6288 : 536536 : rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
6289 : 536536 : if (rootIndex == SymbolKey_NulKey)
6290 : : {
6291 : 284586 : high = Indexing_HighIndice (ConstLitArray);
6292 : 284586 : Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
6293 : 284586 : if (pe == NULL)
6294 : : {
6295 : 0 : M2Error_InternalError ((const char *) "out of memory", 13);
6296 : : }
6297 : : else
6298 : : {
6299 : 284586 : pe->sym = sym;
6300 : 284586 : pe->tok = tok;
6301 : 284586 : pe->constName = constName;
6302 : 284586 : pe->constType = constType;
6303 : 284586 : pe->next = NULL;
6304 : 284586 : SymbolKey_PutSymKey (ConstLitPoolTree, constName, high+1);
6305 : 284586 : Indexing_PutIndice (ConstLitArray, high+1, reinterpret_cast <void *> (pe));
6306 : : }
6307 : : }
6308 : : else
6309 : : {
6310 : 251950 : Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
6311 : 251950 : if (pe == NULL)
6312 : : {
6313 : 0 : M2Error_InternalError ((const char *) "out of memory", 13);
6314 : : }
6315 : : else
6316 : : {
6317 : 251950 : old = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
6318 : 251950 : pe->sym = sym;
6319 : 251950 : pe->tok = tok;
6320 : 251950 : pe->constName = constName;
6321 : 251950 : pe->constType = constType;
6322 : 251950 : pe->next = old;
6323 : 251950 : Indexing_PutIndice (ConstLitArray, rootIndex, reinterpret_cast <void *> (pe));
6324 : : }
6325 : : }
6326 : 536536 : }
6327 : :
6328 : :
6329 : : /*
6330 : : InitConstString - initialize the constant string.
6331 : : */
6332 : :
6333 : 296794 : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known)
6334 : : {
6335 : 296794 : SymbolTable_PtrToSymbol pSym;
6336 : :
6337 : 296794 : pSym = GetPsym (sym);
6338 : 296794 : pSym->SymbolType = SymbolTable_ConstStringSym;
6339 : 296794 : switch (pSym->SymbolType)
6340 : : {
6341 : 296794 : case SymbolTable_ConstStringSym:
6342 : 296794 : pSym->ConstString.name = name;
6343 : 296794 : pSym->ConstString.StringVariant = kind;
6344 : 296794 : pSym->ConstString.Scope = SymbolTable_GetCurrentScope ();
6345 : 296794 : InitWhereDeclaredTok (tok, &pSym->ConstString.At);
6346 : 296794 : SymbolTable_PutConstStringKnown (tok, sym, contents, escape, known);
6347 : 296794 : break;
6348 : :
6349 : :
6350 : : default:
6351 : : M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
6352 : 296794 : break;
6353 : : }
6354 : 296794 : }
6355 : :
6356 : :
6357 : : /*
6358 : : GetConstStringKind - return the StringVariant field associated with sym.
6359 : : */
6360 : :
6361 : 274445 : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym)
6362 : : {
6363 : 274445 : SymbolTable_PtrToSymbol pSym;
6364 : :
6365 : 274445 : pSym = GetPsym (sym);
6366 : 274445 : switch (pSym->SymbolType)
6367 : : {
6368 : 274445 : case SymbolTable_ConstStringSym:
6369 : 274445 : return pSym->ConstString.StringVariant;
6370 : 0 : break;
6371 : :
6372 : :
6373 : 0 : default:
6374 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
6375 : : break;
6376 : : }
6377 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6378 : : __builtin_unreachable ();
6379 : : }
6380 : :
6381 : :
6382 : : /*
6383 : : CanUseBuiltin - returns TRUE if the procedure, Sym, can be
6384 : : inlined via a builtin function.
6385 : : */
6386 : :
6387 : 16506 : static bool CanUseBuiltin (unsigned int Sym)
6388 : : {
6389 : 16506 : return ! M2Options_DebugBuiltins && ((m2builtins_BuiltinExists (reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetProcedureBuiltin (Sym))))) || (m2builtins_BuiltinExists (reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (Sym))))));
6390 : : /* static analysis guarentees a RETURN statement will be used before here. */
6391 : : __builtin_unreachable ();
6392 : : }
6393 : :
6394 : :
6395 : : /*
6396 : : InitPacked - initialise packedInfo to FALSE and NulSym.
6397 : : */
6398 : :
6399 : 861282 : static void InitPacked (SymbolTable_PackedInfo *packedInfo)
6400 : : {
6401 : 861282 : (*packedInfo).IsPacked = false;
6402 : 861282 : (*packedInfo).PackedEquiv = SymbolTable_NulSym;
6403 : 0 : }
6404 : :
6405 : :
6406 : : /*
6407 : : doEquivalent - create a packed equivalent symbol for, sym, and return the
6408 : : new symbol. It sets both fields in packedInfo to FALSE
6409 : : and the new symbol.
6410 : : */
6411 : :
6412 : 14425 : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
6413 : : {
6414 : 14425 : unsigned int nSym;
6415 : 14425 : SymbolTable_PtrToSymbol pSym;
6416 : :
6417 : 14425 : NewSym (&nSym);
6418 : 14425 : pSym = GetPsym (nSym);
6419 : 14425 : pSym->SymbolType = SymbolTable_EquivSym;
6420 : 14425 : pSym->Equiv.nonPacked = sym;
6421 : 14425 : pSym->Equiv.packedInfo.IsPacked = true;
6422 : 14425 : pSym->Equiv.packedInfo.PackedEquiv = SymbolTable_NulSym;
6423 : 14425 : (*packedInfo).IsPacked = false;
6424 : 14425 : (*packedInfo).PackedEquiv = nSym;
6425 : 14425 : return nSym;
6426 : : /* static analysis guarentees a RETURN statement will be used before here. */
6427 : : __builtin_unreachable ();
6428 : : }
6429 : :
6430 : :
6431 : : /*
6432 : : MakeEquivalent - return the equivalent packed symbol for, sym.
6433 : : */
6434 : :
6435 : 14425 : static unsigned int MakeEquivalent (unsigned int sym)
6436 : : {
6437 : 14425 : SymbolTable_PtrToSymbol pSym;
6438 : :
6439 : 14425 : pSym = GetPsym (sym);
6440 : 14425 : switch (pSym->SymbolType)
6441 : : {
6442 : 14365 : case SymbolTable_EnumerationSym:
6443 : 14365 : return doEquivalent (&pSym->Enumeration.packedInfo, sym);
6444 : 60 : break;
6445 : :
6446 : 60 : case SymbolTable_SubrangeSym:
6447 : 60 : return doEquivalent (&pSym->Subrange.packedInfo, sym);
6448 : 0 : break;
6449 : :
6450 : 0 : case SymbolTable_TypeSym:
6451 : 0 : return doEquivalent (&pSym->Type.packedInfo, sym);
6452 : 0 : break;
6453 : :
6454 : 0 : case SymbolTable_SetSym:
6455 : 0 : return doEquivalent (&pSym->Set.packedInfo, sym);
6456 : 0 : break;
6457 : :
6458 : :
6459 : 0 : default:
6460 : 0 : M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
6461 : : break;
6462 : : }
6463 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6464 : : __builtin_unreachable ();
6465 : : }
6466 : :
6467 : :
6468 : : /*
6469 : : GetEquivalent -
6470 : : */
6471 : :
6472 : 14665 : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
6473 : : {
6474 : 14665 : if ((*packedInfo).IsPacked)
6475 : : {
6476 : : return sym;
6477 : : }
6478 : 14665 : else if ((*packedInfo).PackedEquiv == SymbolTable_NulSym)
6479 : : {
6480 : : /* avoid dangling else. */
6481 : 14425 : (*packedInfo).PackedEquiv = MakeEquivalent (sym);
6482 : : }
6483 : 14665 : return (*packedInfo).PackedEquiv;
6484 : : /* static analysis guarentees a RETURN statement will be used before here. */
6485 : : __builtin_unreachable ();
6486 : : }
6487 : :
6488 : :
6489 : : /*
6490 : : doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
6491 : : */
6492 : :
6493 : 369188511 : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase)
6494 : : {
6495 : 369188511 : SymbolTable_PtrToSymbol pSym;
6496 : 369188511 : unsigned int type;
6497 : :
6498 : 369188511 : type = SymbolTable_NulSym;
6499 : 369188511 : M2Debug_Assert (sym != SymbolTable_NulSym);
6500 : 369188511 : pSym = GetPsym (sym);
6501 : 369188511 : switch (pSym->SymbolType)
6502 : : {
6503 : 0 : case SymbolTable_OAFamilySym:
6504 : 0 : type = pSym->OAFamily.SimpleType;
6505 : 0 : break;
6506 : :
6507 : 61952366 : case SymbolTable_VarSym:
6508 : 61952366 : type = GetTypeOfVar (sym);
6509 : 61952366 : break;
6510 : :
6511 : 28112116 : case SymbolTable_ConstLitSym:
6512 : 28112116 : type = pSym->ConstLit.Type;
6513 : 28112116 : break;
6514 : :
6515 : 22091736 : case SymbolTable_ConstVarSym:
6516 : 22091736 : type = pSym->ConstVar.Type;
6517 : 22091736 : break;
6518 : :
6519 : 8308379 : case SymbolTable_ConstStringSym:
6520 : 8308379 : if (pSym->ConstString.Length == 1)
6521 : : {
6522 : 1566432 : type = M2Base_Char;
6523 : : }
6524 : : else
6525 : : {
6526 : : type = SymbolTable_NulSym; /* No type for a string */
6527 : : }
6528 : : break;
6529 : :
6530 : 59111122 : case SymbolTable_TypeSym:
6531 : 59111122 : type = pSym->Type.Type;
6532 : 59111122 : break;
6533 : :
6534 : 85645256 : case SymbolTable_RecordFieldSym:
6535 : 85645256 : type = pSym->RecordField.Type;
6536 : 85645256 : break;
6537 : :
6538 : : case SymbolTable_RecordSym:
6539 : : type = SymbolTable_NulSym; /* No type for a record */
6540 : : break;
6541 : :
6542 : : case SymbolTable_VarientSym:
6543 : : type = SymbolTable_NulSym; /* No type for a record */
6544 : : break;
6545 : :
6546 : 31508400 : case SymbolTable_EnumerationFieldSym:
6547 : 31508400 : type = pSym->EnumerationField.Type; /* No type for a record */
6548 : 31508400 : break;
6549 : :
6550 : : case SymbolTable_EnumerationSym:
6551 : : type = SymbolTable_NulSym; /* No type for enumeration */
6552 : : break;
6553 : :
6554 : 23752290 : case SymbolTable_PointerSym:
6555 : 23752290 : type = pSym->Pointer.Type; /* No type for enumeration */
6556 : 23752290 : break;
6557 : :
6558 : 8313273 : case SymbolTable_ProcedureSym:
6559 : 8313273 : type = pSym->Procedure.ReturnType;
6560 : 8313273 : break;
6561 : :
6562 : 6024384 : case SymbolTable_ProcTypeSym:
6563 : 6024384 : type = pSym->ProcType.ReturnType;
6564 : 6024384 : break;
6565 : :
6566 : 11566495 : case SymbolTable_ParamSym:
6567 : 11566495 : type = pSym->Param.Type;
6568 : 11566495 : break;
6569 : :
6570 : 2317798 : case SymbolTable_VarParamSym:
6571 : 2317798 : type = pSym->VarParam.Type;
6572 : 2317798 : break;
6573 : :
6574 : 5465072 : case SymbolTable_SubrangeSym:
6575 : 5465072 : type = pSym->Subrange.Type;
6576 : 5465072 : break;
6577 : :
6578 : 1813180 : case SymbolTable_ArraySym:
6579 : 1813180 : type = pSym->Array.Type;
6580 : 1813180 : break;
6581 : :
6582 : 1676748 : case SymbolTable_SubscriptSym:
6583 : 1676748 : type = pSym->Subscript.Type;
6584 : 1676748 : break;
6585 : :
6586 : 1747098 : case SymbolTable_SetSym:
6587 : 1747098 : type = pSym->Set.Type;
6588 : 1747098 : break;
6589 : :
6590 : 9747200 : case SymbolTable_UnboundedSym:
6591 : 9747200 : type = pSym->Unbounded.Type;
6592 : 9747200 : break;
6593 : :
6594 : : case SymbolTable_UndefinedSym:
6595 : : type = SymbolTable_NulSym;
6596 : : break;
6597 : :
6598 : 0 : case SymbolTable_PartialUnboundedSym:
6599 : 0 : type = pSym->PartialUnbounded.Type;
6600 : 0 : break;
6601 : :
6602 : : case SymbolTable_ObjectSym:
6603 : : type = SymbolTable_NulSym;
6604 : : break;
6605 : :
6606 : :
6607 : 0 : default:
6608 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
6609 : 362410966 : break;
6610 : : }
6611 : 369188511 : if (((type == SymbolTable_NulSym) && (SymbolTable_IsType (sym))) && ! skipBase)
6612 : : {
6613 : : return sym; /* sym is a base type */
6614 : : }
6615 : 357261034 : else if (type != SymbolTable_NulSym)
6616 : : {
6617 : : /* avoid dangling else. */
6618 : 294601446 : if ((SymbolTable_IsType (type)) && skipEquiv)
6619 : : {
6620 : 12452588 : if ((! (SymbolTable_IsHiddenType (type))) || skipHidden)
6621 : : {
6622 : 12292198 : if (((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym) || skipAlign)
6623 : : {
6624 : 12292180 : return doGetType (type, skipEquiv, skipAlign, skipHidden, skipBase);
6625 : : }
6626 : : }
6627 : : }
6628 : : }
6629 : : return type;
6630 : : /* static analysis guarentees a RETURN statement will be used before here. */
6631 : : __builtin_unreachable ();
6632 : : }
6633 : :
6634 : :
6635 : : /*
6636 : : GetTypeOfVar - returns the type of symbol, var.
6637 : : */
6638 : :
6639 : 99027867 : static unsigned int GetTypeOfVar (unsigned int var)
6640 : : {
6641 : 99027867 : SymbolTable_PtrToSymbol pSym;
6642 : 99027867 : unsigned int high;
6643 : :
6644 : 99027867 : pSym = GetPsym (var);
6645 : 99027867 : switch (pSym->SymbolType)
6646 : : {
6647 : 99027867 : case SymbolTable_VarSym:
6648 : 99027867 : if (pSym->Var.IsTemp && pSym->Var.IsComponentRef)
6649 : : {
6650 : 1559724 : high = Indexing_HighIndice (pSym->Var.list);
6651 : 3119448 : return SymbolTable_GetType (GetFromIndex (pSym->Var.list, high));
6652 : : }
6653 : : else
6654 : : {
6655 : 97468143 : return pSym->Var.Type;
6656 : : }
6657 : 0 : break;
6658 : :
6659 : :
6660 : 0 : default:
6661 : 0 : M2Error_InternalError ((const char *) "expecting a var symbol", 22);
6662 : : break;
6663 : : }
6664 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6665 : : __builtin_unreachable ();
6666 : : }
6667 : :
6668 : :
6669 : : /*
6670 : : GetConstLitType - returns the type of the constant of, name.
6671 : : All floating point constants have type LONGREAL.
6672 : : Character constants are type CHAR.
6673 : : Integer values are INTEGER, LONGINT or LONGCARD
6674 : : depending upon their value.
6675 : : */
6676 : :
6677 : 405082 : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError)
6678 : : {
6679 : 405082 : location_t loc;
6680 : 405082 : DynamicStrings_String s;
6681 : :
6682 : 405082 : s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name));
6683 : 405082 : if ((DynamicStrings_char (s, -1)) == 'C')
6684 : : {
6685 : 116962 : s = DynamicStrings_KillString (s);
6686 : 116962 : return M2Base_Char;
6687 : : }
6688 : : else
6689 : : {
6690 : 288120 : if ((DynamicStrings_Index (s, '.', 0)) != -1) /* found a '.' in our constant */
6691 : : {
6692 : 6484 : s = DynamicStrings_KillString (s);
6693 : 6484 : return M2Base_RType;
6694 : : }
6695 : 281636 : loc = M2LexBuf_TokenToLocation (tok);
6696 : 281636 : switch (DynamicStrings_char (s, -1))
6697 : : {
6698 : 698 : case 'H':
6699 : 698 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 16, issueError);
6700 : 698 : break;
6701 : :
6702 : 2656 : case 'B':
6703 : 2656 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 8, issueError);
6704 : 2656 : break;
6705 : :
6706 : 24 : case 'A':
6707 : 24 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 2, issueError);
6708 : 24 : break;
6709 : :
6710 : :
6711 : 278258 : default:
6712 : 278258 : (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 10, issueError);
6713 : 278258 : break;
6714 : : }
6715 : 281636 : s = DynamicStrings_KillString (s);
6716 : 281636 : return M2Base_ZType;
6717 : : }
6718 : : /* static analysis guarentees a RETURN statement will be used before here. */
6719 : : __builtin_unreachable ();
6720 : : }
6721 : :
6722 : :
6723 : : /*
6724 : : GetNthFromComponent -
6725 : : */
6726 : :
6727 : 304830 : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n)
6728 : : {
6729 : 304830 : SymbolTable_PtrToSymbol pSym;
6730 : :
6731 : 304830 : pSym = GetPsym (Sym);
6732 : 304830 : switch (pSym->SymbolType)
6733 : : {
6734 : 304830 : case SymbolTable_VarSym:
6735 : 304830 : if (SymbolTable_IsComponent (Sym))
6736 : : {
6737 : 304830 : if (Indexing_InBounds (pSym->Var.list, n))
6738 : : {
6739 : 407256 : return GetFromIndex (pSym->Var.list, n);
6740 : : }
6741 : : else
6742 : : {
6743 : : return SymbolTable_NulSym;
6744 : : }
6745 : : }
6746 : : else
6747 : : {
6748 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
6749 : : }
6750 : 0 : break;
6751 : :
6752 : :
6753 : 0 : default:
6754 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
6755 : : break;
6756 : : }
6757 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
6758 : : __builtin_unreachable ();
6759 : : }
6760 : :
6761 : :
6762 : : /*
6763 : : GetNthParamChoice - returns the parameter definition from
6764 : : sym:ParamNo:kind or NulSym.
6765 : : */
6766 : :
6767 : 571234 : static unsigned int GetNthParamChoice (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind kind)
6768 : : {
6769 : 571234 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
6770 : : {
6771 : 571234 : return SymbolTable_GetNthParam (sym, kind, ParamNo);
6772 : : }
6773 : : else
6774 : : {
6775 : : return SymbolTable_NulSym;
6776 : : }
6777 : : /* static analysis guarentees a RETURN statement will be used before here. */
6778 : : __builtin_unreachable ();
6779 : : }
6780 : :
6781 : :
6782 : : /*
6783 : : GetNthParamOrdered - returns the parameter definition from list {a, b, c}
6784 : : in order.
6785 : : sym:ParamNo:{a,b,c} or NulSym.
6786 : : */
6787 : :
6788 : 571234 : static unsigned int GetNthParamOrdered (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind a, SymbolTable_ProcedureKind b, SymbolTable_ProcedureKind c)
6789 : : {
6790 : 571234 : unsigned int param;
6791 : :
6792 : 571234 : param = GetNthParamChoice (sym, ParamNo, a);
6793 : 571234 : if (param == SymbolTable_NulSym)
6794 : : {
6795 : 0 : param = GetNthParamChoice (sym, ParamNo, b);
6796 : 0 : if (param == SymbolTable_NulSym)
6797 : : {
6798 : 0 : param = GetNthParamChoice (sym, ParamNo, c);
6799 : : }
6800 : : }
6801 : 571234 : return param;
6802 : : /* static analysis guarentees a RETURN statement will be used before here. */
6803 : : __builtin_unreachable ();
6804 : : }
6805 : :
6806 : :
6807 : : /*
6808 : : GetOuterModuleScope - returns the outer module symbol scope for sym.
6809 : : */
6810 : :
6811 : 1142468 : static unsigned int GetOuterModuleScope (unsigned int sym)
6812 : : {
6813 : 1713888 : while (! ((SymbolTable_IsDefImp (sym)) || ((SymbolTable_IsModule (sym)) && ((SymbolTable_GetScope (sym)) == SymbolTable_NulSym))))
6814 : : {
6815 : 571420 : sym = SymbolTable_GetScope (sym);
6816 : : }
6817 : 1142468 : return sym;
6818 : : /* static analysis guarentees a RETURN statement will be used before here. */
6819 : : __builtin_unreachable ();
6820 : : }
6821 : :
6822 : :
6823 : : /*
6824 : : EnsureOrder - providing that both symbols, a, and, b, exist in
6825 : : list, l. Ensure that, b, is placed after a.
6826 : : */
6827 : :
6828 : 264 : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b)
6829 : : {
6830 : 264 : unsigned int n;
6831 : :
6832 : 264 : n = Lists_NoOfItemsInList (l);
6833 : 264 : if ((Lists_IsItemInList (l, a)) && (Lists_IsItemInList (l, b)))
6834 : : {
6835 : 264 : Lists_RemoveItemFromList (l, b);
6836 : 264 : Lists_IncludeItemIntoList (l, b);
6837 : : }
6838 : 264 : M2Debug_Assert (n == (Lists_NoOfItemsInList (l)));
6839 : 264 : }
6840 : :
6841 : :
6842 : : /*
6843 : : DumpSons -
6844 : : */
6845 : :
6846 : 0 : static void DumpSons (unsigned int sym)
6847 : : {
6848 : 0 : SymbolTable_PtrToSymbol pSym;
6849 : 0 : unsigned int f;
6850 : 0 : unsigned int n;
6851 : 0 : unsigned int i;
6852 : :
6853 : 0 : pSym = GetPsym (sym);
6854 : 0 : switch (pSym->SymbolType)
6855 : : {
6856 : 0 : case SymbolTable_RecordSym:
6857 : 0 : n = Lists_NoOfItemsInList (pSym->Record.ListOfSons);
6858 : 0 : i = 1;
6859 : 0 : while (i <= n)
6860 : : {
6861 : 0 : f = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, i));
6862 : 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));
6863 : 0 : i += 1;
6864 : : }
6865 : 0 : break;
6866 : :
6867 : :
6868 : 0 : default:
6869 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
6870 : 0 : break;
6871 : : }
6872 : 0 : }
6873 : :
6874 : :
6875 : : /*
6876 : : CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
6877 : : */
6878 : :
6879 : 0 : static void CheckListOfSons (unsigned int sym)
6880 : : {
6881 : 0 : SymbolTable_PtrToSymbol pSym;
6882 : :
6883 : 0 : pSym = GetPsym (recordConsist);
6884 : 0 : switch (pSym->SymbolType)
6885 : : {
6886 : 0 : case SymbolTable_RecordSym:
6887 : 0 : if (! (Lists_IsItemInList (pSym->Record.ListOfSons, sym)))
6888 : : {
6889 : 0 : DumpSons (recordConsist);
6890 : 0 : M2MetaError_MetaError1 ((const char *) "internal error: expecting {%1ad} to exist in record ListOfSons", 63, sym);
6891 : : }
6892 : 0 : break;
6893 : :
6894 : :
6895 : 0 : default:
6896 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
6897 : 0 : break;
6898 : : }
6899 : 0 : }
6900 : :
6901 : :
6902 : : /*
6903 : : CheckRecordConsistency -
6904 : : */
6905 : :
6906 : 0 : static void CheckRecordConsistency (unsigned int sym)
6907 : : {
6908 : 0 : SymbolTable_PtrToSymbol pSym;
6909 : :
6910 : 0 : return;
6911 : : pSym = GetPsym (sym);
6912 : : switch (pSym->SymbolType)
6913 : : {
6914 : : case SymbolTable_RecordSym:
6915 : : recordConsist = sym;
6916 : : SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) CheckListOfSons});
6917 : : break;
6918 : :
6919 : :
6920 : : default:
6921 : : M2Error_InternalError ((const char *) "record symbol expected", 22);
6922 : 0 : break;
6923 : : }
6924 : : }
6925 : :
6926 : :
6927 : : /*
6928 : : PutConstVarTemporary - indicates that constant, sym, is a temporary.
6929 : : */
6930 : :
6931 : 424146 : static void PutConstVarTemporary (unsigned int sym)
6932 : : {
6933 : 424146 : SymbolTable_PtrToSymbol pSym;
6934 : :
6935 : 424146 : pSym = GetPsym (sym);
6936 : 424146 : switch (pSym->SymbolType)
6937 : : {
6938 : 424146 : case SymbolTable_ConstVarSym:
6939 : 424146 : pSym->ConstVar.IsTemp = true;
6940 : 424146 : break;
6941 : :
6942 : :
6943 : 0 : default:
6944 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
6945 : 424146 : break;
6946 : : }
6947 : 424146 : }
6948 : :
6949 : :
6950 : : /*
6951 : : buildTemporary - builds the temporary filling in componentRef, record and sets mode.
6952 : : */
6953 : :
6954 : 1037697 : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record)
6955 : : {
6956 : 1037697 : SymbolTable_PtrToSymbol pSym;
6957 : 1037697 : DynamicStrings_String s;
6958 : 1037697 : unsigned int Sym;
6959 : :
6960 : 1037697 : TemporaryNo += 1;
6961 : : /* Make the name */
6962 : 1037697 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
6963 : 1037697 : if (Mode == SymbolTable_ImmediateValue)
6964 : : {
6965 : 403560 : Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
6966 : 403560 : PutConstVarTemporary (Sym);
6967 : : }
6968 : : else
6969 : : {
6970 : 634137 : Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
6971 : 634137 : pSym = GetPsym (Sym);
6972 : 634137 : switch (pSym->SymbolType)
6973 : : {
6974 : 634137 : case SymbolTable_VarSym:
6975 : 634137 : pSym->Var.AddrMode = Mode;
6976 : 634137 : pSym->Var.IsComponentRef = componentRef;
6977 : 634137 : pSym->Var.IsTemp = true; /* Variable is a temporary var */
6978 : 634137 : if (componentRef) /* Variable is a temporary var */
6979 : : {
6980 : 126940 : pSym->Var.list = Indexing_InitIndex (1);
6981 : 126940 : PutIntoIndex (&pSym->Var.list, 1, record);
6982 : : }
6983 : 634137 : InitWhereDeclaredTok (tok, &pSym->Var.At); /* Declared here */
6984 : 634137 : InitWhereFirstUsedTok (tok, &pSym->Var.At); /* Where symbol first used. */
6985 : 634137 : break;
6986 : :
6987 : :
6988 : 0 : default:
6989 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22); /* Where symbol first used. */
6990 : 1037697 : break;
6991 : : }
6992 : : }
6993 : 1037697 : s = DynamicStrings_KillString (s);
6994 : 1037697 : return Sym;
6995 : : /* static analysis guarentees a RETURN statement will be used before here. */
6996 : : __builtin_unreachable ();
6997 : : }
6998 : :
6999 : :
7000 : : /*
7001 : : AssertInRange - determines whether the Sym is a legal symbol.
7002 : : */
7003 : :
7004 : 1281634480 : static void AssertInRange (unsigned int Sym)
7005 : : {
7006 : 1281634480 : if ((Sym < 1) || (Sym > (SymbolTable_FinalSymbol ())))
7007 : : {
7008 : 6 : M2Error_InternalError ((const char *) "illegal symbol", 14);
7009 : : }
7010 : 1281634474 : }
7011 : :
7012 : :
7013 : : /*
7014 : : CheckForHiddenType - scans the NeedToBeImplemented tree providing
7015 : : that we are currently compiling an implementation
7016 : : module. If a symbol is found with TypeName
7017 : : then its Sym is returned.
7018 : : Otherwise NulSym is returned.
7019 : : CheckForHiddenType is called before any type is
7020 : : created, therefore the compiler allows hidden
7021 : : types to be implemented using any type.
7022 : : */
7023 : :
7024 : 5098576 : static unsigned int CheckForHiddenType (NameKey_Name TypeName)
7025 : : {
7026 : 5098576 : SymbolTable_PtrToSymbol pSym;
7027 : 5098576 : unsigned int Sym;
7028 : :
7029 : 5098576 : Sym = SymbolTable_NulSym;
7030 : 5098576 : if ((((M2Comp_CompilingImplementationModule ()) && (SymbolTable_IsDefImp (CurrentModule))) && (SymbolTable_IsHiddenTypeDeclared (CurrentModule))) && (TypeName != NameKey_NulName))
7031 : : {
7032 : : /* Check to see whether we are declaring a HiddenType. */
7033 : 48079 : pSym = GetPsym (CurrentModule);
7034 : 48079 : switch (pSym->SymbolType)
7035 : : {
7036 : 48079 : case SymbolTable_DefImpSym:
7037 : 48079 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, TypeName));
7038 : 48079 : break;
7039 : :
7040 : :
7041 : 0 : default:
7042 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7043 : 48079 : break;
7044 : : }
7045 : : }
7046 : 5098576 : return Sym;
7047 : : /* static analysis guarentees a RETURN statement will be used before here. */
7048 : : __builtin_unreachable ();
7049 : : }
7050 : :
7051 : :
7052 : : /*
7053 : : RequestFromModule - returns a symbol from module ModSym with name, SymName.
7054 : : */
7055 : :
7056 : 108 : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7057 : : {
7058 : 108 : SymbolTable_PtrToSymbol pSym;
7059 : 108 : unsigned int Sym;
7060 : :
7061 : 108 : pSym = GetPsym (ModSym);
7062 : 108 : switch (pSym->SymbolType)
7063 : : {
7064 : 0 : case SymbolTable_DefImpSym:
7065 : 0 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymName));
7066 : 0 : if (Sym == SymbolTable_NulSym)
7067 : : {
7068 : 0 : Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
7069 : : }
7070 : : break;
7071 : :
7072 : 108 : case SymbolTable_ModuleSym:
7073 : 108 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymName));
7074 : 108 : if (Sym == SymbolTable_NulSym)
7075 : : {
7076 : 12 : Sym = FetchUnknownFromModule (tok, ModSym, SymName);
7077 : : }
7078 : : break;
7079 : :
7080 : :
7081 : 0 : default:
7082 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7083 : 108 : break;
7084 : : }
7085 : 108 : return Sym;
7086 : : /* static analysis guarentees a RETURN statement will be used before here. */
7087 : : __builtin_unreachable ();
7088 : : }
7089 : :
7090 : :
7091 : : /*
7092 : : RequestFromDefinition - returns a symbol from module ModSym with name,
7093 : : SymName.
7094 : : */
7095 : :
7096 : 2058100 : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7097 : : {
7098 : 2058100 : SymbolTable_PtrToSymbol pSym;
7099 : 2058100 : unsigned int Sym;
7100 : 2058100 : unsigned int OldScopePtr;
7101 : :
7102 : 2058100 : pSym = GetPsym (ModSym);
7103 : 2058100 : switch (pSym->SymbolType)
7104 : : {
7105 : 2058100 : case SymbolTable_DefImpSym:
7106 : 2058100 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName));
7107 : 2058100 : if (Sym == SymbolTable_NulSym)
7108 : : {
7109 : 656678 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName));
7110 : 656678 : if (Sym == SymbolTable_NulSym)
7111 : : {
7112 : 317962 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
7113 : 317962 : if (Sym == SymbolTable_NulSym)
7114 : : {
7115 : 285112 : OldScopePtr = ScopePtr;
7116 : 285112 : SymbolTable_StartScope (ModSym);
7117 : 285112 : Sym = GetScopeSym (SymName, true);
7118 : 285112 : SymbolTable_EndScope ();
7119 : 285112 : M2Debug_Assert (OldScopePtr == ScopePtr);
7120 : 285112 : if (Sym == SymbolTable_NulSym)
7121 : : {
7122 : 285080 : Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
7123 : : }
7124 : : else
7125 : : {
7126 : 32 : if (SymbolTable_IsFieldEnumeration (Sym))
7127 : : {
7128 : 6 : if (SymbolTable_IsExported (ModSym, SymbolTable_GetType (Sym)))
7129 : : {
7130 : : return Sym;
7131 : : }
7132 : : }
7133 : : }
7134 : 285106 : SymbolKey_PutSymKey (pSym->DefImp.ExportRequest, SymName, Sym);
7135 : : }
7136 : : }
7137 : : }
7138 : : break;
7139 : :
7140 : :
7141 : 0 : default:
7142 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7143 : : break;
7144 : : }
7145 : : return Sym;
7146 : : /* static analysis guarentees a RETURN statement will be used before here. */
7147 : : __builtin_unreachable ();
7148 : : }
7149 : :
7150 : :
7151 : : /*
7152 : : GetWhereImported - returns the token number where this symbol
7153 : : was imported into the current module.
7154 : : */
7155 : :
7156 : 6 : static unsigned int GetWhereImported (unsigned int Sym)
7157 : : {
7158 : 6 : SymbolTable_PtrToSymbol pSym;
7159 : :
7160 : 6 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
7161 : 6 : switch (pSym->SymbolType)
7162 : : {
7163 : 6 : case SymbolTable_DefImpSym:
7164 : 6 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym));
7165 : 0 : break;
7166 : :
7167 : 0 : case SymbolTable_ModuleSym:
7168 : 0 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym));
7169 : 0 : break;
7170 : :
7171 : :
7172 : 0 : default:
7173 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
7174 : : break;
7175 : : }
7176 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7177 : : __builtin_unreachable ();
7178 : : }
7179 : :
7180 : :
7181 : : /*
7182 : : DisplayName - displays the name.
7183 : : */
7184 : :
7185 : 0 : static void DisplayName (unsigned int sym)
7186 : : {
7187 : 0 : M2Printf_printf1 ((const char *) " %a", 5, (const unsigned char *) &sym, (sizeof (sym)-1));
7188 : 0 : }
7189 : :
7190 : :
7191 : : /*
7192 : : DisplaySymbol - displays the name of a symbol
7193 : : */
7194 : :
7195 : 0 : static void DisplaySymbol (unsigned int sym)
7196 : : {
7197 : 0 : DynamicStrings_String s;
7198 : :
7199 : 0 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym))));
7200 : 0 : M2Printf_printf2 ((const char *) " %s (%d)", 10, (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &sym, (sizeof (sym)-1));
7201 : 0 : }
7202 : :
7203 : :
7204 : : /*
7205 : : FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
7206 : : */
7207 : :
7208 : 12 : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7209 : : {
7210 : 12 : SymbolTable_PtrToSymbol pSym;
7211 : 12 : unsigned int Sym;
7212 : :
7213 : 12 : pSym = GetPsym (ModSym);
7214 : 12 : switch (pSym->SymbolType)
7215 : : {
7216 : 12 : case SymbolTable_ModuleSym:
7217 : 12 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
7218 : 12 : if (Sym == SymbolTable_NulSym)
7219 : : {
7220 : 12 : NewSym (&Sym);
7221 : 12 : FillInUnknownFields (tok, Sym, SymName);
7222 : 12 : SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
7223 : : }
7224 : 12 : break;
7225 : :
7226 : :
7227 : 0 : default:
7228 : 0 : M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
7229 : 12 : break;
7230 : : }
7231 : 12 : return Sym;
7232 : : /* static analysis guarentees a RETURN statement will be used before here. */
7233 : : __builtin_unreachable ();
7234 : : }
7235 : :
7236 : :
7237 : : /*
7238 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
7239 : : */
7240 : :
7241 : 285080 : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
7242 : : {
7243 : 285080 : SymbolTable_PtrToSymbol pSym;
7244 : 285080 : unsigned int Sym;
7245 : :
7246 : 285080 : pSym = GetPsym (ModSym);
7247 : 285080 : switch (pSym->SymbolType)
7248 : : {
7249 : 285080 : case SymbolTable_DefImpSym:
7250 : 285080 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
7251 : 285080 : if (Sym == SymbolTable_NulSym)
7252 : : {
7253 : 285080 : NewSym (&Sym);
7254 : 285080 : FillInUnknownFields (tok, Sym, SymName);
7255 : 285080 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
7256 : : }
7257 : 285080 : break;
7258 : :
7259 : :
7260 : 0 : default:
7261 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7262 : 285080 : break;
7263 : : }
7264 : 285080 : return Sym;
7265 : : /* static analysis guarentees a RETURN statement will be used before here. */
7266 : : __builtin_unreachable ();
7267 : : }
7268 : :
7269 : :
7270 : : /*
7271 : : FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
7272 : : */
7273 : :
7274 : 54 : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName)
7275 : : {
7276 : 54 : SymbolTable_PtrToSymbol pSym;
7277 : 54 : unsigned int Sym;
7278 : :
7279 : 54 : pSym = GetPsym (scope);
7280 : 54 : switch (pSym->SymbolType)
7281 : : {
7282 : 0 : case SymbolTable_DefImpSym:
7283 : 0 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
7284 : 0 : if (Sym == SymbolTable_NulSym)
7285 : : {
7286 : 0 : NewSym (&Sym);
7287 : 0 : FillInUnknownFields (tok, Sym, SymName);
7288 : 0 : SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
7289 : : }
7290 : : break;
7291 : :
7292 : 36 : case SymbolTable_ModuleSym:
7293 : 36 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
7294 : 36 : if (Sym == SymbolTable_NulSym)
7295 : : {
7296 : 36 : NewSym (&Sym);
7297 : 36 : FillInUnknownFields (tok, Sym, SymName);
7298 : 36 : SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
7299 : : }
7300 : : break;
7301 : :
7302 : 18 : case SymbolTable_ProcedureSym:
7303 : 18 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, SymName));
7304 : 18 : if (Sym == SymbolTable_NulSym)
7305 : : {
7306 : 18 : NewSym (&Sym);
7307 : 18 : FillInUnknownFields (tok, Sym, SymName);
7308 : 18 : SymbolKey_PutSymKey (pSym->Procedure.Unresolved, SymName, Sym);
7309 : : }
7310 : : break;
7311 : :
7312 : :
7313 : 0 : default:
7314 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module or Procedure symbol", 48);
7315 : 54 : break;
7316 : : }
7317 : 54 : return Sym;
7318 : : /* static analysis guarentees a RETURN statement will be used before here. */
7319 : : __builtin_unreachable ();
7320 : : }
7321 : :
7322 : :
7323 : : /*
7324 : : UnknownSymbolError - displays symbol name for symbol, sym.
7325 : : */
7326 : :
7327 : 132 : static void UnknownSymbolError (unsigned int sym)
7328 : : {
7329 : 132 : if (IsUnreportedUnknown (sym))
7330 : : {
7331 : 132 : Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
7332 : 132 : M2MetaError_MetaErrorStringT1 (SymbolTable_GetFirstUsed (sym), DynamicStrings_InitString ((const char *) "unknown symbol {%1EUad}", 23), sym);
7333 : : }
7334 : 132 : }
7335 : :
7336 : :
7337 : : /*
7338 : : IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
7339 : : reported and is an unknown symbol.
7340 : : */
7341 : :
7342 : 22821579 : static bool IsUnreportedUnknown (unsigned int sym)
7343 : : {
7344 : 22821579 : return (SymbolTable_IsUnknown (sym)) && (! (Sets_IsElementInSet (ReportedUnknowns, sym)));
7345 : : /* static analysis guarentees a RETURN statement will be used before here. */
7346 : : __builtin_unreachable ();
7347 : : }
7348 : :
7349 : :
7350 : : /*
7351 : : AddListify -
7352 : : */
7353 : :
7354 : 132 : static void AddListify (unsigned int sym)
7355 : : {
7356 : 132 : ListifyWordCount += 1;
7357 : : /* printf ("AddListify: ListifyWordCount = %d, ListifyTotal = %d
7358 : : ",
7359 : : ListifyWordCount, ListifyTotal) ; */
7360 : 132 : if (ListifyWordCount > 1)
7361 : : {
7362 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7363 : 24 : if (ListifyWordCount == ListifyTotal)
7364 : : {
7365 : 24 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) " and ", 5)));
7366 : : }
7367 : : else
7368 : : {
7369 : 0 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ", ", 2)));
7370 : : }
7371 : : }
7372 : 132 : ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym)))));
7373 : 132 : }
7374 : :
7375 : :
7376 : : /*
7377 : : Listify - convert tree into a string list and return the result.
7378 : : */
7379 : :
7380 : 108 : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition)
7381 : : {
7382 : 108 : ListifyTotal = SymbolKey_NoOfNodes (tree, isCondition);
7383 : 108 : ListifyWordCount = 0;
7384 : 108 : ListifySentance = DynamicStrings_InitString ((const char *) "", 0);
7385 : 108 : SymbolKey_ForeachNodeConditionDo (tree, isCondition, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) AddListify});
7386 : 108 : return ListifySentance;
7387 : : /* static analysis guarentees a RETURN statement will be used before here. */
7388 : : __builtin_unreachable ();
7389 : : }
7390 : :
7391 : :
7392 : : /*
7393 : : CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
7394 : : an unknown symbol. All unknown symbols are displayed
7395 : : together with an error message.
7396 : : */
7397 : :
7398 : 1489696 : static void CheckForUnknowns (NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
7399 : : {
7400 : 1489696 : DynamicStrings_String s;
7401 : 1489696 : char a[_a_high+1];
7402 : :
7403 : : /* make a local copy of each unbounded array. */
7404 : 1489696 : memcpy (a, a_, _a_high+1);
7405 : :
7406 : 1489696 : if (SymbolKey_DoesTreeContainAny (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown}))
7407 : : {
7408 : 108 : CurrentError = M2Error_NewError (M2LexBuf_GetTokenNo ());
7409 : 108 : s = DynamicStrings_InitString ((const char *) "{%E} the following unknown symbols in module %<", 47);
7410 : 108 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
7411 : 108 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%> were ", 8)));
7412 : 108 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
7413 : 108 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ": ", 2)));
7414 : 108 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (Listify (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown})));
7415 : 108 : M2MetaError_MetaErrorStringT0 (M2LexBuf_GetTokenNo (), s);
7416 : 108 : SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnknownSymbolError});
7417 : : }
7418 : 1489696 : }
7419 : :
7420 : :
7421 : : /*
7422 : : SymbolError - displays symbol name for symbol, Sym.
7423 : : */
7424 : :
7425 : 0 : static void SymbolError (unsigned int Sym)
7426 : : {
7427 : 0 : M2Error_Error e;
7428 : 0 : NameKey_Name n;
7429 : :
7430 : 0 : n = SymbolTable_GetSymName (Sym);
7431 : 0 : e = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
7432 : 0 : M2Error_ErrorFormat1 (e, (const char *) "unknown symbol '%a' found", 25, (const unsigned char *) &n, (sizeof (n)-1));
7433 : 0 : }
7434 : :
7435 : :
7436 : : /*
7437 : : CheckForSymbols - checks a binary tree, Tree, to see whether it contains
7438 : : any symbol. The tree is expected to be empty, if not
7439 : : then an error has occurred.
7440 : : */
7441 : :
7442 : 349019 : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
7443 : : {
7444 : 349019 : DynamicStrings_String s;
7445 : 349019 : char a[_a_high+1];
7446 : :
7447 : : /* make a local copy of each unbounded array. */
7448 : 349019 : memcpy (a, a_, _a_high+1);
7449 : :
7450 : 349019 : if (! (SymbolKey_IsEmptyTree (Tree)))
7451 : : {
7452 : 0 : s = DynamicStrings_InitString ((const char *) "the symbols are unknown at the end of module {%1Ea} when ", 57);
7453 : 0 : s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
7454 : 0 : M2MetaError_MetaErrorString1 (s, MainModule);
7455 : 0 : SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SymbolError});
7456 : : }
7457 : 349019 : }
7458 : :
7459 : :
7460 : : /*
7461 : : PutExportUndeclared - places a symbol, Sym, into module, ModSym,
7462 : : ExportUndeclared list provided that Sym
7463 : : is unknown.
7464 : : */
7465 : :
7466 : 3163697 : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym)
7467 : : {
7468 : 3163697 : SymbolTable_PtrToSymbol pSym;
7469 : :
7470 : 3163697 : if (SymbolTable_IsUnknown (Sym))
7471 : : {
7472 : 2629474 : pSym = GetPsym (ModSym);
7473 : 2629474 : switch (pSym->SymbolType)
7474 : : {
7475 : 294 : case SymbolTable_ModuleSym:
7476 : 294 : SymbolKey_PutSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
7477 : 294 : break;
7478 : :
7479 : 2629180 : case SymbolTable_DefImpSym:
7480 : 2629180 : SymbolKey_PutSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
7481 : 2629180 : break;
7482 : :
7483 : :
7484 : 0 : default:
7485 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7486 : : break;
7487 : : }
7488 : : }
7489 : 3163697 : }
7490 : :
7491 : :
7492 : : /*
7493 : : GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
7494 : : which is in the ExportUndeclared list.
7495 : : */
7496 : :
7497 : 234 : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name)
7498 : : {
7499 : 234 : SymbolTable_PtrToSymbol pSym;
7500 : :
7501 : 234 : pSym = GetPsym (ModSym);
7502 : 234 : switch (pSym->SymbolType)
7503 : : {
7504 : 228 : case SymbolTable_ModuleSym:
7505 : 228 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, name));
7506 : 6 : break;
7507 : :
7508 : 6 : case SymbolTable_DefImpSym:
7509 : 6 : return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, name));
7510 : 0 : break;
7511 : :
7512 : :
7513 : 0 : default:
7514 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7515 : : break;
7516 : : }
7517 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7518 : : __builtin_unreachable ();
7519 : : }
7520 : :
7521 : :
7522 : : /*
7523 : : RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
7524 : : ExportUndeclaredTree.
7525 : : */
7526 : :
7527 : 7539631 : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym)
7528 : : {
7529 : 7539631 : SymbolTable_PtrToSymbol pSym;
7530 : :
7531 : 7539631 : pSym = GetPsym (ModSym);
7532 : 7539631 : switch (pSym->SymbolType)
7533 : : {
7534 : 18 : case SymbolTable_ModuleSym:
7535 : 18 : if ((SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
7536 : : {
7537 : 18 : SymbolKey_DelSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym));
7538 : : }
7539 : : break;
7540 : :
7541 : 7539613 : case SymbolTable_DefImpSym:
7542 : 7539613 : if ((SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
7543 : : {
7544 : 2628820 : SymbolKey_DelSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym));
7545 : : }
7546 : : break;
7547 : :
7548 : :
7549 : 0 : default:
7550 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7551 : 7539631 : break;
7552 : : }
7553 : 7539631 : }
7554 : :
7555 : :
7556 : : /*
7557 : : CheckForExportedDeclaration - checks to see whether a definition module
7558 : : is currently being compiled, if so,
7559 : : symbol, Sym, is removed from the
7560 : : ExportUndeclared list.
7561 : : This procedure is called whenever a symbol
7562 : : is declared, thus attempting to reduce
7563 : : the ExportUndeclared list.
7564 : : */
7565 : :
7566 : 13652635 : static void CheckForExportedDeclaration (unsigned int Sym)
7567 : : {
7568 : 13652635 : if (M2Comp_CompilingDefinitionModule ())
7569 : : {
7570 : 7539607 : RemoveExportUndeclared (SymbolTable_GetCurrentModule (), Sym);
7571 : : }
7572 : 13652635 : }
7573 : :
7574 : :
7575 : : /*
7576 : : UndeclaredSymbolError - displays symbol name for symbol, Sym.
7577 : : */
7578 : :
7579 : 0 : static void UndeclaredSymbolError (unsigned int Sym)
7580 : : {
7581 : 0 : if (DebugUnknowns)
7582 : : {
7583 : : M2Printf_printf1 ((const char *) "undeclared symbol (%d)\\n", 24, (const unsigned char *) &Sym, (sizeof (Sym)-1));
7584 : : }
7585 : 0 : M2MetaError_MetaError1 ((const char *) "{%1UC} undeclared symbol {%1a}", 30, Sym);
7586 : 0 : }
7587 : :
7588 : :
7589 : : /*
7590 : : RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
7591 : : NeedToBeImplemented list.
7592 : : */
7593 : :
7594 : 1238941 : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym)
7595 : : {
7596 : 1238941 : SymbolTable_PtrToSymbol pSym;
7597 : :
7598 : 1238941 : pSym = GetPsym (ModSym);
7599 : 1238941 : switch (pSym->SymbolType)
7600 : : {
7601 : 1238941 : case SymbolTable_DefImpSym:
7602 : 1238941 : if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
7603 : : {
7604 : 632760 : SymbolKey_DelSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym));
7605 : : }
7606 : 1238941 : break;
7607 : :
7608 : :
7609 : 0 : default:
7610 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7611 : 1238941 : break;
7612 : : }
7613 : 1238941 : }
7614 : :
7615 : :
7616 : : /*
7617 : : RemoveFromExportRequest -
7618 : : */
7619 : :
7620 : 383956 : static void RemoveFromExportRequest (unsigned int Sym)
7621 : : {
7622 : 383956 : SymbolTable_PtrToSymbol pSym;
7623 : :
7624 : 383956 : pSym = GetPsym (ExportRequestModule);
7625 : 383956 : switch (pSym->SymbolType)
7626 : : {
7627 : 383956 : case SymbolTable_DefImpSym:
7628 : 383956 : if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym))) == Sym)
7629 : : {
7630 : 6 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym));
7631 : : }
7632 : 383956 : break;
7633 : :
7634 : :
7635 : 0 : default:
7636 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
7637 : 383956 : break;
7638 : : }
7639 : 383956 : }
7640 : :
7641 : :
7642 : : /*
7643 : : RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
7644 : : (and its fields) from the ExportRequest tree.
7645 : : */
7646 : :
7647 : 13394 : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym)
7648 : : {
7649 : 13394 : if (SymbolTable_IsEnumeration (Sym))
7650 : : {
7651 : 13394 : ExportRequestModule = ModSym;
7652 : 13394 : RemoveFromExportRequest (Sym);
7653 : 13394 : SymbolTable_ForeachLocalSymDo (Sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) RemoveFromExportRequest});
7654 : : }
7655 : 13394 : }
7656 : :
7657 : :
7658 : : /*
7659 : : UnImplementedSymbolError - displays symbol name for symbol, Sym.
7660 : : */
7661 : :
7662 : 0 : static void UnImplementedSymbolError (unsigned int Sym)
7663 : : {
7664 : 0 : NameKey_Name n;
7665 : :
7666 : 0 : CurrentError = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
7667 : 0 : if (SymbolTable_IsType (Sym))
7668 : : {
7669 : 0 : n = SymbolTable_GetSymName (Sym);
7670 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "hidden type is undeclared (%a)", 30, (const unsigned char *) &n, (sizeof (n)-1));
7671 : : }
7672 : 0 : else if (SymbolTable_IsProcedure (Sym))
7673 : : {
7674 : : /* avoid dangling else. */
7675 : 0 : n = SymbolTable_GetSymName (Sym);
7676 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure is undeclared (%a)", 28, (const unsigned char *) &n, (sizeof (n)-1));
7677 : : }
7678 : 0 : else if (SymbolTable_IsProcType (Sym))
7679 : : {
7680 : : /* avoid dangling else. */
7681 : 0 : n = SymbolTable_GetSymName (Sym);
7682 : 0 : M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure type is undeclared (%a)", 33, (const unsigned char *) &n, (sizeof (n)-1));
7683 : : }
7684 : : else
7685 : : {
7686 : : /* avoid dangling else. */
7687 : 0 : M2Error_ErrorFormat0 (CurrentError, (const char *) "undeclared symbol", 17);
7688 : : }
7689 : 0 : }
7690 : :
7691 : :
7692 : : /*
7693 : : CheckEnumerationInList - places symbol, Sym, in the list, l,
7694 : : providing it does not already exist.
7695 : : PseudoScope(Sym) is called if Sym needs to
7696 : : be added to the enumeration list, l.
7697 : : */
7698 : :
7699 : 50838 : static void CheckEnumerationInList (Lists_List l, unsigned int Sym)
7700 : : {
7701 : 50838 : if (! (Lists_IsItemInList (l, Sym)))
7702 : : {
7703 : 44994 : Lists_PutItemIntoList (l, Sym);
7704 : 44994 : SymbolTable_PseudoScope (Sym);
7705 : : }
7706 : 50838 : }
7707 : :
7708 : :
7709 : : /*
7710 : : CheckIfEnumerationExported - An outer module may use an enumeration that
7711 : : is declared inside an inner module. The usage
7712 : : may occur before definition. The first pass
7713 : : exports a symbol, later the symbol is declared
7714 : : as an emumeration type. At this stage the
7715 : : CheckIfEnumerationExported procedure should be
7716 : : called. This procedure ripples from the current
7717 : : (inner) module to outer module and every time
7718 : : it is exported it must be added to the outer
7719 : : module EnumerationScopeList.
7720 : : */
7721 : :
7722 : 38606 : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId)
7723 : : {
7724 : 52002 : SymbolTable_PtrToCallFrame pCall;
7725 : 52002 : unsigned int InnerModId;
7726 : 52002 : unsigned int OuterModId;
7727 : 52002 : unsigned int InnerModSym;
7728 : 52002 : unsigned int OuterModSym;
7729 : :
7730 : 52002 : InnerModId = GetModuleScopeId (ScopeId);
7731 : 52002 : if (InnerModId > 0)
7732 : : {
7733 : 52002 : OuterModId = GetModuleScopeId (InnerModId-1);
7734 : 52002 : if (OuterModId > 0)
7735 : : {
7736 : 52002 : pCall = GetPcall (InnerModId);
7737 : 52002 : InnerModSym = pCall->Search;
7738 : 52002 : pCall = GetPcall (OuterModId);
7739 : 52002 : OuterModSym = pCall->Search;
7740 : 52002 : if ((InnerModSym != SymbolTable_NulSym) && (OuterModSym != SymbolTable_NulSym))
7741 : : {
7742 : 23370 : if (SymbolTable_IsExported (InnerModSym, Sym))
7743 : : {
7744 : 13396 : CheckForEnumerationInOuterModule (Sym, OuterModSym);
7745 : 13396 : CheckIfEnumerationExported (Sym, OuterModId);
7746 : : }
7747 : : }
7748 : : }
7749 : : }
7750 : 38606 : }
7751 : :
7752 : :
7753 : : /*
7754 : : CheckForEnumerationInOuterModule - checks to see whether the enumeration
7755 : : type symbol, Sym, has been entered into
7756 : : the outer module, OuterModule, scope list.
7757 : : OuterModule may be internal to the
7758 : : program module.
7759 : : */
7760 : :
7761 : 13396 : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule)
7762 : : {
7763 : 13396 : SymbolTable_PtrToSymbol pSym;
7764 : :
7765 : 13396 : pSym = GetPsym (OuterModule);
7766 : 13396 : switch (pSym->SymbolType)
7767 : : {
7768 : 0 : case SymbolTable_DefImpSym:
7769 : 0 : Lists_IncludeItemIntoList (pSym->DefImp.EnumerationScopeList, Sym);
7770 : 0 : break;
7771 : :
7772 : 13396 : case SymbolTable_ModuleSym:
7773 : 13396 : Lists_IncludeItemIntoList (pSym->Module.EnumerationScopeList, Sym);
7774 : 13396 : break;
7775 : :
7776 : :
7777 : 0 : default:
7778 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
7779 : 13396 : break;
7780 : : }
7781 : 13396 : }
7782 : :
7783 : :
7784 : : /*
7785 : : MakeVariableForParam -
7786 : : */
7787 : :
7788 : 6018343 : 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)
7789 : : {
7790 : 6018343 : SymbolTable_PtrToSymbol pSym;
7791 : 6018343 : unsigned int VariableSym;
7792 : :
7793 : 6018343 : tok = CheckTok (tok, (const char *) "parameter", 9);
7794 : 6018343 : VariableSym = SymbolTable_MakeVar (tok, ParamName);
7795 : 6018343 : pSym = GetPsym (VariableSym);
7796 : 6018343 : switch (pSym->SymbolType)
7797 : : {
7798 : : case SymbolTable_ErrorSym:
7799 : : return SymbolTable_NulSym;
7800 : 6018343 : break;
7801 : :
7802 : 6018343 : case SymbolTable_VarSym:
7803 : 6018343 : pSym->Var.IsParam = true; /* Variable is really a parameter. */
7804 : 6018343 : break;
7805 : :
7806 : :
7807 : 0 : default:
7808 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
7809 : 6018343 : break;
7810 : : }
7811 : : /* Note that the parameter is now treated as a local variable. */
7812 : 6018343 : SymbolTable_PutVarTok (VariableSym, ParmType, typetok);
7813 : 6018343 : SymbolTable_PutDeclared (tok, VariableSym);
7814 : : /*
7815 : : Normal VAR parameters have LeftValue,
7816 : : however Unbounded VAR parameters have RightValue.
7817 : : Non VAR parameters always have RightValue.
7818 : : */
7819 : 6018343 : if ((SymbolTable_IsVarParam (ProcSym, kind, no)) && (! (SymbolTable_IsUnboundedParam (ProcSym, kind, no))))
7820 : : {
7821 : 184974 : SymbolTable_PutMode (VariableSym, SymbolTable_LeftValue);
7822 : : }
7823 : : else
7824 : : {
7825 : 5833369 : SymbolTable_PutMode (VariableSym, SymbolTable_RightValue);
7826 : : }
7827 : : return VariableSym;
7828 : : /* static analysis guarentees a RETURN statement will be used before here. */
7829 : : __builtin_unreachable ();
7830 : : }
7831 : :
7832 : :
7833 : : /*
7834 : : AddParameter - adds a parameter ParSym to a procedure Sym.
7835 : : */
7836 : :
7837 : 13401891 : static void AddParameter (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParSym)
7838 : : {
7839 : 13401891 : SymbolTable_PtrToSymbol pSym;
7840 : :
7841 : 13401891 : pSym = GetPsym (Sym);
7842 : 13401891 : switch (pSym->SymbolType)
7843 : : {
7844 : : case SymbolTable_ErrorSym:
7845 : : break;
7846 : :
7847 : 7303675 : case SymbolTable_ProcedureSym:
7848 : 7303675 : Lists_PutItemIntoList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParSym);
7849 : 7303675 : break;
7850 : :
7851 : 6098216 : case SymbolTable_ProcTypeSym:
7852 : 6098216 : Lists_PutItemIntoList (pSym->ProcType.ListOfParam, ParSym);
7853 : 6098216 : break;
7854 : :
7855 : :
7856 : 0 : default:
7857 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
7858 : 13401891 : break;
7859 : : }
7860 : 13401891 : }
7861 : :
7862 : :
7863 : : /*
7864 : : AddProcedureProcTypeParam - adds ParamType to the parameter ProcType
7865 : : associated with procedure Sym.
7866 : : */
7867 : :
7868 : 7303675 : static void AddProcedureProcTypeParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded, bool isVarParam)
7869 : : {
7870 : 7303675 : SymbolTable_PtrToSymbol pSym;
7871 : :
7872 : 7303675 : pSym = GetPsym (Sym);
7873 : 7303675 : switch (pSym->SymbolType)
7874 : : {
7875 : 7303675 : case SymbolTable_ProcedureSym:
7876 : 7303675 : if (pSym->Procedure.BuildProcType)
7877 : : {
7878 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7879 : 6018343 : if (isVarParam)
7880 : : {
7881 : 426575 : SymbolTable_PutProcTypeVarParam (pSym->Procedure.ProcedureType, ParamType, isUnbounded);
7882 : : }
7883 : : else
7884 : : {
7885 : 5591768 : SymbolTable_PutProcTypeParam (pSym->Procedure.ProcedureType, ParamType, isUnbounded);
7886 : : }
7887 : : }
7888 : 7303675 : break;
7889 : :
7890 : :
7891 : 0 : default:
7892 : 0 : M2Error_InternalError ((const char *) "expecting Sym to be a procedure", 31);
7893 : 7303675 : break;
7894 : : }
7895 : 7303675 : }
7896 : :
7897 : :
7898 : : /*
7899 : : IsNthParamVar - returns true if the n th parameter of the parameter list,
7900 : : List, is a VAR parameter.
7901 : : */
7902 : :
7903 : 14896626 : static bool IsNthParamVar (Lists_List Head, unsigned int n)
7904 : : {
7905 : 14896626 : SymbolTable_PtrToSymbol pSym;
7906 : 14896626 : unsigned int p;
7907 : :
7908 : 14896626 : p = static_cast<unsigned int> (Lists_GetItemFromList (Head, n));
7909 : 14896626 : if (p == SymbolTable_NulSym)
7910 : : {
7911 : 0 : M2Error_InternalError ((const char *) "parameter does not exist", 24);
7912 : : }
7913 : : else
7914 : : {
7915 : 14896626 : pSym = GetPsym (p);
7916 : 14896626 : switch (pSym->SymbolType)
7917 : : {
7918 : : case SymbolTable_ErrorSym:
7919 : : return false;
7920 : 825331 : break;
7921 : :
7922 : 825331 : case SymbolTable_VarParamSym:
7923 : 825331 : return true;
7924 : : break;
7925 : :
7926 : : case SymbolTable_ParamSym:
7927 : : return false;
7928 : 0 : break;
7929 : :
7930 : :
7931 : 0 : default:
7932 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
7933 : : break;
7934 : : }
7935 : : }
7936 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
7937 : : __builtin_unreachable ();
7938 : : }
7939 : :
7940 : :
7941 : : /*
7942 : : MakeParameterHeapVar - create a heap variable if sym is a pointer.
7943 : : */
7944 : :
7945 : 341099 : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode)
7946 : : {
7947 : 341099 : unsigned int heapvar;
7948 : :
7949 : 341099 : tok = CheckTok (tok, (const char *) "parameter heap var", 18);
7950 : 341099 : heapvar = SymbolTable_NulSym;
7951 : 341099 : type = SymbolTable_SkipType (type);
7952 : 341099 : if (SymbolTable_IsPointer (type))
7953 : : {
7954 : 44948 : heapvar = SymbolTable_MakeTemporary (tok, mode);
7955 : 44948 : SymbolTable_PutVar (heapvar, type);
7956 : 44948 : SymbolTable_PutVarHeap (heapvar, true);
7957 : : }
7958 : 341099 : return heapvar;
7959 : : /* static analysis guarentees a RETURN statement will be used before here. */
7960 : : __builtin_unreachable ();
7961 : : }
7962 : :
7963 : :
7964 : : /*
7965 : : PutParameterHeapVar - creates a heap variable associated with parameter sym.
7966 : : */
7967 : :
7968 : 3187603 : static void PutParameterHeapVar (unsigned int sym)
7969 : : {
7970 : 3187603 : SymbolTable_PtrToSymbol pSym;
7971 : :
7972 : 3187603 : pSym = GetPsym (sym);
7973 : 3187603 : switch (pSym->SymbolType)
7974 : : {
7975 : : case SymbolTable_ParamSym:
7976 : : break;
7977 : :
7978 : 341099 : case SymbolTable_VarParamSym:
7979 : 341099 : pSym->VarParam.HeapVar = MakeParameterHeapVar (SymbolTable_GetDeclaredMod (sym), pSym->VarParam.Type, SymbolTable_LeftValue); /* Nothing to do for the non var parameter. */
7980 : 341099 : break;
7981 : :
7982 : :
7983 : 0 : default:
7984 : 0 : M2Error_InternalError ((const char *) "Param or VarParam symbol expected", 33);
7985 : 3187603 : break;
7986 : : }
7987 : 3187603 : }
7988 : :
7989 : :
7990 : : /*
7991 : : IsProcedureAnyBoolean - returns the boolean result from p
7992 : : for any of procedure kind which is defined.
7993 : : */
7994 : :
7995 : 7041 : static bool IsProcedureAnyBoolean (unsigned int sym, SymbolTable_ProcAnyBoolean p)
7996 : : {
7997 : 7041 : SymbolTable_ProcedureKind kind;
7998 : :
7999 : 21111 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
8000 : : {
8001 : 21111 : if (SymbolTable_GetProcedureDefined (sym, kind))
8002 : : {
8003 : 7041 : return (*p.proc) (sym, kind);
8004 : : }
8005 : : }
8006 : 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
8007 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8008 : : __builtin_unreachable ();
8009 : : }
8010 : :
8011 : :
8012 : : /*
8013 : : IsProcedureAnyDefaultBoolean - returns the boolean result from p
8014 : : for any of procedure kind which is defined.
8015 : : */
8016 : :
8017 : 2461217 : static bool IsProcedureAnyDefaultBoolean (unsigned int sym, bool default_, SymbolTable_ProcAnyBoolean p)
8018 : : {
8019 : 2461217 : SymbolTable_ProcedureKind kind;
8020 : :
8021 : 6131297 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
8022 : : {
8023 : 5832297 : if (SymbolTable_GetProcedureDefined (sym, kind))
8024 : : {
8025 : 2162217 : return (*p.proc) (sym, kind);
8026 : : }
8027 : : }
8028 : : return default_;
8029 : : /* static analysis guarentees a RETURN statement will be used before here. */
8030 : : __builtin_unreachable ();
8031 : : }
8032 : :
8033 : :
8034 : : /*
8035 : : FillInUnknownFields -
8036 : : */
8037 : :
8038 : 6839882 : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName)
8039 : : {
8040 : 6839882 : SymbolTable_PtrToSymbol pSym;
8041 : :
8042 : 6839882 : pSym = GetPsym (sym);
8043 : 6839882 : pSym->SymbolType = SymbolTable_UndefinedSym;
8044 : 6839882 : pSym->Undefined.name = SymName;
8045 : 6839882 : pSym->Undefined.oafamily = SymbolTable_NulSym;
8046 : 6839882 : pSym->Undefined.errorScope = M2Error_GetCurrentErrorScope ();
8047 : 6839882 : InitWhereFirstUsedTok (tok, &pSym->Undefined.At);
8048 : 6839882 : }
8049 : :
8050 : :
8051 : : /*
8052 : : FillInPointerFields - given a new symbol, sym, make it a pointer symbol
8053 : : and initialize its fields.
8054 : : */
8055 : :
8056 : 176102 : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf)
8057 : : {
8058 : 176102 : SymbolTable_PtrToSymbol pSym;
8059 : :
8060 : 176102 : if (! (SymbolTable_IsError (Sym)))
8061 : : {
8062 : 176102 : pSym = GetPsym (Sym);
8063 : 176102 : pSym->SymbolType = SymbolTable_PointerSym;
8064 : 176102 : switch (pSym->SymbolType)
8065 : : {
8066 : 176102 : case SymbolTable_PointerSym:
8067 : 176102 : pSym->Pointer.Type = SymbolTable_NulSym;
8068 : 176102 : pSym->Pointer.name = PointerName;
8069 : 176102 : pSym->Pointer.oafamily = oaf; /* The unbounded for this */
8070 : 176102 : SymbolKey_InitTree (&pSym->Pointer.ConstLitTree); /* constants of this type */
8071 : 176102 : pSym->Pointer.Scope = scope; /* Which scope created it */
8072 : 176102 : pSym->Pointer.Size = M2ALU_InitValue (); /* Which scope created it */
8073 : 176102 : pSym->Pointer.Align = SymbolTable_NulSym; /* Alignment of this type */
8074 : 176102 : break;
8075 : :
8076 : :
8077 : : default:
8078 : : M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26); /* Alignment of this type */
8079 : 176102 : break;
8080 : : }
8081 : : }
8082 : 176102 : }
8083 : :
8084 : :
8085 : : /*
8086 : : ForeachParameterDo -
8087 : : */
8088 : :
8089 : 33548 : static void ForeachParameterDo (SymbolTable_CheckProcedure p)
8090 : : {
8091 : 33548 : unsigned int l;
8092 : 33548 : unsigned int h;
8093 : :
8094 : 33548 : l = Indexing_LowIndice (Symbols);
8095 : 33548 : h = Indexing_HighIndice (Symbols);
8096 : 48589506 : while (l <= h)
8097 : : {
8098 : 48522410 : if (SymbolTable_IsParameter (l))
8099 : : {
8100 : 7086625 : (*p.proc) (l);
8101 : : }
8102 : 48522410 : l += 1;
8103 : : }
8104 : 33548 : }
8105 : :
8106 : :
8107 : : /*
8108 : : CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
8109 : : */
8110 : :
8111 : 7086625 : static void CheckUnbounded (unsigned int Sym)
8112 : : {
8113 : 7086625 : SymbolTable_PtrToSymbol pSym;
8114 : :
8115 : 7086625 : AssertInRange (Sym);
8116 : 7086625 : pSym = GetPsym (Sym);
8117 : 7086625 : switch (pSym->SymbolType)
8118 : : {
8119 : 6196695 : case SymbolTable_ParamSym:
8120 : 6196695 : if (SymbolTable_IsUnbounded (pSym->Param.Type))
8121 : : {
8122 : 362570 : pSym->Param.IsUnbounded = true;
8123 : : }
8124 : : break;
8125 : :
8126 : 889930 : case SymbolTable_VarParamSym:
8127 : 889930 : if (SymbolTable_IsUnbounded (pSym->VarParam.Type))
8128 : : {
8129 : 597444 : pSym->VarParam.IsUnbounded = true;
8130 : : }
8131 : : break;
8132 : :
8133 : :
8134 : 0 : default:
8135 : 0 : M2RTS_HALT (-1);
8136 : : __builtin_unreachable ();
8137 : 7086625 : break;
8138 : : }
8139 : 7086625 : }
8140 : :
8141 : :
8142 : : /*
8143 : : PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
8144 : : */
8145 : :
8146 : 33488 : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf)
8147 : : {
8148 : 33488 : SymbolTable_PtrToSymbol pSym;
8149 : :
8150 : 33488 : pSym = GetPsym (SimpleType);
8151 : 33488 : switch (pSym->SymbolType)
8152 : : {
8153 : : case SymbolTable_ErrorSym:
8154 : : break;
8155 : :
8156 : 12 : case SymbolTable_RecordSym:
8157 : 12 : pSym->Record.oafamily = oaf;
8158 : 12 : break;
8159 : :
8160 : 0 : case SymbolTable_SubrangeSym:
8161 : 0 : pSym->Subrange.oafamily = oaf;
8162 : 0 : break;
8163 : :
8164 : 18 : case SymbolTable_EnumerationSym:
8165 : 18 : pSym->Enumeration.oafamily = oaf;
8166 : 18 : break;
8167 : :
8168 : 6 : case SymbolTable_ArraySym:
8169 : 6 : pSym->Array.oafamily = oaf;
8170 : 6 : break;
8171 : :
8172 : 0 : case SymbolTable_ProcTypeSym:
8173 : 0 : pSym->ProcType.oafamily = oaf;
8174 : 0 : break;
8175 : :
8176 : 18365 : case SymbolTable_TypeSym:
8177 : 18365 : pSym->Type.oafamily = oaf;
8178 : 18365 : break;
8179 : :
8180 : 0 : case SymbolTable_PointerSym:
8181 : 0 : pSym->Pointer.oafamily = oaf;
8182 : 0 : break;
8183 : :
8184 : 15087 : case SymbolTable_SetSym:
8185 : 15087 : pSym->Set.oafamily = oaf;
8186 : 15087 : break;
8187 : :
8188 : 0 : case SymbolTable_UndefinedSym:
8189 : 0 : pSym->Undefined.oafamily = oaf;
8190 : 0 : break;
8191 : :
8192 : :
8193 : 0 : default:
8194 : 0 : M2Error_InternalError ((const char *) "not expecting this SimpleType", 29);
8195 : 33488 : break;
8196 : : }
8197 : 33488 : }
8198 : :
8199 : :
8200 : : /*
8201 : : doFillInOAFamily -
8202 : : */
8203 : :
8204 : 0 : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded)
8205 : : {
8206 : 0 : unsigned int SimpleType;
8207 : :
8208 : 0 : SimpleType = SymbolTable_GetType (oaf);
8209 : 0 : if (unbounded != SymbolTable_NulSym)
8210 : : {
8211 : 0 : FillInUnboundedFields (M2LexBuf_GetTokenNo (), unbounded, SimpleType, i);
8212 : : }
8213 : 0 : }
8214 : :
8215 : :
8216 : : /*
8217 : : FillInUnboundedFields -
8218 : : */
8219 : :
8220 : 33548 : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim)
8221 : : {
8222 : 33548 : SymbolTable_PtrToSymbol pSym;
8223 : 33548 : unsigned int Contents;
8224 : 33548 : unsigned int i;
8225 : :
8226 : 33548 : if (sym != SymbolTable_NulSym)
8227 : : {
8228 : 33548 : pSym = GetPsym (sym);
8229 : 33548 : pSym->SymbolType = SymbolTable_UnboundedSym;
8230 : 33548 : pSym->Unbounded.Type = SimpleType; /* Index to a simple type. */
8231 : 33548 : pSym->Unbounded.Size = M2ALU_InitValue (); /* Size in bytes for this sym */
8232 : 33548 : pSym->Unbounded.Scope = SymbolTable_GetScope (SimpleType); /* Which scope will create it */
8233 : 33548 : InitWhereDeclaredTok (tok, &pSym->Unbounded.At); /* Declared here */
8234 : 33548 : NewSym (&pSym->Unbounded.RecordType); /* Declared here */
8235 : 33548 : FillInRecordFields (tok, pSym->Unbounded.RecordType, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
8236 : 33548 : NewSym (&Contents);
8237 : 33548 : FillInPointerFields (Contents, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
8238 : 33548 : SymbolTable_PutPointer (Contents, SimpleType);
8239 : : /* create the contents field for the unbounded array. */
8240 : 33548 : M2Debug_Assert ((SymbolTable_PutFieldRecord (pSym->Unbounded.RecordType, NameKey_MakeKey ((const char *) "_m2_contents", 12), Contents, SymbolTable_NulSym)) != SymbolTable_NulSym);
8241 : : /* create all the high fields for the unbounded array. */
8242 : 33548 : i = 1;
8243 : 67240 : while (i <= ndim)
8244 : : {
8245 : 33692 : 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);
8246 : 33692 : i += 1;
8247 : : }
8248 : 33548 : pSym->Unbounded.Dimensions = ndim;
8249 : 33548 : ForeachParameterDo ((SymbolTable_CheckProcedure) {(SymbolTable_CheckProcedure_t) CheckUnbounded});
8250 : : }
8251 : 33548 : }
8252 : :
8253 : :
8254 : : /*
8255 : : PutUnbounded - associates the unbounded symbol, open, with
8256 : : SimpleType.
8257 : : */
8258 : :
8259 : 33548 : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim)
8260 : : {
8261 : 33548 : SymbolTable_PtrToSymbol pSym;
8262 : :
8263 : 33548 : pSym = GetPsym (oaf);
8264 : 33548 : switch (pSym->SymbolType)
8265 : : {
8266 : : case SymbolTable_OAFamilySym:
8267 : : /* need to check to see if we need to add NulSym for all dimensions < ndim
8268 : : which have not been used. */
8269 : 67180 : while (pSym->OAFamily.MaxDimensions < ndim)
8270 : : {
8271 : 33632 : pSym->OAFamily.MaxDimensions += 1;
8272 : 33632 : if (pSym->OAFamily.MaxDimensions < ndim)
8273 : : {
8274 : : /* add NulSym to an unused dimension. */
8275 : 84 : PutIntoIndex (&pSym->OAFamily.Dimensions, pSym->OAFamily.MaxDimensions, SymbolTable_NulSym);
8276 : : }
8277 : : }
8278 : : /* and finally add the known sym. */
8279 : 33548 : PutIntoIndex (&pSym->OAFamily.Dimensions, ndim, sym);
8280 : 33548 : break;
8281 : :
8282 : :
8283 : 0 : default:
8284 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
8285 : 33548 : break;
8286 : : }
8287 : 33548 : }
8288 : :
8289 : :
8290 : : /*
8291 : : GetArrayDimension - returns the number of dimensions defined.
8292 : : */
8293 : :
8294 : 6624 : static unsigned int GetArrayDimension (unsigned int sym)
8295 : : {
8296 : 6624 : unsigned int n;
8297 : :
8298 : 6624 : n = 0;
8299 : 13422 : while (SymbolTable_IsArray (sym))
8300 : : {
8301 : 6798 : sym = SymbolTable_SkipType (SymbolTable_GetType (sym));
8302 : 6798 : n += 1;
8303 : : }
8304 : 6624 : return n;
8305 : : /* static analysis guarentees a RETURN statement will be used before here. */
8306 : : __builtin_unreachable ();
8307 : : }
8308 : :
8309 : :
8310 : : /*
8311 : : ResolveConstructorType - if, sym, has an unresolved constructor type
8312 : : then attempt to resolve it by examining the
8313 : : from, type.
8314 : : */
8315 : :
8316 : 22040 : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres)
8317 : : {
8318 : 22040 : if ((*unres))
8319 : : {
8320 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
8321 : 22040 : if (SymbolTable_IsConstructor ((*from)))
8322 : : {
8323 : : /* avoid dangling else. */
8324 : 0 : if (IsConstructorResolved ((*from)))
8325 : : {
8326 : 0 : (*unres) = false;
8327 : 0 : (*type) = SymbolTable_GetType ((*from));
8328 : 0 : if (((*type) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*type)))))
8329 : : {
8330 : 0 : SymbolTable_PutConstSet (sym);
8331 : : }
8332 : : }
8333 : : }
8334 : 22040 : else if (((*from) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*from)))))
8335 : : {
8336 : : /* avoid dangling else. */
8337 : 18880 : (*unres) = false;
8338 : 18880 : (*type) = (*from);
8339 : 18880 : SymbolTable_PutConstSet (sym);
8340 : : }
8341 : 3160 : else if (((*from) != SymbolTable_NulSym) && ((SymbolTable_IsRecord (SymbolTable_SkipType ((*from)))) || (SymbolTable_IsArray (SymbolTable_SkipType ((*from))))))
8342 : : {
8343 : : /* avoid dangling else. */
8344 : 3154 : (*unres) = false;
8345 : 3154 : (*type) = (*from);
8346 : : }
8347 : : }
8348 : 22040 : }
8349 : :
8350 : :
8351 : : /*
8352 : : IsConstructorResolved - returns TRUE if the constructor does not
8353 : : have an unresolved type.
8354 : : */
8355 : :
8356 : 44080 : static bool IsConstructorResolved (unsigned int sym)
8357 : : {
8358 : 44080 : SymbolTable_PtrToSymbol pSym;
8359 : :
8360 : 44080 : pSym = GetPsym (sym);
8361 : 44080 : switch (pSym->SymbolType)
8362 : : {
8363 : 44080 : case SymbolTable_ConstVarSym:
8364 : 44080 : return ! pSym->ConstVar.UnresFromType;
8365 : 0 : break;
8366 : :
8367 : 0 : case SymbolTable_ConstLitSym:
8368 : 0 : return ! pSym->ConstLit.UnresFromType;
8369 : 0 : break;
8370 : :
8371 : :
8372 : 0 : default:
8373 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
8374 : : break;
8375 : : }
8376 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
8377 : : __builtin_unreachable ();
8378 : : }
8379 : :
8380 : :
8381 : : /*
8382 : : CanResolveConstructor - returns TRUE if the type of the constructor,
8383 : : sym, is known.
8384 : : */
8385 : :
8386 : 22040 : static bool CanResolveConstructor (unsigned int sym)
8387 : : {
8388 : 22040 : SymbolTable_PtrToSymbol pSym;
8389 : :
8390 : 22040 : if (! (IsConstructorResolved (sym)))
8391 : : {
8392 : 22040 : pSym = GetPsym (sym);
8393 : 22040 : switch (pSym->SymbolType)
8394 : : {
8395 : 22040 : case SymbolTable_ConstVarSym:
8396 : 22040 : ResolveConstructorType (sym, &pSym->ConstVar.Type, &pSym->ConstVar.FromType, &pSym->ConstVar.UnresFromType);
8397 : 22040 : break;
8398 : :
8399 : 0 : case SymbolTable_ConstLitSym:
8400 : 0 : ResolveConstructorType (sym, &pSym->ConstLit.Type, &pSym->ConstLit.FromType, &pSym->ConstLit.UnresFromType);
8401 : 0 : break;
8402 : :
8403 : :
8404 : 0 : default:
8405 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
8406 : : break;
8407 : : }
8408 : : }
8409 : 22040 : return IsConstructorResolved (sym);
8410 : : /* static analysis guarentees a RETURN statement will be used before here. */
8411 : : __builtin_unreachable ();
8412 : : }
8413 : :
8414 : :
8415 : : /*
8416 : : CheckAllConstructorsResolved - checks to see that the
8417 : : UnresolvedConstructorType list is
8418 : : empty and if it is not then it
8419 : : generates error messages.
8420 : : */
8421 : :
8422 : 14985 : static void CheckAllConstructorsResolved (void)
8423 : : {
8424 : 14985 : unsigned int i;
8425 : 14985 : unsigned int n;
8426 : 14985 : unsigned int s;
8427 : 14985 : M2Error_Error e;
8428 : :
8429 : 14985 : n = Lists_NoOfItemsInList (UnresolvedConstructorType);
8430 : 14985 : if (n > 0)
8431 : : {
8432 : 12 : for (i=1; i<=n; i++)
8433 : : {
8434 : 6 : s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
8435 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredMod (s));
8436 : 6 : M2Error_ErrorFormat0 (e, (const char *) "constructor has an unknown type", 31);
8437 : : }
8438 : 6 : M2Error_FlushErrors ();
8439 : : }
8440 : 14979 : }
8441 : :
8442 : :
8443 : : /*
8444 : : SanityCheckParameters -
8445 : : */
8446 : :
8447 : 3311823 : static void SanityCheckParameters (unsigned int sym)
8448 : : {
8449 : 3311823 : unsigned int p;
8450 : 3311823 : unsigned int i;
8451 : 3311823 : unsigned int n;
8452 : :
8453 : 3311823 : i = 1;
8454 : 3311823 : n = SymbolTable_NoOfParamAny (sym);
8455 : 12412384 : while (i <= n)
8456 : : {
8457 : 5788738 : p = SymbolTable_GetType (SymbolTable_GetParam (sym, i));
8458 : 5788738 : if (SymbolTable_IsConst (p))
8459 : : {
8460 : 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);
8461 : : }
8462 : 5788738 : i += 1;
8463 : : }
8464 : 3311823 : }
8465 : :
8466 : :
8467 : : /*
8468 : : SanityCheckArray - checks to see that an array has a correct subrange type.
8469 : : */
8470 : :
8471 : 41683997 : static void SanityCheckArray (unsigned int sym)
8472 : : {
8473 : 41683997 : unsigned int type;
8474 : 41683997 : unsigned int subscript;
8475 : :
8476 : 41683997 : if (SymbolTable_IsArray (sym))
8477 : : {
8478 : 86698 : subscript = SymbolTable_GetArraySubscript (sym);
8479 : 86698 : if (subscript != SymbolTable_NulSym)
8480 : : {
8481 : 86698 : type = SymbolTable_SkipType (SymbolTable_GetType (subscript));
8482 : 86698 : if (SymbolTable_IsAModula2Type (type))
8483 : : {} /* empty. */
8484 : : else
8485 : : {
8486 : : /* ok all is good */
8487 : 0 : M2MetaError_MetaError2 ((const char *) "the array {%1Dad} must be declared with a simpletype in the [..] component rather than a {%2d}", 94, sym, type);
8488 : : }
8489 : : }
8490 : : }
8491 : 41683997 : }
8492 : :
8493 : :
8494 : : /*
8495 : : ForeachSymbolDo - foreach symbol, call, P(sym).
8496 : : */
8497 : :
8498 : 14979 : static void ForeachSymbolDo (SymbolKey_PerformOperation P)
8499 : : {
8500 : 14979 : unsigned int i;
8501 : 14979 : unsigned int n;
8502 : :
8503 : 14979 : i = Indexing_LowIndice (Symbols);
8504 : 14979 : n = Indexing_HighIndice (Symbols);
8505 : 35597306 : while (i <= n)
8506 : : {
8507 : 35567348 : (*P.proc) (i);
8508 : 35567348 : i += 1;
8509 : : }
8510 : 14979 : }
8511 : :
8512 : :
8513 : : /*
8514 : : SanityCheckProcedure - check to see that procedure parameters do not use constants
8515 : : instead of types in their formal parameter section.
8516 : : */
8517 : :
8518 : 3311823 : static void SanityCheckProcedure (unsigned int sym)
8519 : : {
8520 : 3311823 : SanityCheckParameters (sym);
8521 : 3311823 : }
8522 : :
8523 : :
8524 : : /*
8525 : : SanityCheckModule -
8526 : : */
8527 : :
8528 : 147128 : static void SanityCheckModule (unsigned int sym)
8529 : : {
8530 : 147128 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
8531 : 147128 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckProcedure});
8532 : 147128 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
8533 : 147128 : }
8534 : :
8535 : :
8536 : : /*
8537 : : AddNameTo - adds Name, n, to tree, s.
8538 : : */
8539 : :
8540 : 4862624 : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o)
8541 : : {
8542 : 4862624 : if ((SymbolKey_GetSymKey (s, SymbolTable_GetSymName (o))) == SymbolKey_NulKey)
8543 : : {
8544 : 4226448 : SymbolKey_PutSymKey (s, SymbolTable_GetSymName (o), o);
8545 : : }
8546 : 4862624 : }
8547 : :
8548 : :
8549 : : /*
8550 : : CollectSymbolFrom -
8551 : : */
8552 : :
8553 : 126 : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n)
8554 : : {
8555 : 126 : NameKey_Name n1;
8556 : 126 : unsigned int sym;
8557 : :
8558 : 126 : n1 = SymbolTable_GetSymName (scope);
8559 : 126 : if (DebugUnknowns)
8560 : : {
8561 : : M2Printf_printf2 ((const char *) "declaring %a in %a", 18, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n1, (sizeof (n1)-1));
8562 : : }
8563 : 126 : sym = CheckScopeForSym (scope, n);
8564 : 126 : if (sym == SymbolTable_NulSym)
8565 : : {
8566 : 54 : sym = FetchUnknownFrom (tok, scope, n);
8567 : : }
8568 : 126 : if (DebugUnknowns)
8569 : : {
8570 : : M2Printf_printf1 ((const char *) " symbol created (%d)\\n", 22, (const unsigned char *) &sym, (sizeof (sym)-1));
8571 : : }
8572 : 126 : return sym;
8573 : : /* static analysis guarentees a RETURN statement will be used before here. */
8574 : : __builtin_unreachable ();
8575 : : }
8576 : :
8577 : :
8578 : : /*
8579 : : CollectUnknown -
8580 : : */
8581 : :
8582 : 162 : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n)
8583 : : {
8584 : 222 : SymbolTable_PtrToSymbol pSym;
8585 : 222 : unsigned int s;
8586 : :
8587 : 222 : s = SymbolTable_NulSym;
8588 : 222 : if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
8589 : : {
8590 : 108 : return CollectSymbolFrom (tok, sym, n);
8591 : : }
8592 : 114 : else if (SymbolTable_IsProcedure (sym))
8593 : : {
8594 : : /* avoid dangling else. */
8595 : 114 : s = CheckScopeForSym (sym, n);
8596 : 114 : if (s == SymbolTable_NulSym)
8597 : : {
8598 : 78 : pSym = GetPsym (sym);
8599 : 78 : switch (pSym->SymbolType)
8600 : : {
8601 : 78 : case SymbolTable_ProcedureSym:
8602 : 78 : if ((SymbolKey_GetSymKey (pSym->Procedure.NamedObjects, n)) != SymbolKey_NulKey)
8603 : : {
8604 : 18 : return CollectSymbolFrom (tok, sym, n);
8605 : : }
8606 : 60 : break;
8607 : :
8608 : :
8609 : 0 : default:
8610 : 0 : M2Error_InternalError ((const char *) "expecting - Procedure symbol", 28);
8611 : 60 : break;
8612 : : }
8613 : 60 : s = CollectUnknown (tok, SymbolTable_GetScope (sym), n);
8614 : : }
8615 : : }
8616 : : return s;
8617 : : /* static analysis guarentees a RETURN statement will be used before here. */
8618 : : __builtin_unreachable ();
8619 : : }
8620 : :
8621 : :
8622 : : /*
8623 : : ResolveImport -
8624 : : */
8625 : :
8626 : 162 : static void ResolveImport (unsigned int o)
8627 : : {
8628 : 162 : NameKey_Name n1;
8629 : 162 : NameKey_Name n2;
8630 : 162 : unsigned int tok;
8631 : 162 : unsigned int sym;
8632 : :
8633 : 162 : if (DebugUnknowns)
8634 : : {
8635 : : n1 = SymbolTable_GetSymName (o);
8636 : : M2Printf_printf1 ((const char *) "attempting to find out where %a was declared\\n", 46, (const unsigned char *) &n1, (sizeof (n1)-1));
8637 : : n1 = SymbolTable_GetSymName (ResolveModule);
8638 : : n2 = SymbolTable_GetSymName (SymbolTable_GetScope (ResolveModule));
8639 : : 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));
8640 : : }
8641 : 162 : tok = SymbolTable_GetFirstUsed (o);
8642 : 162 : sym = CollectUnknown (tok, SymbolTable_GetScope (ResolveModule), SymbolTable_GetSymName (o));
8643 : 162 : if (sym == SymbolTable_NulSym)
8644 : : {
8645 : 0 : M2MetaError_MetaError2 ((const char *) "unknown symbol {%1Uad} found in import list of module {%2a}", 59, o, ResolveModule);
8646 : : }
8647 : : else
8648 : : {
8649 : 162 : SymbolTable_AddSymToModuleScope (ResolveModule, sym);
8650 : : }
8651 : 162 : }
8652 : :
8653 : :
8654 : : /*
8655 : : ResolveRelativeImport -
8656 : : */
8657 : :
8658 : 1005920 : static void ResolveRelativeImport (unsigned int sym)
8659 : : {
8660 : 1005920 : SymbolTable_PtrToSymbol pSym;
8661 : :
8662 : 1005920 : if (SymbolTable_IsModule (sym))
8663 : : {
8664 : 420 : ResolveModule = sym;
8665 : 420 : pSym = GetPsym (sym);
8666 : 420 : switch (pSym->SymbolType)
8667 : : {
8668 : 420 : case SymbolTable_ModuleSym:
8669 : 420 : SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveImport});
8670 : 420 : break;
8671 : :
8672 : :
8673 : 0 : default:
8674 : 0 : M2Error_InternalError ((const char *) "expecting - Module symbol", 25);
8675 : 420 : break;
8676 : : }
8677 : : }
8678 : 1005920 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
8679 : 1005920 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
8680 : 1005920 : }
8681 : :
8682 : :
8683 : : /*
8684 : : Max -
8685 : : */
8686 : :
8687 : 0 : static unsigned int Max (unsigned int a, unsigned int b)
8688 : : {
8689 : 0 : if (a > b)
8690 : : {
8691 : : return a;
8692 : : }
8693 : : else
8694 : : {
8695 : : return b;
8696 : : }
8697 : : /* static analysis guarentees a RETURN statement will be used before here. */
8698 : : __builtin_unreachable ();
8699 : : }
8700 : :
8701 : :
8702 : : /*
8703 : : Min -
8704 : : */
8705 : :
8706 : 0 : static unsigned int Min (unsigned int a, unsigned int b)
8707 : : {
8708 : 0 : if (a < b)
8709 : : {
8710 : : return a;
8711 : : }
8712 : : else
8713 : : {
8714 : : return b;
8715 : : }
8716 : : /* static analysis guarentees a RETURN statement will be used before here. */
8717 : : __builtin_unreachable ();
8718 : : }
8719 : :
8720 : :
8721 : : /*
8722 : : DoFindLimits - assigns, Start, and, End, to the start and end
8723 : : limits contained in the list, l. It ensures that
8724 : : Start and End are within StartLimit..EndLimit.
8725 : : If StartLimit or EndLimit are 0 then Start is
8726 : : is set to the first value and End to the last.
8727 : : */
8728 : :
8729 : 30 : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l)
8730 : : {
8731 : 30 : unsigned int i;
8732 : 30 : unsigned int j;
8733 : 30 : unsigned int n;
8734 : :
8735 : 30 : (*End) = 0;
8736 : 30 : (*Start) = 0;
8737 : 30 : i = 1;
8738 : 30 : n = Lists_NoOfItemsInList (l);
8739 : 90 : while (i <= n)
8740 : : {
8741 : 30 : j = static_cast<unsigned int> (Lists_GetItemFromList (l, i));
8742 : 30 : if (((j > (*End)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
8743 : : {
8744 : 24 : (*End) = j;
8745 : : }
8746 : 30 : if ((((((*Start) == 0) || (j < (*Start))) && (j != 0)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
8747 : : {
8748 : 24 : (*Start) = j;
8749 : : }
8750 : 30 : i += 1;
8751 : : }
8752 : 30 : }
8753 : :
8754 : :
8755 : : /*
8756 : : PutDeclaredDefinition - associates the current tokenno with
8757 : : the symbols declaration in the definition
8758 : : module.
8759 : : */
8760 : :
8761 : 11517593 : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym)
8762 : : {
8763 : 11517593 : SymbolTable_PtrToSymbol pSym;
8764 : :
8765 : 11517593 : pSym = GetPsym (Sym);
8766 : 11517593 : switch (pSym->SymbolType)
8767 : : {
8768 : 0 : case SymbolTable_ErrorSym:
8769 : 0 : pSym->Error.At.DefDeclared = tok;
8770 : 0 : break;
8771 : :
8772 : 0 : case SymbolTable_ObjectSym:
8773 : 0 : pSym->Object.At.DefDeclared = tok;
8774 : 0 : break;
8775 : :
8776 : 0 : case SymbolTable_VarientSym:
8777 : 0 : pSym->Varient.At.DefDeclared = tok;
8778 : 0 : break;
8779 : :
8780 : 0 : case SymbolTable_RecordSym:
8781 : 0 : pSym->Record.At.DefDeclared = tok;
8782 : 0 : break;
8783 : :
8784 : 0 : case SymbolTable_SubrangeSym:
8785 : 0 : pSym->Subrange.At.DefDeclared = tok;
8786 : 0 : break;
8787 : :
8788 : 0 : case SymbolTable_EnumerationSym:
8789 : 0 : pSym->Enumeration.At.DefDeclared = tok;
8790 : 0 : break;
8791 : :
8792 : 1184 : case SymbolTable_ArraySym:
8793 : 1184 : pSym->Array.At.DefDeclared = tok;
8794 : 1184 : break;
8795 : :
8796 : 0 : case SymbolTable_SubscriptSym:
8797 : 0 : pSym->Subscript.At.DefDeclared = tok;
8798 : 0 : break;
8799 : :
8800 : 0 : case SymbolTable_UnboundedSym:
8801 : 0 : pSym->Unbounded.At.DefDeclared = tok;
8802 : 0 : break;
8803 : :
8804 : 2030342 : case SymbolTable_ProcedureSym:
8805 : 2030342 : pSym->Procedure.At.DefDeclared = tok;
8806 : 2030342 : break;
8807 : :
8808 : 0 : case SymbolTable_ProcTypeSym:
8809 : 0 : pSym->ProcType.At.DefDeclared = tok;
8810 : 0 : break;
8811 : :
8812 : 0 : case SymbolTable_ParamSym:
8813 : 0 : pSym->Param.At.DefDeclared = tok;
8814 : 0 : break;
8815 : :
8816 : 0 : case SymbolTable_VarParamSym:
8817 : 0 : pSym->VarParam.At.DefDeclared = tok;
8818 : 0 : break;
8819 : :
8820 : 0 : case SymbolTable_ConstStringSym:
8821 : 0 : pSym->ConstString.At.DefDeclared = tok;
8822 : 0 : break;
8823 : :
8824 : 0 : case SymbolTable_ConstLitSym:
8825 : 0 : pSym->ConstLit.At.DefDeclared = tok;
8826 : 0 : break;
8827 : :
8828 : 3642 : case SymbolTable_ConstVarSym:
8829 : 3642 : pSym->ConstVar.At.DefDeclared = tok;
8830 : 3642 : break;
8831 : :
8832 : 4768785 : case SymbolTable_VarSym:
8833 : 4768785 : pSym->Var.At.DefDeclared = tok;
8834 : 4768785 : break;
8835 : :
8836 : 0 : case SymbolTable_TypeSym:
8837 : 0 : pSym->Type.At.DefDeclared = tok;
8838 : 0 : break;
8839 : :
8840 : 0 : case SymbolTable_PointerSym:
8841 : 0 : pSym->Pointer.At.DefDeclared = tok;
8842 : 0 : break;
8843 : :
8844 : 93056 : case SymbolTable_RecordFieldSym:
8845 : 93056 : pSym->RecordField.At.DefDeclared = tok;
8846 : 93056 : break;
8847 : :
8848 : 0 : case SymbolTable_VarientFieldSym:
8849 : 0 : pSym->VarientField.At.DefDeclared = tok;
8850 : 0 : break;
8851 : :
8852 : 0 : case SymbolTable_EnumerationFieldSym:
8853 : 0 : pSym->EnumerationField.At.DefDeclared = tok;
8854 : 0 : break;
8855 : :
8856 : 0 : case SymbolTable_SetSym:
8857 : 0 : pSym->Set.At.DefDeclared = tok;
8858 : 0 : break;
8859 : :
8860 : 4620458 : case SymbolTable_DefImpSym:
8861 : 4620458 : pSym->DefImp.At.DefDeclared = tok;
8862 : 4620458 : break;
8863 : :
8864 : 126 : case SymbolTable_ModuleSym:
8865 : 126 : pSym->Module.At.DefDeclared = tok;
8866 : 126 : break;
8867 : :
8868 : : case SymbolTable_UndefinedSym:
8869 : : break;
8870 : :
8871 : 0 : case SymbolTable_PartialUnboundedSym:
8872 : 0 : PutDeclaredDefinition (tok, pSym->PartialUnbounded.Type);
8873 : 0 : break;
8874 : :
8875 : :
8876 : 0 : default:
8877 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
8878 : 11517593 : break;
8879 : : }
8880 : 11517593 : }
8881 : :
8882 : :
8883 : : /*
8884 : : PutDeclaredModule - returns the token where this symbol was declared
8885 : : in an implementation or program module.
8886 : : */
8887 : :
8888 : 7874491 : static void PutDeclaredModule (unsigned int tok, unsigned int Sym)
8889 : : {
8890 : 7874491 : SymbolTable_PtrToSymbol pSym;
8891 : :
8892 : 7874491 : pSym = GetPsym (Sym);
8893 : 7874491 : switch (pSym->SymbolType)
8894 : : {
8895 : 0 : case SymbolTable_ErrorSym:
8896 : 0 : pSym->Error.At.ModDeclared = tok;
8897 : 0 : break;
8898 : :
8899 : 0 : case SymbolTable_ObjectSym:
8900 : 0 : pSym->Object.At.ModDeclared = tok;
8901 : 0 : break;
8902 : :
8903 : 0 : case SymbolTable_VarientSym:
8904 : 0 : pSym->Varient.At.ModDeclared = tok;
8905 : 0 : break;
8906 : :
8907 : 0 : case SymbolTable_RecordSym:
8908 : 0 : pSym->Record.At.ModDeclared = tok;
8909 : 0 : break;
8910 : :
8911 : 0 : case SymbolTable_SubrangeSym:
8912 : 0 : pSym->Subrange.At.ModDeclared = tok;
8913 : 0 : break;
8914 : :
8915 : 0 : case SymbolTable_EnumerationSym:
8916 : 0 : pSym->Enumeration.At.ModDeclared = tok;
8917 : 0 : break;
8918 : :
8919 : 84274 : case SymbolTable_ArraySym:
8920 : 84274 : pSym->Array.At.ModDeclared = tok;
8921 : 84274 : break;
8922 : :
8923 : 0 : case SymbolTable_SubscriptSym:
8924 : 0 : pSym->Subscript.At.ModDeclared = tok;
8925 : 0 : break;
8926 : :
8927 : 0 : case SymbolTable_UnboundedSym:
8928 : 0 : pSym->Unbounded.At.ModDeclared = tok;
8929 : 0 : break;
8930 : :
8931 : 1595740 : case SymbolTable_ProcedureSym:
8932 : 1595740 : pSym->Procedure.At.ModDeclared = tok;
8933 : 1595740 : break;
8934 : :
8935 : 0 : case SymbolTable_ProcTypeSym:
8936 : 0 : pSym->ProcType.At.ModDeclared = tok;
8937 : 0 : break;
8938 : :
8939 : 0 : case SymbolTable_ParamSym:
8940 : 0 : pSym->Param.At.ModDeclared = tok;
8941 : 0 : break;
8942 : :
8943 : 0 : case SymbolTable_VarParamSym:
8944 : 0 : pSym->VarParam.At.ModDeclared = tok;
8945 : 0 : break;
8946 : :
8947 : 0 : case SymbolTable_ConstStringSym:
8948 : 0 : pSym->ConstString.At.ModDeclared = tok;
8949 : 0 : break;
8950 : :
8951 : 0 : case SymbolTable_ConstLitSym:
8952 : 0 : pSym->ConstLit.At.ModDeclared = tok;
8953 : 0 : break;
8954 : :
8955 : 6782 : case SymbolTable_ConstVarSym:
8956 : 6782 : pSym->ConstVar.At.ModDeclared = tok;
8957 : 6782 : break;
8958 : :
8959 : 2212854 : case SymbolTable_VarSym:
8960 : 2212854 : pSym->Var.At.ModDeclared = tok;
8961 : 2212854 : break;
8962 : :
8963 : 0 : case SymbolTable_TypeSym:
8964 : 0 : pSym->Type.At.ModDeclared = tok;
8965 : 0 : break;
8966 : :
8967 : 0 : case SymbolTable_PointerSym:
8968 : 0 : pSym->Pointer.At.ModDeclared = tok;
8969 : 0 : break;
8970 : :
8971 : 168796 : case SymbolTable_RecordFieldSym:
8972 : 168796 : pSym->RecordField.At.ModDeclared = tok;
8973 : 168796 : break;
8974 : :
8975 : 0 : case SymbolTable_VarientFieldSym:
8976 : 0 : pSym->VarientField.At.ModDeclared = tok;
8977 : 0 : break;
8978 : :
8979 : 0 : case SymbolTable_EnumerationFieldSym:
8980 : 0 : pSym->EnumerationField.At.ModDeclared = tok;
8981 : 0 : break;
8982 : :
8983 : 0 : case SymbolTable_SetSym:
8984 : 0 : pSym->Set.At.ModDeclared = tok;
8985 : 0 : break;
8986 : :
8987 : 3748511 : case SymbolTable_DefImpSym:
8988 : 3748511 : pSym->DefImp.At.ModDeclared = tok;
8989 : 3748511 : break;
8990 : :
8991 : 57534 : case SymbolTable_ModuleSym:
8992 : 57534 : pSym->Module.At.ModDeclared = tok;
8993 : 57534 : break;
8994 : :
8995 : : case SymbolTable_UndefinedSym:
8996 : : break;
8997 : :
8998 : 0 : case SymbolTable_PartialUnboundedSym:
8999 : 0 : PutDeclaredModule (tok, pSym->PartialUnbounded.Type);
9000 : 0 : break;
9001 : :
9002 : :
9003 : 0 : default:
9004 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
9005 : 7874491 : break;
9006 : : }
9007 : 7874491 : }
9008 : :
9009 : :
9010 : : /*
9011 : : DoIsConst - returns TRUE if Sym is defined as a constant
9012 : : or is an enumeration field or string.
9013 : : */
9014 : :
9015 : 131630185 : static bool DoIsConst (unsigned int Sym)
9016 : : {
9017 : 131630185 : SymbolTable_PtrToSymbol pSym;
9018 : :
9019 : 131630185 : pSym = GetPsym (Sym);
9020 : 131630185 : 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);
9021 : : /* static analysis guarentees a RETURN statement will be used before here. */
9022 : : __builtin_unreachable ();
9023 : : }
9024 : :
9025 : :
9026 : : /*
9027 : : GetFromIndex - return a value from list, i, at position, n.
9028 : : */
9029 : :
9030 : 2291627 : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n)
9031 : : {
9032 : 2291627 : typedef unsigned int *GetFromIndex__T2;
9033 : :
9034 : 2291627 : GetFromIndex__T2 p;
9035 : :
9036 : 1763352 : p = static_cast<GetFromIndex__T2> (Indexing_GetIndice (i, n));
9037 : 1763352 : return (*p);
9038 : : /* static analysis guarentees a RETURN statement will be used before here. */
9039 : : __builtin_unreachable ();
9040 : : }
9041 : :
9042 : :
9043 : : /*
9044 : : PutIntoIndex - places value, v, into list, i, at position, n.
9045 : : */
9046 : :
9047 : 292656 : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v)
9048 : : {
9049 : 292656 : typedef unsigned int *PutIntoIndex__T3;
9050 : :
9051 : 292656 : PutIntoIndex__T3 p;
9052 : :
9053 : 292656 : Storage_ALLOCATE ((void **) &p, sizeof (unsigned int));
9054 : 292656 : (*p) = v;
9055 : 292656 : Indexing_PutIndice ((*i), n, reinterpret_cast <void *> (p));
9056 : 292656 : }
9057 : :
9058 : :
9059 : : /*
9060 : : PushConstString - pushes the character string onto the ALU stack.
9061 : : It assumes that the character string is only
9062 : : one character long.
9063 : : */
9064 : :
9065 : 12492 : static void PushConstString (unsigned int Sym)
9066 : : {
9067 : 12492 : typedef struct PushConstString__T7_a PushConstString__T7;
9068 : :
9069 : 12492 : struct PushConstString__T7_a { char array[10+1]; };
9070 : 12492 : SymbolTable_PtrToSymbol pSym;
9071 : 12492 : PushConstString__T7 a;
9072 : :
9073 : 12492 : AssertInRange (Sym);
9074 : 12492 : pSym = GetPsym (Sym);
9075 : 12492 : switch (pSym->SymbolType)
9076 : : {
9077 : 12492 : case SymbolTable_ConstStringSym:
9078 : 12492 : if (pSym->ConstString.Length == 0)
9079 : : {
9080 : 6 : M2ALU_PushChar (ASCII_nul);
9081 : : }
9082 : 12486 : else if (pSym->ConstString.Length == 1)
9083 : : {
9084 : : /* avoid dangling else. */
9085 : 12486 : NameKey_GetKey (pSym->ConstString.Contents, (char *) &a.array[0], 10);
9086 : 12486 : M2ALU_PushChar (a.array[0]);
9087 : : }
9088 : : else
9089 : : {
9090 : : /* avoid dangling else. */
9091 : 0 : M2Error_WriteFormat0 ((const char *) "ConstString must be length 0 or 1", 33);
9092 : : }
9093 : 12492 : break;
9094 : :
9095 : :
9096 : 0 : default:
9097 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
9098 : 12492 : break;
9099 : : }
9100 : 12492 : }
9101 : :
9102 : :
9103 : : /*
9104 : : FinalSymbol - returns the highest number symbol used.
9105 : : */
9106 : :
9107 : 1923448760 : extern "C" unsigned int SymbolTable_FinalSymbol (void)
9108 : : {
9109 : 1923448760 : return FreeSymbol-1;
9110 : : /* static analysis guarentees a RETURN statement will be used before here. */
9111 : : __builtin_unreachable ();
9112 : : }
9113 : :
9114 : :
9115 : : /*
9116 : : MakeComponentRecord - make a temporary which will be used to reference and field
9117 : : (or sub field) of record.
9118 : : */
9119 : :
9120 : 126940 : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record)
9121 : : {
9122 : 126940 : return buildTemporary (tok, Mode, true, record);
9123 : : /* static analysis guarentees a RETURN statement will be used before here. */
9124 : : __builtin_unreachable ();
9125 : : }
9126 : :
9127 : :
9128 : : /*
9129 : : MakeComponentRef - use, sym, to reference, field, sym is returned.
9130 : : */
9131 : :
9132 : 126940 : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field)
9133 : : {
9134 : 126940 : SymbolTable_PtrToSymbol pSym;
9135 : 126940 : unsigned int high;
9136 : :
9137 : 126940 : pSym = GetPsym (sym);
9138 : 126940 : switch (pSym->SymbolType)
9139 : : {
9140 : 126940 : case SymbolTable_VarSym:
9141 : 126940 : if (! pSym->Var.IsTemp)
9142 : : {
9143 : 0 : M2Error_InternalError ((const char *) "variable must be a temporary", 28);
9144 : : }
9145 : 126940 : else if (pSym->Var.IsComponentRef)
9146 : : {
9147 : : /* avoid dangling else. */
9148 : 126940 : high = Indexing_HighIndice (pSym->Var.list);
9149 : 126940 : PutIntoIndex (&pSym->Var.list, high+1, field);
9150 : : }
9151 : : else
9152 : : {
9153 : : /* avoid dangling else. */
9154 : 0 : M2Error_InternalError ((const char *) "temporary is not a component reference", 38);
9155 : : }
9156 : 126940 : break;
9157 : :
9158 : :
9159 : 0 : default:
9160 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
9161 : 126940 : break;
9162 : : }
9163 : 126940 : return sym;
9164 : : /* static analysis guarentees a RETURN statement will be used before here. */
9165 : : __builtin_unreachable ();
9166 : : }
9167 : :
9168 : :
9169 : : /*
9170 : : IsComponent - returns TRUE if symbol, sym, is a temporary and a component
9171 : : reference.
9172 : : */
9173 : :
9174 : 104069284 : extern "C" bool SymbolTable_IsComponent (unsigned int sym)
9175 : : {
9176 : 104069284 : SymbolTable_PtrToSymbol pSym;
9177 : :
9178 : 104069284 : pSym = GetPsym (sym);
9179 : 104069284 : switch (pSym->SymbolType)
9180 : : {
9181 : 2238569 : case SymbolTable_VarSym:
9182 : 2238569 : return pSym->Var.IsComponentRef;
9183 : : break;
9184 : :
9185 : :
9186 : : default:
9187 : : return false;
9188 : : break;
9189 : : }
9190 : : /* static analysis guarentees a RETURN statement will be used before here. */
9191 : : __builtin_unreachable ();
9192 : : }
9193 : :
9194 : :
9195 : : /*
9196 : : MakeTemporary - Makes a new temporary variable at the highest real scope.
9197 : : The addressing mode of the temporary is set to NoValue.
9198 : : */
9199 : :
9200 : 910757 : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode)
9201 : : {
9202 : 910757 : tok = CheckTok (tok, (const char *) "temporary", 9);
9203 : 910757 : return buildTemporary (tok, Mode, false, SymbolTable_NulSym);
9204 : : /* static analysis guarentees a RETURN statement will be used before here. */
9205 : : __builtin_unreachable ();
9206 : : }
9207 : :
9208 : :
9209 : : /*
9210 : : MakeTemporaryFromExpression - makes a new temporary variable at the
9211 : : highest real scope. The addressing
9212 : : mode of the temporary is set and the
9213 : : type is determined by expressions, e.
9214 : : */
9215 : :
9216 : 0 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode)
9217 : : {
9218 : 0 : return SymbolTable_MakeTemporaryFromExpressions (tok, e, e, mode);
9219 : : /* static analysis guarentees a RETURN statement will be used before here. */
9220 : : __builtin_unreachable ();
9221 : : }
9222 : :
9223 : :
9224 : : /*
9225 : : MakeTemporaryFromExpressions - makes a new temporary variable at the
9226 : : highest real scope. The addressing
9227 : : mode of the temporary is set and the
9228 : : type is determined by expressions,
9229 : : e1 and e2.
9230 : : */
9231 : :
9232 : 55538 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode)
9233 : : {
9234 : 55538 : SymbolTable_PtrToSymbol pSym;
9235 : 55538 : DynamicStrings_String s;
9236 : 55538 : unsigned int t;
9237 : 55538 : unsigned int Sym;
9238 : :
9239 : 55538 : TemporaryNo += 1;
9240 : : /* Make the name */
9241 : 55538 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
9242 : 55538 : if (mode == SymbolTable_ImmediateValue)
9243 : : {
9244 : 20586 : Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
9245 : 20586 : if (SymbolTable_IsConstructor (e1))
9246 : : {
9247 : 206 : SymbolTable_PutConstructor (Sym);
9248 : 206 : SymbolTable_PutConstructorFrom (Sym, e1);
9249 : : }
9250 : 20380 : else if (SymbolTable_IsConstructor (e2))
9251 : : {
9252 : : /* avoid dangling else. */
9253 : 12 : SymbolTable_PutConstructor (Sym);
9254 : 12 : SymbolTable_PutConstructorFrom (Sym, e2);
9255 : : }
9256 : : else
9257 : : {
9258 : : /* avoid dangling else. */
9259 : 20368 : SymbolTable_PutVar (Sym, M2Base_MixTypes (SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok));
9260 : : }
9261 : 20586 : PutConstVarTemporary (Sym);
9262 : : }
9263 : : else
9264 : : {
9265 : 34952 : Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
9266 : 34952 : pSym = GetPsym (Sym);
9267 : 34952 : switch (pSym->SymbolType)
9268 : : {
9269 : 34952 : case SymbolTable_VarSym:
9270 : 34952 : pSym->Var.AddrMode = mode;
9271 : 34952 : pSym->Var.IsComponentRef = false;
9272 : 34952 : pSym->Var.IsTemp = true; /* Variable is a temporary var */
9273 : : /* Declared here */
9274 : 34952 : InitWhereDeclaredTok (tok, &pSym->Var.At);
9275 : 34952 : break;
9276 : :
9277 : :
9278 : 0 : default:
9279 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
9280 : 34952 : break;
9281 : : }
9282 : 34952 : t = M2Base_MixTypesDecl (e1, e2, SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok);
9283 : 34844 : if (t != SymbolTable_NulSym)
9284 : : {
9285 : 34832 : M2Debug_Assert (! (SymbolTable_IsConstructor (t)));
9286 : 34832 : SymbolTable_PutVar (Sym, t);
9287 : : }
9288 : : }
9289 : 55430 : s = DynamicStrings_KillString (s);
9290 : 55430 : return Sym;
9291 : : /* static analysis guarentees a RETURN statement will be used before here. */
9292 : : __builtin_unreachable ();
9293 : : }
9294 : :
9295 : :
9296 : : /*
9297 : : PutMode - Puts the addressing mode, SymMode, into symbol Sym.
9298 : : The mode may only be altered if the mode
9299 : : is None.
9300 : : */
9301 : :
9302 : 6018397 : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode)
9303 : : {
9304 : 6018397 : SymbolTable_PtrToSymbol pSym;
9305 : :
9306 : 6018397 : pSym = GetPsym (Sym);
9307 : 6018397 : switch (pSym->SymbolType)
9308 : : {
9309 : : case SymbolTable_ErrorSym:
9310 : : break;
9311 : :
9312 : 6018397 : case SymbolTable_VarSym:
9313 : 6018397 : pSym->Var.AddrMode = SymMode;
9314 : 6018397 : break;
9315 : :
9316 : :
9317 : 0 : default:
9318 : 0 : M2Error_InternalError ((const char *) "Expecting VarSym", 16);
9319 : 6018397 : break;
9320 : : }
9321 : 6018397 : }
9322 : :
9323 : :
9324 : : /*
9325 : : GetMode - Returns the addressing mode of a symbol.
9326 : : */
9327 : :
9328 : 8766902 : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym)
9329 : : {
9330 : 8766902 : SymbolTable_PtrToSymbol pSym;
9331 : :
9332 : 8766902 : pSym = GetPsym (Sym);
9333 : 8766902 : switch (pSym->SymbolType)
9334 : : {
9335 : 12 : case SymbolTable_ErrorSym:
9336 : 12 : M2Error_ErrorAbort0 ((const char *) "", 0);
9337 : 7112439 : break;
9338 : :
9339 : 7112439 : case SymbolTable_VarSym:
9340 : 7112439 : return pSym->Var.AddrMode;
9341 : : break;
9342 : :
9343 : : case SymbolTable_ConstLitSym:
9344 : : return SymbolTable_ImmediateValue;
9345 : : break;
9346 : :
9347 : : case SymbolTable_ConstVarSym:
9348 : : return SymbolTable_ImmediateValue;
9349 : : break;
9350 : :
9351 : : case SymbolTable_ConstStringSym:
9352 : : return SymbolTable_ImmediateValue;
9353 : : break;
9354 : :
9355 : : case SymbolTable_EnumerationFieldSym:
9356 : : return SymbolTable_ImmediateValue;
9357 : : break;
9358 : :
9359 : : case SymbolTable_ProcedureSym:
9360 : : return SymbolTable_ImmediateValue;
9361 : : break;
9362 : :
9363 : : case SymbolTable_RecordFieldSym:
9364 : : return SymbolTable_ImmediateValue;
9365 : : break;
9366 : :
9367 : : case SymbolTable_VarientFieldSym:
9368 : : return SymbolTable_ImmediateValue;
9369 : : break;
9370 : :
9371 : : case SymbolTable_TypeSym:
9372 : : return SymbolTable_NoValue;
9373 : : break;
9374 : :
9375 : : case SymbolTable_ArraySym:
9376 : : return SymbolTable_NoValue;
9377 : : break;
9378 : :
9379 : : case SymbolTable_SubrangeSym:
9380 : : return SymbolTable_NoValue;
9381 : : break;
9382 : :
9383 : : case SymbolTable_EnumerationSym:
9384 : : return SymbolTable_NoValue;
9385 : : break;
9386 : :
9387 : : case SymbolTable_RecordSym:
9388 : : return SymbolTable_NoValue;
9389 : : break;
9390 : :
9391 : : case SymbolTable_PointerSym:
9392 : : return SymbolTable_NoValue;
9393 : : break;
9394 : :
9395 : : case SymbolTable_SetSym:
9396 : : return SymbolTable_NoValue;
9397 : : break;
9398 : :
9399 : : case SymbolTable_ProcTypeSym:
9400 : : return SymbolTable_NoValue;
9401 : : break;
9402 : :
9403 : : case SymbolTable_UnboundedSym:
9404 : : return SymbolTable_NoValue;
9405 : : break;
9406 : :
9407 : : case SymbolTable_UndefinedSym:
9408 : : return SymbolTable_NoValue;
9409 : 0 : break;
9410 : :
9411 : :
9412 : 0 : default:
9413 : 0 : M2Error_InternalError ((const char *) "not expecting this type", 23);
9414 : : break;
9415 : : }
9416 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9417 : : __builtin_unreachable ();
9418 : : }
9419 : :
9420 : :
9421 : : /*
9422 : : StartScope - starts a block scope at Sym. Transparent determines
9423 : : whether the search for a symbol will look at the
9424 : : previous ScopeCallFrame if Sym does not contain the
9425 : : symbol that GetSym is searching.
9426 : :
9427 : : WITH statements are partially implemented by calling
9428 : : StartScope. Therefore we must retain the old Main from
9429 : : the previous ScopePtr when a record is added to the scope
9430 : : stack. (Main contains the symbol where all identifiers
9431 : : should be added.)
9432 : : */
9433 : :
9434 : 18617374 : extern "C" void SymbolTable_StartScope (unsigned int Sym)
9435 : : {
9436 : 18617374 : SymbolTable_PtrToCallFrame oCall;
9437 : 18617374 : SymbolTable_PtrToCallFrame pCall;
9438 : :
9439 : 18617374 : Sym = SymbolTable_SkipType (Sym);
9440 : : /*
9441 : : WriteString('New scope is: ') ; WriteKey(GetSymName(Sym)) ; WriteLn ;
9442 : : */
9443 : 18617374 : ScopePtr += 1;
9444 : 18617374 : if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
9445 : : {
9446 : 18551496 : pCall = GetPcall (ScopePtr);
9447 : : }
9448 : : else
9449 : : {
9450 : 65878 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
9451 : 65878 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
9452 : : }
9453 : 18617374 : pCall->Start = ScopePtr-1; /* Previous ScopePtr value before StartScope */
9454 : 18617374 : pCall->Search = Sym;
9455 : : /* new symbols to ie temporary variables. */
9456 : 18617374 : if (SymbolTable_IsRecord (Sym))
9457 : : {
9458 : 24206 : oCall = GetPcall (ScopePtr-1);
9459 : 24206 : pCall->Main = oCall->Main;
9460 : : }
9461 : : else
9462 : : {
9463 : 18593162 : pCall->Main = Sym;
9464 : 18593162 : PlaceMajorScopesEnumerationListOntoStack (Sym);
9465 : : }
9466 : 18617367 : }
9467 : :
9468 : :
9469 : : /*
9470 : : EndScope - ends a block scope started by StartScope. The current
9471 : : head of the symbol scope reverts back to the symbol
9472 : : which was the Head of the symbol scope before the
9473 : : last StartScope was called.
9474 : : */
9475 : :
9476 : 18601782 : extern "C" void SymbolTable_EndScope (void)
9477 : : {
9478 : 18601782 : SymbolTable_PtrToCallFrame pCall;
9479 : :
9480 : : /*
9481 : : ; WriteString('EndScope - ending scope: ') ;
9482 : : pCall := GetPcall(ScopePtr) ;
9483 : : ; WriteKey(GetSymName(pCall^.Search)) ; WriteLn ;
9484 : : */
9485 : 18601782 : pCall = GetPcall (ScopePtr);
9486 : : /* ; DisplayScopes */
9487 : 18601782 : ScopePtr = pCall->Start;
9488 : 18601782 : }
9489 : :
9490 : :
9491 : : /*
9492 : : PseudoScope - starts a pseudo scope at Sym.
9493 : : We always connect parent up to the last scope,
9494 : : to determine the transparancy of a scope we call
9495 : : TransparentScope.
9496 : :
9497 : : A Pseudo scope has no end block,
9498 : : but is terminated when the next EndScope is used.
9499 : : The function of the pseudo scope is to provide an
9500 : : automatic mechanism to solve enumeration types.
9501 : : A declared enumeration type is a Pseudo scope and
9502 : : identifiers used with the name of an enumeration
9503 : : type field will find the enumeration symbol by
9504 : : the scoping algorithm.
9505 : : */
9506 : :
9507 : 454206 : extern "C" void SymbolTable_PseudoScope (unsigned int Sym)
9508 : : {
9509 : 454206 : SymbolTable_PtrToCallFrame oCall;
9510 : 454206 : SymbolTable_PtrToCallFrame pCall;
9511 : :
9512 : 454206 : if (SymbolTable_IsEnumeration (Sym))
9513 : : {
9514 : 454206 : ScopePtr += 1;
9515 : 454206 : if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
9516 : : {
9517 : 436578 : pCall = GetPcall (ScopePtr);
9518 : : }
9519 : : else
9520 : : {
9521 : 17628 : Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
9522 : 17628 : Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
9523 : : }
9524 : 454206 : oCall = GetPcall (ScopePtr-1);
9525 : 454206 : pCall->Main = oCall->Main;
9526 : 454206 : pCall->Start = oCall->Start;
9527 : 454206 : pCall->Search = Sym;
9528 : : }
9529 : : else
9530 : : {
9531 : 0 : M2Error_InternalError ((const char *) "expecting EnumerationSym", 24);
9532 : : }
9533 : 454206 : }
9534 : :
9535 : :
9536 : : /*
9537 : : GetCurrentScope - returns the symbol who is responsible for the current
9538 : : scope. Note that it ignore pseudo scopes.
9539 : : */
9540 : :
9541 : 27494566 : extern "C" unsigned int SymbolTable_GetCurrentScope (void)
9542 : : {
9543 : 27494566 : SymbolTable_PtrToCallFrame pCall;
9544 : :
9545 : 27494566 : pCall = GetPcall (ScopePtr);
9546 : 27494566 : return pCall->Main;
9547 : : /* static analysis guarentees a RETURN statement will be used before here. */
9548 : : __builtin_unreachable ();
9549 : : }
9550 : :
9551 : :
9552 : : /*
9553 : : IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
9554 : : */
9555 : :
9556 : 195202 : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym)
9557 : : {
9558 : 195202 : unsigned int s;
9559 : :
9560 : 195202 : s = SymbolTable_GetScope (sym);
9561 : 390404 : while (s != scope)
9562 : : {
9563 : 1328 : if ((((s == SymbolTable_NulSym) || (SymbolTable_IsProcedure (s))) || (SymbolTable_IsModule (s))) || (SymbolTable_IsDefImp (s)))
9564 : : {
9565 : 1328 : return false;
9566 : : }
9567 : : else
9568 : : {
9569 : 0 : s = SymbolTable_GetScope (s);
9570 : : }
9571 : : }
9572 : : return true;
9573 : : /* static analysis guarentees a RETURN statement will be used before here. */
9574 : : __builtin_unreachable ();
9575 : : }
9576 : :
9577 : :
9578 : : /*
9579 : : SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
9580 : : This Sym must represent the module name of the
9581 : : file currently being compiled.
9582 : : */
9583 : :
9584 : 980261 : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym)
9585 : : {
9586 : 980261 : CurrentModule = Sym;
9587 : 980261 : }
9588 : :
9589 : :
9590 : : /*
9591 : : SetFileModule - Used to set the FileModule to a symbol, Sym.
9592 : : This Sym must represent the current program module
9593 : : file which is being parsed.
9594 : : */
9595 : :
9596 : 932813 : extern "C" void SymbolTable_SetFileModule (unsigned int Sym)
9597 : : {
9598 : 932813 : FileModule = Sym;
9599 : 932813 : }
9600 : :
9601 : :
9602 : : /*
9603 : : SetMainModule - Used to set the MainModule to a symbol, Sym.
9604 : : This Sym must represent the main module which was
9605 : : envoked by the user to be compiled.
9606 : : */
9607 : :
9608 : 15253 : extern "C" void SymbolTable_SetMainModule (unsigned int Sym)
9609 : : {
9610 : 15253 : MainModule = Sym;
9611 : 15253 : }
9612 : :
9613 : :
9614 : : /*
9615 : : CheckAnonymous - checks to see whether the name is NulName and if so
9616 : : it creates a unique anonymous name.
9617 : : */
9618 : :
9619 : 1266331 : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name)
9620 : : {
9621 : 1266331 : if (name == NameKey_NulName)
9622 : : {
9623 : 50539 : AnonymousName += 1;
9624 : 50539 : 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)))));
9625 : : }
9626 : 1266331 : return name;
9627 : : /* static analysis guarentees a RETURN statement will be used before here. */
9628 : : __builtin_unreachable ();
9629 : : }
9630 : :
9631 : :
9632 : : /*
9633 : : IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
9634 : : or no name.
9635 : : */
9636 : :
9637 : 54446 : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym)
9638 : : {
9639 : 54446 : typedef struct IsNameAnonymous__T8_a IsNameAnonymous__T8;
9640 : :
9641 : 54446 : struct IsNameAnonymous__T8_a { char array[5+1]; };
9642 : 54446 : IsNameAnonymous__T8 a;
9643 : 54446 : NameKey_Name n;
9644 : :
9645 : 54446 : n = SymbolTable_GetSymName (sym);
9646 : 54446 : if (n == NameKey_NulName)
9647 : : {
9648 : : return true;
9649 : : }
9650 : : else
9651 : : {
9652 : 53246 : NameKey_GetKey (n, (char *) &a.array[0], 5);
9653 : 53246 : return StrLib_StrEqual ((const char *) &a.array[0], 5, (const char *) "__anon", 6);
9654 : : }
9655 : : /* static analysis guarentees a RETURN statement will be used before here. */
9656 : : __builtin_unreachable ();
9657 : : }
9658 : :
9659 : :
9660 : : /*
9661 : : NoOfVariables - returns the number of variables in scope. The scope maybe
9662 : : a procedure, module or defimp scope.
9663 : : */
9664 : :
9665 : 30 : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope)
9666 : : {
9667 : 30 : SymbolTable_PtrToSymbol pSym;
9668 : :
9669 : 30 : if (SymbolTable_IsProcedure (scope))
9670 : : {
9671 : 30 : return SymbolTable_NoOfLocalVar (scope);
9672 : : }
9673 : 0 : else if (SymbolTable_IsModule (scope))
9674 : : {
9675 : : /* avoid dangling else. */
9676 : 0 : pSym = GetPsym (scope);
9677 : 0 : switch (pSym->SymbolType)
9678 : : {
9679 : 0 : case SymbolTable_ModuleSym:
9680 : 0 : return Lists_NoOfItemsInList (pSym->Module.ListOfVars);
9681 : 0 : break;
9682 : :
9683 : :
9684 : 0 : default:
9685 : 0 : M2Error_InternalError ((const char *) "expecting module symbol", 23);
9686 : 0 : break;
9687 : : }
9688 : : }
9689 : 0 : else if (SymbolTable_IsDefImp (scope))
9690 : : {
9691 : : /* avoid dangling else. */
9692 : 0 : pSym = GetPsym (scope);
9693 : 0 : switch (pSym->SymbolType)
9694 : : {
9695 : 0 : case SymbolTable_DefImpSym:
9696 : 0 : return Lists_NoOfItemsInList (pSym->DefImp.ListOfVars);
9697 : 0 : break;
9698 : :
9699 : :
9700 : 0 : default:
9701 : 0 : M2Error_InternalError ((const char *) "expecting defimp symbol", 23);
9702 : 0 : break;
9703 : : }
9704 : : }
9705 : : else
9706 : : {
9707 : : /* avoid dangling else. */
9708 : 0 : M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
9709 : : }
9710 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
9711 : : __builtin_unreachable ();
9712 : : }
9713 : :
9714 : :
9715 : : /*
9716 : : MakeModule - creates a module sym with ModuleName. It returns the
9717 : : symbol index.
9718 : : */
9719 : :
9720 : 26870 : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName)
9721 : : {
9722 : 26870 : SymbolTable_PtrToSymbol pSym;
9723 : 26870 : SymbolTable_PtrToCallFrame pCall;
9724 : 26870 : unsigned int Sym;
9725 : :
9726 : : /*
9727 : : Make a new symbol since we are at the outer scope level.
9728 : : DeclareSym examines the current scope level for any symbols
9729 : : that have the correct name, but are yet undefined.
9730 : : Therefore we must not call DeclareSym but create a symbol
9731 : : directly.
9732 : : */
9733 : 26870 : NewSym (&Sym);
9734 : 26870 : pSym = GetPsym (Sym);
9735 : 26870 : pSym->SymbolType = SymbolTable_ModuleSym;
9736 : 26870 : pSym->Module.name = ModuleName; /* Index into name array, name */
9737 : : /* of record field. */
9738 : 26870 : pSym->Module.libname = NameKey_NulName; /* Library association. */
9739 : 26870 : InitCtor (&pSym->Module.ctors); /* Init all ctor functions. */
9740 : 26870 : Lists_InitList (&pSym->Module.ModListOfDep); /* Vector of SymDependency. */
9741 : 26870 : SymbolKey_InitTree (&pSym->Module.LocalSymbols); /* The LocalSymbols hold all the */
9742 : : /* END WeAreHere. */
9743 : 26870 : SymbolKey_InitTree (&pSym->Module.ExportTree); /* Holds all the exported */
9744 : : /* deleted at the end of Pass 1. */
9745 : 26870 : SymbolKey_InitTree (&pSym->Module.ImportTree); /* Contains all IMPORTed */
9746 : : /* identifiers. */
9747 : 26870 : Lists_InitList (&pSym->Module.IncludeList); /* Contains all included symbols */
9748 : : /* modulename.Symbol */
9749 : 26870 : SymbolKey_InitTree (&pSym->Module.ExportUndeclared); /* ExportUndeclared contains all */
9750 : : /* been declared. */
9751 : 26870 : Lists_InitList (&pSym->Module.EnumerationScopeList); /* Enumeration scope list which */
9752 : : /* Outer Module. */
9753 : 26870 : SymbolKey_InitTree (&pSym->Module.NamedObjects); /* Names of all items declared. */
9754 : 26870 : SymbolKey_InitTree (&pSym->Module.NamedImports); /* Names of items imported. */
9755 : 26870 : SymbolKey_InitTree (&pSym->Module.WhereImported); /* Sym to TokenNo where import */
9756 : : /* occurs. Error message use. */
9757 : 26870 : pSym->Module.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9758 : : /* is an index to a constant. */
9759 : 26870 : SymbolKey_InitTree (&pSym->Module.Unresolved); /* All symbols currently */
9760 : : /* unresolved in this module. */
9761 : 26870 : pSym->Module.StartQuad = 0; /* Signify the initialization */
9762 : : /* code. */
9763 : 26870 : pSym->Module.EndQuad = 0; /* EndQuad should point to a */
9764 : : /* goto quad. */
9765 : 26870 : pSym->Module.StartFinishQuad = 0; /* Signify the finalization */
9766 : : /* code. */
9767 : 26870 : pSym->Module.EndFinishQuad = 0; /* should point to a finish */
9768 : 26870 : pSym->Module.FinallyFunction = NULL; /* The GCC function for finally */
9769 : 26870 : pSym->Module.ExceptionFinally = false; /* does it have an exception? */
9770 : 26870 : pSym->Module.ExceptionBlock = false; /* does it have an exception? */
9771 : 26870 : pSym->Module.ModLink = GetLink (); /* Is this parsed for linkage? */
9772 : 26870 : pSym->Module.Builtin = false; /* Is the module builtin? */
9773 : 26870 : Lists_InitList (&pSym->Module.ListOfVars); /* List of variables in this */
9774 : : /* scope. */
9775 : 26870 : Lists_InitList (&pSym->Module.ListOfProcs); /* List of all procedures */
9776 : : /* declared within this module. */
9777 : 26870 : Lists_InitList (&pSym->Module.ListOfModules); /* List of all inner modules. */
9778 : 26870 : InitWhereDeclaredTok (tok, &pSym->Module.At); /* Where symbol declared. */
9779 : 26870 : InitWhereFirstUsedTok (tok, &pSym->Module.At); /* Where symbol first used. */
9780 : 26870 : pCall = GetPcall (ScopePtr); /* Where symbol first used. */
9781 : 26870 : if (pCall->Main == (SymbolTable_GetBaseModule ()))
9782 : : {
9783 : 26870 : pSym->Module.Scope = SymbolTable_NulSym;
9784 : : }
9785 : : else
9786 : : {
9787 : 0 : pSym->Module.Scope = pCall->Main;
9788 : : }
9789 : 26870 : pSym->Module.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9790 : 26870 : SymbolKey_PutSymKey (ModuleTree, ModuleName, Sym); /* Title error scope. */
9791 : 26870 : return Sym;
9792 : : /* static analysis guarentees a RETURN statement will be used before here. */
9793 : : __builtin_unreachable ();
9794 : : }
9795 : :
9796 : :
9797 : : /*
9798 : : MakeDefImp - creates a definition and implementation module sym
9799 : : with name DefImpName. It returns the symbol index.
9800 : : */
9801 : :
9802 : 135563 : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName)
9803 : : {
9804 : 135563 : SymbolTable_PtrToSymbol pSym;
9805 : 135563 : unsigned int Sym;
9806 : :
9807 : : /* tok := CheckTok (tok, 'defimp') ; */
9808 : 135563 : NewSym (&Sym);
9809 : 135563 : pSym = GetPsym (Sym);
9810 : 135563 : pSym->SymbolType = SymbolTable_DefImpSym;
9811 : 135563 : pSym->DefImp.name = DefImpName; /* Index into name array, name */
9812 : : /* of record field. */
9813 : 135563 : pSym->DefImp.libname = NameKey_NulName; /* Library association. */
9814 : 135563 : InitCtor (&pSym->DefImp.ctors);
9815 : : /* Init all ctor functions. */
9816 : 135563 : Lists_InitList (&pSym->DefImp.DefListOfDep); /* Vector of SymDependency. */
9817 : 135563 : Lists_InitList (&pSym->DefImp.ModListOfDep); /* Vector of SymDependency. */
9818 : 135563 : SymbolKey_InitTree (&pSym->DefImp.ExportQualifiedTree);
9819 : : /* deleted at the end of Pass 1. */
9820 : 135563 : SymbolKey_InitTree (&pSym->DefImp.ExportUnQualifiedTree);
9821 : : /* deleted at the end of Pass 1. */
9822 : 135563 : SymbolKey_InitTree (&pSym->DefImp.ExportRequest); /* Contains all identifiers that */
9823 : : /* this list. */
9824 : 135563 : SymbolKey_InitTree (&pSym->DefImp.ImportTree); /* Contains all IMPORTed */
9825 : : /* identifiers. */
9826 : 135563 : Lists_InitList (&pSym->DefImp.IncludeList); /* Contains all included symbols */
9827 : : /* modulename.Symbol */
9828 : 135563 : Lists_InitList (&pSym->DefImp.DefIncludeList); /* Contains all included symbols */
9829 : : /* in the definition module only */
9830 : 135563 : SymbolKey_InitTree (&pSym->DefImp.ExportUndeclared); /* ExportUndeclared contains all */
9831 : : /* been declared. */
9832 : 135563 : SymbolKey_InitTree (&pSym->DefImp.NeedToBeImplemented);
9833 : : /* implemented. */
9834 : 135563 : SymbolKey_InitTree (&pSym->DefImp.LocalSymbols); /* The LocalSymbols hold all the */
9835 : : /* END WeAreHere. */
9836 : 135563 : Lists_InitList (&pSym->DefImp.EnumerationScopeList);
9837 : : /* visable within this scope. */
9838 : 135563 : SymbolKey_InitTree (&pSym->DefImp.NamedObjects); /* names of all items declared. */
9839 : 135563 : SymbolKey_InitTree (&pSym->DefImp.NamedImports); /* Names of items imported. */
9840 : 135563 : SymbolKey_InitTree (&pSym->DefImp.WhereImported); /* Sym to TokenNo where import */
9841 : : /* occurs. Error message use. */
9842 : 135563 : pSym->DefImp.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9843 : : /* is an index to a constant. */
9844 : 135563 : SymbolKey_InitTree (&pSym->DefImp.Unresolved); /* All symbols currently */
9845 : : /* unresolved in this module. */
9846 : 135563 : pSym->DefImp.StartQuad = 0; /* Signify the initialization */
9847 : : /* code. */
9848 : 135563 : pSym->DefImp.EndQuad = 0; /* EndQuad should point to a */
9849 : : /* goto quad. */
9850 : 135563 : pSym->DefImp.StartFinishQuad = 0; /* Signify the finalization */
9851 : : /* code. */
9852 : 135563 : pSym->DefImp.EndFinishQuad = 0; /* should point to a finish */
9853 : 135563 : pSym->DefImp.FinallyFunction = NULL; /* The GCC function for finally */
9854 : 135563 : pSym->DefImp.ExceptionFinally = false; /* does it have an exception? */
9855 : 135563 : pSym->DefImp.ExceptionBlock = false; /* does it have an exception? */
9856 : 135563 : pSym->DefImp.ContainsHiddenType = false; /* True if this module */
9857 : : /* implements a hidden type. */
9858 : 135563 : pSym->DefImp.ContainsBuiltin = false; /* Does module define a builtin */
9859 : : /* procedure? */
9860 : 135563 : pSym->DefImp.ForC = false; /* Is it a definition for "C" */
9861 : 135563 : pSym->DefImp.NeedExportList = false; /* Must user supply export list? */
9862 : 135563 : pSym->DefImp.DefLink = GetLink (); /* Is the def/mod file only */
9863 : 135563 : pSym->DefImp.ModLink = GetLink (); /* parsed for linkage? */
9864 : 135563 : pSym->DefImp.Builtin = false; /* Is the module builtin? */
9865 : 135563 : Lists_InitList (&pSym->DefImp.ListOfVars); /* List of variables in this */
9866 : : /* scope. */
9867 : 135563 : Lists_InitList (&pSym->DefImp.ListOfProcs); /* List of all procedures */
9868 : : /* declared within this module. */
9869 : 135563 : Lists_InitList (&pSym->DefImp.ListOfModules); /* List of all inner modules. */
9870 : 135563 : InitWhereDeclaredTok (tok, &pSym->DefImp.At); /* Where symbol declared. */
9871 : 135563 : InitWhereFirstUsedTok (tok, &pSym->DefImp.At); /* Where symbol first used. */
9872 : 135563 : pSym->DefImp.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9873 : 135563 : SymbolKey_PutSymKey (ModuleTree, DefImpName, Sym); /* Title error scope. */
9874 : 135563 : return Sym;
9875 : : /* static analysis guarentees a RETURN statement will be used before here. */
9876 : : __builtin_unreachable ();
9877 : : }
9878 : :
9879 : :
9880 : : /*
9881 : : MakeInnerModule - creates an inner module sym with ModuleName. It returns the
9882 : : symbol index.
9883 : : */
9884 : :
9885 : 420 : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName)
9886 : : {
9887 : 420 : SymbolTable_PtrToSymbol pSym;
9888 : 420 : unsigned int Sym;
9889 : :
9890 : 420 : Sym = DeclareSym (tok, ModuleName);
9891 : 420 : if (! (SymbolTable_IsError (Sym)))
9892 : : {
9893 : 420 : pSym = GetPsym (Sym);
9894 : 420 : pSym->SymbolType = SymbolTable_ModuleSym;
9895 : 420 : pSym->Module.name = ModuleName; /* Index into name array, name */
9896 : : /* of record field. */
9897 : 420 : pSym->Module.libname = NameKey_NulName; /* Library association. */
9898 : 420 : InitCtor (&pSym->Module.ctors); /* Init all ctor functions. */
9899 : 420 : SymbolKey_InitTree (&pSym->Module.LocalSymbols); /* The LocalSymbols hold all the */
9900 : : /* END WeAreHere. */
9901 : 420 : SymbolKey_InitTree (&pSym->Module.ExportTree); /* Holds all the exported */
9902 : : /* deleted at the end of Pass 1. */
9903 : 420 : SymbolKey_InitTree (&pSym->Module.ImportTree); /* Contains all IMPORTed */
9904 : : /* identifiers. */
9905 : 420 : Lists_InitList (&pSym->Module.IncludeList); /* Contains all included symbols */
9906 : : /* modulename.Symbol */
9907 : 420 : SymbolKey_InitTree (&pSym->Module.ExportUndeclared); /* ExportUndeclared contains all */
9908 : : /* been declared. */
9909 : 420 : Lists_InitList (&pSym->Module.EnumerationScopeList); /* Enumeration scope list which */
9910 : : /* visable within this scope. */
9911 : 420 : SymbolKey_InitTree (&pSym->Module.NamedObjects); /* Names of all items declared. */
9912 : 420 : SymbolKey_InitTree (&pSym->Module.NamedImports); /* Names of items imported. */
9913 : 420 : SymbolKey_InitTree (&pSym->Module.WhereImported); /* Sym to TokenNo where import */
9914 : : /* occurs. Error message use. */
9915 : 420 : pSym->Module.Priority = SymbolTable_NulSym; /* Priority of the module. This */
9916 : : /* is an index to a constant. */
9917 : 420 : SymbolKey_InitTree (&pSym->Module.Unresolved); /* All symbols currently */
9918 : : /* unresolved in this module. */
9919 : 420 : pSym->Module.StartQuad = 0; /* Signify the initialization */
9920 : : /* code. */
9921 : 420 : pSym->Module.EndQuad = 0; /* EndQuad should point to a */
9922 : : /* goto quad. */
9923 : 420 : pSym->Module.StartFinishQuad = 0; /* Signify the finalization */
9924 : : /* code. */
9925 : 420 : pSym->Module.EndFinishQuad = 0; /* should point to a finish */
9926 : 420 : pSym->Module.FinallyFunction = NULL; /* The GCC function for finally */
9927 : 420 : pSym->Module.ExceptionFinally = false; /* does it have an exception? */
9928 : 420 : pSym->Module.ExceptionBlock = false; /* does it have an exception? */
9929 : 420 : pSym->Module.ModLink = GetLink (); /* Is this parsed for linkage? */
9930 : 420 : Lists_InitList (&pSym->Module.ListOfVars); /* List of variables in this */
9931 : : /* scope. */
9932 : 420 : Lists_InitList (&pSym->Module.ListOfProcs); /* List of all procedures */
9933 : : /* declared within this module. */
9934 : 420 : Lists_InitList (&pSym->Module.ListOfModules); /* List of all inner modules. */
9935 : 420 : InitWhereDeclaredTok (tok, &pSym->Module.At); /* Where symbol declared. */
9936 : 420 : InitWhereFirstUsedTok (tok, &pSym->Module.At); /* Where symbol first used. */
9937 : 420 : if ((SymbolTable_GetCurrentScope ()) == (SymbolTable_GetBaseModule ())) /* Where symbol first used. */
9938 : : {
9939 : 0 : pSym->Module.Scope = SymbolTable_NulSym;
9940 : : }
9941 : : else
9942 : : {
9943 : 420 : pSym->Module.Scope = SymbolTable_GetCurrentScope ();
9944 : 420 : AddModuleToParent (Sym, pSym->Module.Scope);
9945 : : }
9946 : 420 : pSym->Module.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
9947 : 420 : AddSymToScope (Sym, ModuleName); /* Title error scope. */
9948 : : }
9949 : 420 : return Sym;
9950 : : /* static analysis guarentees a RETURN statement will be used before here. */
9951 : : __builtin_unreachable ();
9952 : : }
9953 : :
9954 : :
9955 : : /*
9956 : : MakeProcedure - creates a procedure sym with name. It returns
9957 : : the symbol index.
9958 : : */
9959 : :
9960 : 3430171 : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName)
9961 : : {
9962 : 3430171 : SymbolTable_PtrToSymbol pSym;
9963 : 3430171 : unsigned int Sym;
9964 : 3430171 : SymbolTable_ProcedureKind kind;
9965 : :
9966 : 3430171 : tok = CheckTok (tok, (const char *) "procedure", 9);
9967 : 3430171 : Sym = DeclareSym (tok, ProcedureName);
9968 : 3430171 : CheckBreak (Sym);
9969 : 3430171 : if (! (SymbolTable_IsError (Sym)))
9970 : : {
9971 : 3430171 : pSym = GetPsym (Sym);
9972 : 3430171 : pSym->SymbolType = SymbolTable_ProcedureSym;
9973 : 3430171 : pSym->Procedure.name = ProcedureName;
9974 : 13720684 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
9975 : : {
9976 : 10290513 : InitProcedureDeclaration (&pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure]);
9977 : 10290513 : Lists_InitList (&pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam);
9978 : : }
9979 : 3430171 : pSym->Procedure.OptArgInit = SymbolTable_NulSym; /* The optional arg default */
9980 : : /* value. */
9981 : 3430171 : pSym->Procedure.IsExtern = false; /* Make this procedure external. */
9982 : 3430171 : pSym->Procedure.IsPublic = false; /* Make this procedure visible. */
9983 : 3430171 : pSym->Procedure.IsCtor = false; /* Is this procedure a ctor? */
9984 : 3430171 : pSym->Procedure.IsMonoName = false; /* Overrides module name prefix. */
9985 : 3430171 : pSym->Procedure.BuildProcType = true; /* Are we building the */
9986 : : /* proctype associated with sym? */
9987 : 3430171 : pSym->Procedure.Scope = SymbolTable_GetCurrentScope (); /* Scope of procedure. */
9988 : 3430171 : SymbolKey_InitTree (&pSym->Procedure.Unresolved); /* All symbols currently */
9989 : : /* unresolved in this procedure. */
9990 : 3430171 : pSym->Procedure.ScopeQuad = 0; /* Index into list of quads, */
9991 : 3430171 : pSym->Procedure.StartQuad = 0; /* defining the scope, start and */
9992 : 3430171 : pSym->Procedure.EndQuad = 0; /* end of the procedure. */
9993 : 3430171 : pSym->Procedure.Reachable = false; /* Procedure not known to be */
9994 : : /* reachable. */
9995 : 3430171 : pSym->Procedure.SavePriority = false; /* Does procedure need to save */
9996 : : /* and restore interrupts? */
9997 : 3430171 : pSym->Procedure.ReturnType = SymbolTable_NulSym; /* Not a function yet! */
9998 : : /* The ProcType equivalent. */
9999 : 3430171 : pSym->Procedure.ProcedureType = SymbolTable_MakeProcType (tok, NameKey_NulName);
10000 : 3430171 : SymbolKey_InitTree (&pSym->Procedure.LocalSymbols);
10001 : 3430171 : Lists_InitList (&pSym->Procedure.EnumerationScopeList);
10002 : : /* visable within this scope. */
10003 : 3430171 : SymbolKey_InitTree (&pSym->Procedure.NamedObjects); /* Names of all items declared. */
10004 : 3430171 : Lists_InitList (&pSym->Procedure.ListOfVars); /* List of variables in this */
10005 : : /* scope. */
10006 : 3430171 : Lists_InitList (&pSym->Procedure.ListOfProcs);
10007 : : /* procedure. */
10008 : 3430171 : Lists_InitList (&pSym->Procedure.ListOfModules); /* List of all inner modules. */
10009 : 3430171 : pSym->Procedure.ExceptionFinally = false; /* does it have an exception? */
10010 : 3430171 : pSym->Procedure.ExceptionBlock = false; /* does it have an exception? */
10011 : 3430171 : pSym->Procedure.IsBuiltin = false; /* Was it declared __BUILTIN__ ? */
10012 : 3430171 : pSym->Procedure.BuiltinName = NameKey_NulName; /* name of equivalent builtin */
10013 : 3430171 : pSym->Procedure.IsInline = false; /* Was is declared __INLINE__ ? */
10014 : 3430171 : pSym->Procedure.Size = M2ALU_InitValue (); /* Activation record size. */
10015 : 3430171 : pSym->Procedure.TotalParamSize = M2ALU_InitValue (); /* size of all parameters. */
10016 : 3430171 : pSym->Procedure.Begin = 0; /* token number for BEGIN */
10017 : 3430171 : pSym->Procedure.End = 0; /* token number for END */
10018 : 3430171 : InitWhereDeclaredTok (tok, &pSym->Procedure.At); /* Where the symbol was declared. */
10019 : 3430171 : pSym->Procedure.errorScope = M2Error_GetCurrentErrorScope (); /* Title error scope. */
10020 : : /* Now add this procedure to the symbol table of the current scope */
10021 : 3430171 : AddSymToScope (Sym, ProcedureName);
10022 : 3430171 : AddProcedureToList (SymbolTable_GetCurrentScope (), Sym);
10023 : : }
10024 : 3430171 : return Sym;
10025 : : /* static analysis guarentees a RETURN statement will be used before here. */
10026 : : __builtin_unreachable ();
10027 : : }
10028 : :
10029 : :
10030 : : /*
10031 : : MakeProcedureCtorExtern - creates an extern ctor procedure
10032 : : */
10033 : :
10034 : 0 : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename)
10035 : : {
10036 : 0 : unsigned int ctor;
10037 : :
10038 : 0 : ctor = SymbolTable_MakeProcedure (tokenno, GenName (libname, (const char *) "_M2_", 4, modulename, (const char *) "_ctor", 5));
10039 : 0 : SymbolTable_PutExtern (ctor, true);
10040 : 0 : return ctor;
10041 : : /* static analysis guarentees a RETURN statement will be used before here. */
10042 : : __builtin_unreachable ();
10043 : : }
10044 : :
10045 : :
10046 : : /*
10047 : : PutLibName - places libname into defimp or module sym.
10048 : : */
10049 : :
10050 : 187470 : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname)
10051 : : {
10052 : 187470 : SymbolTable_PtrToSymbol pSym;
10053 : :
10054 : 374940 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10055 : 187470 : pSym = GetPsym (sym);
10056 : 187470 : switch (pSym->SymbolType)
10057 : : {
10058 : 175860 : case SymbolTable_DefImpSym:
10059 : 175860 : pSym->DefImp.libname = libname;
10060 : 175860 : break;
10061 : :
10062 : 11610 : case SymbolTable_ModuleSym:
10063 : 11610 : pSym->Module.libname = libname;
10064 : 11610 : break;
10065 : :
10066 : :
10067 : 0 : default:
10068 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10069 : 187470 : break;
10070 : : }
10071 : 187470 : }
10072 : :
10073 : :
10074 : : /*
10075 : : GetLibName - returns libname associated with a defimp or module sym.
10076 : : */
10077 : :
10078 : 3491324 : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym)
10079 : : {
10080 : 3491324 : SymbolTable_PtrToSymbol pSym;
10081 : :
10082 : 6982648 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10083 : 3491324 : pSym = GetPsym (sym);
10084 : 3491324 : switch (pSym->SymbolType)
10085 : : {
10086 : 3400391 : case SymbolTable_DefImpSym:
10087 : 3400391 : return pSym->DefImp.libname;
10088 : 90933 : break;
10089 : :
10090 : 90933 : case SymbolTable_ModuleSym:
10091 : 90933 : return pSym->Module.libname;
10092 : 0 : break;
10093 : :
10094 : :
10095 : 0 : default:
10096 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10097 : : break;
10098 : : }
10099 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10100 : : __builtin_unreachable ();
10101 : : }
10102 : :
10103 : :
10104 : : /*
10105 : : PutMonoName - changes the IsMonoName boolean inside the procedure.
10106 : : */
10107 : :
10108 : 356293 : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value)
10109 : : {
10110 : 356293 : SymbolTable_PtrToSymbol pSym;
10111 : :
10112 : 356293 : pSym = GetPsym (sym);
10113 : 356293 : switch (pSym->SymbolType)
10114 : : {
10115 : 356293 : case SymbolTable_ProcedureSym:
10116 : 356293 : pSym->Procedure.IsMonoName = value;
10117 : 356293 : break;
10118 : :
10119 : :
10120 : 0 : default:
10121 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10122 : 356293 : break;
10123 : : }
10124 : 356293 : }
10125 : :
10126 : :
10127 : : /*
10128 : : IsMonoName - returns the public boolean associated with a procedure.
10129 : : */
10130 : :
10131 : 2279590 : extern "C" bool SymbolTable_IsMonoName (unsigned int sym)
10132 : : {
10133 : 2279590 : SymbolTable_PtrToSymbol pSym;
10134 : :
10135 : 2279590 : pSym = GetPsym (sym);
10136 : 2279590 : switch (pSym->SymbolType)
10137 : : {
10138 : 2279590 : case SymbolTable_ProcedureSym:
10139 : 2279590 : return pSym->Procedure.IsMonoName;
10140 : 0 : break;
10141 : :
10142 : :
10143 : 0 : default:
10144 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10145 : : break;
10146 : : }
10147 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10148 : : __builtin_unreachable ();
10149 : : }
10150 : :
10151 : :
10152 : : /*
10153 : : PutExtern - changes the extern boolean inside the procedure.
10154 : : */
10155 : :
10156 : 530039 : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value)
10157 : : {
10158 : 530039 : SymbolTable_PtrToSymbol pSym;
10159 : :
10160 : 530039 : pSym = GetPsym (sym);
10161 : 530039 : switch (pSym->SymbolType)
10162 : : {
10163 : 530039 : case SymbolTable_ProcedureSym:
10164 : 530039 : pSym->Procedure.IsExtern = value;
10165 : 530039 : break;
10166 : :
10167 : :
10168 : 0 : default:
10169 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10170 : 530039 : break;
10171 : : }
10172 : 530039 : }
10173 : :
10174 : :
10175 : : /*
10176 : : IsExtern - returns the public boolean associated with a procedure.
10177 : : */
10178 : :
10179 : 3361725 : extern "C" bool SymbolTable_IsExtern (unsigned int sym)
10180 : : {
10181 : 3361725 : SymbolTable_PtrToSymbol pSym;
10182 : :
10183 : 3361725 : pSym = GetPsym (sym);
10184 : 3361725 : switch (pSym->SymbolType)
10185 : : {
10186 : 3361725 : case SymbolTable_ProcedureSym:
10187 : 3361725 : return pSym->Procedure.IsExtern;
10188 : 0 : break;
10189 : :
10190 : :
10191 : 0 : default:
10192 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10193 : : break;
10194 : : }
10195 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10196 : : __builtin_unreachable ();
10197 : : }
10198 : :
10199 : :
10200 : : /*
10201 : : PutPublic - changes the public boolean inside the procedure.
10202 : : */
10203 : :
10204 : 544946 : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value)
10205 : : {
10206 : 544946 : SymbolTable_PtrToSymbol pSym;
10207 : :
10208 : 544946 : pSym = GetPsym (sym);
10209 : 544946 : switch (pSym->SymbolType)
10210 : : {
10211 : 544946 : case SymbolTable_ProcedureSym:
10212 : 544946 : pSym->Procedure.IsPublic = value;
10213 : 544946 : break;
10214 : :
10215 : :
10216 : 0 : default:
10217 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10218 : 544946 : break;
10219 : : }
10220 : 544946 : }
10221 : :
10222 : :
10223 : : /*
10224 : : IsPublic - returns the public boolean associated with a procedure.
10225 : : */
10226 : :
10227 : 98814 : extern "C" bool SymbolTable_IsPublic (unsigned int sym)
10228 : : {
10229 : 98814 : SymbolTable_PtrToSymbol pSym;
10230 : :
10231 : 98814 : pSym = GetPsym (sym);
10232 : 98814 : switch (pSym->SymbolType)
10233 : : {
10234 : 98814 : case SymbolTable_ProcedureSym:
10235 : 98814 : return pSym->Procedure.IsPublic;
10236 : 0 : break;
10237 : :
10238 : :
10239 : 0 : default:
10240 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10241 : : break;
10242 : : }
10243 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10244 : : __builtin_unreachable ();
10245 : : }
10246 : :
10247 : :
10248 : : /*
10249 : : PutCtor - changes the ctor boolean inside the procedure.
10250 : : */
10251 : :
10252 : 148545 : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value)
10253 : : {
10254 : 148545 : SymbolTable_PtrToSymbol pSym;
10255 : :
10256 : 148545 : pSym = GetPsym (sym);
10257 : 148545 : switch (pSym->SymbolType)
10258 : : {
10259 : 148545 : case SymbolTable_ProcedureSym:
10260 : 148545 : pSym->Procedure.IsCtor = value;
10261 : 148545 : break;
10262 : :
10263 : :
10264 : 0 : default:
10265 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10266 : 148545 : break;
10267 : : }
10268 : 148545 : }
10269 : :
10270 : :
10271 : : /*
10272 : : IsCtor - returns the ctor boolean associated with a procedure.
10273 : : */
10274 : :
10275 : 138200 : extern "C" bool SymbolTable_IsCtor (unsigned int sym)
10276 : : {
10277 : 138200 : SymbolTable_PtrToSymbol pSym;
10278 : :
10279 : 138200 : pSym = GetPsym (sym);
10280 : 138200 : switch (pSym->SymbolType)
10281 : : {
10282 : 138200 : case SymbolTable_ProcedureSym:
10283 : 138200 : return pSym->Procedure.IsCtor;
10284 : 0 : break;
10285 : :
10286 : :
10287 : 0 : default:
10288 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
10289 : : break;
10290 : : }
10291 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10292 : : __builtin_unreachable ();
10293 : : }
10294 : :
10295 : :
10296 : : /*
10297 : : GetModuleCtors - mod can be a DefImp or Module symbol. ctor, init and fini
10298 : : are assigned for this module. An inner module ctor value will
10299 : : be NulSym.
10300 : : */
10301 : :
10302 : 141153 : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep)
10303 : : {
10304 : 141153 : SymbolTable_PtrToSymbol pSym;
10305 : :
10306 : 141153 : pSym = GetPsym (mod);
10307 : 141153 : switch (pSym->SymbolType)
10308 : : {
10309 : 81498 : case SymbolTable_ModuleSym:
10310 : 81498 : (*ctor) = pSym->Module.ctors.ctor;
10311 : 81498 : (*init) = pSym->Module.ctors.init;
10312 : 81498 : (*fini) = pSym->Module.ctors.fini;
10313 : 81498 : (*dep) = pSym->Module.ctors.dep;
10314 : 81498 : break;
10315 : :
10316 : 59655 : case SymbolTable_DefImpSym:
10317 : 59655 : (*ctor) = pSym->DefImp.ctors.ctor;
10318 : 59655 : (*init) = pSym->DefImp.ctors.init;
10319 : 59655 : (*fini) = pSym->DefImp.ctors.fini;
10320 : 59655 : (*dep) = pSym->DefImp.ctors.dep;
10321 : 59655 : break;
10322 : :
10323 : :
10324 : 0 : default:
10325 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
10326 : 141153 : break;
10327 : : }
10328 : 141153 : }
10329 : :
10330 : :
10331 : : /*
10332 : : MakeModuleCtor - for a defimp or module symbol create all the ctor
10333 : : related procedures.
10334 : : */
10335 : :
10336 : 66109 : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym)
10337 : : {
10338 : 66109 : SymbolTable_PtrToSymbol pSym;
10339 : :
10340 : 132218 : M2Debug_Assert ((SymbolTable_IsDefImp (moduleSym)) || (SymbolTable_IsModule (moduleSym)));
10341 : 66109 : pSym = GetPsym (moduleSym);
10342 : 66109 : if (SymbolTable_IsDefImp (moduleSym))
10343 : : {
10344 : 54217 : InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->DefImp.ctors, SymbolTable_GetSymName (moduleSym), false, true);
10345 : : }
10346 : : else
10347 : : {
10348 : 11892 : InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->Module.ctors, SymbolTable_GetSymName (moduleSym), SymbolTable_IsInnerModule (moduleSym), true);
10349 : : }
10350 : 66109 : }
10351 : :
10352 : :
10353 : : /*
10354 : : PutModuleCtorExtern - for every ctor related procedure in module sym.
10355 : : Make it external. It will create any missing
10356 : : init/fini procedures but not any missing dep/ctor
10357 : : procedures.
10358 : : */
10359 : :
10360 : 83092 : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external)
10361 : : {
10362 : 83092 : SymbolTable_PtrToSymbol pSym;
10363 : :
10364 : 166184 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
10365 : 83092 : pSym = GetPsym (sym);
10366 : 83092 : switch (pSym->SymbolType)
10367 : : {
10368 : 83092 : case SymbolTable_DefImpSym:
10369 : 83092 : PutCtorExtern (tok, sym, &pSym->DefImp.ctors, external);
10370 : 83092 : break;
10371 : :
10372 : 0 : case SymbolTable_ModuleSym:
10373 : 0 : PutCtorExtern (tok, sym, &pSym->Module.ctors, external);
10374 : 0 : break;
10375 : :
10376 : :
10377 : 0 : default:
10378 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
10379 : 83092 : break;
10380 : : }
10381 : 83092 : }
10382 : :
10383 : :
10384 : : /*
10385 : : PutVarHeap - assigns ArrayRef field with value.
10386 : : */
10387 : :
10388 : 45902 : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value)
10389 : : {
10390 : 45902 : SymbolTable_PtrToSymbol pSym;
10391 : :
10392 : 45902 : pSym = GetPsym (sym);
10393 : 45902 : switch (pSym->SymbolType)
10394 : : {
10395 : 45902 : case SymbolTable_VarSym:
10396 : 45902 : pSym->Var.Heap = value;
10397 : 45902 : break;
10398 : :
10399 : :
10400 : 0 : default:
10401 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
10402 : 45902 : break;
10403 : : }
10404 : 45902 : }
10405 : :
10406 : :
10407 : : /*
10408 : : IsVarHeap - returns ArrayRef field value.
10409 : : */
10410 : :
10411 : 546587 : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym)
10412 : : {
10413 : 546587 : SymbolTable_PtrToSymbol pSym;
10414 : :
10415 : 546587 : pSym = GetPsym (sym);
10416 : 546587 : switch (pSym->SymbolType)
10417 : : {
10418 : 546587 : case SymbolTable_VarSym:
10419 : 546587 : return pSym->Var.Heap;
10420 : 0 : break;
10421 : :
10422 : :
10423 : 0 : default:
10424 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
10425 : : break;
10426 : : }
10427 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
10428 : : __builtin_unreachable ();
10429 : : }
10430 : :
10431 : :
10432 : : /*
10433 : : MakeVar - creates a variable sym with VarName. It returns the
10434 : : symbol index.
10435 : : */
10436 : :
10437 : 7668550 : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName)
10438 : : {
10439 : 7668550 : SymbolTable_PtrToSymbol pSym;
10440 : 7668550 : unsigned int Sym;
10441 : :
10442 : 7668550 : Sym = DeclareSym (tok, VarName);
10443 : 7668550 : if (! (SymbolTable_IsError (Sym)))
10444 : : {
10445 : 7668538 : pSym = GetPsym (Sym);
10446 : 7668538 : pSym->SymbolType = SymbolTable_VarSym;
10447 : 7668538 : pSym->Var.name = VarName;
10448 : 7668538 : pSym->Var.Type = SymbolTable_NulSym;
10449 : 7668538 : pSym->Var.BackType = SymbolTable_NulSym;
10450 : 7668538 : pSym->Var.Size = M2ALU_InitValue ();
10451 : 7668538 : pSym->Var.Offset = M2ALU_InitValue ();
10452 : 7668538 : pSym->Var.AddrMode = SymbolTable_RightValue;
10453 : 7668538 : pSym->Var.Scope = SymbolTable_GetCurrentScope (); /* Procedure or Module? */
10454 : 7668538 : pSym->Var.AtAddress = false; /* Procedure or Module? */
10455 : 7668538 : pSym->Var.Address = SymbolTable_NulSym; /* Address at which declared. */
10456 : 7668538 : pSym->Var.IsConditional = false; /* Address at which declared. */
10457 : 7668538 : pSym->Var.IsTemp = false;
10458 : 7668538 : pSym->Var.IsComponentRef = false;
10459 : 7668538 : pSym->Var.IsParam = false;
10460 : 7668538 : pSym->Var.IsPointerCheck = false;
10461 : 7668538 : pSym->Var.IsWritten = false;
10462 : 7668538 : pSym->Var.IsSSA = false;
10463 : 7668538 : pSym->Var.IsConst = false;
10464 : 7668538 : pSym->Var.ArrayRef = false;
10465 : 7668538 : pSym->Var.Heap = false;
10466 : 7668538 : InitVarDecl (&pSym->Var.Declared, tok);
10467 : 7668538 : InitWhereDeclaredTok (tok, &pSym->Var.At);
10468 : 7668538 : InitWhereFirstUsedTok (tok, &pSym->Var.At); /* Where symbol first used. */
10469 : 7668538 : Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]); /* Where symbol first used. */
10470 : 7668538 : Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]);
10471 : 7668538 : Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
10472 : 7668538 : Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
10473 : 7668538 : pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
10474 : 7668538 : pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
10475 : : /* Add Var to Procedure or Module variable list. */
10476 : 7668538 : AddVarToList (Sym);
10477 : : /* Now add this Var to the symbol table of the current scope. */
10478 : 7668538 : AddSymToScope (Sym, VarName);
10479 : : }
10480 : 7668550 : return Sym;
10481 : : /* static analysis guarentees a RETURN statement will be used before here. */
10482 : : __builtin_unreachable ();
10483 : : }
10484 : :
10485 : :
10486 : : /*
10487 : : PutVarConditional - assign IsConditional to value.
10488 : : */
10489 : :
10490 : 15682 : extern "C" void SymbolTable_PutVarConditional (unsigned int sym, bool value)
10491 : : {
10492 : 15682 : SymbolTable_PtrToSymbol pSym;
10493 : :
10494 : 15682 : pSym = GetPsym (sym);
10495 : 15682 : switch (pSym->SymbolType)
10496 : : {
10497 : 15400 : case SymbolTable_VarSym:
10498 : 15400 : pSym->Var.IsConditional = value;
10499 : 15400 : break;
10500 : :
10501 : 282 : case SymbolTable_ConstVarSym:
10502 : 282 : pSym->ConstVar.IsConditional = value;
10503 : 282 : break;
10504 : :
10505 : :
10506 : 0 : default:
10507 : 0 : M2Error_InternalError ((const char *) "expecting Var", 13);
10508 : 15682 : break;
10509 : : }
10510 : 15682 : }
10511 : :
10512 : :
10513 : : /*
10514 : : IsVarConditional - return TRUE if the symbol is a var symbol
10515 : : containing the result of a boolean conditional.
10516 : : */
10517 : :
10518 : 259230 : extern "C" bool SymbolTable_IsVarConditional (unsigned int sym)
10519 : : {
10520 : 259230 : SymbolTable_PtrToSymbol pSym;
10521 : :
10522 : 259230 : pSym = GetPsym (sym);
10523 : 259230 : switch (pSym->SymbolType)
10524 : : {
10525 : 6414 : case SymbolTable_VarSym:
10526 : 6414 : return pSym->Var.IsConditional;
10527 : 251444 : break;
10528 : :
10529 : 251444 : case SymbolTable_ConstVarSym:
10530 : 251444 : return pSym->ConstVar.IsConditional;
10531 : : break;
10532 : :
10533 : :
10534 : : default:
10535 : : return false;
10536 : : break;
10537 : : }
10538 : : return false;
10539 : : /* static analysis guarentees a RETURN statement will be used before here. */
10540 : : __builtin_unreachable ();
10541 : : }
10542 : :
10543 : :
10544 : : /*
10545 : : MakeRecord - makes a Record symbol with name RecordName.
10546 : : */
10547 : :
10548 : 50093 : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName)
10549 : : {
10550 : 50093 : unsigned int oaf;
10551 : 50093 : unsigned int sym;
10552 : :
10553 : 50093 : tok = CheckTok (tok, (const char *) "record", 6);
10554 : 50093 : sym = HandleHiddenOrDeclare (tok, RecordName, &oaf);
10555 : 50093 : FillInRecordFields (tok, sym, RecordName, SymbolTable_GetCurrentScope (), oaf);
10556 : 50093 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10557 : 50093 : return sym;
10558 : : /* static analysis guarentees a RETURN statement will be used before here. */
10559 : : __builtin_unreachable ();
10560 : : }
10561 : :
10562 : :
10563 : : /*
10564 : : MakeVarient - creates a new symbol, a varient symbol for record or varient field
10565 : : symbol, RecOrVarFieldSym.
10566 : : */
10567 : :
10568 : 276 : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym)
10569 : : {
10570 : 276 : SymbolTable_PtrToSymbol pSym;
10571 : 276 : unsigned int Sym;
10572 : :
10573 : 276 : tok = CheckTok (tok, (const char *) "varient", 7);
10574 : 276 : NewSym (&Sym);
10575 : 276 : pSym = GetPsym (Sym);
10576 : 276 : pSym->SymbolType = SymbolTable_VarientSym;
10577 : 276 : pSym->Varient.Size = M2ALU_InitValue ();
10578 : 276 : pSym->Varient.Parent = RecOrVarFieldSym; /* GetRecord(RecOrVarFieldSym) ; */
10579 : 276 : if (SymbolTable_IsRecord (RecOrVarFieldSym)) /* GetRecord(RecOrVarFieldSym) ; */
10580 : : {
10581 : 240 : pSym->Varient.Varient = SymbolTable_NulSym;
10582 : : }
10583 : : else
10584 : : {
10585 : 36 : pSym->Varient.Varient = RecOrVarFieldSym;
10586 : : }
10587 : 276 : pSym->Varient.tag = SymbolTable_NulSym;
10588 : 276 : pSym->Varient.DeclPacked = false;
10589 : 276 : pSym->Varient.Scope = SymbolTable_GetCurrentScope ();
10590 : 276 : Lists_InitList (&pSym->Varient.ListOfSons);
10591 : 276 : InitWhereDeclaredTok (tok, &pSym->Varient.At);
10592 : : /* Now add Sym to the record RecSym field list */
10593 : 276 : pSym = GetPsym (RecOrVarFieldSym);
10594 : 276 : switch (pSym->SymbolType)
10595 : : {
10596 : 240 : case SymbolTable_RecordSym:
10597 : 240 : Lists_PutItemIntoList (pSym->Record.ListOfSons, Sym);
10598 : 240 : break;
10599 : :
10600 : 36 : case SymbolTable_VarientFieldSym:
10601 : 36 : Lists_PutItemIntoList (pSym->VarientField.ListOfSons, Sym);
10602 : 36 : break;
10603 : :
10604 : :
10605 : 0 : default:
10606 : 0 : M2Error_InternalError ((const char *) "expecting Record or VarientField symbol", 39);
10607 : 276 : break;
10608 : : }
10609 : 276 : return Sym;
10610 : : /* static analysis guarentees a RETURN statement will be used before here. */
10611 : : __builtin_unreachable ();
10612 : : }
10613 : :
10614 : :
10615 : : /*
10616 : : MakeFieldVarient - returns a FieldVarient symbol which has been
10617 : : assigned to the Varient symbol, Sym.
10618 : : */
10619 : :
10620 : 666 : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym)
10621 : : {
10622 : 666 : SymbolTable_PtrToSymbol pSym;
10623 : 666 : unsigned int SonSym;
10624 : :
10625 : 666 : NewSym (&SonSym);
10626 : : /* Fill in Sym */
10627 : 666 : pSym = GetPsym (SonSym);
10628 : 666 : pSym->SymbolType = SymbolTable_VarientFieldSym;
10629 : 666 : pSym->VarientField.name = n;
10630 : 666 : Lists_InitList (&pSym->VarientField.ListOfSons);
10631 : 666 : pSym->VarientField.Parent = SymbolTable_GetRecord (Sym);
10632 : 666 : pSym->VarientField.Varient = SymbolTable_NulSym;
10633 : 666 : pSym->VarientField.Size = M2ALU_InitValue ();
10634 : 666 : pSym->VarientField.Offset = M2ALU_InitValue ();
10635 : 666 : pSym->VarientField.DeclPacked = false;
10636 : 666 : pSym->VarientField.DeclResolved = false;
10637 : 666 : pSym->VarientField.Scope = SymbolTable_GetCurrentScope ();
10638 : 666 : InitWhereDeclared (&pSym->VarientField.At);
10639 : 666 : return SonSym;
10640 : : /* static analysis guarentees a RETURN statement will be used before here. */
10641 : : __builtin_unreachable ();
10642 : : }
10643 : :
10644 : :
10645 : : /*
10646 : : MakeEnumeration - places a new symbol in the current scope, the symbol
10647 : : is an enumeration symbol. The symbol index is returned.
10648 : : */
10649 : :
10650 : 38606 : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName)
10651 : : {
10652 : 38606 : SymbolTable_PtrToSymbol pSym;
10653 : 38606 : unsigned int sym;
10654 : 38606 : unsigned int oaf;
10655 : :
10656 : 38606 : tok = CheckTok (tok, (const char *) "enumeration", 11);
10657 : 38606 : sym = CheckForHiddenType (EnumerationName);
10658 : 38606 : if (sym == SymbolTable_NulSym)
10659 : : {
10660 : : /* avoid dangling else. */
10661 : 38606 : sym = DeclareSym (tok, EnumerationName);
10662 : 38606 : oaf = SymbolTable_GetOAFamily (sym);
10663 : 38606 : if (! (SymbolTable_IsError (sym)))
10664 : : {
10665 : 38606 : pSym = GetPsym (sym);
10666 : 38606 : pSym->SymbolType = SymbolTable_EnumerationSym; /* To satisfy AddSymToScope */
10667 : : /* Now add this type to the symbol table of the current scope */
10668 : 38606 : AddSymToScope (sym, EnumerationName);
10669 : : }
10670 : : }
10671 : : else
10672 : : {
10673 : 0 : oaf = SymbolTable_GetOAFamily (sym);
10674 : : }
10675 : 38606 : if (! (SymbolTable_IsError (sym)))
10676 : : {
10677 : 38606 : pSym = GetPsym (sym);
10678 : 38606 : pSym->SymbolType = SymbolTable_EnumerationSym;
10679 : 38606 : pSym->Enumeration.name = EnumerationName; /* Name of enumeration. */
10680 : 38606 : pSym->Enumeration.NoOfElements = 0; /* No of elements in the */
10681 : : /* enumeration type. */
10682 : 38606 : pSym->Enumeration.Size = M2ALU_InitValue (); /* Size at runtime of sym */
10683 : 38606 : SymbolKey_InitTree (&pSym->Enumeration.LocalSymbols); /* Enumeration fields. */
10684 : 38606 : Lists_InitList (&pSym->Enumeration.ListOfFields); /* Ordered as declared. */
10685 : 38606 : InitPacked (&pSym->Enumeration.packedInfo); /* not packed and no */
10686 : : /* equivalent (yet). */
10687 : 38606 : pSym->Enumeration.oafamily = oaf; /* The open array family */
10688 : 38606 : pSym->Enumeration.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10689 : 38606 : InitWhereDeclaredTok (tok, &pSym->Enumeration.At); /* Declared here */
10690 : 38606 : CheckIfEnumerationExported (sym, ScopePtr);
10691 : : }
10692 : 38606 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10693 : 38606 : return sym;
10694 : : /* static analysis guarentees a RETURN statement will be used before here. */
10695 : : __builtin_unreachable ();
10696 : : }
10697 : :
10698 : :
10699 : : /*
10700 : : MakeType - makes a type symbol with name TypeName.
10701 : : */
10702 : :
10703 : 611484 : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName)
10704 : : {
10705 : 611484 : SymbolTable_PtrToSymbol pSym;
10706 : 611484 : unsigned int sym;
10707 : 611484 : unsigned int oaf;
10708 : :
10709 : 611484 : sym = HandleHiddenOrDeclare (tok, TypeName, &oaf);
10710 : 611484 : if (! (SymbolTable_IsError (sym)))
10711 : : {
10712 : 611478 : pSym = GetPsym (sym);
10713 : 611478 : pSym->SymbolType = SymbolTable_TypeSym;
10714 : 611478 : pSym->Type.name = TypeName; /* Index into name array, name */
10715 : : /* of type. */
10716 : 611478 : pSym->Type.Type = SymbolTable_NulSym; /* Index to a type symbol. */
10717 : 611478 : pSym->Type.IsHidden = false; /* Was it declared as hidden? */
10718 : 611478 : SymbolKey_InitTree (&pSym->Type.ConstLitTree); /* constants of this type. */
10719 : 611478 : pSym->Type.Size = M2ALU_InitValue (); /* Runtime size of symbol. */
10720 : 611478 : pSym->Type.Align = SymbolTable_NulSym; /* Alignment of this type. */
10721 : 611478 : InitPacked (&pSym->Type.packedInfo); /* not packed and no */
10722 : : /* equivalent yet. */
10723 : 611478 : pSym->Type.oafamily = oaf; /* The open array family. */
10724 : 611478 : pSym->Type.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10725 : 611478 : InitWhereDeclaredTok (tok, &pSym->Type.At); /* Declared here */
10726 : : }
10727 : 611484 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
10728 : 611484 : return sym;
10729 : : /* static analysis guarentees a RETURN statement will be used before here. */
10730 : : __builtin_unreachable ();
10731 : : }
10732 : :
10733 : :
10734 : : /*
10735 : : MakeHiddenType - makes a type symbol that is hidden from the
10736 : : definition module.
10737 : : This symbol is placed into the UnImplemented list of
10738 : : the definition/implementation module.
10739 : : The type will be filled in when the implementation module
10740 : : is reached.
10741 : : */
10742 : :
10743 : 23383 : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName)
10744 : : {
10745 : 23383 : SymbolTable_PtrToSymbol pSym;
10746 : 23383 : unsigned int Sym;
10747 : :
10748 : 23383 : tok = CheckTok (tok, (const char *) "hidden", 6);
10749 : 23383 : Sym = DeclareSym (tok, TypeName);
10750 : 23383 : if (! (SymbolTable_IsError (Sym)))
10751 : : {
10752 : 23383 : pSym = GetPsym (Sym);
10753 : 23383 : pSym->SymbolType = SymbolTable_TypeSym;
10754 : 23383 : pSym->Type.name = TypeName; /* Index into name array, name */
10755 : : /* of type. */
10756 : 23383 : pSym->Type.IsHidden = (SymbolTable_GetMainModule ()) != (SymbolTable_GetCurrentScope ());
10757 : 23383 : if (M2Options_ExtendedOpaque || ! pSym->Type.IsHidden)
10758 : : {
10759 : 1464 : pSym->Type.Type = SymbolTable_NulSym; /* will be filled in later */
10760 : : }
10761 : : else
10762 : : {
10763 : 21919 : pSym->Type.Type = M2System_Address;
10764 : : }
10765 : 23383 : pSym->Type.Align = SymbolTable_NulSym; /* Alignment of this type. */
10766 : 23383 : pSym->Type.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
10767 : 23383 : pSym->Type.oafamily = SymbolTable_NulSym; /* Which scope created it */
10768 : 23383 : if (! M2Options_ExtendedOpaque)
10769 : : {
10770 : 22015 : Lists_IncludeItemIntoList (AddressTypes, Sym);
10771 : : }
10772 : 23383 : pSym->Type.Size = M2ALU_InitValue (); /* Runtime size of symbol. */
10773 : 23383 : InitWhereDeclaredTok (tok, &pSym->Type.At); /* Declared here */
10774 : 23383 : SymbolTable_PutExportUnImplemented (tok, Sym);
10775 : 23383 : if (M2Options_ExtendedOpaque || ((SymbolTable_GetMainModule ()) == (SymbolTable_GetCurrentScope ())))
10776 : : {
10777 : 1464 : SymbolTable_PutHiddenTypeDeclared ();
10778 : : }
10779 : : /* Now add this type to the symbol table of the current scope */
10780 : 23383 : AddSymToScope (Sym, TypeName);
10781 : : }
10782 : 23383 : return Sym;
10783 : : /* static analysis guarentees a RETURN statement will be used before here. */
10784 : : __builtin_unreachable ();
10785 : : }
10786 : :
10787 : :
10788 : : /*
10789 : : MakeConstant - create a constant cardinal and return the symbol.
10790 : : */
10791 : :
10792 : 30918 : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value)
10793 : : {
10794 : 30918 : DynamicStrings_String str;
10795 : 30918 : unsigned int sym;
10796 : :
10797 : 30918 : tok = CheckTok (tok, (const char *) "constant", 8);
10798 : 30918 : str = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%d", 2)), (const unsigned char *) &value, (sizeof (value)-1));
10799 : 30918 : sym = SymbolTable_MakeConstLit (tok, NameKey_makekey (DynamicStrings_string (str)), M2Base_Cardinal);
10800 : 30918 : str = DynamicStrings_KillString (str);
10801 : 30918 : return sym;
10802 : : /* static analysis guarentees a RETURN statement will be used before here. */
10803 : : __builtin_unreachable ();
10804 : : }
10805 : :
10806 : :
10807 : : /*
10808 : : MakeConstLit - returns a constant literal of type, constType, with a constName,
10809 : : at location, tok.
10810 : : */
10811 : :
10812 : 1307739 : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
10813 : : {
10814 : 1307739 : unsigned int sym;
10815 : :
10816 : 1307739 : tok = CheckTok (tok, (const char *) "constlit", 8);
10817 : 1307739 : sym = LookupConstLitPoolEntry (tok, constName, constType);
10818 : 1307739 : if (sym == SymbolTable_NulSym)
10819 : : {
10820 : 536536 : sym = CreateConstLit (tok, constName, constType);
10821 : 536536 : AddConstLitPoolEntry (sym, tok, constName, constType);
10822 : : }
10823 : 1307739 : return sym;
10824 : : /* static analysis guarentees a RETURN statement will be used before here. */
10825 : : __builtin_unreachable ();
10826 : : }
10827 : :
10828 : :
10829 : : /*
10830 : : MakeConstVar - makes a ConstVar type with
10831 : : name ConstVarName.
10832 : : */
10833 : :
10834 : 1136884 : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName)
10835 : : {
10836 : 1136884 : SymbolTable_PtrToSymbol pSym;
10837 : 1136884 : unsigned int Sym;
10838 : 1136884 : bool temp;
10839 : :
10840 : 1136884 : temp = ConstVarName == NameKey_NulName;
10841 : 1136884 : ConstVarName = SymbolTable_CheckAnonymous (ConstVarName);
10842 : 1136884 : Sym = DeclareSym (tok, ConstVarName);
10843 : 1136884 : if (! (SymbolTable_IsError (Sym)))
10844 : : {
10845 : 1136878 : pSym = GetPsym (Sym);
10846 : 1136878 : pSym->SymbolType = SymbolTable_ConstVarSym;
10847 : 1136878 : pSym->ConstVar.name = ConstVarName;
10848 : 1136878 : pSym->ConstVar.Value = M2ALU_InitValue ();
10849 : 1136878 : pSym->ConstVar.Type = SymbolTable_NulSym;
10850 : 1136878 : pSym->ConstVar.IsSet = false;
10851 : 1136878 : pSym->ConstVar.IsConditional = false;
10852 : 1136878 : pSym->ConstVar.IsConstructor = false;
10853 : 1136878 : pSym->ConstVar.FromType = SymbolTable_NulSym; /* type is determined FromType */
10854 : 1136878 : pSym->ConstVar.UnresFromType = false; /* is Type resolved? */
10855 : 1136878 : pSym->ConstVar.IsTemp = temp; /* is Type resolved? */
10856 : 1136878 : pSym->ConstVar.Scope = SymbolTable_GetCurrentScope ();
10857 : 1136878 : InitWhereDeclaredTok (tok, &pSym->ConstVar.At);
10858 : : /* Now add this constant to the symbol table of the current scope */
10859 : 1136878 : AddSymToScope (Sym, ConstVarName);
10860 : : }
10861 : 1136884 : return Sym;
10862 : : /* static analysis guarentees a RETURN statement will be used before here. */
10863 : : __builtin_unreachable ();
10864 : : }
10865 : :
10866 : :
10867 : : /*
10868 : : MakeConstString - create a string constant in the symboltable.
10869 : : */
10870 : :
10871 : 254348 : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName)
10872 : : {
10873 : 254348 : unsigned int newstr;
10874 : :
10875 : 254348 : NewSym (&newstr);
10876 : 254348 : InitConstString (tok, newstr, ConstName, ConstName, SymbolTable_m2nulstr, false, true);
10877 : 254348 : return newstr;
10878 : : /* static analysis guarentees a RETURN statement will be used before here. */
10879 : : __builtin_unreachable ();
10880 : : }
10881 : :
10882 : :
10883 : : /*
10884 : : MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
10885 : : If known is TRUE then name is assigned to the contents
10886 : : and the escape sequences will be converted into characters.
10887 : : */
10888 : :
10889 : 8001 : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known)
10890 : : {
10891 : 8001 : unsigned int newstr;
10892 : :
10893 : 8001 : tok = CheckTok (tok, (const char *) "conststringcnul", 15);
10894 : 8001 : NewSym (&newstr);
10895 : 8001 : InitConstString (tok, newstr, name, name, SymbolTable_cnulstr, true, known);
10896 : 8001 : return newstr;
10897 : : /* static analysis guarentees a RETURN statement will be used before here. */
10898 : : __builtin_unreachable ();
10899 : : }
10900 : :
10901 : :
10902 : : /*
10903 : : MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
10904 : : If known is TRUE then name is assigned to the contents
10905 : : however the escape sequences are not converted into characters.
10906 : : */
10907 : :
10908 : 31647 : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known)
10909 : : {
10910 : 31647 : unsigned int newstr;
10911 : :
10912 : 31647 : NewSym (&newstr);
10913 : 31647 : InitConstString (tok, newstr, name, name, SymbolTable_m2nulstr, false, known);
10914 : 31647 : return newstr;
10915 : : /* static analysis guarentees a RETURN statement will be used before here. */
10916 : : __builtin_unreachable ();
10917 : : }
10918 : :
10919 : :
10920 : : /*
10921 : : PutConstStringKnown - if sym is a constvar then convert it into a conststring.
10922 : : If known is FALSE then contents is ignored and NulName is
10923 : : stored. If escape is TRUE then the contents will have
10924 : : any escape sequences converted into single characters.
10925 : : */
10926 : :
10927 : 346550 : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known)
10928 : : {
10929 : 346550 : SymbolTable_PtrToSymbol pSym;
10930 : 346550 : DynamicStrings_String s;
10931 : :
10932 : 346550 : pSym = GetPsym (sym);
10933 : 346550 : switch (pSym->SymbolType)
10934 : : {
10935 : 345148 : case SymbolTable_ConstStringSym:
10936 : 345148 : if (known)
10937 : : {
10938 : 303618 : if (escape)
10939 : : {
10940 : 7977 : s = FormatStrings_HandleEscape (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (contents)));
10941 : 7977 : contents = NameKey_makekey (DynamicStrings_string (s));
10942 : 7977 : s = DynamicStrings_KillString (s);
10943 : : }
10944 : 303618 : pSym->ConstString.Length = NameKey_LengthKey (contents);
10945 : 303618 : pSym->ConstString.Contents = contents;
10946 : : }
10947 : : else
10948 : : {
10949 : 41530 : pSym->ConstString.Length = 0;
10950 : 41530 : pSym->ConstString.Contents = NameKey_NulName;
10951 : : }
10952 : 345148 : pSym->ConstString.Known = known;
10953 : 345148 : InitWhereDeclaredTok (tok, &pSym->ConstString.At);
10954 : 345148 : InitWhereFirstUsedTok (tok, &pSym->ConstString.At);
10955 : 345148 : break;
10956 : :
10957 : 1402 : case SymbolTable_ConstVarSym:
10958 : 1402 : InitConstString (tok, sym, pSym->ConstVar.name, contents, SymbolTable_m2str, escape, known); /* Change a ConstVar to a ConstString copy name
10959 : : and alter symboltype. */
10960 : 1402 : break;
10961 : :
10962 : :
10963 : 0 : default:
10964 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
10965 : 346550 : break;
10966 : : }
10967 : 346550 : }
10968 : :
10969 : :
10970 : : /*
10971 : : CopyConstString - copies string contents from expr to des
10972 : : and retain the kind of string.
10973 : : */
10974 : :
10975 : 1396 : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr)
10976 : : {
10977 : 1396 : SymbolTable_PtrToSymbol pSym;
10978 : :
10979 : 1396 : M2Debug_Assert (SymbolTable_IsConstStringKnown (expr));
10980 : 1396 : pSym = GetPsym (des);
10981 : 1396 : switch (pSym->SymbolType)
10982 : : {
10983 : 1372 : case SymbolTable_ConstStringSym:
10984 : 1372 : InitConstString (tok, des, pSym->ConstString.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true);
10985 : 1372 : break;
10986 : :
10987 : 24 : case SymbolTable_ConstVarSym:
10988 : 24 : InitConstString (tok, des, pSym->ConstVar.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true); /* Change a ConstVar to a ConstString copy name
10989 : : and alter symboltype. */
10990 : 24 : break;
10991 : :
10992 : :
10993 : 0 : default:
10994 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
10995 : 1396 : break;
10996 : : }
10997 : 1396 : }
10998 : :
10999 : :
11000 : : /*
11001 : : IsConstStringKnown - returns TRUE if sym is a const string
11002 : : and the contents are known.
11003 : : */
11004 : :
11005 : 839010 : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym)
11006 : : {
11007 : 839010 : SymbolTable_PtrToSymbol pSym;
11008 : :
11009 : 839010 : pSym = GetPsym (sym);
11010 : 839010 : switch (pSym->SymbolType)
11011 : : {
11012 : 838986 : case SymbolTable_ConstStringSym:
11013 : 838986 : return pSym->ConstString.Known;
11014 : : break;
11015 : :
11016 : :
11017 : : default:
11018 : : return false;
11019 : : break;
11020 : : }
11021 : : /* static analysis guarentees a RETURN statement will be used before here. */
11022 : : __builtin_unreachable ();
11023 : : }
11024 : :
11025 : :
11026 : : /*
11027 : : IsConstStringM2 - returns whether this conststring is a
11028 : : Modula-2 string.
11029 : : */
11030 : :
11031 : 0 : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym)
11032 : : {
11033 : 0 : return (GetConstStringKind (sym)) == SymbolTable_m2str;
11034 : : /* static analysis guarentees a RETURN statement will be used before here. */
11035 : : __builtin_unreachable ();
11036 : : }
11037 : :
11038 : :
11039 : : /*
11040 : : IsConstStringC - returns whether this conststring is a C style string
11041 : : which will have any escape translated.
11042 : : */
11043 : :
11044 : 0 : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym)
11045 : : {
11046 : 0 : return (GetConstStringKind (sym)) == SymbolTable_cstr;
11047 : : /* static analysis guarentees a RETURN statement will be used before here. */
11048 : : __builtin_unreachable ();
11049 : : }
11050 : :
11051 : :
11052 : : /*
11053 : : IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
11054 : : contains a nul terminator.
11055 : : */
11056 : :
11057 : 265252 : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym)
11058 : : {
11059 : 265252 : return (GetConstStringKind (sym)) == SymbolTable_m2nulstr;
11060 : : /* static analysis guarentees a RETURN statement will be used before here. */
11061 : : __builtin_unreachable ();
11062 : : }
11063 : :
11064 : :
11065 : : /*
11066 : : IsConstStringCnul - returns whether this conststring is a C style string
11067 : : which will have any escape translated and also contains
11068 : : a nul terminator.
11069 : : */
11070 : :
11071 : 7797 : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym)
11072 : : {
11073 : 7797 : return (GetConstStringKind (sym)) == SymbolTable_cnulstr;
11074 : : /* static analysis guarentees a RETURN statement will be used before here. */
11075 : : __builtin_unreachable ();
11076 : : }
11077 : :
11078 : :
11079 : : /*
11080 : : MakeSubrange - makes a new symbol into a subrange type with
11081 : : name SubrangeName.
11082 : : */
11083 : :
11084 : 148260 : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName)
11085 : : {
11086 : 148260 : SymbolTable_PtrToSymbol pSym;
11087 : 148260 : unsigned int sym;
11088 : 148260 : unsigned int oaf;
11089 : :
11090 : 148260 : tok = CheckTok (tok, (const char *) "subrange", 8);
11091 : 148260 : sym = HandleHiddenOrDeclare (tok, SubrangeName, &oaf);
11092 : 148260 : if (! (SymbolTable_IsError (sym)))
11093 : : {
11094 : 148260 : pSym = GetPsym (sym);
11095 : 148260 : pSym->SymbolType = SymbolTable_SubrangeSym;
11096 : 148260 : pSym->Subrange.name = SubrangeName;
11097 : 148260 : pSym->Subrange.Low = SymbolTable_NulSym; /* Index to a symbol determining */
11098 : : /* ConstExpression. */
11099 : 148260 : pSym->Subrange.High = SymbolTable_NulSym; /* Index to a symbol determining */
11100 : : /* ConstExpression. */
11101 : 148260 : pSym->Subrange.Type = SymbolTable_NulSym; /* Index to a type. Determines */
11102 : : /* the type of subrange. */
11103 : 148260 : pSym->Subrange.Align = SymbolTable_NulSym; /* The alignment of this type. */
11104 : 148260 : InitPacked (&pSym->Subrange.packedInfo); /* not packed and no equivalent */
11105 : 148260 : SymbolKey_InitTree (&pSym->Subrange.ConstLitTree); /* constants of this type. */
11106 : 148260 : pSym->Subrange.Size = M2ALU_InitValue (); /* Size determines the type size */
11107 : 148260 : pSym->Subrange.oafamily = oaf; /* The unbounded sym for this */
11108 : 148260 : pSym->Subrange.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11109 : 148260 : InitWhereDeclaredTok (tok, &pSym->Subrange.At); /* Declared here */
11110 : : }
11111 : 148260 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11112 : 148260 : return sym;
11113 : : /* static analysis guarentees a RETURN statement will be used before here. */
11114 : : __builtin_unreachable ();
11115 : : }
11116 : :
11117 : :
11118 : : /*
11119 : : MakeSet - makes a set Symbol with name, SetName.
11120 : : */
11121 : :
11122 : 62938 : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName)
11123 : : {
11124 : 62938 : SymbolTable_PtrToSymbol pSym;
11125 : 62938 : unsigned int oaf;
11126 : 62938 : unsigned int sym;
11127 : :
11128 : 62938 : tok = CheckTok (tok, (const char *) "set", 3);
11129 : 62938 : sym = HandleHiddenOrDeclare (tok, SetName, &oaf);
11130 : 62938 : if (! (SymbolTable_IsError (sym)))
11131 : : {
11132 : 62938 : pSym = GetPsym (sym);
11133 : 62938 : pSym->SymbolType = SymbolTable_SetSym;
11134 : 62938 : pSym->Set.name = SetName; /* The name of the set. */
11135 : 62938 : pSym->Set.Type = SymbolTable_NulSym; /* Index to a subrange symbol. */
11136 : 62938 : pSym->Set.Size = M2ALU_InitValue (); /* Size of this set */
11137 : 62938 : InitPacked (&pSym->Set.packedInfo); /* not packed and no */
11138 : : /* equivalent (yet). */
11139 : 62938 : pSym->Set.ispacked = false; /* Not yet known to be packed. */
11140 : 62938 : pSym->Set.oafamily = oaf; /* The unbounded sym for this */
11141 : 62938 : pSym->Set.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11142 : 62938 : InitWhereDeclaredTok (tok, &pSym->Set.At); /* Declared here */
11143 : : }
11144 : 62938 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11145 : 62938 : return sym;
11146 : : /* static analysis guarentees a RETURN statement will be used before here. */
11147 : : __builtin_unreachable ();
11148 : : }
11149 : :
11150 : :
11151 : : /*
11152 : : MakeArray - makes an Array symbol with name ArrayName.
11153 : : */
11154 : :
11155 : 88058 : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName)
11156 : : {
11157 : 88058 : SymbolTable_PtrToSymbol pSym;
11158 : 88058 : unsigned int sym;
11159 : 88058 : unsigned int oaf;
11160 : :
11161 : 88058 : sym = HandleHiddenOrDeclare (tok, ArrayName, &oaf);
11162 : 88058 : if (! (SymbolTable_IsError (sym)))
11163 : : {
11164 : 88058 : pSym = GetPsym (sym);
11165 : 88058 : pSym->SymbolType = SymbolTable_ArraySym;
11166 : 88058 : pSym->Array.name = ArrayName;
11167 : 88058 : pSym->Array.Subscript = SymbolTable_NulSym; /* Contains the array subscripts. */
11168 : 88058 : pSym->Array.Size = M2ALU_InitValue (); /* Size of array. */
11169 : 88058 : pSym->Array.Offset = M2ALU_InitValue (); /* Offset of array. */
11170 : 88058 : pSym->Array.Type = SymbolTable_NulSym; /* The Array Type. ARRAY OF Type. */
11171 : 88058 : pSym->Array.Large = false; /* is this array large? */
11172 : 88058 : pSym->Array.Align = SymbolTable_NulSym; /* The alignment of this type. */
11173 : 88058 : pSym->Array.oafamily = oaf; /* The unbounded for this array */
11174 : 88058 : pSym->Array.Scope = SymbolTable_GetCurrentScope (); /* Which scope created it */
11175 : 88058 : InitWhereDeclaredTok (tok, &pSym->Array.At); /* Declared here */
11176 : : }
11177 : 88058 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
11178 : 88058 : return sym;
11179 : : /* static analysis guarentees a RETURN statement will be used before here. */
11180 : : __builtin_unreachable ();
11181 : : }
11182 : :
11183 : :
11184 : : /*
11185 : : PutArrayLarge - indicates that this is a large array in which case
11186 : : the interface to gcc maps this array from 0..high-low,
11187 : : using an integer indice.
11188 : : */
11189 : :
11190 : 24 : extern "C" void SymbolTable_PutArrayLarge (unsigned int array)
11191 : : {
11192 : 24 : SymbolTable_PtrToSymbol pSym;
11193 : :
11194 : 24 : if (! (SymbolTable_IsError (array)))
11195 : : {
11196 : 24 : M2Debug_Assert (SymbolTable_IsArray (array));
11197 : 24 : pSym = GetPsym (array);
11198 : 24 : pSym->Array.Large = true;
11199 : : }
11200 : 24 : }
11201 : :
11202 : :
11203 : : /*
11204 : : IsArrayLarge - returns TRUE if we need to treat this as a large array.
11205 : : */
11206 : :
11207 : 40896 : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array)
11208 : : {
11209 : 40896 : SymbolTable_PtrToSymbol pSym;
11210 : :
11211 : 40896 : M2Debug_Assert (SymbolTable_IsArray (array));
11212 : 40896 : pSym = GetPsym (array);
11213 : 40896 : return pSym->Array.Large;
11214 : : /* static analysis guarentees a RETURN statement will be used before here. */
11215 : : __builtin_unreachable ();
11216 : : }
11217 : :
11218 : :
11219 : : /*
11220 : : PutPriority - places a interrupt, priority, value into module, module.
11221 : : */
11222 : :
11223 : 38 : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority)
11224 : : {
11225 : 38 : SymbolTable_PtrToSymbol pSym;
11226 : :
11227 : 38 : M2Debug_Assert (module != SymbolTable_NulSym);
11228 : 38 : pSym = GetPsym (module);
11229 : 38 : switch (pSym->SymbolType)
11230 : : {
11231 : 14 : case SymbolTable_DefImpSym:
11232 : 14 : pSym->DefImp.Priority = priority;
11233 : 14 : break;
11234 : :
11235 : 24 : case SymbolTable_ModuleSym:
11236 : 24 : pSym->Module.Priority = priority;
11237 : 24 : break;
11238 : :
11239 : :
11240 : 0 : default:
11241 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
11242 : 38 : break;
11243 : : }
11244 : 38 : }
11245 : :
11246 : :
11247 : : /*
11248 : : GetPriority - returns the interrupt priority which was assigned to
11249 : : module, module.
11250 : : */
11251 : :
11252 : 372600 : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module)
11253 : : {
11254 : 372600 : SymbolTable_PtrToSymbol pSym;
11255 : :
11256 : 372600 : M2Debug_Assert (module != SymbolTable_NulSym);
11257 : 372600 : pSym = GetPsym (module);
11258 : 372600 : switch (pSym->SymbolType)
11259 : : {
11260 : 239595 : case SymbolTable_DefImpSym:
11261 : 239595 : return pSym->DefImp.Priority;
11262 : 133005 : break;
11263 : :
11264 : 133005 : case SymbolTable_ModuleSym:
11265 : 133005 : return pSym->Module.Priority;
11266 : 0 : break;
11267 : :
11268 : :
11269 : 0 : default:
11270 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
11271 : : break;
11272 : : }
11273 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11274 : : __builtin_unreachable ();
11275 : : }
11276 : :
11277 : :
11278 : : /*
11279 : : PutNeedSavePriority - set a boolean flag indicating that this procedure
11280 : : needs to save and restore interrupts.
11281 : : */
11282 : :
11283 : 162 : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym)
11284 : : {
11285 : 162 : SymbolTable_PtrToSymbol pSym;
11286 : :
11287 : 162 : pSym = GetPsym (sym);
11288 : 162 : switch (pSym->SymbolType)
11289 : : {
11290 : 162 : case SymbolTable_ProcedureSym:
11291 : 162 : pSym->Procedure.SavePriority = true;
11292 : 162 : break;
11293 : :
11294 : :
11295 : 0 : default:
11296 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
11297 : 162 : break;
11298 : : }
11299 : 162 : }
11300 : :
11301 : :
11302 : : /*
11303 : : GetNeedSavePriority - returns the boolean flag indicating whether this procedure
11304 : : needs to save and restore interrupts.
11305 : : */
11306 : :
11307 : 680 : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym)
11308 : : {
11309 : 680 : SymbolTable_PtrToSymbol pSym;
11310 : :
11311 : 680 : pSym = GetPsym (sym);
11312 : 680 : switch (pSym->SymbolType)
11313 : : {
11314 : 680 : case SymbolTable_ProcedureSym:
11315 : 680 : return pSym->Procedure.SavePriority;
11316 : 0 : break;
11317 : :
11318 : :
11319 : 0 : default:
11320 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
11321 : : break;
11322 : : }
11323 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11324 : : __builtin_unreachable ();
11325 : : }
11326 : :
11327 : :
11328 : : /*
11329 : : PutVariableAtAddress - determines that a variable, sym, is declared at
11330 : : a specific address.
11331 : : */
11332 : :
11333 : 108 : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address)
11334 : : {
11335 : 108 : SymbolTable_PtrToSymbol pSym;
11336 : :
11337 : 108 : M2Debug_Assert (sym != SymbolTable_NulSym);
11338 : 108 : pSym = GetPsym (sym);
11339 : 108 : switch (pSym->SymbolType)
11340 : : {
11341 : 108 : case SymbolTable_VarSym:
11342 : 108 : pSym->Var.AtAddress = true;
11343 : 108 : pSym->Var.Address = address;
11344 : 108 : break;
11345 : :
11346 : :
11347 : 0 : default:
11348 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11349 : 108 : break;
11350 : : }
11351 : 108 : }
11352 : :
11353 : :
11354 : : /*
11355 : : GetVariableAtAddress - returns the address at which variable, sym, is declared.
11356 : : */
11357 : :
11358 : 54 : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym)
11359 : : {
11360 : 54 : SymbolTable_PtrToSymbol pSym;
11361 : :
11362 : 54 : M2Debug_Assert (sym != SymbolTable_NulSym);
11363 : 54 : pSym = GetPsym (sym);
11364 : 54 : switch (pSym->SymbolType)
11365 : : {
11366 : 54 : case SymbolTable_VarSym:
11367 : 54 : return pSym->Var.Address;
11368 : 0 : break;
11369 : :
11370 : :
11371 : 0 : default:
11372 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11373 : : break;
11374 : : }
11375 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11376 : : __builtin_unreachable ();
11377 : : }
11378 : :
11379 : :
11380 : : /*
11381 : : IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
11382 : : a specific address.
11383 : : */
11384 : :
11385 : 274983 : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym)
11386 : : {
11387 : 274983 : SymbolTable_PtrToSymbol pSym;
11388 : :
11389 : 274983 : M2Debug_Assert (sym != SymbolTable_NulSym);
11390 : 274983 : pSym = GetPsym (sym);
11391 : 274983 : switch (pSym->SymbolType)
11392 : : {
11393 : 274983 : case SymbolTable_VarSym:
11394 : 274983 : return pSym->Var.AtAddress;
11395 : 0 : break;
11396 : :
11397 : :
11398 : 0 : default:
11399 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11400 : : break;
11401 : : }
11402 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11403 : : __builtin_unreachable ();
11404 : : }
11405 : :
11406 : :
11407 : : /*
11408 : : PutVariableSSA - assigns value to the SSA field within variable sym.
11409 : : */
11410 : :
11411 : 0 : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value)
11412 : : {
11413 : 0 : SymbolTable_PtrToSymbol pSym;
11414 : :
11415 : 0 : M2Debug_Assert (sym != SymbolTable_NulSym);
11416 : 0 : pSym = GetPsym (sym);
11417 : 0 : switch (pSym->SymbolType)
11418 : : {
11419 : 0 : case SymbolTable_VarSym:
11420 : 0 : pSym->Var.IsSSA = value;
11421 : 0 : break;
11422 : :
11423 : :
11424 : 0 : default:
11425 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11426 : 0 : break;
11427 : : }
11428 : 0 : }
11429 : :
11430 : :
11431 : : /*
11432 : : IsVariableSSA - returns TRUE if variable is known to be a SSA.
11433 : : */
11434 : :
11435 : 168851 : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym)
11436 : : {
11437 : 168851 : SymbolTable_PtrToSymbol pSym;
11438 : :
11439 : 168851 : M2Debug_Assert (sym != SymbolTable_NulSym);
11440 : 168851 : pSym = GetPsym (sym);
11441 : 168851 : switch (pSym->SymbolType)
11442 : : {
11443 : 168851 : case SymbolTable_VarSym:
11444 : 168851 : return pSym->Var.IsSSA;
11445 : 0 : break;
11446 : :
11447 : :
11448 : 0 : default:
11449 : 0 : M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
11450 : : break;
11451 : : }
11452 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11453 : : __builtin_unreachable ();
11454 : : }
11455 : :
11456 : :
11457 : : /*
11458 : : PutVarConst - sets the IsConst field to value indicating the variable is read only.
11459 : : */
11460 : :
11461 : 168130 : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value)
11462 : : {
11463 : 168130 : SymbolTable_PtrToSymbol pSym;
11464 : :
11465 : 168130 : if (SymbolTable_IsVar (sym))
11466 : : {
11467 : 168130 : pSym = GetPsym (sym);
11468 : 168130 : pSym->Var.IsConst = value;
11469 : : }
11470 : 168130 : }
11471 : :
11472 : :
11473 : : /*
11474 : : MakeGnuAsm - create a GnuAsm symbol.
11475 : : */
11476 : :
11477 : 27 : extern "C" unsigned int SymbolTable_MakeGnuAsm (void)
11478 : : {
11479 : 27 : SymbolTable_PtrToSymbol pSym;
11480 : 27 : unsigned int Sym;
11481 : :
11482 : 27 : NewSym (&Sym);
11483 : 27 : pSym = GetPsym (Sym);
11484 : 27 : pSym->SymbolType = SymbolTable_GnuAsmSym;
11485 : 27 : pSym->GnuAsm.String = SymbolTable_NulSym;
11486 : 27 : InitWhereDeclared (&pSym->GnuAsm.At);
11487 : 27 : pSym->GnuAsm.Inputs = SymbolTable_NulSym;
11488 : 27 : pSym->GnuAsm.Outputs = SymbolTable_NulSym;
11489 : 27 : pSym->GnuAsm.Trashed = SymbolTable_NulSym;
11490 : 27 : pSym->GnuAsm.Volatile = false;
11491 : 27 : pSym->GnuAsm.Simple = false;
11492 : 27 : return Sym;
11493 : : /* static analysis guarentees a RETURN statement will be used before here. */
11494 : : __builtin_unreachable ();
11495 : : }
11496 : :
11497 : :
11498 : : /*
11499 : : PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
11500 : : */
11501 : :
11502 : 27 : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string)
11503 : : {
11504 : 27 : SymbolTable_PtrToSymbol pSym;
11505 : :
11506 : 27 : M2Debug_Assert (SymbolTable_IsConstString (string));
11507 : 27 : pSym = GetPsym (sym);
11508 : 27 : switch (pSym->SymbolType)
11509 : : {
11510 : 27 : case SymbolTable_GnuAsmSym:
11511 : 27 : pSym->GnuAsm.String = string;
11512 : 27 : break;
11513 : :
11514 : :
11515 : 0 : default:
11516 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11517 : 27 : break;
11518 : : }
11519 : 27 : }
11520 : :
11521 : :
11522 : : /*
11523 : : PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
11524 : : */
11525 : :
11526 : 21 : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out)
11527 : : {
11528 : 21 : SymbolTable_PtrToSymbol pSym;
11529 : :
11530 : 21 : pSym = GetPsym (sym);
11531 : 21 : switch (pSym->SymbolType)
11532 : : {
11533 : 21 : case SymbolTable_GnuAsmSym:
11534 : 21 : pSym->GnuAsm.Outputs = out;
11535 : 21 : break;
11536 : :
11537 : :
11538 : 0 : default:
11539 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11540 : 21 : break;
11541 : : }
11542 : 21 : }
11543 : :
11544 : :
11545 : : /*
11546 : : PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
11547 : : */
11548 : :
11549 : 15 : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in)
11550 : : {
11551 : 15 : SymbolTable_PtrToSymbol pSym;
11552 : :
11553 : 15 : pSym = GetPsym (sym);
11554 : 15 : switch (pSym->SymbolType)
11555 : : {
11556 : 15 : case SymbolTable_GnuAsmSym:
11557 : 15 : pSym->GnuAsm.Inputs = in;
11558 : 15 : break;
11559 : :
11560 : :
11561 : 0 : default:
11562 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11563 : 15 : break;
11564 : : }
11565 : 15 : }
11566 : :
11567 : :
11568 : : /*
11569 : : PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
11570 : : */
11571 : :
11572 : 9 : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash)
11573 : : {
11574 : 9 : SymbolTable_PtrToSymbol pSym;
11575 : :
11576 : 9 : pSym = GetPsym (sym);
11577 : 9 : switch (pSym->SymbolType)
11578 : : {
11579 : 9 : case SymbolTable_GnuAsmSym:
11580 : 9 : pSym->GnuAsm.Trashed = trash;
11581 : 9 : break;
11582 : :
11583 : :
11584 : 0 : default:
11585 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11586 : 9 : break;
11587 : : }
11588 : 9 : }
11589 : :
11590 : :
11591 : : /*
11592 : : GetGnuAsm - returns the string symbol, representing the instruction textual
11593 : : of the GnuAsm symbol. It will return a ConstString.
11594 : : */
11595 : :
11596 : 27 : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym)
11597 : : {
11598 : 27 : SymbolTable_PtrToSymbol pSym;
11599 : :
11600 : 27 : pSym = GetPsym (sym);
11601 : 27 : switch (pSym->SymbolType)
11602 : : {
11603 : 27 : case SymbolTable_GnuAsmSym:
11604 : 27 : return pSym->GnuAsm.String;
11605 : 0 : break;
11606 : :
11607 : :
11608 : 0 : default:
11609 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11610 : : break;
11611 : : }
11612 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11613 : : __builtin_unreachable ();
11614 : : }
11615 : :
11616 : :
11617 : : /*
11618 : : GetGnuAsmInput - returns the input list of registers.
11619 : : */
11620 : :
11621 : 27 : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym)
11622 : : {
11623 : 27 : SymbolTable_PtrToSymbol pSym;
11624 : :
11625 : 27 : pSym = GetPsym (sym);
11626 : 27 : switch (pSym->SymbolType)
11627 : : {
11628 : 27 : case SymbolTable_GnuAsmSym:
11629 : 27 : return pSym->GnuAsm.Inputs;
11630 : 0 : break;
11631 : :
11632 : :
11633 : 0 : default:
11634 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11635 : : break;
11636 : : }
11637 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11638 : : __builtin_unreachable ();
11639 : : }
11640 : :
11641 : :
11642 : : /*
11643 : : GetGnuAsmOutput - returns the output list of registers.
11644 : : */
11645 : :
11646 : 27 : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym)
11647 : : {
11648 : 27 : SymbolTable_PtrToSymbol pSym;
11649 : :
11650 : 27 : pSym = GetPsym (sym);
11651 : 27 : switch (pSym->SymbolType)
11652 : : {
11653 : 27 : case SymbolTable_GnuAsmSym:
11654 : 27 : return pSym->GnuAsm.Outputs;
11655 : 0 : break;
11656 : :
11657 : :
11658 : 0 : default:
11659 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11660 : : break;
11661 : : }
11662 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11663 : : __builtin_unreachable ();
11664 : : }
11665 : :
11666 : :
11667 : : /*
11668 : : GetGnuAsmTrash - returns the list of trashed registers.
11669 : : */
11670 : :
11671 : 27 : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym)
11672 : : {
11673 : 27 : SymbolTable_PtrToSymbol pSym;
11674 : :
11675 : 27 : pSym = GetPsym (sym);
11676 : 27 : switch (pSym->SymbolType)
11677 : : {
11678 : 27 : case SymbolTable_GnuAsmSym:
11679 : 27 : return pSym->GnuAsm.Trashed;
11680 : 0 : break;
11681 : :
11682 : :
11683 : 0 : default:
11684 : 0 : M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
11685 : : break;
11686 : : }
11687 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
11688 : : __builtin_unreachable ();
11689 : : }
11690 : :
11691 : :
11692 : : /*
11693 : : PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
11694 : : */
11695 : :
11696 : 15 : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym)
11697 : : {
11698 : 15 : SymbolTable_PtrToSymbol pSym;
11699 : :
11700 : 15 : pSym = GetPsym (Sym);
11701 : 15 : switch (pSym->SymbolType)
11702 : : {
11703 : 15 : case SymbolTable_GnuAsmSym:
11704 : 15 : pSym->GnuAsm.Volatile = true;
11705 : 15 : break;
11706 : :
11707 : :
11708 : 0 : default:
11709 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11710 : 15 : break;
11711 : : }
11712 : 15 : }
11713 : :
11714 : :
11715 : : /*
11716 : : PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
11717 : : */
11718 : :
11719 : 6 : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym)
11720 : : {
11721 : 6 : SymbolTable_PtrToSymbol pSym;
11722 : :
11723 : 6 : pSym = GetPsym (Sym);
11724 : 6 : switch (pSym->SymbolType)
11725 : : {
11726 : 6 : case SymbolTable_GnuAsmSym:
11727 : 6 : pSym->GnuAsm.Simple = true;
11728 : 6 : break;
11729 : :
11730 : :
11731 : 0 : default:
11732 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
11733 : 6 : break;
11734 : : }
11735 : 6 : }
11736 : :
11737 : :
11738 : : /*
11739 : : MakeRegInterface - creates and returns a register interface symbol.
11740 : : */
11741 : :
11742 : 33 : extern "C" unsigned int SymbolTable_MakeRegInterface (void)
11743 : : {
11744 : 33 : SymbolTable_PtrToSymbol pSym;
11745 : 33 : unsigned int Sym;
11746 : :
11747 : 33 : NewSym (&Sym);
11748 : 33 : pSym = GetPsym (Sym);
11749 : 33 : pSym->SymbolType = SymbolTable_InterfaceSym;
11750 : 33 : pSym->Interface.Parameters = Indexing_InitIndex (1);
11751 : 33 : InitWhereDeclared (&pSym->Interface.At);
11752 : 33 : return Sym;
11753 : : /* static analysis guarentees a RETURN statement will be used before here. */
11754 : : __builtin_unreachable ();
11755 : : }
11756 : :
11757 : :
11758 : : /*
11759 : : PutRegInterface - places a, name, string, and, object, into the interface array,
11760 : : sym, at position, i.
11761 : : The string symbol will either be a register name or a constraint.
11762 : : The object is an optional Modula-2 variable or constant symbol.
11763 : : read and write are the quadruple numbers representing any read
11764 : : or write operation.
11765 : : */
11766 : :
11767 : 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_)
11768 : : {
11769 : 36 : SymbolTable_PtrToSymbol pSym;
11770 : 36 : SymbolTable_PtrToAsmConstraint p;
11771 : :
11772 : 36 : pSym = GetPsym (sym);
11773 : 36 : switch (pSym->SymbolType)
11774 : : {
11775 : 36 : case SymbolTable_InterfaceSym:
11776 : 36 : if (Indexing_InBounds (pSym->Interface.Parameters, i))
11777 : : {
11778 : 0 : p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
11779 : : }
11780 : 36 : else if (i == ((Indexing_HighIndice (pSym->Interface.Parameters))+1))
11781 : : {
11782 : : /* avoid dangling else. */
11783 : 36 : Storage_ALLOCATE ((void **) &p, sizeof (SymbolTable__T5));
11784 : 36 : Indexing_PutIndice (pSym->Interface.Parameters, i, reinterpret_cast <void *> (p));
11785 : : }
11786 : : else
11787 : : {
11788 : : /* avoid dangling else. */
11789 : 0 : M2Error_InternalError ((const char *) "expecting to add parameters sequentially", 40);
11790 : : }
11791 : 36 : p->tokpos = tok;
11792 : 36 : p->name = n;
11793 : 36 : p->str = string;
11794 : 36 : p->obj = object;
11795 : 36 : PutFirstUsed (object, tok, read_, write_);
11796 : 36 : break;
11797 : :
11798 : :
11799 : 0 : default:
11800 : 0 : M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
11801 : 36 : break;
11802 : : }
11803 : 36 : }
11804 : :
11805 : :
11806 : : /*
11807 : : GetRegInterface - gets a, name, string, and, object, from the interface array,
11808 : : sym, from position, i.
11809 : : */
11810 : :
11811 : 69 : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object)
11812 : : {
11813 : 69 : SymbolTable_PtrToSymbol pSym;
11814 : 69 : SymbolTable_PtrToAsmConstraint p;
11815 : :
11816 : 69 : pSym = GetPsym (sym);
11817 : 69 : switch (pSym->SymbolType)
11818 : : {
11819 : 69 : case SymbolTable_InterfaceSym:
11820 : 69 : if (Indexing_InBounds (pSym->Interface.Parameters, i))
11821 : : {
11822 : 36 : p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
11823 : 36 : (*tok) = p->tokpos;
11824 : 36 : (*n) = p->name;
11825 : 36 : (*string) = p->str;
11826 : 36 : (*object) = p->obj;
11827 : : }
11828 : : else
11829 : : {
11830 : 33 : (*tok) = M2LexBuf_UnknownTokenNo;
11831 : 33 : (*n) = NameKey_NulName;
11832 : 33 : (*string) = SymbolTable_NulSym;
11833 : 33 : (*object) = SymbolTable_NulSym;
11834 : : }
11835 : 69 : break;
11836 : :
11837 : :
11838 : 0 : default:
11839 : 0 : M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
11840 : 69 : break;
11841 : : }
11842 : 69 : }
11843 : :
11844 : :
11845 : : /*
11846 : : GetModule - Returns the Module symbol for the module with name, name.
11847 : : */
11848 : :
11849 : 305540 : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name)
11850 : : {
11851 : 305540 : return static_cast<unsigned int> (SymbolKey_GetSymKey (ModuleTree, name));
11852 : : /* static analysis guarentees a RETURN statement will be used before here. */
11853 : : __builtin_unreachable ();
11854 : : }
11855 : :
11856 : :
11857 : : /*
11858 : : GetCurrentModule - returns the current module Sym that is being
11859 : : compiled.
11860 : : */
11861 : :
11862 : 39112796 : extern "C" unsigned int SymbolTable_GetCurrentModule (void)
11863 : : {
11864 : 39112796 : return CurrentModule;
11865 : : /* static analysis guarentees a RETURN statement will be used before here. */
11866 : : __builtin_unreachable ();
11867 : : }
11868 : :
11869 : :
11870 : : /*
11871 : : GetFileModule - returns the FileModule symbol that was requested by
11872 : : the user to be compiled.
11873 : : */
11874 : :
11875 : 228096 : extern "C" unsigned int SymbolTable_GetFileModule (void)
11876 : : {
11877 : 228096 : return FileModule;
11878 : : /* static analysis guarentees a RETURN statement will be used before here. */
11879 : : __builtin_unreachable ();
11880 : : }
11881 : :
11882 : :
11883 : : /*
11884 : : GetBaseModule - returns the base module symbol that contains Modula-2
11885 : : base types, procedures and functions.
11886 : : */
11887 : :
11888 : 5186565 : extern "C" unsigned int SymbolTable_GetBaseModule (void)
11889 : : {
11890 : 5186565 : return BaseModule;
11891 : : /* static analysis guarentees a RETURN statement will be used before here. */
11892 : : __builtin_unreachable ();
11893 : : }
11894 : :
11895 : :
11896 : : /*
11897 : : GetMainModule - returns the main module symbol that was requested by
11898 : : the user to be compiled.
11899 : : */
11900 : :
11901 : 13475978 : extern "C" unsigned int SymbolTable_GetMainModule (void)
11902 : : {
11903 : 13475978 : return MainModule;
11904 : : /* static analysis guarentees a RETURN statement will be used before here. */
11905 : : __builtin_unreachable ();
11906 : : }
11907 : :
11908 : :
11909 : : /*
11910 : : GetCurrentModuleScope - returns the module symbol which forms the
11911 : : current (possibly inner most) module.
11912 : : */
11913 : :
11914 : 1493548 : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void)
11915 : : {
11916 : 1493548 : SymbolTable_PtrToCallFrame pCall;
11917 : 1493548 : unsigned int i;
11918 : :
11919 : 1493548 : i = ScopePtr;
11920 : 1493548 : pCall = GetPcall (i);
11921 : 3588091 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
11922 : : {
11923 : 600995 : M2Debug_Assert (i > 0);
11924 : 600995 : i -= 1;
11925 : 600995 : pCall = GetPcall (i);
11926 : : }
11927 : 1493548 : return pCall->Search;
11928 : : /* static analysis guarentees a RETURN statement will be used before here. */
11929 : : __builtin_unreachable ();
11930 : : }
11931 : :
11932 : :
11933 : : /*
11934 : : GetLastModuleScope - returns the last module scope encountered,
11935 : : the module scope before the Current Module Scope.
11936 : : */
11937 : :
11938 : 0 : extern "C" unsigned int SymbolTable_GetLastModuleScope (void)
11939 : : {
11940 : 0 : SymbolTable_PtrToCallFrame pCall;
11941 : 0 : unsigned int i;
11942 : :
11943 : 0 : i = ScopePtr;
11944 : 0 : pCall = GetPcall (i);
11945 : 0 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
11946 : : {
11947 : 0 : M2Debug_Assert (i > 0);
11948 : 0 : i -= 1;
11949 : 0 : pCall = GetPcall (i);
11950 : : }
11951 : : /* Found module at position, i. */
11952 : 0 : i -= 1; /* Move to an outer level module scope */
11953 : 0 : pCall = GetPcall (i); /* Move to an outer level module scope */
11954 : 0 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
11955 : : {
11956 : 0 : M2Debug_Assert (i > 0);
11957 : 0 : i -= 1;
11958 : 0 : pCall = GetPcall (i);
11959 : : }
11960 : : /* Found module at position, i. */
11961 : 0 : return pCall->Search;
11962 : : /* static analysis guarentees a RETURN statement will be used before here. */
11963 : : __builtin_unreachable ();
11964 : : }
11965 : :
11966 : :
11967 : : /*
11968 : : AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
11969 : : ModSym.
11970 : : */
11971 : :
11972 : 748854 : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym)
11973 : : {
11974 : 748854 : SymbolTable_PtrToSymbol pSym;
11975 : :
11976 : 748854 : pSym = GetPsym (ModSym);
11977 : 748854 : switch (pSym->SymbolType)
11978 : : {
11979 : 634374 : case SymbolTable_DefImpSym:
11980 : 634374 : if ((SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
11981 : : {
11982 : 634374 : SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
11983 : : }
11984 : : else
11985 : : {
11986 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
11987 : : }
11988 : : break;
11989 : :
11990 : 114420 : case SymbolTable_ModuleSym:
11991 : 114420 : if ((SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
11992 : : {
11993 : 114420 : SymbolKey_PutSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
11994 : : }
11995 : : else
11996 : : {
11997 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
11998 : : }
11999 : : break;
12000 : :
12001 : 60 : case SymbolTable_ProcedureSym:
12002 : 60 : if ((SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
12003 : : {
12004 : 60 : SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
12005 : : }
12006 : : else
12007 : : {
12008 : 0 : M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
12009 : : }
12010 : : break;
12011 : :
12012 : :
12013 : 0 : default:
12014 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
12015 : 748854 : break;
12016 : : }
12017 : 748854 : }
12018 : :
12019 : :
12020 : : /*
12021 : : GetType - Returns the symbol that is the TYPE symbol to Sym.
12022 : : If zero is returned then we assume type unknown.
12023 : : */
12024 : :
12025 : 220928998 : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym)
12026 : : {
12027 : 220928998 : SymbolTable_PtrToSymbol pSym;
12028 : 220928998 : unsigned int type;
12029 : :
12030 : 220928998 : M2Debug_Assert (Sym != SymbolTable_NulSym);
12031 : 220928998 : pSym = GetPsym (Sym);
12032 : 220928998 : switch (pSym->SymbolType)
12033 : : {
12034 : 0 : case SymbolTable_OAFamilySym:
12035 : 0 : type = pSym->OAFamily.SimpleType;
12036 : 0 : break;
12037 : :
12038 : 37075501 : case SymbolTable_VarSym:
12039 : 37075501 : type = GetTypeOfVar (Sym);
12040 : 37075501 : break;
12041 : :
12042 : 14406940 : case SymbolTable_ConstLitSym:
12043 : 14406940 : type = pSym->ConstLit.Type;
12044 : 14406940 : break;
12045 : :
12046 : 12722099 : case SymbolTable_ConstVarSym:
12047 : 12722099 : type = pSym->ConstVar.Type;
12048 : 12722099 : break;
12049 : :
12050 : 4974628 : case SymbolTable_ConstStringSym:
12051 : 4974628 : if (pSym->ConstString.Length == 1)
12052 : : {
12053 : 812150 : type = M2Base_Char;
12054 : : }
12055 : : else
12056 : : {
12057 : : type = SymbolTable_NulSym; /* No type for a string */
12058 : : }
12059 : : break;
12060 : :
12061 : 38229103 : case SymbolTable_TypeSym:
12062 : 38229103 : type = pSym->Type.Type;
12063 : 38229103 : break;
12064 : :
12065 : 44580244 : case SymbolTable_RecordFieldSym:
12066 : 44580244 : type = pSym->RecordField.Type;
12067 : 44580244 : break;
12068 : :
12069 : : case SymbolTable_RecordSym:
12070 : : type = SymbolTable_NulSym; /* No type for a record */
12071 : : break;
12072 : :
12073 : : case SymbolTable_VarientSym:
12074 : : type = SymbolTable_NulSym; /* No type for a record */
12075 : : break;
12076 : :
12077 : 16949102 : case SymbolTable_EnumerationFieldSym:
12078 : 16949102 : type = pSym->EnumerationField.Type; /* No type for a record */
12079 : 16949102 : break;
12080 : :
12081 : : case SymbolTable_EnumerationSym:
12082 : : type = SymbolTable_NulSym; /* No type for enumeration */
12083 : : break;
12084 : :
12085 : 15755759 : case SymbolTable_PointerSym:
12086 : 15755759 : type = pSym->Pointer.Type; /* No type for enumeration */
12087 : 15755759 : break;
12088 : :
12089 : 6488540 : case SymbolTable_ProcedureSym:
12090 : 6488540 : type = pSym->Procedure.ReturnType;
12091 : 6488540 : break;
12092 : :
12093 : 2828335 : case SymbolTable_ProcTypeSym:
12094 : 2828335 : type = pSym->ProcType.ReturnType;
12095 : 2828335 : break;
12096 : :
12097 : 13475893 : case SymbolTable_ParamSym:
12098 : 13475893 : type = pSym->Param.Type;
12099 : 13475893 : break;
12100 : :
12101 : 2016314 : case SymbolTable_VarParamSym:
12102 : 2016314 : type = pSym->VarParam.Type;
12103 : 2016314 : break;
12104 : :
12105 : 2771461 : case SymbolTable_SubrangeSym:
12106 : 2771461 : type = pSym->Subrange.Type;
12107 : 2771461 : break;
12108 : :
12109 : 1000556 : case SymbolTable_ArraySym:
12110 : 1000556 : type = pSym->Array.Type;
12111 : 1000556 : break;
12112 : :
12113 : 983038 : case SymbolTable_SubscriptSym:
12114 : 983038 : type = pSym->Subscript.Type;
12115 : 983038 : break;
12116 : :
12117 : 603998 : case SymbolTable_SetSym:
12118 : 603998 : type = pSym->Set.Type;
12119 : 603998 : break;
12120 : :
12121 : 5114283 : case SymbolTable_UnboundedSym:
12122 : 5114283 : type = pSym->Unbounded.Type;
12123 : 5114283 : break;
12124 : :
12125 : : case SymbolTable_UndefinedSym:
12126 : : type = SymbolTable_NulSym;
12127 : : break;
12128 : :
12129 : 0 : case SymbolTable_PartialUnboundedSym:
12130 : 0 : type = pSym->PartialUnbounded.Type;
12131 : 0 : break;
12132 : :
12133 : : case SymbolTable_ObjectSym:
12134 : : type = SymbolTable_NulSym;
12135 : : break;
12136 : :
12137 : :
12138 : 0 : default:
12139 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
12140 : 220928998 : break;
12141 : : }
12142 : 220928998 : return type;
12143 : : /* static analysis guarentees a RETURN statement will be used before here. */
12144 : : __builtin_unreachable ();
12145 : : }
12146 : :
12147 : :
12148 : : /*
12149 : : SkipType - if sym is a TYPE foo = bar
12150 : : then call SkipType(bar)
12151 : : else return sym
12152 : :
12153 : : it does not skip over hidden types.
12154 : : */
12155 : :
12156 : 35718760 : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym)
12157 : : {
12158 : 35955482 : if ((((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
12159 : : {
12160 : 236722 : return SymbolTable_SkipType (SymbolTable_GetType (Sym));
12161 : : }
12162 : : else
12163 : : {
12164 : 35718760 : return Sym;
12165 : : }
12166 : : /* static analysis guarentees a RETURN statement will be used before here. */
12167 : : __builtin_unreachable ();
12168 : : }
12169 : :
12170 : :
12171 : : /*
12172 : : SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
12173 : : sym is declared as a subrange of bar
12174 : : then call SkipTypeAndSubrange(bar)
12175 : : else return sym
12176 : :
12177 : : it does not skip over hidden types.
12178 : : */
12179 : :
12180 : 4300 : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym)
12181 : : {
12182 : 4348 : if ((((Sym != SymbolTable_NulSym) && ((SymbolTable_IsType (Sym)) || (SymbolTable_IsSubrange (Sym)))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
12183 : : {
12184 : 48 : return SymbolTable_SkipTypeAndSubrange (SymbolTable_GetType (Sym));
12185 : : }
12186 : : else
12187 : : {
12188 : 4300 : return Sym;
12189 : : }
12190 : : /* static analysis guarentees a RETURN statement will be used before here. */
12191 : : __builtin_unreachable ();
12192 : : }
12193 : :
12194 : :
12195 : : /*
12196 : : GetLowestType - Returns the lowest type in the type chain of
12197 : : symbol Sym.
12198 : : If NulSym is returned then we assume type unknown or
12199 : : you have reqested the type of a base type.
12200 : : */
12201 : :
12202 : 1265460 : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym)
12203 : : {
12204 : 2194077 : SymbolTable_PtrToSymbol pSym;
12205 : 2194077 : unsigned int type;
12206 : :
12207 : 2194077 : M2Debug_Assert (Sym != SymbolTable_NulSym);
12208 : 2194077 : pSym = GetPsym (Sym);
12209 : 2194077 : switch (pSym->SymbolType)
12210 : : {
12211 : 397722 : case SymbolTable_VarSym:
12212 : 397722 : type = pSym->Var.Type;
12213 : 397722 : break;
12214 : :
12215 : 252552 : case SymbolTable_ConstLitSym:
12216 : 252552 : type = pSym->ConstLit.Type;
12217 : 252552 : break;
12218 : :
12219 : 324205 : case SymbolTable_ConstVarSym:
12220 : 324205 : type = pSym->ConstVar.Type;
12221 : 324205 : break;
12222 : :
12223 : : case SymbolTable_ConstStringSym:
12224 : : type = SymbolTable_NulSym; /* No type for a string */
12225 : : break;
12226 : :
12227 : 951881 : case SymbolTable_TypeSym:
12228 : 951881 : type = pSym->Type.Type; /* No type for a string */
12229 : 951881 : break;
12230 : :
12231 : 0 : case SymbolTable_RecordFieldSym:
12232 : 0 : type = pSym->RecordField.Type;
12233 : 0 : break;
12234 : :
12235 : : case SymbolTable_RecordSym:
12236 : : type = SymbolTable_NulSym; /* No type for a record */
12237 : : break;
12238 : :
12239 : 31713 : case SymbolTable_EnumerationFieldSym:
12240 : 31713 : type = pSym->EnumerationField.Type; /* No type for a record */
12241 : 31713 : break;
12242 : :
12243 : : case SymbolTable_EnumerationSym:
12244 : : type = SymbolTable_NulSym; /* No type for enumeration */
12245 : : break;
12246 : :
12247 : : case SymbolTable_PointerSym:
12248 : 22020 : type = Sym; /* we don't go to Pointer.Type */
12249 : : break;
12250 : :
12251 : 45807 : case SymbolTable_ProcedureSym:
12252 : 45807 : type = pSym->Procedure.ReturnType; /* we don't go to Pointer.Type */
12253 : 45807 : break;
12254 : :
12255 : 12 : case SymbolTable_ProcTypeSym:
12256 : 12 : type = pSym->ProcType.ReturnType;
12257 : 12 : break;
12258 : :
12259 : 117297 : case SymbolTable_ParamSym:
12260 : 117297 : type = pSym->Param.Type;
12261 : 117297 : break;
12262 : :
12263 : 6118 : case SymbolTable_VarParamSym:
12264 : 6118 : type = pSym->VarParam.Type;
12265 : 6118 : break;
12266 : :
12267 : 48 : case SymbolTable_SubrangeSym:
12268 : 48 : type = pSym->Subrange.Type;
12269 : 48 : break;
12270 : :
12271 : 24 : case SymbolTable_ArraySym:
12272 : 24 : type = pSym->Array.Type;
12273 : 24 : break;
12274 : :
12275 : 40986 : case SymbolTable_SubscriptSym:
12276 : 40986 : type = pSym->Subscript.Type;
12277 : 40986 : break;
12278 : :
12279 : : case SymbolTable_SetSym:
12280 : 22020 : type = Sym; /* Stop at the set type. */
12281 : : break;
12282 : :
12283 : 0 : case SymbolTable_UnboundedSym:
12284 : 0 : type = pSym->Unbounded.Type; /* Stop at the set type. */
12285 : 0 : break;
12286 : :
12287 : : case SymbolTable_UndefinedSym:
12288 : : type = SymbolTable_NulSym;
12289 : : break;
12290 : :
12291 : : case SymbolTable_DummySym:
12292 : : type = SymbolTable_NulSym;
12293 : : break;
12294 : :
12295 : :
12296 : 6 : default:
12297 : 6 : M2Error_InternalError ((const char *) "not implemented yet", 19);
12298 : 2194071 : break;
12299 : : }
12300 : 2194071 : pSym = GetPsym (Sym);
12301 : 2194071 : if ((pSym->SymbolType == SymbolTable_TypeSym) && (type == SymbolTable_NulSym))
12302 : : {
12303 : : type = Sym; /* Base Type */
12304 : : }
12305 : 1263310 : else if (((type != SymbolTable_NulSym) && (SymbolTable_IsType (type))) && ((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym))
12306 : : {
12307 : : /* avoid dangling else. */
12308 : : type = SymbolTable_GetLowestType (type); /* Type def */
12309 : : }
12310 : 1265454 : return type;
12311 : : /* static analysis guarentees a RETURN statement will be used before here. */
12312 : : __builtin_unreachable ();
12313 : : }
12314 : :
12315 : :
12316 : : /*
12317 : : GetLType - get lowest type. It returns the lowest type
12318 : : of symbol, sym. It skips over type equivalences.
12319 : : It will not skip over base types.
12320 : : */
12321 : :
12322 : 5843435 : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym)
12323 : : {
12324 : : /*
12325 : : Assert (doGetType (sym, TRUE, TRUE, TRUE, FALSE) = GetLowestType (sym)) ;
12326 : : */
12327 : 5843435 : return doGetType (sym, true, true, true, false);
12328 : : /* static analysis guarentees a RETURN statement will be used before here. */
12329 : : __builtin_unreachable ();
12330 : : }
12331 : :
12332 : :
12333 : : /*
12334 : : GetSType - get source type. It returns the type closest
12335 : : to the object. It does not skip over type
12336 : : equivalences. It will skip over base types.
12337 : : */
12338 : :
12339 : 165997721 : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym)
12340 : : {
12341 : 165997721 : M2Debug_Assert ((doGetType (sym, false, false, false, true)) == (SymbolTable_GetType (sym)));
12342 : 165997721 : return doGetType (sym, false, false, false, true);
12343 : : /* static analysis guarentees a RETURN statement will be used before here. */
12344 : : __builtin_unreachable ();
12345 : : }
12346 : :
12347 : :
12348 : : /*
12349 : : GetDType - get gcc declared type. It returns the type
12350 : : of the object which is declared to GCC.
12351 : : It does skip over type equivalences but only
12352 : : if they do not contain a user alignment.
12353 : : It does not skip over hidden types.
12354 : : It does not skip over base types.
12355 : : */
12356 : :
12357 : 19057454 : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym)
12358 : : {
12359 : : /*
12360 : : Assert (doGetType (sym, TRUE, FALSE, FALSE, FALSE) = SkipType(GetType(sym))) ;
12361 : : */
12362 : 19057454 : return doGetType (sym, true, false, false, false);
12363 : : /* static analysis guarentees a RETURN statement will be used before here. */
12364 : : __builtin_unreachable ();
12365 : : }
12366 : :
12367 : :
12368 : : /*
12369 : : GetTypeMode - return the type of sym, it returns Address is the
12370 : : symbol is a LValue.
12371 : : */
12372 : :
12373 : 16594 : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym)
12374 : : {
12375 : 16594 : if ((SymbolTable_GetMode (sym)) == SymbolTable_LeftValue)
12376 : : {
12377 : 90 : return M2System_Address;
12378 : : }
12379 : : else
12380 : : {
12381 : 16504 : return SymbolTable_GetType (sym);
12382 : : }
12383 : : /* static analysis guarentees a RETURN statement will be used before here. */
12384 : : __builtin_unreachable ();
12385 : : }
12386 : :
12387 : :
12388 : : /*
12389 : : GetSym - searches the current scope (and previous scopes if the
12390 : : scope tranparent allows) for a symbol with name.
12391 : : */
12392 : :
12393 : 41010199 : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name)
12394 : : {
12395 : 41010199 : unsigned int Sym;
12396 : 41010199 : unsigned int OldScopePtr;
12397 : :
12398 : 41010199 : Sym = GetScopeSym (name, true);
12399 : 41010199 : if (Sym == SymbolTable_NulSym)
12400 : : {
12401 : : /* Check default base types for symbol */
12402 : 14482601 : OldScopePtr = ScopePtr; /* Save ScopePtr */
12403 : 14482601 : ScopePtr = BaseScopePtr; /* Alter ScopePtr to point to top of BaseModule */
12404 : 14482601 : Sym = GetScopeSym (name, false); /* Search BaseModule for name */
12405 : 14482601 : ScopePtr = OldScopePtr; /* Restored ScopePtr */
12406 : : }
12407 : 41010199 : return Sym;
12408 : : /* static analysis guarentees a RETURN statement will be used before here. */
12409 : : __builtin_unreachable ();
12410 : : }
12411 : :
12412 : :
12413 : : /*
12414 : : GetDeclareSym - searches for a symbol with a name SymName in the
12415 : : current and previous scopes.
12416 : : If the symbol is found then it is returned
12417 : : else an unknown symbol is returned.
12418 : : This procedure assumes that SymName is being
12419 : : declared at this point and therefore it does
12420 : : not examine the base scope (for pervasive
12421 : : identifiers).
12422 : : */
12423 : :
12424 : 5881867 : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName)
12425 : : {
12426 : 5881867 : unsigned int Sym;
12427 : :
12428 : 5881867 : Sym = GetScopeSym (SymName, false); /* must not be allowed to fetch a symbol through a procedure scope */
12429 : 5881867 : if (Sym == SymbolTable_NulSym) /* must not be allowed to fetch a symbol through a procedure scope */
12430 : : {
12431 : 2344466 : Sym = GetSymFromUnknownTree (SymName);
12432 : 2344466 : if (Sym == SymbolTable_NulSym)
12433 : : {
12434 : : /* Make unknown */
12435 : 2344466 : NewSym (&Sym);
12436 : 2344466 : FillInUnknownFields (tok, Sym, SymName);
12437 : : /*
12438 : : ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
12439 : : */
12440 : 2344466 : AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
12441 : : }
12442 : : }
12443 : 5881867 : return Sym;
12444 : : /* static analysis guarentees a RETURN statement will be used before here. */
12445 : : __builtin_unreachable ();
12446 : : }
12447 : :
12448 : :
12449 : : /*
12450 : : GetLocalSym - only searches the scope Sym for a symbol with name
12451 : : and returns the index to the symbol.
12452 : : */
12453 : :
12454 : 122560881 : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name)
12455 : : {
12456 : 122560881 : SymbolTable_PtrToSymbol pSym;
12457 : 122560881 : unsigned int LocalSym;
12458 : :
12459 : : /*
12460 : : WriteString('Attempting to retrieve symbol from ') ; WriteKey(GetSymName(Sym)) ;
12461 : : WriteString(' local symbol table') ; WriteLn ;
12462 : : */
12463 : 122560881 : pSym = GetPsym (Sym);
12464 : 122560881 : switch (pSym->SymbolType)
12465 : : {
12466 : 30698518 : case SymbolTable_EnumerationSym:
12467 : 30698518 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, name));
12468 : 30698518 : break;
12469 : :
12470 : 546210 : case SymbolTable_RecordSym:
12471 : 546210 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, name));
12472 : 546210 : break;
12473 : :
12474 : 31457579 : case SymbolTable_ProcedureSym:
12475 : 31457579 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, name));
12476 : 31457579 : break;
12477 : :
12478 : 15926198 : case SymbolTable_ModuleSym:
12479 : 15926198 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, name));
12480 : 15926198 : break;
12481 : :
12482 : 43932376 : case SymbolTable_DefImpSym:
12483 : 43932376 : LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, name));
12484 : 43932376 : break;
12485 : :
12486 : :
12487 : 0 : default:
12488 : 0 : M2Error_InternalError ((const char *) "symbol does not have a LocalSymbols field", 41);
12489 : 122560881 : break;
12490 : : }
12491 : 122560881 : return LocalSym;
12492 : : /* static analysis guarentees a RETURN statement will be used before here. */
12493 : : __builtin_unreachable ();
12494 : : }
12495 : :
12496 : :
12497 : : /*
12498 : : GetRecord - fetches the record symbol from the parent of Sym.
12499 : : Sym maybe a varient symbol in which case its parent is searched
12500 : : etc.
12501 : : */
12502 : :
12503 : 31530 : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym)
12504 : : {
12505 : 32310 : SymbolTable_PtrToSymbol pSym;
12506 : :
12507 : 32310 : pSym = GetPsym (Sym);
12508 : 32310 : switch (pSym->SymbolType)
12509 : : {
12510 : : case SymbolTable_RecordSym:
12511 : : return Sym;
12512 : 666 : break;
12513 : :
12514 : 666 : case SymbolTable_VarientSym:
12515 : 666 : return SymbolTable_GetRecord (pSym->Varient.Parent);
12516 : 114 : break;
12517 : :
12518 : 114 : case SymbolTable_VarientFieldSym:
12519 : 114 : return SymbolTable_GetRecord (pSym->VarientField.Parent);
12520 : 0 : break;
12521 : :
12522 : :
12523 : 0 : default:
12524 : 0 : M2Error_InternalError ((const char *) "expecting Record or Varient symbol", 34);
12525 : : break;
12526 : : }
12527 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12528 : : __builtin_unreachable ();
12529 : : }
12530 : :
12531 : :
12532 : : /*
12533 : : FromModuleGetSym - attempts to find a symbol of name, n, in the
12534 : : module, mod, scope. An unknown symbol is created
12535 : : at token position tok if necessary.
12536 : : */
12537 : :
12538 : 4886812 : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod)
12539 : : {
12540 : 4886812 : NameKey_Name n1;
12541 : 4886812 : unsigned int sym;
12542 : 4886812 : unsigned int OldScopePtr;
12543 : :
12544 : 4886812 : OldScopePtr = ScopePtr;
12545 : 4886812 : SymbolTable_StartScope (mod);
12546 : 4886812 : sym = SymbolTable_RequestSym (tok, n);
12547 : 4886812 : SymbolTable_EndScope ();
12548 : 4886812 : if (sym == SymbolTable_NulSym)
12549 : : {
12550 : : /* --fixme-- can sym ever be NulSym? */
12551 : 0 : n1 = SymbolTable_GetSymName (mod);
12552 : 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));
12553 : : }
12554 : 4886812 : ScopePtr = OldScopePtr;
12555 : 4886812 : return sym;
12556 : : /* static analysis guarentees a RETURN statement will be used before here. */
12557 : : __builtin_unreachable ();
12558 : : }
12559 : :
12560 : :
12561 : : /*
12562 : : GetNth - returns the n th symbol in the list associated with the scope
12563 : : of Sym. Sym may be a Module, DefImp, Procedure, Record or
12564 : : Enumeration symbol.
12565 : : */
12566 : :
12567 : 78628460 : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n)
12568 : : {
12569 : 78628460 : SymbolTable_PtrToSymbol pSym;
12570 : 78628460 : unsigned int i;
12571 : :
12572 : 78628460 : pSym = GetPsym (Sym);
12573 : 78628460 : switch (pSym->SymbolType)
12574 : : {
12575 : 54933998 : case SymbolTable_RecordSym:
12576 : 54933998 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, n));
12577 : 54933998 : break;
12578 : :
12579 : 84018 : case SymbolTable_VarientSym:
12580 : 84018 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Varient.ListOfSons, n));
12581 : 84018 : break;
12582 : :
12583 : 161658 : case SymbolTable_VarientFieldSym:
12584 : 161658 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->VarientField.ListOfSons, n));
12585 : 161658 : break;
12586 : :
12587 : 22355977 : case SymbolTable_ProcedureSym:
12588 : 22355977 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.ListOfVars, n));
12589 : 22355977 : break;
12590 : :
12591 : 193415 : case SymbolTable_DefImpSym:
12592 : 193415 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfVars, n));
12593 : 193415 : break;
12594 : :
12595 : 555398 : case SymbolTable_ModuleSym:
12596 : 555398 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfVars, n));
12597 : 555398 : break;
12598 : :
12599 : 39148 : case SymbolTable_TupleSym:
12600 : 39148 : i = GetFromIndex (pSym->Tuple.list, n);
12601 : 39148 : break;
12602 : :
12603 : 304830 : case SymbolTable_VarSym:
12604 : 304830 : i = GetNthFromComponent (Sym, n);
12605 : 304830 : break;
12606 : :
12607 : 18 : case SymbolTable_EnumerationSym:
12608 : 18 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Enumeration.ListOfFields, n));
12609 : 18 : break;
12610 : :
12611 : :
12612 : 0 : default:
12613 : 0 : M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
12614 : 78628460 : break;
12615 : : }
12616 : 78628460 : return i;
12617 : : /* static analysis guarentees a RETURN statement will be used before here. */
12618 : : __builtin_unreachable ();
12619 : : }
12620 : :
12621 : :
12622 : : /*
12623 : : GetNthParam - returns the n th parameter of a procedure Sym.
12624 : : */
12625 : :
12626 : 33564248 : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
12627 : : {
12628 : 33564248 : SymbolTable_PtrToSymbol pSym;
12629 : 33564248 : unsigned int i;
12630 : :
12631 : 33564248 : if (ParamNo == 0)
12632 : : {
12633 : : /* The return type of the function */
12634 : 0 : i = SymbolTable_GetType (Sym);
12635 : : }
12636 : : else
12637 : : {
12638 : 33564248 : pSym = GetPsym (Sym);
12639 : 33564248 : switch (pSym->SymbolType)
12640 : : {
12641 : 28750482 : case SymbolTable_ProcedureSym:
12642 : 28750482 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo));
12643 : 28750482 : break;
12644 : :
12645 : 4813766 : case SymbolTable_ProcTypeSym:
12646 : 4813766 : i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, ParamNo));
12647 : 4813766 : break;
12648 : :
12649 : :
12650 : 0 : default:
12651 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym or ProcTypeSym", 37);
12652 : 33564248 : break;
12653 : : }
12654 : : }
12655 : 33564248 : return i;
12656 : : /* static analysis guarentees a RETURN statement will be used before here. */
12657 : : __builtin_unreachable ();
12658 : : }
12659 : :
12660 : :
12661 : : /*
12662 : : GetVarScope - returns the symbol which is the scope of variable Sym.
12663 : : ie a Module, DefImp or Procedure Symbol.
12664 : : */
12665 : :
12666 : 3562 : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym)
12667 : : {
12668 : 3562 : SymbolTable_PtrToSymbol pSym;
12669 : :
12670 : 3562 : pSym = GetPsym (Sym);
12671 : 3562 : switch (pSym->SymbolType)
12672 : : {
12673 : : case SymbolTable_ErrorSym:
12674 : : return SymbolTable_NulSym;
12675 : 3562 : break;
12676 : :
12677 : 3562 : case SymbolTable_VarSym:
12678 : 3562 : return pSym->Var.Scope;
12679 : 0 : break;
12680 : :
12681 : :
12682 : 0 : default:
12683 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
12684 : : break;
12685 : : }
12686 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12687 : : __builtin_unreachable ();
12688 : : }
12689 : :
12690 : :
12691 : : /*
12692 : : GetSubrange - returns HighSym and LowSym - two constants which make up the
12693 : : subrange.
12694 : : */
12695 : :
12696 : 6544956 : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym)
12697 : : {
12698 : 6544956 : SymbolTable_PtrToSymbol pSym;
12699 : :
12700 : 6544956 : pSym = GetPsym (Sym);
12701 : 6544956 : switch (pSym->SymbolType)
12702 : : {
12703 : 6544956 : case SymbolTable_SubrangeSym:
12704 : 6544956 : (*HighSym) = pSym->Subrange.High;
12705 : 6544956 : (*LowSym) = pSym->Subrange.Low;
12706 : 6544956 : break;
12707 : :
12708 : :
12709 : 0 : default:
12710 : 0 : M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
12711 : 6544956 : break;
12712 : : }
12713 : 6544956 : }
12714 : :
12715 : :
12716 : : /*
12717 : : GetParam - returns the ParamNo parameter from procedure ProcSym
12718 : : */
12719 : :
12720 : 6410087 : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo)
12721 : : {
12722 : 6410087 : AssertInRange (Sym);
12723 : 6410087 : if (ParamNo == 0)
12724 : : {
12725 : : /* Parameter Zero is the return argument for the Function */
12726 : 0 : return SymbolTable_GetType (Sym);
12727 : : }
12728 : : else
12729 : : {
12730 : 6410087 : return SymbolTable_GetNthParamAny (Sym, ParamNo);
12731 : : }
12732 : : /* static analysis guarentees a RETURN statement will be used before here. */
12733 : : __builtin_unreachable ();
12734 : : }
12735 : :
12736 : :
12737 : : /*
12738 : : GetString - returns the contents of the string symbol sym, note that
12739 : : this is not the same as GetName (unless it was a literal).
12740 : : */
12741 : :
12742 : 459173 : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym)
12743 : : {
12744 : 459173 : SymbolTable_PtrToSymbol pSym;
12745 : :
12746 : 459173 : pSym = GetPsym (Sym);
12747 : 459173 : switch (pSym->SymbolType)
12748 : : {
12749 : 459173 : case SymbolTable_ConstStringSym:
12750 : 459173 : if (pSym->ConstString.Known)
12751 : : {
12752 : 459173 : return pSym->ConstString.Contents;
12753 : : }
12754 : : else
12755 : : {
12756 : 0 : M2Error_InternalError ((const char *) "const string contents are unknown", 33);
12757 : : }
12758 : 0 : break;
12759 : :
12760 : :
12761 : 0 : default:
12762 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
12763 : : break;
12764 : : }
12765 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12766 : : __builtin_unreachable ();
12767 : : }
12768 : :
12769 : :
12770 : : /*
12771 : : GetStringLength - returns the length of the string symbol Sym.
12772 : : */
12773 : :
12774 : 926200 : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym)
12775 : : {
12776 : 926200 : SymbolTable_PtrToSymbol pSym;
12777 : :
12778 : 926200 : pSym = GetPsym (sym);
12779 : 926200 : switch (pSym->SymbolType)
12780 : : {
12781 : 926200 : case SymbolTable_ConstStringSym:
12782 : 926200 : if (pSym->ConstString.Known)
12783 : : {
12784 : 926200 : return pSym->ConstString.Length;
12785 : : }
12786 : : else
12787 : : {
12788 : 0 : M2MetaError_MetaErrorT0 (tok, (const char *) "const string contents are unknown", 33);
12789 : 0 : return 0;
12790 : : }
12791 : 0 : break;
12792 : :
12793 : :
12794 : 0 : default:
12795 : 0 : M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
12796 : : break;
12797 : : }
12798 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12799 : : __builtin_unreachable ();
12800 : : }
12801 : :
12802 : :
12803 : : /*
12804 : : GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
12805 : : */
12806 : :
12807 : 18642 : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym)
12808 : : {
12809 : 18642 : SymbolTable_PtrToSymbol pSym;
12810 : :
12811 : 18642 : pSym = GetPsym (Sym);
12812 : 18642 : switch (pSym->SymbolType)
12813 : : {
12814 : 18642 : case SymbolTable_ProcedureSym:
12815 : 18642 : return pSym->Procedure.BuiltinName;
12816 : 0 : break;
12817 : :
12818 : :
12819 : 0 : default:
12820 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12821 : : break;
12822 : : }
12823 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12824 : : __builtin_unreachable ();
12825 : : }
12826 : :
12827 : :
12828 : : /*
12829 : : PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
12830 : : */
12831 : :
12832 : 107780 : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name)
12833 : : {
12834 : 107780 : SymbolTable_PtrToSymbol pSym;
12835 : :
12836 : 107780 : pSym = GetPsym (Sym);
12837 : 107780 : switch (pSym->SymbolType)
12838 : : {
12839 : 107780 : case SymbolTable_ProcedureSym:
12840 : 107780 : pSym->Procedure.BuiltinName = name;
12841 : 107780 : pSym->Procedure.IsBuiltin = true;
12842 : : /* we use the same extra pass method as hidden types for builtins */
12843 : 107780 : SymbolTable_PutHiddenTypeDeclared ();
12844 : 107780 : break;
12845 : :
12846 : :
12847 : 0 : default:
12848 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12849 : 107780 : break;
12850 : : }
12851 : 107780 : }
12852 : :
12853 : :
12854 : : /*
12855 : : IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
12856 : : */
12857 : :
12858 : 919663 : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym)
12859 : : {
12860 : 919663 : SymbolTable_PtrToSymbol pSym;
12861 : :
12862 : 919663 : pSym = GetPsym (Sym);
12863 : 919663 : switch (pSym->SymbolType)
12864 : : {
12865 : 919663 : case SymbolTable_ProcedureSym:
12866 : 919663 : return pSym->Procedure.IsBuiltin;
12867 : 0 : break;
12868 : :
12869 : :
12870 : 0 : default:
12871 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12872 : : break;
12873 : : }
12874 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12875 : : __builtin_unreachable ();
12876 : : }
12877 : :
12878 : :
12879 : : /*
12880 : : PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
12881 : : */
12882 : :
12883 : 0 : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym)
12884 : : {
12885 : 0 : SymbolTable_PtrToSymbol pSym;
12886 : :
12887 : 0 : pSym = GetPsym (Sym);
12888 : 0 : switch (pSym->SymbolType)
12889 : : {
12890 : 0 : case SymbolTable_ProcedureSym:
12891 : 0 : pSym->Procedure.IsInline = true;
12892 : 0 : break;
12893 : :
12894 : :
12895 : 0 : default:
12896 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12897 : 0 : break;
12898 : : }
12899 : 0 : }
12900 : :
12901 : 69112 : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym)
12902 : : {
12903 : 69112 : SymbolTable_PtrToSymbol pSym;
12904 : :
12905 : : /*
12906 : : IsProcedureBuiltin - returns TRUE if this procedure was declared as inlined.
12907 : : */
12908 : 69112 : pSym = GetPsym (Sym);
12909 : 69112 : switch (pSym->SymbolType)
12910 : : {
12911 : 69112 : case SymbolTable_ProcedureSym:
12912 : 69112 : return pSym->Procedure.IsInline;
12913 : 0 : break;
12914 : :
12915 : :
12916 : 0 : default:
12917 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
12918 : : break;
12919 : : }
12920 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12921 : : __builtin_unreachable ();
12922 : : }
12923 : :
12924 : :
12925 : : /*
12926 : : PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
12927 : : sym, indicating that this block as an EXCEPT
12928 : : statement sequence.
12929 : : */
12930 : :
12931 : 222 : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym)
12932 : : {
12933 : 222 : SymbolTable_PtrToSymbol pSym;
12934 : :
12935 : 222 : pSym = GetPsym (sym);
12936 : 222 : switch (pSym->SymbolType)
12937 : : {
12938 : 168 : case SymbolTable_ProcedureSym:
12939 : 168 : pSym->Procedure.ExceptionBlock = true;
12940 : 168 : break;
12941 : :
12942 : 54 : case SymbolTable_ModuleSym:
12943 : 54 : pSym->Module.ExceptionBlock = true;
12944 : 54 : break;
12945 : :
12946 : 0 : case SymbolTable_DefImpSym:
12947 : 0 : pSym->DefImp.ExceptionBlock = true;
12948 : 0 : break;
12949 : :
12950 : :
12951 : 0 : default:
12952 : 0 : M2Error_InternalError ((const char *) "expecting Procedure", 19);
12953 : 222 : break;
12954 : : }
12955 : 222 : }
12956 : :
12957 : :
12958 : : /*
12959 : : HasExceptionBlock - returns a BOOLEAN determining whether
12960 : : module/procedure/defimp, sym, has
12961 : : an EXCEPT statement sequence.
12962 : : */
12963 : :
12964 : 273833 : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym)
12965 : : {
12966 : 273833 : SymbolTable_PtrToSymbol pSym;
12967 : :
12968 : 273833 : pSym = GetPsym (sym);
12969 : 273833 : switch (pSym->SymbolType)
12970 : : {
12971 : 142246 : case SymbolTable_ProcedureSym:
12972 : 142246 : return pSym->Procedure.ExceptionBlock;
12973 : 23273 : break;
12974 : :
12975 : 23273 : case SymbolTable_ModuleSym:
12976 : 23273 : return pSym->Module.ExceptionBlock;
12977 : 108314 : break;
12978 : :
12979 : 108314 : case SymbolTable_DefImpSym:
12980 : 108314 : return pSym->DefImp.ExceptionBlock;
12981 : 0 : break;
12982 : :
12983 : :
12984 : 0 : default:
12985 : 0 : M2Error_InternalError ((const char *) "expecting Procedure", 19);
12986 : : break;
12987 : : }
12988 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
12989 : : __builtin_unreachable ();
12990 : : }
12991 : :
12992 : :
12993 : : /*
12994 : : PutExceptionFinally - sets a BOOLEAN in block module/defimp,
12995 : : sym, indicating that this FINALLY block
12996 : : as an EXCEPT statement sequence.
12997 : : */
12998 : :
12999 : 0 : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym)
13000 : : {
13001 : 0 : SymbolTable_PtrToSymbol pSym;
13002 : :
13003 : 0 : pSym = GetPsym (sym);
13004 : 0 : switch (pSym->SymbolType)
13005 : : {
13006 : 0 : case SymbolTable_ProcedureSym:
13007 : 0 : pSym->Procedure.ExceptionFinally = true;
13008 : 0 : break;
13009 : :
13010 : 0 : case SymbolTable_ModuleSym:
13011 : 0 : pSym->Module.ExceptionFinally = true;
13012 : 0 : break;
13013 : :
13014 : 0 : case SymbolTable_DefImpSym:
13015 : 0 : pSym->DefImp.ExceptionFinally = true;
13016 : 0 : break;
13017 : :
13018 : :
13019 : 0 : default:
13020 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
13021 : 0 : break;
13022 : : }
13023 : 0 : }
13024 : :
13025 : :
13026 : : /*
13027 : : HasExceptionFinally - returns a BOOLEAN determining whether
13028 : : module/defimp, sym, has
13029 : : an EXCEPT statement sequence.
13030 : : */
13031 : :
13032 : 31000 : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym)
13033 : : {
13034 : 31000 : SymbolTable_PtrToSymbol pSym;
13035 : :
13036 : 31000 : pSym = GetPsym (sym);
13037 : 31000 : switch (pSym->SymbolType)
13038 : : {
13039 : 0 : case SymbolTable_ProcedureSym:
13040 : 0 : return pSym->Procedure.ExceptionFinally;
13041 : 23122 : break;
13042 : :
13043 : 23122 : case SymbolTable_ModuleSym:
13044 : 23122 : return pSym->Module.ExceptionFinally;
13045 : 7878 : break;
13046 : :
13047 : 7878 : case SymbolTable_DefImpSym:
13048 : 7878 : return pSym->DefImp.ExceptionFinally;
13049 : 0 : break;
13050 : :
13051 : :
13052 : 0 : default:
13053 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
13054 : : break;
13055 : : }
13056 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13057 : : __builtin_unreachable ();
13058 : : }
13059 : :
13060 : :
13061 : : /*
13062 : : PutVar - gives the VarSym symbol Sym a type Type.
13063 : : */
13064 : :
13065 : 1354797 : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType)
13066 : : {
13067 : 1354797 : SymbolTable_PtrToSymbol pSym;
13068 : :
13069 : 1354797 : pSym = GetPsym (Sym);
13070 : 1354797 : switch (pSym->SymbolType)
13071 : : {
13072 : 497783 : case SymbolTable_VarSym:
13073 : 497783 : pSym->Var.Type = VarType;
13074 : 497783 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), Sym);
13075 : 497783 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), Sym);
13076 : 497783 : break;
13077 : :
13078 : 857014 : case SymbolTable_ConstVarSym:
13079 : 857014 : pSym->ConstVar.Type = VarType;
13080 : 857014 : break;
13081 : :
13082 : :
13083 : 0 : default:
13084 : 0 : M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
13085 : 1354797 : break;
13086 : : }
13087 : 1354797 : }
13088 : :
13089 : :
13090 : : /*
13091 : : PutVarTok - gives the VarSym symbol Sym a type Type at typetok.
13092 : : */
13093 : :
13094 : 6981601 : extern "C" void SymbolTable_PutVarTok (unsigned int Sym, unsigned int VarType, unsigned int typetok)
13095 : : {
13096 : 6981601 : SymbolTable_PtrToSymbol pSym;
13097 : :
13098 : 6981601 : pSym = GetPsym (Sym);
13099 : 6981601 : switch (pSym->SymbolType)
13100 : : {
13101 : 6981589 : case SymbolTable_VarSym:
13102 : 6981589 : pSym->Var.Type = VarType;
13103 : 6981589 : pSym->Var.Declared.TypeTok = typetok;
13104 : 6981589 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), Sym);
13105 : 6981589 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), Sym);
13106 : 6981589 : break;
13107 : :
13108 : 0 : case SymbolTable_ConstVarSym:
13109 : 0 : pSym->ConstVar.Type = VarType;
13110 : 0 : break;
13111 : :
13112 : :
13113 : 12 : default:
13114 : 12 : M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
13115 : 6981589 : break;
13116 : : }
13117 : 6981589 : }
13118 : :
13119 : :
13120 : : /*
13121 : : PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
13122 : : The variable must be a LeftValue.
13123 : : */
13124 : :
13125 : 62628 : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType)
13126 : : {
13127 : 62628 : SymbolTable_PtrToSymbol pSym;
13128 : :
13129 : 62628 : M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue);
13130 : 62628 : pSym = GetPsym (Sym);
13131 : 62628 : switch (pSym->SymbolType)
13132 : : {
13133 : 62628 : case SymbolTable_VarSym:
13134 : 62628 : pSym->Var.Type = FrontType;
13135 : 62628 : pSym->Var.BackType = BackType;
13136 : 62628 : SymbolTable_PushSize (M2System_Address);
13137 : 62628 : M2ALU_PopInto (pSym->Var.Size);
13138 : 62628 : break;
13139 : :
13140 : :
13141 : 0 : default:
13142 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
13143 : 62628 : break;
13144 : : }
13145 : 62628 : }
13146 : :
13147 : :
13148 : : /*
13149 : : GetVarBackEndType - returns the back end type if specified.
13150 : : */
13151 : :
13152 : 935410 : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym)
13153 : : {
13154 : 935410 : SymbolTable_PtrToSymbol pSym;
13155 : :
13156 : 935410 : M2Debug_Assert (Sym != SymbolTable_NulSym);
13157 : 935410 : pSym = GetPsym (Sym);
13158 : 935410 : switch (pSym->SymbolType)
13159 : : {
13160 : 935410 : case SymbolTable_VarSym:
13161 : 935410 : return pSym->Var.BackType;
13162 : : break;
13163 : :
13164 : :
13165 : : default:
13166 : : return SymbolTable_NulSym;
13167 : : break;
13168 : : }
13169 : : /* static analysis guarentees a RETURN statement will be used before here. */
13170 : : __builtin_unreachable ();
13171 : : }
13172 : :
13173 : :
13174 : : /*
13175 : : PutVarPointerCheck - marks variable, sym, as requiring (or not
13176 : : depending upon the, value), a NIL pointer check
13177 : : when this symbol is dereferenced.
13178 : : */
13179 : :
13180 : 28008 : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value)
13181 : : {
13182 : 28008 : SymbolTable_PtrToSymbol pSym;
13183 : :
13184 : 28008 : if (SymbolTable_IsVar (sym))
13185 : : {
13186 : 28002 : pSym = GetPsym (sym);
13187 : 28002 : pSym->Var.IsPointerCheck = value;
13188 : : }
13189 : 28008 : }
13190 : :
13191 : :
13192 : : /*
13193 : : GetVarPointerCheck - returns TRUE if this symbol is a variable and
13194 : : has been marked as needing a pointer via NIL check.
13195 : : */
13196 : :
13197 : 64735 : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym)
13198 : : {
13199 : 64735 : SymbolTable_PtrToSymbol pSym;
13200 : :
13201 : 64735 : if (SymbolTable_IsVar (sym))
13202 : : {
13203 : 64735 : pSym = GetPsym (sym);
13204 : 64735 : return pSym->Var.IsPointerCheck;
13205 : : }
13206 : : return false;
13207 : : /* static analysis guarentees a RETURN statement will be used before here. */
13208 : : __builtin_unreachable ();
13209 : : }
13210 : :
13211 : :
13212 : : /*
13213 : : PutVarWritten - marks variable, sym, as being written to (or not
13214 : : depending upon the, value).
13215 : : */
13216 : :
13217 : 12024 : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value)
13218 : : {
13219 : 12024 : SymbolTable_PtrToSymbol pSym;
13220 : :
13221 : 12024 : if (SymbolTable_IsVar (sym))
13222 : : {
13223 : 12024 : pSym = GetPsym (sym);
13224 : 12024 : pSym->Var.IsWritten = value;
13225 : : }
13226 : 12024 : }
13227 : :
13228 : :
13229 : : /*
13230 : : GetVarWritten - returns TRUE if this symbol is a variable and
13231 : : has been marked as being written.
13232 : : */
13233 : :
13234 : 75257 : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym)
13235 : : {
13236 : 75257 : SymbolTable_PtrToSymbol pSym;
13237 : :
13238 : 75257 : pSym = GetPsym (sym);
13239 : 75257 : switch (pSym->SymbolType)
13240 : : {
13241 : 75257 : case SymbolTable_VarSym:
13242 : 75257 : return pSym->Var.IsWritten;
13243 : 0 : break;
13244 : :
13245 : :
13246 : 0 : default:
13247 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
13248 : : break;
13249 : : }
13250 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13251 : : __builtin_unreachable ();
13252 : : }
13253 : :
13254 : :
13255 : : /*
13256 : : PutConst - gives the constant symbol Sym a type ConstType.
13257 : : */
13258 : :
13259 : 300044 : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType)
13260 : : {
13261 : 300044 : SymbolTable_PtrToSymbol pSym;
13262 : :
13263 : 300044 : pSym = GetPsym (Sym);
13264 : 300044 : CheckBreak (Sym);
13265 : 300044 : switch (pSym->SymbolType)
13266 : : {
13267 : 300044 : case SymbolTable_ConstVarSym:
13268 : 300044 : pSym->ConstVar.Type = ConstType;
13269 : 300044 : break;
13270 : :
13271 : :
13272 : 0 : default:
13273 : 0 : M2Error_InternalError ((const char *) "expecting ConstVarSym", 21);
13274 : 300044 : break;
13275 : : }
13276 : 300044 : }
13277 : :
13278 : :
13279 : : /*
13280 : : PutConstSet - informs the const var symbol, sym, that it is or will contain
13281 : : a set value.
13282 : : */
13283 : :
13284 : 33562 : extern "C" void SymbolTable_PutConstSet (unsigned int Sym)
13285 : : {
13286 : 33562 : SymbolTable_PtrToSymbol pSym;
13287 : :
13288 : 33562 : pSym = GetPsym (Sym);
13289 : 33562 : switch (pSym->SymbolType)
13290 : : {
13291 : 33562 : case SymbolTable_ConstVarSym:
13292 : 33562 : pSym->ConstVar.IsSet = true;
13293 : 33562 : break;
13294 : :
13295 : 0 : case SymbolTable_ConstLitSym:
13296 : 0 : pSym->ConstLit.IsSet = true;
13297 : 0 : break;
13298 : :
13299 : :
13300 : 0 : default:
13301 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar symbol", 25);
13302 : 33562 : break;
13303 : : }
13304 : 33562 : }
13305 : :
13306 : :
13307 : : /*
13308 : : IsConstSet - returns TRUE if the constant is declared as a set.
13309 : : */
13310 : :
13311 : 39027851 : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym)
13312 : : {
13313 : 39027851 : SymbolTable_PtrToSymbol pSym;
13314 : :
13315 : 39027851 : pSym = GetPsym (Sym);
13316 : 39027851 : switch (pSym->SymbolType)
13317 : : {
13318 : 6938238 : case SymbolTable_ConstVarSym:
13319 : 6938238 : return pSym->ConstVar.IsSet;
13320 : 12483212 : break;
13321 : :
13322 : 12483212 : case SymbolTable_ConstLitSym:
13323 : 12483212 : return pSym->ConstLit.IsSet;
13324 : : break;
13325 : :
13326 : :
13327 : : default:
13328 : : return false;
13329 : : break;
13330 : : }
13331 : : /* static analysis guarentees a RETURN statement will be used before here. */
13332 : : __builtin_unreachable ();
13333 : : }
13334 : :
13335 : :
13336 : : /*
13337 : : PutConstructor - informs the const var symbol, sym, that it is or
13338 : : will contain a constructor (record, set or array)
13339 : : value.
13340 : : */
13341 : :
13342 : 26768 : extern "C" void SymbolTable_PutConstructor (unsigned int Sym)
13343 : : {
13344 : 26768 : SymbolTable_PtrToSymbol pSym;
13345 : :
13346 : 26768 : pSym = GetPsym (Sym);
13347 : 26768 : switch (pSym->SymbolType)
13348 : : {
13349 : 26768 : case SymbolTable_ConstVarSym:
13350 : 26768 : pSym->ConstVar.IsConstructor = true;
13351 : 26768 : break;
13352 : :
13353 : 0 : case SymbolTable_ConstLitSym:
13354 : 0 : pSym->ConstLit.IsConstructor = true;
13355 : 0 : break;
13356 : :
13357 : :
13358 : 0 : default:
13359 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
13360 : 26768 : break;
13361 : : }
13362 : 26768 : }
13363 : :
13364 : :
13365 : : /*
13366 : : PutConstructorFrom - sets the from type field in constructor,
13367 : : Sym, to, from.
13368 : : */
13369 : :
13370 : 22258 : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from)
13371 : : {
13372 : 22258 : SymbolTable_PtrToSymbol pSym;
13373 : :
13374 : 22258 : pSym = GetPsym (Sym);
13375 : 22258 : switch (pSym->SymbolType)
13376 : : {
13377 : 22258 : case SymbolTable_ConstVarSym:
13378 : 22258 : pSym->ConstVar.FromType = from;
13379 : 22258 : pSym->ConstVar.UnresFromType = true;
13380 : 22258 : break;
13381 : :
13382 : 0 : case SymbolTable_ConstLitSym:
13383 : 0 : pSym->ConstLit.FromType = from;
13384 : 0 : pSym->ConstLit.UnresFromType = true;
13385 : 0 : break;
13386 : :
13387 : :
13388 : 0 : default:
13389 : 0 : M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
13390 : 22258 : break;
13391 : : }
13392 : 22258 : Lists_IncludeItemIntoList (UnresolvedConstructorType, Sym);
13393 : 22258 : }
13394 : :
13395 : :
13396 : : /*
13397 : : PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
13398 : : VarSym is a optional varient symbol which can be returned
13399 : : by a call to GetVarient(fieldsymbol). The created field
13400 : : is returned.
13401 : : */
13402 : :
13403 : 329356 : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym)
13404 : : {
13405 : 329356 : SymbolTable_PtrToSymbol oSym;
13406 : 329356 : SymbolTable_PtrToSymbol pSym;
13407 : 329356 : unsigned int esym;
13408 : 329356 : unsigned int ParSym;
13409 : 329356 : unsigned int SonSym;
13410 : :
13411 : 329356 : NewSym (&SonSym); /* Cannot be used before declared since use occurs */
13412 : : /* ensure that it is connected its parent. */
13413 : 329356 : pSym = GetPsym (Sym);
13414 : 329356 : switch (pSym->SymbolType)
13415 : : {
13416 : 328690 : case SymbolTable_RecordSym:
13417 : 328690 : Lists_PutItemIntoList (pSym->Record.ListOfSons, SonSym);
13418 : 328690 : M2Debug_Assert (Lists_IsItemInList (pSym->Record.ListOfSons, SonSym));
13419 : : /* Ensure that the Field is in the Parents Local Symbols */
13420 : 328690 : if (FieldName != NameKey_NulName)
13421 : : {
13422 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
13423 : 328660 : if ((SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName)) == SymbolKey_NulKey)
13424 : : {
13425 : 328660 : SymbolKey_PutSymKey (pSym->Record.LocalSymbols, FieldName, SonSym);
13426 : : }
13427 : : else
13428 : : {
13429 : 0 : esym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName));
13430 : 0 : M2MetaError_MetaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, esym);
13431 : : }
13432 : : }
13433 : : CheckRecordConsistency (Sym);
13434 : : break;
13435 : :
13436 : 666 : case SymbolTable_VarientFieldSym:
13437 : 666 : Lists_PutItemIntoList (pSym->VarientField.ListOfSons, SonSym);
13438 : 666 : ParSym = SymbolTable_GetRecord (pSym->VarientField.Parent);
13439 : 666 : oSym = GetPsym (ParSym);
13440 : 666 : M2Debug_Assert (oSym->SymbolType == SymbolTable_RecordSym);
13441 : 666 : if (FieldName != NameKey_NulName)
13442 : : {
13443 : 654 : oSym = GetPsym (ParSym);
13444 : 654 : SymbolKey_PutSymKey (oSym->Record.LocalSymbols, FieldName, SonSym);
13445 : : }
13446 : : break;
13447 : :
13448 : :
13449 : 0 : default:
13450 : 0 : M2Error_InternalError ((const char *) "expecting Record symbol", 23);
13451 : 329356 : break;
13452 : : }
13453 : : /* Fill in SonSym */
13454 : 329356 : oSym = GetPsym (SonSym);
13455 : 329356 : oSym->SymbolType = SymbolTable_RecordFieldSym;
13456 : 329356 : oSym->RecordField.Type = FieldType;
13457 : 329356 : oSym->RecordField.name = FieldName;
13458 : 329356 : oSym->RecordField.Tag = false;
13459 : 329356 : oSym->RecordField.Parent = Sym;
13460 : 329356 : oSym->RecordField.Varient = VarSym;
13461 : 329356 : oSym->RecordField.Align = SymbolTable_NulSym;
13462 : 329356 : oSym->RecordField.Used = true;
13463 : 329356 : oSym->RecordField.DeclPacked = false; /* not known as packed (yet). */
13464 : 329356 : oSym->RecordField.DeclResolved = false; /* not known as packed (yet). */
13465 : 329356 : oSym->RecordField.Scope = SymbolTable_GetScope (Sym);
13466 : 329356 : oSym->RecordField.Size = M2ALU_InitValue ();
13467 : 329356 : oSym->RecordField.Offset = M2ALU_InitValue ();
13468 : 329356 : InitWhereDeclared (&oSym->RecordField.At);
13469 : 329356 : return SonSym;
13470 : : /* static analysis guarentees a RETURN statement will be used before here. */
13471 : : __builtin_unreachable ();
13472 : : }
13473 : :
13474 : :
13475 : : /*
13476 : : PutFieldVarient - places the field varient, Field, as a brother to, the
13477 : : varient symbol, sym, and also tells Field that its varient
13478 : : parent is Sym.
13479 : : */
13480 : :
13481 : 1236 : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym)
13482 : : {
13483 : 1236 : SymbolTable_PtrToSymbol pSym;
13484 : :
13485 : 1236 : M2Debug_Assert (SymbolTable_IsVarient (Sym));
13486 : 1236 : M2Debug_Assert (SymbolTable_IsFieldVarient (Field));
13487 : 1236 : pSym = GetPsym (Sym);
13488 : 1236 : switch (pSym->SymbolType)
13489 : : {
13490 : 1236 : case SymbolTable_VarientSym:
13491 : 1236 : Lists_IncludeItemIntoList (pSym->Varient.ListOfSons, Field);
13492 : 1236 : break;
13493 : :
13494 : :
13495 : 0 : default:
13496 : 0 : M2Error_InternalError ((const char *) "expecting Varient symbol", 24);
13497 : 1236 : break;
13498 : : }
13499 : 1236 : pSym = GetPsym (Field);
13500 : 1236 : switch (pSym->SymbolType)
13501 : : {
13502 : 1236 : case SymbolTable_VarientFieldSym:
13503 : 1236 : pSym->VarientField.Varient = Sym;
13504 : 1236 : break;
13505 : :
13506 : :
13507 : 0 : default:
13508 : 0 : M2Error_InternalError ((const char *) "expecting VarientField symbol", 29);
13509 : 1236 : break;
13510 : : }
13511 : 1236 : }
13512 : :
13513 : :
13514 : : /*
13515 : : GetVarient - returns the varient symbol associated with the
13516 : : record or varient field symbol, Field.
13517 : : */
13518 : :
13519 : 41320744 : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field)
13520 : : {
13521 : 41320744 : SymbolTable_PtrToSymbol pSym;
13522 : :
13523 : 41320744 : pSym = GetPsym (Field);
13524 : 41320744 : switch (pSym->SymbolType)
13525 : : {
13526 : 0 : case SymbolTable_VarientFieldSym:
13527 : 0 : return pSym->VarientField.Varient;
13528 : 41309332 : break;
13529 : :
13530 : 41309332 : case SymbolTable_RecordFieldSym:
13531 : 41309332 : return pSym->RecordField.Varient;
13532 : 11412 : break;
13533 : :
13534 : 11412 : case SymbolTable_VarientSym:
13535 : 11412 : return pSym->Varient.Varient;
13536 : : break;
13537 : :
13538 : :
13539 : : default:
13540 : : return SymbolTable_NulSym;
13541 : : break;
13542 : : }
13543 : : /* static analysis guarentees a RETURN statement will be used before here. */
13544 : : __builtin_unreachable ();
13545 : : }
13546 : :
13547 : :
13548 : : /*
13549 : : IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
13550 : : a varient tag.
13551 : : */
13552 : :
13553 : 2526382 : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym)
13554 : : {
13555 : 2526382 : SymbolTable_PtrToSymbol pSym;
13556 : :
13557 : 2526382 : if (SymbolTable_IsRecordField (sym))
13558 : : {
13559 : 2526382 : pSym = GetPsym (sym);
13560 : 2526382 : return pSym->RecordField.Tag;
13561 : : }
13562 : : else
13563 : : {
13564 : 0 : M2Error_InternalError ((const char *) "record field symbol expected", 28);
13565 : : }
13566 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13567 : : __builtin_unreachable ();
13568 : : }
13569 : :
13570 : :
13571 : : /*
13572 : : IsEmptyFieldVarient - returns TRUE if the field variant has
13573 : : no fields. This will occur then the
13574 : : compiler constructs 'else end' variants.
13575 : : */
13576 : :
13577 : 0 : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym)
13578 : : {
13579 : 0 : SymbolTable_PtrToSymbol pSym;
13580 : :
13581 : 0 : pSym = GetPsym (sym);
13582 : 0 : switch (pSym->SymbolType)
13583 : : {
13584 : 0 : case SymbolTable_VarientFieldSym:
13585 : 0 : return (Lists_NoOfItemsInList (pSym->VarientField.ListOfSons)) == 0;
13586 : 0 : break;
13587 : :
13588 : :
13589 : 0 : default:
13590 : 0 : M2Error_InternalError ((const char *) "varient field symbol expected", 29);
13591 : : break;
13592 : : }
13593 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13594 : : __builtin_unreachable ();
13595 : : }
13596 : :
13597 : :
13598 : : /*
13599 : : GetVarientTag - returns the varient tag from, Sym.
13600 : : */
13601 : :
13602 : 768 : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym)
13603 : : {
13604 : 768 : SymbolTable_PtrToSymbol pSym;
13605 : :
13606 : 768 : pSym = GetPsym (Sym);
13607 : 768 : switch (pSym->SymbolType)
13608 : : {
13609 : 768 : case SymbolTable_VarientSym:
13610 : 768 : return pSym->Varient.tag;
13611 : 0 : break;
13612 : :
13613 : :
13614 : 0 : default:
13615 : 0 : M2Error_InternalError ((const char *) "varient symbol expected", 23);
13616 : : break;
13617 : : }
13618 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13619 : : __builtin_unreachable ();
13620 : : }
13621 : :
13622 : :
13623 : : /*
13624 : : PutVarientTag - places, Tag, into varient, Sym.
13625 : : */
13626 : :
13627 : 276 : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag)
13628 : : {
13629 : 276 : SymbolTable_PtrToSymbol pSym;
13630 : 276 : unsigned int parent;
13631 : :
13632 : 276 : pSym = GetPsym (Sym);
13633 : 276 : switch (pSym->SymbolType)
13634 : : {
13635 : 276 : case SymbolTable_VarientSym:
13636 : 276 : pSym->Varient.tag = Tag;
13637 : 276 : break;
13638 : :
13639 : :
13640 : 0 : default:
13641 : 0 : M2Error_InternalError ((const char *) "varient symbol expected", 23);
13642 : 276 : break;
13643 : : }
13644 : : /* now ensure that if Tag is a RecordField then it must be
13645 : : placed before the varient symbol in its parent ListOfSons.
13646 : : This allows M2GCCDeclare to declare record fields in order
13647 : : and preserve the order of fields. Otherwise it will add the
13648 : : tag field after the C union. */
13649 : 276 : if (SymbolTable_IsRecordField (Tag))
13650 : : {
13651 : 264 : pSym = GetPsym (Tag);
13652 : 264 : pSym->RecordField.Tag = true;
13653 : 264 : parent = SymbolTable_GetParent (Sym);
13654 : 264 : pSym = GetPsym (parent);
13655 : 264 : switch (pSym->SymbolType)
13656 : : {
13657 : : case SymbolTable_ErrorSym:
13658 : : break;
13659 : :
13660 : 0 : case SymbolTable_VarientSym:
13661 : 0 : EnsureOrder (pSym->Varient.ListOfSons, Tag, Sym);
13662 : 0 : break;
13663 : :
13664 : 36 : case SymbolTable_VarientFieldSym:
13665 : 36 : EnsureOrder (pSym->VarientField.ListOfSons, Tag, Sym);
13666 : 36 : break;
13667 : :
13668 : 228 : case SymbolTable_RecordSym:
13669 : 228 : EnsureOrder (pSym->Record.ListOfSons, Tag, Sym);
13670 : 228 : CheckRecordConsistency (parent);
13671 : 228 : break;
13672 : :
13673 : :
13674 : 0 : default:
13675 : 0 : M2Error_InternalError ((const char *) "not expecting this symbol type", 30);
13676 : : break;
13677 : : }
13678 : : }
13679 : 276 : }
13680 : :
13681 : :
13682 : : /*
13683 : : PutFieldEnumeration - places a field into the enumeration type
13684 : : Sym. The field has a name FieldName and a
13685 : : value FieldVal.
13686 : : */
13687 : :
13688 : 455038 : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName)
13689 : : {
13690 : 455038 : SymbolTable_PtrToSymbol oSym;
13691 : 455038 : SymbolTable_PtrToSymbol pSym;
13692 : 455038 : DynamicStrings_String s;
13693 : 455038 : unsigned int Field;
13694 : :
13695 : 455038 : Field = CheckForHiddenType (FieldName);
13696 : 455038 : if (Field == SymbolTable_NulSym)
13697 : : {
13698 : 455038 : Field = DeclareSym (tok, FieldName);
13699 : : }
13700 : 455038 : if (! (SymbolTable_IsError (Field)))
13701 : : {
13702 : 455032 : pSym = GetPsym (Field);
13703 : 455032 : pSym->SymbolType = SymbolTable_EnumerationFieldSym;
13704 : 455032 : pSym->EnumerationField.name = FieldName; /* Index into name array, name */
13705 : : /* of type. */
13706 : 455032 : oSym = GetPsym (Sym);
13707 : 455032 : M2ALU_PushCard (oSym->Enumeration.NoOfElements);
13708 : 455032 : pSym->EnumerationField.Value = M2ALU_InitValue ();
13709 : 455032 : M2ALU_PopInto (pSym->EnumerationField.Value);
13710 : 455032 : pSym->EnumerationField.Type = Sym;
13711 : 455032 : pSym->EnumerationField.Scope = SymbolTable_GetCurrentScope ();
13712 : 455032 : InitWhereDeclaredTok (tok, &pSym->EnumerationField.At); /* Declared here */
13713 : 455032 : pSym = GetPsym (Sym);
13714 : 455032 : switch (pSym->SymbolType)
13715 : : {
13716 : 455032 : case SymbolTable_EnumerationSym:
13717 : 455032 : pSym->Enumeration.NoOfElements += 1;
13718 : 455032 : if ((SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, FieldName)) != SymbolTable_NulSym)
13719 : : {
13720 : 0 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (FieldName)));
13721 : 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)));
13722 : : }
13723 : : else
13724 : : {
13725 : 455032 : SymbolKey_PutSymKey (pSym->Enumeration.LocalSymbols, FieldName, Field);
13726 : 455032 : Lists_IncludeItemIntoList (pSym->Enumeration.ListOfFields, Field);
13727 : : }
13728 : : break;
13729 : :
13730 : :
13731 : 0 : default:
13732 : 0 : M2Error_InternalError ((const char *) "expecting Sym=Enumeration", 25);
13733 : : break;
13734 : : }
13735 : : }
13736 : 455038 : }
13737 : :
13738 : :
13739 : : /*
13740 : : PutSubrange - places LowSym and HighSym as two symbols
13741 : : which provide the limits of the range.
13742 : : */
13743 : :
13744 : 170194 : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol)
13745 : : {
13746 : 170194 : SymbolTable_PtrToSymbol pSym;
13747 : :
13748 : 170194 : pSym = GetPsym (Sym);
13749 : 170194 : switch (pSym->SymbolType)
13750 : : {
13751 : 170194 : case SymbolTable_SubrangeSym:
13752 : 170194 : pSym->Subrange.Low = LowSym; /* Index to symbol for lower */
13753 : 170194 : pSym->Subrange.High = HighSym; /* Index to symbol for higher */
13754 : 170194 : pSym->Subrange.Type = TypeSymbol; /* Index to type symbol for */
13755 : 170194 : break;
13756 : :
13757 : :
13758 : 0 : default:
13759 : : /* the type of subrange. */
13760 : 0 : M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
13761 : 170194 : break;
13762 : : }
13763 : 170194 : }
13764 : :
13765 : :
13766 : : /*
13767 : : PutSet - places SimpleType as the type for set, Sym.
13768 : : */
13769 : :
13770 : 62938 : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed)
13771 : : {
13772 : 62938 : SymbolTable_PtrToSymbol pSym;
13773 : :
13774 : 62938 : pSym = GetPsym (Sym);
13775 : 62938 : switch (pSym->SymbolType)
13776 : : {
13777 : : case SymbolTable_ErrorSym:
13778 : : break;
13779 : :
13780 : 62938 : case SymbolTable_SetSym:
13781 : 62938 : pSym->Set.Type = SimpleType; /* Index to a subrange symbol */
13782 : : /* or an enumeration type. */
13783 : 62938 : pSym->Set.ispacked = packed;
13784 : 62938 : break;
13785 : :
13786 : :
13787 : 0 : default:
13788 : 0 : M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
13789 : 62938 : break;
13790 : : }
13791 : 62938 : }
13792 : :
13793 : :
13794 : : /*
13795 : : IsSetPacked - returns TRUE if Sym is packed.
13796 : : */
13797 : :
13798 : 1826 : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym)
13799 : : {
13800 : 1826 : SymbolTable_PtrToSymbol pSym;
13801 : :
13802 : 1826 : AssertInRange (Sym);
13803 : 1826 : pSym = GetPsym (Sym);
13804 : 1826 : return (pSym->SymbolType == SymbolTable_SetSym) && pSym->Set.ispacked;
13805 : : /* static analysis guarentees a RETURN statement will be used before here. */
13806 : : __builtin_unreachable ();
13807 : : }
13808 : :
13809 : :
13810 : : /*
13811 : : GetArraySubscript - returns the subscript symbol for array, Sym.
13812 : : */
13813 : :
13814 : 1141242 : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym)
13815 : : {
13816 : 1141242 : SymbolTable_PtrToSymbol pSym;
13817 : :
13818 : 1141242 : pSym = GetPsym (Sym);
13819 : 1141242 : switch (pSym->SymbolType)
13820 : : {
13821 : : case SymbolTable_ErrorSym:
13822 : : return SymbolTable_NulSym;
13823 : 1141242 : break;
13824 : :
13825 : 1141242 : case SymbolTable_ArraySym:
13826 : 1141242 : return pSym->Array.Subscript;
13827 : 0 : break;
13828 : :
13829 : :
13830 : 0 : default:
13831 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
13832 : : break;
13833 : : }
13834 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13835 : : __builtin_unreachable ();
13836 : : }
13837 : :
13838 : :
13839 : : /*
13840 : : PutArraySubscript - places an index field into the array Sym. The
13841 : : index field is a subscript sym.
13842 : : */
13843 : :
13844 : 88058 : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol)
13845 : : {
13846 : 88058 : SymbolTable_PtrToSymbol pSym;
13847 : :
13848 : 88058 : pSym = GetPsym (Sym);
13849 : 88058 : switch (pSym->SymbolType)
13850 : : {
13851 : : case SymbolTable_ErrorSym:
13852 : : break;
13853 : :
13854 : 88058 : case SymbolTable_ArraySym:
13855 : 88058 : pSym->Array.Subscript = SubscriptSymbol;
13856 : 88058 : break;
13857 : :
13858 : :
13859 : 0 : default:
13860 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
13861 : 88058 : break;
13862 : : }
13863 : 88058 : }
13864 : :
13865 : :
13866 : : /*
13867 : : PutType - gives a type symbol Sym type TypeSymbol.
13868 : : */
13869 : :
13870 : 611478 : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol)
13871 : : {
13872 : 611478 : SymbolTable_PtrToSymbol pSym;
13873 : :
13874 : 611478 : if (TypeSymbol == Sym)
13875 : : {
13876 : 0 : M2Error_InternalError ((const char *) "not expecting a type to be declared as itself", 45);
13877 : : }
13878 : 611478 : pSym = GetPsym (Sym);
13879 : 611478 : switch (pSym->SymbolType)
13880 : : {
13881 : : case SymbolTable_ErrorSym:
13882 : : break;
13883 : :
13884 : 611478 : case SymbolTable_TypeSym:
13885 : 611478 : pSym->Type.Type = TypeSymbol;
13886 : 611478 : break;
13887 : :
13888 : :
13889 : 0 : default:
13890 : 0 : M2Error_InternalError ((const char *) "expecting a Type symbol", 23);
13891 : 611478 : break;
13892 : : }
13893 : 611478 : }
13894 : :
13895 : :
13896 : : /*
13897 : : PutFunction - Places a TypeSym as the return type to a procedure Sym.
13898 : : */
13899 : :
13900 : 4363762 : extern "C" void SymbolTable_PutFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym)
13901 : : {
13902 : 8719998 : SymbolTable_PtrToSymbol pSym;
13903 : :
13904 : 8719998 : pSym = GetPsym (Sym);
13905 : 8719998 : switch (pSym->SymbolType)
13906 : : {
13907 : : case SymbolTable_ErrorSym:
13908 : : break;
13909 : :
13910 : 4356236 : case SymbolTable_ProcedureSym:
13911 : 4356236 : pSym->Procedure.ReturnType = TypeSym;
13912 : 4356236 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
13913 : 4356236 : SymbolTable_PutFunction (tok, pSym->Procedure.ProcedureType, kind, TypeSym);
13914 : 4356236 : break;
13915 : :
13916 : 4363762 : case SymbolTable_ProcTypeSym:
13917 : 4363762 : pSym->ProcType.ReturnType = TypeSym;
13918 : 4363762 : pSym->ProcType.ReturnTypeTok = tok;
13919 : 4363762 : break;
13920 : :
13921 : :
13922 : 0 : default:
13923 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
13924 : 4363762 : break;
13925 : : }
13926 : 4363762 : }
13927 : :
13928 : :
13929 : : /*
13930 : : PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
13931 : : */
13932 : :
13933 : 124964 : extern "C" void SymbolTable_PutOptFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym)
13934 : : {
13935 : 249928 : SymbolTable_PtrToSymbol pSym;
13936 : :
13937 : 249928 : pSym = GetPsym (Sym);
13938 : 249928 : switch (pSym->SymbolType)
13939 : : {
13940 : : case SymbolTable_ErrorSym:
13941 : : break;
13942 : :
13943 : 124964 : case SymbolTable_ProcedureSym:
13944 : 124964 : pSym->Procedure.ReturnType = TypeSym;
13945 : 124964 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional = true;
13946 : 124964 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
13947 : 124964 : SymbolTable_PutOptFunction (tok, pSym->Procedure.ProcedureType, kind, TypeSym);
13948 : 124964 : break;
13949 : :
13950 : 124964 : case SymbolTable_ProcTypeSym:
13951 : 124964 : pSym->ProcType.ReturnType = TypeSym;
13952 : 124964 : pSym->ProcType.ReturnTypeTok = tok;
13953 : 124964 : break;
13954 : :
13955 : :
13956 : 0 : default:
13957 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
13958 : 124964 : break;
13959 : : }
13960 : 124964 : }
13961 : :
13962 : :
13963 : : /*
13964 : : IsReturnOptional - returns TRUE if the return value for, sym, is
13965 : : optional.
13966 : : */
13967 : :
13968 : 556973 : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind)
13969 : : {
13970 : 556973 : SymbolTable_PtrToSymbol pSym;
13971 : :
13972 : 556973 : pSym = GetPsym (sym);
13973 : 556973 : switch (pSym->SymbolType)
13974 : : {
13975 : 526941 : case SymbolTable_ProcedureSym:
13976 : 526941 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional;
13977 : 30032 : break;
13978 : :
13979 : 30032 : case SymbolTable_ProcTypeSym:
13980 : 30032 : return pSym->ProcType.ReturnOptional;
13981 : 0 : break;
13982 : :
13983 : :
13984 : 0 : default:
13985 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
13986 : : break;
13987 : : }
13988 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
13989 : : __builtin_unreachable ();
13990 : : }
13991 : :
13992 : :
13993 : : /*
13994 : : IsReturnOptionalAny - returns TRUE if the return value for sym is
13995 : : optional.
13996 : : */
13997 : :
13998 : 7041 : extern "C" bool SymbolTable_IsReturnOptionalAny (unsigned int sym)
13999 : : {
14000 : 7041 : SymbolTable_PtrToSymbol pSym;
14001 : :
14002 : 7041 : pSym = GetPsym (sym);
14003 : 7041 : switch (pSym->SymbolType)
14004 : : {
14005 : 7041 : case SymbolTable_ProcedureSym:
14006 : 7041 : return IsProcedureAnyBoolean (sym, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_IsReturnOptional});
14007 : 0 : break;
14008 : :
14009 : 0 : case SymbolTable_ProcTypeSym:
14010 : 0 : return pSym->ProcType.ReturnOptional;
14011 : 0 : break;
14012 : :
14013 : :
14014 : 0 : default:
14015 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
14016 : : break;
14017 : : }
14018 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14019 : : __builtin_unreachable ();
14020 : : }
14021 : :
14022 : :
14023 : : /*
14024 : : PutParam - Places a Non VAR parameter ParamName with type ParamType into
14025 : : procedure Sym:kind. The parameter number is ParamNo.
14026 : : If the procedure Sym already has this parameter then
14027 : : the parameter is checked for consistancy and the
14028 : : consistancy test is returned.
14029 : : */
14030 : :
14031 : 6734682 : 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)
14032 : : {
14033 : 6734682 : SymbolTable_PtrToSymbol pSym;
14034 : 6734682 : unsigned int ParSym;
14035 : 6734682 : unsigned int VariableSym;
14036 : :
14037 : 6734682 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
14038 : : {
14039 : : /* ParamNo <= NoOfParamAny (Sym) */
14040 : 0 : M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
14041 : : }
14042 : : else
14043 : : {
14044 : : /* Add a new parameter */
14045 : 6734682 : NewSym (&ParSym);
14046 : 6734682 : pSym = GetPsym (ParSym);
14047 : 6734682 : pSym->SymbolType = SymbolTable_ParamSym;
14048 : 6734682 : pSym->Param.name = ParamName;
14049 : 6734682 : pSym->Param.Type = ParamType;
14050 : 6734682 : pSym->Param.IsUnbounded = isUnbounded;
14051 : 6734682 : pSym->Param.ShadowVar = SymbolTable_NulSym;
14052 : 6734682 : InitWhereDeclaredTok (tok, &pSym->Param.At);
14053 : 6734682 : AddParameter (Sym, kind, ParSym);
14054 : : /* Only declare a parameter as a local variable if it has not been done before.
14055 : : It might be declared during the definition module, forward declaration or
14056 : : proper procedure. Name mismatches are checked in P2SymBuild.mod. */
14057 : 6734682 : if ((ParamName != NameKey_NulName) && ((SymbolTable_GetNth (Sym, ParamNo)) == SymbolTable_NulSym))
14058 : : {
14059 : 5591768 : VariableSym = MakeVariableForParam (tok, ParamName, Sym, kind, ParamNo, ParamType, typetok);
14060 : 5591768 : if (VariableSym == SymbolTable_NulSym)
14061 : : {
14062 : : return false;
14063 : : }
14064 : : else
14065 : : {
14066 : 5591768 : pSym = GetPsym (ParSym);
14067 : 5591768 : pSym->Param.ShadowVar = VariableSym;
14068 : : }
14069 : : }
14070 : 6734682 : AddProcedureProcTypeParam (Sym, ParamType, isUnbounded, false);
14071 : : }
14072 : 6734682 : return true;
14073 : : /* static analysis guarentees a RETURN statement will be used before here. */
14074 : : __builtin_unreachable ();
14075 : : }
14076 : :
14077 : :
14078 : : /*
14079 : : PutVarParam - Places a Non VAR parameter ParamName with type
14080 : : ParamType into procedure Sym:kind.
14081 : : The parameter number is ParamNo.
14082 : : If the procedure Sym already has this parameter then
14083 : : the parameter is checked for consistancy and the
14084 : : consistancy test is returned.
14085 : : */
14086 : :
14087 : 568993 : 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)
14088 : : {
14089 : 568993 : SymbolTable_PtrToSymbol pSym;
14090 : 568993 : unsigned int ParSym;
14091 : 568993 : unsigned int VariableSym;
14092 : :
14093 : 568993 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
14094 : : {
14095 : 0 : M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
14096 : : }
14097 : : else
14098 : : {
14099 : : /* Add a new parameter */
14100 : 568993 : NewSym (&ParSym);
14101 : 568993 : pSym = GetPsym (ParSym);
14102 : 568993 : pSym->SymbolType = SymbolTable_VarParamSym;
14103 : 568993 : pSym->VarParam.name = ParamName;
14104 : 568993 : pSym->VarParam.Type = ParamType;
14105 : 568993 : pSym->VarParam.IsUnbounded = isUnbounded;
14106 : 568993 : pSym->VarParam.ShadowVar = SymbolTable_NulSym;
14107 : 568993 : pSym->VarParam.HeapVar = SymbolTable_NulSym; /* Will contain a pointer value. */
14108 : 568993 : InitWhereDeclaredTok (tok, &pSym->VarParam.At); /* Will contain a pointer value. */
14109 : 568993 : AddParameter (Sym, kind, ParSym);
14110 : : /* Only declare a parameter as a local variable if it has not been done before.
14111 : : It might be declared during the definition module, forward declaration or
14112 : : proper procedure. Name mismatches are checked in P2SymBuild.mod. */
14113 : 568993 : if ((ParamName != NameKey_NulName) && ((SymbolTable_GetNth (Sym, ParamNo)) == SymbolTable_NulSym))
14114 : : {
14115 : 426575 : VariableSym = MakeVariableForParam (tok, ParamName, Sym, kind, ParamNo, ParamType, typetok);
14116 : 426575 : if (VariableSym == SymbolTable_NulSym)
14117 : : {
14118 : : return false;
14119 : : }
14120 : : else
14121 : : {
14122 : 426575 : pSym = GetPsym (ParSym);
14123 : 426575 : pSym->VarParam.ShadowVar = VariableSym;
14124 : : }
14125 : : }
14126 : 568993 : AddProcedureProcTypeParam (Sym, ParamType, isUnbounded, true);
14127 : : }
14128 : 568993 : return true;
14129 : : /* static analysis guarentees a RETURN statement will be used before here. */
14130 : : __builtin_unreachable ();
14131 : : }
14132 : :
14133 : :
14134 : : /*
14135 : : PutParamName - assigns a name to paramater no of procedure ProcSym:kind.
14136 : : */
14137 : :
14138 : 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)
14139 : : {
14140 : 0 : SymbolTable_PtrToSymbol pSym;
14141 : 0 : unsigned int ParSym;
14142 : :
14143 : 0 : pSym = GetPsym (ProcSym);
14144 : 0 : ParSym = SymbolTable_NulSym;
14145 : 0 : switch (pSym->SymbolType)
14146 : : {
14147 : : case SymbolTable_ErrorSym:
14148 : : return;
14149 : 0 : break;
14150 : :
14151 : 0 : case SymbolTable_ProcedureSym:
14152 : 0 : ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, no));
14153 : 0 : break;
14154 : :
14155 : 0 : case SymbolTable_ProcTypeSym:
14156 : 0 : ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, no));
14157 : 0 : break;
14158 : :
14159 : :
14160 : 0 : default:
14161 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14162 : 0 : break;
14163 : : }
14164 : 0 : pSym = GetPsym (ParSym);
14165 : 0 : switch (pSym->SymbolType)
14166 : : {
14167 : 0 : case SymbolTable_ParamSym:
14168 : 0 : if (pSym->Param.name == NameKey_NulName)
14169 : : {
14170 : 0 : pSym->Param.name = name;
14171 : 0 : pSym->Param.ShadowVar = MakeVariableForParam (tok, name, ProcSym, kind, no, ParamType, typetok);
14172 : : }
14173 : : else
14174 : : {
14175 : 0 : M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
14176 : : }
14177 : 0 : break;
14178 : :
14179 : 0 : case SymbolTable_VarParamSym:
14180 : 0 : if (pSym->VarParam.name == NameKey_NulName)
14181 : : {
14182 : 0 : pSym->VarParam.name = name;
14183 : 0 : pSym->VarParam.ShadowVar = MakeVariableForParam (tok, name, ProcSym, kind, no, ParamType, typetok);
14184 : : }
14185 : : else
14186 : : {
14187 : 0 : M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
14188 : : }
14189 : 0 : break;
14190 : :
14191 : :
14192 : 0 : default:
14193 : 0 : M2Error_InternalError ((const char *) "expecting a VarParam or Param symbol", 36);
14194 : 0 : break;
14195 : : }
14196 : : }
14197 : :
14198 : :
14199 : : /*
14200 : : PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
14201 : : main Module.
14202 : : */
14203 : :
14204 : 58074 : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym)
14205 : : {
14206 : 58074 : SymbolTable_PtrToSymbol pSym;
14207 : :
14208 : 58074 : pSym = GetPsym (Sym);
14209 : 58074 : switch (pSym->SymbolType)
14210 : : {
14211 : : case SymbolTable_ErrorSym:
14212 : : break;
14213 : :
14214 : 58074 : case SymbolTable_ProcedureSym:
14215 : 58074 : pSym->Procedure.Reachable = true;
14216 : 58074 : break;
14217 : :
14218 : :
14219 : 0 : default:
14220 : 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14221 : 58074 : break;
14222 : : }
14223 : 58074 : }
14224 : :
14225 : :
14226 : : /*
14227 : : IsProcedureReachable - Returns true if the procedure, Sym, is
14228 : : reachable from the main Module.
14229 : : */
14230 : :
14231 : 183960 : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym)
14232 : : {
14233 : 183960 : SymbolTable_PtrToSymbol pSym;
14234 : :
14235 : 183960 : pSym = GetPsym (Sym);
14236 : 183960 : switch (pSym->SymbolType)
14237 : : {
14238 : 183960 : case SymbolTable_ProcedureSym:
14239 : 183960 : return pSym->Procedure.Reachable;
14240 : 0 : break;
14241 : :
14242 : :
14243 : 0 : default:
14244 : 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14245 : : break;
14246 : : }
14247 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14248 : : __builtin_unreachable ();
14249 : : }
14250 : :
14251 : :
14252 : : /*
14253 : : PutProcedureNoReturn - places value into the no return attribute
14254 : : field of procedure sym.
14255 : : */
14256 : :
14257 : 492972 : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind, bool value)
14258 : : {
14259 : 492972 : SymbolTable_PtrToSymbol pSym;
14260 : :
14261 : 492972 : pSym = GetPsym (Sym);
14262 : 492972 : switch (pSym->SymbolType)
14263 : : {
14264 : 492972 : case SymbolTable_ProcedureSym:
14265 : 492972 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].IsNoReturn = value;
14266 : 492972 : break;
14267 : :
14268 : :
14269 : 0 : default:
14270 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
14271 : 492972 : break;
14272 : : }
14273 : 492972 : }
14274 : :
14275 : :
14276 : : /*
14277 : : IsProcedureNoReturn - returns TRUE if this procedure never returns.
14278 : : */
14279 : :
14280 : 1983182 : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind)
14281 : : {
14282 : 1983182 : SymbolTable_PtrToSymbol pSym;
14283 : :
14284 : 1983182 : pSym = GetPsym (Sym);
14285 : 1983182 : switch (pSym->SymbolType)
14286 : : {
14287 : 1983182 : case SymbolTable_ProcedureSym:
14288 : 1983182 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].IsNoReturn;
14289 : 0 : break;
14290 : :
14291 : :
14292 : 0 : default:
14293 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
14294 : : break;
14295 : : }
14296 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14297 : : __builtin_unreachable ();
14298 : : }
14299 : :
14300 : :
14301 : : /*
14302 : : GetProcedureProcType - returns the proctype matching procedure sym.
14303 : : */
14304 : :
14305 : 640190 : extern "C" unsigned int SymbolTable_GetProcedureProcType (unsigned int sym)
14306 : : {
14307 : 640190 : SymbolTable_PtrToSymbol pSym;
14308 : :
14309 : 640190 : pSym = GetPsym (sym);
14310 : 640190 : switch (pSym->SymbolType)
14311 : : {
14312 : 640190 : case SymbolTable_ProcedureSym:
14313 : 640190 : return pSym->Procedure.ProcedureType;
14314 : 0 : break;
14315 : :
14316 : :
14317 : 0 : default:
14318 : 0 : M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
14319 : : break;
14320 : : }
14321 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14322 : : __builtin_unreachable ();
14323 : : }
14324 : :
14325 : :
14326 : : /*
14327 : : PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
14328 : : QuadNumber is the start quad of Module,
14329 : : Sym.
14330 : : */
14331 : :
14332 : 65863 : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber)
14333 : : {
14334 : 65863 : SymbolTable_PtrToSymbol pSym;
14335 : :
14336 : 65863 : pSym = GetPsym (Sym);
14337 : 65863 : switch (pSym->SymbolType)
14338 : : {
14339 : 11706 : case SymbolTable_ModuleSym:
14340 : 11706 : pSym->Module.StartQuad = QuadNumber;
14341 : 11706 : break;
14342 : :
14343 : 54157 : case SymbolTable_DefImpSym:
14344 : 54157 : pSym->DefImp.StartQuad = QuadNumber;
14345 : 54157 : break;
14346 : :
14347 : :
14348 : 0 : default:
14349 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14350 : 65863 : break;
14351 : : }
14352 : 65863 : }
14353 : :
14354 : :
14355 : : /*
14356 : : PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
14357 : : QuadNumber is the end quad of Module,
14358 : : Sym.
14359 : : */
14360 : :
14361 : 65724 : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber)
14362 : : {
14363 : 65724 : SymbolTable_PtrToSymbol pSym;
14364 : :
14365 : 65724 : pSym = GetPsym (Sym);
14366 : 65724 : switch (pSym->SymbolType)
14367 : : {
14368 : 11567 : case SymbolTable_ModuleSym:
14369 : 11567 : pSym->Module.EndQuad = QuadNumber;
14370 : 11567 : break;
14371 : :
14372 : 54157 : case SymbolTable_DefImpSym:
14373 : 54157 : pSym->DefImp.EndQuad = QuadNumber;
14374 : 54157 : break;
14375 : :
14376 : :
14377 : 0 : default:
14378 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14379 : 65724 : break;
14380 : : }
14381 : 65724 : }
14382 : :
14383 : :
14384 : : /*
14385 : : PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
14386 : : QuadNumber is the finally start quad of
14387 : : Module, Sym.
14388 : : */
14389 : :
14390 : 15500 : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber)
14391 : : {
14392 : 15500 : SymbolTable_PtrToSymbol pSym;
14393 : :
14394 : 15500 : pSym = GetPsym (Sym);
14395 : 15500 : switch (pSym->SymbolType)
14396 : : {
14397 : 11561 : case SymbolTable_ModuleSym:
14398 : 11561 : pSym->Module.StartFinishQuad = QuadNumber;
14399 : 11561 : break;
14400 : :
14401 : 3939 : case SymbolTable_DefImpSym:
14402 : 3939 : pSym->DefImp.StartFinishQuad = QuadNumber;
14403 : 3939 : break;
14404 : :
14405 : :
14406 : 0 : default:
14407 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14408 : 15500 : break;
14409 : : }
14410 : 15500 : }
14411 : :
14412 : :
14413 : : /*
14414 : : PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
14415 : : QuadNumber is the end quad of the finally block
14416 : : in Module, Sym.
14417 : : */
14418 : :
14419 : 15500 : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber)
14420 : : {
14421 : 15500 : SymbolTable_PtrToSymbol pSym;
14422 : :
14423 : 15500 : pSym = GetPsym (Sym);
14424 : 15500 : switch (pSym->SymbolType)
14425 : : {
14426 : 11561 : case SymbolTable_ModuleSym:
14427 : 11561 : pSym->Module.EndFinishQuad = QuadNumber;
14428 : 11561 : break;
14429 : :
14430 : 3939 : case SymbolTable_DefImpSym:
14431 : 3939 : pSym->DefImp.EndFinishQuad = QuadNumber;
14432 : 3939 : break;
14433 : :
14434 : :
14435 : 0 : default:
14436 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14437 : 15500 : break;
14438 : : }
14439 : 15500 : }
14440 : :
14441 : :
14442 : : /*
14443 : : GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
14444 : : Quads of a Module, Sym.
14445 : : Start and End represent the initialization code
14446 : : of the Module, Sym.
14447 : : */
14448 : :
14449 : 0 : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish)
14450 : : {
14451 : 0 : SymbolTable_PtrToSymbol pSym;
14452 : :
14453 : 0 : pSym = GetPsym (Sym);
14454 : 0 : switch (pSym->SymbolType)
14455 : : {
14456 : 0 : case SymbolTable_ModuleSym:
14457 : 0 : (*StartInit) = pSym->Module.StartQuad;
14458 : 0 : (*EndInit) = pSym->Module.EndQuad;
14459 : 0 : (*StartFinish) = pSym->Module.StartFinishQuad;
14460 : 0 : (*EndFinish) = pSym->Module.EndFinishQuad;
14461 : 0 : break;
14462 : :
14463 : 0 : case SymbolTable_DefImpSym:
14464 : 0 : (*StartInit) = pSym->DefImp.StartQuad;
14465 : 0 : (*EndInit) = pSym->DefImp.EndQuad;
14466 : 0 : (*StartFinish) = pSym->DefImp.StartFinishQuad;
14467 : 0 : (*EndFinish) = pSym->DefImp.EndFinishQuad;
14468 : 0 : break;
14469 : :
14470 : :
14471 : 0 : default:
14472 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14473 : 0 : break;
14474 : : }
14475 : 0 : }
14476 : :
14477 : :
14478 : : /*
14479 : : PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
14480 : : */
14481 : :
14482 : 0 : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, tree finally)
14483 : : {
14484 : 0 : SymbolTable_PtrToSymbol pSym;
14485 : :
14486 : 0 : pSym = GetPsym (Sym);
14487 : 0 : switch (pSym->SymbolType)
14488 : : {
14489 : 0 : case SymbolTable_ModuleSym:
14490 : 0 : pSym->Module.FinallyFunction = finally;
14491 : 0 : break;
14492 : :
14493 : 0 : case SymbolTable_DefImpSym:
14494 : 0 : pSym->DefImp.FinallyFunction = finally;
14495 : 0 : break;
14496 : :
14497 : :
14498 : 0 : default:
14499 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14500 : 0 : break;
14501 : : }
14502 : 0 : }
14503 : :
14504 : :
14505 : : /*
14506 : : GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
14507 : : */
14508 : :
14509 : 0 : extern "C" tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym)
14510 : : {
14511 : 0 : SymbolTable_PtrToSymbol pSym;
14512 : :
14513 : 0 : pSym = GetPsym (Sym);
14514 : 0 : switch (pSym->SymbolType)
14515 : : {
14516 : 0 : case SymbolTable_ModuleSym:
14517 : 0 : return pSym->Module.FinallyFunction;
14518 : 0 : break;
14519 : :
14520 : 0 : case SymbolTable_DefImpSym:
14521 : 0 : return pSym->DefImp.FinallyFunction;
14522 : 0 : break;
14523 : :
14524 : :
14525 : 0 : default:
14526 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
14527 : : break;
14528 : : }
14529 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14530 : : __builtin_unreachable ();
14531 : : }
14532 : :
14533 : :
14534 : : /*
14535 : : PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
14536 : : QuadNumber is the start quad of scope for procedure,
14537 : : Sym.
14538 : : */
14539 : :
14540 : 71150 : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber)
14541 : : {
14542 : 71150 : SymbolTable_PtrToSymbol pSym;
14543 : :
14544 : 71150 : pSym = GetPsym (Sym);
14545 : 71150 : switch (pSym->SymbolType)
14546 : : {
14547 : 71150 : case SymbolTable_ProcedureSym:
14548 : 71150 : pSym->Procedure.ScopeQuad = QuadNumber;
14549 : 71150 : break;
14550 : :
14551 : :
14552 : 0 : default:
14553 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14554 : 71150 : break;
14555 : : }
14556 : 71150 : }
14557 : :
14558 : :
14559 : : /*
14560 : : PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
14561 : : QuadNumber is the start quad of procedure,
14562 : : Sym.
14563 : : */
14564 : :
14565 : 71138 : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber)
14566 : : {
14567 : 71138 : SymbolTable_PtrToSymbol pSym;
14568 : :
14569 : 71138 : pSym = GetPsym (Sym);
14570 : 71138 : switch (pSym->SymbolType)
14571 : : {
14572 : 71138 : case SymbolTable_ProcedureSym:
14573 : 71138 : pSym->Procedure.StartQuad = QuadNumber;
14574 : 71138 : break;
14575 : :
14576 : :
14577 : 0 : default:
14578 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14579 : 71138 : break;
14580 : : }
14581 : 71138 : }
14582 : :
14583 : :
14584 : : /*
14585 : : PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
14586 : : QuadNumber is the end quad of procedure,
14587 : : Sym.
14588 : : */
14589 : :
14590 : 71108 : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber)
14591 : : {
14592 : 71108 : SymbolTable_PtrToSymbol pSym;
14593 : :
14594 : 71108 : pSym = GetPsym (Sym);
14595 : 71108 : switch (pSym->SymbolType)
14596 : : {
14597 : 71108 : case SymbolTable_ProcedureSym:
14598 : 71108 : pSym->Procedure.EndQuad = QuadNumber;
14599 : 71108 : break;
14600 : :
14601 : :
14602 : 0 : default:
14603 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14604 : 71108 : break;
14605 : : }
14606 : 71108 : }
14607 : :
14608 : :
14609 : : /*
14610 : : GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
14611 : : */
14612 : :
14613 : 582477 : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end)
14614 : : {
14615 : 582477 : SymbolTable_PtrToSymbol pSym;
14616 : :
14617 : 582477 : pSym = GetPsym (Sym);
14618 : 582477 : switch (pSym->SymbolType)
14619 : : {
14620 : 582477 : case SymbolTable_ProcedureSym:
14621 : 582477 : (*scope) = pSym->Procedure.ScopeQuad;
14622 : 582477 : (*start) = pSym->Procedure.StartQuad;
14623 : 582477 : (*end) = pSym->Procedure.EndQuad;
14624 : 582477 : break;
14625 : :
14626 : :
14627 : 0 : default:
14628 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
14629 : 582477 : break;
14630 : : }
14631 : 582477 : }
14632 : :
14633 : :
14634 : : /*
14635 : : GetQuads - assigns Start and End to the beginning and end of
14636 : : symbol, Sym, usage.
14637 : : */
14638 : :
14639 : 0 : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14640 : : {
14641 : 0 : unsigned int StartRead;
14642 : 0 : unsigned int EndRead;
14643 : 0 : unsigned int StartWrite;
14644 : 0 : unsigned int EndWrite;
14645 : :
14646 : 0 : SymbolTable_GetReadQuads (Sym, m, &StartRead, &EndRead);
14647 : 0 : SymbolTable_GetWriteQuads (Sym, m, &StartWrite, &EndWrite);
14648 : 0 : if (StartRead == 0)
14649 : : {
14650 : 0 : (*Start) = StartWrite;
14651 : : }
14652 : 0 : else if (StartWrite == 0)
14653 : : {
14654 : : /* avoid dangling else. */
14655 : 0 : (*Start) = StartRead;
14656 : : }
14657 : : else
14658 : : {
14659 : : /* avoid dangling else. */
14660 : 0 : (*Start) = Min (StartRead, StartWrite);
14661 : : }
14662 : 0 : if (EndRead == 0)
14663 : : {
14664 : 0 : (*End) = EndWrite;
14665 : : }
14666 : 0 : else if (EndWrite == 0)
14667 : : {
14668 : : /* avoid dangling else. */
14669 : 0 : (*End) = EndRead;
14670 : : }
14671 : : else
14672 : : {
14673 : : /* avoid dangling else. */
14674 : 0 : (*End) = Max (EndRead, EndWrite);
14675 : : }
14676 : 0 : }
14677 : :
14678 : :
14679 : : /*
14680 : : GetReadQuads - assigns Start and End to the beginning and end of
14681 : : symbol, Sym, read history usage.
14682 : : */
14683 : :
14684 : 0 : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14685 : : {
14686 : 0 : SymbolTable_GetReadLimitQuads (Sym, m, 0, 0, Start, End);
14687 : 0 : }
14688 : :
14689 : :
14690 : : /*
14691 : : GetWriteQuads - assigns Start and End to the beginning and end of
14692 : : symbol, Sym, usage.
14693 : : */
14694 : :
14695 : 0 : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
14696 : : {
14697 : 0 : SymbolTable_GetWriteLimitQuads (Sym, m, 0, 0, Start, End);
14698 : 0 : }
14699 : :
14700 : :
14701 : : /*
14702 : : PutReadQuad - places Quad into the list of symbol usage.
14703 : : */
14704 : :
14705 : 1393346 : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14706 : : {
14707 : 1393346 : SymbolTable_PtrToSymbol pSym;
14708 : :
14709 : 1393346 : pSym = GetPsym (Sym);
14710 : 1393346 : switch (pSym->SymbolType)
14711 : : {
14712 : 1393346 : case SymbolTable_VarSym:
14713 : 1393346 : Lists_IncludeItemIntoList (static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]), Quad);
14714 : 1393346 : break;
14715 : :
14716 : :
14717 : 0 : default:
14718 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14719 : 1393346 : break;
14720 : : }
14721 : 1393346 : }
14722 : :
14723 : :
14724 : : /*
14725 : : RemoveReadQuad - places Quad into the list of symbol usage.
14726 : : */
14727 : :
14728 : 101344 : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14729 : : {
14730 : 101344 : SymbolTable_PtrToSymbol pSym;
14731 : :
14732 : 101344 : pSym = GetPsym (Sym);
14733 : 101344 : switch (pSym->SymbolType)
14734 : : {
14735 : 101344 : case SymbolTable_VarSym:
14736 : 101344 : Lists_RemoveItemFromList (static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]), Quad);
14737 : 101344 : break;
14738 : :
14739 : :
14740 : 0 : default:
14741 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14742 : 101344 : break;
14743 : : }
14744 : 101344 : }
14745 : :
14746 : :
14747 : : /*
14748 : : PutWriteQuad - places Quad into the list of symbol usage.
14749 : : */
14750 : :
14751 : 908408 : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14752 : : {
14753 : 908408 : SymbolTable_PtrToSymbol pSym;
14754 : :
14755 : 908408 : pSym = GetPsym (Sym);
14756 : 908408 : switch (pSym->SymbolType)
14757 : : {
14758 : 908408 : case SymbolTable_VarSym:
14759 : 908408 : Lists_IncludeItemIntoList (static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]), Quad);
14760 : 908408 : break;
14761 : :
14762 : :
14763 : 0 : default:
14764 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14765 : 908408 : break;
14766 : : }
14767 : 908408 : }
14768 : :
14769 : :
14770 : : /*
14771 : : RemoveWriteQuad - places Quad into the list of symbol usage.
14772 : : */
14773 : :
14774 : 192507 : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
14775 : : {
14776 : 192507 : SymbolTable_PtrToSymbol pSym;
14777 : :
14778 : 192507 : pSym = GetPsym (Sym);
14779 : 192507 : switch (pSym->SymbolType)
14780 : : {
14781 : 192507 : case SymbolTable_VarSym:
14782 : 192507 : Lists_RemoveItemFromList (static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]), Quad);
14783 : 192507 : break;
14784 : :
14785 : :
14786 : 0 : default:
14787 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14788 : 192507 : break;
14789 : : }
14790 : 192507 : }
14791 : :
14792 : :
14793 : : /*
14794 : : GetReadLimitQuads - returns Start and End which have been assigned
14795 : : the start and end of when the symbol was read
14796 : : to within: StartLimit..EndLimit.
14797 : : */
14798 : :
14799 : 0 : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
14800 : : {
14801 : 0 : SymbolTable_PtrToSymbol pSym;
14802 : :
14803 : 0 : pSym = GetPsym (Sym);
14804 : 0 : switch (pSym->SymbolType)
14805 : : {
14806 : 0 : case SymbolTable_VarSym:
14807 : 0 : DoFindLimits (StartLimit, EndLimit, Start, End, static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]));
14808 : 0 : break;
14809 : :
14810 : :
14811 : 0 : default:
14812 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14813 : 0 : break;
14814 : : }
14815 : 0 : }
14816 : :
14817 : :
14818 : : /*
14819 : : GetWriteLimitQuads - returns Start and End which have been assigned
14820 : : the start and end of when the symbol was written
14821 : : to within: StartLimit..EndLimit.
14822 : : */
14823 : :
14824 : 30 : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
14825 : : {
14826 : 30 : SymbolTable_PtrToSymbol pSym;
14827 : :
14828 : 30 : pSym = GetPsym (Sym);
14829 : 30 : switch (pSym->SymbolType)
14830 : : {
14831 : 30 : case SymbolTable_VarSym:
14832 : 30 : DoFindLimits (StartLimit, EndLimit, Start, End, static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]));
14833 : 30 : break;
14834 : :
14835 : :
14836 : 0 : default:
14837 : 0 : M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
14838 : 30 : break;
14839 : : }
14840 : 30 : }
14841 : :
14842 : :
14843 : : /*
14844 : : GetNthProcedure - Returns the Nth procedure in Module, Sym.
14845 : : */
14846 : :
14847 : 0 : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n)
14848 : : {
14849 : 0 : SymbolTable_PtrToSymbol pSym;
14850 : :
14851 : 0 : pSym = GetPsym (Sym);
14852 : 0 : switch (pSym->SymbolType)
14853 : : {
14854 : 0 : case SymbolTable_DefImpSym:
14855 : 0 : return static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfProcs, n));
14856 : 0 : break;
14857 : :
14858 : 0 : case SymbolTable_ModuleSym:
14859 : 0 : return static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfProcs, n));
14860 : 0 : break;
14861 : :
14862 : :
14863 : 0 : default:
14864 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
14865 : : break;
14866 : : }
14867 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
14868 : : __builtin_unreachable ();
14869 : : }
14870 : :
14871 : :
14872 : : /*
14873 : : GetDeclaredDef - returns the tokenno where the symbol was declared
14874 : : in the definition module. UnknownTokenNo is returned
14875 : : if no declaration occurred.
14876 : : */
14877 : :
14878 : 96 : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym)
14879 : : {
14880 : 96 : return SymbolTable_GetDeclaredDefinition (Sym);
14881 : : /* static analysis guarentees a RETURN statement will be used before here. */
14882 : : __builtin_unreachable ();
14883 : : }
14884 : :
14885 : :
14886 : : /*
14887 : : GetDeclaredMod - returns the tokenno where the symbol was declared.
14888 : : in the program or implementation module.
14889 : : UnknownTokenNo is returned if no declaration occurred.
14890 : : */
14891 : :
14892 : 22084552 : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym)
14893 : : {
14894 : 22084552 : return SymbolTable_GetDeclaredModule (Sym);
14895 : : /* static analysis guarentees a RETURN statement will be used before here. */
14896 : : __builtin_unreachable ();
14897 : : }
14898 : :
14899 : :
14900 : : /*
14901 : : GetDeclaredFor - returns the token where this forward procedure symbol
14902 : : was declared in the program or implementation module.
14903 : : UnknownTokenNo is returned if no declaration occurred.
14904 : : */
14905 : :
14906 : 0 : extern "C" unsigned int SymbolTable_GetDeclaredFor (unsigned int Sym)
14907 : : {
14908 : 0 : if (SymbolTable_IsProcedure (Sym))
14909 : : {
14910 : 0 : return SymbolTable_GetProcedureDeclaredTok (Sym, SymbolTable_ForwardProcedure);
14911 : : }
14912 : : else
14913 : : {
14914 : : return M2LexBuf_UnknownTokenNo;
14915 : : }
14916 : : /* static analysis guarentees a RETURN statement will be used before here. */
14917 : : __builtin_unreachable ();
14918 : : }
14919 : :
14920 : :
14921 : : /*
14922 : : GetDeclaredDefinition - returns the token where this symbol
14923 : : was declared in the definition module.
14924 : : */
14925 : :
14926 : 21783 : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym)
14927 : : {
14928 : 21783 : SymbolTable_PtrToSymbol pSym;
14929 : :
14930 : 21783 : pSym = GetPsym (Sym);
14931 : 21783 : switch (pSym->SymbolType)
14932 : : {
14933 : 0 : case SymbolTable_ErrorSym:
14934 : 0 : return pSym->Error.At.DefDeclared;
14935 : 0 : break;
14936 : :
14937 : 0 : case SymbolTable_ObjectSym:
14938 : 0 : return pSym->Object.At.DefDeclared;
14939 : 0 : break;
14940 : :
14941 : 0 : case SymbolTable_VarientSym:
14942 : 0 : return pSym->Varient.At.DefDeclared;
14943 : 6 : break;
14944 : :
14945 : 6 : case SymbolTable_RecordSym:
14946 : 6 : return pSym->Record.At.DefDeclared;
14947 : 0 : break;
14948 : :
14949 : 0 : case SymbolTable_SubrangeSym:
14950 : 0 : return pSym->Subrange.At.DefDeclared;
14951 : 0 : break;
14952 : :
14953 : 0 : case SymbolTable_EnumerationSym:
14954 : 0 : return pSym->Enumeration.At.DefDeclared;
14955 : 0 : break;
14956 : :
14957 : 0 : case SymbolTable_ArraySym:
14958 : 0 : return pSym->Array.At.DefDeclared;
14959 : 0 : break;
14960 : :
14961 : 0 : case SymbolTable_SubscriptSym:
14962 : 0 : return pSym->Subscript.At.DefDeclared;
14963 : 0 : break;
14964 : :
14965 : 0 : case SymbolTable_UnboundedSym:
14966 : 0 : return pSym->Unbounded.At.DefDeclared;
14967 : 0 : break;
14968 : :
14969 : 0 : case SymbolTable_ProcedureSym:
14970 : 0 : return pSym->Procedure.At.DefDeclared;
14971 : 0 : break;
14972 : :
14973 : 0 : case SymbolTable_ProcTypeSym:
14974 : 0 : return pSym->ProcType.At.DefDeclared;
14975 : 84 : break;
14976 : :
14977 : 84 : case SymbolTable_ParamSym:
14978 : 84 : return pSym->Param.At.DefDeclared;
14979 : 6 : break;
14980 : :
14981 : 6 : case SymbolTable_VarParamSym:
14982 : 6 : return pSym->VarParam.At.DefDeclared;
14983 : 0 : break;
14984 : :
14985 : 0 : case SymbolTable_ConstStringSym:
14986 : 0 : return pSym->ConstString.At.DefDeclared;
14987 : 0 : break;
14988 : :
14989 : 0 : case SymbolTable_ConstLitSym:
14990 : 0 : return pSym->ConstLit.At.DefDeclared;
14991 : 0 : break;
14992 : :
14993 : 0 : case SymbolTable_ConstVarSym:
14994 : 0 : return pSym->ConstVar.At.DefDeclared;
14995 : 0 : break;
14996 : :
14997 : 0 : case SymbolTable_VarSym:
14998 : 0 : return pSym->Var.At.DefDeclared;
14999 : 0 : break;
15000 : :
15001 : 0 : case SymbolTable_TypeSym:
15002 : 0 : return pSym->Type.At.DefDeclared;
15003 : 0 : break;
15004 : :
15005 : 0 : case SymbolTable_PointerSym:
15006 : 0 : return pSym->Pointer.At.DefDeclared;
15007 : 0 : break;
15008 : :
15009 : 0 : case SymbolTable_RecordFieldSym:
15010 : 0 : return pSym->RecordField.At.DefDeclared;
15011 : 0 : break;
15012 : :
15013 : 0 : case SymbolTable_VarientFieldSym:
15014 : 0 : return pSym->VarientField.At.DefDeclared;
15015 : 0 : break;
15016 : :
15017 : 0 : case SymbolTable_EnumerationFieldSym:
15018 : 0 : return pSym->EnumerationField.At.DefDeclared;
15019 : 0 : break;
15020 : :
15021 : 0 : case SymbolTable_SetSym:
15022 : 0 : return pSym->Set.At.DefDeclared;
15023 : 0 : break;
15024 : :
15025 : 0 : case SymbolTable_DefImpSym:
15026 : 0 : return pSym->DefImp.At.DefDeclared;
15027 : 0 : break;
15028 : :
15029 : 0 : case SymbolTable_ModuleSym:
15030 : 0 : return pSym->Module.At.DefDeclared;
15031 : 0 : break;
15032 : :
15033 : 0 : case SymbolTable_UndefinedSym:
15034 : 0 : return SymbolTable_GetFirstUsed (Sym);
15035 : 21687 : break;
15036 : :
15037 : 21687 : case SymbolTable_ImportSym:
15038 : 21687 : return pSym->Import.at.DefDeclared;
15039 : 0 : break;
15040 : :
15041 : 0 : case SymbolTable_ImportStatementSym:
15042 : 0 : return pSym->ImportStatement.at.DefDeclared;
15043 : 0 : break;
15044 : :
15045 : 0 : case SymbolTable_PartialUnboundedSym:
15046 : 0 : return SymbolTable_GetDeclaredDefinition (pSym->PartialUnbounded.Type);
15047 : 0 : break;
15048 : :
15049 : :
15050 : 0 : default:
15051 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15052 : : break;
15053 : : }
15054 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15055 : : __builtin_unreachable ();
15056 : : }
15057 : :
15058 : :
15059 : : /*
15060 : : GetDeclaredModule - returns the token where this symbol was declared
15061 : : in an implementation or program module.
15062 : : */
15063 : :
15064 : 22104449 : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym)
15065 : : {
15066 : 22104449 : SymbolTable_PtrToSymbol pSym;
15067 : :
15068 : 22104449 : pSym = GetPsym (Sym);
15069 : 22104449 : switch (pSym->SymbolType)
15070 : : {
15071 : 0 : case SymbolTable_ErrorSym:
15072 : 0 : return pSym->Error.At.ModDeclared;
15073 : 0 : break;
15074 : :
15075 : 0 : case SymbolTable_ObjectSym:
15076 : 0 : return pSym->Object.At.ModDeclared;
15077 : 552 : break;
15078 : :
15079 : 552 : case SymbolTable_VarientSym:
15080 : 552 : return pSym->Varient.At.ModDeclared;
15081 : 245433 : break;
15082 : :
15083 : 245433 : case SymbolTable_RecordSym:
15084 : 245433 : return pSym->Record.At.ModDeclared;
15085 : 1434116 : break;
15086 : :
15087 : 1434116 : case SymbolTable_SubrangeSym:
15088 : 1434116 : return pSym->Subrange.At.ModDeclared;
15089 : 24284 : break;
15090 : :
15091 : 24284 : case SymbolTable_EnumerationSym:
15092 : 24284 : return pSym->Enumeration.At.ModDeclared;
15093 : 32924 : break;
15094 : :
15095 : 32924 : case SymbolTable_ArraySym:
15096 : 32924 : return pSym->Array.At.ModDeclared;
15097 : 0 : break;
15098 : :
15099 : 0 : case SymbolTable_SubscriptSym:
15100 : 0 : return pSym->Subscript.At.ModDeclared;
15101 : 42520 : break;
15102 : :
15103 : 42520 : case SymbolTable_UnboundedSym:
15104 : 42520 : return pSym->Unbounded.At.ModDeclared;
15105 : 3687972 : break;
15106 : :
15107 : 3687972 : case SymbolTable_ProcedureSym:
15108 : 3687972 : return pSym->Procedure.At.ModDeclared;
15109 : 54424 : break;
15110 : :
15111 : 54424 : case SymbolTable_ProcTypeSym:
15112 : 54424 : return pSym->ProcType.At.ModDeclared;
15113 : 71305 : break;
15114 : :
15115 : 71305 : case SymbolTable_ParamSym:
15116 : 71305 : return pSym->Param.At.ModDeclared;
15117 : 347201 : break;
15118 : :
15119 : 347201 : case SymbolTable_VarParamSym:
15120 : 347201 : return pSym->VarParam.At.ModDeclared;
15121 : 793423 : break;
15122 : :
15123 : 793423 : case SymbolTable_ConstStringSym:
15124 : 793423 : return pSym->ConstString.At.ModDeclared;
15125 : 988381 : break;
15126 : :
15127 : 988381 : case SymbolTable_ConstLitSym:
15128 : 988381 : return pSym->ConstLit.At.ModDeclared;
15129 : 552256 : break;
15130 : :
15131 : 552256 : case SymbolTable_ConstVarSym:
15132 : 552256 : return pSym->ConstVar.At.ModDeclared;
15133 : 5542104 : break;
15134 : :
15135 : 5542104 : case SymbolTable_VarSym:
15136 : 5542104 : return pSym->Var.At.ModDeclared;
15137 : 81881 : break;
15138 : :
15139 : 81881 : case SymbolTable_TypeSym:
15140 : 81881 : return pSym->Type.At.ModDeclared;
15141 : 12 : break;
15142 : :
15143 : 12 : case SymbolTable_PointerSym:
15144 : 12 : return pSym->Pointer.At.ModDeclared;
15145 : 325388 : break;
15146 : :
15147 : 325388 : case SymbolTable_RecordFieldSym:
15148 : 325388 : return pSym->RecordField.At.ModDeclared;
15149 : 1332 : break;
15150 : :
15151 : 1332 : case SymbolTable_VarientFieldSym:
15152 : 1332 : return pSym->VarientField.At.ModDeclared;
15153 : 7627632 : break;
15154 : :
15155 : 7627632 : case SymbolTable_EnumerationFieldSym:
15156 : 7627632 : return pSym->EnumerationField.At.ModDeclared;
15157 : 201700 : break;
15158 : :
15159 : 201700 : case SymbolTable_SetSym:
15160 : 201700 : return pSym->Set.At.ModDeclared;
15161 : 7882 : break;
15162 : :
15163 : 7882 : case SymbolTable_DefImpSym:
15164 : 7882 : return pSym->DefImp.At.ModDeclared;
15165 : 21836 : break;
15166 : :
15167 : 21836 : case SymbolTable_ModuleSym:
15168 : 21836 : return pSym->Module.At.ModDeclared;
15169 : 0 : break;
15170 : :
15171 : 0 : case SymbolTable_UndefinedSym:
15172 : 0 : return SymbolTable_GetFirstUsed (Sym);
15173 : 19891 : break;
15174 : :
15175 : 19891 : case SymbolTable_ImportSym:
15176 : 19891 : return pSym->Import.at.ModDeclared;
15177 : 0 : break;
15178 : :
15179 : 0 : case SymbolTable_ImportStatementSym:
15180 : 0 : return pSym->ImportStatement.at.ModDeclared;
15181 : 0 : break;
15182 : :
15183 : 0 : case SymbolTable_PartialUnboundedSym:
15184 : 0 : return SymbolTable_GetDeclaredModule (pSym->PartialUnbounded.Type);
15185 : 0 : break;
15186 : :
15187 : :
15188 : 0 : default:
15189 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15190 : : break;
15191 : : }
15192 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15193 : : __builtin_unreachable ();
15194 : : }
15195 : :
15196 : :
15197 : : /*
15198 : : PutDeclared - adds an entry to symbol, Sym, indicating that it
15199 : : was declared at, tok. This routine
15200 : : may be called twice, once for definition module
15201 : : partial declaration and once when parsing the
15202 : : implementation module.
15203 : : */
15204 : :
15205 : 19392084 : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym)
15206 : : {
15207 : 19392084 : if (M2Comp_CompilingDefinitionModule ())
15208 : : {
15209 : 11517593 : PutDeclaredDefinition (tok, Sym);
15210 : : }
15211 : : else
15212 : : {
15213 : 7874491 : PutDeclaredModule (tok, Sym);
15214 : : }
15215 : 19392084 : }
15216 : :
15217 : :
15218 : : /*
15219 : : GetFirstUsed - returns the token where this symbol was first used.
15220 : : */
15221 : :
15222 : 456 : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym)
15223 : : {
15224 : 456 : SymbolTable_PtrToSymbol pSym;
15225 : :
15226 : 456 : pSym = GetPsym (Sym);
15227 : 456 : switch (pSym->SymbolType)
15228 : : {
15229 : 0 : case SymbolTable_ErrorSym:
15230 : 0 : return pSym->Error.At.FirstUsed;
15231 : 162 : break;
15232 : :
15233 : 162 : case SymbolTable_ObjectSym:
15234 : 162 : return pSym->Object.At.FirstUsed;
15235 : 282 : break;
15236 : :
15237 : 282 : case SymbolTable_UndefinedSym:
15238 : 282 : return pSym->Undefined.At.FirstUsed;
15239 : 0 : break;
15240 : :
15241 : 0 : case SymbolTable_VarientSym:
15242 : 0 : return pSym->Varient.At.FirstUsed;
15243 : 0 : break;
15244 : :
15245 : 0 : case SymbolTable_RecordSym:
15246 : 0 : return pSym->Record.At.FirstUsed;
15247 : 0 : break;
15248 : :
15249 : 0 : case SymbolTable_SubrangeSym:
15250 : 0 : return pSym->Subrange.At.FirstUsed;
15251 : 0 : break;
15252 : :
15253 : 0 : case SymbolTable_EnumerationSym:
15254 : 0 : return pSym->Enumeration.At.FirstUsed;
15255 : 0 : break;
15256 : :
15257 : 0 : case SymbolTable_ArraySym:
15258 : 0 : return pSym->Array.At.FirstUsed;
15259 : 0 : break;
15260 : :
15261 : 0 : case SymbolTable_SubscriptSym:
15262 : 0 : return pSym->Subscript.At.FirstUsed;
15263 : 0 : break;
15264 : :
15265 : 0 : case SymbolTable_UnboundedSym:
15266 : 0 : return pSym->Unbounded.At.FirstUsed;
15267 : 0 : break;
15268 : :
15269 : 0 : case SymbolTable_ProcedureSym:
15270 : 0 : return pSym->Procedure.At.FirstUsed;
15271 : 0 : break;
15272 : :
15273 : 0 : case SymbolTable_ProcTypeSym:
15274 : 0 : return pSym->ProcType.At.FirstUsed;
15275 : 0 : break;
15276 : :
15277 : 0 : case SymbolTable_ParamSym:
15278 : 0 : return pSym->Param.At.FirstUsed;
15279 : 0 : break;
15280 : :
15281 : 0 : case SymbolTable_VarParamSym:
15282 : 0 : return pSym->VarParam.At.FirstUsed;
15283 : 0 : break;
15284 : :
15285 : 0 : case SymbolTable_ConstStringSym:
15286 : 0 : return pSym->ConstString.At.FirstUsed;
15287 : 0 : break;
15288 : :
15289 : 0 : case SymbolTable_ConstLitSym:
15290 : 0 : return pSym->ConstLit.At.FirstUsed;
15291 : 6 : break;
15292 : :
15293 : 6 : case SymbolTable_ConstVarSym:
15294 : 6 : return pSym->ConstVar.At.FirstUsed;
15295 : 6 : break;
15296 : :
15297 : 6 : case SymbolTable_VarSym:
15298 : 6 : return pSym->Var.At.FirstUsed;
15299 : 0 : break;
15300 : :
15301 : 0 : case SymbolTable_TypeSym:
15302 : 0 : return pSym->Type.At.FirstUsed;
15303 : 0 : break;
15304 : :
15305 : 0 : case SymbolTable_PointerSym:
15306 : 0 : return pSym->Pointer.At.FirstUsed;
15307 : 0 : break;
15308 : :
15309 : 0 : case SymbolTable_RecordFieldSym:
15310 : 0 : return pSym->RecordField.At.FirstUsed;
15311 : 0 : break;
15312 : :
15313 : 0 : case SymbolTable_VarientFieldSym:
15314 : 0 : return pSym->VarientField.At.FirstUsed;
15315 : 0 : break;
15316 : :
15317 : 0 : case SymbolTable_EnumerationFieldSym:
15318 : 0 : return pSym->EnumerationField.At.FirstUsed;
15319 : 0 : break;
15320 : :
15321 : 0 : case SymbolTable_SetSym:
15322 : 0 : return pSym->Set.At.FirstUsed;
15323 : 0 : break;
15324 : :
15325 : 0 : case SymbolTable_DefImpSym:
15326 : 0 : return pSym->DefImp.At.FirstUsed;
15327 : 0 : break;
15328 : :
15329 : 0 : case SymbolTable_ModuleSym:
15330 : 0 : return pSym->Module.At.FirstUsed;
15331 : 0 : break;
15332 : :
15333 : :
15334 : 0 : default:
15335 : 0 : M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
15336 : : break;
15337 : : }
15338 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15339 : : __builtin_unreachable ();
15340 : : }
15341 : :
15342 : :
15343 : : /*
15344 : : PutProcedureBegin - assigns begin as the token number matching the
15345 : : procedure BEGIN.
15346 : : */
15347 : :
15348 : 71138 : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin)
15349 : : {
15350 : 71138 : SymbolTable_PtrToSymbol pSym;
15351 : :
15352 : 71138 : pSym = GetPsym (Sym);
15353 : 71138 : switch (pSym->SymbolType)
15354 : : {
15355 : 71138 : case SymbolTable_ProcedureSym:
15356 : 71138 : pSym->Procedure.Begin = begin;
15357 : 71138 : break;
15358 : :
15359 : :
15360 : 0 : default:
15361 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15362 : 71138 : break;
15363 : : }
15364 : 71138 : }
15365 : :
15366 : :
15367 : : /*
15368 : : PutProcedureEnd - assigns end as the token number matching the
15369 : : procedure END.
15370 : : */
15371 : :
15372 : 71108 : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end)
15373 : : {
15374 : 71108 : SymbolTable_PtrToSymbol pSym;
15375 : :
15376 : 71108 : pSym = GetPsym (Sym);
15377 : 71108 : switch (pSym->SymbolType)
15378 : : {
15379 : 71108 : case SymbolTable_ProcedureSym:
15380 : 71108 : pSym->Procedure.End = end;
15381 : 71108 : break;
15382 : :
15383 : :
15384 : 0 : default:
15385 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15386 : 71108 : break;
15387 : : }
15388 : 71108 : }
15389 : :
15390 : :
15391 : : /*
15392 : : GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
15393 : : */
15394 : :
15395 : 2486908 : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end)
15396 : : {
15397 : 2486908 : SymbolTable_PtrToSymbol pSym;
15398 : :
15399 : 2486908 : pSym = GetPsym (Sym);
15400 : 2486908 : switch (pSym->SymbolType)
15401 : : {
15402 : 2486908 : case SymbolTable_ProcedureSym:
15403 : 2486908 : (*begin) = pSym->Procedure.Begin;
15404 : 2486908 : (*end) = pSym->Procedure.End;
15405 : 2486908 : break;
15406 : :
15407 : :
15408 : 0 : default:
15409 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15410 : 2486908 : break;
15411 : : }
15412 : 2486908 : }
15413 : :
15414 : :
15415 : : /*
15416 : : ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
15417 : : */
15418 : :
15419 : 1765175 : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P)
15420 : : {
15421 : 1765175 : SymbolTable_PtrToSymbol pSym;
15422 : :
15423 : 1765175 : pSym = GetPsym (Sym);
15424 : 1765175 : switch (pSym->SymbolType)
15425 : : {
15426 : 331052 : case SymbolTable_DefImpSym:
15427 : 331052 : Lists_ForeachItemInListDo (pSym->DefImp.ListOfProcs, P);
15428 : 331052 : break;
15429 : :
15430 : 108606 : case SymbolTable_ModuleSym:
15431 : 108606 : Lists_ForeachItemInListDo (pSym->Module.ListOfProcs, P);
15432 : 108606 : break;
15433 : :
15434 : 1325517 : case SymbolTable_ProcedureSym:
15435 : 1325517 : Lists_ForeachItemInListDo (pSym->Procedure.ListOfProcs, P);
15436 : 1325517 : break;
15437 : :
15438 : :
15439 : 0 : default:
15440 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
15441 : 1765157 : break;
15442 : : }
15443 : 1765157 : }
15444 : :
15445 : :
15446 : : /*
15447 : : ForeachModuleDo - for each module do procedure, P.
15448 : : */
15449 : :
15450 : 47371 : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P)
15451 : : {
15452 : 47371 : SymbolKey_ForeachNodeDo (ModuleTree, P);
15453 : 47371 : }
15454 : :
15455 : :
15456 : : /*
15457 : : ForeachInnerModuleDo - for each inner module in module, Sym,
15458 : : do procedure, P.
15459 : : */
15460 : :
15461 : 2159793 : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P)
15462 : : {
15463 : 2159793 : SymbolTable_PtrToSymbol pSym;
15464 : :
15465 : 2159793 : pSym = GetPsym (Sym);
15466 : 2159793 : switch (pSym->SymbolType)
15467 : : {
15468 : 336564 : case SymbolTable_DefImpSym:
15469 : 336564 : Lists_ForeachItemInListDo (pSym->DefImp.ListOfModules, P);
15470 : 336564 : break;
15471 : :
15472 : 163196 : case SymbolTable_ModuleSym:
15473 : 163196 : Lists_ForeachItemInListDo (pSym->Module.ListOfModules, P);
15474 : 163196 : break;
15475 : :
15476 : 1660033 : case SymbolTable_ProcedureSym:
15477 : 1660033 : Lists_ForeachItemInListDo (pSym->Procedure.ListOfModules, P);
15478 : 1660033 : break;
15479 : :
15480 : :
15481 : 0 : default:
15482 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
15483 : 2159793 : break;
15484 : : }
15485 : 2159793 : }
15486 : :
15487 : :
15488 : : /*
15489 : : IsVarParam - Returns a conditional depending whether parameter ParamNo
15490 : : is a VAR parameter.
15491 : : */
15492 : :
15493 : 7303669 : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
15494 : : {
15495 : 7303669 : SymbolTable_PtrToSymbol pSym;
15496 : 7303669 : bool IsVar;
15497 : :
15498 : 7303669 : IsVar = false;
15499 : 7303669 : pSym = GetPsym (Sym);
15500 : 7303669 : switch (pSym->SymbolType)
15501 : : {
15502 : : case SymbolTable_ErrorSym:
15503 : : break;
15504 : :
15505 : 7303669 : case SymbolTable_ProcedureSym:
15506 : 7303669 : IsVar = IsNthParamVar (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo);
15507 : 7303669 : break;
15508 : :
15509 : 0 : case SymbolTable_ProcTypeSym:
15510 : 0 : IsVar = IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
15511 : 0 : break;
15512 : :
15513 : :
15514 : 0 : default:
15515 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15516 : 7303669 : break;
15517 : : }
15518 : 7303669 : return IsVar;
15519 : : /* static analysis guarentees a RETURN statement will be used before here. */
15520 : : __builtin_unreachable ();
15521 : : }
15522 : :
15523 : :
15524 : : /*
15525 : : IsVarParamAny - Returns a conditional depending whether parameter ParamNo
15526 : : is a VAR parameter.
15527 : : */
15528 : :
15529 : 8279390 : extern "C" bool SymbolTable_IsVarParamAny (unsigned int Sym, unsigned int ParamNo)
15530 : : {
15531 : 8279390 : SymbolTable_PtrToSymbol pSym;
15532 : 8279390 : SymbolTable_ProcedureKind kind;
15533 : :
15534 : 8279390 : pSym = GetPsym (Sym);
15535 : 8279390 : switch (pSym->SymbolType)
15536 : : {
15537 : : case SymbolTable_ErrorSym:
15538 : : break;
15539 : :
15540 : : case SymbolTable_ProcedureSym:
15541 : 18672428 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
15542 : : {
15543 : 17985995 : if (SymbolTable_GetProcedureDefined (Sym, kind))
15544 : : {
15545 : 7036074 : return IsNthParamVar (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo);
15546 : : }
15547 : : }
15548 : : break;
15549 : :
15550 : 556883 : case SymbolTable_ProcTypeSym:
15551 : 556883 : return IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
15552 : 0 : break;
15553 : :
15554 : :
15555 : 0 : default:
15556 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15557 : : break;
15558 : : }
15559 : : return false;
15560 : : /* static analysis guarentees a RETURN statement will be used before here. */
15561 : : __builtin_unreachable ();
15562 : : }
15563 : :
15564 : :
15565 : : /*
15566 : : IsUnboundedParam - Returns a conditional depending whether parameter
15567 : : ParamNo is an unbounded array procedure parameter.
15568 : : */
15569 : :
15570 : 15006475 : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
15571 : : {
15572 : 15006475 : unsigned int param;
15573 : :
15574 : 15006475 : param = SymbolTable_GetNthParam (Sym, kind, ParamNo);
15575 : 15006475 : return SymbolTable_IsParameterUnbounded (param);
15576 : : /* static analysis guarentees a RETURN statement will be used before here. */
15577 : : __builtin_unreachable ();
15578 : : }
15579 : :
15580 : 13294574 : extern "C" bool SymbolTable_IsUnboundedParamAny (unsigned int Sym, unsigned int ParamNo)
15581 : : {
15582 : 13294574 : SymbolTable_ProcedureKind kind;
15583 : :
15584 : 28607204 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
15585 : : {
15586 : : /*
15587 : : IsUnboundedParam - Returns a conditional depending whether parameter
15588 : : ParamNo is an unbounded array procedure parameter.
15589 : : */
15590 : 28607204 : if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
15591 : : {
15592 : 13294574 : return SymbolTable_IsUnboundedParam (Sym, kind, ParamNo);
15593 : : }
15594 : : }
15595 : 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
15596 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15597 : : __builtin_unreachable ();
15598 : : }
15599 : :
15600 : :
15601 : : /*
15602 : : IsParameterUnbounded - returns TRUE if parameter, Sym, is
15603 : : unbounded.
15604 : : */
15605 : :
15606 : 15006487 : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym)
15607 : : {
15608 : 15006487 : SymbolTable_PtrToSymbol pSym;
15609 : :
15610 : 15006487 : pSym = GetPsym (Sym);
15611 : 15006487 : switch (pSym->SymbolType)
15612 : : {
15613 : 13641473 : case SymbolTable_ParamSym:
15614 : 13641473 : return pSym->Param.IsUnbounded;
15615 : 1365014 : break;
15616 : :
15617 : 1365014 : case SymbolTable_VarParamSym:
15618 : 1365014 : return pSym->VarParam.IsUnbounded;
15619 : 0 : break;
15620 : :
15621 : :
15622 : 0 : default:
15623 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
15624 : : break;
15625 : : }
15626 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15627 : : __builtin_unreachable ();
15628 : : }
15629 : :
15630 : :
15631 : : /*
15632 : : IsParameterVar - returns true if parameter symbol Sym
15633 : : was declared as a VAR.
15634 : : */
15635 : :
15636 : 132 : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym)
15637 : : {
15638 : 132 : SymbolTable_PtrToSymbol pSym;
15639 : :
15640 : 132 : pSym = GetPsym (Sym);
15641 : 132 : switch (pSym->SymbolType)
15642 : : {
15643 : : case SymbolTable_ParamSym:
15644 : : return false;
15645 : 18 : break;
15646 : :
15647 : 18 : case SymbolTable_VarParamSym:
15648 : 18 : return true;
15649 : 0 : break;
15650 : :
15651 : :
15652 : 0 : default:
15653 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
15654 : : break;
15655 : : }
15656 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15657 : : __builtin_unreachable ();
15658 : : }
15659 : :
15660 : :
15661 : : /*
15662 : : GetParameterShadowVar - returns the local variable associated with the
15663 : : parameter symbol, sym.
15664 : : */
15665 : :
15666 : 276 : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym)
15667 : : {
15668 : 276 : SymbolTable_PtrToSymbol pSym;
15669 : :
15670 : 276 : pSym = GetPsym (sym);
15671 : 276 : switch (pSym->SymbolType)
15672 : : {
15673 : 180 : case SymbolTable_ParamSym:
15674 : 180 : return pSym->Param.ShadowVar;
15675 : 96 : break;
15676 : :
15677 : 96 : case SymbolTable_VarParamSym:
15678 : 96 : return pSym->VarParam.ShadowVar;
15679 : 0 : break;
15680 : :
15681 : :
15682 : 0 : default:
15683 : 0 : M2Error_InternalError ((const char *) "expecting a ParamSym or VarParamSym", 35);
15684 : : break;
15685 : : }
15686 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
15687 : : __builtin_unreachable ();
15688 : : }
15689 : :
15690 : :
15691 : : /*
15692 : : NoOfParam - Returns the number of parameters that procedure Sym contains.
15693 : : */
15694 : :
15695 : 16449614 : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym, SymbolTable_ProcedureKind kind)
15696 : : {
15697 : 16449614 : SymbolTable_PtrToSymbol pSym;
15698 : 16449614 : unsigned int n;
15699 : :
15700 : 16449614 : AssertInRange (Sym);
15701 : 16449614 : pSym = GetPsym (Sym);
15702 : 16449614 : switch (pSym->SymbolType)
15703 : : {
15704 : : case SymbolTable_ErrorSym:
15705 : : n = 0;
15706 : : break;
15707 : :
15708 : 16449614 : case SymbolTable_ProcedureSym:
15709 : 16449614 : n = Lists_NoOfItemsInList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam);
15710 : 16449614 : break;
15711 : :
15712 : 0 : case SymbolTable_ProcTypeSym:
15713 : 0 : n = Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
15714 : 0 : break;
15715 : :
15716 : :
15717 : 0 : default:
15718 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
15719 : 16449614 : break;
15720 : : }
15721 : 16449614 : return n;
15722 : : /* static analysis guarentees a RETURN statement will be used before here. */
15723 : : __builtin_unreachable ();
15724 : : }
15725 : :
15726 : :
15727 : : /*
15728 : : HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
15729 : : */
15730 : :
15731 : 0 : extern "C" bool SymbolTable_HasVarParameters (unsigned int p)
15732 : : {
15733 : 0 : unsigned int i;
15734 : 0 : unsigned int n;
15735 : :
15736 : 0 : n = SymbolTable_NoOfParamAny (p);
15737 : 0 : i = 1;
15738 : 0 : while (i <= n)
15739 : : {
15740 : 0 : if (SymbolTable_IsParameterVar (SymbolTable_GetNthParamAny (p, i)))
15741 : : {
15742 : : return true;
15743 : : }
15744 : 0 : i += 1;
15745 : : }
15746 : : return false;
15747 : : /* static analysis guarentees a RETURN statement will be used before here. */
15748 : : __builtin_unreachable ();
15749 : : }
15750 : :
15751 : :
15752 : : /*
15753 : : NoOfLocalVar - returns the number of local variables that exist in
15754 : : procedure Sym. Parameters are NOT included in the
15755 : : count.
15756 : : */
15757 : :
15758 : 30 : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym)
15759 : : {
15760 : 30 : SymbolTable_PtrToSymbol pSym;
15761 : 30 : unsigned int n;
15762 : :
15763 : 30 : pSym = GetPsym (Sym);
15764 : 30 : switch (pSym->SymbolType)
15765 : : {
15766 : : case SymbolTable_ErrorSym:
15767 : : n = 0;
15768 : : break;
15769 : :
15770 : 30 : case SymbolTable_ProcedureSym:
15771 : 30 : n = Lists_NoOfItemsInList (pSym->Procedure.ListOfVars);
15772 : 30 : break;
15773 : :
15774 : :
15775 : 0 : default:
15776 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
15777 : 30 : break;
15778 : : }
15779 : : /*
15780 : : Parameters are actually included in the list of local varaibles,
15781 : : therefore we must subtract the Parameter Number from local variable
15782 : : total.
15783 : : */
15784 : 30 : return n-(SymbolTable_NoOfParamAny (Sym));
15785 : : /* static analysis guarentees a RETURN statement will be used before here. */
15786 : : __builtin_unreachable ();
15787 : : }
15788 : :
15789 : :
15790 : : /*
15791 : : IsDefImp - returns true is the Sym is a DefImp symbol.
15792 : : Definition/Implementation module symbol.
15793 : : */
15794 : :
15795 : 219830753 : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym)
15796 : : {
15797 : 219830753 : SymbolTable_PtrToSymbol pSym;
15798 : :
15799 : 219830753 : pSym = GetPsym (Sym);
15800 : 219830753 : return pSym->SymbolType == SymbolTable_DefImpSym;
15801 : : /* static analysis guarentees a RETURN statement will be used before here. */
15802 : : __builtin_unreachable ();
15803 : : }
15804 : :
15805 : :
15806 : : /*
15807 : : IsModule - returns true is the Sym is a Module symbol.
15808 : : Program module symbol.
15809 : : */
15810 : :
15811 : 185290632 : extern "C" bool SymbolTable_IsModule (unsigned int Sym)
15812 : : {
15813 : 185290632 : SymbolTable_PtrToSymbol pSym;
15814 : :
15815 : 185290632 : pSym = GetPsym (Sym);
15816 : 185290632 : return pSym->SymbolType == SymbolTable_ModuleSym;
15817 : : /* static analysis guarentees a RETURN statement will be used before here. */
15818 : : __builtin_unreachable ();
15819 : : }
15820 : :
15821 : :
15822 : : /*
15823 : : IsInnerModule - returns true if the symbol, Sym, is an inner module.
15824 : : */
15825 : :
15826 : 6744856 : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym)
15827 : : {
15828 : 6744856 : if (SymbolTable_IsModule (Sym))
15829 : : {
15830 : 221230 : return (SymbolTable_GetScope (Sym)) != SymbolTable_NulSym;
15831 : : }
15832 : : else
15833 : : {
15834 : : return false;
15835 : : }
15836 : : /* static analysis guarentees a RETURN statement will be used before here. */
15837 : : __builtin_unreachable ();
15838 : : }
15839 : :
15840 : :
15841 : : /*
15842 : : GetSymName - returns the symbol name.
15843 : : */
15844 : :
15845 : 911135774 : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym)
15846 : : {
15847 : 911135774 : SymbolTable_PtrToSymbol pSym;
15848 : 911135774 : NameKey_Name n;
15849 : :
15850 : 911135774 : if (Sym == SymbolTable_NulSym)
15851 : : {
15852 : : n = SymbolKey_NulKey;
15853 : : }
15854 : : else
15855 : : {
15856 : 911135774 : pSym = GetPsym (Sym);
15857 : 911135774 : switch (pSym->SymbolType)
15858 : : {
15859 : 327 : case SymbolTable_ErrorSym:
15860 : 327 : n = pSym->Error.name;
15861 : 327 : break;
15862 : :
15863 : 9089234 : case SymbolTable_ObjectSym:
15864 : 9089234 : n = pSym->Object.name;
15865 : 9089234 : break;
15866 : :
15867 : 5390739 : case SymbolTable_DefImpSym:
15868 : 5390739 : n = pSym->DefImp.name;
15869 : 5390739 : break;
15870 : :
15871 : 470833 : case SymbolTable_ModuleSym:
15872 : 470833 : n = pSym->Module.name;
15873 : 470833 : break;
15874 : :
15875 : 718218921 : case SymbolTable_TypeSym:
15876 : 718218921 : n = pSym->Type.name;
15877 : 718218921 : break;
15878 : :
15879 : 6537162 : case SymbolTable_VarSym:
15880 : 6537162 : n = pSym->Var.name;
15881 : 6537162 : break;
15882 : :
15883 : 14001 : case SymbolTable_ConstLitSym:
15884 : 14001 : n = pSym->ConstLit.name;
15885 : 14001 : break;
15886 : :
15887 : 125822 : case SymbolTable_ConstVarSym:
15888 : 125822 : n = pSym->ConstVar.name;
15889 : 125822 : break;
15890 : :
15891 : 8950 : case SymbolTable_ConstStringSym:
15892 : 8950 : n = pSym->ConstString.name;
15893 : 8950 : break;
15894 : :
15895 : 969552 : case SymbolTable_EnumerationSym:
15896 : 969552 : n = pSym->Enumeration.name;
15897 : 969552 : break;
15898 : :
15899 : 1389387 : case SymbolTable_EnumerationFieldSym:
15900 : 1389387 : n = pSym->EnumerationField.name;
15901 : 1389387 : break;
15902 : :
15903 : 9907296 : case SymbolTable_UndefinedSym:
15904 : 9907296 : n = pSym->Undefined.name;
15905 : 9907296 : break;
15906 : :
15907 : 30823065 : case SymbolTable_ProcedureSym:
15908 : 30823065 : n = pSym->Procedure.name;
15909 : 30823065 : break;
15910 : :
15911 : 524394 : case SymbolTable_ProcTypeSym:
15912 : 524394 : n = pSym->ProcType.name;
15913 : 524394 : break;
15914 : :
15915 : 878312 : case SymbolTable_RecordFieldSym:
15916 : 878312 : n = pSym->RecordField.name;
15917 : 878312 : break;
15918 : :
15919 : 291700 : case SymbolTable_RecordSym:
15920 : 291700 : n = pSym->Record.name;
15921 : 291700 : break;
15922 : :
15923 : : case SymbolTable_VarientSym:
15924 : : n = NameKey_NulName;
15925 : : break;
15926 : :
15927 : 810 : case SymbolTable_VarientFieldSym:
15928 : 810 : n = pSym->VarientField.name;
15929 : 810 : break;
15930 : :
15931 : 7367 : case SymbolTable_VarParamSym:
15932 : 7367 : n = pSym->VarParam.name;
15933 : 7367 : break;
15934 : :
15935 : 69930 : case SymbolTable_ParamSym:
15936 : 69930 : n = pSym->Param.name;
15937 : 69930 : break;
15938 : :
15939 : 51313316 : case SymbolTable_PointerSym:
15940 : 51313316 : n = pSym->Pointer.name;
15941 : 51313316 : break;
15942 : :
15943 : 85044 : case SymbolTable_ArraySym:
15944 : 85044 : n = pSym->Array.name;
15945 : 85044 : break;
15946 : :
15947 : : case SymbolTable_UnboundedSym:
15948 : : n = NameKey_NulName;
15949 : : break;
15950 : :
15951 : 270227 : case SymbolTable_SubrangeSym:
15952 : 270227 : n = pSym->Subrange.name;
15953 : 270227 : break;
15954 : :
15955 : 69909398 : case SymbolTable_SetSym:
15956 : 69909398 : n = pSym->Set.name;
15957 : 69909398 : break;
15958 : :
15959 : : case SymbolTable_SubscriptSym:
15960 : : n = NameKey_NulName;
15961 : : break;
15962 : :
15963 : : case SymbolTable_DummySym:
15964 : : n = NameKey_NulName;
15965 : : break;
15966 : :
15967 : 0 : case SymbolTable_PartialUnboundedSym:
15968 : 0 : n = SymbolTable_GetSymName (pSym->PartialUnbounded.Type);
15969 : 0 : break;
15970 : :
15971 : : case SymbolTable_TupleSym:
15972 : : n = NameKey_NulName;
15973 : : break;
15974 : :
15975 : : case SymbolTable_GnuAsmSym:
15976 : : n = NameKey_NulName;
15977 : : break;
15978 : :
15979 : : case SymbolTable_InterfaceSym:
15980 : : n = NameKey_NulName;
15981 : : break;
15982 : :
15983 : : case SymbolTable_ImportSym:
15984 : : n = NameKey_NulName;
15985 : : break;
15986 : :
15987 : : case SymbolTable_ImportStatementSym:
15988 : : n = NameKey_NulName;
15989 : : break;
15990 : :
15991 : :
15992 : 0 : default:
15993 : 0 : M2Error_InternalError ((const char *) "unexpected symbol type", 22);
15994 : 911135774 : break;
15995 : : }
15996 : : }
15997 : 911135774 : return n;
15998 : : /* static analysis guarentees a RETURN statement will be used before here. */
15999 : : __builtin_unreachable ();
16000 : : }
16001 : :
16002 : :
16003 : : /*
16004 : : RenameSym - renames a symbol, Sym, with SymName.
16005 : : It also checks the unknown tree for a symbol
16006 : : with this new name. Must only be renamed in
16007 : : the same scope of being declared.
16008 : : */
16009 : :
16010 : 0 : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName)
16011 : : {
16012 : 0 : SymbolTable_PtrToSymbol pSym;
16013 : :
16014 : 0 : if ((SymbolTable_GetSymName (Sym)) == NameKey_NulName)
16015 : : {
16016 : 0 : pSym = GetPsym (Sym);
16017 : 0 : switch (pSym->SymbolType)
16018 : : {
16019 : 0 : case SymbolTable_ErrorSym:
16020 : 0 : M2Error_ErrorAbort0 ((const char *) "", 0);
16021 : 0 : break;
16022 : :
16023 : 0 : case SymbolTable_TypeSym:
16024 : 0 : pSym->Type.name = SymName;
16025 : 0 : break;
16026 : :
16027 : 0 : case SymbolTable_VarSym:
16028 : 0 : pSym->Var.name = SymName;
16029 : 0 : break;
16030 : :
16031 : 0 : case SymbolTable_ConstLitSym:
16032 : 0 : pSym->ConstLit.name = SymName;
16033 : 0 : break;
16034 : :
16035 : 0 : case SymbolTable_ConstVarSym:
16036 : 0 : pSym->ConstVar.name = SymName;
16037 : 0 : break;
16038 : :
16039 : 0 : case SymbolTable_UndefinedSym:
16040 : 0 : pSym->Undefined.name = SymName;
16041 : 0 : break;
16042 : :
16043 : 0 : case SymbolTable_RecordSym:
16044 : 0 : pSym->Record.name = SymName;
16045 : 0 : break;
16046 : :
16047 : 0 : case SymbolTable_PointerSym:
16048 : 0 : pSym->Pointer.name = SymName;
16049 : 0 : break;
16050 : :
16051 : :
16052 : 0 : default:
16053 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
16054 : 0 : break;
16055 : : }
16056 : 0 : AddSymToScope (Sym, SymName);
16057 : : }
16058 : : else
16059 : : {
16060 : 0 : M2Error_InternalError ((const char *) "old name of symbol must be nul", 30);
16061 : : }
16062 : 0 : }
16063 : :
16064 : :
16065 : : /*
16066 : : IsUnknown - returns true is the symbol Sym is unknown.
16067 : : */
16068 : :
16069 : 32762542 : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym)
16070 : : {
16071 : 32762542 : SymbolTable_PtrToSymbol pSym;
16072 : :
16073 : 32762542 : AssertInRange (Sym);
16074 : 32762542 : pSym = GetPsym (Sym);
16075 : 32762542 : return pSym->SymbolType == SymbolTable_UndefinedSym;
16076 : : /* static analysis guarentees a RETURN statement will be used before here. */
16077 : : __builtin_unreachable ();
16078 : : }
16079 : :
16080 : :
16081 : : /*
16082 : : IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
16083 : : */
16084 : :
16085 : 694932 : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym)
16086 : : {
16087 : 694932 : SymbolTable_PtrToSymbol pSym;
16088 : :
16089 : 694932 : if (sym > 0)
16090 : : {
16091 : 694932 : pSym = GetPsym (sym);
16092 : 694932 : switch (pSym->SymbolType)
16093 : : {
16094 : : case SymbolTable_PartialUnboundedSym:
16095 : : return true;
16096 : : break;
16097 : :
16098 : :
16099 : : default:
16100 : : return false;
16101 : : break;
16102 : : }
16103 : : }
16104 : : else
16105 : : {
16106 : : return false;
16107 : : }
16108 : : /* static analysis guarentees a RETURN statement will be used before here. */
16109 : : __builtin_unreachable ();
16110 : : }
16111 : :
16112 : :
16113 : : /*
16114 : : RequestSym - searches for a symbol with a name SymName in the
16115 : : current and previous scopes.
16116 : : If the symbol is found then it is returned
16117 : : else an unknown symbol is returned create at token
16118 : : position, tok.
16119 : : This procedure does search the base scope (for
16120 : : pervasive identifiers).
16121 : : */
16122 : :
16123 : 27603002 : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName)
16124 : : {
16125 : 27603002 : unsigned int Sym;
16126 : :
16127 : : /*
16128 : : WriteString('RequestSym for: ') ; WriteKey(SymName) ; WriteLn ;
16129 : : */
16130 : 27603002 : Sym = SymbolTable_GetSym (SymName);
16131 : 27603002 : if (Sym == SymbolTable_NulSym)
16132 : : {
16133 : 4210270 : Sym = GetSymFromUnknownTree (SymName);
16134 : 4210270 : if (Sym == SymbolTable_NulSym)
16135 : : {
16136 : : /* Make unknown */
16137 : 4210270 : NewSym (&Sym);
16138 : 4210270 : FillInUnknownFields (tok, Sym, SymName);
16139 : : /*
16140 : : ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
16141 : : */
16142 : 4210270 : AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
16143 : : }
16144 : : }
16145 : 27603002 : return Sym;
16146 : : /* static analysis guarentees a RETURN statement will be used before here. */
16147 : : __builtin_unreachable ();
16148 : : }
16149 : :
16150 : :
16151 : : /*
16152 : : PutImported - places a symbol, Sym, into the current main scope.
16153 : : */
16154 : :
16155 : 733398 : extern "C" void SymbolTable_PutImported (unsigned int Sym)
16156 : : {
16157 : 733398 : SymbolTable_PtrToSymbol pSym;
16158 : 733398 : unsigned int ModSym;
16159 : 733398 : NameKey_Name n;
16160 : :
16161 : : /*
16162 : : We have currently imported Sym, now place it into the current module.
16163 : : */
16164 : 733398 : ModSym = SymbolTable_GetCurrentModuleScope ();
16165 : 1466796 : M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
16166 : 733398 : pSym = GetPsym (ModSym);
16167 : 733398 : switch (pSym->SymbolType)
16168 : : {
16169 : 98934 : case SymbolTable_ModuleSym:
16170 : 98934 : if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
16171 : : {
16172 : : /* avoid dangling else. */
16173 : 90 : if (M2Options_Pedantic)
16174 : : {
16175 : 6 : n = SymbolTable_GetSymName (Sym);
16176 : 6 : M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
16177 : : }
16178 : : }
16179 : 98844 : else if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
16180 : : {
16181 : : /* avoid dangling else. */
16182 : 98844 : if ((SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym)) == SymbolKey_NulKey)
16183 : : {
16184 : 98844 : SymbolKey_PutSymKey (pSym->Module.WhereImported, Sym, M2LexBuf_GetTokenNo ());
16185 : : }
16186 : 98844 : SymbolKey_PutSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym), Sym);
16187 : 98844 : SymbolTable_AddSymToModuleScope (ModSym, Sym);
16188 : : }
16189 : : else
16190 : : {
16191 : : /* avoid dangling else. */
16192 : 0 : n = SymbolTable_GetSymName (Sym);
16193 : 0 : M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
16194 : : }
16195 : : break;
16196 : :
16197 : 634464 : case SymbolTable_DefImpSym:
16198 : 634464 : if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
16199 : : {
16200 : : /* avoid dangling else. */
16201 : 96 : if (M2Options_Pedantic)
16202 : : {
16203 : 0 : n = SymbolTable_GetSymName (Sym);
16204 : 0 : M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
16205 : : }
16206 : : }
16207 : 634368 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
16208 : : {
16209 : : /* avoid dangling else. */
16210 : 634368 : if ((SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym)) == SymbolKey_NulKey)
16211 : : {
16212 : 634368 : SymbolKey_PutSymKey (pSym->DefImp.WhereImported, Sym, M2LexBuf_GetTokenNo ());
16213 : : }
16214 : 634368 : SymbolKey_PutSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym), Sym);
16215 : 634368 : SymbolTable_AddSymToModuleScope (ModSym, Sym);
16216 : : }
16217 : : else
16218 : : {
16219 : : /* avoid dangling else. */
16220 : 0 : n = SymbolTable_GetSymName (Sym);
16221 : 0 : M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
16222 : : }
16223 : : break;
16224 : :
16225 : :
16226 : 0 : default:
16227 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
16228 : 733398 : break;
16229 : : }
16230 : 733398 : }
16231 : :
16232 : :
16233 : : /*
16234 : : PutIncluded - places a symbol, Sym, into the included list of the
16235 : : current module.
16236 : : Symbols that are placed in this list are indirectly declared
16237 : : by:
16238 : :
16239 : : IMPORT modulename ;
16240 : :
16241 : : modulename.identifier
16242 : : */
16243 : :
16244 : 365606 : extern "C" void SymbolTable_PutIncluded (unsigned int Sym)
16245 : : {
16246 : 365606 : SymbolTable_PtrToSymbol pSym;
16247 : 365606 : unsigned int ModSym;
16248 : 365606 : NameKey_Name n1;
16249 : 365606 : NameKey_Name n2;
16250 : :
16251 : : /*
16252 : : We have referenced Sym, via modulename.Sym
16253 : : now place it into the current module include list.
16254 : : */
16255 : 365606 : ModSym = SymbolTable_GetCurrentModuleScope ();
16256 : 731212 : M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
16257 : 365606 : if (DebugUnknowns)
16258 : : {
16259 : : n1 = SymbolTable_GetSymName (Sym);
16260 : : n2 = SymbolTable_GetSymName (ModSym);
16261 : : 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));
16262 : : }
16263 : 365606 : pSym = GetPsym (ModSym);
16264 : 365606 : switch (pSym->SymbolType)
16265 : : {
16266 : 3722 : case SymbolTable_ModuleSym:
16267 : 3722 : Lists_IncludeItemIntoList (pSym->Module.IncludeList, Sym);
16268 : 3722 : break;
16269 : :
16270 : 361884 : case SymbolTable_DefImpSym:
16271 : 361884 : Lists_IncludeItemIntoList (pSym->DefImp.IncludeList, Sym);
16272 : 361884 : break;
16273 : :
16274 : :
16275 : 0 : default:
16276 : 0 : M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
16277 : 365606 : break;
16278 : : }
16279 : 365606 : }
16280 : :
16281 : :
16282 : : /*
16283 : : PutExported - places a symbol, Sym into the next level out module.
16284 : : Sym is also placed in the ExportTree of the current inner
16285 : : module.
16286 : : */
16287 : :
16288 : 276 : extern "C" void SymbolTable_PutExported (unsigned int Sym)
16289 : : {
16290 : 276 : SymbolTable_PtrToSymbol pSym;
16291 : :
16292 : : /*
16293 : : WriteString('PutExported') ; WriteLn ;
16294 : : */
16295 : 276 : SymbolTable_AddSymToModuleScope (GetLastModuleOrProcedureScope (), Sym);
16296 : 276 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
16297 : 276 : switch (pSym->SymbolType)
16298 : : {
16299 : 276 : case SymbolTable_ModuleSym:
16300 : 276 : SymbolKey_PutSymKey (pSym->Module.ExportTree, SymbolTable_GetSymName (Sym), Sym);
16301 : 276 : if (SymbolTable_IsUnknown (Sym))
16302 : : {
16303 : 276 : PutExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
16304 : : }
16305 : : /*
16306 : : ; WriteKey(Module.name) ; WriteString(' exports ') ;
16307 : : ; WriteKey(GetSymName(Sym)) ; WriteLn ;
16308 : : */
16309 : 276 : break;
16310 : :
16311 : :
16312 : 0 : default:
16313 : 0 : M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
16314 : 276 : break;
16315 : : }
16316 : 276 : }
16317 : :
16318 : :
16319 : : /*
16320 : : PutExportQualified - places a symbol with the name, SymName,
16321 : : into the export tree of the
16322 : : Definition module being compiled.
16323 : : The symbol with name has been EXPORT QUALIFIED
16324 : : by the definition module and therefore any reference
16325 : : to this symbol in the code generation phase
16326 : : will be in the form _Module_Name.
16327 : : */
16328 : :
16329 : 2758485 : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName)
16330 : : {
16331 : 2758485 : SymbolTable_PtrToSymbol pSym;
16332 : 2758485 : NameKey_Name n;
16333 : 2758485 : unsigned int Sym;
16334 : 2758485 : unsigned int ModSym;
16335 : :
16336 : 2758485 : ModSym = SymbolTable_GetCurrentModule ();
16337 : 2758485 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16338 : 5516970 : M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
16339 : : /*
16340 : : WriteString('1st MODULE ') ; WriteKey(GetSymName(ModSym)) ;
16341 : : WriteString(' identifier ') ; WriteKey(SymName) ; WriteLn ;
16342 : : */
16343 : 2758485 : pSym = GetPsym (ModSym);
16344 : 2758485 : switch (pSym->SymbolType)
16345 : : {
16346 : 2758485 : case SymbolTable_DefImpSym:
16347 : 2758485 : if (((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
16348 : : {
16349 : 6 : n = SymbolTable_GetSymName (ModSym);
16350 : 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));
16351 : : }
16352 : 2758479 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
16353 : : {
16354 : : /* avoid dangling else. */
16355 : 258351 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
16356 : 258351 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
16357 : 258351 : SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
16358 : 258351 : PutExportUndeclared (ModSym, Sym);
16359 : : }
16360 : : else
16361 : : {
16362 : : /* avoid dangling else. */
16363 : 2500128 : Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
16364 : 2500128 : SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
16365 : 2500128 : PutExportUndeclared (ModSym, Sym);
16366 : : }
16367 : 2758485 : break;
16368 : :
16369 : :
16370 : 0 : default:
16371 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16372 : 2758485 : break;
16373 : : }
16374 : 2758485 : }
16375 : :
16376 : :
16377 : : /*
16378 : : PutExportUnQualified - places a symbol with the name, SymName,
16379 : : into the export tree of the
16380 : : Definition module being compiled.
16381 : : The symbol with Name has been EXPORT UNQUALIFIED
16382 : : by the definition module and therefore any reference
16383 : : to this symbol in the code generation phase
16384 : : will be in the form _Name.
16385 : : */
16386 : :
16387 : 404924 : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName)
16388 : : {
16389 : 404924 : SymbolTable_PtrToSymbol pSym;
16390 : 404924 : NameKey_Name n;
16391 : 404924 : unsigned int Sym;
16392 : 404924 : unsigned int ModSym;
16393 : :
16394 : 404924 : ModSym = SymbolTable_GetCurrentModule ();
16395 : 404924 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16396 : 809848 : M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
16397 : 404924 : pSym = GetPsym (ModSym);
16398 : 404924 : switch (pSym->SymbolType)
16399 : : {
16400 : 404924 : case SymbolTable_DefImpSym:
16401 : 404924 : if (((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
16402 : : {
16403 : 0 : n = SymbolTable_GetSymName (ModSym);
16404 : 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));
16405 : : }
16406 : 404924 : else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
16407 : : {
16408 : : /* avoid dangling else. */
16409 : 26363 : Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
16410 : 26363 : SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
16411 : 26363 : SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
16412 : 26363 : PutExportUndeclared (ModSym, Sym);
16413 : : }
16414 : : else
16415 : : {
16416 : : /* avoid dangling else. */
16417 : 378561 : Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
16418 : 378561 : SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
16419 : 378561 : PutExportUndeclared (ModSym, Sym);
16420 : : }
16421 : 404924 : break;
16422 : :
16423 : :
16424 : 0 : default:
16425 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16426 : 404924 : break;
16427 : : }
16428 : 404924 : }
16429 : :
16430 : :
16431 : : /*
16432 : : PutExportUnImplemented - places a symbol, Sym, into the currently compiled
16433 : : DefImp module NeedToBeImplemented list.
16434 : : */
16435 : :
16436 : 2053719 : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym)
16437 : : {
16438 : 2053719 : SymbolTable_PtrToSymbol pSym;
16439 : :
16440 : 2053719 : pSym = GetPsym (CurrentModule);
16441 : 2053719 : switch (pSym->SymbolType)
16442 : : {
16443 : 2053719 : case SymbolTable_DefImpSym:
16444 : 2053719 : if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
16445 : : {
16446 : : /*
16447 : : n1 := GetSymName (Sym) ;
16448 : : n2 := GetSymName (CurrentModule) ;
16449 : : WriteFormat2 ('symbol (%a) already exported from module (%a)', n1, n2)
16450 : : */
16451 : 0 : M2MetaError_MetaErrorT2 (tokenno, (const char *) "symbol {%1a} is already exported from module {%2a}", 50, Sym, CurrentModule);
16452 : : }
16453 : : else
16454 : : {
16455 : 2053719 : SymbolKey_PutSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym), Sym);
16456 : : }
16457 : 2053719 : break;
16458 : :
16459 : :
16460 : 0 : default:
16461 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16462 : 2053719 : break;
16463 : : }
16464 : 2053719 : }
16465 : :
16466 : :
16467 : : /*
16468 : : GetExported - returns the symbol which has a name SymName,
16469 : : and is exported from the definition module ModSym.
16470 : :
16471 : : */
16472 : :
16473 : 2058208 : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName)
16474 : : {
16475 : 2058208 : SymbolTable_PtrToSymbol pSym;
16476 : 2058208 : unsigned int Sym;
16477 : :
16478 : 2058208 : pSym = GetPsym (ModSym);
16479 : 2058208 : switch (pSym->SymbolType)
16480 : : {
16481 : 2058100 : case SymbolTable_DefImpSym:
16482 : 2058100 : Sym = RequestFromDefinition (tokenno, ModSym, SymName);
16483 : 2058100 : break;
16484 : :
16485 : 108 : case SymbolTable_ModuleSym:
16486 : 108 : Sym = RequestFromModule (tokenno, ModSym, SymName);
16487 : 108 : break;
16488 : :
16489 : :
16490 : 0 : default:
16491 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16492 : 2058208 : break;
16493 : : }
16494 : 2058208 : return Sym;
16495 : : /* static analysis guarentees a RETURN statement will be used before here. */
16496 : : __builtin_unreachable ();
16497 : : }
16498 : :
16499 : :
16500 : : /*
16501 : : GetFromOuterModule - returns a symbol with name, SymName, which comes
16502 : : from outside the current module.
16503 : : */
16504 : :
16505 : 324 : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName)
16506 : : {
16507 : 324 : SymbolTable_PtrToCallFrame pCall;
16508 : 324 : unsigned int ScopeId;
16509 : 324 : unsigned int Sym;
16510 : 324 : unsigned int ScopeSym;
16511 : :
16512 : 324 : ScopeId = ScopePtr;
16513 : 324 : pCall = GetPcall (ScopeId);
16514 : 672 : while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
16515 : : {
16516 : 24 : M2Debug_Assert (ScopeId > 0);
16517 : 24 : ScopeId -= 1;
16518 : 24 : pCall = GetPcall (ScopeId);
16519 : : }
16520 : 324 : ScopeId -= 1;
16521 : : /* we are now below the current module */
16522 : 480 : while (ScopeId > 0)
16523 : : {
16524 : 480 : pCall = GetPcall (ScopeId);
16525 : 480 : ScopeSym = pCall->Search;
16526 : 480 : if (ScopeSym != SymbolTable_NulSym)
16527 : : {
16528 : 480 : Sym = SymbolTable_GetLocalSym (ScopeSym, SymName);
16529 : 480 : if (Sym == SymbolTable_NulSym)
16530 : : {
16531 : : /* avoid dangling else. */
16532 : 168 : if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsProcedure (ScopeSym))) || (SymbolTable_IsDefImp (ScopeSym)))
16533 : : {
16534 : 132 : if (Sym == SymbolTable_NulSym)
16535 : : {
16536 : 132 : Sym = ExamineUnresolvedTree (ScopeSym, SymName);
16537 : 132 : if (Sym != SymbolTable_NulSym)
16538 : : {
16539 : : return Sym;
16540 : : }
16541 : : }
16542 : : }
16543 : : }
16544 : : else
16545 : : {
16546 : : return Sym;
16547 : : }
16548 : : }
16549 : 156 : ScopeId -= 1;
16550 : 156 : pCall = GetPcall (ScopeId);
16551 : : }
16552 : : /* at this point we force an unknown from the last module scope */
16553 : 0 : return RequestFromModule (tokenno, SymbolTable_GetLastModuleScope (), SymName);
16554 : : /* static analysis guarentees a RETURN statement will be used before here. */
16555 : : __builtin_unreachable ();
16556 : : }
16557 : :
16558 : :
16559 : : /*
16560 : : TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
16561 : : name, name, which is
16562 : : currently undefined in the
16563 : : outer scope to the inner scope.
16564 : : If successful then the symbol is
16565 : : returned otherwise NulSym is
16566 : : returned.
16567 : : */
16568 : :
16569 : 234 : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name)
16570 : : {
16571 : 234 : SymbolTable_PtrToSymbol pSym;
16572 : 234 : unsigned int sym;
16573 : :
16574 : : /* assume this should not be called if OuterScope was a procedure
16575 : : as this case is handled by the caller (P1SymBuild)
16576 : : */
16577 : 468 : M2Debug_Assert ((SymbolTable_IsModule (OuterScope)) || (SymbolTable_IsDefImp (OuterScope)));
16578 : 234 : sym = GetExportUndeclared (OuterScope, name);
16579 : 234 : if (sym != SymbolTable_NulSym)
16580 : : {
16581 : 18 : M2Debug_Assert (SymbolTable_IsUnknown (sym));
16582 : 18 : RemoveExportUndeclared (OuterScope, sym);
16583 : 18 : SymbolTable_AddSymToModuleScope (OuterScope, sym);
16584 : 18 : AddVarToScopeList (OuterScope, sym);
16585 : 18 : pSym = GetPsym (OuterScope);
16586 : 18 : switch (pSym->SymbolType)
16587 : : {
16588 : 0 : case SymbolTable_DefImpSym:
16589 : 0 : if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) == sym)
16590 : : {
16591 : 0 : SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
16592 : : }
16593 : : break;
16594 : :
16595 : 18 : case SymbolTable_ModuleSym:
16596 : 18 : if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) == sym)
16597 : : {
16598 : 18 : SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
16599 : : }
16600 : : break;
16601 : :
16602 : :
16603 : 0 : default:
16604 : 0 : M2Error_InternalError ((const char *) "expecting DefImp, Module symbol", 31);
16605 : 18 : break;
16606 : : }
16607 : 18 : AddSymToUnknown (InnerScope, name, sym);
16608 : 18 : PutExportUndeclared (InnerScope, sym);
16609 : : }
16610 : 234 : return sym;
16611 : : /* static analysis guarentees a RETURN statement will be used before here. */
16612 : : __builtin_unreachable ();
16613 : : }
16614 : :
16615 : :
16616 : : /*
16617 : : IsExportQualified - returns true if a symbol, Sym, was defined as
16618 : : being EXPORT QUALIFIED.
16619 : : Sym is expected to be either a procedure or a
16620 : : variable.
16621 : : */
16622 : :
16623 : 5887252 : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym)
16624 : : {
16625 : 5887252 : SymbolTable_PtrToSymbol pSym;
16626 : 5887252 : unsigned int OuterModule;
16627 : :
16628 : 5887252 : OuterModule = Sym;
16629 : 6459639 : do {
16630 : 6459639 : OuterModule = SymbolTable_GetScope (OuterModule);
16631 : 6459639 : } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
16632 : 5887252 : pSym = GetPsym (OuterModule);
16633 : 5887252 : switch (pSym->SymbolType)
16634 : : {
16635 : : case SymbolTable_ModuleSym:
16636 : : return false;
16637 : 5448142 : break;
16638 : :
16639 : 5448142 : case SymbolTable_DefImpSym:
16640 : 5448142 : return (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
16641 : 0 : break;
16642 : :
16643 : :
16644 : 0 : default:
16645 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16646 : : break;
16647 : : }
16648 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16649 : : __builtin_unreachable ();
16650 : : }
16651 : :
16652 : :
16653 : : /*
16654 : : IsExportUnQualified - returns true if a symbol, Sym, was defined as
16655 : : being EXPORT UNQUALIFIED.
16656 : : */
16657 : :
16658 : 2665196 : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym)
16659 : : {
16660 : 2665196 : SymbolTable_PtrToSymbol pSym;
16661 : 2665196 : unsigned int OuterModule;
16662 : :
16663 : 2665196 : OuterModule = Sym;
16664 : 2665196 : do {
16665 : 2665196 : OuterModule = SymbolTable_GetScope (OuterModule);
16666 : 2665196 : } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
16667 : 2665196 : pSym = GetPsym (OuterModule);
16668 : 2665196 : switch (pSym->SymbolType)
16669 : : {
16670 : : case SymbolTable_ModuleSym:
16671 : : return false;
16672 : 2586079 : break;
16673 : :
16674 : 2586079 : case SymbolTable_DefImpSym:
16675 : 2586079 : return (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
16676 : 0 : break;
16677 : :
16678 : :
16679 : 0 : default:
16680 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16681 : : break;
16682 : : }
16683 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16684 : : __builtin_unreachable ();
16685 : : }
16686 : :
16687 : :
16688 : : /*
16689 : : IsExported - returns true if a symbol, Sym, is exported
16690 : : from module, ModSym.
16691 : : If ModSym is a DefImp symbol then its
16692 : : ExportQualified and ExportUnQualified lists are examined.
16693 : : */
16694 : :
16695 : 5048793 : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym)
16696 : : {
16697 : 5048793 : SymbolTable_PtrToSymbol pSym;
16698 : 5048793 : NameKey_Name SymName;
16699 : :
16700 : 5048793 : SymName = SymbolTable_GetSymName (Sym);
16701 : 5048793 : pSym = GetPsym (ModSym);
16702 : 5048793 : switch (pSym->SymbolType)
16703 : : {
16704 : 4578672 : case SymbolTable_DefImpSym:
16705 : 4578672 : return ((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) == Sym) || ((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) == Sym);
16706 : 470121 : break;
16707 : :
16708 : 470121 : case SymbolTable_ModuleSym:
16709 : 470121 : return (SymbolKey_GetSymKey (pSym->Module.ExportTree, SymName)) == Sym;
16710 : 0 : break;
16711 : :
16712 : :
16713 : 0 : default:
16714 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16715 : : break;
16716 : : }
16717 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16718 : : __builtin_unreachable ();
16719 : : }
16720 : :
16721 : :
16722 : : /*
16723 : : IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
16724 : : ModSym must be a defimp symbol.
16725 : : */
16726 : :
16727 : 84 : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym)
16728 : : {
16729 : 84 : unsigned int type;
16730 : 84 : SymbolTable_PtrToSymbol pSym;
16731 : :
16732 : 84 : if ((SymbolTable_IsDefImp (ModSym)) && (SymbolTable_IsFieldEnumeration (Sym)))
16733 : : {
16734 : 66 : pSym = GetPsym (ModSym);
16735 : 66 : type = SymbolTable_SkipType (SymbolTable_GetType (Sym));
16736 : 66 : return Lists_IsItemInList (pSym->DefImp.EnumerationScopeList, type);
16737 : : }
16738 : : return false;
16739 : : /* static analysis guarentees a RETURN statement will be used before here. */
16740 : : __builtin_unreachable ();
16741 : : }
16742 : :
16743 : :
16744 : : /*
16745 : : IsImported - returns true if a symbol, Sym, in module, ModSym,
16746 : : was imported.
16747 : : */
16748 : :
16749 : 20698500 : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym)
16750 : : {
16751 : 20698500 : SymbolTable_PtrToSymbol pSym;
16752 : 20698500 : NameKey_Name SymName;
16753 : :
16754 : 20698500 : SymName = SymbolTable_GetSymName (Sym);
16755 : 20698500 : pSym = GetPsym (ModSym);
16756 : 20698500 : switch (pSym->SymbolType)
16757 : : {
16758 : 13567824 : case SymbolTable_DefImpSym:
16759 : 13567824 : return ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->DefImp.IncludeList, Sym));
16760 : 7130676 : break;
16761 : :
16762 : 7130676 : case SymbolTable_ModuleSym:
16763 : 7130676 : return ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->Module.IncludeList, Sym));
16764 : 0 : break;
16765 : :
16766 : :
16767 : 0 : default:
16768 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16769 : : break;
16770 : : }
16771 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16772 : : __builtin_unreachable ();
16773 : : }
16774 : :
16775 : :
16776 : : /*
16777 : : PutIncludedByDefinition - places a module symbol, Sym, into the
16778 : : included list of the current definition module.
16779 : : */
16780 : :
16781 : 9286 : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym)
16782 : : {
16783 : 9286 : SymbolTable_PtrToSymbol pSym;
16784 : 9286 : unsigned int ModSym;
16785 : :
16786 : 9286 : ModSym = SymbolTable_GetCurrentModuleScope ();
16787 : 9286 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16788 : 9286 : M2Debug_Assert (SymbolTable_IsDefImp (Sym));
16789 : 9286 : pSym = GetPsym (ModSym);
16790 : 9286 : switch (pSym->SymbolType)
16791 : : {
16792 : 9286 : case SymbolTable_DefImpSym:
16793 : 9286 : Lists_IncludeItemIntoList (pSym->DefImp.DefIncludeList, Sym);
16794 : 9286 : break;
16795 : :
16796 : :
16797 : 0 : default:
16798 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16799 : 9286 : break;
16800 : : }
16801 : 9286 : }
16802 : :
16803 : :
16804 : : /*
16805 : : IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
16806 : : by ModSym's definition module.
16807 : : */
16808 : :
16809 : 12 : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym)
16810 : : {
16811 : 12 : SymbolTable_PtrToSymbol pSym;
16812 : :
16813 : 12 : M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
16814 : 12 : M2Debug_Assert (SymbolTable_IsDefImp (Sym));
16815 : 12 : pSym = GetPsym (ModSym);
16816 : 12 : switch (pSym->SymbolType)
16817 : : {
16818 : 12 : case SymbolTable_DefImpSym:
16819 : 12 : return Lists_IsItemInList (pSym->DefImp.DefIncludeList, Sym);
16820 : 0 : break;
16821 : :
16822 : :
16823 : 0 : default:
16824 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16825 : : break;
16826 : : }
16827 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
16828 : : __builtin_unreachable ();
16829 : : }
16830 : :
16831 : :
16832 : : /*
16833 : : ForeachImportedDo - calls a procedure, P, foreach imported symbol
16834 : : in module, ModSym.
16835 : : */
16836 : :
16837 : 14653 : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
16838 : : {
16839 : 14653 : SymbolTable_PtrToSymbol pSym;
16840 : :
16841 : 14653 : pSym = GetPsym (ModSym);
16842 : 14653 : switch (pSym->SymbolType)
16843 : : {
16844 : 3939 : case SymbolTable_DefImpSym:
16845 : 3939 : SymbolKey_ForeachNodeDo (pSym->DefImp.ImportTree, P);
16846 : 3939 : Lists_ForeachItemInListDo (pSym->DefImp.IncludeList, P);
16847 : 3939 : break;
16848 : :
16849 : 10714 : case SymbolTable_ModuleSym:
16850 : 10714 : SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, P);
16851 : 10714 : Lists_ForeachItemInListDo (pSym->Module.IncludeList, P);
16852 : 10714 : break;
16853 : :
16854 : :
16855 : 0 : default:
16856 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16857 : 14653 : break;
16858 : : }
16859 : 14653 : }
16860 : :
16861 : :
16862 : : /*
16863 : : ForeachExportedDo - calls a procedure, P, foreach imported symbol
16864 : : in module, ModSym.
16865 : : */
16866 : :
16867 : 8230 : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
16868 : : {
16869 : 8230 : SymbolTable_PtrToSymbol pSym;
16870 : :
16871 : 8230 : pSym = GetPsym (ModSym);
16872 : 8230 : switch (pSym->SymbolType)
16873 : : {
16874 : 2900 : case SymbolTable_DefImpSym:
16875 : 2900 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, P);
16876 : 2900 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, P);
16877 : 2900 : break;
16878 : :
16879 : 5330 : case SymbolTable_ModuleSym:
16880 : 5330 : SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, P);
16881 : 5330 : break;
16882 : :
16883 : :
16884 : 0 : default:
16885 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16886 : 8230 : break;
16887 : : }
16888 : 8230 : }
16889 : :
16890 : :
16891 : : /*
16892 : : CheckForExportedImplementation - checks to see whether an implementation
16893 : : module is currently being compiled, if so,
16894 : : symbol, Sym, is removed from the
16895 : : NeedToBeImplemented list.
16896 : : This procedure is called whenever a symbol
16897 : : is declared, thus attempting to reduce
16898 : : the NeedToBeImplemented list.
16899 : : Only needs to be called when a TYPE or
16900 : : PROCEDURE is built since the implementation
16901 : : module can only implement these objects
16902 : : declared in the definition module.
16903 : :
16904 : : It also checks whether a definition module
16905 : : is currently being compiled and, if so,
16906 : : it will ensure that symbol, Sym, is removed
16907 : : from the ExportRequest list. If Sym is an
16908 : : enumerated type it ensures that its fields
16909 : : are also removed.
16910 : : */
16911 : :
16912 : 1368905 : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym)
16913 : : {
16914 : 1368905 : if (M2Comp_CompilingImplementationModule ())
16915 : : {
16916 : 1238941 : RemoveExportUnImplemented (SymbolTable_GetCurrentModule (), Sym);
16917 : : }
16918 : 1368905 : if ((M2Comp_CompilingDefinitionModule ()) && (SymbolTable_IsEnumeration (Sym)))
16919 : : {
16920 : 13394 : RemoveEnumerationFromExportRequest (SymbolTable_GetCurrentModule (), Sym);
16921 : : }
16922 : 1368905 : }
16923 : :
16924 : :
16925 : : /*
16926 : : CheckForUnImplementedExports - displays an error and the offending symbols
16927 : : which have been exported but not implemented
16928 : : from the current compiled module.
16929 : : */
16930 : :
16931 : 54217 : extern "C" void SymbolTable_CheckForUnImplementedExports (void)
16932 : : {
16933 : 54217 : SymbolTable_PtrToSymbol pSym;
16934 : :
16935 : : /* WriteString('Inside CheckForImplementedExports') ; WriteLn ; */
16936 : 54217 : pSym = GetPsym (CurrentModule);
16937 : 54217 : switch (pSym->SymbolType)
16938 : : {
16939 : 54217 : case SymbolTable_DefImpSym:
16940 : 54217 : if (! (SymbolKey_IsEmptyTree (pSym->DefImp.NeedToBeImplemented)))
16941 : : {
16942 : 0 : CurrentError = M2Error_NewError (M2LexBuf_GetTokenNo ());
16943 : 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));
16944 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NeedToBeImplemented, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnImplementedSymbolError});
16945 : : }
16946 : 54217 : break;
16947 : :
16948 : :
16949 : 0 : default:
16950 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
16951 : 54217 : break;
16952 : : }
16953 : 54217 : }
16954 : :
16955 : :
16956 : : /*
16957 : : CheckForUndeclaredExports - displays an error and the offending symbols
16958 : : which have been exported but not declared
16959 : : from module, ModSym.
16960 : : */
16961 : :
16962 : 132821 : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym)
16963 : : {
16964 : 132821 : SymbolTable_PtrToSymbol pSym;
16965 : :
16966 : : /* WriteString('Inside CheckForUndeclaredExports') ; WriteLn ; */
16967 : 132821 : pSym = GetPsym (ModSym);
16968 : 132821 : switch (pSym->SymbolType)
16969 : : {
16970 : 11868 : case SymbolTable_ModuleSym:
16971 : 11868 : if (! (SymbolKey_IsEmptyTree (pSym->Module.ExportUndeclared)))
16972 : : {
16973 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in EXPORT list of {%1ERd} {%1a}", 56, ModSym);
16974 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
16975 : : }
16976 : : break;
16977 : :
16978 : 120953 : case SymbolTable_DefImpSym:
16979 : 120953 : if (! (SymbolKey_IsEmptyTree (pSym->DefImp.ExportUndeclared)))
16980 : : {
16981 : 0 : if (SymbolTable_DoesNotNeedExportList (ModSym))
16982 : : {
16983 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in {%1ERd} {%1a}", 41, ModSym);
16984 : : }
16985 : : else
16986 : : {
16987 : 0 : M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in export list of {%1ERd} {%1a}", 56, ModSym);
16988 : : }
16989 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
16990 : : }
16991 : : break;
16992 : :
16993 : :
16994 : 0 : default:
16995 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
16996 : 132821 : break;
16997 : : }
16998 : 132821 : }
16999 : :
17000 : :
17001 : : /*
17002 : : CheckForUnknownInModule - checks for any unknown symbols in the
17003 : : current module.
17004 : : If any unknown symbols are found then
17005 : : an error message is displayed.
17006 : : */
17007 : :
17008 : 372424 : extern "C" void SymbolTable_CheckForUnknownInModule (void)
17009 : : {
17010 : 372424 : SymbolTable_PtrToSymbol pSym;
17011 : :
17012 : 372424 : pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
17013 : 372424 : switch (pSym->SymbolType)
17014 : : {
17015 : 349019 : case SymbolTable_DefImpSym:
17016 : 349019 : CheckForUnknowns (pSym->DefImp.name, pSym->DefImp.ExportQualifiedTree, (const char *) "EXPORT QUALIFIED", 16);
17017 : 349019 : CheckForUnknowns (pSym->DefImp.name, pSym->DefImp.ExportUnQualifiedTree, (const char *) "EXPORT UNQUALIFIED", 18);
17018 : 349019 : CheckForSymbols (pSym->DefImp.ExportRequest, (const char *) "requested by another modules import (symbols have not been exported by the appropriate definition module)", 105);
17019 : 349019 : CheckForUnknowns (pSym->DefImp.name, pSym->DefImp.Unresolved, (const char *) "unresolved", 10);
17020 : 349019 : CheckForUnknowns (pSym->DefImp.name, pSym->DefImp.LocalSymbols, (const char *) "locally used", 12);
17021 : 349019 : break;
17022 : :
17023 : 23405 : case SymbolTable_ModuleSym:
17024 : 23405 : CheckForUnknowns (pSym->Module.name, pSym->Module.Unresolved, (const char *) "unresolved", 10);
17025 : 23405 : CheckForUnknowns (pSym->Module.name, pSym->Module.ExportUndeclared, (const char *) "exported but undeclared", 23);
17026 : 23405 : CheckForUnknowns (pSym->Module.name, pSym->Module.ExportTree, (const char *) "exported but undeclared", 23);
17027 : 23405 : CheckForUnknowns (pSym->Module.name, pSym->Module.LocalSymbols, (const char *) "locally used", 12);
17028 : 23405 : break;
17029 : :
17030 : :
17031 : 0 : default:
17032 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17033 : 372424 : break;
17034 : : }
17035 : 372424 : }
17036 : :
17037 : :
17038 : : /*
17039 : : UnknownReported - if sym is an unknown symbol and has not been reported
17040 : : then include it into the set of reported unknowns.
17041 : : */
17042 : :
17043 : 6 : extern "C" void SymbolTable_UnknownReported (unsigned int sym)
17044 : : {
17045 : 6 : if (IsUnreportedUnknown (sym))
17046 : : {
17047 : 6 : Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
17048 : : }
17049 : 6 : }
17050 : :
17051 : :
17052 : : /*
17053 : : IsReallyPointer - returns TRUE is sym is a pointer, address or a
17054 : : type declared as a pointer or address.
17055 : : */
17056 : :
17057 : 504812 : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym)
17058 : : {
17059 : 504812 : if (SymbolTable_IsVar (Sym))
17060 : : {
17061 : 189393 : Sym = SymbolTable_GetType (Sym);
17062 : : }
17063 : 504812 : Sym = SymbolTable_SkipType (Sym);
17064 : 504812 : return ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address)) || (SymbolTable_IsHiddenReallyPointer (Sym));
17065 : : /* static analysis guarentees a RETURN statement will be used before here. */
17066 : : __builtin_unreachable ();
17067 : : }
17068 : :
17069 : :
17070 : : /*
17071 : : CheckHiddenTypeAreAddress - checks to see that any hidden types
17072 : : which we have declared are actually
17073 : : of type ADDRESS or map onto a POINTER type.
17074 : : */
17075 : :
17076 : 14329 : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void)
17077 : : {
17078 : 14329 : NameKey_Name name;
17079 : 14329 : M2Error_Error e;
17080 : 14329 : unsigned int sym;
17081 : 14329 : unsigned int i;
17082 : 14329 : unsigned int n;
17083 : :
17084 : 14329 : i = 1;
17085 : 14329 : n = Lists_NoOfItemsInList (AddressTypes);
17086 : 49845 : while (i <= n)
17087 : : {
17088 : 21187 : sym = static_cast<unsigned int> (Lists_GetItemFromList (AddressTypes, i));
17089 : 21187 : if (! (SymbolTable_IsHiddenReallyPointer (sym)))
17090 : : {
17091 : 6 : name = SymbolTable_GetSymName (sym);
17092 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredDef (sym));
17093 : 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));
17094 : 6 : e = M2Error_NewError (SymbolTable_GetDeclaredMod (sym));
17095 : 6 : M2Error_ErrorFormat0 (e, (const char *) "if you really need a non POINTER type use the -fextended-opaque switch", 70);
17096 : : }
17097 : 21187 : i += 1;
17098 : : }
17099 : 14329 : }
17100 : :
17101 : :
17102 : : /*
17103 : : PutDefinitionForC - sets a flag in the current compiled module which
17104 : : indicates that this module is a wrapper for a C
17105 : : file. Parameters passes to procedures in this module
17106 : : will adopt the C calling convention.
17107 : : */
17108 : :
17109 : 16032 : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym)
17110 : : {
17111 : 16032 : SymbolTable_PtrToSymbol pSym;
17112 : :
17113 : 16032 : pSym = GetPsym (Sym);
17114 : 16032 : switch (pSym->SymbolType)
17115 : : {
17116 : 16032 : case SymbolTable_DefImpSym:
17117 : 16032 : pSym->DefImp.ForC = true;
17118 : 16032 : break;
17119 : :
17120 : :
17121 : 0 : default:
17122 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17123 : 16032 : break;
17124 : : }
17125 : 16032 : }
17126 : :
17127 : :
17128 : : /*
17129 : : IsDefinitionForC - returns true if this definition module was declared
17130 : : as a DEFINITION MODULE FOR "C".
17131 : : */
17132 : :
17133 : 881756 : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym)
17134 : : {
17135 : 881756 : SymbolTable_PtrToSymbol pSym;
17136 : :
17137 : 881756 : pSym = GetPsym (Sym);
17138 : 881756 : switch (pSym->SymbolType)
17139 : : {
17140 : 881756 : case SymbolTable_DefImpSym:
17141 : 881756 : return pSym->DefImp.ForC;
17142 : 0 : break;
17143 : :
17144 : :
17145 : 0 : default:
17146 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17147 : : break;
17148 : : }
17149 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17150 : : __builtin_unreachable ();
17151 : : }
17152 : :
17153 : :
17154 : : /*
17155 : : PutDoesNeedExportList - sets a flag in module, Sym, which
17156 : : indicates that this module requires an explicit
17157 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
17158 : : */
17159 : :
17160 : 70851 : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym)
17161 : : {
17162 : 70851 : SymbolTable_PtrToSymbol pSym;
17163 : :
17164 : 70851 : pSym = GetPsym (Sym);
17165 : 70851 : switch (pSym->SymbolType)
17166 : : {
17167 : 70851 : case SymbolTable_DefImpSym:
17168 : 70851 : pSym->DefImp.NeedExportList = true;
17169 : 70851 : break;
17170 : :
17171 : :
17172 : 0 : default:
17173 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17174 : 70851 : break;
17175 : : }
17176 : 70851 : }
17177 : :
17178 : :
17179 : : /*
17180 : : PutDoesNotNeedExportList - sets a flag in module, Sym, which
17181 : : indicates that this module does not require an explicit
17182 : : EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
17183 : : */
17184 : :
17185 : 121085 : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym)
17186 : : {
17187 : 121085 : SymbolTable_PtrToSymbol pSym;
17188 : :
17189 : 121085 : pSym = GetPsym (Sym);
17190 : 121085 : switch (pSym->SymbolType)
17191 : : {
17192 : 121085 : case SymbolTable_DefImpSym:
17193 : 121085 : pSym->DefImp.NeedExportList = false;
17194 : 121085 : break;
17195 : :
17196 : :
17197 : 0 : default:
17198 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17199 : 121085 : break;
17200 : : }
17201 : 121085 : }
17202 : :
17203 : :
17204 : : /*
17205 : : DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
17206 : : EXPORT QUALIFIED list.
17207 : : */
17208 : :
17209 : 2730015 : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym)
17210 : : {
17211 : 2730015 : SymbolTable_PtrToSymbol pSym;
17212 : :
17213 : 2730015 : pSym = GetPsym (Sym);
17214 : 2730015 : switch (pSym->SymbolType)
17215 : : {
17216 : 2730015 : case SymbolTable_DefImpSym:
17217 : 2730015 : return ! pSym->DefImp.NeedExportList;
17218 : 0 : break;
17219 : :
17220 : :
17221 : 0 : default:
17222 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
17223 : : break;
17224 : : }
17225 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17226 : : __builtin_unreachable ();
17227 : : }
17228 : :
17229 : :
17230 : : /*
17231 : : CheckForEnumerationInCurrentModule - checks to see whether the enumeration
17232 : : type symbol, Sym, has been entered into
17233 : : the current modules scope list.
17234 : : */
17235 : :
17236 : 1233122 : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym)
17237 : : {
17238 : 1233122 : SymbolTable_PtrToSymbol pSym;
17239 : 1233122 : unsigned int ModSym;
17240 : :
17241 : 1233122 : if (((SymbolTable_SkipType (Sym)) != SymbolTable_NulSym) && (SymbolTable_IsEnumeration (SymbolTable_SkipType (Sym))))
17242 : : {
17243 : 12232 : Sym = SymbolTable_SkipType (Sym);
17244 : : }
17245 : 1233122 : if (SymbolTable_IsEnumeration (Sym))
17246 : : {
17247 : 12232 : ModSym = SymbolTable_GetCurrentModuleScope ();
17248 : 12232 : pSym = GetPsym (ModSym);
17249 : 12232 : switch (pSym->SymbolType)
17250 : : {
17251 : 11866 : case SymbolTable_DefImpSym:
17252 : 11866 : CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
17253 : 11866 : break;
17254 : :
17255 : 366 : case SymbolTable_ModuleSym:
17256 : 366 : CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
17257 : 366 : break;
17258 : :
17259 : :
17260 : 0 : default:
17261 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
17262 : : break;
17263 : : }
17264 : : }
17265 : 1233122 : }
17266 : :
17267 : :
17268 : : /*
17269 : : SanityCheckConstants - must only be called once all constants, types, procedures
17270 : : have been declared. It checks to see that constants are
17271 : : not used as procedure parameter types.
17272 : : */
17273 : :
17274 : 14979 : extern "C" void SymbolTable_SanityCheckConstants (void)
17275 : : {
17276 : 14979 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
17277 : 14979 : ForeachSymbolDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
17278 : 14979 : }
17279 : :
17280 : :
17281 : : /*
17282 : : ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
17283 : : perform the procedure, P.
17284 : : */
17285 : :
17286 : 4344485 : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
17287 : : {
17288 : 4344485 : SymbolTable_PtrToSymbol pSym;
17289 : :
17290 : 4344485 : pSym = GetPsym (Sym);
17291 : 4344485 : switch (pSym->SymbolType)
17292 : : {
17293 : 429291 : case SymbolTable_DefImpSym:
17294 : 429291 : SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, P);
17295 : 429291 : break;
17296 : :
17297 : 92115 : case SymbolTable_ModuleSym:
17298 : 92115 : SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, P);
17299 : 92115 : break;
17300 : :
17301 : 211440 : case SymbolTable_ProcedureSym:
17302 : 211440 : SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, P);
17303 : 211440 : break;
17304 : :
17305 : 0 : case SymbolTable_RecordSym:
17306 : 0 : SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, P);
17307 : 0 : break;
17308 : :
17309 : 3611639 : case SymbolTable_EnumerationSym:
17310 : 3611639 : SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
17311 : 3611639 : break;
17312 : :
17313 : :
17314 : 0 : default:
17315 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp, Module or Procedure symbol", 46);
17316 : 4344485 : break;
17317 : : }
17318 : 4344485 : }
17319 : :
17320 : :
17321 : : /*
17322 : : ForeachParamSymDo - foreach parameter symbol in procedure Sym
17323 : : perform the procedure P. Each symbol
17324 : : looked up will be VarParam or Param
17325 : : (not the shadow variable). Every parameter
17326 : : from each KindProcedure is iterated over.
17327 : : */
17328 : :
17329 : 976323 : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
17330 : : {
17331 : 976323 : SymbolTable_ProcedureKind kind;
17332 : 976323 : unsigned int param;
17333 : 976323 : unsigned int p;
17334 : 976323 : unsigned int i;
17335 : :
17336 : 976323 : if (SymbolTable_IsProcedure (Sym))
17337 : : {
17338 : 3897856 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
17339 : : {
17340 : 2923392 : p = SymbolTable_NoOfParam (Sym, kind);
17341 : 2923392 : i = p;
17342 : 9034663 : while (i > 0)
17343 : : {
17344 : 3187879 : param = SymbolTable_GetNthParam (Sym, kind, i);
17345 : 3187879 : (*P.proc) (param);
17346 : 3187879 : i -= 1;
17347 : : }
17348 : : }
17349 : : }
17350 : 976323 : }
17351 : :
17352 : :
17353 : : /*
17354 : : ForeachFieldEnumerationDo - for each field in enumeration, Sym,
17355 : : do procedure, P. Each call to P contains
17356 : : an enumeration field, the order is alphabetical.
17357 : : Use ForeachLocalSymDo for declaration order.
17358 : : */
17359 : :
17360 : 62779 : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P)
17361 : : {
17362 : 62779 : SymbolTable_PtrToSymbol pSym;
17363 : :
17364 : 62779 : pSym = GetPsym (Sym);
17365 : 62779 : switch (pSym->SymbolType)
17366 : : {
17367 : 62779 : case SymbolTable_EnumerationSym:
17368 : 62779 : SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
17369 : 62779 : break;
17370 : :
17371 : :
17372 : 0 : default:
17373 : 0 : M2Error_InternalError ((const char *) "expecting Enumeration symbol", 28);
17374 : 62779 : break;
17375 : : }
17376 : 62779 : }
17377 : :
17378 : :
17379 : : /*
17380 : : IsType - returns true if the Sym is a type symbol.
17381 : : */
17382 : :
17383 : 495500575 : extern "C" bool SymbolTable_IsType (unsigned int Sym)
17384 : : {
17385 : 495500575 : SymbolTable_PtrToSymbol pSym;
17386 : :
17387 : 495500575 : pSym = GetPsym (Sym);
17388 : 495500575 : return pSym->SymbolType == SymbolTable_TypeSym;
17389 : : /* static analysis guarentees a RETURN statement will be used before here. */
17390 : : __builtin_unreachable ();
17391 : : }
17392 : :
17393 : :
17394 : : /*
17395 : : IsProcedure - returns true if Sym is a procedure symbol.
17396 : : */
17397 : :
17398 : 249014573 : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym)
17399 : : {
17400 : 249014573 : SymbolTable_PtrToSymbol pSym;
17401 : :
17402 : 249014573 : AssertInRange (Sym);
17403 : 249014573 : pSym = GetPsym (Sym);
17404 : 249014573 : return pSym->SymbolType == SymbolTable_ProcedureSym;
17405 : : /* static analysis guarentees a RETURN statement will be used before here. */
17406 : : __builtin_unreachable ();
17407 : : }
17408 : :
17409 : :
17410 : : /*
17411 : : IsParameter - returns true if Sym is a parameter symbol.
17412 : : */
17413 : :
17414 : 67612962 : extern "C" bool SymbolTable_IsParameter (unsigned int Sym)
17415 : : {
17416 : 67612962 : SymbolTable_PtrToSymbol pSym;
17417 : :
17418 : 67612962 : pSym = GetPsym (Sym);
17419 : 67612962 : switch (pSym->SymbolType)
17420 : : {
17421 : : case SymbolTable_ParamSym:
17422 : : case SymbolTable_VarParamSym:
17423 : : return true;
17424 : 56427480 : break;
17425 : :
17426 : :
17427 : 56427480 : default:
17428 : 56427480 : return false;
17429 : : break;
17430 : : }
17431 : : /* static analysis guarentees a RETURN statement will be used before here. */
17432 : : __builtin_unreachable ();
17433 : : }
17434 : :
17435 : :
17436 : : /*
17437 : : GetProcedureKind - returns the procedure kind given the declaration tok.
17438 : : The declaration tok must match the ident tok in the
17439 : : procedure name. It is only safe to call this
17440 : : procedure function during pass 2 onwards.
17441 : : */
17442 : :
17443 : 17901595 : extern "C" SymbolTable_ProcedureKind SymbolTable_GetProcedureKind (unsigned int sym, unsigned int tok)
17444 : : {
17445 : 17901595 : SymbolTable_ProcedureKind kind;
17446 : 17901595 : SymbolTable_PtrToSymbol pSym;
17447 : :
17448 : 17901595 : pSym = GetPsym (sym);
17449 : 17901595 : switch (pSym->SymbolType)
17450 : : {
17451 : : case SymbolTable_ProcedureSym:
17452 : 41460311 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
17453 : : {
17454 : 41460311 : if (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok == tok)
17455 : : {
17456 : : return kind;
17457 : : }
17458 : : }
17459 : 0 : break;
17460 : :
17461 : : case SymbolTable_ProcTypeSym:
17462 : : return SymbolTable_ProperProcedure;
17463 : 0 : break;
17464 : :
17465 : :
17466 : 0 : default:
17467 : 0 : M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
17468 : 0 : break;
17469 : : }
17470 : 0 : M2Error_InternalError ((const char *) "ProcedureSym kind has not yet been declared", 43);
17471 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17472 : : __builtin_unreachable ();
17473 : : }
17474 : :
17475 : :
17476 : : /*
17477 : : GetProcedureDeclaredTok - return the token where the
17478 : : declaration of procedure sym:kind
17479 : : occurred.
17480 : : */
17481 : :
17482 : 36 : extern "C" unsigned int SymbolTable_GetProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind)
17483 : : {
17484 : 36 : SymbolTable_PtrToSymbol pSym;
17485 : :
17486 : 36 : pSym = GetPsym (sym);
17487 : 36 : switch (pSym->SymbolType)
17488 : : {
17489 : 36 : case SymbolTable_ProcedureSym:
17490 : 36 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok;
17491 : 0 : break;
17492 : :
17493 : :
17494 : 0 : default:
17495 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17496 : : break;
17497 : : }
17498 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17499 : : __builtin_unreachable ();
17500 : : }
17501 : :
17502 : :
17503 : : /*
17504 : : PutProcedureDeclaredTok - places the tok where the
17505 : : declaration of procedure sym:kind
17506 : : occurred.
17507 : : */
17508 : :
17509 : 3206071 : extern "C" void SymbolTable_PutProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok)
17510 : : {
17511 : 3206071 : SymbolTable_PtrToSymbol pSym;
17512 : :
17513 : 3206071 : pSym = GetPsym (sym);
17514 : 3206071 : switch (pSym->SymbolType)
17515 : : {
17516 : 3206071 : case SymbolTable_ProcedureSym:
17517 : 3206071 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok = tok;
17518 : 3206071 : break;
17519 : :
17520 : :
17521 : 0 : default:
17522 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17523 : 3206071 : break;
17524 : : }
17525 : 3206071 : }
17526 : :
17527 : :
17528 : : /*
17529 : : GetReturnTypeTok - return the token where the
17530 : : return type procedure sym:kind or proctype
17531 : : was defined.
17532 : : */
17533 : :
17534 : 6 : extern "C" unsigned int SymbolTable_GetReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind)
17535 : : {
17536 : 6 : SymbolTable_PtrToSymbol pSym;
17537 : :
17538 : 6 : pSym = GetPsym (sym);
17539 : 6 : switch (pSym->SymbolType)
17540 : : {
17541 : 6 : case SymbolTable_ProcedureSym:
17542 : 6 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok;
17543 : 0 : break;
17544 : :
17545 : 0 : case SymbolTable_ProcTypeSym:
17546 : 0 : return pSym->ProcType.ReturnTypeTok;
17547 : 0 : break;
17548 : :
17549 : :
17550 : 0 : default:
17551 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17552 : : break;
17553 : : }
17554 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17555 : : __builtin_unreachable ();
17556 : : }
17557 : :
17558 : :
17559 : : /*
17560 : : PutReturnTypeTok - places the tok where the
17561 : : return type of procedure sym:kind or proctype
17562 : : was defined.
17563 : : */
17564 : :
17565 : 0 : extern "C" void SymbolTable_PutReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok)
17566 : : {
17567 : 0 : SymbolTable_PtrToSymbol pSym;
17568 : :
17569 : 0 : pSym = GetPsym (sym);
17570 : 0 : switch (pSym->SymbolType)
17571 : : {
17572 : 0 : case SymbolTable_ProcedureSym:
17573 : 0 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
17574 : 0 : break;
17575 : :
17576 : 0 : case SymbolTable_ProcTypeSym:
17577 : 0 : pSym->ProcType.ReturnTypeTok = tok;
17578 : 0 : break;
17579 : :
17580 : :
17581 : 0 : default:
17582 : 0 : M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
17583 : 0 : break;
17584 : : }
17585 : 0 : }
17586 : :
17587 : :
17588 : : /*
17589 : : PutProcedureParametersDefined - the procedure symbol sym:kind
17590 : : parameters have been defined.
17591 : : */
17592 : :
17593 : 6276295 : extern "C" void SymbolTable_PutProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17594 : : {
17595 : 6276295 : SymbolTable_PtrToSymbol pSym;
17596 : :
17597 : 6276295 : AssertInRange (sym);
17598 : 6276295 : pSym = GetPsym (sym);
17599 : 6276295 : switch (pSym->SymbolType)
17600 : : {
17601 : : case SymbolTable_ErrorSym:
17602 : : break;
17603 : :
17604 : 6276295 : case SymbolTable_ProcedureSym:
17605 : 6276295 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ParamDefined = true;
17606 : 6276295 : pSym->Procedure.BuildProcType = false;
17607 : 6276295 : break;
17608 : :
17609 : : case SymbolTable_ProcTypeSym:
17610 : : break;
17611 : :
17612 : :
17613 : 0 : default:
17614 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17615 : 6276295 : break;
17616 : : }
17617 : 6276295 : }
17618 : :
17619 : :
17620 : : /*
17621 : : GetProcedureParametersDefined - returns true if procedure symbol sym:kind
17622 : : parameters are defined.
17623 : : */
17624 : :
17625 : 121537742 : extern "C" bool SymbolTable_GetProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17626 : : {
17627 : 121537742 : SymbolTable_PtrToSymbol pSym;
17628 : :
17629 : 121537742 : AssertInRange (sym);
17630 : 121537742 : pSym = GetPsym (sym);
17631 : 121537742 : switch (pSym->SymbolType)
17632 : : {
17633 : : case SymbolTable_ErrorSym:
17634 : : return false;
17635 : 116708960 : break;
17636 : :
17637 : 116708960 : case SymbolTable_ProcedureSym:
17638 : 116708960 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ParamDefined;
17639 : 4828782 : break;
17640 : :
17641 : 4828782 : case SymbolTable_ProcTypeSym:
17642 : 4828782 : return true;
17643 : 0 : break;
17644 : :
17645 : :
17646 : 0 : default:
17647 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17648 : : break;
17649 : : }
17650 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17651 : : __builtin_unreachable ();
17652 : : }
17653 : :
17654 : :
17655 : : /*
17656 : : PutProcedureDefined - the procedure symbol sym:kind is defined.
17657 : : */
17658 : :
17659 : 4097203 : extern "C" void SymbolTable_PutProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17660 : : {
17661 : 4097203 : SymbolTable_PtrToSymbol pSym;
17662 : :
17663 : 4097203 : AssertInRange (sym);
17664 : 4097203 : pSym = GetPsym (sym);
17665 : 4097203 : switch (pSym->SymbolType)
17666 : : {
17667 : : case SymbolTable_ErrorSym:
17668 : : break;
17669 : :
17670 : 4097203 : case SymbolTable_ProcedureSym:
17671 : 4097203 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].Defined = true;
17672 : 4097203 : break;
17673 : :
17674 : :
17675 : 0 : default:
17676 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17677 : 4097203 : break;
17678 : : }
17679 : 4097203 : }
17680 : :
17681 : :
17682 : : /*
17683 : : GetProcedureDefined - returns true if procedure symbol sym:kind
17684 : : is defined.
17685 : : */
17686 : :
17687 : 26845815 : extern "C" bool SymbolTable_GetProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
17688 : : {
17689 : 26845815 : SymbolTable_PtrToSymbol pSym;
17690 : :
17691 : 26845815 : AssertInRange (sym);
17692 : 26845815 : pSym = GetPsym (sym);
17693 : 26845815 : switch (pSym->SymbolType)
17694 : : {
17695 : : case SymbolTable_ErrorSym:
17696 : : return false;
17697 : 26845815 : break;
17698 : :
17699 : 26845815 : case SymbolTable_ProcedureSym:
17700 : 26845815 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].Defined;
17701 : 0 : break;
17702 : :
17703 : :
17704 : 0 : default:
17705 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
17706 : : break;
17707 : : }
17708 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17709 : : __builtin_unreachable ();
17710 : : }
17711 : :
17712 : :
17713 : : /*
17714 : : PutUseVarArgs - tell the symbol table that this procedure, Sym,
17715 : : uses varargs.
17716 : : The procedure _must_ be declared inside a
17717 : : DEFINITION FOR "C"
17718 : :
17719 : : */
17720 : :
17721 : 11072 : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym)
17722 : : {
17723 : 11072 : SymbolTable_PtrToSymbol pSym;
17724 : :
17725 : 11072 : AssertInRange (Sym);
17726 : 11072 : pSym = GetPsym (Sym);
17727 : 11072 : switch (pSym->SymbolType)
17728 : : {
17729 : : case SymbolTable_ErrorSym:
17730 : : break;
17731 : :
17732 : 11072 : case SymbolTable_ProcedureSym:
17733 : : /* Currently can only declare var args in a definition module. */
17734 : 11072 : pSym->Procedure.Decl.array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure].HasVarArgs = true;
17735 : 11072 : break;
17736 : :
17737 : 0 : case SymbolTable_ProcTypeSym:
17738 : 0 : pSym->ProcType.HasVarArgs = true;
17739 : 0 : break;
17740 : :
17741 : :
17742 : 0 : default:
17743 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17744 : 11072 : break;
17745 : : }
17746 : 11072 : }
17747 : :
17748 : :
17749 : : /*
17750 : : UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
17751 : : The procedure _must_ be declared inside a
17752 : : DEFINITION FOR "C"
17753 : : */
17754 : :
17755 : 2392425 : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym)
17756 : : {
17757 : 2392425 : SymbolTable_PtrToSymbol pSym;
17758 : :
17759 : 2392425 : AssertInRange (Sym);
17760 : 2392425 : pSym = GetPsym (Sym);
17761 : 2392425 : switch (pSym->SymbolType)
17762 : : {
17763 : : case SymbolTable_ErrorSym:
17764 : : return false;
17765 : 2338013 : break;
17766 : :
17767 : 2338013 : case SymbolTable_ProcedureSym:
17768 : : /* Currently can only declare var args in a definition module. */
17769 : 2338013 : return pSym->Procedure.Decl.array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure].HasVarArgs;
17770 : 54412 : break;
17771 : :
17772 : 54412 : case SymbolTable_ProcTypeSym:
17773 : 54412 : return pSym->ProcType.HasVarArgs;
17774 : 0 : break;
17775 : :
17776 : :
17777 : 0 : default:
17778 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17779 : : break;
17780 : : }
17781 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17782 : : __builtin_unreachable ();
17783 : : }
17784 : :
17785 : :
17786 : : /*
17787 : : PutUseOptArg - tell the symbol table that this procedure, Sym,
17788 : : uses an optarg.
17789 : : */
17790 : :
17791 : 17849 : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind)
17792 : : {
17793 : 17849 : SymbolTable_PtrToSymbol pSym;
17794 : :
17795 : 17849 : AssertInRange (Sym);
17796 : 17849 : pSym = GetPsym (Sym);
17797 : 17849 : switch (pSym->SymbolType)
17798 : : {
17799 : : case SymbolTable_ErrorSym:
17800 : : break;
17801 : :
17802 : 17849 : case SymbolTable_ProcedureSym:
17803 : 17849 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].HasOptArg = true;
17804 : 17849 : break;
17805 : :
17806 : 0 : case SymbolTable_ProcTypeSym:
17807 : 0 : pSym->ProcType.HasOptArg = true;
17808 : 0 : break;
17809 : :
17810 : :
17811 : 0 : default:
17812 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17813 : 17849 : break;
17814 : : }
17815 : 17849 : }
17816 : :
17817 : :
17818 : : /*
17819 : : UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
17820 : : */
17821 : :
17822 : 190107 : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind)
17823 : : {
17824 : 190107 : SymbolTable_PtrToSymbol pSym;
17825 : :
17826 : 190107 : AssertInRange (Sym);
17827 : 190107 : pSym = GetPsym (Sym);
17828 : 190107 : switch (pSym->SymbolType)
17829 : : {
17830 : : case SymbolTable_ErrorSym:
17831 : : return false;
17832 : 190107 : break;
17833 : :
17834 : 190107 : case SymbolTable_ProcedureSym:
17835 : 190107 : return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].HasOptArg;
17836 : 0 : break;
17837 : :
17838 : 0 : case SymbolTable_ProcTypeSym:
17839 : 0 : return pSym->ProcType.HasOptArg;
17840 : 0 : break;
17841 : :
17842 : :
17843 : 0 : default:
17844 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17845 : : break;
17846 : : }
17847 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
17848 : : __builtin_unreachable ();
17849 : : }
17850 : :
17851 : :
17852 : : /*
17853 : : PutOptArgInit - makes symbol, Sym, the initializer value to
17854 : : procedure, ProcSym.
17855 : : */
17856 : :
17857 : 15005 : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym)
17858 : : {
17859 : 15005 : SymbolTable_PtrToSymbol pSym;
17860 : :
17861 : 15005 : AssertInRange (Sym);
17862 : 15005 : if (! (SymbolTable_IsError (ProcSym)))
17863 : : {
17864 : 15005 : pSym = GetPsym (ProcSym);
17865 : 15005 : switch (pSym->SymbolType)
17866 : : {
17867 : : case SymbolTable_ErrorSym:
17868 : : break;
17869 : :
17870 : 15005 : case SymbolTable_ProcedureSym:
17871 : 15005 : pSym->Procedure.OptArgInit = Sym;
17872 : 15005 : break;
17873 : :
17874 : 0 : case SymbolTable_ProcTypeSym:
17875 : 0 : pSym->ProcType.OptArgInit = Sym;
17876 : 0 : break;
17877 : :
17878 : :
17879 : 0 : default:
17880 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17881 : : break;
17882 : : }
17883 : : }
17884 : 15005 : }
17885 : :
17886 : :
17887 : : /*
17888 : : GetOptArgInit - returns the initializer value to the optional parameter in
17889 : : procedure, ProcSym.
17890 : : */
17891 : :
17892 : 2886 : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym)
17893 : : {
17894 : 2886 : SymbolTable_PtrToSymbol pSym;
17895 : :
17896 : 2886 : if (! (SymbolTable_IsError (ProcSym)))
17897 : : {
17898 : 2886 : pSym = GetPsym (ProcSym);
17899 : 2886 : switch (pSym->SymbolType)
17900 : : {
17901 : : case SymbolTable_ErrorSym:
17902 : : break;
17903 : :
17904 : 2886 : case SymbolTable_ProcedureSym:
17905 : 2886 : return pSym->Procedure.OptArgInit;
17906 : 0 : break;
17907 : :
17908 : 0 : case SymbolTable_ProcTypeSym:
17909 : 0 : return pSym->ProcType.OptArgInit;
17910 : 0 : break;
17911 : :
17912 : :
17913 : 0 : default:
17914 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
17915 : : break;
17916 : : }
17917 : : }
17918 : : return SymbolTable_NulSym;
17919 : : /* static analysis guarentees a RETURN statement will be used before here. */
17920 : : __builtin_unreachable ();
17921 : : }
17922 : :
17923 : :
17924 : : /*
17925 : : MakePointer - returns a pointer symbol with PointerName.
17926 : : */
17927 : :
17928 : 142554 : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName)
17929 : : {
17930 : 142554 : unsigned int oaf;
17931 : 142554 : unsigned int sym;
17932 : :
17933 : 142554 : tok = CheckTok (tok, (const char *) "pointer", 7);
17934 : 142554 : sym = HandleHiddenOrDeclare (tok, PointerName, &oaf);
17935 : 142554 : FillInPointerFields (sym, PointerName, SymbolTable_GetCurrentScope (), oaf);
17936 : 142554 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
17937 : 142554 : return sym;
17938 : : /* static analysis guarentees a RETURN statement will be used before here. */
17939 : : __builtin_unreachable ();
17940 : : }
17941 : :
17942 : :
17943 : : /*
17944 : : PutPointer - gives a pointer symbol a type, PointerType.
17945 : : */
17946 : :
17947 : 176102 : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType)
17948 : : {
17949 : 176102 : SymbolTable_PtrToSymbol pSym;
17950 : :
17951 : 176102 : pSym = GetPsym (Sym);
17952 : 176102 : switch (pSym->SymbolType)
17953 : : {
17954 : : case SymbolTable_ErrorSym:
17955 : : break;
17956 : :
17957 : 176102 : case SymbolTable_PointerSym:
17958 : 176102 : pSym->Pointer.Type = PointerType;
17959 : 176102 : break;
17960 : :
17961 : :
17962 : 0 : default:
17963 : 0 : M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26);
17964 : 176102 : break;
17965 : : }
17966 : 176102 : }
17967 : :
17968 : :
17969 : : /*
17970 : : IsPointer - returns true is Sym is a pointer type symbol.
17971 : : */
17972 : :
17973 : 136787812 : extern "C" bool SymbolTable_IsPointer (unsigned int Sym)
17974 : : {
17975 : 136787812 : SymbolTable_PtrToSymbol pSym;
17976 : :
17977 : 136787812 : AssertInRange (Sym);
17978 : 136787812 : pSym = GetPsym (Sym);
17979 : 136787812 : return pSym->SymbolType == SymbolTable_PointerSym;
17980 : : /* static analysis guarentees a RETURN statement will be used before here. */
17981 : : __builtin_unreachable ();
17982 : : }
17983 : :
17984 : :
17985 : : /*
17986 : : IsRecord - returns true is Sym is a record type symbol.
17987 : : */
17988 : :
17989 : 156822481 : extern "C" bool SymbolTable_IsRecord (unsigned int Sym)
17990 : : {
17991 : 156822481 : SymbolTable_PtrToSymbol pSym;
17992 : :
17993 : 156822481 : AssertInRange (Sym);
17994 : 156822475 : pSym = GetPsym (Sym);
17995 : 156822475 : return pSym->SymbolType == SymbolTable_RecordSym;
17996 : : /* static analysis guarentees a RETURN statement will be used before here. */
17997 : : __builtin_unreachable ();
17998 : : }
17999 : :
18000 : :
18001 : : /*
18002 : : IsVarient - returns true if the symbol, Sym, is a
18003 : : varient symbol.
18004 : : */
18005 : :
18006 : 109857588 : extern "C" bool SymbolTable_IsVarient (unsigned int Sym)
18007 : : {
18008 : 109857588 : SymbolTable_PtrToSymbol pSym;
18009 : :
18010 : 109857588 : pSym = GetPsym (Sym);
18011 : 109857588 : return pSym->SymbolType == SymbolTable_VarientSym;
18012 : : /* static analysis guarentees a RETURN statement will be used before here. */
18013 : : __builtin_unreachable ();
18014 : : }
18015 : :
18016 : :
18017 : : /*
18018 : : IsFieldVarient - returns true if the symbol, Sym, is a
18019 : : varient field.
18020 : : */
18021 : :
18022 : 76302296 : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym)
18023 : : {
18024 : 76302296 : SymbolTable_PtrToSymbol pSym;
18025 : :
18026 : 76302296 : pSym = GetPsym (Sym);
18027 : 76302296 : return pSym->SymbolType == SymbolTable_VarientFieldSym;
18028 : : /* static analysis guarentees a RETURN statement will be used before here. */
18029 : : __builtin_unreachable ();
18030 : : }
18031 : :
18032 : :
18033 : : /*
18034 : : IsFieldEnumeration - returns true if the symbol, Sym, is an
18035 : : enumeration field.
18036 : : */
18037 : :
18038 : 8012193 : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym)
18039 : : {
18040 : 8012193 : SymbolTable_PtrToSymbol pSym;
18041 : :
18042 : 8012193 : pSym = GetPsym (Sym);
18043 : 8012193 : return pSym->SymbolType == SymbolTable_EnumerationFieldSym;
18044 : : /* static analysis guarentees a RETURN statement will be used before here. */
18045 : : __builtin_unreachable ();
18046 : : }
18047 : :
18048 : :
18049 : : /*
18050 : : IsArray - returns true is Sym is an array type symbol.
18051 : : */
18052 : :
18053 : 148498781 : extern "C" bool SymbolTable_IsArray (unsigned int Sym)
18054 : : {
18055 : 148498781 : SymbolTable_PtrToSymbol pSym;
18056 : :
18057 : 148498781 : AssertInRange (Sym);
18058 : 148498781 : pSym = GetPsym (Sym);
18059 : 148498781 : return pSym->SymbolType == SymbolTable_ArraySym;
18060 : : /* static analysis guarentees a RETURN statement will be used before here. */
18061 : : __builtin_unreachable ();
18062 : : }
18063 : :
18064 : :
18065 : : /*
18066 : : IsEnumeration - returns true if Sym is an enumeration symbol.
18067 : : */
18068 : :
18069 : 140891931 : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym)
18070 : : {
18071 : 140891931 : SymbolTable_PtrToSymbol pSym;
18072 : :
18073 : 140891931 : AssertInRange (Sym);
18074 : 140891931 : pSym = GetPsym (Sym);
18075 : 140891931 : return pSym->SymbolType == SymbolTable_EnumerationSym;
18076 : : /* static analysis guarentees a RETURN statement will be used before here. */
18077 : : __builtin_unreachable ();
18078 : : }
18079 : :
18080 : :
18081 : : /*
18082 : : IsSet - returns TRUE if Sym is a set symbol.
18083 : : */
18084 : :
18085 : 68948594 : extern "C" bool SymbolTable_IsSet (unsigned int Sym)
18086 : : {
18087 : 68948594 : SymbolTable_PtrToSymbol pSym;
18088 : :
18089 : 68948594 : AssertInRange (Sym);
18090 : 68948594 : pSym = GetPsym (Sym);
18091 : 68948594 : return pSym->SymbolType == SymbolTable_SetSym;
18092 : : /* static analysis guarentees a RETURN statement will be used before here. */
18093 : : __builtin_unreachable ();
18094 : : }
18095 : :
18096 : :
18097 : : /*
18098 : : IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
18099 : : */
18100 : :
18101 : 20116388 : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym)
18102 : : {
18103 : 20116388 : SymbolTable_PtrToSymbol pSym;
18104 : :
18105 : 20116388 : pSym = GetPsym (Sym);
18106 : 20116388 : switch (pSym->SymbolType)
18107 : : {
18108 : 20093278 : case SymbolTable_TypeSym:
18109 : 20093278 : return pSym->Type.IsHidden;
18110 : : break;
18111 : :
18112 : :
18113 : : default:
18114 : : return false;
18115 : : break;
18116 : : }
18117 : : /* static analysis guarentees a RETURN statement will be used before here. */
18118 : : __builtin_unreachable ();
18119 : : }
18120 : :
18121 : :
18122 : : /*
18123 : : IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
18124 : : */
18125 : :
18126 : 0 : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym)
18127 : : {
18128 : 0 : SymbolTable_PtrToSymbol pSym;
18129 : :
18130 : 0 : AssertInRange (Sym);
18131 : 0 : pSym = GetPsym (Sym);
18132 : 0 : return pSym->SymbolType == SymbolTable_OAFamilySym;
18133 : : /* static analysis guarentees a RETURN statement will be used before here. */
18134 : : __builtin_unreachable ();
18135 : : }
18136 : :
18137 : :
18138 : : /*
18139 : : GetDimension - return the number of dimensions associated with
18140 : : this unbounded ARRAY parameter.
18141 : : */
18142 : :
18143 : 253159 : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym)
18144 : : {
18145 : 433729 : SymbolTable_PtrToSymbol pSym;
18146 : :
18147 : 433729 : pSym = GetPsym (sym);
18148 : 433729 : switch (pSym->SymbolType)
18149 : : {
18150 : 0 : case SymbolTable_PartialUnboundedSym:
18151 : 0 : return pSym->PartialUnbounded.NDim;
18152 : 246535 : break;
18153 : :
18154 : 246535 : case SymbolTable_UnboundedSym:
18155 : 246535 : return pSym->Unbounded.Dimensions;
18156 : 0 : break;
18157 : :
18158 : 0 : case SymbolTable_OAFamilySym:
18159 : 0 : return pSym->OAFamily.MaxDimensions;
18160 : 107306 : break;
18161 : :
18162 : 107306 : case SymbolTable_ParamSym:
18163 : 107306 : if (pSym->Param.IsUnbounded)
18164 : : {
18165 : 107306 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18166 : : }
18167 : : else
18168 : : {
18169 : 0 : M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
18170 : : }
18171 : 73228 : break;
18172 : :
18173 : 73228 : case SymbolTable_VarParamSym:
18174 : 73228 : if (pSym->VarParam.IsUnbounded)
18175 : : {
18176 : 73228 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18177 : : }
18178 : : else
18179 : : {
18180 : 0 : M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
18181 : : }
18182 : 6624 : break;
18183 : :
18184 : 6624 : case SymbolTable_ArraySym:
18185 : 6624 : return GetArrayDimension (sym);
18186 : 0 : break;
18187 : :
18188 : 0 : case SymbolTable_TypeSym:
18189 : 0 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18190 : 36 : break;
18191 : :
18192 : 36 : case SymbolTable_VarSym:
18193 : 36 : return SymbolTable_GetDimension (SymbolTable_GetType (sym));
18194 : 0 : break;
18195 : :
18196 : :
18197 : 0 : default:
18198 : 0 : M2Error_InternalError ((const char *) "expecting PartialUnbounded", 26);
18199 : : break;
18200 : : }
18201 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18202 : : __builtin_unreachable ();
18203 : : }
18204 : :
18205 : :
18206 : : /*
18207 : : MakeOAFamily - makes an OAFamily symbol based on SimpleType.
18208 : : It returns the OAFamily symbol. A new symbol
18209 : : is created if one does not already exist for
18210 : : SimpleType.
18211 : : */
18212 : :
18213 : 522675 : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType)
18214 : : {
18215 : 522675 : SymbolTable_PtrToSymbol pSym;
18216 : 522675 : unsigned int sym;
18217 : :
18218 : 522675 : sym = SymbolTable_GetOAFamily (SimpleType);
18219 : 522675 : if (sym == SymbolTable_NulSym)
18220 : : {
18221 : 33488 : NewSym (&sym);
18222 : 33488 : pSym = GetPsym (sym);
18223 : 33488 : pSym->SymbolType = SymbolTable_OAFamilySym;
18224 : 33488 : pSym->OAFamily.MaxDimensions = 0;
18225 : 33488 : pSym->OAFamily.SimpleType = SimpleType;
18226 : 33488 : pSym->OAFamily.Dimensions = Indexing_InitIndex (1);
18227 : 33488 : PutOAFamily (SimpleType, sym);
18228 : : }
18229 : 522675 : return sym;
18230 : : /* static analysis guarentees a RETURN statement will be used before here. */
18231 : : __builtin_unreachable ();
18232 : : }
18233 : :
18234 : :
18235 : : /*
18236 : : GetOAFamily - returns the oafamily symbol associated with
18237 : : SimpleType.
18238 : : */
18239 : :
18240 : 108344177 : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType)
18241 : : {
18242 : 108344177 : SymbolTable_PtrToSymbol pSym;
18243 : :
18244 : 108344177 : pSym = GetPsym (SimpleType);
18245 : 108344177 : switch (pSym->SymbolType)
18246 : : {
18247 : : case SymbolTable_ErrorSym:
18248 : : return SymbolTable_NulSym;
18249 : 7201625 : break;
18250 : :
18251 : 7201625 : case SymbolTable_RecordSym:
18252 : 7201625 : return pSym->Record.oafamily;
18253 : 1320079 : break;
18254 : :
18255 : 1320079 : case SymbolTable_SubrangeSym:
18256 : 1320079 : return pSym->Subrange.oafamily;
18257 : 2901499 : break;
18258 : :
18259 : 2901499 : case SymbolTable_EnumerationSym:
18260 : 2901499 : return pSym->Enumeration.oafamily;
18261 : 678856 : break;
18262 : :
18263 : 678856 : case SymbolTable_ArraySym:
18264 : 678856 : return pSym->Array.oafamily;
18265 : 2346161 : break;
18266 : :
18267 : 2346161 : case SymbolTable_ProcTypeSym:
18268 : 2346161 : return pSym->ProcType.oafamily;
18269 : 23696250 : break;
18270 : :
18271 : 23696250 : case SymbolTable_TypeSym:
18272 : 23696250 : return pSym->Type.oafamily;
18273 : 10482825 : break;
18274 : :
18275 : 10482825 : case SymbolTable_PointerSym:
18276 : 10482825 : return pSym->Pointer.oafamily;
18277 : 1348358 : break;
18278 : :
18279 : 1348358 : case SymbolTable_SetSym:
18280 : 1348358 : return pSym->Set.oafamily;
18281 : 99129 : break;
18282 : :
18283 : 99129 : case SymbolTable_UndefinedSym:
18284 : 99129 : return pSym->Undefined.oafamily;
18285 : : break;
18286 : :
18287 : :
18288 : : default:
18289 : : return SymbolTable_NulSym;
18290 : : break;
18291 : : }
18292 : : /* static analysis guarentees a RETURN statement will be used before here. */
18293 : : __builtin_unreachable ();
18294 : : }
18295 : :
18296 : :
18297 : : /*
18298 : : ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
18299 : : sym, in the oaf.
18300 : : */
18301 : :
18302 : 107821502 : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p)
18303 : : {
18304 : 107821502 : typedef unsigned int *ForeachOAFamily__T1;
18305 : :
18306 : 107821502 : SymbolTable_PtrToSymbol pSym;
18307 : 107821502 : unsigned int h;
18308 : 107821502 : unsigned int i;
18309 : 107821502 : ForeachOAFamily__T1 pc;
18310 : :
18311 : 107821502 : if (sym != SymbolTable_NulSym)
18312 : : {
18313 : 4707408 : pSym = GetPsym (sym);
18314 : 4707408 : switch (pSym->SymbolType)
18315 : : {
18316 : 4707408 : case SymbolTable_OAFamilySym:
18317 : 4707408 : h = Indexing_HighIndice (pSym->OAFamily.Dimensions);
18318 : 4707408 : i = 1;
18319 : 14172072 : while (i <= h)
18320 : : {
18321 : 4757256 : pc = static_cast<ForeachOAFamily__T1> (Indexing_GetIndice (pSym->OAFamily.Dimensions, i));
18322 : 4757256 : if (pc != NULL)
18323 : : {
18324 : 4757256 : (*p.proc) (sym, i, (*pc));
18325 : : }
18326 : 4757256 : i += 1;
18327 : : }
18328 : : break;
18329 : :
18330 : :
18331 : 0 : default:
18332 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
18333 : : break;
18334 : : }
18335 : : }
18336 : 107821502 : }
18337 : :
18338 : :
18339 : : /*
18340 : : IsUnbounded - returns true if Sym is an unbounded symbol.
18341 : : */
18342 : :
18343 : 77495838 : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym)
18344 : : {
18345 : 77495838 : SymbolTable_PtrToSymbol pSym;
18346 : :
18347 : 77495838 : AssertInRange (Sym);
18348 : 77495838 : pSym = GetPsym (Sym);
18349 : 77495838 : return pSym->SymbolType == SymbolTable_UnboundedSym;
18350 : : /* static analysis guarentees a RETURN statement will be used before here. */
18351 : : __builtin_unreachable ();
18352 : : }
18353 : :
18354 : :
18355 : : /*
18356 : : GetUnbounded - returns the unbounded symbol associated with
18357 : : the OAFamily symbol, oaf, and the number of
18358 : : dimensions, ndim, of the open array.
18359 : : */
18360 : :
18361 : 522675 : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim)
18362 : : {
18363 : 522675 : SymbolTable_PtrToSymbol pSym;
18364 : :
18365 : 522675 : pSym = GetPsym (oaf);
18366 : 522675 : switch (pSym->SymbolType)
18367 : : {
18368 : 522675 : case SymbolTable_OAFamilySym:
18369 : 522675 : if (ndim > pSym->OAFamily.MaxDimensions)
18370 : : {
18371 : : return SymbolTable_NulSym;
18372 : : }
18373 : : else
18374 : : {
18375 : 489127 : return GetFromIndex (pSym->OAFamily.Dimensions, ndim);
18376 : : }
18377 : 0 : break;
18378 : :
18379 : :
18380 : 0 : default:
18381 : 0 : M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
18382 : : break;
18383 : : }
18384 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18385 : : __builtin_unreachable ();
18386 : : }
18387 : :
18388 : :
18389 : : /*
18390 : : GetUnboundedRecordType - returns the record type used to
18391 : : implement the unbounded array.
18392 : : */
18393 : :
18394 : 4997634 : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym)
18395 : : {
18396 : 4997634 : SymbolTable_PtrToSymbol pSym;
18397 : :
18398 : 4997634 : pSym = GetPsym (Sym);
18399 : 4997634 : switch (pSym->SymbolType)
18400 : : {
18401 : 4997634 : case SymbolTable_UnboundedSym:
18402 : 4997634 : return pSym->Unbounded.RecordType;
18403 : 0 : break;
18404 : :
18405 : :
18406 : 0 : default:
18407 : 0 : M2Error_InternalError ((const char *) "expecting an UnBounded symbol", 29);
18408 : : break;
18409 : : }
18410 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18411 : : __builtin_unreachable ();
18412 : : }
18413 : :
18414 : :
18415 : : /*
18416 : : GetUnboundedAddressOffset - returns the offset of the address field
18417 : : inside the record used to implement the
18418 : : unbounded type.
18419 : : */
18420 : :
18421 : 64439 : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym)
18422 : : {
18423 : 64439 : unsigned int field;
18424 : 64439 : unsigned int rec;
18425 : :
18426 : 64439 : rec = SymbolTable_GetUnboundedRecordType (sym);
18427 : 64439 : if (rec == SymbolTable_NulSym)
18428 : : {
18429 : 0 : M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
18430 : : }
18431 : : else
18432 : : {
18433 : 64439 : field = SymbolTable_GetLocalSym (rec, NameKey_MakeKey ((const char *) "_m2_contents", 12));
18434 : 64439 : if (field == SymbolTable_NulSym)
18435 : : {
18436 : 0 : M2Error_InternalError ((const char *) "expecting address field to be present inside unbounded record", 61);
18437 : : }
18438 : : else
18439 : : {
18440 : 64439 : return field;
18441 : : }
18442 : : }
18443 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18444 : : __builtin_unreachable ();
18445 : : }
18446 : :
18447 : :
18448 : : /*
18449 : : GetUnboundedHighOffset - returns the offset of the high field
18450 : : inside the record used to implement the
18451 : : unbounded type.
18452 : : */
18453 : :
18454 : 87093 : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim)
18455 : : {
18456 : 87093 : unsigned int rec;
18457 : :
18458 : 87093 : rec = SymbolTable_GetUnboundedRecordType (sym);
18459 : 87093 : if (rec == SymbolTable_NulSym)
18460 : : {
18461 : 0 : M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
18462 : : }
18463 : : else
18464 : : {
18465 : 87093 : 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))))));
18466 : : }
18467 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18468 : : __builtin_unreachable ();
18469 : : }
18470 : :
18471 : :
18472 : : /*
18473 : : MakeSubscript - makes a subscript Symbol.
18474 : : No name is required.
18475 : : */
18476 : :
18477 : 88058 : extern "C" unsigned int SymbolTable_MakeSubscript (void)
18478 : : {
18479 : 88058 : SymbolTable_PtrToSymbol pSym;
18480 : 88058 : unsigned int Sym;
18481 : :
18482 : 88058 : NewSym (&Sym);
18483 : 88058 : pSym = GetPsym (Sym);
18484 : 88058 : pSym->SymbolType = SymbolTable_SubscriptSym;
18485 : 88058 : pSym->Subscript.Type = SymbolTable_NulSym; /* Index to a subrange symbol. */
18486 : 88058 : pSym->Subscript.Size = M2ALU_InitValue (); /* Size of this indice in*Size */
18487 : 88058 : pSym->Subscript.Offset = M2ALU_InitValue (); /* Offset at runtime of symbol */
18488 : 88058 : InitWhereDeclared (&pSym->Subscript.At); /* Declared here */
18489 : 88058 : return Sym;
18490 : : /* static analysis guarentees a RETURN statement will be used before here. */
18491 : : __builtin_unreachable ();
18492 : : }
18493 : :
18494 : :
18495 : : /*
18496 : : PutSubscript - gives a subscript symbol a type, SimpleType.
18497 : : */
18498 : :
18499 : 88058 : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType)
18500 : : {
18501 : 88058 : SymbolTable_PtrToSymbol pSym;
18502 : :
18503 : 88058 : pSym = GetPsym (Sym);
18504 : 88058 : switch (pSym->SymbolType)
18505 : : {
18506 : : case SymbolTable_ErrorSym:
18507 : : break;
18508 : :
18509 : 88058 : case SymbolTable_SubscriptSym:
18510 : 88058 : pSym->Subscript.Type = SimpleType;
18511 : 88058 : break;
18512 : :
18513 : :
18514 : 0 : default:
18515 : 0 : M2Error_InternalError ((const char *) "expecting a SubScript symbol", 28);
18516 : 88058 : break;
18517 : : }
18518 : 88058 : }
18519 : :
18520 : :
18521 : : /*
18522 : : MakeUnbounded - makes an unbounded array Symbol.
18523 : : ndim is the number of dimensions required.
18524 : : No name is required.
18525 : : */
18526 : :
18527 : 522675 : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim)
18528 : : {
18529 : 522675 : unsigned int sym;
18530 : 522675 : unsigned int oaf;
18531 : :
18532 : 522675 : tok = CheckTok (tok, (const char *) "unbounded", 9);
18533 : 522675 : oaf = SymbolTable_MakeOAFamily (SimpleType);
18534 : 522675 : sym = SymbolTable_GetUnbounded (oaf, ndim);
18535 : 522675 : if (sym == SymbolTable_NulSym)
18536 : : {
18537 : 33548 : NewSym (&sym);
18538 : 33548 : if (SymbolTable_IsUnknown (SimpleType))
18539 : : {
18540 : 0 : PutPartialUnbounded (sym, SimpleType, ndim);
18541 : : }
18542 : : else
18543 : : {
18544 : 33548 : FillInUnboundedFields (tok, sym, SimpleType, ndim);
18545 : : }
18546 : 33548 : PutUnbounded (oaf, sym, ndim);
18547 : : }
18548 : 522675 : return sym;
18549 : : /* static analysis guarentees a RETURN statement will be used before here. */
18550 : : __builtin_unreachable ();
18551 : : }
18552 : :
18553 : :
18554 : : /*
18555 : : NoOfElements - Returns the number of elements in array Sym,
18556 : : or the number of elements in an enumeration Sym or
18557 : : the number of interface symbols in an Interface list.
18558 : : */
18559 : :
18560 : 244 : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym)
18561 : : {
18562 : 244 : SymbolTable_PtrToSymbol pSym;
18563 : 244 : unsigned int n;
18564 : :
18565 : 244 : pSym = GetPsym (Sym);
18566 : 244 : switch (pSym->SymbolType)
18567 : : {
18568 : : case SymbolTable_ErrorSym:
18569 : : n = 0;
18570 : : break;
18571 : :
18572 : 244 : case SymbolTable_EnumerationSym:
18573 : : /*
18574 : : ArraySym ,
18575 : : UnboundedSym : n := 1 | Standard language limitation
18576 : : */
18577 : 244 : n = pSym->Enumeration.NoOfElements;
18578 : 244 : break;
18579 : :
18580 : 0 : case SymbolTable_InterfaceSym:
18581 : 0 : n = Indexing_HighIndice (pSym->Interface.Parameters);
18582 : 0 : break;
18583 : :
18584 : :
18585 : 0 : default:
18586 : 0 : M2Error_InternalError ((const char *) "expecting an Array or UnBounded symbol", 38);
18587 : 244 : break;
18588 : : }
18589 : 244 : return n;
18590 : : /* static analysis guarentees a RETURN statement will be used before here. */
18591 : : __builtin_unreachable ();
18592 : : }
18593 : :
18594 : :
18595 : : /*
18596 : : PutArray - places a type symbol into an arraysym.
18597 : : */
18598 : :
18599 : 88058 : extern "C" void SymbolTable_PutArray (unsigned int arraysym, unsigned int typesym)
18600 : : {
18601 : 88058 : SymbolTable_PtrToSymbol pSym;
18602 : :
18603 : 88058 : pSym = GetPsym (arraysym);
18604 : 88058 : switch (pSym->SymbolType)
18605 : : {
18606 : : case SymbolTable_ErrorSym:
18607 : : break;
18608 : :
18609 : 88058 : case SymbolTable_ArraySym:
18610 : 88058 : pSym->Array.Type = typesym; /* The ARRAY OF typesym. */
18611 : 88058 : break;
18612 : :
18613 : :
18614 : 0 : default:
18615 : 0 : M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
18616 : 88058 : break;
18617 : : }
18618 : 88058 : }
18619 : :
18620 : :
18621 : : /*
18622 : : ResolveImports - it examines the import list of all inner modules
18623 : : and resolves all relative imports.
18624 : : */
18625 : :
18626 : 65797 : extern "C" void SymbolTable_ResolveImports (void)
18627 : : {
18628 : 65797 : unsigned int scope;
18629 : :
18630 : 65797 : scope = SymbolTable_GetCurrentScope ();
18631 : 65797 : if (DebugUnknowns)
18632 : : {
18633 : : SymbolTable_DisplayTrees (scope);
18634 : : }
18635 : 65797 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
18636 : 65797 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
18637 : 65797 : }
18638 : :
18639 : :
18640 : : /*
18641 : : ResolveConstructorTypes - to be called at the end of pass three. Its
18642 : : purpose is to fix up all constructors whose
18643 : : types are unknown.
18644 : : */
18645 : :
18646 : 14985 : extern "C" void SymbolTable_ResolveConstructorTypes (void)
18647 : : {
18648 : 37019 : bool finished;
18649 : 37019 : unsigned int i;
18650 : 37019 : unsigned int n;
18651 : 37019 : unsigned int s;
18652 : :
18653 : 37019 : do {
18654 : 37019 : n = Lists_NoOfItemsInList (UnresolvedConstructorType);
18655 : 37019 : finished = true;
18656 : 37019 : i = 1;
18657 : 96078 : while (i <= n)
18658 : : {
18659 : 22040 : s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
18660 : 22040 : M2Debug_Assert (SymbolTable_IsConstructor (s));
18661 : 22040 : if (CanResolveConstructor (s))
18662 : : {
18663 : 22034 : finished = false;
18664 : 22034 : Lists_RemoveItemFromList (UnresolvedConstructorType, s);
18665 : 22034 : i = n;
18666 : : }
18667 : 22040 : i += 1;
18668 : : }
18669 : 37019 : } while (! (finished));
18670 : 14985 : CheckAllConstructorsResolved ();
18671 : 14979 : }
18672 : :
18673 : :
18674 : : /*
18675 : : AddNameToScope - adds a Name, n, to the list of objects declared at the
18676 : : current scope.
18677 : : */
18678 : :
18679 : 4862462 : extern "C" void SymbolTable_AddNameToScope (NameKey_Name n)
18680 : : {
18681 : 4862462 : SymbolTable_PtrToSymbol pSym;
18682 : 4862462 : unsigned int scope;
18683 : :
18684 : 4862462 : scope = SymbolTable_GetCurrentScope ();
18685 : 4862462 : pSym = GetPsym (scope);
18686 : 4862462 : switch (pSym->SymbolType)
18687 : : {
18688 : 854377 : case SymbolTable_ProcedureSym:
18689 : 854377 : AddNameTo (pSym->Procedure.NamedObjects, MakeObject (n));
18690 : 854377 : break;
18691 : :
18692 : 44298 : case SymbolTable_ModuleSym:
18693 : 44298 : AddNameTo (pSym->Module.NamedObjects, MakeObject (n));
18694 : 44298 : break;
18695 : :
18696 : 3963787 : case SymbolTable_DefImpSym:
18697 : 3963787 : AddNameTo (pSym->DefImp.NamedObjects, MakeObject (n));
18698 : 3963787 : break;
18699 : :
18700 : :
18701 : 0 : default:
18702 : 0 : M2Error_InternalError ((const char *) "expecting - DefImp", 18);
18703 : 4862462 : break;
18704 : : }
18705 : 4862462 : }
18706 : :
18707 : :
18708 : : /*
18709 : : AddNameToImportList - adds a Name, n, to the import list of the current
18710 : : module.
18711 : : */
18712 : :
18713 : 162 : extern "C" void SymbolTable_AddNameToImportList (NameKey_Name n)
18714 : : {
18715 : 162 : SymbolTable_PtrToSymbol pSym;
18716 : 162 : unsigned int scope;
18717 : :
18718 : 162 : scope = SymbolTable_GetCurrentScope ();
18719 : 162 : pSym = GetPsym (scope);
18720 : 162 : switch (pSym->SymbolType)
18721 : : {
18722 : 162 : case SymbolTable_ModuleSym:
18723 : 162 : AddNameTo (pSym->Module.NamedImports, MakeObject (n));
18724 : 162 : break;
18725 : :
18726 : 0 : case SymbolTable_DefImpSym:
18727 : 0 : AddNameTo (pSym->DefImp.NamedImports, MakeObject (n));
18728 : 0 : break;
18729 : :
18730 : :
18731 : 0 : default:
18732 : 0 : M2Error_InternalError ((const char *) "expecting - DefImp or Module symbol", 35);
18733 : 162 : break;
18734 : : }
18735 : 162 : }
18736 : :
18737 : :
18738 : : /*
18739 : : GetScope - returns the declaration scope of the symbol.
18740 : : */
18741 : :
18742 : 53407424 : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym)
18743 : : {
18744 : 53407514 : SymbolTable_PtrToSymbol pSym;
18745 : :
18746 : 53407514 : pSym = GetPsym (Sym);
18747 : 53407514 : switch (pSym->SymbolType)
18748 : : {
18749 : 0 : case SymbolTable_ErrorSym:
18750 : 0 : return pSym->Error.Scope;
18751 : : break;
18752 : :
18753 : : case SymbolTable_DefImpSym:
18754 : : return SymbolTable_NulSym;
18755 : 3104938 : break;
18756 : :
18757 : 3104938 : case SymbolTable_ModuleSym:
18758 : 3104938 : return pSym->Module.Scope;
18759 : 2803406 : break;
18760 : :
18761 : 2803406 : case SymbolTable_VarSym:
18762 : 2803406 : return pSym->Var.Scope;
18763 : 30637088 : break;
18764 : :
18765 : 30637088 : case SymbolTable_ProcedureSym:
18766 : 30637088 : return pSym->Procedure.Scope;
18767 : 221200 : break;
18768 : :
18769 : 221200 : case SymbolTable_ProcTypeSym:
18770 : 221200 : return pSym->ProcType.Scope;
18771 : 847716 : break;
18772 : :
18773 : 847716 : case SymbolTable_RecordFieldSym:
18774 : 847716 : return pSym->RecordField.Scope;
18775 : 336 : break;
18776 : :
18777 : 336 : case SymbolTable_VarientSym:
18778 : 336 : return pSym->Varient.Scope;
18779 : 1476 : break;
18780 : :
18781 : 1476 : case SymbolTable_VarientFieldSym:
18782 : 1476 : return pSym->VarientField.Scope;
18783 : 91456 : break;
18784 : :
18785 : 91456 : case SymbolTable_EnumerationSym:
18786 : 91456 : return pSym->Enumeration.Scope;
18787 : 1676316 : break;
18788 : :
18789 : 1676316 : case SymbolTable_EnumerationFieldSym:
18790 : 1676316 : return pSym->EnumerationField.Scope;
18791 : 187379 : break;
18792 : :
18793 : 187379 : case SymbolTable_SubrangeSym:
18794 : 187379 : return pSym->Subrange.Scope;
18795 : 1366 : break;
18796 : :
18797 : 1366 : case SymbolTable_ArraySym:
18798 : 1366 : return pSym->Array.Scope;
18799 : 135822 : break;
18800 : :
18801 : 135822 : case SymbolTable_TypeSym:
18802 : 135822 : return pSym->Type.Scope;
18803 : 78678 : break;
18804 : :
18805 : 78678 : case SymbolTable_PointerSym:
18806 : 78678 : return pSym->Pointer.Scope;
18807 : 533803 : break;
18808 : :
18809 : 533803 : case SymbolTable_RecordSym:
18810 : 533803 : return pSym->Record.Scope;
18811 : 50163 : break;
18812 : :
18813 : 50163 : case SymbolTable_SetSym:
18814 : 50163 : return pSym->Set.Scope;
18815 : 24 : break;
18816 : :
18817 : 24 : case SymbolTable_UnboundedSym:
18818 : 24 : return pSym->Unbounded.Scope;
18819 : 12 : break;
18820 : :
18821 : 12 : case SymbolTable_ConstLitSym:
18822 : 12 : return pSym->ConstLit.Scope;
18823 : 48 : break;
18824 : :
18825 : 48 : case SymbolTable_ConstStringSym:
18826 : 48 : return pSym->ConstString.Scope;
18827 : 258 : break;
18828 : :
18829 : 258 : case SymbolTable_ConstVarSym:
18830 : 258 : return pSym->ConstVar.Scope;
18831 : 138 : break;
18832 : :
18833 : 138 : case SymbolTable_ParamSym:
18834 : 138 : if (pSym->Param.ShadowVar == SymbolTable_NulSym)
18835 : : {
18836 : : return SymbolTable_NulSym;
18837 : : }
18838 : : else
18839 : : {
18840 : : return SymbolTable_GetScope (pSym->Param.ShadowVar);
18841 : : }
18842 : 12 : break;
18843 : :
18844 : 12 : case SymbolTable_VarParamSym:
18845 : 12 : if (pSym->VarParam.ShadowVar == SymbolTable_NulSym)
18846 : : {
18847 : : return SymbolTable_NulSym;
18848 : : }
18849 : : else
18850 : : {
18851 : : return SymbolTable_GetScope (pSym->VarParam.ShadowVar);
18852 : : }
18853 : : break;
18854 : :
18855 : : case SymbolTable_UndefinedSym:
18856 : : return SymbolTable_NulSym;
18857 : 0 : break;
18858 : :
18859 : 0 : case SymbolTable_PartialUnboundedSym:
18860 : 0 : M2Error_InternalError ((const char *) "should not be requesting the scope of a PartialUnbounded symbol", 63);
18861 : 0 : break;
18862 : :
18863 : :
18864 : 0 : default:
18865 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
18866 : : break;
18867 : : }
18868 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18869 : : __builtin_unreachable ();
18870 : : }
18871 : :
18872 : :
18873 : : /*
18874 : : GetModuleScope - returns the module scope of symbol, sym.
18875 : : If sym was declared within a nested procedure
18876 : : then return the module which defines the
18877 : : procedure.
18878 : : */
18879 : :
18880 : 352956 : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym)
18881 : : {
18882 : 352956 : unsigned int mod;
18883 : :
18884 : 352956 : mod = SymbolTable_GetScope (sym);
18885 : 706968 : while (((mod != SymbolTable_NulSym) && (! (SymbolTable_IsDefImp (mod)))) && (! (SymbolTable_IsModule (mod))))
18886 : : {
18887 : 1056 : mod = SymbolTable_GetScope (mod);
18888 : : }
18889 : 352956 : return mod;
18890 : : /* static analysis guarentees a RETURN statement will be used before here. */
18891 : : __builtin_unreachable ();
18892 : : }
18893 : :
18894 : :
18895 : : /*
18896 : : GetProcedureScope - returns the innermost procedure (if any)
18897 : : in which the symbol, sym, resides.
18898 : : A module inside the procedure is skipped
18899 : : over.
18900 : : */
18901 : :
18902 : 337184 : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym)
18903 : : {
18904 : 678976 : while ((sym != SymbolTable_NulSym) && (! (SymbolTable_IsProcedure (sym))))
18905 : : {
18906 : 341792 : sym = SymbolTable_GetScope (sym);
18907 : : }
18908 : 337184 : if ((sym != SymbolTable_NulSym) && (SymbolTable_IsProcedure (sym)))
18909 : : {
18910 : : return sym;
18911 : : }
18912 : : else
18913 : : {
18914 : 334850 : return SymbolTable_NulSym;
18915 : : }
18916 : : /* static analysis guarentees a RETURN statement will be used before here. */
18917 : : __builtin_unreachable ();
18918 : : }
18919 : :
18920 : :
18921 : : /*
18922 : : IsModuleWithinProcedure - returns TRUE if module, sym, is
18923 : : inside a procedure.
18924 : : */
18925 : :
18926 : 232144 : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym)
18927 : : {
18928 : 232144 : return (SymbolTable_GetProcedureScope (sym)) != SymbolTable_NulSym;
18929 : : /* static analysis guarentees a RETURN statement will be used before here. */
18930 : : __builtin_unreachable ();
18931 : : }
18932 : :
18933 : :
18934 : : /*
18935 : : GetParent - returns the parent of symbol, Sym.
18936 : : */
18937 : :
18938 : 98946 : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym)
18939 : : {
18940 : 98946 : SymbolTable_PtrToSymbol pSym;
18941 : :
18942 : 98946 : pSym = GetPsym (Sym);
18943 : 98946 : switch (pSym->SymbolType)
18944 : : {
18945 : 6 : case SymbolTable_ErrorSym:
18946 : 6 : M2Error_ErrorAbort0 ((const char *) "", 0);
18947 : 14418 : break;
18948 : :
18949 : 14418 : case SymbolTable_VarientSym:
18950 : 14418 : return pSym->Varient.Parent;
18951 : 54894 : break;
18952 : :
18953 : 54894 : case SymbolTable_VarientFieldSym:
18954 : 54894 : return pSym->VarientField.Parent;
18955 : 29628 : break;
18956 : :
18957 : 29628 : case SymbolTable_RecordFieldSym:
18958 : 29628 : return pSym->RecordField.Parent;
18959 : 0 : break;
18960 : :
18961 : 0 : case SymbolTable_EnumerationFieldSym:
18962 : 0 : return pSym->EnumerationField.Type;
18963 : 0 : break;
18964 : :
18965 : :
18966 : 0 : default:
18967 : 0 : M2Error_InternalError ((const char *) "not implemented yet", 19);
18968 : : break;
18969 : : }
18970 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
18971 : : __builtin_unreachable ();
18972 : : }
18973 : :
18974 : :
18975 : : /*
18976 : : IsRecordField - returns true if Sym is a record field.
18977 : : */
18978 : :
18979 : 152864704 : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym)
18980 : : {
18981 : 152864704 : SymbolTable_PtrToSymbol pSym;
18982 : :
18983 : 152864704 : pSym = GetPsym (Sym);
18984 : 152864704 : return pSym->SymbolType == SymbolTable_RecordFieldSym;
18985 : : /* static analysis guarentees a RETURN statement will be used before here. */
18986 : : __builtin_unreachable ();
18987 : : }
18988 : :
18989 : :
18990 : : /*
18991 : : MakeProcType - returns a procedure type symbol with ProcTypeName.
18992 : : */
18993 : :
18994 : 3501545 : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName)
18995 : : {
18996 : 3501545 : SymbolTable_PtrToSymbol pSym;
18997 : 3501545 : unsigned int oaf;
18998 : 3501545 : unsigned int sym;
18999 : :
19000 : 3501545 : tok = CheckTok (tok, (const char *) "proctype", 8);
19001 : 3501545 : sym = HandleHiddenOrDeclare (tok, ProcTypeName, &oaf);
19002 : 3501545 : if (! (SymbolTable_IsError (sym)))
19003 : : {
19004 : 3501545 : pSym = GetPsym (sym);
19005 : 3501545 : pSym->SymbolType = SymbolTable_ProcTypeSym;
19006 : 3501545 : switch (pSym->SymbolType)
19007 : : {
19008 : 3501545 : case SymbolTable_ProcTypeSym:
19009 : 3501545 : pSym->ProcType.ReturnType = SymbolTable_NulSym;
19010 : 3501545 : pSym->ProcType.name = ProcTypeName;
19011 : 3501545 : Lists_InitList (&pSym->ProcType.ListOfParam);
19012 : 3501545 : pSym->ProcType.HasVarArgs = false; /* Does this proc type use ... ? */
19013 : 3501545 : pSym->ProcType.HasOptArg = false; /* Does this proc type use [ ] ? */
19014 : 3501545 : pSym->ProcType.OptArgInit = SymbolTable_NulSym; /* The optarg initial value. */
19015 : 3501545 : pSym->ProcType.ReturnOptional = false; /* Is the return value optional? */
19016 : 3501545 : pSym->ProcType.ReturnTypeTok = M2LexBuf_UnknownTokenNo; /* Is the return value optional? */
19017 : 3501545 : pSym->ProcType.Scope = SymbolTable_GetCurrentScope ();
19018 : : /* scope of procedure. */
19019 : 3501545 : pSym->ProcType.Size = M2ALU_InitValue ();
19020 : 3501545 : pSym->ProcType.TotalParamSize = M2ALU_InitValue (); /* size of all parameters */
19021 : 3501545 : pSym->ProcType.oafamily = oaf; /* The oa family for this symbol */
19022 : 3501545 : InitWhereDeclaredTok (tok, &pSym->ProcType.At); /* Declared here */
19023 : 3501545 : break;
19024 : :
19025 : :
19026 : : default:
19027 : : M2Error_InternalError ((const char *) "expecting ProcType symbol", 25);
19028 : 3501545 : break;
19029 : : }
19030 : : }
19031 : 3501545 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
19032 : 3501545 : return sym;
19033 : : /* static analysis guarentees a RETURN statement will be used before here. */
19034 : : __builtin_unreachable ();
19035 : : }
19036 : :
19037 : :
19038 : : /*
19039 : : PutProcTypeParam - Places a Non VAR parameter ParamName with type
19040 : : ParamType into ProcType Sym.
19041 : : */
19042 : :
19043 : 5665533 : extern "C" void SymbolTable_PutProcTypeParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded)
19044 : : {
19045 : 5665533 : SymbolTable_PtrToSymbol pSym;
19046 : 5665533 : unsigned int ParSym;
19047 : :
19048 : 5665533 : NewSym (&ParSym);
19049 : 5665533 : pSym = GetPsym (ParSym);
19050 : 5665533 : pSym->SymbolType = SymbolTable_ParamSym;
19051 : 5665533 : pSym->Param.name = NameKey_NulName;
19052 : 5665533 : pSym->Param.Type = ParamType;
19053 : 5665533 : pSym->Param.IsUnbounded = isUnbounded;
19054 : 5665533 : pSym->Param.ShadowVar = SymbolTable_NulSym;
19055 : 5665533 : InitWhereDeclared (&pSym->Param.At);
19056 : 5665533 : AddParameter (Sym, SymbolTable_ProperProcedure, ParSym);
19057 : 5665533 : }
19058 : :
19059 : :
19060 : : /*
19061 : : PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
19062 : : ParamType into ProcType Sym.
19063 : : */
19064 : :
19065 : 432683 : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded)
19066 : : {
19067 : 432683 : SymbolTable_PtrToSymbol pSym;
19068 : 432683 : unsigned int ParSym;
19069 : :
19070 : 432683 : NewSym (&ParSym);
19071 : 432683 : pSym = GetPsym (ParSym);
19072 : 432683 : pSym->SymbolType = SymbolTable_VarParamSym;
19073 : 432683 : pSym->Param.name = NameKey_NulName;
19074 : 432683 : pSym->Param.Type = ParamType;
19075 : 432683 : pSym->Param.IsUnbounded = isUnbounded;
19076 : 432683 : pSym->Param.ShadowVar = SymbolTable_NulSym;
19077 : 432683 : InitWhereDeclared (&pSym->Param.At);
19078 : 432683 : AddParameter (Sym, SymbolTable_ProperProcedure, ParSym);
19079 : 432683 : }
19080 : :
19081 : :
19082 : : /*
19083 : : IsProcType - returns true if Sym is a ProcType Symbol.
19084 : : */
19085 : :
19086 : 111928476 : extern "C" bool SymbolTable_IsProcType (unsigned int Sym)
19087 : : {
19088 : 111928476 : SymbolTable_PtrToSymbol pSym;
19089 : :
19090 : 111928476 : pSym = GetPsym (Sym);
19091 : 111928476 : return pSym->SymbolType == SymbolTable_ProcTypeSym;
19092 : : /* static analysis guarentees a RETURN statement will be used before here. */
19093 : : __builtin_unreachable ();
19094 : : }
19095 : :
19096 : :
19097 : : /*
19098 : : IsVar - returns true if Sym is a Var Symbol.
19099 : : */
19100 : :
19101 : 81671534 : extern "C" bool SymbolTable_IsVar (unsigned int Sym)
19102 : : {
19103 : 81671534 : SymbolTable_PtrToSymbol pSym;
19104 : :
19105 : 81671534 : pSym = GetPsym (Sym);
19106 : 81671534 : return pSym->SymbolType == SymbolTable_VarSym;
19107 : : /* static analysis guarentees a RETURN statement will be used before here. */
19108 : : __builtin_unreachable ();
19109 : : }
19110 : :
19111 : :
19112 : : /*
19113 : : IsVarConst - returns the IsConst field indicating the variable is read only.
19114 : : */
19115 : :
19116 : 274052 : extern "C" bool SymbolTable_IsVarConst (unsigned int sym)
19117 : : {
19118 : 274052 : SymbolTable_PtrToSymbol pSym;
19119 : :
19120 : 274052 : pSym = GetPsym (sym);
19121 : 274052 : switch (pSym->SymbolType)
19122 : : {
19123 : 274052 : case SymbolTable_VarSym:
19124 : 274052 : return pSym->Var.IsConst;
19125 : 0 : break;
19126 : :
19127 : :
19128 : 0 : default:
19129 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
19130 : : break;
19131 : : }
19132 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19133 : : __builtin_unreachable ();
19134 : : }
19135 : :
19136 : :
19137 : : /*
19138 : : IsConst - returns true if Sym contains a constant value.
19139 : : */
19140 : :
19141 : 134456197 : extern "C" bool SymbolTable_IsConst (unsigned int Sym)
19142 : : {
19143 : 134456197 : if (SymbolTable_IsConstructor (Sym))
19144 : : {
19145 : 2826012 : return SymbolTable_IsConstructorConstant (Sym);
19146 : : }
19147 : : else
19148 : : {
19149 : 131630185 : return DoIsConst (Sym);
19150 : : }
19151 : : /* static analysis guarentees a RETURN statement will be used before here. */
19152 : : __builtin_unreachable ();
19153 : : }
19154 : :
19155 : :
19156 : : /*
19157 : : IsConstString - returns whether sym is a conststring of any variant.
19158 : : */
19159 : :
19160 : 6491866 : extern "C" bool SymbolTable_IsConstString (unsigned int sym)
19161 : : {
19162 : 6491866 : SymbolTable_PtrToSymbol pSym;
19163 : :
19164 : 6491866 : pSym = GetPsym (sym);
19165 : 6491866 : return pSym->SymbolType == SymbolTable_ConstStringSym;
19166 : : /* static analysis guarentees a RETURN statement will be used before here. */
19167 : : __builtin_unreachable ();
19168 : : }
19169 : :
19170 : :
19171 : : /*
19172 : : IsConstStringNulTerminated - returns TRUE if the constant string, sym,
19173 : : should be created with a nul terminator.
19174 : : */
19175 : :
19176 : 0 : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym)
19177 : : {
19178 : 0 : SymbolTable_PtrToSymbol pSym;
19179 : :
19180 : 0 : pSym = GetPsym (sym);
19181 : 0 : switch (pSym->SymbolType)
19182 : : {
19183 : 0 : case SymbolTable_ConstStringSym:
19184 : 0 : return (pSym->ConstString.StringVariant == SymbolTable_m2nulstr) || (pSym->ConstString.StringVariant == SymbolTable_cnulstr);
19185 : 0 : break;
19186 : :
19187 : :
19188 : 0 : default:
19189 : 0 : M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
19190 : : break;
19191 : : }
19192 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19193 : : __builtin_unreachable ();
19194 : : }
19195 : :
19196 : :
19197 : : /*
19198 : : IsConstLit - returns true if Sym is a literal constant.
19199 : : */
19200 : :
19201 : 7311092 : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym)
19202 : : {
19203 : 7311092 : SymbolTable_PtrToSymbol pSym;
19204 : :
19205 : 7311092 : pSym = GetPsym (Sym);
19206 : 7311092 : return pSym->SymbolType == SymbolTable_ConstLitSym;
19207 : : /* static analysis guarentees a RETURN statement will be used before here. */
19208 : : __builtin_unreachable ();
19209 : : }
19210 : :
19211 : :
19212 : : /*
19213 : : IsConstructor - returns TRUE if the constant is declared as a
19214 : : constant set, array or record.
19215 : : */
19216 : :
19217 : 224746751 : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym)
19218 : : {
19219 : 224746751 : SymbolTable_PtrToSymbol pSym;
19220 : :
19221 : 224746751 : pSym = GetPsym (Sym);
19222 : 224746751 : switch (pSym->SymbolType)
19223 : : {
19224 : 36226028 : case SymbolTable_ConstVarSym:
19225 : 36226028 : return pSym->ConstVar.IsConstructor;
19226 : 43194624 : break;
19227 : :
19228 : 43194624 : case SymbolTable_ConstLitSym:
19229 : 43194624 : return pSym->ConstLit.IsConstructor;
19230 : : break;
19231 : :
19232 : :
19233 : : default:
19234 : : return false;
19235 : : break;
19236 : : }
19237 : : /* static analysis guarentees a RETURN statement will be used before here. */
19238 : : __builtin_unreachable ();
19239 : : }
19240 : :
19241 : :
19242 : : /*
19243 : : IsDummy - returns true if Sym is a Dummy symbol.
19244 : : */
19245 : :
19246 : 0 : extern "C" bool SymbolTable_IsDummy (unsigned int Sym)
19247 : : {
19248 : 0 : SymbolTable_PtrToSymbol pSym;
19249 : :
19250 : 0 : pSym = GetPsym (Sym);
19251 : 0 : return pSym->SymbolType == SymbolTable_DummySym;
19252 : : /* static analysis guarentees a RETURN statement will be used before here. */
19253 : : __builtin_unreachable ();
19254 : : }
19255 : :
19256 : :
19257 : : /*
19258 : : IsTemporary - returns true if Sym is a Temporary symbol.
19259 : : */
19260 : :
19261 : 1746898 : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym)
19262 : : {
19263 : 1746898 : SymbolTable_PtrToSymbol pSym;
19264 : :
19265 : 1746898 : pSym = GetPsym (Sym);
19266 : 1746898 : switch (pSym->SymbolType)
19267 : : {
19268 : 1664553 : case SymbolTable_VarSym:
19269 : 1664553 : return pSym->Var.IsTemp;
19270 : 3162 : break;
19271 : :
19272 : 3162 : case SymbolTable_ConstVarSym:
19273 : 3162 : return pSym->ConstVar.IsTemp;
19274 : : break;
19275 : :
19276 : :
19277 : : default:
19278 : : return false;
19279 : : break;
19280 : : }
19281 : : /* static analysis guarentees a RETURN statement will be used before here. */
19282 : : __builtin_unreachable ();
19283 : : }
19284 : :
19285 : :
19286 : : /*
19287 : : IsVarAParam - returns true if Sym is a variable declared as a parameter.
19288 : : */
19289 : :
19290 : 32088 : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym)
19291 : : {
19292 : 32088 : SymbolTable_PtrToSymbol pSym;
19293 : :
19294 : 32088 : pSym = GetPsym (Sym);
19295 : 32088 : switch (pSym->SymbolType)
19296 : : {
19297 : 32088 : case SymbolTable_VarSym:
19298 : 32088 : return pSym->Var.IsParam;
19299 : : break;
19300 : :
19301 : :
19302 : : default:
19303 : : return false;
19304 : : break;
19305 : : }
19306 : : /* static analysis guarentees a RETURN statement will be used before here. */
19307 : : __builtin_unreachable ();
19308 : : }
19309 : :
19310 : :
19311 : : /*
19312 : : IsSubscript - returns true if Sym is a subscript symbol.
19313 : : */
19314 : :
19315 : 883892 : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym)
19316 : : {
19317 : 883892 : SymbolTable_PtrToSymbol pSym;
19318 : :
19319 : 883892 : pSym = GetPsym (Sym);
19320 : 883892 : return pSym->SymbolType == SymbolTable_SubscriptSym;
19321 : : /* static analysis guarentees a RETURN statement will be used before here. */
19322 : : __builtin_unreachable ();
19323 : : }
19324 : :
19325 : :
19326 : : /*
19327 : : IsSubrange - returns true if Sym is a subrange symbol.
19328 : : */
19329 : :
19330 : 121200998 : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym)
19331 : : {
19332 : 121200998 : SymbolTable_PtrToSymbol pSym;
19333 : :
19334 : 121200998 : pSym = GetPsym (Sym);
19335 : 121200998 : return pSym->SymbolType == SymbolTable_SubrangeSym;
19336 : : /* static analysis guarentees a RETURN statement will be used before here. */
19337 : : __builtin_unreachable ();
19338 : : }
19339 : :
19340 : :
19341 : : /*
19342 : : IsProcedureVariable - returns true if a Sym is a variable and
19343 : : it was declared within a procedure.
19344 : : */
19345 : :
19346 : 0 : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym)
19347 : : {
19348 : 0 : AssertInRange (Sym);
19349 : 0 : return (SymbolTable_IsVar (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetVarScope (Sym)));
19350 : : /* static analysis guarentees a RETURN statement will be used before here. */
19351 : : __builtin_unreachable ();
19352 : : }
19353 : :
19354 : :
19355 : : /*
19356 : : IsProcedureNested - returns TRUE if procedure, Sym, was
19357 : : declared as a nested procedure.
19358 : : */
19359 : :
19360 : 3066723 : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym)
19361 : : {
19362 : 3066723 : return (SymbolTable_IsProcedure (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetScope (Sym)));
19363 : : /* static analysis guarentees a RETURN statement will be used before here. */
19364 : : __builtin_unreachable ();
19365 : : }
19366 : :
19367 : :
19368 : : /*
19369 : : IsAModula2Type - returns true if Sym, is a:
19370 : : IsType, IsPointer, IsRecord, IsEnumeration,
19371 : : IsSubrange, IsArray, IsUnbounded, IsProcType.
19372 : : NOTE that it different from IsType.
19373 : : */
19374 : :
19375 : 15580871 : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym)
19376 : : {
19377 : 15580871 : AssertInRange (Sym);
19378 : 15580871 : 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));
19379 : : /* static analysis guarentees a RETURN statement will be used before here. */
19380 : : __builtin_unreachable ();
19381 : : }
19382 : :
19383 : :
19384 : : /*
19385 : : IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
19386 : : */
19387 : :
19388 : 27 : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym)
19389 : : {
19390 : 27 : SymbolTable_PtrToSymbol pSym;
19391 : :
19392 : 27 : pSym = GetPsym (Sym);
19393 : 27 : switch (pSym->SymbolType)
19394 : : {
19395 : 27 : case SymbolTable_GnuAsmSym:
19396 : 27 : return pSym->GnuAsm.Volatile;
19397 : 0 : break;
19398 : :
19399 : :
19400 : 0 : default:
19401 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
19402 : : break;
19403 : : }
19404 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19405 : : __builtin_unreachable ();
19406 : : }
19407 : :
19408 : :
19409 : : /*
19410 : : IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
19411 : : */
19412 : :
19413 : 27 : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym)
19414 : : {
19415 : 27 : SymbolTable_PtrToSymbol pSym;
19416 : :
19417 : 27 : pSym = GetPsym (Sym);
19418 : 27 : switch (pSym->SymbolType)
19419 : : {
19420 : 27 : case SymbolTable_GnuAsmSym:
19421 : 27 : return pSym->GnuAsm.Simple;
19422 : 0 : break;
19423 : :
19424 : :
19425 : 0 : default:
19426 : 0 : M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
19427 : : break;
19428 : : }
19429 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19430 : : __builtin_unreachable ();
19431 : : }
19432 : :
19433 : :
19434 : : /*
19435 : : IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
19436 : : */
19437 : :
19438 : 108 : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym)
19439 : : {
19440 : 108 : SymbolTable_PtrToSymbol pSym;
19441 : :
19442 : 108 : pSym = GetPsym (Sym);
19443 : 108 : return pSym->SymbolType == SymbolTable_GnuAsmSym;
19444 : : /* static analysis guarentees a RETURN statement will be used before here. */
19445 : : __builtin_unreachable ();
19446 : : }
19447 : :
19448 : :
19449 : : /*
19450 : : IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
19451 : : */
19452 : :
19453 : 0 : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym)
19454 : : {
19455 : 0 : SymbolTable_PtrToSymbol pSym;
19456 : :
19457 : 0 : pSym = GetPsym (Sym);
19458 : 0 : return pSym->SymbolType == SymbolTable_InterfaceSym;
19459 : : /* static analysis guarentees a RETURN statement will be used before here. */
19460 : : __builtin_unreachable ();
19461 : : }
19462 : :
19463 : :
19464 : : /*
19465 : : IsSizeSolved - returns true if the size of Sym is solved.
19466 : : */
19467 : :
19468 : 19886 : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym)
19469 : : {
19470 : 19886 : SymbolTable_PtrToSymbol pSym;
19471 : :
19472 : 19886 : AssertInRange (Sym);
19473 : 19886 : pSym = GetPsym (Sym);
19474 : 19886 : switch (pSym->SymbolType)
19475 : : {
19476 : 0 : case SymbolTable_ProcedureSym:
19477 : 0 : return M2ALU_IsSolved (pSym->Procedure.Size);
19478 : 1364 : break;
19479 : :
19480 : 1364 : case SymbolTable_VarSym:
19481 : 1364 : return M2ALU_IsSolved (pSym->Var.Size);
19482 : 12510 : break;
19483 : :
19484 : 12510 : case SymbolTable_TypeSym:
19485 : 12510 : return M2ALU_IsSolved (pSym->Type.Size);
19486 : 2450 : break;
19487 : :
19488 : 2450 : case SymbolTable_SetSym:
19489 : 2450 : return M2ALU_IsSolved (pSym->Set.Size);
19490 : 12 : break;
19491 : :
19492 : 12 : case SymbolTable_RecordSym:
19493 : 12 : return M2ALU_IsSolved (pSym->Record.Size);
19494 : 0 : break;
19495 : :
19496 : 0 : case SymbolTable_VarientSym:
19497 : 0 : return M2ALU_IsSolved (pSym->Varient.Size);
19498 : 12 : break;
19499 : :
19500 : 12 : case SymbolTable_EnumerationSym:
19501 : 12 : return M2ALU_IsSolved (pSym->Enumeration.Size);
19502 : 52 : break;
19503 : :
19504 : 52 : case SymbolTable_PointerSym:
19505 : 52 : return M2ALU_IsSolved (pSym->Pointer.Size);
19506 : 3474 : break;
19507 : :
19508 : 3474 : case SymbolTable_ArraySym:
19509 : 3474 : return M2ALU_IsSolved (pSym->Array.Size);
19510 : 0 : break;
19511 : :
19512 : 0 : case SymbolTable_RecordFieldSym:
19513 : 0 : return M2ALU_IsSolved (pSym->RecordField.Size);
19514 : 0 : break;
19515 : :
19516 : 0 : case SymbolTable_VarientFieldSym:
19517 : 0 : return M2ALU_IsSolved (pSym->VarientField.Size);
19518 : 0 : break;
19519 : :
19520 : 0 : case SymbolTable_SubrangeSym:
19521 : 0 : return M2ALU_IsSolved (pSym->Subrange.Size);
19522 : 0 : break;
19523 : :
19524 : 0 : case SymbolTable_SubscriptSym:
19525 : 0 : return M2ALU_IsSolved (pSym->Subscript.Size);
19526 : 12 : break;
19527 : :
19528 : 12 : case SymbolTable_ProcTypeSym:
19529 : 12 : return M2ALU_IsSolved (pSym->ProcType.Size);
19530 : 0 : break;
19531 : :
19532 : 0 : case SymbolTable_UnboundedSym:
19533 : 0 : return M2ALU_IsSolved (pSym->Unbounded.Size);
19534 : 0 : break;
19535 : :
19536 : :
19537 : 0 : default:
19538 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19539 : : break;
19540 : : }
19541 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19542 : : __builtin_unreachable ();
19543 : : }
19544 : :
19545 : :
19546 : : /*
19547 : : IsOffsetSolved - returns true if the Offset of Sym is solved.
19548 : : */
19549 : :
19550 : 0 : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym)
19551 : : {
19552 : 0 : SymbolTable_PtrToSymbol pSym;
19553 : :
19554 : 0 : AssertInRange (Sym);
19555 : 0 : pSym = GetPsym (Sym);
19556 : 0 : switch (pSym->SymbolType)
19557 : : {
19558 : 0 : case SymbolTable_VarSym:
19559 : 0 : return M2ALU_IsSolved (pSym->Var.Offset);
19560 : 0 : break;
19561 : :
19562 : 0 : case SymbolTable_RecordFieldSym:
19563 : 0 : return M2ALU_IsSolved (pSym->RecordField.Offset);
19564 : 0 : break;
19565 : :
19566 : 0 : case SymbolTable_VarientFieldSym:
19567 : 0 : return M2ALU_IsSolved (pSym->VarientField.Offset);
19568 : 0 : break;
19569 : :
19570 : :
19571 : 0 : default:
19572 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19573 : : break;
19574 : : }
19575 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19576 : : __builtin_unreachable ();
19577 : : }
19578 : :
19579 : :
19580 : : /*
19581 : : IsValueSolved - returns true if the value of Sym is solved.
19582 : : */
19583 : :
19584 : 2667521 : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym)
19585 : : {
19586 : 2667521 : SymbolTable_PtrToSymbol pSym;
19587 : :
19588 : 2667521 : AssertInRange (Sym);
19589 : 2667521 : pSym = GetPsym (Sym);
19590 : 2667521 : switch (pSym->SymbolType)
19591 : : {
19592 : 1365198 : case SymbolTable_ConstLitSym:
19593 : 1365198 : return M2ALU_IsSolved (pSym->ConstLit.Value);
19594 : 564153 : break;
19595 : :
19596 : 564153 : case SymbolTable_ConstVarSym:
19597 : 564153 : return M2ALU_IsSolved (pSym->ConstVar.Value);
19598 : 480842 : break;
19599 : :
19600 : 480842 : case SymbolTable_EnumerationFieldSym:
19601 : 480842 : return M2ALU_IsSolved (pSym->EnumerationField.Value);
19602 : : break;
19603 : :
19604 : : case SymbolTable_ConstStringSym:
19605 : : return true;
19606 : 6 : break;
19607 : :
19608 : :
19609 : 6 : default:
19610 : 6 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
19611 : : break;
19612 : : }
19613 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19614 : : __builtin_unreachable ();
19615 : : }
19616 : :
19617 : :
19618 : : /*
19619 : : IsConstructorConstant - returns TRUE if constructor, Sym, is
19620 : : defined by only constants.
19621 : : */
19622 : :
19623 : 3261862 : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym)
19624 : : {
19625 : 3261862 : SymbolTable_PtrToSymbol pSym;
19626 : :
19627 : 3261862 : if ((SymbolTable_IsConstructor (Sym)) || (SymbolTable_IsConstSet (Sym)))
19628 : : {
19629 : 3261862 : pSym = GetPsym (Sym);
19630 : 3261862 : switch (pSym->SymbolType)
19631 : : {
19632 : 3261862 : case SymbolTable_ConstVarSym:
19633 : 3261862 : return M2ALU_IsValueConst (pSym->ConstVar.Value);
19634 : 0 : break;
19635 : :
19636 : 0 : case SymbolTable_ConstLitSym:
19637 : 0 : return M2ALU_IsValueConst (pSym->ConstLit.Value);
19638 : 0 : break;
19639 : :
19640 : :
19641 : 0 : default:
19642 : 0 : M2Error_InternalError ((const char *) "expecting Constructor", 21);
19643 : 0 : break;
19644 : : }
19645 : : }
19646 : : else
19647 : : {
19648 : 0 : M2Error_InternalError ((const char *) "expecting Constructor", 21);
19649 : : }
19650 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19651 : : __builtin_unreachable ();
19652 : : }
19653 : :
19654 : :
19655 : : /*
19656 : : IsComposite - returns TRUE if symbol, sym, is a composite
19657 : : type: ie an ARRAY or RECORD.
19658 : : */
19659 : :
19660 : 126322 : extern "C" bool SymbolTable_IsComposite (unsigned int sym)
19661 : : {
19662 : 126322 : if (sym == SymbolTable_NulSym)
19663 : : {
19664 : : return false;
19665 : : }
19666 : : else
19667 : : {
19668 : 126310 : sym = SymbolTable_SkipType (sym);
19669 : 126310 : return (SymbolTable_IsArray (sym)) || (SymbolTable_IsRecord (sym));
19670 : : }
19671 : : /* static analysis guarentees a RETURN statement will be used before here. */
19672 : : __builtin_unreachable ();
19673 : : }
19674 : :
19675 : :
19676 : : /*
19677 : : IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
19678 : : */
19679 : :
19680 : 0 : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym)
19681 : : {
19682 : 0 : SymbolTable_PtrToSymbol pSym;
19683 : :
19684 : 0 : AssertInRange (Sym);
19685 : 0 : pSym = GetPsym (Sym);
19686 : 0 : switch (pSym->SymbolType)
19687 : : {
19688 : 0 : case SymbolTable_ProcedureSym:
19689 : 0 : return M2ALU_IsSolved (pSym->Procedure.TotalParamSize);
19690 : 0 : break;
19691 : :
19692 : 0 : case SymbolTable_ProcTypeSym:
19693 : 0 : return M2ALU_IsSolved (pSym->ProcType.TotalParamSize);
19694 : 0 : break;
19695 : :
19696 : :
19697 : 0 : default:
19698 : 0 : M2Error_InternalError ((const char *) "expecting Procedure or ProcType symbol", 38);
19699 : : break;
19700 : : }
19701 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19702 : : __builtin_unreachable ();
19703 : : }
19704 : :
19705 : :
19706 : : /*
19707 : : PutAlignment - assigns the alignment constant associated with,
19708 : : type, with, align.
19709 : : */
19710 : :
19711 : 192 : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align)
19712 : : {
19713 : 192 : SymbolTable_PtrToSymbol pSym;
19714 : :
19715 : 192 : pSym = GetPsym (type);
19716 : 192 : switch (pSym->SymbolType)
19717 : : {
19718 : 0 : case SymbolTable_RecordSym:
19719 : 0 : pSym->Record.Align = align;
19720 : 0 : break;
19721 : :
19722 : 120 : case SymbolTable_RecordFieldSym:
19723 : 120 : pSym->RecordField.Align = align;
19724 : 120 : break;
19725 : :
19726 : 18 : case SymbolTable_TypeSym:
19727 : 18 : pSym->Type.Align = align;
19728 : 18 : break;
19729 : :
19730 : 30 : case SymbolTable_ArraySym:
19731 : 30 : pSym->Array.Align = align;
19732 : 30 : break;
19733 : :
19734 : 12 : case SymbolTable_PointerSym:
19735 : 12 : pSym->Pointer.Align = align;
19736 : 12 : break;
19737 : :
19738 : 12 : case SymbolTable_SubrangeSym:
19739 : 12 : pSym->Subrange.Align = align;
19740 : 12 : break;
19741 : :
19742 : :
19743 : 0 : default:
19744 : 0 : M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
19745 : 192 : break;
19746 : : }
19747 : 192 : }
19748 : :
19749 : :
19750 : : /*
19751 : : GetAlignment - returns the alignment constant associated with,
19752 : : type.
19753 : : */
19754 : :
19755 : 92980716 : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type)
19756 : : {
19757 : 92981454 : SymbolTable_PtrToSymbol pSym;
19758 : :
19759 : 92981454 : pSym = GetPsym (type);
19760 : 92981454 : switch (pSym->SymbolType)
19761 : : {
19762 : 82509 : case SymbolTable_RecordSym:
19763 : 82509 : return pSym->Record.Align;
19764 : 42758154 : break;
19765 : :
19766 : 42758154 : case SymbolTable_RecordFieldSym:
19767 : 42758154 : return pSym->RecordField.Align;
19768 : 36509613 : break;
19769 : :
19770 : 36509613 : case SymbolTable_TypeSym:
19771 : 36509613 : return pSym->Type.Align;
19772 : 817916 : break;
19773 : :
19774 : 817916 : case SymbolTable_ArraySym:
19775 : 817916 : return pSym->Array.Align;
19776 : 11471709 : break;
19777 : :
19778 : 11471709 : case SymbolTable_PointerSym:
19779 : 11471709 : return pSym->Pointer.Align;
19780 : 702 : break;
19781 : :
19782 : 702 : case SymbolTable_VarientFieldSym:
19783 : 702 : return SymbolTable_GetAlignment (pSym->VarientField.Parent);
19784 : 36 : break;
19785 : :
19786 : 36 : case SymbolTable_VarientSym:
19787 : 36 : return SymbolTable_GetAlignment (pSym->Varient.Parent);
19788 : 1340815 : break;
19789 : :
19790 : 1340815 : case SymbolTable_SubrangeSym:
19791 : 1340815 : return pSym->Subrange.Align;
19792 : 0 : break;
19793 : :
19794 : :
19795 : 0 : default:
19796 : 0 : M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
19797 : : break;
19798 : : }
19799 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19800 : : __builtin_unreachable ();
19801 : : }
19802 : :
19803 : :
19804 : : /*
19805 : : GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
19806 : : to record, sym.
19807 : : */
19808 : :
19809 : 8294419 : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym)
19810 : : {
19811 : 8295049 : SymbolTable_PtrToSymbol pSym;
19812 : :
19813 : 8295049 : pSym = GetPsym (sym);
19814 : 8295049 : switch (pSym->SymbolType)
19815 : : {
19816 : 8294419 : case SymbolTable_RecordSym:
19817 : 8294419 : return pSym->Record.DefaultAlign;
19818 : 630 : break;
19819 : :
19820 : 630 : case SymbolTable_VarientFieldSym:
19821 : 630 : return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
19822 : 0 : break;
19823 : :
19824 : 0 : case SymbolTable_VarientSym:
19825 : 0 : return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
19826 : 0 : break;
19827 : :
19828 : :
19829 : 0 : default:
19830 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
19831 : : break;
19832 : : }
19833 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19834 : : __builtin_unreachable ();
19835 : : }
19836 : :
19837 : :
19838 : : /*
19839 : : PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
19840 : : to record, sym.
19841 : : */
19842 : :
19843 : 36 : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align)
19844 : : {
19845 : 36 : SymbolTable_PtrToSymbol pSym;
19846 : :
19847 : 36 : pSym = GetPsym (sym);
19848 : 36 : switch (pSym->SymbolType)
19849 : : {
19850 : 36 : case SymbolTable_RecordSym:
19851 : 36 : pSym->Record.DefaultAlign = align;
19852 : 36 : break;
19853 : :
19854 : :
19855 : 0 : default:
19856 : 0 : M2Error_InternalError ((const char *) "expecting record symbol", 23);
19857 : 36 : break;
19858 : : }
19859 : 36 : }
19860 : :
19861 : :
19862 : : /*
19863 : : PutUnused - sets, sym, as unused. This is a gm2 pragma.
19864 : : */
19865 : :
19866 : 0 : extern "C" void SymbolTable_PutUnused (unsigned int sym)
19867 : : {
19868 : 0 : SymbolTable_PtrToSymbol pSym;
19869 : :
19870 : 0 : pSym = GetPsym (sym);
19871 : 0 : switch (pSym->SymbolType)
19872 : : {
19873 : 0 : case SymbolTable_RecordFieldSym:
19874 : 0 : pSym->RecordField.Used = false;
19875 : 0 : break;
19876 : :
19877 : :
19878 : 0 : default:
19879 : 0 : M2MetaError_MetaError1 ((const char *) "cannot use pragma 'unused' on symbol {%1ad}", 43, sym);
19880 : 0 : break;
19881 : : }
19882 : 0 : }
19883 : :
19884 : :
19885 : : /*
19886 : : IsUnused - returns TRUE if the symbol was declared as unused with a
19887 : : gm2 pragma.
19888 : : */
19889 : :
19890 : 126940 : extern "C" bool SymbolTable_IsUnused (unsigned int sym)
19891 : : {
19892 : 126940 : SymbolTable_PtrToSymbol pSym;
19893 : :
19894 : 126940 : pSym = GetPsym (sym);
19895 : 126940 : switch (pSym->SymbolType)
19896 : : {
19897 : 126940 : case SymbolTable_RecordFieldSym:
19898 : 126940 : return ! pSym->RecordField.Used;
19899 : 0 : break;
19900 : :
19901 : :
19902 : 0 : default:
19903 : 0 : M2Error_InternalError ((const char *) "expecting a record field symbol", 31);
19904 : : break;
19905 : : }
19906 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19907 : : __builtin_unreachable ();
19908 : : }
19909 : :
19910 : :
19911 : : /*
19912 : : PutDeclaredPacked - sets the Packed field of the record or record field symbol.
19913 : : */
19914 : :
19915 : 407975 : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b)
19916 : : {
19917 : 407975 : SymbolTable_PtrToSymbol pSym;
19918 : :
19919 : 407975 : pSym = GetPsym (sym);
19920 : 407975 : switch (pSym->SymbolType)
19921 : : {
19922 : 81807 : case SymbolTable_RecordSym:
19923 : 81807 : pSym->Record.DeclPacked = b;
19924 : 81807 : pSym->Record.DeclResolved = true;
19925 : 81807 : break;
19926 : :
19927 : 325064 : case SymbolTable_RecordFieldSym:
19928 : 325064 : pSym->RecordField.DeclPacked = b;
19929 : 325064 : pSym->RecordField.DeclResolved = true;
19930 : 325064 : break;
19931 : :
19932 : 600 : case SymbolTable_VarientFieldSym:
19933 : 600 : pSym->VarientField.DeclPacked = b;
19934 : 600 : pSym->VarientField.DeclResolved = true;
19935 : 600 : break;
19936 : :
19937 : 504 : case SymbolTable_VarientSym:
19938 : 504 : pSym->Varient.DeclPacked = b;
19939 : 504 : pSym->Varient.DeclResolved = true;
19940 : 504 : break;
19941 : :
19942 : :
19943 : 0 : default:
19944 : 0 : M2Error_InternalError ((const char *) "expecting a record or field record symbol", 41);
19945 : 407975 : break;
19946 : : }
19947 : 407975 : }
19948 : :
19949 : :
19950 : : /*
19951 : : IsDeclaredPacked - was the record symbol or record field, sym,
19952 : : declared as packed?
19953 : : */
19954 : :
19955 : 1140912 : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym)
19956 : : {
19957 : 1140912 : SymbolTable_PtrToSymbol pSym;
19958 : :
19959 : 1140912 : pSym = GetPsym (sym);
19960 : 1140912 : switch (pSym->SymbolType)
19961 : : {
19962 : 163614 : case SymbolTable_RecordSym:
19963 : 163614 : return pSym->Record.DeclPacked;
19964 : 975414 : break;
19965 : :
19966 : 975414 : case SymbolTable_RecordFieldSym:
19967 : 975414 : return pSym->RecordField.DeclPacked;
19968 : 1332 : break;
19969 : :
19970 : 1332 : case SymbolTable_VarientFieldSym:
19971 : 1332 : return pSym->VarientField.DeclPacked;
19972 : 552 : break;
19973 : :
19974 : 552 : case SymbolTable_VarientSym:
19975 : 552 : return pSym->Varient.DeclPacked;
19976 : 0 : break;
19977 : :
19978 : :
19979 : 0 : default:
19980 : 0 : M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
19981 : : break;
19982 : : }
19983 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
19984 : : __builtin_unreachable ();
19985 : : }
19986 : :
19987 : :
19988 : : /*
19989 : : IsDeclaredPackedResolved - do we know if the record symbol or record
19990 : : field, sym, declared as packed or not packed?
19991 : : */
19992 : :
19993 : 0 : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym)
19994 : : {
19995 : 0 : SymbolTable_PtrToSymbol pSym;
19996 : :
19997 : 0 : pSym = GetPsym (sym);
19998 : 0 : switch (pSym->SymbolType)
19999 : : {
20000 : 0 : case SymbolTable_RecordSym:
20001 : 0 : return pSym->Record.DeclResolved;
20002 : 0 : break;
20003 : :
20004 : 0 : case SymbolTable_RecordFieldSym:
20005 : 0 : return pSym->RecordField.DeclResolved;
20006 : 0 : break;
20007 : :
20008 : 0 : case SymbolTable_VarientFieldSym:
20009 : 0 : return pSym->VarientField.DeclResolved;
20010 : 0 : break;
20011 : :
20012 : 0 : case SymbolTable_VarientSym:
20013 : 0 : return pSym->Varient.DeclResolved;
20014 : 0 : break;
20015 : :
20016 : :
20017 : 0 : default:
20018 : 0 : M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
20019 : : break;
20020 : : }
20021 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20022 : : __builtin_unreachable ();
20023 : : }
20024 : :
20025 : :
20026 : : /*
20027 : : GetPackedEquivalent - returns the packed equivalent of type, sym.
20028 : : sym must be a type, subrange or enumerated type.
20029 : : */
20030 : :
20031 : 14665 : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym)
20032 : : {
20033 : 14665 : SymbolTable_PtrToSymbol pSym;
20034 : :
20035 : 14665 : pSym = GetPsym (sym);
20036 : 14665 : switch (pSym->SymbolType)
20037 : : {
20038 : 14545 : case SymbolTable_EnumerationSym:
20039 : 14545 : return GetEquivalent (&pSym->Enumeration.packedInfo, sym);
20040 : 120 : break;
20041 : :
20042 : 120 : case SymbolTable_SubrangeSym:
20043 : 120 : return GetEquivalent (&pSym->Subrange.packedInfo, sym);
20044 : 0 : break;
20045 : :
20046 : 0 : case SymbolTable_TypeSym:
20047 : 0 : return GetEquivalent (&pSym->Type.packedInfo, sym);
20048 : 0 : break;
20049 : :
20050 : 0 : case SymbolTable_SetSym:
20051 : 0 : return GetEquivalent (&pSym->Set.packedInfo, sym);
20052 : 0 : break;
20053 : :
20054 : :
20055 : 0 : default:
20056 : 0 : M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
20057 : : break;
20058 : : }
20059 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20060 : : __builtin_unreachable ();
20061 : : }
20062 : :
20063 : :
20064 : : /*
20065 : : GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
20066 : : */
20067 : :
20068 : 0 : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym)
20069 : : {
20070 : 0 : SymbolTable_PtrToSymbol pSym;
20071 : :
20072 : 0 : pSym = GetPsym (sym);
20073 : 0 : switch (pSym->SymbolType)
20074 : : {
20075 : 0 : case SymbolTable_EquivSym:
20076 : 0 : return pSym->Equiv.nonPacked;
20077 : 0 : break;
20078 : :
20079 : :
20080 : 0 : default:
20081 : 0 : M2Error_InternalError ((const char *) "expecting equivalent symbol", 27);
20082 : : break;
20083 : : }
20084 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20085 : : __builtin_unreachable ();
20086 : : }
20087 : :
20088 : :
20089 : : /*
20090 : : IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
20091 : : */
20092 : :
20093 : 0 : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym)
20094 : : {
20095 : 0 : SymbolTable_PtrToSymbol pSym;
20096 : :
20097 : 0 : pSym = GetPsym (sym);
20098 : 0 : switch (pSym->SymbolType)
20099 : : {
20100 : : case SymbolTable_EquivSym:
20101 : : return true;
20102 : 0 : break;
20103 : :
20104 : :
20105 : 0 : default:
20106 : 0 : return false;
20107 : : break;
20108 : : }
20109 : : /* static analysis guarentees a RETURN statement will be used before here. */
20110 : : __builtin_unreachable ();
20111 : : }
20112 : :
20113 : :
20114 : : /*
20115 : : PushSize - pushes the size of Sym.
20116 : : */
20117 : :
20118 : 82514 : extern "C" void SymbolTable_PushSize (unsigned int Sym)
20119 : : {
20120 : 82514 : SymbolTable_PtrToSymbol pSym;
20121 : :
20122 : 82514 : AssertInRange (Sym);
20123 : 82514 : pSym = GetPsym (Sym);
20124 : 82514 : switch (pSym->SymbolType)
20125 : : {
20126 : 0 : case SymbolTable_ProcedureSym:
20127 : 0 : M2ALU_PushFrom (pSym->Procedure.Size);
20128 : 0 : break;
20129 : :
20130 : 1364 : case SymbolTable_VarSym:
20131 : 1364 : M2ALU_PushFrom (pSym->Var.Size);
20132 : 1364 : break;
20133 : :
20134 : 12510 : case SymbolTable_TypeSym:
20135 : 12510 : M2ALU_PushFrom (pSym->Type.Size);
20136 : 12510 : break;
20137 : :
20138 : 2450 : case SymbolTable_SetSym:
20139 : 2450 : M2ALU_PushFrom (pSym->Set.Size);
20140 : 2450 : break;
20141 : :
20142 : 0 : case SymbolTable_VarientSym:
20143 : 0 : M2ALU_PushFrom (pSym->Varient.Size);
20144 : 0 : break;
20145 : :
20146 : 12 : case SymbolTable_RecordSym:
20147 : 12 : M2ALU_PushFrom (pSym->Record.Size);
20148 : 12 : break;
20149 : :
20150 : 12 : case SymbolTable_EnumerationSym:
20151 : 12 : M2ALU_PushFrom (pSym->Enumeration.Size);
20152 : 12 : break;
20153 : :
20154 : 62680 : case SymbolTable_PointerSym:
20155 : 62680 : M2ALU_PushFrom (pSym->Pointer.Size);
20156 : 62680 : break;
20157 : :
20158 : 3474 : case SymbolTable_ArraySym:
20159 : 3474 : M2ALU_PushFrom (pSym->Array.Size);
20160 : 3474 : break;
20161 : :
20162 : 0 : case SymbolTable_RecordFieldSym:
20163 : 0 : M2ALU_PushFrom (pSym->RecordField.Size);
20164 : 0 : break;
20165 : :
20166 : 0 : case SymbolTable_VarientFieldSym:
20167 : 0 : M2ALU_PushFrom (pSym->VarientField.Size);
20168 : 0 : break;
20169 : :
20170 : 0 : case SymbolTable_SubrangeSym:
20171 : 0 : M2ALU_PushFrom (pSym->Subrange.Size);
20172 : 0 : break;
20173 : :
20174 : 0 : case SymbolTable_SubscriptSym:
20175 : 0 : M2ALU_PushFrom (pSym->Subscript.Size);
20176 : 0 : break;
20177 : :
20178 : 12 : case SymbolTable_ProcTypeSym:
20179 : 12 : M2ALU_PushFrom (pSym->ProcType.Size);
20180 : 12 : break;
20181 : :
20182 : 0 : case SymbolTable_UnboundedSym:
20183 : 0 : M2ALU_PushFrom (pSym->Unbounded.Size);
20184 : 0 : break;
20185 : :
20186 : :
20187 : 0 : default:
20188 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20189 : 82514 : break;
20190 : : }
20191 : 82514 : }
20192 : :
20193 : :
20194 : : /*
20195 : : PopSize - pops the ALU stack into Size of Sym.
20196 : : */
20197 : :
20198 : 714278 : extern "C" void SymbolTable_PopSize (unsigned int Sym)
20199 : : {
20200 : 714278 : SymbolTable_PtrToSymbol pSym;
20201 : :
20202 : 714278 : AssertInRange (Sym);
20203 : 714278 : pSym = GetPsym (Sym);
20204 : 714278 : switch (pSym->SymbolType)
20205 : : {
20206 : 0 : case SymbolTable_ProcedureSym:
20207 : 0 : M2ALU_PopInto (pSym->Procedure.Size);
20208 : 0 : break;
20209 : :
20210 : 1096 : case SymbolTable_VarSym:
20211 : 1096 : M2ALU_PopInto (pSym->Var.Size);
20212 : 1096 : break;
20213 : :
20214 : 595154 : case SymbolTable_TypeSym:
20215 : 595154 : M2ALU_PopInto (pSym->Type.Size);
20216 : 595154 : break;
20217 : :
20218 : 12 : case SymbolTable_RecordSym:
20219 : 12 : M2ALU_PopInto (pSym->Record.Size);
20220 : 12 : break;
20221 : :
20222 : 0 : case SymbolTable_VarientSym:
20223 : 0 : M2ALU_PopInto (pSym->Varient.Size);
20224 : 0 : break;
20225 : :
20226 : 6 : case SymbolTable_EnumerationSym:
20227 : 6 : M2ALU_PopInto (pSym->Enumeration.Size);
20228 : 6 : break;
20229 : :
20230 : 15288 : case SymbolTable_PointerSym:
20231 : 15288 : M2ALU_PopInto (pSym->Pointer.Size);
20232 : 15288 : break;
20233 : :
20234 : 624 : case SymbolTable_ArraySym:
20235 : 624 : M2ALU_PopInto (pSym->Array.Size);
20236 : 624 : break;
20237 : :
20238 : 0 : case SymbolTable_RecordFieldSym:
20239 : 0 : M2ALU_PopInto (pSym->RecordField.Size);
20240 : 0 : break;
20241 : :
20242 : 0 : case SymbolTable_VarientFieldSym:
20243 : 0 : M2ALU_PopInto (pSym->VarientField.Size);
20244 : 0 : break;
20245 : :
20246 : 0 : case SymbolTable_SubrangeSym:
20247 : 0 : M2ALU_PopInto (pSym->Subrange.Size);
20248 : 0 : break;
20249 : :
20250 : 25414 : case SymbolTable_SubscriptSym:
20251 : 25414 : M2ALU_PopInto (pSym->Subscript.Size);
20252 : 25414 : break;
20253 : :
20254 : 15272 : case SymbolTable_ProcTypeSym:
20255 : 15272 : M2ALU_PopInto (pSym->ProcType.Size);
20256 : 15272 : break;
20257 : :
20258 : 0 : case SymbolTable_UnboundedSym:
20259 : 0 : M2ALU_PopInto (pSym->Unbounded.Size);
20260 : 0 : break;
20261 : :
20262 : 61412 : case SymbolTable_SetSym:
20263 : 61412 : M2ALU_PopInto (pSym->Set.Size);
20264 : 61412 : break;
20265 : :
20266 : :
20267 : 0 : default:
20268 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20269 : 714278 : break;
20270 : : }
20271 : 714278 : }
20272 : :
20273 : :
20274 : : /*
20275 : : PushValue - pushes the Value of Sym onto the ALU stack.
20276 : : */
20277 : :
20278 : 18942085 : extern "C" void SymbolTable_PushValue (unsigned int Sym)
20279 : : {
20280 : 18942085 : SymbolTable_PtrToSymbol pSym;
20281 : :
20282 : 18942085 : AssertInRange (Sym);
20283 : 18942085 : pSym = GetPsym (Sym);
20284 : 18942085 : switch (pSym->SymbolType)
20285 : : {
20286 : 1892352 : case SymbolTable_ConstLitSym:
20287 : 1892352 : M2ALU_PushFrom (pSym->ConstLit.Value);
20288 : 1892352 : break;
20289 : :
20290 : 1489909 : case SymbolTable_ConstVarSym:
20291 : 1489909 : M2ALU_PushFrom (pSym->ConstVar.Value);
20292 : 1489909 : break;
20293 : :
20294 : 15547332 : case SymbolTable_EnumerationFieldSym:
20295 : 15547332 : M2ALU_PushFrom (pSym->EnumerationField.Value);
20296 : 15547332 : break;
20297 : :
20298 : 12492 : case SymbolTable_ConstStringSym:
20299 : 12492 : PushConstString (Sym);
20300 : 12492 : break;
20301 : :
20302 : :
20303 : 0 : default:
20304 : 0 : M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
20305 : 18942085 : break;
20306 : : }
20307 : 18942085 : }
20308 : :
20309 : :
20310 : : /*
20311 : : PushVarSize - pushes the size of a variable, Sym.
20312 : : The runtime size of Sym will depend upon its addressing mode,
20313 : : RightValue has size PushSize(GetType(Sym)) and
20314 : : LeftValue has size PushSize(Address) since it points to a
20315 : : variable.
20316 : : */
20317 : :
20318 : 0 : extern "C" void SymbolTable_PushVarSize (unsigned int Sym)
20319 : : {
20320 : 0 : AssertInRange (Sym);
20321 : 0 : M2Debug_Assert (SymbolTable_IsVar (Sym));
20322 : 0 : if ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue)
20323 : : {
20324 : 0 : SymbolTable_PushSize (M2System_Address);
20325 : : }
20326 : : else
20327 : : {
20328 : 0 : M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_RightValue);
20329 : 0 : SymbolTable_PushSize (SymbolTable_GetType (Sym));
20330 : : }
20331 : 0 : }
20332 : :
20333 : :
20334 : : /*
20335 : : PopValue - pops the ALU stack into Value of Sym.
20336 : : */
20337 : :
20338 : 1208607 : extern "C" void SymbolTable_PopValue (unsigned int Sym)
20339 : : {
20340 : 1208607 : SymbolTable_PtrToSymbol pSym;
20341 : :
20342 : 1208607 : AssertInRange (Sym);
20343 : 1208607 : pSym = GetPsym (Sym);
20344 : 1208607 : switch (pSym->SymbolType)
20345 : : {
20346 : 0 : case SymbolTable_ConstLitSym:
20347 : 0 : M2ALU_PopInto (pSym->ConstLit.Value);
20348 : 0 : break;
20349 : :
20350 : 1208607 : case SymbolTable_ConstVarSym:
20351 : 1208607 : M2ALU_PopInto (pSym->ConstVar.Value);
20352 : 1208607 : break;
20353 : :
20354 : 0 : case SymbolTable_EnumerationFieldSym:
20355 : 0 : M2Error_InternalError ((const char *) "cannot pop into an enumeration field", 36);
20356 : 0 : break;
20357 : :
20358 : :
20359 : 0 : default:
20360 : 0 : M2Error_InternalError ((const char *) "symbol type not expected", 24);
20361 : 1208607 : break;
20362 : : }
20363 : 1208607 : }
20364 : :
20365 : :
20366 : : /*
20367 : : IsObject - returns TRUE if the symbol is an object symbol.
20368 : : */
20369 : :
20370 : 0 : extern "C" bool SymbolTable_IsObject (unsigned int Sym)
20371 : : {
20372 : 0 : SymbolTable_PtrToSymbol pSym;
20373 : :
20374 : 0 : AssertInRange (Sym);
20375 : 0 : pSym = GetPsym (Sym);
20376 : 0 : return pSym->SymbolType == SymbolTable_ObjectSym;
20377 : : /* static analysis guarentees a RETURN statement will be used before here. */
20378 : : __builtin_unreachable ();
20379 : : }
20380 : :
20381 : :
20382 : : /*
20383 : : IsTuple - returns TRUE if the symbol is a tuple symbol.
20384 : : */
20385 : :
20386 : 14092 : extern "C" bool SymbolTable_IsTuple (unsigned int Sym)
20387 : : {
20388 : 14092 : SymbolTable_PtrToSymbol pSym;
20389 : :
20390 : 14092 : AssertInRange (Sym);
20391 : 14092 : pSym = GetPsym (Sym);
20392 : 14092 : return pSym->SymbolType == SymbolTable_TupleSym;
20393 : : /* static analysis guarentees a RETURN statement will be used before here. */
20394 : : __builtin_unreachable ();
20395 : : }
20396 : :
20397 : :
20398 : : /*
20399 : : Make2Tuple - creates and returns a 2 tuple from, a, and, b.
20400 : : */
20401 : :
20402 : 2572 : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b)
20403 : : {
20404 : 2572 : SymbolTable_PtrToSymbol pSym;
20405 : 2572 : unsigned int Sym;
20406 : :
20407 : 2572 : NewSym (&Sym);
20408 : 2572 : pSym = GetPsym (Sym);
20409 : 2572 : pSym->SymbolType = SymbolTable_TupleSym;
20410 : 2572 : pSym->Tuple.nTuple = 2;
20411 : 2572 : pSym->Tuple.list = Indexing_InitIndex (1);
20412 : 2572 : PutIntoIndex (&pSym->Tuple.list, 1, a);
20413 : 2572 : PutIntoIndex (&pSym->Tuple.list, 2, b);
20414 : 2572 : InitWhereDeclared (&pSym->Tuple.At);
20415 : 2572 : InitWhereFirstUsed (&pSym->Tuple.At);
20416 : 2572 : return Sym;
20417 : : /* static analysis guarentees a RETURN statement will be used before here. */
20418 : : __builtin_unreachable ();
20419 : : }
20420 : :
20421 : :
20422 : : /*
20423 : : MakeError - creates an error node, which can be used in MetaError messages.
20424 : : It will be removed from ExportUndeclared and Unknown trees.
20425 : : */
20426 : :
20427 : 200 : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name)
20428 : : {
20429 : 200 : SymbolTable_PtrToSymbol pSym;
20430 : 200 : unsigned int Sym;
20431 : :
20432 : : /* if Sym is present on the unknown tree then remove it */
20433 : 200 : Sym = FetchUnknownSym (name);
20434 : 200 : if (Sym == SymbolTable_NulSym)
20435 : : {
20436 : 194 : NewSym (&Sym);
20437 : : }
20438 : : else
20439 : : {
20440 : : /*
20441 : : remove symbol from this tree as we have already generated
20442 : : a meaningful error message
20443 : : */
20444 : 6 : RemoveExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
20445 : : }
20446 : 200 : pSym = GetPsym (Sym);
20447 : 200 : pSym->SymbolType = SymbolTable_ErrorSym;
20448 : 200 : pSym->Error.name = name;
20449 : 200 : pSym->Error.Scope = SymbolTable_GetCurrentScope ();
20450 : 200 : InitWhereDeclaredTok (tok, &pSym->Error.At);
20451 : 200 : InitWhereFirstUsedTok (tok, &pSym->Error.At);
20452 : 200 : return Sym;
20453 : : /* static analysis guarentees a RETURN statement will be used before here. */
20454 : : __builtin_unreachable ();
20455 : : }
20456 : :
20457 : :
20458 : : /*
20459 : : MakeErrorS - creates an error node from a string, which can be used
20460 : : in MetaError messages.
20461 : : It will be removed from ExportUndeclared and Unknown trees.
20462 : : */
20463 : :
20464 : 0 : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name)
20465 : : {
20466 : 0 : return SymbolTable_MakeError (tok, NameKey_makekey (DynamicStrings_string (name)));
20467 : : /* static analysis guarentees a RETURN statement will be used before here. */
20468 : : __builtin_unreachable ();
20469 : : }
20470 : :
20471 : :
20472 : : /*
20473 : : IsError - returns TRUE if the symbol is an error symbol.
20474 : : */
20475 : :
20476 : 22394198 : extern "C" bool SymbolTable_IsError (unsigned int Sym)
20477 : : {
20478 : 22394198 : SymbolTable_PtrToSymbol pSym;
20479 : :
20480 : 22394198 : AssertInRange (Sym);
20481 : 22394198 : pSym = GetPsym (Sym);
20482 : 22394198 : return pSym->SymbolType == SymbolTable_ErrorSym;
20483 : : /* static analysis guarentees a RETURN statement will be used before here. */
20484 : : __builtin_unreachable ();
20485 : : }
20486 : :
20487 : :
20488 : : /*
20489 : : IsLegal - returns TRUE if, sym, is a legal symbol.
20490 : : */
20491 : :
20492 : 973272 : extern "C" bool SymbolTable_IsLegal (unsigned int sym)
20493 : : {
20494 : 973272 : return sym < FreeSymbol;
20495 : : /* static analysis guarentees a RETURN statement will be used before here. */
20496 : : __builtin_unreachable ();
20497 : : }
20498 : :
20499 : :
20500 : : /*
20501 : : PutModuleContainsBuiltin - sets a flag in the current compiled module which
20502 : : indicates that a builtin procedure is being declared.
20503 : : This is only expected to be called when we are
20504 : : parsing the definition module.
20505 : : */
20506 : :
20507 : 53664 : extern "C" void SymbolTable_PutModuleContainsBuiltin (void)
20508 : : {
20509 : 53664 : SymbolTable_PtrToSymbol pSym;
20510 : :
20511 : 53664 : SymbolTable_PutHiddenTypeDeclared ();
20512 : 53664 : pSym = GetPsym (CurrentModule);
20513 : 53664 : switch (pSym->SymbolType)
20514 : : {
20515 : 53664 : case SymbolTable_DefImpSym:
20516 : 53664 : pSym->DefImp.ContainsBuiltin = true;
20517 : 53664 : break;
20518 : :
20519 : :
20520 : 0 : default:
20521 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20522 : 53664 : break;
20523 : : }
20524 : 53664 : }
20525 : :
20526 : :
20527 : : /*
20528 : : IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
20529 : : */
20530 : :
20531 : 116538 : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym)
20532 : : {
20533 : 116538 : SymbolTable_PtrToSymbol pSym;
20534 : :
20535 : 116538 : pSym = GetPsym (Sym);
20536 : 116538 : switch (pSym->SymbolType)
20537 : : {
20538 : 116538 : case SymbolTable_DefImpSym:
20539 : 116538 : return pSym->DefImp.ContainsBuiltin;
20540 : 0 : break;
20541 : :
20542 : :
20543 : 0 : default:
20544 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20545 : : break;
20546 : : }
20547 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20548 : : __builtin_unreachable ();
20549 : : }
20550 : :
20551 : :
20552 : : /*
20553 : : PutHiddenTypeDeclared - sets a flag in the current compiled module which
20554 : : indicates that a Hidden Type is declared within
20555 : : the implementation part of the module.
20556 : : This procedure is expected to be called while
20557 : : compiling the associated definition module.
20558 : : */
20559 : :
20560 : 186415 : extern "C" void SymbolTable_PutHiddenTypeDeclared (void)
20561 : : {
20562 : 186415 : SymbolTable_PtrToSymbol pSym;
20563 : :
20564 : 186415 : pSym = GetPsym (CurrentModule);
20565 : 186415 : switch (pSym->SymbolType)
20566 : : {
20567 : 186415 : case SymbolTable_DefImpSym:
20568 : 186415 : pSym->DefImp.ContainsHiddenType = true;
20569 : 186415 : break;
20570 : :
20571 : :
20572 : 0 : default:
20573 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20574 : 186415 : break;
20575 : : }
20576 : 186415 : }
20577 : :
20578 : :
20579 : : /*
20580 : : IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
20581 : : the module, Sym.
20582 : : */
20583 : :
20584 : 5810147 : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym)
20585 : : {
20586 : 5810147 : SymbolTable_PtrToSymbol pSym;
20587 : :
20588 : 5810147 : pSym = GetPsym (Sym);
20589 : 5810147 : switch (pSym->SymbolType)
20590 : : {
20591 : 5810147 : case SymbolTable_DefImpSym:
20592 : 5810147 : return pSym->DefImp.ContainsHiddenType;
20593 : 0 : break;
20594 : :
20595 : :
20596 : 0 : default:
20597 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
20598 : : break;
20599 : : }
20600 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20601 : : __builtin_unreachable ();
20602 : : }
20603 : :
20604 : :
20605 : : /*
20606 : : IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
20607 : : type declared as a pointer or address.
20608 : : */
20609 : :
20610 : 369513 : extern "C" bool SymbolTable_IsHiddenReallyPointer (unsigned int Sym)
20611 : : {
20612 : 369513 : if (SymbolTable_IsVar (Sym))
20613 : : {
20614 : 0 : Sym = SymbolTable_GetType (Sym);
20615 : : }
20616 : 390642 : while ((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym)))
20617 : : {
20618 : 21129 : Sym = SymbolTable_SkipType (SymbolTable_GetType (Sym));
20619 : : }
20620 : 369513 : return (Sym != SymbolTable_NulSym) && ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address));
20621 : : /* static analysis guarentees a RETURN statement will be used before here. */
20622 : : __builtin_unreachable ();
20623 : : }
20624 : :
20625 : :
20626 : : /*
20627 : : DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
20628 : : */
20629 : :
20630 : 0 : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym)
20631 : : {
20632 : 0 : SymbolTable_PtrToSymbol pSym;
20633 : 0 : NameKey_Name n;
20634 : :
20635 : 0 : n = SymbolTable_GetSymName (ModSym);
20636 : 0 : M2Printf_printf1 ((const char *) "Symbol trees for module/procedure: %a\\n", 39, (const unsigned char *) &n, (sizeof (n)-1));
20637 : 0 : pSym = GetPsym (ModSym);
20638 : 0 : switch (pSym->SymbolType)
20639 : : {
20640 : 0 : case SymbolTable_DefImpSym:
20641 : 0 : n = SymbolTable_GetSymName (ModSym);
20642 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20643 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20644 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20645 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20646 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20647 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20648 : 0 : M2Printf_printf1 ((const char *) "%a ExportRequest", 17, (const unsigned char *) &n, (sizeof (n)-1));
20649 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportRequest, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20650 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20651 : 0 : M2Printf_printf1 ((const char *) "%a ExportQualified", 19, (const unsigned char *) &n, (sizeof (n)-1));
20652 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20653 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20654 : 0 : M2Printf_printf1 ((const char *) "%a ExportUnQualified", 21, (const unsigned char *) &n, (sizeof (n)-1));
20655 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20656 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20657 : 0 : M2Printf_printf1 ((const char *) "%a ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
20658 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20659 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20660 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20661 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20662 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20663 : 0 : M2Printf_printf1 ((const char *) "%a ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20664 : 0 : SymbolKey_ForeachNodeDo (pSym->DefImp.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20665 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20666 : 0 : break;
20667 : :
20668 : 0 : case SymbolTable_ModuleSym:
20669 : 0 : n = SymbolTable_GetSymName (ModSym);
20670 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20671 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20672 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20673 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20674 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20675 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20676 : 0 : M2Printf_printf1 ((const char *) "%a ImportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
20677 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20678 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20679 : 0 : M2Printf_printf1 ((const char *) "%a ExportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
20680 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20681 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20682 : 0 : M2Printf_printf1 ((const char *) "%a ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
20683 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20684 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20685 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20686 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20687 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20688 : 0 : M2Printf_printf1 ((const char *) "%a ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20689 : 0 : SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20690 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20691 : 0 : break;
20692 : :
20693 : 0 : case SymbolTable_ProcedureSym:
20694 : 0 : n = SymbolTable_GetSymName (ModSym);
20695 : 0 : M2Printf_printf1 ((const char *) "%a UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
20696 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20697 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20698 : 0 : M2Printf_printf1 ((const char *) "%a Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
20699 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
20700 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20701 : 0 : M2Printf_printf1 ((const char *) "%a DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
20702 : 0 : SymbolKey_ForeachNodeDo (pSym->Procedure.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
20703 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
20704 : 0 : break;
20705 : :
20706 : :
20707 : 0 : default:
20708 : 0 : M2Error_InternalError ((const char *) "expecting DefImp symbol", 23);
20709 : 0 : break;
20710 : : }
20711 : 0 : }
20712 : :
20713 : :
20714 : : /*
20715 : : DebugLineNumbers - internal debugging, emit all procedure names in this module
20716 : : together with the line numbers for the corresponding begin/end
20717 : : tokens.
20718 : : */
20719 : :
20720 : 14041 : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym)
20721 : : {
20722 : 14041 : if (M2Options_GetDebugFunctionLineNumbers ())
20723 : : {
20724 : 0 : M2Printf_printf0 ((const char *) "<lines>\\n", 9);
20725 : 0 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DebugProcedureLineNumber});
20726 : 0 : M2Printf_printf0 ((const char *) "</lines>\\n", 10);
20727 : : }
20728 : 14041 : }
20729 : :
20730 : :
20731 : : /*
20732 : : GetErrorScope - returns the error scope for a symbol.
20733 : : The error scope is the title scope which is used to
20734 : : announce the symbol in the GCC error message.
20735 : : */
20736 : :
20737 : 83154628 : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym)
20738 : : {
20739 : 83154628 : SymbolTable_PtrToSymbol pSym;
20740 : :
20741 : 83154628 : pSym = GetPsym (sym);
20742 : 83154628 : switch (pSym->SymbolType)
20743 : : {
20744 : 1367125 : case SymbolTable_ProcedureSym:
20745 : 1367125 : return pSym->Procedure.errorScope;
20746 : 3277424 : break;
20747 : :
20748 : 3277424 : case SymbolTable_ModuleSym:
20749 : 3277424 : return pSym->Module.errorScope;
20750 : 78510079 : break;
20751 : :
20752 : 78510079 : case SymbolTable_DefImpSym:
20753 : 78510079 : return pSym->DefImp.errorScope;
20754 : 0 : break;
20755 : :
20756 : 0 : case SymbolTable_UndefinedSym:
20757 : 0 : return pSym->Undefined.errorScope;
20758 : 0 : break;
20759 : :
20760 : :
20761 : 0 : default:
20762 : 0 : M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
20763 : : break;
20764 : : }
20765 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
20766 : : __builtin_unreachable ();
20767 : : }
20768 : :
20769 : :
20770 : : /*
20771 : : MakeImport - create and return an import symbol.
20772 : : moduleSym is the symbol being imported.
20773 : : isqualified is FALSE if it were IMPORT modulename and
20774 : : TRUE for the qualified FROM modulename IMPORT etc.
20775 : : listno is the import list count for this module.
20776 : : tok should match this modulename position.
20777 : : */
20778 : :
20779 : 298179 : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified)
20780 : : {
20781 : 298179 : unsigned int importSym;
20782 : 298179 : SymbolTable_PtrToSymbol pSym;
20783 : :
20784 : 298179 : NewSym (&importSym);
20785 : 298179 : pSym = GetPsym (importSym);
20786 : 298179 : pSym->SymbolType = SymbolTable_ImportSym;
20787 : 298179 : pSym->Import.module = moduleSym;
20788 : 298179 : pSym->Import.listNo = listno;
20789 : 298179 : pSym->Import.qualified = isqualified;
20790 : 298179 : InitWhereDeclaredTok (tok, &pSym->Import.at);
20791 : 298179 : return importSym;
20792 : : /* static analysis guarentees a RETURN statement will be used before here. */
20793 : : __builtin_unreachable ();
20794 : : }
20795 : :
20796 : :
20797 : : /*
20798 : : MakeImportStatement - return a dependent symbol which represents an import statement
20799 : : or a qualified import statement. The tok should either match
20800 : : the FROM token or the IMPORT token. listno is the import list
20801 : : count for the module.
20802 : : */
20803 : :
20804 : 289307 : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno)
20805 : : {
20806 : 289307 : unsigned int dependentSym;
20807 : 289307 : SymbolTable_PtrToSymbol pSym;
20808 : :
20809 : 289307 : NewSym (&dependentSym);
20810 : 289307 : pSym = GetPsym (dependentSym);
20811 : 289307 : pSym->SymbolType = SymbolTable_ImportStatementSym;
20812 : 289307 : pSym->ImportStatement.listNo = listno;
20813 : 289307 : Lists_InitList (&pSym->ImportStatement.ListOfImports);
20814 : 289307 : InitWhereDeclaredTok (tok, &pSym->ImportStatement.at);
20815 : 289307 : return dependentSym;
20816 : : /* static analysis guarentees a RETURN statement will be used before here. */
20817 : : __builtin_unreachable ();
20818 : : }
20819 : :
20820 : :
20821 : : /*
20822 : : IsImport - returns TRUE if sym is an import symbol.
20823 : : */
20824 : :
20825 : 827492 : extern "C" bool SymbolTable_IsImport (unsigned int sym)
20826 : : {
20827 : 827492 : SymbolTable_PtrToSymbol pSym;
20828 : :
20829 : 827492 : pSym = GetPsym (sym);
20830 : 827492 : return pSym->SymbolType == SymbolTable_ImportSym;
20831 : : /* static analysis guarentees a RETURN statement will be used before here. */
20832 : : __builtin_unreachable ();
20833 : : }
20834 : :
20835 : :
20836 : : /*
20837 : : IsImportStatement - returns TRUE if sym is a dependent symbol.
20838 : : */
20839 : :
20840 : 1092304 : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym)
20841 : : {
20842 : 1092304 : SymbolTable_PtrToSymbol pSym;
20843 : :
20844 : 1092304 : pSym = GetPsym (sym);
20845 : 1092304 : return pSym->SymbolType == SymbolTable_ImportStatementSym;
20846 : : /* static analysis guarentees a RETURN statement will be used before here. */
20847 : : __builtin_unreachable ();
20848 : : }
20849 : :
20850 : :
20851 : : /*
20852 : : GetImportModule - returns the module associated with the import symbol.
20853 : : */
20854 : :
20855 : 253813 : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym)
20856 : : {
20857 : 253813 : SymbolTable_PtrToSymbol pSym;
20858 : :
20859 : 253813 : M2Debug_Assert (SymbolTable_IsImport (sym));
20860 : 253813 : pSym = GetPsym (sym);
20861 : 253813 : return pSym->Import.module;
20862 : : /* static analysis guarentees a RETURN statement will be used before here. */
20863 : : __builtin_unreachable ();
20864 : : }
20865 : :
20866 : :
20867 : : /*
20868 : : GetImportDeclared - returns the token associated with the import symbol.
20869 : : */
20870 : :
20871 : 21687 : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym)
20872 : : {
20873 : 21687 : unsigned int tok;
20874 : :
20875 : 21687 : M2Debug_Assert (SymbolTable_IsImport (sym));
20876 : 21687 : tok = SymbolTable_GetDeclaredDefinition (sym);
20877 : 21687 : if (tok == M2LexBuf_UnknownTokenNo)
20878 : : {
20879 : 19891 : return SymbolTable_GetDeclaredModule (sym);
20880 : : }
20881 : : return tok;
20882 : : /* static analysis guarentees a RETURN statement will be used before here. */
20883 : : __builtin_unreachable ();
20884 : : }
20885 : :
20886 : :
20887 : : /*
20888 : : GetImportStatementList - returns the list of imports for this dependent.
20889 : : Each import symbol corresponds to a module.
20890 : : */
20891 : :
20892 : 546152 : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym)
20893 : : {
20894 : 546152 : SymbolTable_PtrToSymbol pSym;
20895 : :
20896 : 546152 : M2Debug_Assert (SymbolTable_IsImportStatement (sym));
20897 : 546152 : pSym = GetPsym (sym);
20898 : 546152 : return pSym->ImportStatement.ListOfImports;
20899 : : /* static analysis guarentees a RETURN statement will be used before here. */
20900 : : __builtin_unreachable ();
20901 : : }
20902 : :
20903 : :
20904 : : /*
20905 : : GetModuleDefImportStatementList - returns the list of dependents associated with
20906 : : the definition module.
20907 : : */
20908 : :
20909 : 153755 : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym)
20910 : : {
20911 : 153755 : SymbolTable_PtrToSymbol pSym;
20912 : :
20913 : 307510 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
20914 : 153755 : if (SymbolTable_IsDefImp (sym))
20915 : : {
20916 : 139877 : pSym = GetPsym (sym);
20917 : 139877 : return pSym->DefImp.DefListOfDep;
20918 : : }
20919 : : return static_cast<Lists_List> (NULL);
20920 : : /* static analysis guarentees a RETURN statement will be used before here. */
20921 : : __builtin_unreachable ();
20922 : : }
20923 : :
20924 : :
20925 : : /*
20926 : : GetModuleModImportStatementList - returns the list of dependents associated with
20927 : : the implementation or program module.
20928 : : */
20929 : :
20930 : 300042 : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym)
20931 : : {
20932 : 300042 : SymbolTable_PtrToSymbol pSym;
20933 : :
20934 : 600084 : M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
20935 : 300042 : pSym = GetPsym (sym);
20936 : 300042 : if (SymbolTable_IsDefImp (sym))
20937 : : {
20938 : 272149 : return pSym->DefImp.ModListOfDep;
20939 : : }
20940 : : else
20941 : : {
20942 : 27893 : return pSym->Module.ModListOfDep;
20943 : : }
20944 : : /* static analysis guarentees a RETURN statement will be used before here. */
20945 : : __builtin_unreachable ();
20946 : : }
20947 : :
20948 : :
20949 : : /*
20950 : : AppendModuleImportStatement - appends the ImportStatement symbol onto the
20951 : : module import list.
20952 : :
20953 : : For example:
20954 : :
20955 : : FROM x IMPORT y, z ;
20956 : : ^^^^
20957 : :
20958 : : also:
20959 : :
20960 : : IMPORT p, q, r;
20961 : : ^^^^^^
20962 : : will result in a new ImportStatement symbol added
20963 : : to the current module import list.
20964 : : The statement symbol is expected to be created
20965 : : by MakeImportStatement using the token positions
20966 : : outlined above.
20967 : : */
20968 : :
20969 : 289307 : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement)
20970 : : {
20971 : 289307 : SymbolTable_PtrToSymbol pSym;
20972 : :
20973 : 289307 : if (SymbolTable_IsDefImp (module))
20974 : : {
20975 : 275508 : pSym = GetPsym (module);
20976 : 275508 : if (M2Comp_CompilingDefinitionModule ())
20977 : : {
20978 : 73730 : Lists_IncludeItemIntoList (pSym->DefImp.DefListOfDep, statement);
20979 : : }
20980 : : else
20981 : : {
20982 : 201778 : Lists_IncludeItemIntoList (pSym->DefImp.ModListOfDep, statement);
20983 : : }
20984 : : }
20985 : 13799 : else if (SymbolTable_IsModule (module))
20986 : : {
20987 : : /* avoid dangling else. */
20988 : 13799 : pSym = GetPsym (module);
20989 : 13799 : Lists_IncludeItemIntoList (pSym->Module.ModListOfDep, statement);
20990 : : }
20991 : : else
20992 : : {
20993 : : /* avoid dangling else. */
20994 : 0 : M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
20995 : : }
20996 : 289307 : }
20997 : :
20998 : :
20999 : : /*
21000 : : AppendModuleOnImportStatement - appends the import symbol onto the
21001 : : dependent list (chain).
21002 : :
21003 : : For example each:
21004 : :
21005 : : FROM x IMPORT y, z ;
21006 : : ^
21007 : : x are added to the dependent list.
21008 : :
21009 : : also:
21010 : :
21011 : : IMPORT p, q, r;
21012 : : ^ ^ ^
21013 : : will result in p, q and r added to
21014 : : to the dependent list.
21015 : :
21016 : : The import symbol is created by MakeImport
21017 : : and the token is expected to match the module
21018 : : name position outlined above.
21019 : : */
21020 : :
21021 : 298179 : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import)
21022 : : {
21023 : 298179 : Lists_List l;
21024 : 298179 : unsigned int lastImportStatement;
21025 : :
21026 : 298179 : M2Debug_Assert (SymbolTable_IsImport (import));
21027 : 298179 : if (M2Comp_CompilingDefinitionModule ())
21028 : : {
21029 : 75946 : l = SymbolTable_GetModuleDefImportStatementList (module);
21030 : : }
21031 : : else
21032 : : {
21033 : 222233 : l = SymbolTable_GetModuleModImportStatementList (module);
21034 : : }
21035 : 298179 : M2Debug_Assert (l != NULL);
21036 : 298179 : M2Debug_Assert ((Lists_NoOfItemsInList (l)) > 0); /* There should always be one on the list. */
21037 : 298179 : lastImportStatement = static_cast<unsigned int> (Lists_GetItemFromList (l, Lists_NoOfItemsInList (l))); /* There should always be one on the list. */
21038 : 298179 : M2Debug_Assert (SymbolTable_IsImportStatement (lastImportStatement));
21039 : 298179 : l = SymbolTable_GetImportStatementList (lastImportStatement);
21040 : 298179 : Lists_IncludeItemIntoList (l, import);
21041 : 298179 : }
21042 : :
21043 : :
21044 : : /*
21045 : : PutModLink - assigns link to module sym.
21046 : : */
21047 : :
21048 : 48500 : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link)
21049 : : {
21050 : 48500 : SymbolTable_PtrToSymbol pSym;
21051 : :
21052 : 48500 : if (SymbolTable_IsModule (sym))
21053 : : {
21054 : 0 : pSym = GetPsym (sym);
21055 : 0 : pSym->Module.ModLink = link;
21056 : : }
21057 : 48500 : else if (SymbolTable_IsDefImp (sym))
21058 : : {
21059 : : /* avoid dangling else. */
21060 : 48500 : pSym = GetPsym (sym);
21061 : 48500 : pSym->DefImp.ModLink = link;
21062 : : }
21063 : : else
21064 : : {
21065 : : /* avoid dangling else. */
21066 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
21067 : : }
21068 : 48500 : }
21069 : :
21070 : :
21071 : : /*
21072 : : IsModLink - returns the ModLink value associated with the module symbol.
21073 : : */
21074 : :
21075 : 296925 : extern "C" bool SymbolTable_IsModLink (unsigned int sym)
21076 : : {
21077 : 296925 : SymbolTable_PtrToSymbol pSym;
21078 : :
21079 : 296925 : if (SymbolTable_IsModule (sym))
21080 : : {
21081 : 148258 : pSym = GetPsym (sym);
21082 : 148258 : return pSym->Module.ModLink;
21083 : : }
21084 : 148667 : else if (SymbolTable_IsDefImp (sym))
21085 : : {
21086 : : /* avoid dangling else. */
21087 : 148667 : pSym = GetPsym (sym);
21088 : 148667 : return pSym->DefImp.ModLink;
21089 : : }
21090 : : else
21091 : : {
21092 : : /* avoid dangling else. */
21093 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
21094 : : }
21095 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21096 : : __builtin_unreachable ();
21097 : : }
21098 : :
21099 : :
21100 : : /*
21101 : : PutDefLink - assigns link to the definition module sym.
21102 : : */
21103 : :
21104 : 0 : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link)
21105 : : {
21106 : 0 : SymbolTable_PtrToSymbol pSym;
21107 : :
21108 : 0 : if (SymbolTable_IsDefImp (sym))
21109 : : {
21110 : 0 : pSym = GetPsym (sym);
21111 : 0 : pSym->DefImp.DefLink = link;
21112 : : }
21113 : : else
21114 : : {
21115 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
21116 : : }
21117 : 0 : }
21118 : :
21119 : :
21120 : : /*
21121 : : IsDefLink - returns the DefLink value associated with the definition module symbol.
21122 : : */
21123 : :
21124 : 125141 : extern "C" bool SymbolTable_IsDefLink (unsigned int sym)
21125 : : {
21126 : 125141 : SymbolTable_PtrToSymbol pSym;
21127 : :
21128 : 125141 : if (SymbolTable_IsDefImp (sym))
21129 : : {
21130 : 125141 : pSym = GetPsym (sym);
21131 : 125141 : return pSym->DefImp.DefLink;
21132 : : }
21133 : : else
21134 : : {
21135 : 0 : M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
21136 : : }
21137 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21138 : : __builtin_unreachable ();
21139 : : }
21140 : :
21141 : :
21142 : : /*
21143 : : IsModuleBuiltin - returns TRUE if the module is a builtin module.
21144 : : (For example _BaseTypes).
21145 : : */
21146 : :
21147 : 62562 : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym)
21148 : : {
21149 : 62562 : SymbolTable_PtrToSymbol pSym;
21150 : :
21151 : 62562 : if (SymbolTable_IsDefImp (sym))
21152 : : {
21153 : 59962 : pSym = GetPsym (sym);
21154 : 59962 : return pSym->DefImp.Builtin;
21155 : : }
21156 : 2600 : else if (SymbolTable_IsModule (sym))
21157 : : {
21158 : : /* avoid dangling else. */
21159 : 2600 : pSym = GetPsym (sym);
21160 : 2600 : return pSym->Module.Builtin;
21161 : : }
21162 : : return false;
21163 : : /* static analysis guarentees a RETURN statement will be used before here. */
21164 : : __builtin_unreachable ();
21165 : : }
21166 : :
21167 : :
21168 : : /*
21169 : : PutModuleBuiltin - sets the Builtin flag to value.
21170 : : Currently the procedure expects sym to be a DefImp
21171 : : module only.
21172 : : */
21173 : :
21174 : 15260 : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value)
21175 : : {
21176 : 15260 : SymbolTable_PtrToSymbol pSym;
21177 : :
21178 : 15260 : if (SymbolTable_IsDefImp (sym))
21179 : : {
21180 : 0 : pSym = GetPsym (sym);
21181 : 0 : pSym->DefImp.Builtin = value;
21182 : : }
21183 : 15260 : else if (SymbolTable_IsModule (sym))
21184 : : {
21185 : : /* avoid dangling else. */
21186 : 15260 : pSym = GetPsym (sym);
21187 : 15260 : pSym->Module.Builtin = value;
21188 : : }
21189 : : else
21190 : : {
21191 : : /* avoid dangling else. */
21192 : 0 : M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
21193 : : }
21194 : 15260 : }
21195 : :
21196 : :
21197 : : /*
21198 : : PutVarArrayRef - assigns ArrayRef field with value.
21199 : : */
21200 : :
21201 : 48624 : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value)
21202 : : {
21203 : 48624 : SymbolTable_PtrToSymbol pSym;
21204 : :
21205 : 48624 : pSym = GetPsym (sym);
21206 : 48624 : switch (pSym->SymbolType)
21207 : : {
21208 : 48624 : case SymbolTable_VarSym:
21209 : 48624 : pSym->Var.ArrayRef = value;
21210 : 48624 : break;
21211 : :
21212 : :
21213 : 0 : default:
21214 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
21215 : 48624 : break;
21216 : : }
21217 : 48624 : }
21218 : :
21219 : :
21220 : : /*
21221 : : IsVarArrayRef - returns ArrayRef field value.
21222 : : */
21223 : :
21224 : 3310 : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym)
21225 : : {
21226 : 3310 : SymbolTable_PtrToSymbol pSym;
21227 : :
21228 : 3310 : pSym = GetPsym (sym);
21229 : 3310 : switch (pSym->SymbolType)
21230 : : {
21231 : 3310 : case SymbolTable_VarSym:
21232 : 3310 : return pSym->Var.ArrayRef;
21233 : 0 : break;
21234 : :
21235 : :
21236 : 0 : default:
21237 : 0 : M2Error_InternalError ((const char *) "expecting VarSym", 16);
21238 : : break;
21239 : : }
21240 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21241 : : __builtin_unreachable ();
21242 : : }
21243 : :
21244 : :
21245 : : /*
21246 : : VarCheckReadInit - returns TRUE if sym has been initialized.
21247 : : */
21248 : :
21249 : 2800 : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode)
21250 : : {
21251 : 2800 : SymbolTable_PtrToSymbol pSym;
21252 : :
21253 : 2800 : if (SymbolTable_IsVar (sym))
21254 : : {
21255 : 2800 : pSym = GetPsym (sym);
21256 : 2800 : switch (pSym->SymbolType)
21257 : : {
21258 : 2800 : case SymbolTable_VarSym:
21259 : 2800 : return M2SymInit_GetInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]));
21260 : : break;
21261 : :
21262 : :
21263 : : default:
21264 : : break;
21265 : : }
21266 : : }
21267 : : return false;
21268 : : /* static analysis guarentees a RETURN statement will be used before here. */
21269 : : __builtin_unreachable ();
21270 : : }
21271 : :
21272 : :
21273 : : /*
21274 : : VarInitState - initializes the init state for variable sym.
21275 : : */
21276 : :
21277 : 10240 : extern "C" void SymbolTable_VarInitState (unsigned int sym)
21278 : : {
21279 : 10240 : SymbolTable_PtrToSymbol pSym;
21280 : :
21281 : 10240 : if (SymbolTable_IsVar (sym))
21282 : : {
21283 : 10240 : pSym = GetPsym (sym);
21284 : 10240 : switch (pSym->SymbolType)
21285 : : {
21286 : 10240 : case SymbolTable_VarSym:
21287 : 10240 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), sym);
21288 : 10240 : M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), sym);
21289 : 10240 : break;
21290 : :
21291 : :
21292 : : default:
21293 : : break;
21294 : : }
21295 : : }
21296 : 10240 : }
21297 : :
21298 : :
21299 : : /*
21300 : : PutVarInitialized - set sym as initialized.
21301 : : */
21302 : :
21303 : 5085 : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode)
21304 : : {
21305 : 5085 : SymbolTable_PtrToSymbol pSym;
21306 : :
21307 : 5085 : if (SymbolTable_IsVar (sym))
21308 : : {
21309 : 5085 : pSym = GetPsym (sym);
21310 : 5085 : switch (pSym->SymbolType)
21311 : : {
21312 : 5085 : case SymbolTable_VarSym:
21313 : 5085 : M2SymInit_SetInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]));
21314 : 5085 : break;
21315 : :
21316 : :
21317 : : default:
21318 : : break;
21319 : : }
21320 : : }
21321 : 5085 : }
21322 : :
21323 : :
21324 : : /*
21325 : : PutVarFieldInitialized - records that field has been initialized with
21326 : : variable sym. TRUE is returned if the field
21327 : : is detected and changed to initialized.
21328 : : */
21329 : :
21330 : 684 : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
21331 : : {
21332 : 684 : SymbolTable_PtrToSymbol pSym;
21333 : :
21334 : 684 : if (SymbolTable_IsVar (sym))
21335 : : {
21336 : 684 : pSym = GetPsym (sym);
21337 : 684 : switch (pSym->SymbolType)
21338 : : {
21339 : 684 : case SymbolTable_VarSym:
21340 : 684 : return M2SymInit_SetFieldInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]), fieldlist);
21341 : : break;
21342 : :
21343 : :
21344 : : default:
21345 : : break;
21346 : : }
21347 : : }
21348 : : return false;
21349 : : /* static analysis guarentees a RETURN statement will be used before here. */
21350 : : __builtin_unreachable ();
21351 : : }
21352 : :
21353 : :
21354 : : /*
21355 : : GetVarFieldInitialized - return TRUE if fieldlist has been initialized
21356 : : within variable sym.
21357 : : */
21358 : :
21359 : 204 : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
21360 : : {
21361 : 204 : SymbolTable_PtrToSymbol pSym;
21362 : :
21363 : 204 : if (SymbolTable_IsVar (sym))
21364 : : {
21365 : 204 : pSym = GetPsym (sym);
21366 : 204 : switch (pSym->SymbolType)
21367 : : {
21368 : 204 : case SymbolTable_VarSym:
21369 : 204 : return M2SymInit_GetFieldInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]), fieldlist);
21370 : : break;
21371 : :
21372 : :
21373 : : default:
21374 : : break;
21375 : : }
21376 : : }
21377 : : return false;
21378 : : /* static analysis guarentees a RETURN statement will be used before here. */
21379 : : __builtin_unreachable ();
21380 : : }
21381 : :
21382 : :
21383 : : /*
21384 : : PrintInitialized - display variable sym initialization state.
21385 : : */
21386 : :
21387 : 0 : extern "C" void SymbolTable_PrintInitialized (unsigned int sym)
21388 : : {
21389 : 0 : SymbolTable_PtrToSymbol pSym;
21390 : :
21391 : 0 : if (SymbolTable_IsVar (sym))
21392 : : {
21393 : 0 : pSym = GetPsym (sym);
21394 : 0 : switch (pSym->SymbolType)
21395 : : {
21396 : 0 : case SymbolTable_VarSym:
21397 : 0 : M2Printf_printf0 ((const char *) "LeftMode init: ", 15);
21398 : 0 : M2SymInit_PrintSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]));
21399 : 0 : M2Printf_printf0 ((const char *) "RightMode init: ", 16);
21400 : 0 : M2SymInit_PrintSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]));
21401 : 0 : break;
21402 : :
21403 : :
21404 : : default:
21405 : : break;
21406 : : }
21407 : : }
21408 : 0 : }
21409 : :
21410 : :
21411 : : /*
21412 : : GetParameterHeapVar - return the heap variable associated with the
21413 : : parameter or NulSym.
21414 : : */
21415 : :
21416 : 276 : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym)
21417 : : {
21418 : 276 : SymbolTable_PtrToSymbol pSym;
21419 : :
21420 : 276 : pSym = GetPsym (ParSym);
21421 : 276 : switch (pSym->SymbolType)
21422 : : {
21423 : : case SymbolTable_ParamSym:
21424 : : return SymbolTable_NulSym; /* Only VarParam has the pointer. */
21425 : 96 : break;
21426 : :
21427 : 96 : case SymbolTable_VarParamSym:
21428 : 96 : return pSym->VarParam.HeapVar; /* Only VarParam has the pointer. */
21429 : 0 : break;
21430 : :
21431 : :
21432 : 0 : default:
21433 : 0 : M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
21434 : : break;
21435 : : }
21436 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21437 : : __builtin_unreachable ();
21438 : : }
21439 : :
21440 : :
21441 : : /*
21442 : : PutProcedureParameterHeapVars - creates heap variables for parameter sym.
21443 : : */
21444 : :
21445 : 972374 : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym)
21446 : : {
21447 : 972374 : M2Debug_Assert (SymbolTable_IsProcedure (sym));
21448 : 972374 : SymbolTable_ForeachParamSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PutParameterHeapVar});
21449 : 972374 : }
21450 : :
21451 : :
21452 : : /*
21453 : : IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
21454 : : for the target architecture.
21455 : : */
21456 : :
21457 : 919633 : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure)
21458 : : {
21459 : 919633 : return (SymbolTable_IsProcedureBuiltin (procedure)) && (CanUseBuiltin (procedure));
21460 : : /* static analysis guarentees a RETURN statement will be used before here. */
21461 : : __builtin_unreachable ();
21462 : : }
21463 : :
21464 : :
21465 : : /*
21466 : : PutConstLitInternal - marks the sym as being an internal constant.
21467 : : Currently this is used when generating a default
21468 : : BY constant expression during a FOR loop.
21469 : : A constant marked as internal will always pass
21470 : : an expression type check.
21471 : : */
21472 : :
21473 : 13990 : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value)
21474 : : {
21475 : 13990 : SymbolTable_PtrToSymbol pSym;
21476 : :
21477 : 13990 : pSym = GetPsym (sym);
21478 : 13990 : switch (pSym->SymbolType)
21479 : : {
21480 : 13990 : case SymbolTable_ConstLitSym:
21481 : 13990 : pSym->ConstLit.IsInternal = value;
21482 : 13990 : break;
21483 : :
21484 : :
21485 : 0 : default:
21486 : 0 : M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
21487 : 13990 : break;
21488 : : }
21489 : 13990 : }
21490 : :
21491 : :
21492 : : /*
21493 : : IsConstLitInternal - returns the value of the IsInternal field within
21494 : : a constant expression.
21495 : : */
21496 : :
21497 : 743811 : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym)
21498 : : {
21499 : 743811 : SymbolTable_PtrToSymbol pSym;
21500 : :
21501 : 743811 : pSym = GetPsym (sym);
21502 : 743811 : switch (pSym->SymbolType)
21503 : : {
21504 : 743811 : case SymbolTable_ConstLitSym:
21505 : 743811 : return pSym->ConstLit.IsInternal;
21506 : 0 : break;
21507 : :
21508 : :
21509 : 0 : default:
21510 : 0 : M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
21511 : : break;
21512 : : }
21513 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21514 : : __builtin_unreachable ();
21515 : : }
21516 : :
21517 : :
21518 : : /*
21519 : : GetVarDeclTypeTok - returns the TypeTok field associate with variable sym.
21520 : : */
21521 : :
21522 : 0 : extern "C" unsigned int SymbolTable_GetVarDeclTypeTok (unsigned int sym)
21523 : : {
21524 : 0 : SymbolTable_PtrToSymbol pSym;
21525 : :
21526 : 0 : if (SymbolTable_IsParameter (sym))
21527 : : {
21528 : 0 : pSym = GetPsym (sym);
21529 : 0 : if (SymbolTable_IsParameterVar (sym))
21530 : : {
21531 : 0 : return SymbolTable_GetVarDeclTypeTok (pSym->VarParam.ShadowVar);
21532 : : }
21533 : : else
21534 : : {
21535 : 0 : return SymbolTable_GetVarDeclTypeTok (pSym->Param.ShadowVar);
21536 : : }
21537 : : }
21538 : 0 : else if (SymbolTable_IsVar (sym))
21539 : : {
21540 : : /* avoid dangling else. */
21541 : 0 : return doGetVarDeclTypeTok (sym);
21542 : : }
21543 : : else
21544 : : {
21545 : : /* avoid dangling else. */
21546 : : return M2LexBuf_UnknownTokenNo;
21547 : : }
21548 : : /* static analysis guarentees a RETURN statement will be used before here. */
21549 : : __builtin_unreachable ();
21550 : : }
21551 : :
21552 : :
21553 : : /*
21554 : : PutVarDeclTypeTok - assigns the TypeTok field to typetok.
21555 : : sym can be a variable or parameter.
21556 : : */
21557 : :
21558 : 0 : extern "C" void SymbolTable_PutVarDeclTypeTok (unsigned int sym, unsigned int typetok)
21559 : : {
21560 : 0 : SymbolTable_PtrToSymbol pSym;
21561 : :
21562 : 0 : if (SymbolTable_IsParameter (sym))
21563 : : {
21564 : 0 : pSym = GetPsym (sym);
21565 : 0 : if (SymbolTable_IsParameterVar (sym))
21566 : : {
21567 : 0 : SymbolTable_PutVarDeclTypeTok (pSym->VarParam.ShadowVar, typetok);
21568 : : }
21569 : : else
21570 : : {
21571 : 0 : SymbolTable_PutVarDeclTypeTok (pSym->Param.ShadowVar, typetok);
21572 : : }
21573 : : }
21574 : 0 : else if (SymbolTable_IsVar (sym))
21575 : : {
21576 : : /* avoid dangling else. */
21577 : 0 : doPutVarDeclTypeTok (sym, typetok);
21578 : : }
21579 : 0 : }
21580 : :
21581 : :
21582 : : /*
21583 : : GetVarDeclTok - returns the TypeTok field associate with variable sym.
21584 : : */
21585 : :
21586 : 54 : extern "C" unsigned int SymbolTable_GetVarDeclTok (unsigned int sym)
21587 : : {
21588 : 108 : SymbolTable_PtrToSymbol pSym;
21589 : :
21590 : 108 : if (SymbolTable_IsParameter (sym))
21591 : : {
21592 : 54 : pSym = GetPsym (sym);
21593 : 54 : if (SymbolTable_IsParameterVar (sym))
21594 : : {
21595 : 6 : return SymbolTable_GetVarDeclTok (pSym->VarParam.ShadowVar);
21596 : : }
21597 : : else
21598 : : {
21599 : 48 : return SymbolTable_GetVarDeclTok (pSym->Param.ShadowVar);
21600 : : }
21601 : : }
21602 : 54 : else if (SymbolTable_IsVar (sym))
21603 : : {
21604 : : /* avoid dangling else. */
21605 : 54 : return doGetVarDeclTok (sym);
21606 : : }
21607 : : else
21608 : : {
21609 : : /* avoid dangling else. */
21610 : : return M2LexBuf_UnknownTokenNo;
21611 : : }
21612 : : /* static analysis guarentees a RETURN statement will be used before here. */
21613 : : __builtin_unreachable ();
21614 : : }
21615 : :
21616 : :
21617 : : /*
21618 : : PutVarDeclTok - assigns the VarTok field to typetok.
21619 : : sym can be a variable or parameter.
21620 : : */
21621 : :
21622 : 963246 : extern "C" void SymbolTable_PutVarDeclTok (unsigned int sym, unsigned int vartok)
21623 : : {
21624 : 963246 : SymbolTable_PtrToSymbol pSym;
21625 : :
21626 : 963246 : if (SymbolTable_IsParameter (sym))
21627 : : {
21628 : 0 : pSym = GetPsym (sym);
21629 : 0 : if (SymbolTable_IsParameterVar (sym))
21630 : : {
21631 : 0 : SymbolTable_PutVarDeclTok (pSym->VarParam.ShadowVar, vartok);
21632 : : }
21633 : : else
21634 : : {
21635 : 0 : SymbolTable_PutVarDeclTok (pSym->Param.ShadowVar, vartok);
21636 : : }
21637 : : }
21638 : 963246 : else if (SymbolTable_IsVar (sym))
21639 : : {
21640 : : /* avoid dangling else. */
21641 : 963246 : doPutVarDeclTok (sym, vartok);
21642 : : }
21643 : 963246 : }
21644 : :
21645 : :
21646 : : /*
21647 : : GetVarDeclFullTok - returns the full virtual token containing var: type.
21648 : : */
21649 : :
21650 : 330 : extern "C" unsigned int SymbolTable_GetVarDeclFullTok (unsigned int sym)
21651 : : {
21652 : 378 : SymbolTable_PtrToSymbol pSym;
21653 : :
21654 : 378 : pSym = GetPsym (sym);
21655 : 378 : if (SymbolTable_IsParameter (sym))
21656 : : {
21657 : 48 : if (SymbolTable_IsParameterVar (sym))
21658 : : {
21659 : 0 : return SymbolTable_GetVarDeclFullTok (pSym->VarParam.ShadowVar);
21660 : : }
21661 : : else
21662 : : {
21663 : 48 : return SymbolTable_GetVarDeclFullTok (pSym->Param.ShadowVar);
21664 : : }
21665 : : }
21666 : 330 : else if (SymbolTable_IsVar (sym))
21667 : : {
21668 : : /* avoid dangling else. */
21669 : 330 : return doGetVarDeclFullTok (sym);
21670 : : }
21671 : : else
21672 : : {
21673 : : /* avoid dangling else. */
21674 : : return M2LexBuf_UnknownTokenNo;
21675 : : }
21676 : : /* static analysis guarentees a RETURN statement will be used before here. */
21677 : : __builtin_unreachable ();
21678 : : }
21679 : :
21680 : :
21681 : : /*
21682 : : IsProcedureAnyNoReturn - return TRUE if any of the defined kinds
21683 : : of procedure sym is declared no return.
21684 : : */
21685 : :
21686 : 2279590 : extern "C" bool SymbolTable_IsProcedureAnyNoReturn (unsigned int sym)
21687 : : {
21688 : 2279590 : return IsProcedureAnyDefaultBoolean (sym, false, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_IsProcedureNoReturn});
21689 : : /* static analysis guarentees a RETURN statement will be used before here. */
21690 : : __builtin_unreachable ();
21691 : : }
21692 : :
21693 : :
21694 : : /*
21695 : : GetNthParamAny - returns the nth parameter from the order
21696 : : proper procedure, forward declaration
21697 : : or definition module procedure.
21698 : : */
21699 : :
21700 : 13339340 : extern "C" unsigned int SymbolTable_GetNthParamAny (unsigned int sym, unsigned int ParamNo)
21701 : : {
21702 : 13339340 : SymbolTable_ProcedureKind kind;
21703 : :
21704 : 22923740 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
21705 : : {
21706 : 22923740 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
21707 : : {
21708 : 13339340 : return SymbolTable_GetNthParam (sym, kind, ParamNo);
21709 : : }
21710 : : }
21711 : 0 : M2Error_InternalError ((const char *) "no procedure kind exists", 24);
21712 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21713 : : __builtin_unreachable ();
21714 : : }
21715 : :
21716 : :
21717 : : /*
21718 : : NoOfParamAny - return the number of parameters for sym.
21719 : : */
21720 : :
21721 : 17443719 : extern "C" unsigned int SymbolTable_NoOfParamAny (unsigned int sym)
21722 : : {
21723 : 17443719 : SymbolTable_ProcedureKind kind;
21724 : 17443719 : SymbolTable_PtrToSymbol pSym;
21725 : :
21726 : 17443719 : AssertInRange (sym);
21727 : 17443719 : pSym = GetPsym (sym);
21728 : 17443719 : switch (pSym->SymbolType)
21729 : : {
21730 : : case SymbolTable_ErrorSym:
21731 : : return 0;
21732 : : break;
21733 : :
21734 : : case SymbolTable_ProcedureSym:
21735 : 31820710 : for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
21736 : : {
21737 : 29842384 : if (SymbolTable_GetProcedureParametersDefined (sym, kind))
21738 : : {
21739 : 11618190 : return SymbolTable_NoOfParam (sym, kind);
21740 : : }
21741 : : }
21742 : : break;
21743 : :
21744 : 3847191 : case SymbolTable_ProcTypeSym:
21745 : 3847191 : return Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
21746 : 12 : break;
21747 : :
21748 : :
21749 : 12 : default:
21750 : 12 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
21751 : : break;
21752 : : }
21753 : : return 0;
21754 : : /* static analysis guarentees a RETURN statement will be used before here. */
21755 : : __builtin_unreachable ();
21756 : : }
21757 : :
21758 : :
21759 : : /*
21760 : : SetReturnOptional - sets the ReturnOptional field in the Procedure:kind or
21761 : : ProcType symboltable entry.
21762 : : */
21763 : :
21764 : 1319358 : extern "C" void SymbolTable_SetReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind, bool isopt)
21765 : : {
21766 : 1319358 : SymbolTable_PtrToSymbol pSym;
21767 : :
21768 : 1319358 : pSym = GetPsym (sym);
21769 : 1319358 : switch (pSym->SymbolType)
21770 : : {
21771 : 1311850 : case SymbolTable_ProcedureSym:
21772 : 1311850 : pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional = isopt;
21773 : 1311850 : break;
21774 : :
21775 : 7508 : case SymbolTable_ProcTypeSym:
21776 : 7508 : pSym->ProcType.ReturnOptional = isopt;
21777 : 7508 : break;
21778 : :
21779 : :
21780 : 0 : default:
21781 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
21782 : 1319358 : break;
21783 : : }
21784 : 1319358 : }
21785 : :
21786 : :
21787 : : /*
21788 : : UsesOptArgAny - returns TRUE if procedure Sym:kind uses an optional argument.
21789 : : */
21790 : :
21791 : 182347 : extern "C" bool SymbolTable_UsesOptArgAny (unsigned int Sym)
21792 : : {
21793 : 182347 : SymbolTable_PtrToSymbol pSym;
21794 : :
21795 : 182347 : pSym = GetPsym (Sym);
21796 : 182347 : switch (pSym->SymbolType)
21797 : : {
21798 : : case SymbolTable_ErrorSym:
21799 : : return false;
21800 : 181627 : break;
21801 : :
21802 : 181627 : case SymbolTable_ProcedureSym:
21803 : 181627 : return IsProcedureAnyDefaultBoolean (Sym, false, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_UsesOptArg});
21804 : 720 : break;
21805 : :
21806 : 720 : case SymbolTable_ProcTypeSym:
21807 : 720 : return pSym->ProcType.HasOptArg;
21808 : 0 : break;
21809 : :
21810 : :
21811 : 0 : default:
21812 : 0 : M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
21813 : : break;
21814 : : }
21815 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21816 : : __builtin_unreachable ();
21817 : : }
21818 : :
21819 : :
21820 : : /*
21821 : : GetProcedureKindDesc - return a string describing kind.
21822 : : */
21823 : :
21824 : 168 : extern "C" DynamicStrings_String SymbolTable_GetProcedureKindDesc (SymbolTable_ProcedureKind kind)
21825 : : {
21826 : 168 : if (kind == SymbolTable_ProperProcedure)
21827 : : {
21828 : 84 : return DynamicStrings_InitString ((const char *) "proper procedure", 16);
21829 : : }
21830 : 84 : else if (kind == SymbolTable_ForwardProcedure)
21831 : : {
21832 : : /* avoid dangling else. */
21833 : 24 : return DynamicStrings_InitString ((const char *) "forward procedure", 17);
21834 : : }
21835 : 60 : else if (kind == SymbolTable_DefProcedure)
21836 : : {
21837 : : /* avoid dangling else. */
21838 : 60 : return DynamicStrings_InitString ((const char *) "definition procedure", 20);
21839 : : }
21840 : 0 : M2Error_InternalError ((const char *) "unknown kind value", 18);
21841 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
21842 : : __builtin_unreachable ();
21843 : : }
21844 : :
21845 : :
21846 : : /*
21847 : : GetNthParamAnyClosest - returns the nth parameter from the order
21848 : : proper procedure, forward declaration
21849 : : or definition module procedure.
21850 : : It chooses the parameter which is closest
21851 : : in source terms to currentmodule.
21852 : : The same module will return using the order
21853 : : proper procedure, forward procedure, definition module.
21854 : : Whereas an imported procedure will choose from
21855 : : DefProcedure, ProperProcedure, ForwardProcedure.
21856 : : */
21857 : :
21858 : 571234 : extern "C" unsigned int SymbolTable_GetNthParamAnyClosest (unsigned int sym, unsigned int ParamNo, unsigned int currentmodule)
21859 : : {
21860 : 571234 : if ((GetOuterModuleScope (currentmodule)) == (GetOuterModuleScope (sym)))
21861 : : {
21862 : : /* Same module. */
21863 : 211572 : return GetNthParamOrdered (sym, ParamNo, SymbolTable_ProperProcedure, SymbolTable_ForwardProcedure, SymbolTable_DefProcedure);
21864 : : }
21865 : : else
21866 : : {
21867 : : /* Procedure is imported. */
21868 : 359662 : return GetNthParamOrdered (sym, ParamNo, SymbolTable_DefProcedure, SymbolTable_ProperProcedure, SymbolTable_ForwardProcedure);
21869 : : }
21870 : : /* static analysis guarentees a RETURN statement will be used before here. */
21871 : : __builtin_unreachable ();
21872 : : }
21873 : :
21874 : 15260 : extern "C" void _M2_SymbolTable_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
21875 : : {
21876 : 15260 : Init ();
21877 : 15260 : }
21878 : :
21879 : 0 : extern "C" void _M2_SymbolTable_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
21880 : : {
21881 : 0 : }
|