LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2Batch.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 83.9 % 174 146
Test Date: 2026-02-28 14:20:25 Functions: 77.3 % 22 17
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* do not edit automatically generated by mc from M2Batch.  */
       2              : /* M2Batch.mod implements a queue for modules pending compilation.
       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              : #   include "GStorage.h"
      35              : #   include "Gmcrts.h"
      36              : #if defined(__cplusplus)
      37              : #   undef NULL
      38              : #   define NULL 0
      39              : #endif
      40              : #define _M2Batch_C
      41              : 
      42              : #include "GM2Batch.h"
      43              : #   include "GM2Debug.h"
      44              : #   include "GSymbolTable.h"
      45              : #   include "GNameKey.h"
      46              : #   include "GM2Printf.h"
      47              : #   include "GM2Error.h"
      48              : #   include "GM2MetaError.h"
      49              : #   include "GIndexing.h"
      50              : #   include "GLists.h"
      51              : #   include "GStorage.h"
      52              : #   include "GDynamicStrings.h"
      53              : #   include "GM2Pass.h"
      54              : 
      55              : typedef struct M2Batch_DoProcedure_p M2Batch_DoProcedure;
      56              : 
      57              : typedef struct M2Batch__T1_r M2Batch__T1;
      58              : 
      59              : typedef M2Batch__T1 *M2Batch_Module;
      60              : 
      61              : struct M2Batch__T1_r {
      62              :                        unsigned int SymNo;
      63              :                        NameKey_Name Key;
      64              :                        DynamicStrings_String DefFile;
      65              :                        DynamicStrings_String ModFile;
      66              :                      };
      67              : 
      68              : static Indexing_Index SeenList;
      69              : static Lists_List PendingQueue;
      70              : 
      71              : /*
      72              :    MakeDefinitionSource - is given a Name, n, which is used to create a Definition
      73              :                           module.
      74              :                           The Definition Module will be placed onto the
      75              :                           compilation pending queue if it has not yet been
      76              :                           compiled.
      77              :                           If the module has been compiled then no action is
      78              :                           taken. The Module Sym is returned.
      79              : */
      80              : 
      81              : extern "C" unsigned int M2Batch_MakeDefinitionSource (unsigned int tok, NameKey_Name n);
      82              : 
      83              : /*
      84              :    MakeImplementationSource - is given a Name, n, which is used to create an
      85              :                               implementation module.
      86              :                               The implementation Module will be placed onto
      87              :                               the compilation pending
      88              :                               queue if it has not yet been compiled.
      89              :                               If the module has been compiled then no
      90              :                               action is taken. The Module Sym is returned.
      91              : */
      92              : 
      93              : extern "C" unsigned int M2Batch_MakeImplementationSource (unsigned int tok, NameKey_Name n);
      94              : 
      95              : /*
      96              :    MakeProgramSource - is given a Name, n, which is used to create a program module.
      97              :                        The program module will be placed onto the compilation
      98              :                        pending queue if it has not yet been compiled.
      99              :                        If the module has been compiled then no action is taken.
     100              :                        The Module Sym is returned.
     101              : */
     102              : 
     103              : extern "C" unsigned int M2Batch_MakeProgramSource (unsigned int tok, NameKey_Name n);
     104              : 
     105              : /*
     106              :    GetSource - returns with the symbol Sym of the next module to be compiled.
     107              :                If Sym returns with value 0 then no module should be compiled.
     108              : */
     109              : 
     110              : extern "C" unsigned int M2Batch_GetSource (void);
     111              : 
     112              : /*
     113              :    GetModuleNo - returns with symbol number of the nth module read during Pass 1.
     114              : */
     115              : 
     116              : extern "C" unsigned int M2Batch_GetModuleNo (unsigned int nth);
     117              : 
     118              : /*
     119              :    IsModuleKnown - returns TRUE if the Name n matches a module.
     120              : */
     121              : 
     122              : extern "C" bool M2Batch_IsModuleKnown (NameKey_Name n);
     123              : 
     124              : /*
     125              :    AssociateDefinition - associate the source file, filename, with the definition module,
     126              :                          Sym.
     127              : */
     128              : 
     129              : extern "C" DynamicStrings_String M2Batch_AssociateDefinition (DynamicStrings_String filename, unsigned int Sym);
     130              : 
     131              : /*
     132              :    GetDefinitionModuleFile - returns the filename associated with the definition module, Sym.
     133              :                              It may return a temporary preprocessed file.
     134              : */
     135              : 
     136              : extern "C" DynamicStrings_String M2Batch_GetDefinitionModuleFile (unsigned int Sym);
     137              : 
     138              : /*
     139              :    AssociateModule - associate the source file, filename, with the implementation/program
     140              :                      module, Sym.
     141              : */
     142              : 
     143              : extern "C" DynamicStrings_String M2Batch_AssociateModule (DynamicStrings_String filename, unsigned int Sym);
     144              : 
     145              : /*
     146              :    GetModuleFile - returns the filename associated with the implementation/program module, Sym.
     147              :                    It may return a temporary preprocessed file.
     148              : */
     149              : 
     150              : extern "C" DynamicStrings_String M2Batch_GetModuleFile (unsigned int Sym);
     151              : 
     152              : /*
     153              :    ForeachSourceModuleDo - for each source file call procedure, p.
     154              : */
     155              : 
     156              : extern "C" void M2Batch_ForeachSourceModuleDo (M2Batch_DoProcedure p);
     157              : 
     158              : /*
     159              :    IsSourceSeen - returns TRUE if the source for the program module or
     160              :                   implementation module has been seen.
     161              : */
     162              : 
     163              : extern "C" bool M2Batch_IsSourceSeen (unsigned int sym);
     164              : 
     165              : /*
     166              :    IsModuleSeen - returns TRUE if the source for module, name, has been seen.
     167              : */
     168              : 
     169              : extern "C" bool M2Batch_IsModuleSeen (NameKey_Name n);
     170              : 
     171              : /*
     172              :    LookupModule - looks up a module in the current scope, if a module does not exist
     173              :                   then it creates a DefImp module.
     174              : */
     175              : 
     176              : extern "C" unsigned int M2Batch_LookupModule (unsigned int tok, NameKey_Name n);
     177              : 
     178              : /*
     179              :    LookupOuterModule - looks up a module in the order of: current scope, then outer scope, finally if a
     180              :                        module does not exist then it creates a DefImp module.
     181              : */
     182              : 
     183              : extern "C" unsigned int M2Batch_LookupOuterModule (unsigned int tok, NameKey_Name n);
     184              : 
     185              : /*
     186              :    Get - returns the module symbol matching name n.
     187              : */
     188              : 
     189              : extern "C" unsigned int M2Batch_Get (NameKey_Name n);
     190              : 
     191              : /*
     192              :    DisplayModules - a debugging routine to textually emit the names of modules in the SeenList.
     193              : */
     194              : 
     195              : extern "C" void M2Batch_DisplayModules (void);
     196              : 
     197              : /*
     198              :    Get - returns the module symbol matching name n.
     199              : */
     200              : 
     201              : static void Put (unsigned int Sym, NameKey_Name n);
     202              : 
     203              : /*
     204              :    Get - returns the module symbol matching name n.
     205              : */
     206              : 
     207              : static void Push (unsigned int Sym);
     208              : 
     209              : /*
     210              :    Get - returns the module symbol matching name n.
     211              : */
     212              : 
     213              : static unsigned int Pop (void);
     214              : 
     215              : 
     216              : /*
     217              :    Get - returns the module symbol matching name n.
     218              : */
     219              : 
     220       185071 : static void Put (unsigned int Sym, NameKey_Name n)
     221              : {
     222       185071 :   M2Batch_Module m;
     223              : 
     224       185071 :   Storage_ALLOCATE ((void **) &m, sizeof (M2Batch__T1));
     225       185071 :   Indexing_IncludeIndiceIntoIndex (SeenList, reinterpret_cast <void *> (m));
     226       185071 :   m->SymNo = Sym;
     227       185071 :   m->Key = n;
     228       185071 :   m->DefFile = static_cast<DynamicStrings_String> (NULL);
     229       185071 :   m->ModFile = static_cast<DynamicStrings_String> (NULL);
     230       185071 : }
     231              : 
     232              : 
     233              : /*
     234              :    Get - returns the module symbol matching name n.
     235              : */
     236              : 
     237       185071 : static void Push (unsigned int Sym)
     238              : {
     239            0 :   Lists_IncludeItemIntoList (PendingQueue, Sym);
     240       185071 : }
     241              : 
     242              : 
     243              : /*
     244              :    Get - returns the module symbol matching name n.
     245              : */
     246              : 
     247            0 : static unsigned int Pop (void)
     248              : {
     249            0 :   unsigned int n;
     250            0 :   unsigned int Sym;
     251              : 
     252            0 :   n = Lists_NoOfItemsInList (PendingQueue);
     253            0 :   if (n == 0)
     254              :     {
     255              :       return SymbolTable_NulSym;
     256              :     }
     257              :   else
     258              :     {
     259            0 :       Sym = static_cast<unsigned int> (Lists_GetItemFromList (PendingQueue, n));
     260            0 :       Lists_RemoveItemFromList (PendingQueue, Sym);
     261            0 :       return Sym;
     262              :     }
     263              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     264              :   __builtin_unreachable ();
     265              : }
     266              : 
     267              : 
     268              : /*
     269              :    MakeDefinitionSource - is given a Name, n, which is used to create a Definition
     270              :                           module.
     271              :                           The Definition Module will be placed onto the
     272              :                           compilation pending queue if it has not yet been
     273              :                           compiled.
     274              :                           If the module has been compiled then no action is
     275              :                           taken. The Module Sym is returned.
     276              : */
     277              : 
     278     13791872 : extern "C" unsigned int M2Batch_MakeDefinitionSource (unsigned int tok, NameKey_Name n)
     279              : {
     280     13791872 :   unsigned int Sym;
     281              : 
     282     13791872 :   Sym = M2Batch_Get (n);
     283     13791872 :   if (Sym == SymbolTable_NulSym)
     284              :     {
     285       170184 :       M2Debug_Assert ((((! (M2Pass_IsPass1 ())) && (! (M2Pass_IsPass2 ()))) && (! (M2Pass_IsPass3 ()))) && (! (M2Pass_IsPassC ())));
     286              :       /* Neither been compiled or on the Pending Queue  */
     287       170184 :       Sym = SymbolTable_MakeDefImp (tok, n);
     288       170184 :       Put (Sym, n);
     289       170184 :       Push (Sym);
     290              :     }
     291              :   else
     292              :     {
     293     13621688 :       SymbolTable_PutDeclared (tok, Sym);
     294              :     }
     295     13791872 :   return Sym;
     296              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     297              :   __builtin_unreachable ();
     298              : }
     299              : 
     300              : 
     301              : /*
     302              :    MakeImplementationSource - is given a Name, n, which is used to create an
     303              :                               implementation module.
     304              :                               The implementation Module will be placed onto
     305              :                               the compilation pending
     306              :                               queue if it has not yet been compiled.
     307              :                               If the module has been compiled then no
     308              :                               action is taken. The Module Sym is returned.
     309              : */
     310              : 
     311       357130 : extern "C" unsigned int M2Batch_MakeImplementationSource (unsigned int tok, NameKey_Name n)
     312              : {
     313       357130 :   unsigned int Sym;
     314              : 
     315       357130 :   Sym = M2Batch_Get (n);
     316       357130 :   if (Sym == SymbolTable_NulSym)
     317              :     {
     318         3021 :       M2Debug_Assert ((((! (M2Pass_IsPass1 ())) && (! (M2Pass_IsPass2 ()))) && (! (M2Pass_IsPass3 ()))) && (! (M2Pass_IsPassC ())));
     319              :       /* Neither been compiled or on the Pending Queue  */
     320         3021 :       Sym = SymbolTable_MakeDefImp (tok, n);
     321         3021 :       Put (Sym, n);
     322         3021 :       Push (Sym);
     323              :     }
     324              :   else
     325              :     {
     326       354109 :       SymbolTable_PutDeclared (tok, Sym);
     327              :     }
     328       357130 :   return Sym;
     329              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     330              :   __builtin_unreachable ();
     331              : }
     332              : 
     333              : 
     334              : /*
     335              :    MakeProgramSource - is given a Name, n, which is used to create a program module.
     336              :                        The program module will be placed onto the compilation
     337              :                        pending queue if it has not yet been compiled.
     338              :                        If the module has been compiled then no action is taken.
     339              :                        The Module Sym is returned.
     340              : */
     341              : 
     342        70517 : extern "C" unsigned int M2Batch_MakeProgramSource (unsigned int tok, NameKey_Name n)
     343              : {
     344        70517 :   unsigned int Sym;
     345              : 
     346        70517 :   Sym = M2Batch_Get (n);
     347        70517 :   if (Sym == SymbolTable_NulSym)
     348              :     {
     349        11866 :       M2Debug_Assert ((((! (M2Pass_IsPass1 ())) && (! (M2Pass_IsPass2 ()))) && (! (M2Pass_IsPass3 ()))) && (! (M2Pass_IsPassC ())));
     350              :       /* Neither been compiled or on the Pending Queue  */
     351        11866 :       Sym = SymbolTable_MakeModule (tok, n);
     352        11866 :       Put (Sym, n);
     353        11866 :       Push (Sym);
     354              :     }
     355              :   else
     356              :     {
     357        58651 :       SymbolTable_PutDeclared (tok, Sym);
     358              :     }
     359        70517 :   return Sym;
     360              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     361              :   __builtin_unreachable ();
     362              : }
     363              : 
     364              : 
     365              : /*
     366              :    GetSource - returns with the symbol Sym of the next module to be compiled.
     367              :                If Sym returns with value 0 then no module should be compiled.
     368              : */
     369              : 
     370            0 : extern "C" unsigned int M2Batch_GetSource (void)
     371              : {
     372            0 :   return Pop ();
     373              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     374              :   __builtin_unreachable ();
     375              : }
     376              : 
     377              : 
     378              : /*
     379              :    GetModuleNo - returns with symbol number of the nth module read during Pass 1.
     380              : */
     381              : 
     382       938012 : extern "C" unsigned int M2Batch_GetModuleNo (unsigned int nth)
     383              : {
     384       938012 :   M2Batch_Module m;
     385              : 
     386       938012 :   M2Debug_Assert (nth != 0);
     387       938012 :   if (Indexing_InBounds (SeenList, nth))
     388              :     {
     389       864526 :       m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, nth));
     390       864526 :       return m->SymNo;
     391              :     }
     392              :   else
     393              :     {
     394              :       return SymbolTable_NulSym;
     395              :     }
     396              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     397              :   __builtin_unreachable ();
     398              : }
     399              : 
     400              : 
     401              : /*
     402              :    IsModuleKnown - returns TRUE if the Name n matches a module.
     403              : */
     404              : 
     405            6 : extern "C" bool M2Batch_IsModuleKnown (NameKey_Name n)
     406              : {
     407            6 :   return (M2Batch_Get (n)) != SymbolTable_NulSym;
     408              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     409              :   __builtin_unreachable ();
     410              : }
     411              : 
     412              : 
     413              : /*
     414              :    AssociateDefinition - associate the source file, filename, with the definition module,
     415              :                          Sym.
     416              : */
     417              : 
     418       162096 : extern "C" DynamicStrings_String M2Batch_AssociateDefinition (DynamicStrings_String filename, unsigned int Sym)
     419              : {
     420       162096 :   unsigned int no;
     421       162096 :   unsigned int i;
     422       162096 :   M2Batch_Module m;
     423              : 
     424       162096 :   i = 1;
     425       162096 :   no = Indexing_HighIndice (SeenList);
     426      2275566 :   while (i <= no)
     427              :     {
     428      2113470 :       m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
     429      2113470 :       if (m->SymNo == Sym)
     430              :         {
     431       162096 :           m->DefFile = filename;
     432       162096 :           return filename;
     433              :         }
     434              :       else
     435              :         {
     436      1951374 :           i += 1;
     437              :         }
     438              :     }
     439            0 :   M2Error_InternalError ((const char *) "failed to find module sym", 25);
     440              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Batch.def", 20, 1);
     441              :   __builtin_unreachable ();
     442              : }
     443              : 
     444              : 
     445              : /*
     446              :    GetDefinitionModuleFile - returns the filename associated with the definition module, Sym.
     447              :                              It may return a temporary preprocessed file.
     448              : */
     449              : 
     450       690441 : extern "C" DynamicStrings_String M2Batch_GetDefinitionModuleFile (unsigned int Sym)
     451              : {
     452       690441 :   unsigned int no;
     453       690441 :   unsigned int i;
     454       690441 :   M2Batch_Module m;
     455              : 
     456       690441 :   i = 1;
     457       690441 :   no = Indexing_HighIndice (SeenList);
     458      9353124 :   while (i <= no)
     459              :     {
     460      8662683 :       m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
     461      8662683 :       if (m->SymNo == Sym)
     462              :         {
     463       690441 :           return m->DefFile;
     464              :         }
     465              :       else
     466              :         {
     467      7972242 :           i += 1;
     468              :         }
     469              :     }
     470              :   return static_cast<DynamicStrings_String> (NULL);
     471              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     472              :   __builtin_unreachable ();
     473              : }
     474              : 
     475              : 
     476              : /*
     477              :    AssociateModule - associate the source file, filename, with the implementation/program
     478              :                      module, Sym.
     479              : */
     480              : 
     481        82813 : extern "C" DynamicStrings_String M2Batch_AssociateModule (DynamicStrings_String filename, unsigned int Sym)
     482              : {
     483        82813 :   unsigned int no;
     484        82813 :   unsigned int i;
     485        82813 :   M2Batch_Module m;
     486              : 
     487        82813 :   i = 1;
     488        82813 :   no = Indexing_HighIndice (SeenList);
     489      1293856 :   while (i <= no)
     490              :     {
     491      1211043 :       m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
     492      1211043 :       if (m->SymNo == Sym)
     493              :         {
     494        82813 :           m->ModFile = filename;
     495        82813 :           return filename;
     496              :         }
     497              :       else
     498              :         {
     499      1128230 :           i += 1;
     500              :         }
     501              :     }
     502            0 :   M2Error_InternalError ((const char *) "failed to find module sym", 25);
     503              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Batch.def", 20, 1);
     504              :   __builtin_unreachable ();
     505              : }
     506              : 
     507              : 
     508              : /*
     509              :    GetModuleFile - returns the filename associated with the implementation/program module, Sym.
     510              :                    It may return a temporary preprocessed file.
     511              : */
     512              : 
     513       716763 : extern "C" DynamicStrings_String M2Batch_GetModuleFile (unsigned int Sym)
     514              : {
     515       716763 :   unsigned int no;
     516       716763 :   unsigned int i;
     517       716763 :   M2Batch_Module m;
     518              : 
     519       716763 :   i = 1;
     520       716763 :   no = Indexing_HighIndice (SeenList);
     521      9769488 :   while (i <= no)
     522              :     {
     523      9052725 :       m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
     524      9052725 :       if (m->SymNo == Sym)
     525              :         {
     526       716763 :           return m->ModFile;
     527              :         }
     528              :       else
     529              :         {
     530      8335962 :           i += 1;
     531              :         }
     532              :     }
     533              :   return static_cast<DynamicStrings_String> (NULL);
     534              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     535              :   __builtin_unreachable ();
     536              : }
     537              : 
     538              : 
     539              : /*
     540              :    ForeachSourceModuleDo - for each source file call procedure, p.
     541              : */
     542              : 
     543           96 : extern "C" void M2Batch_ForeachSourceModuleDo (M2Batch_DoProcedure p)
     544              : {
     545           96 :   unsigned int i;
     546           96 :   unsigned int no;
     547           96 :   M2Batch_Module m;
     548              : 
     549           96 :   i = 1;
     550           96 :   no = Indexing_HighIndice (SeenList);
     551         3360 :   while (i <= no)
     552              :     {
     553         3168 :       m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
     554         3168 :       if (m->ModFile != NULL)
     555              :         {
     556         2208 :           (*p.proc) (m->SymNo);
     557              :         }
     558         3168 :       i += 1;
     559              :     }
     560           96 : }
     561              : 
     562              : 
     563              : /*
     564              :    IsSourceSeen - returns TRUE if the source for the program module or
     565              :                   implementation module has been seen.
     566              : */
     567              : 
     568         1890 : extern "C" bool M2Batch_IsSourceSeen (unsigned int sym)
     569              : {
     570         3780 :   M2Debug_Assert ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)));
     571         1890 :   return (M2Batch_GetModuleFile (sym)) != NULL;
     572              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     573              :   __builtin_unreachable ();
     574              : }
     575              : 
     576              : 
     577              : /*
     578              :    IsModuleSeen - returns TRUE if the source for module, name, has been seen.
     579              : */
     580              : 
     581            0 : extern "C" bool M2Batch_IsModuleSeen (NameKey_Name n)
     582              : {
     583            0 :   return (M2Batch_Get (n)) != SymbolTable_NulSym;
     584              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     585              :   __builtin_unreachable ();
     586              : }
     587              : 
     588              : 
     589              : /*
     590              :    LookupModule - looks up a module in the current scope, if a module does not exist
     591              :                   then it creates a DefImp module.
     592              : */
     593              : 
     594      1534160 : extern "C" unsigned int M2Batch_LookupModule (unsigned int tok, NameKey_Name n)
     595              : {
     596      1534160 :   unsigned int sym;
     597              : 
     598      1534160 :   sym = SymbolTable_GetSym (n);
     599      1534160 :   if (sym == SymbolTable_NulSym)
     600              :     {
     601      1484246 :       return M2Batch_MakeDefinitionSource (tok, n);
     602              :     }
     603        49914 :   else if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
     604              :     {
     605              :       /* avoid dangling else.  */
     606        44226 :       return sym;
     607              :     }
     608              :   else
     609              :     {
     610              :       /* avoid dangling else.  */
     611         5688 :       return M2Batch_MakeDefinitionSource (tok, n);
     612              :     }
     613              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     614              :   __builtin_unreachable ();
     615              : }
     616              : 
     617              : 
     618              : /*
     619              :    LookupOuterModule - looks up a module in the order of: current scope, then outer scope, finally if a
     620              :                        module does not exist then it creates a DefImp module.
     621              : */
     622              : 
     623       119992 : extern "C" unsigned int M2Batch_LookupOuterModule (unsigned int tok, NameKey_Name n)
     624              : {
     625       119992 :   unsigned int outer;
     626       119992 :   unsigned int sym;
     627              : 
     628       119992 :   sym = SymbolTable_GetSym (n);
     629       119992 :   if (sym == SymbolTable_NulSym)
     630              :     {
     631       113896 :       outer = SymbolTable_GetScope (SymbolTable_GetCurrentScope ());
     632       113896 :       if (outer != SymbolTable_NulSym)
     633              :         {
     634          264 :           sym = SymbolTable_GetLocalSym (outer, n);
     635              :         }
     636       113896 :       if (sym == SymbolTable_NulSym)
     637              :         {
     638              :           /* not a local module, so it must be referring to a definition module.  */
     639       113752 :           sym = M2Batch_MakeDefinitionSource (tok, n);
     640              :         }
     641              :     }
     642       119992 :   if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
     643              :     {
     644       119932 :       return sym;
     645              :     }
     646              :   else
     647              :     {
     648           60 :       return M2Batch_MakeDefinitionSource (tok, n);
     649              :     }
     650              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     651              :   __builtin_unreachable ();
     652              : }
     653              : 
     654              : 
     655              : /*
     656              :    Get - returns the module symbol matching name n.
     657              : */
     658              : 
     659     14219525 : extern "C" unsigned int M2Batch_Get (NameKey_Name n)
     660              : {
     661     14219525 :   unsigned int i;
     662     14219525 :   unsigned int no;
     663     14219525 :   M2Batch_Module m;
     664              : 
     665     14219525 :   i = 1;
     666     14219525 :   no = Indexing_HighIndice (SeenList);
     667    165421346 :   while (i <= no)
     668              :     {
     669    151016750 :       m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
     670    151016750 :       if (m->Key == n)
     671              :         {
     672     14034454 :           return m->SymNo;
     673              :         }
     674              :       else
     675              :         {
     676    136982296 :           i += 1;
     677              :         }
     678              :     }
     679              :   return SymbolTable_NulSym;
     680              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     681              :   __builtin_unreachable ();
     682              : }
     683              : 
     684              : 
     685              : /*
     686              :    DisplayModules - a debugging routine to textually emit the names of modules in the SeenList.
     687              : */
     688              : 
     689            0 : extern "C" void M2Batch_DisplayModules (void)
     690              : {
     691            0 :   M2Batch_Module m;
     692            0 :   unsigned int n;
     693            0 :   unsigned int i;
     694              : 
     695            0 :   i = 1;
     696            0 :   n = Indexing_HighIndice (SeenList);
     697            0 :   while (i <= n)
     698              :     {
     699            0 :       m = static_cast<M2Batch_Module> (Indexing_GetIndice (SeenList, i));
     700            0 :       M2Printf_printf2 ((const char *) "Module %a %d\\n", 14, (const unsigned char *) &m->Key, (sizeof (m->Key)-1), (const unsigned char *) &i, (sizeof (i)-1));
     701            0 :       i += 1;
     702              :     }
     703            0 : }
     704              : 
     705        14952 : extern "C" void _M2_M2Batch_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
     706              : {
     707        14952 :   Lists_InitList (&PendingQueue);
     708        14952 :   SeenList = Indexing_InitIndex (1);
     709        14952 : }
     710              : 
     711            0 : extern "C" void _M2_M2Batch_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
     712              : {
     713            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.