LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - SymbolTable.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 75.1 % 7421 5572
Test Date: 2026-02-28 14:20:25 Functions: 89.1 % 569 507
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* do not edit automatically generated by mc from SymbolTable.  */
       2              : /* SymbolTable.mod provides access to the symbol table.
       3              : 
       4              : Copyright (C) 2001-2026 Free Software Foundation, Inc.
       5              : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6              : 
       7              : This file is part of GNU Modula-2.
       8              : 
       9              : GNU Modula-2 is free software; you can redistribute it and/or modify
      10              : it under the terms of the GNU General Public License as published by
      11              : the Free Software Foundation; either version 3, or (at your option)
      12              : any later version.
      13              : 
      14              : GNU Modula-2 is distributed in the hope that it will be useful, but
      15              : WITHOUT ANY WARRANTY; without even the implied warranty of
      16              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17              : General Public License for more details.
      18              : 
      19              : You should have received a copy of the GNU General Public License
      20              : along with GNU Modula-2; see the file COPYING3.  If not see
      21              : <http://www.gnu.org/licenses/>.  */
      22              : 
      23              : #include "config.h"
      24              : #include "system.h"
      25              : #include "gcc-consolidation.h"
      26              : 
      27              : #include <stdbool.h>
      28              : #   if !defined (PROC_D)
      29              : #      define PROC_D
      30              :        typedef void (*PROC_t) (void);
      31              :        typedef struct { PROC_t proc; } PROC;
      32              : #   endif
      33              : 
      34              : #   if !defined (TRUE)
      35              : #      define TRUE (1==1)
      36              : #   endif
      37              : 
      38              : #   if !defined (FALSE)
      39              : #      define FALSE (1==0)
      40              : #   endif
      41              : 
      42              : #   include "GStorage.h"
      43              : #   include "Gmcrts.h"
      44              : #if defined(__cplusplus)
      45              : #   undef NULL
      46              : #   define NULL 0
      47              : #endif
      48              : #define _SymbolTable_C
      49              : 
      50              : #include "GSymbolTable.h"
      51              : #   include "GSYSTEM.h"
      52              : #   include "GStorage.h"
      53              : #   include "GM2Debug.h"
      54              : #   include "Glibc.h"
      55              : #   include "GASCII.h"
      56              : #   include "GIndexing.h"
      57              : #   include "GSets.h"
      58              : #   include "Ggcctypes.h"
      59              : #   include "GM2Options.h"
      60              : #   include "GM2LexBuf.h"
      61              : #   include "GM2ALU.h"
      62              : #   include "GM2Error.h"
      63              : #   include "GM2MetaError.h"
      64              : #   include "GFormatStrings.h"
      65              : #   include "GM2Printf.h"
      66              : #   include "GDynamicStrings.h"
      67              : #   include "GLists.h"
      68              : #   include "GNameKey.h"
      69              : #   include "GSymbolKey.h"
      70              : #   include "GM2Base.h"
      71              : #   include "GM2System.h"
      72              : #   include "Gm2expr.h"
      73              : #   include "Gm2linemap.h"
      74              : #   include "GStrLib.h"
      75              : #   include "Gm2builtins.h"
      76              : #   include "GM2Comp.h"
      77              : #   include "GM2Scaffold.h"
      78              : #   include "GM2Diagnostic.h"
      79              : #   include "GM2SymInit.h"
      80              : #   include "GM2RTS.h"
      81              : 
      82              : #   define SymbolTable_NulSym 0
      83              : typedef struct SymbolTable_FamilyOperation_p SymbolTable_FamilyOperation;
      84              : 
      85              : #   define DebugUnknowns false
      86              : #   define DebugUnknownToken false
      87              : #   define BreakNew 97
      88              : #   define UnboundedAddressName "_m2_contents"
      89              : #   define UnboundedHighName "_m2_high_%d"
      90              : typedef struct SymbolTable_ProcAnyBoolean_p SymbolTable_ProcAnyBoolean;
      91              : 
      92              : typedef struct SymbolTable_ProcAnyCardinal_p SymbolTable_ProcAnyCardinal;
      93              : 
      94              : typedef struct SymbolTable_LRLists_a SymbolTable_LRLists;
      95              : 
      96              : typedef struct SymbolTable_LRInitDesc_a SymbolTable_LRInitDesc;
      97              : 
      98              : typedef struct SymbolTable_Where_r SymbolTable_Where;
      99              : 
     100              : typedef struct SymbolTable_VarDecl_r SymbolTable_VarDecl;
     101              : 
     102              : typedef struct SymbolTable_PackedInfo_r SymbolTable_PackedInfo;
     103              : 
     104              : typedef struct SymbolTable_ModuleCtor_r SymbolTable_ModuleCtor;
     105              : 
     106              : typedef struct SymbolTable_SymImportStatement_r SymbolTable_SymImportStatement;
     107              : 
     108              : typedef struct SymbolTable_SymImport_r SymbolTable_SymImport;
     109              : 
     110              : typedef struct SymbolTable_SymEquiv_r SymbolTable_SymEquiv;
     111              : 
     112              : typedef struct SymbolTable_SymOAFamily_r SymbolTable_SymOAFamily;
     113              : 
     114              : typedef struct SymbolTable_SymTuple_r SymbolTable_SymTuple;
     115              : 
     116              : typedef struct SymbolTable_SymError_r SymbolTable_SymError;
     117              : 
     118              : typedef struct SymbolTable_SymObject_r SymbolTable_SymObject;
     119              : 
     120              : typedef struct SymbolTable_SymUndefined_r SymbolTable_SymUndefined;
     121              : 
     122              : typedef struct SymbolTable_SymGnuAsm_r SymbolTable_SymGnuAsm;
     123              : 
     124              : typedef struct SymbolTable_SymInterface_r SymbolTable_SymInterface;
     125              : 
     126              : typedef struct SymbolTable_SymVarient_r SymbolTable_SymVarient;
     127              : 
     128              : typedef struct SymbolTable_SymRecord_r SymbolTable_SymRecord;
     129              : 
     130              : typedef struct SymbolTable_SymSubrange_r SymbolTable_SymSubrange;
     131              : 
     132              : typedef struct SymbolTable_SymEnumeration_r SymbolTable_SymEnumeration;
     133              : 
     134              : typedef struct SymbolTable_SymArray_r SymbolTable_SymArray;
     135              : 
     136              : typedef struct SymbolTable_SymSubscript_r SymbolTable_SymSubscript;
     137              : 
     138              : typedef struct SymbolTable_SymUnbounded_r SymbolTable_SymUnbounded;
     139              : 
     140              : typedef struct SymbolTable_SymPartialUnbounded_r SymbolTable_SymPartialUnbounded;
     141              : 
     142              : typedef struct SymbolTable_ProcedureDeclaration_r SymbolTable_ProcedureDeclaration;
     143              : 
     144              : typedef struct SymbolTable_SymProcedure_r SymbolTable_SymProcedure;
     145              : 
     146              : typedef struct SymbolTable_SymProcType_r SymbolTable_SymProcType;
     147              : 
     148              : typedef struct SymbolTable_SymParam_r SymbolTable_SymParam;
     149              : 
     150              : typedef struct SymbolTable_SymVarParam_r SymbolTable_SymVarParam;
     151              : 
     152              : typedef struct SymbolTable_SymConstString_r SymbolTable_SymConstString;
     153              : 
     154              : typedef struct SymbolTable_SymConstLit_r SymbolTable_SymConstLit;
     155              : 
     156              : typedef struct SymbolTable_SymConstVar_r SymbolTable_SymConstVar;
     157              : 
     158              : typedef struct SymbolTable_SymVar_r SymbolTable_SymVar;
     159              : 
     160              : typedef struct SymbolTable_SymType_r SymbolTable_SymType;
     161              : 
     162              : typedef struct SymbolTable_SymPointer_r SymbolTable_SymPointer;
     163              : 
     164              : typedef struct SymbolTable_SymRecordField_r SymbolTable_SymRecordField;
     165              : 
     166              : typedef struct SymbolTable_SymVarientField_r SymbolTable_SymVarientField;
     167              : 
     168              : typedef struct SymbolTable_SymEnumerationField_r SymbolTable_SymEnumerationField;
     169              : 
     170              : typedef struct SymbolTable_SymSet_r SymbolTable_SymSet;
     171              : 
     172              : typedef struct SymbolTable_SymDefImp_r SymbolTable_SymDefImp;
     173              : 
     174              : typedef struct SymbolTable_SymModule_r SymbolTable_SymModule;
     175              : 
     176              : typedef struct SymbolTable_SymDummy_r SymbolTable_SymDummy;
     177              : 
     178              : typedef struct SymbolTable_Symbol_r SymbolTable_Symbol;
     179              : 
     180              : typedef struct SymbolTable_CallFrame_r SymbolTable_CallFrame;
     181              : 
     182              : typedef struct SymbolTable_CheckProcedure_p SymbolTable_CheckProcedure;
     183              : 
     184              : typedef SymbolTable_Symbol *SymbolTable_PtrToSymbol;
     185              : 
     186              : typedef SymbolTable_CallFrame *SymbolTable_PtrToCallFrame;
     187              : 
     188              : typedef struct SymbolTable__T4_r SymbolTable__T4;
     189              : 
     190              : typedef SymbolTable__T4 *SymbolTable_ConstLitPoolEntry;
     191              : 
     192              : typedef struct SymbolTable__T5_r SymbolTable__T5;
     193              : 
     194              : typedef SymbolTable__T5 *SymbolTable_PtrToAsmConstraint;
     195              : 
     196              : typedef struct SymbolTable__T6_a SymbolTable__T6;
     197              : 
     198              : typedef enum {SymbolTable_m2str, SymbolTable_cstr, SymbolTable_m2nulstr, SymbolTable_cnulstr} SymbolTable_ConstStringVariant;
     199              : 
     200              : typedef enum {SymbolTable_RecordSym, SymbolTable_VarientSym, SymbolTable_DummySym, SymbolTable_VarSym, SymbolTable_EnumerationSym, SymbolTable_SubrangeSym, SymbolTable_ArraySym, SymbolTable_ConstStringSym, SymbolTable_ConstVarSym, SymbolTable_ConstLitSym, SymbolTable_VarParamSym, SymbolTable_ParamSym, SymbolTable_PointerSym, SymbolTable_UndefinedSym, SymbolTable_TypeSym, SymbolTable_RecordFieldSym, SymbolTable_VarientFieldSym, SymbolTable_EnumerationFieldSym, SymbolTable_DefImpSym, SymbolTable_ModuleSym, SymbolTable_SetSym, SymbolTable_ProcedureSym, SymbolTable_ProcTypeSym, SymbolTable_SubscriptSym, SymbolTable_UnboundedSym, SymbolTable_GnuAsmSym, SymbolTable_InterfaceSym, SymbolTable_ObjectSym, SymbolTable_PartialUnboundedSym, SymbolTable_TupleSym, SymbolTable_OAFamilySym, SymbolTable_ImportSym, SymbolTable_ImportStatementSym, SymbolTable_EquivSym, SymbolTable_ErrorSym} SymbolTable_TypeOfSymbol;
     201              : 
     202              : typedef bool (*SymbolTable_ProcAnyBoolean_t) (unsigned int, SymbolTable_ProcedureKind);
     203              : struct SymbolTable_ProcAnyBoolean_p { SymbolTable_ProcAnyBoolean_t proc; };
     204              : 
     205              : typedef unsigned int (*SymbolTable_ProcAnyCardinal_t) (unsigned int, SymbolTable_ProcedureKind);
     206              : struct SymbolTable_ProcAnyCardinal_p { SymbolTable_ProcAnyCardinal_t proc; };
     207              : 
     208              : struct SymbolTable_LRLists_a { Lists_List array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
     209              : struct SymbolTable_LRInitDesc_a { M2SymInit_InitDesc array[SymbolTable_LeftValue-SymbolTable_RightValue+1]; };
     210              : struct SymbolTable_Where_r {
     211              :                              unsigned int DefDeclared;
     212              :                              unsigned int FirstUsed;
     213              :                              unsigned int ModDeclared;
     214              :                            };
     215              : 
     216              : struct SymbolTable_VarDecl_r {
     217              :                                unsigned int FullTok;
     218              :                                unsigned int VarTok;
     219              :                                unsigned int TypeTok;
     220              :                              };
     221              : 
     222              : struct SymbolTable_PackedInfo_r {
     223              :                                   bool IsPacked;
     224              :                                   unsigned int PackedEquiv;
     225              :                                 };
     226              : 
     227              : struct SymbolTable_ModuleCtor_r {
     228              :                                   unsigned int ctor;
     229              :                                   unsigned int init;
     230              :                                   unsigned int fini;
     231              :                                   unsigned int dep;
     232              :                                 };
     233              : 
     234              : struct SymbolTable_SymOAFamily_r {
     235              :                                    unsigned int MaxDimensions;
     236              :                                    unsigned int SimpleType;
     237              :                                    Indexing_Index Dimensions;
     238              :                                  };
     239              : 
     240              : struct SymbolTable_SymPartialUnbounded_r {
     241              :                                            unsigned int Type;
     242              :                                            unsigned int NDim;
     243              :                                          };
     244              : 
     245              : struct SymbolTable_ProcedureDeclaration_r {
     246              :                                             Lists_List ListOfParam;
     247              :                                             bool Defined;
     248              :                                             bool ParamDefined;
     249              :                                             bool HasVarArgs;
     250              :                                             bool HasOptArg;
     251              :                                             bool IsNoReturn;
     252              :                                             bool ReturnOptional;
     253              :                                             unsigned int ReturnTypeTok;
     254              :                                             unsigned int ProcedureTok;
     255              :                                           };
     256              : 
     257              : struct SymbolTable_SymParam_r {
     258              :                                 NameKey_Name name;
     259              :                                 unsigned int Type;
     260              :                                 bool IsUnbounded;
     261              :                                 unsigned int Scope;
     262              :                                 unsigned int ShadowVar;
     263              :                                 unsigned int FullTok;
     264              :                                 unsigned int At;
     265              :                               };
     266              : 
     267              : struct SymbolTable_SymVarParam_r {
     268              :                                    NameKey_Name name;
     269              :                                    unsigned int Type;
     270              :                                    bool IsUnbounded;
     271              :                                    unsigned int HeapVar;
     272              :                                    unsigned int Scope;
     273              :                                    unsigned int ShadowVar;
     274              :                                    unsigned int FullTok;
     275              :                                    unsigned int At;
     276              :                                  };
     277              : 
     278              : struct SymbolTable_SymDummy_r {
     279              :                                 unsigned int NextFree;
     280              :                               };
     281              : 
     282              : struct SymbolTable_CallFrame_r {
     283              :                                  unsigned int Main;
     284              :                                  unsigned int Search;
     285              :                                  unsigned int Start;
     286              :                                };
     287              : 
     288              : typedef void (*SymbolTable_CheckProcedure_t) (unsigned int);
     289              : struct SymbolTable_CheckProcedure_p { SymbolTable_CheckProcedure_t proc; };
     290              : 
     291              : struct SymbolTable__T4_r {
     292              :                            unsigned int sym;
     293              :                            unsigned int tok;
     294              :                            NameKey_Name constName;
     295              :                            unsigned int constType;
     296              :                            SymbolTable_ConstLitPoolEntry next;
     297              :                          };
     298              : 
     299              : struct SymbolTable__T5_r {
     300              :                            unsigned int tokpos;
     301              :                            NameKey_Name name;
     302              :                            unsigned int str;
     303              :                            unsigned int obj;
     304              :                          };
     305              : 
     306              : struct SymbolTable_SymImportStatement_r {
     307              :                                           unsigned int listNo;
     308              :                                           Lists_List ListOfImports;
     309              :                                           SymbolTable_Where at;
     310              :                                         };
     311              : 
     312              : struct SymbolTable_SymImport_r {
     313              :                                  unsigned int module;
     314              :                                  unsigned int listNo;
     315              :                                  bool qualified;
     316              :                                  SymbolTable_Where at;
     317              :                                };
     318              : 
     319              : struct SymbolTable_SymEquiv_r {
     320              :                                 SymbolTable_PackedInfo packedInfo;
     321              :                                 unsigned int nonPacked;
     322              :                               };
     323              : 
     324              : struct SymbolTable_SymTuple_r {
     325              :                                 SymbolTable_Where At;
     326              :                                 unsigned int nTuple;
     327              :                                 Indexing_Index list;
     328              :                               };
     329              : 
     330              : struct SymbolTable_SymError_r {
     331              :                                 NameKey_Name name;
     332              :                                 unsigned int Scope;
     333              :                                 SymbolTable_Where At;
     334              :                               };
     335              : 
     336              : struct SymbolTable_SymObject_r {
     337              :                                  NameKey_Name name;
     338              :                                  SymbolTable_Where At;
     339              :                                };
     340              : 
     341              : struct SymbolTable_SymUndefined_r {
     342              :                                     NameKey_Name name;
     343              :                                     unsigned int declScope;
     344              :                                     bool onImport;
     345              :                                     unsigned int oafamily;
     346              :                                     M2Error_ErrorScope errorScope;
     347              :                                     SymbolTable_Where At;
     348              :                                   };
     349              : 
     350              : struct SymbolTable_SymGnuAsm_r {
     351              :                                  unsigned int String;
     352              :                                  SymbolTable_Where At;
     353              :                                  unsigned int Inputs;
     354              :                                  unsigned int Outputs;
     355              :                                  unsigned int Trashed;
     356              :                                  bool Volatile;
     357              :                                  bool Simple;
     358              :                                };
     359              : 
     360              : struct SymbolTable_SymInterface_r {
     361              :                                     Indexing_Index Parameters;
     362              :                                     SymbolTable_Where At;
     363              :                                   };
     364              : 
     365              : struct SymbolTable_SymVarient_r {
     366              :                                   M2ALU_PtrToValue Size;
     367              :                                   Lists_List ListOfSons;
     368              :                                   bool DeclPacked;
     369              :                                   bool DeclResolved;
     370              :                                   unsigned int Parent;
     371              :                                   unsigned int Varient;
     372              :                                   unsigned int tag;
     373              :                                   unsigned int Scope;
     374              :                                   SymbolTable_Where At;
     375              :                                 };
     376              : 
     377              : struct SymbolTable_SymRecord_r {
     378              :                                  NameKey_Name name;
     379              :                                  SymbolKey_SymbolTree LocalSymbols;
     380              :                                  M2ALU_PtrToValue Size;
     381              :                                  Lists_List ListOfSons;
     382              :                                  unsigned int Align;
     383              :                                  unsigned int DefaultAlign;
     384              :                                  bool DeclPacked;
     385              :                                  bool DeclResolved;
     386              :                                  unsigned int oafamily;
     387              :                                  unsigned int Parent;
     388              :                                  unsigned int Scope;
     389              :                                  SymbolTable_Where At;
     390              :                                };
     391              : 
     392              : struct SymbolTable_SymSubrange_r {
     393              :                                    NameKey_Name name;
     394              :                                    unsigned int Low;
     395              :                                    unsigned int High;
     396              :                                    M2ALU_PtrToValue Size;
     397              :                                    unsigned int Type;
     398              :                                    unsigned int Align;
     399              :                                    SymbolKey_SymbolTree ConstLitTree;
     400              :                                    SymbolTable_PackedInfo packedInfo;
     401              :                                    unsigned int oafamily;
     402              :                                    unsigned int Scope;
     403              :                                    SymbolTable_Where At;
     404              :                                  };
     405              : 
     406              : struct SymbolTable_SymEnumeration_r {
     407              :                                       NameKey_Name name;
     408              :                                       unsigned int NoOfElements;
     409              :                                       SymbolKey_SymbolTree LocalSymbols;
     410              :                                       Lists_List ListOfFields;
     411              :                                       M2ALU_PtrToValue Size;
     412              :                                       SymbolTable_PackedInfo packedInfo;
     413              :                                       unsigned int oafamily;
     414              :                                       unsigned int Scope;
     415              :                                       SymbolTable_Where At;
     416              :                                     };
     417              : 
     418              : struct SymbolTable_SymArray_r {
     419              :                                 NameKey_Name name;
     420              :                                 unsigned int Subscript;
     421              :                                 M2ALU_PtrToValue Size;
     422              :                                 M2ALU_PtrToValue Offset;
     423              :                                 unsigned int Type;
     424              :                                 unsigned int Align;
     425              :                                 bool Large;
     426              :                                 unsigned int oafamily;
     427              :                                 unsigned int Scope;
     428              :                                 SymbolTable_Where At;
     429              :                               };
     430              : 
     431              : struct SymbolTable_SymSubscript_r {
     432              :                                     unsigned int Type;
     433              :                                     M2ALU_PtrToValue Size;
     434              :                                     M2ALU_PtrToValue Offset;
     435              :                                     SymbolTable_Where At;
     436              :                                   };
     437              : 
     438              : struct SymbolTable_SymUnbounded_r {
     439              :                                     unsigned int Type;
     440              :                                     M2ALU_PtrToValue Size;
     441              :                                     unsigned int RecordType;
     442              :                                     unsigned int Dimensions;
     443              :                                     unsigned int Scope;
     444              :                                     SymbolTable_Where At;
     445              :                                   };
     446              : 
     447              : struct SymbolTable_SymProcType_r {
     448              :                                    NameKey_Name name;
     449              :                                    Lists_List ListOfParam;
     450              :                                    bool HasVarArgs;
     451              :                                    bool HasOptArg;
     452              :                                    unsigned int OptArgInit;
     453              :                                    unsigned int ReturnType;
     454              :                                    bool ReturnOptional;
     455              :                                    unsigned int ReturnTypeTok;
     456              :                                    unsigned int Scope;
     457              :                                    M2ALU_PtrToValue Size;
     458              :                                    M2ALU_PtrToValue TotalParamSize;
     459              :                                    unsigned int oafamily;
     460              :                                    SymbolTable_Where At;
     461              :                                  };
     462              : 
     463              : struct SymbolTable_SymConstString_r {
     464              :                                       NameKey_Name name;
     465              :                                       NameKey_Name Contents;
     466              :                                       unsigned int Length;
     467              :                                       SymbolTable_ConstStringVariant StringVariant;
     468              :                                       bool Known;
     469              :                                       unsigned int Scope;
     470              :                                       SymbolTable_Where At;
     471              :                                     };
     472              : 
     473              : struct SymbolTable_SymConstLit_r {
     474              :                                    NameKey_Name name;
     475              :                                    M2ALU_PtrToValue Value;
     476              :                                    unsigned int Type;
     477              :                                    bool IsSet;
     478              :                                    bool IsConstructor;
     479              :                                    bool IsInternal;
     480              :                                    unsigned int FromType;
     481              :                                    bool RangeError;
     482              :                                    bool UnresFromType;
     483              :                                    unsigned int Scope;
     484              :                                    SymbolTable_Where At;
     485              :                                  };
     486              : 
     487              : struct SymbolTable_SymConstVar_r {
     488              :                                    NameKey_Name name;
     489              :                                    M2ALU_PtrToValue Value;
     490              :                                    unsigned int Type;
     491              :                                    bool IsConditional;
     492              :                                    bool IsSet;
     493              :                                    bool IsConstructor;
     494              :                                    unsigned int FromType;
     495              :                                    bool UnresFromType;
     496              :                                    bool IsTemp;
     497              :                                    unsigned int Scope;
     498              :                                    SymbolTable_Where At;
     499              :                                  };
     500              : 
     501              : struct SymbolTable_SymVar_r {
     502              :                               NameKey_Name name;
     503              :                               unsigned int Type;
     504              :                               unsigned int BackType;
     505              :                               M2ALU_PtrToValue Size;
     506              :                               M2ALU_PtrToValue Offset;
     507              :                               SymbolTable_ModeOfAddr AddrMode;
     508              :                               unsigned int Scope;
     509              :                               bool AtAddress;
     510              :                               unsigned int Address;
     511              :                               bool IsComponentRef;
     512              :                               Indexing_Index list;
     513              :                               bool IsConditional;
     514              :                               bool IsTemp;
     515              :                               bool IsParam;
     516              :                               bool IsPointerCheck;
     517              :                               bool IsWritten;
     518              :                               bool IsSSA;
     519              :                               bool IsConst;
     520              :                               bool ArrayRef;
     521              :                               bool Heap;
     522              :                               SymbolTable_LRInitDesc InitState;
     523              :                               SymbolTable_VarDecl Declared;
     524              :                               SymbolTable_Where At;
     525              :                               SymbolTable_LRLists ReadUsageList;
     526              :                               SymbolTable_LRLists WriteUsageList;
     527              :                             };
     528              : 
     529              : struct SymbolTable_SymType_r {
     530              :                                NameKey_Name name;
     531              :                                unsigned int Type;
     532              :                                bool IsHidden;
     533              :                                SymbolKey_SymbolTree ConstLitTree;
     534              :                                M2ALU_PtrToValue Size;
     535              :                                SymbolTable_PackedInfo packedInfo;
     536              :                                unsigned int oafamily;
     537              :                                unsigned int Align;
     538              :                                unsigned int Scope;
     539              :                                SymbolTable_Where At;
     540              :                              };
     541              : 
     542              : struct SymbolTable_SymPointer_r {
     543              :                                   NameKey_Name name;
     544              :                                   unsigned int Type;
     545              :                                   M2ALU_PtrToValue Size;
     546              :                                   unsigned int Align;
     547              :                                   SymbolKey_SymbolTree ConstLitTree;
     548              :                                   unsigned int oafamily;
     549              :                                   unsigned int Scope;
     550              :                                   SymbolTable_Where At;
     551              :                                 };
     552              : 
     553              : struct SymbolTable_SymRecordField_r {
     554              :                                       NameKey_Name name;
     555              :                                       unsigned int Type;
     556              :                                       bool Tag;
     557              :                                       M2ALU_PtrToValue Size;
     558              :                                       M2ALU_PtrToValue Offset;
     559              :                                       unsigned int Parent;
     560              :                                       unsigned int Varient;
     561              :                                       unsigned int Align;
     562              :                                       bool Used;
     563              :                                       bool DeclPacked;
     564              :                                       bool DeclResolved;
     565              :                                       unsigned int Scope;
     566              :                                       SymbolTable_Where At;
     567              :                                     };
     568              : 
     569              : struct SymbolTable_SymVarientField_r {
     570              :                                        NameKey_Name name;
     571              :                                        M2ALU_PtrToValue Size;
     572              :                                        M2ALU_PtrToValue Offset;
     573              :                                        unsigned int Parent;
     574              :                                        unsigned int Varient;
     575              :                                        Lists_List ListOfSons;
     576              :                                        bool DeclPacked;
     577              :                                        bool DeclResolved;
     578              :                                        unsigned int Scope;
     579              :                                        SymbolTable_Where At;
     580              :                                      };
     581              : 
     582              : struct SymbolTable_SymEnumerationField_r {
     583              :                                            NameKey_Name name;
     584              :                                            M2ALU_PtrToValue Value;
     585              :                                            unsigned int Type;
     586              :                                            unsigned int Scope;
     587              :                                            SymbolTable_Where At;
     588              :                                          };
     589              : 
     590              : struct SymbolTable_SymSet_r {
     591              :                               NameKey_Name name;
     592              :                               unsigned int Type;
     593              :                               SymbolTable_PackedInfo packedInfo;
     594              :                               bool ispacked;
     595              :                               bool SetInWord;
     596              :                               unsigned int SetArray;
     597              :                               unsigned int Align;
     598              :                               M2ALU_PtrToValue Size;
     599              :                               unsigned int oafamily;
     600              :                               unsigned int Scope;
     601              :                               SymbolTable_Where At;
     602              :                             };
     603              : 
     604              : struct SymbolTable_SymDefImp_r {
     605              :                                  NameKey_Name name;
     606              :                                  NameKey_Name libname;
     607              :                                  SymbolTable_ModuleCtor ctors;
     608              :                                  Lists_List DefListOfDep;
     609              :                                  Lists_List ModListOfDep;
     610              :                                  SymbolKey_SymbolTree ExportQualifiedTree;
     611              :                                  SymbolKey_SymbolTree ExportUnQualifiedTree;
     612              :                                  SymbolKey_SymbolTree ExportRequest;
     613              :                                  Lists_List IncludeList;
     614              :                                  Lists_List DefIncludeList;
     615              :                                  SymbolKey_SymbolTree ImportTree;
     616              :                                  SymbolKey_SymbolTree ExportUndeclared;
     617              :                                  SymbolKey_SymbolTree NeedToBeImplemented;
     618              :                                  SymbolKey_SymbolTree LocalSymbols;
     619              :                                  Lists_List EnumerationScopeList;
     620              :                                  SymbolKey_SymbolTree NamedObjects;
     621              :                                  SymbolKey_SymbolTree NamedImports;
     622              :                                  SymbolKey_SymbolTree WhereImported;
     623              :                                  unsigned int Priority;
     624              :                                  SymbolKey_SymbolTree Unresolved;
     625              :                                  unsigned int StartQuad;
     626              :                                  unsigned int EndQuad;
     627              :                                  unsigned int StartFinishQuad;
     628              :                                  unsigned int EndFinishQuad;
     629              :                                  tree FinallyFunction;
     630              :                                  bool ExceptionFinally;
     631              :                                  bool ExceptionBlock;
     632              :                                  bool ContainsHiddenType;
     633              :                                  bool ContainsBuiltin;
     634              :                                  bool ForC;
     635              :                                  bool NeedExportList;
     636              :                                  bool ModLink;
     637              :                                  bool DefLink;
     638              :                                  bool Builtin;
     639              :                                  Lists_List ListOfVars;
     640              :                                  Lists_List ListOfProcs;
     641              :                                  Lists_List ListOfModules;
     642              :                                  M2Error_ErrorScope errorScope;
     643              :                                  SymbolTable_Where At;
     644              :                                };
     645              : 
     646              : struct SymbolTable_SymModule_r {
     647              :                                  NameKey_Name name;
     648              :                                  NameKey_Name libname;
     649              :                                  SymbolTable_ModuleCtor ctors;
     650              :                                  Lists_List ModListOfDep;
     651              :                                  SymbolKey_SymbolTree LocalSymbols;
     652              :                                  SymbolKey_SymbolTree ExportTree;
     653              :                                  Lists_List IncludeList;
     654              :                                  SymbolKey_SymbolTree ImportTree;
     655              :                                  SymbolKey_SymbolTree ExportUndeclared;
     656              :                                  Lists_List EnumerationScopeList;
     657              :                                  SymbolKey_SymbolTree NamedObjects;
     658              :                                  SymbolKey_SymbolTree NamedImports;
     659              :                                  SymbolKey_SymbolTree WhereImported;
     660              :                                  unsigned int Scope;
     661              :                                  unsigned int Priority;
     662              :                                  SymbolKey_SymbolTree Unresolved;
     663              :                                  unsigned int StartQuad;
     664              :                                  unsigned int EndQuad;
     665              :                                  unsigned int StartFinishQuad;
     666              :                                  unsigned int EndFinishQuad;
     667              :                                  tree FinallyFunction;
     668              :                                  bool ExceptionFinally;
     669              :                                  bool ExceptionBlock;
     670              :                                  bool ModLink;
     671              :                                  bool Builtin;
     672              :                                  Lists_List ListOfVars;
     673              :                                  Lists_List ListOfProcs;
     674              :                                  Lists_List ListOfModules;
     675              :                                  M2Error_ErrorScope errorScope;
     676              :                                  SymbolTable_Where At;
     677              :                                };
     678              : 
     679              : struct SymbolTable__T6_a { SymbolTable_ProcedureDeclaration array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure+1]; };
     680              : struct SymbolTable_SymProcedure_r {
     681              :                                     NameKey_Name name;
     682              :                                     SymbolTable__T6 Decl;
     683              :                                     unsigned int OptArgInit;
     684              :                                     bool IsExtern;
     685              :                                     bool IsPublic;
     686              :                                     bool IsCtor;
     687              :                                     bool IsMonoName;
     688              :                                     bool BuildProcType;
     689              :                                     SymbolKey_SymbolTree Unresolved;
     690              :                                     unsigned int ScopeQuad;
     691              :                                     unsigned int StartQuad;
     692              :                                     unsigned int EndQuad;
     693              :                                     bool Reachable;
     694              :                                     bool SavePriority;
     695              :                                     unsigned int ReturnType;
     696              :                                     unsigned int ProcedureType;
     697              :                                     bool IsBuiltin;
     698              :                                     NameKey_Name BuiltinName;
     699              :                                     bool IsInline;
     700              :                                     SymbolKey_SymbolTree LocalSymbols;
     701              :                                     Lists_List EnumerationScopeList;
     702              :                                     Lists_List ListOfVars;
     703              :                                     Lists_List ListOfProcs;
     704              :                                     SymbolKey_SymbolTree NamedObjects;
     705              :                                     M2ALU_PtrToValue Size;
     706              :                                     M2ALU_PtrToValue TotalParamSize;
     707              :                                     bool ExceptionFinally;
     708              :                                     bool ExceptionBlock;
     709              :                                     unsigned int Scope;
     710              :                                     M2Error_ErrorScope errorScope;
     711              :                                     Lists_List ListOfModules;
     712              :                                     unsigned int Begin;
     713              :                                     unsigned int End;
     714              :                                     SymbolTable_Where At;
     715              :                                   };
     716              : 
     717              : struct SymbolTable_Symbol_r {
     718              :                               SymbolTable_TypeOfSymbol SymbolType;  /* case tag */
     719              :                               union {
     720              :                                       SymbolTable_SymOAFamily OAFamily;
     721              :                                       SymbolTable_SymObject Object;
     722              :                                       SymbolTable_SymEquiv Equiv;
     723              :                                       SymbolTable_SymRecord Record;
     724              :                                       SymbolTable_SymVarient Varient;
     725              :                                       SymbolTable_SymVar Var;
     726              :                                       SymbolTable_SymEnumeration Enumeration;
     727              :                                       SymbolTable_SymSubrange Subrange;
     728              :                                       SymbolTable_SymSubscript Subscript;
     729              :                                       SymbolTable_SymArray Array;
     730              :                                       SymbolTable_SymUnbounded Unbounded;
     731              :                                       SymbolTable_SymPartialUnbounded PartialUnbounded;
     732              :                                       SymbolTable_SymConstVar ConstVar;
     733              :                                       SymbolTable_SymConstLit ConstLit;
     734              :                                       SymbolTable_SymConstString ConstString;
     735              :                                       SymbolTable_SymVarParam VarParam;
     736              :                                       SymbolTable_SymParam Param;
     737              :                                       SymbolTable_SymError Error;
     738              :                                       SymbolTable_SymUndefined Undefined;
     739              :                                       SymbolTable_SymType Type;
     740              :                                       SymbolTable_SymPointer Pointer;
     741              :                                       SymbolTable_SymRecordField RecordField;
     742              :                                       SymbolTable_SymVarientField VarientField;
     743              :                                       SymbolTable_SymEnumerationField EnumerationField;
     744              :                                       SymbolTable_SymDefImp DefImp;
     745              :                                       SymbolTable_SymModule Module;
     746              :                                       SymbolTable_SymSet Set;
     747              :                                       SymbolTable_SymProcedure Procedure;
     748              :                                       SymbolTable_SymProcType ProcType;
     749              :                                       SymbolTable_SymImportStatement ImportStatement;
     750              :                                       SymbolTable_SymImport Import;
     751              :                                       SymbolTable_SymGnuAsm GnuAsm;
     752              :                                       SymbolTable_SymInterface Interface;
     753              :                                       SymbolTable_SymTuple Tuple;
     754              :                                       SymbolTable_SymDummy Dummy;
     755              :                                     };
     756              :                             };
     757              : 
     758              : static Indexing_Index Symbols;
     759              : static Indexing_Index ScopeCallFrame;
     760              : static unsigned int FreeSymbol;
     761              : static SymbolKey_SymbolTree DefModuleTree;
     762              : static SymbolKey_SymbolTree ModuleTree;
     763              : static unsigned int CurrentModule;
     764              : static unsigned int MainModule;
     765              : static unsigned int FileModule;
     766              : static unsigned int ScopePtr;
     767              : static unsigned int BaseScopePtr;
     768              : static unsigned int BaseModule;
     769              : static unsigned int TemporaryNo;
     770              : static M2Error_Error CurrentError;
     771              : static Lists_List AddressTypes;
     772              : static Lists_List UnresolvedConstructorType;
     773              : static unsigned int AnonymousName;
     774              : static Sets_Set ReportedUnknowns;
     775              : static SymbolKey_SymbolTree ConstLitPoolTree;
     776              : static Indexing_Index ConstLitArray;
     777              : static unsigned int BreakSym;
     778              : static M2Diagnostic_Diagnostic SymMemDiag;
     779              : static unsigned int recordConsist;
     780              : static DynamicStrings_String ListifySentance;
     781              : static unsigned int ListifyTotal;
     782              : static unsigned int ListifyWordCount;
     783              : static unsigned int ExportRequestModule;
     784              : static unsigned int ResolveModule;
     785              : 
     786              : /*
     787              :    FinalSymbol - returns the highest number symbol used.
     788              : */
     789              : 
     790              : extern "C" unsigned int SymbolTable_FinalSymbol (void);
     791              : 
     792              : /*
     793              :    MakeComponentRecord - make a temporary which will be used to reference and field
     794              :                          (or sub field) of record.
     795              : */
     796              : 
     797              : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record);
     798              : 
     799              : /*
     800              :    MakeComponentRef - use, sym, to reference, field, sym is returned.
     801              : */
     802              : 
     803              : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field);
     804              : 
     805              : /*
     806              :    IsComponent - returns TRUE if symbol, sym, is a temporary and a component
     807              :                  reference.
     808              : */
     809              : 
     810              : extern "C" bool SymbolTable_IsComponent (unsigned int sym);
     811              : 
     812              : /*
     813              :    MakeTemporary - Makes a new temporary variable at the highest real scope.
     814              :                    The addressing mode of the temporary is set to NoValue.
     815              : */
     816              : 
     817              : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode);
     818              : 
     819              : /*
     820              :    MakeTemporaryFromExpression - makes a new temporary variable at the
     821              :                                  highest real scope.  The addressing
     822              :                                  mode of the temporary is set and the
     823              :                                  type is determined by expressions, e.
     824              : */
     825              : 
     826              : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode);
     827              : 
     828              : /*
     829              :    MakeTemporaryFromExpressions - makes a new temporary variable at the
     830              :                                   highest real scope.  The addressing
     831              :                                   mode of the temporary is set and the
     832              :                                   type is determined by expressions,
     833              :                                   e1 and e2.
     834              : */
     835              : 
     836              : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode);
     837              : 
     838              : /*
     839              :    PutMode - Puts the addressing mode, SymMode, into symbol Sym.
     840              :              The mode may only be altered if the mode
     841              :              is None.
     842              : */
     843              : 
     844              : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode);
     845              : 
     846              : /*
     847              :    GetMode - Returns the addressing mode of a symbol.
     848              : */
     849              : 
     850              : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym);
     851              : 
     852              : /*
     853              :    StartScope - starts a block scope at Sym. Transparent determines
     854              :                 whether the search for a symbol will look at the
     855              :                 previous ScopeCallFrame if Sym does not contain the
     856              :                 symbol that GetSym is searching.
     857              : 
     858              :                 WITH statements are partially implemented by calling
     859              :                 StartScope. Therefore we must retain the old Main from
     860              :                 the previous ScopePtr when a record is added to the scope
     861              :                 stack. (Main contains the symbol where all identifiers
     862              :                 should be added.)
     863              : */
     864              : 
     865              : extern "C" void SymbolTable_StartScope (unsigned int Sym);
     866              : 
     867              : /*
     868              :    EndScope - ends a block scope started by StartScope. The current
     869              :               head of the symbol scope reverts back to the symbol
     870              :               which was the Head of the symbol scope before the
     871              :               last StartScope was called.
     872              : */
     873              : 
     874              : extern "C" void SymbolTable_EndScope (void);
     875              : 
     876              : /*
     877              :    PseudoScope - starts a pseudo scope at Sym.
     878              :                  We always connect parent up to the last scope,
     879              :                  to determine the transparancy of a scope we call
     880              :                  TransparentScope.
     881              : 
     882              :                  A Pseudo scope has no end block,
     883              :                  but is terminated when the next EndScope is used.
     884              :                  The function of the pseudo scope is to provide an
     885              :                  automatic mechanism to solve enumeration types.
     886              :                  A declared enumeration type is a Pseudo scope and
     887              :                  identifiers used with the name of an enumeration
     888              :                  type field will find the enumeration symbol by
     889              :                  the scoping algorithm.
     890              : */
     891              : 
     892              : extern "C" void SymbolTable_PseudoScope (unsigned int Sym);
     893              : 
     894              : /*
     895              :    GetCurrentScope - returns the symbol who is responsible for the current
     896              :                      scope. Note that it ignore pseudo scopes.
     897              : */
     898              : 
     899              : extern "C" unsigned int SymbolTable_GetCurrentScope (void);
     900              : 
     901              : /*
     902              :    IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
     903              : */
     904              : 
     905              : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym);
     906              : 
     907              : /*
     908              :    SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
     909              :                       This Sym must represent the module name of the
     910              :                       file currently being compiled.
     911              : */
     912              : 
     913              : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym);
     914              : 
     915              : /*
     916              :    SetFileModule - Used to set the FileModule to a symbol, Sym.
     917              :                    This Sym must represent the current program module
     918              :                    file which is being parsed.
     919              : */
     920              : 
     921              : extern "C" void SymbolTable_SetFileModule (unsigned int Sym);
     922              : 
     923              : /*
     924              :    SetMainModule - Used to set the MainModule to a symbol, Sym.
     925              :                    This Sym must represent the main module which was
     926              :                    envoked by the user to be compiled.
     927              : */
     928              : 
     929              : extern "C" void SymbolTable_SetMainModule (unsigned int Sym);
     930              : 
     931              : /*
     932              :    CheckAnonymous - checks to see whether the name is NulName and if so
     933              :                     it creates a unique anonymous name.
     934              : */
     935              : 
     936              : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name);
     937              : 
     938              : /*
     939              :    IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
     940              :                      or no name.
     941              : */
     942              : 
     943              : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym);
     944              : 
     945              : /*
     946              :    NoOfVariables - returns the number of variables in scope.  The scope maybe
     947              :                    a procedure, module or defimp scope.
     948              : */
     949              : 
     950              : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope);
     951              : 
     952              : /*
     953              :    MakeModule - creates a module sym with ModuleName. It returns the
     954              :                 symbol index.
     955              : */
     956              : 
     957              : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName);
     958              : 
     959              : /*
     960              :    MakeDefImp - creates a definition and implementation module sym
     961              :                 with name DefImpName.  It returns the symbol index.
     962              : */
     963              : 
     964              : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName);
     965              : 
     966              : /*
     967              :    MakeInnerModule - creates an inner module sym with ModuleName. It returns the
     968              :                      symbol index.
     969              : */
     970              : 
     971              : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName);
     972              : 
     973              : /*
     974              :    MakeProcedure - creates a procedure sym with name. It returns
     975              :                    the symbol index.
     976              : */
     977              : 
     978              : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName);
     979              : 
     980              : /*
     981              :    MakeProcedureCtorExtern - creates an extern ctor procedure
     982              : */
     983              : 
     984              : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename);
     985              : 
     986              : /*
     987              :    PutLibName - places libname into defimp or module sym.
     988              : */
     989              : 
     990              : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname);
     991              : 
     992              : /*
     993              :    GetLibName - returns libname associated with a defimp or module sym.
     994              : */
     995              : 
     996              : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym);
     997              : 
     998              : /*
     999              :    PutMonoName - changes the IsMonoName boolean inside the procedure.
    1000              : */
    1001              : 
    1002              : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value);
    1003              : 
    1004              : /*
    1005              :    IsMonoName - returns the public boolean associated with a procedure.
    1006              : */
    1007              : 
    1008              : extern "C" bool SymbolTable_IsMonoName (unsigned int sym);
    1009              : 
    1010              : /*
    1011              :    PutExtern - changes the extern boolean inside the procedure.
    1012              : */
    1013              : 
    1014              : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value);
    1015              : 
    1016              : /*
    1017              :    IsExtern - returns the public boolean associated with a procedure.
    1018              : */
    1019              : 
    1020              : extern "C" bool SymbolTable_IsExtern (unsigned int sym);
    1021              : 
    1022              : /*
    1023              :    PutPublic - changes the public boolean inside the procedure.
    1024              : */
    1025              : 
    1026              : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value);
    1027              : 
    1028              : /*
    1029              :    IsPublic - returns the public boolean associated with a procedure.
    1030              : */
    1031              : 
    1032              : extern "C" bool SymbolTable_IsPublic (unsigned int sym);
    1033              : 
    1034              : /*
    1035              :    PutCtor - changes the ctor boolean inside the procedure.
    1036              : */
    1037              : 
    1038              : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value);
    1039              : 
    1040              : /*
    1041              :    IsCtor - returns the ctor boolean associated with a procedure.
    1042              : */
    1043              : 
    1044              : extern "C" bool SymbolTable_IsCtor (unsigned int sym);
    1045              : 
    1046              : /*
    1047              :    GetModuleCtors - mod can be a DefImp or Module symbol.  ctor, init and fini
    1048              :                     are assigned for this module.  An inner module ctor value will
    1049              :                     be NulSym.
    1050              : */
    1051              : 
    1052              : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep);
    1053              : 
    1054              : /*
    1055              :    MakeModuleCtor - for a defimp or module symbol create all the ctor
    1056              :                     related procedures.
    1057              : */
    1058              : 
    1059              : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym);
    1060              : 
    1061              : /*
    1062              :    PutModuleCtorExtern - for every ctor related procedure in module sym.
    1063              :                          Make it external.  It will create any missing
    1064              :                          init/fini procedures but not any missing dep/ctor
    1065              :                          procedures.
    1066              : */
    1067              : 
    1068              : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external);
    1069              : 
    1070              : /*
    1071              :    PutVarHeap - assigns ArrayRef field with value.
    1072              : */
    1073              : 
    1074              : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value);
    1075              : 
    1076              : /*
    1077              :    IsVarHeap - returns ArrayRef field value.
    1078              : */
    1079              : 
    1080              : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym);
    1081              : 
    1082              : /*
    1083              :    MakeVar - creates a variable sym with VarName. It returns the
    1084              :              symbol index.
    1085              : */
    1086              : 
    1087              : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName);
    1088              : 
    1089              : /*
    1090              :    PutVarConditional - assign IsConditional to value.
    1091              : */
    1092              : 
    1093              : extern "C" void SymbolTable_PutVarConditional (unsigned int sym, bool value);
    1094              : 
    1095              : /*
    1096              :    IsVarConditional - return TRUE if the symbol is a var symbol
    1097              :                       containing the result of a boolean conditional.
    1098              : */
    1099              : 
    1100              : extern "C" bool SymbolTable_IsVarConditional (unsigned int sym);
    1101              : 
    1102              : /*
    1103              :    MakeRecord - makes a Record symbol with name RecordName.
    1104              : */
    1105              : 
    1106              : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName);
    1107              : 
    1108              : /*
    1109              :    MakeVarient - creates a new symbol, a varient symbol for record or varient field
    1110              :                  symbol, RecOrVarFieldSym.
    1111              : */
    1112              : 
    1113              : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym);
    1114              : 
    1115              : /*
    1116              :    MakeFieldVarient - returns a FieldVarient symbol which has been
    1117              :                       assigned to the Varient symbol, Sym.
    1118              : */
    1119              : 
    1120              : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym);
    1121              : 
    1122              : /*
    1123              :    MakeEnumeration - places a new symbol in the current scope, the symbol
    1124              :                      is an enumeration symbol. The symbol index is returned.
    1125              : */
    1126              : 
    1127              : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName);
    1128              : 
    1129              : /*
    1130              :    MakeType - makes a type symbol with name TypeName.
    1131              : */
    1132              : 
    1133              : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName);
    1134              : 
    1135              : /*
    1136              :    MakeHiddenType - makes a type symbol that is hidden from the
    1137              :                     definition module.
    1138              :                     This symbol is placed into the UnImplemented list of
    1139              :                     the definition/implementation module.
    1140              :                     The type will be filled in when the implementation module
    1141              :                     is reached.
    1142              : */
    1143              : 
    1144              : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName);
    1145              : 
    1146              : /*
    1147              :    MakeConstant - create a constant cardinal and return the symbol.
    1148              : */
    1149              : 
    1150              : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value);
    1151              : 
    1152              : /*
    1153              :    MakeConstLit - returns a constant literal of type, constType, with a constName,
    1154              :                   at location, tok.
    1155              : */
    1156              : 
    1157              : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
    1158              : 
    1159              : /*
    1160              :    MakeConstVar - makes a ConstVar type with
    1161              :                   name ConstVarName.
    1162              : */
    1163              : 
    1164              : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName);
    1165              : 
    1166              : /*
    1167              :    MakeConstString - create a string constant in the symboltable.
    1168              : */
    1169              : 
    1170              : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName);
    1171              : 
    1172              : /*
    1173              :    MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
    1174              :                          If known is TRUE then name is assigned to the contents
    1175              :                          and the escape sequences will be converted into characters.
    1176              : */
    1177              : 
    1178              : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known);
    1179              : 
    1180              : /*
    1181              :    MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
    1182              :                           If known is TRUE then name is assigned to the contents
    1183              :                           however the escape sequences are not converted into characters.
    1184              : */
    1185              : 
    1186              : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known);
    1187              : 
    1188              : /*
    1189              :    PutConstStringKnown - if sym is a constvar then convert it into a conststring.
    1190              :                          If known is FALSE then contents is ignored and NulName is
    1191              :                          stored.  If escape is TRUE then the contents will have
    1192              :                          any escape sequences converted into single characters.
    1193              : */
    1194              : 
    1195              : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known);
    1196              : 
    1197              : /*
    1198              :    CopyConstString - copies string contents from expr to des
    1199              :                      and retain the kind of string.
    1200              : */
    1201              : 
    1202              : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr);
    1203              : 
    1204              : /*
    1205              :    IsConstStringKnown - returns TRUE if sym is a const string
    1206              :                         and the contents are known.
    1207              : */
    1208              : 
    1209              : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym);
    1210              : 
    1211              : /*
    1212              :    IsConstStringM2 - returns whether this conststring is a
    1213              :                      Modula-2 string.
    1214              : */
    1215              : 
    1216              : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym);
    1217              : 
    1218              : /*
    1219              :    IsConstStringC - returns whether this conststring is a C style string
    1220              :                     which will have any escape translated.
    1221              : */
    1222              : 
    1223              : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym);
    1224              : 
    1225              : /*
    1226              :    IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
    1227              :                         contains a nul terminator.
    1228              : */
    1229              : 
    1230              : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym);
    1231              : 
    1232              : /*
    1233              :    IsConstStringCnul - returns whether this conststring is a C style string
    1234              :                        which will have any escape translated and also contains
    1235              :                        a nul terminator.
    1236              : */
    1237              : 
    1238              : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym);
    1239              : 
    1240              : /*
    1241              :    MakeSubrange - makes a new symbol into a subrange type with
    1242              :                   name SubrangeName.
    1243              : */
    1244              : 
    1245              : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName);
    1246              : 
    1247              : /*
    1248              :    MakeSet - makes a set Symbol with name, SetName.
    1249              : */
    1250              : 
    1251              : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName);
    1252              : 
    1253              : /*
    1254              :    GetSetArray - return the set array for a large set.
    1255              : */
    1256              : 
    1257              : extern "C" unsigned int SymbolTable_GetSetArray (unsigned int sym);
    1258              : 
    1259              : /*
    1260              :    PutSetArray - places array into the setarray field.
    1261              : */
    1262              : 
    1263              : extern "C" void SymbolTable_PutSetArray (unsigned int Sym, unsigned int array);
    1264              : 
    1265              : /*
    1266              :    MakeSetArray - create an ARRAY simpletype OF BOOLEAN.
    1267              : */
    1268              : 
    1269              : extern "C" unsigned int SymbolTable_MakeSetArray (unsigned int token, unsigned int subrangetype);
    1270              : 
    1271              : /*
    1272              :    PutSetInWord - set the SetInWord boolean to value.
    1273              : */
    1274              : 
    1275              : extern "C" void SymbolTable_PutSetInWord (unsigned int sym, bool value);
    1276              : 
    1277              : /*
    1278              :    GetSetInWord - return SetInWord.
    1279              : */
    1280              : 
    1281              : extern "C" bool SymbolTable_GetSetInWord (unsigned int sym);
    1282              : 
    1283              : /*
    1284              :    MakeArray - makes an Array symbol with name ArrayName.
    1285              : */
    1286              : 
    1287              : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName);
    1288              : 
    1289              : /*
    1290              :    PutArrayLarge - indicates that this is a large array in which case
    1291              :                    the interface to gcc maps this array from 0..high-low,
    1292              :                    using an integer indice.
    1293              : */
    1294              : 
    1295              : extern "C" void SymbolTable_PutArrayLarge (unsigned int array);
    1296              : 
    1297              : /*
    1298              :    IsArrayLarge - returns TRUE if we need to treat this as a large array.
    1299              : */
    1300              : 
    1301              : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array);
    1302              : 
    1303              : /*
    1304              :    PutPriority - places a interrupt, priority, value into module, module.
    1305              : */
    1306              : 
    1307              : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority);
    1308              : 
    1309              : /*
    1310              :    GetPriority - returns the interrupt priority which was assigned to
    1311              :                  module, module.
    1312              : */
    1313              : 
    1314              : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module);
    1315              : 
    1316              : /*
    1317              :    PutNeedSavePriority - set a boolean flag indicating that this procedure
    1318              :                          needs to save and restore interrupts.
    1319              : */
    1320              : 
    1321              : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym);
    1322              : 
    1323              : /*
    1324              :    GetNeedSavePriority - returns the boolean flag indicating whether this procedure
    1325              :                          needs to save and restore interrupts.
    1326              : */
    1327              : 
    1328              : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym);
    1329              : 
    1330              : /*
    1331              :    PutVariableAtAddress - determines that a variable, sym, is declared at
    1332              :                           a specific address.
    1333              : */
    1334              : 
    1335              : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address);
    1336              : 
    1337              : /*
    1338              :    GetVariableAtAddress - returns the address at which variable, sym, is declared.
    1339              : */
    1340              : 
    1341              : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym);
    1342              : 
    1343              : /*
    1344              :    IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
    1345              :                          a specific address.
    1346              : */
    1347              : 
    1348              : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym);
    1349              : 
    1350              : /*
    1351              :    PutVariableSSA - assigns value to the SSA field within variable sym.
    1352              : */
    1353              : 
    1354              : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value);
    1355              : 
    1356              : /*
    1357              :    IsVariableSSA - returns TRUE if variable is known to be a SSA.
    1358              : */
    1359              : 
    1360              : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym);
    1361              : 
    1362              : /*
    1363              :    PutVarConst - sets the IsConst field to value indicating the variable is read only.
    1364              : */
    1365              : 
    1366              : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value);
    1367              : 
    1368              : /*
    1369              :    MakeGnuAsm - create a GnuAsm symbol.
    1370              : */
    1371              : 
    1372              : extern "C" unsigned int SymbolTable_MakeGnuAsm (void);
    1373              : 
    1374              : /*
    1375              :    PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
    1376              : */
    1377              : 
    1378              : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string);
    1379              : 
    1380              : /*
    1381              :    PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
    1382              : */
    1383              : 
    1384              : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out);
    1385              : 
    1386              : /*
    1387              :    PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
    1388              : */
    1389              : 
    1390              : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in);
    1391              : 
    1392              : /*
    1393              :    PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
    1394              : */
    1395              : 
    1396              : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash);
    1397              : 
    1398              : /*
    1399              :    GetGnuAsm - returns the string symbol, representing the instruction textual
    1400              :                of the GnuAsm symbol. It will return a ConstString.
    1401              : */
    1402              : 
    1403              : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym);
    1404              : 
    1405              : /*
    1406              :    GetGnuAsmInput - returns the input list of registers.
    1407              : */
    1408              : 
    1409              : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym);
    1410              : 
    1411              : /*
    1412              :    GetGnuAsmOutput - returns the output list of registers.
    1413              : */
    1414              : 
    1415              : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym);
    1416              : 
    1417              : /*
    1418              :    GetGnuAsmTrash - returns the list of trashed registers.
    1419              : */
    1420              : 
    1421              : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym);
    1422              : 
    1423              : /*
    1424              :    PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
    1425              : */
    1426              : 
    1427              : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym);
    1428              : 
    1429              : /*
    1430              :    PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
    1431              : */
    1432              : 
    1433              : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym);
    1434              : 
    1435              : /*
    1436              :    MakeRegInterface - creates and returns a register interface symbol.
    1437              : */
    1438              : 
    1439              : extern "C" unsigned int SymbolTable_MakeRegInterface (void);
    1440              : 
    1441              : /*
    1442              :    PutRegInterface - places a, name, string, and, object, into the interface array,
    1443              :                      sym, at position, i.
    1444              :                      The string symbol will either be a register name or a constraint.
    1445              :                      The object is an optional Modula-2 variable or constant symbol.
    1446              :                      read and write are the quadruple numbers representing any read
    1447              :                      or write operation.
    1448              : */
    1449              : 
    1450              : extern "C" void SymbolTable_PutRegInterface (unsigned int tok, unsigned int sym, unsigned int i, NameKey_Name n, unsigned int string, unsigned int object, unsigned int read_, unsigned int write_);
    1451              : 
    1452              : /*
    1453              :    GetRegInterface - gets a, name, string, and, object, from the interface array,
    1454              :                      sym, from position, i.
    1455              : */
    1456              : 
    1457              : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object);
    1458              : 
    1459              : /*
    1460              :    GetModule - Returns the Module symbol for the module with name, name.
    1461              : */
    1462              : 
    1463              : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name);
    1464              : 
    1465              : /*
    1466              :    GetCurrentModule - returns the current module Sym that is being
    1467              :                       compiled.
    1468              : */
    1469              : 
    1470              : extern "C" unsigned int SymbolTable_GetCurrentModule (void);
    1471              : 
    1472              : /*
    1473              :    GetFileModule - returns the FileModule symbol that was requested by
    1474              :                    the user to be compiled.
    1475              : */
    1476              : 
    1477              : extern "C" unsigned int SymbolTable_GetFileModule (void);
    1478              : 
    1479              : /*
    1480              :    GetBaseModule - returns the base module symbol that contains Modula-2
    1481              :                    base types, procedures and functions.
    1482              : */
    1483              : 
    1484              : extern "C" unsigned int SymbolTable_GetBaseModule (void);
    1485              : 
    1486              : /*
    1487              :    GetMainModule - returns the main module symbol that was requested by
    1488              :                    the user to be compiled.
    1489              : */
    1490              : 
    1491              : extern "C" unsigned int SymbolTable_GetMainModule (void);
    1492              : 
    1493              : /*
    1494              :    GetCurrentModuleScope - returns the module symbol which forms the
    1495              :                            current (possibly inner most) module.
    1496              : */
    1497              : 
    1498              : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void);
    1499              : 
    1500              : /*
    1501              :    GetLastModuleScope - returns the last module scope encountered,
    1502              :                         the module scope before the Current Module Scope.
    1503              : */
    1504              : 
    1505              : extern "C" unsigned int SymbolTable_GetLastModuleScope (void);
    1506              : 
    1507              : /*
    1508              :    AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
    1509              :                          ModSym.
    1510              : */
    1511              : 
    1512              : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym);
    1513              : 
    1514              : /*
    1515              :    GetType - Returns the symbol that is the TYPE symbol to Sym.
    1516              :              If zero is returned then we assume type unknown.
    1517              : */
    1518              : 
    1519              : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym);
    1520              : 
    1521              : /*
    1522              :    SkipType - if sym is a TYPE foo = bar
    1523              :               then call SkipType(bar)
    1524              :               else return sym
    1525              : 
    1526              :               it does not skip over hidden types.
    1527              : */
    1528              : 
    1529              : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym);
    1530              : 
    1531              : /*
    1532              :    SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
    1533              :                             sym is declared as a subrange of bar
    1534              :                          then call SkipTypeAndSubrange(bar)
    1535              :                          else return sym
    1536              : 
    1537              :                          it does not skip over hidden types.
    1538              : */
    1539              : 
    1540              : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym);
    1541              : 
    1542              : /*
    1543              :    GetLowestType - Returns the lowest type in the type chain of
    1544              :                    symbol Sym.
    1545              :                    If NulSym is returned then we assume type unknown or
    1546              :                    you have reqested the type of a base type.
    1547              : */
    1548              : 
    1549              : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym);
    1550              : 
    1551              : /*
    1552              :    GetLType - get lowest type.  It returns the lowest type
    1553              :               of symbol, sym.  It skips over type equivalences.
    1554              :               It will not skip over base types.
    1555              : */
    1556              : 
    1557              : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym);
    1558              : 
    1559              : /*
    1560              :    GetSType - get source type.  It returns the type closest
    1561              :               to the object.  It does not skip over type
    1562              :               equivalences.  It will skip over base types.
    1563              : */
    1564              : 
    1565              : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym);
    1566              : 
    1567              : /*
    1568              :    GetDType - get gcc declared type.  It returns the type
    1569              :               of the object which is declared to GCC.
    1570              :               It does skip over type equivalences but only
    1571              :               if they do not contain a user alignment.
    1572              :               It does not skip over hidden types.
    1573              :               It does not skip over base types.
    1574              : */
    1575              : 
    1576              : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym);
    1577              : 
    1578              : /*
    1579              :    GetTypeMode - return the type of sym, it returns Address is the
    1580              :                  symbol is a LValue.
    1581              : */
    1582              : 
    1583              : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym);
    1584              : 
    1585              : /*
    1586              :    GetSym - searches the current scope (and previous scopes if the
    1587              :             scope tranparent allows) for a symbol with name.
    1588              : */
    1589              : 
    1590              : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name);
    1591              : 
    1592              : /*
    1593              :    GetDeclareSym - searches for a symbol with a name SymName in the
    1594              :                    current and previous scopes.
    1595              :                    If the symbol is found then it is returned
    1596              :                    else an unknown symbol is returned.
    1597              :                    This procedure assumes that SymName is being
    1598              :                    declared at this point and therefore it does
    1599              :                    not examine the base scope (for pervasive
    1600              :                    identifiers).
    1601              : */
    1602              : 
    1603              : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName);
    1604              : 
    1605              : /*
    1606              :    GetLocalSym - only searches the scope Sym for a symbol with name
    1607              :                  and returns the index to the symbol.
    1608              : */
    1609              : 
    1610              : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name);
    1611              : 
    1612              : /*
    1613              :    GetRecord - fetches the record symbol from the parent of Sym.
    1614              :                Sym maybe a varient symbol in which case its parent is searched
    1615              :                etc.
    1616              : */
    1617              : 
    1618              : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym);
    1619              : 
    1620              : /*
    1621              :    FromModuleGetSym - attempts to find a symbol of name, n, in the
    1622              :                       module, mod, scope.  An unknown symbol is created
    1623              :                       at token position tok if necessary.
    1624              : */
    1625              : 
    1626              : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod);
    1627              : 
    1628              : /*
    1629              :    GetNth - returns the n th symbol in the list associated with the scope
    1630              :             of Sym.  Sym may be a Module, DefImp, Procedure, Record or
    1631              :             Enumeration symbol.
    1632              : */
    1633              : 
    1634              : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n);
    1635              : 
    1636              : /*
    1637              :    GetNthParam - returns the n th parameter of a procedure Sym.
    1638              : */
    1639              : 
    1640              : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
    1641              : 
    1642              : /*
    1643              :    GetVarScope - returns the symbol which is the scope of variable Sym.
    1644              :                  ie a Module, DefImp or Procedure Symbol.
    1645              : */
    1646              : 
    1647              : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym);
    1648              : 
    1649              : /*
    1650              :    GetSubrange - returns HighSym and LowSym - two constants which make up the
    1651              :                  subrange.
    1652              : */
    1653              : 
    1654              : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym);
    1655              : 
    1656              : /*
    1657              :    GetParam - returns the ParamNo parameter from procedure ProcSym
    1658              : */
    1659              : 
    1660              : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo);
    1661              : 
    1662              : /*
    1663              :    GetString - returns the contents of the string symbol sym, note that
    1664              :                this is not the same as GetName (unless it was a literal).
    1665              : */
    1666              : 
    1667              : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym);
    1668              : 
    1669              : /*
    1670              :    GetStringLength - returns the length of the string symbol Sym.
    1671              : */
    1672              : 
    1673              : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym);
    1674              : 
    1675              : /*
    1676              :    GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
    1677              : */
    1678              : 
    1679              : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym);
    1680              : 
    1681              : /*
    1682              :    PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
    1683              : */
    1684              : 
    1685              : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name);
    1686              : 
    1687              : /*
    1688              :    IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
    1689              : */
    1690              : 
    1691              : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym);
    1692              : 
    1693              : /*
    1694              :    PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
    1695              : */
    1696              : 
    1697              : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym);
    1698              : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym);
    1699              : 
    1700              : /*
    1701              :    PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
    1702              :                        sym, indicating that this block as an EXCEPT
    1703              :                        statement sequence.
    1704              : */
    1705              : 
    1706              : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym);
    1707              : 
    1708              : /*
    1709              :    HasExceptionBlock - returns a BOOLEAN determining whether
    1710              :                        module/procedure/defimp, sym, has
    1711              :                        an EXCEPT statement sequence.
    1712              : */
    1713              : 
    1714              : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym);
    1715              : 
    1716              : /*
    1717              :    PutExceptionFinally - sets a BOOLEAN in block module/defimp,
    1718              :                          sym, indicating that this FINALLY block
    1719              :                          as an EXCEPT statement sequence.
    1720              : */
    1721              : 
    1722              : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym);
    1723              : 
    1724              : /*
    1725              :    HasExceptionFinally - returns a BOOLEAN determining whether
    1726              :                          module/defimp, sym, has
    1727              :                          an EXCEPT statement sequence.
    1728              : */
    1729              : 
    1730              : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym);
    1731              : 
    1732              : /*
    1733              :    PutVar - gives the VarSym symbol Sym a type Type.
    1734              : */
    1735              : 
    1736              : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType);
    1737              : 
    1738              : /*
    1739              :    PutVarTok - gives the VarSym symbol Sym a type Type at typetok.
    1740              : */
    1741              : 
    1742              : extern "C" void SymbolTable_PutVarTok (unsigned int Sym, unsigned int VarType, unsigned int typetok);
    1743              : 
    1744              : /*
    1745              :    PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
    1746              :                                The variable must be a LeftValue.
    1747              : */
    1748              : 
    1749              : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType);
    1750              : 
    1751              : /*
    1752              :    GetVarBackEndType - returns the back end type if specified.
    1753              : */
    1754              : 
    1755              : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym);
    1756              : 
    1757              : /*
    1758              :    PutVarPointerCheck - marks variable, sym, as requiring (or not
    1759              :                         depending upon the, value), a NIL pointer check
    1760              :                         when this symbol is dereferenced.
    1761              : */
    1762              : 
    1763              : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value);
    1764              : 
    1765              : /*
    1766              :    GetVarPointerCheck - returns TRUE if this symbol is a variable and
    1767              :                         has been marked as needing a pointer via NIL check.
    1768              : */
    1769              : 
    1770              : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym);
    1771              : 
    1772              : /*
    1773              :    PutVarWritten - marks variable, sym, as being written to (or not
    1774              :                    depending upon the, value).
    1775              : */
    1776              : 
    1777              : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value);
    1778              : 
    1779              : /*
    1780              :    GetVarWritten - returns TRUE if this symbol is a variable and
    1781              :                    has been marked as being written.
    1782              : */
    1783              : 
    1784              : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym);
    1785              : 
    1786              : /*
    1787              :    PutConst - gives the constant symbol Sym a type ConstType.
    1788              : */
    1789              : 
    1790              : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType);
    1791              : 
    1792              : /*
    1793              :    PutConstSet - informs the const var symbol, sym, that it is or will contain
    1794              :                  a set value.
    1795              : */
    1796              : 
    1797              : extern "C" void SymbolTable_PutConstSet (unsigned int Sym);
    1798              : 
    1799              : /*
    1800              :    IsConstSet - returns TRUE if the constant is declared as a set.
    1801              : */
    1802              : 
    1803              : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym);
    1804              : 
    1805              : /*
    1806              :    PutConstructor - informs the const var symbol, sym, that it is or
    1807              :                     will contain a constructor (record, set or array)
    1808              :                     value.
    1809              : */
    1810              : 
    1811              : extern "C" void SymbolTable_PutConstructor (unsigned int Sym);
    1812              : 
    1813              : /*
    1814              :    PutConstructorFrom - sets the from type field in constructor,
    1815              :                         Sym, to, from.
    1816              : */
    1817              : 
    1818              : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from);
    1819              : 
    1820              : /*
    1821              :    PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
    1822              :                     VarSym is a optional varient symbol which can be returned
    1823              :                     by a call to GetVarient(fieldsymbol).  The created field
    1824              :                     is returned.
    1825              : */
    1826              : 
    1827              : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym);
    1828              : 
    1829              : /*
    1830              :    PutFieldVarient - places the field varient, Field, as a brother to, the
    1831              :                      varient symbol, sym, and also tells Field that its varient
    1832              :                      parent is Sym.
    1833              : */
    1834              : 
    1835              : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym);
    1836              : 
    1837              : /*
    1838              :    GetVarient - returns the varient symbol associated with the
    1839              :                 record or varient field symbol, Field.
    1840              : */
    1841              : 
    1842              : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field);
    1843              : 
    1844              : /*
    1845              :    IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
    1846              :                               a varient tag.
    1847              : */
    1848              : 
    1849              : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym);
    1850              : 
    1851              : /*
    1852              :    IsEmptyFieldVarient - returns TRUE if the field variant has
    1853              :                          no fields.  This will occur then the
    1854              :                          compiler constructs 'else end' variants.
    1855              : */
    1856              : 
    1857              : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym);
    1858              : 
    1859              : /*
    1860              :    GetVarientTag - returns the varient tag from, Sym.
    1861              : */
    1862              : 
    1863              : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym);
    1864              : 
    1865              : /*
    1866              :    PutVarientTag - places, Tag, into varient, Sym.
    1867              : */
    1868              : 
    1869              : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag);
    1870              : 
    1871              : /*
    1872              :    PutFieldEnumeration - places a field into the enumeration type
    1873              :                          Sym. The field has a name FieldName and a
    1874              :                          value FieldVal.
    1875              : */
    1876              : 
    1877              : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName);
    1878              : 
    1879              : /*
    1880              :    PutSubrange - places LowSym and HighSym as two symbols
    1881              :                  which provide the limits of the range.
    1882              : */
    1883              : 
    1884              : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol);
    1885              : 
    1886              : /*
    1887              :    PutSet - places SimpleType as the type for set, Sym.
    1888              : */
    1889              : 
    1890              : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed);
    1891              : 
    1892              : /*
    1893              :    IsSetPacked - returns TRUE if Sym is packed.
    1894              : */
    1895              : 
    1896              : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym);
    1897              : 
    1898              : /*
    1899              :    GetArraySubscript - returns the subscript symbol for array, Sym.
    1900              : */
    1901              : 
    1902              : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym);
    1903              : 
    1904              : /*
    1905              :    PutArraySubscript - places an index field into the array Sym. The
    1906              :                        index field is a subscript sym.
    1907              : */
    1908              : 
    1909              : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol);
    1910              : 
    1911              : /*
    1912              :    PutType - gives a type symbol Sym type TypeSymbol.
    1913              : */
    1914              : 
    1915              : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol);
    1916              : 
    1917              : /*
    1918              :    PutFunction - Places a TypeSym as the return type to a procedure Sym.
    1919              : */
    1920              : 
    1921              : extern "C" void SymbolTable_PutFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym);
    1922              : 
    1923              : /*
    1924              :    PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
    1925              : */
    1926              : 
    1927              : extern "C" void SymbolTable_PutOptFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym);
    1928              : 
    1929              : /*
    1930              :    IsReturnOptional - returns TRUE if the return value for, sym, is
    1931              :                       optional.
    1932              : */
    1933              : 
    1934              : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind);
    1935              : 
    1936              : /*
    1937              :    IsReturnOptionalAny - returns TRUE if the return value for sym is
    1938              :                          optional.
    1939              : */
    1940              : 
    1941              : extern "C" bool SymbolTable_IsReturnOptionalAny (unsigned int sym);
    1942              : 
    1943              : /*
    1944              :    PutParam - Places a Non VAR parameter ParamName with type ParamType into
    1945              :               procedure Sym:kind.  The parameter number is ParamNo.
    1946              :               If the procedure Sym already has this parameter then
    1947              :               the parameter is checked for consistancy and the
    1948              :               consistancy test is returned.
    1949              : */
    1950              : 
    1951              : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok);
    1952              : 
    1953              : /*
    1954              :    PutVarParam - Places a Non VAR parameter ParamName with type
    1955              :                  ParamType into procedure Sym:kind.
    1956              :                  The parameter number is ParamNo.
    1957              :                  If the procedure Sym already has this parameter then
    1958              :                  the parameter is checked for consistancy and the
    1959              :                  consistancy test is returned.
    1960              : */
    1961              : 
    1962              : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok);
    1963              : 
    1964              : /*
    1965              :    PutParamName - assigns a name to paramater no of procedure ProcSym:kind.
    1966              : */
    1967              : 
    1968              : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, NameKey_Name name, unsigned int ParamType, unsigned int typetok);
    1969              : 
    1970              : /*
    1971              :    PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
    1972              :                            main Module.
    1973              : */
    1974              : 
    1975              : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym);
    1976              : 
    1977              : /*
    1978              :    IsProcedureReachable - Returns true if the procedure, Sym, is
    1979              :                           reachable from the main Module.
    1980              : */
    1981              : 
    1982              : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym);
    1983              : 
    1984              : /*
    1985              :    PutProcedureNoReturn - places value into the no return attribute
    1986              :                           field of procedure sym.
    1987              : */
    1988              : 
    1989              : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind, bool value);
    1990              : 
    1991              : /*
    1992              :    IsProcedureNoReturn - returns TRUE if this procedure never returns.
    1993              : */
    1994              : 
    1995              : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind);
    1996              : 
    1997              : /*
    1998              :    GetProcedureProcType - returns the proctype matching procedure sym.
    1999              : */
    2000              : 
    2001              : extern "C" unsigned int SymbolTable_GetProcedureProcType (unsigned int sym);
    2002              : 
    2003              : /*
    2004              :    PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
    2005              :                         QuadNumber is the start quad of Module,
    2006              :                         Sym.
    2007              : */
    2008              : 
    2009              : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber);
    2010              : 
    2011              : /*
    2012              :    PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
    2013              :                       QuadNumber is the end quad of Module,
    2014              :                       Sym.
    2015              : */
    2016              : 
    2017              : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber);
    2018              : 
    2019              : /*
    2020              :    PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
    2021              :                                QuadNumber is the finally start quad of
    2022              :                                Module, Sym.
    2023              : */
    2024              : 
    2025              : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber);
    2026              : 
    2027              : /*
    2028              :    PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
    2029              :                              QuadNumber is the end quad of the finally block
    2030              :                              in Module, Sym.
    2031              : */
    2032              : 
    2033              : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber);
    2034              : 
    2035              : /*
    2036              :    GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
    2037              :                     Quads of a Module, Sym.
    2038              :                     Start and End represent the initialization code
    2039              :                     of the Module, Sym.
    2040              : */
    2041              : 
    2042              : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish);
    2043              : 
    2044              : /*
    2045              :    PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
    2046              : */
    2047              : 
    2048              : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, tree finally);
    2049              : 
    2050              : /*
    2051              :    GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
    2052              : */
    2053              : 
    2054              : extern "C" tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym);
    2055              : 
    2056              : /*
    2057              :    PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
    2058              :                            QuadNumber is the start quad of scope for procedure,
    2059              :                            Sym.
    2060              : */
    2061              : 
    2062              : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber);
    2063              : 
    2064              : /*
    2065              :    PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
    2066              :                            QuadNumber is the start quad of procedure,
    2067              :                            Sym.
    2068              : */
    2069              : 
    2070              : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber);
    2071              : 
    2072              : /*
    2073              :    PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
    2074              :                          QuadNumber is the end quad of procedure,
    2075              :                          Sym.
    2076              : */
    2077              : 
    2078              : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber);
    2079              : 
    2080              : /*
    2081              :    GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
    2082              : */
    2083              : 
    2084              : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end);
    2085              : 
    2086              : /*
    2087              :    GetQuads - assigns Start and End to the beginning and end of
    2088              :               symbol, Sym, usage.
    2089              : */
    2090              : 
    2091              : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
    2092              : 
    2093              : /*
    2094              :    GetReadQuads - assigns Start and End to the beginning and end of
    2095              :                   symbol, Sym, read history usage.
    2096              : */
    2097              : 
    2098              : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
    2099              : 
    2100              : /*
    2101              :    GetWriteQuads - assigns Start and End to the beginning and end of
    2102              :                    symbol, Sym, usage.
    2103              : */
    2104              : 
    2105              : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
    2106              : 
    2107              : /*
    2108              :    PutReadQuad - places Quad into the list of symbol usage.
    2109              : */
    2110              : 
    2111              : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
    2112              : 
    2113              : /*
    2114              :    RemoveReadQuad - places Quad into the list of symbol usage.
    2115              : */
    2116              : 
    2117              : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
    2118              : 
    2119              : /*
    2120              :    PutWriteQuad - places Quad into the list of symbol usage.
    2121              : */
    2122              : 
    2123              : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
    2124              : 
    2125              : /*
    2126              :    RemoveWriteQuad - places Quad into the list of symbol usage.
    2127              : */
    2128              : 
    2129              : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
    2130              : 
    2131              : /*
    2132              :    GetReadLimitQuads - returns Start and End which have been assigned
    2133              :                        the start and end of when the symbol was read
    2134              :                        to within: StartLimit..EndLimit.
    2135              : */
    2136              : 
    2137              : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
    2138              : 
    2139              : /*
    2140              :    GetWriteLimitQuads - returns Start and End which have been assigned
    2141              :                         the start and end of when the symbol was written
    2142              :                         to within: StartLimit..EndLimit.
    2143              : */
    2144              : 
    2145              : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
    2146              : 
    2147              : /*
    2148              :    GetNthProcedure - Returns the Nth procedure in Module, Sym.
    2149              : */
    2150              : 
    2151              : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n);
    2152              : 
    2153              : /*
    2154              :    GetDeclaredDef - returns the tokenno where the symbol was declared
    2155              :                     in the definition module.  UnknownTokenNo is returned
    2156              :                     if no declaration occurred.
    2157              : */
    2158              : 
    2159              : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym);
    2160              : 
    2161              : /*
    2162              :    GetDeclaredMod - returns the tokenno where the symbol was declared.
    2163              :                     in the program or implementation module.
    2164              :                     UnknownTokenNo is returned if no declaration occurred.
    2165              : */
    2166              : 
    2167              : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym);
    2168              : 
    2169              : /*
    2170              :    GetDeclaredFor - returns the token where this forward procedure symbol
    2171              :                     was declared in the program or implementation module.
    2172              :                     UnknownTokenNo is returned if no declaration occurred.
    2173              : */
    2174              : 
    2175              : extern "C" unsigned int SymbolTable_GetDeclaredFor (unsigned int Sym);
    2176              : 
    2177              : /*
    2178              :    GetDeclaredDefinition - returns the token where this symbol
    2179              :                            was declared in the definition module.
    2180              : */
    2181              : 
    2182              : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym);
    2183              : 
    2184              : /*
    2185              :    GetDeclaredModule - returns the token where this symbol was declared
    2186              :                        in an implementation or program module.
    2187              : */
    2188              : 
    2189              : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym);
    2190              : 
    2191              : /*
    2192              :    PutDeclared - adds an entry to symbol, Sym, indicating that it
    2193              :                  was declared at, tok.  This routine
    2194              :                  may be called twice, once for definition module
    2195              :                  partial declaration and once when parsing the
    2196              :                  implementation module.
    2197              : */
    2198              : 
    2199              : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym);
    2200              : 
    2201              : /*
    2202              :    GetFirstUsed - returns the token where this symbol was first used.
    2203              : */
    2204              : 
    2205              : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym);
    2206              : 
    2207              : /*
    2208              :    PutProcedureBegin - assigns begin as the token number matching the
    2209              :                        procedure BEGIN.
    2210              : */
    2211              : 
    2212              : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin);
    2213              : 
    2214              : /*
    2215              :    PutProcedureEnd - assigns end as the token number matching the
    2216              :                      procedure END.
    2217              : */
    2218              : 
    2219              : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end);
    2220              : 
    2221              : /*
    2222              :    GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
    2223              : */
    2224              : 
    2225              : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end);
    2226              : 
    2227              : /*
    2228              :    ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
    2229              : */
    2230              : 
    2231              : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P);
    2232              : 
    2233              : /*
    2234              :    ForeachModuleDo - for each module do procedure, P.
    2235              : */
    2236              : 
    2237              : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P);
    2238              : 
    2239              : /*
    2240              :    ForeachInnerModuleDo - for each inner module in module, Sym,
    2241              :                           do procedure, P.
    2242              : */
    2243              : 
    2244              : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P);
    2245              : 
    2246              : /*
    2247              :    IsVarParam - Returns a conditional depending whether parameter ParamNo
    2248              :                 is a VAR parameter.
    2249              : */
    2250              : 
    2251              : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
    2252              : 
    2253              : /*
    2254              :    IsVarParamAny - Returns a conditional depending whether parameter ParamNo
    2255              :                    is a VAR parameter.
    2256              : */
    2257              : 
    2258              : extern "C" bool SymbolTable_IsVarParamAny (unsigned int Sym, unsigned int ParamNo);
    2259              : 
    2260              : /*
    2261              :    IsUnboundedParam - Returns a conditional depending whether parameter
    2262              :                       ParamNo is an unbounded array procedure parameter.
    2263              : */
    2264              : 
    2265              : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo);
    2266              : extern "C" bool SymbolTable_IsUnboundedParamAny (unsigned int Sym, unsigned int ParamNo);
    2267              : 
    2268              : /*
    2269              :    IsParameterUnbounded - returns TRUE if parameter, Sym, is
    2270              :                           unbounded.
    2271              : */
    2272              : 
    2273              : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym);
    2274              : 
    2275              : /*
    2276              :    IsParameterVar - returns true if parameter symbol Sym
    2277              :                     was declared as a VAR.
    2278              : */
    2279              : 
    2280              : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym);
    2281              : 
    2282              : /*
    2283              :    GetParameterShadowVar - returns the local variable associated with the
    2284              :                            parameter symbol, sym.
    2285              : */
    2286              : 
    2287              : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym);
    2288              : 
    2289              : /*
    2290              :    NoOfParam - Returns the number of parameters that procedure Sym contains.
    2291              : */
    2292              : 
    2293              : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym, SymbolTable_ProcedureKind kind);
    2294              : 
    2295              : /*
    2296              :    HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
    2297              : */
    2298              : 
    2299              : extern "C" bool SymbolTable_HasVarParameters (unsigned int p);
    2300              : 
    2301              : /*
    2302              :    NoOfLocalVar - returns the number of local variables that exist in
    2303              :                   procedure Sym. Parameters are NOT included in the
    2304              :                   count.
    2305              : */
    2306              : 
    2307              : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym);
    2308              : 
    2309              : /*
    2310              :    IsDefImp - returns true is the Sym is a DefImp symbol.
    2311              :               Definition/Implementation module symbol.
    2312              : */
    2313              : 
    2314              : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym);
    2315              : 
    2316              : /*
    2317              :    IsModule - returns true is the Sym is a Module symbol.
    2318              :               Program module symbol.
    2319              : */
    2320              : 
    2321              : extern "C" bool SymbolTable_IsModule (unsigned int Sym);
    2322              : 
    2323              : /*
    2324              :    IsInnerModule - returns true if the symbol, Sym, is an inner module.
    2325              : */
    2326              : 
    2327              : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym);
    2328              : 
    2329              : /*
    2330              :    GetSymName - returns the symbol name.
    2331              : */
    2332              : 
    2333              : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym);
    2334              : 
    2335              : /*
    2336              :    RenameSym - renames a symbol, Sym, with SymName.
    2337              :                It also checks the unknown tree for a symbol
    2338              :                with this new name. Must only be renamed in
    2339              :                the same scope of being declared.
    2340              : */
    2341              : 
    2342              : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName);
    2343              : 
    2344              : /*
    2345              :    IsUnknown - returns true is the symbol Sym is unknown.
    2346              : */
    2347              : 
    2348              : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym);
    2349              : 
    2350              : /*
    2351              :    IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
    2352              : */
    2353              : 
    2354              : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym);
    2355              : 
    2356              : /*
    2357              :    RequestSym - searches for a symbol with a name SymName in the
    2358              :                 current and previous scopes.
    2359              :                 If the symbol is found then it is returned
    2360              :                 else an unknown symbol is returned create at token
    2361              :                 position, tok.
    2362              :                 This procedure does search the base scope (for
    2363              :                 pervasive identifiers).
    2364              : */
    2365              : 
    2366              : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName);
    2367              : 
    2368              : /*
    2369              :    PutImported - places a symbol, Sym, into the current main scope.
    2370              : */
    2371              : 
    2372              : extern "C" void SymbolTable_PutImported (unsigned int Sym);
    2373              : 
    2374              : /*
    2375              :    PutIncluded - places a symbol, Sym, into the included list of the
    2376              :                  current module.
    2377              :                  Symbols that are placed in this list are indirectly declared
    2378              :                  by:
    2379              : 
    2380              :                  IMPORT modulename ;
    2381              : 
    2382              :                  modulename.identifier
    2383              : */
    2384              : 
    2385              : extern "C" void SymbolTable_PutIncluded (unsigned int Sym);
    2386              : 
    2387              : /*
    2388              :    PutExported - places a symbol, Sym into the next level out module.
    2389              :                  Sym is also placed in the ExportTree of the current inner
    2390              :                  module.
    2391              : */
    2392              : 
    2393              : extern "C" void SymbolTable_PutExported (unsigned int Sym);
    2394              : 
    2395              : /*
    2396              :    PutExportQualified - places a symbol with the name, SymName,
    2397              :                         into the export tree of the
    2398              :                         Definition module being compiled.
    2399              :                         The symbol with name has been EXPORT QUALIFIED
    2400              :                         by the definition module and therefore any reference
    2401              :                         to this symbol in the code generation phase
    2402              :                         will be in the form _Module_Name.
    2403              : */
    2404              : 
    2405              : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName);
    2406              : 
    2407              : /*
    2408              :    PutExportUnQualified - places a symbol with the name, SymName,
    2409              :                           into the export tree of the
    2410              :                           Definition module being compiled.
    2411              :                           The symbol with Name has been EXPORT UNQUALIFIED
    2412              :                           by the definition module and therefore any reference
    2413              :                           to this symbol in the code generation phase
    2414              :                           will be in the form _Name.
    2415              : */
    2416              : 
    2417              : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName);
    2418              : 
    2419              : /*
    2420              :    PutExportUnImplemented - places a symbol, Sym, into the currently compiled
    2421              :                             DefImp module NeedToBeImplemented list.
    2422              : */
    2423              : 
    2424              : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym);
    2425              : 
    2426              : /*
    2427              :    GetExported - returns the symbol which has a name SymName,
    2428              :                  and is exported from the definition module ModSym.
    2429              : 
    2430              : */
    2431              : 
    2432              : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName);
    2433              : 
    2434              : /*
    2435              :    GetFromOuterModule - returns a symbol with name, SymName, which comes
    2436              :                         from outside the current module.
    2437              : */
    2438              : 
    2439              : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName);
    2440              : 
    2441              : /*
    2442              :    TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
    2443              :                                        name, name, which is
    2444              :                                        currently undefined in the
    2445              :                                        outer scope to the inner scope.
    2446              :                                        If successful then the symbol is
    2447              :                                        returned otherwise NulSym is
    2448              :                                        returned.
    2449              : */
    2450              : 
    2451              : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name);
    2452              : 
    2453              : /*
    2454              :    IsExportQualified - returns true if a symbol, Sym, was defined as
    2455              :                        being EXPORT QUALIFIED.
    2456              :                        Sym is expected to be either a procedure or a
    2457              :                        variable.
    2458              : */
    2459              : 
    2460              : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym);
    2461              : 
    2462              : /*
    2463              :    IsExportUnQualified - returns true if a symbol, Sym, was defined as
    2464              :                          being EXPORT UNQUALIFIED.
    2465              : */
    2466              : 
    2467              : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym);
    2468              : 
    2469              : /*
    2470              :    IsExported - returns true if a symbol, Sym, is exported
    2471              :                 from module, ModSym.
    2472              :                 If ModSym is a DefImp symbol then its
    2473              :                 ExportQualified and ExportUnQualified lists are examined.
    2474              : */
    2475              : 
    2476              : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym);
    2477              : 
    2478              : /*
    2479              :    IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
    2480              :                          ModSym must be a defimp symbol.
    2481              : */
    2482              : 
    2483              : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym);
    2484              : 
    2485              : /*
    2486              :    IsImported - returns true if a symbol, Sym, in module, ModSym,
    2487              :                 was imported.
    2488              : */
    2489              : 
    2490              : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym);
    2491              : 
    2492              : /*
    2493              :    PutIncludedByDefinition - places a module symbol, Sym, into the
    2494              :                              included list of the current definition module.
    2495              : */
    2496              : 
    2497              : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym);
    2498              : 
    2499              : /*
    2500              :    IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
    2501              :                             by ModSym's definition module.
    2502              : */
    2503              : 
    2504              : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym);
    2505              : 
    2506              : /*
    2507              :    ForeachImportedDo - calls a procedure, P, foreach imported symbol
    2508              :                        in module, ModSym.
    2509              : */
    2510              : 
    2511              : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
    2512              : 
    2513              : /*
    2514              :    ForeachExportedDo - calls a procedure, P, foreach imported symbol
    2515              :                        in module, ModSym.
    2516              : */
    2517              : 
    2518              : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
    2519              : 
    2520              : /*
    2521              :    CheckForExportedImplementation - checks to see whether an implementation
    2522              :                                     module is currently being compiled, if so,
    2523              :                                     symbol, Sym, is removed from the
    2524              :                                     NeedToBeImplemented list.
    2525              :                                     This procedure is called whenever a symbol
    2526              :                                     is declared, thus attempting to reduce
    2527              :                                     the NeedToBeImplemented list.
    2528              :                                     Only needs to be called when a TYPE or
    2529              :                                     PROCEDURE is built since the implementation
    2530              :                                     module can only implement these objects
    2531              :                                     declared in the definition module.
    2532              : 
    2533              :                                     It also checks whether a definition module
    2534              :                                     is currently being compiled and, if so,
    2535              :                                     it will ensure that symbol, Sym, is removed
    2536              :                                     from the ExportRequest list. If Sym is an
    2537              :                                     enumerated type it ensures that its fields
    2538              :                                     are also removed.
    2539              : */
    2540              : 
    2541              : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym);
    2542              : 
    2543              : /*
    2544              :    CheckForUnImplementedExports - displays an error and the offending symbols
    2545              :                                   which have been exported but not implemented
    2546              :                                   from the current compiled module.
    2547              : */
    2548              : 
    2549              : extern "C" void SymbolTable_CheckForUnImplementedExports (void);
    2550              : 
    2551              : /*
    2552              :    CheckForUndeclaredExports - displays an error and the offending symbols
    2553              :                                which have been exported but not declared
    2554              :                                from module, ModSym.
    2555              : */
    2556              : 
    2557              : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym);
    2558              : 
    2559              : /*
    2560              :    CheckForUnknownInModule - checks for any unknown symbols in the
    2561              :                              current module.
    2562              :                              If any unknown symbols are found then
    2563              :                              an error message is displayed.
    2564              : */
    2565              : 
    2566              : extern "C" void SymbolTable_CheckForUnknownInModule (unsigned int tokno);
    2567              : 
    2568              : /*
    2569              :    UnknownReported - if sym is an unknown symbol and has not been reported
    2570              :                      then include it into the set of reported unknowns.
    2571              : */
    2572              : 
    2573              : extern "C" void SymbolTable_UnknownReported (unsigned int sym);
    2574              : 
    2575              : /*
    2576              :    GetUnknownOnImport - returns the onimport field of unknown sym.
    2577              : */
    2578              : 
    2579              : extern "C" bool SymbolTable_GetUnknownOnImport (unsigned int sym);
    2580              : 
    2581              : /*
    2582              :    GetUnknownDeclScope - returns the decl scope of unknown sym.
    2583              : */
    2584              : 
    2585              : extern "C" unsigned int SymbolTable_GetUnknownDeclScope (unsigned int sym);
    2586              : 
    2587              : /*
    2588              :    IsReallyPointer - returns TRUE is sym is a pointer, address or a
    2589              :                      type declared as a pointer or address.
    2590              : */
    2591              : 
    2592              : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym);
    2593              : 
    2594              : /*
    2595              :    CheckHiddenTypeAreAddress - checks to see that any hidden types
    2596              :                                which we have declared are actually
    2597              :                                of type ADDRESS or map onto a POINTER type.
    2598              : */
    2599              : 
    2600              : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void);
    2601              : 
    2602              : /*
    2603              :    PutDefinitionForC - sets a flag in the current compiled module which
    2604              :                        indicates that this module is a wrapper for a C
    2605              :                        file. Parameters passes to procedures in this module
    2606              :                        will adopt the C calling convention.
    2607              : */
    2608              : 
    2609              : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym);
    2610              : 
    2611              : /*
    2612              :    IsDefinitionForC - returns true if this definition module was declared
    2613              :                       as a DEFINITION MODULE FOR "C".
    2614              : */
    2615              : 
    2616              : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym);
    2617              : 
    2618              : /*
    2619              :    PutDoesNeedExportList - sets a flag in module, Sym, which
    2620              :                            indicates that this module requires an explicit
    2621              :                            EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
    2622              : */
    2623              : 
    2624              : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym);
    2625              : 
    2626              : /*
    2627              :    PutDoesNotNeedExportList - sets a flag in module, Sym, which
    2628              :                               indicates that this module does not require an explicit
    2629              :                               EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
    2630              : */
    2631              : 
    2632              : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym);
    2633              : 
    2634              : /*
    2635              :    DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
    2636              :                            EXPORT QUALIFIED list.
    2637              : */
    2638              : 
    2639              : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym);
    2640              : 
    2641              : /*
    2642              :    CheckForEnumerationInCurrentModule - checks to see whether the enumeration
    2643              :                                         type symbol, Sym, has been entered into
    2644              :                                         the current modules scope list.
    2645              : */
    2646              : 
    2647              : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym);
    2648              : 
    2649              : /*
    2650              :    SanityCheckConstants - must only be called once all constants, types, procedures
    2651              :                           have been declared.  It checks to see that constants are
    2652              :                           not used as procedure parameter types.
    2653              : */
    2654              : 
    2655              : extern "C" void SymbolTable_SanityCheckConstants (void);
    2656              : 
    2657              : /*
    2658              :    ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
    2659              :                        perform the procedure, P.
    2660              : */
    2661              : 
    2662              : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
    2663              : 
    2664              : /*
    2665              :    ForeachParamSymDo - foreach parameter symbol in procedure Sym
    2666              :                        perform the procedure P.  Each symbol
    2667              :                        looked up will be VarParam or Param
    2668              :                        (not the shadow variable).  Every parameter
    2669              :                        from each KindProcedure is iterated over.
    2670              : */
    2671              : 
    2672              : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
    2673              : 
    2674              : /*
    2675              :    ForeachFieldEnumerationDo - for each field in enumeration, Sym,
    2676              :                                do procedure, P.  Each call to P contains
    2677              :                                an enumeration field, the order is alphabetical.
    2678              :                                Use ForeachLocalSymDo for declaration order.
    2679              : */
    2680              : 
    2681              : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P);
    2682              : 
    2683              : /*
    2684              :    IsType - returns true if the Sym is a type symbol.
    2685              : */
    2686              : 
    2687              : extern "C" bool SymbolTable_IsType (unsigned int Sym);
    2688              : 
    2689              : /*
    2690              :    IsProcedure - returns true if Sym is a procedure symbol.
    2691              : */
    2692              : 
    2693              : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym);
    2694              : 
    2695              : /*
    2696              :    IsParameter - returns true if Sym is a parameter symbol.
    2697              : */
    2698              : 
    2699              : extern "C" bool SymbolTable_IsParameter (unsigned int Sym);
    2700              : 
    2701              : /*
    2702              :    GetProcedureKind - returns the procedure kind given the declaration tok.
    2703              :                       The declaration tok must match the ident tok in the
    2704              :                       procedure name.  It is only safe to call this
    2705              :                       procedure function during pass 2 onwards.
    2706              : */
    2707              : 
    2708              : extern "C" SymbolTable_ProcedureKind SymbolTable_GetProcedureKind (unsigned int sym, unsigned int tok);
    2709              : 
    2710              : /*
    2711              :    GetProcedureDeclaredTok - return the token where the
    2712              :                              declaration of procedure sym:kind
    2713              :                              occurred.
    2714              : */
    2715              : 
    2716              : extern "C" unsigned int SymbolTable_GetProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind);
    2717              : 
    2718              : /*
    2719              :    PutProcedureDeclaredTok - places the tok where the
    2720              :                              declaration of procedure sym:kind
    2721              :                              occurred.
    2722              : */
    2723              : 
    2724              : extern "C" void SymbolTable_PutProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok);
    2725              : 
    2726              : /*
    2727              :    GetReturnTypeTok - return the token where the
    2728              :                                return type procedure sym:kind or proctype
    2729              :                                was defined.
    2730              : */
    2731              : 
    2732              : extern "C" unsigned int SymbolTable_GetReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind);
    2733              : 
    2734              : /*
    2735              :    PutReturnTypeTok - places the tok where the
    2736              :                       return type of procedure sym:kind or proctype
    2737              :                       was defined.
    2738              : */
    2739              : 
    2740              : extern "C" void SymbolTable_PutReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok);
    2741              : 
    2742              : /*
    2743              :    PutProcedureParametersDefined - the procedure symbol sym:kind
    2744              :                                    parameters have been defined.
    2745              : */
    2746              : 
    2747              : extern "C" void SymbolTable_PutProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
    2748              : 
    2749              : /*
    2750              :    GetProcedureParametersDefined - returns true if procedure symbol sym:kind
    2751              :                                    parameters are defined.
    2752              : */
    2753              : 
    2754              : extern "C" bool SymbolTable_GetProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
    2755              : 
    2756              : /*
    2757              :    PutProcedureDefined - the procedure symbol sym:kind is defined.
    2758              : */
    2759              : 
    2760              : extern "C" void SymbolTable_PutProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
    2761              : 
    2762              : /*
    2763              :    GetProcedureDefined - returns true if procedure symbol sym:kind
    2764              :                          is defined.
    2765              : */
    2766              : 
    2767              : extern "C" bool SymbolTable_GetProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind);
    2768              : 
    2769              : /*
    2770              :    PutUseVarArgs - tell the symbol table that this procedure, Sym,
    2771              :                    uses varargs.
    2772              :                    The procedure _must_ be declared inside a
    2773              :                    DEFINITION FOR "C"
    2774              : 
    2775              : */
    2776              : 
    2777              : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym);
    2778              : 
    2779              : /*
    2780              :    UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
    2781              :                  The procedure _must_ be declared inside a
    2782              :                  DEFINITION FOR "C"
    2783              : */
    2784              : 
    2785              : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym);
    2786              : 
    2787              : /*
    2788              :    PutUseOptArg - tell the symbol table that this procedure, Sym,
    2789              :                   uses an optarg.
    2790              : */
    2791              : 
    2792              : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind);
    2793              : 
    2794              : /*
    2795              :    UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
    2796              : */
    2797              : 
    2798              : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind);
    2799              : 
    2800              : /*
    2801              :    PutOptArgInit - makes symbol, Sym, the initializer value to
    2802              :                    procedure, ProcSym.
    2803              : */
    2804              : 
    2805              : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym);
    2806              : 
    2807              : /*
    2808              :    GetOptArgInit - returns the initializer value to the optional parameter in
    2809              :                    procedure, ProcSym.
    2810              : */
    2811              : 
    2812              : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym);
    2813              : 
    2814              : /*
    2815              :    MakePointer - returns a pointer symbol with PointerName.
    2816              : */
    2817              : 
    2818              : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName);
    2819              : 
    2820              : /*
    2821              :    PutPointer - gives a pointer symbol a type, PointerType.
    2822              : */
    2823              : 
    2824              : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType);
    2825              : 
    2826              : /*
    2827              :    IsPointer - returns true is Sym is a pointer type symbol.
    2828              : */
    2829              : 
    2830              : extern "C" bool SymbolTable_IsPointer (unsigned int Sym);
    2831              : 
    2832              : /*
    2833              :    IsRecord - returns true is Sym is a record type symbol.
    2834              : */
    2835              : 
    2836              : extern "C" bool SymbolTable_IsRecord (unsigned int Sym);
    2837              : 
    2838              : /*
    2839              :    IsVarient - returns true if the symbol, Sym, is a
    2840              :                varient symbol.
    2841              : */
    2842              : 
    2843              : extern "C" bool SymbolTable_IsVarient (unsigned int Sym);
    2844              : 
    2845              : /*
    2846              :    IsFieldVarient - returns true if the symbol, Sym, is a
    2847              :                     varient field.
    2848              : */
    2849              : 
    2850              : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym);
    2851              : 
    2852              : /*
    2853              :    IsFieldEnumeration - returns true if the symbol, Sym, is an
    2854              :                         enumeration field.
    2855              : */
    2856              : 
    2857              : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym);
    2858              : 
    2859              : /*
    2860              :    IsArray - returns true is Sym is an array type symbol.
    2861              : */
    2862              : 
    2863              : extern "C" bool SymbolTable_IsArray (unsigned int Sym);
    2864              : 
    2865              : /*
    2866              :    IsEnumeration - returns true if Sym is an enumeration symbol.
    2867              : */
    2868              : 
    2869              : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym);
    2870              : 
    2871              : /*
    2872              :    IsSet - returns TRUE if Sym is a set symbol.
    2873              : */
    2874              : 
    2875              : extern "C" bool SymbolTable_IsSet (unsigned int Sym);
    2876              : 
    2877              : /*
    2878              :    IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
    2879              : */
    2880              : 
    2881              : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym);
    2882              : 
    2883              : /*
    2884              :    IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
    2885              : */
    2886              : 
    2887              : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym);
    2888              : 
    2889              : /*
    2890              :    GetDimension - return the number of dimensions associated with
    2891              :                   this unbounded ARRAY parameter.
    2892              : */
    2893              : 
    2894              : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym);
    2895              : 
    2896              : /*
    2897              :    MakeOAFamily - makes an OAFamily symbol based on SimpleType.
    2898              :                   It returns the OAFamily symbol.  A new symbol
    2899              :                   is created if one does not already exist for
    2900              :                   SimpleType.
    2901              : */
    2902              : 
    2903              : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType);
    2904              : 
    2905              : /*
    2906              :    GetOAFamily - returns the oafamily symbol associated with
    2907              :                  SimpleType.
    2908              : */
    2909              : 
    2910              : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType);
    2911              : 
    2912              : /*
    2913              :    ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
    2914              :                      sym, in the oaf.
    2915              : */
    2916              : 
    2917              : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p);
    2918              : 
    2919              : /*
    2920              :    IsUnbounded - returns true if Sym is an unbounded symbol.
    2921              : */
    2922              : 
    2923              : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym);
    2924              : 
    2925              : /*
    2926              :    GetUnbounded - returns the unbounded symbol associated with
    2927              :                   the OAFamily symbol, oaf, and the number of
    2928              :                   dimensions, ndim, of the open array.
    2929              : */
    2930              : 
    2931              : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim);
    2932              : 
    2933              : /*
    2934              :    GetUnboundedRecordType - returns the record type used to
    2935              :                             implement the unbounded array.
    2936              : */
    2937              : 
    2938              : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym);
    2939              : 
    2940              : /*
    2941              :    GetUnboundedAddressOffset - returns the offset of the address field
    2942              :                                inside the record used to implement the
    2943              :                                unbounded type.
    2944              : */
    2945              : 
    2946              : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym);
    2947              : 
    2948              : /*
    2949              :    GetUnboundedHighOffset - returns the offset of the high field
    2950              :                             inside the record used to implement the
    2951              :                             unbounded type.
    2952              : */
    2953              : 
    2954              : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim);
    2955              : 
    2956              : /*
    2957              :    MakeSubscript - makes a subscript Symbol.
    2958              :                    No name is required.
    2959              : */
    2960              : 
    2961              : extern "C" unsigned int SymbolTable_MakeSubscript (void);
    2962              : 
    2963              : /*
    2964              :    PutSubscript - gives a subscript symbol a type, SimpleType.
    2965              : */
    2966              : 
    2967              : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType);
    2968              : 
    2969              : /*
    2970              :    MakeUnbounded - makes an unbounded array Symbol.
    2971              :                    ndim is the number of dimensions required.
    2972              :                    No name is required.
    2973              : */
    2974              : 
    2975              : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim);
    2976              : 
    2977              : /*
    2978              :    NoOfElements - Returns the number of elements in array Sym,
    2979              :                   or the number of elements in an enumeration Sym or
    2980              :                   the number of interface symbols in an Interface list.
    2981              : */
    2982              : 
    2983              : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym);
    2984              : 
    2985              : /*
    2986              :    PutArray - places a type symbol into an arraysym.
    2987              : */
    2988              : 
    2989              : extern "C" void SymbolTable_PutArray (unsigned int arraysym, unsigned int typesym);
    2990              : 
    2991              : /*
    2992              :    ResolveImports - it examines the import list of all inner modules
    2993              :                     and resolves all relative imports.
    2994              : */
    2995              : 
    2996              : extern "C" void SymbolTable_ResolveImports (void);
    2997              : 
    2998              : /*
    2999              :    ResolveConstructorTypes - to be called at the end of pass three.  Its
    3000              :                              purpose is to fix up all constructors whose
    3001              :                              types are unknown.
    3002              : */
    3003              : 
    3004              : extern "C" void SymbolTable_ResolveConstructorTypes (void);
    3005              : 
    3006              : /*
    3007              :    AddNameToScope - adds a Name, n, to the list of objects declared at the
    3008              :                     current scope.
    3009              : */
    3010              : 
    3011              : extern "C" void SymbolTable_AddNameToScope (unsigned int tok, NameKey_Name n);
    3012              : 
    3013              : /*
    3014              :    AddNameToImportList - adds a Name, n, to the import list of the current
    3015              :                          module.
    3016              : */
    3017              : 
    3018              : extern "C" void SymbolTable_AddNameToImportList (unsigned int tok, NameKey_Name n);
    3019              : 
    3020              : /*
    3021              :    GetScope - returns the declaration scope of the symbol.
    3022              : */
    3023              : 
    3024              : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym);
    3025              : 
    3026              : /*
    3027              :    GetModuleScope - returns the module scope of symbol, sym.
    3028              :                     If sym was declared within a nested procedure
    3029              :                     then return the module which defines the
    3030              :                     procedure.
    3031              : */
    3032              : 
    3033              : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym);
    3034              : 
    3035              : /*
    3036              :    GetProcedureScope - returns the innermost procedure (if any)
    3037              :                        in which the symbol, sym, resides.
    3038              :                        A module inside the procedure is skipped
    3039              :                        over.
    3040              : */
    3041              : 
    3042              : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym);
    3043              : 
    3044              : /*
    3045              :    IsModuleWithinProcedure - returns TRUE if module, sym, is
    3046              :                              inside a procedure.
    3047              : */
    3048              : 
    3049              : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym);
    3050              : 
    3051              : /*
    3052              :    GetParent - returns the parent of symbol, Sym.
    3053              : */
    3054              : 
    3055              : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym);
    3056              : 
    3057              : /*
    3058              :    IsRecordField - returns true if Sym is a record field.
    3059              : */
    3060              : 
    3061              : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym);
    3062              : 
    3063              : /*
    3064              :    MakeProcType - returns a procedure type symbol with ProcTypeName.
    3065              : */
    3066              : 
    3067              : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName);
    3068              : 
    3069              : /*
    3070              :    PutProcTypeParam - Places a Non VAR parameter ParamName with type
    3071              :                       ParamType into ProcType Sym.
    3072              : */
    3073              : 
    3074              : extern "C" void SymbolTable_PutProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded);
    3075              : 
    3076              : /*
    3077              :    PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
    3078              :                          ParamType into ProcType Sym.
    3079              : */
    3080              : 
    3081              : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded);
    3082              : 
    3083              : /*
    3084              :    IsProcType - returns true if Sym is a ProcType Symbol.
    3085              : */
    3086              : 
    3087              : extern "C" bool SymbolTable_IsProcType (unsigned int Sym);
    3088              : 
    3089              : /*
    3090              :    IsVar - returns true if Sym is a Var Symbol.
    3091              : */
    3092              : 
    3093              : extern "C" bool SymbolTable_IsVar (unsigned int Sym);
    3094              : 
    3095              : /*
    3096              :    IsVarConst - returns the IsConst field indicating the variable is read only.
    3097              : */
    3098              : 
    3099              : extern "C" bool SymbolTable_IsVarConst (unsigned int sym);
    3100              : 
    3101              : /*
    3102              :    IsConst - returns true if Sym contains a constant value.
    3103              : */
    3104              : 
    3105              : extern "C" bool SymbolTable_IsConst (unsigned int Sym);
    3106              : 
    3107              : /*
    3108              :    IsConstString - returns whether sym is a conststring of any variant.
    3109              : */
    3110              : 
    3111              : extern "C" bool SymbolTable_IsConstString (unsigned int sym);
    3112              : 
    3113              : /*
    3114              :    IsConstStringNulTerminated - returns TRUE if the constant string, sym,
    3115              :                                 should be created with a nul terminator.
    3116              : */
    3117              : 
    3118              : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym);
    3119              : 
    3120              : /*
    3121              :    IsConstLit - returns true if Sym is a literal constant.
    3122              : */
    3123              : 
    3124              : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym);
    3125              : 
    3126              : /*
    3127              :    IsConstructor - returns TRUE if the constant is declared as a
    3128              :                    constant set, array or record.
    3129              : */
    3130              : 
    3131              : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym);
    3132              : 
    3133              : /*
    3134              :    IsDummy - returns true if Sym is a Dummy symbol.
    3135              : */
    3136              : 
    3137              : extern "C" bool SymbolTable_IsDummy (unsigned int Sym);
    3138              : 
    3139              : /*
    3140              :    IsTemporary - returns true if Sym is a Temporary symbol.
    3141              : */
    3142              : 
    3143              : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym);
    3144              : 
    3145              : /*
    3146              :    IsVarAParam - returns true if Sym is a variable declared as a parameter.
    3147              : */
    3148              : 
    3149              : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym);
    3150              : 
    3151              : /*
    3152              :    IsSubscript - returns true if Sym is a subscript symbol.
    3153              : */
    3154              : 
    3155              : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym);
    3156              : 
    3157              : /*
    3158              :    IsSubrange - returns true if Sym is a subrange symbol.
    3159              : */
    3160              : 
    3161              : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym);
    3162              : 
    3163              : /*
    3164              :    IsProcedureVariable - returns true if a Sym is a variable and
    3165              :                          it was declared within a procedure.
    3166              : */
    3167              : 
    3168              : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym);
    3169              : 
    3170              : /*
    3171              :    IsProcedureNested - returns TRUE if procedure, Sym, was
    3172              :                        declared as a nested procedure.
    3173              : */
    3174              : 
    3175              : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym);
    3176              : 
    3177              : /*
    3178              :    IsAModula2Type - returns true if Sym, is a:
    3179              :                     IsType, IsPointer, IsRecord, IsEnumeration,
    3180              :                     IsSubrange, IsArray, IsUnbounded, IsProcType.
    3181              :                     NOTE that it different from IsType.
    3182              : */
    3183              : 
    3184              : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym);
    3185              : 
    3186              : /*
    3187              :    IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
    3188              : */
    3189              : 
    3190              : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym);
    3191              : 
    3192              : /*
    3193              :    IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
    3194              : */
    3195              : 
    3196              : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym);
    3197              : 
    3198              : /*
    3199              :    IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
    3200              : */
    3201              : 
    3202              : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym);
    3203              : 
    3204              : /*
    3205              :    IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
    3206              : */
    3207              : 
    3208              : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym);
    3209              : 
    3210              : /*
    3211              :    IsSizeSolved - returns true if the size of Sym is solved.
    3212              : */
    3213              : 
    3214              : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym);
    3215              : 
    3216              : /*
    3217              :    IsOffsetSolved - returns true if the Offset of Sym is solved.
    3218              : */
    3219              : 
    3220              : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym);
    3221              : 
    3222              : /*
    3223              :    IsValueSolved - returns true if the value of Sym is solved.
    3224              : */
    3225              : 
    3226              : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym);
    3227              : 
    3228              : /*
    3229              :    IsConstructorConstant - returns TRUE if constructor, Sym, is
    3230              :                            defined by only constants.
    3231              : */
    3232              : 
    3233              : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym);
    3234              : 
    3235              : /*
    3236              :    IsComposite - returns TRUE if symbol, sym, is a composite
    3237              :                  type:  ie an ARRAY or RECORD.
    3238              : */
    3239              : 
    3240              : extern "C" bool SymbolTable_IsComposite (unsigned int sym);
    3241              : 
    3242              : /*
    3243              :    IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
    3244              : */
    3245              : 
    3246              : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym);
    3247              : 
    3248              : /*
    3249              :    PutAlignment - assigns the alignment constant associated with,
    3250              :                   type, with, align.
    3251              : */
    3252              : 
    3253              : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align);
    3254              : 
    3255              : /*
    3256              :    GetAlignment - returns the alignment constant associated with,
    3257              :                   type.
    3258              : */
    3259              : 
    3260              : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type);
    3261              : 
    3262              : /*
    3263              :    GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
    3264              :                                     to record, sym.
    3265              : */
    3266              : 
    3267              : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym);
    3268              : 
    3269              : /*
    3270              :    PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
    3271              :                                     to record, sym.
    3272              : */
    3273              : 
    3274              : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align);
    3275              : 
    3276              : /*
    3277              :    PutUnused - sets, sym, as unused.  This is a gm2 pragma.
    3278              : */
    3279              : 
    3280              : extern "C" void SymbolTable_PutUnused (unsigned int sym);
    3281              : 
    3282              : /*
    3283              :    IsUnused - returns TRUE if the symbol was declared as unused with a
    3284              :               gm2 pragma.
    3285              : */
    3286              : 
    3287              : extern "C" bool SymbolTable_IsUnused (unsigned int sym);
    3288              : 
    3289              : /*
    3290              :    PutDeclaredPacked - sets the Packed field of the record or record field symbol.
    3291              : */
    3292              : 
    3293              : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b);
    3294              : 
    3295              : /*
    3296              :    IsDeclaredPacked - was the record symbol or record field, sym,
    3297              :                       declared as packed?
    3298              : */
    3299              : 
    3300              : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym);
    3301              : 
    3302              : /*
    3303              :    IsDeclaredPackedResolved - do we know if the record symbol or record
    3304              :                               field, sym, declared as packed or not packed?
    3305              : */
    3306              : 
    3307              : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym);
    3308              : 
    3309              : /*
    3310              :    GetPackedEquivalent - returns the packed equivalent of type, sym.
    3311              :                          sym must be a type, subrange or enumerated type.
    3312              : */
    3313              : 
    3314              : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym);
    3315              : 
    3316              : /*
    3317              :    GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
    3318              : */
    3319              : 
    3320              : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym);
    3321              : 
    3322              : /*
    3323              :    IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
    3324              : */
    3325              : 
    3326              : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym);
    3327              : 
    3328              : /*
    3329              :    PushSize - pushes the size of Sym.
    3330              : */
    3331              : 
    3332              : extern "C" void SymbolTable_PushSize (unsigned int Sym);
    3333              : 
    3334              : /*
    3335              :    PopSize - pops the ALU stack into Size of Sym.
    3336              : */
    3337              : 
    3338              : extern "C" void SymbolTable_PopSize (unsigned int Sym);
    3339              : 
    3340              : /*
    3341              :    PushValue - pushes the Value of Sym onto the ALU stack.
    3342              : */
    3343              : 
    3344              : extern "C" void SymbolTable_PushValue (unsigned int Sym);
    3345              : 
    3346              : /*
    3347              :    PushVarSize - pushes the size of a variable, Sym.
    3348              :                  The runtime size of Sym will depend upon its addressing mode,
    3349              :                  RightValue has size PushSize(GetType(Sym)) and
    3350              :                  LeftValue has size PushSize(Address) since it points to a
    3351              :                  variable.
    3352              : */
    3353              : 
    3354              : extern "C" void SymbolTable_PushVarSize (unsigned int Sym);
    3355              : 
    3356              : /*
    3357              :    PopValue - pops the ALU stack into Value of Sym.
    3358              : */
    3359              : 
    3360              : extern "C" void SymbolTable_PopValue (unsigned int Sym);
    3361              : 
    3362              : /*
    3363              :    IsObject - returns TRUE if the symbol is an object symbol.
    3364              : */
    3365              : 
    3366              : extern "C" bool SymbolTable_IsObject (unsigned int Sym);
    3367              : 
    3368              : /*
    3369              :    IsTuple - returns TRUE if the symbol is a tuple symbol.
    3370              : */
    3371              : 
    3372              : extern "C" bool SymbolTable_IsTuple (unsigned int Sym);
    3373              : 
    3374              : /*
    3375              :    Make2Tuple - creates and returns a 2 tuple from, a, and, b.
    3376              : */
    3377              : 
    3378              : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b);
    3379              : 
    3380              : /*
    3381              :    MakeError - creates an error node, which can be used in MetaError messages.
    3382              :                It will be removed from ExportUndeclared and Unknown trees.
    3383              : */
    3384              : 
    3385              : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name);
    3386              : 
    3387              : /*
    3388              :    MakeErrorS - creates an error node from a string, which can be used
    3389              :                 in MetaError messages.
    3390              :                 It will be removed from ExportUndeclared and Unknown trees.
    3391              : */
    3392              : 
    3393              : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name);
    3394              : 
    3395              : /*
    3396              :    IsError - returns TRUE if the symbol is an error symbol.
    3397              : */
    3398              : 
    3399              : extern "C" bool SymbolTable_IsError (unsigned int Sym);
    3400              : 
    3401              : /*
    3402              :    IsLegal - returns TRUE if, sym, is a legal symbol.
    3403              : */
    3404              : 
    3405              : extern "C" bool SymbolTable_IsLegal (unsigned int sym);
    3406              : 
    3407              : /*
    3408              :    PutModuleContainsBuiltin - sets a flag in the current compiled module which
    3409              :                               indicates that a builtin procedure is being declared.
    3410              :                               This is only expected to be called when we are
    3411              :                               parsing the definition module.
    3412              : */
    3413              : 
    3414              : extern "C" void SymbolTable_PutModuleContainsBuiltin (void);
    3415              : 
    3416              : /*
    3417              :    IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
    3418              : */
    3419              : 
    3420              : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym);
    3421              : 
    3422              : /*
    3423              :    PutHiddenTypeDeclared - sets a flag in the current compiled module which
    3424              :                            indicates that a Hidden Type is declared within
    3425              :                            the implementation part of the module.
    3426              :                            This procedure is expected to be called while
    3427              :                            compiling the associated definition module.
    3428              : */
    3429              : 
    3430              : extern "C" void SymbolTable_PutHiddenTypeDeclared (void);
    3431              : 
    3432              : /*
    3433              :    IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
    3434              :                           the module, Sym.
    3435              : */
    3436              : 
    3437              : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym);
    3438              : 
    3439              : /*
    3440              :    IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
    3441              :                            type declared as a pointer or address.
    3442              : */
    3443              : 
    3444              : extern "C" bool SymbolTable_IsHiddenReallyPointer (unsigned int Sym);
    3445              : 
    3446              : /*
    3447              :    DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
    3448              : */
    3449              : 
    3450              : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym);
    3451              : 
    3452              : /*
    3453              :    DebugLineNumbers - internal debugging, emit all procedure names in this module
    3454              :                       together with the line numbers for the corresponding begin/end
    3455              :                       tokens.
    3456              : */
    3457              : 
    3458              : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym);
    3459              : 
    3460              : /*
    3461              :    GetErrorScope - returns the error scope for a symbol.
    3462              :                    The error scope is the title scope which is used to
    3463              :                    announce the symbol in the GCC error message.
    3464              : */
    3465              : 
    3466              : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym);
    3467              : 
    3468              : /*
    3469              :    MakeImport - create and return an import symbol.
    3470              :                 moduleSym is the symbol being imported.
    3471              :                 isqualified is FALSE if it were IMPORT modulename and
    3472              :                 TRUE for the qualified FROM modulename IMPORT etc.
    3473              :                 listno is the import list count for this module.
    3474              :                 tok should match this modulename position.
    3475              : */
    3476              : 
    3477              : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified);
    3478              : 
    3479              : /*
    3480              :    MakeImportStatement - return a dependent symbol which represents an import statement
    3481              :                    or a qualified import statement.  The tok should either match
    3482              :                    the FROM token or the IMPORT token.  listno is the import list
    3483              :                    count for the module.
    3484              : */
    3485              : 
    3486              : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno);
    3487              : 
    3488              : /*
    3489              :    IsImport - returns TRUE if sym is an import symbol.
    3490              : */
    3491              : 
    3492              : extern "C" bool SymbolTable_IsImport (unsigned int sym);
    3493              : 
    3494              : /*
    3495              :    IsImportStatement - returns TRUE if sym is a dependent symbol.
    3496              : */
    3497              : 
    3498              : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym);
    3499              : 
    3500              : /*
    3501              :    GetImportModule - returns the module associated with the import symbol.
    3502              : */
    3503              : 
    3504              : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym);
    3505              : 
    3506              : /*
    3507              :    GetImportDeclared - returns the token associated with the import symbol.
    3508              : */
    3509              : 
    3510              : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym);
    3511              : 
    3512              : /*
    3513              :    GetImportStatementList - returns the list of imports for this dependent.
    3514              :                             Each import symbol corresponds to a module.
    3515              : */
    3516              : 
    3517              : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym);
    3518              : 
    3519              : /*
    3520              :    GetModuleDefImportStatementList - returns the list of dependents associated with
    3521              :                                      the definition module.
    3522              : */
    3523              : 
    3524              : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym);
    3525              : 
    3526              : /*
    3527              :    GetModuleModImportStatementList - returns the list of dependents associated with
    3528              :                                      the implementation or program module.
    3529              : */
    3530              : 
    3531              : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym);
    3532              : 
    3533              : /*
    3534              :    AppendModuleImportStatement - appends the ImportStatement symbol onto the
    3535              :                                  module import list.
    3536              : 
    3537              :                                  For example:
    3538              : 
    3539              :                                  FROM x IMPORT y, z ;
    3540              :                                  ^^^^
    3541              : 
    3542              :                                  also:
    3543              : 
    3544              :                                  IMPORT p, q, r;
    3545              :                                  ^^^^^^
    3546              :                                  will result in a new ImportStatement symbol added
    3547              :                                  to the current module import list.
    3548              :                                  The statement symbol is expected to be created
    3549              :                                  by MakeImportStatement using the token positions
    3550              :                                  outlined above.
    3551              : */
    3552              : 
    3553              : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement);
    3554              : 
    3555              : /*
    3556              :    AppendModuleOnImportStatement - appends the import symbol onto the
    3557              :                                    dependent list (chain).
    3558              : 
    3559              :                                    For example each:
    3560              : 
    3561              :                                    FROM x IMPORT y, z ;
    3562              :                                         ^
    3563              :                                    x are added to the dependent list.
    3564              : 
    3565              :                                    also:
    3566              : 
    3567              :                                    IMPORT p, q, r;
    3568              :                                           ^  ^  ^
    3569              :                                    will result in p, q and r added to
    3570              :                                    to the dependent list.
    3571              : 
    3572              :                                    The import symbol is created by MakeImport
    3573              :                                    and the token is expected to match the module
    3574              :                                    name position outlined above.
    3575              : */
    3576              : 
    3577              : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import);
    3578              : 
    3579              : /*
    3580              :    PutModLink - assigns link to module sym.
    3581              : */
    3582              : 
    3583              : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link);
    3584              : 
    3585              : /*
    3586              :    IsModLink - returns the ModLink value associated with the module symbol.
    3587              : */
    3588              : 
    3589              : extern "C" bool SymbolTable_IsModLink (unsigned int sym);
    3590              : 
    3591              : /*
    3592              :    PutDefLink - assigns link to the definition module sym.
    3593              : */
    3594              : 
    3595              : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link);
    3596              : 
    3597              : /*
    3598              :    IsDefLink - returns the DefLink value associated with the definition module symbol.
    3599              : */
    3600              : 
    3601              : extern "C" bool SymbolTable_IsDefLink (unsigned int sym);
    3602              : 
    3603              : /*
    3604              :    IsModuleBuiltin - returns TRUE if the module is a builtin module.
    3605              :                      (For example _BaseTypes).
    3606              : */
    3607              : 
    3608              : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym);
    3609              : 
    3610              : /*
    3611              :    PutModuleBuiltin - sets the Builtin flag to value.
    3612              :                       Currently the procedure expects sym to be a DefImp
    3613              :                       module only.
    3614              : */
    3615              : 
    3616              : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value);
    3617              : 
    3618              : /*
    3619              :    PutVarArrayRef - assigns ArrayRef field with value.
    3620              : */
    3621              : 
    3622              : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value);
    3623              : 
    3624              : /*
    3625              :    IsVarArrayRef - returns ArrayRef field value.
    3626              : */
    3627              : 
    3628              : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym);
    3629              : 
    3630              : /*
    3631              :    VarCheckReadInit - returns TRUE if sym has been initialized.
    3632              : */
    3633              : 
    3634              : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode);
    3635              : 
    3636              : /*
    3637              :    VarInitState - initializes the init state for variable sym.
    3638              : */
    3639              : 
    3640              : extern "C" void SymbolTable_VarInitState (unsigned int sym);
    3641              : 
    3642              : /*
    3643              :    PutVarInitialized - set sym as initialized.
    3644              : */
    3645              : 
    3646              : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode);
    3647              : 
    3648              : /*
    3649              :    PutVarFieldInitialized - records that field has been initialized with
    3650              :                             variable sym.  TRUE is returned if the field
    3651              :                             is detected and changed to initialized.
    3652              : */
    3653              : 
    3654              : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
    3655              : 
    3656              : /*
    3657              :    GetVarFieldInitialized - return TRUE if fieldlist has been initialized
    3658              :                             within variable sym.
    3659              : */
    3660              : 
    3661              : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
    3662              : 
    3663              : /*
    3664              :    PrintInitialized - display variable sym initialization state.
    3665              : */
    3666              : 
    3667              : extern "C" void SymbolTable_PrintInitialized (unsigned int sym);
    3668              : 
    3669              : /*
    3670              :    GetParameterHeapVar - return the heap variable associated with the
    3671              :                          parameter or NulSym.
    3672              : */
    3673              : 
    3674              : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym);
    3675              : 
    3676              : /*
    3677              :    PutProcedureParameterHeapVars - creates heap variables for parameter sym.
    3678              : */
    3679              : 
    3680              : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym);
    3681              : 
    3682              : /*
    3683              :    IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
    3684              :                                  for the target architecture.
    3685              : */
    3686              : 
    3687              : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure);
    3688              : 
    3689              : /*
    3690              :    PutConstLitInternal - marks the sym as being an internal constant.
    3691              :                          Currently this is used when generating a default
    3692              :                          BY constant expression during a FOR loop.
    3693              :                          A constant marked as internal will always pass
    3694              :                          an expression type check.
    3695              : */
    3696              : 
    3697              : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value);
    3698              : 
    3699              : /*
    3700              :    IsConstLitInternal - returns the value of the IsInternal field within
    3701              :                         a constant expression.
    3702              : */
    3703              : 
    3704              : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym);
    3705              : 
    3706              : /*
    3707              :    GetVarDeclTypeTok - returns the TypeTok field associate with variable sym.
    3708              : */
    3709              : 
    3710              : extern "C" unsigned int SymbolTable_GetVarDeclTypeTok (unsigned int sym);
    3711              : 
    3712              : /*
    3713              :    PutVarDeclTypeTok - assigns the TypeTok field to typetok.
    3714              :                        sym can be a variable or parameter.
    3715              : */
    3716              : 
    3717              : extern "C" void SymbolTable_PutVarDeclTypeTok (unsigned int sym, unsigned int typetok);
    3718              : 
    3719              : /*
    3720              :    GetVarDeclTok - returns the TypeTok field associate with variable sym.
    3721              : */
    3722              : 
    3723              : extern "C" unsigned int SymbolTable_GetVarDeclTok (unsigned int sym);
    3724              : 
    3725              : /*
    3726              :    PutVarDeclTok - assigns the VarTok field to typetok.
    3727              :                    sym can be a variable or parameter.
    3728              : */
    3729              : 
    3730              : extern "C" void SymbolTable_PutVarDeclTok (unsigned int sym, unsigned int vartok);
    3731              : 
    3732              : /*
    3733              :    GetVarDeclFullTok - returns the full virtual token containing var: type.
    3734              : */
    3735              : 
    3736              : extern "C" unsigned int SymbolTable_GetVarDeclFullTok (unsigned int sym);
    3737              : 
    3738              : /*
    3739              :    IsProcedureAnyNoReturn - return TRUE if any of the defined kinds
    3740              :                             of procedure sym is declared no return.
    3741              : */
    3742              : 
    3743              : extern "C" bool SymbolTable_IsProcedureAnyNoReturn (unsigned int sym);
    3744              : 
    3745              : /*
    3746              :    GetNthParamAny - returns the nth parameter from the order
    3747              :                     proper procedure, forward declaration
    3748              :                     or definition module procedure.
    3749              : */
    3750              : 
    3751              : extern "C" unsigned int SymbolTable_GetNthParamAny (unsigned int sym, unsigned int ParamNo);
    3752              : 
    3753              : /*
    3754              :    NoOfParamAny - return the number of parameters for sym.
    3755              : */
    3756              : 
    3757              : extern "C" unsigned int SymbolTable_NoOfParamAny (unsigned int sym);
    3758              : 
    3759              : /*
    3760              :    SetReturnOptional - sets the ReturnOptional field in the Procedure:kind or
    3761              :                        ProcType symboltable entry.
    3762              : */
    3763              : 
    3764              : extern "C" void SymbolTable_SetReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind, bool isopt);
    3765              : 
    3766              : /*
    3767              :    UsesOptArgAny - returns TRUE if procedure Sym:kind uses an optional argument.
    3768              : */
    3769              : 
    3770              : extern "C" bool SymbolTable_UsesOptArgAny (unsigned int Sym);
    3771              : 
    3772              : /*
    3773              :    GetProcedureKindDesc - return a string describing kind.
    3774              : */
    3775              : 
    3776              : extern "C" DynamicStrings_String SymbolTable_GetProcedureKindDesc (SymbolTable_ProcedureKind kind);
    3777              : 
    3778              : /*
    3779              :    GetNthParamAnyClosest - returns the nth parameter from the order
    3780              :                            proper procedure, forward declaration
    3781              :                            or definition module procedure.
    3782              :                            It chooses the parameter which is closest
    3783              :                            in source terms to currentmodule.
    3784              :                            The same module will return using the order
    3785              :                            proper procedure, forward procedure, definition module.
    3786              :                            Whereas an imported procedure will choose from
    3787              :                            DefProcedure, ProperProcedure, ForwardProcedure.
    3788              : */
    3789              : 
    3790              : extern "C" unsigned int SymbolTable_GetNthParamAnyClosest (unsigned int sym, unsigned int ParamNo, unsigned int currentmodule);
    3791              : 
    3792              : /*
    3793              :    IsConstVar - returns TRUE if sym is a const var.  This is a
    3794              :                 constant which might be assigned to TRUE or FALSE
    3795              :                 depending upon the result of the quad stack control flow.
    3796              :                 Typically used in CONST foo = (a AND b) or similar.
    3797              :                 This symbol will only be assigned once with a value, but
    3798              :                 will appear more than once as a designator to an assignment
    3799              :                 in the quad table.  However as the quad table is reduced
    3800              :                 only one assignment will remain.  If after reducing quads
    3801              :                 two or more assignments remain, then there is an error
    3802              :                 as sym should not have been declared a constant.
    3803              : */
    3804              : 
    3805              : extern "C" bool SymbolTable_IsConstVar (unsigned int sym);
    3806              : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at);
    3807              : 
    3808              : /*
    3809              :    InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
    3810              : */
    3811              : 
    3812              : static void InitWhereDeclared (SymbolTable_Where *at);
    3813              : 
    3814              : /*
    3815              :    InitWhereFirstUsed - sets the FirstUsed field of record, at.
    3816              : */
    3817              : 
    3818              : static void InitWhereFirstUsed (SymbolTable_Where *at);
    3819              : 
    3820              : /*
    3821              :    InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
    3822              : */
    3823              : 
    3824              : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at);
    3825              : 
    3826              : /*
    3827              :    gdbhook - a debugger convenience hook.
    3828              : */
    3829              : 
    3830              : static void gdbhook (void);
    3831              : 
    3832              : /*
    3833              :    BreakWhenSymCreated - to be called interactively by gdb.
    3834              : */
    3835              : 
    3836              : static void BreakWhenSymCreated (unsigned int sym);
    3837              : 
    3838              : /*
    3839              :    CheckBreak - if sym = BreakSym then call gdbhook.
    3840              : */
    3841              : 
    3842              : static void CheckBreak (unsigned int sym);
    3843              : 
    3844              : /*
    3845              :    NewSym - Sets Sym to a new symbol index.
    3846              : */
    3847              : 
    3848              : static void NewSym (unsigned int *sym);
    3849              : 
    3850              : /*
    3851              :    GetPsym - returns the pointer to, sym.
    3852              : */
    3853              : 
    3854              : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym);
    3855              : 
    3856              : /*
    3857              :    GetPcall - returns the pointer to the CallFrame.
    3858              : */
    3859              : 
    3860              : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call);
    3861              : 
    3862              : /*
    3863              :    DebugProcedureLineNumber -
    3864              : */
    3865              : 
    3866              : static void DebugProcedureLineNumber (unsigned int sym);
    3867              : 
    3868              : /*
    3869              :    PutPartialUnbounded -
    3870              : */
    3871              : 
    3872              : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim);
    3873              : 
    3874              : /*
    3875              :    AlreadyDeclaredError - generate an error message, a, and two areas of code showing
    3876              :                           the places where the symbols were declared.
    3877              : */
    3878              : 
    3879              : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance);
    3880              : 
    3881              : /*
    3882              :    MakeObject - creates an object node.
    3883              : */
    3884              : 
    3885              : static unsigned int MakeObject (unsigned int tok, NameKey_Name name);
    3886              : 
    3887              : /*
    3888              :    DeclareSym - returns a symbol which was either in the unknown tree or
    3889              :                 a New symbol, since name is about to be declared.
    3890              : */
    3891              : 
    3892              : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name);
    3893              : 
    3894              : /*
    3895              :    Init - Initializes the data structures and variables in this module.
    3896              :           Initialize the trees.
    3897              : */
    3898              : 
    3899              : static void Init (void);
    3900              : 
    3901              : /*
    3902              :    AddSymToUnknown -
    3903              : */
    3904              : 
    3905              : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym);
    3906              : 
    3907              : /*
    3908              :    AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
    3909              :                          unknown tree.
    3910              : */
    3911              : 
    3912              : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym);
    3913              : 
    3914              : /*
    3915              :    SubSymFromUnknownTree - removes a symbol with name, name, from the
    3916              :                            unknown tree.
    3917              : */
    3918              : 
    3919              : static void SubSymFromUnknownTree (NameKey_Name name);
    3920              : 
    3921              : /*
    3922              :    GetSymFromUnknownTree - returns a symbol with name, name, from the
    3923              :                            unknown tree.
    3924              :                            If no symbol with name is found then NulSym
    3925              :                            is returned.
    3926              : */
    3927              : 
    3928              : static unsigned int GetSymFromUnknownTree (NameKey_Name name);
    3929              : 
    3930              : /*
    3931              :    ExamineUnresolvedTree - returns a symbol with name, name, from the
    3932              :                            unresolved tree of module, ModSym.
    3933              :                            If no symbol with name is found then NulSym
    3934              :                            is returned.
    3935              : */
    3936              : 
    3937              : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
    3938              : 
    3939              : /*
    3940              :    RemoveFromUnresolvedTree - removes a symbol with name, name, from the
    3941              :                               unresolved tree of symbol, ScopeSym.
    3942              : */
    3943              : 
    3944              : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name);
    3945              : 
    3946              : /*
    3947              :    FetchUnknownSym - returns a symbol from the unknown tree if one is
    3948              :                      available. It also updates the unknown tree.
    3949              : */
    3950              : 
    3951              : static unsigned int FetchUnknownSym (NameKey_Name name);
    3952              : 
    3953              : /*
    3954              :    TransparentScope - returns true is the scope symbol Sym is allowed
    3955              :                       to look to an outer level for a symbol.
    3956              :                       ie is the symbol allowed to look to the parent
    3957              :                       scope for a symbol.
    3958              : */
    3959              : 
    3960              : static bool TransparentScope (unsigned int Sym);
    3961              : 
    3962              : /*
    3963              :    GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
    3964              :                                    the scope before the current module scope.
    3965              : */
    3966              : 
    3967              : static unsigned int GetLastModuleOrProcedureScope (void);
    3968              : 
    3969              : /*
    3970              :    AddSymToScope - adds a symbol Sym with name name to
    3971              :                    the current scope symbol tree.
    3972              : */
    3973              : 
    3974              : static void AddSymToScope (unsigned int Sym, NameKey_Name name);
    3975              : 
    3976              : /*
    3977              :    PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
    3978              :                                               Procedure symbols enumeration
    3979              :                                               list onto the scope stack.
    3980              : */
    3981              : 
    3982              : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym);
    3983              : 
    3984              : /*
    3985              :    PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
    3986              :                                    scope stack. This list will automatically
    3987              :                                    removed via one call to EndScope which
    3988              :                                    matches the StartScope by which this
    3989              :                                    procedure is invoked.
    3990              : */
    3991              : 
    3992              : static void PlaceEnumerationListOntoScope (Lists_List l);
    3993              : 
    3994              : /*
    3995              :    SetFirstUsed - assigns the FirstUsed field in at to tok providing
    3996              :                   it has not already been set.
    3997              : */
    3998              : 
    3999              : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at);
    4000              : 
    4001              : /*
    4002              :    PutFirstUsed - sets tok to the first used providing it has not already been set.
    4003              :                   It also includes the read and write quad into the usage list
    4004              :                   providing the quad numbers are not 0.
    4005              : */
    4006              : 
    4007              : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_);
    4008              : 
    4009              : /*
    4010              :    CanLookThroughScope - by default this procedure returns TRUE.  It only returns
    4011              :                          FALSE if, throughProcedure, is FALSE and the ScopeSym is
    4012              :                          a procedure.
    4013              : */
    4014              : 
    4015              : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure);
    4016              : 
    4017              : /*
    4018              :    GetScopeSym - searches the current scope and below, providing that the
    4019              :                  scopes are transparent, for a symbol with name, name.
    4020              :                  It only passes over procedure scopes if, throughProcedure,
    4021              :                  is TRUE.
    4022              : */
    4023              : 
    4024              : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure);
    4025              : 
    4026              : /*
    4027              :    CheckScopeForSym - checks the scope, ScopeSym, for an identifier
    4028              :                       of name, name. CheckScopeForSym checks for
    4029              :                       the symbol by the GetLocalSym and also
    4030              :                       ExamineUnresolvedTree.
    4031              : */
    4032              : 
    4033              : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name);
    4034              : 
    4035              : /*
    4036              :    GetModuleScopeId - returns the scope index to the next module starting
    4037              :                       at index, Id.
    4038              :                       Id will either point to a null scope (NulSym) or
    4039              :                       alternatively point to a Module or DefImp symbol.
    4040              : */
    4041              : 
    4042              : static unsigned int GetModuleScopeId (unsigned int Id);
    4043              : 
    4044              : /*
    4045              :    GetVisibleSym -
    4046              : */
    4047              : 
    4048              : static unsigned int GetVisibleSym (NameKey_Name name);
    4049              : 
    4050              : /*
    4051              :    IsAlreadyDeclaredSym - returns true if Sym has already been declared
    4052              :                           in the current main scope.
    4053              : */
    4054              : 
    4055              : static bool IsAlreadyDeclaredSym (NameKey_Name name);
    4056              : 
    4057              : /*
    4058              :    GenName - returns a new name consisting of pre, name, post concatenation.
    4059              : */
    4060              : 
    4061              : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high);
    4062              : 
    4063              : /*
    4064              :    InitCtor - initialize the ModuleCtor fields to NulSym.
    4065              : */
    4066              : 
    4067              : static void InitCtor (SymbolTable_ModuleCtor *ctor);
    4068              : 
    4069              : /*
    4070              :    InitCtorFields - initialize the ModuleCtor fields.  An inner module has no
    4071              :                     ctor procedure.
    4072              : */
    4073              : 
    4074              : static void InitCtorFields (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym, SymbolTable_ModuleCtor *ctor, NameKey_Name name, bool inner, bool pub);
    4075              : 
    4076              : /*
    4077              :    CheckTok - checks to see that tok is at a known location.  If not
    4078              :               it uses GetTokenNo as a fall back.
    4079              : */
    4080              : 
    4081              : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high);
    4082              : 
    4083              : /*
    4084              :    GetLink - returns TRUE if the current module is only used for linkage.
    4085              : */
    4086              : 
    4087              : static bool GetLink (void);
    4088              : 
    4089              : /*
    4090              :    AddModuleToParent - adds symbol, Sym, to module, Parent.
    4091              : */
    4092              : 
    4093              : static void AddModuleToParent (unsigned int Sym, unsigned int Parent);
    4094              : 
    4095              : /*
    4096              :    PutProcedureExternPublic - if procedure is not NulSym set extern
    4097              :                               and public booleans.
    4098              : */
    4099              : 
    4100              : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub);
    4101              : 
    4102              : /*
    4103              :    PutCtorExtern -
    4104              : */
    4105              : 
    4106              : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_);
    4107              : 
    4108              : /*
    4109              :    InitProcedureDeclaration - initialize all the ProcedureDeclaration
    4110              :                               fields.
    4111              : */
    4112              : 
    4113              : static void InitProcedureDeclaration (SymbolTable_ProcedureDeclaration *decl);
    4114              : 
    4115              : /*
    4116              :    AddProcedureToList - adds a procedure, Proc, to the list of procedures
    4117              :                         in module, Mod.
    4118              : */
    4119              : 
    4120              : static void AddProcedureToList (unsigned int Mod, unsigned int Proc);
    4121              : 
    4122              : /*
    4123              :    AddVarToScopeList - adds symbol, sym, to, scope.
    4124              : */
    4125              : 
    4126              : static void AddVarToScopeList (unsigned int scope, unsigned int sym);
    4127              : 
    4128              : /*
    4129              :    AddVarToList - add a variable symbol to the list of variables maintained
    4130              :                   by the inner most scope. (Procedure or Module).
    4131              : */
    4132              : 
    4133              : static void AddVarToList (unsigned int Sym);
    4134              : 
    4135              : /*
    4136              :    InitVarDecl - initialize the variable and type token location positions.
    4137              : */
    4138              : 
    4139              : static void InitVarDecl (SymbolTable_VarDecl *decl, unsigned int vartok);
    4140              : 
    4141              : /*
    4142              :    doPutVarDeclTypeTok - places typetok into decl.TypeTok.
    4143              :                          sym must be a variable.
    4144              : */
    4145              : 
    4146              : static void doPutVarDeclTypeTok (unsigned int sym, unsigned int typetok);
    4147              : 
    4148              : /*
    4149              :    doPutVarDeclTok - places vartok into decl.VarTok.
    4150              :                      sym must be a variable.
    4151              : */
    4152              : 
    4153              : static void doPutVarDeclTok (unsigned int sym, unsigned int vartok);
    4154              : 
    4155              : /*
    4156              :    doGetVarDeclTok - return decl.VarTok for a variable.
    4157              : */
    4158              : 
    4159              : static unsigned int doGetVarDeclTok (unsigned int sym);
    4160              : 
    4161              : /*
    4162              :    doGetVarDeclTypeTok - return decl.TypeTok for a variable.
    4163              : */
    4164              : 
    4165              : static unsigned int doGetVarDeclTypeTok (unsigned int sym);
    4166              : 
    4167              : /*
    4168              :    doGetVarDeclFullTok - return the full declaration of var: type.
    4169              : */
    4170              : 
    4171              : static unsigned int doGetVarDeclFullTok (unsigned int sym);
    4172              : 
    4173              : /*
    4174              :    FillInRecordFields - given a new symbol, sym, make it a record symbol
    4175              :                         and initialize its fields.
    4176              : */
    4177              : 
    4178              : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf);
    4179              : 
    4180              : /*
    4181              :    HandleHiddenOrDeclare -
    4182              : */
    4183              : 
    4184              : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf);
    4185              : 
    4186              : /*
    4187              :    CreateConstLit -
    4188              : */
    4189              : 
    4190              : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
    4191              : 
    4192              : /*
    4193              :    LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
    4194              :                              matches tok, constName and constType.
    4195              : */
    4196              : 
    4197              : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType);
    4198              : 
    4199              : /*
    4200              :    AddConstLitPoolEntry - adds sym to the constlit pool.
    4201              : */
    4202              : 
    4203              : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType);
    4204              : 
    4205              : /*
    4206              :    InitConstString - initialize the constant string.
    4207              : */
    4208              : 
    4209              : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known);
    4210              : 
    4211              : /*
    4212              :    GetConstStringKind - return the StringVariant field associated with sym.
    4213              : */
    4214              : 
    4215              : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym);
    4216              : 
    4217              : /*
    4218              :    CanUseBuiltin - returns TRUE if the procedure, Sym, can be
    4219              :                    inlined via a builtin function.
    4220              : */
    4221              : 
    4222              : static bool CanUseBuiltin (unsigned int Sym);
    4223              : 
    4224              : /*
    4225              :    InitPacked - initialise packedInfo to FALSE and NulSym.
    4226              : */
    4227              : 
    4228              : static void InitPacked (SymbolTable_PackedInfo *packedInfo);
    4229              : 
    4230              : /*
    4231              :    doEquivalent - create a packed equivalent symbol for, sym, and return the
    4232              :                   new symbol.  It sets both fields in packedInfo to FALSE
    4233              :                   and the new symbol.
    4234              : */
    4235              : 
    4236              : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
    4237              : 
    4238              : /*
    4239              :    MakeEquivalent - return the equivalent packed symbol for, sym.
    4240              : */
    4241              : 
    4242              : static unsigned int MakeEquivalent (unsigned int sym);
    4243              : 
    4244              : /*
    4245              :    GetEquivalent -
    4246              : */
    4247              : 
    4248              : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym);
    4249              : 
    4250              : /*
    4251              :    doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
    4252              : */
    4253              : 
    4254              : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase);
    4255              : 
    4256              : /*
    4257              :    GetTypeOfVar - returns the type of symbol, var.
    4258              : */
    4259              : 
    4260              : static unsigned int GetTypeOfVar (unsigned int var);
    4261              : 
    4262              : /*
    4263              :    GetConstLitType - returns the type of the constant of, name.
    4264              :                      All floating point constants have type LONGREAL.
    4265              :                      Character constants are type CHAR.
    4266              :                      Integer values are INTEGER, LONGINT or LONGCARD
    4267              :                      depending upon their value.
    4268              : */
    4269              : 
    4270              : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError);
    4271              : 
    4272              : /*
    4273              :    GetNthFromComponent -
    4274              : */
    4275              : 
    4276              : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n);
    4277              : 
    4278              : /*
    4279              :    GetNthParamChoice - returns the parameter definition from
    4280              :                        sym:ParamNo:kind or NulSym.
    4281              : */
    4282              : 
    4283              : static unsigned int GetNthParamChoice (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind kind);
    4284              : 
    4285              : /*
    4286              :    GetNthParamOrdered - returns the parameter definition from list {a, b, c}
    4287              :                         in order.
    4288              :                         sym:ParamNo:{a,b,c} or NulSym.
    4289              : */
    4290              : 
    4291              : static unsigned int GetNthParamOrdered (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind a, SymbolTable_ProcedureKind b, SymbolTable_ProcedureKind c);
    4292              : 
    4293              : /*
    4294              :    GetOuterModuleScope - returns the outer module symbol scope for sym.
    4295              : */
    4296              : 
    4297              : static unsigned int GetOuterModuleScope (unsigned int sym);
    4298              : 
    4299              : /*
    4300              :    EnsureOrder - providing that both symbols, a, and, b, exist in
    4301              :                  list, l.  Ensure that, b, is placed after a.
    4302              : */
    4303              : 
    4304              : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b);
    4305              : 
    4306              : /*
    4307              :    DumpSons -
    4308              : */
    4309              : 
    4310              : static void DumpSons (unsigned int sym);
    4311              : 
    4312              : /*
    4313              :    CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
    4314              : */
    4315              : 
    4316              : static void CheckListOfSons (unsigned int sym);
    4317              : 
    4318              : /*
    4319              :    CheckRecordConsistency -
    4320              : */
    4321              : 
    4322              : static void CheckRecordConsistency (unsigned int sym);
    4323              : 
    4324              : /*
    4325              :    PutConstVarTemporary - indicates that constant, sym, is a temporary.
    4326              : */
    4327              : 
    4328              : static void PutConstVarTemporary (unsigned int sym);
    4329              : 
    4330              : /*
    4331              :    buildTemporary - builds the temporary filling in componentRef, record and sets mode.
    4332              : */
    4333              : 
    4334              : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record);
    4335              : 
    4336              : /*
    4337              :    AssertInRange - determines whether the Sym is a legal symbol.
    4338              : */
    4339              : 
    4340              : static void AssertInRange (unsigned int Sym);
    4341              : 
    4342              : /*
    4343              :    CheckForHiddenType - scans the NeedToBeImplemented tree providing
    4344              :                         that we are currently compiling an implementation
    4345              :                         module. If a symbol is found with TypeName
    4346              :                         then its Sym is returned.
    4347              :                         Otherwise NulSym is returned.
    4348              :                         CheckForHiddenType is called before any type is
    4349              :                         created, therefore the compiler allows hidden
    4350              :                         types to be implemented using any type.
    4351              : */
    4352              : 
    4353              : static unsigned int CheckForHiddenType (NameKey_Name TypeName);
    4354              : 
    4355              : /*
    4356              :    RequestFromModule - returns a symbol from module ModSym with name, SymName.
    4357              : */
    4358              : 
    4359              : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
    4360              : 
    4361              : /*
    4362              :    RequestFromDefinition - returns a symbol from module ModSym with name,
    4363              :                            SymName.
    4364              : */
    4365              : 
    4366              : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
    4367              : 
    4368              : /*
    4369              :    GetWhereImported - returns the token number where this symbol
    4370              :                       was imported into the current module.
    4371              : */
    4372              : 
    4373              : static unsigned int GetWhereImported (unsigned int Sym);
    4374              : 
    4375              : /*
    4376              :    DisplayName - displays the name.
    4377              : */
    4378              : 
    4379              : static void DisplayName (unsigned int sym);
    4380              : 
    4381              : /*
    4382              :    DisplaySymbol - displays the name of a symbol
    4383              : */
    4384              : 
    4385              : static void DisplaySymbol (unsigned int sym);
    4386              : 
    4387              : /*
    4388              :    FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
    4389              : */
    4390              : 
    4391              : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
    4392              : 
    4393              : /*
    4394              :    FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
    4395              : */
    4396              : 
    4397              : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName);
    4398              : 
    4399              : /*
    4400              :    FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
    4401              : */
    4402              : 
    4403              : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName);
    4404              : 
    4405              : /*
    4406              :    UnknownSymbolError - displays symbol name for symbol, sym.
    4407              : */
    4408              : 
    4409              : static void UnknownSymbolError (unsigned int sym);
    4410              : 
    4411              : /*
    4412              :    IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
    4413              :                          reported and is an unknown symbol.
    4414              : */
    4415              : 
    4416              : static bool IsUnreportedUnknown (unsigned int sym);
    4417              : 
    4418              : /*
    4419              :    AddListify -
    4420              : */
    4421              : 
    4422              : static void AddListify (unsigned int sym);
    4423              : 
    4424              : /*
    4425              :    Listify - convert tree into a string list and return the result.
    4426              : */
    4427              : 
    4428              : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition);
    4429              : 
    4430              : /*
    4431              :    CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
    4432              :                       an unknown symbol. All unknown symbols are displayed
    4433              :                       together with an error message.
    4434              : */
    4435              : 
    4436              : static void CheckForUnknowns (unsigned int tokno, NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
    4437              : 
    4438              : /*
    4439              :    SymbolError - displays symbol name for symbol, Sym.
    4440              : */
    4441              : 
    4442              : static void SymbolError (unsigned int Sym);
    4443              : 
    4444              : /*
    4445              :    CheckForSymbols  - checks a binary tree, Tree, to see whether it contains
    4446              :                       any symbol. The tree is expected to be empty, if not
    4447              :                       then an error has occurred.
    4448              : */
    4449              : 
    4450              : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high);
    4451              : 
    4452              : /*
    4453              :    PutExportUndeclared - places a symbol, Sym, into module, ModSym,
    4454              :                          ExportUndeclared list provided that Sym
    4455              :                          is unknown.
    4456              : */
    4457              : 
    4458              : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym);
    4459              : 
    4460              : /*
    4461              :    GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
    4462              :                          which is in the ExportUndeclared list.
    4463              : */
    4464              : 
    4465              : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name);
    4466              : 
    4467              : /*
    4468              :    RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
    4469              :                             ExportUndeclaredTree.
    4470              : */
    4471              : 
    4472              : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym);
    4473              : 
    4474              : /*
    4475              :    CheckForExportedDeclaration - checks to see whether a definition module
    4476              :                                  is currently being compiled, if so,
    4477              :                                  symbol, Sym, is removed from the
    4478              :                                  ExportUndeclared list.
    4479              :                                  This procedure is called whenever a symbol
    4480              :                                  is declared, thus attempting to reduce
    4481              :                                  the ExportUndeclared list.
    4482              : */
    4483              : 
    4484              : static void CheckForExportedDeclaration (unsigned int Sym);
    4485              : 
    4486              : /*
    4487              :    UndeclaredSymbolError - displays symbol name for symbol, Sym.
    4488              : */
    4489              : 
    4490              : static void UndeclaredSymbolError (unsigned int Sym);
    4491              : 
    4492              : /*
    4493              :    RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
    4494              :                                NeedToBeImplemented list.
    4495              : */
    4496              : 
    4497              : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym);
    4498              : 
    4499              : /*
    4500              :    RemoveFromExportRequest -
    4501              : */
    4502              : 
    4503              : static void RemoveFromExportRequest (unsigned int Sym);
    4504              : 
    4505              : /*
    4506              :    RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
    4507              :                                         (and its fields) from the ExportRequest tree.
    4508              : */
    4509              : 
    4510              : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym);
    4511              : 
    4512              : /*
    4513              :    UnImplementedSymbolError - displays symbol name for symbol, Sym.
    4514              : */
    4515              : 
    4516              : static void UnImplementedSymbolError (unsigned int Sym);
    4517              : 
    4518              : /*
    4519              :    CheckEnumerationInList - places symbol, Sym, in the list, l,
    4520              :                             providing it does not already exist.
    4521              :                             PseudoScope(Sym) is called if Sym needs to
    4522              :                             be added to the enumeration list, l.
    4523              : */
    4524              : 
    4525              : static void CheckEnumerationInList (Lists_List l, unsigned int Sym);
    4526              : 
    4527              : /*
    4528              :    CheckIfEnumerationExported - An outer module may use an enumeration that
    4529              :                                 is declared inside an inner module. The usage
    4530              :                                 may occur before definition. The first pass
    4531              :                                 exports a symbol, later the symbol is declared
    4532              :                                 as an emumeration type. At this stage the
    4533              :                                 CheckIfEnumerationExported procedure should be
    4534              :                                 called. This procedure ripples from the current
    4535              :                                 (inner) module to outer module and every time
    4536              :                                 it is exported it must be added to the outer
    4537              :                                 module EnumerationScopeList.
    4538              : */
    4539              : 
    4540              : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId);
    4541              : 
    4542              : /*
    4543              :    CheckForEnumerationInOuterModule - checks to see whether the enumeration
    4544              :                                       type symbol, Sym, has been entered into
    4545              :                                       the outer module, OuterModule, scope list.
    4546              :                                       OuterModule may be internal to the
    4547              :                                       program module.
    4548              : */
    4549              : 
    4550              : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule);
    4551              : 
    4552              : /*
    4553              :    MakeVariableForParam -
    4554              : */
    4555              : 
    4556              : static unsigned int MakeVariableForParam (unsigned int tok, NameKey_Name ParamName, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, unsigned int ParmType, unsigned int typetok);
    4557              : 
    4558              : /*
    4559              :    AddParameter - adds a parameter ParSym to a procedure Sym.
    4560              : */
    4561              : 
    4562              : static void AddParameter (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParSym);
    4563              : 
    4564              : /*
    4565              :    AddProcedureProcTypeParam - adds ParamType to the parameter ProcType
    4566              :                                associated with procedure Sym.
    4567              : */
    4568              : 
    4569              : static void AddProcedureProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded, bool isVarParam);
    4570              : 
    4571              : /*
    4572              :    IsNthParamVar - returns true if the n th parameter of the parameter list,
    4573              :                    List, is a VAR parameter.
    4574              : */
    4575              : 
    4576              : static bool IsNthParamVar (Lists_List Head, unsigned int n);
    4577              : 
    4578              : /*
    4579              :    MakeParameterHeapVar - create a heap variable if sym is a pointer.
    4580              : */
    4581              : 
    4582              : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode);
    4583              : 
    4584              : /*
    4585              :    PutParameterHeapVar - creates a heap variable associated with parameter sym.
    4586              : */
    4587              : 
    4588              : static void PutParameterHeapVar (unsigned int sym);
    4589              : 
    4590              : /*
    4591              :    IsProcedureAnyBoolean - returns the boolean result from p
    4592              :                            for any of procedure kind which is defined.
    4593              : */
    4594              : 
    4595              : static bool IsProcedureAnyBoolean (unsigned int sym, SymbolTable_ProcAnyBoolean p);
    4596              : 
    4597              : /*
    4598              :    IsProcedureAnyDefaultBoolean - returns the boolean result from p
    4599              :                                   for any of procedure kind which is defined.
    4600              : */
    4601              : 
    4602              : static bool IsProcedureAnyDefaultBoolean (unsigned int sym, bool default_, SymbolTable_ProcAnyBoolean p);
    4603              : 
    4604              : /*
    4605              :    FillInUnknownFields - fills in all fields for the undefined sym.
    4606              : */
    4607              : 
    4608              : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName, unsigned int descscope, bool onimport);
    4609              : 
    4610              : /*
    4611              :    FillInPointerFields - given a new symbol, sym, make it a pointer symbol
    4612              :                          and initialize its fields.
    4613              : */
    4614              : 
    4615              : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf);
    4616              : 
    4617              : /*
    4618              :    ForeachParameterDo -
    4619              : */
    4620              : 
    4621              : static void ForeachParameterDo (SymbolTable_CheckProcedure p);
    4622              : 
    4623              : /*
    4624              :    CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
    4625              : */
    4626              : 
    4627              : static void CheckUnbounded (unsigned int Sym);
    4628              : 
    4629              : /*
    4630              :    PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
    4631              : */
    4632              : 
    4633              : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf);
    4634              : 
    4635              : /*
    4636              :    doFillInOAFamily -
    4637              : */
    4638              : 
    4639              : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded);
    4640              : 
    4641              : /*
    4642              :    FillInUnboundedFields -
    4643              : */
    4644              : 
    4645              : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim);
    4646              : 
    4647              : /*
    4648              :    PutUnbounded - associates the unbounded symbol, open, with
    4649              :                   SimpleType.
    4650              : */
    4651              : 
    4652              : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim);
    4653              : 
    4654              : /*
    4655              :    GetArrayDimension - returns the number of dimensions defined.
    4656              : */
    4657              : 
    4658              : static unsigned int GetArrayDimension (unsigned int sym);
    4659              : 
    4660              : /*
    4661              :    ResolveConstructorType - if, sym, has an unresolved constructor type
    4662              :                             then attempt to resolve it by examining the
    4663              :                             from, type.
    4664              : */
    4665              : 
    4666              : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres);
    4667              : 
    4668              : /*
    4669              :    IsConstructorResolved - returns TRUE if the constructor does not
    4670              :                            have an unresolved type.
    4671              : */
    4672              : 
    4673              : static bool IsConstructorResolved (unsigned int sym);
    4674              : 
    4675              : /*
    4676              :    CanResolveConstructor - returns TRUE if the type of the constructor,
    4677              :                            sym, is known.
    4678              : */
    4679              : 
    4680              : static bool CanResolveConstructor (unsigned int sym);
    4681              : 
    4682              : /*
    4683              :    CheckAllConstructorsResolved - checks to see that the
    4684              :                                   UnresolvedConstructorType list is
    4685              :                                   empty and if it is not then it
    4686              :                                   generates error messages.
    4687              : */
    4688              : 
    4689              : static void CheckAllConstructorsResolved (void);
    4690              : 
    4691              : /*
    4692              :    SanityCheckParameters -
    4693              : */
    4694              : 
    4695              : static void SanityCheckParameters (unsigned int sym);
    4696              : 
    4697              : /*
    4698              :    SanityCheckArray - checks to see that an array has a correct subrange type.
    4699              : */
    4700              : 
    4701              : static void SanityCheckArray (unsigned int sym);
    4702              : 
    4703              : /*
    4704              :    ForeachSymbolDo - foreach symbol, call, P(sym).
    4705              : */
    4706              : 
    4707              : static void ForeachSymbolDo (SymbolKey_PerformOperation P);
    4708              : 
    4709              : /*
    4710              :    SanityCheckProcedure - check to see that procedure parameters do not use constants
    4711              :                           instead of types in their formal parameter section.
    4712              : */
    4713              : 
    4714              : static void SanityCheckProcedure (unsigned int sym);
    4715              : 
    4716              : /*
    4717              :    SanityCheckModule -
    4718              : */
    4719              : 
    4720              : static void SanityCheckModule (unsigned int sym);
    4721              : 
    4722              : /*
    4723              :    AddNameTo - adds Name, n, to tree, s.
    4724              : */
    4725              : 
    4726              : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o);
    4727              : 
    4728              : /*
    4729              :    CollectSymbolFrom -
    4730              : */
    4731              : 
    4732              : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n);
    4733              : 
    4734              : /*
    4735              :    CollectUnknown -
    4736              : */
    4737              : 
    4738              : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n);
    4739              : 
    4740              : /*
    4741              :    ResolveImport -
    4742              : */
    4743              : 
    4744              : static void ResolveImport (unsigned int o);
    4745              : 
    4746              : /*
    4747              :    ResolveRelativeImport -
    4748              : */
    4749              : 
    4750              : static void ResolveRelativeImport (unsigned int sym);
    4751              : 
    4752              : /*
    4753              :    Max -
    4754              : */
    4755              : 
    4756              : static unsigned int Max (unsigned int a, unsigned int b);
    4757              : 
    4758              : /*
    4759              :    Min -
    4760              : */
    4761              : 
    4762              : static unsigned int Min (unsigned int a, unsigned int b);
    4763              : 
    4764              : /*
    4765              :    DoFindLimits - assigns, Start, and, End, to the start and end
    4766              :                   limits contained in the list, l.  It ensures that
    4767              :                   Start and End are within StartLimit..EndLimit.
    4768              :                   If StartLimit or EndLimit are 0 then Start is
    4769              :                   is set to the first value and End to the last.
    4770              : */
    4771              : 
    4772              : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l);
    4773              : 
    4774              : /*
    4775              :    PutDeclaredDefinition - associates the current tokenno with
    4776              :                            the symbols declaration in the definition
    4777              :                            module.
    4778              : */
    4779              : 
    4780              : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym);
    4781              : 
    4782              : /*
    4783              :    PutDeclaredModule - returns the token where this symbol was declared
    4784              :                        in an implementation or program module.
    4785              : */
    4786              : 
    4787              : static void PutDeclaredModule (unsigned int tok, unsigned int Sym);
    4788              : 
    4789              : /*
    4790              :    DoIsConst - returns TRUE if Sym is defined as a constant
    4791              :                or is an enumeration field or string.
    4792              : */
    4793              : 
    4794              : static bool DoIsConst (unsigned int Sym);
    4795              : 
    4796              : /*
    4797              :    GetFromIndex - return a value from list, i, at position, n.
    4798              : */
    4799              : 
    4800              : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n);
    4801              : 
    4802              : /*
    4803              :    PutIntoIndex - places value, v, into list, i, at position, n.
    4804              : */
    4805              : 
    4806              : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v);
    4807              : 
    4808              : /*
    4809              :    PushConstString - pushes the character string onto the ALU stack.
    4810              :                      It assumes that the character string is only
    4811              :                      one character long.
    4812              : */
    4813              : 
    4814              : static void PushConstString (unsigned int Sym);
    4815              : 
    4816     36078099 : static void InitWhereDeclaredTok (unsigned int tok, SymbolTable_Where *at)
    4817              : {
    4818              :   /* 
    4819              :    InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
    4820              :   */
    4821     36078099 :   if (M2Comp_CompilingDefinitionModule ())
    4822              :     {
    4823     19013493 :       (*at).DefDeclared = tok;
    4824     19013493 :       (*at).ModDeclared = M2LexBuf_UnknownTokenNo;
    4825              :     }
    4826              :   else
    4827              :     {
    4828     17064606 :       (*at).DefDeclared = M2LexBuf_UnknownTokenNo;
    4829     17064606 :       (*at).ModDeclared = tok;
    4830              :     }
    4831     36078099 :   (*at).FirstUsed = tok;  /* we assign this field to something legal  */
    4832     36078099 : }
    4833              : 
    4834              : 
    4835              : /*
    4836              :    InitWhereDeclared - sets the Declared and FirstUsed fields of record, at.
    4837              : */
    4838              : 
    4839       579046 : static void InitWhereDeclared (SymbolTable_Where *at)
    4840              : {
    4841       579046 :   InitWhereDeclaredTok (M2LexBuf_GetTokenNo (), at);
    4842       579046 : }
    4843              : 
    4844              : 
    4845              : /*
    4846              :    InitWhereFirstUsed - sets the FirstUsed field of record, at.
    4847              : */
    4848              : 
    4849         3004 : static void InitWhereFirstUsed (SymbolTable_Where *at)
    4850              : {
    4851            0 :   InitWhereFirstUsedTok (M2LexBuf_GetTokenNo (), at);
    4852            0 : }
    4853              : 
    4854              : 
    4855              : /*
    4856              :    InitWhereFirstUsedTok - sets the FirstUsed field of record, at.
    4857              : */
    4858              : 
    4859     32037554 : static void InitWhereFirstUsedTok (unsigned int tok, SymbolTable_Where *at)
    4860              : {
    4861     32037554 :   (*at).FirstUsed = tok;
    4862      1145052 : }
    4863              : 
    4864              : 
    4865              : /*
    4866              :    gdbhook - a debugger convenience hook.
    4867              : */
    4868              : 
    4869            0 : static void gdbhook (void)
    4870              : {
    4871            0 : }
    4872              : 
    4873              : 
    4874              : /*
    4875              :    BreakWhenSymCreated - to be called interactively by gdb.
    4876              : */
    4877              : 
    4878        14952 : static void BreakWhenSymCreated (unsigned int sym)
    4879              : {
    4880        14952 :   BreakSym = sym;
    4881            0 : }
    4882              : 
    4883              : 
    4884              : /*
    4885              :    CheckBreak - if sym = BreakSym then call gdbhook.
    4886              : */
    4887              : 
    4888            0 : static void CheckBreak (unsigned int sym)
    4889              : {
    4890            0 :   if (sym == BreakSym)
    4891              :     {
    4892            0 :       gdbhook ();
    4893              :     }
    4894            0 : }
    4895              : 
    4896              : 
    4897              : /*
    4898              :    NewSym - Sets Sym to a new symbol index.
    4899              : */
    4900              : 
    4901     61454944 : static void NewSym (unsigned int *sym)
    4902              : {
    4903     61454944 :   SymbolTable_PtrToSymbol pSym;
    4904              : 
    4905     61454944 :   (*sym) = FreeSymbol;
    4906     61454944 :   Storage_ALLOCATE ((void **) &pSym, sizeof (SymbolTable_Symbol));
    4907     61454944 :   pSym->SymbolType = SymbolTable_DummySym;
    4908     61454944 :   Indexing_PutIndice (Symbols, (*sym), reinterpret_cast <void *> (pSym));
    4909     61454944 :   CheckBreak ((*sym));
    4910     61454944 :   FreeSymbol += 1;
    4911     61454944 :   M2Diagnostic_MemSet (SymMemDiag, 1, FreeSymbol-1);
    4912     61454944 :   M2Diagnostic_MemIncr (SymMemDiag, 2, sizeof ((*pSym)));
    4913     61454944 : }
    4914              : 
    4915              : 
    4916              : /*
    4917              :    GetPsym - returns the pointer to, sym.
    4918              : */
    4919              : 
    4920  15102775475 : static SymbolTable_PtrToSymbol GetPsym (unsigned int sym)
    4921              : {
    4922  15102775475 :   SymbolTable_PtrToSymbol pSym;
    4923              : 
    4924  15102775475 :   if (Indexing_InBounds (Symbols, sym))
    4925              :     {
    4926  15102775475 :       pSym = static_cast<SymbolTable_PtrToSymbol> (Indexing_GetIndice (Symbols, sym));
    4927  15102775475 :       return pSym;
    4928              :     }
    4929              :   else
    4930              :     {
    4931            0 :       M2Error_InternalError ((const char *) "symbol out of bounds", 20);
    4932              :     }
    4933              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    4934              :   __builtin_unreachable ();
    4935              : }
    4936              : 
    4937              : 
    4938              : /*
    4939              :    GetPcall - returns the pointer to the CallFrame.
    4940              : */
    4941              : 
    4942    410128364 : static SymbolTable_PtrToCallFrame GetPcall (unsigned int call)
    4943              : {
    4944    410128364 :   SymbolTable_PtrToCallFrame pCall;
    4945              : 
    4946    410128364 :   if (Indexing_InBounds (ScopeCallFrame, call))
    4947              :     {
    4948    410128364 :       pCall = static_cast<SymbolTable_PtrToCallFrame> (Indexing_GetIndice (ScopeCallFrame, call));
    4949    410128364 :       return pCall;
    4950              :     }
    4951              :   else
    4952              :     {
    4953            0 :       M2Error_InternalError ((const char *) "symbol out of bounds", 20);
    4954              :     }
    4955              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    4956              :   __builtin_unreachable ();
    4957              : }
    4958              : 
    4959              : 
    4960              : /*
    4961              :    DebugProcedureLineNumber -
    4962              : */
    4963              : 
    4964            0 : static void DebugProcedureLineNumber (unsigned int sym)
    4965              : {
    4966            0 :   unsigned int begin;
    4967            0 :   unsigned int end;
    4968            0 :   NameKey_Name n;
    4969            0 :   DynamicStrings_String f;
    4970            0 :   unsigned int l;
    4971              : 
    4972            0 :   SymbolTable_GetProcedureBeginEnd (sym, &begin, &end);
    4973            0 :   n = SymbolTable_GetSymName (sym);
    4974            0 :   if (begin != 0)
    4975              :     {
    4976            0 :       f = M2LexBuf_FindFileNameFromToken (begin, 0);
    4977            0 :       l = M2LexBuf_TokenToLineNo (begin, 0);
    4978            0 :       M2Printf_printf3 ((const char *) "%s:%d:%a:begin\\n", 16, (const unsigned char *) &f, (sizeof (f)-1), (const unsigned char *) &l, (sizeof (l)-1), (const unsigned char *) &n, (sizeof (n)-1));
    4979              :     }
    4980            0 :   if (end != 0)
    4981              :     {
    4982            0 :       f = M2LexBuf_FindFileNameFromToken (end, 0);
    4983            0 :       l = M2LexBuf_TokenToLineNo (end, 0);
    4984            0 :       M2Printf_printf3 ((const char *) "%s:%d:%a:end\\n", 14, (const unsigned char *) &f, (sizeof (f)-1), (const unsigned char *) &l, (sizeof (l)-1), (const unsigned char *) &n, (sizeof (n)-1));
    4985              :     }
    4986            0 : }
    4987              : 
    4988              : 
    4989              : /*
    4990              :    PutPartialUnbounded -
    4991              : */
    4992              : 
    4993            0 : static void PutPartialUnbounded (unsigned int sym, unsigned int type, unsigned int ndim)
    4994              : {
    4995            0 :   SymbolTable_PtrToSymbol pSym;
    4996              : 
    4997            0 :   pSym = GetPsym (sym);
    4998            0 :   if (SymbolTable_IsDummy (sym))
    4999              :     {
    5000            0 :       pSym->SymbolType = SymbolTable_PartialUnboundedSym;
    5001              :     }
    5002            0 :   switch (pSym->SymbolType)
    5003              :     {
    5004            0 :       case SymbolTable_PartialUnboundedSym:
    5005            0 :         pSym->PartialUnbounded.Type = type;
    5006            0 :         pSym->PartialUnbounded.NDim = ndim;
    5007            0 :         break;
    5008              : 
    5009              : 
    5010            0 :       default:
    5011            0 :         M2Error_InternalError ((const char *) "not expecting this type", 23);
    5012            0 :         break;
    5013              :     }
    5014            0 : }
    5015              : 
    5016              : 
    5017              : /*
    5018              :    AlreadyDeclaredError - generate an error message, a, and two areas of code showing
    5019              :                           the places where the symbols were declared.
    5020              : */
    5021              : 
    5022            0 : static void AlreadyDeclaredError (DynamicStrings_String s, NameKey_Name name, unsigned int OtherOccurance)
    5023              : {
    5024            0 :   M2Error_Error e;
    5025              : 
    5026            0 :   if ((OtherOccurance == 0) || (OtherOccurance == (M2LexBuf_GetTokenNo ())))
    5027              :     {
    5028            0 :       e = M2Error_NewError (M2LexBuf_GetTokenNo ());
    5029            0 :       M2Error_ErrorString (e, s);
    5030              :     }
    5031              :   else
    5032              :     {
    5033            0 :       e = M2Error_NewError (M2LexBuf_GetTokenNo ());
    5034            0 :       M2Error_ErrorString (e, s);
    5035            0 :       e = M2Error_ChainError (OtherOccurance, e);
    5036            0 :       M2Error_ErrorFormat1 (e, (const char *) "and symbol (%a) is also declared here", 37, (const unsigned char *) &name, (sizeof (name)-1));
    5037              :     }
    5038            0 : }
    5039              : 
    5040              : 
    5041              : /*
    5042              :    MakeObject - creates an object node.
    5043              : */
    5044              : 
    5045      7898340 : static unsigned int MakeObject (unsigned int tok, NameKey_Name name)
    5046              : {
    5047      7898340 :   SymbolTable_PtrToSymbol pSym;
    5048      7898340 :   unsigned int Sym;
    5049              : 
    5050      7898340 :   NewSym (&Sym);
    5051      7898340 :   pSym = GetPsym (Sym);
    5052      7898340 :   pSym->SymbolType = SymbolTable_ObjectSym;
    5053      7898340 :   pSym->Object.name = name;
    5054      7898340 :   InitWhereDeclaredTok (tok, &pSym->Object.At);
    5055      7898340 :   InitWhereFirstUsedTok (tok, &pSym->Object.At);
    5056      7898340 :   return Sym;
    5057              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5058              :   __builtin_unreachable ();
    5059              : }
    5060              : 
    5061              : 
    5062              : /*
    5063              :    DeclareSym - returns a symbol which was either in the unknown tree or
    5064              :                 a New symbol, since name is about to be declared.
    5065              : */
    5066              : 
    5067     24510932 : static unsigned int DeclareSym (unsigned int tok, NameKey_Name name)
    5068              : {
    5069     24510932 :   unsigned int Sym;
    5070              : 
    5071     24510932 :   if (name == NameKey_NulName)
    5072              :     {
    5073      5448282 :       NewSym (&Sym);
    5074              :     }
    5075     19062650 :   else if (IsAlreadyDeclaredSym (name))
    5076              :     {
    5077              :       /* avoid dangling else.  */
    5078           36 :       Sym = SymbolTable_GetSym (name);
    5079           36 :       if (SymbolTable_IsImported (SymbolTable_GetCurrentModuleScope (), Sym))
    5080              :         {
    5081              :           /* avoid dangling else.  */
    5082            6 :           M2MetaError_MetaErrorT1 (GetWhereImported (Sym), (const char *) "symbol {%1Rad} is already present in this scope, check both definition and implementation modules, use a different name or remove the import", 140, Sym);
    5083            6 :           M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
    5084            6 :           if (Sym != (GetVisibleSym (name)))
    5085              :             {
    5086            0 :               M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
    5087              :             }
    5088              :         }
    5089              :       else
    5090              :         {
    5091           30 :           M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1RMad} is already declared in this scope, use a different name or remove the declaration", 97, Sym);
    5092           30 :           M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1Cad} also declared in this module", 43, Sym);
    5093           30 :           if (Sym != (GetVisibleSym (name)))
    5094              :             {
    5095            0 :               M2MetaError_MetaErrorT1 (tok, (const char *) "symbol {%1CMad} also declared in this module", 44, GetVisibleSym (name));
    5096              :             }
    5097              :         }
    5098           36 :       Sym = SymbolTable_MakeError (tok, name);
    5099              :     }
    5100              :   else
    5101              :     {
    5102              :       /* avoid dangling else.  */
    5103     19062614 :       Sym = FetchUnknownSym (name);
    5104     19062614 :       if (Sym == SymbolTable_NulSym)
    5105              :         {
    5106     14427494 :           NewSym (&Sym);
    5107              :         }
    5108     19062614 :       CheckForExportedDeclaration (Sym);
    5109              :     }
    5110     24510932 :   return Sym;
    5111              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5112              :   __builtin_unreachable ();
    5113              : }
    5114              : 
    5115              : 
    5116              : /*
    5117              :    Init - Initializes the data structures and variables in this module.
    5118              :           Initialize the trees.
    5119              : */
    5120              : 
    5121        14952 : static void Init (void)
    5122              : {
    5123        14952 :   SymbolTable_PtrToCallFrame pCall;
    5124              : 
    5125        14952 :   SymMemDiag = M2Diagnostic_InitMemDiagnostic ((const char *) "SymbolTable:Symbols", 19, (const char *) "{0N} total symbols {1d} consuming {2M} ram {0M} ({2P})", 54);
    5126        14952 :   BreakWhenSymCreated (SymbolTable_NulSym);
    5127              :   /* To examine the symbol table when a symbol is created run cc1gm2 from gdb
    5128              :       and set a break point on gdbhook.
    5129              :       (gdb) break gdbhook
    5130              :       (gdb) run
    5131              :       Now below interactively call BreakWhenSymCreated with the symbol
    5132              :       under investigation.  */
    5133        14952 :   gdbhook ();
    5134              :   /* Now is the time to interactively call gdb, for example:
    5135              :       (gdb) print BreakWhenSymCreated (1234)
    5136              :       (gdb) cont
    5137              :       and you will arrive at gdbhook when this symbol is created.  */
    5138        14952 :   AnonymousName = 0;
    5139        14952 :   CurrentError = static_cast<M2Error_Error> (NULL);
    5140        14952 :   SymbolKey_InitTree (&ConstLitPoolTree);
    5141        14952 :   SymbolKey_InitTree (&DefModuleTree);
    5142        14952 :   SymbolKey_InitTree (&ModuleTree);
    5143        14952 :   Symbols = Indexing_InitIndexTuned (1, (1024*1024) / 16, 16);
    5144        14952 :   ConstLitArray = Indexing_InitIndex (1);
    5145        14952 :   FreeSymbol = 1;
    5146        14952 :   ScopePtr = 1;
    5147        14952 :   ScopeCallFrame = Indexing_InitIndex (1);
    5148        14952 :   Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
    5149        14952 :   pCall->Main = SymbolTable_NulSym;
    5150        14952 :   pCall->Search = SymbolTable_NulSym;
    5151        14952 :   Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
    5152        14952 :   CurrentModule = SymbolTable_NulSym;
    5153        14952 :   MainModule = SymbolTable_NulSym;
    5154        14952 :   FileModule = SymbolTable_NulSym;
    5155        14952 :   TemporaryNo = 0;
    5156              :   /* 
    5157              :    InitList(FreeFVarientList) ;              Lists used to maintain GC of field 
    5158              :    InitList(UsedFVarientList) ;              varients.                          
    5159              :   */
    5160        14952 :   Lists_InitList (&UnresolvedConstructorType);
    5161        14952 :   M2Base_InitBase (m2linemap_BuiltinsLocation (), &BaseModule);
    5162        14952 :   SymbolTable_StartScope (BaseModule);  /* BaseModule scope placed at the bottom of the stack  */
    5163        14952 :   BaseScopePtr = ScopePtr;  /* BaseScopePtr points to the top of the BaseModule scope  */
    5164        14952 :   Lists_InitList (&AddressTypes);  /* BaseScopePtr points to the top of the BaseModule scope  */
    5165        14952 :   ReportedUnknowns = Sets_InitSet (1);
    5166        14952 : }
    5167              : 
    5168              : 
    5169              : /*
    5170              :    AddSymToUnknown -
    5171              : */
    5172              : 
    5173     10587665 : static void AddSymToUnknown (unsigned int scope, NameKey_Name name, unsigned int Sym)
    5174              : {
    5175     10587665 :   SymbolTable_PtrToSymbol pSym;
    5176     10587665 :   NameKey_Name n;
    5177              : 
    5178     10587665 :   if (DebugUnknowns)
    5179              :     {
    5180              :       n = SymbolTable_GetSymName (scope);
    5181              :       M2Printf_printf3 ((const char *) "adding unknown %a (%d) to scope %a\\n", 36, (const unsigned char *) &name, (sizeof (name)-1), (const unsigned char *) &Sym, (sizeof (Sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5182              :     }
    5183              :   /* Add symbol to unknown tree  */
    5184     10587665 :   pSym = GetPsym (scope);
    5185     10587665 :   switch (pSym->SymbolType)
    5186              :     {
    5187     10577575 :       case SymbolTable_DefImpSym:
    5188     10577575 :         SymbolKey_PutSymKey (pSym->DefImp.Unresolved, name, Sym);
    5189     10577575 :         break;
    5190              : 
    5191        10090 :       case SymbolTable_ModuleSym:
    5192        10090 :         SymbolKey_PutSymKey (pSym->Module.Unresolved, name, Sym);
    5193        10090 :         break;
    5194              : 
    5195            0 :       case SymbolTable_ProcedureSym:
    5196            0 :         SymbolKey_PutSymKey (pSym->Procedure.Unresolved, name, Sym);
    5197            0 :         break;
    5198              : 
    5199              : 
    5200            0 :       default:
    5201            0 :         M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
    5202     10587665 :         break;
    5203              :     }
    5204     10587665 : }
    5205              : 
    5206              : 
    5207              : /*
    5208              :    AddSymToUnknownTree - adds a symbol with name, name, and Sym to the
    5209              :                          unknown tree.
    5210              : */
    5211              : 
    5212     10587647 : static void AddSymToUnknownTree (int ScopeId, NameKey_Name name, unsigned int Sym)
    5213              : {
    5214     10587647 :   SymbolTable_PtrToCallFrame pCall;
    5215     10587647 :   unsigned int ScopeSym;
    5216              : 
    5217     10587647 :   if (ScopeId > 0)
    5218              :     {
    5219              :       /* choose to place the unknown symbol in the first module scope
    5220              :          outside the current scope  */
    5221     10588337 :       do {
    5222     10588337 :         pCall = GetPcall (static_cast<unsigned int> (ScopeId));
    5223     10588337 :         ScopeSym = pCall->Main;
    5224     10588337 :         if ((ScopeSym > 0) && ((SymbolTable_IsDefImp (ScopeSym)) || (SymbolTable_IsModule (ScopeSym))))
    5225              :           {
    5226     10587647 :             AddSymToUnknown (ScopeSym, name, Sym);
    5227     10587647 :             return;
    5228              :           }
    5229          690 :         ScopeId -= 1;
    5230          690 :       } while (! (ScopeId == 0));
    5231              :     }
    5232            0 :   AddSymToUnknown (CurrentModule, name, Sym);
    5233              : }
    5234              : 
    5235              : 
    5236              : /*
    5237              :    SubSymFromUnknownTree - removes a symbol with name, name, from the
    5238              :                            unknown tree.
    5239              : */
    5240              : 
    5241      4635126 : static void SubSymFromUnknownTree (NameKey_Name name)
    5242              : {
    5243      4635126 :   SymbolTable_PtrToCallFrame pCall;
    5244      4635126 :   unsigned int ScopeSym;
    5245      4635126 :   unsigned int ScopeId;
    5246              : 
    5247      4635126 :   if (ScopePtr > 0)
    5248              :     {
    5249              :       ScopeId = ScopePtr;
    5250      5974377 :       do {
    5251      5974377 :         pCall = GetPcall (ScopeId);
    5252      5974377 :         ScopeSym = pCall->Search;
    5253      5974377 :         if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
    5254              :           {
    5255      4635744 :             if (RemoveFromUnresolvedTree (ScopeSym, name))
    5256              :               {
    5257              :                 return;
    5258              :               }
    5259              :           }
    5260      1339251 :         ScopeId -= 1;
    5261      2678502 :       } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
    5262              :     }
    5263            0 :   if (RemoveFromUnresolvedTree (CurrentModule, name))
    5264              :     {}  /* empty.  */
    5265              : }
    5266              : 
    5267              : 
    5268              : /*
    5269              :    GetSymFromUnknownTree - returns a symbol with name, name, from the
    5270              :                            unknown tree.
    5271              :                            If no symbol with name is found then NulSym
    5272              :                            is returned.
    5273              : */
    5274              : 
    5275     29650461 : static unsigned int GetSymFromUnknownTree (NameKey_Name name)
    5276              : {
    5277     29650461 :   SymbolTable_PtrToCallFrame pCall;
    5278     29650461 :   unsigned int ScopeSym;
    5279     29650461 :   unsigned int ScopeId;
    5280     29650461 :   unsigned int Sym;
    5281              : 
    5282     29650461 :   if (ScopePtr > 0)
    5283              :     {
    5284              :       ScopeId = ScopePtr;
    5285     48346246 :       do {
    5286     48346246 :         pCall = GetPcall (ScopeId);
    5287     48346246 :         ScopeSym = pCall->Search;
    5288     48346246 :         if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym)))
    5289              :           {
    5290     40853660 :             Sym = ExamineUnresolvedTree (ScopeSym, name);
    5291     40853660 :             if (Sym != SymbolTable_NulSym)
    5292              :               {
    5293              :                 return Sym;
    5294              :               }
    5295              :           }
    5296     43711120 :         ScopeId -= 1;
    5297     87422240 :       } while (! ((ScopeId > 0) && ((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym)))));
    5298              :     }
    5299              :   /* Get symbol from unknown tree  */
    5300     25015335 :   return ExamineUnresolvedTree (CurrentModule, name);
    5301              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5302              :   __builtin_unreachable ();
    5303              : }
    5304              : 
    5305              : 
    5306              : /*
    5307              :    ExamineUnresolvedTree - returns a symbol with name, name, from the
    5308              :                            unresolved tree of module, ModSym.
    5309              :                            If no symbol with name is found then NulSym
    5310              :                            is returned.
    5311              : */
    5312              : 
    5313    138164352 : static unsigned int ExamineUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
    5314              : {
    5315    138164352 :   SymbolTable_PtrToSymbol pSym;
    5316    138164352 :   unsigned int Sym;
    5317              : 
    5318              :   /* Get symbol from unknown tree  */
    5319    138164352 :   pSym = GetPsym (ScopeSym);
    5320    138164352 :   switch (pSym->SymbolType)
    5321              :     {
    5322     83001010 :       case SymbolTable_DefImpSym:
    5323     83001010 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name));
    5324     83001010 :         break;
    5325              : 
    5326     14074359 :       case SymbolTable_ModuleSym:
    5327     14074359 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, name));
    5328     14074359 :         break;
    5329              : 
    5330     41088983 :       case SymbolTable_ProcedureSym:
    5331     41088983 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name));
    5332     41088983 :         break;
    5333              : 
    5334              : 
    5335            0 :       default:
    5336            0 :         M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
    5337    138164352 :         break;
    5338              :     }
    5339    138164352 :   return Sym;
    5340              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5341              :   __builtin_unreachable ();
    5342              : }
    5343              : 
    5344              : 
    5345              : /*
    5346              :    RemoveFromUnresolvedTree - removes a symbol with name, name, from the
    5347              :                               unresolved tree of symbol, ScopeSym.
    5348              : */
    5349              : 
    5350      4635744 : static bool RemoveFromUnresolvedTree (unsigned int ScopeSym, NameKey_Name name)
    5351              : {
    5352      4635744 :   SymbolTable_PtrToSymbol pSym;
    5353              : 
    5354              :   /* Get symbol from unknown tree  */
    5355      4635744 :   pSym = GetPsym (ScopeSym);
    5356      4635744 :   switch (pSym->SymbolType)
    5357              :     {
    5358      4625191 :       case SymbolTable_DefImpSym:
    5359      4625191 :         if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) != SymbolKey_NulKey)
    5360              :           {
    5361      4625191 :             SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
    5362      4625191 :             return true;
    5363              :           }
    5364              :         break;
    5365              : 
    5366         9917 :       case SymbolTable_ModuleSym:
    5367         9917 :         if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) != SymbolKey_NulKey)
    5368              :           {
    5369         9917 :             SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
    5370         9917 :             return true;
    5371              :           }
    5372              :         break;
    5373              : 
    5374          636 :       case SymbolTable_ProcedureSym:
    5375          636 :         if ((SymbolKey_GetSymKey (pSym->Procedure.Unresolved, name)) != SymbolKey_NulKey)
    5376              :           {
    5377           18 :             SymbolKey_DelSymKey (pSym->Procedure.Unresolved, name);
    5378           18 :             return true;
    5379              :           }
    5380              :         break;
    5381              : 
    5382              : 
    5383            0 :       default:
    5384            0 :         M2Error_InternalError ((const char *) "expecting DefImp, Module or Procedure symbol", 44);
    5385              :         break;
    5386              :     }
    5387              :   return false;
    5388              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5389              :   __builtin_unreachable ();
    5390              : }
    5391              : 
    5392              : 
    5393              : /*
    5394              :    FetchUnknownSym - returns a symbol from the unknown tree if one is
    5395              :                      available. It also updates the unknown tree.
    5396              : */
    5397              : 
    5398     19062814 : static unsigned int FetchUnknownSym (NameKey_Name name)
    5399              : {
    5400     19062814 :   unsigned int Sym;
    5401              : 
    5402     19062814 :   Sym = GetSymFromUnknownTree (name);
    5403     19062814 :   if (Sym != SymbolTable_NulSym)
    5404              :     {
    5405      4635126 :       SubSymFromUnknownTree (name);
    5406              :     }
    5407     19062814 :   return Sym;
    5408              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5409              :   __builtin_unreachable ();
    5410              : }
    5411              : 
    5412              : 
    5413              : /*
    5414              :    TransparentScope - returns true is the scope symbol Sym is allowed
    5415              :                       to look to an outer level for a symbol.
    5416              :                       ie is the symbol allowed to look to the parent
    5417              :                       scope for a symbol.
    5418              : */
    5419              : 
    5420    114273504 : static bool TransparentScope (unsigned int Sym)
    5421              : {
    5422    114273504 :   SymbolTable_PtrToSymbol pSym;
    5423              : 
    5424    114273504 :   pSym = GetPsym (Sym);
    5425    114273504 :   return (pSym->SymbolType != SymbolTable_DefImpSym) && (pSym->SymbolType != SymbolTable_ModuleSym);
    5426              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5427              :   __builtin_unreachable ();
    5428              : }
    5429              : 
    5430              : 
    5431              : /*
    5432              :    GetLastModuleOrProcedureScope - returns the last module or procedure scope encountered,
    5433              :                                    the scope before the current module scope.
    5434              : */
    5435              : 
    5436          276 : static unsigned int GetLastModuleOrProcedureScope (void)
    5437              : {
    5438          276 :   SymbolTable_PtrToCallFrame pCall;
    5439          276 :   unsigned int i;
    5440              : 
    5441              :   /* find current inner module  */
    5442          276 :   i = ScopePtr;
    5443          276 :   pCall = GetPcall (i);
    5444          552 :   while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
    5445              :     {
    5446            0 :       M2Debug_Assert (i > 0);
    5447            0 :       i -= 1;
    5448            0 :       pCall = GetPcall (i);
    5449              :     }
    5450              :   /* found module at position, i.  */
    5451          276 :   i -= 1;  /* Move to an outer level module or procedure scope  */
    5452          276 :   pCall = GetPcall (i);  /* Move to an outer level module or procedure scope  */
    5453          552 :   while (((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search)))) && (! (SymbolTable_IsProcedure (pCall->Search))))
    5454              :     {
    5455            0 :       M2Debug_Assert (i > 0);
    5456            0 :       i -= 1;
    5457            0 :       pCall = GetPcall (i);
    5458              :     }
    5459              :   /* Found module at position, i.  */
    5460          276 :   return pCall->Search;
    5461              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5462              :   __builtin_unreachable ();
    5463              : }
    5464              : 
    5465              : 
    5466              : /*
    5467              :    AddSymToScope - adds a symbol Sym with name name to
    5468              :                    the current scope symbol tree.
    5469              : */
    5470              : 
    5471     24017471 : static void AddSymToScope (unsigned int Sym, NameKey_Name name)
    5472              : {
    5473     24017471 :   SymbolTable_PtrToSymbol pSym;
    5474     24017471 :   SymbolTable_PtrToCallFrame pCall;
    5475     24017471 :   unsigned int ScopeId;
    5476              : 
    5477     24017471 :   pCall = GetPcall (ScopePtr);
    5478     24017471 :   ScopeId = pCall->Main;
    5479              :   /* 
    5480              :       WriteString('Adding ') ; WriteKey(name) ; WriteString(' :') ; WriteCard(Sym, 4) ; WriteString(' to scope: ') ;
    5481              :       WriteKey(GetSymName(ScopeId)) ; WriteLn ;
    5482              :   */
    5483     24017471 :   pSym = GetPsym (ScopeId);
    5484     24017471 :   switch (pSym->SymbolType)
    5485              :     {
    5486     10371657 :       case SymbolTable_DefImpSym:
    5487     10371657 :         if (name != NameKey_NulName)
    5488              :           {
    5489      5922577 :             SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, name, Sym);
    5490              :           }
    5491     10371657 :         if (SymbolTable_IsEnumeration (Sym))
    5492              :           {
    5493        33185 :             CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
    5494              :           }
    5495              :         break;
    5496              : 
    5497      2288942 :       case SymbolTable_ModuleSym:
    5498      2288942 :         if (name != NameKey_NulName)
    5499              :           {
    5500      1488716 :             SymbolKey_PutSymKey (pSym->Module.LocalSymbols, name, Sym);
    5501              :           }
    5502      2288942 :         if (SymbolTable_IsEnumeration (Sym))
    5503              :           {
    5504        15930 :             CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
    5505              :           }
    5506              :         break;
    5507              : 
    5508     11356872 :       case SymbolTable_ProcedureSym:
    5509     11356872 :         if (name != NameKey_NulName)
    5510              :           {
    5511     11157896 :             SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, name, Sym);
    5512              :           }
    5513     11356872 :         if (SymbolTable_IsEnumeration (Sym))
    5514              :           {
    5515            0 :             CheckEnumerationInList (pSym->Procedure.EnumerationScopeList, Sym);
    5516              :           }
    5517              :         break;
    5518              : 
    5519              : 
    5520            0 :       default:
    5521            0 :         M2Error_InternalError ((const char *) "should never get here", 21);
    5522     24017471 :         break;
    5523              :     }
    5524     24017471 : }
    5525              : 
    5526              : 
    5527              : /*
    5528              :    PlaceMajorScopesEnumerationListOntoStack - places the DefImp, Module and
    5529              :                                               Procedure symbols enumeration
    5530              :                                               list onto the scope stack.
    5531              : */
    5532              : 
    5533     31096624 : static void PlaceMajorScopesEnumerationListOntoStack (unsigned int Sym)
    5534              : {
    5535     31096624 :   SymbolTable_PtrToSymbol pSym;
    5536              : 
    5537     31096624 :   pSym = GetPsym (Sym);
    5538     31096624 :   switch (pSym->SymbolType)
    5539              :     {
    5540     10093933 :       case SymbolTable_DefImpSym:
    5541     10093933 :         PlaceEnumerationListOntoScope (pSym->DefImp.EnumerationScopeList);
    5542     10093933 :         break;
    5543              : 
    5544        78441 :       case SymbolTable_ModuleSym:
    5545        78441 :         PlaceEnumerationListOntoScope (pSym->Module.EnumerationScopeList);
    5546        78441 :         break;
    5547              : 
    5548     20924249 :       case SymbolTable_ProcedureSym:
    5549     20924249 :         PlaceEnumerationListOntoScope (pSym->Procedure.EnumerationScopeList);
    5550     20924249 :         break;
    5551              : 
    5552              : 
    5553            1 :       default:
    5554            1 :         M2Error_InternalError ((const char *) "expecting - DefImp, Module or Procedure symbol", 46);
    5555     31096623 :         break;
    5556              :     }
    5557     31096623 : }
    5558              : 
    5559              : 
    5560              : /*
    5561              :    PlaceEnumerationListOntoScope - places an enumeration list, l, onto the
    5562              :                                    scope stack. This list will automatically
    5563              :                                    removed via one call to EndScope which
    5564              :                                    matches the StartScope by which this
    5565              :                                    procedure is invoked.
    5566              : */
    5567              : 
    5568     31096623 : static void PlaceEnumerationListOntoScope (Lists_List l)
    5569              : {
    5570     31096623 :   unsigned int i;
    5571     31096623 :   unsigned int n;
    5572              : 
    5573     31096623 :   n = Lists_NoOfItemsInList (l);
    5574     31096623 :   i = 1;
    5575     62768423 :   while (i <= n)
    5576              :     {
    5577       575177 :       SymbolTable_PseudoScope (Lists_GetItemFromList (l, i));
    5578       575177 :       i += 1;
    5579              :     }
    5580     31096623 : }
    5581              : 
    5582              : 
    5583              : /*
    5584              :    SetFirstUsed - assigns the FirstUsed field in at to tok providing
    5585              :                   it has not already been set.
    5586              : */
    5587              : 
    5588           33 : static void SetFirstUsed (unsigned int tok, SymbolTable_Where *at)
    5589              : {
    5590            0 :   if ((*at).FirstUsed == M2LexBuf_UnknownTokenNo)
    5591              :     {
    5592            0 :       (*at).FirstUsed = tok;
    5593              :     }
    5594            0 : }
    5595              : 
    5596              : 
    5597              : /*
    5598              :    PutFirstUsed - sets tok to the first used providing it has not already been set.
    5599              :                   It also includes the read and write quad into the usage list
    5600              :                   providing the quad numbers are not 0.
    5601              : */
    5602              : 
    5603           36 : static void PutFirstUsed (unsigned int object, unsigned int tok, unsigned int read_, unsigned int write_)
    5604              : {
    5605           36 :   SymbolTable_PtrToSymbol pSym;
    5606              : 
    5607           36 :   if (SymbolTable_IsVar (object))
    5608              :     {
    5609           33 :       pSym = GetPsym (object);
    5610           33 :       SetFirstUsed (tok, &pSym->Var.At);
    5611           33 :       if (read_ != 0)
    5612              :         {
    5613           18 :           SymbolTable_PutReadQuad (object, SymbolTable_GetMode (object), read_);
    5614              :         }
    5615           33 :       if (write_ != 0)
    5616              :         {
    5617           15 :           SymbolTable_PutWriteQuad (object, SymbolTable_GetMode (object), write_);
    5618              :         }
    5619              :     }
    5620           36 : }
    5621              : 
    5622              : 
    5623              : /*
    5624              :    CanLookThroughScope - by default this procedure returns TRUE.  It only returns
    5625              :                          FALSE if, throughProcedure, is FALSE and the ScopeSym is
    5626              :                          a procedure.
    5627              : */
    5628              : 
    5629     76114380 : static bool CanLookThroughScope (unsigned int ScopeSym, bool throughProcedure)
    5630              : {
    5631     76114380 :   if (SymbolTable_IsProcedure (ScopeSym))
    5632              :     {
    5633              :       return throughProcedure;
    5634              :     }
    5635              :   else
    5636              :     {
    5637            0 :       return true;
    5638              :     }
    5639              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5640              :   __builtin_unreachable ();
    5641              : }
    5642              : 
    5643              : 
    5644              : /*
    5645              :    GetScopeSym - searches the current scope and below, providing that the
    5646              :                  scopes are transparent, for a symbol with name, name.
    5647              :                  It only passes over procedure scopes if, throughProcedure,
    5648              :                  is TRUE.
    5649              : */
    5650              : 
    5651    105185303 : static unsigned int GetScopeSym (NameKey_Name name, bool throughProcedure)
    5652              : {
    5653    105185303 :   SymbolTable_PtrToCallFrame pCall;
    5654    105185303 :   unsigned int ScopeSym;
    5655    105185303 :   unsigned int ScopeId;
    5656    105185303 :   unsigned int Sym;
    5657              : 
    5658              :   /* DisplayScopes ;  */
    5659    105185303 :   ScopeId = ScopePtr;
    5660    105185303 :   pCall = GetPcall (ScopeId);
    5661    105185303 :   ScopeSym = pCall->Search;
    5662              :   /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym)) ;  */
    5663    105185303 :   Sym = CheckScopeForSym (ScopeSym, name);
    5664    430644034 :   while ((((ScopeId > 0) && (Sym == SymbolTable_NulSym)) && (TransparentScope (ScopeSym))) && (CanLookThroughScope (ScopeSym, throughProcedure)))
    5665              :     {
    5666     76114380 :       ScopeId -= 1;
    5667     76114380 :       pCall = GetPcall (ScopeId);
    5668     76114380 :       ScopeSym = pCall->Search;
    5669     76114380 :       Sym = CheckScopeForSym (ScopeSym, name);
    5670              :     }
    5671              :   /* WriteString(' scope: ') ; WriteKey(GetSymName(ScopeSym))  */
    5672              :   /* IF Sym#NulSym THEN WriteKey(GetSymName(Sym)) END ; WriteLn ;  */
    5673    105185303 :   return Sym;
    5674              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5675              :   __builtin_unreachable ();
    5676              : }
    5677              : 
    5678              : 
    5679              : /*
    5680              :    CheckScopeForSym - checks the scope, ScopeSym, for an identifier
    5681              :                       of name, name. CheckScopeForSym checks for
    5682              :                       the symbol by the GetLocalSym and also
    5683              :                       ExamineUnresolvedTree.
    5684              : */
    5685              : 
    5686    181299931 : static unsigned int CheckScopeForSym (unsigned int ScopeSym, NameKey_Name name)
    5687              : {
    5688    181299931 :   unsigned int Sym;
    5689              : 
    5690    181299931 :   Sym = SymbolTable_GetLocalSym (ScopeSym, name);
    5691    181299931 :   if ((Sym == SymbolTable_NulSym) && (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsDefImp (ScopeSym))) || (SymbolTable_IsProcedure (ScopeSym))))
    5692              :     {
    5693     72295221 :       Sym = ExamineUnresolvedTree (ScopeSym, name);
    5694              :     }
    5695    181299931 :   return Sym;
    5696              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5697              :   __builtin_unreachable ();
    5698              : }
    5699              : 
    5700              : 
    5701              : /*
    5702              :    GetModuleScopeId - returns the scope index to the next module starting
    5703              :                       at index, Id.
    5704              :                       Id will either point to a null scope (NulSym) or
    5705              :                       alternatively point to a Module or DefImp symbol.
    5706              : */
    5707              : 
    5708       135824 : static unsigned int GetModuleScopeId (unsigned int Id)
    5709              : {
    5710       135824 :   SymbolTable_PtrToCallFrame pCall;
    5711       135824 :   unsigned int s;
    5712              : 
    5713       135824 :   pCall = GetPcall (Id);
    5714       135824 :   s = pCall->Search;
    5715       225602 :   while (((Id > 0) && (s != SymbolTable_NulSym)) && ((! (SymbolTable_IsModule (s))) && (! (SymbolTable_IsDefImp (s)))))
    5716              :     {
    5717        89778 :       Id -= 1;
    5718        89778 :       pCall = GetPcall (Id);
    5719        89778 :       s = pCall->Search;
    5720              :     }
    5721       135824 :   return Id;
    5722              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5723              :   __builtin_unreachable ();
    5724              : }
    5725              : 
    5726              : 
    5727              : /*
    5728              :    GetVisibleSym -
    5729              : */
    5730              : 
    5731           36 : static unsigned int GetVisibleSym (NameKey_Name name)
    5732              : {
    5733           36 :   SymbolTable_PtrToCallFrame pCall;
    5734           36 :   unsigned int Sym;
    5735           36 :   unsigned int i;
    5736              : 
    5737           36 :   i = ScopePtr;
    5738           42 :   while (i >= 1)
    5739              :     {
    5740           42 :       pCall = GetPcall (i);
    5741           42 :       if (pCall->Search == pCall->Main)
    5742              :         {
    5743           30 :           return SymbolTable_GetLocalSym (pCall->Main, name);
    5744              :         }
    5745              :       else
    5746              :         {
    5747           12 :           if (SymbolTable_IsEnumeration (pCall->Search))
    5748              :             {
    5749           12 :               Sym = SymbolTable_GetLocalSym (pCall->Search, name);
    5750           12 :               if (Sym != SymbolTable_NulSym)
    5751              :                 {
    5752              :                   return Sym;
    5753              :                 }
    5754              :             }
    5755              :         }
    5756            6 :       i -= 1;
    5757              :     }
    5758              :   return SymbolTable_NulSym;
    5759              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5760              :   __builtin_unreachable ();
    5761              : }
    5762              : 
    5763              : 
    5764              : /*
    5765              :    IsAlreadyDeclaredSym - returns true if Sym has already been declared
    5766              :                           in the current main scope.
    5767              : */
    5768              : 
    5769     19062650 : static bool IsAlreadyDeclaredSym (NameKey_Name name)
    5770              : {
    5771     19062650 :   SymbolTable_PtrToCallFrame pCall;
    5772     19062650 :   unsigned int i;
    5773              : 
    5774     19062650 :   i = ScopePtr;
    5775     21957336 :   while (i >= 1)
    5776              :     {
    5777     21957336 :       pCall = GetPcall (i);
    5778     21957336 :       if (pCall->Search == pCall->Main)
    5779              :         {
    5780     19062644 :           return (SymbolTable_GetLocalSym (pCall->Main, name)) != SymbolTable_NulSym;
    5781              :         }
    5782              :       else
    5783              :         {
    5784      2894692 :           if ((SymbolTable_IsEnumeration (pCall->Search)) && ((SymbolTable_GetLocalSym (pCall->Search, name)) != SymbolTable_NulSym))
    5785              :             {
    5786              :               return true;
    5787              :             }
    5788              :         }
    5789      2894686 :       i -= 1;
    5790              :     }
    5791              :   return false;
    5792              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5793              :   __builtin_unreachable ();
    5794              : }
    5795              : 
    5796              : 
    5797              : /*
    5798              :    GenName - returns a new name consisting of pre, name, post concatenation.
    5799              : */
    5800              : 
    5801       407120 : static NameKey_Name GenName (NameKey_Name libname, const char *pre_, unsigned int _pre_high, NameKey_Name name, const char *post_, unsigned int _post_high)
    5802              : {
    5803       407120 :   DynamicStrings_String str;
    5804       407120 :   NameKey_Name result;
    5805       407120 :   char pre[_pre_high+1];
    5806       407120 :   char post[_post_high+1];
    5807              : 
    5808              :   /* make a local copy of each unbounded array.  */
    5809       407120 :   memcpy (pre, pre_, _pre_high+1);
    5810       407120 :   memcpy (post, post_, _post_high+1);
    5811              : 
    5812       407120 :   str = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (libname));
    5813       407120 :   str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) pre, _pre_high)));
    5814       407120 :   str = DynamicStrings_ConCat (str, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
    5815       407120 :   str = DynamicStrings_ConCat (str, DynamicStrings_InitString ((const char *) post, _post_high));
    5816       407120 :   result = NameKey_makekey (DynamicStrings_string (str));
    5817       407120 :   str = DynamicStrings_KillString (str);
    5818       407120 :   return result;
    5819              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5820              :   __builtin_unreachable ();
    5821       407120 : }
    5822              : 
    5823              : 
    5824              : /*
    5825              :    InitCtor - initialize the ModuleCtor fields to NulSym.
    5826              : */
    5827              : 
    5828       200451 : static void InitCtor (SymbolTable_ModuleCtor *ctor)
    5829              : {
    5830       200451 :   (*ctor).ctor = SymbolTable_NulSym;
    5831       200451 :   (*ctor).dep = SymbolTable_NulSym;
    5832       200451 :   (*ctor).init = SymbolTable_NulSym;
    5833       200451 :   (*ctor).fini = SymbolTable_NulSym;
    5834            0 : }
    5835              : 
    5836              : 
    5837              : /*
    5838              :    InitCtorFields - initialize the ModuleCtor fields.  An inner module has no
    5839              :                     ctor procedure.
    5840              : */
    5841              : 
    5842        82934 : static void InitCtorFields (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym, SymbolTable_ModuleCtor *ctor, NameKey_Name name, bool inner, bool pub)
    5843              : {
    5844        82934 :   if (M2Options_ScaffoldDynamic && ! inner)
    5845              :     {
    5846              :       /* The ctor procedure must be public.  */
    5847        82198 :       (*ctor).ctor = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_ctor", 5));
    5848        82198 :       SymbolTable_PutCtor ((*ctor).ctor, true);
    5849        82198 :       M2Debug_Assert (pub);
    5850        82198 :       SymbolTable_PutPublic ((*ctor).ctor, pub);
    5851        82198 :       SymbolTable_PutExtern ((*ctor).ctor, ! pub);
    5852        82198 :       SymbolTable_PutMonoName ((*ctor).ctor, true);
    5853              :       /* The dep procedure is local to the module.  */
    5854        82198 :       (*ctor).dep = SymbolTable_MakeProcedure (moduleTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_dep", 4));
    5855        82198 :       SymbolTable_PutMonoName ((*ctor).dep, true);
    5856              :     }
    5857              :   else
    5858              :     {
    5859          736 :       (*ctor).ctor = SymbolTable_NulSym;
    5860          736 :       (*ctor).dep = SymbolTable_NulSym;
    5861              :     }
    5862              :   /* The init/fini procedures must be public.  */
    5863        82934 :   (*ctor).init = SymbolTable_MakeProcedure (beginTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_init", 5));
    5864        82934 :   SymbolTable_PutPublic ((*ctor).init, pub);
    5865        82934 :   SymbolTable_PutExtern ((*ctor).init, ! pub);
    5866        82934 :   SymbolTable_PutMonoName ((*ctor).init, ! inner);
    5867        82934 :   M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).init);
    5868        82934 :   (*ctor).fini = SymbolTable_MakeProcedure (finallyTok, GenName (SymbolTable_GetLibName (moduleSym), (const char *) "_M2_", 4, name, (const char *) "_fini", 5));
    5869        82934 :   SymbolTable_PutPublic ((*ctor).fini, pub);
    5870        82934 :   SymbolTable_PutExtern ((*ctor).fini, ! pub);
    5871        82934 :   SymbolTable_PutMonoName ((*ctor).fini, ! inner);
    5872        82934 :   M2Scaffold_DeclareArgEnvParams (beginTok, (*ctor).fini);
    5873        82934 : }
    5874              : 
    5875              : 
    5876              : /*
    5877              :    CheckTok - checks to see that tok is at a known location.  If not
    5878              :               it uses GetTokenNo as a fall back.
    5879              : */
    5880              : 
    5881     23821479 : static unsigned int CheckTok (unsigned int tok, const char *name_, unsigned int _name_high)
    5882              : {
    5883     23821479 :   DynamicStrings_String s;
    5884     23821479 :   char name[_name_high+1];
    5885              : 
    5886              :   /* make a local copy of each unbounded array.  */
    5887     23821479 :   memcpy (name, name_, _name_high+1);
    5888              : 
    5889     23821479 :   if (tok == M2LexBuf_UnknownTokenNo)
    5890              :     {
    5891        45170 :       tok = M2LexBuf_GetTokenNo ();
    5892        45170 :       if (DebugUnknownToken)
    5893              :         {
    5894              :           s = DynamicStrings_InitString ((const char *) name, _name_high);
    5895              :           s = DynamicStrings_ConCat (s, DynamicStrings_InitString ((const char *) " symbol {%W} has been created with an unknown token location", 60));
    5896              :           M2MetaError_MetaErrorStringT0 (M2LexBuf_GetTokenNo (), s);
    5897              :         }
    5898              :     }
    5899     23821479 :   return tok;
    5900              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5901              :   __builtin_unreachable ();
    5902            0 : }
    5903              : 
    5904              : 
    5905              : /*
    5906              :    GetLink - returns TRUE if the current module is only used for linkage.
    5907              : */
    5908              : 
    5909       373656 : static bool GetLink (void)
    5910              : {
    5911       373656 :   unsigned int OuterModule;
    5912              : 
    5913       373656 :   OuterModule = SymbolTable_GetCurrentModule ();
    5914       373656 :   if (OuterModule != SymbolTable_NulSym)
    5915              :     {
    5916              :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    5917       358704 :       if (M2Comp_CompilingDefinitionModule ())
    5918              :         {
    5919         8480 :           return SymbolTable_IsDefLink (OuterModule);
    5920              :         }
    5921              :       else
    5922              :         {
    5923       350224 :           return SymbolTable_IsModLink (OuterModule);
    5924              :         }
    5925              :     }
    5926              :   /* Default is that the module is for compiling.  */
    5927              :   return false;
    5928              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5929              :   __builtin_unreachable ();
    5930              : }
    5931              : 
    5932              : 
    5933              : /*
    5934              :    AddModuleToParent - adds symbol, Sym, to module, Parent.
    5935              : */
    5936              : 
    5937          428 : static void AddModuleToParent (unsigned int Sym, unsigned int Parent)
    5938              : {
    5939          428 :   SymbolTable_PtrToSymbol pSym;
    5940              : 
    5941          428 :   pSym = GetPsym (Parent);
    5942          428 :   switch (pSym->SymbolType)
    5943              :     {
    5944           18 :       case SymbolTable_DefImpSym:
    5945           18 :         Lists_PutItemIntoList (pSym->DefImp.ListOfModules, Sym);
    5946           18 :         break;
    5947              : 
    5948          254 :       case SymbolTable_ModuleSym:
    5949          254 :         Lists_PutItemIntoList (pSym->Module.ListOfModules, Sym);
    5950          254 :         break;
    5951              : 
    5952          156 :       case SymbolTable_ProcedureSym:
    5953          156 :         Lists_PutItemIntoList (pSym->Procedure.ListOfModules, Sym);
    5954          156 :         break;
    5955              : 
    5956              : 
    5957            0 :       default:
    5958            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
    5959          428 :         break;
    5960              :     }
    5961          428 : }
    5962              : 
    5963              : 
    5964              : /*
    5965              :    PutProcedureExternPublic - if procedure is not NulSym set extern
    5966              :                               and public booleans.
    5967              : */
    5968              : 
    5969       453640 : static void PutProcedureExternPublic (unsigned int procedure, bool extern_, bool pub)
    5970              : {
    5971       453640 :   if (procedure != SymbolTable_NulSym)
    5972              :     {
    5973       453640 :       SymbolTable_PutExtern (procedure, extern_);
    5974       453640 :       SymbolTable_PutPublic (procedure, pub);
    5975              :     }
    5976       453640 : }
    5977              : 
    5978              : 
    5979              : /*
    5980              :    PutCtorExtern -
    5981              : */
    5982              : 
    5983       113410 : static void PutCtorExtern (unsigned int tok, unsigned int sym, SymbolTable_ModuleCtor *ctor, bool extern_)
    5984              : {
    5985              :   /* If the ctor does not exist then make it extern/ (~extern) public.  */
    5986       113410 :   if ((*ctor).ctor == SymbolTable_NulSym)
    5987              :     {
    5988        19346 :       (*ctor).ctor = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_ctor", 5));
    5989        19346 :       SymbolTable_PutMonoName ((*ctor).ctor, true);
    5990              :     }
    5991       113410 :   PutProcedureExternPublic ((*ctor).ctor, extern_, ! extern_);
    5992       113410 :   SymbolTable_PutCtor ((*ctor).ctor, true);
    5993              :   /* If the ctor does not exist then make it extern/ (~extern) public.  */
    5994       113410 :   if ((*ctor).dep == SymbolTable_NulSym)
    5995              :     {
    5996        19346 :       (*ctor).dep = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_dep", 4));
    5997        19346 :       SymbolTable_PutMonoName ((*ctor).dep, true);
    5998              :     }
    5999       113410 :   PutProcedureExternPublic ((*ctor).dep, extern_, ! extern_);
    6000              :   /* If init/fini do not exist then create them.  */
    6001       113410 :   if ((*ctor).init == SymbolTable_NulSym)
    6002              :     {
    6003        19082 :       (*ctor).init = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_init", 5));
    6004        19082 :       M2Scaffold_DeclareArgEnvParams (tok, (*ctor).init);
    6005        19082 :       SymbolTable_PutMonoName ((*ctor).init, ! (SymbolTable_IsInnerModule (sym)));
    6006              :     }
    6007       113410 :   PutProcedureExternPublic ((*ctor).init, extern_, ! extern_);
    6008       113410 :   if ((*ctor).fini == SymbolTable_NulSym)
    6009              :     {
    6010        19082 :       (*ctor).fini = SymbolTable_MakeProcedure (tok, GenName (SymbolTable_GetLibName (sym), (const char *) "_M2_", 4, SymbolTable_GetSymName (sym), (const char *) "_fini", 5));
    6011        19082 :       M2Scaffold_DeclareArgEnvParams (tok, (*ctor).fini);
    6012        19082 :       SymbolTable_PutMonoName ((*ctor).fini, ! (SymbolTable_IsInnerModule (sym)));
    6013              :     }
    6014       113410 :   PutProcedureExternPublic ((*ctor).fini, extern_, ! extern_);
    6015       113410 : }
    6016              : 
    6017              : 
    6018              : /*
    6019              :    InitProcedureDeclaration - initialize all the ProcedureDeclaration
    6020              :                               fields.
    6021              : */
    6022              : 
    6023     15072666 : static void InitProcedureDeclaration (SymbolTable_ProcedureDeclaration *decl)
    6024              : {
    6025     15072666 :   (*decl).Defined = false;  /* Has the procedure been  */
    6026              :   /* declared yet?  */
    6027     15072666 :   (*decl).ParamDefined = false;  /* Have the parameters been  */
    6028              :   /* defined yet?  */
    6029     15072666 :   (*decl).HasVarArgs = false;  /* Does the procedure use ... ?  */
    6030     15072666 :   (*decl).HasOptArg = false;  /* Does this procedure use [ ] ?  */
    6031     15072666 :   (*decl).IsNoReturn = false;  /* Declared attribute noreturn ?  */
    6032     15072666 :   (*decl).ReturnOptional = false;  /* Is the return value optional?  */
    6033     15072666 :   (*decl).ProcedureTok = M2LexBuf_UnknownTokenNo;  /* Is the return value optional?  */
    6034            0 : }
    6035              : 
    6036              : 
    6037              : /*
    6038              :    AddProcedureToList - adds a procedure, Proc, to the list of procedures
    6039              :                         in module, Mod.
    6040              : */
    6041              : 
    6042      5024222 : static void AddProcedureToList (unsigned int Mod, unsigned int Proc)
    6043              : {
    6044      5024222 :   SymbolTable_PtrToSymbol pSym;
    6045              : 
    6046      5024222 :   pSym = GetPsym (Mod);
    6047      5024222 :   switch (pSym->SymbolType)
    6048              :     {
    6049      4357062 :       case SymbolTable_DefImpSym:
    6050      4357062 :         Lists_PutItemIntoList (pSym->DefImp.ListOfProcs, Proc);
    6051      4357062 :         break;
    6052              : 
    6053       666728 :       case SymbolTable_ModuleSym:
    6054       666728 :         Lists_PutItemIntoList (pSym->Module.ListOfProcs, Proc);
    6055       666728 :         break;
    6056              : 
    6057          432 :       case SymbolTable_ProcedureSym:
    6058          432 :         Lists_PutItemIntoList (pSym->Procedure.ListOfProcs, Proc);
    6059          432 :         break;
    6060              : 
    6061              : 
    6062            0 :       default:
    6063            0 :         M2Error_InternalError ((const char *) "expecting ModuleSym, DefImpSym or ProcedureSym symbol", 53);
    6064      5024222 :         break;
    6065              :     }
    6066      5024222 : }
    6067              : 
    6068              : 
    6069              : /*
    6070              :    AddVarToScopeList - adds symbol, sym, to, scope.
    6071              : */
    6072              : 
    6073     11267181 : static void AddVarToScopeList (unsigned int scope, unsigned int sym)
    6074              : {
    6075     11267181 :   SymbolTable_PtrToSymbol pSym;
    6076              : 
    6077     11267181 :   pSym = GetPsym (scope);
    6078     11267181 :   switch (pSym->SymbolType)
    6079              :     {
    6080     11018494 :       case SymbolTable_ProcedureSym:
    6081     11018494 :         Lists_PutItemIntoList (pSym->Procedure.ListOfVars, sym);
    6082     11018494 :         break;
    6083              : 
    6084       102515 :       case SymbolTable_ModuleSym:
    6085       102515 :         Lists_PutItemIntoList (pSym->Module.ListOfVars, sym);
    6086       102515 :         break;
    6087              : 
    6088       146172 :       case SymbolTable_DefImpSym:
    6089       146172 :         Lists_PutItemIntoList (pSym->DefImp.ListOfVars, sym);
    6090       146172 :         break;
    6091              : 
    6092              : 
    6093            0 :       default:
    6094            0 :         M2Error_InternalError ((const char *) "expecting Procedure or Module symbol", 36);
    6095     11267181 :         break;
    6096              :     }
    6097     11267181 : }
    6098              : 
    6099              : 
    6100              : /*
    6101              :    AddVarToList - add a variable symbol to the list of variables maintained
    6102              :                   by the inner most scope. (Procedure or Module).
    6103              : */
    6104              : 
    6105     11267163 : static void AddVarToList (unsigned int Sym)
    6106              : {
    6107     11267163 :   SymbolTable_PtrToCallFrame pCall;
    6108              : 
    6109     11267163 :   pCall = GetPcall (ScopePtr);
    6110     11267163 :   AddVarToScopeList (pCall->Main, Sym);
    6111     11267163 : }
    6112              : 
    6113              : 
    6114              : /*
    6115              :    InitVarDecl - initialize the variable and type token location positions.
    6116              : */
    6117              : 
    6118     11267163 : static void InitVarDecl (SymbolTable_VarDecl *decl, unsigned int vartok)
    6119              : {
    6120     11267163 :   (*decl).FullTok = M2LexBuf_UnknownTokenNo;
    6121     11267163 :   (*decl).VarTok = vartok;
    6122     11267163 :   (*decl).TypeTok = M2LexBuf_UnknownTokenNo;
    6123            0 : }
    6124              : 
    6125              : 
    6126              : /*
    6127              :    doPutVarDeclTypeTok - places typetok into decl.TypeTok.
    6128              :                          sym must be a variable.
    6129              : */
    6130              : 
    6131            0 : static void doPutVarDeclTypeTok (unsigned int sym, unsigned int typetok)
    6132              : {
    6133            0 :   SymbolTable_PtrToSymbol pSym;
    6134              : 
    6135            0 :   M2Debug_Assert (SymbolTable_IsVar (sym));
    6136            0 :   pSym = GetPsym (sym);
    6137            0 :   pSym->Var.Declared.TypeTok = typetok;
    6138            0 : }
    6139              : 
    6140              : 
    6141              : /*
    6142              :    doPutVarDeclTok - places vartok into decl.VarTok.
    6143              :                      sym must be a variable.
    6144              : */
    6145              : 
    6146      1694926 : static void doPutVarDeclTok (unsigned int sym, unsigned int vartok)
    6147              : {
    6148      1694926 :   SymbolTable_PtrToSymbol pSym;
    6149              : 
    6150      1694926 :   M2Debug_Assert (SymbolTable_IsVar (sym));
    6151      1694926 :   pSym = GetPsym (sym);
    6152      1694926 :   pSym->Var.Declared.VarTok = vartok;
    6153      1694926 : }
    6154              : 
    6155              : 
    6156              : /*
    6157              :    doGetVarDeclTok - return decl.VarTok for a variable.
    6158              : */
    6159              : 
    6160           60 : static unsigned int doGetVarDeclTok (unsigned int sym)
    6161              : {
    6162           60 :   SymbolTable_PtrToSymbol pSym;
    6163              : 
    6164           60 :   pSym = GetPsym (sym);
    6165           60 :   M2Debug_Assert (SymbolTable_IsVar (sym));
    6166           60 :   return pSym->Var.Declared.VarTok;
    6167              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6168              :   __builtin_unreachable ();
    6169              : }
    6170              : 
    6171              : 
    6172              : /*
    6173              :    doGetVarDeclTypeTok - return decl.TypeTok for a variable.
    6174              : */
    6175              : 
    6176            0 : static unsigned int doGetVarDeclTypeTok (unsigned int sym)
    6177              : {
    6178            0 :   SymbolTable_PtrToSymbol pSym;
    6179              : 
    6180            0 :   pSym = GetPsym (sym);
    6181            0 :   M2Debug_Assert (SymbolTable_IsVar (sym));
    6182            0 :   return pSym->Var.Declared.TypeTok;
    6183              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6184              :   __builtin_unreachable ();
    6185              : }
    6186              : 
    6187              : 
    6188              : /*
    6189              :    doGetVarDeclFullTok - return the full declaration of var: type.
    6190              : */
    6191              : 
    6192          282 : static unsigned int doGetVarDeclFullTok (unsigned int sym)
    6193              : {
    6194          282 :   SymbolTable_PtrToSymbol pSym;
    6195              : 
    6196          282 :   pSym = GetPsym (sym);
    6197          282 :   M2Debug_Assert (SymbolTable_IsVar (sym));
    6198          282 :   if (pSym->Var.Declared.FullTok == M2LexBuf_UnknownTokenNo)
    6199              :     {
    6200              :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    6201          282 :       if (pSym->Var.Declared.TypeTok == M2LexBuf_UnknownTokenNo)
    6202              :         {
    6203           66 :           return pSym->Var.Declared.VarTok;
    6204              :         }
    6205              :       else
    6206              :         {
    6207          216 :           pSym->Var.Declared.FullTok = M2LexBuf_MakeVirtual2Tok (pSym->Var.Declared.VarTok, pSym->Var.Declared.TypeTok);
    6208              :         }
    6209              :     }
    6210          216 :   return pSym->Var.Declared.FullTok;
    6211              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6212              :   __builtin_unreachable ();
    6213              : }
    6214              : 
    6215              : 
    6216              : /*
    6217              :    FillInRecordFields - given a new symbol, sym, make it a record symbol
    6218              :                         and initialize its fields.
    6219              : */
    6220              : 
    6221       101329 : static void FillInRecordFields (unsigned int tok, unsigned int sym, NameKey_Name RecordName, unsigned int scope, unsigned int oaf)
    6222              : {
    6223       101329 :   SymbolTable_PtrToSymbol pSym;
    6224              : 
    6225       101329 :   if (! (SymbolTable_IsError (sym)))
    6226              :     {
    6227       101323 :       pSym = GetPsym (sym);
    6228       101323 :       pSym->SymbolType = SymbolTable_RecordSym;
    6229       101323 :       pSym->Record.name = RecordName;
    6230       101323 :       SymbolKey_InitTree (&pSym->Record.LocalSymbols);
    6231       101323 :       pSym->Record.Size = M2ALU_InitValue ();
    6232       101323 :       Lists_InitList (&pSym->Record.ListOfSons);  /* List of RecordFieldSym and VarientSym  */
    6233       101323 :       pSym->Record.oafamily = oaf;  /* List of RecordFieldSym and VarientSym  */
    6234       101323 :       pSym->Record.Parent = SymbolTable_NulSym;
    6235       101323 :       pSym->Record.Align = SymbolTable_NulSym;
    6236       101323 :       pSym->Record.DefaultAlign = SymbolTable_NulSym;
    6237       101323 :       pSym->Record.DeclPacked = false;
    6238       101323 :       pSym->Record.DeclResolved = false;
    6239       101323 :       pSym->Record.Scope = scope;
    6240       101323 :       InitWhereDeclaredTok (tok, &pSym->Record.At);
    6241              :     }
    6242       101329 : }
    6243              : 
    6244              : 
    6245              : /*
    6246              :    HandleHiddenOrDeclare -
    6247              : */
    6248              : 
    6249      6399480 : static unsigned int HandleHiddenOrDeclare (unsigned int tok, NameKey_Name name, unsigned int *oaf)
    6250              : {
    6251      6399480 :   unsigned int sym;
    6252              : 
    6253      6399480 :   sym = CheckForHiddenType (name);
    6254      6399480 :   if (sym == SymbolTable_NulSym)
    6255              :     {
    6256      6383800 :       sym = DeclareSym (tok, name);
    6257      6383800 :       if (! (SymbolTable_IsError (sym)))
    6258              :         {
    6259              :           /* Now add this type to the symbol table of the current scope  */
    6260      6383788 :           AddSymToScope (sym, name);
    6261              :         }
    6262              :     }
    6263      6399480 :   (*oaf) = SymbolTable_GetOAFamily (sym);
    6264      6399480 :   return sym;
    6265              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6266              :   __builtin_unreachable ();
    6267              : }
    6268              : 
    6269              : 
    6270              : /*
    6271              :    CreateConstLit -
    6272              : */
    6273              : 
    6274       610547 : static unsigned int CreateConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
    6275              : {
    6276       610547 :   SymbolTable_PtrToSymbol pSym;
    6277       610547 :   unsigned int Sym;
    6278       610547 :   bool overflow;
    6279              : 
    6280       610547 :   overflow = false;
    6281       610547 :   if (constType == SymbolTable_NulSym)
    6282              :     {
    6283       466411 :       constType = GetConstLitType (tok, constName, &overflow, true);
    6284              :     }
    6285       610547 :   NewSym (&Sym);
    6286       610547 :   pSym = GetPsym (Sym);
    6287       610547 :   pSym->SymbolType = SymbolTable_ConstLitSym;
    6288       610547 :   switch (pSym->SymbolType)
    6289              :     {
    6290       610547 :       case SymbolTable_ConstLitSym:
    6291       610547 :         pSym->ConstLit.name = constName;
    6292       610547 :         pSym->ConstLit.Value = M2ALU_InitValue ();
    6293       610547 :         M2ALU_PushString (tok, constName, ! overflow);
    6294       610547 :         M2ALU_PopInto (pSym->ConstLit.Value);
    6295       610547 :         pSym->ConstLit.Type = constType;
    6296       610547 :         pSym->ConstLit.IsSet = false;
    6297       610547 :         pSym->ConstLit.IsInternal = false;  /* Is it a default BY constant
    6298              :                                                         expression?  */
    6299       610547 :         pSym->ConstLit.IsConstructor = false;  /* Is it a default BY constant
    6300              :                                                         expression?  */
    6301       610547 :         pSym->ConstLit.FromType = SymbolTable_NulSym;  /* type is determined FromType  */
    6302       610547 :         pSym->ConstLit.RangeError = overflow;  /* type is determined FromType  */
    6303       610547 :         pSym->ConstLit.UnresFromType = false;  /* is Type resolved?  */
    6304       610547 :         pSym->ConstLit.Scope = SymbolTable_GetCurrentScope ();  /* is Type resolved?  */
    6305       610547 :         InitWhereDeclaredTok (tok, &pSym->ConstLit.At);
    6306       610547 :         InitWhereFirstUsedTok (tok, &pSym->ConstLit.At);
    6307       610547 :         break;
    6308              : 
    6309              : 
    6310              :       default:
    6311              :         M2Error_InternalError ((const char *) "expecting ConstLit symbol", 25);
    6312       610547 :         break;
    6313              :     }
    6314       610547 :   return Sym;
    6315              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6316              :   __builtin_unreachable ();
    6317              : }
    6318              : 
    6319              : 
    6320              : /*
    6321              :    LookupConstLitPoolEntry - return a ConstLit symbol from the constant pool which
    6322              :                              matches tok, constName and constType.
    6323              : */
    6324              : 
    6325      1634836 : static unsigned int LookupConstLitPoolEntry (unsigned int tok, NameKey_Name constName, unsigned int constType)
    6326              : {
    6327      1634836 :   SymbolTable_ConstLitPoolEntry pe;
    6328      1634836 :   unsigned int rootIndex;
    6329              : 
    6330      1634836 :   rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
    6331      1634836 :   if (rootIndex != 0)
    6332              :     {
    6333      1335841 :       pe = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
    6334     16846379 :       while (pe != NULL)
    6335              :         {
    6336     15198986 :           if (((pe->tok == tok) && (pe->constName == constName)) && (pe->constType == constType))
    6337              :             {
    6338      1024289 :               return pe->sym;
    6339              :             }
    6340     14174697 :           pe = pe->next;
    6341              :         }
    6342              :     }
    6343              :   return SymbolTable_NulSym;
    6344              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6345              :   __builtin_unreachable ();
    6346              : }
    6347              : 
    6348              : 
    6349              : /*
    6350              :    AddConstLitPoolEntry - adds sym to the constlit pool.
    6351              : */
    6352              : 
    6353       610547 : static void AddConstLitPoolEntry (unsigned int sym, unsigned int tok, NameKey_Name constName, unsigned int constType)
    6354              : {
    6355       610547 :   SymbolTable_ConstLitPoolEntry pe;
    6356       610547 :   SymbolTable_ConstLitPoolEntry old;
    6357       610547 :   unsigned int rootIndex;
    6358       610547 :   unsigned int high;
    6359              : 
    6360       610547 :   rootIndex = static_cast<unsigned int> (SymbolKey_GetSymKey (ConstLitPoolTree, constName));
    6361       610547 :   if (rootIndex == SymbolKey_NulKey)
    6362              :     {
    6363       298995 :       high = Indexing_HighIndice (ConstLitArray);
    6364       298995 :       Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
    6365       298995 :       if (pe == NULL)
    6366              :         {
    6367            0 :           M2Error_InternalError ((const char *) "out of memory", 13);
    6368              :         }
    6369              :       else
    6370              :         {
    6371       298995 :           pe->sym = sym;
    6372       298995 :           pe->tok = tok;
    6373       298995 :           pe->constName = constName;
    6374       298995 :           pe->constType = constType;
    6375       298995 :           pe->next = NULL;
    6376       298995 :           SymbolKey_PutSymKey (ConstLitPoolTree, constName, high+1);
    6377       298995 :           Indexing_PutIndice (ConstLitArray, high+1, reinterpret_cast <void *> (pe));
    6378              :         }
    6379              :     }
    6380              :   else
    6381              :     {
    6382       311552 :       Storage_ALLOCATE ((void **) &pe, sizeof (SymbolTable__T4));
    6383       311552 :       if (pe == NULL)
    6384              :         {
    6385            0 :           M2Error_InternalError ((const char *) "out of memory", 13);
    6386              :         }
    6387              :       else
    6388              :         {
    6389       311552 :           old = static_cast<SymbolTable_ConstLitPoolEntry> (Indexing_GetIndice (ConstLitArray, rootIndex));
    6390       311552 :           pe->sym = sym;
    6391       311552 :           pe->tok = tok;
    6392       311552 :           pe->constName = constName;
    6393       311552 :           pe->constType = constType;
    6394       311552 :           pe->next = old;
    6395       311552 :           Indexing_PutIndice (ConstLitArray, rootIndex, reinterpret_cast <void *> (pe));
    6396              :         }
    6397              :     }
    6398       610547 : }
    6399              : 
    6400              : 
    6401              : /*
    6402              :    InitConstString - initialize the constant string.
    6403              : */
    6404              : 
    6405       368735 : static void InitConstString (unsigned int tok, unsigned int sym, NameKey_Name name, NameKey_Name contents, SymbolTable_ConstStringVariant kind, bool escape, bool known)
    6406              : {
    6407       368735 :   SymbolTable_PtrToSymbol pSym;
    6408              : 
    6409       368735 :   pSym = GetPsym (sym);
    6410       368735 :   pSym->SymbolType = SymbolTable_ConstStringSym;
    6411       368735 :   switch (pSym->SymbolType)
    6412              :     {
    6413       368735 :       case SymbolTable_ConstStringSym:
    6414       368735 :         pSym->ConstString.name = name;
    6415       368735 :         pSym->ConstString.StringVariant = kind;
    6416       368735 :         pSym->ConstString.Scope = SymbolTable_GetCurrentScope ();
    6417       368735 :         InitWhereDeclaredTok (tok, &pSym->ConstString.At);
    6418       368735 :         SymbolTable_PutConstStringKnown (tok, sym, contents, escape, known);
    6419       368735 :         break;
    6420              : 
    6421              : 
    6422              :       default:
    6423              :         M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
    6424       368735 :         break;
    6425              :     }
    6426       368735 : }
    6427              : 
    6428              : 
    6429              : /*
    6430              :    GetConstStringKind - return the StringVariant field associated with sym.
    6431              : */
    6432              : 
    6433       291955 : static SymbolTable_ConstStringVariant GetConstStringKind (unsigned int sym)
    6434              : {
    6435       291955 :   SymbolTable_PtrToSymbol pSym;
    6436              : 
    6437       291955 :   pSym = GetPsym (sym);
    6438       291955 :   switch (pSym->SymbolType)
    6439              :     {
    6440       291955 :       case SymbolTable_ConstStringSym:
    6441       291955 :         return pSym->ConstString.StringVariant;
    6442            0 :         break;
    6443              : 
    6444              : 
    6445            0 :       default:
    6446            0 :         M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
    6447              :         break;
    6448              :     }
    6449              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    6450              :   __builtin_unreachable ();
    6451              : }
    6452              : 
    6453              : 
    6454              : /*
    6455              :    CanUseBuiltin - returns TRUE if the procedure, Sym, can be
    6456              :                    inlined via a builtin function.
    6457              : */
    6458              : 
    6459        19162 : static bool CanUseBuiltin (unsigned int Sym)
    6460              : {
    6461        19162 :   return ! M2Options_DebugBuiltins && ((m2builtins_BuiltinExists (reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetProcedureBuiltin (Sym))))) || (m2builtins_BuiltinExists (reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (Sym))))));
    6462              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6463              :   __builtin_unreachable ();
    6464              : }
    6465              : 
    6466              : 
    6467              : /*
    6468              :    InitPacked - initialise packedInfo to FALSE and NulSym.
    6469              : */
    6470              : 
    6471       943705 : static void InitPacked (SymbolTable_PackedInfo *packedInfo)
    6472              : {
    6473       943705 :   (*packedInfo).IsPacked = false;
    6474       943705 :   (*packedInfo).PackedEquiv = SymbolTable_NulSym;
    6475            0 : }
    6476              : 
    6477              : 
    6478              : /*
    6479              :    doEquivalent - create a packed equivalent symbol for, sym, and return the
    6480              :                   new symbol.  It sets both fields in packedInfo to FALSE
    6481              :                   and the new symbol.
    6482              : */
    6483              : 
    6484        14036 : static unsigned int doEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
    6485              : {
    6486        14036 :   unsigned int nSym;
    6487        14036 :   SymbolTable_PtrToSymbol pSym;
    6488              : 
    6489        14036 :   NewSym (&nSym);
    6490        14036 :   pSym = GetPsym (nSym);
    6491        14036 :   pSym->SymbolType = SymbolTable_EquivSym;
    6492        14036 :   pSym->Equiv.nonPacked = sym;
    6493        14036 :   pSym->Equiv.packedInfo.IsPacked = true;
    6494        14036 :   pSym->Equiv.packedInfo.PackedEquiv = SymbolTable_NulSym;
    6495        14036 :   (*packedInfo).IsPacked = false;
    6496        14036 :   (*packedInfo).PackedEquiv = nSym;
    6497        14036 :   return nSym;
    6498              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6499              :   __builtin_unreachable ();
    6500              : }
    6501              : 
    6502              : 
    6503              : /*
    6504              :    MakeEquivalent - return the equivalent packed symbol for, sym.
    6505              : */
    6506              : 
    6507        14036 : static unsigned int MakeEquivalent (unsigned int sym)
    6508              : {
    6509        14036 :   SymbolTable_PtrToSymbol pSym;
    6510              : 
    6511        14036 :   pSym = GetPsym (sym);
    6512        14036 :   switch (pSym->SymbolType)
    6513              :     {
    6514        13976 :       case SymbolTable_EnumerationSym:
    6515        13976 :         return doEquivalent (&pSym->Enumeration.packedInfo, sym);
    6516           60 :         break;
    6517              : 
    6518           60 :       case SymbolTable_SubrangeSym:
    6519           60 :         return doEquivalent (&pSym->Subrange.packedInfo, sym);
    6520            0 :         break;
    6521              : 
    6522            0 :       case SymbolTable_TypeSym:
    6523            0 :         return doEquivalent (&pSym->Type.packedInfo, sym);
    6524            0 :         break;
    6525              : 
    6526            0 :       case SymbolTable_SetSym:
    6527            0 :         return doEquivalent (&pSym->Set.packedInfo, sym);
    6528            0 :         break;
    6529              : 
    6530              : 
    6531            0 :       default:
    6532            0 :         M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
    6533              :         break;
    6534              :     }
    6535              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    6536              :   __builtin_unreachable ();
    6537              : }
    6538              : 
    6539              : 
    6540              : /*
    6541              :    GetEquivalent -
    6542              : */
    6543              : 
    6544        14276 : static unsigned int GetEquivalent (SymbolTable_PackedInfo *packedInfo, unsigned int sym)
    6545              : {
    6546        14276 :   if ((*packedInfo).IsPacked)
    6547              :     {
    6548              :       return sym;
    6549              :     }
    6550        14276 :   else if ((*packedInfo).PackedEquiv == SymbolTable_NulSym)
    6551              :     {
    6552              :       /* avoid dangling else.  */
    6553        14036 :       (*packedInfo).PackedEquiv = MakeEquivalent (sym);
    6554              :     }
    6555        14276 :   return (*packedInfo).PackedEquiv;
    6556              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6557              :   __builtin_unreachable ();
    6558              : }
    6559              : 
    6560              : 
    6561              : /*
    6562              :    doGetType - subsiduary helper procedure function of GetDType, GetSType and GetLType.
    6563              : */
    6564              : 
    6565   1357625976 : static unsigned int doGetType (unsigned int sym, bool skipEquiv, bool skipAlign, bool skipHidden, bool skipBase)
    6566              : {
    6567   1357625976 :   SymbolTable_PtrToSymbol pSym;
    6568   1357625976 :   unsigned int type;
    6569              : 
    6570   1357625976 :   type = SymbolTable_NulSym;
    6571   1357625976 :   M2Debug_Assert (sym != SymbolTable_NulSym);
    6572   1357625976 :   pSym = GetPsym (sym);
    6573   1357625976 :   switch (pSym->SymbolType)
    6574              :     {
    6575            0 :       case SymbolTable_OAFamilySym:
    6576            0 :         type = pSym->OAFamily.SimpleType;
    6577            0 :         break;
    6578              : 
    6579    155994048 :       case SymbolTable_VarSym:
    6580    155994048 :         type = GetTypeOfVar (sym);
    6581    155994048 :         break;
    6582              : 
    6583     43802272 :       case SymbolTable_ConstLitSym:
    6584     43802272 :         type = pSym->ConstLit.Type;
    6585     43802272 :         break;
    6586              : 
    6587     38455894 :       case SymbolTable_ConstVarSym:
    6588     38455894 :         type = pSym->ConstVar.Type;
    6589     38455894 :         break;
    6590              : 
    6591      9821563 :       case SymbolTable_ConstStringSym:
    6592      9821563 :         if (pSym->ConstString.Length == 1)
    6593              :           {
    6594      2008532 :             type = M2Base_Char;
    6595              :           }
    6596              :         else
    6597              :           {
    6598              :             type = SymbolTable_NulSym;  /* No type for a string  */
    6599              :           }
    6600              :         break;
    6601              : 
    6602    185384099 :       case SymbolTable_TypeSym:
    6603    185384099 :         type = pSym->Type.Type;
    6604    185384099 :         break;
    6605              : 
    6606    473146000 :       case SymbolTable_RecordFieldSym:
    6607    473146000 :         type = pSym->RecordField.Type;
    6608    473146000 :         break;
    6609              : 
    6610              :       case SymbolTable_RecordSym:
    6611              :         type = SymbolTable_NulSym;  /* No type for a record  */
    6612              :         break;
    6613              : 
    6614              :       case SymbolTable_VarientSym:
    6615              :         type = SymbolTable_NulSym;  /* No type for a record  */
    6616              :         break;
    6617              : 
    6618     86547382 :       case SymbolTable_EnumerationFieldSym:
    6619     86547382 :         type = pSym->EnumerationField.Type;  /* No type for a record  */
    6620     86547382 :         break;
    6621              : 
    6622              :       case SymbolTable_EnumerationSym:
    6623              :         type = SymbolTable_NulSym;  /* No type for enumeration  */
    6624              :         break;
    6625              : 
    6626    196592454 :       case SymbolTable_PointerSym:
    6627    196592454 :         type = pSym->Pointer.Type;  /* No type for enumeration  */
    6628    196592454 :         break;
    6629              : 
    6630     26058381 :       case SymbolTable_ProcedureSym:
    6631     26058381 :         type = pSym->Procedure.ReturnType;
    6632     26058381 :         break;
    6633              : 
    6634     11059822 :       case SymbolTable_ProcTypeSym:
    6635     11059822 :         type = pSym->ProcType.ReturnType;
    6636     11059822 :         break;
    6637              : 
    6638     19199999 :       case SymbolTable_ParamSym:
    6639     19199999 :         type = pSym->Param.Type;
    6640     19199999 :         break;
    6641              : 
    6642      4288774 :       case SymbolTable_VarParamSym:
    6643      4288774 :         type = pSym->VarParam.Type;
    6644      4288774 :         break;
    6645              : 
    6646     24094094 :       case SymbolTable_SubrangeSym:
    6647     24094094 :         type = pSym->Subrange.Type;
    6648     24094094 :         break;
    6649              : 
    6650     10803536 :       case SymbolTable_ArraySym:
    6651     10803536 :         type = pSym->Array.Type;
    6652     10803536 :         break;
    6653              : 
    6654     10981482 :       case SymbolTable_SubscriptSym:
    6655     10981482 :         type = pSym->Subscript.Type;
    6656     10981482 :         break;
    6657              : 
    6658      2235988 :       case SymbolTable_SetSym:
    6659      2235988 :         type = pSym->Set.Type;
    6660      2235988 :         break;
    6661              : 
    6662     58077604 :       case SymbolTable_UnboundedSym:
    6663     58077604 :         type = pSym->Unbounded.Type;
    6664     58077604 :         break;
    6665              : 
    6666              :       case SymbolTable_UndefinedSym:
    6667              :         type = SymbolTable_NulSym;
    6668              :         break;
    6669              : 
    6670            0 :       case SymbolTable_PartialUnboundedSym:
    6671            0 :         type = pSym->PartialUnbounded.Type;
    6672            0 :         break;
    6673              : 
    6674              :       case SymbolTable_ObjectSym:
    6675              :         type = SymbolTable_NulSym;
    6676              :         break;
    6677              : 
    6678              : 
    6679            6 :       default:
    6680            6 :         M2Error_InternalError ((const char *) "not implemented yet", 19);
    6681   1348730361 :         break;
    6682              :     }
    6683   1357625970 :   if (((type == SymbolTable_NulSym) && (SymbolTable_IsType (sym))) && ! skipBase)
    6684              :     {
    6685              :       return sym;  /* sym is a base type  */
    6686              :     }
    6687   1342452585 :   else if (type != SymbolTable_NulSym)
    6688              :     {
    6689              :       /* avoid dangling else.  */
    6690   1139204117 :       if ((SymbolTable_IsType (type)) && skipEquiv)
    6691              :         {
    6692     15827955 :           if ((! (SymbolTable_IsHiddenType (type))) || skipHidden)
    6693              :             {
    6694     15661117 :               if (((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym) || skipAlign)
    6695              :                 {
    6696     15661099 :                   return doGetType (type, skipEquiv, skipAlign, skipHidden, skipBase);
    6697              :                 }
    6698              :             }
    6699              :         }
    6700              :     }
    6701              :   return type;
    6702              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6703              :   __builtin_unreachable ();
    6704              : }
    6705              : 
    6706              : 
    6707              : /*
    6708              :    GetTypeOfVar - returns the type of symbol, var.
    6709              : */
    6710              : 
    6711    244961476 : static unsigned int GetTypeOfVar (unsigned int var)
    6712              : {
    6713    244961476 :   SymbolTable_PtrToSymbol pSym;
    6714    244961476 :   unsigned int high;
    6715              : 
    6716    244961476 :   pSym = GetPsym (var);
    6717    244961476 :   switch (pSym->SymbolType)
    6718              :     {
    6719    244961476 :       case SymbolTable_VarSym:
    6720    244961476 :         if (pSym->Var.IsTemp && pSym->Var.IsComponentRef)
    6721              :           {
    6722      6308212 :             high = Indexing_HighIndice (pSym->Var.list);
    6723     12616424 :             return SymbolTable_GetType (GetFromIndex (pSym->Var.list, high));
    6724              :           }
    6725              :         else
    6726              :           {
    6727    238653264 :             return pSym->Var.Type;
    6728              :           }
    6729            0 :         break;
    6730              : 
    6731              : 
    6732            0 :       default:
    6733            0 :         M2Error_InternalError ((const char *) "expecting a var symbol", 22);
    6734              :         break;
    6735              :     }
    6736              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    6737              :   __builtin_unreachable ();
    6738              : }
    6739              : 
    6740              : 
    6741              : /*
    6742              :    GetConstLitType - returns the type of the constant of, name.
    6743              :                      All floating point constants have type LONGREAL.
    6744              :                      Character constants are type CHAR.
    6745              :                      Integer values are INTEGER, LONGINT or LONGCARD
    6746              :                      depending upon their value.
    6747              : */
    6748              : 
    6749       466411 : static unsigned int GetConstLitType (unsigned int tok, NameKey_Name name, bool *overflow, bool issueError)
    6750              : {
    6751       466411 :   location_t loc;
    6752       466411 :   DynamicStrings_String s;
    6753              : 
    6754       466411 :   s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name));
    6755       466411 :   if ((DynamicStrings_char (s, -1)) == 'C')
    6756              :     {
    6757       119400 :       s = DynamicStrings_KillString (s);
    6758       119400 :       return M2Base_Char;
    6759              :     }
    6760              :   else
    6761              :     {
    6762       347011 :       if ((DynamicStrings_Index (s, '.', 0)) != -1)  /* found a '.' in our constant  */
    6763              :         {
    6764         6676 :           s = DynamicStrings_KillString (s);
    6765         6676 :           return M2Base_RType;
    6766              :         }
    6767       340335 :       loc = M2LexBuf_TokenToLocation (tok);
    6768       340335 :       switch (DynamicStrings_char (s, -1))
    6769              :         {
    6770          690 :           case 'H':
    6771          690 :             (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 16, issueError);
    6772          690 :             break;
    6773              : 
    6774         2740 :           case 'B':
    6775         2740 :             (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 8, issueError);
    6776         2740 :             break;
    6777              : 
    6778           24 :           case 'A':
    6779           24 :             (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 2, issueError);
    6780           24 :             break;
    6781              : 
    6782              : 
    6783       336881 :           default:
    6784       336881 :             (*overflow) = m2expr_OverflowZType (loc, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (s))), 10, issueError);
    6785       336881 :             break;
    6786              :         }
    6787       340335 :       s = DynamicStrings_KillString (s);
    6788       340335 :       return M2Base_ZType;
    6789              :     }
    6790              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6791              :   __builtin_unreachable ();
    6792              : }
    6793              : 
    6794              : 
    6795              : /*
    6796              :    GetNthFromComponent -
    6797              : */
    6798              : 
    6799       365566 : static unsigned int GetNthFromComponent (unsigned int Sym, unsigned int n)
    6800              : {
    6801       365566 :   SymbolTable_PtrToSymbol pSym;
    6802              : 
    6803       365566 :   pSym = GetPsym (Sym);
    6804       365566 :   switch (pSym->SymbolType)
    6805              :     {
    6806       365566 :       case SymbolTable_VarSym:
    6807       365566 :         if (SymbolTable_IsComponent (Sym))
    6808              :           {
    6809       365566 :             if (Indexing_InBounds (pSym->Var.list, n))
    6810              :               {
    6811       490816 :                 return GetFromIndex (pSym->Var.list, n);
    6812              :               }
    6813              :             else
    6814              :               {
    6815              :                 return SymbolTable_NulSym;
    6816              :               }
    6817              :           }
    6818              :         else
    6819              :           {
    6820            0 :             M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
    6821              :           }
    6822            0 :         break;
    6823              : 
    6824              : 
    6825            0 :       default:
    6826            0 :         M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
    6827              :         break;
    6828              :     }
    6829              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    6830              :   __builtin_unreachable ();
    6831              : }
    6832              : 
    6833              : 
    6834              : /*
    6835              :    GetNthParamChoice - returns the parameter definition from
    6836              :                        sym:ParamNo:kind or NulSym.
    6837              : */
    6838              : 
    6839       616715 : static unsigned int GetNthParamChoice (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind kind)
    6840              : {
    6841       616715 :   if (SymbolTable_GetProcedureParametersDefined (sym, kind))
    6842              :     {
    6843       616715 :       return SymbolTable_GetNthParam (sym, kind, ParamNo);
    6844              :     }
    6845              :   else
    6846              :     {
    6847              :       return SymbolTable_NulSym;
    6848              :     }
    6849              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6850              :   __builtin_unreachable ();
    6851              : }
    6852              : 
    6853              : 
    6854              : /*
    6855              :    GetNthParamOrdered - returns the parameter definition from list {a, b, c}
    6856              :                         in order.
    6857              :                         sym:ParamNo:{a,b,c} or NulSym.
    6858              : */
    6859              : 
    6860       616715 : static unsigned int GetNthParamOrdered (unsigned int sym, unsigned int ParamNo, SymbolTable_ProcedureKind a, SymbolTable_ProcedureKind b, SymbolTable_ProcedureKind c)
    6861              : {
    6862       616715 :   if (SymbolTable_GetProcedureParametersDefined (sym, a))
    6863              :     {
    6864       616715 :       return GetNthParamChoice (sym, ParamNo, a);
    6865              :     }
    6866            0 :   else if (SymbolTable_GetProcedureParametersDefined (sym, b))
    6867              :     {
    6868              :       /* avoid dangling else.  */
    6869            0 :       return GetNthParamChoice (sym, ParamNo, b);
    6870              :     }
    6871            0 :   else if (SymbolTable_GetProcedureParametersDefined (sym, c))
    6872              :     {
    6873              :       /* avoid dangling else.  */
    6874            0 :       return GetNthParamChoice (sym, ParamNo, c);
    6875              :     }
    6876              :   else
    6877              :     {
    6878              :       /* avoid dangling else.  */
    6879              :       return SymbolTable_NulSym;
    6880              :     }
    6881              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6882              :   __builtin_unreachable ();
    6883              : }
    6884              : 
    6885              : 
    6886              : /*
    6887              :    GetOuterModuleScope - returns the outer module symbol scope for sym.
    6888              : */
    6889              : 
    6890      1233430 : static unsigned int GetOuterModuleScope (unsigned int sym)
    6891              : {
    6892      1850331 :   do {
    6893      1850331 :     if (SymbolTable_IsDefImp (sym))
    6894              :       {
    6895              :         /* Definition/implementation module.  */
    6896              :         return sym;
    6897              :       }
    6898      1123559 :     else if (SymbolTable_IsModule (sym))
    6899              :       {
    6900              :         /* avoid dangling else.  */
    6901       506742 :         if ((SymbolTable_GetScope (sym)) == SymbolTable_NulSym)
    6902              :           {
    6903              :             /* Outer module.  */
    6904              :             return sym;
    6905              :           }
    6906              :       }
    6907       616901 :     sym = SymbolTable_GetScope (sym);
    6908       616901 :   } while (! (sym == SymbolTable_NulSym));
    6909            0 :   M2Error_InternalError ((const char *) "not expecting to reach an outer scope", 37);
    6910              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    6911              :   __builtin_unreachable ();
    6912              : }
    6913              : 
    6914              : 
    6915              : /*
    6916              :    EnsureOrder - providing that both symbols, a, and, b, exist in
    6917              :                  list, l.  Ensure that, b, is placed after a.
    6918              : */
    6919              : 
    6920         2976 : static void EnsureOrder (Lists_List l, unsigned int a, unsigned int b)
    6921              : {
    6922         2976 :   unsigned int n;
    6923              : 
    6924         2976 :   n = Lists_NoOfItemsInList (l);
    6925         2976 :   if ((Lists_IsItemInList (l, a)) && (Lists_IsItemInList (l, b)))
    6926              :     {
    6927         2976 :       Lists_RemoveItemFromList (l, b);
    6928         2976 :       Lists_IncludeItemIntoList (l, b);
    6929              :     }
    6930         2976 :   M2Debug_Assert (n == (Lists_NoOfItemsInList (l)));
    6931         2976 : }
    6932              : 
    6933              : 
    6934              : /*
    6935              :    DumpSons -
    6936              : */
    6937              : 
    6938            0 : static void DumpSons (unsigned int sym)
    6939              : {
    6940            0 :   SymbolTable_PtrToSymbol pSym;
    6941            0 :   unsigned int f;
    6942            0 :   unsigned int n;
    6943            0 :   unsigned int i;
    6944              : 
    6945            0 :   pSym = GetPsym (sym);
    6946            0 :   switch (pSym->SymbolType)
    6947              :     {
    6948            0 :       case SymbolTable_RecordSym:
    6949            0 :         n = Lists_NoOfItemsInList (pSym->Record.ListOfSons);
    6950            0 :         i = 1;
    6951            0 :         while (i <= n)
    6952              :           {
    6953            0 :             f = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, i));
    6954            0 :             M2Printf_printf3 ((const char *) "record %d field %d is %d\\n", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &i, (sizeof (i)-1), (const unsigned char *) &f, (sizeof (f)-1));
    6955            0 :             i += 1;
    6956              :           }
    6957            0 :         break;
    6958              : 
    6959              : 
    6960            0 :       default:
    6961            0 :         M2Error_InternalError ((const char *) "expecting record symbol", 23);
    6962            0 :         break;
    6963              :     }
    6964            0 : }
    6965              : 
    6966              : 
    6967              : /*
    6968              :    CheckListOfSons - checks to see that sym, is present in, recordConsist, ListOfSons.
    6969              : */
    6970              : 
    6971            0 : static void CheckListOfSons (unsigned int sym)
    6972              : {
    6973            0 :   SymbolTable_PtrToSymbol pSym;
    6974              : 
    6975            0 :   pSym = GetPsym (recordConsist);
    6976            0 :   switch (pSym->SymbolType)
    6977              :     {
    6978            0 :       case SymbolTable_RecordSym:
    6979            0 :         if (! (Lists_IsItemInList (pSym->Record.ListOfSons, sym)))
    6980              :           {
    6981            0 :             DumpSons (recordConsist);
    6982            0 :             M2MetaError_MetaError1 ((const char *) "internal error:  expecting {%1ad} to exist in record ListOfSons", 63, sym);
    6983              :           }
    6984            0 :         break;
    6985              : 
    6986              : 
    6987            0 :       default:
    6988            0 :         M2Error_InternalError ((const char *) "expecting record symbol", 23);
    6989            0 :         break;
    6990              :     }
    6991            0 : }
    6992              : 
    6993              : 
    6994              : /*
    6995              :    CheckRecordConsistency -
    6996              : */
    6997              : 
    6998            0 : static void CheckRecordConsistency (unsigned int sym)
    6999              : {
    7000            0 :   SymbolTable_PtrToSymbol pSym;
    7001              : 
    7002            0 :   return;
    7003              :   pSym = GetPsym (sym);
    7004              :   switch (pSym->SymbolType)
    7005              :     {
    7006              :       case SymbolTable_RecordSym:
    7007              :         recordConsist = sym;
    7008              :         SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) CheckListOfSons});
    7009              :         break;
    7010              : 
    7011              : 
    7012              :       default:
    7013              :         M2Error_InternalError ((const char *) "record symbol expected", 22);
    7014            0 :         break;
    7015              :     }
    7016              : }
    7017              : 
    7018              : 
    7019              : /*
    7020              :    PutConstVarTemporary - indicates that constant, sym, is a temporary.
    7021              : */
    7022              : 
    7023       454697 : static void PutConstVarTemporary (unsigned int sym)
    7024              : {
    7025       454697 :   SymbolTable_PtrToSymbol pSym;
    7026              : 
    7027       454697 :   pSym = GetPsym (sym);
    7028       454697 :   switch (pSym->SymbolType)
    7029              :     {
    7030       454697 :       case SymbolTable_ConstVarSym:
    7031       454697 :         pSym->ConstVar.IsTemp = true;
    7032       454697 :         break;
    7033              : 
    7034              : 
    7035            0 :       default:
    7036            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
    7037       454697 :         break;
    7038              :     }
    7039       454697 : }
    7040              : 
    7041              : 
    7042              : /*
    7043              :    buildTemporary - builds the temporary filling in componentRef, record and sets mode.
    7044              : */
    7045              : 
    7046      1144054 : static unsigned int buildTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode, bool componentRef, unsigned int record)
    7047              : {
    7048      1144054 :   SymbolTable_PtrToSymbol pSym;
    7049      1144054 :   DynamicStrings_String s;
    7050      1144054 :   unsigned int Sym;
    7051              : 
    7052      1144054 :   TemporaryNo += 1;
    7053              :   /* Make the name  */
    7054      1144054 :   s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
    7055      1144054 :   if (Mode == SymbolTable_ImmediateValue)
    7056              :     {
    7057       420278 :       Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
    7058       420278 :       PutConstVarTemporary (Sym);
    7059              :     }
    7060              :   else
    7061              :     {
    7062       723776 :       Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
    7063       723776 :       pSym = GetPsym (Sym);
    7064       723776 :       switch (pSym->SymbolType)
    7065              :         {
    7066       723776 :           case SymbolTable_VarSym:
    7067       723776 :             pSym->Var.AddrMode = Mode;
    7068       723776 :             pSym->Var.IsComponentRef = componentRef;
    7069       723776 :             pSym->Var.IsTemp = true;  /* Variable is a temporary var  */
    7070       723776 :             if (componentRef)  /* Variable is a temporary var  */
    7071              :               {
    7072       143312 :                 pSym->Var.list = Indexing_InitIndex (1);
    7073       143312 :                 PutIntoIndex (&pSym->Var.list, 1, record);
    7074              :               }
    7075       723776 :             InitWhereDeclaredTok (tok, &pSym->Var.At);  /* Declared here  */
    7076       723776 :             InitWhereFirstUsedTok (tok, &pSym->Var.At);  /* Where symbol first used.  */
    7077       723776 :             break;
    7078              : 
    7079              : 
    7080            0 :           default:
    7081            0 :             M2Error_InternalError ((const char *) "expecting a Var symbol", 22);  /* Where symbol first used.  */
    7082      1144054 :             break;
    7083              :         }
    7084              :     }
    7085      1144054 :   s = DynamicStrings_KillString (s);
    7086      1144054 :   return Sym;
    7087              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7088              :   __builtin_unreachable ();
    7089              : }
    7090              : 
    7091              : 
    7092              : /*
    7093              :    AssertInRange - determines whether the Sym is a legal symbol.
    7094              : */
    7095              : 
    7096   3080027456 : static void AssertInRange (unsigned int Sym)
    7097              : {
    7098   3080027456 :   if ((Sym < 1) || (Sym > (SymbolTable_FinalSymbol ())))
    7099              :     {
    7100            6 :       M2Error_InternalError ((const char *) "illegal symbol", 14);
    7101              :     }
    7102   3080027450 : }
    7103              : 
    7104              : 
    7105              : /*
    7106              :    CheckForHiddenType - scans the NeedToBeImplemented tree providing
    7107              :                         that we are currently compiling an implementation
    7108              :                         module. If a symbol is found with TypeName
    7109              :                         then its Sym is returned.
    7110              :                         Otherwise NulSym is returned.
    7111              :                         CheckForHiddenType is called before any type is
    7112              :                         created, therefore the compiler allows hidden
    7113              :                         types to be implemented using any type.
    7114              : */
    7115              : 
    7116      6942026 : static unsigned int CheckForHiddenType (NameKey_Name TypeName)
    7117              : {
    7118      6942026 :   SymbolTable_PtrToSymbol pSym;
    7119      6942026 :   unsigned int Sym;
    7120              : 
    7121      6942026 :   Sym = SymbolTable_NulSym;
    7122      6942026 :   if ((((M2Comp_CompilingImplementationModule ()) && (SymbolTable_IsDefImp (CurrentModule))) && (SymbolTable_IsHiddenTypeDeclared (CurrentModule))) && (TypeName != NameKey_NulName))
    7123              :     {
    7124              :       /* Check to see whether we are declaring a HiddenType.  */
    7125       104499 :       pSym = GetPsym (CurrentModule);
    7126       104499 :       switch (pSym->SymbolType)
    7127              :         {
    7128       104499 :           case SymbolTable_DefImpSym:
    7129       104499 :             Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, TypeName));
    7130       104499 :             break;
    7131              : 
    7132              : 
    7133            0 :           default:
    7134            0 :             M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
    7135       104499 :             break;
    7136              :         }
    7137              :     }
    7138      6942026 :   return Sym;
    7139              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7140              :   __builtin_unreachable ();
    7141              : }
    7142              : 
    7143              : 
    7144              : /*
    7145              :    RequestFromModule - returns a symbol from module ModSym with name, SymName.
    7146              : */
    7147              : 
    7148          108 : static unsigned int RequestFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
    7149              : {
    7150          108 :   SymbolTable_PtrToSymbol pSym;
    7151          108 :   unsigned int Sym;
    7152              : 
    7153          108 :   pSym = GetPsym (ModSym);
    7154          108 :   switch (pSym->SymbolType)
    7155              :     {
    7156            0 :       case SymbolTable_DefImpSym:
    7157            0 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymName));
    7158            0 :         if (Sym == SymbolTable_NulSym)
    7159              :           {
    7160            0 :             Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
    7161              :           }
    7162              :         break;
    7163              : 
    7164          108 :       case SymbolTable_ModuleSym:
    7165          108 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymName));
    7166          108 :         if (Sym == SymbolTable_NulSym)
    7167              :           {
    7168           12 :             Sym = FetchUnknownFromModule (tok, ModSym, SymName);
    7169              :           }
    7170              :         break;
    7171              : 
    7172              : 
    7173            0 :       default:
    7174            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
    7175          108 :         break;
    7176              :     }
    7177          108 :   return Sym;
    7178              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7179              :   __builtin_unreachable ();
    7180              : }
    7181              : 
    7182              : 
    7183              : /*
    7184              :    RequestFromDefinition - returns a symbol from module ModSym with name,
    7185              :                            SymName.
    7186              : */
    7187              : 
    7188      2756250 : static unsigned int RequestFromDefinition (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
    7189              : {
    7190      2756250 :   SymbolTable_PtrToSymbol pSym;
    7191      2756250 :   unsigned int Sym;
    7192      2756250 :   unsigned int OldScopePtr;
    7193              : 
    7194      2756250 :   pSym = GetPsym (ModSym);
    7195      2756250 :   switch (pSym->SymbolType)
    7196              :     {
    7197      2756250 :       case SymbolTable_DefImpSym:
    7198      2756250 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName));
    7199      2756250 :         if (Sym == SymbolTable_NulSym)
    7200              :           {
    7201       761674 :             Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName));
    7202       761674 :             if (Sym == SymbolTable_NulSym)
    7203              :               {
    7204       362290 :                 Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
    7205       362290 :                 if (Sym == SymbolTable_NulSym)
    7206              :                   {
    7207       325114 :                     OldScopePtr = ScopePtr;
    7208       325114 :                     SymbolTable_StartScope (ModSym);
    7209       325114 :                     Sym = GetScopeSym (SymName, true);
    7210       325114 :                     SymbolTable_EndScope ();
    7211       325114 :                     M2Debug_Assert (OldScopePtr == ScopePtr);
    7212       325114 :                     if (Sym == SymbolTable_NulSym)
    7213              :                       {
    7214       325082 :                         Sym = FetchUnknownFromDefImp (tok, ModSym, SymName);
    7215              :                       }
    7216              :                     else
    7217              :                       {
    7218           32 :                         if (SymbolTable_IsFieldEnumeration (Sym))
    7219              :                           {
    7220            6 :                             if (SymbolTable_IsExported (ModSym, SymbolTable_GetType (Sym)))
    7221              :                               {
    7222              :                                 return Sym;
    7223              :                               }
    7224              :                           }
    7225              :                       }
    7226       325108 :                     SymbolKey_PutSymKey (pSym->DefImp.ExportRequest, SymName, Sym);
    7227              :                   }
    7228              :               }
    7229              :           }
    7230              :         break;
    7231              : 
    7232              : 
    7233            0 :       default:
    7234            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
    7235              :         break;
    7236              :     }
    7237              :   return Sym;
    7238              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7239              :   __builtin_unreachable ();
    7240              : }
    7241              : 
    7242              : 
    7243              : /*
    7244              :    GetWhereImported - returns the token number where this symbol
    7245              :                       was imported into the current module.
    7246              : */
    7247              : 
    7248            6 : static unsigned int GetWhereImported (unsigned int Sym)
    7249              : {
    7250            6 :   SymbolTable_PtrToSymbol pSym;
    7251              : 
    7252            6 :   pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
    7253            6 :   switch (pSym->SymbolType)
    7254              :     {
    7255            6 :       case SymbolTable_DefImpSym:
    7256            6 :         return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym));
    7257            0 :         break;
    7258              : 
    7259            0 :       case SymbolTable_ModuleSym:
    7260            0 :         return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym));
    7261            0 :         break;
    7262              : 
    7263              : 
    7264            0 :       default:
    7265            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
    7266              :         break;
    7267              :     }
    7268              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    7269              :   __builtin_unreachable ();
    7270              : }
    7271              : 
    7272              : 
    7273              : /*
    7274              :    DisplayName - displays the name.
    7275              : */
    7276              : 
    7277            0 : static void DisplayName (unsigned int sym)
    7278              : {
    7279            0 :   M2Printf_printf1 ((const char *) "   %a", 5, (const unsigned char *) &sym, (sizeof (sym)-1));
    7280            0 : }
    7281              : 
    7282              : 
    7283              : /*
    7284              :    DisplaySymbol - displays the name of a symbol
    7285              : */
    7286              : 
    7287            0 : static void DisplaySymbol (unsigned int sym)
    7288              : {
    7289            0 :   DynamicStrings_String s;
    7290              : 
    7291            0 :   s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym))));
    7292            0 :   M2Printf_printf2 ((const char *) "   %s (%d)", 10, (const unsigned char *) &s, (sizeof (s)-1), (const unsigned char *) &sym, (sizeof (sym)-1));
    7293            0 : }
    7294              : 
    7295              : 
    7296              : /*
    7297              :    FetchUnknownFromModule - returns an Unknown symbol from module, ModSym.
    7298              : */
    7299              : 
    7300           12 : static unsigned int FetchUnknownFromModule (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
    7301              : {
    7302           12 :   SymbolTable_PtrToSymbol pSym;
    7303           12 :   unsigned int Sym;
    7304              : 
    7305           12 :   pSym = GetPsym (ModSym);
    7306           12 :   switch (pSym->SymbolType)
    7307              :     {
    7308           12 :       case SymbolTable_ModuleSym:
    7309           12 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
    7310           12 :         if (Sym == SymbolTable_NulSym)
    7311              :           {
    7312           12 :             NewSym (&Sym);
    7313           12 :             FillInUnknownFields (tok, Sym, SymName, ModSym, true);
    7314           12 :             SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
    7315              :           }
    7316           12 :         break;
    7317              : 
    7318              : 
    7319            0 :       default:
    7320            0 :         M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
    7321           12 :         break;
    7322              :     }
    7323           12 :   return Sym;
    7324              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7325              :   __builtin_unreachable ();
    7326              : }
    7327              : 
    7328              : 
    7329              : /*
    7330              :    FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
    7331              : */
    7332              : 
    7333       325082 : static unsigned int FetchUnknownFromDefImp (unsigned int tok, unsigned int ModSym, NameKey_Name SymName)
    7334              : {
    7335       325082 :   SymbolTable_PtrToSymbol pSym;
    7336       325082 :   unsigned int Sym;
    7337              : 
    7338       325082 :   pSym = GetPsym (ModSym);
    7339       325082 :   switch (pSym->SymbolType)
    7340              :     {
    7341       325082 :       case SymbolTable_DefImpSym:
    7342       325082 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
    7343       325082 :         if (Sym == SymbolTable_NulSym)
    7344              :           {
    7345       325082 :             NewSym (&Sym);
    7346       325082 :             FillInUnknownFields (tok, Sym, SymName, ModSym, true);
    7347       325082 :             SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
    7348              :           }
    7349       325082 :         break;
    7350              : 
    7351              : 
    7352            0 :       default:
    7353            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
    7354       325082 :         break;
    7355              :     }
    7356       325082 :   return Sym;
    7357              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7358              :   __builtin_unreachable ();
    7359              : }
    7360              : 
    7361              : 
    7362              : /*
    7363              :    FetchUnknownFromDefImp - returns an Unknown symbol from module, ModSym.
    7364              : */
    7365              : 
    7366           56 : static unsigned int FetchUnknownFrom (unsigned int tok, unsigned int scope, NameKey_Name SymName)
    7367              : {
    7368           56 :   SymbolTable_PtrToSymbol pSym;
    7369           56 :   unsigned int Sym;
    7370              : 
    7371           56 :   pSym = GetPsym (scope);
    7372           56 :   switch (pSym->SymbolType)
    7373              :     {
    7374            0 :       case SymbolTable_DefImpSym:
    7375            0 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.Unresolved, SymName));
    7376            0 :         if (Sym == SymbolTable_NulSym)
    7377              :           {
    7378            0 :             NewSym (&Sym);
    7379            0 :             FillInUnknownFields (tok, Sym, SymName, scope, true);
    7380            0 :             SymbolKey_PutSymKey (pSym->DefImp.Unresolved, SymName, Sym);
    7381              :           }
    7382              :         break;
    7383              : 
    7384           38 :       case SymbolTable_ModuleSym:
    7385           38 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.Unresolved, SymName));
    7386           38 :         if (Sym == SymbolTable_NulSym)
    7387              :           {
    7388           38 :             NewSym (&Sym);
    7389           38 :             FillInUnknownFields (tok, Sym, SymName, scope, true);
    7390           38 :             SymbolKey_PutSymKey (pSym->Module.Unresolved, SymName, Sym);
    7391              :           }
    7392              :         break;
    7393              : 
    7394           18 :       case SymbolTable_ProcedureSym:
    7395           18 :         Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.Unresolved, SymName));
    7396           18 :         if (Sym == SymbolTable_NulSym)
    7397              :           {
    7398           18 :             NewSym (&Sym);
    7399           18 :             FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
    7400           18 :             SymbolKey_PutSymKey (pSym->Procedure.Unresolved, SymName, Sym);
    7401              :           }
    7402              :         break;
    7403              : 
    7404              : 
    7405            0 :       default:
    7406            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module or Procedure symbol", 48);
    7407           56 :         break;
    7408              :     }
    7409           56 :   return Sym;
    7410              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7411              :   __builtin_unreachable ();
    7412              : }
    7413              : 
    7414              : 
    7415              : /*
    7416              :    UnknownSymbolError - displays symbol name for symbol, sym.
    7417              : */
    7418              : 
    7419          151 : static void UnknownSymbolError (unsigned int sym)
    7420              : {
    7421          151 :   if (IsUnreportedUnknown (sym))
    7422              :     {
    7423          143 :       Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
    7424          143 :       M2MetaError_MetaErrorStringT1 (SymbolTable_GetFirstUsed (sym), DynamicStrings_InitString ((const char *) "unknown symbol {%1EUad} {%1&s}", 30), sym);
    7425              :     }
    7426          151 : }
    7427              : 
    7428              : 
    7429              : /*
    7430              :    IsUnreportedUnknown - returns TRUE if symbol, sym, has not been
    7431              :                          reported and is an unknown symbol.
    7432              : */
    7433              : 
    7434     33389898 : static bool IsUnreportedUnknown (unsigned int sym)
    7435              : {
    7436     33389898 :   return (SymbolTable_IsUnknown (sym)) && (! (Sets_IsElementInSet (ReportedUnknowns, sym)));
    7437              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7438              :   __builtin_unreachable ();
    7439              : }
    7440              : 
    7441              : 
    7442              : /*
    7443              :    AddListify -
    7444              : */
    7445              : 
    7446            0 : static void AddListify (unsigned int sym)
    7447              : {
    7448            0 :   ListifyWordCount += 1;
    7449              :   /* printf ("AddListify: ListifyWordCount = %d, ListifyTotal = %d
    7450              :   ",
    7451              :               ListifyWordCount, ListifyTotal) ;  */
    7452            0 :   if (ListifyWordCount > 1)
    7453              :     {
    7454              :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    7455            0 :       if (ListifyWordCount == ListifyTotal)
    7456              :         {
    7457            0 :           ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) " and ", 5)));
    7458              :         }
    7459              :       else
    7460              :         {
    7461            0 :           ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ", ", 2)));
    7462              :         }
    7463              :     }
    7464            0 :   ListifySentance = DynamicStrings_ConCat (ListifySentance, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym)))));
    7465            0 : }
    7466              : 
    7467              : 
    7468              : /*
    7469              :    Listify - convert tree into a string list and return the result.
    7470              : */
    7471              : 
    7472            0 : static DynamicStrings_String Listify (SymbolKey_SymbolTree tree, SymbolKey_IsSymbol isCondition)
    7473              : {
    7474            0 :   ListifyTotal = SymbolKey_NoOfNodes (tree, isCondition);
    7475            0 :   ListifyWordCount = 0;
    7476            0 :   ListifySentance = DynamicStrings_InitString ((const char *) "", 0);
    7477            0 :   SymbolKey_ForeachNodeConditionDo (tree, isCondition, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) AddListify});
    7478            0 :   return ListifySentance;
    7479              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7480              :   __builtin_unreachable ();
    7481              : }
    7482              : 
    7483              : 
    7484              : /*
    7485              :    CheckForUnknowns - checks a binary tree, Tree, to see whether it contains
    7486              :                       an unknown symbol. All unknown symbols are displayed
    7487              :                       together with an error message.
    7488              : */
    7489              : 
    7490      1945188 : static void CheckForUnknowns (unsigned int tokno, NameKey_Name name, SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
    7491              : {
    7492      1945188 :   DynamicStrings_String s;
    7493      1945188 :   char a[_a_high+1];
    7494              : 
    7495              :   /* make a local copy of each unbounded array.  */
    7496      1945188 :   memcpy (a, a_, _a_high+1);
    7497              : 
    7498      1945188 :   if (SymbolKey_DoesTreeContainAny (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown}))
    7499              :     {
    7500          119 :       SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnknownSymbolError});
    7501          119 :       if ((SymbolKey_NoOfNodes (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown})) > 0)
    7502              :         {
    7503            0 :           s = DynamicStrings_InitString ((const char *) "{%E} the following unknown symbols in module %<", 47);
    7504            0 :           s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (name))));
    7505            0 :           s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%> were ", 8)));
    7506            0 :           s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
    7507            0 :           s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ": ", 2)));
    7508            0 :           s = DynamicStrings_ConCat (s, DynamicStrings_Mark (Listify (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown})));
    7509            0 :           M2MetaError_MetaErrorStringT0 (tokno, s);
    7510              :         }
    7511              :     }
    7512      1945188 : }
    7513              : 
    7514              : 
    7515              : /*
    7516              :    SymbolError - displays symbol name for symbol, Sym.
    7517              : */
    7518              : 
    7519            0 : static void SymbolError (unsigned int Sym)
    7520              : {
    7521            0 :   M2Error_Error e;
    7522            0 :   NameKey_Name n;
    7523              : 
    7524            0 :   n = SymbolTable_GetSymName (Sym);
    7525            0 :   e = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
    7526            0 :   M2Error_ErrorFormat1 (e, (const char *) "unknown symbol '%a' found", 25, (const unsigned char *) &n, (sizeof (n)-1));
    7527            0 : }
    7528              : 
    7529              : 
    7530              : /*
    7531              :    CheckForSymbols  - checks a binary tree, Tree, to see whether it contains
    7532              :                       any symbol. The tree is expected to be empty, if not
    7533              :                       then an error has occurred.
    7534              : */
    7535              : 
    7536       462398 : static void CheckForSymbols (SymbolKey_SymbolTree Tree, const char *a_, unsigned int _a_high)
    7537              : {
    7538       462398 :   DynamicStrings_String s;
    7539       462398 :   char a[_a_high+1];
    7540              : 
    7541              :   /* make a local copy of each unbounded array.  */
    7542       462398 :   memcpy (a, a_, _a_high+1);
    7543              : 
    7544       462398 :   if (SymbolKey_DoesTreeContainAny (Tree, (SymbolKey_IsSymbol) {(SymbolKey_IsSymbol_t) IsUnreportedUnknown}))
    7545              :     {
    7546            0 :       s = DynamicStrings_InitString ((const char *) "the symbols are unknown at the end of module {%1Ea} when ", 57);
    7547            0 :       s = DynamicStrings_ConCat (s, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
    7548            0 :       M2MetaError_MetaErrorString1 (s, MainModule);
    7549            0 :       SymbolKey_ForeachNodeDo (Tree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SymbolError});
    7550              :     }
    7551       462398 : }
    7552              : 
    7553              : 
    7554              : /*
    7555              :    PutExportUndeclared - places a symbol, Sym, into module, ModSym,
    7556              :                          ExportUndeclared list provided that Sym
    7557              :                          is unknown.
    7558              : */
    7559              : 
    7560      4505963 : static void PutExportUndeclared (unsigned int ModSym, unsigned int Sym)
    7561              : {
    7562      4505963 :   SymbolTable_PtrToSymbol pSym;
    7563              : 
    7564      4505963 :   if (SymbolTable_IsUnknown (Sym))
    7565              :     {
    7566      3981393 :       pSym = GetPsym (ModSym);
    7567      3981393 :       switch (pSym->SymbolType)
    7568              :         {
    7569          294 :           case SymbolTable_ModuleSym:
    7570          294 :             SymbolKey_PutSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
    7571          294 :             break;
    7572              : 
    7573      3981099 :           case SymbolTable_DefImpSym:
    7574      3981099 :             SymbolKey_PutSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym), Sym);
    7575      3981099 :             break;
    7576              : 
    7577              : 
    7578            0 :           default:
    7579            0 :             M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
    7580              :             break;
    7581              :         }
    7582              :     }
    7583      4505963 : }
    7584              : 
    7585              : 
    7586              : /*
    7587              :    GetExportUndeclared - returns a symbol which has, name, from module, ModSym,
    7588              :                          which is in the ExportUndeclared list.
    7589              : */
    7590              : 
    7591          234 : static unsigned int GetExportUndeclared (unsigned int ModSym, NameKey_Name name)
    7592              : {
    7593          234 :   SymbolTable_PtrToSymbol pSym;
    7594              : 
    7595          234 :   pSym = GetPsym (ModSym);
    7596          234 :   switch (pSym->SymbolType)
    7597              :     {
    7598          228 :       case SymbolTable_ModuleSym:
    7599          228 :         return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, name));
    7600            6 :         break;
    7601              : 
    7602            6 :       case SymbolTable_DefImpSym:
    7603            6 :         return static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, name));
    7604            0 :         break;
    7605              : 
    7606              : 
    7607            0 :       default:
    7608            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
    7609              :         break;
    7610              :     }
    7611              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    7612              :   __builtin_unreachable ();
    7613              : }
    7614              : 
    7615              : 
    7616              : /*
    7617              :    RemoveExportUndeclared - removes a symbol, Sym, from the module, ModSym,
    7618              :                             ExportUndeclaredTree.
    7619              : */
    7620              : 
    7621     11004905 : static void RemoveExportUndeclared (unsigned int ModSym, unsigned int Sym)
    7622              : {
    7623     11004905 :   SymbolTable_PtrToSymbol pSym;
    7624              : 
    7625     11004905 :   pSym = GetPsym (ModSym);
    7626     11004905 :   switch (pSym->SymbolType)
    7627              :     {
    7628           18 :       case SymbolTable_ModuleSym:
    7629           18 :         if ((SymbolKey_GetSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
    7630              :           {
    7631           18 :             SymbolKey_DelSymKey (pSym->Module.ExportUndeclared, SymbolTable_GetSymName (Sym));
    7632              :           }
    7633              :         break;
    7634              : 
    7635     11004887 :       case SymbolTable_DefImpSym:
    7636     11004887 :         if ((SymbolKey_GetSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym))) == Sym)
    7637              :           {
    7638      3980739 :             SymbolKey_DelSymKey (pSym->DefImp.ExportUndeclared, SymbolTable_GetSymName (Sym));
    7639              :           }
    7640              :         break;
    7641              : 
    7642              : 
    7643            0 :       default:
    7644            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
    7645     11004905 :         break;
    7646              :     }
    7647     11004905 : }
    7648              : 
    7649              : 
    7650              : /*
    7651              :    CheckForExportedDeclaration - checks to see whether a definition module
    7652              :                                  is currently being compiled, if so,
    7653              :                                  symbol, Sym, is removed from the
    7654              :                                  ExportUndeclared list.
    7655              :                                  This procedure is called whenever a symbol
    7656              :                                  is declared, thus attempting to reduce
    7657              :                                  the ExportUndeclared list.
    7658              : */
    7659              : 
    7660     19062614 : static void CheckForExportedDeclaration (unsigned int Sym)
    7661              : {
    7662     19062614 :   if (M2Comp_CompilingDefinitionModule ())
    7663              :     {
    7664     11004881 :       RemoveExportUndeclared (SymbolTable_GetCurrentModule (), Sym);
    7665              :     }
    7666     19062614 : }
    7667              : 
    7668              : 
    7669              : /*
    7670              :    UndeclaredSymbolError - displays symbol name for symbol, Sym.
    7671              : */
    7672              : 
    7673            0 : static void UndeclaredSymbolError (unsigned int Sym)
    7674              : {
    7675            0 :   if (DebugUnknowns)
    7676              :     {
    7677              :       M2Printf_printf1 ((const char *) "undeclared symbol (%d)\\n", 24, (const unsigned char *) &Sym, (sizeof (Sym)-1));
    7678              :     }
    7679            0 :   M2MetaError_MetaError1 ((const char *) "{%1UC} undeclared symbol {%1a}", 30, Sym);
    7680            0 : }
    7681              : 
    7682              : 
    7683              : /*
    7684              :    RemoveExportUnImplemented - removes a symbol, Sym, from the module, ModSym,
    7685              :                                NeedToBeImplemented list.
    7686              : */
    7687              : 
    7688      2233569 : static void RemoveExportUnImplemented (unsigned int ModSym, unsigned int Sym)
    7689              : {
    7690      2233569 :   SymbolTable_PtrToSymbol pSym;
    7691              : 
    7692      2233569 :   pSym = GetPsym (ModSym);
    7693      2233569 :   switch (pSym->SymbolType)
    7694              :     {
    7695      2233569 :       case SymbolTable_DefImpSym:
    7696      2233569 :         if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
    7697              :           {
    7698      1283624 :             SymbolKey_DelSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym));
    7699              :           }
    7700      2233569 :         break;
    7701              : 
    7702              : 
    7703            0 :       default:
    7704            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
    7705      2233569 :         break;
    7706              :     }
    7707      2233569 : }
    7708              : 
    7709              : 
    7710              : /*
    7711              :    RemoveFromExportRequest -
    7712              : */
    7713              : 
    7714       411786 : static void RemoveFromExportRequest (unsigned int Sym)
    7715              : {
    7716       411786 :   SymbolTable_PtrToSymbol pSym;
    7717              : 
    7718       411786 :   pSym = GetPsym (ExportRequestModule);
    7719       411786 :   switch (pSym->SymbolType)
    7720              :     {
    7721       411786 :       case SymbolTable_DefImpSym:
    7722       411786 :         if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym))) == Sym)
    7723              :           {
    7724            6 :             SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymbolTable_GetSymName (Sym));
    7725              :           }
    7726       411786 :         break;
    7727              : 
    7728              : 
    7729            0 :       default:
    7730            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
    7731       411786 :         break;
    7732              :     }
    7733       411786 : }
    7734              : 
    7735              : 
    7736              : /*
    7737              :    RemoveEnumerationFromExportRequest - removes enumeration symbol, sym,
    7738              :                                         (and its fields) from the ExportRequest tree.
    7739              : */
    7740              : 
    7741        18779 : static void RemoveEnumerationFromExportRequest (unsigned int ModSym, unsigned int Sym)
    7742              : {
    7743        18779 :   if (SymbolTable_IsEnumeration (Sym))
    7744              :     {
    7745        18779 :       ExportRequestModule = ModSym;
    7746        18779 :       RemoveFromExportRequest (Sym);
    7747        18779 :       SymbolTable_ForeachLocalSymDo (Sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) RemoveFromExportRequest});
    7748              :     }
    7749        18779 : }
    7750              : 
    7751              : 
    7752              : /*
    7753              :    UnImplementedSymbolError - displays symbol name for symbol, Sym.
    7754              : */
    7755              : 
    7756            0 : static void UnImplementedSymbolError (unsigned int Sym)
    7757              : {
    7758            0 :   NameKey_Name n;
    7759              : 
    7760            0 :   CurrentError = M2Error_ChainError (SymbolTable_GetFirstUsed (Sym), CurrentError);
    7761            0 :   if (SymbolTable_IsType (Sym))
    7762              :     {
    7763            0 :       n = SymbolTable_GetSymName (Sym);
    7764            0 :       M2Error_ErrorFormat1 (CurrentError, (const char *) "hidden type is undeclared (%a)", 30, (const unsigned char *) &n, (sizeof (n)-1));
    7765              :     }
    7766            0 :   else if (SymbolTable_IsProcedure (Sym))
    7767              :     {
    7768              :       /* avoid dangling else.  */
    7769            0 :       n = SymbolTable_GetSymName (Sym);
    7770            0 :       M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure is undeclared (%a)", 28, (const unsigned char *) &n, (sizeof (n)-1));
    7771              :     }
    7772            0 :   else if (SymbolTable_IsProcType (Sym))
    7773              :     {
    7774              :       /* avoid dangling else.  */
    7775            0 :       n = SymbolTable_GetSymName (Sym);
    7776            0 :       M2Error_ErrorFormat1 (CurrentError, (const char *) "procedure type is undeclared (%a)", 33, (const unsigned char *) &n, (sizeof (n)-1));
    7777              :     }
    7778              :   else
    7779              :     {
    7780              :       /* avoid dangling else.  */
    7781            0 :       M2Error_ErrorFormat0 (CurrentError, (const char *) "undeclared symbol", 17);
    7782              :     }
    7783            0 : }
    7784              : 
    7785              : 
    7786              : /*
    7787              :    CheckEnumerationInList - places symbol, Sym, in the list, l,
    7788              :                             providing it does not already exist.
    7789              :                             PseudoScope(Sym) is called if Sym needs to
    7790              :                             be added to the enumeration list, l.
    7791              : */
    7792              : 
    7793        66785 : static void CheckEnumerationInList (Lists_List l, unsigned int Sym)
    7794              : {
    7795        66785 :   if (! (Lists_IsItemInList (l, Sym)))
    7796              :     {
    7797        58277 :       Lists_PutItemIntoList (l, Sym);
    7798        58277 :       SymbolTable_PseudoScope (Sym);
    7799              :     }
    7800        66785 : }
    7801              : 
    7802              : 
    7803              : /*
    7804              :    CheckIfEnumerationExported - An outer module may use an enumeration that
    7805              :                                 is declared inside an inner module. The usage
    7806              :                                 may occur before definition. The first pass
    7807              :                                 exports a symbol, later the symbol is declared
    7808              :                                 as an emumeration type. At this stage the
    7809              :                                 CheckIfEnumerationExported procedure should be
    7810              :                                 called. This procedure ripples from the current
    7811              :                                 (inner) module to outer module and every time
    7812              :                                 it is exported it must be added to the outer
    7813              :                                 module EnumerationScopeList.
    7814              : */
    7815              : 
    7816        49115 : static void CheckIfEnumerationExported (unsigned int Sym, unsigned int ScopeId)
    7817              : {
    7818        67912 :   SymbolTable_PtrToCallFrame pCall;
    7819        67912 :   unsigned int InnerModId;
    7820        67912 :   unsigned int OuterModId;
    7821        67912 :   unsigned int InnerModSym;
    7822        67912 :   unsigned int OuterModSym;
    7823              : 
    7824        67912 :   InnerModId = GetModuleScopeId (ScopeId);
    7825        67912 :   if (InnerModId > 0)
    7826              :     {
    7827        67912 :       OuterModId = GetModuleScopeId (InnerModId-1);
    7828        67912 :       if (OuterModId > 0)
    7829              :         {
    7830        67912 :           pCall = GetPcall (InnerModId);
    7831        67912 :           InnerModSym = pCall->Search;
    7832        67912 :           pCall = GetPcall (OuterModId);
    7833        67912 :           OuterModSym = pCall->Search;
    7834        67912 :           if ((InnerModSym != SymbolTable_NulSym) && (OuterModSym != SymbolTable_NulSym))
    7835              :             {
    7836        34187 :               if (SymbolTable_IsExported (InnerModSym, Sym))
    7837              :                 {
    7838        18797 :                   CheckForEnumerationInOuterModule (Sym, OuterModSym);
    7839        18797 :                   CheckIfEnumerationExported (Sym, OuterModId);
    7840              :                 }
    7841              :             }
    7842              :         }
    7843              :     }
    7844        49115 : }
    7845              : 
    7846              : 
    7847              : /*
    7848              :    CheckForEnumerationInOuterModule - checks to see whether the enumeration
    7849              :                                       type symbol, Sym, has been entered into
    7850              :                                       the outer module, OuterModule, scope list.
    7851              :                                       OuterModule may be internal to the
    7852              :                                       program module.
    7853              : */
    7854              : 
    7855        18797 : static void CheckForEnumerationInOuterModule (unsigned int Sym, unsigned int OuterModule)
    7856              : {
    7857        18797 :   SymbolTable_PtrToSymbol pSym;
    7858              : 
    7859        18797 :   pSym = GetPsym (OuterModule);
    7860        18797 :   switch (pSym->SymbolType)
    7861              :     {
    7862            0 :       case SymbolTable_DefImpSym:
    7863            0 :         Lists_IncludeItemIntoList (pSym->DefImp.EnumerationScopeList, Sym);
    7864            0 :         break;
    7865              : 
    7866        18797 :       case SymbolTable_ModuleSym:
    7867        18797 :         Lists_IncludeItemIntoList (pSym->Module.EnumerationScopeList, Sym);
    7868        18797 :         break;
    7869              : 
    7870              : 
    7871            0 :       default:
    7872            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
    7873        18797 :         break;
    7874              :     }
    7875        18797 : }
    7876              : 
    7877              : 
    7878              : /*
    7879              :    MakeVariableForParam -
    7880              : */
    7881              : 
    7882      8788946 : static unsigned int MakeVariableForParam (unsigned int tok, NameKey_Name ParamName, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, unsigned int ParmType, unsigned int typetok)
    7883              : {
    7884      8788946 :   SymbolTable_PtrToSymbol pSym;
    7885      8788946 :   unsigned int VariableSym;
    7886              : 
    7887      8788946 :   tok = CheckTok (tok, (const char *) "parameter", 9);
    7888      8788946 :   VariableSym = SymbolTable_MakeVar (tok, ParamName);
    7889      8788946 :   pSym = GetPsym (VariableSym);
    7890      8788946 :   switch (pSym->SymbolType)
    7891              :     {
    7892              :       case SymbolTable_ErrorSym:
    7893              :         return SymbolTable_NulSym;
    7894      8788946 :         break;
    7895              : 
    7896      8788946 :       case SymbolTable_VarSym:
    7897      8788946 :         pSym->Var.IsParam = true;  /* Variable is really a parameter.  */
    7898      8788946 :         break;
    7899              : 
    7900              : 
    7901            0 :       default:
    7902            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
    7903      8788946 :         break;
    7904              :     }
    7905              :   /* Note that the parameter is now treated as a local variable.  */
    7906      8788946 :   SymbolTable_PutVarTok (VariableSym, ParmType, typetok);
    7907      8788946 :   SymbolTable_PutDeclared (tok, VariableSym);
    7908              :   /* 
    7909              :       Normal VAR parameters have LeftValue,
    7910              :       however Unbounded VAR parameters have RightValue.
    7911              :       Non VAR parameters always have RightValue.
    7912              :   */
    7913      8788946 :   if ((SymbolTable_IsVarParam (ProcSym, kind, no)) && (! (SymbolTable_IsUnboundedParam (ProcSym, kind, no))))
    7914              :     {
    7915       265882 :       SymbolTable_PutMode (VariableSym, SymbolTable_LeftValue);
    7916              :     }
    7917              :   else
    7918              :     {
    7919      8523064 :       SymbolTable_PutMode (VariableSym, SymbolTable_RightValue);
    7920              :     }
    7921              :   return VariableSym;
    7922              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7923              :   __builtin_unreachable ();
    7924              : }
    7925              : 
    7926              : 
    7927              : /*
    7928              :    AddParameter - adds a parameter ParSym to a procedure Sym.
    7929              : */
    7930              : 
    7931     20058782 : static void AddParameter (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParSym)
    7932              : {
    7933     20058782 :   SymbolTable_PtrToSymbol pSym;
    7934              : 
    7935     20058782 :   pSym = GetPsym (Sym);
    7936     20058782 :   switch (pSym->SymbolType)
    7937              :     {
    7938              :       case SymbolTable_ErrorSym:
    7939              :         break;
    7940              : 
    7941     11186148 :       case SymbolTable_ProcedureSym:
    7942     11186148 :         Lists_PutItemIntoList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParSym);
    7943     11186148 :         break;
    7944              : 
    7945      8872634 :       case SymbolTable_ProcTypeSym:
    7946      8872634 :         Lists_PutItemIntoList (pSym->ProcType.ListOfParam, ParSym);
    7947      8872634 :         break;
    7948              : 
    7949              : 
    7950            0 :       default:
    7951            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
    7952     20058782 :         break;
    7953              :     }
    7954     20058782 : }
    7955              : 
    7956              : 
    7957              : /*
    7958              :    AddProcedureProcTypeParam - adds ParamType to the parameter ProcType
    7959              :                                associated with procedure Sym.
    7960              : */
    7961              : 
    7962     11186148 : static void AddProcedureProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded, bool isVarParam)
    7963              : {
    7964     11186148 :   SymbolTable_PtrToSymbol pSym;
    7965              : 
    7966     11186148 :   pSym = GetPsym (Sym);
    7967     11186148 :   switch (pSym->SymbolType)
    7968              :     {
    7969     11186148 :       case SymbolTable_ProcedureSym:
    7970     11186148 :         if (pSym->Procedure.BuildProcType)
    7971              :           {
    7972              :             /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    7973      8788946 :             if (isVarParam)
    7974              :               {
    7975       745246 :                 SymbolTable_PutProcTypeVarParam (tok, pSym->Procedure.ProcedureType, ParamType, isUnbounded);
    7976              :               }
    7977              :             else
    7978              :               {
    7979      8043700 :                 SymbolTable_PutProcTypeParam (tok, pSym->Procedure.ProcedureType, ParamType, isUnbounded);
    7980              :               }
    7981              :           }
    7982     11186148 :         break;
    7983              : 
    7984              : 
    7985            0 :       default:
    7986            0 :         M2Error_InternalError ((const char *) "expecting Sym to be a procedure", 31);
    7987     11186148 :         break;
    7988              :     }
    7989     11186148 : }
    7990              : 
    7991              : 
    7992              : /*
    7993              :    IsNthParamVar - returns true if the n th parameter of the parameter list,
    7994              :                    List, is a VAR parameter.
    7995              : */
    7996              : 
    7997     20879607 : static bool IsNthParamVar (Lists_List Head, unsigned int n)
    7998              : {
    7999     20879607 :   SymbolTable_PtrToSymbol pSym;
    8000     20879607 :   unsigned int p;
    8001              : 
    8002     20879607 :   p = static_cast<unsigned int> (Lists_GetItemFromList (Head, n));
    8003     20879607 :   if (p == SymbolTable_NulSym)
    8004              :     {
    8005            0 :       M2Error_InternalError ((const char *) "parameter does not exist", 24);
    8006              :     }
    8007              :   else
    8008              :     {
    8009     20879607 :       pSym = GetPsym (p);
    8010     20879607 :       switch (pSym->SymbolType)
    8011              :         {
    8012              :           case SymbolTable_ErrorSym:
    8013              :             return false;
    8014      1275089 :             break;
    8015              : 
    8016      1275089 :           case SymbolTable_VarParamSym:
    8017      1275089 :             return true;
    8018              :             break;
    8019              : 
    8020              :           case SymbolTable_ParamSym:
    8021              :             return false;
    8022            0 :             break;
    8023              : 
    8024              : 
    8025            0 :           default:
    8026            0 :             M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
    8027              :             break;
    8028              :         }
    8029              :     }
    8030              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    8031              :   __builtin_unreachable ();
    8032              : }
    8033              : 
    8034              : 
    8035              : /*
    8036              :    MakeParameterHeapVar - create a heap variable if sym is a pointer.
    8037              : */
    8038              : 
    8039       534787 : static unsigned int MakeParameterHeapVar (unsigned int tok, unsigned int type, SymbolTable_ModeOfAddr mode)
    8040              : {
    8041       534787 :   unsigned int heapvar;
    8042              : 
    8043       534787 :   tok = CheckTok (tok, (const char *) "parameter heap var", 18);
    8044       534787 :   heapvar = SymbolTable_NulSym;
    8045       534787 :   type = SymbolTable_SkipType (type);
    8046       534787 :   if (SymbolTable_IsPointer (type))
    8047              :     {
    8048        51248 :       heapvar = SymbolTable_MakeTemporary (tok, mode);
    8049        51248 :       SymbolTable_PutVar (heapvar, type);
    8050        51248 :       SymbolTable_PutVarHeap (heapvar, true);
    8051              :     }
    8052       534787 :   return heapvar;
    8053              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8054              :   __builtin_unreachable ();
    8055              : }
    8056              : 
    8057              : 
    8058              : /*
    8059              :    PutParameterHeapVar - creates a heap variable associated with parameter sym.
    8060              : */
    8061              : 
    8062      5899869 : static void PutParameterHeapVar (unsigned int sym)
    8063              : {
    8064      5899869 :   SymbolTable_PtrToSymbol pSym;
    8065              : 
    8066      5899869 :   pSym = GetPsym (sym);
    8067      5899869 :   switch (pSym->SymbolType)
    8068              :     {
    8069              :       case SymbolTable_ParamSym:
    8070              :         break;
    8071              : 
    8072       534787 :       case SymbolTable_VarParamSym:
    8073       534787 :         pSym->VarParam.HeapVar = MakeParameterHeapVar (SymbolTable_GetDeclaredMod (sym), pSym->VarParam.Type, SymbolTable_LeftValue);  /* Nothing to do for the non var parameter.  */
    8074       534787 :         break;
    8075              : 
    8076              : 
    8077            0 :       default:
    8078            0 :         M2Error_InternalError ((const char *) "Param or VarParam symbol expected", 33);
    8079      5899869 :         break;
    8080              :     }
    8081      5899869 : }
    8082              : 
    8083              : 
    8084              : /*
    8085              :    IsProcedureAnyBoolean - returns the boolean result from p
    8086              :                            for any of procedure kind which is defined.
    8087              : */
    8088              : 
    8089         8941 : static bool IsProcedureAnyBoolean (unsigned int sym, SymbolTable_ProcAnyBoolean p)
    8090              : {
    8091         8941 :   SymbolTable_ProcedureKind kind;
    8092              : 
    8093        26459 :   for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
    8094              :     {
    8095        26459 :       if (SymbolTable_GetProcedureDefined (sym, kind))
    8096              :         {
    8097         8941 :           return (*p.proc) (sym, kind);
    8098              :         }
    8099              :     }
    8100            0 :   M2Error_InternalError ((const char *) "no procedure kind exists", 24);
    8101              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    8102              :   __builtin_unreachable ();
    8103              : }
    8104              : 
    8105              : 
    8106              : /*
    8107              :    IsProcedureAnyDefaultBoolean - returns the boolean result from p
    8108              :                                   for any of procedure kind which is defined.
    8109              : */
    8110              : 
    8111      3871181 : static bool IsProcedureAnyDefaultBoolean (unsigned int sym, bool default_, SymbolTable_ProcAnyBoolean p)
    8112              : {
    8113      3871181 :   SymbolTable_ProcedureKind kind;
    8114              : 
    8115      9103070 :   for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
    8116              :     {
    8117      8706639 :       if (SymbolTable_GetProcedureDefined (sym, kind))
    8118              :         {
    8119      3474750 :           return (*p.proc) (sym, kind);
    8120              :         }
    8121              :     }
    8122              :   return default_;
    8123              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8124              :   __builtin_unreachable ();
    8125              : }
    8126              : 
    8127              : 
    8128              : /*
    8129              :    FillInUnknownFields - fills in all fields for the undefined sym.
    8130              : */
    8131              : 
    8132     10912797 : static void FillInUnknownFields (unsigned int tok, unsigned int sym, NameKey_Name SymName, unsigned int descscope, bool onimport)
    8133              : {
    8134     10912797 :   SymbolTable_PtrToSymbol pSym;
    8135              : 
    8136     10912797 :   pSym = GetPsym (sym);
    8137     10912797 :   pSym->SymbolType = SymbolTable_UndefinedSym;
    8138     10912797 :   pSym->Undefined.name = SymName;
    8139     10912797 :   pSym->Undefined.oafamily = SymbolTable_NulSym;
    8140     10912797 :   pSym->Undefined.errorScope = M2Error_GetCurrentErrorScope ();
    8141     10912797 :   pSym->Undefined.declScope = descscope;
    8142     10912797 :   pSym->Undefined.onImport = onimport;
    8143     10912797 :   InitWhereFirstUsedTok (tok, &pSym->Undefined.At);
    8144     10912797 : }
    8145              : 
    8146              : 
    8147              : /*
    8148              :    FillInPointerFields - given a new symbol, sym, make it a pointer symbol
    8149              :                          and initialize its fields.
    8150              : */
    8151              : 
    8152       201487 : static void FillInPointerFields (unsigned int Sym, NameKey_Name PointerName, unsigned int scope, unsigned int oaf)
    8153              : {
    8154       201487 :   SymbolTable_PtrToSymbol pSym;
    8155              : 
    8156       201487 :   if (! (SymbolTable_IsError (Sym)))
    8157              :     {
    8158       201487 :       pSym = GetPsym (Sym);
    8159       201487 :       pSym->SymbolType = SymbolTable_PointerSym;
    8160       201487 :       switch (pSym->SymbolType)
    8161              :         {
    8162       201487 :           case SymbolTable_PointerSym:
    8163       201487 :             pSym->Pointer.Type = SymbolTable_NulSym;
    8164       201487 :             pSym->Pointer.name = PointerName;
    8165       201487 :             pSym->Pointer.oafamily = oaf;  /* The unbounded for this  */
    8166       201487 :             SymbolKey_InitTree (&pSym->Pointer.ConstLitTree);  /* constants of this type  */
    8167       201487 :             pSym->Pointer.Scope = scope;  /* Which scope created it  */
    8168       201487 :             pSym->Pointer.Size = M2ALU_InitValue ();  /* Which scope created it  */
    8169       201487 :             pSym->Pointer.Align = SymbolTable_NulSym;  /* Alignment of this type  */
    8170       201487 :             break;
    8171              : 
    8172              : 
    8173              :           default:
    8174              :             M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26);  /* Alignment of this type  */
    8175       201487 :             break;
    8176              :         }
    8177              :     }
    8178       201487 : }
    8179              : 
    8180              : 
    8181              : /*
    8182              :    ForeachParameterDo -
    8183              : */
    8184              : 
    8185        29838 : static void ForeachParameterDo (SymbolTable_CheckProcedure p)
    8186              : {
    8187        29838 :   unsigned int l;
    8188        29838 :   unsigned int h;
    8189              : 
    8190        29838 :   l = Indexing_LowIndice (Symbols);
    8191        29838 :   h = Indexing_HighIndice (Symbols);
    8192     46905480 :   while (l <= h)
    8193              :     {
    8194     46845804 :       if (SymbolTable_IsParameter (l))
    8195              :         {
    8196      3240646 :           (*p.proc) (l);
    8197              :         }
    8198     46845804 :       l += 1;
    8199              :     }
    8200        29838 : }
    8201              : 
    8202              : 
    8203              : /*
    8204              :    CheckUnbounded - checks to see if parameter, Sym, is now an unbounded parameter.
    8205              : */
    8206              : 
    8207      3240646 : static void CheckUnbounded (unsigned int Sym)
    8208              : {
    8209      3240646 :   SymbolTable_PtrToSymbol pSym;
    8210              : 
    8211      3240646 :   AssertInRange (Sym);
    8212      3240646 :   pSym = GetPsym (Sym);
    8213      3240646 :   switch (pSym->SymbolType)
    8214              :     {
    8215      2309634 :       case SymbolTable_ParamSym:
    8216      2309634 :         if (SymbolTable_IsUnbounded (pSym->Param.Type))
    8217              :           {
    8218       418268 :             pSym->Param.IsUnbounded = true;
    8219              :           }
    8220              :         break;
    8221              : 
    8222       931012 :       case SymbolTable_VarParamSym:
    8223       931012 :         if (SymbolTable_IsUnbounded (pSym->VarParam.Type))
    8224              :           {
    8225       917496 :             pSym->VarParam.IsUnbounded = true;
    8226              :           }
    8227              :         break;
    8228              : 
    8229              : 
    8230            0 :       default:
    8231            0 :         M2RTS_HALT (-1);
    8232              :         __builtin_unreachable ();
    8233      3240646 :         break;
    8234              :     }
    8235      3240646 : }
    8236              : 
    8237              : 
    8238              : /*
    8239              :    PutOAFamily - places the, oaf, into, SimpleType, oafamily field.
    8240              : */
    8241              : 
    8242        29778 : static void PutOAFamily (unsigned int SimpleType, unsigned int oaf)
    8243              : {
    8244        29778 :   SymbolTable_PtrToSymbol pSym;
    8245              : 
    8246        29778 :   pSym = GetPsym (SimpleType);
    8247        29778 :   switch (pSym->SymbolType)
    8248              :     {
    8249              :       case SymbolTable_ErrorSym:
    8250              :         break;
    8251              : 
    8252           12 :       case SymbolTable_RecordSym:
    8253           12 :         pSym->Record.oafamily = oaf;
    8254           12 :         break;
    8255              : 
    8256            0 :       case SymbolTable_SubrangeSym:
    8257            0 :         pSym->Subrange.oafamily = oaf;
    8258            0 :         break;
    8259              : 
    8260           18 :       case SymbolTable_EnumerationSym:
    8261           18 :         pSym->Enumeration.oafamily = oaf;
    8262           18 :         break;
    8263              : 
    8264            6 :       case SymbolTable_ArraySym:
    8265            6 :         pSym->Array.oafamily = oaf;
    8266            6 :         break;
    8267              : 
    8268            0 :       case SymbolTable_ProcTypeSym:
    8269            0 :         pSym->ProcType.oafamily = oaf;
    8270            0 :         break;
    8271              : 
    8272        29742 :       case SymbolTable_TypeSym:
    8273        29742 :         pSym->Type.oafamily = oaf;
    8274        29742 :         break;
    8275              : 
    8276            0 :       case SymbolTable_PointerSym:
    8277            0 :         pSym->Pointer.oafamily = oaf;
    8278            0 :         break;
    8279              : 
    8280            0 :       case SymbolTable_SetSym:
    8281            0 :         pSym->Set.oafamily = oaf;
    8282            0 :         break;
    8283              : 
    8284            0 :       case SymbolTable_UndefinedSym:
    8285            0 :         pSym->Undefined.oafamily = oaf;
    8286            0 :         break;
    8287              : 
    8288              : 
    8289            0 :       default:
    8290            0 :         M2Error_InternalError ((const char *) "not expecting this SimpleType", 29);
    8291        29778 :         break;
    8292              :     }
    8293        29778 : }
    8294              : 
    8295              : 
    8296              : /*
    8297              :    doFillInOAFamily -
    8298              : */
    8299              : 
    8300            0 : static void doFillInOAFamily (unsigned int oaf, unsigned int i, unsigned int unbounded)
    8301              : {
    8302            0 :   unsigned int SimpleType;
    8303              : 
    8304            0 :   SimpleType = SymbolTable_GetType (oaf);
    8305            0 :   if (unbounded != SymbolTable_NulSym)
    8306              :     {
    8307            0 :       FillInUnboundedFields (M2LexBuf_GetTokenNo (), unbounded, SimpleType, i);
    8308              :     }
    8309            0 : }
    8310              : 
    8311              : 
    8312              : /*
    8313              :    FillInUnboundedFields -
    8314              : */
    8315              : 
    8316        29838 : static void FillInUnboundedFields (unsigned int tok, unsigned int sym, unsigned int SimpleType, unsigned int ndim)
    8317              : {
    8318        29838 :   SymbolTable_PtrToSymbol pSym;
    8319        29838 :   unsigned int Contents;
    8320        29838 :   unsigned int i;
    8321              : 
    8322        29838 :   if (sym != SymbolTable_NulSym)
    8323              :     {
    8324        29838 :       pSym = GetPsym (sym);
    8325        29838 :       pSym->SymbolType = SymbolTable_UnboundedSym;
    8326        29838 :       pSym->Unbounded.Type = SimpleType;  /* Index to a simple type.  */
    8327        29838 :       pSym->Unbounded.Size = M2ALU_InitValue ();  /* Size in bytes for this sym  */
    8328        29838 :       pSym->Unbounded.Scope = SymbolTable_GetScope (SimpleType);  /* Which scope will create it  */
    8329        29838 :       InitWhereDeclaredTok (tok, &pSym->Unbounded.At);  /* Declared here  */
    8330        29838 :       NewSym (&pSym->Unbounded.RecordType);  /* Declared here  */
    8331        29838 :       FillInRecordFields (tok, pSym->Unbounded.RecordType, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
    8332        29838 :       NewSym (&Contents);
    8333        29838 :       FillInPointerFields (Contents, NameKey_NulName, SymbolTable_GetScope (SimpleType), SymbolTable_NulSym);
    8334        29838 :       SymbolTable_PutPointer (Contents, SimpleType);
    8335              :       /* create the contents field for the unbounded array.  */
    8336        29838 :       M2Debug_Assert ((SymbolTable_PutFieldRecord (pSym->Unbounded.RecordType, NameKey_MakeKey ((const char *) "_m2_contents", 12), Contents, SymbolTable_NulSym)) != SymbolTable_NulSym);
    8337              :       /* create all the high fields for the unbounded array.  */
    8338        29838 :       i = 1;
    8339        59820 :       while (i <= ndim)
    8340              :         {
    8341        29982 :           M2Debug_Assert ((SymbolTable_PutFieldRecord (pSym->Unbounded.RecordType, NameKey_makekey (DynamicStrings_string (DynamicStrings_Mark (FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_m2_high_%d", 11)), (const unsigned char *) &i, (sizeof (i)-1))))), M2Base_Cardinal, SymbolTable_NulSym)) != SymbolTable_NulSym);
    8342        29982 :           i += 1;
    8343              :         }
    8344        29838 :       pSym->Unbounded.Dimensions = ndim;
    8345        29838 :       ForeachParameterDo ((SymbolTable_CheckProcedure) {(SymbolTable_CheckProcedure_t) CheckUnbounded});
    8346              :     }
    8347        29838 : }
    8348              : 
    8349              : 
    8350              : /*
    8351              :    PutUnbounded - associates the unbounded symbol, open, with
    8352              :                   SimpleType.
    8353              : */
    8354              : 
    8355        29838 : static void PutUnbounded (unsigned int oaf, unsigned int sym, unsigned int ndim)
    8356              : {
    8357        29838 :   SymbolTable_PtrToSymbol pSym;
    8358              : 
    8359        29838 :   pSym = GetPsym (oaf);
    8360        29838 :   switch (pSym->SymbolType)
    8361              :     {
    8362              :       case SymbolTable_OAFamilySym:
    8363              :         /* need to check to see if we need to add NulSym for all dimensions < ndim
    8364              :                           which have not been used.  */
    8365        59760 :         while (pSym->OAFamily.MaxDimensions < ndim)
    8366              :           {
    8367        29922 :             pSym->OAFamily.MaxDimensions += 1;
    8368        29922 :             if (pSym->OAFamily.MaxDimensions < ndim)
    8369              :               {
    8370              :                 /* add NulSym to an unused dimension.  */
    8371           84 :                 PutIntoIndex (&pSym->OAFamily.Dimensions, pSym->OAFamily.MaxDimensions, SymbolTable_NulSym);
    8372              :               }
    8373              :           }
    8374              :         /* and finally add the known sym.  */
    8375        29838 :         PutIntoIndex (&pSym->OAFamily.Dimensions, ndim, sym);
    8376        29838 :         break;
    8377              : 
    8378              : 
    8379            0 :       default:
    8380            0 :         M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
    8381        29838 :         break;
    8382              :     }
    8383        29838 : }
    8384              : 
    8385              : 
    8386              : /*
    8387              :    GetArrayDimension - returns the number of dimensions defined.
    8388              : */
    8389              : 
    8390         6630 : static unsigned int GetArrayDimension (unsigned int sym)
    8391              : {
    8392         6630 :   unsigned int n;
    8393              : 
    8394         6630 :   n = 0;
    8395        13434 :   while (SymbolTable_IsArray (sym))
    8396              :     {
    8397         6804 :       sym = SymbolTable_SkipType (SymbolTable_GetType (sym));
    8398         6804 :       n += 1;
    8399              :     }
    8400         6630 :   return n;
    8401              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8402              :   __builtin_unreachable ();
    8403              : }
    8404              : 
    8405              : 
    8406              : /*
    8407              :    ResolveConstructorType - if, sym, has an unresolved constructor type
    8408              :                             then attempt to resolve it by examining the
    8409              :                             from, type.
    8410              : */
    8411              : 
    8412        36464 : static void ResolveConstructorType (unsigned int sym, unsigned int *type, unsigned int *from, bool *unres)
    8413              : {
    8414        36464 :   if ((*unres))
    8415              :     {
    8416              :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    8417        36464 :       if (SymbolTable_IsConstructor ((*from)))
    8418              :         {
    8419              :           /* avoid dangling else.  */
    8420            0 :           if (IsConstructorResolved ((*from)))
    8421              :             {
    8422            0 :               (*unres) = false;
    8423            0 :               (*type) = SymbolTable_GetType ((*from));
    8424            0 :               if (((*type) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*type)))))
    8425              :                 {
    8426            0 :                   SymbolTable_PutConstSet (sym);
    8427              :                 }
    8428              :             }
    8429              :         }
    8430        36464 :       else if (((*from) != SymbolTable_NulSym) && (SymbolTable_IsSet (SymbolTable_SkipType ((*from)))))
    8431              :         {
    8432              :           /* avoid dangling else.  */
    8433        33232 :           (*unres) = false;
    8434        33232 :           (*type) = (*from);
    8435        33232 :           SymbolTable_PutConstSet (sym);
    8436              :         }
    8437         3232 :       else if (((*from) != SymbolTable_NulSym) && ((SymbolTable_IsRecord (SymbolTable_SkipType ((*from)))) || (SymbolTable_IsArray (SymbolTable_SkipType ((*from))))))
    8438              :         {
    8439              :           /* avoid dangling else.  */
    8440         3226 :           (*unres) = false;
    8441         3226 :           (*type) = (*from);
    8442              :         }
    8443              :     }
    8444        36464 : }
    8445              : 
    8446              : 
    8447              : /*
    8448              :    IsConstructorResolved - returns TRUE if the constructor does not
    8449              :                            have an unresolved type.
    8450              : */
    8451              : 
    8452        72928 : static bool IsConstructorResolved (unsigned int sym)
    8453              : {
    8454        72928 :   SymbolTable_PtrToSymbol pSym;
    8455              : 
    8456        72928 :   pSym = GetPsym (sym);
    8457        72928 :   switch (pSym->SymbolType)
    8458              :     {
    8459        72928 :       case SymbolTable_ConstVarSym:
    8460        72928 :         return ! pSym->ConstVar.UnresFromType;
    8461            0 :         break;
    8462              : 
    8463            0 :       case SymbolTable_ConstLitSym:
    8464            0 :         return ! pSym->ConstLit.UnresFromType;
    8465            0 :         break;
    8466              : 
    8467              : 
    8468            0 :       default:
    8469            0 :         M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
    8470              :         break;
    8471              :     }
    8472              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    8473              :   __builtin_unreachable ();
    8474              : }
    8475              : 
    8476              : 
    8477              : /*
    8478              :    CanResolveConstructor - returns TRUE if the type of the constructor,
    8479              :                            sym, is known.
    8480              : */
    8481              : 
    8482        36464 : static bool CanResolveConstructor (unsigned int sym)
    8483              : {
    8484        36464 :   SymbolTable_PtrToSymbol pSym;
    8485              : 
    8486        36464 :   if (! (IsConstructorResolved (sym)))
    8487              :     {
    8488        36464 :       pSym = GetPsym (sym);
    8489        36464 :       switch (pSym->SymbolType)
    8490              :         {
    8491        36464 :           case SymbolTable_ConstVarSym:
    8492        36464 :             ResolveConstructorType (sym, &pSym->ConstVar.Type, &pSym->ConstVar.FromType, &pSym->ConstVar.UnresFromType);
    8493        36464 :             break;
    8494              : 
    8495            0 :           case SymbolTable_ConstLitSym:
    8496            0 :             ResolveConstructorType (sym, &pSym->ConstLit.Type, &pSym->ConstLit.FromType, &pSym->ConstLit.UnresFromType);
    8497            0 :             break;
    8498              : 
    8499              : 
    8500            0 :           default:
    8501            0 :             M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
    8502              :             break;
    8503              :         }
    8504              :     }
    8505        36464 :   return IsConstructorResolved (sym);
    8506              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8507              :   __builtin_unreachable ();
    8508              : }
    8509              : 
    8510              : 
    8511              : /*
    8512              :    CheckAllConstructorsResolved - checks to see that the
    8513              :                                   UnresolvedConstructorType list is
    8514              :                                   empty and if it is not then it
    8515              :                                   generates error messages.
    8516              : */
    8517              : 
    8518        14664 : static void CheckAllConstructorsResolved (void)
    8519              : {
    8520        14664 :   unsigned int i;
    8521        14664 :   unsigned int n;
    8522        14664 :   unsigned int s;
    8523        14664 :   M2Error_Error e;
    8524              : 
    8525        14664 :   n = Lists_NoOfItemsInList (UnresolvedConstructorType);
    8526        14664 :   if (n > 0)
    8527              :     {
    8528           12 :       for (i=1; i<=n; i++)
    8529              :         {
    8530            6 :           s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
    8531            6 :           e = M2Error_NewError (SymbolTable_GetDeclaredMod (s));
    8532            6 :           M2Error_ErrorFormat0 (e, (const char *) "constructor has an unknown type", 31);
    8533              :         }
    8534            6 :       M2Error_FlushErrors ();
    8535              :     }
    8536        14658 : }
    8537              : 
    8538              : 
    8539              : /*
    8540              :    SanityCheckParameters -
    8541              : */
    8542              : 
    8543      4871412 : static void SanityCheckParameters (unsigned int sym)
    8544              : {
    8545      4871412 :   unsigned int p;
    8546      4871412 :   unsigned int i;
    8547      4871412 :   unsigned int n;
    8548              : 
    8549      4871412 :   i = 1;
    8550      4871412 :   n = SymbolTable_NoOfParamAny (sym);
    8551     18252401 :   while (i <= n)
    8552              :     {
    8553      8509577 :       p = SymbolTable_GetType (SymbolTable_GetParam (sym, i));
    8554      8509577 :       if (SymbolTable_IsConst (p))
    8555              :         {
    8556            0 :           M2MetaError_MetaError3 ((const char *) "the {%1N} formal parameter in procedure {%2Dad} should have a type rather than a constant {%3Dad}", 97, i, sym, p);
    8557              :         }
    8558      8509577 :       i += 1;
    8559              :     }
    8560      4871412 : }
    8561              : 
    8562              : 
    8563              : /*
    8564              :    SanityCheckArray - checks to see that an array has a correct subrange type.
    8565              : */
    8566              : 
    8567     60377252 : static void SanityCheckArray (unsigned int sym)
    8568              : {
    8569     60377252 :   unsigned int type;
    8570     60377252 :   unsigned int subscript;
    8571              : 
    8572     60377252 :   if (SymbolTable_IsArray (sym))
    8573              :     {
    8574       101396 :       subscript = SymbolTable_GetArraySubscript (sym);
    8575       101396 :       if (subscript != SymbolTable_NulSym)
    8576              :         {
    8577       101396 :           type = SymbolTable_SkipType (SymbolTable_GetType (subscript));
    8578       101396 :           if (SymbolTable_IsAModula2Type (type))
    8579              :             {}  /* empty.  */
    8580              :           else
    8581              :             {
    8582              :               /* Ok all is good.  */
    8583            0 :               M2MetaError_MetaError2 ((const char *) "the array {%1Dad} must be declared with a simpletype in the [..] component rather than a {%2dv}", 95, sym, type);
    8584              :             }
    8585              :         }
    8586              :     }
    8587     60377252 : }
    8588              : 
    8589              : 
    8590              : /*
    8591              :    ForeachSymbolDo - foreach symbol, call, P(sym).
    8592              : */
    8593              : 
    8594        14658 : static void ForeachSymbolDo (SymbolKey_PerformOperation P)
    8595              : {
    8596        14658 :   unsigned int i;
    8597        14658 :   unsigned int n;
    8598              : 
    8599        14658 :   i = Indexing_LowIndice (Symbols);
    8600        14658 :   n = Indexing_HighIndice (Symbols);
    8601     52381774 :   while (i <= n)
    8602              :     {
    8603     52352458 :       (*P.proc) (i);
    8604     52352458 :       i += 1;
    8605              :     }
    8606        14658 : }
    8607              : 
    8608              : 
    8609              : /*
    8610              :    SanityCheckProcedure - check to see that procedure parameters do not use constants
    8611              :                           instead of types in their formal parameter section.
    8612              : */
    8613              : 
    8614      4871412 : static void SanityCheckProcedure (unsigned int sym)
    8615              : {
    8616      4871412 :   SanityCheckParameters (sym);
    8617      4871412 : }
    8618              : 
    8619              : 
    8620              : /*
    8621              :    SanityCheckModule -
    8622              : */
    8623              : 
    8624       187231 : static void SanityCheckModule (unsigned int sym)
    8625              : {
    8626       187231 :   SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
    8627       187231 :   SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckProcedure});
    8628       187231 :   SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
    8629       187231 : }
    8630              : 
    8631              : 
    8632              : /*
    8633              :    AddNameTo - adds Name, n, to tree, s.
    8634              : */
    8635              : 
    8636      7898340 : static void AddNameTo (SymbolKey_SymbolTree s, unsigned int o)
    8637              : {
    8638      7898340 :   if ((SymbolKey_GetSymKey (s, SymbolTable_GetSymName (o))) == SymbolKey_NulKey)
    8639              :     {
    8640      6610226 :       SymbolKey_PutSymKey (s, SymbolTable_GetSymName (o), o);
    8641              :     }
    8642      7898340 : }
    8643              : 
    8644              : 
    8645              : /*
    8646              :    CollectSymbolFrom -
    8647              : */
    8648              : 
    8649          134 : static unsigned int CollectSymbolFrom (unsigned int tok, unsigned int scope, NameKey_Name n)
    8650              : {
    8651          134 :   NameKey_Name n1;
    8652          134 :   unsigned int sym;
    8653              : 
    8654          134 :   n1 = SymbolTable_GetSymName (scope);
    8655          134 :   if (DebugUnknowns)
    8656              :     {
    8657              :       M2Printf_printf2 ((const char *) "declaring %a in %a", 18, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n1, (sizeof (n1)-1));
    8658              :     }
    8659          134 :   sym = CheckScopeForSym (scope, n);
    8660          134 :   if (sym == SymbolTable_NulSym)
    8661              :     {
    8662           56 :       sym = FetchUnknownFrom (tok, scope, n);
    8663              :     }
    8664          134 :   if (DebugUnknowns)
    8665              :     {
    8666              :       M2Printf_printf1 ((const char *) " symbol created (%d)\\n", 22, (const unsigned char *) &sym, (sizeof (sym)-1));
    8667              :     }
    8668          134 :   return sym;
    8669              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8670              :   __builtin_unreachable ();
    8671              : }
    8672              : 
    8673              : 
    8674              : /*
    8675              :    CollectUnknown -
    8676              : */
    8677              : 
    8678          170 : static unsigned int CollectUnknown (unsigned int tok, unsigned int sym, NameKey_Name n)
    8679              : {
    8680          230 :   SymbolTable_PtrToSymbol pSym;
    8681          230 :   unsigned int s;
    8682              : 
    8683          230 :   s = SymbolTable_NulSym;
    8684          230 :   if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
    8685              :     {
    8686          116 :       return CollectSymbolFrom (tok, sym, n);
    8687              :     }
    8688          114 :   else if (SymbolTable_IsProcedure (sym))
    8689              :     {
    8690              :       /* avoid dangling else.  */
    8691          114 :       s = CheckScopeForSym (sym, n);
    8692          114 :       if (s == SymbolTable_NulSym)
    8693              :         {
    8694           78 :           pSym = GetPsym (sym);
    8695           78 :           switch (pSym->SymbolType)
    8696              :             {
    8697           78 :               case SymbolTable_ProcedureSym:
    8698           78 :                 if ((SymbolKey_GetSymKey (pSym->Procedure.NamedObjects, n)) != SymbolKey_NulKey)
    8699              :                   {
    8700           18 :                     return CollectSymbolFrom (tok, sym, n);
    8701              :                   }
    8702           60 :                 break;
    8703              : 
    8704              : 
    8705            0 :               default:
    8706            0 :                 M2Error_InternalError ((const char *) "expecting - Procedure symbol", 28);
    8707           60 :                 break;
    8708              :             }
    8709           60 :           s = CollectUnknown (tok, SymbolTable_GetScope (sym), n);
    8710              :         }
    8711              :     }
    8712              :   return s;
    8713              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8714              :   __builtin_unreachable ();
    8715              : }
    8716              : 
    8717              : 
    8718              : /*
    8719              :    ResolveImport -
    8720              : */
    8721              : 
    8722          170 : static void ResolveImport (unsigned int o)
    8723              : {
    8724          170 :   NameKey_Name n1;
    8725          170 :   NameKey_Name n2;
    8726          170 :   unsigned int tok;
    8727          170 :   unsigned int sym;
    8728              : 
    8729          170 :   if (DebugUnknowns)
    8730              :     {
    8731              :       n1 = SymbolTable_GetSymName (o);
    8732              :       M2Printf_printf1 ((const char *) "attempting to find out where %a was declared\\n", 46, (const unsigned char *) &n1, (sizeof (n1)-1));
    8733              :       n1 = SymbolTable_GetSymName (ResolveModule);
    8734              :       n2 = SymbolTable_GetSymName (SymbolTable_GetScope (ResolveModule));
    8735              :       M2Printf_printf2 ((const char *) "scope of module %a is %a\\n", 26, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
    8736              :     }
    8737          170 :   tok = SymbolTable_GetFirstUsed (o);
    8738          170 :   sym = CollectUnknown (tok, SymbolTable_GetScope (ResolveModule), SymbolTable_GetSymName (o));
    8739          170 :   if (sym == SymbolTable_NulSym)
    8740              :     {
    8741            0 :       M2MetaError_MetaError2 ((const char *) "unknown symbol {%1Uad} found in import list of module {%2a}", 59, o, ResolveModule);
    8742              :     }
    8743              :   else
    8744              :     {
    8745          170 :       SymbolTable_AddSymToModuleScope (ResolveModule, sym);
    8746              :     }
    8747          170 : }
    8748              : 
    8749              : 
    8750              : /*
    8751              :    ResolveRelativeImport -
    8752              : */
    8753              : 
    8754      1919433 : static void ResolveRelativeImport (unsigned int sym)
    8755              : {
    8756      1919433 :   SymbolTable_PtrToSymbol pSym;
    8757              : 
    8758      1919433 :   if (SymbolTable_IsModule (sym))
    8759              :     {
    8760          428 :       ResolveModule = sym;
    8761          428 :       pSym = GetPsym (sym);
    8762          428 :       switch (pSym->SymbolType)
    8763              :         {
    8764          428 :           case SymbolTable_ModuleSym:
    8765          428 :             SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveImport});
    8766          428 :             break;
    8767              : 
    8768              : 
    8769            0 :           default:
    8770            0 :             M2Error_InternalError ((const char *) "expecting - Module symbol", 25);
    8771          428 :             break;
    8772              :         }
    8773              :     }
    8774      1919433 :   SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
    8775      1919433 :   SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
    8776      1919433 : }
    8777              : 
    8778              : 
    8779              : /*
    8780              :    Max -
    8781              : */
    8782              : 
    8783            0 : static unsigned int Max (unsigned int a, unsigned int b)
    8784              : {
    8785            0 :   if (a > b)
    8786              :     {
    8787              :       return a;
    8788              :     }
    8789              :   else
    8790              :     {
    8791              :       return b;
    8792              :     }
    8793              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8794              :   __builtin_unreachable ();
    8795              : }
    8796              : 
    8797              : 
    8798              : /*
    8799              :    Min -
    8800              : */
    8801              : 
    8802            0 : static unsigned int Min (unsigned int a, unsigned int b)
    8803              : {
    8804            0 :   if (a < b)
    8805              :     {
    8806              :       return a;
    8807              :     }
    8808              :   else
    8809              :     {
    8810              :       return b;
    8811              :     }
    8812              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8813              :   __builtin_unreachable ();
    8814              : }
    8815              : 
    8816              : 
    8817              : /*
    8818              :    DoFindLimits - assigns, Start, and, End, to the start and end
    8819              :                   limits contained in the list, l.  It ensures that
    8820              :                   Start and End are within StartLimit..EndLimit.
    8821              :                   If StartLimit or EndLimit are 0 then Start is
    8822              :                   is set to the first value and End to the last.
    8823              : */
    8824              : 
    8825           30 : static void DoFindLimits (unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End, Lists_List l)
    8826              : {
    8827           30 :   unsigned int i;
    8828           30 :   unsigned int j;
    8829           30 :   unsigned int n;
    8830              : 
    8831           30 :   (*End) = 0;
    8832           30 :   (*Start) = 0;
    8833           30 :   i = 1;
    8834           30 :   n = Lists_NoOfItemsInList (l);
    8835           90 :   while (i <= n)
    8836              :     {
    8837           30 :       j = static_cast<unsigned int> (Lists_GetItemFromList (l, i));
    8838           30 :       if (((j > (*End)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
    8839              :         {
    8840           24 :           (*End) = j;
    8841              :         }
    8842           30 :       if ((((((*Start) == 0) || (j < (*Start))) && (j != 0)) && (j >= StartLimit)) && ((j <= EndLimit) || (EndLimit == 0)))
    8843              :         {
    8844           24 :           (*Start) = j;
    8845              :         }
    8846           30 :       i += 1;
    8847              :     }
    8848           30 : }
    8849              : 
    8850              : 
    8851              : /*
    8852              :    PutDeclaredDefinition - associates the current tokenno with
    8853              :                            the symbols declaration in the definition
    8854              :                            module.
    8855              : */
    8856              : 
    8857     18484094 : static void PutDeclaredDefinition (unsigned int tok, unsigned int Sym)
    8858              : {
    8859     18484094 :   SymbolTable_PtrToSymbol pSym;
    8860              : 
    8861     18484094 :   pSym = GetPsym (Sym);
    8862     18484094 :   switch (pSym->SymbolType)
    8863              :     {
    8864            0 :       case SymbolTable_ErrorSym:
    8865            0 :         pSym->Error.At.DefDeclared = tok;
    8866            0 :         break;
    8867              : 
    8868            0 :       case SymbolTable_ObjectSym:
    8869            0 :         pSym->Object.At.DefDeclared = tok;
    8870            0 :         break;
    8871              : 
    8872            0 :       case SymbolTable_VarientSym:
    8873            0 :         pSym->Varient.At.DefDeclared = tok;
    8874            0 :         break;
    8875              : 
    8876            0 :       case SymbolTable_RecordSym:
    8877            0 :         pSym->Record.At.DefDeclared = tok;
    8878            0 :         break;
    8879              : 
    8880            0 :       case SymbolTable_SubrangeSym:
    8881            0 :         pSym->Subrange.At.DefDeclared = tok;
    8882            0 :         break;
    8883              : 
    8884            0 :       case SymbolTable_EnumerationSym:
    8885            0 :         pSym->Enumeration.At.DefDeclared = tok;
    8886            0 :         break;
    8887              : 
    8888          998 :       case SymbolTable_ArraySym:
    8889          998 :         pSym->Array.At.DefDeclared = tok;
    8890          998 :         break;
    8891              : 
    8892            0 :       case SymbolTable_SubscriptSym:
    8893            0 :         pSym->Subscript.At.DefDeclared = tok;
    8894            0 :         break;
    8895              : 
    8896            0 :       case SymbolTable_UnboundedSym:
    8897            0 :         pSym->Unbounded.At.DefDeclared = tok;
    8898            0 :         break;
    8899              : 
    8900      3273319 :       case SymbolTable_ProcedureSym:
    8901      3273319 :         pSym->Procedure.At.DefDeclared = tok;
    8902      3273319 :         break;
    8903              : 
    8904            0 :       case SymbolTable_ProcTypeSym:
    8905            0 :         pSym->ProcType.At.DefDeclared = tok;
    8906            0 :         break;
    8907              : 
    8908            0 :       case SymbolTable_ConstStringSym:
    8909            0 :         pSym->ConstString.At.DefDeclared = tok;
    8910            0 :         break;
    8911              : 
    8912            0 :       case SymbolTable_ConstLitSym:
    8913            0 :         pSym->ConstLit.At.DefDeclared = tok;
    8914            0 :         break;
    8915              : 
    8916         3940 :       case SymbolTable_ConstVarSym:
    8917         3940 :         pSym->ConstVar.At.DefDeclared = tok;
    8918         3940 :         break;
    8919              : 
    8920      6946552 :       case SymbolTable_VarSym:
    8921      6946552 :         pSym->Var.At.DefDeclared = tok;
    8922      6946552 :         break;
    8923              : 
    8924            0 :       case SymbolTable_TypeSym:
    8925            0 :         pSym->Type.At.DefDeclared = tok;
    8926            0 :         break;
    8927              : 
    8928            0 :       case SymbolTable_PointerSym:
    8929            0 :         pSym->Pointer.At.DefDeclared = tok;
    8930            0 :         break;
    8931              : 
    8932        94512 :       case SymbolTable_RecordFieldSym:
    8933        94512 :         pSym->RecordField.At.DefDeclared = tok;
    8934        94512 :         break;
    8935              : 
    8936            0 :       case SymbolTable_VarientFieldSym:
    8937            0 :         pSym->VarientField.At.DefDeclared = tok;
    8938            0 :         break;
    8939              : 
    8940            0 :       case SymbolTable_EnumerationFieldSym:
    8941            0 :         pSym->EnumerationField.At.DefDeclared = tok;
    8942            0 :         break;
    8943              : 
    8944            0 :       case SymbolTable_SetSym:
    8945            0 :         pSym->Set.At.DefDeclared = tok;
    8946            0 :         break;
    8947              : 
    8948      8164587 :       case SymbolTable_DefImpSym:
    8949      8164587 :         pSym->DefImp.At.DefDeclared = tok;
    8950      8164587 :         break;
    8951              : 
    8952          186 :       case SymbolTable_ModuleSym:
    8953          186 :         pSym->Module.At.DefDeclared = tok;
    8954          186 :         break;
    8955              : 
    8956              :       case SymbolTable_UndefinedSym:
    8957              :         break;
    8958              : 
    8959            0 :       case SymbolTable_PartialUnboundedSym:
    8960            0 :         PutDeclaredDefinition (tok, pSym->PartialUnbounded.Type);
    8961            0 :         break;
    8962              : 
    8963              : 
    8964            0 :       default:
    8965            0 :         M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
    8966     18484094 :         break;
    8967              :     }
    8968     18484094 : }
    8969              : 
    8970              : 
    8971              : /*
    8972              :    PutDeclaredModule - returns the token where this symbol was declared
    8973              :                        in an implementation or program module.
    8974              : */
    8975              : 
    8976     12916040 : static void PutDeclaredModule (unsigned int tok, unsigned int Sym)
    8977              : {
    8978     12916040 :   SymbolTable_PtrToSymbol pSym;
    8979              : 
    8980     12916040 :   pSym = GetPsym (Sym);
    8981     12916040 :   switch (pSym->SymbolType)
    8982              :     {
    8983            0 :       case SymbolTable_ErrorSym:
    8984            0 :         pSym->Error.At.ModDeclared = tok;
    8985            0 :         break;
    8986              : 
    8987            0 :       case SymbolTable_ObjectSym:
    8988            0 :         pSym->Object.At.ModDeclared = tok;
    8989            0 :         break;
    8990              : 
    8991            0 :       case SymbolTable_VarientSym:
    8992            0 :         pSym->Varient.At.ModDeclared = tok;
    8993            0 :         break;
    8994              : 
    8995            0 :       case SymbolTable_RecordSym:
    8996            0 :         pSym->Record.At.ModDeclared = tok;
    8997            0 :         break;
    8998              : 
    8999            0 :       case SymbolTable_SubrangeSym:
    9000            0 :         pSym->Subrange.At.ModDeclared = tok;
    9001            0 :         break;
    9002              : 
    9003            0 :       case SymbolTable_EnumerationSym:
    9004            0 :         pSym->Enumeration.At.ModDeclared = tok;
    9005            0 :         break;
    9006              : 
    9007        99124 :       case SymbolTable_ArraySym:
    9008        99124 :         pSym->Array.At.ModDeclared = tok;
    9009        99124 :         break;
    9010              : 
    9011            0 :       case SymbolTable_SubscriptSym:
    9012            0 :         pSym->Subscript.At.ModDeclared = tok;
    9013            0 :         break;
    9014              : 
    9015            0 :       case SymbolTable_UnboundedSym:
    9016            0 :         pSym->Unbounded.At.ModDeclared = tok;
    9017            0 :         break;
    9018              : 
    9019      3153493 :       case SymbolTable_ProcedureSym:
    9020      3153493 :         pSym->Procedure.At.ModDeclared = tok;
    9021      3153493 :         break;
    9022              : 
    9023            0 :       case SymbolTable_ProcTypeSym:
    9024            0 :         pSym->ProcType.At.ModDeclared = tok;
    9025            0 :         break;
    9026              : 
    9027            0 :       case SymbolTable_ConstStringSym:
    9028            0 :         pSym->ConstString.At.ModDeclared = tok;
    9029            0 :         break;
    9030              : 
    9031            0 :       case SymbolTable_ConstLitSym:
    9032            0 :         pSym->ConstLit.At.ModDeclared = tok;
    9033            0 :         break;
    9034              : 
    9035         7002 :       case SymbolTable_ConstVarSym:
    9036         7002 :         pSym->ConstVar.At.ModDeclared = tok;
    9037         7002 :         break;
    9038              : 
    9039      3537392 :       case SymbolTable_VarSym:
    9040      3537392 :         pSym->Var.At.ModDeclared = tok;
    9041      3537392 :         break;
    9042              : 
    9043            0 :       case SymbolTable_TypeSym:
    9044            0 :         pSym->Type.At.ModDeclared = tok;
    9045            0 :         break;
    9046              : 
    9047            0 :       case SymbolTable_PointerSym:
    9048            0 :         pSym->Pointer.At.ModDeclared = tok;
    9049            0 :         break;
    9050              : 
    9051       249354 :       case SymbolTable_RecordFieldSym:
    9052       249354 :         pSym->RecordField.At.ModDeclared = tok;
    9053       249354 :         break;
    9054              : 
    9055            0 :       case SymbolTable_VarientFieldSym:
    9056            0 :         pSym->VarientField.At.ModDeclared = tok;
    9057            0 :         break;
    9058              : 
    9059            0 :       case SymbolTable_EnumerationFieldSym:
    9060            0 :         pSym->EnumerationField.At.ModDeclared = tok;
    9061            0 :         break;
    9062              : 
    9063            0 :       case SymbolTable_SetSym:
    9064            0 :         pSym->Set.At.ModDeclared = tok;
    9065            0 :         break;
    9066              : 
    9067      5810868 :       case SymbolTable_DefImpSym:
    9068      5810868 :         pSym->DefImp.At.ModDeclared = tok;
    9069      5810868 :         break;
    9070              : 
    9071        58807 :       case SymbolTable_ModuleSym:
    9072        58807 :         pSym->Module.At.ModDeclared = tok;
    9073        58807 :         break;
    9074              : 
    9075              :       case SymbolTable_UndefinedSym:
    9076              :         break;
    9077              : 
    9078            0 :       case SymbolTable_PartialUnboundedSym:
    9079            0 :         PutDeclaredModule (tok, pSym->PartialUnbounded.Type);
    9080            0 :         break;
    9081              : 
    9082              : 
    9083            0 :       default:
    9084            0 :         M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
    9085     12916040 :         break;
    9086              :     }
    9087     12916040 : }
    9088              : 
    9089              : 
    9090              : /*
    9091              :    DoIsConst - returns TRUE if Sym is defined as a constant
    9092              :                or is an enumeration field or string.
    9093              : */
    9094              : 
    9095    232090682 : static bool DoIsConst (unsigned int Sym)
    9096              : {
    9097    232090682 :   SymbolTable_PtrToSymbol pSym;
    9098              : 
    9099    232090682 :   pSym = GetPsym (Sym);
    9100    232090682 :   return ((((pSym->SymbolType == SymbolTable_ConstVarSym) || (pSym->SymbolType == SymbolTable_ConstLitSym)) || (pSym->SymbolType == SymbolTable_ConstStringSym)) || ((pSym->SymbolType == SymbolTable_VarSym) && (pSym->Var.AddrMode == SymbolTable_ImmediateValue))) || (pSym->SymbolType == SymbolTable_EnumerationFieldSym);
    9101              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9102              :   __builtin_unreachable ();
    9103              : }
    9104              : 
    9105              : 
    9106              : /*
    9107              :    GetFromIndex - return a value from list, i, at position, n.
    9108              : */
    9109              : 
    9110      7587360 : static unsigned int GetFromIndex (Indexing_Index i, unsigned int n)
    9111              : {
    9112      7587360 :   typedef unsigned int *GetFromIndex__T2;
    9113              : 
    9114      7587360 :   GetFromIndex__T2 p;
    9115              : 
    9116      6553620 :   p = static_cast<GetFromIndex__T2> (Indexing_GetIndice (i, n));
    9117      6553620 :   return (*p);
    9118              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9119              :   __builtin_unreachable ();
    9120              : }
    9121              : 
    9122              : 
    9123              : /*
    9124              :    PutIntoIndex - places value, v, into list, i, at position, n.
    9125              : */
    9126              : 
    9127       322554 : static void PutIntoIndex (Indexing_Index *i, unsigned int n, unsigned int v)
    9128              : {
    9129       322554 :   typedef unsigned int *PutIntoIndex__T3;
    9130              : 
    9131       322554 :   PutIntoIndex__T3 p;
    9132              : 
    9133       322554 :   Storage_ALLOCATE ((void **) &p, sizeof (unsigned int));
    9134       322554 :   (*p) = v;
    9135       322554 :   Indexing_PutIndice ((*i), n, reinterpret_cast <void *> (p));
    9136       322554 : }
    9137              : 
    9138              : 
    9139              : /*
    9140              :    PushConstString - pushes the character string onto the ALU stack.
    9141              :                      It assumes that the character string is only
    9142              :                      one character long.
    9143              : */
    9144              : 
    9145        32924 : static void PushConstString (unsigned int Sym)
    9146              : {
    9147        32924 :   typedef struct PushConstString__T7_a PushConstString__T7;
    9148              : 
    9149        32924 :   struct PushConstString__T7_a { char array[10+1]; };
    9150        32924 :   SymbolTable_PtrToSymbol pSym;
    9151        32924 :   PushConstString__T7 a;
    9152              : 
    9153        32924 :   AssertInRange (Sym);
    9154        32924 :   pSym = GetPsym (Sym);
    9155        32924 :   switch (pSym->SymbolType)
    9156              :     {
    9157        32924 :       case SymbolTable_ConstStringSym:
    9158        32924 :         if (pSym->ConstString.Length == 0)
    9159              :           {
    9160            6 :             M2ALU_PushChar (ASCII_nul);
    9161              :           }
    9162        32918 :         else if (pSym->ConstString.Length == 1)
    9163              :           {
    9164              :             /* avoid dangling else.  */
    9165        32918 :             NameKey_GetKey (pSym->ConstString.Contents, (char *) &a.array[0], 10);
    9166        32918 :             M2ALU_PushChar (a.array[0]);
    9167              :           }
    9168              :         else
    9169              :           {
    9170              :             /* avoid dangling else.  */
    9171            0 :             M2Error_WriteFormat0 ((const char *) "ConstString must be length 0 or 1", 33);
    9172              :           }
    9173        32924 :         break;
    9174              : 
    9175              : 
    9176            0 :       default:
    9177            0 :         M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
    9178        32924 :         break;
    9179              :     }
    9180        32924 : }
    9181              : 
    9182              : 
    9183              : /*
    9184              :    FinalSymbol - returns the highest number symbol used.
    9185              : */
    9186              : 
    9187   5397671716 : extern "C" unsigned int SymbolTable_FinalSymbol (void)
    9188              : {
    9189   5397671716 :   return FreeSymbol-1;
    9190              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9191              :   __builtin_unreachable ();
    9192              : }
    9193              : 
    9194              : 
    9195              : /*
    9196              :    MakeComponentRecord - make a temporary which will be used to reference and field
    9197              :                          (or sub field) of record.
    9198              : */
    9199              : 
    9200       143312 : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record)
    9201              : {
    9202       143312 :   return buildTemporary (tok, Mode, true, record);
    9203              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9204              :   __builtin_unreachable ();
    9205              : }
    9206              : 
    9207              : 
    9208              : /*
    9209              :    MakeComponentRef - use, sym, to reference, field, sym is returned.
    9210              : */
    9211              : 
    9212       143312 : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field)
    9213              : {
    9214       143312 :   SymbolTable_PtrToSymbol pSym;
    9215       143312 :   unsigned int high;
    9216              : 
    9217       143312 :   pSym = GetPsym (sym);
    9218       143312 :   switch (pSym->SymbolType)
    9219              :     {
    9220       143312 :       case SymbolTable_VarSym:
    9221       143312 :         if (! pSym->Var.IsTemp)
    9222              :           {
    9223            0 :             M2Error_InternalError ((const char *) "variable must be a temporary", 28);
    9224              :           }
    9225       143312 :         else if (pSym->Var.IsComponentRef)
    9226              :           {
    9227              :             /* avoid dangling else.  */
    9228       143312 :             high = Indexing_HighIndice (pSym->Var.list);
    9229       143312 :             PutIntoIndex (&pSym->Var.list, high+1, field);
    9230              :           }
    9231              :         else
    9232              :           {
    9233              :             /* avoid dangling else.  */
    9234            0 :             M2Error_InternalError ((const char *) "temporary is not a component reference", 38);
    9235              :           }
    9236       143312 :         break;
    9237              : 
    9238              : 
    9239            0 :       default:
    9240            0 :         M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
    9241       143312 :         break;
    9242              :     }
    9243       143312 :   return sym;
    9244              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9245              :   __builtin_unreachable ();
    9246              : }
    9247              : 
    9248              : 
    9249              : /*
    9250              :    IsComponent - returns TRUE if symbol, sym, is a temporary and a component
    9251              :                  reference.
    9252              : */
    9253              : 
    9254    413487999 : extern "C" bool SymbolTable_IsComponent (unsigned int sym)
    9255              : {
    9256    413487999 :   SymbolTable_PtrToSymbol pSym;
    9257              : 
    9258    413487999 :   pSym = GetPsym (sym);
    9259    413487999 :   switch (pSym->SymbolType)
    9260              :     {
    9261      2646236 :       case SymbolTable_VarSym:
    9262      2646236 :         return pSym->Var.IsComponentRef;
    9263              :         break;
    9264              : 
    9265              : 
    9266              :       default:
    9267              :         return false;
    9268              :         break;
    9269              :     }
    9270              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9271              :   __builtin_unreachable ();
    9272              : }
    9273              : 
    9274              : 
    9275              : /*
    9276              :    MakeTemporary - Makes a new temporary variable at the highest real scope.
    9277              :                    The addressing mode of the temporary is set to NoValue.
    9278              : */
    9279              : 
    9280      1000742 : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode)
    9281              : {
    9282      1000742 :   tok = CheckTok (tok, (const char *) "temporary", 9);
    9283      1000742 :   return buildTemporary (tok, Mode, false, SymbolTable_NulSym);
    9284              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9285              :   __builtin_unreachable ();
    9286              : }
    9287              : 
    9288              : 
    9289              : /*
    9290              :    MakeTemporaryFromExpression - makes a new temporary variable at the
    9291              :                                  highest real scope.  The addressing
    9292              :                                  mode of the temporary is set and the
    9293              :                                  type is determined by expressions, e.
    9294              : */
    9295              : 
    9296            0 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode)
    9297              : {
    9298            0 :   return SymbolTable_MakeTemporaryFromExpressions (tok, e, e, mode);
    9299              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9300              :   __builtin_unreachable ();
    9301              : }
    9302              : 
    9303              : 
    9304              : /*
    9305              :    MakeTemporaryFromExpressions - makes a new temporary variable at the
    9306              :                                   highest real scope.  The addressing
    9307              :                                   mode of the temporary is set and the
    9308              :                                   type is determined by expressions,
    9309              :                                   e1 and e2.
    9310              : */
    9311              : 
    9312        76298 : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode)
    9313              : {
    9314        76298 :   SymbolTable_PtrToSymbol pSym;
    9315        76298 :   DynamicStrings_String s;
    9316        76298 :   unsigned int t;
    9317        76298 :   unsigned int Sym;
    9318              : 
    9319        76298 :   TemporaryNo += 1;
    9320              :   /* Make the name  */
    9321        76298 :   s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_T%d", 4)), (const unsigned char *) &TemporaryNo, (sizeof (TemporaryNo)-1));
    9322        76298 :   if (mode == SymbolTable_ImmediateValue)
    9323              :     {
    9324        34419 :       Sym = SymbolTable_MakeConstVar (tok, NameKey_makekey (DynamicStrings_string (s)));
    9325        34419 :       if (SymbolTable_IsConstructor (e1))
    9326              :         {
    9327          218 :           SymbolTable_PutConstructor (Sym);
    9328          218 :           SymbolTable_PutConstructorFrom (Sym, e1);
    9329              :         }
    9330        34201 :       else if (SymbolTable_IsConstructor (e2))
    9331              :         {
    9332              :           /* avoid dangling else.  */
    9333           12 :           SymbolTable_PutConstructor (Sym);
    9334           12 :           SymbolTable_PutConstructorFrom (Sym, e2);
    9335              :         }
    9336              :       else
    9337              :         {
    9338              :           /* avoid dangling else.  */
    9339        34189 :           SymbolTable_PutVar (Sym, M2Base_MixTypes (SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok));
    9340              :         }
    9341        34419 :       PutConstVarTemporary (Sym);
    9342              :     }
    9343              :   else
    9344              :     {
    9345        41879 :       Sym = SymbolTable_MakeVar (tok, NameKey_makekey (DynamicStrings_string (s)));
    9346        41879 :       pSym = GetPsym (Sym);
    9347        41879 :       switch (pSym->SymbolType)
    9348              :         {
    9349        41879 :           case SymbolTable_VarSym:
    9350        41879 :             pSym->Var.AddrMode = mode;
    9351        41879 :             pSym->Var.IsComponentRef = false;
    9352        41879 :             pSym->Var.IsTemp = true;  /* Variable is a temporary var  */
    9353              :             /* Declared here  */
    9354        41879 :             InitWhereDeclaredTok (tok, &pSym->Var.At);
    9355        41879 :             break;
    9356              : 
    9357              : 
    9358            0 :           default:
    9359            0 :             M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
    9360        41879 :             break;
    9361              :         }
    9362        41879 :       t = M2Base_MixTypesDecl (e1, e2, SymbolTable_GetType (e1), SymbolTable_GetType (e2), tok);
    9363        41771 :       if (t != SymbolTable_NulSym)
    9364              :         {
    9365        41759 :           M2Debug_Assert (! (SymbolTable_IsConstructor (t)));
    9366        41759 :           SymbolTable_PutVar (Sym, t);
    9367              :         }
    9368              :     }
    9369        76190 :   s = DynamicStrings_KillString (s);
    9370        76190 :   return Sym;
    9371              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9372              :   __builtin_unreachable ();
    9373              : }
    9374              : 
    9375              : 
    9376              : /*
    9377              :    PutMode - Puts the addressing mode, SymMode, into symbol Sym.
    9378              :              The mode may only be altered if the mode
    9379              :              is None.
    9380              : */
    9381              : 
    9382      8789000 : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode)
    9383              : {
    9384      8789000 :   SymbolTable_PtrToSymbol pSym;
    9385              : 
    9386      8789000 :   pSym = GetPsym (Sym);
    9387      8789000 :   switch (pSym->SymbolType)
    9388              :     {
    9389              :       case SymbolTable_ErrorSym:
    9390              :         break;
    9391              : 
    9392      8789000 :       case SymbolTable_VarSym:
    9393      8789000 :         pSym->Var.AddrMode = SymMode;
    9394      8789000 :         break;
    9395              : 
    9396              : 
    9397            0 :       default:
    9398            0 :         M2Error_InternalError ((const char *) "Expecting VarSym", 16);
    9399      8789000 :         break;
    9400              :     }
    9401      8789000 : }
    9402              : 
    9403              : 
    9404              : /*
    9405              :    GetMode - Returns the addressing mode of a symbol.
    9406              : */
    9407              : 
    9408     10336698 : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym)
    9409              : {
    9410     10336698 :   SymbolTable_PtrToSymbol pSym;
    9411              : 
    9412     10336698 :   pSym = GetPsym (Sym);
    9413     10336698 :   switch (pSym->SymbolType)
    9414              :     {
    9415            6 :       case SymbolTable_ErrorSym:
    9416            6 :         M2Error_ErrorAbort0 ((const char *) "", 0);
    9417      8355662 :         break;
    9418              : 
    9419      8355662 :       case SymbolTable_VarSym:
    9420      8355662 :         return pSym->Var.AddrMode;
    9421              :         break;
    9422              : 
    9423              :       case SymbolTable_ConstLitSym:
    9424              :         return SymbolTable_ImmediateValue;
    9425              :         break;
    9426              : 
    9427              :       case SymbolTable_ConstVarSym:
    9428              :         return SymbolTable_ImmediateValue;
    9429              :         break;
    9430              : 
    9431              :       case SymbolTable_ConstStringSym:
    9432              :         return SymbolTable_ImmediateValue;
    9433              :         break;
    9434              : 
    9435              :       case SymbolTable_EnumerationFieldSym:
    9436              :         return SymbolTable_ImmediateValue;
    9437              :         break;
    9438              : 
    9439              :       case SymbolTable_ProcedureSym:
    9440              :         return SymbolTable_ImmediateValue;
    9441              :         break;
    9442              : 
    9443              :       case SymbolTable_RecordFieldSym:
    9444              :         return SymbolTable_ImmediateValue;
    9445              :         break;
    9446              : 
    9447              :       case SymbolTable_VarientFieldSym:
    9448              :         return SymbolTable_ImmediateValue;
    9449              :         break;
    9450              : 
    9451              :       case SymbolTable_TypeSym:
    9452              :         return SymbolTable_NoValue;
    9453              :         break;
    9454              : 
    9455              :       case SymbolTable_ArraySym:
    9456              :         return SymbolTable_NoValue;
    9457              :         break;
    9458              : 
    9459              :       case SymbolTable_SubrangeSym:
    9460              :         return SymbolTable_NoValue;
    9461              :         break;
    9462              : 
    9463              :       case SymbolTable_EnumerationSym:
    9464              :         return SymbolTable_NoValue;
    9465              :         break;
    9466              : 
    9467              :       case SymbolTable_RecordSym:
    9468              :         return SymbolTable_NoValue;
    9469              :         break;
    9470              : 
    9471              :       case SymbolTable_PointerSym:
    9472              :         return SymbolTable_NoValue;
    9473              :         break;
    9474              : 
    9475              :       case SymbolTable_SetSym:
    9476              :         return SymbolTable_NoValue;
    9477              :         break;
    9478              : 
    9479              :       case SymbolTable_ProcTypeSym:
    9480              :         return SymbolTable_NoValue;
    9481              :         break;
    9482              : 
    9483              :       case SymbolTable_UnboundedSym:
    9484              :         return SymbolTable_NoValue;
    9485              :         break;
    9486              : 
    9487              :       case SymbolTable_UndefinedSym:
    9488              :         return SymbolTable_NoValue;
    9489            0 :         break;
    9490              : 
    9491              : 
    9492            0 :       default:
    9493            0 :         M2Error_InternalError ((const char *) "not expecting this type", 23);
    9494              :         break;
    9495              :     }
    9496              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    9497              :   __builtin_unreachable ();
    9498              : }
    9499              : 
    9500              : 
    9501              : /*
    9502              :    StartScope - starts a block scope at Sym. Transparent determines
    9503              :                 whether the search for a symbol will look at the
    9504              :                 previous ScopeCallFrame if Sym does not contain the
    9505              :                 symbol that GetSym is searching.
    9506              : 
    9507              :                 WITH statements are partially implemented by calling
    9508              :                 StartScope. Therefore we must retain the old Main from
    9509              :                 the previous ScopePtr when a record is added to the scope
    9510              :                 stack. (Main contains the symbol where all identifiers
    9511              :                 should be added.)
    9512              : */
    9513              : 
    9514     31128734 : extern "C" void SymbolTable_StartScope (unsigned int Sym)
    9515              : {
    9516     31128734 :   SymbolTable_PtrToCallFrame oCall;
    9517     31128734 :   SymbolTable_PtrToCallFrame pCall;
    9518              : 
    9519     31128734 :   Sym = SymbolTable_SkipType (Sym);
    9520              :   /* 
    9521              :    WriteString('New scope is: ') ; WriteKey(GetSymName(Sym)) ; WriteLn ;
    9522              :   */
    9523     31128734 :   ScopePtr += 1;
    9524     31128734 :   if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
    9525              :     {
    9526     31064038 :       pCall = GetPcall (ScopePtr);
    9527              :     }
    9528              :   else
    9529              :     {
    9530        64696 :       Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
    9531        64696 :       Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
    9532              :     }
    9533     31128734 :   pCall->Start = ScopePtr-1;  /* Previous ScopePtr value before StartScope  */
    9534     31128734 :   pCall->Search = Sym;
    9535              :   /* new symbols to ie temporary variables.  */
    9536     31128734 :   if (SymbolTable_IsRecord (Sym))
    9537              :     {
    9538        32104 :       oCall = GetPcall (ScopePtr-1);
    9539        32104 :       pCall->Main = oCall->Main;
    9540              :     }
    9541              :   else
    9542              :     {
    9543     31096624 :       pCall->Main = Sym;
    9544     31096624 :       PlaceMajorScopesEnumerationListOntoStack (Sym);
    9545              :     }
    9546     31128727 : }
    9547              : 
    9548              : 
    9549              : /*
    9550              :    EndScope - ends a block scope started by StartScope. The current
    9551              :               head of the symbol scope reverts back to the symbol
    9552              :               which was the Head of the symbol scope before the
    9553              :               last StartScope was called.
    9554              : */
    9555              : 
    9556     31113435 : extern "C" void SymbolTable_EndScope (void)
    9557              : {
    9558     31113435 :   SymbolTable_PtrToCallFrame pCall;
    9559              : 
    9560              :   /* 
    9561              :    ; WriteString('EndScope - ending scope: ') ;
    9562              :    pCall := GetPcall(ScopePtr) ;
    9563              :    ; WriteKey(GetSymName(pCall^.Search)) ; WriteLn ;
    9564              :   */
    9565     31113435 :   pCall = GetPcall (ScopePtr);
    9566              :   /* ; DisplayScopes  */
    9567     31113435 :   ScopePtr = pCall->Start;
    9568     31113435 : }
    9569              : 
    9570              : 
    9571              : /*
    9572              :    PseudoScope - starts a pseudo scope at Sym.
    9573              :                  We always connect parent up to the last scope,
    9574              :                  to determine the transparancy of a scope we call
    9575              :                  TransparentScope.
    9576              : 
    9577              :                  A Pseudo scope has no end block,
    9578              :                  but is terminated when the next EndScope is used.
    9579              :                  The function of the pseudo scope is to provide an
    9580              :                  automatic mechanism to solve enumeration types.
    9581              :                  A declared enumeration type is a Pseudo scope and
    9582              :                  identifiers used with the name of an enumeration
    9583              :                  type field will find the enumeration symbol by
    9584              :                  the scoping algorithm.
    9585              : */
    9586              : 
    9587       633454 : extern "C" void SymbolTable_PseudoScope (unsigned int Sym)
    9588              : {
    9589       633454 :   SymbolTable_PtrToCallFrame oCall;
    9590       633454 :   SymbolTable_PtrToCallFrame pCall;
    9591              : 
    9592       633454 :   if (SymbolTable_IsEnumeration (Sym))
    9593              :     {
    9594       633454 :       ScopePtr += 1;
    9595       633454 :       if (Indexing_InBounds (ScopeCallFrame, ScopePtr))
    9596              :         {
    9597       614620 :           pCall = GetPcall (ScopePtr);
    9598              :         }
    9599              :       else
    9600              :         {
    9601        18834 :           Storage_ALLOCATE ((void **) &pCall, sizeof (SymbolTable_CallFrame));
    9602        18834 :           Indexing_PutIndice (ScopeCallFrame, ScopePtr, reinterpret_cast <void *> (pCall));
    9603              :         }
    9604       633454 :       oCall = GetPcall (ScopePtr-1);
    9605       633454 :       pCall->Main = oCall->Main;
    9606       633454 :       pCall->Start = oCall->Start;
    9607       633454 :       pCall->Search = Sym;
    9608              :     }
    9609              :   else
    9610              :     {
    9611            0 :       M2Error_InternalError ((const char *) "expecting EnumerationSym", 24);
    9612              :     }
    9613       633454 : }
    9614              : 
    9615              : 
    9616              : /*
    9617              :    GetCurrentScope - returns the symbol who is responsible for the current
    9618              :                      scope. Note that it ignore pseudo scopes.
    9619              : */
    9620              : 
    9621     39790121 : extern "C" unsigned int SymbolTable_GetCurrentScope (void)
    9622              : {
    9623     39790121 :   SymbolTable_PtrToCallFrame pCall;
    9624              : 
    9625     39790121 :   pCall = GetPcall (ScopePtr);
    9626     39790121 :   return pCall->Main;
    9627              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9628              :   __builtin_unreachable ();
    9629              : }
    9630              : 
    9631              : 
    9632              : /*
    9633              :    IsDeclaredIn - returns TRUE if a symbol was declared in, scope.
    9634              : */
    9635              : 
    9636       252504 : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym)
    9637              : {
    9638       252504 :   unsigned int s;
    9639              : 
    9640       252504 :   s = SymbolTable_GetScope (sym);
    9641       505008 :   while (s != scope)
    9642              :     {
    9643         1462 :       if ((((s == SymbolTable_NulSym) || (SymbolTable_IsProcedure (s))) || (SymbolTable_IsModule (s))) || (SymbolTable_IsDefImp (s)))
    9644              :         {
    9645         1462 :           return false;
    9646              :         }
    9647              :       else
    9648              :         {
    9649            0 :           s = SymbolTable_GetScope (s);
    9650              :         }
    9651              :     }
    9652              :   return true;
    9653              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9654              :   __builtin_unreachable ();
    9655              : }
    9656              : 
    9657              : 
    9658              : /*
    9659              :    SetCurrentModule - Used to set the CurrentModule to a symbol, Sym.
    9660              :                       This Sym must represent the module name of the
    9661              :                       file currently being compiled.
    9662              : */
    9663              : 
    9664      1265018 : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym)
    9665              : {
    9666      1265018 :   CurrentModule = Sym;
    9667      1265018 : }
    9668              : 
    9669              : 
    9670              : /*
    9671              :    SetFileModule - Used to set the FileModule to a symbol, Sym.
    9672              :                    This Sym must represent the current program module
    9673              :                    file which is being parsed.
    9674              : */
    9675              : 
    9676      1218466 : extern "C" void SymbolTable_SetFileModule (unsigned int Sym)
    9677              : {
    9678      1218466 :   FileModule = Sym;
    9679      1218466 : }
    9680              : 
    9681              : 
    9682              : /*
    9683              :    SetMainModule - Used to set the MainModule to a symbol, Sym.
    9684              :                    This Sym must represent the main module which was
    9685              :                    envoked by the user to be compiled.
    9686              : */
    9687              : 
    9688        14945 : extern "C" void SymbolTable_SetMainModule (unsigned int Sym)
    9689              : {
    9690        14945 :   MainModule = Sym;
    9691        14945 : }
    9692              : 
    9693              : 
    9694              : /*
    9695              :    CheckAnonymous - checks to see whether the name is NulName and if so
    9696              :                     it creates a unique anonymous name.
    9697              : */
    9698              : 
    9699      1442809 : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name)
    9700              : {
    9701      1442809 :   if (name == NameKey_NulName)
    9702              :     {
    9703        64780 :       AnonymousName += 1;
    9704        64780 :       name = NameKey_makekey (DynamicStrings_string (DynamicStrings_Mark (FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "__anon%d", 8)), (const unsigned char *) &AnonymousName, (sizeof (AnonymousName)-1)))));
    9705              :     }
    9706      1442809 :   return name;
    9707              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9708              :   __builtin_unreachable ();
    9709              : }
    9710              : 
    9711              : 
    9712              : /*
    9713              :    IsNameAnonymous - returns TRUE if the symbol, sym, has an anonymous name
    9714              :                      or no name.
    9715              : */
    9716              : 
    9717        56328 : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym)
    9718              : {
    9719        56328 :   typedef struct IsNameAnonymous__T8_a IsNameAnonymous__T8;
    9720              : 
    9721        56328 :   struct IsNameAnonymous__T8_a { char array[5+1]; };
    9722        56328 :   IsNameAnonymous__T8 a;
    9723        56328 :   NameKey_Name n;
    9724              : 
    9725        56328 :   n = SymbolTable_GetSymName (sym);
    9726        56328 :   if (n == NameKey_NulName)
    9727              :     {
    9728              :       return true;
    9729              :     }
    9730              :   else
    9731              :     {
    9732        55074 :       NameKey_GetKey (n, (char *) &a.array[0], 5);
    9733        55074 :       return StrLib_StrEqual ((const char *) &a.array[0], 5, (const char *) "__anon", 6);
    9734              :     }
    9735              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9736              :   __builtin_unreachable ();
    9737              : }
    9738              : 
    9739              : 
    9740              : /*
    9741              :    NoOfVariables - returns the number of variables in scope.  The scope maybe
    9742              :                    a procedure, module or defimp scope.
    9743              : */
    9744              : 
    9745           30 : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope)
    9746              : {
    9747           30 :   SymbolTable_PtrToSymbol pSym;
    9748              : 
    9749           30 :   if (SymbolTable_IsProcedure (scope))
    9750              :     {
    9751           30 :       return SymbolTable_NoOfLocalVar (scope);
    9752              :     }
    9753            0 :   else if (SymbolTable_IsModule (scope))
    9754              :     {
    9755              :       /* avoid dangling else.  */
    9756            0 :       pSym = GetPsym (scope);
    9757            0 :       switch (pSym->SymbolType)
    9758              :         {
    9759            0 :           case SymbolTable_ModuleSym:
    9760            0 :             return Lists_NoOfItemsInList (pSym->Module.ListOfVars);
    9761            0 :             break;
    9762              : 
    9763              : 
    9764            0 :           default:
    9765            0 :             M2Error_InternalError ((const char *) "expecting module symbol", 23);
    9766            0 :             break;
    9767              :         }
    9768              :     }
    9769            0 :   else if (SymbolTable_IsDefImp (scope))
    9770              :     {
    9771              :       /* avoid dangling else.  */
    9772            0 :       pSym = GetPsym (scope);
    9773            0 :       switch (pSym->SymbolType)
    9774              :         {
    9775            0 :           case SymbolTable_DefImpSym:
    9776            0 :             return Lists_NoOfItemsInList (pSym->DefImp.ListOfVars);
    9777            0 :             break;
    9778              : 
    9779              : 
    9780            0 :           default:
    9781            0 :             M2Error_InternalError ((const char *) "expecting defimp symbol", 23);
    9782            0 :             break;
    9783              :         }
    9784              :     }
    9785              :   else
    9786              :     {
    9787              :       /* avoid dangling else.  */
    9788            0 :       M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
    9789              :     }
    9790              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
    9791              :   __builtin_unreachable ();
    9792              : }
    9793              : 
    9794              : 
    9795              : /*
    9796              :    MakeModule - creates a module sym with ModuleName. It returns the
    9797              :                 symbol index.
    9798              : */
    9799              : 
    9800        26818 : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName)
    9801              : {
    9802        26818 :   SymbolTable_PtrToSymbol pSym;
    9803        26818 :   SymbolTable_PtrToCallFrame pCall;
    9804        26818 :   unsigned int Sym;
    9805              : 
    9806              :   /* 
    9807              :       Make a new symbol since we are at the outer scope level.
    9808              :       DeclareSym examines the current scope level for any symbols
    9809              :       that have the correct name, but are yet undefined.
    9810              :       Therefore we must not call DeclareSym but create a symbol
    9811              :       directly.
    9812              :   */
    9813        26818 :   NewSym (&Sym);
    9814        26818 :   pSym = GetPsym (Sym);
    9815        26818 :   pSym->SymbolType = SymbolTable_ModuleSym;
    9816        26818 :   pSym->Module.name = ModuleName;  /* Index into name array, name  */
    9817              :   /* of record field.  */
    9818        26818 :   pSym->Module.libname = NameKey_NulName;  /* Library association.  */
    9819        26818 :   InitCtor (&pSym->Module.ctors);  /* Init all ctor functions.  */
    9820        26818 :   Lists_InitList (&pSym->Module.ModListOfDep);  /* Vector of SymDependency.  */
    9821        26818 :   SymbolKey_InitTree (&pSym->Module.LocalSymbols);  /* The LocalSymbols hold all the  */
    9822              :   /* END WeAreHere.  */
    9823        26818 :   SymbolKey_InitTree (&pSym->Module.ExportTree);  /* Holds all the exported  */
    9824              :   /* deleted at the end of Pass 1.  */
    9825        26818 :   SymbolKey_InitTree (&pSym->Module.ImportTree);  /* Contains all IMPORTed  */
    9826              :   /* identifiers.  */
    9827        26818 :   Lists_InitList (&pSym->Module.IncludeList);  /* Contains all included symbols  */
    9828              :   /* modulename.Symbol  */
    9829        26818 :   SymbolKey_InitTree (&pSym->Module.ExportUndeclared);  /* ExportUndeclared contains all  */
    9830              :   /* been declared.  */
    9831        26818 :   Lists_InitList (&pSym->Module.EnumerationScopeList);  /* Enumeration scope list which  */
    9832              :   /* Outer Module.  */
    9833        26818 :   SymbolKey_InitTree (&pSym->Module.NamedObjects);  /* Names of all items declared.  */
    9834        26818 :   SymbolKey_InitTree (&pSym->Module.NamedImports);  /* Names of items imported.  */
    9835        26818 :   SymbolKey_InitTree (&pSym->Module.WhereImported);  /* Sym to TokenNo where import  */
    9836              :   /* occurs. Error message use.  */
    9837        26818 :   pSym->Module.Priority = SymbolTable_NulSym;  /* Priority of the module. This  */
    9838              :   /* is an index to a constant.  */
    9839        26818 :   SymbolKey_InitTree (&pSym->Module.Unresolved);  /* All symbols currently  */
    9840              :   /* unresolved in this module.  */
    9841        26818 :   pSym->Module.StartQuad = 0;  /* Signify the initialization  */
    9842              :   /* code.  */
    9843        26818 :   pSym->Module.EndQuad = 0;  /* EndQuad should point to a  */
    9844              :   /* goto quad.  */
    9845        26818 :   pSym->Module.StartFinishQuad = 0;  /* Signify the finalization  */
    9846              :   /* code.  */
    9847        26818 :   pSym->Module.EndFinishQuad = 0;  /* should point to a finish  */
    9848        26818 :   pSym->Module.FinallyFunction = NULL;  /* The GCC function for finally  */
    9849        26818 :   pSym->Module.ExceptionFinally = false;  /* does it have an exception?  */
    9850        26818 :   pSym->Module.ExceptionBlock = false;  /* does it have an exception?  */
    9851        26818 :   pSym->Module.ModLink = GetLink ();  /* Is this parsed for linkage?  */
    9852        26818 :   pSym->Module.Builtin = false;  /* Is the module builtin?  */
    9853        26818 :   Lists_InitList (&pSym->Module.ListOfVars);  /* List of variables in this  */
    9854              :   /* scope.  */
    9855        26818 :   Lists_InitList (&pSym->Module.ListOfProcs);  /* List of all procedures  */
    9856              :   /* declared within this module.  */
    9857        26818 :   Lists_InitList (&pSym->Module.ListOfModules);  /* List of all inner modules.  */
    9858        26818 :   InitWhereDeclaredTok (tok, &pSym->Module.At);  /* Where symbol declared.  */
    9859        26818 :   InitWhereFirstUsedTok (tok, &pSym->Module.At);  /* Where symbol first used.  */
    9860        26818 :   pCall = GetPcall (ScopePtr);  /* Where symbol first used.  */
    9861        26818 :   if (pCall->Main == (SymbolTable_GetBaseModule ()))
    9862              :     {
    9863        26818 :       pSym->Module.Scope = SymbolTable_NulSym;
    9864              :     }
    9865              :   else
    9866              :     {
    9867            0 :       pSym->Module.Scope = pCall->Main;
    9868              :     }
    9869        26818 :   pSym->Module.errorScope = M2Error_GetCurrentErrorScope ();  /* Title error scope.  */
    9870        26818 :   SymbolKey_PutSymKey (ModuleTree, ModuleName, Sym);  /* Title error scope.  */
    9871        26818 :   return Sym;
    9872              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9873              :   __builtin_unreachable ();
    9874              : }
    9875              : 
    9876              : 
    9877              : /*
    9878              :    MakeDefImp - creates a definition and implementation module sym
    9879              :                 with name DefImpName.  It returns the symbol index.
    9880              : */
    9881              : 
    9882       173205 : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName)
    9883              : {
    9884       173205 :   SymbolTable_PtrToSymbol pSym;
    9885       173205 :   unsigned int Sym;
    9886              : 
    9887              :   /* tok := CheckTok (tok, 'defimp') ;  */
    9888       173205 :   NewSym (&Sym);
    9889       173205 :   pSym = GetPsym (Sym);
    9890       173205 :   pSym->SymbolType = SymbolTable_DefImpSym;
    9891       173205 :   pSym->DefImp.name = DefImpName;  /* Index into name array, name  */
    9892              :   /* of record field.  */
    9893       173205 :   pSym->DefImp.libname = NameKey_NulName;  /* Library association.  */
    9894       173205 :   InitCtor (&pSym->DefImp.ctors);
    9895              :   /* Init all ctor functions.  */
    9896       173205 :   Lists_InitList (&pSym->DefImp.DefListOfDep);  /* Vector of SymDependency.  */
    9897       173205 :   Lists_InitList (&pSym->DefImp.ModListOfDep);  /* Vector of SymDependency.  */
    9898       173205 :   SymbolKey_InitTree (&pSym->DefImp.ExportQualifiedTree);
    9899              :   /* deleted at the end of Pass 1.  */
    9900       173205 :   SymbolKey_InitTree (&pSym->DefImp.ExportUnQualifiedTree);
    9901              :   /* deleted at the end of Pass 1.  */
    9902       173205 :   SymbolKey_InitTree (&pSym->DefImp.ExportRequest);  /* Contains all identifiers that  */
    9903              :   /* this list.  */
    9904       173205 :   SymbolKey_InitTree (&pSym->DefImp.ImportTree);  /* Contains all IMPORTed  */
    9905              :   /* identifiers.  */
    9906       173205 :   Lists_InitList (&pSym->DefImp.IncludeList);  /* Contains all included symbols  */
    9907              :   /* modulename.Symbol  */
    9908       173205 :   Lists_InitList (&pSym->DefImp.DefIncludeList);  /* Contains all included symbols  */
    9909              :   /* in the definition module only  */
    9910       173205 :   SymbolKey_InitTree (&pSym->DefImp.ExportUndeclared);  /* ExportUndeclared contains all  */
    9911              :   /* been declared.  */
    9912       173205 :   SymbolKey_InitTree (&pSym->DefImp.NeedToBeImplemented);
    9913              :   /* implemented.  */
    9914       173205 :   SymbolKey_InitTree (&pSym->DefImp.LocalSymbols);  /* The LocalSymbols hold all the  */
    9915              :   /* END WeAreHere.  */
    9916       173205 :   Lists_InitList (&pSym->DefImp.EnumerationScopeList);
    9917              :   /* visable within this scope.  */
    9918       173205 :   SymbolKey_InitTree (&pSym->DefImp.NamedObjects);  /* names of all items declared.  */
    9919       173205 :   SymbolKey_InitTree (&pSym->DefImp.NamedImports);  /* Names of items imported.  */
    9920       173205 :   SymbolKey_InitTree (&pSym->DefImp.WhereImported);  /* Sym to TokenNo where import  */
    9921              :   /* occurs. Error message use.  */
    9922       173205 :   pSym->DefImp.Priority = SymbolTable_NulSym;  /* Priority of the module. This  */
    9923              :   /* is an index to a constant.  */
    9924       173205 :   SymbolKey_InitTree (&pSym->DefImp.Unresolved);  /* All symbols currently  */
    9925              :   /* unresolved in this module.  */
    9926       173205 :   pSym->DefImp.StartQuad = 0;  /* Signify the initialization  */
    9927              :   /* code.  */
    9928       173205 :   pSym->DefImp.EndQuad = 0;  /* EndQuad should point to a  */
    9929              :   /* goto quad.  */
    9930       173205 :   pSym->DefImp.StartFinishQuad = 0;  /* Signify the finalization  */
    9931              :   /* code.  */
    9932       173205 :   pSym->DefImp.EndFinishQuad = 0;  /* should point to a finish  */
    9933       173205 :   pSym->DefImp.FinallyFunction = NULL;  /* The GCC function for finally  */
    9934       173205 :   pSym->DefImp.ExceptionFinally = false;  /* does it have an exception?  */
    9935       173205 :   pSym->DefImp.ExceptionBlock = false;  /* does it have an exception?  */
    9936       173205 :   pSym->DefImp.ContainsHiddenType = false;  /* True if this module  */
    9937              :   /* implements a hidden type.  */
    9938       173205 :   pSym->DefImp.ContainsBuiltin = false;  /* Does module define a builtin  */
    9939              :   /* procedure?  */
    9940       173205 :   pSym->DefImp.ForC = false;  /* Is it a definition for "C"  */
    9941       173205 :   pSym->DefImp.NeedExportList = false;  /* Must user supply export list?  */
    9942       173205 :   pSym->DefImp.DefLink = GetLink ();  /* Is the def/mod file only  */
    9943       173205 :   pSym->DefImp.ModLink = GetLink ();  /* parsed for linkage?  */
    9944       173205 :   pSym->DefImp.Builtin = false;  /* Is the module builtin?  */
    9945       173205 :   Lists_InitList (&pSym->DefImp.ListOfVars);  /* List of variables in this  */
    9946              :   /* scope.  */
    9947       173205 :   Lists_InitList (&pSym->DefImp.ListOfProcs);  /* List of all procedures  */
    9948              :   /* declared within this module.  */
    9949       173205 :   Lists_InitList (&pSym->DefImp.ListOfModules);  /* List of all inner modules.  */
    9950       173205 :   InitWhereDeclaredTok (tok, &pSym->DefImp.At);  /* Where symbol declared.  */
    9951       173205 :   InitWhereFirstUsedTok (tok, &pSym->DefImp.At);  /* Where symbol first used.  */
    9952       173205 :   pSym->DefImp.errorScope = M2Error_GetCurrentErrorScope ();  /* Title error scope.  */
    9953       173205 :   SymbolKey_PutSymKey (ModuleTree, DefImpName, Sym);  /* Title error scope.  */
    9954       173205 :   return Sym;
    9955              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    9956              :   __builtin_unreachable ();
    9957              : }
    9958              : 
    9959              : 
    9960              : /*
    9961              :    MakeInnerModule - creates an inner module sym with ModuleName. It returns the
    9962              :                      symbol index.
    9963              : */
    9964              : 
    9965          428 : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName)
    9966              : {
    9967          428 :   SymbolTable_PtrToSymbol pSym;
    9968          428 :   unsigned int Sym;
    9969              : 
    9970          428 :   Sym = DeclareSym (tok, ModuleName);
    9971          428 :   if (! (SymbolTable_IsError (Sym)))
    9972              :     {
    9973          428 :       pSym = GetPsym (Sym);
    9974          428 :       pSym->SymbolType = SymbolTable_ModuleSym;
    9975          428 :       pSym->Module.name = ModuleName;  /* Index into name array, name  */
    9976              :       /* of record field.  */
    9977          428 :       pSym->Module.libname = NameKey_NulName;  /* Library association.  */
    9978          428 :       InitCtor (&pSym->Module.ctors);  /* Init all ctor functions.  */
    9979          428 :       SymbolKey_InitTree (&pSym->Module.LocalSymbols);  /* The LocalSymbols hold all the  */
    9980              :       /* END WeAreHere.  */
    9981          428 :       SymbolKey_InitTree (&pSym->Module.ExportTree);  /* Holds all the exported  */
    9982              :       /* deleted at the end of Pass 1.  */
    9983          428 :       SymbolKey_InitTree (&pSym->Module.ImportTree);  /* Contains all IMPORTed  */
    9984              :       /* identifiers.  */
    9985          428 :       Lists_InitList (&pSym->Module.IncludeList);  /* Contains all included symbols  */
    9986              :       /* modulename.Symbol  */
    9987          428 :       SymbolKey_InitTree (&pSym->Module.ExportUndeclared);  /* ExportUndeclared contains all  */
    9988              :       /* been declared.  */
    9989          428 :       Lists_InitList (&pSym->Module.EnumerationScopeList);  /* Enumeration scope list which  */
    9990              :       /* visable within this scope.  */
    9991          428 :       SymbolKey_InitTree (&pSym->Module.NamedObjects);  /* Names of all items declared.  */
    9992          428 :       SymbolKey_InitTree (&pSym->Module.NamedImports);  /* Names of items imported.  */
    9993          428 :       SymbolKey_InitTree (&pSym->Module.WhereImported);  /* Sym to TokenNo where import  */
    9994              :       /* occurs. Error message use.  */
    9995          428 :       pSym->Module.Priority = SymbolTable_NulSym;  /* Priority of the module. This  */
    9996              :       /* is an index to a constant.  */
    9997          428 :       SymbolKey_InitTree (&pSym->Module.Unresolved);  /* All symbols currently  */
    9998              :       /* unresolved in this module.  */
    9999          428 :       pSym->Module.StartQuad = 0;  /* Signify the initialization  */
   10000              :       /* code.  */
   10001          428 :       pSym->Module.EndQuad = 0;  /* EndQuad should point to a  */
   10002              :       /* goto quad.  */
   10003          428 :       pSym->Module.StartFinishQuad = 0;  /* Signify the finalization  */
   10004              :       /* code.  */
   10005          428 :       pSym->Module.EndFinishQuad = 0;  /* should point to a finish  */
   10006          428 :       pSym->Module.FinallyFunction = NULL;  /* The GCC function for finally  */
   10007          428 :       pSym->Module.ExceptionFinally = false;  /* does it have an exception?  */
   10008          428 :       pSym->Module.ExceptionBlock = false;  /* does it have an exception?  */
   10009          428 :       pSym->Module.ModLink = GetLink ();  /* Is this parsed for linkage?  */
   10010          428 :       Lists_InitList (&pSym->Module.ListOfVars);  /* List of variables in this  */
   10011              :       /* scope.  */
   10012          428 :       Lists_InitList (&pSym->Module.ListOfProcs);  /* List of all procedures  */
   10013              :       /* declared within this module.  */
   10014          428 :       Lists_InitList (&pSym->Module.ListOfModules);  /* List of all inner modules.  */
   10015          428 :       InitWhereDeclaredTok (tok, &pSym->Module.At);  /* Where symbol declared.  */
   10016          428 :       InitWhereFirstUsedTok (tok, &pSym->Module.At);  /* Where symbol first used.  */
   10017          428 :       if ((SymbolTable_GetCurrentScope ()) == (SymbolTable_GetBaseModule ()))  /* Where symbol first used.  */
   10018              :         {
   10019            0 :           pSym->Module.Scope = SymbolTable_NulSym;
   10020              :         }
   10021              :       else
   10022              :         {
   10023          428 :           pSym->Module.Scope = SymbolTable_GetCurrentScope ();
   10024          428 :           AddModuleToParent (Sym, pSym->Module.Scope);
   10025              :         }
   10026          428 :       pSym->Module.errorScope = M2Error_GetCurrentErrorScope ();  /* Title error scope.  */
   10027          428 :       AddSymToScope (Sym, ModuleName);  /* Title error scope.  */
   10028              :     }
   10029          428 :   return Sym;
   10030              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10031              :   __builtin_unreachable ();
   10032              : }
   10033              : 
   10034              : 
   10035              : /*
   10036              :    MakeProcedure - creates a procedure sym with name. It returns
   10037              :                    the symbol index.
   10038              : */
   10039              : 
   10040      5024222 : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName)
   10041              : {
   10042      5024222 :   SymbolTable_PtrToSymbol pSym;
   10043      5024222 :   unsigned int Sym;
   10044      5024222 :   SymbolTable_ProcedureKind kind;
   10045              : 
   10046      5024222 :   tok = CheckTok (tok, (const char *) "procedure", 9);
   10047      5024222 :   Sym = DeclareSym (tok, ProcedureName);
   10048      5024222 :   CheckBreak (Sym);
   10049      5024222 :   if (! (SymbolTable_IsError (Sym)))
   10050              :     {
   10051      5024222 :       pSym = GetPsym (Sym);
   10052      5024222 :       pSym->SymbolType = SymbolTable_ProcedureSym;
   10053      5024222 :       pSym->Procedure.name = ProcedureName;
   10054     20096888 :       for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
   10055              :         {
   10056     15072666 :           InitProcedureDeclaration (&pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure]);
   10057     15072666 :           Lists_InitList (&pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam);
   10058              :         }
   10059      5024222 :       pSym->Procedure.OptArgInit = SymbolTable_NulSym;  /* The optional arg default  */
   10060              :       /* value.  */
   10061      5024222 :       pSym->Procedure.IsExtern = false;  /* Make this procedure external.  */
   10062      5024222 :       pSym->Procedure.IsPublic = false;  /* Make this procedure visible.  */
   10063      5024222 :       pSym->Procedure.IsCtor = false;  /* Is this procedure a ctor?  */
   10064      5024222 :       pSym->Procedure.IsMonoName = false;  /* Overrides module name prefix.  */
   10065      5024222 :       pSym->Procedure.BuildProcType = true;  /* Are we building the  */
   10066              :       /* proctype associated with sym?  */
   10067      5024222 :       pSym->Procedure.Scope = SymbolTable_GetCurrentScope ();  /* Scope of procedure.  */
   10068      5024222 :       SymbolKey_InitTree (&pSym->Procedure.Unresolved);  /* All symbols currently  */
   10069              :       /* unresolved in this procedure.  */
   10070      5024222 :       pSym->Procedure.ScopeQuad = 0;  /* Index into list of quads,  */
   10071      5024222 :       pSym->Procedure.StartQuad = 0;  /* defining the scope, start and  */
   10072      5024222 :       pSym->Procedure.EndQuad = 0;  /* end of the procedure.  */
   10073      5024222 :       pSym->Procedure.Reachable = false;  /* Procedure not known to be  */
   10074              :       /* reachable.  */
   10075      5024222 :       pSym->Procedure.SavePriority = false;  /* Does procedure need to save  */
   10076              :       /* and restore interrupts?  */
   10077      5024222 :       pSym->Procedure.ReturnType = SymbolTable_NulSym;  /* Not a function yet!  */
   10078              :       /* The ProcType equivalent.  */
   10079      5024222 :       pSym->Procedure.ProcedureType = SymbolTable_MakeProcType (tok, NameKey_NulName);
   10080      5024222 :       SymbolKey_InitTree (&pSym->Procedure.LocalSymbols);
   10081      5024222 :       Lists_InitList (&pSym->Procedure.EnumerationScopeList);
   10082              :       /* visable within this scope.  */
   10083      5024222 :       SymbolKey_InitTree (&pSym->Procedure.NamedObjects);  /* Names of all items declared.  */
   10084      5024222 :       Lists_InitList (&pSym->Procedure.ListOfVars);  /* List of variables in this  */
   10085              :       /* scope.  */
   10086      5024222 :       Lists_InitList (&pSym->Procedure.ListOfProcs);  /* List of all procedures  */
   10087              :       /* procedure.  */
   10088      5024222 :       Lists_InitList (&pSym->Procedure.ListOfModules);  /* List of all inner modules.  */
   10089      5024222 :       pSym->Procedure.ExceptionFinally = false;  /* does it have an exception?  */
   10090      5024222 :       pSym->Procedure.ExceptionBlock = false;  /* does it have an exception?  */
   10091      5024222 :       pSym->Procedure.IsBuiltin = false;  /* Was it declared __BUILTIN__ ?  */
   10092      5024222 :       pSym->Procedure.BuiltinName = NameKey_NulName;  /* name of equivalent builtin  */
   10093      5024222 :       pSym->Procedure.IsInline = false;  /* Was is declared __INLINE__ ?  */
   10094      5024222 :       pSym->Procedure.Size = M2ALU_InitValue ();  /* Activation record size.  */
   10095      5024222 :       pSym->Procedure.TotalParamSize = M2ALU_InitValue ();  /* size of all parameters.  */
   10096      5024222 :       pSym->Procedure.Begin = 0;  /* token number for BEGIN  */
   10097      5024222 :       pSym->Procedure.End = 0;  /* token number for END  */
   10098      5024222 :       InitWhereDeclaredTok (tok, &pSym->Procedure.At);  /* Where the symbol was declared.  */
   10099      5024222 :       pSym->Procedure.errorScope = M2Error_GetCurrentErrorScope ();  /* Title error scope.  */
   10100              :       /* Now add this procedure to the symbol table of the current scope  */
   10101      5024222 :       AddSymToScope (Sym, ProcedureName);
   10102      5024222 :       AddProcedureToList (SymbolTable_GetCurrentScope (), Sym);
   10103              :     }
   10104      5024222 :   return Sym;
   10105              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10106              :   __builtin_unreachable ();
   10107              : }
   10108              : 
   10109              : 
   10110              : /*
   10111              :    MakeProcedureCtorExtern - creates an extern ctor procedure
   10112              : */
   10113              : 
   10114            0 : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename)
   10115              : {
   10116            0 :   unsigned int ctor;
   10117              : 
   10118            0 :   ctor = SymbolTable_MakeProcedure (tokenno, GenName (libname, (const char *) "_M2_", 4, modulename, (const char *) "_ctor", 5));
   10119            0 :   SymbolTable_PutExtern (ctor, true);
   10120            0 :   return ctor;
   10121              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10122              :   __builtin_unreachable ();
   10123              : }
   10124              : 
   10125              : 
   10126              : /*
   10127              :    PutLibName - places libname into defimp or module sym.
   10128              : */
   10129              : 
   10130       244903 : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname)
   10131              : {
   10132       244903 :   SymbolTable_PtrToSymbol pSym;
   10133              : 
   10134       489806 :   M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
   10135       244903 :   pSym = GetPsym (sym);
   10136       244903 :   switch (pSym->SymbolType)
   10137              :     {
   10138       233037 :       case SymbolTable_DefImpSym:
   10139       233037 :         pSym->DefImp.libname = libname;
   10140       233037 :         break;
   10141              : 
   10142        11866 :       case SymbolTable_ModuleSym:
   10143        11866 :         pSym->Module.libname = libname;
   10144        11866 :         break;
   10145              : 
   10146              : 
   10147            0 :       default:
   10148            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   10149       244903 :         break;
   10150              :     }
   10151       244903 : }
   10152              : 
   10153              : 
   10154              : /*
   10155              :    GetLibName - returns libname associated with a defimp or module sym.
   10156              : */
   10157              : 
   10158      5348780 : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym)
   10159              : {
   10160      5348780 :   SymbolTable_PtrToSymbol pSym;
   10161              : 
   10162     10697560 :   M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
   10163      5348780 :   pSym = GetPsym (sym);
   10164      5348780 :   switch (pSym->SymbolType)
   10165              :     {
   10166      5255479 :       case SymbolTable_DefImpSym:
   10167      5255479 :         return pSym->DefImp.libname;
   10168        93301 :         break;
   10169              : 
   10170        93301 :       case SymbolTable_ModuleSym:
   10171        93301 :         return pSym->Module.libname;
   10172            0 :         break;
   10173              : 
   10174              : 
   10175            0 :       default:
   10176            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   10177              :         break;
   10178              :     }
   10179              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   10180              :   __builtin_unreachable ();
   10181              : }
   10182              : 
   10183              : 
   10184              : /*
   10185              :    PutMonoName - changes the IsMonoName boolean inside the procedure.
   10186              : */
   10187              : 
   10188       453535 : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value)
   10189              : {
   10190       453535 :   SymbolTable_PtrToSymbol pSym;
   10191              : 
   10192       453535 :   pSym = GetPsym (sym);
   10193       453535 :   switch (pSym->SymbolType)
   10194              :     {
   10195       453535 :       case SymbolTable_ProcedureSym:
   10196       453535 :         pSym->Procedure.IsMonoName = value;
   10197       453535 :         break;
   10198              : 
   10199              : 
   10200            0 :       default:
   10201            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   10202       453535 :         break;
   10203              :     }
   10204       453535 : }
   10205              : 
   10206              : 
   10207              : /*
   10208              :    IsMonoName - returns the public boolean associated with a procedure.
   10209              : */
   10210              : 
   10211      3665242 : extern "C" bool SymbolTable_IsMonoName (unsigned int sym)
   10212              : {
   10213      3665242 :   SymbolTable_PtrToSymbol pSym;
   10214              : 
   10215      3665242 :   pSym = GetPsym (sym);
   10216      3665242 :   switch (pSym->SymbolType)
   10217              :     {
   10218      3665242 :       case SymbolTable_ProcedureSym:
   10219      3665242 :         return pSym->Procedure.IsMonoName;
   10220            0 :         break;
   10221              : 
   10222              : 
   10223            0 :       default:
   10224            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   10225              :         break;
   10226              :     }
   10227              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   10228              :   __builtin_unreachable ();
   10229              : }
   10230              : 
   10231              : 
   10232              : /*
   10233              :    PutExtern - changes the extern boolean inside the procedure.
   10234              : */
   10235              : 
   10236       701706 : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value)
   10237              : {
   10238       701706 :   SymbolTable_PtrToSymbol pSym;
   10239              : 
   10240       701706 :   pSym = GetPsym (sym);
   10241       701706 :   switch (pSym->SymbolType)
   10242              :     {
   10243       701706 :       case SymbolTable_ProcedureSym:
   10244       701706 :         pSym->Procedure.IsExtern = value;
   10245       701706 :         break;
   10246              : 
   10247              : 
   10248            0 :       default:
   10249            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   10250       701706 :         break;
   10251              :     }
   10252       701706 : }
   10253              : 
   10254              : 
   10255              : /*
   10256              :    IsExtern - returns the public boolean associated with a procedure.
   10257              : */
   10258              : 
   10259      5094495 : extern "C" bool SymbolTable_IsExtern (unsigned int sym)
   10260              : {
   10261      5094495 :   SymbolTable_PtrToSymbol pSym;
   10262              : 
   10263      5094495 :   pSym = GetPsym (sym);
   10264      5094495 :   switch (pSym->SymbolType)
   10265              :     {
   10266      5094495 :       case SymbolTable_ProcedureSym:
   10267      5094495 :         return pSym->Procedure.IsExtern;
   10268            0 :         break;
   10269              : 
   10270              : 
   10271            0 :       default:
   10272            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   10273              :         break;
   10274              :     }
   10275              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   10276              :   __builtin_unreachable ();
   10277              : }
   10278              : 
   10279              : 
   10280              : /*
   10281              :    PutPublic - changes the public boolean inside the procedure.
   10282              : */
   10283              : 
   10284       716283 : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value)
   10285              : {
   10286       716283 :   SymbolTable_PtrToSymbol pSym;
   10287              : 
   10288       716283 :   pSym = GetPsym (sym);
   10289       716283 :   switch (pSym->SymbolType)
   10290              :     {
   10291       716283 :       case SymbolTable_ProcedureSym:
   10292       716283 :         pSym->Procedure.IsPublic = value;
   10293       716283 :         break;
   10294              : 
   10295              : 
   10296            0 :       default:
   10297            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   10298       716283 :         break;
   10299              :     }
   10300       716283 : }
   10301              : 
   10302              : 
   10303              : /*
   10304              :    IsPublic - returns the public boolean associated with a procedure.
   10305              : */
   10306              : 
   10307       105973 : extern "C" bool SymbolTable_IsPublic (unsigned int sym)
   10308              : {
   10309       105973 :   SymbolTable_PtrToSymbol pSym;
   10310              : 
   10311       105973 :   pSym = GetPsym (sym);
   10312       105973 :   switch (pSym->SymbolType)
   10313              :     {
   10314       105973 :       case SymbolTable_ProcedureSym:
   10315       105973 :         return pSym->Procedure.IsPublic;
   10316            0 :         break;
   10317              : 
   10318              : 
   10319            0 :       default:
   10320            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   10321              :         break;
   10322              :     }
   10323              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   10324              :   __builtin_unreachable ();
   10325              : }
   10326              : 
   10327              : 
   10328              : /*
   10329              :    PutCtor - changes the ctor boolean inside the procedure.
   10330              : */
   10331              : 
   10332       195608 : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value)
   10333              : {
   10334       195608 :   SymbolTable_PtrToSymbol pSym;
   10335              : 
   10336       195608 :   pSym = GetPsym (sym);
   10337       195608 :   switch (pSym->SymbolType)
   10338              :     {
   10339       195608 :       case SymbolTable_ProcedureSym:
   10340       195608 :         pSym->Procedure.IsCtor = value;
   10341       195608 :         break;
   10342              : 
   10343              : 
   10344            0 :       default:
   10345            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   10346       195608 :         break;
   10347              :     }
   10348       195608 : }
   10349              : 
   10350              : 
   10351              : /*
   10352              :    IsCtor - returns the ctor boolean associated with a procedure.
   10353              : */
   10354              : 
   10355       153498 : extern "C" bool SymbolTable_IsCtor (unsigned int sym)
   10356              : {
   10357       153498 :   SymbolTable_PtrToSymbol pSym;
   10358              : 
   10359       153498 :   pSym = GetPsym (sym);
   10360       153498 :   switch (pSym->SymbolType)
   10361              :     {
   10362       153498 :       case SymbolTable_ProcedureSym:
   10363       153498 :         return pSym->Procedure.IsCtor;
   10364            0 :         break;
   10365              : 
   10366              : 
   10367            0 :       default:
   10368            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   10369              :         break;
   10370              :     }
   10371              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   10372              :   __builtin_unreachable ();
   10373              : }
   10374              : 
   10375              : 
   10376              : /*
   10377              :    GetModuleCtors - mod can be a DefImp or Module symbol.  ctor, init and fini
   10378              :                     are assigned for this module.  An inner module ctor value will
   10379              :                     be NulSym.
   10380              : */
   10381              : 
   10382       154262 : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep)
   10383              : {
   10384       154262 :   SymbolTable_PtrToSymbol pSym;
   10385              : 
   10386       154262 :   pSym = GetPsym (mod);
   10387       154262 :   switch (pSym->SymbolType)
   10388              :     {
   10389        83255 :       case SymbolTable_ModuleSym:
   10390        83255 :         (*ctor) = pSym->Module.ctors.ctor;
   10391        83255 :         (*init) = pSym->Module.ctors.init;
   10392        83255 :         (*fini) = pSym->Module.ctors.fini;
   10393        83255 :         (*dep) = pSym->Module.ctors.dep;
   10394        83255 :         break;
   10395              : 
   10396        71007 :       case SymbolTable_DefImpSym:
   10397        71007 :         (*ctor) = pSym->DefImp.ctors.ctor;
   10398        71007 :         (*init) = pSym->DefImp.ctors.init;
   10399        71007 :         (*fini) = pSym->DefImp.ctors.fini;
   10400        71007 :         (*dep) = pSym->DefImp.ctors.dep;
   10401        71007 :         break;
   10402              : 
   10403              : 
   10404            0 :       default:
   10405            0 :         M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
   10406       154262 :         break;
   10407              :     }
   10408       154262 : }
   10409              : 
   10410              : 
   10411              : /*
   10412              :    MakeModuleCtor - for a defimp or module symbol create all the ctor
   10413              :                     related procedures.
   10414              : */
   10415              : 
   10416        82934 : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym)
   10417              : {
   10418        82934 :   SymbolTable_PtrToSymbol pSym;
   10419              : 
   10420       165868 :   M2Debug_Assert ((SymbolTable_IsDefImp (moduleSym)) || (SymbolTable_IsModule (moduleSym)));
   10421        82934 :   pSym = GetPsym (moduleSym);
   10422        82934 :   if (SymbolTable_IsDefImp (moduleSym))
   10423              :     {
   10424        70785 :       InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->DefImp.ctors, SymbolTable_GetSymName (moduleSym), false, true);
   10425              :     }
   10426              :   else
   10427              :     {
   10428        12149 :       InitCtorFields (moduleTok, beginTok, finallyTok, moduleSym, &pSym->Module.ctors, SymbolTable_GetSymName (moduleSym), SymbolTable_IsInnerModule (moduleSym), true);
   10429              :     }
   10430        82934 : }
   10431              : 
   10432              : 
   10433              : /*
   10434              :    PutModuleCtorExtern - for every ctor related procedure in module sym.
   10435              :                          Make it external.  It will create any missing
   10436              :                          init/fini procedures but not any missing dep/ctor
   10437              :                          procedures.
   10438              : */
   10439              : 
   10440       113410 : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external)
   10441              : {
   10442       113410 :   SymbolTable_PtrToSymbol pSym;
   10443              : 
   10444       226820 :   M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
   10445       113410 :   pSym = GetPsym (sym);
   10446       113410 :   switch (pSym->SymbolType)
   10447              :     {
   10448       113410 :       case SymbolTable_DefImpSym:
   10449       113410 :         PutCtorExtern (tok, sym, &pSym->DefImp.ctors, external);
   10450       113410 :         break;
   10451              : 
   10452            0 :       case SymbolTable_ModuleSym:
   10453            0 :         PutCtorExtern (tok, sym, &pSym->Module.ctors, external);
   10454            0 :         break;
   10455              : 
   10456              : 
   10457            0 :       default:
   10458            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   10459       113410 :         break;
   10460              :     }
   10461       113410 : }
   10462              : 
   10463              : 
   10464              : /*
   10465              :    PutVarHeap - assigns ArrayRef field with value.
   10466              : */
   10467              : 
   10468        52518 : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value)
   10469              : {
   10470        52518 :   SymbolTable_PtrToSymbol pSym;
   10471              : 
   10472        52518 :   pSym = GetPsym (sym);
   10473        52518 :   switch (pSym->SymbolType)
   10474              :     {
   10475        52518 :       case SymbolTable_VarSym:
   10476        52518 :         pSym->Var.Heap = value;
   10477        52518 :         break;
   10478              : 
   10479              : 
   10480            0 :       default:
   10481            0 :         M2Error_InternalError ((const char *) "expecting VarSym", 16);
   10482        52518 :         break;
   10483              :     }
   10484        52518 : }
   10485              : 
   10486              : 
   10487              : /*
   10488              :    IsVarHeap - returns ArrayRef field value.
   10489              : */
   10490              : 
   10491       625378 : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym)
   10492              : {
   10493       625378 :   SymbolTable_PtrToSymbol pSym;
   10494              : 
   10495       625378 :   pSym = GetPsym (sym);
   10496       625378 :   switch (pSym->SymbolType)
   10497              :     {
   10498       625378 :       case SymbolTable_VarSym:
   10499       625378 :         return pSym->Var.Heap;
   10500            0 :         break;
   10501              : 
   10502              : 
   10503            0 :       default:
   10504            0 :         M2Error_InternalError ((const char *) "expecting VarSym", 16);
   10505              :         break;
   10506              :     }
   10507              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   10508              :   __builtin_unreachable ();
   10509              : }
   10510              : 
   10511              : 
   10512              : /*
   10513              :    MakeVar - creates a variable sym with VarName. It returns the
   10514              :              symbol index.
   10515              : */
   10516              : 
   10517     11267175 : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName)
   10518              : {
   10519     11267175 :   SymbolTable_PtrToSymbol pSym;
   10520     11267175 :   unsigned int Sym;
   10521              : 
   10522     11267175 :   Sym = DeclareSym (tok, VarName);
   10523     11267175 :   if (! (SymbolTable_IsError (Sym)))
   10524              :     {
   10525     11267163 :       pSym = GetPsym (Sym);
   10526     11267163 :       pSym->SymbolType = SymbolTable_VarSym;
   10527     11267163 :       pSym->Var.name = VarName;
   10528     11267163 :       pSym->Var.Type = SymbolTable_NulSym;
   10529     11267163 :       pSym->Var.BackType = SymbolTable_NulSym;
   10530     11267163 :       pSym->Var.Size = M2ALU_InitValue ();
   10531     11267163 :       pSym->Var.Offset = M2ALU_InitValue ();
   10532     11267163 :       pSym->Var.AddrMode = SymbolTable_RightValue;
   10533     11267163 :       pSym->Var.Scope = SymbolTable_GetCurrentScope ();  /* Procedure or Module?  */
   10534     11267163 :       pSym->Var.AtAddress = false;  /* Procedure or Module?  */
   10535     11267163 :       pSym->Var.Address = SymbolTable_NulSym;  /* Address at which declared.  */
   10536     11267163 :       pSym->Var.IsConditional = false;  /* Address at which declared.  */
   10537     11267163 :       pSym->Var.IsTemp = false;
   10538     11267163 :       pSym->Var.IsComponentRef = false;
   10539     11267163 :       pSym->Var.IsParam = false;
   10540     11267163 :       pSym->Var.IsPointerCheck = false;
   10541     11267163 :       pSym->Var.IsWritten = false;
   10542     11267163 :       pSym->Var.IsSSA = false;
   10543     11267163 :       pSym->Var.IsConst = false;
   10544     11267163 :       pSym->Var.ArrayRef = false;
   10545     11267163 :       pSym->Var.Heap = false;
   10546     11267163 :       InitVarDecl (&pSym->Var.Declared, tok);
   10547     11267163 :       InitWhereDeclaredTok (tok, &pSym->Var.At);
   10548     11267163 :       InitWhereFirstUsedTok (tok, &pSym->Var.At);  /* Where symbol first used.  */
   10549     11267163 :       Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]);  /* Where symbol first used.  */
   10550     11267163 :       Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_RightValue-SymbolTable_RightValue]);
   10551     11267163 :       Lists_InitList (&pSym->Var.ReadUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
   10552     11267163 :       Lists_InitList (&pSym->Var.WriteUsageList.array[SymbolTable_LeftValue-SymbolTable_RightValue]);
   10553     11267163 :       pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
   10554     11267163 :       pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue] = M2SymInit_InitSymInit ();
   10555              :       /* Add Var to Procedure or Module variable list.  */
   10556     11267163 :       AddVarToList (Sym);
   10557              :       /* Now add this Var to the symbol table of the current scope.  */
   10558     11267163 :       AddSymToScope (Sym, VarName);
   10559              :     }
   10560     11267175 :   return Sym;
   10561              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10562              :   __builtin_unreachable ();
   10563              : }
   10564              : 
   10565              : 
   10566              : /*
   10567              :    PutVarConditional - assign IsConditional to value.
   10568              : */
   10569              : 
   10570        17128 : extern "C" void SymbolTable_PutVarConditional (unsigned int sym, bool value)
   10571              : {
   10572        17128 :   SymbolTable_PtrToSymbol pSym;
   10573              : 
   10574        17128 :   pSym = GetPsym (sym);
   10575        17128 :   switch (pSym->SymbolType)
   10576              :     {
   10577        16846 :       case SymbolTable_VarSym:
   10578        16846 :         pSym->Var.IsConditional = value;
   10579        16846 :         break;
   10580              : 
   10581          282 :       case SymbolTable_ConstVarSym:
   10582          282 :         pSym->ConstVar.IsConditional = value;
   10583          282 :         break;
   10584              : 
   10585              : 
   10586            0 :       default:
   10587            0 :         M2Error_InternalError ((const char *) "expecting Var", 13);
   10588        17128 :         break;
   10589              :     }
   10590        17128 : }
   10591              : 
   10592              : 
   10593              : /*
   10594              :    IsVarConditional - return TRUE if the symbol is a var symbol
   10595              :                       containing the result of a boolean conditional.
   10596              : */
   10597              : 
   10598       316318 : extern "C" bool SymbolTable_IsVarConditional (unsigned int sym)
   10599              : {
   10600       316318 :   SymbolTable_PtrToSymbol pSym;
   10601              : 
   10602       316318 :   pSym = GetPsym (sym);
   10603       316318 :   switch (pSym->SymbolType)
   10604              :     {
   10605        19814 :       case SymbolTable_VarSym:
   10606        19814 :         return pSym->Var.IsConditional;
   10607       295382 :         break;
   10608              : 
   10609       295382 :       case SymbolTable_ConstVarSym:
   10610       295382 :         return pSym->ConstVar.IsConditional;
   10611              :         break;
   10612              : 
   10613              : 
   10614              :       default:
   10615              :         return false;
   10616              :         break;
   10617              :     }
   10618              :   return false;
   10619              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10620              :   __builtin_unreachable ();
   10621              : }
   10622              : 
   10623              : 
   10624              : /*
   10625              :    MakeRecord - makes a Record symbol with name RecordName.
   10626              : */
   10627              : 
   10628        71491 : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName)
   10629              : {
   10630        71491 :   unsigned int oaf;
   10631        71491 :   unsigned int sym;
   10632              : 
   10633        71491 :   tok = CheckTok (tok, (const char *) "record", 6);
   10634        71491 :   sym = HandleHiddenOrDeclare (tok, RecordName, &oaf);
   10635        71491 :   FillInRecordFields (tok, sym, RecordName, SymbolTable_GetCurrentScope (), oaf);
   10636        71491 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
   10637        71491 :   return sym;
   10638              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10639              :   __builtin_unreachable ();
   10640              : }
   10641              : 
   10642              : 
   10643              : /*
   10644              :    MakeVarient - creates a new symbol, a varient symbol for record or varient field
   10645              :                  symbol, RecOrVarFieldSym.
   10646              : */
   10647              : 
   10648         2988 : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym)
   10649              : {
   10650         2988 :   SymbolTable_PtrToSymbol pSym;
   10651         2988 :   unsigned int Sym;
   10652              : 
   10653         2988 :   tok = CheckTok (tok, (const char *) "varient", 7);
   10654         2988 :   NewSym (&Sym);
   10655         2988 :   pSym = GetPsym (Sym);
   10656         2988 :   pSym->SymbolType = SymbolTable_VarientSym;
   10657         2988 :   pSym->Varient.Size = M2ALU_InitValue ();
   10658         2988 :   pSym->Varient.Parent = RecOrVarFieldSym;  /* GetRecord(RecOrVarFieldSym) ;  */
   10659         2988 :   if (SymbolTable_IsRecord (RecOrVarFieldSym))  /* GetRecord(RecOrVarFieldSym) ;  */
   10660              :     {
   10661         2952 :       pSym->Varient.Varient = SymbolTable_NulSym;
   10662              :     }
   10663              :   else
   10664              :     {
   10665           36 :       pSym->Varient.Varient = RecOrVarFieldSym;
   10666              :     }
   10667         2988 :   pSym->Varient.tag = SymbolTable_NulSym;
   10668         2988 :   pSym->Varient.DeclPacked = false;
   10669         2988 :   pSym->Varient.Scope = SymbolTable_GetCurrentScope ();
   10670         2988 :   Lists_InitList (&pSym->Varient.ListOfSons);
   10671         2988 :   InitWhereDeclaredTok (tok, &pSym->Varient.At);
   10672              :   /* Now add Sym to the record RecSym field list  */
   10673         2988 :   pSym = GetPsym (RecOrVarFieldSym);
   10674         2988 :   switch (pSym->SymbolType)
   10675              :     {
   10676         2952 :       case SymbolTable_RecordSym:
   10677         2952 :         Lists_PutItemIntoList (pSym->Record.ListOfSons, Sym);
   10678         2952 :         break;
   10679              : 
   10680           36 :       case SymbolTable_VarientFieldSym:
   10681           36 :         Lists_PutItemIntoList (pSym->VarientField.ListOfSons, Sym);
   10682           36 :         break;
   10683              : 
   10684              : 
   10685            0 :       default:
   10686            0 :         M2Error_InternalError ((const char *) "expecting Record or VarientField symbol", 39);
   10687         2988 :         break;
   10688              :     }
   10689         2988 :   return Sym;
   10690              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10691              :   __builtin_unreachable ();
   10692              : }
   10693              : 
   10694              : 
   10695              : /*
   10696              :    MakeFieldVarient - returns a FieldVarient symbol which has been
   10697              :                       assigned to the Varient symbol, Sym.
   10698              : */
   10699              : 
   10700         6090 : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym)
   10701              : {
   10702         6090 :   SymbolTable_PtrToSymbol pSym;
   10703         6090 :   unsigned int SonSym;
   10704              : 
   10705         6090 :   NewSym (&SonSym);
   10706              :   /* Fill in Sym  */
   10707         6090 :   pSym = GetPsym (SonSym);
   10708         6090 :   pSym->SymbolType = SymbolTable_VarientFieldSym;
   10709         6090 :   pSym->VarientField.name = n;
   10710         6090 :   Lists_InitList (&pSym->VarientField.ListOfSons);
   10711         6090 :   pSym->VarientField.Parent = SymbolTable_GetRecord (Sym);
   10712         6090 :   pSym->VarientField.Varient = SymbolTable_NulSym;
   10713         6090 :   pSym->VarientField.Size = M2ALU_InitValue ();
   10714         6090 :   pSym->VarientField.Offset = M2ALU_InitValue ();
   10715         6090 :   pSym->VarientField.DeclPacked = false;
   10716         6090 :   pSym->VarientField.DeclResolved = false;
   10717         6090 :   pSym->VarientField.Scope = SymbolTable_GetCurrentScope ();
   10718         6090 :   InitWhereDeclared (&pSym->VarientField.At);
   10719         6090 :   return SonSym;
   10720              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10721              :   __builtin_unreachable ();
   10722              : }
   10723              : 
   10724              : 
   10725              : /*
   10726              :    MakeEnumeration - places a new symbol in the current scope, the symbol
   10727              :                      is an enumeration symbol. The symbol index is returned.
   10728              : */
   10729              : 
   10730        49115 : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName)
   10731              : {
   10732        49115 :   SymbolTable_PtrToSymbol pSym;
   10733        49115 :   unsigned int sym;
   10734        49115 :   unsigned int oaf;
   10735              : 
   10736        49115 :   tok = CheckTok (tok, (const char *) "enumeration", 11);
   10737        49115 :   sym = CheckForHiddenType (EnumerationName);
   10738        49115 :   if (sym == SymbolTable_NulSym)
   10739              :     {
   10740              :       /* avoid dangling else.  */
   10741        49115 :       sym = DeclareSym (tok, EnumerationName);
   10742        49115 :       oaf = SymbolTable_GetOAFamily (sym);
   10743        49115 :       if (! (SymbolTable_IsError (sym)))
   10744              :         {
   10745        49115 :           pSym = GetPsym (sym);
   10746        49115 :           pSym->SymbolType = SymbolTable_EnumerationSym;  /* To satisfy AddSymToScope  */
   10747              :           /* Now add this type to the symbol table of the current scope  */
   10748        49115 :           AddSymToScope (sym, EnumerationName);
   10749              :         }
   10750              :     }
   10751              :   else
   10752              :     {
   10753            0 :       oaf = SymbolTable_GetOAFamily (sym);
   10754              :     }
   10755        49115 :   if (! (SymbolTable_IsError (sym)))
   10756              :     {
   10757        49115 :       pSym = GetPsym (sym);
   10758        49115 :       pSym->SymbolType = SymbolTable_EnumerationSym;
   10759        49115 :       pSym->Enumeration.name = EnumerationName;  /* Name of enumeration.  */
   10760        49115 :       pSym->Enumeration.NoOfElements = 0;  /* No of elements in the  */
   10761              :       /* enumeration type.  */
   10762        49115 :       pSym->Enumeration.Size = M2ALU_InitValue ();  /* Size at runtime of sym  */
   10763        49115 :       SymbolKey_InitTree (&pSym->Enumeration.LocalSymbols);  /* Enumeration fields.  */
   10764        49115 :       Lists_InitList (&pSym->Enumeration.ListOfFields);  /* Ordered as declared.  */
   10765        49115 :       InitPacked (&pSym->Enumeration.packedInfo);  /* not packed and no  */
   10766              :       /* equivalent (yet).  */
   10767        49115 :       pSym->Enumeration.oafamily = oaf;  /* The open array family  */
   10768        49115 :       pSym->Enumeration.Scope = SymbolTable_GetCurrentScope ();  /* Which scope created it  */
   10769        49115 :       InitWhereDeclaredTok (tok, &pSym->Enumeration.At);  /* Declared here  */
   10770        49115 :       CheckIfEnumerationExported (sym, ScopePtr);
   10771              :     }
   10772        49115 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
   10773        49115 :   return sym;
   10774              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10775              :   __builtin_unreachable ();
   10776              : }
   10777              : 
   10778              : 
   10779              : /*
   10780              :    MakeType - makes a type symbol with name TypeName.
   10781              : */
   10782              : 
   10783       605268 : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName)
   10784              : {
   10785       605268 :   SymbolTable_PtrToSymbol pSym;
   10786       605268 :   unsigned int sym;
   10787       605268 :   unsigned int oaf;
   10788              : 
   10789       605268 :   sym = HandleHiddenOrDeclare (tok, TypeName, &oaf);
   10790       605268 :   if (! (SymbolTable_IsError (sym)))
   10791              :     {
   10792       605262 :       pSym = GetPsym (sym);
   10793       605262 :       pSym->SymbolType = SymbolTable_TypeSym;
   10794       605262 :       pSym->Type.name = TypeName;  /* Index into name array, name  */
   10795              :       /* of type.  */
   10796       605262 :       pSym->Type.Type = SymbolTable_NulSym;  /* Index to a type symbol.  */
   10797       605262 :       pSym->Type.IsHidden = false;  /* Was it declared as hidden?  */
   10798       605262 :       SymbolKey_InitTree (&pSym->Type.ConstLitTree);  /* constants of this type.  */
   10799       605262 :       pSym->Type.Size = M2ALU_InitValue ();  /* Runtime size of symbol.  */
   10800       605262 :       pSym->Type.Align = SymbolTable_NulSym;  /* Alignment of this type.  */
   10801       605262 :       InitPacked (&pSym->Type.packedInfo);  /* not packed and no  */
   10802              :       /* equivalent yet.  */
   10803       605262 :       pSym->Type.oafamily = oaf;  /* The open array family.  */
   10804       605262 :       pSym->Type.Scope = SymbolTable_GetCurrentScope ();  /* Which scope created it  */
   10805       605262 :       InitWhereDeclaredTok (tok, &pSym->Type.At);  /* Declared here  */
   10806              :     }
   10807       605268 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
   10808       605268 :   return sym;
   10809              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10810              :   __builtin_unreachable ();
   10811              : }
   10812              : 
   10813              : 
   10814              : /*
   10815              :    MakeHiddenType - makes a type symbol that is hidden from the
   10816              :                     definition module.
   10817              :                     This symbol is placed into the UnImplemented list of
   10818              :                     the definition/implementation module.
   10819              :                     The type will be filled in when the implementation module
   10820              :                     is reached.
   10821              : */
   10822              : 
   10823        28458 : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName)
   10824              : {
   10825        28458 :   SymbolTable_PtrToSymbol pSym;
   10826        28458 :   unsigned int Sym;
   10827              : 
   10828        28458 :   tok = CheckTok (tok, (const char *) "hidden", 6);
   10829        28458 :   Sym = DeclareSym (tok, TypeName);
   10830        28458 :   if (! (SymbolTable_IsError (Sym)))
   10831              :     {
   10832        28458 :       pSym = GetPsym (Sym);
   10833        28458 :       pSym->SymbolType = SymbolTable_TypeSym;
   10834        28458 :       pSym->Type.name = TypeName;  /* Index into name array, name  */
   10835              :       /* of type.  */
   10836        28458 :       pSym->Type.IsHidden = (SymbolTable_GetMainModule ()) != (SymbolTable_GetCurrentScope ());
   10837        28458 :       if (M2Options_ExtendedOpaque || ! pSym->Type.IsHidden)
   10838              :         {
   10839         1500 :           pSym->Type.Type = SymbolTable_NulSym;  /* will be filled in later  */
   10840              :         }
   10841              :       else
   10842              :         {
   10843        26958 :           pSym->Type.Type = M2System_Address;
   10844              :         }
   10845        28458 :       pSym->Type.Align = SymbolTable_NulSym;  /* Alignment of this type.  */
   10846        28458 :       pSym->Type.Scope = SymbolTable_GetCurrentScope ();  /* Which scope created it  */
   10847        28458 :       pSym->Type.oafamily = SymbolTable_NulSym;  /* Which scope created it  */
   10848        28458 :       if (! M2Options_ExtendedOpaque)
   10849              :         {
   10850        27062 :           Lists_IncludeItemIntoList (AddressTypes, Sym);
   10851              :         }
   10852        28458 :       pSym->Type.Size = M2ALU_InitValue ();  /* Runtime size of symbol.  */
   10853        28458 :       InitWhereDeclaredTok (tok, &pSym->Type.At);  /* Declared here  */
   10854        28458 :       SymbolTable_PutExportUnImplemented (tok, Sym);
   10855        28458 :       if (M2Options_ExtendedOpaque || ((SymbolTable_GetMainModule ()) == (SymbolTable_GetCurrentScope ())))
   10856              :         {
   10857         1500 :           SymbolTable_PutHiddenTypeDeclared ();
   10858              :         }
   10859              :       /* Now add this type to the symbol table of the current scope  */
   10860        28458 :       AddSymToScope (Sym, TypeName);
   10861              :     }
   10862        28458 :   return Sym;
   10863              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10864              :   __builtin_unreachable ();
   10865              : }
   10866              : 
   10867              : 
   10868              : /*
   10869              :    MakeConstant - create a constant cardinal and return the symbol.
   10870              : */
   10871              : 
   10872       100366 : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value)
   10873              : {
   10874       100366 :   DynamicStrings_String str;
   10875       100366 :   unsigned int sym;
   10876              : 
   10877       100366 :   tok = CheckTok (tok, (const char *) "constant", 8);
   10878       100366 :   str = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%d", 2)), (const unsigned char *) &value, (sizeof (value)-1));
   10879       100366 :   sym = SymbolTable_MakeConstLit (tok, NameKey_makekey (DynamicStrings_string (str)), M2Base_Cardinal);
   10880       100366 :   str = DynamicStrings_KillString (str);
   10881       100366 :   return sym;
   10882              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10883              :   __builtin_unreachable ();
   10884              : }
   10885              : 
   10886              : 
   10887              : /*
   10888              :    MakeConstLit - returns a constant literal of type, constType, with a constName,
   10889              :                   at location, tok.
   10890              : */
   10891              : 
   10892      1634836 : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType)
   10893              : {
   10894      1634836 :   unsigned int sym;
   10895              : 
   10896      1634836 :   tok = CheckTok (tok, (const char *) "constlit", 8);
   10897      1634836 :   sym = LookupConstLitPoolEntry (tok, constName, constType);
   10898      1634836 :   if (sym == SymbolTable_NulSym)
   10899              :     {
   10900       610547 :       sym = CreateConstLit (tok, constName, constType);
   10901       610547 :       AddConstLitPoolEntry (sym, tok, constName, constType);
   10902              :     }
   10903      1634836 :   return sym;
   10904              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10905              :   __builtin_unreachable ();
   10906              : }
   10907              : 
   10908              : 
   10909              : /*
   10910              :    MakeConstVar - makes a ConstVar type with
   10911              :                   name ConstVarName.
   10912              : */
   10913              : 
   10914      1264303 : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName)
   10915              : {
   10916      1264303 :   SymbolTable_PtrToSymbol pSym;
   10917      1264303 :   unsigned int Sym;
   10918      1264303 :   bool temp;
   10919              : 
   10920      1264303 :   temp = ConstVarName == NameKey_NulName;
   10921      1264303 :   ConstVarName = SymbolTable_CheckAnonymous (ConstVarName);
   10922      1264303 :   Sym = DeclareSym (tok, ConstVarName);
   10923      1264303 :   if (! (SymbolTable_IsError (Sym)))
   10924              :     {
   10925      1264297 :       pSym = GetPsym (Sym);
   10926      1264297 :       pSym->SymbolType = SymbolTable_ConstVarSym;
   10927      1264297 :       pSym->ConstVar.name = ConstVarName;
   10928      1264297 :       pSym->ConstVar.Value = M2ALU_InitValue ();
   10929      1264297 :       pSym->ConstVar.Type = SymbolTable_NulSym;
   10930      1264297 :       pSym->ConstVar.IsSet = false;
   10931      1264297 :       pSym->ConstVar.IsConditional = false;
   10932      1264297 :       pSym->ConstVar.IsConstructor = false;
   10933      1264297 :       pSym->ConstVar.FromType = SymbolTable_NulSym;  /* type is determined FromType  */
   10934      1264297 :       pSym->ConstVar.UnresFromType = false;  /* is Type resolved?  */
   10935      1264297 :       pSym->ConstVar.IsTemp = temp;  /* is Type resolved?  */
   10936      1264297 :       pSym->ConstVar.Scope = SymbolTable_GetCurrentScope ();
   10937      1264297 :       InitWhereDeclaredTok (tok, &pSym->ConstVar.At);
   10938              :       /* Now add this constant to the symbol table of the current scope  */
   10939      1264297 :       AddSymToScope (Sym, ConstVarName);
   10940              :     }
   10941      1264303 :   return Sym;
   10942              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10943              :   __builtin_unreachable ();
   10944              : }
   10945              : 
   10946              : 
   10947              : /*
   10948              :    MakeConstString - create a string constant in the symboltable.
   10949              : */
   10950              : 
   10951       322854 : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName)
   10952              : {
   10953       322854 :   unsigned int newstr;
   10954              : 
   10955       322854 :   NewSym (&newstr);
   10956       322854 :   InitConstString (tok, newstr, ConstName, ConstName, SymbolTable_m2nulstr, false, true);
   10957       322854 :   return newstr;
   10958              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10959              :   __builtin_unreachable ();
   10960              : }
   10961              : 
   10962              : 
   10963              : /*
   10964              :    MakeConstStringCnul - creates a constant string nul terminated string suitable for C.
   10965              :                          If known is TRUE then name is assigned to the contents
   10966              :                          and the escape sequences will be converted into characters.
   10967              : */
   10968              : 
   10969         9583 : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known)
   10970              : {
   10971         9583 :   unsigned int newstr;
   10972              : 
   10973         9583 :   tok = CheckTok (tok, (const char *) "conststringcnul", 15);
   10974         9583 :   NewSym (&newstr);
   10975         9583 :   InitConstString (tok, newstr, name, name, SymbolTable_cnulstr, true, known);
   10976         9583 :   return newstr;
   10977              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10978              :   __builtin_unreachable ();
   10979              : }
   10980              : 
   10981              : 
   10982              : /*
   10983              :    MakeConstStringM2nul - creates a constant string nul terminated string suitable for M2.
   10984              :                           If known is TRUE then name is assigned to the contents
   10985              :                           however the escape sequences are not converted into characters.
   10986              : */
   10987              : 
   10988        34000 : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known)
   10989              : {
   10990        34000 :   unsigned int newstr;
   10991              : 
   10992        34000 :   NewSym (&newstr);
   10993        34000 :   InitConstString (tok, newstr, name, name, SymbolTable_m2nulstr, false, known);
   10994        34000 :   return newstr;
   10995              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   10996              :   __builtin_unreachable ();
   10997              : }
   10998              : 
   10999              : 
   11000              : /*
   11001              :    PutConstStringKnown - if sym is a constvar then convert it into a conststring.
   11002              :                          If known is FALSE then contents is ignored and NulName is
   11003              :                          stored.  If escape is TRUE then the contents will have
   11004              :                          any escape sequences converted into single characters.
   11005              : */
   11006              : 
   11007       422428 : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known)
   11008              : {
   11009       422428 :   SymbolTable_PtrToSymbol pSym;
   11010       422428 :   DynamicStrings_String s;
   11011              : 
   11012       422428 :   pSym = GetPsym (sym);
   11013       422428 :   switch (pSym->SymbolType)
   11014              :     {
   11015       421276 :       case SymbolTable_ConstStringSym:
   11016       421276 :         if (known)
   11017              :           {
   11018       376061 :             if (escape)
   11019              :               {
   11020         9559 :                 s = FormatStrings_HandleEscape (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (contents)));
   11021         9559 :                 contents = NameKey_makekey (DynamicStrings_string (s));
   11022         9559 :                 s = DynamicStrings_KillString (s);
   11023              :               }
   11024       376061 :             pSym->ConstString.Length = NameKey_LengthKey (contents);
   11025       376061 :             pSym->ConstString.Contents = contents;
   11026              :           }
   11027              :         else
   11028              :           {
   11029        45215 :             pSym->ConstString.Length = 0;
   11030        45215 :             pSym->ConstString.Contents = NameKey_NulName;
   11031              :           }
   11032       421276 :         pSym->ConstString.Known = known;
   11033       421276 :         InitWhereDeclaredTok (tok, &pSym->ConstString.At);
   11034       421276 :         InitWhereFirstUsedTok (tok, &pSym->ConstString.At);
   11035       421276 :         break;
   11036              : 
   11037         1152 :       case SymbolTable_ConstVarSym:
   11038         1152 :         InitConstString (tok, sym, pSym->ConstVar.name, contents, SymbolTable_m2str, escape, known);  /* Change a ConstVar to a ConstString copy name
   11039              :                          and alter symboltype.  */
   11040         1152 :         break;
   11041              : 
   11042              : 
   11043            0 :       default:
   11044            0 :         M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
   11045       422428 :         break;
   11046              :     }
   11047       422428 : }
   11048              : 
   11049              : 
   11050              : /*
   11051              :    CopyConstString - copies string contents from expr to des
   11052              :                      and retain the kind of string.
   11053              : */
   11054              : 
   11055         1146 : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr)
   11056              : {
   11057         1146 :   SymbolTable_PtrToSymbol pSym;
   11058              : 
   11059         1146 :   M2Debug_Assert (SymbolTable_IsConstStringKnown (expr));
   11060         1146 :   pSym = GetPsym (des);
   11061         1146 :   switch (pSym->SymbolType)
   11062              :     {
   11063         1122 :       case SymbolTable_ConstStringSym:
   11064         1122 :         InitConstString (tok, des, pSym->ConstString.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true);
   11065         1122 :         break;
   11066              : 
   11067           24 :       case SymbolTable_ConstVarSym:
   11068           24 :         InitConstString (tok, des, pSym->ConstVar.name, SymbolTable_GetString (expr), GetConstStringKind (expr), false, true);  /* Change a ConstVar to a ConstString copy name
   11069              :                          and alter symboltype.  */
   11070           24 :         break;
   11071              : 
   11072              : 
   11073            0 :       default:
   11074            0 :         M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
   11075         1146 :         break;
   11076              :     }
   11077         1146 : }
   11078              : 
   11079              : 
   11080              : /*
   11081              :    IsConstStringKnown - returns TRUE if sym is a const string
   11082              :                         and the contents are known.
   11083              : */
   11084              : 
   11085       897549 : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym)
   11086              : {
   11087       897549 :   SymbolTable_PtrToSymbol pSym;
   11088              : 
   11089       897549 :   pSym = GetPsym (sym);
   11090       897549 :   switch (pSym->SymbolType)
   11091              :     {
   11092       897525 :       case SymbolTable_ConstStringSym:
   11093       897525 :         return pSym->ConstString.Known;
   11094              :         break;
   11095              : 
   11096              : 
   11097              :       default:
   11098              :         return false;
   11099              :         break;
   11100              :     }
   11101              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11102              :   __builtin_unreachable ();
   11103              : }
   11104              : 
   11105              : 
   11106              : /*
   11107              :    IsConstStringM2 - returns whether this conststring is a
   11108              :                      Modula-2 string.
   11109              : */
   11110              : 
   11111            0 : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym)
   11112              : {
   11113            0 :   return (GetConstStringKind (sym)) == SymbolTable_m2str;
   11114              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11115              :   __builtin_unreachable ();
   11116              : }
   11117              : 
   11118              : 
   11119              : /*
   11120              :    IsConstStringC - returns whether this conststring is a C style string
   11121              :                     which will have any escape translated.
   11122              : */
   11123              : 
   11124            0 : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym)
   11125              : {
   11126            0 :   return (GetConstStringKind (sym)) == SymbolTable_cstr;
   11127              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11128              :   __builtin_unreachable ();
   11129              : }
   11130              : 
   11131              : 
   11132              : /*
   11133              :    IsConstStringM2nul - returns whether this conststring is a Modula-2 string which
   11134              :                         contains a nul terminator.
   11135              : */
   11136              : 
   11137       281590 : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym)
   11138              : {
   11139       281590 :   return (GetConstStringKind (sym)) == SymbolTable_m2nulstr;
   11140              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11141              :   __builtin_unreachable ();
   11142              : }
   11143              : 
   11144              : 
   11145              : /*
   11146              :    IsConstStringCnul - returns whether this conststring is a C style string
   11147              :                        which will have any escape translated and also contains
   11148              :                        a nul terminator.
   11149              : */
   11150              : 
   11151         9219 : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym)
   11152              : {
   11153         9219 :   return (GetConstStringKind (sym)) == SymbolTable_cnulstr;
   11154              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11155              :   __builtin_unreachable ();
   11156              : }
   11157              : 
   11158              : 
   11159              : /*
   11160              :    MakeSubrange - makes a new symbol into a subrange type with
   11161              :                   name SubrangeName.
   11162              : */
   11163              : 
   11164       224778 : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName)
   11165              : {
   11166       224778 :   SymbolTable_PtrToSymbol pSym;
   11167       224778 :   unsigned int sym;
   11168       224778 :   unsigned int oaf;
   11169              : 
   11170       224778 :   tok = CheckTok (tok, (const char *) "subrange", 8);
   11171       224778 :   sym = HandleHiddenOrDeclare (tok, SubrangeName, &oaf);
   11172       224778 :   if (! (SymbolTable_IsError (sym)))
   11173              :     {
   11174       224778 :       pSym = GetPsym (sym);
   11175       224778 :       pSym->SymbolType = SymbolTable_SubrangeSym;
   11176       224778 :       pSym->Subrange.name = SubrangeName;
   11177       224778 :       pSym->Subrange.Low = SymbolTable_NulSym;  /* Index to a symbol determining  */
   11178              :       /* ConstExpression.  */
   11179       224778 :       pSym->Subrange.High = SymbolTable_NulSym;  /* Index to a symbol determining  */
   11180              :       /* ConstExpression.  */
   11181       224778 :       pSym->Subrange.Type = SymbolTable_NulSym;  /* Index to a type. Determines  */
   11182              :       /* the type of subrange.  */
   11183       224778 :       pSym->Subrange.Align = SymbolTable_NulSym;  /* The alignment of this type.  */
   11184       224778 :       InitPacked (&pSym->Subrange.packedInfo);  /* not packed and no equivalent  */
   11185       224778 :       SymbolKey_InitTree (&pSym->Subrange.ConstLitTree);  /* constants of this type.  */
   11186       224778 :       pSym->Subrange.Size = M2ALU_InitValue ();  /* Size determines the type size  */
   11187       224778 :       pSym->Subrange.oafamily = oaf;  /* The unbounded sym for this  */
   11188       224778 :       pSym->Subrange.Scope = SymbolTable_GetCurrentScope ();  /* Which scope created it  */
   11189       224778 :       InitWhereDeclaredTok (tok, &pSym->Subrange.At);  /* Declared here  */
   11190              :     }
   11191       224778 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
   11192       224778 :   return sym;
   11193              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11194              :   __builtin_unreachable ();
   11195              : }
   11196              : 
   11197              : 
   11198              : /*
   11199              :    MakeSet - makes a set Symbol with name, SetName.
   11200              : */
   11201              : 
   11202        64550 : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName)
   11203              : {
   11204        64550 :   SymbolTable_PtrToSymbol pSym;
   11205        64550 :   unsigned int oaf;
   11206        64550 :   unsigned int sym;
   11207              : 
   11208        64550 :   tok = CheckTok (tok, (const char *) "set", 3);
   11209        64550 :   sym = HandleHiddenOrDeclare (tok, SetName, &oaf);
   11210        64550 :   if (! (SymbolTable_IsError (sym)))
   11211              :     {
   11212        64550 :       pSym = GetPsym (sym);
   11213        64550 :       pSym->SymbolType = SymbolTable_SetSym;
   11214        64550 :       pSym->Set.name = SetName;  /* The name of the set.  */
   11215        64550 :       pSym->Set.Type = SymbolTable_NulSym;  /* Index to a subrange symbol.  */
   11216        64550 :       pSym->Set.Size = M2ALU_InitValue ();  /* Size of this set  */
   11217        64550 :       InitPacked (&pSym->Set.packedInfo);  /* not packed and no  */
   11218              :       /* equivalent (yet).  */
   11219        64550 :       pSym->Set.ispacked = false;  /* Not yet known to be packed.  */
   11220        64550 :       pSym->Set.SetInWord = true;  /* Can the set be stored in a  */
   11221              :       /* single word?  */
   11222        64550 :       pSym->Set.SetArray = SymbolTable_NulSym;  /* Set used for large sets.  */
   11223        64550 :       pSym->Set.Align = SymbolTable_NulSym;  /* Set used for large sets.  */
   11224        64550 :       pSym->Set.oafamily = oaf;  /* The unbounded sym for this  */
   11225        64550 :       pSym->Set.Scope = SymbolTable_GetCurrentScope ();  /* Which scope created it  */
   11226        64550 :       InitWhereDeclaredTok (tok, &pSym->Set.At);  /* Declared here  */
   11227              :     }
   11228        64550 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
   11229        64550 :   return sym;
   11230              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11231              :   __builtin_unreachable ();
   11232              : }
   11233              : 
   11234              : 
   11235              : /*
   11236              :    GetSetArray - return the set array for a large set.
   11237              : */
   11238              : 
   11239      1670738 : extern "C" unsigned int SymbolTable_GetSetArray (unsigned int sym)
   11240              : {
   11241      1670738 :   SymbolTable_PtrToSymbol pSym;
   11242              : 
   11243      1670738 :   AssertInRange (sym);
   11244      1670738 :   pSym = GetPsym (sym);
   11245      1670738 :   switch (pSym->SymbolType)
   11246              :     {
   11247      1670738 :       case SymbolTable_SetSym:
   11248      1670738 :         return pSym->Set.SetArray;
   11249              :         break;
   11250              : 
   11251              : 
   11252              :       default:
   11253              :         return SymbolTable_NulSym;
   11254              :         break;
   11255              :     }
   11256              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11257              :   __builtin_unreachable ();
   11258              : }
   11259              : 
   11260              : 
   11261              : /*
   11262              :    PutSetArray - places array into the setarray field.
   11263              : */
   11264              : 
   11265        60424 : extern "C" void SymbolTable_PutSetArray (unsigned int Sym, unsigned int array)
   11266              : {
   11267        60424 :   SymbolTable_PtrToSymbol pSym;
   11268              : 
   11269        60424 :   pSym = GetPsym (Sym);
   11270        60424 :   switch (pSym->SymbolType)
   11271              :     {
   11272              :       case SymbolTable_ErrorSym:
   11273              :         break;
   11274              : 
   11275        60424 :       case SymbolTable_SetSym:
   11276        60424 :         pSym->Set.SetArray = array;
   11277        60424 :         break;
   11278              : 
   11279              : 
   11280            0 :       default:
   11281            0 :         M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
   11282        60424 :         break;
   11283              :     }
   11284        60424 : }
   11285              : 
   11286              : 
   11287              : /*
   11288              :    MakeSetArray - create an ARRAY simpletype OF BOOLEAN.
   11289              : */
   11290              : 
   11291        60424 : extern "C" unsigned int SymbolTable_MakeSetArray (unsigned int token, unsigned int subrangetype)
   11292              : {
   11293        60424 :   unsigned int array;
   11294        60424 :   unsigned int subscript;
   11295              : 
   11296        60424 :   array = SymbolTable_MakeArray (token, SymbolTable_NulSym);
   11297        60424 :   SymbolTable_PutArray (array, M2System_Byte);
   11298        60424 :   subscript = SymbolTable_MakeSubscript ();
   11299        60424 :   SymbolTable_PutSubscript (subscript, subrangetype);
   11300        60424 :   SymbolTable_PutArraySubscript (array, subscript);
   11301        60424 :   return array;
   11302              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11303              :   __builtin_unreachable ();
   11304              : }
   11305              : 
   11306              : 
   11307              : /*
   11308              :    PutSetInWord - set the SetInWord boolean to value.
   11309              : */
   11310              : 
   11311        65088 : extern "C" void SymbolTable_PutSetInWord (unsigned int sym, bool value)
   11312              : {
   11313        65088 :   SymbolTable_PtrToSymbol pSym;
   11314              : 
   11315        65088 :   AssertInRange (sym);
   11316        65088 :   pSym = GetPsym (sym);
   11317        65088 :   switch (pSym->SymbolType)
   11318              :     {
   11319        65088 :       case SymbolTable_SetSym:
   11320        65088 :         pSym->Set.SetInWord = value;
   11321        65088 :         if (value)
   11322              :           {
   11323        63550 :             pSym->Set.Align = SymbolTable_MakeConstant (SymbolTable_GetDeclaredMod (sym), 0);
   11324        63550 :             pSym->Set.ispacked = true;
   11325              :           }
   11326        65088 :         break;
   11327              : 
   11328              : 
   11329            0 :       default:
   11330            0 :         M2Error_InternalError ((const char *) "expecting a set symbol", 22);
   11331        65088 :         break;
   11332              :     }
   11333        65088 : }
   11334              : 
   11335              : 
   11336              : /*
   11337              :    GetSetInWord - return SetInWord.
   11338              : */
   11339              : 
   11340        20126 : extern "C" bool SymbolTable_GetSetInWord (unsigned int sym)
   11341              : {
   11342        20126 :   SymbolTable_PtrToSymbol pSym;
   11343              : 
   11344        20126 :   AssertInRange (sym);
   11345        20126 :   pSym = GetPsym (sym);
   11346        20126 :   switch (pSym->SymbolType)
   11347              :     {
   11348        20126 :       case SymbolTable_SetSym:
   11349        20126 :         return pSym->Set.SetInWord;
   11350            0 :         break;
   11351              : 
   11352              : 
   11353            0 :       default:
   11354            0 :         M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
   11355              :         break;
   11356              :     }
   11357              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11358              :   __builtin_unreachable ();
   11359              : }
   11360              : 
   11361              : 
   11362              : /*
   11363              :    MakeArray - makes an Array symbol with name ArrayName.
   11364              : */
   11365              : 
   11366       163230 : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName)
   11367              : {
   11368       163230 :   SymbolTable_PtrToSymbol pSym;
   11369       163230 :   unsigned int sym;
   11370       163230 :   unsigned int oaf;
   11371              : 
   11372       163230 :   sym = HandleHiddenOrDeclare (tok, ArrayName, &oaf);
   11373       163230 :   if (! (SymbolTable_IsError (sym)))
   11374              :     {
   11375       163230 :       pSym = GetPsym (sym);
   11376       163230 :       pSym->SymbolType = SymbolTable_ArraySym;
   11377       163230 :       pSym->Array.name = ArrayName;
   11378       163230 :       pSym->Array.Subscript = SymbolTable_NulSym;  /* Contains the array subscripts.  */
   11379       163230 :       pSym->Array.Size = M2ALU_InitValue ();  /* Size of array.  */
   11380       163230 :       pSym->Array.Offset = M2ALU_InitValue ();  /* Offset of array.  */
   11381       163230 :       pSym->Array.Type = SymbolTable_NulSym;  /* The Array Type. ARRAY OF Type.  */
   11382       163230 :       pSym->Array.Align = SymbolTable_NulSym;  /* Alignment of this type.  */
   11383       163230 :       pSym->Array.Large = false;  /* is this array large?  */
   11384       163230 :       pSym->Array.oafamily = oaf;  /* The unbounded for this array  */
   11385       163230 :       pSym->Array.Scope = SymbolTable_GetCurrentScope ();  /* Which scope created it  */
   11386       163230 :       InitWhereDeclaredTok (tok, &pSym->Array.At);  /* Declared here  */
   11387              :     }
   11388       163230 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
   11389       163230 :   return sym;
   11390              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11391              :   __builtin_unreachable ();
   11392              : }
   11393              : 
   11394              : 
   11395              : /*
   11396              :    PutArrayLarge - indicates that this is a large array in which case
   11397              :                    the interface to gcc maps this array from 0..high-low,
   11398              :                    using an integer indice.
   11399              : */
   11400              : 
   11401           24 : extern "C" void SymbolTable_PutArrayLarge (unsigned int array)
   11402              : {
   11403           24 :   SymbolTable_PtrToSymbol pSym;
   11404              : 
   11405           24 :   if (! (SymbolTable_IsError (array)))
   11406              :     {
   11407           24 :       M2Debug_Assert (SymbolTable_IsArray (array));
   11408           24 :       pSym = GetPsym (array);
   11409           24 :       pSym->Array.Large = true;
   11410              :     }
   11411           24 : }
   11412              : 
   11413              : 
   11414              : /*
   11415              :    IsArrayLarge - returns TRUE if we need to treat this as a large array.
   11416              : */
   11417              : 
   11418        46734 : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array)
   11419              : {
   11420        46734 :   SymbolTable_PtrToSymbol pSym;
   11421              : 
   11422        46734 :   M2Debug_Assert (SymbolTable_IsArray (array));
   11423        46734 :   pSym = GetPsym (array);
   11424        46734 :   return pSym->Array.Large;
   11425              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11426              :   __builtin_unreachable ();
   11427              : }
   11428              : 
   11429              : 
   11430              : /*
   11431              :    PutPriority - places a interrupt, priority, value into module, module.
   11432              : */
   11433              : 
   11434           38 : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority)
   11435              : {
   11436           38 :   SymbolTable_PtrToSymbol pSym;
   11437              : 
   11438           38 :   M2Debug_Assert (module != SymbolTable_NulSym);
   11439           38 :   pSym = GetPsym (module);
   11440           38 :   switch (pSym->SymbolType)
   11441              :     {
   11442           14 :       case SymbolTable_DefImpSym:
   11443           14 :         pSym->DefImp.Priority = priority;
   11444           14 :         break;
   11445              : 
   11446           24 :       case SymbolTable_ModuleSym:
   11447           24 :         pSym->Module.Priority = priority;
   11448           24 :         break;
   11449              : 
   11450              : 
   11451            0 :       default:
   11452            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   11453           38 :         break;
   11454              :     }
   11455           38 : }
   11456              : 
   11457              : 
   11458              : /*
   11459              :    GetPriority - returns the interrupt priority which was assigned to
   11460              :                  module, module.
   11461              : */
   11462              : 
   11463       451605 : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module)
   11464              : {
   11465       451605 :   SymbolTable_PtrToSymbol pSym;
   11466              : 
   11467       451605 :   M2Debug_Assert (module != SymbolTable_NulSym);
   11468       451605 :   pSym = GetPsym (module);
   11469       451605 :   switch (pSym->SymbolType)
   11470              :     {
   11471       315235 :       case SymbolTable_DefImpSym:
   11472       315235 :         return pSym->DefImp.Priority;
   11473       136370 :         break;
   11474              : 
   11475       136370 :       case SymbolTable_ModuleSym:
   11476       136370 :         return pSym->Module.Priority;
   11477            0 :         break;
   11478              : 
   11479              : 
   11480            0 :       default:
   11481            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   11482              :         break;
   11483              :     }
   11484              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11485              :   __builtin_unreachable ();
   11486              : }
   11487              : 
   11488              : 
   11489              : /*
   11490              :    PutNeedSavePriority - set a boolean flag indicating that this procedure
   11491              :                          needs to save and restore interrupts.
   11492              : */
   11493              : 
   11494          162 : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym)
   11495              : {
   11496          162 :   SymbolTable_PtrToSymbol pSym;
   11497              : 
   11498          162 :   pSym = GetPsym (sym);
   11499          162 :   switch (pSym->SymbolType)
   11500              :     {
   11501          162 :       case SymbolTable_ProcedureSym:
   11502          162 :         pSym->Procedure.SavePriority = true;
   11503          162 :         break;
   11504              : 
   11505              : 
   11506            0 :       default:
   11507            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   11508          162 :         break;
   11509              :     }
   11510          162 : }
   11511              : 
   11512              : 
   11513              : /*
   11514              :    GetNeedSavePriority - returns the boolean flag indicating whether this procedure
   11515              :                          needs to save and restore interrupts.
   11516              : */
   11517              : 
   11518          680 : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym)
   11519              : {
   11520          680 :   SymbolTable_PtrToSymbol pSym;
   11521              : 
   11522          680 :   pSym = GetPsym (sym);
   11523          680 :   switch (pSym->SymbolType)
   11524              :     {
   11525          680 :       case SymbolTable_ProcedureSym:
   11526          680 :         return pSym->Procedure.SavePriority;
   11527            0 :         break;
   11528              : 
   11529              : 
   11530            0 :       default:
   11531            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   11532              :         break;
   11533              :     }
   11534              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11535              :   __builtin_unreachable ();
   11536              : }
   11537              : 
   11538              : 
   11539              : /*
   11540              :    PutVariableAtAddress - determines that a variable, sym, is declared at
   11541              :                           a specific address.
   11542              : */
   11543              : 
   11544          108 : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address)
   11545              : {
   11546          108 :   SymbolTable_PtrToSymbol pSym;
   11547              : 
   11548          108 :   M2Debug_Assert (sym != SymbolTable_NulSym);
   11549          108 :   pSym = GetPsym (sym);
   11550          108 :   switch (pSym->SymbolType)
   11551              :     {
   11552          108 :       case SymbolTable_VarSym:
   11553          108 :         pSym->Var.AtAddress = true;
   11554          108 :         pSym->Var.Address = address;
   11555          108 :         break;
   11556              : 
   11557              : 
   11558            0 :       default:
   11559            0 :         M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
   11560          108 :         break;
   11561              :     }
   11562          108 : }
   11563              : 
   11564              : 
   11565              : /*
   11566              :    GetVariableAtAddress - returns the address at which variable, sym, is declared.
   11567              : */
   11568              : 
   11569           54 : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym)
   11570              : {
   11571           54 :   SymbolTable_PtrToSymbol pSym;
   11572              : 
   11573           54 :   M2Debug_Assert (sym != SymbolTable_NulSym);
   11574           54 :   pSym = GetPsym (sym);
   11575           54 :   switch (pSym->SymbolType)
   11576              :     {
   11577           54 :       case SymbolTable_VarSym:
   11578           54 :         return pSym->Var.Address;
   11579            0 :         break;
   11580              : 
   11581              : 
   11582            0 :       default:
   11583            0 :         M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
   11584              :         break;
   11585              :     }
   11586              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11587              :   __builtin_unreachable ();
   11588              : }
   11589              : 
   11590              : 
   11591              : /*
   11592              :    IsVariableAtAddress - returns TRUE if a variable, sym, was declared at
   11593              :                          a specific address.
   11594              : */
   11595              : 
   11596       334198 : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym)
   11597              : {
   11598       334198 :   SymbolTable_PtrToSymbol pSym;
   11599              : 
   11600       334198 :   M2Debug_Assert (sym != SymbolTable_NulSym);
   11601       334198 :   pSym = GetPsym (sym);
   11602       334198 :   switch (pSym->SymbolType)
   11603              :     {
   11604       334198 :       case SymbolTable_VarSym:
   11605       334198 :         return pSym->Var.AtAddress;
   11606            0 :         break;
   11607              : 
   11608              : 
   11609            0 :       default:
   11610            0 :         M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
   11611              :         break;
   11612              :     }
   11613              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11614              :   __builtin_unreachable ();
   11615              : }
   11616              : 
   11617              : 
   11618              : /*
   11619              :    PutVariableSSA - assigns value to the SSA field within variable sym.
   11620              : */
   11621              : 
   11622            0 : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value)
   11623              : {
   11624            0 :   SymbolTable_PtrToSymbol pSym;
   11625              : 
   11626            0 :   M2Debug_Assert (sym != SymbolTable_NulSym);
   11627            0 :   pSym = GetPsym (sym);
   11628            0 :   switch (pSym->SymbolType)
   11629              :     {
   11630            0 :       case SymbolTable_VarSym:
   11631            0 :         pSym->Var.IsSSA = value;
   11632            0 :         break;
   11633              : 
   11634              : 
   11635            0 :       default:
   11636            0 :         M2Error_InternalError ((const char *) "expecting a variable symbol", 27);
   11637            0 :         break;
   11638              :     }
   11639            0 : }
   11640              : 
   11641              : 
   11642              : /*
   11643              :    IsVariableSSA - returns TRUE if variable is known to be a SSA.
   11644              : */
   11645              : 
   11646       191568 : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym)
   11647              : {
   11648       191568 :   SymbolTable_PtrToSymbol pSym;
   11649              : 
   11650       191568 :   M2Debug_Assert (sym != SymbolTable_NulSym);
   11651       191568 :   pSym = GetPsym (sym);
   11652       191568 :   switch (pSym->SymbolType)
   11653              :     {
   11654       191568 :       case SymbolTable_VarSym:
   11655       191568 :         return pSym->Var.IsSSA;
   11656              :         break;
   11657              : 
   11658              : 
   11659              :       default:
   11660              :         return false;
   11661              :         break;
   11662              :     }
   11663              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11664              :   __builtin_unreachable ();
   11665              : }
   11666              : 
   11667              : 
   11668              : /*
   11669              :    PutVarConst - sets the IsConst field to value indicating the variable is read only.
   11670              : */
   11671              : 
   11672       190340 : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value)
   11673              : {
   11674       190340 :   SymbolTable_PtrToSymbol pSym;
   11675              : 
   11676       190340 :   if (SymbolTable_IsVar (sym))
   11677              :     {
   11678       190340 :       pSym = GetPsym (sym);
   11679       190340 :       pSym->Var.IsConst = value;
   11680              :     }
   11681       190340 : }
   11682              : 
   11683              : 
   11684              : /*
   11685              :    MakeGnuAsm - create a GnuAsm symbol.
   11686              : */
   11687              : 
   11688           27 : extern "C" unsigned int SymbolTable_MakeGnuAsm (void)
   11689              : {
   11690           27 :   SymbolTable_PtrToSymbol pSym;
   11691           27 :   unsigned int Sym;
   11692              : 
   11693           27 :   NewSym (&Sym);
   11694           27 :   pSym = GetPsym (Sym);
   11695           27 :   pSym->SymbolType = SymbolTable_GnuAsmSym;
   11696           27 :   pSym->GnuAsm.String = SymbolTable_NulSym;
   11697           27 :   InitWhereDeclared (&pSym->GnuAsm.At);
   11698           27 :   pSym->GnuAsm.Inputs = SymbolTable_NulSym;
   11699           27 :   pSym->GnuAsm.Outputs = SymbolTable_NulSym;
   11700           27 :   pSym->GnuAsm.Trashed = SymbolTable_NulSym;
   11701           27 :   pSym->GnuAsm.Volatile = false;
   11702           27 :   pSym->GnuAsm.Simple = false;
   11703           27 :   return Sym;
   11704              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11705              :   __builtin_unreachable ();
   11706              : }
   11707              : 
   11708              : 
   11709              : /*
   11710              :    PutGnuAsm - places the instruction textual name into the GnuAsm symbol.
   11711              : */
   11712              : 
   11713           27 : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string)
   11714              : {
   11715           27 :   SymbolTable_PtrToSymbol pSym;
   11716              : 
   11717           27 :   M2Debug_Assert (SymbolTable_IsConstString (string));
   11718           27 :   pSym = GetPsym (sym);
   11719           27 :   switch (pSym->SymbolType)
   11720              :     {
   11721           27 :       case SymbolTable_GnuAsmSym:
   11722           27 :         pSym->GnuAsm.String = string;
   11723           27 :         break;
   11724              : 
   11725              : 
   11726            0 :       default:
   11727            0 :         M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
   11728           27 :         break;
   11729              :     }
   11730           27 : }
   11731              : 
   11732              : 
   11733              : /*
   11734              :    PutGnuAsmOutput - places the interface object, out, into GnuAsm symbol, sym.
   11735              : */
   11736              : 
   11737           21 : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out)
   11738              : {
   11739           21 :   SymbolTable_PtrToSymbol pSym;
   11740              : 
   11741           21 :   pSym = GetPsym (sym);
   11742           21 :   switch (pSym->SymbolType)
   11743              :     {
   11744           21 :       case SymbolTable_GnuAsmSym:
   11745           21 :         pSym->GnuAsm.Outputs = out;
   11746           21 :         break;
   11747              : 
   11748              : 
   11749            0 :       default:
   11750            0 :         M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
   11751           21 :         break;
   11752              :     }
   11753           21 : }
   11754              : 
   11755              : 
   11756              : /*
   11757              :    PutGnuAsmInput - places the interface object, in, into GnuAsm symbol, sym.
   11758              : */
   11759              : 
   11760           15 : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in)
   11761              : {
   11762           15 :   SymbolTable_PtrToSymbol pSym;
   11763              : 
   11764           15 :   pSym = GetPsym (sym);
   11765           15 :   switch (pSym->SymbolType)
   11766              :     {
   11767           15 :       case SymbolTable_GnuAsmSym:
   11768           15 :         pSym->GnuAsm.Inputs = in;
   11769           15 :         break;
   11770              : 
   11771              : 
   11772            0 :       default:
   11773            0 :         M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
   11774           15 :         break;
   11775              :     }
   11776           15 : }
   11777              : 
   11778              : 
   11779              : /*
   11780              :    PutGnuAsmTrash - places the interface object, trash, into GnuAsm symbol, sym.
   11781              : */
   11782              : 
   11783            9 : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash)
   11784              : {
   11785            9 :   SymbolTable_PtrToSymbol pSym;
   11786              : 
   11787            9 :   pSym = GetPsym (sym);
   11788            9 :   switch (pSym->SymbolType)
   11789              :     {
   11790            9 :       case SymbolTable_GnuAsmSym:
   11791            9 :         pSym->GnuAsm.Trashed = trash;
   11792            9 :         break;
   11793              : 
   11794              : 
   11795            0 :       default:
   11796            0 :         M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
   11797            9 :         break;
   11798              :     }
   11799            9 : }
   11800              : 
   11801              : 
   11802              : /*
   11803              :    GetGnuAsm - returns the string symbol, representing the instruction textual
   11804              :                of the GnuAsm symbol. It will return a ConstString.
   11805              : */
   11806              : 
   11807           27 : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym)
   11808              : {
   11809           27 :   SymbolTable_PtrToSymbol pSym;
   11810              : 
   11811           27 :   pSym = GetPsym (sym);
   11812           27 :   switch (pSym->SymbolType)
   11813              :     {
   11814           27 :       case SymbolTable_GnuAsmSym:
   11815           27 :         return pSym->GnuAsm.String;
   11816            0 :         break;
   11817              : 
   11818              : 
   11819            0 :       default:
   11820            0 :         M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
   11821              :         break;
   11822              :     }
   11823              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11824              :   __builtin_unreachable ();
   11825              : }
   11826              : 
   11827              : 
   11828              : /*
   11829              :    GetGnuAsmInput - returns the input list of registers.
   11830              : */
   11831              : 
   11832           27 : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym)
   11833              : {
   11834           27 :   SymbolTable_PtrToSymbol pSym;
   11835              : 
   11836           27 :   pSym = GetPsym (sym);
   11837           27 :   switch (pSym->SymbolType)
   11838              :     {
   11839           27 :       case SymbolTable_GnuAsmSym:
   11840           27 :         return pSym->GnuAsm.Inputs;
   11841            0 :         break;
   11842              : 
   11843              : 
   11844            0 :       default:
   11845            0 :         M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
   11846              :         break;
   11847              :     }
   11848              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11849              :   __builtin_unreachable ();
   11850              : }
   11851              : 
   11852              : 
   11853              : /*
   11854              :    GetGnuAsmOutput - returns the output list of registers.
   11855              : */
   11856              : 
   11857           27 : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym)
   11858              : {
   11859           27 :   SymbolTable_PtrToSymbol pSym;
   11860              : 
   11861           27 :   pSym = GetPsym (sym);
   11862           27 :   switch (pSym->SymbolType)
   11863              :     {
   11864           27 :       case SymbolTable_GnuAsmSym:
   11865           27 :         return pSym->GnuAsm.Outputs;
   11866            0 :         break;
   11867              : 
   11868              : 
   11869            0 :       default:
   11870            0 :         M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
   11871              :         break;
   11872              :     }
   11873              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11874              :   __builtin_unreachable ();
   11875              : }
   11876              : 
   11877              : 
   11878              : /*
   11879              :    GetGnuAsmTrash - returns the list of trashed registers.
   11880              : */
   11881              : 
   11882           27 : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym)
   11883              : {
   11884           27 :   SymbolTable_PtrToSymbol pSym;
   11885              : 
   11886           27 :   pSym = GetPsym (sym);
   11887           27 :   switch (pSym->SymbolType)
   11888              :     {
   11889           27 :       case SymbolTable_GnuAsmSym:
   11890           27 :         return pSym->GnuAsm.Trashed;
   11891            0 :         break;
   11892              : 
   11893              : 
   11894            0 :       default:
   11895            0 :         M2Error_InternalError ((const char *) "expecting PutGnuAsm symbol", 26);
   11896              :         break;
   11897              :     }
   11898              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   11899              :   __builtin_unreachable ();
   11900              : }
   11901              : 
   11902              : 
   11903              : /*
   11904              :    PutGnuAsmVolatile - defines a GnuAsm symbol as VOLATILE.
   11905              : */
   11906              : 
   11907           15 : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym)
   11908              : {
   11909           15 :   SymbolTable_PtrToSymbol pSym;
   11910              : 
   11911           15 :   pSym = GetPsym (Sym);
   11912           15 :   switch (pSym->SymbolType)
   11913              :     {
   11914           15 :       case SymbolTable_GnuAsmSym:
   11915           15 :         pSym->GnuAsm.Volatile = true;
   11916           15 :         break;
   11917              : 
   11918              : 
   11919            0 :       default:
   11920            0 :         M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
   11921           15 :         break;
   11922              :     }
   11923           15 : }
   11924              : 
   11925              : 
   11926              : /*
   11927              :    PutGnuAsmSimple - defines a GnuAsm symbol as a simple kind.
   11928              : */
   11929              : 
   11930            6 : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym)
   11931              : {
   11932            6 :   SymbolTable_PtrToSymbol pSym;
   11933              : 
   11934            6 :   pSym = GetPsym (Sym);
   11935            6 :   switch (pSym->SymbolType)
   11936              :     {
   11937            6 :       case SymbolTable_GnuAsmSym:
   11938            6 :         pSym->GnuAsm.Simple = true;
   11939            6 :         break;
   11940              : 
   11941              : 
   11942            0 :       default:
   11943            0 :         M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
   11944            6 :         break;
   11945              :     }
   11946            6 : }
   11947              : 
   11948              : 
   11949              : /*
   11950              :    MakeRegInterface - creates and returns a register interface symbol.
   11951              : */
   11952              : 
   11953           33 : extern "C" unsigned int SymbolTable_MakeRegInterface (void)
   11954              : {
   11955           33 :   SymbolTable_PtrToSymbol pSym;
   11956           33 :   unsigned int Sym;
   11957              : 
   11958           33 :   NewSym (&Sym);
   11959           33 :   pSym = GetPsym (Sym);
   11960           33 :   pSym->SymbolType = SymbolTable_InterfaceSym;
   11961           33 :   pSym->Interface.Parameters = Indexing_InitIndex (1);
   11962           33 :   InitWhereDeclared (&pSym->Interface.At);
   11963           33 :   return Sym;
   11964              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   11965              :   __builtin_unreachable ();
   11966              : }
   11967              : 
   11968              : 
   11969              : /*
   11970              :    PutRegInterface - places a, name, string, and, object, into the interface array,
   11971              :                      sym, at position, i.
   11972              :                      The string symbol will either be a register name or a constraint.
   11973              :                      The object is an optional Modula-2 variable or constant symbol.
   11974              :                      read and write are the quadruple numbers representing any read
   11975              :                      or write operation.
   11976              : */
   11977              : 
   11978           36 : extern "C" void SymbolTable_PutRegInterface (unsigned int tok, unsigned int sym, unsigned int i, NameKey_Name n, unsigned int string, unsigned int object, unsigned int read_, unsigned int write_)
   11979              : {
   11980           36 :   SymbolTable_PtrToSymbol pSym;
   11981           36 :   SymbolTable_PtrToAsmConstraint p;
   11982              : 
   11983           36 :   pSym = GetPsym (sym);
   11984           36 :   switch (pSym->SymbolType)
   11985              :     {
   11986           36 :       case SymbolTable_InterfaceSym:
   11987           36 :         if (Indexing_InBounds (pSym->Interface.Parameters, i))
   11988              :           {
   11989            0 :             p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
   11990              :           }
   11991           36 :         else if (i == ((Indexing_HighIndice (pSym->Interface.Parameters))+1))
   11992              :           {
   11993              :             /* avoid dangling else.  */
   11994           36 :             Storage_ALLOCATE ((void **) &p, sizeof (SymbolTable__T5));
   11995           36 :             Indexing_PutIndice (pSym->Interface.Parameters, i, reinterpret_cast <void *> (p));
   11996              :           }
   11997              :         else
   11998              :           {
   11999              :             /* avoid dangling else.  */
   12000            0 :             M2Error_InternalError ((const char *) "expecting to add parameters sequentially", 40);
   12001              :           }
   12002           36 :         p->tokpos = tok;
   12003           36 :         p->name = n;
   12004           36 :         p->str = string;
   12005           36 :         p->obj = object;
   12006           36 :         PutFirstUsed (object, tok, read_, write_);
   12007           36 :         break;
   12008              : 
   12009              : 
   12010            0 :       default:
   12011            0 :         M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
   12012           36 :         break;
   12013              :     }
   12014           36 : }
   12015              : 
   12016              : 
   12017              : /*
   12018              :    GetRegInterface - gets a, name, string, and, object, from the interface array,
   12019              :                      sym, from position, i.
   12020              : */
   12021              : 
   12022           69 : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object)
   12023              : {
   12024           69 :   SymbolTable_PtrToSymbol pSym;
   12025           69 :   SymbolTable_PtrToAsmConstraint p;
   12026              : 
   12027           69 :   pSym = GetPsym (sym);
   12028           69 :   switch (pSym->SymbolType)
   12029              :     {
   12030           69 :       case SymbolTable_InterfaceSym:
   12031           69 :         if (Indexing_InBounds (pSym->Interface.Parameters, i))
   12032              :           {
   12033           36 :             p = static_cast<SymbolTable_PtrToAsmConstraint> (Indexing_GetIndice (pSym->Interface.Parameters, i));
   12034           36 :             (*tok) = p->tokpos;
   12035           36 :             (*n) = p->name;
   12036           36 :             (*string) = p->str;
   12037           36 :             (*object) = p->obj;
   12038              :           }
   12039              :         else
   12040              :           {
   12041           33 :             (*tok) = M2LexBuf_UnknownTokenNo;
   12042           33 :             (*n) = NameKey_NulName;
   12043           33 :             (*string) = SymbolTable_NulSym;
   12044           33 :             (*object) = SymbolTable_NulSym;
   12045              :           }
   12046           69 :         break;
   12047              : 
   12048              : 
   12049            0 :       default:
   12050            0 :         M2Error_InternalError ((const char *) "expecting Interface symbol", 26);
   12051           69 :         break;
   12052              :     }
   12053           69 : }
   12054              : 
   12055              : 
   12056              : /*
   12057              :    GetModule - Returns the Module symbol for the module with name, name.
   12058              : */
   12059              : 
   12060       402449 : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name)
   12061              : {
   12062       402449 :   return static_cast<unsigned int> (SymbolKey_GetSymKey (ModuleTree, name));
   12063              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12064              :   __builtin_unreachable ();
   12065              : }
   12066              : 
   12067              : 
   12068              : /*
   12069              :    GetCurrentModule - returns the current module Sym that is being
   12070              :                       compiled.
   12071              : */
   12072              : 
   12073     59044150 : extern "C" unsigned int SymbolTable_GetCurrentModule (void)
   12074              : {
   12075     59044150 :   return CurrentModule;
   12076              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12077              :   __builtin_unreachable ();
   12078              : }
   12079              : 
   12080              : 
   12081              : /*
   12082              :    GetFileModule - returns the FileModule symbol that was requested by
   12083              :                    the user to be compiled.
   12084              : */
   12085              : 
   12086       278127 : extern "C" unsigned int SymbolTable_GetFileModule (void)
   12087              : {
   12088       278127 :   return FileModule;
   12089              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12090              :   __builtin_unreachable ();
   12091              : }
   12092              : 
   12093              : 
   12094              : /*
   12095              :    GetBaseModule - returns the base module symbol that contains Modula-2
   12096              :                    base types, procedures and functions.
   12097              : */
   12098              : 
   12099      8409329 : extern "C" unsigned int SymbolTable_GetBaseModule (void)
   12100              : {
   12101      8409329 :   return BaseModule;
   12102              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12103              :   __builtin_unreachable ();
   12104              : }
   12105              : 
   12106              : 
   12107              : /*
   12108              :    GetMainModule - returns the main module symbol that was requested by
   12109              :                    the user to be compiled.
   12110              : */
   12111              : 
   12112     19922995 : extern "C" unsigned int SymbolTable_GetMainModule (void)
   12113              : {
   12114     19922995 :   return MainModule;
   12115              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12116              :   __builtin_unreachable ();
   12117              : }
   12118              : 
   12119              : 
   12120              : /*
   12121              :    GetCurrentModuleScope - returns the module symbol which forms the
   12122              :                            current (possibly inner most) module.
   12123              : */
   12124              : 
   12125      2271236 : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void)
   12126              : {
   12127      2271236 :   SymbolTable_PtrToCallFrame pCall;
   12128      2271236 :   unsigned int i;
   12129              : 
   12130      2271236 :   i = ScopePtr;
   12131      2271236 :   pCall = GetPcall (i);
   12132      5311361 :   while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
   12133              :     {
   12134       768889 :       M2Debug_Assert (i > 0);
   12135       768889 :       i -= 1;
   12136       768889 :       pCall = GetPcall (i);
   12137              :     }
   12138      2271236 :   return pCall->Search;
   12139              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12140              :   __builtin_unreachable ();
   12141              : }
   12142              : 
   12143              : 
   12144              : /*
   12145              :    GetLastModuleScope - returns the last module scope encountered,
   12146              :                         the module scope before the Current Module Scope.
   12147              : */
   12148              : 
   12149            0 : extern "C" unsigned int SymbolTable_GetLastModuleScope (void)
   12150              : {
   12151            0 :   SymbolTable_PtrToCallFrame pCall;
   12152            0 :   unsigned int i;
   12153              : 
   12154            0 :   i = ScopePtr;
   12155            0 :   pCall = GetPcall (i);
   12156            0 :   while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
   12157              :     {
   12158            0 :       M2Debug_Assert (i > 0);
   12159            0 :       i -= 1;
   12160            0 :       pCall = GetPcall (i);
   12161              :     }
   12162              :   /* Found module at position, i.  */
   12163            0 :   i -= 1;  /* Move to an outer level module scope  */
   12164            0 :   pCall = GetPcall (i);  /* Move to an outer level module scope  */
   12165            0 :   while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
   12166              :     {
   12167            0 :       M2Debug_Assert (i > 0);
   12168            0 :       i -= 1;
   12169            0 :       pCall = GetPcall (i);
   12170              :     }
   12171              :   /* Found module at position, i.  */
   12172            0 :   return pCall->Search;
   12173              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12174              :   __builtin_unreachable ();
   12175              : }
   12176              : 
   12177              : 
   12178              : /*
   12179              :    AddSymToModuleScope - adds a symbol, Sym, to the scope of the module
   12180              :                          ModSym.
   12181              : */
   12182              : 
   12183      1002966 : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym)
   12184              : {
   12185      1002966 :   SymbolTable_PtrToSymbol pSym;
   12186              : 
   12187      1002966 :   pSym = GetPsym (ModSym);
   12188      1002966 :   switch (pSym->SymbolType)
   12189              :     {
   12190       886699 :       case SymbolTable_DefImpSym:
   12191       886699 :         if ((SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
   12192              :           {
   12193       886699 :             SymbolKey_PutSymKey (pSym->DefImp.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
   12194              :           }
   12195              :         else
   12196              :           {
   12197            0 :             M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
   12198              :           }
   12199              :         break;
   12200              : 
   12201       116207 :       case SymbolTable_ModuleSym:
   12202       116207 :         if ((SymbolKey_GetSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
   12203              :           {
   12204       116207 :             SymbolKey_PutSymKey (pSym->Module.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
   12205              :           }
   12206              :         else
   12207              :           {
   12208            0 :             M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
   12209              :           }
   12210              :         break;
   12211              : 
   12212           60 :       case SymbolTable_ProcedureSym:
   12213           60 :         if ((SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
   12214              :           {
   12215           60 :             SymbolKey_PutSymKey (pSym->Procedure.LocalSymbols, SymbolTable_GetSymName (Sym), Sym);
   12216              :           }
   12217              :         else
   12218              :           {
   12219            0 :             M2MetaError_MetaError1 ((const char *) "{%kIMPORT} name clash with symbol {%1Ead} symbol already declared ", 66, Sym);
   12220              :           }
   12221              :         break;
   12222              : 
   12223              : 
   12224            0 :       default:
   12225            0 :         M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
   12226      1002966 :         break;
   12227              :     }
   12228      1002966 : }
   12229              : 
   12230              : 
   12231              : /*
   12232              :    GetType - Returns the symbol that is the TYPE symbol to Sym.
   12233              :              If zero is returned then we assume type unknown.
   12234              : */
   12235              : 
   12236    742635278 : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym)
   12237              : {
   12238    742635278 :   SymbolTable_PtrToSymbol pSym;
   12239    742635278 :   unsigned int type;
   12240              : 
   12241    742635278 :   M2Debug_Assert (Sym != SymbolTable_NulSym);
   12242    742635272 :   pSym = GetPsym (Sym);
   12243    742635272 :   switch (pSym->SymbolType)
   12244              :     {
   12245            0 :       case SymbolTable_OAFamilySym:
   12246            0 :         type = pSym->OAFamily.SimpleType;
   12247            0 :         break;
   12248              : 
   12249     88967428 :       case SymbolTable_VarSym:
   12250     88967428 :         type = GetTypeOfVar (Sym);
   12251     88967428 :         break;
   12252              : 
   12253     22211497 :       case SymbolTable_ConstLitSym:
   12254     22211497 :         type = pSym->ConstLit.Type;
   12255     22211497 :         break;
   12256              : 
   12257     21717162 :       case SymbolTable_ConstVarSym:
   12258     21717162 :         type = pSym->ConstVar.Type;
   12259     21717162 :         break;
   12260              : 
   12261      5877395 :       case SymbolTable_ConstStringSym:
   12262      5877395 :         if (pSym->ConstString.Length == 1)
   12263              :           {
   12264      1033117 :             type = M2Base_Char;
   12265              :           }
   12266              :         else
   12267              :           {
   12268              :             type = SymbolTable_NulSym;  /* No type for a string  */
   12269              :           }
   12270              :         break;
   12271              : 
   12272    109482046 :       case SymbolTable_TypeSym:
   12273    109482046 :         type = pSym->Type.Type;
   12274    109482046 :         break;
   12275              : 
   12276    243112922 :       case SymbolTable_RecordFieldSym:
   12277    243112922 :         type = pSym->RecordField.Type;
   12278    243112922 :         break;
   12279              : 
   12280              :       case SymbolTable_RecordSym:
   12281              :         type = SymbolTable_NulSym;  /* No type for a record  */
   12282              :         break;
   12283              : 
   12284              :       case SymbolTable_VarientSym:
   12285              :         type = SymbolTable_NulSym;  /* No type for a record  */
   12286              :         break;
   12287              : 
   12288     44974238 :       case SymbolTable_EnumerationFieldSym:
   12289     44974238 :         type = pSym->EnumerationField.Type;  /* No type for a record  */
   12290     44974238 :         break;
   12291              : 
   12292              :       case SymbolTable_EnumerationSym:
   12293              :         type = SymbolTable_NulSym;  /* No type for enumeration  */
   12294              :         break;
   12295              : 
   12296    103511641 :       case SymbolTable_PointerSym:
   12297    103511641 :         type = pSym->Pointer.Type;  /* No type for enumeration  */
   12298    103511641 :         break;
   12299              : 
   12300     17883761 :       case SymbolTable_ProcedureSym:
   12301     17883761 :         type = pSym->Procedure.ReturnType;
   12302     17883761 :         break;
   12303              : 
   12304      5291406 :       case SymbolTable_ProcTypeSym:
   12305      5291406 :         type = pSym->ProcType.ReturnType;
   12306      5291406 :         break;
   12307              : 
   12308     21093258 :       case SymbolTable_ParamSym:
   12309     21093258 :         type = pSym->Param.Type;
   12310     21093258 :         break;
   12311              : 
   12312      3471805 :       case SymbolTable_VarParamSym:
   12313      3471805 :         type = pSym->VarParam.Type;
   12314      3471805 :         break;
   12315              : 
   12316     12090442 :       case SymbolTable_SubrangeSym:
   12317     12090442 :         type = pSym->Subrange.Type;
   12318     12090442 :         break;
   12319              : 
   12320      5424122 :       case SymbolTable_ArraySym:
   12321      5424122 :         type = pSym->Array.Type;
   12322      5424122 :         break;
   12323              : 
   12324      5428770 :       case SymbolTable_SubscriptSym:
   12325      5428770 :         type = pSym->Subscript.Type;
   12326      5428770 :         break;
   12327              : 
   12328       563218 :       case SymbolTable_SetSym:
   12329       563218 :         type = pSym->Set.Type;
   12330       563218 :         break;
   12331              : 
   12332     29333593 :       case SymbolTable_UnboundedSym:
   12333     29333593 :         type = pSym->Unbounded.Type;
   12334     29333593 :         break;
   12335              : 
   12336              :       case SymbolTable_UndefinedSym:
   12337              :         type = SymbolTable_NulSym;
   12338              :         break;
   12339              : 
   12340            0 :       case SymbolTable_PartialUnboundedSym:
   12341            0 :         type = pSym->PartialUnbounded.Type;
   12342            0 :         break;
   12343              : 
   12344              :       case SymbolTable_ObjectSym:
   12345              :         type = SymbolTable_NulSym;
   12346              :         break;
   12347              : 
   12348              : 
   12349            0 :       default:
   12350            0 :         M2Error_InternalError ((const char *) "not implemented yet", 19);
   12351    742635272 :         break;
   12352              :     }
   12353    742635272 :   return type;
   12354              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12355              :   __builtin_unreachable ();
   12356              : }
   12357              : 
   12358              : 
   12359              : /*
   12360              :    SkipType - if sym is a TYPE foo = bar
   12361              :               then call SkipType(bar)
   12362              :               else return sym
   12363              : 
   12364              :               it does not skip over hidden types.
   12365              : */
   12366              : 
   12367     58172413 : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym)
   12368              : {
   12369     58435887 :   if ((((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
   12370              :     {
   12371       263474 :       return SymbolTable_SkipType (SymbolTable_GetType (Sym));
   12372              :     }
   12373              :   else
   12374              :     {
   12375     58172413 :       return Sym;
   12376              :     }
   12377              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12378              :   __builtin_unreachable ();
   12379              : }
   12380              : 
   12381              : 
   12382              : /*
   12383              :    SkipTypeAndSubrange - if sym is a TYPE foo = bar OR
   12384              :                             sym is declared as a subrange of bar
   12385              :                          then call SkipTypeAndSubrange(bar)
   12386              :                          else return sym
   12387              : 
   12388              :                          it does not skip over hidden types.
   12389              : */
   12390              : 
   12391         4290 : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym)
   12392              : {
   12393         4338 :   if ((((Sym != SymbolTable_NulSym) && ((SymbolTable_IsType (Sym)) || (SymbolTable_IsSubrange (Sym)))) && (! (SymbolTable_IsHiddenType (Sym)))) && ((SymbolTable_GetType (Sym)) != SymbolTable_NulSym))
   12394              :     {
   12395           48 :       return SymbolTable_SkipTypeAndSubrange (SymbolTable_GetType (Sym));
   12396              :     }
   12397              :   else
   12398              :     {
   12399         4290 :       return Sym;
   12400              :     }
   12401              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12402              :   __builtin_unreachable ();
   12403              : }
   12404              : 
   12405              : 
   12406              : /*
   12407              :    GetLowestType - Returns the lowest type in the type chain of
   12408              :                    symbol Sym.
   12409              :                    If NulSym is returned then we assume type unknown or
   12410              :                    you have reqested the type of a base type.
   12411              : */
   12412              : 
   12413      1474379 : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym)
   12414              : {
   12415      2504757 :   SymbolTable_PtrToSymbol pSym;
   12416      2504757 :   unsigned int type;
   12417              : 
   12418      2504757 :   M2Debug_Assert (Sym != SymbolTable_NulSym);
   12419      2504757 :   pSym = GetPsym (Sym);
   12420      2504757 :   switch (pSym->SymbolType)
   12421              :     {
   12422       453943 :       case SymbolTable_VarSym:
   12423       453943 :         type = pSym->Var.Type;
   12424       453943 :         break;
   12425              : 
   12426       276689 :       case SymbolTable_ConstLitSym:
   12427       276689 :         type = pSym->ConstLit.Type;
   12428       276689 :         break;
   12429              : 
   12430       382722 :       case SymbolTable_ConstVarSym:
   12431       382722 :         type = pSym->ConstVar.Type;
   12432       382722 :         break;
   12433              : 
   12434              :       case SymbolTable_ConstStringSym:
   12435              :         type = SymbolTable_NulSym;  /* No type for a string  */
   12436              :         break;
   12437              : 
   12438      1053540 :       case SymbolTable_TypeSym:
   12439      1053540 :         type = pSym->Type.Type;  /* No type for a string  */
   12440      1053540 :         break;
   12441              : 
   12442            0 :       case SymbolTable_RecordFieldSym:
   12443            0 :         type = pSym->RecordField.Type;
   12444            0 :         break;
   12445              : 
   12446              :       case SymbolTable_RecordSym:
   12447              :         type = SymbolTable_NulSym;  /* No type for a record  */
   12448              :         break;
   12449              : 
   12450        57719 :       case SymbolTable_EnumerationFieldSym:
   12451        57719 :         type = pSym->EnumerationField.Type;  /* No type for a record  */
   12452        57719 :         break;
   12453              : 
   12454              :       case SymbolTable_EnumerationSym:
   12455              :         type = SymbolTable_NulSym;  /* No type for enumeration  */
   12456              :         break;
   12457              : 
   12458              :       case SymbolTable_PointerSym:
   12459        31322 :         type = Sym;  /* we don't go to Pointer.Type  */
   12460              :         break;
   12461              : 
   12462        60233 :       case SymbolTable_ProcedureSym:
   12463        60233 :         type = pSym->Procedure.ReturnType;  /* we don't go to Pointer.Type  */
   12464        60233 :         break;
   12465              : 
   12466           12 :       case SymbolTable_ProcTypeSym:
   12467           12 :         type = pSym->ProcType.ReturnType;
   12468           12 :         break;
   12469              : 
   12470       129875 :       case SymbolTable_ParamSym:
   12471       129875 :         type = pSym->Param.Type;
   12472       129875 :         break;
   12473              : 
   12474         6680 :       case SymbolTable_VarParamSym:
   12475         6680 :         type = pSym->VarParam.Type;
   12476         6680 :         break;
   12477              : 
   12478           48 :       case SymbolTable_SubrangeSym:
   12479           48 :         type = pSym->Subrange.Type;
   12480           48 :         break;
   12481              : 
   12482           24 :       case SymbolTable_ArraySym:
   12483           24 :         type = pSym->Array.Type;
   12484           24 :         break;
   12485              : 
   12486        46824 :       case SymbolTable_SubscriptSym:
   12487        46824 :         type = pSym->Subscript.Type;
   12488        46824 :         break;
   12489              : 
   12490              :       case SymbolTable_SetSym:
   12491        31322 :         type = Sym;  /* Stop at the set type.  */
   12492              :         break;
   12493              : 
   12494            0 :       case SymbolTable_UnboundedSym:
   12495            0 :         type = pSym->Unbounded.Type;  /* Stop at the set type.  */
   12496            0 :         break;
   12497              : 
   12498              :       case SymbolTable_UndefinedSym:
   12499              :         type = SymbolTable_NulSym;
   12500              :         break;
   12501              : 
   12502              :       case SymbolTable_DummySym:
   12503              :         type = SymbolTable_NulSym;
   12504              :         break;
   12505              : 
   12506              : 
   12507            6 :       default:
   12508            6 :         M2Error_InternalError ((const char *) "not implemented yet", 19);
   12509      2504751 :         break;
   12510              :     }
   12511      2504751 :   pSym = GetPsym (Sym);
   12512      2504751 :   if ((pSym->SymbolType == SymbolTable_TypeSym) && (type == SymbolTable_NulSym))
   12513              :     {
   12514              :       type = Sym;  /* Base Type  */
   12515              :     }
   12516      1473383 :   else if (((type != SymbolTable_NulSym) && (SymbolTable_IsType (type))) && ((SymbolTable_GetAlignment (type)) == SymbolTable_NulSym))
   12517              :     {
   12518              :       /* avoid dangling else.  */
   12519              :       type = SymbolTable_GetLowestType (type);  /* Type def  */
   12520              :     }
   12521      1474373 :   return type;
   12522              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12523              :   __builtin_unreachable ();
   12524              : }
   12525              : 
   12526              : 
   12527              : /*
   12528              :    GetLType - get lowest type.  It returns the lowest type
   12529              :               of symbol, sym.  It skips over type equivalences.
   12530              :               It will not skip over base types.
   12531              : */
   12532              : 
   12533      8452934 : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym)
   12534              : {
   12535              :   /* 
   12536              :    Assert (doGetType (sym, TRUE, TRUE, TRUE, FALSE) = GetLowestType (sym)) ;
   12537              :   */
   12538      8452934 :   return doGetType (sym, true, true, true, false);
   12539              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12540              :   __builtin_unreachable ();
   12541              : }
   12542              : 
   12543              : 
   12544              : /*
   12545              :    GetSType - get source type.  It returns the type closest
   12546              :               to the object.  It does not skip over type
   12547              :               equivalences.  It will skip over base types.
   12548              : */
   12549              : 
   12550    654885280 : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym)
   12551              : {
   12552    654885280 :   M2Debug_Assert ((doGetType (sym, false, false, false, true)) == (SymbolTable_GetType (sym)));
   12553    654885280 :   return doGetType (sym, false, false, false, true);
   12554              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12555              :   __builtin_unreachable ();
   12556              : }
   12557              : 
   12558              : 
   12559              : /*
   12560              :    GetDType - get gcc declared type.  It returns the type
   12561              :               of the object which is declared to GCC.
   12562              :               It does skip over type equivalences but only
   12563              :               if they do not contain a user alignment.
   12564              :               It does not skip over hidden types.
   12565              :               It does not skip over base types.
   12566              : */
   12567              : 
   12568     23741383 : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym)
   12569              : {
   12570              :   /* 
   12571              :    Assert (doGetType (sym, TRUE, FALSE, FALSE, FALSE) = SkipType(GetType(sym))) ;
   12572              :   */
   12573     23741383 :   return doGetType (sym, true, false, false, false);
   12574              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12575              :   __builtin_unreachable ();
   12576              : }
   12577              : 
   12578              : 
   12579              : /*
   12580              :    GetTypeMode - return the type of sym, it returns Address is the
   12581              :                  symbol is a LValue.
   12582              : */
   12583              : 
   12584        20642 : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym)
   12585              : {
   12586        20642 :   if ((SymbolTable_GetMode (sym)) == SymbolTable_LeftValue)
   12587              :     {
   12588           90 :       return M2System_Address;
   12589              :     }
   12590              :   else
   12591              :     {
   12592        20552 :       return SymbolTable_GetType (sym);
   12593              :     }
   12594              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12595              :   __builtin_unreachable ();
   12596              : }
   12597              : 
   12598              : 
   12599              : /*
   12600              :    GetSym - searches the current scope (and previous scopes if the
   12601              :             scope tranparent allows) for a symbol with name.
   12602              : */
   12603              : 
   12604     70527113 : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name)
   12605              : {
   12606     70527113 :   unsigned int Sym;
   12607     70527113 :   unsigned int OldScopePtr;
   12608              : 
   12609     70527113 :   Sym = GetScopeSym (name, true);
   12610     70527113 :   if (Sym == SymbolTable_NulSym)
   12611              :     {
   12612              :       /* Check default base types for symbol  */
   12613     24994510 :       OldScopePtr = ScopePtr;  /* Save ScopePtr  */
   12614     24994510 :       ScopePtr = BaseScopePtr;  /* Alter ScopePtr to point to top of BaseModule  */
   12615     24994510 :       Sym = GetScopeSym (name, false);  /* Search BaseModule for name  */
   12616     24994510 :       ScopePtr = OldScopePtr;  /* Restored ScopePtr  */
   12617              :     }
   12618     70527113 :   return Sym;
   12619              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12620              :   __builtin_unreachable ();
   12621              : }
   12622              : 
   12623              : 
   12624              : /*
   12625              :    GetDeclareSym - searches for a symbol with a name SymName in the
   12626              :                    current and previous scopes.
   12627              :                    If the symbol is found then it is returned
   12628              :                    else an unknown symbol is returned.
   12629              :                    This procedure assumes that SymName is being
   12630              :                    declared at this point and therefore it does
   12631              :                    not examine the base scope (for pervasive
   12632              :                    identifiers).
   12633              : */
   12634              : 
   12635      9338566 : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName)
   12636              : {
   12637      9338566 :   unsigned int Sym;
   12638              : 
   12639      9338566 :   Sym = GetScopeSym (SymName, false);  /* must not be allowed to fetch a symbol through a procedure scope  */
   12640      9338566 :   if (Sym == SymbolTable_NulSym)  /* must not be allowed to fetch a symbol through a procedure scope  */
   12641              :     {
   12642      3656398 :       Sym = GetSymFromUnknownTree (SymName);
   12643      3656398 :       if (Sym == SymbolTable_NulSym)
   12644              :         {
   12645              :           /* Make unknown  */
   12646      3656398 :           NewSym (&Sym);
   12647      3656398 :           FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
   12648              :           /* 
   12649              :            ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
   12650              :   */
   12651      3656398 :           AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
   12652              :         }
   12653              :     }
   12654      9338566 :   return Sym;
   12655              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12656              :   __builtin_unreachable ();
   12657              : }
   12658              : 
   12659              : 
   12660              : /*
   12661              :    GetLocalSym - only searches the scope Sym for a symbol with name
   12662              :                  and returns the index to the symbol.
   12663              : */
   12664              : 
   12665    203774920 : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name)
   12666              : {
   12667    203774920 :   SymbolTable_PtrToSymbol pSym;
   12668    203774920 :   unsigned int LocalSym;
   12669              : 
   12670              :   /* 
   12671              :    WriteString('Attempting to retrieve symbol from ') ; WriteKey(GetSymName(Sym)) ;
   12672              :    WriteString(' local symbol table') ; WriteLn ;
   12673              :   */
   12674    203774920 :   pSym = GetPsym (Sym);
   12675    203774920 :   switch (pSym->SymbolType)
   12676              :     {
   12677     50480198 :       case SymbolTable_EnumerationSym:
   12678     50480198 :         LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, name));
   12679     50480198 :         break;
   12680              : 
   12681       621674 :       case SymbolTable_RecordSym:
   12682       621674 :         LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, name));
   12683       621674 :         break;
   12684              : 
   12685     53788252 :       case SymbolTable_ProcedureSym:
   12686     53788252 :         LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Procedure.LocalSymbols, name));
   12687     53788252 :         break;
   12688              : 
   12689     26221946 :       case SymbolTable_ModuleSym:
   12690     26221946 :         LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Module.LocalSymbols, name));
   12691     26221946 :         break;
   12692              : 
   12693     72662850 :       case SymbolTable_DefImpSym:
   12694     72662850 :         LocalSym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.LocalSymbols, name));
   12695     72662850 :         break;
   12696              : 
   12697              : 
   12698            0 :       default:
   12699            0 :         M2Error_InternalError ((const char *) "symbol does not have a LocalSymbols field", 41);
   12700    203774920 :         break;
   12701              :     }
   12702    203774920 :   return LocalSym;
   12703              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12704              :   __builtin_unreachable ();
   12705              : }
   12706              : 
   12707              : 
   12708              : /*
   12709              :    GetRecord - fetches the record symbol from the parent of Sym.
   12710              :                Sym maybe a varient symbol in which case its parent is searched
   12711              :                etc.
   12712              : */
   12713              : 
   12714        48134 : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym)
   12715              : {
   12716        54478 :   SymbolTable_PtrToSymbol pSym;
   12717              : 
   12718        54478 :   pSym = GetPsym (Sym);
   12719        54478 :   switch (pSym->SymbolType)
   12720              :     {
   12721              :       case SymbolTable_RecordSym:
   12722              :         return Sym;
   12723         6090 :         break;
   12724              : 
   12725         6090 :       case SymbolTable_VarientSym:
   12726         6090 :         return SymbolTable_GetRecord (pSym->Varient.Parent);
   12727          254 :         break;
   12728              : 
   12729          254 :       case SymbolTable_VarientFieldSym:
   12730          254 :         return SymbolTable_GetRecord (pSym->VarientField.Parent);
   12731            0 :         break;
   12732              : 
   12733              : 
   12734            0 :       default:
   12735            0 :         M2Error_InternalError ((const char *) "expecting Record or Varient symbol", 34);
   12736              :         break;
   12737              :     }
   12738              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   12739              :   __builtin_unreachable ();
   12740              : }
   12741              : 
   12742              : 
   12743              : /*
   12744              :    FromModuleGetSym - attempts to find a symbol of name, n, in the
   12745              :                       module, mod, scope.  An unknown symbol is created
   12746              :                       at token position tok if necessary.
   12747              : */
   12748              : 
   12749      8058261 : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod)
   12750              : {
   12751      8058261 :   NameKey_Name n1;
   12752      8058261 :   unsigned int sym;
   12753      8058261 :   unsigned int OldScopePtr;
   12754              : 
   12755      8058261 :   OldScopePtr = ScopePtr;
   12756      8058261 :   SymbolTable_StartScope (mod);
   12757      8058261 :   sym = SymbolTable_RequestSym (tok, n);
   12758      8058261 :   SymbolTable_EndScope ();
   12759      8058261 :   if (sym == SymbolTable_NulSym)
   12760              :     {
   12761              :       /* --fixme-- can sym ever be NulSym?  */
   12762            0 :       n1 = SymbolTable_GetSymName (mod);
   12763            0 :       M2Error_WriteFormat2 ((const char *) "cannot find procedure %a in module, %a", 38, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n1, (sizeof (n1)-1));
   12764              :     }
   12765      8058261 :   ScopePtr = OldScopePtr;
   12766      8058261 :   return sym;
   12767              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12768              :   __builtin_unreachable ();
   12769              : }
   12770              : 
   12771              : 
   12772              : /*
   12773              :    GetNth - returns the n th symbol in the list associated with the scope
   12774              :             of Sym.  Sym may be a Module, DefImp, Procedure, Record or
   12775              :             Enumeration symbol.
   12776              : */
   12777              : 
   12778    367777242 : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n)
   12779              : {
   12780    367777242 :   SymbolTable_PtrToSymbol pSym;
   12781    367777242 :   unsigned int i;
   12782              : 
   12783    367777242 :   pSym = GetPsym (Sym);
   12784    367777242 :   switch (pSym->SymbolType)
   12785              :     {
   12786    281835997 :       case SymbolTable_RecordSym:
   12787    281835997 :         i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Record.ListOfSons, n));
   12788    281835997 :         break;
   12789              : 
   12790      2874404 :       case SymbolTable_VarientSym:
   12791      2874404 :         i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Varient.ListOfSons, n));
   12792      2874404 :         break;
   12793              : 
   12794      5176350 :       case SymbolTable_VarientFieldSym:
   12795      5176350 :         i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->VarientField.ListOfSons, n));
   12796      5176350 :         break;
   12797              : 
   12798     76270412 :       case SymbolTable_ProcedureSym:
   12799     76270412 :         i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.ListOfVars, n));
   12800     76270412 :         break;
   12801              : 
   12802       642089 :       case SymbolTable_DefImpSym:
   12803       642089 :         i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfVars, n));
   12804       642089 :         break;
   12805              : 
   12806       565282 :       case SymbolTable_ModuleSym:
   12807       565282 :         i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfVars, n));
   12808       565282 :         break;
   12809              : 
   12810        47124 :       case SymbolTable_TupleSym:
   12811        47124 :         i = GetFromIndex (pSym->Tuple.list, n);
   12812        47124 :         break;
   12813              : 
   12814       365566 :       case SymbolTable_VarSym:
   12815       365566 :         i = GetNthFromComponent (Sym, n);
   12816       365566 :         break;
   12817              : 
   12818           18 :       case SymbolTable_EnumerationSym:
   12819           18 :         i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Enumeration.ListOfFields, n));
   12820           18 :         break;
   12821              : 
   12822              : 
   12823            0 :       default:
   12824            0 :         M2Error_InternalError ((const char *) "cannot GetNth from this symbol", 30);
   12825    367777242 :         break;
   12826              :     }
   12827    367777242 :   return i;
   12828              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12829              :   __builtin_unreachable ();
   12830              : }
   12831              : 
   12832              : 
   12833              : /*
   12834              :    GetNthParam - returns the n th parameter of a procedure Sym.
   12835              : */
   12836              : 
   12837     52926416 : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
   12838              : {
   12839     52926416 :   SymbolTable_PtrToSymbol pSym;
   12840     52926416 :   unsigned int i;
   12841              : 
   12842     52926416 :   if (ParamNo == 0)
   12843              :     {
   12844              :       /* The return type of the function  */
   12845            0 :       i = SymbolTable_GetType (Sym);
   12846              :     }
   12847              :   else
   12848              :     {
   12849     52926416 :       pSym = GetPsym (Sym);
   12850     52926416 :       switch (pSym->SymbolType)
   12851              :         {
   12852     44023698 :           case SymbolTable_ProcedureSym:
   12853     44023698 :             i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo));
   12854     44023698 :             break;
   12855              : 
   12856      8902718 :           case SymbolTable_ProcTypeSym:
   12857      8902718 :             i = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, ParamNo));
   12858      8902718 :             break;
   12859              : 
   12860              : 
   12861            0 :           default:
   12862            0 :             M2Error_InternalError ((const char *) "expecting ProcedureSym or ProcTypeSym", 37);
   12863     52926416 :             break;
   12864              :         }
   12865              :     }
   12866     52926416 :   return i;
   12867              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12868              :   __builtin_unreachable ();
   12869              : }
   12870              : 
   12871              : 
   12872              : /*
   12873              :    GetVarScope - returns the symbol which is the scope of variable Sym.
   12874              :                  ie a Module, DefImp or Procedure Symbol.
   12875              : */
   12876              : 
   12877        20802 : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym)
   12878              : {
   12879        20802 :   SymbolTable_PtrToSymbol pSym;
   12880              : 
   12881        20802 :   pSym = GetPsym (Sym);
   12882        20802 :   switch (pSym->SymbolType)
   12883              :     {
   12884              :       case SymbolTable_ErrorSym:
   12885              :         return SymbolTable_NulSym;
   12886        20802 :         break;
   12887              : 
   12888        20802 :       case SymbolTable_VarSym:
   12889        20802 :         return pSym->Var.Scope;
   12890            0 :         break;
   12891              : 
   12892              : 
   12893            0 :       default:
   12894            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
   12895              :         break;
   12896              :     }
   12897              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   12898              :   __builtin_unreachable ();
   12899              : }
   12900              : 
   12901              : 
   12902              : /*
   12903              :    GetSubrange - returns HighSym and LowSym - two constants which make up the
   12904              :                  subrange.
   12905              : */
   12906              : 
   12907     26232486 : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym)
   12908              : {
   12909     26232486 :   SymbolTable_PtrToSymbol pSym;
   12910              : 
   12911     26232486 :   pSym = GetPsym (Sym);
   12912     26232486 :   switch (pSym->SymbolType)
   12913              :     {
   12914     26232486 :       case SymbolTable_SubrangeSym:
   12915     26232486 :         (*HighSym) = pSym->Subrange.High;
   12916     26232486 :         (*LowSym) = pSym->Subrange.Low;
   12917     26232486 :         break;
   12918              : 
   12919              : 
   12920            0 :       default:
   12921            0 :         M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
   12922     26232486 :         break;
   12923              :     }
   12924     26232486 : }
   12925              : 
   12926              : 
   12927              : /*
   12928              :    GetParam - returns the ParamNo parameter from procedure ProcSym
   12929              : */
   12930              : 
   12931      9178199 : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo)
   12932              : {
   12933      9178199 :   AssertInRange (Sym);
   12934      9178199 :   if (ParamNo == 0)
   12935              :     {
   12936              :       /* Parameter Zero is the return argument for the Function  */
   12937            0 :       return SymbolTable_GetType (Sym);
   12938              :     }
   12939              :   else
   12940              :     {
   12941      9178199 :       return SymbolTable_GetNthParamAny (Sym, ParamNo);
   12942              :     }
   12943              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   12944              :   __builtin_unreachable ();
   12945              : }
   12946              : 
   12947              : 
   12948              : /*
   12949              :    GetString - returns the contents of the string symbol sym, note that
   12950              :                this is not the same as GetName (unless it was a literal).
   12951              : */
   12952              : 
   12953       484757 : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym)
   12954              : {
   12955       484757 :   SymbolTable_PtrToSymbol pSym;
   12956              : 
   12957       484757 :   pSym = GetPsym (Sym);
   12958       484757 :   switch (pSym->SymbolType)
   12959              :     {
   12960       484757 :       case SymbolTable_ConstStringSym:
   12961       484757 :         if (pSym->ConstString.Known)
   12962              :           {
   12963       484757 :             return pSym->ConstString.Contents;
   12964              :           }
   12965              :         else
   12966              :           {
   12967            0 :             M2Error_InternalError ((const char *) "const string contents are unknown", 33);
   12968              :           }
   12969            0 :         break;
   12970              : 
   12971              : 
   12972            0 :       default:
   12973            0 :         M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
   12974              :         break;
   12975              :     }
   12976              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   12977              :   __builtin_unreachable ();
   12978              : }
   12979              : 
   12980              : 
   12981              : /*
   12982              :    GetStringLength - returns the length of the string symbol Sym.
   12983              : */
   12984              : 
   12985       974263 : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym)
   12986              : {
   12987       974263 :   SymbolTable_PtrToSymbol pSym;
   12988              : 
   12989       974263 :   pSym = GetPsym (sym);
   12990       974263 :   switch (pSym->SymbolType)
   12991              :     {
   12992       974263 :       case SymbolTable_ConstStringSym:
   12993       974263 :         if (pSym->ConstString.Known)
   12994              :           {
   12995       974263 :             return pSym->ConstString.Length;
   12996              :           }
   12997              :         else
   12998              :           {
   12999            0 :             M2MetaError_MetaErrorT0 (tok, (const char *) "const string contents are unknown", 33);
   13000            0 :             return 0;
   13001              :           }
   13002            0 :         break;
   13003              : 
   13004              : 
   13005            0 :       default:
   13006            0 :         M2Error_InternalError ((const char *) "expecting ConstString symbol", 28);
   13007              :         break;
   13008              :     }
   13009              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13010              :   __builtin_unreachable ();
   13011              : }
   13012              : 
   13013              : 
   13014              : /*
   13015              :    GetProcedureBuiltin - returns the builtin name for the equivalent procedure, Sym.
   13016              : */
   13017              : 
   13018        21466 : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym)
   13019              : {
   13020        21466 :   SymbolTable_PtrToSymbol pSym;
   13021              : 
   13022        21466 :   pSym = GetPsym (Sym);
   13023        21466 :   switch (pSym->SymbolType)
   13024              :     {
   13025        21466 :       case SymbolTable_ProcedureSym:
   13026        21466 :         return pSym->Procedure.BuiltinName;
   13027            0 :         break;
   13028              : 
   13029              : 
   13030            0 :       default:
   13031            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   13032              :         break;
   13033              :     }
   13034              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13035              :   __builtin_unreachable ();
   13036              : }
   13037              : 
   13038              : 
   13039              : /*
   13040              :    PutProcedureBuiltin - assigns the builtin name for the equivalent procedure, Sym.
   13041              : */
   13042              : 
   13043       881504 : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name)
   13044              : {
   13045       881504 :   SymbolTable_PtrToSymbol pSym;
   13046              : 
   13047       881504 :   pSym = GetPsym (Sym);
   13048       881504 :   switch (pSym->SymbolType)
   13049              :     {
   13050       881504 :       case SymbolTable_ProcedureSym:
   13051       881504 :         pSym->Procedure.BuiltinName = name;
   13052       881504 :         pSym->Procedure.IsBuiltin = true;
   13053              :         /* we use the same extra pass method as hidden types for builtins  */
   13054       881504 :         SymbolTable_PutHiddenTypeDeclared ();
   13055       881504 :         break;
   13056              : 
   13057              : 
   13058            0 :       default:
   13059            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   13060       881504 :         break;
   13061              :     }
   13062       881504 : }
   13063              : 
   13064              : 
   13065              : /*
   13066              :    IsProcedureBuiltin - returns TRUE if this procedure has a builtin equivalent.
   13067              : */
   13068              : 
   13069      1214238 : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym)
   13070              : {
   13071      1214238 :   SymbolTable_PtrToSymbol pSym;
   13072              : 
   13073      1214238 :   pSym = GetPsym (Sym);
   13074      1214238 :   switch (pSym->SymbolType)
   13075              :     {
   13076      1214238 :       case SymbolTable_ProcedureSym:
   13077      1214238 :         return pSym->Procedure.IsBuiltin;
   13078            0 :         break;
   13079              : 
   13080              : 
   13081            0 :       default:
   13082            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   13083              :         break;
   13084              :     }
   13085              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13086              :   __builtin_unreachable ();
   13087              : }
   13088              : 
   13089              : 
   13090              : /*
   13091              :    PutProcedureInline - determines that procedure, Sym, has been requested to be inlined.
   13092              : */
   13093              : 
   13094            0 : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym)
   13095              : {
   13096            0 :   SymbolTable_PtrToSymbol pSym;
   13097              : 
   13098            0 :   pSym = GetPsym (Sym);
   13099            0 :   switch (pSym->SymbolType)
   13100              :     {
   13101            0 :       case SymbolTable_ProcedureSym:
   13102            0 :         pSym->Procedure.IsInline = true;
   13103            0 :         break;
   13104              : 
   13105              : 
   13106            0 :       default:
   13107            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   13108            0 :         break;
   13109              :     }
   13110            0 : }
   13111              : 
   13112        76761 : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym)
   13113              : {
   13114        76761 :   SymbolTable_PtrToSymbol pSym;
   13115              : 
   13116              :   /* 
   13117              :    IsProcedureBuiltin - returns TRUE if this procedure was declared as inlined.
   13118              :   */
   13119        76761 :   pSym = GetPsym (Sym);
   13120        76761 :   switch (pSym->SymbolType)
   13121              :     {
   13122        76761 :       case SymbolTable_ProcedureSym:
   13123        76761 :         return pSym->Procedure.IsInline;
   13124            0 :         break;
   13125              : 
   13126              : 
   13127            0 :       default:
   13128            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   13129              :         break;
   13130              :     }
   13131              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13132              :   __builtin_unreachable ();
   13133              : }
   13134              : 
   13135              : 
   13136              : /*
   13137              :    PutExceptionBlock - sets a BOOLEAN in block module/procedure/defimp,
   13138              :                        sym, indicating that this block as an EXCEPT
   13139              :                        statement sequence.
   13140              : */
   13141              : 
   13142          222 : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym)
   13143              : {
   13144          222 :   SymbolTable_PtrToSymbol pSym;
   13145              : 
   13146          222 :   pSym = GetPsym (sym);
   13147          222 :   switch (pSym->SymbolType)
   13148              :     {
   13149          168 :       case SymbolTable_ProcedureSym:
   13150          168 :         pSym->Procedure.ExceptionBlock = true;
   13151          168 :         break;
   13152              : 
   13153           54 :       case SymbolTable_ModuleSym:
   13154           54 :         pSym->Module.ExceptionBlock = true;
   13155           54 :         break;
   13156              : 
   13157            0 :       case SymbolTable_DefImpSym:
   13158            0 :         pSym->DefImp.ExceptionBlock = true;
   13159            0 :         break;
   13160              : 
   13161              : 
   13162            0 :       default:
   13163            0 :         M2Error_InternalError ((const char *) "expecting Procedure", 19);
   13164          222 :         break;
   13165              :     }
   13166          222 : }
   13167              : 
   13168              : 
   13169              : /*
   13170              :    HasExceptionBlock - returns a BOOLEAN determining whether
   13171              :                        module/procedure/defimp, sym, has
   13172              :                        an EXCEPT statement sequence.
   13173              : */
   13174              : 
   13175       323076 : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym)
   13176              : {
   13177       323076 :   SymbolTable_PtrToSymbol pSym;
   13178              : 
   13179       323076 :   pSym = GetPsym (sym);
   13180       323076 :   switch (pSym->SymbolType)
   13181              :     {
   13182       157882 :       case SymbolTable_ProcedureSym:
   13183       157882 :         return pSym->Procedure.ExceptionBlock;
   13184        23756 :         break;
   13185              : 
   13186        23756 :       case SymbolTable_ModuleSym:
   13187        23756 :         return pSym->Module.ExceptionBlock;
   13188       141438 :         break;
   13189              : 
   13190       141438 :       case SymbolTable_DefImpSym:
   13191       141438 :         return pSym->DefImp.ExceptionBlock;
   13192            0 :         break;
   13193              : 
   13194              : 
   13195            0 :       default:
   13196            0 :         M2Error_InternalError ((const char *) "expecting Procedure", 19);
   13197              :         break;
   13198              :     }
   13199              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13200              :   __builtin_unreachable ();
   13201              : }
   13202              : 
   13203              : 
   13204              : /*
   13205              :    PutExceptionFinally - sets a BOOLEAN in block module/defimp,
   13206              :                          sym, indicating that this FINALLY block
   13207              :                          as an EXCEPT statement sequence.
   13208              : */
   13209              : 
   13210            0 : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym)
   13211              : {
   13212            0 :   SymbolTable_PtrToSymbol pSym;
   13213              : 
   13214            0 :   pSym = GetPsym (sym);
   13215            0 :   switch (pSym->SymbolType)
   13216              :     {
   13217            0 :       case SymbolTable_ProcedureSym:
   13218            0 :         pSym->Procedure.ExceptionFinally = true;
   13219            0 :         break;
   13220              : 
   13221            0 :       case SymbolTable_ModuleSym:
   13222            0 :         pSym->Module.ExceptionFinally = true;
   13223            0 :         break;
   13224              : 
   13225            0 :       case SymbolTable_DefImpSym:
   13226            0 :         pSym->DefImp.ExceptionFinally = true;
   13227            0 :         break;
   13228              : 
   13229              : 
   13230            0 :       default:
   13231            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   13232            0 :         break;
   13233              :     }
   13234            0 : }
   13235              : 
   13236              : 
   13237              : /*
   13238              :    HasExceptionFinally - returns a BOOLEAN determining whether
   13239              :                          module/defimp, sym, has
   13240              :                          an EXCEPT statement sequence.
   13241              : */
   13242              : 
   13243        30622 : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym)
   13244              : {
   13245        30622 :   SymbolTable_PtrToSymbol pSym;
   13246              : 
   13247        30622 :   pSym = GetPsym (sym);
   13248        30622 :   switch (pSym->SymbolType)
   13249              :     {
   13250            0 :       case SymbolTable_ProcedureSym:
   13251            0 :         return pSym->Procedure.ExceptionFinally;
   13252        23596 :         break;
   13253              : 
   13254        23596 :       case SymbolTable_ModuleSym:
   13255        23596 :         return pSym->Module.ExceptionFinally;
   13256         7026 :         break;
   13257              : 
   13258         7026 :       case SymbolTable_DefImpSym:
   13259         7026 :         return pSym->DefImp.ExceptionFinally;
   13260            0 :         break;
   13261              : 
   13262              : 
   13263            0 :       default:
   13264            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   13265              :         break;
   13266              :     }
   13267              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13268              :   __builtin_unreachable ();
   13269              : }
   13270              : 
   13271              : 
   13272              : /*
   13273              :    PutVar - gives the VarSym symbol Sym a type Type.
   13274              : */
   13275              : 
   13276      1437882 : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType)
   13277              : {
   13278      1437882 :   SymbolTable_PtrToSymbol pSym;
   13279              : 
   13280      1437882 :   pSym = GetPsym (Sym);
   13281      1437882 :   switch (pSym->SymbolType)
   13282              :     {
   13283       564757 :       case SymbolTable_VarSym:
   13284       564757 :         pSym->Var.Type = VarType;
   13285       564757 :         M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), Sym);
   13286       564757 :         M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), Sym);
   13287       564757 :         break;
   13288              : 
   13289       873125 :       case SymbolTable_ConstVarSym:
   13290       873125 :         pSym->ConstVar.Type = VarType;
   13291       873125 :         break;
   13292              : 
   13293              : 
   13294            0 :       default:
   13295            0 :         M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
   13296      1437882 :         break;
   13297              :     }
   13298      1437882 : }
   13299              : 
   13300              : 
   13301              : /*
   13302              :    PutVarTok - gives the VarSym symbol Sym a type Type at typetok.
   13303              : */
   13304              : 
   13305     10483884 : extern "C" void SymbolTable_PutVarTok (unsigned int Sym, unsigned int VarType, unsigned int typetok)
   13306              : {
   13307     10483884 :   SymbolTable_PtrToSymbol pSym;
   13308              : 
   13309     10483884 :   pSym = GetPsym (Sym);
   13310     10483884 :   switch (pSym->SymbolType)
   13311              :     {
   13312     10483872 :       case SymbolTable_VarSym:
   13313     10483872 :         pSym->Var.Type = VarType;
   13314     10483872 :         pSym->Var.Declared.TypeTok = typetok;
   13315     10483872 :         M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), Sym);
   13316     10483872 :         M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), Sym);
   13317     10483872 :         break;
   13318              : 
   13319            0 :       case SymbolTable_ConstVarSym:
   13320            0 :         pSym->ConstVar.Type = VarType;
   13321            0 :         break;
   13322              : 
   13323              : 
   13324           12 :       default:
   13325           12 :         M2Error_InternalError ((const char *) "expecting VarSym or ConstVarSym", 31);
   13326     10483872 :         break;
   13327              :     }
   13328     10483872 : }
   13329              : 
   13330              : 
   13331              : /*
   13332              :    PutLeftValueFrontBackType - gives the variable symbol a front and backend type.
   13333              :                                The variable must be a LeftValue.
   13334              : */
   13335              : 
   13336        75540 : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType)
   13337              : {
   13338        75540 :   SymbolTable_PtrToSymbol pSym;
   13339              : 
   13340        75540 :   M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue);
   13341        75540 :   pSym = GetPsym (Sym);
   13342        75540 :   switch (pSym->SymbolType)
   13343              :     {
   13344        75540 :       case SymbolTable_VarSym:
   13345        75540 :         pSym->Var.Type = FrontType;
   13346        75540 :         pSym->Var.BackType = BackType;
   13347        75540 :         SymbolTable_PushSize (M2System_Address);
   13348        75540 :         M2ALU_PopInto (pSym->Var.Size);
   13349        75540 :         break;
   13350              : 
   13351              : 
   13352            0 :       default:
   13353            0 :         M2Error_InternalError ((const char *) "expecting VarSym", 16);
   13354        75540 :         break;
   13355              :     }
   13356        75540 : }
   13357              : 
   13358              : 
   13359              : /*
   13360              :    GetVarBackEndType - returns the back end type if specified.
   13361              : */
   13362              : 
   13363      1103931 : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym)
   13364              : {
   13365      1103931 :   SymbolTable_PtrToSymbol pSym;
   13366              : 
   13367      1103931 :   M2Debug_Assert (Sym != SymbolTable_NulSym);
   13368      1103931 :   pSym = GetPsym (Sym);
   13369      1103931 :   switch (pSym->SymbolType)
   13370              :     {
   13371      1103931 :       case SymbolTable_VarSym:
   13372      1103931 :         return pSym->Var.BackType;
   13373              :         break;
   13374              : 
   13375              : 
   13376              :       default:
   13377              :         return SymbolTable_NulSym;
   13378              :         break;
   13379              :     }
   13380              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   13381              :   __builtin_unreachable ();
   13382              : }
   13383              : 
   13384              : 
   13385              : /*
   13386              :    PutVarPointerCheck - marks variable, sym, as requiring (or not
   13387              :                         depending upon the, value), a NIL pointer check
   13388              :                         when this symbol is dereferenced.
   13389              : */
   13390              : 
   13391        39500 : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value)
   13392              : {
   13393        39500 :   SymbolTable_PtrToSymbol pSym;
   13394              : 
   13395        39500 :   if (SymbolTable_IsVar (sym))
   13396              :     {
   13397        39494 :       pSym = GetPsym (sym);
   13398        39494 :       pSym->Var.IsPointerCheck = value;
   13399              :     }
   13400        39500 : }
   13401              : 
   13402              : 
   13403              : /*
   13404              :    GetVarPointerCheck - returns TRUE if this symbol is a variable and
   13405              :                         has been marked as needing a pointer via NIL check.
   13406              : */
   13407              : 
   13408        79417 : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym)
   13409              : {
   13410        79417 :   SymbolTable_PtrToSymbol pSym;
   13411              : 
   13412        79417 :   if (SymbolTable_IsVar (sym))
   13413              :     {
   13414        79417 :       pSym = GetPsym (sym);
   13415        79417 :       return pSym->Var.IsPointerCheck;
   13416              :     }
   13417              :   return false;
   13418              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   13419              :   __builtin_unreachable ();
   13420              : }
   13421              : 
   13422              : 
   13423              : /*
   13424              :    PutVarWritten - marks variable, sym, as being written to (or not
   13425              :                    depending upon the, value).
   13426              : */
   13427              : 
   13428        12536 : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value)
   13429              : {
   13430        12536 :   SymbolTable_PtrToSymbol pSym;
   13431              : 
   13432        12536 :   if (SymbolTable_IsVar (sym))
   13433              :     {
   13434        12536 :       pSym = GetPsym (sym);
   13435        12536 :       pSym->Var.IsWritten = value;
   13436              :     }
   13437        12536 : }
   13438              : 
   13439              : 
   13440              : /*
   13441              :    GetVarWritten - returns TRUE if this symbol is a variable and
   13442              :                    has been marked as being written.
   13443              : */
   13444              : 
   13445        89275 : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym)
   13446              : {
   13447        89275 :   SymbolTable_PtrToSymbol pSym;
   13448              : 
   13449        89275 :   pSym = GetPsym (sym);
   13450        89275 :   switch (pSym->SymbolType)
   13451              :     {
   13452        89275 :       case SymbolTable_VarSym:
   13453        89275 :         return pSym->Var.IsWritten;
   13454            0 :         break;
   13455              : 
   13456              : 
   13457            0 :       default:
   13458            0 :         M2Error_InternalError ((const char *) "expecting VarSym", 16);
   13459              :         break;
   13460              :     }
   13461              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13462              :   __builtin_unreachable ();
   13463              : }
   13464              : 
   13465              : 
   13466              : /*
   13467              :    PutConst - gives the constant symbol Sym a type ConstType.
   13468              : */
   13469              : 
   13470       424338 : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType)
   13471              : {
   13472       424338 :   SymbolTable_PtrToSymbol pSym;
   13473              : 
   13474       424338 :   pSym = GetPsym (Sym);
   13475       424338 :   CheckBreak (Sym);
   13476       424338 :   switch (pSym->SymbolType)
   13477              :     {
   13478       424338 :       case SymbolTable_ConstVarSym:
   13479       424338 :         pSym->ConstVar.Type = ConstType;
   13480       424338 :         break;
   13481              : 
   13482              : 
   13483            0 :       default:
   13484            0 :         M2Error_InternalError ((const char *) "expecting ConstVarSym", 21);
   13485       424338 :         break;
   13486              :     }
   13487       424338 : }
   13488              : 
   13489              : 
   13490              : /*
   13491              :    PutConstSet - informs the const var symbol, sym, that it is or will contain
   13492              :                  a set value.
   13493              : */
   13494              : 
   13495        49322 : extern "C" void SymbolTable_PutConstSet (unsigned int Sym)
   13496              : {
   13497        49322 :   SymbolTable_PtrToSymbol pSym;
   13498              : 
   13499        49322 :   pSym = GetPsym (Sym);
   13500        49322 :   switch (pSym->SymbolType)
   13501              :     {
   13502        49322 :       case SymbolTable_ConstVarSym:
   13503        49322 :         pSym->ConstVar.IsSet = true;
   13504        49322 :         break;
   13505              : 
   13506            0 :       case SymbolTable_ConstLitSym:
   13507            0 :         pSym->ConstLit.IsSet = true;
   13508            0 :         break;
   13509              : 
   13510              : 
   13511            0 :       default:
   13512            0 :         M2Error_InternalError ((const char *) "expecting ConstVar symbol", 25);
   13513        49322 :         break;
   13514              :     }
   13515        49322 : }
   13516              : 
   13517              : 
   13518              : /*
   13519              :    IsConstSet - returns TRUE if the constant is declared as a set.
   13520              : */
   13521              : 
   13522     81554853 : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym)
   13523              : {
   13524     81554853 :   SymbolTable_PtrToSymbol pSym;
   13525              : 
   13526     81554853 :   pSym = GetPsym (Sym);
   13527     81554853 :   switch (pSym->SymbolType)
   13528              :     {
   13529     13894992 :       case SymbolTable_ConstVarSym:
   13530     13894992 :         return pSym->ConstVar.IsSet;
   13531     19897406 :         break;
   13532              : 
   13533     19897406 :       case SymbolTable_ConstLitSym:
   13534     19897406 :         return pSym->ConstLit.IsSet;
   13535              :         break;
   13536              : 
   13537              : 
   13538              :       default:
   13539              :         return false;
   13540              :         break;
   13541              :     }
   13542              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   13543              :   __builtin_unreachable ();
   13544              : }
   13545              : 
   13546              : 
   13547              : /*
   13548              :    PutConstructor - informs the const var symbol, sym, that it is or
   13549              :                     will contain a constructor (record, set or array)
   13550              :                     value.
   13551              : */
   13552              : 
   13553        41550 : extern "C" void SymbolTable_PutConstructor (unsigned int Sym)
   13554              : {
   13555        41550 :   SymbolTable_PtrToSymbol pSym;
   13556              : 
   13557        41550 :   pSym = GetPsym (Sym);
   13558        41550 :   switch (pSym->SymbolType)
   13559              :     {
   13560        41550 :       case SymbolTable_ConstVarSym:
   13561        41550 :         pSym->ConstVar.IsConstructor = true;
   13562        41550 :         break;
   13563              : 
   13564            0 :       case SymbolTable_ConstLitSym:
   13565            0 :         pSym->ConstLit.IsConstructor = true;
   13566            0 :         break;
   13567              : 
   13568              : 
   13569            0 :       default:
   13570            0 :         M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
   13571        41550 :         break;
   13572              :     }
   13573        41550 : }
   13574              : 
   13575              : 
   13576              : /*
   13577              :    PutConstructorFrom - sets the from type field in constructor,
   13578              :                         Sym, to, from.
   13579              : */
   13580              : 
   13581        36694 : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from)
   13582              : {
   13583        36694 :   SymbolTable_PtrToSymbol pSym;
   13584              : 
   13585        36694 :   pSym = GetPsym (Sym);
   13586        36694 :   switch (pSym->SymbolType)
   13587              :     {
   13588        36694 :       case SymbolTable_ConstVarSym:
   13589        36694 :         pSym->ConstVar.FromType = from;
   13590        36694 :         pSym->ConstVar.UnresFromType = true;
   13591        36694 :         break;
   13592              : 
   13593            0 :       case SymbolTable_ConstLitSym:
   13594            0 :         pSym->ConstLit.FromType = from;
   13595            0 :         pSym->ConstLit.UnresFromType = true;
   13596            0 :         break;
   13597              : 
   13598              : 
   13599            0 :       default:
   13600            0 :         M2Error_InternalError ((const char *) "expecting ConstVar or ConstLit symbol", 37);
   13601        36694 :         break;
   13602              :     }
   13603        36694 :   Lists_IncludeItemIntoList (UnresolvedConstructorType, Sym);
   13604        36694 : }
   13605              : 
   13606              : 
   13607              : /*
   13608              :    PutFieldRecord - places a field, FieldName and FieldType into a record, Sym.
   13609              :                     VarSym is a optional varient symbol which can be returned
   13610              :                     by a call to GetVarient(fieldsymbol).  The created field
   13611              :                     is returned.
   13612              : */
   13613              : 
   13614       406662 : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym)
   13615              : {
   13616       406662 :   SymbolTable_PtrToSymbol oSym;
   13617       406662 :   SymbolTable_PtrToSymbol pSym;
   13618       406662 :   unsigned int esym;
   13619       406662 :   unsigned int ParSym;
   13620       406662 :   unsigned int SonSym;
   13621              : 
   13622       406662 :   NewSym (&SonSym);  /* Cannot be used before declared since use occurs  */
   13623              :   /* ensure that it is connected its parent.  */
   13624       406662 :   pSym = GetPsym (Sym);
   13625       406662 :   switch (pSym->SymbolType)
   13626              :     {
   13627       400572 :       case SymbolTable_RecordSym:
   13628       400572 :         Lists_PutItemIntoList (pSym->Record.ListOfSons, SonSym);
   13629       400572 :         M2Debug_Assert (Lists_IsItemInList (pSym->Record.ListOfSons, SonSym));
   13630              :         /* Ensure that the Field is in the Parents Local Symbols  */
   13631       400572 :         if (FieldName != NameKey_NulName)
   13632              :           {
   13633              :             /* avoid gcc warning by using compound statement even if not strictly necessary.  */
   13634       400542 :             if ((SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName)) == SymbolKey_NulKey)
   13635              :               {
   13636       400542 :                 SymbolKey_PutSymKey (pSym->Record.LocalSymbols, FieldName, SonSym);
   13637              :               }
   13638              :             else
   13639              :               {
   13640            0 :                 esym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->Record.LocalSymbols, FieldName));
   13641            0 :                 M2MetaError_MetaErrors1 ((const char *) "field record {%1Dad} has already been declared", 46, (const char *) "field record duplicate", 22, esym);
   13642              :               }
   13643              :           }
   13644              :         CheckRecordConsistency (Sym);
   13645              :         break;
   13646              : 
   13647         6090 :       case SymbolTable_VarientFieldSym:
   13648         6090 :         Lists_PutItemIntoList (pSym->VarientField.ListOfSons, SonSym);
   13649         6090 :         ParSym = SymbolTable_GetRecord (pSym->VarientField.Parent);
   13650         6090 :         oSym = GetPsym (ParSym);
   13651         6090 :         M2Debug_Assert (oSym->SymbolType == SymbolTable_RecordSym);
   13652         6090 :         if (FieldName != NameKey_NulName)
   13653              :           {
   13654         6078 :             oSym = GetPsym (ParSym);
   13655         6078 :             SymbolKey_PutSymKey (oSym->Record.LocalSymbols, FieldName, SonSym);
   13656              :           }
   13657              :         break;
   13658              : 
   13659              : 
   13660            0 :       default:
   13661            0 :         M2Error_InternalError ((const char *) "expecting Record symbol", 23);
   13662       406662 :         break;
   13663              :     }
   13664              :   /* Fill in SonSym  */
   13665       406662 :   oSym = GetPsym (SonSym);
   13666       406662 :   oSym->SymbolType = SymbolTable_RecordFieldSym;
   13667       406662 :   oSym->RecordField.Type = FieldType;
   13668       406662 :   oSym->RecordField.name = FieldName;
   13669       406662 :   oSym->RecordField.Tag = false;
   13670       406662 :   oSym->RecordField.Parent = Sym;
   13671       406662 :   oSym->RecordField.Varient = VarSym;
   13672       406662 :   oSym->RecordField.Align = SymbolTable_NulSym;
   13673       406662 :   oSym->RecordField.Used = true;
   13674       406662 :   oSym->RecordField.DeclPacked = false;  /* not known as packed (yet).  */
   13675       406662 :   oSym->RecordField.DeclResolved = false;  /* not known as packed (yet).  */
   13676       406662 :   oSym->RecordField.Scope = SymbolTable_GetScope (Sym);
   13677       406662 :   oSym->RecordField.Size = M2ALU_InitValue ();
   13678       406662 :   oSym->RecordField.Offset = M2ALU_InitValue ();
   13679       406662 :   InitWhereDeclared (&oSym->RecordField.At);
   13680       406662 :   return SonSym;
   13681              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   13682              :   __builtin_unreachable ();
   13683              : }
   13684              : 
   13685              : 
   13686              : /*
   13687              :    PutFieldVarient - places the field varient, Field, as a brother to, the
   13688              :                      varient symbol, sym, and also tells Field that its varient
   13689              :                      parent is Sym.
   13690              : */
   13691              : 
   13692        12084 : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym)
   13693              : {
   13694        12084 :   SymbolTable_PtrToSymbol pSym;
   13695              : 
   13696        12084 :   M2Debug_Assert (SymbolTable_IsVarient (Sym));
   13697        12084 :   M2Debug_Assert (SymbolTable_IsFieldVarient (Field));
   13698        12084 :   pSym = GetPsym (Sym);
   13699        12084 :   switch (pSym->SymbolType)
   13700              :     {
   13701        12084 :       case SymbolTable_VarientSym:
   13702        12084 :         Lists_IncludeItemIntoList (pSym->Varient.ListOfSons, Field);
   13703        12084 :         break;
   13704              : 
   13705              : 
   13706            0 :       default:
   13707            0 :         M2Error_InternalError ((const char *) "expecting Varient symbol", 24);
   13708        12084 :         break;
   13709              :     }
   13710        12084 :   pSym = GetPsym (Field);
   13711        12084 :   switch (pSym->SymbolType)
   13712              :     {
   13713        12084 :       case SymbolTable_VarientFieldSym:
   13714        12084 :         pSym->VarientField.Varient = Sym;
   13715        12084 :         break;
   13716              : 
   13717              : 
   13718            0 :       default:
   13719            0 :         M2Error_InternalError ((const char *) "expecting VarientField symbol", 29);
   13720        12084 :         break;
   13721              :     }
   13722        12084 : }
   13723              : 
   13724              : 
   13725              : /*
   13726              :    GetVarient - returns the varient symbol associated with the
   13727              :                 record or varient field symbol, Field.
   13728              : */
   13729              : 
   13730    233041362 : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field)
   13731              : {
   13732    233041362 :   SymbolTable_PtrToSymbol pSym;
   13733              : 
   13734    233041362 :   pSym = GetPsym (Field);
   13735    233041362 :   switch (pSym->SymbolType)
   13736              :     {
   13737            0 :       case SymbolTable_VarientFieldSym:
   13738            0 :         return pSym->VarientField.Varient;
   13739    232507298 :         break;
   13740              : 
   13741    232507298 :       case SymbolTable_RecordFieldSym:
   13742    232507298 :         return pSym->RecordField.Varient;
   13743       534064 :         break;
   13744              : 
   13745       534064 :       case SymbolTable_VarientSym:
   13746       534064 :         return pSym->Varient.Varient;
   13747              :         break;
   13748              : 
   13749              : 
   13750              :       default:
   13751              :         return SymbolTable_NulSym;
   13752              :         break;
   13753              :     }
   13754              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   13755              :   __builtin_unreachable ();
   13756              : }
   13757              : 
   13758              : 
   13759              : /*
   13760              :    IsRecordFieldAVarientTag - returns TRUE if record field, sym, is
   13761              :                               a varient tag.
   13762              : */
   13763              : 
   13764      3383066 : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym)
   13765              : {
   13766      3383066 :   SymbolTable_PtrToSymbol pSym;
   13767              : 
   13768      3383066 :   if (SymbolTable_IsRecordField (sym))
   13769              :     {
   13770      3383066 :       pSym = GetPsym (sym);
   13771      3383066 :       return pSym->RecordField.Tag;
   13772              :     }
   13773              :   else
   13774              :     {
   13775            0 :       M2Error_InternalError ((const char *) "record field symbol expected", 28);
   13776              :     }
   13777              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13778              :   __builtin_unreachable ();
   13779              : }
   13780              : 
   13781              : 
   13782              : /*
   13783              :    IsEmptyFieldVarient - returns TRUE if the field variant has
   13784              :                          no fields.  This will occur then the
   13785              :                          compiler constructs 'else end' variants.
   13786              : */
   13787              : 
   13788            0 : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym)
   13789              : {
   13790            0 :   SymbolTable_PtrToSymbol pSym;
   13791              : 
   13792            0 :   pSym = GetPsym (sym);
   13793            0 :   switch (pSym->SymbolType)
   13794              :     {
   13795            0 :       case SymbolTable_VarientFieldSym:
   13796            0 :         return (Lists_NoOfItemsInList (pSym->VarientField.ListOfSons)) == 0;
   13797            0 :         break;
   13798              : 
   13799              : 
   13800            0 :       default:
   13801            0 :         M2Error_InternalError ((const char *) "varient field symbol expected", 29);
   13802              :         break;
   13803              :     }
   13804              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13805              :   __builtin_unreachable ();
   13806              : }
   13807              : 
   13808              : 
   13809              : /*
   13810              :    GetVarientTag - returns the varient tag from, Sym.
   13811              : */
   13812              : 
   13813        12750 : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym)
   13814              : {
   13815        12750 :   SymbolTable_PtrToSymbol pSym;
   13816              : 
   13817        12750 :   pSym = GetPsym (Sym);
   13818        12750 :   switch (pSym->SymbolType)
   13819              :     {
   13820        12750 :       case SymbolTable_VarientSym:
   13821        12750 :         return pSym->Varient.tag;
   13822            0 :         break;
   13823              : 
   13824              : 
   13825            0 :       default:
   13826            0 :         M2Error_InternalError ((const char *) "varient symbol expected", 23);
   13827              :         break;
   13828              :     }
   13829              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   13830              :   __builtin_unreachable ();
   13831              : }
   13832              : 
   13833              : 
   13834              : /*
   13835              :    PutVarientTag - places, Tag, into varient, Sym.
   13836              : */
   13837              : 
   13838         2988 : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag)
   13839              : {
   13840         2988 :   SymbolTable_PtrToSymbol pSym;
   13841         2988 :   unsigned int parent;
   13842              : 
   13843         2988 :   pSym = GetPsym (Sym);
   13844         2988 :   switch (pSym->SymbolType)
   13845              :     {
   13846         2988 :       case SymbolTable_VarientSym:
   13847         2988 :         pSym->Varient.tag = Tag;
   13848         2988 :         break;
   13849              : 
   13850              : 
   13851            0 :       default:
   13852            0 :         M2Error_InternalError ((const char *) "varient symbol expected", 23);
   13853         2988 :         break;
   13854              :     }
   13855              :   /* now ensure that if Tag is a RecordField then it must be
   13856              :       placed before the varient symbol in its parent ListOfSons.
   13857              :       This allows M2GCCDeclare to declare record fields in order
   13858              :       and preserve the order of fields.  Otherwise it will add the
   13859              :       tag field after the C union.  */
   13860         2988 :   if (SymbolTable_IsRecordField (Tag))
   13861              :     {
   13862         2976 :       pSym = GetPsym (Tag);
   13863         2976 :       pSym->RecordField.Tag = true;
   13864         2976 :       parent = SymbolTable_GetParent (Sym);
   13865         2976 :       pSym = GetPsym (parent);
   13866         2976 :       switch (pSym->SymbolType)
   13867              :         {
   13868              :           case SymbolTable_ErrorSym:
   13869              :             break;
   13870              : 
   13871            0 :           case SymbolTable_VarientSym:
   13872            0 :             EnsureOrder (pSym->Varient.ListOfSons, Tag, Sym);
   13873            0 :             break;
   13874              : 
   13875           36 :           case SymbolTable_VarientFieldSym:
   13876           36 :             EnsureOrder (pSym->VarientField.ListOfSons, Tag, Sym);
   13877           36 :             break;
   13878              : 
   13879         2940 :           case SymbolTable_RecordSym:
   13880         2940 :             EnsureOrder (pSym->Record.ListOfSons, Tag, Sym);
   13881         2940 :             CheckRecordConsistency (parent);
   13882         2940 :             break;
   13883              : 
   13884              : 
   13885            0 :           default:
   13886            0 :             M2Error_InternalError ((const char *) "not expecting this symbol type", 30);
   13887              :             break;
   13888              :         }
   13889              :     }
   13890         2988 : }
   13891              : 
   13892              : 
   13893              : /*
   13894              :    PutFieldEnumeration - places a field into the enumeration type
   13895              :                          Sym. The field has a name FieldName and a
   13896              :                          value FieldVal.
   13897              : */
   13898              : 
   13899       493431 : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName)
   13900              : {
   13901       493431 :   SymbolTable_PtrToSymbol oSym;
   13902       493431 :   SymbolTable_PtrToSymbol pSym;
   13903       493431 :   DynamicStrings_String s;
   13904       493431 :   unsigned int Field;
   13905              : 
   13906       493431 :   Field = CheckForHiddenType (FieldName);
   13907       493431 :   if (Field == SymbolTable_NulSym)
   13908              :     {
   13909       493431 :       Field = DeclareSym (tok, FieldName);
   13910              :     }
   13911       493431 :   if (! (SymbolTable_IsError (Field)))
   13912              :     {
   13913       493425 :       pSym = GetPsym (Field);
   13914       493425 :       pSym->SymbolType = SymbolTable_EnumerationFieldSym;
   13915       493425 :       pSym->EnumerationField.name = FieldName;  /* Index into name array, name  */
   13916              :       /* of type.  */
   13917       493425 :       oSym = GetPsym (Sym);
   13918       493425 :       M2ALU_PushCard (oSym->Enumeration.NoOfElements);
   13919       493425 :       pSym->EnumerationField.Value = M2ALU_InitValue ();
   13920       493425 :       M2ALU_PopInto (pSym->EnumerationField.Value);
   13921       493425 :       pSym->EnumerationField.Type = Sym;
   13922       493425 :       pSym->EnumerationField.Scope = SymbolTable_GetCurrentScope ();
   13923       493425 :       InitWhereDeclaredTok (tok, &pSym->EnumerationField.At);  /* Declared here  */
   13924       493425 :       pSym = GetPsym (Sym);
   13925       493425 :       switch (pSym->SymbolType)
   13926              :         {
   13927       493425 :           case SymbolTable_EnumerationSym:
   13928       493425 :             pSym->Enumeration.NoOfElements += 1;
   13929       493425 :             if ((SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, FieldName)) != SymbolTable_NulSym)
   13930              :               {
   13931            0 :                 s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (FieldName)));
   13932            0 :                 AlreadyDeclaredError (FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "enumeration field (%s) is already declared elsewhere, use a different name or remove the declaration", 100)), (const unsigned char *) &s, (sizeof (s)-1)), FieldName, SymbolTable_GetDeclaredMod (SymbolKey_GetSymKey (pSym->Enumeration.LocalSymbols, FieldName)));
   13933              :               }
   13934              :             else
   13935              :               {
   13936       493425 :                 SymbolKey_PutSymKey (pSym->Enumeration.LocalSymbols, FieldName, Field);
   13937       493425 :                 Lists_IncludeItemIntoList (pSym->Enumeration.ListOfFields, Field);
   13938              :               }
   13939              :             break;
   13940              : 
   13941              : 
   13942            0 :           default:
   13943            0 :             M2Error_InternalError ((const char *) "expecting Sym=Enumeration", 25);
   13944              :             break;
   13945              :         }
   13946              :     }
   13947       493431 : }
   13948              : 
   13949              : 
   13950              : /*
   13951              :    PutSubrange - places LowSym and HighSym as two symbols
   13952              :                  which provide the limits of the range.
   13953              : */
   13954              : 
   13955       326454 : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol)
   13956              : {
   13957       326454 :   SymbolTable_PtrToSymbol pSym;
   13958              : 
   13959       326454 :   pSym = GetPsym (Sym);
   13960       326454 :   switch (pSym->SymbolType)
   13961              :     {
   13962       326454 :       case SymbolTable_SubrangeSym:
   13963       326454 :         pSym->Subrange.Low = LowSym;  /* Index to symbol for lower  */
   13964       326454 :         pSym->Subrange.High = HighSym;  /* Index to symbol for higher  */
   13965       326454 :         pSym->Subrange.Type = TypeSymbol;  /* Index to type symbol for  */
   13966       326454 :         break;
   13967              : 
   13968              : 
   13969            0 :       default:
   13970              :         /* the type of subrange.  */
   13971            0 :         M2Error_InternalError ((const char *) "expecting Subrange symbol", 25);
   13972       326454 :         break;
   13973              :     }
   13974       326454 : }
   13975              : 
   13976              : 
   13977              : /*
   13978              :    PutSet - places SimpleType as the type for set, Sym.
   13979              : */
   13980              : 
   13981        64550 : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed)
   13982              : {
   13983        64550 :   SymbolTable_PtrToSymbol pSym;
   13984              : 
   13985        64550 :   pSym = GetPsym (Sym);
   13986        64550 :   switch (pSym->SymbolType)
   13987              :     {
   13988              :       case SymbolTable_ErrorSym:
   13989              :         break;
   13990              : 
   13991        64550 :       case SymbolTable_SetSym:
   13992        64550 :         pSym->Set.Type = SimpleType;  /* Index to a subrange symbol  */
   13993              :         /* or an enumeration type.  */
   13994        64550 :         pSym->Set.ispacked = packed;
   13995        64550 :         break;
   13996              : 
   13997              : 
   13998            0 :       default:
   13999            0 :         M2Error_InternalError ((const char *) "expecting a Set symbol", 22);
   14000        64550 :         break;
   14001              :     }
   14002        64550 : }
   14003              : 
   14004              : 
   14005              : /*
   14006              :    IsSetPacked - returns TRUE if Sym is packed.
   14007              : */
   14008              : 
   14009            0 : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym)
   14010              : {
   14011            0 :   SymbolTable_PtrToSymbol pSym;
   14012              : 
   14013            0 :   AssertInRange (Sym);
   14014            0 :   pSym = GetPsym (Sym);
   14015            0 :   return (pSym->SymbolType == SymbolTable_SetSym) && pSym->Set.ispacked;
   14016              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   14017              :   __builtin_unreachable ();
   14018              : }
   14019              : 
   14020              : 
   14021              : /*
   14022              :    GetArraySubscript - returns the subscript symbol for array, Sym.
   14023              : */
   14024              : 
   14025      6200098 : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym)
   14026              : {
   14027      6200098 :   SymbolTable_PtrToSymbol pSym;
   14028              : 
   14029      6200098 :   pSym = GetPsym (Sym);
   14030      6200098 :   switch (pSym->SymbolType)
   14031              :     {
   14032              :       case SymbolTable_ErrorSym:
   14033              :         return SymbolTable_NulSym;
   14034      6200098 :         break;
   14035              : 
   14036      6200098 :       case SymbolTable_ArraySym:
   14037      6200098 :         return pSym->Array.Subscript;
   14038            0 :         break;
   14039              : 
   14040              : 
   14041            0 :       default:
   14042            0 :         M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
   14043              :         break;
   14044              :     }
   14045              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   14046              :   __builtin_unreachable ();
   14047              : }
   14048              : 
   14049              : 
   14050              : /*
   14051              :    PutArraySubscript - places an index field into the array Sym. The
   14052              :                        index field is a subscript sym.
   14053              : */
   14054              : 
   14055       163230 : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol)
   14056              : {
   14057       163230 :   SymbolTable_PtrToSymbol pSym;
   14058              : 
   14059       163230 :   pSym = GetPsym (Sym);
   14060       163230 :   switch (pSym->SymbolType)
   14061              :     {
   14062              :       case SymbolTable_ErrorSym:
   14063              :         break;
   14064              : 
   14065       163230 :       case SymbolTable_ArraySym:
   14066       163230 :         pSym->Array.Subscript = SubscriptSymbol;
   14067       163230 :         break;
   14068              : 
   14069              : 
   14070            0 :       default:
   14071            0 :         M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
   14072       163230 :         break;
   14073              :     }
   14074       163230 : }
   14075              : 
   14076              : 
   14077              : /*
   14078              :    PutType - gives a type symbol Sym type TypeSymbol.
   14079              : */
   14080              : 
   14081       605262 : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol)
   14082              : {
   14083       605262 :   SymbolTable_PtrToSymbol pSym;
   14084              : 
   14085       605262 :   if (TypeSymbol == Sym)
   14086              :     {
   14087            0 :       M2Error_InternalError ((const char *) "not expecting a type to be declared as itself", 45);
   14088              :     }
   14089       605262 :   pSym = GetPsym (Sym);
   14090       605262 :   switch (pSym->SymbolType)
   14091              :     {
   14092              :       case SymbolTable_ErrorSym:
   14093              :         break;
   14094              : 
   14095       605262 :       case SymbolTable_TypeSym:
   14096       605262 :         pSym->Type.Type = TypeSymbol;
   14097       605262 :         break;
   14098              : 
   14099              : 
   14100            0 :       default:
   14101            0 :         M2Error_InternalError ((const char *) "expecting a Type symbol", 23);
   14102       605262 :         break;
   14103              :     }
   14104       605262 : }
   14105              : 
   14106              : 
   14107              : /*
   14108              :    PutFunction - Places a TypeSym as the return type to a procedure Sym.
   14109              : */
   14110              : 
   14111      8290521 : extern "C" void SymbolTable_PutFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym)
   14112              : {
   14113     16573160 :   SymbolTable_PtrToSymbol pSym;
   14114              : 
   14115     16573160 :   pSym = GetPsym (Sym);
   14116     16573160 :   switch (pSym->SymbolType)
   14117              :     {
   14118              :       case SymbolTable_ErrorSym:
   14119              :         break;
   14120              : 
   14121      8282639 :       case SymbolTable_ProcedureSym:
   14122      8282639 :         pSym->Procedure.ReturnType = TypeSym;
   14123      8282639 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
   14124      8282639 :         SymbolTable_PutFunction (tok, pSym->Procedure.ProcedureType, kind, TypeSym);
   14125      8282639 :         break;
   14126              : 
   14127      8290521 :       case SymbolTable_ProcTypeSym:
   14128      8290521 :         pSym->ProcType.ReturnType = TypeSym;
   14129      8290521 :         pSym->ProcType.ReturnTypeTok = tok;
   14130      8290521 :         break;
   14131              : 
   14132              : 
   14133            0 :       default:
   14134            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   14135      8290521 :         break;
   14136              :     }
   14137      8290521 : }
   14138              : 
   14139              : 
   14140              : /*
   14141              :    PutOptFunction - places a TypeSym as the optional return type to a procedure Sym.
   14142              : */
   14143              : 
   14144       133810 : extern "C" void SymbolTable_PutOptFunction (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int TypeSym)
   14145              : {
   14146       267620 :   SymbolTable_PtrToSymbol pSym;
   14147              : 
   14148       267620 :   pSym = GetPsym (Sym);
   14149       267620 :   switch (pSym->SymbolType)
   14150              :     {
   14151              :       case SymbolTable_ErrorSym:
   14152              :         break;
   14153              : 
   14154       133810 :       case SymbolTable_ProcedureSym:
   14155       133810 :         pSym->Procedure.ReturnType = TypeSym;
   14156       133810 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional = true;
   14157       133810 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
   14158       133810 :         SymbolTable_PutOptFunction (tok, pSym->Procedure.ProcedureType, kind, TypeSym);
   14159       133810 :         break;
   14160              : 
   14161       133810 :       case SymbolTable_ProcTypeSym:
   14162       133810 :         pSym->ProcType.ReturnType = TypeSym;
   14163       133810 :         pSym->ProcType.ReturnTypeTok = tok;
   14164       133810 :         break;
   14165              : 
   14166              : 
   14167            0 :       default:
   14168            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   14169       133810 :         break;
   14170              :     }
   14171       133810 : }
   14172              : 
   14173              : 
   14174              : /*
   14175              :    IsReturnOptional - returns TRUE if the return value for, sym, is
   14176              :                       optional.
   14177              : */
   14178              : 
   14179      1716445 : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind)
   14180              : {
   14181      1716445 :   SymbolTable_PtrToSymbol pSym;
   14182              : 
   14183      1716445 :   pSym = GetPsym (sym);
   14184      1716445 :   switch (pSym->SymbolType)
   14185              :     {
   14186      1684989 :       case SymbolTable_ProcedureSym:
   14187      1684989 :         return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional;
   14188        31456 :         break;
   14189              : 
   14190        31456 :       case SymbolTable_ProcTypeSym:
   14191        31456 :         return pSym->ProcType.ReturnOptional;
   14192            0 :         break;
   14193              : 
   14194              : 
   14195            0 :       default:
   14196            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   14197              :         break;
   14198              :     }
   14199              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   14200              :   __builtin_unreachable ();
   14201              : }
   14202              : 
   14203              : 
   14204              : /*
   14205              :    IsReturnOptionalAny - returns TRUE if the return value for sym is
   14206              :                          optional.
   14207              : */
   14208              : 
   14209         8941 : extern "C" bool SymbolTable_IsReturnOptionalAny (unsigned int sym)
   14210              : {
   14211         8941 :   SymbolTable_PtrToSymbol pSym;
   14212              : 
   14213         8941 :   pSym = GetPsym (sym);
   14214         8941 :   switch (pSym->SymbolType)
   14215              :     {
   14216         8941 :       case SymbolTable_ProcedureSym:
   14217         8941 :         return IsProcedureAnyBoolean (sym, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_IsReturnOptional});
   14218            0 :         break;
   14219              : 
   14220            0 :       case SymbolTable_ProcTypeSym:
   14221            0 :         return pSym->ProcType.ReturnOptional;
   14222            0 :         break;
   14223              : 
   14224              : 
   14225            0 :       default:
   14226            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   14227              :         break;
   14228              :     }
   14229              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   14230              :   __builtin_unreachable ();
   14231              : }
   14232              : 
   14233              : 
   14234              : /*
   14235              :    PutParam - Places a Non VAR parameter ParamName with type ParamType into
   14236              :               procedure Sym:kind.  The parameter number is ParamNo.
   14237              :               If the procedure Sym already has this parameter then
   14238              :               the parameter is checked for consistancy and the
   14239              :               consistancy test is returned.
   14240              : */
   14241              : 
   14242     10230926 : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok)
   14243              : {
   14244     10230926 :   SymbolTable_PtrToSymbol pSym;
   14245     10230926 :   unsigned int ParSym;
   14246     10230926 :   unsigned int VariableSym;
   14247              : 
   14248     10230926 :   if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
   14249              :     {
   14250              :       /* ParamNo <= NoOfParamAny (Sym)  */
   14251            0 :       M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
   14252              :     }
   14253              :   else
   14254              :     {
   14255              :       /* Add a new parameter  */
   14256     10230926 :       NewSym (&ParSym);
   14257     10230926 :       pSym = GetPsym (ParSym);
   14258     10230926 :       pSym->SymbolType = SymbolTable_ParamSym;
   14259     10230926 :       pSym->Param.name = ParamName;
   14260     10230926 :       pSym->Param.Type = ParamType;
   14261     10230926 :       pSym->Param.IsUnbounded = isUnbounded;
   14262     10230926 :       pSym->Param.Scope = Sym;
   14263     10230926 :       pSym->Param.ShadowVar = SymbolTable_NulSym;
   14264     10230926 :       pSym->Param.FullTok = M2LexBuf_MakeVirtual2Tok (tok, typetok);
   14265     10230926 :       pSym->Param.At = tok;
   14266     10230926 :       AddParameter (Sym, kind, ParSym);
   14267              :       /* Only declare a parameter as a local variable if it has not been done before.
   14268              :          It might be declared during the definition module, forward declaration or
   14269              :          proper procedure.  Name mismatches are checked in P2SymBuild.mod.  */
   14270     10230926 :       if ((ParamName != NameKey_NulName) && ((SymbolTable_GetNth (Sym, ParamNo)) == SymbolTable_NulSym))
   14271              :         {
   14272      8043700 :           VariableSym = MakeVariableForParam (tok, ParamName, Sym, kind, ParamNo, ParamType, typetok);
   14273      8043700 :           if (VariableSym == SymbolTable_NulSym)
   14274              :             {
   14275              :               return false;
   14276              :             }
   14277              :           else
   14278              :             {
   14279      8043700 :               pSym = GetPsym (ParSym);
   14280      8043700 :               pSym->Param.ShadowVar = VariableSym;
   14281              :             }
   14282              :         }
   14283     10230926 :       AddProcedureProcTypeParam (tok, Sym, ParamType, isUnbounded, false);
   14284              :     }
   14285     10230926 :   return true;
   14286              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   14287              :   __builtin_unreachable ();
   14288              : }
   14289              : 
   14290              : 
   14291              : /*
   14292              :    PutVarParam - Places a Non VAR parameter ParamName with type
   14293              :                  ParamType into procedure Sym:kind.
   14294              :                  The parameter number is ParamNo.
   14295              :                  If the procedure Sym already has this parameter then
   14296              :                  the parameter is checked for consistancy and the
   14297              :                  consistancy test is returned.
   14298              : */
   14299              : 
   14300       955222 : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded, unsigned int typetok)
   14301              : {
   14302       955222 :   SymbolTable_PtrToSymbol pSym;
   14303       955222 :   unsigned int ParSym;
   14304       955222 :   unsigned int VariableSym;
   14305              : 
   14306       955222 :   if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
   14307              :     {
   14308            0 :       M2Error_InternalError ((const char *) "why are we trying to put parameters again", 41);
   14309              :     }
   14310              :   else
   14311              :     {
   14312              :       /* Add a new parameter  */
   14313       955222 :       NewSym (&ParSym);
   14314       955222 :       pSym = GetPsym (ParSym);
   14315       955222 :       pSym->SymbolType = SymbolTable_VarParamSym;
   14316       955222 :       pSym->VarParam.name = ParamName;
   14317       955222 :       pSym->VarParam.Type = ParamType;
   14318       955222 :       pSym->VarParam.IsUnbounded = isUnbounded;
   14319       955222 :       pSym->VarParam.Scope = Sym;
   14320       955222 :       pSym->VarParam.ShadowVar = SymbolTable_NulSym;
   14321       955222 :       pSym->VarParam.HeapVar = SymbolTable_NulSym;  /* Will contain a pointer value.  */
   14322       955222 :       pSym->VarParam.FullTok = M2LexBuf_MakeVirtual2Tok (tok, typetok);  /* Will contain a pointer value.  */
   14323       955222 :       pSym->VarParam.At = tok;
   14324       955222 :       AddParameter (Sym, kind, ParSym);
   14325              :       /* Only declare a parameter as a local variable if it has not been done before.
   14326              :          It might be declared during the definition module, forward declaration or
   14327              :          proper procedure.  Name mismatches are checked in P2SymBuild.mod.  */
   14328       955222 :       if ((ParamName != NameKey_NulName) && ((SymbolTable_GetNth (Sym, ParamNo)) == SymbolTable_NulSym))
   14329              :         {
   14330       745246 :           VariableSym = MakeVariableForParam (tok, ParamName, Sym, kind, ParamNo, ParamType, typetok);
   14331       745246 :           if (VariableSym == SymbolTable_NulSym)
   14332              :             {
   14333              :               return false;
   14334              :             }
   14335              :           else
   14336              :             {
   14337       745246 :               pSym = GetPsym (ParSym);
   14338       745246 :               pSym->VarParam.ShadowVar = VariableSym;
   14339              :             }
   14340              :         }
   14341       955222 :       AddProcedureProcTypeParam (tok, Sym, ParamType, isUnbounded, true);
   14342              :     }
   14343       955222 :   return true;
   14344              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   14345              :   __builtin_unreachable ();
   14346              : }
   14347              : 
   14348              : 
   14349              : /*
   14350              :    PutParamName - assigns a name to paramater no of procedure ProcSym:kind.
   14351              : */
   14352              : 
   14353            0 : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, SymbolTable_ProcedureKind kind, unsigned int no, NameKey_Name name, unsigned int ParamType, unsigned int typetok)
   14354              : {
   14355            0 :   SymbolTable_PtrToSymbol pSym;
   14356            0 :   unsigned int ParSym;
   14357              : 
   14358            0 :   pSym = GetPsym (ProcSym);
   14359            0 :   ParSym = SymbolTable_NulSym;
   14360            0 :   switch (pSym->SymbolType)
   14361              :     {
   14362              :       case SymbolTable_ErrorSym:
   14363              :         return;
   14364            0 :         break;
   14365              : 
   14366            0 :       case SymbolTable_ProcedureSym:
   14367            0 :         ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, no));
   14368            0 :         break;
   14369              : 
   14370            0 :       case SymbolTable_ProcTypeSym:
   14371            0 :         ParSym = static_cast<unsigned int> (Lists_GetItemFromList (pSym->ProcType.ListOfParam, no));
   14372            0 :         break;
   14373              : 
   14374              : 
   14375            0 :       default:
   14376            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   14377            0 :         break;
   14378              :     }
   14379            0 :   pSym = GetPsym (ParSym);
   14380            0 :   switch (pSym->SymbolType)
   14381              :     {
   14382            0 :       case SymbolTable_ParamSym:
   14383            0 :         if (pSym->Param.name == NameKey_NulName)
   14384              :           {
   14385            0 :             pSym->Param.name = name;
   14386            0 :             pSym->Param.ShadowVar = MakeVariableForParam (tok, name, ProcSym, kind, no, ParamType, typetok);
   14387              :           }
   14388              :         else
   14389              :           {
   14390            0 :             M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
   14391              :           }
   14392            0 :         break;
   14393              : 
   14394            0 :       case SymbolTable_VarParamSym:
   14395            0 :         if (pSym->VarParam.name == NameKey_NulName)
   14396              :           {
   14397            0 :             pSym->VarParam.name = name;
   14398            0 :             pSym->VarParam.ShadowVar = MakeVariableForParam (tok, name, ProcSym, kind, no, ParamType, typetok);
   14399              :           }
   14400              :         else
   14401              :           {
   14402            0 :             M2Error_InternalError ((const char *) "name of parameter has already been assigned", 43);
   14403              :           }
   14404            0 :         break;
   14405              : 
   14406              : 
   14407            0 :       default:
   14408            0 :         M2Error_InternalError ((const char *) "expecting a VarParam or Param symbol", 36);
   14409            0 :         break;
   14410              :     }
   14411              : }
   14412              : 
   14413              : 
   14414              : /*
   14415              :    PutProcedureReachable - Sets the procedure, Sym, to be reachable by the
   14416              :                            main Module.
   14417              : */
   14418              : 
   14419        69201 : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym)
   14420              : {
   14421        69201 :   SymbolTable_PtrToSymbol pSym;
   14422              : 
   14423        69201 :   pSym = GetPsym (Sym);
   14424        69201 :   switch (pSym->SymbolType)
   14425              :     {
   14426              :       case SymbolTable_ErrorSym:
   14427              :         break;
   14428              : 
   14429        69201 :       case SymbolTable_ProcedureSym:
   14430        69201 :         pSym->Procedure.Reachable = true;
   14431        69201 :         break;
   14432              : 
   14433              : 
   14434            0 :       default:
   14435            0 :         M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
   14436        69201 :         break;
   14437              :     }
   14438        69201 : }
   14439              : 
   14440              : 
   14441              : /*
   14442              :    IsProcedureReachable - Returns true if the procedure, Sym, is
   14443              :                           reachable from the main Module.
   14444              : */
   14445              : 
   14446       238385 : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym)
   14447              : {
   14448       238385 :   SymbolTable_PtrToSymbol pSym;
   14449              : 
   14450       238385 :   pSym = GetPsym (Sym);
   14451       238385 :   switch (pSym->SymbolType)
   14452              :     {
   14453       238385 :       case SymbolTable_ProcedureSym:
   14454       238385 :         return pSym->Procedure.Reachable;
   14455            0 :         break;
   14456              : 
   14457              : 
   14458            0 :       default:
   14459            0 :         M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
   14460              :         break;
   14461              :     }
   14462              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   14463              :   __builtin_unreachable ();
   14464              : }
   14465              : 
   14466              : 
   14467              : /*
   14468              :    PutProcedureNoReturn - places value into the no return attribute
   14469              :                           field of procedure sym.
   14470              : */
   14471              : 
   14472       483828 : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind, bool value)
   14473              : {
   14474       483828 :   SymbolTable_PtrToSymbol pSym;
   14475              : 
   14476       483828 :   pSym = GetPsym (Sym);
   14477       483828 :   switch (pSym->SymbolType)
   14478              :     {
   14479       483828 :       case SymbolTable_ProcedureSym:
   14480       483828 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].IsNoReturn = value;
   14481       483828 :         break;
   14482              : 
   14483              : 
   14484            0 :       default:
   14485            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   14486       483828 :         break;
   14487              :     }
   14488       483828 : }
   14489              : 
   14490              : 
   14491              : /*
   14492              :    IsProcedureNoReturn - returns TRUE if this procedure never returns.
   14493              : */
   14494              : 
   14495      3271498 : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym, SymbolTable_ProcedureKind kind)
   14496              : {
   14497      3271498 :   SymbolTable_PtrToSymbol pSym;
   14498              : 
   14499      3271498 :   pSym = GetPsym (Sym);
   14500      3271498 :   switch (pSym->SymbolType)
   14501              :     {
   14502      3271498 :       case SymbolTable_ProcedureSym:
   14503      3271498 :         return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].IsNoReturn;
   14504            0 :         break;
   14505              : 
   14506              : 
   14507            0 :       default:
   14508            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   14509              :         break;
   14510              :     }
   14511              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   14512              :   __builtin_unreachable ();
   14513              : }
   14514              : 
   14515              : 
   14516              : /*
   14517              :    GetProcedureProcType - returns the proctype matching procedure sym.
   14518              : */
   14519              : 
   14520       760462 : extern "C" unsigned int SymbolTable_GetProcedureProcType (unsigned int sym)
   14521              : {
   14522       760462 :   SymbolTable_PtrToSymbol pSym;
   14523              : 
   14524       760462 :   pSym = GetPsym (sym);
   14525       760462 :   switch (pSym->SymbolType)
   14526              :     {
   14527       760462 :       case SymbolTable_ProcedureSym:
   14528       760462 :         return pSym->Procedure.ProcedureType;
   14529            0 :         break;
   14530              : 
   14531              : 
   14532            0 :       default:
   14533            0 :         M2Error_InternalError ((const char *) "expecting Procedure symbol", 26);
   14534              :         break;
   14535              :     }
   14536              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   14537              :   __builtin_unreachable ();
   14538              : }
   14539              : 
   14540              : 
   14541              : /*
   14542              :    PutModuleStartQuad - Places QuadNumber into the Module symbol, Sym.
   14543              :                         QuadNumber is the start quad of Module,
   14544              :                         Sym.
   14545              : */
   14546              : 
   14547        82671 : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber)
   14548              : {
   14549        82671 :   SymbolTable_PtrToSymbol pSym;
   14550              : 
   14551        82671 :   pSym = GetPsym (Sym);
   14552        82671 :   switch (pSym->SymbolType)
   14553              :     {
   14554        11952 :       case SymbolTable_ModuleSym:
   14555        11952 :         pSym->Module.StartQuad = QuadNumber;
   14556        11952 :         break;
   14557              : 
   14558        70719 :       case SymbolTable_DefImpSym:
   14559        70719 :         pSym->DefImp.StartQuad = QuadNumber;
   14560        70719 :         break;
   14561              : 
   14562              : 
   14563            0 :       default:
   14564            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   14565        82671 :         break;
   14566              :     }
   14567        82671 : }
   14568              : 
   14569              : 
   14570              : /*
   14571              :    PutModuleEndQuad - Places QuadNumber into the Module symbol, Sym.
   14572              :                       QuadNumber is the end quad of Module,
   14573              :                       Sym.
   14574              : */
   14575              : 
   14576        82523 : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber)
   14577              : {
   14578        82523 :   SymbolTable_PtrToSymbol pSym;
   14579              : 
   14580        82523 :   pSym = GetPsym (Sym);
   14581        82523 :   switch (pSym->SymbolType)
   14582              :     {
   14583        11804 :       case SymbolTable_ModuleSym:
   14584        11804 :         pSym->Module.EndQuad = QuadNumber;
   14585        11804 :         break;
   14586              : 
   14587        70719 :       case SymbolTable_DefImpSym:
   14588        70719 :         pSym->DefImp.EndQuad = QuadNumber;
   14589        70719 :         break;
   14590              : 
   14591              : 
   14592            0 :       default:
   14593            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   14594        82523 :         break;
   14595              :     }
   14596        82523 : }
   14597              : 
   14598              : 
   14599              : /*
   14600              :    PutModuleFinallyStartQuad - Places QuadNumber into the Module symbol, Sym.
   14601              :                                QuadNumber is the finally start quad of
   14602              :                                Module, Sym.
   14603              : */
   14604              : 
   14605        15311 : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber)
   14606              : {
   14607        15311 :   SymbolTable_PtrToSymbol pSym;
   14608              : 
   14609        15311 :   pSym = GetPsym (Sym);
   14610        15311 :   switch (pSym->SymbolType)
   14611              :     {
   14612        11798 :       case SymbolTable_ModuleSym:
   14613        11798 :         pSym->Module.StartFinishQuad = QuadNumber;
   14614        11798 :         break;
   14615              : 
   14616         3513 :       case SymbolTable_DefImpSym:
   14617         3513 :         pSym->DefImp.StartFinishQuad = QuadNumber;
   14618         3513 :         break;
   14619              : 
   14620              : 
   14621            0 :       default:
   14622            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   14623        15311 :         break;
   14624              :     }
   14625        15311 : }
   14626              : 
   14627              : 
   14628              : /*
   14629              :    PutModuleFinallyEndQuad - Places QuadNumber into the Module symbol, Sym.
   14630              :                              QuadNumber is the end quad of the finally block
   14631              :                              in Module, Sym.
   14632              : */
   14633              : 
   14634        15311 : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber)
   14635              : {
   14636        15311 :   SymbolTable_PtrToSymbol pSym;
   14637              : 
   14638        15311 :   pSym = GetPsym (Sym);
   14639        15311 :   switch (pSym->SymbolType)
   14640              :     {
   14641        11798 :       case SymbolTable_ModuleSym:
   14642        11798 :         pSym->Module.EndFinishQuad = QuadNumber;
   14643        11798 :         break;
   14644              : 
   14645         3513 :       case SymbolTable_DefImpSym:
   14646         3513 :         pSym->DefImp.EndFinishQuad = QuadNumber;
   14647         3513 :         break;
   14648              : 
   14649              : 
   14650            0 :       default:
   14651            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   14652        15311 :         break;
   14653              :     }
   14654        15311 : }
   14655              : 
   14656              : 
   14657              : /*
   14658              :    GetModuleQuads - Returns, StartInit EndInit StartFinish EndFinish,
   14659              :                     Quads of a Module, Sym.
   14660              :                     Start and End represent the initialization code
   14661              :                     of the Module, Sym.
   14662              : */
   14663              : 
   14664            0 : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish)
   14665              : {
   14666            0 :   SymbolTable_PtrToSymbol pSym;
   14667              : 
   14668            0 :   pSym = GetPsym (Sym);
   14669            0 :   switch (pSym->SymbolType)
   14670              :     {
   14671            0 :       case SymbolTable_ModuleSym:
   14672            0 :         (*StartInit) = pSym->Module.StartQuad;
   14673            0 :         (*EndInit) = pSym->Module.EndQuad;
   14674            0 :         (*StartFinish) = pSym->Module.StartFinishQuad;
   14675            0 :         (*EndFinish) = pSym->Module.EndFinishQuad;
   14676            0 :         break;
   14677              : 
   14678            0 :       case SymbolTable_DefImpSym:
   14679            0 :         (*StartInit) = pSym->DefImp.StartQuad;
   14680            0 :         (*EndInit) = pSym->DefImp.EndQuad;
   14681            0 :         (*StartFinish) = pSym->DefImp.StartFinishQuad;
   14682            0 :         (*EndFinish) = pSym->DefImp.EndFinishQuad;
   14683            0 :         break;
   14684              : 
   14685              : 
   14686            0 :       default:
   14687            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   14688            0 :         break;
   14689              :     }
   14690            0 : }
   14691              : 
   14692              : 
   14693              : /*
   14694              :    PutModuleFinallyFunction - Places Tree, finally, into the Module symbol, Sym.
   14695              : */
   14696              : 
   14697            0 : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, tree finally)
   14698              : {
   14699            0 :   SymbolTable_PtrToSymbol pSym;
   14700              : 
   14701            0 :   pSym = GetPsym (Sym);
   14702            0 :   switch (pSym->SymbolType)
   14703              :     {
   14704            0 :       case SymbolTable_ModuleSym:
   14705            0 :         pSym->Module.FinallyFunction = finally;
   14706            0 :         break;
   14707              : 
   14708            0 :       case SymbolTable_DefImpSym:
   14709            0 :         pSym->DefImp.FinallyFunction = finally;
   14710            0 :         break;
   14711              : 
   14712              : 
   14713            0 :       default:
   14714            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   14715            0 :         break;
   14716              :     }
   14717            0 : }
   14718              : 
   14719              : 
   14720              : /*
   14721              :    GetModuleFinallyFunction - returns the finally tree from the Module symbol, Sym.
   14722              : */
   14723              : 
   14724            0 : extern "C" tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym)
   14725              : {
   14726            0 :   SymbolTable_PtrToSymbol pSym;
   14727              : 
   14728            0 :   pSym = GetPsym (Sym);
   14729            0 :   switch (pSym->SymbolType)
   14730              :     {
   14731            0 :       case SymbolTable_ModuleSym:
   14732            0 :         return pSym->Module.FinallyFunction;
   14733            0 :         break;
   14734              : 
   14735            0 :       case SymbolTable_DefImpSym:
   14736            0 :         return pSym->DefImp.FinallyFunction;
   14737            0 :         break;
   14738              : 
   14739              : 
   14740            0 :       default:
   14741            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   14742              :         break;
   14743              :     }
   14744              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   14745              :   __builtin_unreachable ();
   14746              : }
   14747              : 
   14748              : 
   14749              : /*
   14750              :    PutProcedureScopeQuad - Places QuadNumber into the Procedure symbol, Sym.
   14751              :                            QuadNumber is the start quad of scope for procedure,
   14752              :                            Sym.
   14753              : */
   14754              : 
   14755        78968 : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber)
   14756              : {
   14757        78968 :   SymbolTable_PtrToSymbol pSym;
   14758              : 
   14759        78968 :   pSym = GetPsym (Sym);
   14760        78968 :   switch (pSym->SymbolType)
   14761              :     {
   14762        78968 :       case SymbolTable_ProcedureSym:
   14763        78968 :         pSym->Procedure.ScopeQuad = QuadNumber;
   14764        78968 :         break;
   14765              : 
   14766              : 
   14767            0 :       default:
   14768            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   14769        78968 :         break;
   14770              :     }
   14771        78968 : }
   14772              : 
   14773              : 
   14774              : /*
   14775              :    PutProcedureStartQuad - Places QuadNumber into the Procedure symbol, Sym.
   14776              :                            QuadNumber is the start quad of procedure,
   14777              :                            Sym.
   14778              : */
   14779              : 
   14780        78956 : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber)
   14781              : {
   14782        78956 :   SymbolTable_PtrToSymbol pSym;
   14783              : 
   14784        78956 :   pSym = GetPsym (Sym);
   14785        78956 :   switch (pSym->SymbolType)
   14786              :     {
   14787        78956 :       case SymbolTable_ProcedureSym:
   14788        78956 :         pSym->Procedure.StartQuad = QuadNumber;
   14789        78956 :         break;
   14790              : 
   14791              : 
   14792            0 :       default:
   14793            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   14794        78956 :         break;
   14795              :     }
   14796        78956 : }
   14797              : 
   14798              : 
   14799              : /*
   14800              :    PutProcedureEndQuad - Places QuadNumber into the Procedure symbol, Sym.
   14801              :                          QuadNumber is the end quad of procedure,
   14802              :                          Sym.
   14803              : */
   14804              : 
   14805        78926 : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber)
   14806              : {
   14807        78926 :   SymbolTable_PtrToSymbol pSym;
   14808              : 
   14809        78926 :   pSym = GetPsym (Sym);
   14810        78926 :   switch (pSym->SymbolType)
   14811              :     {
   14812        78926 :       case SymbolTable_ProcedureSym:
   14813        78926 :         pSym->Procedure.EndQuad = QuadNumber;
   14814        78926 :         break;
   14815              : 
   14816              : 
   14817            0 :       default:
   14818            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   14819        78926 :         break;
   14820              :     }
   14821        78926 : }
   14822              : 
   14823              : 
   14824              : /*
   14825              :    GetProcedureQuads - Returns, Start and End, Quads of a procedure, Sym.
   14826              : */
   14827              : 
   14828       687841 : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end)
   14829              : {
   14830       687841 :   SymbolTable_PtrToSymbol pSym;
   14831              : 
   14832       687841 :   pSym = GetPsym (Sym);
   14833       687841 :   switch (pSym->SymbolType)
   14834              :     {
   14835       687841 :       case SymbolTable_ProcedureSym:
   14836       687841 :         (*scope) = pSym->Procedure.ScopeQuad;
   14837       687841 :         (*start) = pSym->Procedure.StartQuad;
   14838       687841 :         (*end) = pSym->Procedure.EndQuad;
   14839       687841 :         break;
   14840              : 
   14841              : 
   14842            0 :       default:
   14843            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   14844       687841 :         break;
   14845              :     }
   14846       687841 : }
   14847              : 
   14848              : 
   14849              : /*
   14850              :    GetQuads - assigns Start and End to the beginning and end of
   14851              :               symbol, Sym, usage.
   14852              : */
   14853              : 
   14854            0 : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
   14855              : {
   14856            0 :   unsigned int StartRead;
   14857            0 :   unsigned int EndRead;
   14858            0 :   unsigned int StartWrite;
   14859            0 :   unsigned int EndWrite;
   14860              : 
   14861            0 :   SymbolTable_GetReadQuads (Sym, m, &StartRead, &EndRead);
   14862            0 :   SymbolTable_GetWriteQuads (Sym, m, &StartWrite, &EndWrite);
   14863            0 :   if (StartRead == 0)
   14864              :     {
   14865            0 :       (*Start) = StartWrite;
   14866              :     }
   14867            0 :   else if (StartWrite == 0)
   14868              :     {
   14869              :       /* avoid dangling else.  */
   14870            0 :       (*Start) = StartRead;
   14871              :     }
   14872              :   else
   14873              :     {
   14874              :       /* avoid dangling else.  */
   14875            0 :       (*Start) = Min (StartRead, StartWrite);
   14876              :     }
   14877            0 :   if (EndRead == 0)
   14878              :     {
   14879            0 :       (*End) = EndWrite;
   14880              :     }
   14881            0 :   else if (EndWrite == 0)
   14882              :     {
   14883              :       /* avoid dangling else.  */
   14884            0 :       (*End) = EndRead;
   14885              :     }
   14886              :   else
   14887              :     {
   14888              :       /* avoid dangling else.  */
   14889            0 :       (*End) = Max (EndRead, EndWrite);
   14890              :     }
   14891            0 : }
   14892              : 
   14893              : 
   14894              : /*
   14895              :    GetReadQuads - assigns Start and End to the beginning and end of
   14896              :                   symbol, Sym, read history usage.
   14897              : */
   14898              : 
   14899            0 : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
   14900              : {
   14901            0 :   SymbolTable_GetReadLimitQuads (Sym, m, 0, 0, Start, End);
   14902            0 : }
   14903              : 
   14904              : 
   14905              : /*
   14906              :    GetWriteQuads - assigns Start and End to the beginning and end of
   14907              :                    symbol, Sym, usage.
   14908              : */
   14909              : 
   14910            0 : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End)
   14911              : {
   14912            0 :   SymbolTable_GetWriteLimitQuads (Sym, m, 0, 0, Start, End);
   14913            0 : }
   14914              : 
   14915              : 
   14916              : /*
   14917              :    PutReadQuad - places Quad into the list of symbol usage.
   14918              : */
   14919              : 
   14920      1590181 : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
   14921              : {
   14922      1590181 :   SymbolTable_PtrToSymbol pSym;
   14923              : 
   14924      1590181 :   pSym = GetPsym (Sym);
   14925      1590181 :   switch (pSym->SymbolType)
   14926              :     {
   14927      1590181 :       case SymbolTable_VarSym:
   14928      1590181 :         Lists_IncludeItemIntoList (static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]), Quad);
   14929      1590181 :         break;
   14930              : 
   14931              : 
   14932            0 :       default:
   14933            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
   14934      1590181 :         break;
   14935              :     }
   14936      1590181 : }
   14937              : 
   14938              : 
   14939              : /*
   14940              :    RemoveReadQuad - places Quad into the list of symbol usage.
   14941              : */
   14942              : 
   14943       131558 : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
   14944              : {
   14945       131558 :   SymbolTable_PtrToSymbol pSym;
   14946              : 
   14947       131558 :   pSym = GetPsym (Sym);
   14948       131558 :   switch (pSym->SymbolType)
   14949              :     {
   14950       131558 :       case SymbolTable_VarSym:
   14951       131558 :         Lists_RemoveItemFromList (static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]), Quad);
   14952       131558 :         break;
   14953              : 
   14954              : 
   14955            0 :       default:
   14956            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
   14957       131558 :         break;
   14958              :     }
   14959       131558 : }
   14960              : 
   14961              : 
   14962              : /*
   14963              :    PutWriteQuad - places Quad into the list of symbol usage.
   14964              : */
   14965              : 
   14966      1038015 : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
   14967              : {
   14968      1038015 :   SymbolTable_PtrToSymbol pSym;
   14969              : 
   14970      1038015 :   pSym = GetPsym (Sym);
   14971      1038015 :   switch (pSym->SymbolType)
   14972              :     {
   14973      1038015 :       case SymbolTable_VarSym:
   14974      1038015 :         Lists_IncludeItemIntoList (static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]), Quad);
   14975      1038015 :         break;
   14976              : 
   14977              : 
   14978            0 :       default:
   14979            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
   14980      1038015 :         break;
   14981              :     }
   14982      1038015 : }
   14983              : 
   14984              : 
   14985              : /*
   14986              :    RemoveWriteQuad - places Quad into the list of symbol usage.
   14987              : */
   14988              : 
   14989       212930 : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad)
   14990              : {
   14991       212930 :   SymbolTable_PtrToSymbol pSym;
   14992              : 
   14993       212930 :   pSym = GetPsym (Sym);
   14994       212930 :   switch (pSym->SymbolType)
   14995              :     {
   14996       212930 :       case SymbolTable_VarSym:
   14997       212930 :         Lists_RemoveItemFromList (static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]), Quad);
   14998       212930 :         break;
   14999              : 
   15000              : 
   15001            0 :       default:
   15002            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
   15003       212930 :         break;
   15004              :     }
   15005       212930 : }
   15006              : 
   15007              : 
   15008              : /*
   15009              :    GetReadLimitQuads - returns Start and End which have been assigned
   15010              :                        the start and end of when the symbol was read
   15011              :                        to within: StartLimit..EndLimit.
   15012              : */
   15013              : 
   15014            0 : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
   15015              : {
   15016            0 :   SymbolTable_PtrToSymbol pSym;
   15017              : 
   15018            0 :   pSym = GetPsym (Sym);
   15019            0 :   switch (pSym->SymbolType)
   15020              :     {
   15021            0 :       case SymbolTable_VarSym:
   15022            0 :         DoFindLimits (StartLimit, EndLimit, Start, End, static_cast<Lists_List> (pSym->Var.ReadUsageList.array[m-SymbolTable_RightValue]));
   15023            0 :         break;
   15024              : 
   15025              : 
   15026            0 :       default:
   15027            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
   15028            0 :         break;
   15029              :     }
   15030            0 : }
   15031              : 
   15032              : 
   15033              : /*
   15034              :    GetWriteLimitQuads - returns Start and End which have been assigned
   15035              :                         the start and end of when the symbol was written
   15036              :                         to within: StartLimit..EndLimit.
   15037              : */
   15038              : 
   15039           30 : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End)
   15040              : {
   15041           30 :   SymbolTable_PtrToSymbol pSym;
   15042              : 
   15043           30 :   pSym = GetPsym (Sym);
   15044           30 :   switch (pSym->SymbolType)
   15045              :     {
   15046           30 :       case SymbolTable_VarSym:
   15047           30 :         DoFindLimits (StartLimit, EndLimit, Start, End, static_cast<Lists_List> (pSym->Var.WriteUsageList.array[m-SymbolTable_RightValue]));
   15048           30 :         break;
   15049              : 
   15050              : 
   15051            0 :       default:
   15052            0 :         M2Error_InternalError ((const char *) "expecting a Var symbol", 22);
   15053           30 :         break;
   15054              :     }
   15055           30 : }
   15056              : 
   15057              : 
   15058              : /*
   15059              :    GetNthProcedure - Returns the Nth procedure in Module, Sym.
   15060              : */
   15061              : 
   15062        12573 : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n)
   15063              : {
   15064        12573 :   SymbolTable_PtrToSymbol pSym;
   15065              : 
   15066        12573 :   pSym = GetPsym (Sym);
   15067        12573 :   switch (pSym->SymbolType)
   15068              :     {
   15069        12564 :       case SymbolTable_DefImpSym:
   15070        12564 :         return static_cast<unsigned int> (Lists_GetItemFromList (pSym->DefImp.ListOfProcs, n));
   15071            9 :         break;
   15072              : 
   15073            9 :       case SymbolTable_ModuleSym:
   15074            9 :         return static_cast<unsigned int> (Lists_GetItemFromList (pSym->Module.ListOfProcs, n));
   15075            0 :         break;
   15076              : 
   15077              : 
   15078            0 :       default:
   15079            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   15080              :         break;
   15081              :     }
   15082              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   15083              :   __builtin_unreachable ();
   15084              : }
   15085              : 
   15086              : 
   15087              : /*
   15088              :    GetDeclaredDef - returns the tokenno where the symbol was declared
   15089              :                     in the definition module.  UnknownTokenNo is returned
   15090              :                     if no declaration occurred.
   15091              : */
   15092              : 
   15093           36 : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym)
   15094              : {
   15095           36 :   return SymbolTable_GetDeclaredDefinition (Sym);
   15096              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15097              :   __builtin_unreachable ();
   15098              : }
   15099              : 
   15100              : 
   15101              : /*
   15102              :    GetDeclaredMod - returns the tokenno where the symbol was declared.
   15103              :                     in the program or implementation module.
   15104              :                     UnknownTokenNo is returned if no declaration occurred.
   15105              : */
   15106              : 
   15107     34981541 : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym)
   15108              : {
   15109     34981541 :   return SymbolTable_GetDeclaredModule (Sym);
   15110              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15111              :   __builtin_unreachable ();
   15112              : }
   15113              : 
   15114              : 
   15115              : /*
   15116              :    GetDeclaredFor - returns the token where this forward procedure symbol
   15117              :                     was declared in the program or implementation module.
   15118              :                     UnknownTokenNo is returned if no declaration occurred.
   15119              : */
   15120              : 
   15121            0 : extern "C" unsigned int SymbolTable_GetDeclaredFor (unsigned int Sym)
   15122              : {
   15123            0 :   if (SymbolTable_IsProcedure (Sym))
   15124              :     {
   15125            0 :       return SymbolTable_GetProcedureDeclaredTok (Sym, SymbolTable_ForwardProcedure);
   15126              :     }
   15127              :   else
   15128              :     {
   15129              :       return M2LexBuf_UnknownTokenNo;
   15130              :     }
   15131              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15132              :   __builtin_unreachable ();
   15133              : }
   15134              : 
   15135              : 
   15136              : /*
   15137              :    GetDeclaredDefinition - returns the token where this symbol
   15138              :                            was declared in the definition module.
   15139              : */
   15140              : 
   15141        22611 : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym)
   15142              : {
   15143        22611 :   SymbolTable_PtrToSymbol pSym;
   15144              : 
   15145        22611 :   pSym = GetPsym (Sym);
   15146        22611 :   switch (pSym->SymbolType)
   15147              :     {
   15148            0 :       case SymbolTable_ErrorSym:
   15149            0 :         return pSym->Error.At.DefDeclared;
   15150            0 :         break;
   15151              : 
   15152            0 :       case SymbolTable_ObjectSym:
   15153            0 :         return pSym->Object.At.DefDeclared;
   15154            0 :         break;
   15155              : 
   15156            0 :       case SymbolTable_VarientSym:
   15157            0 :         return pSym->Varient.At.DefDeclared;
   15158            6 :         break;
   15159              : 
   15160            6 :       case SymbolTable_RecordSym:
   15161            6 :         return pSym->Record.At.DefDeclared;
   15162            0 :         break;
   15163              : 
   15164            0 :       case SymbolTable_SubrangeSym:
   15165            0 :         return pSym->Subrange.At.DefDeclared;
   15166            0 :         break;
   15167              : 
   15168            0 :       case SymbolTable_EnumerationSym:
   15169            0 :         return pSym->Enumeration.At.DefDeclared;
   15170            0 :         break;
   15171              : 
   15172            0 :       case SymbolTable_ArraySym:
   15173            0 :         return pSym->Array.At.DefDeclared;
   15174            0 :         break;
   15175              : 
   15176            0 :       case SymbolTable_SubscriptSym:
   15177            0 :         return pSym->Subscript.At.DefDeclared;
   15178            0 :         break;
   15179              : 
   15180            0 :       case SymbolTable_UnboundedSym:
   15181            0 :         return pSym->Unbounded.At.DefDeclared;
   15182            0 :         break;
   15183              : 
   15184            0 :       case SymbolTable_ProcedureSym:
   15185            0 :         return pSym->Procedure.At.DefDeclared;
   15186            0 :         break;
   15187              : 
   15188            0 :       case SymbolTable_ProcTypeSym:
   15189            0 :         return pSym->ProcType.At.DefDeclared;
   15190           30 :         break;
   15191              : 
   15192           30 :       case SymbolTable_ParamSym:
   15193           30 :         return pSym->Param.At;
   15194            0 :         break;
   15195              : 
   15196            0 :       case SymbolTable_VarParamSym:
   15197            0 :         return pSym->VarParam.At;
   15198            0 :         break;
   15199              : 
   15200            0 :       case SymbolTable_ConstStringSym:
   15201            0 :         return pSym->ConstString.At.DefDeclared;
   15202            0 :         break;
   15203              : 
   15204            0 :       case SymbolTable_ConstLitSym:
   15205            0 :         return pSym->ConstLit.At.DefDeclared;
   15206            0 :         break;
   15207              : 
   15208            0 :       case SymbolTable_ConstVarSym:
   15209            0 :         return pSym->ConstVar.At.DefDeclared;
   15210            0 :         break;
   15211              : 
   15212            0 :       case SymbolTable_VarSym:
   15213            0 :         return pSym->Var.At.DefDeclared;
   15214            0 :         break;
   15215              : 
   15216            0 :       case SymbolTable_TypeSym:
   15217            0 :         return pSym->Type.At.DefDeclared;
   15218            0 :         break;
   15219              : 
   15220            0 :       case SymbolTable_PointerSym:
   15221            0 :         return pSym->Pointer.At.DefDeclared;
   15222            0 :         break;
   15223              : 
   15224            0 :       case SymbolTable_RecordFieldSym:
   15225            0 :         return pSym->RecordField.At.DefDeclared;
   15226            0 :         break;
   15227              : 
   15228            0 :       case SymbolTable_VarientFieldSym:
   15229            0 :         return pSym->VarientField.At.DefDeclared;
   15230            0 :         break;
   15231              : 
   15232            0 :       case SymbolTable_EnumerationFieldSym:
   15233            0 :         return pSym->EnumerationField.At.DefDeclared;
   15234            0 :         break;
   15235              : 
   15236            0 :       case SymbolTable_SetSym:
   15237            0 :         return pSym->Set.At.DefDeclared;
   15238            0 :         break;
   15239              : 
   15240            0 :       case SymbolTable_DefImpSym:
   15241            0 :         return pSym->DefImp.At.DefDeclared;
   15242            0 :         break;
   15243              : 
   15244            0 :       case SymbolTable_ModuleSym:
   15245            0 :         return pSym->Module.At.DefDeclared;
   15246            0 :         break;
   15247              : 
   15248            0 :       case SymbolTable_UndefinedSym:
   15249            0 :         return SymbolTable_GetFirstUsed (Sym);
   15250        22575 :         break;
   15251              : 
   15252        22575 :       case SymbolTable_ImportSym:
   15253        22575 :         return pSym->Import.at.DefDeclared;
   15254            0 :         break;
   15255              : 
   15256            0 :       case SymbolTable_ImportStatementSym:
   15257            0 :         return pSym->ImportStatement.at.DefDeclared;
   15258            0 :         break;
   15259              : 
   15260            0 :       case SymbolTable_PartialUnboundedSym:
   15261            0 :         return SymbolTable_GetDeclaredDefinition (pSym->PartialUnbounded.Type);
   15262            0 :         break;
   15263              : 
   15264              : 
   15265            0 :       default:
   15266            0 :         M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
   15267              :         break;
   15268              :     }
   15269              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   15270              :   __builtin_unreachable ();
   15271              : }
   15272              : 
   15273              : 
   15274              : /*
   15275              :    GetDeclaredModule - returns the token where this symbol was declared
   15276              :                        in an implementation or program module.
   15277              : */
   15278              : 
   15279     35002464 : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym)
   15280              : {
   15281     35002464 :   SymbolTable_PtrToSymbol pSym;
   15282              : 
   15283     35002464 :   pSym = GetPsym (Sym);
   15284     35002464 :   switch (pSym->SymbolType)
   15285              :     {
   15286            0 :       case SymbolTable_ErrorSym:
   15287            0 :         return pSym->Error.At.ModDeclared;
   15288            0 :         break;
   15289              : 
   15290            0 :       case SymbolTable_ObjectSym:
   15291            0 :         return pSym->Object.At.ModDeclared;
   15292         5976 :         break;
   15293              : 
   15294         5976 :       case SymbolTable_VarientSym:
   15295         5976 :         return pSym->Varient.At.ModDeclared;
   15296       298071 :         break;
   15297              : 
   15298       298071 :       case SymbolTable_RecordSym:
   15299       298071 :         return pSym->Record.At.ModDeclared;
   15300      6168906 :         break;
   15301              : 
   15302      6168906 :       case SymbolTable_SubrangeSym:
   15303      6168906 :         return pSym->Subrange.At.ModDeclared;
   15304        34988 :         break;
   15305              : 
   15306        34988 :       case SymbolTable_EnumerationSym:
   15307        34988 :         return pSym->Enumeration.At.ModDeclared;
   15308       168148 :         break;
   15309              : 
   15310       168148 :       case SymbolTable_ArraySym:
   15311       168148 :         return pSym->Array.At.ModDeclared;
   15312            0 :         break;
   15313              : 
   15314            0 :       case SymbolTable_SubscriptSym:
   15315            0 :         return pSym->Subscript.At.ModDeclared;
   15316        45680 :         break;
   15317              : 
   15318        45680 :       case SymbolTable_UnboundedSym:
   15319        45680 :         return pSym->Unbounded.At.ModDeclared;
   15320      5287936 :         break;
   15321              : 
   15322      5287936 :       case SymbolTable_ProcedureSym:
   15323      5287936 :         return pSym->Procedure.At.ModDeclared;
   15324        57502 :         break;
   15325              : 
   15326        57502 :       case SymbolTable_ProcTypeSym:
   15327        57502 :         return pSym->ProcType.At.ModDeclared;
   15328        74508 :         break;
   15329              : 
   15330        74508 :       case SymbolTable_ParamSym:
   15331        74508 :         return pSym->Param.At;
   15332       541279 :         break;
   15333              : 
   15334       541279 :       case SymbolTable_VarParamSym:
   15335       541279 :         return pSym->VarParam.At;
   15336       967309 :         break;
   15337              : 
   15338       967309 :       case SymbolTable_ConstStringSym:
   15339       967309 :         return pSym->ConstString.At.ModDeclared;
   15340      1265102 :         break;
   15341              : 
   15342      1265102 :       case SymbolTable_ConstLitSym:
   15343      1265102 :         return pSym->ConstLit.At.ModDeclared;
   15344       648290 :         break;
   15345              : 
   15346       648290 :       case SymbolTable_ConstVarSym:
   15347       648290 :         return pSym->ConstVar.At.ModDeclared;
   15348      8113161 :         break;
   15349              : 
   15350      8113161 :       case SymbolTable_VarSym:
   15351      8113161 :         return pSym->Var.At.ModDeclared;
   15352        37710 :         break;
   15353              : 
   15354        37710 :       case SymbolTable_TypeSym:
   15355        37710 :         return pSym->Type.At.ModDeclared;
   15356           12 :         break;
   15357              : 
   15358           12 :       case SymbolTable_PointerSym:
   15359           12 :         return pSym->Pointer.At.ModDeclared;
   15360       402410 :         break;
   15361              : 
   15362       402410 :       case SymbolTable_RecordFieldSym:
   15363       402410 :         return pSym->RecordField.At.ModDeclared;
   15364        12180 :         break;
   15365              : 
   15366        12180 :       case SymbolTable_VarientFieldSym:
   15367        12180 :         return pSym->VarientField.At.ModDeclared;
   15368     10490018 :         break;
   15369              : 
   15370     10490018 :       case SymbolTable_EnumerationFieldSym:
   15371     10490018 :         return pSym->EnumerationField.At.ModDeclared;
   15372       333126 :         break;
   15373              : 
   15374       333126 :       case SymbolTable_SetSym:
   15375       333126 :         return pSym->Set.At.ModDeclared;
   15376         7037 :         break;
   15377              : 
   15378         7037 :       case SymbolTable_DefImpSym:
   15379         7037 :         return pSym->DefImp.At.ModDeclared;
   15380        22198 :         break;
   15381              : 
   15382        22198 :       case SymbolTable_ModuleSym:
   15383        22198 :         return pSym->Module.At.ModDeclared;
   15384            0 :         break;
   15385              : 
   15386            0 :       case SymbolTable_UndefinedSym:
   15387            0 :         return SymbolTable_GetFirstUsed (Sym);
   15388        20917 :         break;
   15389              : 
   15390        20917 :       case SymbolTable_ImportSym:
   15391        20917 :         return pSym->Import.at.ModDeclared;
   15392            0 :         break;
   15393              : 
   15394            0 :       case SymbolTable_ImportStatementSym:
   15395            0 :         return pSym->ImportStatement.at.ModDeclared;
   15396            0 :         break;
   15397              : 
   15398            0 :       case SymbolTable_PartialUnboundedSym:
   15399            0 :         return SymbolTable_GetDeclaredModule (pSym->PartialUnbounded.Type);
   15400            0 :         break;
   15401              : 
   15402              : 
   15403            0 :       default:
   15404            0 :         M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
   15405              :         break;
   15406              :     }
   15407              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   15408              :   __builtin_unreachable ();
   15409              : }
   15410              : 
   15411              : 
   15412              : /*
   15413              :    PutDeclared - adds an entry to symbol, Sym, indicating that it
   15414              :                  was declared at, tok.  This routine
   15415              :                  may be called twice, once for definition module
   15416              :                  partial declaration and once when parsing the
   15417              :                  implementation module.
   15418              : */
   15419              : 
   15420     31400134 : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym)
   15421              : {
   15422     31400134 :   if (M2Comp_CompilingDefinitionModule ())
   15423              :     {
   15424     18484094 :       PutDeclaredDefinition (tok, Sym);
   15425              :     }
   15426              :   else
   15427              :     {
   15428     12916040 :       PutDeclaredModule (tok, Sym);
   15429              :     }
   15430     31400134 : }
   15431              : 
   15432              : 
   15433              : /*
   15434              :    GetFirstUsed - returns the token where this symbol was first used.
   15435              : */
   15436              : 
   15437          522 : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym)
   15438              : {
   15439          522 :   SymbolTable_PtrToSymbol pSym;
   15440              : 
   15441          522 :   pSym = GetPsym (Sym);
   15442          522 :   switch (pSym->SymbolType)
   15443              :     {
   15444            0 :       case SymbolTable_ErrorSym:
   15445            0 :         return pSym->Error.At.FirstUsed;
   15446          170 :         break;
   15447              : 
   15448          170 :       case SymbolTable_ObjectSym:
   15449          170 :         return pSym->Object.At.FirstUsed;
   15450          340 :         break;
   15451              : 
   15452          340 :       case SymbolTable_UndefinedSym:
   15453          340 :         return pSym->Undefined.At.FirstUsed;
   15454            0 :         break;
   15455              : 
   15456            0 :       case SymbolTable_VarientSym:
   15457            0 :         return pSym->Varient.At.FirstUsed;
   15458            0 :         break;
   15459              : 
   15460            0 :       case SymbolTable_RecordSym:
   15461            0 :         return pSym->Record.At.FirstUsed;
   15462            0 :         break;
   15463              : 
   15464            0 :       case SymbolTable_SubrangeSym:
   15465            0 :         return pSym->Subrange.At.FirstUsed;
   15466            0 :         break;
   15467              : 
   15468            0 :       case SymbolTable_EnumerationSym:
   15469            0 :         return pSym->Enumeration.At.FirstUsed;
   15470            0 :         break;
   15471              : 
   15472            0 :       case SymbolTable_ArraySym:
   15473            0 :         return pSym->Array.At.FirstUsed;
   15474            0 :         break;
   15475              : 
   15476            0 :       case SymbolTable_SubscriptSym:
   15477            0 :         return pSym->Subscript.At.FirstUsed;
   15478            0 :         break;
   15479              : 
   15480            0 :       case SymbolTable_UnboundedSym:
   15481            0 :         return pSym->Unbounded.At.FirstUsed;
   15482            0 :         break;
   15483              : 
   15484            0 :       case SymbolTable_ProcedureSym:
   15485            0 :         return pSym->Procedure.At.FirstUsed;
   15486            0 :         break;
   15487              : 
   15488            0 :       case SymbolTable_ProcTypeSym:
   15489            0 :         return pSym->ProcType.At.FirstUsed;
   15490            0 :         break;
   15491              : 
   15492            0 :       case SymbolTable_ConstStringSym:
   15493              :         /* 
   15494              :       ParamSym           : RETURN( Param.At.FirstUsed ) |
   15495              :       VarParamSym        : RETURN( VarParam.At.FirstUsed ) |
   15496              :   */
   15497            0 :         return pSym->ConstString.At.FirstUsed;
   15498            0 :         break;
   15499              : 
   15500            0 :       case SymbolTable_ConstLitSym:
   15501            0 :         return pSym->ConstLit.At.FirstUsed;
   15502            6 :         break;
   15503              : 
   15504            6 :       case SymbolTable_ConstVarSym:
   15505            6 :         return pSym->ConstVar.At.FirstUsed;
   15506            6 :         break;
   15507              : 
   15508            6 :       case SymbolTable_VarSym:
   15509            6 :         return pSym->Var.At.FirstUsed;
   15510            0 :         break;
   15511              : 
   15512            0 :       case SymbolTable_TypeSym:
   15513            0 :         return pSym->Type.At.FirstUsed;
   15514            0 :         break;
   15515              : 
   15516            0 :       case SymbolTable_PointerSym:
   15517            0 :         return pSym->Pointer.At.FirstUsed;
   15518            0 :         break;
   15519              : 
   15520            0 :       case SymbolTable_RecordFieldSym:
   15521            0 :         return pSym->RecordField.At.FirstUsed;
   15522            0 :         break;
   15523              : 
   15524            0 :       case SymbolTable_VarientFieldSym:
   15525            0 :         return pSym->VarientField.At.FirstUsed;
   15526            0 :         break;
   15527              : 
   15528            0 :       case SymbolTable_EnumerationFieldSym:
   15529            0 :         return pSym->EnumerationField.At.FirstUsed;
   15530            0 :         break;
   15531              : 
   15532            0 :       case SymbolTable_SetSym:
   15533            0 :         return pSym->Set.At.FirstUsed;
   15534            0 :         break;
   15535              : 
   15536            0 :       case SymbolTable_DefImpSym:
   15537            0 :         return pSym->DefImp.At.FirstUsed;
   15538            0 :         break;
   15539              : 
   15540            0 :       case SymbolTable_ModuleSym:
   15541            0 :         return pSym->Module.At.FirstUsed;
   15542            0 :         break;
   15543              : 
   15544              : 
   15545            0 :       default:
   15546            0 :         M2Error_InternalError ((const char *) "not expecting this type of symbol", 33);
   15547              :         break;
   15548              :     }
   15549              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   15550              :   __builtin_unreachable ();
   15551              : }
   15552              : 
   15553              : 
   15554              : /*
   15555              :    PutProcedureBegin - assigns begin as the token number matching the
   15556              :                        procedure BEGIN.
   15557              : */
   15558              : 
   15559        78956 : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin)
   15560              : {
   15561        78956 :   SymbolTable_PtrToSymbol pSym;
   15562              : 
   15563        78956 :   pSym = GetPsym (Sym);
   15564        78956 :   switch (pSym->SymbolType)
   15565              :     {
   15566        78956 :       case SymbolTable_ProcedureSym:
   15567        78956 :         pSym->Procedure.Begin = begin;
   15568        78956 :         break;
   15569              : 
   15570              : 
   15571            0 :       default:
   15572            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   15573        78956 :         break;
   15574              :     }
   15575        78956 : }
   15576              : 
   15577              : 
   15578              : /*
   15579              :    PutProcedureEnd - assigns end as the token number matching the
   15580              :                      procedure END.
   15581              : */
   15582              : 
   15583        78926 : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end)
   15584              : {
   15585        78926 :   SymbolTable_PtrToSymbol pSym;
   15586              : 
   15587        78926 :   pSym = GetPsym (Sym);
   15588        78926 :   switch (pSym->SymbolType)
   15589              :     {
   15590        78926 :       case SymbolTable_ProcedureSym:
   15591        78926 :         pSym->Procedure.End = end;
   15592        78926 :         break;
   15593              : 
   15594              : 
   15595            0 :       default:
   15596            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   15597        78926 :         break;
   15598              :     }
   15599        78926 : }
   15600              : 
   15601              : 
   15602              : /*
   15603              :    GetProcedureBeginEnd - assigns, begin, end, to the stored token values.
   15604              : */
   15605              : 
   15606      3895507 : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end)
   15607              : {
   15608      3895507 :   SymbolTable_PtrToSymbol pSym;
   15609              : 
   15610      3895507 :   pSym = GetPsym (Sym);
   15611      3895507 :   switch (pSym->SymbolType)
   15612              :     {
   15613      3895507 :       case SymbolTable_ProcedureSym:
   15614      3895507 :         (*begin) = pSym->Procedure.Begin;
   15615      3895507 :         (*end) = pSym->Procedure.End;
   15616      3895507 :         break;
   15617              : 
   15618              : 
   15619            0 :       default:
   15620            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   15621      3895507 :         break;
   15622              :     }
   15623      3895507 : }
   15624              : 
   15625              : 
   15626              : /*
   15627              :    ForeachProcedureDo - for each procedure in module, Sym, do procedure, P.
   15628              : */
   15629              : 
   15630      2831662 : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P)
   15631              : {
   15632      2831662 :   SymbolTable_PtrToSymbol pSym;
   15633              : 
   15634      2831662 :   pSym = GetPsym (Sym);
   15635      2831662 :   switch (pSym->SymbolType)
   15636              :     {
   15637       430793 :       case SymbolTable_DefImpSym:
   15638       430793 :         Lists_ForeachItemInListDo (pSym->DefImp.ListOfProcs, P);
   15639       430793 :         break;
   15640              : 
   15641       109801 :       case SymbolTable_ModuleSym:
   15642       109801 :         Lists_ForeachItemInListDo (pSym->Module.ListOfProcs, P);
   15643       109801 :         break;
   15644              : 
   15645      2291068 :       case SymbolTable_ProcedureSym:
   15646      2291068 :         Lists_ForeachItemInListDo (pSym->Procedure.ListOfProcs, P);
   15647      2291068 :         break;
   15648              : 
   15649              : 
   15650            0 :       default:
   15651            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   15652      2831644 :         break;
   15653              :     }
   15654      2831644 : }
   15655              : 
   15656              : 
   15657              : /*
   15658              :    ForeachModuleDo - for each module do procedure, P.
   15659              : */
   15660              : 
   15661        46788 : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P)
   15662              : {
   15663        46788 :   SymbolKey_ForeachNodeDo (ModuleTree, P);
   15664        46788 : }
   15665              : 
   15666              : 
   15667              : /*
   15668              :    ForeachInnerModuleDo - for each inner module in module, Sym,
   15669              :                           do procedure, P.
   15670              : */
   15671              : 
   15672      3269423 : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P)
   15673              : {
   15674      3269423 :   SymbolTable_PtrToSymbol pSym;
   15675              : 
   15676      3269423 :   pSym = GetPsym (Sym);
   15677      3269423 :   switch (pSym->SymbolType)
   15678              :     {
   15679       437018 :       case SymbolTable_DefImpSym:
   15680       437018 :         Lists_ForeachItemInListDo (pSym->DefImp.ListOfModules, P);
   15681       437018 :         break;
   15682              : 
   15683       165098 :       case SymbolTable_ModuleSym:
   15684       165098 :         Lists_ForeachItemInListDo (pSym->Module.ListOfModules, P);
   15685       165098 :         break;
   15686              : 
   15687      2667307 :       case SymbolTable_ProcedureSym:
   15688      2667307 :         Lists_ForeachItemInListDo (pSym->Procedure.ListOfModules, P);
   15689      2667307 :         break;
   15690              : 
   15691              : 
   15692            0 :       default:
   15693            0 :         M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   15694      3269423 :         break;
   15695              :     }
   15696      3269423 : }
   15697              : 
   15698              : 
   15699              : /*
   15700              :    IsVarParam - Returns a conditional depending whether parameter ParamNo
   15701              :                 is a VAR parameter.
   15702              : */
   15703              : 
   15704     11186142 : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
   15705              : {
   15706     11186142 :   SymbolTable_PtrToSymbol pSym;
   15707     11186142 :   bool IsVar;
   15708              : 
   15709     11186142 :   IsVar = false;
   15710     11186142 :   pSym = GetPsym (Sym);
   15711     11186142 :   switch (pSym->SymbolType)
   15712              :     {
   15713              :       case SymbolTable_ErrorSym:
   15714              :         break;
   15715              : 
   15716     11186142 :       case SymbolTable_ProcedureSym:
   15717     11186142 :         IsVar = IsNthParamVar (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo);
   15718     11186142 :         break;
   15719              : 
   15720            0 :       case SymbolTable_ProcTypeSym:
   15721            0 :         IsVar = IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
   15722            0 :         break;
   15723              : 
   15724              : 
   15725            0 :       default:
   15726            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   15727     11186142 :         break;
   15728              :     }
   15729     11186142 :   return IsVar;
   15730              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15731              :   __builtin_unreachable ();
   15732              : }
   15733              : 
   15734              : 
   15735              : /*
   15736              :    IsVarParamAny - Returns a conditional depending whether parameter ParamNo
   15737              :                    is a VAR parameter.
   15738              : */
   15739              : 
   15740     10523310 : extern "C" bool SymbolTable_IsVarParamAny (unsigned int Sym, unsigned int ParamNo)
   15741              : {
   15742     10523310 :   SymbolTable_PtrToSymbol pSym;
   15743     10523310 :   SymbolTable_ProcedureKind kind;
   15744              : 
   15745     10523310 :   pSym = GetPsym (Sym);
   15746     10523310 :   switch (pSym->SymbolType)
   15747              :     {
   15748              :       case SymbolTable_ErrorSym:
   15749              :         break;
   15750              : 
   15751              :       case SymbolTable_ProcedureSym:
   15752     22976975 :         for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
   15753              :           {
   15754     22147130 :             if (SymbolTable_GetProcedureDefined (Sym, kind))
   15755              :               {
   15756      9136065 :                 return IsNthParamVar (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam, ParamNo);
   15757              :               }
   15758              :           }
   15759              :         break;
   15760              : 
   15761       557400 :       case SymbolTable_ProcTypeSym:
   15762       557400 :         return IsNthParamVar (pSym->ProcType.ListOfParam, ParamNo);
   15763            0 :         break;
   15764              : 
   15765              : 
   15766            0 :       default:
   15767            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   15768              :         break;
   15769              :     }
   15770              :   return false;
   15771              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15772              :   __builtin_unreachable ();
   15773              : }
   15774              : 
   15775              : 
   15776              : /*
   15777              :    IsUnboundedParam - Returns a conditional depending whether parameter
   15778              :                       ParamNo is an unbounded array procedure parameter.
   15779              : */
   15780              : 
   15781     22776180 : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, SymbolTable_ProcedureKind kind, unsigned int ParamNo)
   15782              : {
   15783     22776180 :   unsigned int param;
   15784              : 
   15785     22776180 :   param = SymbolTable_GetNthParam (Sym, kind, ParamNo);
   15786     22776180 :   return SymbolTable_IsParameterUnbounded (param);
   15787              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15788              :   __builtin_unreachable ();
   15789              : }
   15790              : 
   15791     19633738 : extern "C" bool SymbolTable_IsUnboundedParamAny (unsigned int Sym, unsigned int ParamNo)
   15792              : {
   15793     19633738 :   SymbolTable_ProcedureKind kind;
   15794              : 
   15795     39840260 :   for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
   15796              :     {
   15797              :       /* 
   15798              :    IsUnboundedParam - Returns a conditional depending whether parameter
   15799              :                       ParamNo is an unbounded array procedure parameter.
   15800              :   */
   15801     39840260 :       if (SymbolTable_GetProcedureParametersDefined (Sym, kind))
   15802              :         {
   15803     19633738 :           return SymbolTable_IsUnboundedParam (Sym, kind, ParamNo);
   15804              :         }
   15805              :     }
   15806            0 :   M2Error_InternalError ((const char *) "no procedure kind exists", 24);
   15807              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   15808              :   __builtin_unreachable ();
   15809              : }
   15810              : 
   15811              : 
   15812              : /*
   15813              :    IsParameterUnbounded - returns TRUE if parameter, Sym, is
   15814              :                           unbounded.
   15815              : */
   15816              : 
   15817     22776192 : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym)
   15818              : {
   15819     22776192 :   SymbolTable_PtrToSymbol pSym;
   15820              : 
   15821     22776192 :   pSym = GetPsym (Sym);
   15822     22776192 :   switch (pSym->SymbolType)
   15823              :     {
   15824     20271113 :       case SymbolTable_ParamSym:
   15825     20271113 :         return pSym->Param.IsUnbounded;
   15826      2505079 :         break;
   15827              : 
   15828      2505079 :       case SymbolTable_VarParamSym:
   15829      2505079 :         return pSym->VarParam.IsUnbounded;
   15830            0 :         break;
   15831              : 
   15832              : 
   15833            0 :       default:
   15834            0 :         M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
   15835              :         break;
   15836              :     }
   15837              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   15838              :   __builtin_unreachable ();
   15839              : }
   15840              : 
   15841              : 
   15842              : /*
   15843              :    IsParameterVar - returns true if parameter symbol Sym
   15844              :                     was declared as a VAR.
   15845              : */
   15846              : 
   15847          204 : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym)
   15848              : {
   15849          204 :   SymbolTable_PtrToSymbol pSym;
   15850              : 
   15851          204 :   pSym = GetPsym (Sym);
   15852          204 :   switch (pSym->SymbolType)
   15853              :     {
   15854              :       case SymbolTable_ParamSym:
   15855              :         return false;
   15856           24 :         break;
   15857              : 
   15858           24 :       case SymbolTable_VarParamSym:
   15859           24 :         return true;
   15860            0 :         break;
   15861              : 
   15862              : 
   15863            0 :       default:
   15864            0 :         M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
   15865              :         break;
   15866              :     }
   15867              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   15868              :   __builtin_unreachable ();
   15869              : }
   15870              : 
   15871              : 
   15872              : /*
   15873              :    GetParameterShadowVar - returns the local variable associated with the
   15874              :                            parameter symbol, sym.
   15875              : */
   15876              : 
   15877        46916 : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym)
   15878              : {
   15879        46916 :   SymbolTable_PtrToSymbol pSym;
   15880              : 
   15881        46916 :   pSym = GetPsym (sym);
   15882        46916 :   switch (pSym->SymbolType)
   15883              :     {
   15884        39740 :       case SymbolTable_ParamSym:
   15885        39740 :         return pSym->Param.ShadowVar;
   15886         7176 :         break;
   15887              : 
   15888         7176 :       case SymbolTable_VarParamSym:
   15889         7176 :         return pSym->VarParam.ShadowVar;
   15890            0 :         break;
   15891              : 
   15892              : 
   15893            0 :       default:
   15894            0 :         M2Error_InternalError ((const char *) "expecting a ParamSym or VarParamSym", 35);
   15895              :         break;
   15896              :     }
   15897              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   15898              :   __builtin_unreachable ();
   15899              : }
   15900              : 
   15901              : 
   15902              : /*
   15903              :    NoOfParam - Returns the number of parameters that procedure Sym contains.
   15904              : */
   15905              : 
   15906     26351023 : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym, SymbolTable_ProcedureKind kind)
   15907              : {
   15908     26351023 :   SymbolTable_PtrToSymbol pSym;
   15909     26351023 :   unsigned int n;
   15910              : 
   15911     26351023 :   AssertInRange (Sym);
   15912     26351023 :   pSym = GetPsym (Sym);
   15913     26351023 :   switch (pSym->SymbolType)
   15914              :     {
   15915              :       case SymbolTable_ErrorSym:
   15916              :         n = 0;
   15917              :         break;
   15918              : 
   15919     26351023 :       case SymbolTable_ProcedureSym:
   15920     26351023 :         n = Lists_NoOfItemsInList (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ListOfParam);
   15921     26351023 :         break;
   15922              : 
   15923            0 :       case SymbolTable_ProcTypeSym:
   15924            0 :         n = Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
   15925            0 :         break;
   15926              : 
   15927              : 
   15928            0 :       default:
   15929            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   15930     26351023 :         break;
   15931              :     }
   15932     26351023 :   return n;
   15933              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15934              :   __builtin_unreachable ();
   15935              : }
   15936              : 
   15937              : 
   15938              : /*
   15939              :    HasVarParameters - returns TRUE if procedure, p, has any VAR parameters.
   15940              : */
   15941              : 
   15942            0 : extern "C" bool SymbolTable_HasVarParameters (unsigned int p)
   15943              : {
   15944            0 :   unsigned int i;
   15945            0 :   unsigned int n;
   15946              : 
   15947            0 :   n = SymbolTable_NoOfParamAny (p);
   15948            0 :   i = 1;
   15949            0 :   while (i <= n)
   15950              :     {
   15951            0 :       if (SymbolTable_IsParameterVar (SymbolTable_GetNthParamAny (p, i)))
   15952              :         {
   15953              :           return true;
   15954              :         }
   15955            0 :       i += 1;
   15956              :     }
   15957              :   return false;
   15958              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15959              :   __builtin_unreachable ();
   15960              : }
   15961              : 
   15962              : 
   15963              : /*
   15964              :    NoOfLocalVar - returns the number of local variables that exist in
   15965              :                   procedure Sym. Parameters are NOT included in the
   15966              :                   count.
   15967              : */
   15968              : 
   15969           30 : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym)
   15970              : {
   15971           30 :   SymbolTable_PtrToSymbol pSym;
   15972           30 :   unsigned int n;
   15973              : 
   15974           30 :   pSym = GetPsym (Sym);
   15975           30 :   switch (pSym->SymbolType)
   15976              :     {
   15977              :       case SymbolTable_ErrorSym:
   15978              :         n = 0;
   15979              :         break;
   15980              : 
   15981           30 :       case SymbolTable_ProcedureSym:
   15982           30 :         n = Lists_NoOfItemsInList (pSym->Procedure.ListOfVars);
   15983           30 :         break;
   15984              : 
   15985              : 
   15986            0 :       default:
   15987            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   15988           30 :         break;
   15989              :     }
   15990              :   /* 
   15991              :       Parameters are actually included in the list of local varaibles,
   15992              :       therefore we must subtract the Parameter Number from local variable
   15993              :       total.
   15994              :   */
   15995           30 :   return n-(SymbolTable_NoOfParamAny (Sym));
   15996              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   15997              :   __builtin_unreachable ();
   15998              : }
   15999              : 
   16000              : 
   16001              : /*
   16002              :    IsDefImp - returns true is the Sym is a DefImp symbol.
   16003              :               Definition/Implementation module symbol.
   16004              : */
   16005              : 
   16006    352678216 : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym)
   16007              : {
   16008    352678216 :   SymbolTable_PtrToSymbol pSym;
   16009              : 
   16010    352678216 :   pSym = GetPsym (Sym);
   16011    352678216 :   return pSym->SymbolType == SymbolTable_DefImpSym;
   16012              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16013              :   __builtin_unreachable ();
   16014              : }
   16015              : 
   16016              : 
   16017              : /*
   16018              :    IsModule - returns true is the Sym is a Module symbol.
   16019              :               Program module symbol.
   16020              : */
   16021              : 
   16022    292204828 : extern "C" bool SymbolTable_IsModule (unsigned int Sym)
   16023              : {
   16024    292204828 :   SymbolTable_PtrToSymbol pSym;
   16025              : 
   16026    292204828 :   pSym = GetPsym (Sym);
   16027    292204828 :   return pSym->SymbolType == SymbolTable_ModuleSym;
   16028              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16029              :   __builtin_unreachable ();
   16030              : }
   16031              : 
   16032              : 
   16033              : /*
   16034              :    IsInnerModule - returns true if the symbol, Sym, is an inner module.
   16035              : */
   16036              : 
   16037     10064035 : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym)
   16038              : {
   16039     10064035 :   if (SymbolTable_IsModule (Sym))
   16040              :     {
   16041       225488 :       return (SymbolTable_GetScope (Sym)) != SymbolTable_NulSym;
   16042              :     }
   16043              :   else
   16044              :     {
   16045              :       return false;
   16046              :     }
   16047              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16048              :   __builtin_unreachable ();
   16049              : }
   16050              : 
   16051              : 
   16052              : /*
   16053              :    GetSymName - returns the symbol name.
   16054              : */
   16055              : 
   16056   1121839351 : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym)
   16057              : {
   16058   1121839351 :   SymbolTable_PtrToSymbol pSym;
   16059   1121839351 :   NameKey_Name n;
   16060              : 
   16061   1121839351 :   if (Sym == SymbolTable_NulSym)
   16062              :     {
   16063              :       n = SymbolKey_NulKey;
   16064              :     }
   16065              :   else
   16066              :     {
   16067   1121839351 :       pSym = GetPsym (Sym);
   16068   1121839351 :       switch (pSym->SymbolType)
   16069              :         {
   16070          327 :           case SymbolTable_ErrorSym:
   16071          327 :             n = pSym->Error.name;
   16072          327 :             break;
   16073              : 
   16074     14508736 :           case SymbolTable_ObjectSym:
   16075     14508736 :             n = pSym->Object.name;
   16076     14508736 :             break;
   16077              : 
   16078      8122057 :           case SymbolTable_DefImpSym:
   16079      8122057 :             n = pSym->DefImp.name;
   16080      8122057 :             break;
   16081              : 
   16082       504091 :           case SymbolTable_ModuleSym:
   16083       504091 :             n = pSym->Module.name;
   16084       504091 :             break;
   16085              : 
   16086    865930674 :           case SymbolTable_TypeSym:
   16087    865930674 :             n = pSym->Type.name;
   16088    865930674 :             break;
   16089              : 
   16090      9833592 :           case SymbolTable_VarSym:
   16091      9833592 :             n = pSym->Var.name;
   16092      9833592 :             break;
   16093              : 
   16094        14937 :           case SymbolTable_ConstLitSym:
   16095        14937 :             n = pSym->ConstLit.name;
   16096        14937 :             break;
   16097              : 
   16098       149429 :           case SymbolTable_ConstVarSym:
   16099       149429 :             n = pSym->ConstVar.name;
   16100       149429 :             break;
   16101              : 
   16102        14026 :           case SymbolTable_ConstStringSym:
   16103        14026 :             n = pSym->ConstString.name;
   16104        14026 :             break;
   16105              : 
   16106      1715558 :           case SymbolTable_EnumerationSym:
   16107      1715558 :             n = pSym->Enumeration.name;
   16108      1715558 :             break;
   16109              : 
   16110      1528012 :           case SymbolTable_EnumerationFieldSym:
   16111      1528012 :             n = pSym->EnumerationField.name;
   16112      1528012 :             break;
   16113              : 
   16114     14225143 :           case SymbolTable_UndefinedSym:
   16115     14225143 :             n = pSym->Undefined.name;
   16116     14225143 :             break;
   16117              : 
   16118     50159486 :           case SymbolTable_ProcedureSym:
   16119     50159486 :             n = pSym->Procedure.name;
   16120     50159486 :             break;
   16121              : 
   16122       547519 :           case SymbolTable_ProcTypeSym:
   16123       547519 :             n = pSym->ProcType.name;
   16124       547519 :             break;
   16125              : 
   16126      1204698 :           case SymbolTable_RecordFieldSym:
   16127      1204698 :             n = pSym->RecordField.name;
   16128      1204698 :             break;
   16129              : 
   16130       423484 :           case SymbolTable_RecordSym:
   16131       423484 :             n = pSym->Record.name;
   16132       423484 :             break;
   16133              : 
   16134              :           case SymbolTable_VarientSym:
   16135              :             n = NameKey_NulName;
   16136              :             break;
   16137              : 
   16138        17034 :           case SymbolTable_VarientFieldSym:
   16139        17034 :             n = pSym->VarientField.name;
   16140        17034 :             break;
   16141              : 
   16142        12147 :           case SymbolTable_VarParamSym:
   16143        12147 :             n = pSym->VarParam.name;
   16144        12147 :             break;
   16145              : 
   16146       122122 :           case SymbolTable_ParamSym:
   16147       122122 :             n = pSym->Param.name;
   16148       122122 :             break;
   16149              : 
   16150     61873507 :           case SymbolTable_PointerSym:
   16151     61873507 :             n = pSym->Pointer.name;
   16152     61873507 :             break;
   16153              : 
   16154        99828 :           case SymbolTable_ArraySym:
   16155        99828 :             n = pSym->Array.name;
   16156        99828 :             break;
   16157              : 
   16158              :           case SymbolTable_UnboundedSym:
   16159              :             n = NameKey_NulName;
   16160              :             break;
   16161              : 
   16162       436854 :           case SymbolTable_SubrangeSym:
   16163       436854 :             n = pSym->Subrange.name;
   16164       436854 :             break;
   16165              : 
   16166     83371814 :           case SymbolTable_SetSym:
   16167     83371814 :             n = pSym->Set.name;
   16168     83371814 :             break;
   16169              : 
   16170              :           case SymbolTable_SubscriptSym:
   16171              :             n = NameKey_NulName;
   16172              :             break;
   16173              : 
   16174              :           case SymbolTable_DummySym:
   16175              :             n = NameKey_NulName;
   16176              :             break;
   16177              : 
   16178            0 :           case SymbolTable_PartialUnboundedSym:
   16179            0 :             n = SymbolTable_GetSymName (pSym->PartialUnbounded.Type);
   16180            0 :             break;
   16181              : 
   16182              :           case SymbolTable_TupleSym:
   16183              :             n = NameKey_NulName;
   16184              :             break;
   16185              : 
   16186              :           case SymbolTable_GnuAsmSym:
   16187              :             n = NameKey_NulName;
   16188              :             break;
   16189              : 
   16190              :           case SymbolTable_InterfaceSym:
   16191              :             n = NameKey_NulName;
   16192              :             break;
   16193              : 
   16194              :           case SymbolTable_ImportSym:
   16195              :             n = NameKey_NulName;
   16196              :             break;
   16197              : 
   16198              :           case SymbolTable_ImportStatementSym:
   16199              :             n = NameKey_NulName;
   16200              :             break;
   16201              : 
   16202              : 
   16203            0 :           default:
   16204            0 :             M2Error_InternalError ((const char *) "unexpected symbol type", 22);
   16205   1121839351 :             break;
   16206              :         }
   16207              :     }
   16208   1121839351 :   return n;
   16209              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16210              :   __builtin_unreachable ();
   16211              : }
   16212              : 
   16213              : 
   16214              : /*
   16215              :    RenameSym - renames a symbol, Sym, with SymName.
   16216              :                It also checks the unknown tree for a symbol
   16217              :                with this new name. Must only be renamed in
   16218              :                the same scope of being declared.
   16219              : */
   16220              : 
   16221            0 : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName)
   16222              : {
   16223            0 :   SymbolTable_PtrToSymbol pSym;
   16224              : 
   16225            0 :   if ((SymbolTable_GetSymName (Sym)) == NameKey_NulName)
   16226              :     {
   16227            0 :       pSym = GetPsym (Sym);
   16228            0 :       switch (pSym->SymbolType)
   16229              :         {
   16230            0 :           case SymbolTable_ErrorSym:
   16231            0 :             M2Error_ErrorAbort0 ((const char *) "", 0);
   16232            0 :             break;
   16233              : 
   16234            0 :           case SymbolTable_TypeSym:
   16235            0 :             pSym->Type.name = SymName;
   16236            0 :             break;
   16237              : 
   16238            0 :           case SymbolTable_VarSym:
   16239            0 :             pSym->Var.name = SymName;
   16240            0 :             break;
   16241              : 
   16242            0 :           case SymbolTable_ConstLitSym:
   16243            0 :             pSym->ConstLit.name = SymName;
   16244            0 :             break;
   16245              : 
   16246            0 :           case SymbolTable_ConstVarSym:
   16247            0 :             pSym->ConstVar.name = SymName;
   16248            0 :             break;
   16249              : 
   16250            0 :           case SymbolTable_UndefinedSym:
   16251            0 :             pSym->Undefined.name = SymName;
   16252            0 :             break;
   16253              : 
   16254            0 :           case SymbolTable_RecordSym:
   16255            0 :             pSym->Record.name = SymName;
   16256            0 :             break;
   16257              : 
   16258            0 :           case SymbolTable_PointerSym:
   16259            0 :             pSym->Pointer.name = SymName;
   16260            0 :             break;
   16261              : 
   16262              : 
   16263            0 :           default:
   16264            0 :             M2Error_InternalError ((const char *) "not implemented yet", 19);
   16265            0 :             break;
   16266              :         }
   16267            0 :       AddSymToScope (Sym, SymName);
   16268              :     }
   16269              :   else
   16270              :     {
   16271            0 :       M2Error_InternalError ((const char *) "old name of symbol must be nul", 30);
   16272              :     }
   16273            0 : }
   16274              : 
   16275              : 
   16276              : /*
   16277              :    IsUnknown - returns true is the symbol Sym is unknown.
   16278              : */
   16279              : 
   16280     49855123 : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym)
   16281              : {
   16282     49855123 :   SymbolTable_PtrToSymbol pSym;
   16283              : 
   16284     49855123 :   AssertInRange (Sym);
   16285     49855123 :   pSym = GetPsym (Sym);
   16286     49855123 :   return pSym->SymbolType == SymbolTable_UndefinedSym;
   16287              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16288              :   __builtin_unreachable ();
   16289              : }
   16290              : 
   16291              : 
   16292              : /*
   16293              :    IsPartialUnbounded - returns TRUE if, sym, is a partially unbounded symbol.
   16294              : */
   16295              : 
   16296      1003609 : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym)
   16297              : {
   16298      1003609 :   SymbolTable_PtrToSymbol pSym;
   16299              : 
   16300      1003609 :   if (sym > 0)
   16301              :     {
   16302      1003609 :       pSym = GetPsym (sym);
   16303      1003609 :       switch (pSym->SymbolType)
   16304              :         {
   16305              :           case SymbolTable_PartialUnboundedSym:
   16306              :             return true;
   16307              :             break;
   16308              : 
   16309              : 
   16310              :           default:
   16311              :             return false;
   16312              :             break;
   16313              :         }
   16314              :     }
   16315              :   else
   16316              :     {
   16317              :       return false;
   16318              :     }
   16319              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16320              :   __builtin_unreachable ();
   16321              : }
   16322              : 
   16323              : 
   16324              : /*
   16325              :    RequestSym - searches for a symbol with a name SymName in the
   16326              :                 current and previous scopes.
   16327              :                 If the symbol is found then it is returned
   16328              :                 else an unknown symbol is returned create at token
   16329              :                 position, tok.
   16330              :                 This procedure does search the base scope (for
   16331              :                 pervasive identifiers).
   16332              : */
   16333              : 
   16334     46169376 : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName)
   16335              : {
   16336     46169376 :   unsigned int Sym;
   16337              : 
   16338              :   /* 
   16339              :       WriteString('RequestSym for: ') ; WriteKey(SymName) ; WriteLn ;
   16340              :   */
   16341     46169376 :   Sym = SymbolTable_GetSym (SymName);
   16342     46169376 :   if (Sym == SymbolTable_NulSym)
   16343              :     {
   16344      6931249 :       Sym = GetSymFromUnknownTree (SymName);
   16345      6931249 :       if (Sym == SymbolTable_NulSym)
   16346              :         {
   16347              :           /* Make unknown.  */
   16348      6931249 :           NewSym (&Sym);
   16349      6931249 :           FillInUnknownFields (tok, Sym, SymName, SymbolTable_NulSym, false);
   16350              :           /* 
   16351              :            ; WriteKey(SymName) ; WriteString(' unknown demanded') ; WriteLn
   16352              :   */
   16353      6931249 :           AddSymToUnknownTree (static_cast<int> (ScopePtr), SymName, Sym);
   16354              :         }
   16355              :     }
   16356     46169376 :   return Sym;
   16357              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16358              :   __builtin_unreachable ();
   16359              : }
   16360              : 
   16361              : 
   16362              : /*
   16363              :    PutImported - places a symbol, Sym, into the current main scope.
   16364              : */
   16365              : 
   16366       987802 : extern "C" void SymbolTable_PutImported (unsigned int Sym)
   16367              : {
   16368       987802 :   SymbolTable_PtrToSymbol pSym;
   16369       987802 :   unsigned int ModSym;
   16370       987802 :   NameKey_Name n;
   16371              : 
   16372              :   /* 
   16373              :       We have currently imported Sym, now place it into the current module.
   16374              :   */
   16375       987802 :   ModSym = SymbolTable_GetCurrentModuleScope ();
   16376      1975604 :   M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
   16377       987802 :   pSym = GetPsym (ModSym);
   16378       987802 :   switch (pSym->SymbolType)
   16379              :     {
   16380       101021 :       case SymbolTable_ModuleSym:
   16381       101021 :         if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
   16382              :           {
   16383              :             /* avoid dangling else.  */
   16384           90 :             if (M2Options_Pedantic)
   16385              :               {
   16386            6 :                 n = SymbolTable_GetSymName (Sym);
   16387            6 :                 M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
   16388              :               }
   16389              :           }
   16390       100931 :         else if ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
   16391              :           {
   16392              :             /* avoid dangling else.  */
   16393       100931 :             if ((SymbolKey_GetSymKey (pSym->Module.WhereImported, Sym)) == SymbolKey_NulKey)
   16394              :               {
   16395       100931 :                 SymbolKey_PutSymKey (pSym->Module.WhereImported, Sym, M2LexBuf_GetTokenNo ());
   16396              :               }
   16397       100931 :             SymbolKey_PutSymKey (pSym->Module.ImportTree, SymbolTable_GetSymName (Sym), Sym);
   16398       100931 :             SymbolTable_AddSymToModuleScope (ModSym, Sym);
   16399              :           }
   16400              :         else
   16401              :           {
   16402              :             /* avoid dangling else.  */
   16403            0 :             n = SymbolTable_GetSymName (Sym);
   16404            0 :             M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
   16405              :           }
   16406              :         break;
   16407              : 
   16408       886781 :       case SymbolTable_DefImpSym:
   16409       886781 :         if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == Sym)
   16410              :           {
   16411              :             /* avoid dangling else.  */
   16412           88 :             if (M2Options_Pedantic)
   16413              :               {
   16414            0 :                 n = SymbolTable_GetSymName (Sym);
   16415            0 :                 M2Error_WriteFormat1 ((const char *) "symbol (%a) has already been imported", 37, (const unsigned char *) &n, (sizeof (n)-1));
   16416              :               }
   16417              :           }
   16418       886693 :         else if ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym))) == SymbolKey_NulKey)
   16419              :           {
   16420              :             /* avoid dangling else.  */
   16421       886693 :             if ((SymbolKey_GetSymKey (pSym->DefImp.WhereImported, Sym)) == SymbolKey_NulKey)
   16422              :               {
   16423       886693 :                 SymbolKey_PutSymKey (pSym->DefImp.WhereImported, Sym, M2LexBuf_GetTokenNo ());
   16424              :               }
   16425       886693 :             SymbolKey_PutSymKey (pSym->DefImp.ImportTree, SymbolTable_GetSymName (Sym), Sym);
   16426       886693 :             SymbolTable_AddSymToModuleScope (ModSym, Sym);
   16427              :           }
   16428              :         else
   16429              :           {
   16430              :             /* avoid dangling else.  */
   16431            0 :             n = SymbolTable_GetSymName (Sym);
   16432            0 :             M2Error_WriteFormat1 ((const char *) "name clash when trying to import (%a)", 37, (const unsigned char *) &n, (sizeof (n)-1));
   16433              :           }
   16434              :         break;
   16435              : 
   16436              : 
   16437            0 :       default:
   16438            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   16439       987802 :         break;
   16440              :     }
   16441       987802 : }
   16442              : 
   16443              : 
   16444              : /*
   16445              :    PutIncluded - places a symbol, Sym, into the included list of the
   16446              :                  current module.
   16447              :                  Symbols that are placed in this list are indirectly declared
   16448              :                  by:
   16449              : 
   16450              :                  IMPORT modulename ;
   16451              : 
   16452              :                  modulename.identifier
   16453              : */
   16454              : 
   16455       768852 : extern "C" void SymbolTable_PutIncluded (unsigned int Sym)
   16456              : {
   16457       768852 :   SymbolTable_PtrToSymbol pSym;
   16458       768852 :   unsigned int ModSym;
   16459       768852 :   NameKey_Name n1;
   16460       768852 :   NameKey_Name n2;
   16461              : 
   16462              :   /* 
   16463              :       We have referenced Sym, via modulename.Sym
   16464              :       now place it into the current module include list.
   16465              :   */
   16466       768852 :   ModSym = SymbolTable_GetCurrentModuleScope ();
   16467      1537704 :   M2Debug_Assert ((SymbolTable_IsDefImp (ModSym)) || (SymbolTable_IsModule (ModSym)));
   16468       768852 :   if (DebugUnknowns)
   16469              :     {
   16470              :       n1 = SymbolTable_GetSymName (Sym);
   16471              :       n2 = SymbolTable_GetSymName (ModSym);
   16472              :       M2Printf_printf2 ((const char *) "including %a into scope %a\\n", 28, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
   16473              :     }
   16474       768852 :   pSym = GetPsym (ModSym);
   16475       768852 :   switch (pSym->SymbolType)
   16476              :     {
   16477         4778 :       case SymbolTable_ModuleSym:
   16478         4778 :         Lists_IncludeItemIntoList (pSym->Module.IncludeList, Sym);
   16479         4778 :         break;
   16480              : 
   16481       764074 :       case SymbolTable_DefImpSym:
   16482       764074 :         Lists_IncludeItemIntoList (pSym->DefImp.IncludeList, Sym);
   16483       764074 :         break;
   16484              : 
   16485              : 
   16486            0 :       default:
   16487            0 :         M2Error_InternalError ((const char *) "expecting a Module or DefImp symbol", 35);
   16488       768852 :         break;
   16489              :     }
   16490       768852 : }
   16491              : 
   16492              : 
   16493              : /*
   16494              :    PutExported - places a symbol, Sym into the next level out module.
   16495              :                  Sym is also placed in the ExportTree of the current inner
   16496              :                  module.
   16497              : */
   16498              : 
   16499          276 : extern "C" void SymbolTable_PutExported (unsigned int Sym)
   16500              : {
   16501          276 :   SymbolTable_PtrToSymbol pSym;
   16502              : 
   16503              :   /* 
   16504              :    WriteString('PutExported') ; WriteLn ;
   16505              :   */
   16506          276 :   SymbolTable_AddSymToModuleScope (GetLastModuleOrProcedureScope (), Sym);
   16507          276 :   pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
   16508          276 :   switch (pSym->SymbolType)
   16509              :     {
   16510          276 :       case SymbolTable_ModuleSym:
   16511          276 :         SymbolKey_PutSymKey (pSym->Module.ExportTree, SymbolTable_GetSymName (Sym), Sym);
   16512          276 :         if (SymbolTable_IsUnknown (Sym))
   16513              :           {
   16514          276 :             PutExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
   16515              :           }
   16516              :         /* 
   16517              :                  ; WriteKey(Module.name) ; WriteString(' exports ') ;
   16518              :                  ; WriteKey(GetSymName(Sym)) ; WriteLn ;
   16519              :   */
   16520          276 :         break;
   16521              : 
   16522              : 
   16523            0 :       default:
   16524            0 :         M2Error_InternalError ((const char *) "expecting a Module symbol", 25);
   16525          276 :         break;
   16526              :     }
   16527          276 : }
   16528              : 
   16529              : 
   16530              : /*
   16531              :    PutExportQualified - places a symbol with the name, SymName,
   16532              :                         into the export tree of the
   16533              :                         Definition module being compiled.
   16534              :                         The symbol with name has been EXPORT QUALIFIED
   16535              :                         by the definition module and therefore any reference
   16536              :                         to this symbol in the code generation phase
   16537              :                         will be in the form _Module_Name.
   16538              : */
   16539              : 
   16540      3689451 : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName)
   16541              : {
   16542      3689451 :   SymbolTable_PtrToSymbol pSym;
   16543      3689451 :   NameKey_Name n;
   16544      3689451 :   unsigned int Sym;
   16545      3689451 :   unsigned int ModSym;
   16546              : 
   16547      3689451 :   ModSym = SymbolTable_GetCurrentModule ();
   16548      3689451 :   M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
   16549      7378902 :   M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
   16550              :   /* 
   16551              :    WriteString('1st MODULE ') ; WriteKey(GetSymName(ModSym)) ;
   16552              :    WriteString(' identifier ') ; WriteKey(SymName) ; WriteLn ;
   16553              :   */
   16554      3689451 :   pSym = GetPsym (ModSym);
   16555      3689451 :   switch (pSym->SymbolType)
   16556              :     {
   16557      3689451 :       case SymbolTable_DefImpSym:
   16558      3689451 :         if (((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
   16559              :           {
   16560            6 :             n = SymbolTable_GetSymName (ModSym);
   16561            6 :             M2Error_WriteFormat2 ((const char *) "identifier (%a) has already been exported from MODULE %a", 56, (const unsigned char *) &SymName, (sizeof (SymName)-1), (const unsigned char *) &n, (sizeof (n)-1));
   16562              :           }
   16563      3689445 :         else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
   16564              :           {
   16565              :             /* avoid dangling else.  */
   16566       300616 :             Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
   16567       300616 :             SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
   16568       300616 :             SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
   16569       300616 :             PutExportUndeclared (ModSym, Sym);
   16570              :           }
   16571              :         else
   16572              :           {
   16573              :             /* avoid dangling else.  */
   16574      3388829 :             Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
   16575      3388829 :             SymbolKey_PutSymKey (pSym->DefImp.ExportQualifiedTree, SymName, Sym);
   16576      3388829 :             PutExportUndeclared (ModSym, Sym);
   16577              :           }
   16578      3689451 :         break;
   16579              : 
   16580              : 
   16581            0 :       default:
   16582            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   16583      3689451 :         break;
   16584              :     }
   16585      3689451 : }
   16586              : 
   16587              : 
   16588              : /*
   16589              :    PutExportUnQualified - places a symbol with the name, SymName,
   16590              :                           into the export tree of the
   16591              :                           Definition module being compiled.
   16592              :                           The symbol with Name has been EXPORT UNQUALIFIED
   16593              :                           by the definition module and therefore any reference
   16594              :                           to this symbol in the code generation phase
   16595              :                           will be in the form _Name.
   16596              : */
   16597              : 
   16598       816224 : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName)
   16599              : {
   16600       816224 :   SymbolTable_PtrToSymbol pSym;
   16601       816224 :   NameKey_Name n;
   16602       816224 :   unsigned int Sym;
   16603       816224 :   unsigned int ModSym;
   16604              : 
   16605       816224 :   ModSym = SymbolTable_GetCurrentModule ();
   16606       816224 :   M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
   16607      1632448 :   M2Debug_Assert ((M2Comp_CompilingDefinitionModule ()) || ((SymbolTable_GetSymName (ModSym)) == (NameKey_MakeKey ((const char *) "SYSTEM", 6))));
   16608       816224 :   pSym = GetPsym (ModSym);
   16609       816224 :   switch (pSym->SymbolType)
   16610              :     {
   16611       816224 :       case SymbolTable_DefImpSym:
   16612       816224 :         if (((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) != SymbolKey_NulKey) && ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) == SymbolKey_NulKey))
   16613              :           {
   16614            0 :             n = SymbolTable_GetSymName (ModSym);
   16615            0 :             M2Error_WriteFormat2 ((const char *) "identifier (%a) has already been exported from MODULE %a", 56, (const unsigned char *) &SymName, (sizeof (SymName)-1), (const unsigned char *) &n, (sizeof (n)-1));
   16616              :           }
   16617       816224 :         else if ((SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName)) != SymbolKey_NulKey)
   16618              :           {
   16619              :             /* avoid dangling else.  */
   16620        24085 :             Sym = static_cast<unsigned int> (SymbolKey_GetSymKey (pSym->DefImp.ExportRequest, SymName));
   16621        24085 :             SymbolKey_DelSymKey (pSym->DefImp.ExportRequest, SymName);
   16622        24085 :             SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
   16623        24085 :             PutExportUndeclared (ModSym, Sym);
   16624              :           }
   16625              :         else
   16626              :           {
   16627              :             /* avoid dangling else.  */
   16628       792139 :             Sym = SymbolTable_GetDeclareSym (tokenno, SymName);
   16629       792139 :             SymbolKey_PutSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName, Sym);
   16630       792139 :             PutExportUndeclared (ModSym, Sym);
   16631              :           }
   16632       816224 :         break;
   16633              : 
   16634              : 
   16635            0 :       default:
   16636            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   16637       816224 :         break;
   16638              :     }
   16639       816224 : }
   16640              : 
   16641              : 
   16642              : /*
   16643              :    PutExportUnImplemented - places a symbol, Sym, into the currently compiled
   16644              :                             DefImp module NeedToBeImplemented list.
   16645              : */
   16646              : 
   16647      3301771 : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym)
   16648              : {
   16649      3301771 :   SymbolTable_PtrToSymbol pSym;
   16650              : 
   16651      3301771 :   pSym = GetPsym (CurrentModule);
   16652      3301771 :   switch (pSym->SymbolType)
   16653              :     {
   16654      3301771 :       case SymbolTable_DefImpSym:
   16655      3301771 :         if ((SymbolKey_GetSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym))) == Sym)
   16656              :           {
   16657              :             /* 
   16658              :                     n1 := GetSymName (Sym) ;
   16659              :                     n2 := GetSymName (CurrentModule) ;
   16660              :                     WriteFormat2 ('symbol (%a) already exported from module (%a)', n1, n2)
   16661              :   */
   16662            0 :             M2MetaError_MetaErrorT2 (tokenno, (const char *) "symbol {%1a} is already exported from module {%2a}", 50, Sym, CurrentModule);
   16663              :           }
   16664              :         else
   16665              :           {
   16666      3301771 :             SymbolKey_PutSymKey (pSym->DefImp.NeedToBeImplemented, SymbolTable_GetSymName (Sym), Sym);
   16667              :           }
   16668      3301771 :         break;
   16669              : 
   16670              : 
   16671            0 :       default:
   16672            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   16673      3301771 :         break;
   16674              :     }
   16675      3301771 : }
   16676              : 
   16677              : 
   16678              : /*
   16679              :    GetExported - returns the symbol which has a name SymName,
   16680              :                  and is exported from the definition module ModSym.
   16681              : 
   16682              : */
   16683              : 
   16684      2756358 : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName)
   16685              : {
   16686      2756358 :   SymbolTable_PtrToSymbol pSym;
   16687      2756358 :   unsigned int Sym;
   16688              : 
   16689      2756358 :   pSym = GetPsym (ModSym);
   16690      2756358 :   switch (pSym->SymbolType)
   16691              :     {
   16692      2756250 :       case SymbolTable_DefImpSym:
   16693      2756250 :         Sym = RequestFromDefinition (tokenno, ModSym, SymName);
   16694      2756250 :         break;
   16695              : 
   16696          108 :       case SymbolTable_ModuleSym:
   16697          108 :         Sym = RequestFromModule (tokenno, ModSym, SymName);
   16698          108 :         break;
   16699              : 
   16700              : 
   16701            0 :       default:
   16702            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   16703      2756358 :         break;
   16704              :     }
   16705      2756358 :   return Sym;
   16706              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16707              :   __builtin_unreachable ();
   16708              : }
   16709              : 
   16710              : 
   16711              : /*
   16712              :    GetFromOuterModule - returns a symbol with name, SymName, which comes
   16713              :                         from outside the current module.
   16714              : */
   16715              : 
   16716          340 : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName)
   16717              : {
   16718          340 :   SymbolTable_PtrToCallFrame pCall;
   16719          340 :   unsigned int ScopeId;
   16720          340 :   unsigned int Sym;
   16721          340 :   unsigned int ScopeSym;
   16722              : 
   16723          340 :   ScopeId = ScopePtr;
   16724          340 :   pCall = GetPcall (ScopeId);
   16725          704 :   while ((! (SymbolTable_IsModule (pCall->Search))) && (! (SymbolTable_IsDefImp (pCall->Search))))
   16726              :     {
   16727           24 :       M2Debug_Assert (ScopeId > 0);
   16728           24 :       ScopeId -= 1;
   16729           24 :       pCall = GetPcall (ScopeId);
   16730              :     }
   16731          340 :   ScopeId -= 1;
   16732              :   /* we are now below the current module  */
   16733          496 :   while (ScopeId > 0)
   16734              :     {
   16735          496 :       pCall = GetPcall (ScopeId);
   16736          496 :       ScopeSym = pCall->Search;
   16737          496 :       if (ScopeSym != SymbolTable_NulSym)
   16738              :         {
   16739          496 :           Sym = SymbolTable_GetLocalSym (ScopeSym, SymName);
   16740          496 :           if (Sym == SymbolTable_NulSym)
   16741              :             {
   16742              :               /* avoid dangling else.  */
   16743          172 :               if (((SymbolTable_IsModule (ScopeSym)) || (SymbolTable_IsProcedure (ScopeSym))) || (SymbolTable_IsDefImp (ScopeSym)))
   16744              :                 {
   16745          136 :                   if (Sym == SymbolTable_NulSym)
   16746              :                     {
   16747          136 :                       Sym = ExamineUnresolvedTree (ScopeSym, SymName);
   16748          136 :                       if (Sym != SymbolTable_NulSym)
   16749              :                         {
   16750              :                           return Sym;
   16751              :                         }
   16752              :                     }
   16753              :                 }
   16754              :             }
   16755              :           else
   16756              :             {
   16757              :               return Sym;
   16758              :             }
   16759              :         }
   16760          156 :       ScopeId -= 1;
   16761          156 :       pCall = GetPcall (ScopeId);
   16762              :     }
   16763              :   /* at this point we force an unknown from the last module scope  */
   16764            0 :   return RequestFromModule (tokenno, SymbolTable_GetLastModuleScope (), SymName);
   16765              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16766              :   __builtin_unreachable ();
   16767              : }
   16768              : 
   16769              : 
   16770              : /*
   16771              :    TryMoveUndeclaredSymToInnerModule - attempts to move a symbol of
   16772              :                                        name, name, which is
   16773              :                                        currently undefined in the
   16774              :                                        outer scope to the inner scope.
   16775              :                                        If successful then the symbol is
   16776              :                                        returned otherwise NulSym is
   16777              :                                        returned.
   16778              : */
   16779              : 
   16780          234 : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name)
   16781              : {
   16782          234 :   SymbolTable_PtrToSymbol pSym;
   16783          234 :   unsigned int sym;
   16784              : 
   16785              :   /* assume this should not be called if OuterScope was a procedure
   16786              :       as this case is handled by the caller (P1SymBuild)
   16787              :   */
   16788          468 :   M2Debug_Assert ((SymbolTable_IsModule (OuterScope)) || (SymbolTable_IsDefImp (OuterScope)));
   16789          234 :   sym = GetExportUndeclared (OuterScope, name);
   16790          234 :   if (sym != SymbolTable_NulSym)
   16791              :     {
   16792           18 :       M2Debug_Assert (SymbolTable_IsUnknown (sym));
   16793           18 :       RemoveExportUndeclared (OuterScope, sym);
   16794           18 :       SymbolTable_AddSymToModuleScope (OuterScope, sym);
   16795           18 :       AddVarToScopeList (OuterScope, sym);
   16796           18 :       pSym = GetPsym (OuterScope);
   16797           18 :       switch (pSym->SymbolType)
   16798              :         {
   16799            0 :           case SymbolTable_DefImpSym:
   16800            0 :             if ((SymbolKey_GetSymKey (pSym->DefImp.Unresolved, name)) == sym)
   16801              :               {
   16802            0 :                 SymbolKey_DelSymKey (pSym->DefImp.Unresolved, name);
   16803              :               }
   16804              :             break;
   16805              : 
   16806           18 :           case SymbolTable_ModuleSym:
   16807           18 :             if ((SymbolKey_GetSymKey (pSym->Module.Unresolved, name)) == sym)
   16808              :               {
   16809           18 :                 SymbolKey_DelSymKey (pSym->Module.Unresolved, name);
   16810              :               }
   16811              :             break;
   16812              : 
   16813              : 
   16814            0 :           default:
   16815            0 :             M2Error_InternalError ((const char *) "expecting DefImp, Module symbol", 31);
   16816           18 :             break;
   16817              :         }
   16818           18 :       AddSymToUnknown (InnerScope, name, sym);
   16819           18 :       PutExportUndeclared (InnerScope, sym);
   16820              :     }
   16821          234 :   return sym;
   16822              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16823              :   __builtin_unreachable ();
   16824              : }
   16825              : 
   16826              : 
   16827              : /*
   16828              :    IsExportQualified - returns true if a symbol, Sym, was defined as
   16829              :                        being EXPORT QUALIFIED.
   16830              :                        Sym is expected to be either a procedure or a
   16831              :                        variable.
   16832              : */
   16833              : 
   16834      8238184 : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym)
   16835              : {
   16836      8238184 :   SymbolTable_PtrToSymbol pSym;
   16837      8238184 :   unsigned int OuterModule;
   16838              : 
   16839      8238184 :   OuterModule = Sym;
   16840      8903784 :   do {
   16841      8903784 :     OuterModule = SymbolTable_GetScope (OuterModule);
   16842      8903784 :   } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
   16843      8238184 :   pSym = GetPsym (OuterModule);
   16844      8238184 :   switch (pSym->SymbolType)
   16845              :     {
   16846              :       case SymbolTable_ModuleSym:
   16847              :         return false;
   16848      7781469 :         break;
   16849              : 
   16850      7781469 :       case SymbolTable_DefImpSym:
   16851      7781469 :         return (SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
   16852            0 :         break;
   16853              : 
   16854              : 
   16855            0 :       default:
   16856            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   16857              :         break;
   16858              :     }
   16859              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   16860              :   __builtin_unreachable ();
   16861              : }
   16862              : 
   16863              : 
   16864              : /*
   16865              :    IsExportUnQualified - returns true if a symbol, Sym, was defined as
   16866              :                          being EXPORT UNQUALIFIED.
   16867              : */
   16868              : 
   16869      4050988 : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym)
   16870              : {
   16871      4050988 :   SymbolTable_PtrToSymbol pSym;
   16872      4050988 :   unsigned int OuterModule;
   16873              : 
   16874      4050988 :   OuterModule = Sym;
   16875      4050988 :   do {
   16876      4050988 :     OuterModule = SymbolTable_GetScope (OuterModule);
   16877      4050988 :   } while (! ((SymbolTable_GetScope (OuterModule)) == SymbolTable_NulSym));
   16878      4050988 :   pSym = GetPsym (OuterModule);
   16879      4050988 :   switch (pSym->SymbolType)
   16880              :     {
   16881              :       case SymbolTable_ModuleSym:
   16882              :         return false;
   16883      3975446 :         break;
   16884              : 
   16885      3975446 :       case SymbolTable_DefImpSym:
   16886      3975446 :         return (SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymbolTable_GetSymName (Sym))) == Sym;
   16887            0 :         break;
   16888              : 
   16889              : 
   16890            0 :       default:
   16891            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   16892              :         break;
   16893              :     }
   16894              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   16895              :   __builtin_unreachable ();
   16896              : }
   16897              : 
   16898              : 
   16899              : /*
   16900              :    IsExported - returns true if a symbol, Sym, is exported
   16901              :                 from module, ModSym.
   16902              :                 If ModSym is a DefImp symbol then its
   16903              :                 ExportQualified and ExportUnQualified lists are examined.
   16904              : */
   16905              : 
   16906      8509402 : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym)
   16907              : {
   16908      8509402 :   SymbolTable_PtrToSymbol pSym;
   16909      8509402 :   NameKey_Name SymName;
   16910              : 
   16911      8509402 :   SymName = SymbolTable_GetSymName (Sym);
   16912      8509402 :   pSym = GetPsym (ModSym);
   16913      8509402 :   switch (pSym->SymbolType)
   16914              :     {
   16915      7976184 :       case SymbolTable_DefImpSym:
   16916      7976184 :         return ((SymbolKey_GetSymKey (pSym->DefImp.ExportQualifiedTree, SymName)) == Sym) || ((SymbolKey_GetSymKey (pSym->DefImp.ExportUnQualifiedTree, SymName)) == Sym);
   16917       533218 :         break;
   16918              : 
   16919       533218 :       case SymbolTable_ModuleSym:
   16920       533218 :         return (SymbolKey_GetSymKey (pSym->Module.ExportTree, SymName)) == Sym;
   16921            0 :         break;
   16922              : 
   16923              : 
   16924            0 :       default:
   16925            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   16926              :         break;
   16927              :     }
   16928              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   16929              :   __builtin_unreachable ();
   16930              : }
   16931              : 
   16932              : 
   16933              : /*
   16934              :    IsImplicityExported - returns TRUE if, Sym, is implicitly exported from module, ModSym.
   16935              :                          ModSym must be a defimp symbol.
   16936              : */
   16937              : 
   16938           90 : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym)
   16939              : {
   16940           90 :   unsigned int type;
   16941           90 :   SymbolTable_PtrToSymbol pSym;
   16942              : 
   16943           90 :   if ((SymbolTable_IsDefImp (ModSym)) && (SymbolTable_IsFieldEnumeration (Sym)))
   16944              :     {
   16945           66 :       pSym = GetPsym (ModSym);
   16946           66 :       type = SymbolTable_SkipType (SymbolTable_GetType (Sym));
   16947           66 :       return Lists_IsItemInList (pSym->DefImp.EnumerationScopeList, type);
   16948              :     }
   16949              :   return false;
   16950              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   16951              :   __builtin_unreachable ();
   16952              : }
   16953              : 
   16954              : 
   16955              : /*
   16956              :    IsImported - returns true if a symbol, Sym, in module, ModSym,
   16957              :                 was imported.
   16958              : */
   16959              : 
   16960     34211580 : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym)
   16961              : {
   16962     34211580 :   SymbolTable_PtrToSymbol pSym;
   16963     34211580 :   NameKey_Name SymName;
   16964              : 
   16965     34211580 :   SymName = SymbolTable_GetSymName (Sym);
   16966     34211580 :   pSym = GetPsym (ModSym);
   16967     34211580 :   switch (pSym->SymbolType)
   16968              :     {
   16969     22390180 :       case SymbolTable_DefImpSym:
   16970     22390180 :         return ((SymbolKey_GetSymKey (pSym->DefImp.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->DefImp.IncludeList, Sym));
   16971     11821400 :         break;
   16972              : 
   16973     11821400 :       case SymbolTable_ModuleSym:
   16974     11821400 :         return ((SymbolKey_GetSymKey (pSym->Module.ImportTree, SymName)) == Sym) || (Lists_IsItemInList (pSym->Module.IncludeList, Sym));
   16975            0 :         break;
   16976              : 
   16977              : 
   16978            0 :       default:
   16979            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   16980              :         break;
   16981              :     }
   16982              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   16983              :   __builtin_unreachable ();
   16984              : }
   16985              : 
   16986              : 
   16987              : /*
   16988              :    PutIncludedByDefinition - places a module symbol, Sym, into the
   16989              :                              included list of the current definition module.
   16990              : */
   16991              : 
   16992        10013 : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym)
   16993              : {
   16994        10013 :   SymbolTable_PtrToSymbol pSym;
   16995        10013 :   unsigned int ModSym;
   16996              : 
   16997        10013 :   ModSym = SymbolTable_GetCurrentModuleScope ();
   16998        10013 :   M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
   16999        10013 :   M2Debug_Assert (SymbolTable_IsDefImp (Sym));
   17000        10013 :   pSym = GetPsym (ModSym);
   17001        10013 :   switch (pSym->SymbolType)
   17002              :     {
   17003        10013 :       case SymbolTable_DefImpSym:
   17004        10013 :         Lists_IncludeItemIntoList (pSym->DefImp.DefIncludeList, Sym);
   17005        10013 :         break;
   17006              : 
   17007              : 
   17008            0 :       default:
   17009            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   17010        10013 :         break;
   17011              :     }
   17012        10013 : }
   17013              : 
   17014              : 
   17015              : /*
   17016              :    IsIncludedByDefinition - returns TRUE if definition module symbol, Sym, was included
   17017              :                             by ModSym's definition module.
   17018              : */
   17019              : 
   17020           12 : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym)
   17021              : {
   17022           12 :   SymbolTable_PtrToSymbol pSym;
   17023              : 
   17024           12 :   M2Debug_Assert (SymbolTable_IsDefImp (ModSym));
   17025           12 :   M2Debug_Assert (SymbolTable_IsDefImp (Sym));
   17026           12 :   pSym = GetPsym (ModSym);
   17027           12 :   switch (pSym->SymbolType)
   17028              :     {
   17029           12 :       case SymbolTable_DefImpSym:
   17030           12 :         return Lists_IsItemInList (pSym->DefImp.DefIncludeList, Sym);
   17031            0 :         break;
   17032              : 
   17033              : 
   17034            0 :       default:
   17035            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   17036              :         break;
   17037              :     }
   17038              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   17039              :   __builtin_unreachable ();
   17040              : }
   17041              : 
   17042              : 
   17043              : /*
   17044              :    ForeachImportedDo - calls a procedure, P, foreach imported symbol
   17045              :                        in module, ModSym.
   17046              : */
   17047              : 
   17048        14408 : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
   17049              : {
   17050        14408 :   SymbolTable_PtrToSymbol pSym;
   17051              : 
   17052        14408 :   pSym = GetPsym (ModSym);
   17053        14408 :   switch (pSym->SymbolType)
   17054              :     {
   17055         3513 :       case SymbolTable_DefImpSym:
   17056         3513 :         SymbolKey_ForeachNodeDo (pSym->DefImp.ImportTree, P);
   17057         3513 :         Lists_ForeachItemInListDo (pSym->DefImp.IncludeList, P);
   17058         3513 :         break;
   17059              : 
   17060        10895 :       case SymbolTable_ModuleSym:
   17061        10895 :         SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, P);
   17062        10895 :         Lists_ForeachItemInListDo (pSym->Module.IncludeList, P);
   17063        10895 :         break;
   17064              : 
   17065              : 
   17066            0 :       default:
   17067            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   17068        14408 :         break;
   17069              :     }
   17070        14408 : }
   17071              : 
   17072              : 
   17073              : /*
   17074              :    ForeachExportedDo - calls a procedure, P, foreach imported symbol
   17075              :                        in module, ModSym.
   17076              : */
   17077              : 
   17078         8756 : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P)
   17079              : {
   17080         8756 :   SymbolTable_PtrToSymbol pSym;
   17081              : 
   17082         8756 :   pSym = GetPsym (ModSym);
   17083         8756 :   switch (pSym->SymbolType)
   17084              :     {
   17085         3359 :       case SymbolTable_DefImpSym:
   17086         3359 :         SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, P);
   17087         3359 :         SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, P);
   17088         3359 :         break;
   17089              : 
   17090         5397 :       case SymbolTable_ModuleSym:
   17091         5397 :         SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, P);
   17092         5397 :         break;
   17093              : 
   17094              : 
   17095            0 :       default:
   17096            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   17097         8756 :         break;
   17098              :     }
   17099         8756 : }
   17100              : 
   17101              : 
   17102              : /*
   17103              :    CheckForExportedImplementation - checks to see whether an implementation
   17104              :                                     module is currently being compiled, if so,
   17105              :                                     symbol, Sym, is removed from the
   17106              :                                     NeedToBeImplemented list.
   17107              :                                     This procedure is called whenever a symbol
   17108              :                                     is declared, thus attempting to reduce
   17109              :                                     the NeedToBeImplemented list.
   17110              :                                     Only needs to be called when a TYPE or
   17111              :                                     PROCEDURE is built since the implementation
   17112              :                                     module can only implement these objects
   17113              :                                     declared in the definition module.
   17114              : 
   17115              :                                     It also checks whether a definition module
   17116              :                                     is currently being compiled and, if so,
   17117              :                                     it will ensure that symbol, Sym, is removed
   17118              :                                     from the ExportRequest list. If Sym is an
   17119              :                                     enumerated type it ensures that its fields
   17120              :                                     are also removed.
   17121              : */
   17122              : 
   17123      2378564 : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym)
   17124              : {
   17125      2378564 :   if (M2Comp_CompilingImplementationModule ())
   17126              :     {
   17127      2233569 :       RemoveExportUnImplemented (SymbolTable_GetCurrentModule (), Sym);
   17128              :     }
   17129      2378564 :   if ((M2Comp_CompilingDefinitionModule ()) && (SymbolTable_IsEnumeration (Sym)))
   17130              :     {
   17131        18779 :       RemoveEnumerationFromExportRequest (SymbolTable_GetCurrentModule (), Sym);
   17132              :     }
   17133      2378564 : }
   17134              : 
   17135              : 
   17136              : /*
   17137              :    CheckForUnImplementedExports - displays an error and the offending symbols
   17138              :                                   which have been exported but not implemented
   17139              :                                   from the current compiled module.
   17140              : */
   17141              : 
   17142        70785 : extern "C" void SymbolTable_CheckForUnImplementedExports (void)
   17143              : {
   17144        70785 :   SymbolTable_PtrToSymbol pSym;
   17145              : 
   17146              :   /* WriteString('Inside CheckForImplementedExports') ; WriteLn ;  */
   17147        70785 :   pSym = GetPsym (CurrentModule);
   17148        70785 :   switch (pSym->SymbolType)
   17149              :     {
   17150        70785 :       case SymbolTable_DefImpSym:
   17151        70785 :         if (! (SymbolKey_IsEmptyTree (pSym->DefImp.NeedToBeImplemented)))
   17152              :           {
   17153            0 :             CurrentError = M2Error_NewError (M2LexBuf_GetTokenNo ());
   17154            0 :             M2Error_ErrorFormat1 (CurrentError, (const char *) "unimplemented identifier(s) in EXPORT list of DEFINITION MODULE %a\\nthe implementation module fails to implement the following exported identifier(s)", 149, (const unsigned char *) &pSym->DefImp.name, (sizeof (pSym->DefImp.name)-1));
   17155            0 :             SymbolKey_ForeachNodeDo (pSym->DefImp.NeedToBeImplemented, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UnImplementedSymbolError});
   17156              :           }
   17157        70785 :         break;
   17158              : 
   17159              : 
   17160            0 :       default:
   17161            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   17162        70785 :         break;
   17163              :     }
   17164        70785 : }
   17165              : 
   17166              : 
   17167              : /*
   17168              :    CheckForUndeclaredExports - displays an error and the offending symbols
   17169              :                                which have been exported but not declared
   17170              :                                from module, ModSym.
   17171              : */
   17172              : 
   17173       173413 : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym)
   17174              : {
   17175       173413 :   SymbolTable_PtrToSymbol pSym;
   17176              : 
   17177              :   /* WriteString('Inside CheckForUndeclaredExports') ; WriteLn ;  */
   17178       173413 :   pSym = GetPsym (ModSym);
   17179       173413 :   switch (pSym->SymbolType)
   17180              :     {
   17181        12125 :       case SymbolTable_ModuleSym:
   17182        12125 :         if (! (SymbolKey_IsEmptyTree (pSym->Module.ExportUndeclared)))
   17183              :           {
   17184            0 :             M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in EXPORT list of {%1ERd} {%1a}", 56, ModSym);
   17185            0 :             SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
   17186              :           }
   17187              :         break;
   17188              : 
   17189       161288 :       case SymbolTable_DefImpSym:
   17190       161288 :         if (! (SymbolKey_IsEmptyTree (pSym->DefImp.ExportUndeclared)))
   17191              :           {
   17192            0 :             if (SymbolTable_DoesNotNeedExportList (ModSym))
   17193              :               {
   17194            0 :                 M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in {%1ERd} {%1a}", 41, ModSym);
   17195              :               }
   17196              :             else
   17197              :               {
   17198            0 :                 M2MetaError_MetaError1 ((const char *) "undeclared identifier(s) in export list of {%1ERd} {%1a}", 56, ModSym);
   17199              :               }
   17200            0 :             SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) UndeclaredSymbolError});
   17201              :           }
   17202              :         break;
   17203              : 
   17204              : 
   17205            0 :       default:
   17206            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   17207       173413 :         break;
   17208              :     }
   17209       173413 : }
   17210              : 
   17211              : 
   17212              : /*
   17213              :    CheckForUnknownInModule - checks for any unknown symbols in the
   17214              :                              current module.
   17215              :                              If any unknown symbols are found then
   17216              :                              an error message is displayed.
   17217              : */
   17218              : 
   17219       486297 : extern "C" void SymbolTable_CheckForUnknownInModule (unsigned int tokno)
   17220              : {
   17221       486297 :   SymbolTable_PtrToSymbol pSym;
   17222              : 
   17223       486297 :   pSym = GetPsym (SymbolTable_GetCurrentModuleScope ());
   17224       486297 :   switch (pSym->SymbolType)
   17225              :     {
   17226       462398 :       case SymbolTable_DefImpSym:
   17227       462398 :         CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.ExportQualifiedTree, (const char *) "EXPORT QUALIFIED", 16);
   17228       462398 :         CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.ExportUnQualifiedTree, (const char *) "EXPORT UNQUALIFIED", 18);
   17229       462398 :         CheckForSymbols (pSym->DefImp.ExportRequest, (const char *) "requested by another module import and the symbol has not been exported by the appropriate definition module", 108);
   17230       462398 :         CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.Unresolved, (const char *) "unresolved", 10);
   17231       462398 :         CheckForUnknowns (tokno, pSym->DefImp.name, pSym->DefImp.LocalSymbols, (const char *) "locally used", 12);
   17232       462398 :         break;
   17233              : 
   17234        23899 :       case SymbolTable_ModuleSym:
   17235        23899 :         CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.Unresolved, (const char *) "unresolved", 10);
   17236        23899 :         CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.ExportUndeclared, (const char *) "exported but undeclared", 23);
   17237        23899 :         CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.ExportTree, (const char *) "exported but undeclared", 23);
   17238        23899 :         CheckForUnknowns (tokno, pSym->Module.name, pSym->Module.LocalSymbols, (const char *) "locally used", 12);
   17239        23899 :         break;
   17240              : 
   17241              : 
   17242            0 :       default:
   17243            0 :         M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   17244       486297 :         break;
   17245              :     }
   17246       486297 : }
   17247              : 
   17248              : 
   17249              : /*
   17250              :    UnknownReported - if sym is an unknown symbol and has not been reported
   17251              :                      then include it into the set of reported unknowns.
   17252              : */
   17253              : 
   17254           54 : extern "C" void SymbolTable_UnknownReported (unsigned int sym)
   17255              : {
   17256           54 :   if (IsUnreportedUnknown (sym))
   17257              :     {
   17258           54 :       Sets_IncludeElementIntoSet (ReportedUnknowns, sym);
   17259              :     }
   17260           54 : }
   17261              : 
   17262              : 
   17263              : /*
   17264              :    GetUnknownOnImport - returns the onimport field of unknown sym.
   17265              : */
   17266              : 
   17267          243 : extern "C" bool SymbolTable_GetUnknownOnImport (unsigned int sym)
   17268              : {
   17269          243 :   SymbolTable_PtrToSymbol pSym;
   17270              : 
   17271          243 :   M2Debug_Assert (SymbolTable_IsUnknown (sym));
   17272          243 :   pSym = GetPsym (sym);
   17273          243 :   return pSym->Undefined.onImport;
   17274              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   17275              :   __builtin_unreachable ();
   17276              : }
   17277              : 
   17278              : 
   17279              : /*
   17280              :    GetUnknownDeclScope - returns the decl scope of unknown sym.
   17281              : */
   17282              : 
   17283            6 : extern "C" unsigned int SymbolTable_GetUnknownDeclScope (unsigned int sym)
   17284              : {
   17285            6 :   SymbolTable_PtrToSymbol pSym;
   17286              : 
   17287            6 :   M2Debug_Assert (SymbolTable_IsUnknown (sym));
   17288            6 :   pSym = GetPsym (sym);
   17289            6 :   return pSym->Undefined.declScope;
   17290              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   17291              :   __builtin_unreachable ();
   17292              : }
   17293              : 
   17294              : 
   17295              : /*
   17296              :    IsReallyPointer - returns TRUE is sym is a pointer, address or a
   17297              :                      type declared as a pointer or address.
   17298              : */
   17299              : 
   17300       774046 : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym)
   17301              : {
   17302       774046 :   if (SymbolTable_IsVar (Sym))
   17303              :     {
   17304       230637 :       Sym = SymbolTable_GetType (Sym);
   17305              :     }
   17306       774046 :   Sym = SymbolTable_SkipType (Sym);
   17307       774046 :   return ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address)) || (SymbolTable_IsHiddenReallyPointer (Sym));
   17308              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   17309              :   __builtin_unreachable ();
   17310              : }
   17311              : 
   17312              : 
   17313              : /*
   17314              :    CheckHiddenTypeAreAddress - checks to see that any hidden types
   17315              :                                which we have declared are actually
   17316              :                                of type ADDRESS or map onto a POINTER type.
   17317              : */
   17318              : 
   17319        13940 : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void)
   17320              : {
   17321        13940 :   NameKey_Name name;
   17322        13940 :   M2Error_Error e;
   17323        13940 :   unsigned int sym;
   17324        13940 :   unsigned int i;
   17325        13940 :   unsigned int n;
   17326              : 
   17327        13940 :   i = 1;
   17328        13940 :   n = Lists_NoOfItemsInList (AddressTypes);
   17329        54040 :   while (i <= n)
   17330              :     {
   17331        26160 :       sym = static_cast<unsigned int> (Lists_GetItemFromList (AddressTypes, i));
   17332        26160 :       if (! (SymbolTable_IsHiddenReallyPointer (sym)))
   17333              :         {
   17334            6 :           name = SymbolTable_GetSymName (sym);
   17335            6 :           e = M2Error_NewError (SymbolTable_GetDeclaredDef (sym));
   17336            6 :           M2Error_ErrorFormat1 (e, (const char *) "opaque type (%a) should be equivalent to a POINTER or an ADDRESS", 64, (const unsigned char *) &name, (sizeof (name)-1));
   17337            6 :           e = M2Error_NewError (SymbolTable_GetDeclaredMod (sym));
   17338            6 :           M2Error_ErrorFormat0 (e, (const char *) "if you really need a non POINTER type use the -fextended-opaque switch", 70);
   17339              :         }
   17340        26160 :       i += 1;
   17341              :     }
   17342        13940 : }
   17343              : 
   17344              : 
   17345              : /*
   17346              :    PutDefinitionForC - sets a flag in the current compiled module which
   17347              :                        indicates that this module is a wrapper for a C
   17348              :                        file. Parameters passes to procedures in this module
   17349              :                        will adopt the C calling convention.
   17350              : */
   17351              : 
   17352        26200 : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym)
   17353              : {
   17354        26200 :   SymbolTable_PtrToSymbol pSym;
   17355              : 
   17356        26200 :   pSym = GetPsym (Sym);
   17357        26200 :   switch (pSym->SymbolType)
   17358              :     {
   17359        26200 :       case SymbolTable_DefImpSym:
   17360        26200 :         pSym->DefImp.ForC = true;
   17361        26200 :         break;
   17362              : 
   17363              : 
   17364            0 :       default:
   17365            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   17366        26200 :         break;
   17367              :     }
   17368        26200 : }
   17369              : 
   17370              : 
   17371              : /*
   17372              :    IsDefinitionForC - returns true if this definition module was declared
   17373              :                       as a DEFINITION MODULE FOR "C".
   17374              : */
   17375              : 
   17376      1209008 : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym)
   17377              : {
   17378      1209008 :   SymbolTable_PtrToSymbol pSym;
   17379              : 
   17380      1209008 :   pSym = GetPsym (Sym);
   17381      1209008 :   switch (pSym->SymbolType)
   17382              :     {
   17383      1209008 :       case SymbolTable_DefImpSym:
   17384      1209008 :         return pSym->DefImp.ForC;
   17385            0 :         break;
   17386              : 
   17387              : 
   17388            0 :       default:
   17389            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   17390              :         break;
   17391              :     }
   17392              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   17393              :   __builtin_unreachable ();
   17394              : }
   17395              : 
   17396              : 
   17397              : /*
   17398              :    PutDoesNeedExportList - sets a flag in module, Sym, which
   17399              :                            indicates that this module requires an explicit
   17400              :                            EXPORT QUALIFIED or UNQUALIFIED list. PIM-2
   17401              : */
   17402              : 
   17403        85402 : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym)
   17404              : {
   17405        85402 :   SymbolTable_PtrToSymbol pSym;
   17406              : 
   17407        85402 :   pSym = GetPsym (Sym);
   17408        85402 :   switch (pSym->SymbolType)
   17409              :     {
   17410        85402 :       case SymbolTable_DefImpSym:
   17411        85402 :         pSym->DefImp.NeedExportList = true;
   17412        85402 :         break;
   17413              : 
   17414              : 
   17415            0 :       default:
   17416            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   17417        85402 :         break;
   17418              :     }
   17419        85402 : }
   17420              : 
   17421              : 
   17422              : /*
   17423              :    PutDoesNotNeedExportList - sets a flag in module, Sym, which
   17424              :                               indicates that this module does not require an explicit
   17425              :                               EXPORT QUALIFIED or UNQUALIFIED list. PIM-3|4
   17426              : */
   17427              : 
   17428       161456 : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym)
   17429              : {
   17430       161456 :   SymbolTable_PtrToSymbol pSym;
   17431              : 
   17432       161456 :   pSym = GetPsym (Sym);
   17433       161456 :   switch (pSym->SymbolType)
   17434              :     {
   17435       161456 :       case SymbolTable_DefImpSym:
   17436       161456 :         pSym->DefImp.NeedExportList = false;
   17437       161456 :         break;
   17438              : 
   17439              : 
   17440            0 :       default:
   17441            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   17442       161456 :         break;
   17443              :     }
   17444       161456 : }
   17445              : 
   17446              : 
   17447              : /*
   17448              :    DoesNotNeedExportList - returns TRUE if module, Sym, does not require an explicit
   17449              :                            EXPORT QUALIFIED list.
   17450              : */
   17451              : 
   17452      4018269 : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym)
   17453              : {
   17454      4018269 :   SymbolTable_PtrToSymbol pSym;
   17455              : 
   17456      4018269 :   pSym = GetPsym (Sym);
   17457      4018269 :   switch (pSym->SymbolType)
   17458              :     {
   17459      4018269 :       case SymbolTable_DefImpSym:
   17460      4018269 :         return ! pSym->DefImp.NeedExportList;
   17461            0 :         break;
   17462              : 
   17463              : 
   17464            0 :       default:
   17465            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   17466              :         break;
   17467              :     }
   17468              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   17469              :   __builtin_unreachable ();
   17470              : }
   17471              : 
   17472              : 
   17473              : /*
   17474              :    CheckForEnumerationInCurrentModule - checks to see whether the enumeration
   17475              :                                         type symbol, Sym, has been entered into
   17476              :                                         the current modules scope list.
   17477              : */
   17478              : 
   17479      1697654 : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym)
   17480              : {
   17481      1697654 :   SymbolTable_PtrToSymbol pSym;
   17482      1697654 :   unsigned int ModSym;
   17483              : 
   17484      1697654 :   if (((SymbolTable_SkipType (Sym)) != SymbolTable_NulSym) && (SymbolTable_IsEnumeration (SymbolTable_SkipType (Sym))))
   17485              :     {
   17486        17670 :       Sym = SymbolTable_SkipType (Sym);
   17487              :     }
   17488      1697654 :   if (SymbolTable_IsEnumeration (Sym))
   17489              :     {
   17490        17670 :       ModSym = SymbolTable_GetCurrentModuleScope ();
   17491        17670 :       pSym = GetPsym (ModSym);
   17492        17670 :       switch (pSym->SymbolType)
   17493              :         {
   17494        17268 :           case SymbolTable_DefImpSym:
   17495        17268 :             CheckEnumerationInList (pSym->DefImp.EnumerationScopeList, Sym);
   17496        17268 :             break;
   17497              : 
   17498          402 :           case SymbolTable_ModuleSym:
   17499          402 :             CheckEnumerationInList (pSym->Module.EnumerationScopeList, Sym);
   17500          402 :             break;
   17501              : 
   17502              : 
   17503            0 :           default:
   17504            0 :             M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   17505              :             break;
   17506              :         }
   17507              :     }
   17508      1697654 : }
   17509              : 
   17510              : 
   17511              : /*
   17512              :    SanityCheckConstants - must only be called once all constants, types, procedures
   17513              :                           have been declared.  It checks to see that constants are
   17514              :                           not used as procedure parameter types.
   17515              : */
   17516              : 
   17517        14658 : extern "C" void SymbolTable_SanityCheckConstants (void)
   17518              : {
   17519        14658 :   SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckModule});
   17520        14658 :   ForeachSymbolDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SanityCheckArray});
   17521        14658 : }
   17522              : 
   17523              : 
   17524              : /*
   17525              :    ForeachLocalSymDo - foreach local symbol in module, Sym, or procedure, Sym,
   17526              :                        perform the procedure, P.
   17527              : */
   17528              : 
   17529     13294276 : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
   17530              : {
   17531     13294276 :   SymbolTable_PtrToSymbol pSym;
   17532              : 
   17533     13294276 :   pSym = GetPsym (Sym);
   17534     13294276 :   switch (pSym->SymbolType)
   17535              :     {
   17536       594114 :       case SymbolTable_DefImpSym:
   17537       594114 :         SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, P);
   17538       594114 :         break;
   17539              : 
   17540        92681 :       case SymbolTable_ModuleSym:
   17541        92681 :         SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, P);
   17542        92681 :         break;
   17543              : 
   17544       252124 :       case SymbolTable_ProcedureSym:
   17545       252124 :         SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, P);
   17546       252124 :         break;
   17547              : 
   17548            0 :       case SymbolTable_RecordSym:
   17549            0 :         SymbolKey_ForeachNodeDo (pSym->Record.LocalSymbols, P);
   17550            0 :         break;
   17551              : 
   17552     12355357 :       case SymbolTable_EnumerationSym:
   17553     12355357 :         SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
   17554     12355357 :         break;
   17555              : 
   17556              : 
   17557            0 :       default:
   17558            0 :         M2Error_InternalError ((const char *) "expecting a DefImp, Module or Procedure symbol", 46);
   17559     13294276 :         break;
   17560              :     }
   17561     13294276 : }
   17562              : 
   17563              : 
   17564              : /*
   17565              :    ForeachParamSymDo - foreach parameter symbol in procedure Sym
   17566              :                        perform the procedure P.  Each symbol
   17567              :                        looked up will be VarParam or Param
   17568              :                        (not the shadow variable).  Every parameter
   17569              :                        from each KindProcedure is iterated over.
   17570              : */
   17571              : 
   17572      1918073 : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P)
   17573              : {
   17574      1918073 :   SymbolTable_ProcedureKind kind;
   17575      1918073 :   unsigned int param;
   17576      1918073 :   unsigned int p;
   17577      1918073 :   unsigned int i;
   17578              : 
   17579      1918073 :   if (SymbolTable_IsProcedure (Sym))
   17580              :     {
   17581      7613868 :       for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
   17582              :         {
   17583      5710401 :           p = SymbolTable_NoOfParam (Sym, kind);
   17584      5710401 :           i = p;
   17585     17367587 :           while (i > 0)
   17586              :             {
   17587      5946785 :               param = SymbolTable_GetNthParam (Sym, kind, i);
   17588      5946785 :               (*P.proc) (param);
   17589      5946785 :               i -= 1;
   17590              :             }
   17591              :         }
   17592              :     }
   17593      1918073 : }
   17594              : 
   17595              : 
   17596              : /*
   17597              :    ForeachFieldEnumerationDo - for each field in enumeration, Sym,
   17598              :                                do procedure, P.  Each call to P contains
   17599              :                                an enumeration field, the order is alphabetical.
   17600              :                                Use ForeachLocalSymDo for declaration order.
   17601              : */
   17602              : 
   17603        92027 : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P)
   17604              : {
   17605        92027 :   SymbolTable_PtrToSymbol pSym;
   17606              : 
   17607        92027 :   pSym = GetPsym (Sym);
   17608        92027 :   switch (pSym->SymbolType)
   17609              :     {
   17610        92027 :       case SymbolTable_EnumerationSym:
   17611        92027 :         SymbolKey_ForeachNodeDo (pSym->Enumeration.LocalSymbols, P);
   17612        92027 :         break;
   17613              : 
   17614              : 
   17615            0 :       default:
   17616            0 :         M2Error_InternalError ((const char *) "expecting Enumeration symbol", 28);
   17617        92027 :         break;
   17618              :     }
   17619        92027 : }
   17620              : 
   17621              : 
   17622              : /*
   17623              :    IsType - returns true if the Sym is a type symbol.
   17624              : */
   17625              : 
   17626   1655589184 : extern "C" bool SymbolTable_IsType (unsigned int Sym)
   17627              : {
   17628   1655589184 :   SymbolTable_PtrToSymbol pSym;
   17629              : 
   17630   1655589184 :   pSym = GetPsym (Sym);
   17631   1655589184 :   return pSym->SymbolType == SymbolTable_TypeSym;
   17632              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   17633              :   __builtin_unreachable ();
   17634              : }
   17635              : 
   17636              : 
   17637              : /*
   17638              :    IsProcedure - returns true if Sym is a procedure symbol.
   17639              : */
   17640              : 
   17641    425789545 : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym)
   17642              : {
   17643    425789545 :   SymbolTable_PtrToSymbol pSym;
   17644              : 
   17645    425789545 :   AssertInRange (Sym);
   17646    425789545 :   pSym = GetPsym (Sym);
   17647    425789545 :   return pSym->SymbolType == SymbolTable_ProcedureSym;
   17648              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   17649              :   __builtin_unreachable ();
   17650              : }
   17651              : 
   17652              : 
   17653              : /*
   17654              :    IsParameter - returns true if Sym is a parameter symbol.
   17655              : */
   17656              : 
   17657     73369090 : extern "C" bool SymbolTable_IsParameter (unsigned int Sym)
   17658              : {
   17659     73369090 :   SymbolTable_PtrToSymbol pSym;
   17660              : 
   17661     73369090 :   pSym = GetPsym (Sym);
   17662     73369090 :   switch (pSym->SymbolType)
   17663              :     {
   17664              :       case SymbolTable_ParamSym:
   17665              :       case SymbolTable_VarParamSym:
   17666              :         return true;
   17667     65473662 :         break;
   17668              : 
   17669              : 
   17670     65473662 :       default:
   17671     65473662 :         return false;
   17672              :         break;
   17673              :     }
   17674              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   17675              :   __builtin_unreachable ();
   17676              : }
   17677              : 
   17678              : 
   17679              : /*
   17680              :    GetProcedureKind - returns the procedure kind given the declaration tok.
   17681              :                       The declaration tok must match the ident tok in the
   17682              :                       procedure name.  It is only safe to call this
   17683              :                       procedure function during pass 2 onwards.
   17684              : */
   17685              : 
   17686     32145119 : extern "C" SymbolTable_ProcedureKind SymbolTable_GetProcedureKind (unsigned int sym, unsigned int tok)
   17687              : {
   17688     32145119 :   SymbolTable_ProcedureKind kind;
   17689     32145119 :   SymbolTable_PtrToSymbol pSym;
   17690              : 
   17691     32145119 :   pSym = GetPsym (sym);
   17692     32145119 :   switch (pSym->SymbolType)
   17693              :     {
   17694              :       case SymbolTable_ProcedureSym:
   17695     71326921 :         for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
   17696              :           {
   17697     71326921 :             if (pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok == tok)
   17698              :               {
   17699              :                 return kind;
   17700              :               }
   17701              :           }
   17702            0 :         break;
   17703              : 
   17704              :       case SymbolTable_ProcTypeSym:
   17705              :         return SymbolTable_ProperProcedure;
   17706            0 :         break;
   17707              : 
   17708              : 
   17709            0 :       default:
   17710            0 :         M2Error_InternalError ((const char *) "expecting ProcedureSym symbol", 29);
   17711            0 :         break;
   17712              :     }
   17713            0 :   M2Error_InternalError ((const char *) "ProcedureSym kind has not yet been declared", 43);
   17714              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   17715              :   __builtin_unreachable ();
   17716              : }
   17717              : 
   17718              : 
   17719              : /*
   17720              :    GetProcedureDeclaredTok - return the token where the
   17721              :                              declaration of procedure sym:kind
   17722              :                              occurred.
   17723              : */
   17724              : 
   17725           36 : extern "C" unsigned int SymbolTable_GetProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind)
   17726              : {
   17727           36 :   SymbolTable_PtrToSymbol pSym;
   17728              : 
   17729           36 :   pSym = GetPsym (sym);
   17730           36 :   switch (pSym->SymbolType)
   17731              :     {
   17732           36 :       case SymbolTable_ProcedureSym:
   17733           36 :         return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok;
   17734            0 :         break;
   17735              : 
   17736              : 
   17737            0 :       default:
   17738            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   17739              :         break;
   17740              :     }
   17741              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   17742              :   __builtin_unreachable ();
   17743              : }
   17744              : 
   17745              : 
   17746              : /*
   17747              :    PutProcedureDeclaredTok - places the tok where the
   17748              :                              declaration of procedure sym:kind
   17749              :                              occurred.
   17750              : */
   17751              : 
   17752      5410939 : extern "C" void SymbolTable_PutProcedureDeclaredTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok)
   17753              : {
   17754      5410939 :   SymbolTable_PtrToSymbol pSym;
   17755              : 
   17756      5410939 :   pSym = GetPsym (sym);
   17757      5410939 :   switch (pSym->SymbolType)
   17758              :     {
   17759      5410939 :       case SymbolTable_ProcedureSym:
   17760      5410939 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ProcedureTok = tok;
   17761      5410939 :         break;
   17762              : 
   17763              : 
   17764            0 :       default:
   17765            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   17766      5410939 :         break;
   17767              :     }
   17768      5410939 : }
   17769              : 
   17770              : 
   17771              : /*
   17772              :    GetReturnTypeTok - return the token where the
   17773              :                                return type procedure sym:kind or proctype
   17774              :                                was defined.
   17775              : */
   17776              : 
   17777            6 : extern "C" unsigned int SymbolTable_GetReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind)
   17778              : {
   17779            6 :   SymbolTable_PtrToSymbol pSym;
   17780              : 
   17781            6 :   pSym = GetPsym (sym);
   17782            6 :   switch (pSym->SymbolType)
   17783              :     {
   17784            6 :       case SymbolTable_ProcedureSym:
   17785            6 :         return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok;
   17786            0 :         break;
   17787              : 
   17788            0 :       case SymbolTable_ProcTypeSym:
   17789            0 :         return pSym->ProcType.ReturnTypeTok;
   17790            0 :         break;
   17791              : 
   17792              : 
   17793            0 :       default:
   17794            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   17795              :         break;
   17796              :     }
   17797              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   17798              :   __builtin_unreachable ();
   17799              : }
   17800              : 
   17801              : 
   17802              : /*
   17803              :    PutReturnTypeTok - places the tok where the
   17804              :                       return type of procedure sym:kind or proctype
   17805              :                       was defined.
   17806              : */
   17807              : 
   17808            0 : extern "C" void SymbolTable_PutReturnTypeTok (unsigned int sym, SymbolTable_ProcedureKind kind, unsigned int tok)
   17809              : {
   17810            0 :   SymbolTable_PtrToSymbol pSym;
   17811              : 
   17812            0 :   pSym = GetPsym (sym);
   17813            0 :   switch (pSym->SymbolType)
   17814              :     {
   17815            0 :       case SymbolTable_ProcedureSym:
   17816            0 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnTypeTok = tok;
   17817            0 :         break;
   17818              : 
   17819            0 :       case SymbolTable_ProcTypeSym:
   17820            0 :         pSym->ProcType.ReturnTypeTok = tok;
   17821            0 :         break;
   17822              : 
   17823              : 
   17824            0 :       default:
   17825            0 :         M2Error_InternalError ((const char *) "expecting procedure symbol", 26);
   17826            0 :         break;
   17827              :     }
   17828            0 : }
   17829              : 
   17830              : 
   17831              : /*
   17832              :    PutProcedureParametersDefined - the procedure symbol sym:kind
   17833              :                                    parameters have been defined.
   17834              : */
   17835              : 
   17836     10641029 : extern "C" void SymbolTable_PutProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
   17837              : {
   17838     10641029 :   SymbolTable_PtrToSymbol pSym;
   17839              : 
   17840     10641029 :   AssertInRange (sym);
   17841     10641029 :   pSym = GetPsym (sym);
   17842     10641029 :   switch (pSym->SymbolType)
   17843              :     {
   17844              :       case SymbolTable_ErrorSym:
   17845              :         break;
   17846              : 
   17847     10641029 :       case SymbolTable_ProcedureSym:
   17848     10641029 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ParamDefined = true;
   17849     10641029 :         pSym->Procedure.BuildProcType = false;
   17850     10641029 :         break;
   17851              : 
   17852              :       case SymbolTable_ProcTypeSym:
   17853              :         break;
   17854              : 
   17855              : 
   17856            0 :       default:
   17857            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   17858     10641029 :         break;
   17859              :     }
   17860     10641029 : }
   17861              : 
   17862              : 
   17863              : /*
   17864              :    GetProcedureParametersDefined - returns true if procedure symbol sym:kind
   17865              :                                    parameters are defined.
   17866              : */
   17867              : 
   17868    181438214 : extern "C" bool SymbolTable_GetProcedureParametersDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
   17869              : {
   17870    181438214 :   SymbolTable_PtrToSymbol pSym;
   17871              : 
   17872    181438214 :   AssertInRange (sym);
   17873    181438214 :   pSym = GetPsym (sym);
   17874    181438214 :   switch (pSym->SymbolType)
   17875              :     {
   17876              :       case SymbolTable_ErrorSym:
   17877              :         return false;
   17878    172518356 :         break;
   17879              : 
   17880    172518356 :       case SymbolTable_ProcedureSym:
   17881    172518356 :         return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ParamDefined;
   17882      8919858 :         break;
   17883              : 
   17884      8919858 :       case SymbolTable_ProcTypeSym:
   17885      8919858 :         return true;
   17886            0 :         break;
   17887              : 
   17888              : 
   17889            0 :       default:
   17890            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   17891              :         break;
   17892              :     }
   17893              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   17894              :   __builtin_unreachable ();
   17895              : }
   17896              : 
   17897              : 
   17898              : /*
   17899              :    PutProcedureDefined - the procedure symbol sym:kind is defined.
   17900              : */
   17901              : 
   17902      7172326 : extern "C" void SymbolTable_PutProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
   17903              : {
   17904      7172326 :   SymbolTable_PtrToSymbol pSym;
   17905              : 
   17906      7172326 :   AssertInRange (sym);
   17907      7172326 :   pSym = GetPsym (sym);
   17908      7172326 :   switch (pSym->SymbolType)
   17909              :     {
   17910              :       case SymbolTable_ErrorSym:
   17911              :         break;
   17912              : 
   17913      7172326 :       case SymbolTable_ProcedureSym:
   17914      7172326 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].Defined = true;
   17915      7172326 :         break;
   17916              : 
   17917              : 
   17918            0 :       default:
   17919            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   17920      7172326 :         break;
   17921              :     }
   17922      7172326 : }
   17923              : 
   17924              : 
   17925              : /*
   17926              :    GetProcedureDefined - returns true if procedure symbol sym:kind
   17927              :                          is defined.
   17928              : */
   17929              : 
   17930     36043416 : extern "C" bool SymbolTable_GetProcedureDefined (unsigned int sym, SymbolTable_ProcedureKind kind)
   17931              : {
   17932     36043416 :   SymbolTable_PtrToSymbol pSym;
   17933              : 
   17934     36043416 :   AssertInRange (sym);
   17935     36043416 :   pSym = GetPsym (sym);
   17936     36043416 :   switch (pSym->SymbolType)
   17937              :     {
   17938              :       case SymbolTable_ErrorSym:
   17939              :         return false;
   17940     36043416 :         break;
   17941              : 
   17942     36043416 :       case SymbolTable_ProcedureSym:
   17943     36043416 :         return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].Defined;
   17944            0 :         break;
   17945              : 
   17946              : 
   17947            0 :       default:
   17948            0 :         M2Error_InternalError ((const char *) "expecting a Procedure symbol", 28);
   17949              :         break;
   17950              :     }
   17951              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   17952              :   __builtin_unreachable ();
   17953              : }
   17954              : 
   17955              : 
   17956              : /*
   17957              :    PutUseVarArgs - tell the symbol table that this procedure, Sym,
   17958              :                    uses varargs.
   17959              :                    The procedure _must_ be declared inside a
   17960              :                    DEFINITION FOR "C"
   17961              : 
   17962              : */
   17963              : 
   17964        11332 : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym)
   17965              : {
   17966        11332 :   SymbolTable_PtrToSymbol pSym;
   17967              : 
   17968        11332 :   AssertInRange (Sym);
   17969        11332 :   pSym = GetPsym (Sym);
   17970        11332 :   switch (pSym->SymbolType)
   17971              :     {
   17972              :       case SymbolTable_ErrorSym:
   17973              :         break;
   17974              : 
   17975        11332 :       case SymbolTable_ProcedureSym:
   17976              :         /* Currently can only declare var args in a definition module.  */
   17977        11332 :         pSym->Procedure.Decl.array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure].HasVarArgs = true;
   17978        11332 :         break;
   17979              : 
   17980            0 :       case SymbolTable_ProcTypeSym:
   17981            0 :         pSym->ProcType.HasVarArgs = true;
   17982            0 :         break;
   17983              : 
   17984              : 
   17985            0 :       default:
   17986            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   17987        11332 :         break;
   17988              :     }
   17989        11332 : }
   17990              : 
   17991              : 
   17992              : /*
   17993              :    UsesVarArgs - returns TRUE if procedure, Sym, uses varargs.
   17994              :                  The procedure _must_ be declared inside a
   17995              :                  DEFINITION FOR "C"
   17996              : */
   17997              : 
   17998      3786966 : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym)
   17999              : {
   18000      3786966 :   SymbolTable_PtrToSymbol pSym;
   18001              : 
   18002      3786966 :   AssertInRange (Sym);
   18003      3786966 :   pSym = GetPsym (Sym);
   18004      3786966 :   switch (pSym->SymbolType)
   18005              :     {
   18006              :       case SymbolTable_ErrorSym:
   18007              :         return false;
   18008      3729476 :         break;
   18009              : 
   18010      3729476 :       case SymbolTable_ProcedureSym:
   18011              :         /* Currently can only declare var args in a definition module.  */
   18012      3729476 :         return pSym->Procedure.Decl.array[SymbolTable_DefProcedure-SymbolTable_ProperProcedure].HasVarArgs;
   18013        57490 :         break;
   18014              : 
   18015        57490 :       case SymbolTable_ProcTypeSym:
   18016        57490 :         return pSym->ProcType.HasVarArgs;
   18017            0 :         break;
   18018              : 
   18019              : 
   18020            0 :       default:
   18021            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   18022              :         break;
   18023              :     }
   18024              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   18025              :   __builtin_unreachable ();
   18026              : }
   18027              : 
   18028              : 
   18029              : /*
   18030              :    PutUseOptArg - tell the symbol table that this procedure, Sym,
   18031              :                   uses an optarg.
   18032              : */
   18033              : 
   18034        17618 : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind)
   18035              : {
   18036        17618 :   SymbolTable_PtrToSymbol pSym;
   18037              : 
   18038        17618 :   AssertInRange (Sym);
   18039        17618 :   pSym = GetPsym (Sym);
   18040        17618 :   switch (pSym->SymbolType)
   18041              :     {
   18042              :       case SymbolTable_ErrorSym:
   18043              :         break;
   18044              : 
   18045        17618 :       case SymbolTable_ProcedureSym:
   18046        17618 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].HasOptArg = true;
   18047        17618 :         break;
   18048              : 
   18049            0 :       case SymbolTable_ProcTypeSym:
   18050            0 :         pSym->ProcType.HasOptArg = true;
   18051            0 :         break;
   18052              : 
   18053              : 
   18054            0 :       default:
   18055            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   18056        17618 :         break;
   18057              :     }
   18058        17618 : }
   18059              : 
   18060              : 
   18061              : /*
   18062              :    UsesOptArg - returns TRUE if procedure, Sym, uses varargs.
   18063              : */
   18064              : 
   18065       214584 : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym, SymbolTable_ProcedureKind kind)
   18066              : {
   18067       214584 :   SymbolTable_PtrToSymbol pSym;
   18068              : 
   18069       214584 :   AssertInRange (Sym);
   18070       214584 :   pSym = GetPsym (Sym);
   18071       214584 :   switch (pSym->SymbolType)
   18072              :     {
   18073              :       case SymbolTable_ErrorSym:
   18074              :         return false;
   18075       214584 :         break;
   18076              : 
   18077       214584 :       case SymbolTable_ProcedureSym:
   18078       214584 :         return pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].HasOptArg;
   18079            0 :         break;
   18080              : 
   18081            0 :       case SymbolTable_ProcTypeSym:
   18082            0 :         return pSym->ProcType.HasOptArg;
   18083            0 :         break;
   18084              : 
   18085              : 
   18086            0 :       default:
   18087            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   18088              :         break;
   18089              :     }
   18090              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   18091              :   __builtin_unreachable ();
   18092              : }
   18093              : 
   18094              : 
   18095              : /*
   18096              :    PutOptArgInit - makes symbol, Sym, the initializer value to
   18097              :                    procedure, ProcSym.
   18098              : */
   18099              : 
   18100        14675 : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym)
   18101              : {
   18102        14675 :   SymbolTable_PtrToSymbol pSym;
   18103              : 
   18104        14675 :   AssertInRange (Sym);
   18105        14675 :   if (! (SymbolTable_IsError (ProcSym)))
   18106              :     {
   18107        14675 :       pSym = GetPsym (ProcSym);
   18108        14675 :       switch (pSym->SymbolType)
   18109              :         {
   18110              :           case SymbolTable_ErrorSym:
   18111              :             break;
   18112              : 
   18113        14675 :           case SymbolTable_ProcedureSym:
   18114        14675 :             pSym->Procedure.OptArgInit = Sym;
   18115        14675 :             break;
   18116              : 
   18117            0 :           case SymbolTable_ProcTypeSym:
   18118            0 :             pSym->ProcType.OptArgInit = Sym;
   18119            0 :             break;
   18120              : 
   18121              : 
   18122            0 :           default:
   18123            0 :             M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   18124              :             break;
   18125              :         }
   18126              :     }
   18127        14675 : }
   18128              : 
   18129              : 
   18130              : /*
   18131              :    GetOptArgInit - returns the initializer value to the optional parameter in
   18132              :                    procedure, ProcSym.
   18133              : */
   18134              : 
   18135         3336 : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym)
   18136              : {
   18137         3336 :   SymbolTable_PtrToSymbol pSym;
   18138              : 
   18139         3336 :   if (! (SymbolTable_IsError (ProcSym)))
   18140              :     {
   18141         3336 :       pSym = GetPsym (ProcSym);
   18142         3336 :       switch (pSym->SymbolType)
   18143              :         {
   18144              :           case SymbolTable_ErrorSym:
   18145              :             break;
   18146              : 
   18147         3336 :           case SymbolTable_ProcedureSym:
   18148         3336 :             return pSym->Procedure.OptArgInit;
   18149            0 :             break;
   18150              : 
   18151            0 :           case SymbolTable_ProcTypeSym:
   18152            0 :             return pSym->ProcType.OptArgInit;
   18153            0 :             break;
   18154              : 
   18155              : 
   18156            0 :           default:
   18157            0 :             M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   18158              :             break;
   18159              :         }
   18160              :     }
   18161              :   return SymbolTable_NulSym;
   18162              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18163              :   __builtin_unreachable ();
   18164              : }
   18165              : 
   18166              : 
   18167              : /*
   18168              :    MakePointer - returns a pointer symbol with PointerName.
   18169              : */
   18170              : 
   18171       171649 : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName)
   18172              : {
   18173       171649 :   unsigned int oaf;
   18174       171649 :   unsigned int sym;
   18175              : 
   18176       171649 :   tok = CheckTok (tok, (const char *) "pointer", 7);
   18177       171649 :   sym = HandleHiddenOrDeclare (tok, PointerName, &oaf);
   18178       171649 :   FillInPointerFields (sym, PointerName, SymbolTable_GetCurrentScope (), oaf);
   18179       171649 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
   18180       171649 :   return sym;
   18181              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18182              :   __builtin_unreachable ();
   18183              : }
   18184              : 
   18185              : 
   18186              : /*
   18187              :    PutPointer - gives a pointer symbol a type, PointerType.
   18188              : */
   18189              : 
   18190       201487 : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType)
   18191              : {
   18192       201487 :   SymbolTable_PtrToSymbol pSym;
   18193              : 
   18194       201487 :   pSym = GetPsym (Sym);
   18195       201487 :   switch (pSym->SymbolType)
   18196              :     {
   18197              :       case SymbolTable_ErrorSym:
   18198              :         break;
   18199              : 
   18200       201487 :       case SymbolTable_PointerSym:
   18201       201487 :         pSym->Pointer.Type = PointerType;
   18202       201487 :         break;
   18203              : 
   18204              : 
   18205            0 :       default:
   18206            0 :         M2Error_InternalError ((const char *) "expecting a Pointer symbol", 26);
   18207       201487 :         break;
   18208              :     }
   18209       201487 : }
   18210              : 
   18211              : 
   18212              : /*
   18213              :    IsPointer - returns true is Sym is a pointer type symbol.
   18214              : */
   18215              : 
   18216    471506945 : extern "C" bool SymbolTable_IsPointer (unsigned int Sym)
   18217              : {
   18218    471506945 :   SymbolTable_PtrToSymbol pSym;
   18219              : 
   18220    471506945 :   AssertInRange (Sym);
   18221    471506945 :   pSym = GetPsym (Sym);
   18222    471506945 :   return pSym->SymbolType == SymbolTable_PointerSym;
   18223              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18224              :   __builtin_unreachable ();
   18225              : }
   18226              : 
   18227              : 
   18228              : /*
   18229              :    IsRecord - returns true is Sym is a record type symbol.
   18230              : */
   18231              : 
   18232    471711190 : extern "C" bool SymbolTable_IsRecord (unsigned int Sym)
   18233              : {
   18234    471711190 :   SymbolTable_PtrToSymbol pSym;
   18235              : 
   18236    471711190 :   AssertInRange (Sym);
   18237    471711184 :   pSym = GetPsym (Sym);
   18238    471711184 :   return pSym->SymbolType == SymbolTable_RecordSym;
   18239              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18240              :   __builtin_unreachable ();
   18241              : }
   18242              : 
   18243              : 
   18244              : /*
   18245              :    IsVarient - returns true if the symbol, Sym, is a
   18246              :                varient symbol.
   18247              : */
   18248              : 
   18249    385522702 : extern "C" bool SymbolTable_IsVarient (unsigned int Sym)
   18250              : {
   18251    385522702 :   SymbolTable_PtrToSymbol pSym;
   18252              : 
   18253    385522702 :   pSym = GetPsym (Sym);
   18254    385522702 :   return pSym->SymbolType == SymbolTable_VarientSym;
   18255              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18256              :   __builtin_unreachable ();
   18257              : }
   18258              : 
   18259              : 
   18260              : /*
   18261              :    IsFieldVarient - returns true if the symbol, Sym, is a
   18262              :                     varient field.
   18263              : */
   18264              : 
   18265    222105899 : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym)
   18266              : {
   18267    222105899 :   SymbolTable_PtrToSymbol pSym;
   18268              : 
   18269    222105899 :   pSym = GetPsym (Sym);
   18270    222105899 :   return pSym->SymbolType == SymbolTable_VarientFieldSym;
   18271              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18272              :   __builtin_unreachable ();
   18273              : }
   18274              : 
   18275              : 
   18276              : /*
   18277              :    IsFieldEnumeration - returns true if the symbol, Sym, is an
   18278              :                         enumeration field.
   18279              : */
   18280              : 
   18281     11495032 : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym)
   18282              : {
   18283     11495032 :   SymbolTable_PtrToSymbol pSym;
   18284              : 
   18285     11495032 :   pSym = GetPsym (Sym);
   18286     11495032 :   return pSym->SymbolType == SymbolTable_EnumerationFieldSym;
   18287              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18288              :   __builtin_unreachable ();
   18289              : }
   18290              : 
   18291              : 
   18292              : /*
   18293              :    IsArray - returns true is Sym is an array type symbol.
   18294              : */
   18295              : 
   18296    325795972 : extern "C" bool SymbolTable_IsArray (unsigned int Sym)
   18297              : {
   18298    325795972 :   SymbolTable_PtrToSymbol pSym;
   18299              : 
   18300    325795972 :   AssertInRange (Sym);
   18301    325795972 :   pSym = GetPsym (Sym);
   18302    325795972 :   return pSym->SymbolType == SymbolTable_ArraySym;
   18303              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18304              :   __builtin_unreachable ();
   18305              : }
   18306              : 
   18307              : 
   18308              : /*
   18309              :    IsEnumeration - returns true if Sym is an enumeration symbol.
   18310              : */
   18311              : 
   18312    465841119 : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym)
   18313              : {
   18314    465841119 :   SymbolTable_PtrToSymbol pSym;
   18315              : 
   18316    465841119 :   AssertInRange (Sym);
   18317    465841119 :   pSym = GetPsym (Sym);
   18318    465841119 :   return pSym->SymbolType == SymbolTable_EnumerationSym;
   18319              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18320              :   __builtin_unreachable ();
   18321              : }
   18322              : 
   18323              : 
   18324              : /*
   18325              :    IsSet - returns TRUE if Sym is a set symbol.
   18326              : */
   18327              : 
   18328    201042256 : extern "C" bool SymbolTable_IsSet (unsigned int Sym)
   18329              : {
   18330    201042256 :   SymbolTable_PtrToSymbol pSym;
   18331              : 
   18332    201042256 :   AssertInRange (Sym);
   18333    201042256 :   pSym = GetPsym (Sym);
   18334    201042256 :   return pSym->SymbolType == SymbolTable_SetSym;
   18335              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18336              :   __builtin_unreachable ();
   18337              : }
   18338              : 
   18339              : 
   18340              : /*
   18341              :    IsHiddenType - returns TRUE if, Sym, is a Type and is also declared as a hidden type.
   18342              : */
   18343              : 
   18344     26246466 : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym)
   18345              : {
   18346     26246466 :   SymbolTable_PtrToSymbol pSym;
   18347              : 
   18348     26246466 :   pSym = GetPsym (Sym);
   18349     26246466 :   switch (pSym->SymbolType)
   18350              :     {
   18351     26216262 :       case SymbolTable_TypeSym:
   18352     26216262 :         return pSym->Type.IsHidden;
   18353              :         break;
   18354              : 
   18355              : 
   18356              :       default:
   18357              :         return false;
   18358              :         break;
   18359              :     }
   18360              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18361              :   __builtin_unreachable ();
   18362              : }
   18363              : 
   18364              : 
   18365              : /*
   18366              :    IsOAFamily - returns TRUE if, Sym, is an OAFamily symbol.
   18367              : */
   18368              : 
   18369            0 : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym)
   18370              : {
   18371            0 :   SymbolTable_PtrToSymbol pSym;
   18372              : 
   18373            0 :   AssertInRange (Sym);
   18374            0 :   pSym = GetPsym (Sym);
   18375            0 :   return pSym->SymbolType == SymbolTable_OAFamilySym;
   18376              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18377              :   __builtin_unreachable ();
   18378              : }
   18379              : 
   18380              : 
   18381              : /*
   18382              :    GetDimension - return the number of dimensions associated with
   18383              :                   this unbounded ARRAY parameter.
   18384              : */
   18385              : 
   18386       374503 : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym)
   18387              : {
   18388       666217 :   SymbolTable_PtrToSymbol pSym;
   18389              : 
   18390       666217 :   pSym = GetPsym (sym);
   18391       666217 :   switch (pSym->SymbolType)
   18392              :     {
   18393            0 :       case SymbolTable_PartialUnboundedSym:
   18394            0 :         return pSym->PartialUnbounded.NDim;
   18395       367873 :         break;
   18396              : 
   18397       367873 :       case SymbolTable_UnboundedSym:
   18398       367873 :         return pSym->Unbounded.Dimensions;
   18399            0 :         break;
   18400              : 
   18401            0 :       case SymbolTable_OAFamilySym:
   18402            0 :         return pSym->OAFamily.MaxDimensions;
   18403       176014 :         break;
   18404              : 
   18405       176014 :       case SymbolTable_ParamSym:
   18406       176014 :         if (pSym->Param.IsUnbounded)
   18407              :           {
   18408       176014 :             return SymbolTable_GetDimension (SymbolTable_GetType (sym));
   18409              :           }
   18410              :         else
   18411              :           {
   18412            0 :             M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
   18413              :           }
   18414       115664 :         break;
   18415              : 
   18416       115664 :       case SymbolTable_VarParamSym:
   18417       115664 :         if (pSym->VarParam.IsUnbounded)
   18418              :           {
   18419       115664 :             return SymbolTable_GetDimension (SymbolTable_GetType (sym));
   18420              :           }
   18421              :         else
   18422              :           {
   18423            0 :             M2Error_InternalError ((const char *) "expecting unbounded paramater", 29);
   18424              :           }
   18425         6630 :         break;
   18426              : 
   18427         6630 :       case SymbolTable_ArraySym:
   18428         6630 :         return GetArrayDimension (sym);
   18429            0 :         break;
   18430              : 
   18431            0 :       case SymbolTable_TypeSym:
   18432            0 :         return SymbolTable_GetDimension (SymbolTable_GetType (sym));
   18433           36 :         break;
   18434              : 
   18435           36 :       case SymbolTable_VarSym:
   18436           36 :         return SymbolTable_GetDimension (SymbolTable_GetType (sym));
   18437            0 :         break;
   18438              : 
   18439              : 
   18440            0 :       default:
   18441            0 :         M2Error_InternalError ((const char *) "expecting PartialUnbounded", 26);
   18442              :         break;
   18443              :     }
   18444              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   18445              :   __builtin_unreachable ();
   18446              : }
   18447              : 
   18448              : 
   18449              : /*
   18450              :    MakeOAFamily - makes an OAFamily symbol based on SimpleType.
   18451              :                   It returns the OAFamily symbol.  A new symbol
   18452              :                   is created if one does not already exist for
   18453              :                   SimpleType.
   18454              : */
   18455              : 
   18456      1016454 : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType)
   18457              : {
   18458      1016454 :   SymbolTable_PtrToSymbol pSym;
   18459      1016454 :   unsigned int sym;
   18460              : 
   18461      1016454 :   sym = SymbolTable_GetOAFamily (SimpleType);
   18462      1016454 :   if (sym == SymbolTable_NulSym)
   18463              :     {
   18464        29778 :       NewSym (&sym);
   18465        29778 :       pSym = GetPsym (sym);
   18466        29778 :       pSym->SymbolType = SymbolTable_OAFamilySym;
   18467        29778 :       pSym->OAFamily.MaxDimensions = 0;
   18468        29778 :       pSym->OAFamily.SimpleType = SimpleType;
   18469        29778 :       pSym->OAFamily.Dimensions = Indexing_InitIndex (1);
   18470        29778 :       PutOAFamily (SimpleType, sym);
   18471              :     }
   18472      1016454 :   return sym;
   18473              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18474              :   __builtin_unreachable ();
   18475              : }
   18476              : 
   18477              : 
   18478              : /*
   18479              :    GetOAFamily - returns the oafamily symbol associated with
   18480              :                  SimpleType.
   18481              : */
   18482              : 
   18483    419750613 : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType)
   18484              : {
   18485    419750613 :   SymbolTable_PtrToSymbol pSym;
   18486              : 
   18487    419750613 :   pSym = GetPsym (SimpleType);
   18488    419750613 :   switch (pSym->SymbolType)
   18489              :     {
   18490              :       case SymbolTable_ErrorSym:
   18491              :         return SymbolTable_NulSym;
   18492     41100784 :         break;
   18493              : 
   18494     41100784 :       case SymbolTable_RecordSym:
   18495     41100784 :         return pSym->Record.oafamily;
   18496      5553336 :         break;
   18497              : 
   18498      5553336 :       case SymbolTable_SubrangeSym:
   18499      5553336 :         return pSym->Subrange.oafamily;
   18500     11353555 :         break;
   18501              : 
   18502     11353555 :       case SymbolTable_EnumerationSym:
   18503     11353555 :         return pSym->Enumeration.oafamily;
   18504      4737194 :         break;
   18505              : 
   18506      4737194 :       case SymbolTable_ArraySym:
   18507      4737194 :         return pSym->Array.oafamily;
   18508      4719740 :         break;
   18509              : 
   18510      4719740 :       case SymbolTable_ProcTypeSym:
   18511      4719740 :         return pSym->ProcType.oafamily;
   18512     85588134 :         break;
   18513              : 
   18514     85588134 :       case SymbolTable_TypeSym:
   18515     85588134 :         return pSym->Type.oafamily;
   18516     48189274 :         break;
   18517              : 
   18518     48189274 :       case SymbolTable_PointerSym:
   18519     48189274 :         return pSym->Pointer.oafamily;
   18520      1678732 :         break;
   18521              : 
   18522      1678732 :       case SymbolTable_SetSym:
   18523      1678732 :         return pSym->Set.oafamily;
   18524       127079 :         break;
   18525              : 
   18526       127079 :       case SymbolTable_UndefinedSym:
   18527       127079 :         return pSym->Undefined.oafamily;
   18528              :         break;
   18529              : 
   18530              : 
   18531              :       default:
   18532              :         return SymbolTable_NulSym;
   18533              :         break;
   18534              :     }
   18535              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18536              :   __builtin_unreachable ();
   18537              : }
   18538              : 
   18539              : 
   18540              : /*
   18541              :    ForeachOAFamily - call, p[oaf, ndim, symbol] for every unbounded symbol,
   18542              :                      sym, in the oaf.
   18543              : */
   18544              : 
   18545    418734159 : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p)
   18546              : {
   18547    418734159 :   typedef unsigned int *ForeachOAFamily__T1;
   18548              : 
   18549    418734159 :   SymbolTable_PtrToSymbol pSym;
   18550    418734159 :   unsigned int h;
   18551    418734159 :   unsigned int i;
   18552    418734159 :   ForeachOAFamily__T1 pc;
   18553              : 
   18554    418734159 :   if (sym != SymbolTable_NulSym)
   18555              :     {
   18556     25883811 :       pSym = GetPsym (sym);
   18557     25883811 :       switch (pSym->SymbolType)
   18558              :         {
   18559     25883811 :           case SymbolTable_OAFamilySym:
   18560     25883811 :             h = Indexing_HighIndice (pSym->OAFamily.Dimensions);
   18561     25883811 :             i = 1;
   18562     77814597 :             while (i <= h)
   18563              :               {
   18564     26046975 :                 pc = static_cast<ForeachOAFamily__T1> (Indexing_GetIndice (pSym->OAFamily.Dimensions, i));
   18565     26046975 :                 if (pc != NULL)
   18566              :                   {
   18567     26046975 :                     (*p.proc) (sym, i, (*pc));
   18568              :                   }
   18569     26046975 :                 i += 1;
   18570              :               }
   18571              :             break;
   18572              : 
   18573              : 
   18574            0 :           default:
   18575            0 :             M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
   18576              :             break;
   18577              :         }
   18578              :     }
   18579    418734159 : }
   18580              : 
   18581              : 
   18582              : /*
   18583              :    IsUnbounded - returns true if Sym is an unbounded symbol.
   18584              : */
   18585              : 
   18586    252567448 : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym)
   18587              : {
   18588    252567448 :   SymbolTable_PtrToSymbol pSym;
   18589              : 
   18590    252567448 :   AssertInRange (Sym);
   18591    252567448 :   pSym = GetPsym (Sym);
   18592    252567448 :   return pSym->SymbolType == SymbolTable_UnboundedSym;
   18593              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18594              :   __builtin_unreachable ();
   18595              : }
   18596              : 
   18597              : 
   18598              : /*
   18599              :    GetUnbounded - returns the unbounded symbol associated with
   18600              :                   the OAFamily symbol, oaf, and the number of
   18601              :                   dimensions, ndim, of the open array.
   18602              : */
   18603              : 
   18604      1016454 : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim)
   18605              : {
   18606      1016454 :   SymbolTable_PtrToSymbol pSym;
   18607              : 
   18608      1016454 :   pSym = GetPsym (oaf);
   18609      1016454 :   switch (pSym->SymbolType)
   18610              :     {
   18611      1016454 :       case SymbolTable_OAFamilySym:
   18612      1016454 :         if (ndim > pSym->OAFamily.MaxDimensions)
   18613              :           {
   18614              :             return SymbolTable_NulSym;
   18615              :           }
   18616              :         else
   18617              :           {
   18618       986616 :             return GetFromIndex (pSym->OAFamily.Dimensions, ndim);
   18619              :           }
   18620            0 :         break;
   18621              : 
   18622              : 
   18623            0 :       default:
   18624            0 :         M2Error_InternalError ((const char *) "expecting OAFamily symbol", 25);
   18625              :         break;
   18626              :     }
   18627              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   18628              :   __builtin_unreachable ();
   18629              : }
   18630              : 
   18631              : 
   18632              : /*
   18633              :    GetUnboundedRecordType - returns the record type used to
   18634              :                             implement the unbounded array.
   18635              : */
   18636              : 
   18637     29111902 : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym)
   18638              : {
   18639     29111902 :   SymbolTable_PtrToSymbol pSym;
   18640              : 
   18641     29111902 :   pSym = GetPsym (Sym);
   18642     29111902 :   switch (pSym->SymbolType)
   18643              :     {
   18644     29111902 :       case SymbolTable_UnboundedSym:
   18645     29111902 :         return pSym->Unbounded.RecordType;
   18646            0 :         break;
   18647              : 
   18648              : 
   18649            0 :       default:
   18650            0 :         M2Error_InternalError ((const char *) "expecting an UnBounded symbol", 29);
   18651              :         break;
   18652              :     }
   18653              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   18654              :   __builtin_unreachable ();
   18655              : }
   18656              : 
   18657              : 
   18658              : /*
   18659              :    GetUnboundedAddressOffset - returns the offset of the address field
   18660              :                                inside the record used to implement the
   18661              :                                unbounded type.
   18662              : */
   18663              : 
   18664        76769 : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym)
   18665              : {
   18666        76769 :   unsigned int field;
   18667        76769 :   unsigned int rec;
   18668              : 
   18669        76769 :   rec = SymbolTable_GetUnboundedRecordType (sym);
   18670        76769 :   if (rec == SymbolTable_NulSym)
   18671              :     {
   18672            0 :       M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
   18673              :     }
   18674              :   else
   18675              :     {
   18676        76769 :       field = SymbolTable_GetLocalSym (rec, NameKey_MakeKey ((const char *) "_m2_contents", 12));
   18677        76769 :       if (field == SymbolTable_NulSym)
   18678              :         {
   18679            0 :           M2Error_InternalError ((const char *) "expecting address field to be present inside unbounded record", 61);
   18680              :         }
   18681              :       else
   18682              :         {
   18683        76769 :           return field;
   18684              :         }
   18685              :     }
   18686              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   18687              :   __builtin_unreachable ();
   18688              : }
   18689              : 
   18690              : 
   18691              : /*
   18692              :    GetUnboundedHighOffset - returns the offset of the high field
   18693              :                             inside the record used to implement the
   18694              :                             unbounded type.
   18695              : */
   18696              : 
   18697        63365 : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim)
   18698              : {
   18699        63365 :   unsigned int rec;
   18700              : 
   18701        63365 :   rec = SymbolTable_GetUnboundedRecordType (sym);
   18702        63365 :   if (rec == SymbolTable_NulSym)
   18703              :     {
   18704            0 :       M2Error_InternalError ((const char *) "expecting record type to be declared", 36);
   18705              :     }
   18706              :   else
   18707              :     {
   18708        63365 :       return SymbolTable_GetLocalSym (rec, NameKey_makekey (DynamicStrings_string (DynamicStrings_Mark (FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "_m2_high_%d", 11)), (const unsigned char *) &ndim, (sizeof (ndim)-1))))));
   18709              :     }
   18710              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   18711              :   __builtin_unreachable ();
   18712              : }
   18713              : 
   18714              : 
   18715              : /*
   18716              :    MakeSubscript - makes a subscript Symbol.
   18717              :                    No name is required.
   18718              : */
   18719              : 
   18720       163230 : extern "C" unsigned int SymbolTable_MakeSubscript (void)
   18721              : {
   18722       163230 :   SymbolTable_PtrToSymbol pSym;
   18723       163230 :   unsigned int Sym;
   18724              : 
   18725       163230 :   NewSym (&Sym);
   18726       163230 :   pSym = GetPsym (Sym);
   18727       163230 :   pSym->SymbolType = SymbolTable_SubscriptSym;
   18728       163230 :   pSym->Subscript.Type = SymbolTable_NulSym;  /* Index to a subrange symbol.  */
   18729       163230 :   pSym->Subscript.Size = M2ALU_InitValue ();  /* Size of this indice in*Size  */
   18730       163230 :   pSym->Subscript.Offset = M2ALU_InitValue ();  /* Offset at runtime of symbol  */
   18731       163230 :   InitWhereDeclared (&pSym->Subscript.At);  /* Declared here  */
   18732       163230 :   return Sym;
   18733              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18734              :   __builtin_unreachable ();
   18735              : }
   18736              : 
   18737              : 
   18738              : /*
   18739              :    PutSubscript - gives a subscript symbol a type, SimpleType.
   18740              : */
   18741              : 
   18742       163230 : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType)
   18743              : {
   18744       163230 :   SymbolTable_PtrToSymbol pSym;
   18745              : 
   18746       163230 :   pSym = GetPsym (Sym);
   18747       163230 :   switch (pSym->SymbolType)
   18748              :     {
   18749              :       case SymbolTable_ErrorSym:
   18750              :         break;
   18751              : 
   18752       163230 :       case SymbolTable_SubscriptSym:
   18753       163230 :         pSym->Subscript.Type = SimpleType;
   18754       163230 :         break;
   18755              : 
   18756              : 
   18757            0 :       default:
   18758            0 :         M2Error_InternalError ((const char *) "expecting a SubScript symbol", 28);
   18759       163230 :         break;
   18760              :     }
   18761       163230 : }
   18762              : 
   18763              : 
   18764              : /*
   18765              :    MakeUnbounded - makes an unbounded array Symbol.
   18766              :                    ndim is the number of dimensions required.
   18767              :                    No name is required.
   18768              : */
   18769              : 
   18770      1016454 : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim)
   18771              : {
   18772      1016454 :   unsigned int sym;
   18773      1016454 :   unsigned int oaf;
   18774              : 
   18775      1016454 :   tok = CheckTok (tok, (const char *) "unbounded", 9);
   18776      1016454 :   oaf = SymbolTable_MakeOAFamily (SimpleType);
   18777      1016454 :   sym = SymbolTable_GetUnbounded (oaf, ndim);
   18778      1016454 :   if (sym == SymbolTable_NulSym)
   18779              :     {
   18780        29838 :       NewSym (&sym);
   18781        29838 :       if (SymbolTable_IsUnknown (SimpleType))
   18782              :         {
   18783            0 :           PutPartialUnbounded (sym, SimpleType, ndim);
   18784              :         }
   18785              :       else
   18786              :         {
   18787        29838 :           FillInUnboundedFields (tok, sym, SimpleType, ndim);
   18788              :         }
   18789        29838 :       PutUnbounded (oaf, sym, ndim);
   18790              :     }
   18791      1016454 :   return sym;
   18792              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18793              :   __builtin_unreachable ();
   18794              : }
   18795              : 
   18796              : 
   18797              : /*
   18798              :    NoOfElements - Returns the number of elements in array Sym,
   18799              :                   or the number of elements in an enumeration Sym or
   18800              :                   the number of interface symbols in an Interface list.
   18801              : */
   18802              : 
   18803          244 : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym)
   18804              : {
   18805          244 :   SymbolTable_PtrToSymbol pSym;
   18806          244 :   unsigned int n;
   18807              : 
   18808          244 :   pSym = GetPsym (Sym);
   18809          244 :   switch (pSym->SymbolType)
   18810              :     {
   18811              :       case SymbolTable_ErrorSym:
   18812              :         n = 0;
   18813              :         break;
   18814              : 
   18815          244 :       case SymbolTable_EnumerationSym:
   18816          244 :         n = pSym->Enumeration.NoOfElements;
   18817          244 :         break;
   18818              : 
   18819            0 :       case SymbolTable_InterfaceSym:
   18820            0 :         n = Indexing_HighIndice (pSym->Interface.Parameters);
   18821            0 :         break;
   18822              : 
   18823              : 
   18824            0 :       default:
   18825            0 :         M2Error_InternalError ((const char *) "expecting an Array or UnBounded symbol", 38);
   18826          244 :         break;
   18827              :     }
   18828          244 :   return n;
   18829              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   18830              :   __builtin_unreachable ();
   18831              : }
   18832              : 
   18833              : 
   18834              : /*
   18835              :    PutArray - places a type symbol into an arraysym.
   18836              : */
   18837              : 
   18838       163230 : extern "C" void SymbolTable_PutArray (unsigned int arraysym, unsigned int typesym)
   18839              : {
   18840       163230 :   SymbolTable_PtrToSymbol pSym;
   18841              : 
   18842       163230 :   pSym = GetPsym (arraysym);
   18843       163230 :   switch (pSym->SymbolType)
   18844              :     {
   18845              :       case SymbolTable_ErrorSym:
   18846              :         break;
   18847              : 
   18848       163230 :       case SymbolTable_ArraySym:
   18849       163230 :         pSym->Array.Type = typesym;  /* The ARRAY OF typesym.  */
   18850       163230 :         break;
   18851              : 
   18852              : 
   18853            0 :       default:
   18854            0 :         M2Error_InternalError ((const char *) "expecting an Array symbol", 25);
   18855       163230 :         break;
   18856              :     }
   18857       163230 : }
   18858              : 
   18859              : 
   18860              : /*
   18861              :    ResolveImports - it examines the import list of all inner modules
   18862              :                     and resolves all relative imports.
   18863              : */
   18864              : 
   18865        82626 : extern "C" void SymbolTable_ResolveImports (void)
   18866              : {
   18867        82626 :   unsigned int scope;
   18868              : 
   18869        82626 :   scope = SymbolTable_GetCurrentScope ();
   18870        82626 :   if (DebugUnknowns)
   18871              :     {
   18872              :       SymbolTable_DisplayTrees (scope);
   18873              :     }
   18874        82626 :   SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
   18875        82626 :   SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) ResolveRelativeImport});
   18876        82626 : }
   18877              : 
   18878              : 
   18879              : /*
   18880              :    ResolveConstructorTypes - to be called at the end of pass three.  Its
   18881              :                              purpose is to fix up all constructors whose
   18882              :                              types are unknown.
   18883              : */
   18884              : 
   18885        14664 : extern "C" void SymbolTable_ResolveConstructorTypes (void)
   18886              : {
   18887        51122 :   bool finished;
   18888        51122 :   unsigned int i;
   18889        51122 :   unsigned int n;
   18890        51122 :   unsigned int s;
   18891              : 
   18892        51122 :   do {
   18893        51122 :     n = Lists_NoOfItemsInList (UnresolvedConstructorType);
   18894        51122 :     finished = true;
   18895        51122 :     i = 1;
   18896       138708 :     while (i <= n)
   18897              :       {
   18898        36464 :         s = static_cast<unsigned int> (Lists_GetItemFromList (UnresolvedConstructorType, i));
   18899        36464 :         M2Debug_Assert (SymbolTable_IsConstructor (s));
   18900        36464 :         if (CanResolveConstructor (s))
   18901              :           {
   18902        36458 :             finished = false;
   18903        36458 :             Lists_RemoveItemFromList (UnresolvedConstructorType, s);
   18904        36458 :             i = n;
   18905              :           }
   18906        36464 :         i += 1;
   18907              :       }
   18908        51122 :   } while (! (finished));
   18909        14664 :   CheckAllConstructorsResolved ();
   18910        14658 : }
   18911              : 
   18912              : 
   18913              : /*
   18914              :    AddNameToScope - adds a Name, n, to the list of objects declared at the
   18915              :                     current scope.
   18916              : */
   18917              : 
   18918      7898170 : extern "C" void SymbolTable_AddNameToScope (unsigned int tok, NameKey_Name n)
   18919              : {
   18920      7898170 :   SymbolTable_PtrToSymbol pSym;
   18921      7898170 :   unsigned int scope;
   18922              : 
   18923      7898170 :   scope = SymbolTable_GetCurrentScope ();
   18924      7898170 :   pSym = GetPsym (scope);
   18925      7898170 :   switch (pSym->SymbolType)
   18926              :     {
   18927      1567297 :       case SymbolTable_ProcedureSym:
   18928      1567297 :         AddNameTo (pSym->Procedure.NamedObjects, MakeObject (tok, n));
   18929      1567297 :         break;
   18930              : 
   18931        45386 :       case SymbolTable_ModuleSym:
   18932        45386 :         AddNameTo (pSym->Module.NamedObjects, MakeObject (tok, n));
   18933        45386 :         break;
   18934              : 
   18935      6285487 :       case SymbolTable_DefImpSym:
   18936      6285487 :         AddNameTo (pSym->DefImp.NamedObjects, MakeObject (tok, n));
   18937      6285487 :         break;
   18938              : 
   18939              : 
   18940            0 :       default:
   18941            0 :         M2Error_InternalError ((const char *) "expecting - DefImp", 18);
   18942      7898170 :         break;
   18943              :     }
   18944      7898170 : }
   18945              : 
   18946              : 
   18947              : /*
   18948              :    AddNameToImportList - adds a Name, n, to the import list of the current
   18949              :                          module.
   18950              : */
   18951              : 
   18952          170 : extern "C" void SymbolTable_AddNameToImportList (unsigned int tok, NameKey_Name n)
   18953              : {
   18954          170 :   SymbolTable_PtrToSymbol pSym;
   18955          170 :   unsigned int scope;
   18956              : 
   18957          170 :   scope = SymbolTable_GetCurrentScope ();
   18958          170 :   pSym = GetPsym (scope);
   18959          170 :   switch (pSym->SymbolType)
   18960              :     {
   18961          170 :       case SymbolTable_ModuleSym:
   18962          170 :         AddNameTo (pSym->Module.NamedImports, MakeObject (tok, n));
   18963          170 :         break;
   18964              : 
   18965            0 :       case SymbolTable_DefImpSym:
   18966            0 :         AddNameTo (pSym->DefImp.NamedImports, MakeObject (tok, n));
   18967            0 :         break;
   18968              : 
   18969              : 
   18970            0 :       default:
   18971            0 :         M2Error_InternalError ((const char *) "expecting - DefImp or Module symbol", 35);
   18972          170 :         break;
   18973              :     }
   18974          170 : }
   18975              : 
   18976              : 
   18977              : /*
   18978              :    GetScope - returns the declaration scope of the symbol.
   18979              : */
   18980              : 
   18981     78182704 : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym)
   18982              : {
   18983     78182704 :   SymbolTable_PtrToSymbol pSym;
   18984              : 
   18985     78182704 :   pSym = GetPsym (Sym);
   18986     78182704 :   switch (pSym->SymbolType)
   18987              :     {
   18988            0 :       case SymbolTable_ErrorSym:
   18989            0 :         return pSym->Error.Scope;
   18990              :         break;
   18991              : 
   18992              :       case SymbolTable_DefImpSym:
   18993              :         return SymbolTable_NulSym;
   18994      3336605 :         break;
   18995              : 
   18996      3336605 :       case SymbolTable_ModuleSym:
   18997      3336605 :         return pSym->Module.Scope;
   18998      3185984 :         break;
   18999              : 
   19000      3185984 :       case SymbolTable_VarSym:
   19001      3185984 :         return pSym->Var.Scope;
   19002     47249548 :         break;
   19003              : 
   19004     47249548 :       case SymbolTable_ProcedureSym:
   19005     47249548 :         return pSym->Procedure.Scope;
   19006       233804 :         break;
   19007              : 
   19008       233804 :       case SymbolTable_ProcTypeSym:
   19009       233804 :         return pSym->ProcType.Scope;
   19010      1136526 :         break;
   19011              : 
   19012      1136526 :       case SymbolTable_RecordFieldSym:
   19013      1136526 :         return pSym->RecordField.Scope;
   19014         8448 :         break;
   19015              : 
   19016         8448 :       case SymbolTable_VarientSym:
   19017         8448 :         return pSym->Varient.Scope;
   19018        23124 :         break;
   19019              : 
   19020        23124 :       case SymbolTable_VarientFieldSym:
   19021        23124 :         return pSym->VarientField.Scope;
   19022       134621 :         break;
   19023              : 
   19024       134621 :       case SymbolTable_EnumerationSym:
   19025       134621 :         return pSym->Enumeration.Scope;
   19026      1832148 :         break;
   19027              : 
   19028      1832148 :       case SymbolTable_EnumerationFieldSym:
   19029      1832148 :         return pSym->EnumerationField.Scope;
   19030       336636 :         break;
   19031              : 
   19032       336636 :       case SymbolTable_SubrangeSym:
   19033       336636 :         return pSym->Subrange.Scope;
   19034         1400 :         break;
   19035              : 
   19036         1400 :       case SymbolTable_ArraySym:
   19037         1400 :         return pSym->Array.Scope;
   19038       185560 :         break;
   19039              : 
   19040       185560 :       case SymbolTable_TypeSym:
   19041       185560 :         return pSym->Type.Scope;
   19042       100915 :         break;
   19043              : 
   19044       100915 :       case SymbolTable_PointerSym:
   19045       100915 :         return pSym->Pointer.Scope;
   19046       705165 :         break;
   19047              : 
   19048       705165 :       case SymbolTable_RecordSym:
   19049       705165 :         return pSym->Record.Scope;
   19050        16116 :         break;
   19051              : 
   19052        16116 :       case SymbolTable_SetSym:
   19053        16116 :         return pSym->Set.Scope;
   19054           24 :         break;
   19055              : 
   19056           24 :       case SymbolTable_UnboundedSym:
   19057           24 :         return pSym->Unbounded.Scope;
   19058           12 :         break;
   19059              : 
   19060           12 :       case SymbolTable_ConstLitSym:
   19061           12 :         return pSym->ConstLit.Scope;
   19062           48 :         break;
   19063              : 
   19064           48 :       case SymbolTable_ConstStringSym:
   19065           48 :         return pSym->ConstString.Scope;
   19066          258 :         break;
   19067              : 
   19068          258 :       case SymbolTable_ConstVarSym:
   19069          258 :         return pSym->ConstVar.Scope;
   19070          150 :         break;
   19071              : 
   19072          150 :       case SymbolTable_ParamSym:
   19073          150 :         return pSym->Param.Scope;
   19074           12 :         break;
   19075              : 
   19076           12 :       case SymbolTable_VarParamSym:
   19077           12 :         return pSym->VarParam.Scope;
   19078              :         break;
   19079              : 
   19080              :       case SymbolTable_UndefinedSym:
   19081              :         return SymbolTable_NulSym;
   19082            0 :         break;
   19083              : 
   19084            0 :       case SymbolTable_PartialUnboundedSym:
   19085            0 :         M2Error_InternalError ((const char *) "should not be requesting the scope of a PartialUnbounded symbol", 63);
   19086            0 :         break;
   19087              : 
   19088              : 
   19089            0 :       default:
   19090            0 :         M2Error_InternalError ((const char *) "not implemented yet", 19);
   19091              :         break;
   19092              :     }
   19093              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19094              :   __builtin_unreachable ();
   19095              : }
   19096              : 
   19097              : 
   19098              : /*
   19099              :    GetModuleScope - returns the module scope of symbol, sym.
   19100              :                     If sym was declared within a nested procedure
   19101              :                     then return the module which defines the
   19102              :                     procedure.
   19103              : */
   19104              : 
   19105       454410 : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym)
   19106              : {
   19107       454410 :   unsigned int mod;
   19108              : 
   19109       454410 :   mod = SymbolTable_GetScope (sym);
   19110       909876 :   while (((mod != SymbolTable_NulSym) && (! (SymbolTable_IsDefImp (mod)))) && (! (SymbolTable_IsModule (mod))))
   19111              :     {
   19112         1056 :       mod = SymbolTable_GetScope (mod);
   19113              :     }
   19114       454410 :   return mod;
   19115              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19116              :   __builtin_unreachable ();
   19117              : }
   19118              : 
   19119              : 
   19120              : /*
   19121              :    GetProcedureScope - returns the innermost procedure (if any)
   19122              :                        in which the symbol, sym, resides.
   19123              :                        A module inside the procedure is skipped
   19124              :                        over.
   19125              : */
   19126              : 
   19127       370997 : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym)
   19128              : {
   19129       746602 :   while ((sym != SymbolTable_NulSym) && (! (SymbolTable_IsProcedure (sym))))
   19130              :     {
   19131       375605 :       sym = SymbolTable_GetScope (sym);
   19132              :     }
   19133       370997 :   if ((sym != SymbolTable_NulSym) && (SymbolTable_IsProcedure (sym)))
   19134              :     {
   19135              :       return sym;
   19136              :     }
   19137              :   else
   19138              :     {
   19139       368663 :       return SymbolTable_NulSym;
   19140              :     }
   19141              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19142              :   __builtin_unreachable ();
   19143              : }
   19144              : 
   19145              : 
   19146              : /*
   19147              :    IsModuleWithinProcedure - returns TRUE if module, sym, is
   19148              :                              inside a procedure.
   19149              : */
   19150              : 
   19151       264007 : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym)
   19152              : {
   19153       264007 :   return (SymbolTable_GetProcedureScope (sym)) != SymbolTable_NulSym;
   19154              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19155              :   __builtin_unreachable ();
   19156              : }
   19157              : 
   19158              : 
   19159              : /*
   19160              :    GetParent - returns the parent of symbol, Sym.
   19161              : */
   19162              : 
   19163      2345148 : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym)
   19164              : {
   19165      2345148 :   SymbolTable_PtrToSymbol pSym;
   19166              : 
   19167      2345148 :   pSym = GetPsym (Sym);
   19168      2345148 :   switch (pSym->SymbolType)
   19169              :     {
   19170            6 :       case SymbolTable_ErrorSym:
   19171            6 :         M2Error_ErrorAbort0 ((const char *) "", 0);
   19172       577900 :         break;
   19173              : 
   19174       577900 :       case SymbolTable_VarientSym:
   19175       577900 :         return pSym->Varient.Parent;
   19176      1737282 :         break;
   19177              : 
   19178      1737282 :       case SymbolTable_VarientFieldSym:
   19179      1737282 :         return pSym->VarientField.Parent;
   19180        29960 :         break;
   19181              : 
   19182        29960 :       case SymbolTable_RecordFieldSym:
   19183        29960 :         return pSym->RecordField.Parent;
   19184            0 :         break;
   19185              : 
   19186            0 :       case SymbolTable_EnumerationFieldSym:
   19187            0 :         return pSym->EnumerationField.Type;
   19188            0 :         break;
   19189              : 
   19190              : 
   19191            0 :       default:
   19192            0 :         M2Error_InternalError ((const char *) "not implemented yet", 19);
   19193              :         break;
   19194              :     }
   19195              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19196              :   __builtin_unreachable ();
   19197              : }
   19198              : 
   19199              : 
   19200              : /*
   19201              :    IsRecordField - returns true if Sym is a record field.
   19202              : */
   19203              : 
   19204    668354627 : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym)
   19205              : {
   19206    668354627 :   SymbolTable_PtrToSymbol pSym;
   19207              : 
   19208    668354627 :   pSym = GetPsym (Sym);
   19209    668354627 :   return pSym->SymbolType == SymbolTable_RecordFieldSym;
   19210              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19211              :   __builtin_unreachable ();
   19212              : }
   19213              : 
   19214              : 
   19215              : /*
   19216              :    MakeProcType - returns a procedure type symbol with ProcTypeName.
   19217              : */
   19218              : 
   19219      5098514 : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName)
   19220              : {
   19221      5098514 :   SymbolTable_PtrToSymbol pSym;
   19222      5098514 :   unsigned int oaf;
   19223      5098514 :   unsigned int sym;
   19224              : 
   19225      5098514 :   tok = CheckTok (tok, (const char *) "proctype", 8);
   19226      5098514 :   sym = HandleHiddenOrDeclare (tok, ProcTypeName, &oaf);
   19227      5098514 :   if (! (SymbolTable_IsError (sym)))
   19228              :     {
   19229      5098514 :       pSym = GetPsym (sym);
   19230      5098514 :       pSym->SymbolType = SymbolTable_ProcTypeSym;
   19231      5098514 :       switch (pSym->SymbolType)
   19232              :         {
   19233      5098514 :           case SymbolTable_ProcTypeSym:
   19234      5098514 :             pSym->ProcType.ReturnType = SymbolTable_NulSym;
   19235      5098514 :             pSym->ProcType.name = ProcTypeName;
   19236      5098514 :             Lists_InitList (&pSym->ProcType.ListOfParam);
   19237      5098514 :             pSym->ProcType.HasVarArgs = false;  /* Does this proc type use ... ?  */
   19238      5098514 :             pSym->ProcType.HasOptArg = false;  /* Does this proc type use [ ] ?  */
   19239      5098514 :             pSym->ProcType.OptArgInit = SymbolTable_NulSym;  /* The optarg initial value.  */
   19240      5098514 :             pSym->ProcType.ReturnOptional = false;  /* Is the return value optional?  */
   19241      5098514 :             pSym->ProcType.ReturnTypeTok = M2LexBuf_UnknownTokenNo;  /* Is the return value optional?  */
   19242      5098514 :             pSym->ProcType.Scope = SymbolTable_GetCurrentScope ();
   19243              :             /* scope of procedure.  */
   19244      5098514 :             pSym->ProcType.Size = M2ALU_InitValue ();
   19245      5098514 :             pSym->ProcType.TotalParamSize = M2ALU_InitValue ();  /* size of all parameters  */
   19246      5098514 :             pSym->ProcType.oafamily = oaf;  /* The oa family for this symbol  */
   19247      5098514 :             InitWhereDeclaredTok (tok, &pSym->ProcType.At);  /* Declared here  */
   19248      5098514 :             break;
   19249              : 
   19250              : 
   19251              :           default:
   19252              :             M2Error_InternalError ((const char *) "expecting ProcType symbol", 25);
   19253      5098514 :             break;
   19254              :         }
   19255              :     }
   19256      5098514 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) doFillInOAFamily});
   19257      5098514 :   return sym;
   19258              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19259              :   __builtin_unreachable ();
   19260              : }
   19261              : 
   19262              : 
   19263              : /*
   19264              :    PutProcTypeParam - Places a Non VAR parameter ParamName with type
   19265              :                       ParamType into ProcType Sym.
   19266              : */
   19267              : 
   19268      8120890 : extern "C" void SymbolTable_PutProcTypeParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded)
   19269              : {
   19270      8120890 :   SymbolTable_PtrToSymbol pSym;
   19271      8120890 :   unsigned int ParSym;
   19272              : 
   19273      8120890 :   NewSym (&ParSym);
   19274      8120890 :   pSym = GetPsym (ParSym);
   19275      8120890 :   pSym->SymbolType = SymbolTable_ParamSym;
   19276      8120890 :   pSym->Param.name = NameKey_NulName;
   19277      8120890 :   pSym->Param.Type = ParamType;
   19278      8120890 :   pSym->Param.IsUnbounded = isUnbounded;
   19279      8120890 :   pSym->Param.ShadowVar = SymbolTable_NulSym;
   19280      8120890 :   pSym->Param.FullTok = tok;
   19281      8120890 :   pSym->Param.At = tok;
   19282      8120890 :   AddParameter (Sym, SymbolTable_ProperProcedure, ParSym);
   19283      8120890 : }
   19284              : 
   19285              : 
   19286              : /*
   19287              :    PutProcTypeVarParam - Places a Non VAR parameter ParamName with type
   19288              :                          ParamType into ProcType Sym.
   19289              : */
   19290              : 
   19291       751744 : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamType, bool isUnbounded)
   19292              : {
   19293       751744 :   SymbolTable_PtrToSymbol pSym;
   19294       751744 :   unsigned int ParSym;
   19295              : 
   19296       751744 :   NewSym (&ParSym);
   19297       751744 :   pSym = GetPsym (ParSym);
   19298       751744 :   pSym->SymbolType = SymbolTable_VarParamSym;
   19299       751744 :   pSym->Param.name = NameKey_NulName;
   19300       751744 :   pSym->Param.Type = ParamType;
   19301       751744 :   pSym->Param.IsUnbounded = isUnbounded;
   19302       751744 :   pSym->Param.ShadowVar = SymbolTable_NulSym;
   19303       751744 :   pSym->Param.FullTok = tok;
   19304       751744 :   pSym->Param.At = tok;
   19305       751744 :   AddParameter (Sym, SymbolTable_ProperProcedure, ParSym);
   19306       751744 : }
   19307              : 
   19308              : 
   19309              : /*
   19310              :    IsProcType - returns true if Sym is a ProcType Symbol.
   19311              : */
   19312              : 
   19313    278039765 : extern "C" bool SymbolTable_IsProcType (unsigned int Sym)
   19314              : {
   19315    278039765 :   SymbolTable_PtrToSymbol pSym;
   19316              : 
   19317    278039765 :   pSym = GetPsym (Sym);
   19318    278039765 :   return pSym->SymbolType == SymbolTable_ProcTypeSym;
   19319              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19320              :   __builtin_unreachable ();
   19321              : }
   19322              : 
   19323              : 
   19324              : /*
   19325              :    IsVar - returns true if Sym is a Var Symbol.
   19326              : */
   19327              : 
   19328    151654752 : extern "C" bool SymbolTable_IsVar (unsigned int Sym)
   19329              : {
   19330    151654752 :   SymbolTable_PtrToSymbol pSym;
   19331              : 
   19332    151654752 :   pSym = GetPsym (Sym);
   19333    151654752 :   return pSym->SymbolType == SymbolTable_VarSym;
   19334              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19335              :   __builtin_unreachable ();
   19336              : }
   19337              : 
   19338              : 
   19339              : /*
   19340              :    IsVarConst - returns the IsConst field indicating the variable is read only.
   19341              : */
   19342              : 
   19343       314927 : extern "C" bool SymbolTable_IsVarConst (unsigned int sym)
   19344              : {
   19345       314927 :   SymbolTable_PtrToSymbol pSym;
   19346              : 
   19347       314927 :   pSym = GetPsym (sym);
   19348       314927 :   switch (pSym->SymbolType)
   19349              :     {
   19350       314927 :       case SymbolTable_VarSym:
   19351       314927 :         return pSym->Var.IsConst;
   19352            0 :         break;
   19353              : 
   19354              : 
   19355            0 :       default:
   19356            0 :         M2Error_InternalError ((const char *) "expecting VarSym", 16);
   19357              :         break;
   19358              :     }
   19359              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19360              :   __builtin_unreachable ();
   19361              : }
   19362              : 
   19363              : 
   19364              : /*
   19365              :    IsConst - returns true if Sym contains a constant value.
   19366              : */
   19367              : 
   19368    235676036 : extern "C" bool SymbolTable_IsConst (unsigned int Sym)
   19369              : {
   19370    235676036 :   if (SymbolTable_IsConstructor (Sym))
   19371              :     {
   19372      3585354 :       return SymbolTable_IsConstructorConstant (Sym);
   19373              :     }
   19374              :   else
   19375              :     {
   19376    232090682 :       return DoIsConst (Sym);
   19377              :     }
   19378              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19379              :   __builtin_unreachable ();
   19380              : }
   19381              : 
   19382              : 
   19383              : /*
   19384              :    IsConstString - returns whether sym is a conststring of any variant.
   19385              : */
   19386              : 
   19387      7433537 : extern "C" bool SymbolTable_IsConstString (unsigned int sym)
   19388              : {
   19389      7433537 :   SymbolTable_PtrToSymbol pSym;
   19390              : 
   19391      7433537 :   pSym = GetPsym (sym);
   19392      7433537 :   return pSym->SymbolType == SymbolTable_ConstStringSym;
   19393              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19394              :   __builtin_unreachable ();
   19395              : }
   19396              : 
   19397              : 
   19398              : /*
   19399              :    IsConstStringNulTerminated - returns TRUE if the constant string, sym,
   19400              :                                 should be created with a nul terminator.
   19401              : */
   19402              : 
   19403            0 : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym)
   19404              : {
   19405            0 :   SymbolTable_PtrToSymbol pSym;
   19406              : 
   19407            0 :   pSym = GetPsym (sym);
   19408            0 :   switch (pSym->SymbolType)
   19409              :     {
   19410            0 :       case SymbolTable_ConstStringSym:
   19411            0 :         return (pSym->ConstString.StringVariant == SymbolTable_m2nulstr) || (pSym->ConstString.StringVariant == SymbolTable_cnulstr);
   19412            0 :         break;
   19413              : 
   19414              : 
   19415            0 :       default:
   19416            0 :         M2Error_InternalError ((const char *) "expecting ConstStringSym", 24);
   19417              :         break;
   19418              :     }
   19419              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19420              :   __builtin_unreachable ();
   19421              : }
   19422              : 
   19423              : 
   19424              : /*
   19425              :    IsConstLit - returns true if Sym is a literal constant.
   19426              : */
   19427              : 
   19428      8890831 : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym)
   19429              : {
   19430      8890831 :   SymbolTable_PtrToSymbol pSym;
   19431              : 
   19432      8890831 :   pSym = GetPsym (Sym);
   19433      8890831 :   return pSym->SymbolType == SymbolTable_ConstLitSym;
   19434              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19435              :   __builtin_unreachable ();
   19436              : }
   19437              : 
   19438              : 
   19439              : /*
   19440              :    IsConstructor - returns TRUE if the constant is declared as a
   19441              :                    constant set, array or record.
   19442              : */
   19443              : 
   19444    383879453 : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym)
   19445              : {
   19446    383879453 :   SymbolTable_PtrToSymbol pSym;
   19447              : 
   19448    383879453 :   pSym = GetPsym (Sym);
   19449    383879453 :   switch (pSym->SymbolType)
   19450              :     {
   19451     62495741 :       case SymbolTable_ConstVarSym:
   19452     62495741 :         return pSym->ConstVar.IsConstructor;
   19453     66895264 :         break;
   19454              : 
   19455     66895264 :       case SymbolTable_ConstLitSym:
   19456     66895264 :         return pSym->ConstLit.IsConstructor;
   19457              :         break;
   19458              : 
   19459              : 
   19460              :       default:
   19461              :         return false;
   19462              :         break;
   19463              :     }
   19464              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19465              :   __builtin_unreachable ();
   19466              : }
   19467              : 
   19468              : 
   19469              : /*
   19470              :    IsDummy - returns true if Sym is a Dummy symbol.
   19471              : */
   19472              : 
   19473            0 : extern "C" bool SymbolTable_IsDummy (unsigned int Sym)
   19474              : {
   19475            0 :   SymbolTable_PtrToSymbol pSym;
   19476              : 
   19477            0 :   pSym = GetPsym (Sym);
   19478            0 :   return pSym->SymbolType == SymbolTable_DummySym;
   19479              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19480              :   __builtin_unreachable ();
   19481              : }
   19482              : 
   19483              : 
   19484              : /*
   19485              :    IsTemporary - returns true if Sym is a Temporary symbol.
   19486              : */
   19487              : 
   19488      1991483 : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym)
   19489              : {
   19490      1991483 :   SymbolTable_PtrToSymbol pSym;
   19491              : 
   19492      1991483 :   pSym = GetPsym (Sym);
   19493      1991483 :   switch (pSym->SymbolType)
   19494              :     {
   19495      1908508 :       case SymbolTable_VarSym:
   19496      1908508 :         return pSym->Var.IsTemp;
   19497         3318 :         break;
   19498              : 
   19499         3318 :       case SymbolTable_ConstVarSym:
   19500         3318 :         return pSym->ConstVar.IsTemp;
   19501              :         break;
   19502              : 
   19503              : 
   19504              :       default:
   19505              :         return false;
   19506              :         break;
   19507              :     }
   19508              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19509              :   __builtin_unreachable ();
   19510              : }
   19511              : 
   19512              : 
   19513              : /*
   19514              :    IsVarAParam - returns true if Sym is a variable declared as a parameter.
   19515              : */
   19516              : 
   19517        33762 : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym)
   19518              : {
   19519        33762 :   SymbolTable_PtrToSymbol pSym;
   19520              : 
   19521        33762 :   pSym = GetPsym (Sym);
   19522        33762 :   switch (pSym->SymbolType)
   19523              :     {
   19524        33762 :       case SymbolTable_VarSym:
   19525        33762 :         return pSym->Var.IsParam;
   19526              :         break;
   19527              : 
   19528              : 
   19529              :       default:
   19530              :         return false;
   19531              :         break;
   19532              :     }
   19533              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19534              :   __builtin_unreachable ();
   19535              : }
   19536              : 
   19537              : 
   19538              : /*
   19539              :    IsSubscript - returns true if Sym is a subscript symbol.
   19540              : */
   19541              : 
   19542      5772274 : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym)
   19543              : {
   19544      5772274 :   SymbolTable_PtrToSymbol pSym;
   19545              : 
   19546      5772274 :   pSym = GetPsym (Sym);
   19547      5772274 :   return pSym->SymbolType == SymbolTable_SubscriptSym;
   19548              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19549              :   __builtin_unreachable ();
   19550              : }
   19551              : 
   19552              : 
   19553              : /*
   19554              :    IsSubrange - returns true if Sym is a subrange symbol.
   19555              : */
   19556              : 
   19557    438604872 : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym)
   19558              : {
   19559    438604872 :   SymbolTable_PtrToSymbol pSym;
   19560              : 
   19561    438604872 :   pSym = GetPsym (Sym);
   19562    438604872 :   return pSym->SymbolType == SymbolTable_SubrangeSym;
   19563              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19564              :   __builtin_unreachable ();
   19565              : }
   19566              : 
   19567              : 
   19568              : /*
   19569              :    IsProcedureVariable - returns true if a Sym is a variable and
   19570              :                          it was declared within a procedure.
   19571              : */
   19572              : 
   19573            0 : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym)
   19574              : {
   19575            0 :   AssertInRange (Sym);
   19576            0 :   return (SymbolTable_IsVar (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetVarScope (Sym)));
   19577              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19578              :   __builtin_unreachable ();
   19579              : }
   19580              : 
   19581              : 
   19582              : /*
   19583              :    IsProcedureNested - returns TRUE if procedure, Sym, was
   19584              :                        declared as a nested procedure.
   19585              : */
   19586              : 
   19587      4561783 : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym)
   19588              : {
   19589      4561783 :   return (SymbolTable_IsProcedure (Sym)) && (SymbolTable_IsProcedure (SymbolTable_GetScope (Sym)));
   19590              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19591              :   __builtin_unreachable ();
   19592              : }
   19593              : 
   19594              : 
   19595              : /*
   19596              :    IsAModula2Type - returns true if Sym, is a:
   19597              :                     IsType, IsPointer, IsRecord, IsEnumeration,
   19598              :                     IsSubrange, IsArray, IsUnbounded, IsProcType.
   19599              :                     NOTE that it different from IsType.
   19600              : */
   19601              : 
   19602     47358449 : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym)
   19603              : {
   19604     47358449 :   AssertInRange (Sym);
   19605     47358449 :   return ((((((((SymbolTable_IsType (Sym)) || (SymbolTable_IsRecord (Sym))) || (SymbolTable_IsPointer (Sym))) || (SymbolTable_IsEnumeration (Sym))) || (SymbolTable_IsSubrange (Sym))) || (SymbolTable_IsArray (Sym))) || (SymbolTable_IsUnbounded (Sym))) || (SymbolTable_IsProcType (Sym))) || (SymbolTable_IsSet (Sym));
   19606              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19607              :   __builtin_unreachable ();
   19608              : }
   19609              : 
   19610              : 
   19611              : /*
   19612              :    IsGnuAsmVolatile - returns TRUE if a GnuAsm symbol was defined as VOLATILE.
   19613              : */
   19614              : 
   19615           27 : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym)
   19616              : {
   19617           27 :   SymbolTable_PtrToSymbol pSym;
   19618              : 
   19619           27 :   pSym = GetPsym (Sym);
   19620           27 :   switch (pSym->SymbolType)
   19621              :     {
   19622           27 :       case SymbolTable_GnuAsmSym:
   19623           27 :         return pSym->GnuAsm.Volatile;
   19624            0 :         break;
   19625              : 
   19626              : 
   19627            0 :       default:
   19628            0 :         M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
   19629              :         break;
   19630              :     }
   19631              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19632              :   __builtin_unreachable ();
   19633              : }
   19634              : 
   19635              : 
   19636              : /*
   19637              :    IsGnuAsmSimple - returns TRUE if a GnuAsm symbol is a simple kind.
   19638              : */
   19639              : 
   19640           27 : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym)
   19641              : {
   19642           27 :   SymbolTable_PtrToSymbol pSym;
   19643              : 
   19644           27 :   pSym = GetPsym (Sym);
   19645           27 :   switch (pSym->SymbolType)
   19646              :     {
   19647           27 :       case SymbolTable_GnuAsmSym:
   19648           27 :         return pSym->GnuAsm.Simple;
   19649            0 :         break;
   19650              : 
   19651              : 
   19652            0 :       default:
   19653            0 :         M2Error_InternalError ((const char *) "expecting GnuAsm symbol", 23);
   19654              :         break;
   19655              :     }
   19656              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19657              :   __builtin_unreachable ();
   19658              : }
   19659              : 
   19660              : 
   19661              : /*
   19662              :    IsGnuAsm - returns TRUE if Sym is a GnuAsm symbol.
   19663              : */
   19664              : 
   19665          108 : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym)
   19666              : {
   19667          108 :   SymbolTable_PtrToSymbol pSym;
   19668              : 
   19669          108 :   pSym = GetPsym (Sym);
   19670          108 :   return pSym->SymbolType == SymbolTable_GnuAsmSym;
   19671              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19672              :   __builtin_unreachable ();
   19673              : }
   19674              : 
   19675              : 
   19676              : /*
   19677              :    IsRegInterface - returns TRUE if Sym is a RegInterface symbol.
   19678              : */
   19679              : 
   19680            0 : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym)
   19681              : {
   19682            0 :   SymbolTable_PtrToSymbol pSym;
   19683              : 
   19684            0 :   pSym = GetPsym (Sym);
   19685            0 :   return pSym->SymbolType == SymbolTable_InterfaceSym;
   19686              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19687              :   __builtin_unreachable ();
   19688              : }
   19689              : 
   19690              : 
   19691              : /*
   19692              :    IsSizeSolved - returns true if the size of Sym is solved.
   19693              : */
   19694              : 
   19695        23496 : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym)
   19696              : {
   19697        23496 :   SymbolTable_PtrToSymbol pSym;
   19698              : 
   19699        23496 :   AssertInRange (Sym);
   19700        23496 :   pSym = GetPsym (Sym);
   19701        23496 :   switch (pSym->SymbolType)
   19702              :     {
   19703            0 :       case SymbolTable_ProcedureSym:
   19704            0 :         return M2ALU_IsSolved (pSym->Procedure.Size);
   19705         3084 :         break;
   19706              : 
   19707         3084 :       case SymbolTable_VarSym:
   19708         3084 :         return M2ALU_IsSolved (pSym->Var.Size);
   19709        16050 :         break;
   19710              : 
   19711        16050 :       case SymbolTable_TypeSym:
   19712        16050 :         return M2ALU_IsSolved (pSym->Type.Size);
   19713          788 :         break;
   19714              : 
   19715          788 :       case SymbolTable_SetSym:
   19716          788 :         return M2ALU_IsSolved (pSym->Set.Size);
   19717           12 :         break;
   19718              : 
   19719           12 :       case SymbolTable_RecordSym:
   19720           12 :         return M2ALU_IsSolved (pSym->Record.Size);
   19721            0 :         break;
   19722              : 
   19723            0 :       case SymbolTable_VarientSym:
   19724            0 :         return M2ALU_IsSolved (pSym->Varient.Size);
   19725           12 :         break;
   19726              : 
   19727           12 :       case SymbolTable_EnumerationSym:
   19728           12 :         return M2ALU_IsSolved (pSym->Enumeration.Size);
   19729           52 :         break;
   19730              : 
   19731           52 :       case SymbolTable_PointerSym:
   19732           52 :         return M2ALU_IsSolved (pSym->Pointer.Size);
   19733         3486 :         break;
   19734              : 
   19735         3486 :       case SymbolTable_ArraySym:
   19736         3486 :         return M2ALU_IsSolved (pSym->Array.Size);
   19737            0 :         break;
   19738              : 
   19739            0 :       case SymbolTable_RecordFieldSym:
   19740            0 :         return M2ALU_IsSolved (pSym->RecordField.Size);
   19741            0 :         break;
   19742              : 
   19743            0 :       case SymbolTable_VarientFieldSym:
   19744            0 :         return M2ALU_IsSolved (pSym->VarientField.Size);
   19745            0 :         break;
   19746              : 
   19747            0 :       case SymbolTable_SubrangeSym:
   19748            0 :         return M2ALU_IsSolved (pSym->Subrange.Size);
   19749            0 :         break;
   19750              : 
   19751            0 :       case SymbolTable_SubscriptSym:
   19752            0 :         return M2ALU_IsSolved (pSym->Subscript.Size);
   19753           12 :         break;
   19754              : 
   19755           12 :       case SymbolTable_ProcTypeSym:
   19756           12 :         return M2ALU_IsSolved (pSym->ProcType.Size);
   19757            0 :         break;
   19758              : 
   19759            0 :       case SymbolTable_UnboundedSym:
   19760            0 :         return M2ALU_IsSolved (pSym->Unbounded.Size);
   19761            0 :         break;
   19762              : 
   19763              : 
   19764            0 :       default:
   19765            0 :         M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
   19766              :         break;
   19767              :     }
   19768              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19769              :   __builtin_unreachable ();
   19770              : }
   19771              : 
   19772              : 
   19773              : /*
   19774              :    IsOffsetSolved - returns true if the Offset of Sym is solved.
   19775              : */
   19776              : 
   19777            0 : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym)
   19778              : {
   19779            0 :   SymbolTable_PtrToSymbol pSym;
   19780              : 
   19781            0 :   AssertInRange (Sym);
   19782            0 :   pSym = GetPsym (Sym);
   19783            0 :   switch (pSym->SymbolType)
   19784              :     {
   19785            0 :       case SymbolTable_VarSym:
   19786            0 :         return M2ALU_IsSolved (pSym->Var.Offset);
   19787            0 :         break;
   19788              : 
   19789            0 :       case SymbolTable_RecordFieldSym:
   19790            0 :         return M2ALU_IsSolved (pSym->RecordField.Offset);
   19791            0 :         break;
   19792              : 
   19793            0 :       case SymbolTable_VarientFieldSym:
   19794            0 :         return M2ALU_IsSolved (pSym->VarientField.Offset);
   19795            0 :         break;
   19796              : 
   19797              : 
   19798            0 :       default:
   19799            0 :         M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
   19800              :         break;
   19801              :     }
   19802              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19803              :   __builtin_unreachable ();
   19804              : }
   19805              : 
   19806              : 
   19807              : /*
   19808              :    IsValueSolved - returns true if the value of Sym is solved.
   19809              : */
   19810              : 
   19811      3661663 : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym)
   19812              : {
   19813      3661663 :   SymbolTable_PtrToSymbol pSym;
   19814              : 
   19815      3661663 :   AssertInRange (Sym);
   19816      3661663 :   pSym = GetPsym (Sym);
   19817      3661663 :   switch (pSym->SymbolType)
   19818              :     {
   19819      2060274 :       case SymbolTable_ConstLitSym:
   19820      2060274 :         return M2ALU_IsSolved (pSym->ConstLit.Value);
   19821       784441 :         break;
   19822              : 
   19823       784441 :       case SymbolTable_ConstVarSym:
   19824       784441 :         return M2ALU_IsSolved (pSym->ConstVar.Value);
   19825       545318 :         break;
   19826              : 
   19827       545318 :       case SymbolTable_EnumerationFieldSym:
   19828       545318 :         return M2ALU_IsSolved (pSym->EnumerationField.Value);
   19829              :         break;
   19830              : 
   19831              :       case SymbolTable_ConstStringSym:
   19832              :         return true;
   19833            6 :         break;
   19834              : 
   19835              : 
   19836            6 :       default:
   19837            6 :         M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
   19838              :         break;
   19839              :     }
   19840              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19841              :   __builtin_unreachable ();
   19842              : }
   19843              : 
   19844              : 
   19845              : /*
   19846              :    IsConstructorConstant - returns TRUE if constructor, Sym, is
   19847              :                            defined by only constants.
   19848              : */
   19849              : 
   19850      4191942 : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym)
   19851              : {
   19852      4191942 :   SymbolTable_PtrToSymbol pSym;
   19853              : 
   19854      4191942 :   if ((SymbolTable_IsConstructor (Sym)) || (SymbolTable_IsConstSet (Sym)))
   19855              :     {
   19856      4191942 :       pSym = GetPsym (Sym);
   19857      4191942 :       switch (pSym->SymbolType)
   19858              :         {
   19859      4191942 :           case SymbolTable_ConstVarSym:
   19860      4191942 :             return M2ALU_IsValueConst (pSym->ConstVar.Value);
   19861            0 :             break;
   19862              : 
   19863            0 :           case SymbolTable_ConstLitSym:
   19864            0 :             return M2ALU_IsValueConst (pSym->ConstLit.Value);
   19865            0 :             break;
   19866              : 
   19867              : 
   19868            0 :           default:
   19869            0 :             M2Error_InternalError ((const char *) "expecting Constructor", 21);
   19870            0 :             break;
   19871              :         }
   19872              :     }
   19873              :   else
   19874              :     {
   19875            0 :       M2Error_InternalError ((const char *) "expecting Constructor", 21);
   19876              :     }
   19877              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19878              :   __builtin_unreachable ();
   19879              : }
   19880              : 
   19881              : 
   19882              : /*
   19883              :    IsComposite - returns TRUE if symbol, sym, is a composite
   19884              :                  type:  ie an ARRAY or RECORD.
   19885              : */
   19886              : 
   19887       145398 : extern "C" bool SymbolTable_IsComposite (unsigned int sym)
   19888              : {
   19889       145398 :   if (sym == SymbolTable_NulSym)
   19890              :     {
   19891              :       return false;
   19892              :     }
   19893              :   else
   19894              :     {
   19895       145374 :       sym = SymbolTable_SkipType (sym);
   19896       145374 :       return (SymbolTable_IsArray (sym)) || (SymbolTable_IsRecord (sym));
   19897              :     }
   19898              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   19899              :   __builtin_unreachable ();
   19900              : }
   19901              : 
   19902              : 
   19903              : /*
   19904              :    IsSumOfParamSizeSolved - has the sum of parameters been solved yet?
   19905              : */
   19906              : 
   19907            0 : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym)
   19908              : {
   19909            0 :   SymbolTable_PtrToSymbol pSym;
   19910              : 
   19911            0 :   AssertInRange (Sym);
   19912            0 :   pSym = GetPsym (Sym);
   19913            0 :   switch (pSym->SymbolType)
   19914              :     {
   19915            0 :       case SymbolTable_ProcedureSym:
   19916            0 :         return M2ALU_IsSolved (pSym->Procedure.TotalParamSize);
   19917            0 :         break;
   19918              : 
   19919            0 :       case SymbolTable_ProcTypeSym:
   19920            0 :         return M2ALU_IsSolved (pSym->ProcType.TotalParamSize);
   19921            0 :         break;
   19922              : 
   19923              : 
   19924            0 :       default:
   19925            0 :         M2Error_InternalError ((const char *) "expecting Procedure or ProcType symbol", 38);
   19926              :         break;
   19927              :     }
   19928              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   19929              :   __builtin_unreachable ();
   19930              : }
   19931              : 
   19932              : 
   19933              : /*
   19934              :    PutAlignment - assigns the alignment constant associated with,
   19935              :                   type, with, align.
   19936              : */
   19937              : 
   19938          192 : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align)
   19939              : {
   19940          192 :   SymbolTable_PtrToSymbol pSym;
   19941              : 
   19942          192 :   pSym = GetPsym (type);
   19943          192 :   switch (pSym->SymbolType)
   19944              :     {
   19945            0 :       case SymbolTable_RecordSym:
   19946            0 :         pSym->Record.Align = align;
   19947            0 :         break;
   19948              : 
   19949          120 :       case SymbolTable_RecordFieldSym:
   19950          120 :         pSym->RecordField.Align = align;
   19951          120 :         break;
   19952              : 
   19953           18 :       case SymbolTable_TypeSym:
   19954           18 :         pSym->Type.Align = align;
   19955           18 :         break;
   19956              : 
   19957           12 :       case SymbolTable_PointerSym:
   19958           12 :         pSym->Pointer.Align = align;
   19959           12 :         break;
   19960              : 
   19961           12 :       case SymbolTable_SubrangeSym:
   19962           12 :         pSym->Subrange.Align = align;
   19963           12 :         break;
   19964              : 
   19965            0 :       case SymbolTable_SetSym:
   19966            0 :         pSym->Set.Align = align;
   19967            0 :         break;
   19968              : 
   19969           30 :       case SymbolTable_ArraySym:
   19970           30 :         pSym->Array.Align = align;
   19971           30 :         break;
   19972              : 
   19973              : 
   19974            0 :       default:
   19975            0 :         M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
   19976          192 :         break;
   19977              :     }
   19978          192 : }
   19979              : 
   19980              : 
   19981              : /*
   19982              :    GetAlignment - returns the alignment constant associated with,
   19983              :                   type.
   19984              : */
   19985              : 
   19986    396963862 : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type)
   19987              : {
   19988    396970024 :   SymbolTable_PtrToSymbol pSym;
   19989              : 
   19990    396970024 :   pSym = GetPsym (type);
   19991    396970024 :   switch (pSym->SymbolType)
   19992              :     {
   19993       105479 :       case SymbolTable_RecordSym:
   19994       105479 :         return pSym->Record.Align;
   19995    234616268 :         break;
   19996              : 
   19997    234616268 :       case SymbolTable_RecordFieldSym:
   19998    234616268 :         return pSym->RecordField.Align;
   19999    101373160 :         break;
   20000              : 
   20001    101373160 :       case SymbolTable_TypeSym:
   20002    101373160 :         return pSym->Type.Align;
   20003     49502521 :         break;
   20004              : 
   20005     49502521 :       case SymbolTable_PointerSym:
   20006     49502521 :         return pSym->Pointer.Align;
   20007         6126 :         break;
   20008              : 
   20009         6126 :       case SymbolTable_VarientFieldSym:
   20010         6126 :         return SymbolTable_GetAlignment (pSym->VarientField.Parent);
   20011           36 :         break;
   20012              : 
   20013           36 :       case SymbolTable_VarientSym:
   20014           36 :         return SymbolTable_GetAlignment (pSym->Varient.Parent);
   20015      5997832 :         break;
   20016              : 
   20017      5997832 :       case SymbolTable_SubrangeSym:
   20018      5997832 :         return pSym->Subrange.Align;
   20019            0 :         break;
   20020              : 
   20021            0 :       case SymbolTable_SetSym:
   20022            0 :         return pSym->Set.Align;
   20023      5368602 :         break;
   20024              : 
   20025      5368602 :       case SymbolTable_ArraySym:
   20026      5368602 :         return pSym->Array.Align;
   20027            0 :         break;
   20028              : 
   20029              : 
   20030            0 :       default:
   20031            0 :         M2Error_InternalError ((const char *) "expecting record, field, pointer, type, subrange or an array symbol", 67);
   20032              :         break;
   20033              :     }
   20034              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20035              :   __builtin_unreachable ();
   20036              : }
   20037              : 
   20038              : 
   20039              : /*
   20040              :    GetDefaultRecordFieldAlignment - assigns, align, as the default alignment
   20041              :                                     to record, sym.
   20042              : */
   20043              : 
   20044     44755920 : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym)
   20045              : {
   20046     44761974 :   SymbolTable_PtrToSymbol pSym;
   20047              : 
   20048     44761974 :   pSym = GetPsym (sym);
   20049     44761974 :   switch (pSym->SymbolType)
   20050              :     {
   20051     44755920 :       case SymbolTable_RecordSym:
   20052     44755920 :         return pSym->Record.DefaultAlign;
   20053         6054 :         break;
   20054              : 
   20055         6054 :       case SymbolTable_VarientFieldSym:
   20056         6054 :         return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
   20057            0 :         break;
   20058              : 
   20059            0 :       case SymbolTable_VarientSym:
   20060            0 :         return SymbolTable_GetDefaultRecordFieldAlignment (SymbolTable_GetParent (sym));
   20061            0 :         break;
   20062              : 
   20063              : 
   20064            0 :       default:
   20065            0 :         M2Error_InternalError ((const char *) "expecting record symbol", 23);
   20066              :         break;
   20067              :     }
   20068              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20069              :   __builtin_unreachable ();
   20070              : }
   20071              : 
   20072              : 
   20073              : /*
   20074              :    PutDefaultRecordFieldAlignment - assigns, align, as the default alignment
   20075              :                                     to record, sym.
   20076              : */
   20077              : 
   20078           36 : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align)
   20079              : {
   20080           36 :   SymbolTable_PtrToSymbol pSym;
   20081              : 
   20082           36 :   pSym = GetPsym (sym);
   20083           36 :   switch (pSym->SymbolType)
   20084              :     {
   20085           36 :       case SymbolTable_RecordSym:
   20086           36 :         pSym->Record.DefaultAlign = align;
   20087           36 :         break;
   20088              : 
   20089              : 
   20090            0 :       default:
   20091            0 :         M2Error_InternalError ((const char *) "expecting record symbol", 23);
   20092           36 :         break;
   20093              :     }
   20094           36 : }
   20095              : 
   20096              : 
   20097              : /*
   20098              :    PutUnused - sets, sym, as unused.  This is a gm2 pragma.
   20099              : */
   20100              : 
   20101            0 : extern "C" void SymbolTable_PutUnused (unsigned int sym)
   20102              : {
   20103            0 :   SymbolTable_PtrToSymbol pSym;
   20104              : 
   20105            0 :   pSym = GetPsym (sym);
   20106            0 :   switch (pSym->SymbolType)
   20107              :     {
   20108            0 :       case SymbolTable_RecordFieldSym:
   20109            0 :         pSym->RecordField.Used = false;
   20110            0 :         break;
   20111              : 
   20112              : 
   20113            0 :       default:
   20114            0 :         M2MetaError_MetaError1 ((const char *) "cannot use pragma 'unused' on symbol {%1ad}", 43, sym);
   20115            0 :         break;
   20116              :     }
   20117            0 : }
   20118              : 
   20119              : 
   20120              : /*
   20121              :    IsUnused - returns TRUE if the symbol was declared as unused with a
   20122              :               gm2 pragma.
   20123              : */
   20124              : 
   20125       143312 : extern "C" bool SymbolTable_IsUnused (unsigned int sym)
   20126              : {
   20127       143312 :   SymbolTable_PtrToSymbol pSym;
   20128              : 
   20129       143312 :   pSym = GetPsym (sym);
   20130       143312 :   switch (pSym->SymbolType)
   20131              :     {
   20132       143312 :       case SymbolTable_RecordFieldSym:
   20133       143312 :         return ! pSym->RecordField.Used;
   20134            0 :         break;
   20135              : 
   20136              : 
   20137            0 :       default:
   20138            0 :         M2Error_InternalError ((const char *) "expecting a record field symbol", 31);
   20139              :         break;
   20140              :     }
   20141              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20142              :   __builtin_unreachable ();
   20143              : }
   20144              : 
   20145              : 
   20146              : /*
   20147              :    PutDeclaredPacked - sets the Packed field of the record or record field symbol.
   20148              : */
   20149              : 
   20150       513391 : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b)
   20151              : {
   20152       513391 :   SymbolTable_PtrToSymbol pSym;
   20153              : 
   20154       513391 :   pSym = GetPsym (sym);
   20155       513391 :   switch (pSym->SymbolType)
   20156              :     {
   20157        99353 :       case SymbolTable_RecordSym:
   20158        99353 :         pSym->Record.DeclPacked = b;
   20159        99353 :         pSym->Record.DeclResolved = true;
   20160        99353 :         break;
   20161              : 
   20162       402086 :       case SymbolTable_RecordFieldSym:
   20163       402086 :         pSym->RecordField.DeclPacked = b;
   20164       402086 :         pSym->RecordField.DeclResolved = true;
   20165       402086 :         break;
   20166              : 
   20167         6024 :       case SymbolTable_VarientFieldSym:
   20168         6024 :         pSym->VarientField.DeclPacked = b;
   20169         6024 :         pSym->VarientField.DeclResolved = true;
   20170         6024 :         break;
   20171              : 
   20172         5928 :       case SymbolTable_VarientSym:
   20173         5928 :         pSym->Varient.DeclPacked = b;
   20174         5928 :         pSym->Varient.DeclResolved = true;
   20175         5928 :         break;
   20176              : 
   20177              : 
   20178            0 :       default:
   20179            0 :         M2Error_InternalError ((const char *) "expecting a record or field record symbol", 41);
   20180       513391 :         break;
   20181              :     }
   20182       513391 : }
   20183              : 
   20184              : 
   20185              : /*
   20186              :    IsDeclaredPacked - was the record symbol or record field, sym,
   20187              :                       declared as packed?
   20188              : */
   20189              : 
   20190      1423342 : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym)
   20191              : {
   20192      1423342 :   SymbolTable_PtrToSymbol pSym;
   20193              : 
   20194      1423342 :   pSym = GetPsym (sym);
   20195      1423342 :   switch (pSym->SymbolType)
   20196              :     {
   20197       198706 :       case SymbolTable_RecordSym:
   20198       198706 :         return pSym->Record.DeclPacked;
   20199      1206480 :         break;
   20200              : 
   20201      1206480 :       case SymbolTable_RecordFieldSym:
   20202      1206480 :         return pSym->RecordField.DeclPacked;
   20203        12180 :         break;
   20204              : 
   20205        12180 :       case SymbolTable_VarientFieldSym:
   20206        12180 :         return pSym->VarientField.DeclPacked;
   20207         5976 :         break;
   20208              : 
   20209         5976 :       case SymbolTable_VarientSym:
   20210         5976 :         return pSym->Varient.DeclPacked;
   20211            0 :         break;
   20212              : 
   20213              : 
   20214            0 :       default:
   20215            0 :         M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
   20216              :         break;
   20217              :     }
   20218              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20219              :   __builtin_unreachable ();
   20220              : }
   20221              : 
   20222              : 
   20223              : /*
   20224              :    IsDeclaredPackedResolved - do we know if the record symbol or record
   20225              :                               field, sym, declared as packed or not packed?
   20226              : */
   20227              : 
   20228            0 : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym)
   20229              : {
   20230            0 :   SymbolTable_PtrToSymbol pSym;
   20231              : 
   20232            0 :   pSym = GetPsym (sym);
   20233            0 :   switch (pSym->SymbolType)
   20234              :     {
   20235            0 :       case SymbolTable_RecordSym:
   20236            0 :         return pSym->Record.DeclResolved;
   20237            0 :         break;
   20238              : 
   20239            0 :       case SymbolTable_RecordFieldSym:
   20240            0 :         return pSym->RecordField.DeclResolved;
   20241            0 :         break;
   20242              : 
   20243            0 :       case SymbolTable_VarientFieldSym:
   20244            0 :         return pSym->VarientField.DeclResolved;
   20245            0 :         break;
   20246              : 
   20247            0 :       case SymbolTable_VarientSym:
   20248            0 :         return pSym->Varient.DeclResolved;
   20249            0 :         break;
   20250              : 
   20251              : 
   20252            0 :       default:
   20253            0 :         M2Error_InternalError ((const char *) "expecting a record or a record field symbol", 43);
   20254              :         break;
   20255              :     }
   20256              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20257              :   __builtin_unreachable ();
   20258              : }
   20259              : 
   20260              : 
   20261              : /*
   20262              :    GetPackedEquivalent - returns the packed equivalent of type, sym.
   20263              :                          sym must be a type, subrange or enumerated type.
   20264              : */
   20265              : 
   20266        14276 : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym)
   20267              : {
   20268        14276 :   SymbolTable_PtrToSymbol pSym;
   20269              : 
   20270        14276 :   pSym = GetPsym (sym);
   20271        14276 :   switch (pSym->SymbolType)
   20272              :     {
   20273        14156 :       case SymbolTable_EnumerationSym:
   20274        14156 :         return GetEquivalent (&pSym->Enumeration.packedInfo, sym);
   20275          120 :         break;
   20276              : 
   20277          120 :       case SymbolTable_SubrangeSym:
   20278          120 :         return GetEquivalent (&pSym->Subrange.packedInfo, sym);
   20279            0 :         break;
   20280              : 
   20281            0 :       case SymbolTable_TypeSym:
   20282            0 :         return GetEquivalent (&pSym->Type.packedInfo, sym);
   20283            0 :         break;
   20284              : 
   20285            0 :       case SymbolTable_SetSym:
   20286            0 :         return GetEquivalent (&pSym->Set.packedInfo, sym);
   20287            0 :         break;
   20288              : 
   20289              : 
   20290            0 :       default:
   20291            0 :         M2Error_InternalError ((const char *) "expecting type, subrange or enumerated type symbol", 50);
   20292              :         break;
   20293              :     }
   20294              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20295              :   __builtin_unreachable ();
   20296              : }
   20297              : 
   20298              : 
   20299              : /*
   20300              :    GetNonPackedEquivalent - returns the equivalent non packed symbol associated with, sym.
   20301              : */
   20302              : 
   20303            0 : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym)
   20304              : {
   20305            0 :   SymbolTable_PtrToSymbol pSym;
   20306              : 
   20307            0 :   pSym = GetPsym (sym);
   20308            0 :   switch (pSym->SymbolType)
   20309              :     {
   20310            0 :       case SymbolTable_EquivSym:
   20311            0 :         return pSym->Equiv.nonPacked;
   20312            0 :         break;
   20313              : 
   20314              : 
   20315            0 :       default:
   20316            0 :         M2Error_InternalError ((const char *) "expecting equivalent symbol", 27);
   20317              :         break;
   20318              :     }
   20319              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20320              :   __builtin_unreachable ();
   20321              : }
   20322              : 
   20323              : 
   20324              : /*
   20325              :    IsEquivalent - returns TRUE if, sym, is an equivalent symbol.
   20326              : */
   20327              : 
   20328            0 : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym)
   20329              : {
   20330            0 :   SymbolTable_PtrToSymbol pSym;
   20331              : 
   20332            0 :   pSym = GetPsym (sym);
   20333            0 :   switch (pSym->SymbolType)
   20334              :     {
   20335              :       case SymbolTable_EquivSym:
   20336              :         return true;
   20337            0 :         break;
   20338              : 
   20339              : 
   20340            0 :       default:
   20341            0 :         return false;
   20342              :         break;
   20343              :     }
   20344              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20345              :   __builtin_unreachable ();
   20346              : }
   20347              : 
   20348              : 
   20349              : /*
   20350              :    PushSize - pushes the size of Sym.
   20351              : */
   20352              : 
   20353        99036 : extern "C" void SymbolTable_PushSize (unsigned int Sym)
   20354              : {
   20355        99036 :   SymbolTable_PtrToSymbol pSym;
   20356              : 
   20357        99036 :   AssertInRange (Sym);
   20358        99036 :   pSym = GetPsym (Sym);
   20359        99036 :   switch (pSym->SymbolType)
   20360              :     {
   20361            0 :       case SymbolTable_ProcedureSym:
   20362            0 :         M2ALU_PushFrom (pSym->Procedure.Size);
   20363            0 :         break;
   20364              : 
   20365         3084 :       case SymbolTable_VarSym:
   20366         3084 :         M2ALU_PushFrom (pSym->Var.Size);
   20367         3084 :         break;
   20368              : 
   20369        16050 :       case SymbolTable_TypeSym:
   20370        16050 :         M2ALU_PushFrom (pSym->Type.Size);
   20371        16050 :         break;
   20372              : 
   20373          788 :       case SymbolTable_SetSym:
   20374          788 :         M2ALU_PushFrom (pSym->Set.Size);
   20375          788 :         break;
   20376              : 
   20377            0 :       case SymbolTable_VarientSym:
   20378            0 :         M2ALU_PushFrom (pSym->Varient.Size);
   20379            0 :         break;
   20380              : 
   20381           12 :       case SymbolTable_RecordSym:
   20382           12 :         M2ALU_PushFrom (pSym->Record.Size);
   20383           12 :         break;
   20384              : 
   20385           12 :       case SymbolTable_EnumerationSym:
   20386           12 :         M2ALU_PushFrom (pSym->Enumeration.Size);
   20387           12 :         break;
   20388              : 
   20389        75592 :       case SymbolTable_PointerSym:
   20390        75592 :         M2ALU_PushFrom (pSym->Pointer.Size);
   20391        75592 :         break;
   20392              : 
   20393         3486 :       case SymbolTable_ArraySym:
   20394         3486 :         M2ALU_PushFrom (pSym->Array.Size);
   20395         3486 :         break;
   20396              : 
   20397            0 :       case SymbolTable_RecordFieldSym:
   20398            0 :         M2ALU_PushFrom (pSym->RecordField.Size);
   20399            0 :         break;
   20400              : 
   20401            0 :       case SymbolTable_VarientFieldSym:
   20402            0 :         M2ALU_PushFrom (pSym->VarientField.Size);
   20403            0 :         break;
   20404              : 
   20405            0 :       case SymbolTable_SubrangeSym:
   20406            0 :         M2ALU_PushFrom (pSym->Subrange.Size);
   20407            0 :         break;
   20408              : 
   20409            0 :       case SymbolTable_SubscriptSym:
   20410            0 :         M2ALU_PushFrom (pSym->Subscript.Size);
   20411            0 :         break;
   20412              : 
   20413           12 :       case SymbolTable_ProcTypeSym:
   20414           12 :         M2ALU_PushFrom (pSym->ProcType.Size);
   20415           12 :         break;
   20416              : 
   20417            0 :       case SymbolTable_UnboundedSym:
   20418            0 :         M2ALU_PushFrom (pSym->Unbounded.Size);
   20419            0 :         break;
   20420              : 
   20421              : 
   20422            0 :       default:
   20423            0 :         M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
   20424        99036 :         break;
   20425              :     }
   20426        99036 : }
   20427              : 
   20428              : 
   20429              : /*
   20430              :    PopSize - pops the ALU stack into Size of Sym.
   20431              : */
   20432              : 
   20433       836950 : extern "C" void SymbolTable_PopSize (unsigned int Sym)
   20434              : {
   20435       836950 :   SymbolTable_PtrToSymbol pSym;
   20436              : 
   20437       836950 :   AssertInRange (Sym);
   20438       836950 :   pSym = GetPsym (Sym);
   20439       836950 :   switch (pSym->SymbolType)
   20440              :     {
   20441            0 :       case SymbolTable_ProcedureSym:
   20442            0 :         M2ALU_PopInto (pSym->Procedure.Size);
   20443            0 :         break;
   20444              : 
   20445         2788 :       case SymbolTable_VarSym:
   20446         2788 :         M2ALU_PopInto (pSym->Var.Size);
   20447         2788 :         break;
   20448              : 
   20449       583142 :       case SymbolTable_TypeSym:
   20450       583142 :         M2ALU_PopInto (pSym->Type.Size);
   20451       583142 :         break;
   20452              : 
   20453           12 :       case SymbolTable_RecordSym:
   20454           12 :         M2ALU_PopInto (pSym->Record.Size);
   20455           12 :         break;
   20456              : 
   20457            0 :       case SymbolTable_VarientSym:
   20458            0 :         M2ALU_PopInto (pSym->Varient.Size);
   20459            0 :         break;
   20460              : 
   20461            6 :       case SymbolTable_EnumerationSym:
   20462            6 :         M2ALU_PopInto (pSym->Enumeration.Size);
   20463            6 :         break;
   20464              : 
   20465        14980 :       case SymbolTable_PointerSym:
   20466        14980 :         M2ALU_PopInto (pSym->Pointer.Size);
   20467        14980 :         break;
   20468              : 
   20469          636 :       case SymbolTable_ArraySym:
   20470          636 :         M2ALU_PopInto (pSym->Array.Size);
   20471          636 :         break;
   20472              : 
   20473            0 :       case SymbolTable_RecordFieldSym:
   20474            0 :         M2ALU_PopInto (pSym->RecordField.Size);
   20475            0 :         break;
   20476              : 
   20477            0 :       case SymbolTable_VarientFieldSym:
   20478            0 :         M2ALU_PopInto (pSym->VarientField.Size);
   20479            0 :         break;
   20480              : 
   20481            0 :       case SymbolTable_SubrangeSym:
   20482            0 :         M2ALU_PopInto (pSym->Subrange.Size);
   20483            0 :         break;
   20484              : 
   20485       160574 :       case SymbolTable_SubscriptSym:
   20486       160574 :         M2ALU_PopInto (pSym->Subscript.Size);
   20487       160574 :         break;
   20488              : 
   20489        14964 :       case SymbolTable_ProcTypeSym:
   20490        14964 :         M2ALU_PopInto (pSym->ProcType.Size);
   20491        14964 :         break;
   20492              : 
   20493            0 :       case SymbolTable_UnboundedSym:
   20494            0 :         M2ALU_PopInto (pSym->Unbounded.Size);
   20495            0 :         break;
   20496              : 
   20497        59848 :       case SymbolTable_SetSym:
   20498        59848 :         M2ALU_PopInto (pSym->Set.Size);
   20499        59848 :         break;
   20500              : 
   20501              : 
   20502            0 :       default:
   20503            0 :         M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
   20504       836950 :         break;
   20505              :     }
   20506       836950 : }
   20507              : 
   20508              : 
   20509              : /*
   20510              :    PushValue - pushes the Value of Sym onto the ALU stack.
   20511              : */
   20512              : 
   20513     25625652 : extern "C" void SymbolTable_PushValue (unsigned int Sym)
   20514              : {
   20515     25625652 :   SymbolTable_PtrToSymbol pSym;
   20516              : 
   20517     25625652 :   AssertInRange (Sym);
   20518     25625652 :   pSym = GetPsym (Sym);
   20519     25625652 :   switch (pSym->SymbolType)
   20520              :     {
   20521      2470696 :       case SymbolTable_ConstLitSym:
   20522      2470696 :         M2ALU_PushFrom (pSym->ConstLit.Value);
   20523      2470696 :         break;
   20524              : 
   20525      1860136 :       case SymbolTable_ConstVarSym:
   20526      1860136 :         M2ALU_PushFrom (pSym->ConstVar.Value);
   20527      1860136 :         break;
   20528              : 
   20529     21261896 :       case SymbolTable_EnumerationFieldSym:
   20530     21261896 :         M2ALU_PushFrom (pSym->EnumerationField.Value);
   20531     21261896 :         break;
   20532              : 
   20533        32924 :       case SymbolTable_ConstStringSym:
   20534        32924 :         PushConstString (Sym);
   20535        32924 :         break;
   20536              : 
   20537              : 
   20538            0 :       default:
   20539            0 :         M2Error_InternalError ((const char *) "not expecting this kind of symbol", 33);
   20540     25625652 :         break;
   20541              :     }
   20542     25625652 : }
   20543              : 
   20544              : 
   20545              : /*
   20546              :    PushVarSize - pushes the size of a variable, Sym.
   20547              :                  The runtime size of Sym will depend upon its addressing mode,
   20548              :                  RightValue has size PushSize(GetType(Sym)) and
   20549              :                  LeftValue has size PushSize(Address) since it points to a
   20550              :                  variable.
   20551              : */
   20552              : 
   20553            0 : extern "C" void SymbolTable_PushVarSize (unsigned int Sym)
   20554              : {
   20555            0 :   AssertInRange (Sym);
   20556            0 :   M2Debug_Assert (SymbolTable_IsVar (Sym));
   20557            0 :   if ((SymbolTable_GetMode (Sym)) == SymbolTable_LeftValue)
   20558              :     {
   20559            0 :       SymbolTable_PushSize (M2System_Address);
   20560              :     }
   20561              :   else
   20562              :     {
   20563            0 :       M2Debug_Assert ((SymbolTable_GetMode (Sym)) == SymbolTable_RightValue);
   20564            0 :       SymbolTable_PushSize (SymbolTable_GetType (Sym));
   20565              :     }
   20566            0 : }
   20567              : 
   20568              : 
   20569              : /*
   20570              :    PopValue - pops the ALU stack into Value of Sym.
   20571              : */
   20572              : 
   20573      1344961 : extern "C" void SymbolTable_PopValue (unsigned int Sym)
   20574              : {
   20575      1344961 :   SymbolTable_PtrToSymbol pSym;
   20576              : 
   20577      1344961 :   AssertInRange (Sym);
   20578      1344961 :   pSym = GetPsym (Sym);
   20579      1344961 :   switch (pSym->SymbolType)
   20580              :     {
   20581            0 :       case SymbolTable_ConstLitSym:
   20582            0 :         M2ALU_PopInto (pSym->ConstLit.Value);
   20583            0 :         break;
   20584              : 
   20585      1344961 :       case SymbolTable_ConstVarSym:
   20586      1344961 :         M2ALU_PopInto (pSym->ConstVar.Value);
   20587      1344961 :         break;
   20588              : 
   20589            0 :       case SymbolTable_EnumerationFieldSym:
   20590            0 :         M2Error_InternalError ((const char *) "cannot pop into an enumeration field", 36);
   20591            0 :         break;
   20592              : 
   20593              : 
   20594            0 :       default:
   20595            0 :         M2Error_InternalError ((const char *) "symbol type not expected", 24);
   20596      1344961 :         break;
   20597              :     }
   20598      1344961 : }
   20599              : 
   20600              : 
   20601              : /*
   20602              :    IsObject - returns TRUE if the symbol is an object symbol.
   20603              : */
   20604              : 
   20605            0 : extern "C" bool SymbolTable_IsObject (unsigned int Sym)
   20606              : {
   20607            0 :   SymbolTable_PtrToSymbol pSym;
   20608              : 
   20609            0 :   AssertInRange (Sym);
   20610            0 :   pSym = GetPsym (Sym);
   20611            0 :   return pSym->SymbolType == SymbolTable_ObjectSym;
   20612              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20613              :   __builtin_unreachable ();
   20614              : }
   20615              : 
   20616              : 
   20617              : /*
   20618              :    IsTuple - returns TRUE if the symbol is a tuple symbol.
   20619              : */
   20620              : 
   20621        17504 : extern "C" bool SymbolTable_IsTuple (unsigned int Sym)
   20622              : {
   20623        17504 :   SymbolTable_PtrToSymbol pSym;
   20624              : 
   20625        17504 :   AssertInRange (Sym);
   20626        17504 :   pSym = GetPsym (Sym);
   20627        17504 :   return pSym->SymbolType == SymbolTable_TupleSym;
   20628              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20629              :   __builtin_unreachable ();
   20630              : }
   20631              : 
   20632              : 
   20633              : /*
   20634              :    Make2Tuple - creates and returns a 2 tuple from, a, and, b.
   20635              : */
   20636              : 
   20637         3004 : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b)
   20638              : {
   20639         3004 :   SymbolTable_PtrToSymbol pSym;
   20640         3004 :   unsigned int Sym;
   20641              : 
   20642         3004 :   NewSym (&Sym);
   20643         3004 :   pSym = GetPsym (Sym);
   20644         3004 :   pSym->SymbolType = SymbolTable_TupleSym;
   20645         3004 :   pSym->Tuple.nTuple = 2;
   20646         3004 :   pSym->Tuple.list = Indexing_InitIndex (1);
   20647         3004 :   PutIntoIndex (&pSym->Tuple.list, 1, a);
   20648         3004 :   PutIntoIndex (&pSym->Tuple.list, 2, b);
   20649         3004 :   InitWhereDeclared (&pSym->Tuple.At);
   20650         3004 :   InitWhereFirstUsed (&pSym->Tuple.At);
   20651         3004 :   return Sym;
   20652              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20653              :   __builtin_unreachable ();
   20654              : }
   20655              : 
   20656              : 
   20657              : /*
   20658              :    MakeError - creates an error node, which can be used in MetaError messages.
   20659              :                It will be removed from ExportUndeclared and Unknown trees.
   20660              : */
   20661              : 
   20662          200 : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name)
   20663              : {
   20664          200 :   SymbolTable_PtrToSymbol pSym;
   20665          200 :   unsigned int Sym;
   20666              : 
   20667              :   /* if Sym is present on the unknown tree then remove it  */
   20668          200 :   Sym = FetchUnknownSym (name);
   20669          200 :   if (Sym == SymbolTable_NulSym)
   20670              :     {
   20671          194 :       NewSym (&Sym);
   20672              :     }
   20673              :   else
   20674              :     {
   20675              :       /* 
   20676              :          remove symbol from this tree as we have already generated
   20677              :          a meaningful error message
   20678              :   */
   20679            6 :       RemoveExportUndeclared (SymbolTable_GetCurrentModuleScope (), Sym);
   20680              :     }
   20681          200 :   pSym = GetPsym (Sym);
   20682          200 :   pSym->SymbolType = SymbolTable_ErrorSym;
   20683          200 :   pSym->Error.name = name;
   20684          200 :   pSym->Error.Scope = SymbolTable_GetCurrentScope ();
   20685          200 :   InitWhereDeclaredTok (tok, &pSym->Error.At);
   20686          200 :   InitWhereFirstUsedTok (tok, &pSym->Error.At);
   20687          200 :   return Sym;
   20688              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20689              :   __builtin_unreachable ();
   20690              : }
   20691              : 
   20692              : 
   20693              : /*
   20694              :    MakeErrorS - creates an error node from a string, which can be used
   20695              :                 in MetaError messages.
   20696              :                 It will be removed from ExportUndeclared and Unknown trees.
   20697              : */
   20698              : 
   20699            0 : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name)
   20700              : {
   20701            0 :   return SymbolTable_MakeError (tok, NameKey_makekey (DynamicStrings_string (name)));
   20702              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20703              :   __builtin_unreachable ();
   20704              : }
   20705              : 
   20706              : 
   20707              : /*
   20708              :    IsError - returns TRUE if the symbol is an error symbol.
   20709              : */
   20710              : 
   20711     31436834 : extern "C" bool SymbolTable_IsError (unsigned int Sym)
   20712              : {
   20713     31436834 :   SymbolTable_PtrToSymbol pSym;
   20714              : 
   20715     31436834 :   AssertInRange (Sym);
   20716     31436834 :   pSym = GetPsym (Sym);
   20717     31436834 :   return pSym->SymbolType == SymbolTable_ErrorSym;
   20718              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20719              :   __builtin_unreachable ();
   20720              : }
   20721              : 
   20722              : 
   20723              : /*
   20724              :    IsLegal - returns TRUE if, sym, is a legal symbol.
   20725              : */
   20726              : 
   20727      1033811 : extern "C" bool SymbolTable_IsLegal (unsigned int sym)
   20728              : {
   20729      1033811 :   return sym < FreeSymbol;
   20730              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20731              :   __builtin_unreachable ();
   20732              : }
   20733              : 
   20734              : 
   20735              : /*
   20736              :    PutModuleContainsBuiltin - sets a flag in the current compiled module which
   20737              :                               indicates that a builtin procedure is being declared.
   20738              :                               This is only expected to be called when we are
   20739              :                               parsing the definition module.
   20740              : */
   20741              : 
   20742       440526 : extern "C" void SymbolTable_PutModuleContainsBuiltin (void)
   20743              : {
   20744       440526 :   SymbolTable_PtrToSymbol pSym;
   20745              : 
   20746       440526 :   SymbolTable_PutHiddenTypeDeclared ();
   20747       440526 :   pSym = GetPsym (CurrentModule);
   20748       440526 :   switch (pSym->SymbolType)
   20749              :     {
   20750       440526 :       case SymbolTable_DefImpSym:
   20751       440526 :         pSym->DefImp.ContainsBuiltin = true;
   20752       440526 :         break;
   20753              : 
   20754              : 
   20755            0 :       default:
   20756            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   20757       440526 :         break;
   20758              :     }
   20759       440526 : }
   20760              : 
   20761              : 
   20762              : /*
   20763              :    IsBuiltinInModule - returns true if a module, Sym, has declared a builtin procedure.
   20764              : */
   20765              : 
   20766       157647 : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym)
   20767              : {
   20768       157647 :   SymbolTable_PtrToSymbol pSym;
   20769              : 
   20770       157647 :   pSym = GetPsym (Sym);
   20771       157647 :   switch (pSym->SymbolType)
   20772              :     {
   20773       157647 :       case SymbolTable_DefImpSym:
   20774       157647 :         return pSym->DefImp.ContainsBuiltin;
   20775            0 :         break;
   20776              : 
   20777              : 
   20778            0 :       default:
   20779            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   20780              :         break;
   20781              :     }
   20782              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20783              :   __builtin_unreachable ();
   20784              : }
   20785              : 
   20786              : 
   20787              : /*
   20788              :    PutHiddenTypeDeclared - sets a flag in the current compiled module which
   20789              :                            indicates that a Hidden Type is declared within
   20790              :                            the implementation part of the module.
   20791              :                            This procedure is expected to be called while
   20792              :                            compiling the associated definition module.
   20793              : */
   20794              : 
   20795      1352131 : extern "C" void SymbolTable_PutHiddenTypeDeclared (void)
   20796              : {
   20797      1352131 :   SymbolTable_PtrToSymbol pSym;
   20798              : 
   20799      1352131 :   pSym = GetPsym (CurrentModule);
   20800      1352131 :   switch (pSym->SymbolType)
   20801              :     {
   20802      1352131 :       case SymbolTable_DefImpSym:
   20803      1352131 :         pSym->DefImp.ContainsHiddenType = true;
   20804      1352131 :         break;
   20805              : 
   20806              : 
   20807            0 :       default:
   20808            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   20809      1352131 :         break;
   20810              :     }
   20811      1352131 : }
   20812              : 
   20813              : 
   20814              : /*
   20815              :    IsHiddenTypeDeclared - returns true if a Hidden Type was declared in
   20816              :                           the module, Sym.
   20817              : */
   20818              : 
   20819      8232315 : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym)
   20820              : {
   20821      8232315 :   SymbolTable_PtrToSymbol pSym;
   20822              : 
   20823      8232315 :   pSym = GetPsym (Sym);
   20824      8232315 :   switch (pSym->SymbolType)
   20825              :     {
   20826      8232315 :       case SymbolTable_DefImpSym:
   20827      8232315 :         return pSym->DefImp.ContainsHiddenType;
   20828            0 :         break;
   20829              : 
   20830              : 
   20831            0 :       default:
   20832            0 :         M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   20833              :         break;
   20834              :     }
   20835              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   20836              :   __builtin_unreachable ();
   20837              : }
   20838              : 
   20839              : 
   20840              : /*
   20841              :    IsHiddenReallyPointer - returns TRUE is sym is a pointer, address or a
   20842              :                            type declared as a pointer or address.
   20843              : */
   20844              : 
   20845       435164 : extern "C" bool SymbolTable_IsHiddenReallyPointer (unsigned int Sym)
   20846              : {
   20847       435164 :   if (SymbolTable_IsVar (Sym))
   20848              :     {
   20849            0 :       Sym = SymbolTable_GetType (Sym);
   20850              :     }
   20851       455494 :   while ((Sym != SymbolTable_NulSym) && (SymbolTable_IsType (Sym)))
   20852              :     {
   20853        20330 :       Sym = SymbolTable_SkipType (SymbolTable_GetType (Sym));
   20854              :     }
   20855       435164 :   return (Sym != SymbolTable_NulSym) && ((SymbolTable_IsPointer (Sym)) || (Sym == M2System_Address));
   20856              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   20857              :   __builtin_unreachable ();
   20858              : }
   20859              : 
   20860              : 
   20861              : /*
   20862              :    DisplayTrees - displays the SymbolTrees for Module symbol, ModSym.
   20863              : */
   20864              : 
   20865            0 : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym)
   20866              : {
   20867            0 :   SymbolTable_PtrToSymbol pSym;
   20868            0 :   NameKey_Name n;
   20869              : 
   20870            0 :   n = SymbolTable_GetSymName (ModSym);
   20871            0 :   M2Printf_printf1 ((const char *) "Symbol trees for module/procedure: %a\\n", 39, (const unsigned char *) &n, (sizeof (n)-1));
   20872            0 :   pSym = GetPsym (ModSym);
   20873            0 :   switch (pSym->SymbolType)
   20874              :     {
   20875            0 :       case SymbolTable_DefImpSym:
   20876            0 :         n = SymbolTable_GetSymName (ModSym);
   20877            0 :         M2Printf_printf1 ((const char *) "%a  UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
   20878            0 :         SymbolKey_ForeachNodeDo (pSym->DefImp.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20879            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20880            0 :         M2Printf_printf1 ((const char *) "%a  Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
   20881            0 :         SymbolKey_ForeachNodeDo (pSym->DefImp.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20882            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20883            0 :         M2Printf_printf1 ((const char *) "%a  ExportRequest", 17, (const unsigned char *) &n, (sizeof (n)-1));
   20884            0 :         SymbolKey_ForeachNodeDo (pSym->DefImp.ExportRequest, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20885            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20886            0 :         M2Printf_printf1 ((const char *) "%a  ExportQualified", 19, (const unsigned char *) &n, (sizeof (n)-1));
   20887            0 :         SymbolKey_ForeachNodeDo (pSym->DefImp.ExportQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20888            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20889            0 :         M2Printf_printf1 ((const char *) "%a  ExportUnQualified", 21, (const unsigned char *) &n, (sizeof (n)-1));
   20890            0 :         SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUnQualifiedTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20891            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20892            0 :         M2Printf_printf1 ((const char *) "%a  ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
   20893            0 :         SymbolKey_ForeachNodeDo (pSym->DefImp.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20894            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20895            0 :         M2Printf_printf1 ((const char *) "%a  DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
   20896            0 :         SymbolKey_ForeachNodeDo (pSym->DefImp.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20897            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20898            0 :         M2Printf_printf1 ((const char *) "%a  ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
   20899            0 :         SymbolKey_ForeachNodeDo (pSym->DefImp.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
   20900            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20901            0 :         break;
   20902              : 
   20903            0 :       case SymbolTable_ModuleSym:
   20904            0 :         n = SymbolTable_GetSymName (ModSym);
   20905            0 :         M2Printf_printf1 ((const char *) "%a  UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
   20906            0 :         SymbolKey_ForeachNodeDo (pSym->Module.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20907            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20908            0 :         M2Printf_printf1 ((const char *) "%a  Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
   20909            0 :         SymbolKey_ForeachNodeDo (pSym->Module.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20910            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20911            0 :         M2Printf_printf1 ((const char *) "%a  ImportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
   20912            0 :         SymbolKey_ForeachNodeDo (pSym->Module.ImportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20913            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20914            0 :         M2Printf_printf1 ((const char *) "%a  ExportTree", 14, (const unsigned char *) &n, (sizeof (n)-1));
   20915            0 :         SymbolKey_ForeachNodeDo (pSym->Module.ExportTree, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20916            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20917            0 :         M2Printf_printf1 ((const char *) "%a  ExportUndeclared", 20, (const unsigned char *) &n, (sizeof (n)-1));
   20918            0 :         SymbolKey_ForeachNodeDo (pSym->Module.ExportUndeclared, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20919            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20920            0 :         M2Printf_printf1 ((const char *) "%a  DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
   20921            0 :         SymbolKey_ForeachNodeDo (pSym->Module.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20922            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20923            0 :         M2Printf_printf1 ((const char *) "%a  ImportedObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
   20924            0 :         SymbolKey_ForeachNodeDo (pSym->Module.NamedImports, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
   20925            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20926            0 :         break;
   20927              : 
   20928            0 :       case SymbolTable_ProcedureSym:
   20929            0 :         n = SymbolTable_GetSymName (ModSym);
   20930            0 :         M2Printf_printf1 ((const char *) "%a  UndefinedTree", 17, (const unsigned char *) &n, (sizeof (n)-1));
   20931            0 :         SymbolKey_ForeachNodeDo (pSym->Procedure.Unresolved, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20932            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20933            0 :         M2Printf_printf1 ((const char *) "%a  Local symbols", 17, (const unsigned char *) &n, (sizeof (n)-1));
   20934            0 :         SymbolKey_ForeachNodeDo (pSym->Procedure.LocalSymbols, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplaySymbol});
   20935            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20936            0 :         M2Printf_printf1 ((const char *) "%a  DeclaredObjects", 19, (const unsigned char *) &n, (sizeof (n)-1));
   20937            0 :         SymbolKey_ForeachNodeDo (pSym->Procedure.NamedObjects, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DisplayName});
   20938            0 :         M2Printf_printf0 ((const char *) "\\n", 2);
   20939            0 :         break;
   20940              : 
   20941              : 
   20942            0 :       default:
   20943            0 :         M2Error_InternalError ((const char *) "expecting DefImp symbol", 23);
   20944            0 :         break;
   20945              :     }
   20946            0 : }
   20947              : 
   20948              : 
   20949              : /*
   20950              :    DebugLineNumbers - internal debugging, emit all procedure names in this module
   20951              :                       together with the line numbers for the corresponding begin/end
   20952              :                       tokens.
   20953              : */
   20954              : 
   20955        13652 : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym)
   20956              : {
   20957        13652 :   if (M2Options_GetDebugFunctionLineNumbers ())
   20958              :     {
   20959            0 :       M2Printf_printf0 ((const char *) "<lines>\\n", 9);
   20960            0 :       SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DebugProcedureLineNumber});
   20961            0 :       M2Printf_printf0 ((const char *) "</lines>\\n", 10);
   20962              :     }
   20963        13652 : }
   20964              : 
   20965              : 
   20966              : /*
   20967              :    GetErrorScope - returns the error scope for a symbol.
   20968              :                    The error scope is the title scope which is used to
   20969              :                    announce the symbol in the GCC error message.
   20970              : */
   20971              : 
   20972    147826938 : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym)
   20973              : {
   20974    147826938 :   SymbolTable_PtrToSymbol pSym;
   20975              : 
   20976    147826938 :   pSym = GetPsym (sym);
   20977    147826938 :   switch (pSym->SymbolType)
   20978              :     {
   20979      1592721 :       case SymbolTable_ProcedureSym:
   20980      1592721 :         return pSym->Procedure.errorScope;
   20981      4373038 :         break;
   20982              : 
   20983      4373038 :       case SymbolTable_ModuleSym:
   20984      4373038 :         return pSym->Module.errorScope;
   20985    141861179 :         break;
   20986              : 
   20987    141861179 :       case SymbolTable_DefImpSym:
   20988    141861179 :         return pSym->DefImp.errorScope;
   20989            0 :         break;
   20990              : 
   20991            0 :       case SymbolTable_UndefinedSym:
   20992            0 :         return pSym->Undefined.errorScope;
   20993            0 :         break;
   20994              : 
   20995              : 
   20996            0 :       default:
   20997            0 :         M2Error_InternalError ((const char *) "expecting procedure, module or defimp symbol", 44);
   20998              :         break;
   20999              :     }
   21000              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   21001              :   __builtin_unreachable ();
   21002              : }
   21003              : 
   21004              : 
   21005              : /*
   21006              :    MakeImport - create and return an import symbol.
   21007              :                 moduleSym is the symbol being imported.
   21008              :                 isqualified is FALSE if it were IMPORT modulename and
   21009              :                 TRUE for the qualified FROM modulename IMPORT etc.
   21010              :                 listno is the import list count for this module.
   21011              :                 tok should match this modulename position.
   21012              : */
   21013              : 
   21014       415937 : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified)
   21015              : {
   21016       415937 :   unsigned int importSym;
   21017       415937 :   SymbolTable_PtrToSymbol pSym;
   21018              : 
   21019       415937 :   NewSym (&importSym);
   21020       415937 :   pSym = GetPsym (importSym);
   21021       415937 :   pSym->SymbolType = SymbolTable_ImportSym;
   21022       415937 :   pSym->Import.module = moduleSym;
   21023       415937 :   pSym->Import.listNo = listno;
   21024       415937 :   pSym->Import.qualified = isqualified;
   21025       415937 :   InitWhereDeclaredTok (tok, &pSym->Import.at);
   21026       415937 :   return importSym;
   21027              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21028              :   __builtin_unreachable ();
   21029              : }
   21030              : 
   21031              : 
   21032              : /*
   21033              :    MakeImportStatement - return a dependent symbol which represents an import statement
   21034              :                    or a qualified import statement.  The tok should either match
   21035              :                    the FROM token or the IMPORT token.  listno is the import list
   21036              :                    count for the module.
   21037              : */
   21038              : 
   21039       400749 : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno)
   21040              : {
   21041       400749 :   unsigned int dependentSym;
   21042       400749 :   SymbolTable_PtrToSymbol pSym;
   21043              : 
   21044       400749 :   NewSym (&dependentSym);
   21045       400749 :   pSym = GetPsym (dependentSym);
   21046       400749 :   pSym->SymbolType = SymbolTable_ImportStatementSym;
   21047       400749 :   pSym->ImportStatement.listNo = listno;
   21048       400749 :   Lists_InitList (&pSym->ImportStatement.ListOfImports);
   21049       400749 :   InitWhereDeclaredTok (tok, &pSym->ImportStatement.at);
   21050       400749 :   return dependentSym;
   21051              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21052              :   __builtin_unreachable ();
   21053              : }
   21054              : 
   21055              : 
   21056              : /*
   21057              :    IsImport - returns TRUE if sym is an import symbol.
   21058              : */
   21059              : 
   21060      1153082 : extern "C" bool SymbolTable_IsImport (unsigned int sym)
   21061              : {
   21062      1153082 :   SymbolTable_PtrToSymbol pSym;
   21063              : 
   21064      1153082 :   pSym = GetPsym (sym);
   21065      1153082 :   return pSym->SymbolType == SymbolTable_ImportSym;
   21066              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21067              :   __builtin_unreachable ();
   21068              : }
   21069              : 
   21070              : 
   21071              : /*
   21072              :    IsImportStatement - returns TRUE if sym is a dependent symbol.
   21073              : */
   21074              : 
   21075      1522148 : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym)
   21076              : {
   21077      1522148 :   SymbolTable_PtrToSymbol pSym;
   21078              : 
   21079      1522148 :   pSym = GetPsym (sym);
   21080      1522148 :   return pSym->SymbolType == SymbolTable_ImportStatementSym;
   21081              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21082              :   __builtin_unreachable ();
   21083              : }
   21084              : 
   21085              : 
   21086              : /*
   21087              :    GetImportModule - returns the module associated with the import symbol.
   21088              : */
   21089              : 
   21090       357285 : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym)
   21091              : {
   21092       357285 :   SymbolTable_PtrToSymbol pSym;
   21093              : 
   21094       357285 :   M2Debug_Assert (SymbolTable_IsImport (sym));
   21095       357285 :   pSym = GetPsym (sym);
   21096       357285 :   return pSym->Import.module;
   21097              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21098              :   __builtin_unreachable ();
   21099              : }
   21100              : 
   21101              : 
   21102              : /*
   21103              :    GetImportDeclared - returns the token associated with the import symbol.
   21104              : */
   21105              : 
   21106        22575 : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym)
   21107              : {
   21108        22575 :   unsigned int tok;
   21109              : 
   21110        22575 :   M2Debug_Assert (SymbolTable_IsImport (sym));
   21111        22575 :   tok = SymbolTable_GetDeclaredDefinition (sym);
   21112        22575 :   if (tok == M2LexBuf_UnknownTokenNo)
   21113              :     {
   21114        20917 :       return SymbolTable_GetDeclaredModule (sym);
   21115              :     }
   21116              :   return tok;
   21117              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21118              :   __builtin_unreachable ();
   21119              : }
   21120              : 
   21121              : 
   21122              : /*
   21123              :    GetImportStatementList - returns the list of imports for this dependent.
   21124              :                             Each import symbol corresponds to a module.
   21125              : */
   21126              : 
   21127       761074 : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym)
   21128              : {
   21129       761074 :   SymbolTable_PtrToSymbol pSym;
   21130              : 
   21131       761074 :   M2Debug_Assert (SymbolTable_IsImportStatement (sym));
   21132       761074 :   pSym = GetPsym (sym);
   21133       761074 :   return pSym->ImportStatement.ListOfImports;
   21134              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21135              :   __builtin_unreachable ();
   21136              : }
   21137              : 
   21138              : 
   21139              : /*
   21140              :    GetModuleDefImportStatementList - returns the list of dependents associated with
   21141              :                                      the definition module.
   21142              : */
   21143              : 
   21144       214274 : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym)
   21145              : {
   21146       214274 :   SymbolTable_PtrToSymbol pSym;
   21147              : 
   21148       428548 :   M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
   21149       214274 :   if (SymbolTable_IsDefImp (sym))
   21150              :     {
   21151       200072 :       pSym = GetPsym (sym);
   21152       200072 :       return pSym->DefImp.DefListOfDep;
   21153              :     }
   21154              :   return static_cast<Lists_List> (NULL);
   21155              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21156              :   __builtin_unreachable ();
   21157              : }
   21158              : 
   21159              : 
   21160              : /*
   21161              :    GetModuleModImportStatementList - returns the list of dependents associated with
   21162              :                                      the implementation or program module.
   21163              : */
   21164              : 
   21165       406421 : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym)
   21166              : {
   21167       406421 :   SymbolTable_PtrToSymbol pSym;
   21168              : 
   21169       812842 :   M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
   21170       406421 :   pSym = GetPsym (sym);
   21171       406421 :   if (SymbolTable_IsDefImp (sym))
   21172              :     {
   21173       377601 :       return pSym->DefImp.ModListOfDep;
   21174              :     }
   21175              :   else
   21176              :     {
   21177        28820 :       return pSym->Module.ModListOfDep;
   21178              :     }
   21179              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21180              :   __builtin_unreachable ();
   21181              : }
   21182              : 
   21183              : 
   21184              : /*
   21185              :    AppendModuleImportStatement - appends the ImportStatement symbol onto the
   21186              :                                  module import list.
   21187              : 
   21188              :                                  For example:
   21189              : 
   21190              :                                  FROM x IMPORT y, z ;
   21191              :                                  ^^^^
   21192              : 
   21193              :                                  also:
   21194              : 
   21195              :                                  IMPORT p, q, r;
   21196              :                                  ^^^^^^
   21197              :                                  will result in a new ImportStatement symbol added
   21198              :                                  to the current module import list.
   21199              :                                  The statement symbol is expected to be created
   21200              :                                  by MakeImportStatement using the token positions
   21201              :                                  outlined above.
   21202              : */
   21203              : 
   21204       400749 : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement)
   21205              : {
   21206       400749 :   SymbolTable_PtrToSymbol pSym;
   21207              : 
   21208       400749 :   if (SymbolTable_IsDefImp (module))
   21209              :     {
   21210       386539 :       pSym = GetPsym (module);
   21211       386539 :       if (M2Comp_CompilingDefinitionModule ())
   21212              :         {
   21213       109487 :           Lists_IncludeItemIntoList (pSym->DefImp.DefListOfDep, statement);
   21214              :         }
   21215              :       else
   21216              :         {
   21217       277052 :           Lists_IncludeItemIntoList (pSym->DefImp.ModListOfDep, statement);
   21218              :         }
   21219              :     }
   21220        14210 :   else if (SymbolTable_IsModule (module))
   21221              :     {
   21222              :       /* avoid dangling else.  */
   21223        14210 :       pSym = GetPsym (module);
   21224        14210 :       Lists_IncludeItemIntoList (pSym->Module.ModListOfDep, statement);
   21225              :     }
   21226              :   else
   21227              :     {
   21228              :       /* avoid dangling else.  */
   21229            0 :       M2Error_InternalError ((const char *) "expecting DefImp or Module symbol", 33);
   21230              :     }
   21231       400749 : }
   21232              : 
   21233              : 
   21234              : /*
   21235              :    AppendModuleOnImportStatement - appends the import symbol onto the
   21236              :                                    dependent list (chain).
   21237              : 
   21238              :                                    For example each:
   21239              : 
   21240              :                                    FROM x IMPORT y, z ;
   21241              :                                         ^
   21242              :                                    x are added to the dependent list.
   21243              : 
   21244              :                                    also:
   21245              : 
   21246              :                                    IMPORT p, q, r;
   21247              :                                           ^  ^  ^
   21248              :                                    will result in p, q and r added to
   21249              :                                    to the dependent list.
   21250              : 
   21251              :                                    The import symbol is created by MakeImport
   21252              :                                    and the token is expected to match the module
   21253              :                                    name position outlined above.
   21254              : */
   21255              : 
   21256       415937 : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import)
   21257              : {
   21258       415937 :   Lists_List l;
   21259       415937 :   unsigned int lastImportStatement;
   21260              : 
   21261       415937 :   M2Debug_Assert (SymbolTable_IsImport (import));
   21262       415937 :   if (M2Comp_CompilingDefinitionModule ())
   21263              :     {
   21264       111895 :       l = SymbolTable_GetModuleDefImportStatementList (module);
   21265              :     }
   21266              :   else
   21267              :     {
   21268       304042 :       l = SymbolTable_GetModuleModImportStatementList (module);
   21269              :     }
   21270       415937 :   M2Debug_Assert (l != NULL);
   21271       415937 :   M2Debug_Assert ((Lists_NoOfItemsInList (l)) > 0);  /* There should always be one on the list.  */
   21272       415937 :   lastImportStatement = static_cast<unsigned int> (Lists_GetItemFromList (l, Lists_NoOfItemsInList (l)));  /* There should always be one on the list.  */
   21273       415937 :   M2Debug_Assert (SymbolTable_IsImportStatement (lastImportStatement));
   21274       415937 :   l = SymbolTable_GetImportStatementList (lastImportStatement);
   21275       415937 :   Lists_IncludeItemIntoList (l, import);
   21276       415937 : }
   21277              : 
   21278              : 
   21279              : /*
   21280              :    PutModLink - assigns link to module sym.
   21281              : */
   21282              : 
   21283        62958 : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link)
   21284              : {
   21285        62958 :   SymbolTable_PtrToSymbol pSym;
   21286              : 
   21287        62958 :   if (SymbolTable_IsModule (sym))
   21288              :     {
   21289            0 :       pSym = GetPsym (sym);
   21290            0 :       pSym->Module.ModLink = link;
   21291              :     }
   21292        62958 :   else if (SymbolTable_IsDefImp (sym))
   21293              :     {
   21294              :       /* avoid dangling else.  */
   21295        62958 :       pSym = GetPsym (sym);
   21296        62958 :       pSym->DefImp.ModLink = link;
   21297              :     }
   21298              :   else
   21299              :     {
   21300              :       /* avoid dangling else.  */
   21301            0 :       M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   21302              :     }
   21303        62958 : }
   21304              : 
   21305              : 
   21306              : /*
   21307              :    IsModLink - returns the ModLink value associated with the module symbol.
   21308              : */
   21309              : 
   21310       370019 : extern "C" bool SymbolTable_IsModLink (unsigned int sym)
   21311              : {
   21312       370019 :   SymbolTable_PtrToSymbol pSym;
   21313              : 
   21314       370019 :   if (SymbolTable_IsModule (sym))
   21315              :     {
   21316       176478 :       pSym = GetPsym (sym);
   21317       176478 :       return pSym->Module.ModLink;
   21318              :     }
   21319       193541 :   else if (SymbolTable_IsDefImp (sym))
   21320              :     {
   21321              :       /* avoid dangling else.  */
   21322       193541 :       pSym = GetPsym (sym);
   21323       193541 :       return pSym->DefImp.ModLink;
   21324              :     }
   21325              :   else
   21326              :     {
   21327              :       /* avoid dangling else.  */
   21328            0 :       M2Error_InternalError ((const char *) "expecting a DefImp or Module symbol", 35);
   21329              :     }
   21330              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   21331              :   __builtin_unreachable ();
   21332              : }
   21333              : 
   21334              : 
   21335              : /*
   21336              :    PutDefLink - assigns link to the definition module sym.
   21337              : */
   21338              : 
   21339            0 : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link)
   21340              : {
   21341            0 :   SymbolTable_PtrToSymbol pSym;
   21342              : 
   21343            0 :   if (SymbolTable_IsDefImp (sym))
   21344              :     {
   21345            0 :       pSym = GetPsym (sym);
   21346            0 :       pSym->DefImp.DefLink = link;
   21347              :     }
   21348              :   else
   21349              :     {
   21350            0 :       M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   21351              :     }
   21352            0 : }
   21353              : 
   21354              : 
   21355              : /*
   21356              :    IsDefLink - returns the DefLink value associated with the definition module symbol.
   21357              : */
   21358              : 
   21359       170570 : extern "C" bool SymbolTable_IsDefLink (unsigned int sym)
   21360              : {
   21361       170570 :   SymbolTable_PtrToSymbol pSym;
   21362              : 
   21363       170570 :   if (SymbolTable_IsDefImp (sym))
   21364              :     {
   21365       170570 :       pSym = GetPsym (sym);
   21366       170570 :       return pSym->DefImp.DefLink;
   21367              :     }
   21368              :   else
   21369              :     {
   21370            0 :       M2Error_InternalError ((const char *) "expecting a DefImp symbol", 25);
   21371              :     }
   21372              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   21373              :   __builtin_unreachable ();
   21374              : }
   21375              : 
   21376              : 
   21377              : /*
   21378              :    IsModuleBuiltin - returns TRUE if the module is a builtin module.
   21379              :                      (For example _BaseTypes).
   21380              : */
   21381              : 
   21382        87318 : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym)
   21383              : {
   21384        87318 :   SymbolTable_PtrToSymbol pSym;
   21385              : 
   21386        87318 :   if (SymbolTable_IsDefImp (sym))
   21387              :     {
   21388        84634 :       pSym = GetPsym (sym);
   21389        84634 :       return pSym->DefImp.Builtin;
   21390              :     }
   21391         2684 :   else if (SymbolTable_IsModule (sym))
   21392              :     {
   21393              :       /* avoid dangling else.  */
   21394         2684 :       pSym = GetPsym (sym);
   21395         2684 :       return pSym->Module.Builtin;
   21396              :     }
   21397              :   return false;
   21398              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21399              :   __builtin_unreachable ();
   21400              : }
   21401              : 
   21402              : 
   21403              : /*
   21404              :    PutModuleBuiltin - sets the Builtin flag to value.
   21405              :                       Currently the procedure expects sym to be a DefImp
   21406              :                       module only.
   21407              : */
   21408              : 
   21409        14952 : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value)
   21410              : {
   21411        14952 :   SymbolTable_PtrToSymbol pSym;
   21412              : 
   21413        14952 :   if (SymbolTable_IsDefImp (sym))
   21414              :     {
   21415            0 :       pSym = GetPsym (sym);
   21416            0 :       pSym->DefImp.Builtin = value;
   21417              :     }
   21418        14952 :   else if (SymbolTable_IsModule (sym))
   21419              :     {
   21420              :       /* avoid dangling else.  */
   21421        14952 :       pSym = GetPsym (sym);
   21422        14952 :       pSym->Module.Builtin = value;
   21423              :     }
   21424              :   else
   21425              :     {
   21426              :       /* avoid dangling else.  */
   21427            0 :       M2Error_InternalError ((const char *) "expecting Module or DefImp symbol", 33);
   21428              :     }
   21429        14952 : }
   21430              : 
   21431              : 
   21432              : /*
   21433              :    PutVarArrayRef - assigns ArrayRef field with value.
   21434              : */
   21435              : 
   21436        55790 : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value)
   21437              : {
   21438        55790 :   SymbolTable_PtrToSymbol pSym;
   21439              : 
   21440        55790 :   pSym = GetPsym (sym);
   21441        55790 :   switch (pSym->SymbolType)
   21442              :     {
   21443        55790 :       case SymbolTable_VarSym:
   21444        55790 :         pSym->Var.ArrayRef = value;
   21445        55790 :         break;
   21446              : 
   21447              : 
   21448            0 :       default:
   21449            0 :         M2Error_InternalError ((const char *) "expecting VarSym", 16);
   21450        55790 :         break;
   21451              :     }
   21452        55790 : }
   21453              : 
   21454              : 
   21455              : /*
   21456              :    IsVarArrayRef - returns ArrayRef field value.
   21457              : */
   21458              : 
   21459        18166 : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym)
   21460              : {
   21461        18166 :   SymbolTable_PtrToSymbol pSym;
   21462              : 
   21463        18166 :   pSym = GetPsym (sym);
   21464        18166 :   switch (pSym->SymbolType)
   21465              :     {
   21466        18166 :       case SymbolTable_VarSym:
   21467        18166 :         return pSym->Var.ArrayRef;
   21468            0 :         break;
   21469              : 
   21470              : 
   21471            0 :       default:
   21472            0 :         M2Error_InternalError ((const char *) "expecting VarSym", 16);
   21473              :         break;
   21474              :     }
   21475              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   21476              :   __builtin_unreachable ();
   21477              : }
   21478              : 
   21479              : 
   21480              : /*
   21481              :    VarCheckReadInit - returns TRUE if sym has been initialized.
   21482              : */
   21483              : 
   21484         9790 : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode)
   21485              : {
   21486         9790 :   SymbolTable_PtrToSymbol pSym;
   21487              : 
   21488         9790 :   if (SymbolTable_IsVar (sym))
   21489              :     {
   21490         9790 :       pSym = GetPsym (sym);
   21491         9790 :       switch (pSym->SymbolType)
   21492              :         {
   21493         9790 :           case SymbolTable_VarSym:
   21494         9790 :             return M2SymInit_GetInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]));
   21495              :             break;
   21496              : 
   21497              : 
   21498              :           default:
   21499              :             break;
   21500              :         }
   21501              :     }
   21502              :   return false;
   21503              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21504              :   __builtin_unreachable ();
   21505              : }
   21506              : 
   21507              : 
   21508              : /*
   21509              :    VarInitState - initializes the init state for variable sym.
   21510              : */
   21511              : 
   21512       210788 : extern "C" void SymbolTable_VarInitState (unsigned int sym)
   21513              : {
   21514       210788 :   SymbolTable_PtrToSymbol pSym;
   21515              : 
   21516       210788 :   if (SymbolTable_IsVar (sym))
   21517              :     {
   21518       210788 :       pSym = GetPsym (sym);
   21519       210788 :       switch (pSym->SymbolType)
   21520              :         {
   21521       210788 :           case SymbolTable_VarSym:
   21522       210788 :             M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]), sym);
   21523       210788 :             M2SymInit_ConfigSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]), sym);
   21524       210788 :             break;
   21525              : 
   21526              : 
   21527              :           default:
   21528              :             break;
   21529              :         }
   21530              :     }
   21531       210788 : }
   21532              : 
   21533              : 
   21534              : /*
   21535              :    PutVarInitialized - set sym as initialized.
   21536              : */
   21537              : 
   21538        40387 : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode)
   21539              : {
   21540        40387 :   SymbolTable_PtrToSymbol pSym;
   21541              : 
   21542        40387 :   if (SymbolTable_IsVar (sym))
   21543              :     {
   21544        40387 :       pSym = GetPsym (sym);
   21545        40387 :       switch (pSym->SymbolType)
   21546              :         {
   21547        40387 :           case SymbolTable_VarSym:
   21548        40387 :             M2SymInit_SetInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]));
   21549        40387 :             break;
   21550              : 
   21551              : 
   21552              :           default:
   21553              :             break;
   21554              :         }
   21555              :     }
   21556        40387 : }
   21557              : 
   21558              : 
   21559              : /*
   21560              :    PutVarFieldInitialized - records that field has been initialized with
   21561              :                             variable sym.  TRUE is returned if the field
   21562              :                             is detected and changed to initialized.
   21563              : */
   21564              : 
   21565         3364 : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
   21566              : {
   21567         3364 :   SymbolTable_PtrToSymbol pSym;
   21568              : 
   21569         3364 :   if (SymbolTable_IsVar (sym))
   21570              :     {
   21571         3364 :       pSym = GetPsym (sym);
   21572         3364 :       switch (pSym->SymbolType)
   21573              :         {
   21574         3364 :           case SymbolTable_VarSym:
   21575         3364 :             return M2SymInit_SetFieldInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]), fieldlist);
   21576              :             break;
   21577              : 
   21578              : 
   21579              :           default:
   21580              :             break;
   21581              :         }
   21582              :     }
   21583              :   return false;
   21584              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21585              :   __builtin_unreachable ();
   21586              : }
   21587              : 
   21588              : 
   21589              : /*
   21590              :    GetVarFieldInitialized - return TRUE if fieldlist has been initialized
   21591              :                             within variable sym.
   21592              : */
   21593              : 
   21594          232 : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist)
   21595              : {
   21596          232 :   SymbolTable_PtrToSymbol pSym;
   21597              : 
   21598          232 :   if (SymbolTable_IsVar (sym))
   21599              :     {
   21600          232 :       pSym = GetPsym (sym);
   21601          232 :       switch (pSym->SymbolType)
   21602              :         {
   21603          232 :           case SymbolTable_VarSym:
   21604          232 :             return M2SymInit_GetFieldInitialized (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[mode-SymbolTable_RightValue]), fieldlist);
   21605              :             break;
   21606              : 
   21607              : 
   21608              :           default:
   21609              :             break;
   21610              :         }
   21611              :     }
   21612              :   return false;
   21613              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21614              :   __builtin_unreachable ();
   21615              : }
   21616              : 
   21617              : 
   21618              : /*
   21619              :    PrintInitialized - display variable sym initialization state.
   21620              : */
   21621              : 
   21622            0 : extern "C" void SymbolTable_PrintInitialized (unsigned int sym)
   21623              : {
   21624            0 :   SymbolTable_PtrToSymbol pSym;
   21625              : 
   21626            0 :   if (SymbolTable_IsVar (sym))
   21627              :     {
   21628            0 :       pSym = GetPsym (sym);
   21629            0 :       switch (pSym->SymbolType)
   21630              :         {
   21631            0 :           case SymbolTable_VarSym:
   21632            0 :             M2Printf_printf0 ((const char *) "LeftMode init: ", 15);
   21633            0 :             M2SymInit_PrintSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_LeftValue-SymbolTable_RightValue]));
   21634            0 :             M2Printf_printf0 ((const char *) "RightMode init: ", 16);
   21635            0 :             M2SymInit_PrintSymInit (static_cast<M2SymInit_InitDesc> (pSym->Var.InitState.array[SymbolTable_RightValue-SymbolTable_RightValue]));
   21636            0 :             break;
   21637              : 
   21638              : 
   21639              :           default:
   21640              :             break;
   21641              :         }
   21642              :     }
   21643            0 : }
   21644              : 
   21645              : 
   21646              : /*
   21647              :    GetParameterHeapVar - return the heap variable associated with the
   21648              :                          parameter or NulSym.
   21649              : */
   21650              : 
   21651        46916 : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym)
   21652              : {
   21653        46916 :   SymbolTable_PtrToSymbol pSym;
   21654              : 
   21655        46916 :   pSym = GetPsym (ParSym);
   21656        46916 :   switch (pSym->SymbolType)
   21657              :     {
   21658              :       case SymbolTable_ParamSym:
   21659              :         return SymbolTable_NulSym;  /* Only VarParam has the pointer.  */
   21660         7176 :         break;
   21661              : 
   21662         7176 :       case SymbolTable_VarParamSym:
   21663         7176 :         return pSym->VarParam.HeapVar;  /* Only VarParam has the pointer.  */
   21664            0 :         break;
   21665              : 
   21666              : 
   21667            0 :       default:
   21668            0 :         M2Error_InternalError ((const char *) "expecting Param or VarParam symbol", 34);
   21669              :         break;
   21670              :     }
   21671              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   21672              :   __builtin_unreachable ();
   21673              : }
   21674              : 
   21675              : 
   21676              : /*
   21677              :    PutProcedureParameterHeapVars - creates heap variables for parameter sym.
   21678              : */
   21679              : 
   21680      1883809 : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym)
   21681              : {
   21682      1883809 :   M2Debug_Assert (SymbolTable_IsProcedure (sym));
   21683      1883809 :   SymbolTable_ForeachParamSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PutParameterHeapVar});
   21684      1883809 : }
   21685              : 
   21686              : 
   21687              : /*
   21688              :    IsProcedureBuiltinAvailable - return TRUE if procedure is available as a builtin
   21689              :                                  for the target architecture.
   21690              : */
   21691              : 
   21692      1214208 : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure)
   21693              : {
   21694      1214208 :   return (SymbolTable_IsProcedureBuiltin (procedure)) && (CanUseBuiltin (procedure));
   21695              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21696              :   __builtin_unreachable ();
   21697              : }
   21698              : 
   21699              : 
   21700              : /*
   21701              :    PutConstLitInternal - marks the sym as being an internal constant.
   21702              :                          Currently this is used when generating a default
   21703              :                          BY constant expression during a FOR loop.
   21704              :                          A constant marked as internal will always pass
   21705              :                          an expression type check.
   21706              : */
   21707              : 
   21708        15240 : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value)
   21709              : {
   21710        15240 :   SymbolTable_PtrToSymbol pSym;
   21711              : 
   21712        15240 :   pSym = GetPsym (sym);
   21713        15240 :   switch (pSym->SymbolType)
   21714              :     {
   21715        15240 :       case SymbolTable_ConstLitSym:
   21716        15240 :         pSym->ConstLit.IsInternal = value;
   21717        15240 :         break;
   21718              : 
   21719              : 
   21720            0 :       default:
   21721            0 :         M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
   21722        15240 :         break;
   21723              :     }
   21724        15240 : }
   21725              : 
   21726              : 
   21727              : /*
   21728              :    IsConstLitInternal - returns the value of the IsInternal field within
   21729              :                         a constant expression.
   21730              : */
   21731              : 
   21732       822276 : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym)
   21733              : {
   21734       822276 :   SymbolTable_PtrToSymbol pSym;
   21735              : 
   21736       822276 :   pSym = GetPsym (sym);
   21737       822276 :   switch (pSym->SymbolType)
   21738              :     {
   21739       822276 :       case SymbolTable_ConstLitSym:
   21740       822276 :         return pSym->ConstLit.IsInternal;
   21741            0 :         break;
   21742              : 
   21743              : 
   21744            0 :       default:
   21745            0 :         M2Error_InternalError ((const char *) "expecting ConstLitSym", 21);
   21746              :         break;
   21747              :     }
   21748              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   21749              :   __builtin_unreachable ();
   21750              : }
   21751              : 
   21752              : 
   21753              : /*
   21754              :    GetVarDeclTypeTok - returns the TypeTok field associate with variable sym.
   21755              : */
   21756              : 
   21757            0 : extern "C" unsigned int SymbolTable_GetVarDeclTypeTok (unsigned int sym)
   21758              : {
   21759            0 :   SymbolTable_PtrToSymbol pSym;
   21760              : 
   21761            0 :   if (SymbolTable_IsParameter (sym))
   21762              :     {
   21763            0 :       pSym = GetPsym (sym);
   21764            0 :       if (SymbolTable_IsParameterVar (sym))
   21765              :         {
   21766            0 :           return SymbolTable_GetVarDeclTypeTok (pSym->VarParam.ShadowVar);
   21767              :         }
   21768              :       else
   21769              :         {
   21770            0 :           return SymbolTable_GetVarDeclTypeTok (pSym->Param.ShadowVar);
   21771              :         }
   21772              :     }
   21773            0 :   else if (SymbolTable_IsVar (sym))
   21774              :     {
   21775              :       /* avoid dangling else.  */
   21776            0 :       return doGetVarDeclTypeTok (sym);
   21777              :     }
   21778              :   else
   21779              :     {
   21780              :       /* avoid dangling else.  */
   21781              :       return M2LexBuf_UnknownTokenNo;
   21782              :     }
   21783              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21784              :   __builtin_unreachable ();
   21785              : }
   21786              : 
   21787              : 
   21788              : /*
   21789              :    PutVarDeclTypeTok - assigns the TypeTok field to typetok.
   21790              :                        sym can be a variable or parameter.
   21791              : */
   21792              : 
   21793            0 : extern "C" void SymbolTable_PutVarDeclTypeTok (unsigned int sym, unsigned int typetok)
   21794              : {
   21795            0 :   SymbolTable_PtrToSymbol pSym;
   21796              : 
   21797            0 :   if (SymbolTable_IsParameter (sym))
   21798              :     {
   21799            0 :       pSym = GetPsym (sym);
   21800            0 :       if (SymbolTable_IsParameterVar (sym))
   21801              :         {
   21802            0 :           SymbolTable_PutVarDeclTypeTok (pSym->VarParam.ShadowVar, typetok);
   21803              :         }
   21804              :       else
   21805              :         {
   21806            0 :           SymbolTable_PutVarDeclTypeTok (pSym->Param.ShadowVar, typetok);
   21807              :         }
   21808              :     }
   21809            0 :   else if (SymbolTable_IsVar (sym))
   21810              :     {
   21811              :       /* avoid dangling else.  */
   21812            0 :       doPutVarDeclTypeTok (sym, typetok);
   21813              :     }
   21814            0 : }
   21815              : 
   21816              : 
   21817              : /*
   21818              :    GetVarDeclTok - returns the TypeTok field associate with variable sym.
   21819              : */
   21820              : 
   21821           96 : extern "C" unsigned int SymbolTable_GetVarDeclTok (unsigned int sym)
   21822              : {
   21823          156 :   SymbolTable_PtrToSymbol pSym;
   21824              : 
   21825          156 :   if (SymbolTable_IsParameter (sym))
   21826              :     {
   21827           96 :       pSym = GetPsym (sym);
   21828           96 :       if (SymbolTable_IsParameterVar (sym))
   21829              :         {
   21830            6 :           if (pSym->VarParam.ShadowVar == SymbolTable_NulSym)
   21831              :             {
   21832            0 :               return pSym->VarParam.At;
   21833              :             }
   21834              :           else
   21835              :             {
   21836              :               return SymbolTable_GetVarDeclTok (pSym->VarParam.ShadowVar);
   21837              :             }
   21838              :         }
   21839              :       else
   21840              :         {
   21841           90 :           if (pSym->Param.ShadowVar == SymbolTable_NulSym)
   21842              :             {
   21843           36 :               return pSym->Param.At;
   21844              :             }
   21845              :           else
   21846              :             {
   21847              :               return SymbolTable_GetVarDeclTok (pSym->Param.ShadowVar);
   21848              :             }
   21849              :         }
   21850              :     }
   21851           60 :   else if (SymbolTable_IsVar (sym))
   21852              :     {
   21853              :       /* avoid dangling else.  */
   21854           60 :       return doGetVarDeclTok (sym);
   21855              :     }
   21856              :   else
   21857              :     {
   21858              :       /* avoid dangling else.  */
   21859              :       return M2LexBuf_UnknownTokenNo;
   21860              :     }
   21861              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21862              :   __builtin_unreachable ();
   21863              : }
   21864              : 
   21865              : 
   21866              : /*
   21867              :    PutVarDeclTok - assigns the VarTok field to typetok.
   21868              :                    sym can be a variable or parameter.
   21869              : */
   21870              : 
   21871      1694926 : extern "C" void SymbolTable_PutVarDeclTok (unsigned int sym, unsigned int vartok)
   21872              : {
   21873      1694926 :   SymbolTable_PtrToSymbol pSym;
   21874              : 
   21875      1694926 :   if (SymbolTable_IsParameter (sym))
   21876              :     {
   21877            0 :       pSym = GetPsym (sym);
   21878            0 :       if (SymbolTable_IsParameterVar (sym))
   21879              :         {
   21880            0 :           SymbolTable_PutVarDeclTok (pSym->VarParam.ShadowVar, vartok);
   21881              :         }
   21882              :       else
   21883              :         {
   21884            0 :           SymbolTable_PutVarDeclTok (pSym->Param.ShadowVar, vartok);
   21885              :         }
   21886              :     }
   21887      1694926 :   else if (SymbolTable_IsVar (sym))
   21888              :     {
   21889              :       /* avoid dangling else.  */
   21890      1694926 :       doPutVarDeclTok (sym, vartok);
   21891              :     }
   21892      1694926 : }
   21893              : 
   21894              : 
   21895              : /*
   21896              :    GetVarDeclFullTok - returns the full virtual token containing var: type.
   21897              : */
   21898              : 
   21899          360 : extern "C" unsigned int SymbolTable_GetVarDeclFullTok (unsigned int sym)
   21900              : {
   21901          360 :   SymbolTable_PtrToSymbol pSym;
   21902              : 
   21903          360 :   pSym = GetPsym (sym);
   21904          360 :   if (SymbolTable_IsParameter (sym))
   21905              :     {
   21906           78 :       if (SymbolTable_IsParameterVar (sym))
   21907              :         {
   21908            6 :           return pSym->VarParam.FullTok;
   21909              :         }
   21910              :       else
   21911              :         {
   21912           72 :           return pSym->Param.FullTok;
   21913              :         }
   21914              :     }
   21915          282 :   else if (SymbolTable_IsVar (sym))
   21916              :     {
   21917              :       /* avoid dangling else.  */
   21918          282 :       return doGetVarDeclFullTok (sym);
   21919              :     }
   21920              :   else
   21921              :     {
   21922              :       /* avoid dangling else.  */
   21923              :       return M2LexBuf_UnknownTokenNo;
   21924              :     }
   21925              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21926              :   __builtin_unreachable ();
   21927              : }
   21928              : 
   21929              : 
   21930              : /*
   21931              :    IsProcedureAnyNoReturn - return TRUE if any of the defined kinds
   21932              :                             of procedure sym is declared no return.
   21933              : */
   21934              : 
   21935      3665242 : extern "C" bool SymbolTable_IsProcedureAnyNoReturn (unsigned int sym)
   21936              : {
   21937      3665242 :   return IsProcedureAnyDefaultBoolean (sym, false, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_IsProcedureNoReturn});
   21938              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   21939              :   __builtin_unreachable ();
   21940              : }
   21941              : 
   21942              : 
   21943              : /*
   21944              :    GetNthParamAny - returns the nth parameter from the order
   21945              :                     proper procedure, forward declaration
   21946              :                     or definition module procedure.
   21947              : */
   21948              : 
   21949     20904396 : extern "C" unsigned int SymbolTable_GetNthParamAny (unsigned int sym, unsigned int ParamNo)
   21950              : {
   21951     20904396 :   SymbolTable_ProcedureKind kind;
   21952              : 
   21953     33079912 :   for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
   21954              :     {
   21955     33079912 :       if (SymbolTable_GetProcedureParametersDefined (sym, kind))
   21956              :         {
   21957     20904396 :           return SymbolTable_GetNthParam (sym, kind, ParamNo);
   21958              :         }
   21959              :     }
   21960            0 :   M2Error_InternalError ((const char *) "no procedure kind exists", 24);
   21961              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   21962              :   __builtin_unreachable ();
   21963              : }
   21964              : 
   21965              : 
   21966              : /*
   21967              :    NoOfParamAny - return the number of parameters for sym.
   21968              : */
   21969              : 
   21970     25614409 : extern "C" unsigned int SymbolTable_NoOfParamAny (unsigned int sym)
   21971              : {
   21972     25614409 :   SymbolTable_ProcedureKind kind;
   21973     25614409 :   SymbolTable_PtrToSymbol pSym;
   21974              : 
   21975     25614409 :   AssertInRange (sym);
   21976     25614409 :   pSym = GetPsym (sym);
   21977     25614409 :   switch (pSym->SymbolType)
   21978              :     {
   21979              :       case SymbolTable_ErrorSym:
   21980              :         return 0;
   21981              :         break;
   21982              : 
   21983              :       case SymbolTable_ProcedureSym:
   21984     41803622 :         for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
   21985              :           {
   21986     39661542 :             if (SymbolTable_GetProcedureParametersDefined (sym, kind))
   21987              :               {
   21988     16975392 :                 return SymbolTable_NoOfParam (sym, kind);
   21989              :               }
   21990              :           }
   21991              :         break;
   21992              : 
   21993      6496925 :       case SymbolTable_ProcTypeSym:
   21994      6496925 :         return Lists_NoOfItemsInList (pSym->ProcType.ListOfParam);
   21995           12 :         break;
   21996              : 
   21997              : 
   21998           12 :       default:
   21999           12 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   22000              :         break;
   22001              :     }
   22002              :   return 0;
   22003              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   22004              :   __builtin_unreachable ();
   22005              : }
   22006              : 
   22007              : 
   22008              : /*
   22009              :    SetReturnOptional - sets the ReturnOptional field in the Procedure:kind or
   22010              :                        ProcType symboltable entry.
   22011              : */
   22012              : 
   22013      3141715 : extern "C" void SymbolTable_SetReturnOptional (unsigned int sym, SymbolTable_ProcedureKind kind, bool isopt)
   22014              : {
   22015      3141715 :   SymbolTable_PtrToSymbol pSym;
   22016              : 
   22017      3141715 :   pSym = GetPsym (sym);
   22018      3141715 :   switch (pSym->SymbolType)
   22019              :     {
   22020      3133851 :       case SymbolTable_ProcedureSym:
   22021      3133851 :         pSym->Procedure.Decl.array[kind-SymbolTable_ProperProcedure].ReturnOptional = isopt;
   22022      3133851 :         break;
   22023              : 
   22024         7864 :       case SymbolTable_ProcTypeSym:
   22025         7864 :         pSym->ProcType.ReturnOptional = isopt;
   22026         7864 :         break;
   22027              : 
   22028              : 
   22029            0 :       default:
   22030            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   22031      3141715 :         break;
   22032              :     }
   22033      3141715 : }
   22034              : 
   22035              : 
   22036              : /*
   22037              :    UsesOptArgAny - returns TRUE if procedure Sym:kind uses an optional argument.
   22038              : */
   22039              : 
   22040       206711 : extern "C" bool SymbolTable_UsesOptArgAny (unsigned int Sym)
   22041              : {
   22042       206711 :   SymbolTable_PtrToSymbol pSym;
   22043              : 
   22044       206711 :   pSym = GetPsym (Sym);
   22045       206711 :   switch (pSym->SymbolType)
   22046              :     {
   22047              :       case SymbolTable_ErrorSym:
   22048              :         return false;
   22049       205939 :         break;
   22050              : 
   22051       205939 :       case SymbolTable_ProcedureSym:
   22052       205939 :         return IsProcedureAnyDefaultBoolean (Sym, false, (SymbolTable_ProcAnyBoolean) {(SymbolTable_ProcAnyBoolean_t) SymbolTable_UsesOptArg});
   22053          772 :         break;
   22054              : 
   22055          772 :       case SymbolTable_ProcTypeSym:
   22056          772 :         return pSym->ProcType.HasOptArg;
   22057            0 :         break;
   22058              : 
   22059              : 
   22060            0 :       default:
   22061            0 :         M2Error_InternalError ((const char *) "expecting a Procedure or ProcType symbol", 40);
   22062              :         break;
   22063              :     }
   22064              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   22065              :   __builtin_unreachable ();
   22066              : }
   22067              : 
   22068              : 
   22069              : /*
   22070              :    GetProcedureKindDesc - return a string describing kind.
   22071              : */
   22072              : 
   22073          180 : extern "C" DynamicStrings_String SymbolTable_GetProcedureKindDesc (SymbolTable_ProcedureKind kind)
   22074              : {
   22075          180 :   if (kind == SymbolTable_ProperProcedure)
   22076              :     {
   22077           90 :       return DynamicStrings_InitString ((const char *) "proper procedure", 16);
   22078              :     }
   22079           90 :   else if (kind == SymbolTable_ForwardProcedure)
   22080              :     {
   22081              :       /* avoid dangling else.  */
   22082           24 :       return DynamicStrings_InitString ((const char *) "forward procedure", 17);
   22083              :     }
   22084           66 :   else if (kind == SymbolTable_DefProcedure)
   22085              :     {
   22086              :       /* avoid dangling else.  */
   22087           66 :       return DynamicStrings_InitString ((const char *) "definition procedure", 20);
   22088              :     }
   22089            0 :   M2Error_InternalError ((const char *) "unknown kind value", 18);
   22090              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.def", 20, 1);
   22091              :   __builtin_unreachable ();
   22092              : }
   22093              : 
   22094              : 
   22095              : /*
   22096              :    GetNthParamAnyClosest - returns the nth parameter from the order
   22097              :                            proper procedure, forward declaration
   22098              :                            or definition module procedure.
   22099              :                            It chooses the parameter which is closest
   22100              :                            in source terms to currentmodule.
   22101              :                            The same module will return using the order
   22102              :                            proper procedure, forward procedure, definition module.
   22103              :                            Whereas an imported procedure will choose from
   22104              :                            DefProcedure, ProperProcedure, ForwardProcedure.
   22105              : */
   22106              : 
   22107       616715 : extern "C" unsigned int SymbolTable_GetNthParamAnyClosest (unsigned int sym, unsigned int ParamNo, unsigned int currentmodule)
   22108              : {
   22109       616715 :   if (SymbolTable_IsUnknown (sym))
   22110              :     {
   22111            0 :       M2Error_InternalError ((const char *) "/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/SymbolTable.mod:GetNthParamAnyClosest:not expecting an unknown symbol", 131);
   22112              :     }
   22113       616715 :   if ((GetOuterModuleScope (currentmodule)) == (GetOuterModuleScope (sym)))
   22114              :     {
   22115              :       /* Same module.  */
   22116       226612 :       return GetNthParamOrdered (sym, ParamNo, SymbolTable_ProperProcedure, SymbolTable_ForwardProcedure, SymbolTable_DefProcedure);
   22117              :     }
   22118              :   else
   22119              :     {
   22120              :       /* Procedure is imported.  */
   22121       390103 :       return GetNthParamOrdered (sym, ParamNo, SymbolTable_DefProcedure, SymbolTable_ProperProcedure, SymbolTable_ForwardProcedure);
   22122              :     }
   22123              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   22124              :   __builtin_unreachable ();
   22125              : }
   22126              : 
   22127              : 
   22128              : /*
   22129              :    IsConstVar - returns TRUE if sym is a const var.  This is a
   22130              :                 constant which might be assigned to TRUE or FALSE
   22131              :                 depending upon the result of the quad stack control flow.
   22132              :                 Typically used in CONST foo = (a AND b) or similar.
   22133              :                 This symbol will only be assigned once with a value, but
   22134              :                 will appear more than once as a designator to an assignment
   22135              :                 in the quad table.  However as the quad table is reduced
   22136              :                 only one assignment will remain.  If after reducing quads
   22137              :                 two or more assignments remain, then there is an error
   22138              :                 as sym should not have been declared a constant.
   22139              : */
   22140              : 
   22141          150 : extern "C" bool SymbolTable_IsConstVar (unsigned int sym)
   22142              : {
   22143          150 :   SymbolTable_PtrToSymbol pSym;
   22144              : 
   22145          150 :   pSym = GetPsym (sym);
   22146          150 :   return pSym->SymbolType == SymbolTable_ConstVarSym;
   22147              :   /* static analysis guarentees a RETURN statement will be used before here.  */
   22148              :   __builtin_unreachable ();
   22149              : }
   22150              : 
   22151        14952 : extern "C" void _M2_SymbolTable_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
   22152              : {
   22153        14952 :   Init ();
   22154        14952 : }
   22155              : 
   22156            0 : extern "C" void _M2_SymbolTable_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
   22157              : {
   22158            0 : }
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.