LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - P1SymBuild.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 90.1 % 333 300
Test Date: 2024-04-20 14:03:02 Functions: 92.0 % 25 23
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* do not edit automatically generated by mc from P1SymBuild.  */
       2                 :             : /* P1SymBuild.mod pass 1 symbol creation.
       3                 :             : 
       4                 :             : Copyright (C) 2001-2024 Free Software Foundation, Inc.
       5                 :             : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6                 :             : 
       7                 :             : This file is part of GNU Modula-2.
       8                 :             : 
       9                 :             : GNU Modula-2 is free software; you can redistribute it and/or modify
      10                 :             : it under the terms of the GNU General Public License as published by
      11                 :             : the Free Software Foundation; either version 3, or (at your option)
      12                 :             : any later version.
      13                 :             : 
      14                 :             : GNU Modula-2 is distributed in the hope that it will be useful, but
      15                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :             : General Public License for more details.
      18                 :             : 
      19                 :             : You should have received a copy of the GNU General Public License
      20                 :             : along with GNU Modula-2; see the file COPYING3.  If not see
      21                 :             : <http://www.gnu.org/licenses/>.  */
      22                 :             : 
      23                 :             : #include "config.h"
      24                 :             : #include "system.h"
      25                 :             : #include <stdbool.h>
      26                 :             : #   if !defined (PROC_D)
      27                 :             : #      define PROC_D
      28                 :             :        typedef void (*PROC_t) (void);
      29                 :             :        typedef struct { PROC_t proc; } PROC;
      30                 :             : #   endif
      31                 :             : 
      32                 :             : #   if !defined (FALSE)
      33                 :             : #      define FALSE (1==0)
      34                 :             : #   endif
      35                 :             : 
      36                 :             : #define _P1SymBuild_H
      37                 :             : #define _P1SymBuild_C
      38                 :             : 
      39                 :             : #   include "GASCII.h"
      40                 :             : #   include "GNameKey.h"
      41                 :             : #   include "GM2Debug.h"
      42                 :             : #   include "GM2LexBuf.h"
      43                 :             : #   include "GM2MetaError.h"
      44                 :             : #   include "GDynamicStrings.h"
      45                 :             : #   include "GM2Printf.h"
      46                 :             : #   include "GM2Options.h"
      47                 :             : #   include "GM2Reserved.h"
      48                 :             : #   include "GFifoQueue.h"
      49                 :             : #   include "GP0SymBuild.h"
      50                 :             : #   include "GSymbolTable.h"
      51                 :             : #   include "GM2Batch.h"
      52                 :             : #   include "GM2Quads.h"
      53                 :             : #   include "GM2Comp.h"
      54                 :             : 
      55                 :             : #   define Debugging false
      56                 :             : static unsigned int importStatementCount;
      57                 :             : extern "C" void P1SymBuild_P1StartBuildDefinitionModule (void);
      58                 :             : extern "C" void P1SymBuild_P1EndBuildDefinitionModule (void);
      59                 :             : extern "C" void P1SymBuild_P1StartBuildImplementationModule (void);
      60                 :             : extern "C" void P1SymBuild_P1EndBuildImplementationModule (void);
      61                 :             : extern "C" void P1SymBuild_P1StartBuildProgramModule (void);
      62                 :             : extern "C" void P1SymBuild_P1EndBuildProgramModule (void);
      63                 :             : 
      64                 :             : /*
      65                 :             :    StartBuildInnerModule - Creates an Inner module and starts
      66                 :             :                            a new scope.
      67                 :             : 
      68                 :             :                            The Stack is expected:
      69                 :             : 
      70                 :             :                            Entry                 Exit
      71                 :             : 
      72                 :             :                     Ptr ->                                     <- Ptr
      73                 :             :                            +------------+        +-----------+
      74                 :             :                            | NameStart  |        | NameStart |
      75                 :             :                            |------------|        |-----------|
      76                 :             : 
      77                 :             : */
      78                 :             : 
      79                 :             : extern "C" void P1SymBuild_StartBuildInnerModule (void);
      80                 :             : 
      81                 :             : /*
      82                 :             :    EndBuildInnerModule - Destroys the Inner module scope and
      83                 :             :                          checks for correct name.
      84                 :             : 
      85                 :             :                          The Stack is expected:
      86                 :             : 
      87                 :             :                          Entry                 Exit
      88                 :             : 
      89                 :             :                   Ptr ->
      90                 :             :                          +------------+        +-----------+
      91                 :             :                          | NameEnd    |        |           |
      92                 :             :                          |------------|        |-----------|
      93                 :             :                          | NameStart  |        |           | <- Ptr
      94                 :             :                          |------------|        |-----------|
      95                 :             : */
      96                 :             : 
      97                 :             : extern "C" void P1SymBuild_EndBuildInnerModule (void);
      98                 :             : 
      99                 :             : /*
     100                 :             :    BuildImportOuterModule - Builds imported identifiers into an outer module
     101                 :             :                             from a definition module.
     102                 :             : 
     103                 :             :                             The Stack is expected:
     104                 :             : 
     105                 :             :                             Entry           OR    Entry
     106                 :             : 
     107                 :             :                      Ptr ->                Ptr ->
     108                 :             :                             +------------+        +-----------+
     109                 :             :                             | #          |        | #         |
     110                 :             :                             |------------|        |-----------|
     111                 :             :                             | Id1        |        | Id1       |
     112                 :             :                             |------------|        |-----------|
     113                 :             :                             .            .        .           .
     114                 :             :                             .            .        .           .
     115                 :             :                             .            .        .           .
     116                 :             :                             |------------|        |-----------|
     117                 :             :                             | Id#        |        | Id#       |
     118                 :             :                             |------------|        |-----------|
     119                 :             :                             | ImportTok  |        | Ident     |
     120                 :             :                             |------------|        |-----------|
     121                 :             : 
     122                 :             :                             IMPORT Id1, .. Id# ;  FROM Ident IMPORT Id1 .. Id# ;
     123                 :             : 
     124                 :             : 
     125                 :             :                             Exit
     126                 :             : 
     127                 :             :                             All above stack discarded
     128                 :             : */
     129                 :             : 
     130                 :             : extern "C" void P1SymBuild_BuildImportOuterModule (bool definition);
     131                 :             : 
     132                 :             : /*
     133                 :             :    BuildExportOuterModule - Builds exported identifiers from an outer module
     134                 :             :                             to the outside world of library modules.
     135                 :             : 
     136                 :             :                             The Stack is expected:
     137                 :             : 
     138                 :             :                             Entry           OR    Entry
     139                 :             : 
     140                 :             :                      Ptr ->                Ptr ->
     141                 :             :                             +------------+        +--------------+
     142                 :             :                             | #          |        | #            |
     143                 :             :                             |------------|        |--------------|
     144                 :             :                             | Id1        |        | Id1          |
     145                 :             :                             |------------|        |--------------|
     146                 :             :                             .            .        .              .
     147                 :             :                             .            .        .              .
     148                 :             :                             .            .        .              .
     149                 :             :                             |------------|        |--------------|
     150                 :             :                             | Id#        |        | Id#          |
     151                 :             :                             |------------|        |--------------|
     152                 :             :                             | ExportTok  |        | QualifiedTok |
     153                 :             :                             |------------|        |--------------|
     154                 :             : 
     155                 :             :                             EXPORT Id1, .. Id# ;  EXPORT QUALIFIED Id1 .. Id# ;
     156                 :             : 
     157                 :             :                             Error Condition
     158                 :             : 
     159                 :             : 
     160                 :             :                             Exit
     161                 :             : 
     162                 :             :                             All above stack discarded
     163                 :             : */
     164                 :             : 
     165                 :             : extern "C" void P1SymBuild_BuildExportOuterModule (void);
     166                 :             : 
     167                 :             : /*
     168                 :             :    CheckExplicitExported - checks to see whether we are compiling
     169                 :             :                            a definition module and whether the ident
     170                 :             :                            is implicitly export qualified or unqualified.
     171                 :             : 
     172                 :             : 
     173                 :             :                                   The Stack is expected:
     174                 :             : 
     175                 :             :                                   Entry                 Exit
     176                 :             : 
     177                 :             :                            Ptr ->                Ptr ->
     178                 :             :                                   +------------+        +-----------+
     179                 :             :                                   | Identname  |        | Identname |
     180                 :             :                                   |------------|        |-----------|
     181                 :             : 
     182                 :             : */
     183                 :             : 
     184                 :             : extern "C" void P1SymBuild_CheckExplicitExported (void);
     185                 :             : 
     186                 :             : /*
     187                 :             :    BuildImportInnerModule - Builds imported identifiers into an inner module
     188                 :             :                             from the last level of module.
     189                 :             : 
     190                 :             :                             The Stack is expected:
     191                 :             : 
     192                 :             :                             Entry           OR    Entry
     193                 :             : 
     194                 :             :                      Ptr ->                Ptr ->
     195                 :             :                             +------------+        +-----------+
     196                 :             :                             | #          |        | #         |
     197                 :             :                             |------------|        |-----------|
     198                 :             :                             | Id1        |        | Id1       |
     199                 :             :                             |------------|        |-----------|
     200                 :             :                             .            .        .           .
     201                 :             :                             .            .        .           .
     202                 :             :                             .            .        .           .
     203                 :             :                             |------------|        |-----------|
     204                 :             :                             | Id#        |        | Id#       |
     205                 :             :                             |------------|        |-----------|
     206                 :             :                             | ImportTok  |        | Ident     |
     207                 :             :                             |------------|        |-----------|
     208                 :             : 
     209                 :             :                             IMPORT Id1, .. Id# ;  FROM Ident IMPORT Id1 .. Id# ;
     210                 :             : 
     211                 :             :                             Exit
     212                 :             : 
     213                 :             :                             All above stack discarded
     214                 :             : */
     215                 :             : 
     216                 :             : extern "C" void P1SymBuild_BuildImportInnerModule (void);
     217                 :             : 
     218                 :             : /*
     219                 :             :    BuildExportInnerModule - Builds exported identifiers from an inner module
     220                 :             :                             to the next layer module.
     221                 :             : 
     222                 :             :                             The Stack is expected:
     223                 :             : 
     224                 :             :                             Entry           OR    Entry
     225                 :             : 
     226                 :             :                      Ptr ->                Ptr ->
     227                 :             :                             +------------+        +--------------+
     228                 :             :                             | #          |        | #            |
     229                 :             :                             |------------|        |--------------|
     230                 :             :                             | Id1        |        | Id1          |
     231                 :             :                             |------------|        |--------------|
     232                 :             :                             .            .        .              .
     233                 :             :                             .            .        .              .
     234                 :             :                             .            .        .              .
     235                 :             :                             |------------|        |--------------|
     236                 :             :                             | Id#        |        | Id#          |
     237                 :             :                             |------------|        |--------------|
     238                 :             :                             | ExportTok  |        | QualifiedTok |
     239                 :             :                             |------------|        |--------------|
     240                 :             : 
     241                 :             :                             EXPORT Id1, .. Id# ;  EXPORT QUALIFIED Id1 .. Id# ;
     242                 :             : 
     243                 :             : 
     244                 :             :                             Exit
     245                 :             : 
     246                 :             : 
     247                 :             :                             All above stack discarded
     248                 :             : */
     249                 :             : 
     250                 :             : extern "C" void P1SymBuild_BuildExportInnerModule (void);
     251                 :             : 
     252                 :             : /*
     253                 :             :    StartBuildEnumeration - Builds an Enumeration type Type.
     254                 :             : 
     255                 :             : 
     256                 :             :                            Stack
     257                 :             : 
     258                 :             :                            Entry                 Exit
     259                 :             : 
     260                 :             :                     Ptr ->
     261                 :             :                            +------------+
     262                 :             :                            | #          |
     263                 :             :                            |------------|
     264                 :             :                            | en 1       |
     265                 :             :                            |------------|
     266                 :             :                            | en 2       |
     267                 :             :                            |------------|
     268                 :             :                            .            .
     269                 :             :                            .            .
     270                 :             :                            .            .                       <- Ptr
     271                 :             :                            |------------|        +------------+
     272                 :             :                            | en #       |        | Type       |
     273                 :             :                            |------------|        |------------|
     274                 :             :                            | Name       |        | Name       |
     275                 :             :                            |------------|        |------------|
     276                 :             : */
     277                 :             : 
     278                 :             : extern "C" void P1SymBuild_StartBuildEnumeration (void);
     279                 :             : 
     280                 :             : /*
     281                 :             :    EndBuildEnumeration - completes the construction of the enumeration type.
     282                 :             : 
     283                 :             : 
     284                 :             :                          Stack
     285                 :             : 
     286                 :             :                          Entry                 Exit
     287                 :             : 
     288                 :             :                   Ptr ->
     289                 :             :                          +------------+
     290                 :             :                          | Type       |                          <- Ptr
     291                 :             :                          |------------|        +---------------+
     292                 :             :                          | Name       |        | Type  | Name  |
     293                 :             :                          |------------|        |---------------|
     294                 :             : 
     295                 :             :                                                Empty
     296                 :             : */
     297                 :             : 
     298                 :             : extern "C" void P1SymBuild_EndBuildEnumeration (void);
     299                 :             : 
     300                 :             : /*
     301                 :             :    BuildHiddenType - Builds a Hidden Type.
     302                 :             : 
     303                 :             : 
     304                 :             :                      Stack
     305                 :             : 
     306                 :             :                      Entry                 Exit
     307                 :             : 
     308                 :             :               Ptr ->
     309                 :             :                      +------------+
     310                 :             :                      | Name       |                          <- Ptr
     311                 :             :                      |------------|        Empty
     312                 :             : */
     313                 :             : 
     314                 :             : extern "C" void P1SymBuild_BuildHiddenType (void);
     315                 :             : 
     316                 :             : /*
     317                 :             :    StartBuildProcedure - Builds a Procedure.
     318                 :             : 
     319                 :             :                          The Stack:
     320                 :             : 
     321                 :             :                          Entry                 Exit
     322                 :             : 
     323                 :             :                   Ptr ->                                      <- Ptr
     324                 :             :                          +------------+        +------------+
     325                 :             :                          | Name       |        | ProcSym    |
     326                 :             :                          |------------|        |------------|
     327                 :             :                          | inlinetok  |        |            |
     328                 :             :                          | or         |        |            |
     329                 :             :                          | builtintok |        |            |
     330                 :             :                          | or name or |        | Name       |
     331                 :             :                          | NulTok     |        |            |
     332                 :             :                          |------------|        |------------|
     333                 :             : */
     334                 :             : 
     335                 :             : extern "C" void P1SymBuild_StartBuildProcedure (void);
     336                 :             : 
     337                 :             : /*
     338                 :             :    EndBuildProcedure - Ends building a Procedure.
     339                 :             :                        It checks the start procedure name matches the end
     340                 :             :                        procedure name.
     341                 :             : 
     342                 :             :                        The Stack:
     343                 :             : 
     344                 :             :                        (Procedure Not Defined in definition module)
     345                 :             : 
     346                 :             :                        Entry                 Exit
     347                 :             : 
     348                 :             :                 Ptr ->
     349                 :             :                        +------------+
     350                 :             :                        | NameEnd    |
     351                 :             :                        |------------|
     352                 :             :                        | ProcSym    |
     353                 :             :                        |------------|
     354                 :             :                        | NameStart  |
     355                 :             :                        |------------|
     356                 :             :                                              Empty
     357                 :             : */
     358                 :             : 
     359                 :             : extern "C" void P1SymBuild_EndBuildProcedure (void);
     360                 :             : 
     361                 :             : /*
     362                 :             :    BuildProcedureHeading - Builds a procedure heading for the definition
     363                 :             :                            module procedures.
     364                 :             : 
     365                 :             :                            Operation only performed if compiling a
     366                 :             :                            definition module.
     367                 :             : 
     368                 :             :                            The Stack:
     369                 :             : 
     370                 :             :                            Entry                       Exit
     371                 :             : 
     372                 :             :                     Ptr ->
     373                 :             :                            +------------+
     374                 :             :                            | ProcSym    |
     375                 :             :                            |------------|
     376                 :             :                            | NameStart  |
     377                 :             :                            |------------|
     378                 :             :                                                        Empty
     379                 :             : 
     380                 :             : */
     381                 :             : 
     382                 :             : extern "C" void P1SymBuild_BuildProcedureHeading (void);
     383                 :             : 
     384                 :             : /*
     385                 :             :    BuildNulName - Pushes a NulName onto the top of the stack.
     386                 :             :                   The Stack:
     387                 :             : 
     388                 :             : 
     389                 :             :                   Entry                    Exit
     390                 :             : 
     391                 :             :                                                           <- Ptr
     392                 :             :                   Empty                    +------------+
     393                 :             :                                            | NulName    |
     394                 :             :                                            |------------|
     395                 :             : */
     396                 :             : 
     397                 :             : extern "C" void P1SymBuild_BuildNulName (void);
     398                 :             : 
     399                 :             : /*
     400                 :             :    BuildTypeEnd - Pops the type Type and Name.
     401                 :             :                   The Stack:
     402                 :             : 
     403                 :             : 
     404                 :             :                   Entry                    Exit
     405                 :             : 
     406                 :             : 
     407                 :             :            Ptr ->
     408                 :             :                   +-------------+
     409                 :             :                   | Type | Name |          Empty
     410                 :             :                   |-------------|
     411                 :             : */
     412                 :             : 
     413                 :             : extern "C" void P1SymBuild_BuildTypeEnd (void);
     414                 :             : 
     415                 :             : /*
     416                 :             :    BuildImportStatement - create a new import statement in the current module.
     417                 :             :                           It ignores local modules.
     418                 :             : 
     419                 :             :                           The quadruple stack is not used.
     420                 :             : */
     421                 :             : 
     422                 :             : extern "C" void P1SymBuild_BuildImportStatement (unsigned int tok);
     423                 :             : 
     424                 :             : /*
     425                 :             :    AddImportToImportStatement - the top of stack is expected to be a module name.
     426                 :             :                                 This is looked up from the module universe and
     427                 :             :                                 wrapped in an import symbol and placed into the
     428                 :             :                                 current import statement.
     429                 :             : 
     430                 :             :                                 The quadruple stack is unchanged.
     431                 :             : 
     432                 :             :                                 Entry                      Exit
     433                 :             : 
     434                 :             : 
     435                 :             :                          Ptr ->                                                   <- Ptr
     436                 :             :                                 +---------------------+    +---------------------+
     437                 :             :                                 | ImportedModuleName  |    | ImportedModuleName  |
     438                 :             :                                 |---------------------|    |---------------------|
     439                 :             : */
     440                 :             : 
     441                 :             : extern "C" void P1SymBuild_AddImportToImportStatement (bool qualified);
     442                 :             : 
     443                 :      125459 : extern "C" void P1SymBuild_P1StartBuildDefinitionModule (void)
     444                 :             : {
     445                 :      125459 :   NameKey_Name name;
     446                 :      125459 :   unsigned int language;
     447                 :      125459 :   unsigned int ModuleSym;
     448                 :             : 
     449                 :             :   /* 
     450                 :             :    StartBuildDefinitionModule - Creates a definition module and starts
     451                 :             :                                 a new scope.
     452                 :             : 
     453                 :             :                                 he Stack is expected:
     454                 :             : 
     455                 :             :                                 Entry                 Exit
     456                 :             : 
     457                 :             :                          Ptr ->
     458                 :             :                                 +------------+
     459                 :             :                                 | NameStart  |                       <- Ptr
     460                 :             :                                 |------------|        +------------+
     461                 :             :                                 | NulName/"C"|        | NameStart  |
     462                 :             :                                 |------------|        |------------|
     463                 :             :   */
     464                 :      125459 :   importStatementCount = 0;
     465                 :      125459 :   M2Quads_PopT (&name);
     466                 :             :   /* CheckFileName(name, 'definition') ;  */
     467                 :      125459 :   ModuleSym = M2Batch_MakeDefinitionSource (M2LexBuf_GetTokenNo (), name);
     468                 :      125459 :   SymbolTable_PutDoesNotNeedExportList (ModuleSym);
     469                 :      125459 :   SymbolTable_SetCurrentModule (ModuleSym);
     470                 :      125459 :   SymbolTable_SetFileModule (ModuleSym);
     471                 :      125459 :   SymbolTable_StartScope (ModuleSym);
     472                 :      125459 :   M2Debug_Assert (SymbolTable_IsDefImp (ModuleSym));
     473                 :      125459 :   M2Debug_Assert (M2Comp_CompilingDefinitionModule ());
     474                 :      125459 :   M2Quads_PopT (&language);
     475                 :      125459 :   if ((language != SymbolTable_NulSym) && (SymbolTable_IsConstString (language)))
     476                 :             :     {
     477                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
     478                 :        7702 :       if ((SymbolTable_GetSymName (language)) == (NameKey_MakeKey ((const char *) "C", 1)))
     479                 :             :         {
     480                 :        7702 :           SymbolTable_PutDefinitionForC (ModuleSym);
     481                 :             :         }
     482                 :           0 :       else if ((SymbolTable_GetSymName (language)) == NameKey_NulName)
     483                 :             :         {
     484                 :             :           /* avoid dangling else.  */
     485                 :           0 :           M2MetaError_MetaError0 ((const char *) "{%E}currently a non modula-2 definition module can only be declared as DEFINITION FOR {%k\"C\"}", 93);
     486                 :             :         }
     487                 :             :       else
     488                 :             :         {
     489                 :             :           /* avoid dangling else.  */
     490                 :           0 :           M2MetaError_MetaError1 ((const char *) "unknown definition module language {%1Ea}, currently a non modula-2 definition module can only be declared as DEFINITION FOR {%k\"C\"}", 132, language);
     491                 :             :         }
     492                 :             :     }
     493                 :      125459 :   M2Quads_PushT (name);
     494                 :      125459 :   P0SymBuild_EnterBlock (name);
     495                 :      125459 : }
     496                 :             : 
     497                 :      125459 : extern "C" void P1SymBuild_P1EndBuildDefinitionModule (void)
     498                 :             : {
     499                 :      125459 :   unsigned int start;
     500                 :      125459 :   NameKey_Name NameStart;
     501                 :      125459 :   NameKey_Name NameEnd;
     502                 :             : 
     503                 :             :   /* 
     504                 :             :    EndBuildDefinitionModule - Destroys the definition module scope and
     505                 :             :                               checks for correct name.
     506                 :             : 
     507                 :             :                               The Stack is expected:
     508                 :             : 
     509                 :             :                               Entry                 Exit
     510                 :             : 
     511                 :             :                        Ptr ->
     512                 :             :                               +------------+        +-----------+
     513                 :             :                               | NameEnd    |        |           |
     514                 :             :                               |------------|        |-----------|
     515                 :             :                               | NameStart  |        |           | <- Ptr
     516                 :             :                               |------------|        |-----------|
     517                 :             :   */
     518                 :      125459 :   M2Debug_Assert (M2Comp_CompilingDefinitionModule ());
     519                 :      125459 :   SymbolTable_EndScope ();
     520                 :      125459 :   M2Quads_PopTtok (&NameStart, &start);
     521                 :      125459 :   M2Quads_PopT (&NameEnd);
     522                 :      125459 :   if (Debugging)
     523                 :             :     {
     524                 :             :       M2Printf_printf0 ((const char *) "pass 1: ", 8);
     525                 :             :       SymbolTable_DisplayTrees (SymbolTable_GetCurrentModule ());
     526                 :             :     }
     527                 :      125459 :   if (NameStart != NameEnd)
     528                 :             :     {
     529                 :           0 :       M2MetaError_MetaError1 ((const char *) "inconsistant definition module name {%1Wa}", 42, SymbolTable_MakeError (start, NameStart));
     530                 :             :     }
     531                 :      125459 :   P0SymBuild_LeaveBlock ();
     532                 :      125459 : }
     533                 :             : 
     534                 :       52824 : extern "C" void P1SymBuild_P1StartBuildImplementationModule (void)
     535                 :             : {
     536                 :       52824 :   unsigned int tok;
     537                 :       52824 :   NameKey_Name name;
     538                 :       52824 :   unsigned int ModuleSym;
     539                 :             : 
     540                 :             :   /* 
     541                 :             :    StartBuildImplementationModule - Creates an implementation module and starts
     542                 :             :                                     a new scope.
     543                 :             : 
     544                 :             :                                     The Stack is expected:
     545                 :             : 
     546                 :             :                                     Entry                 Exit
     547                 :             : 
     548                 :             :                              Ptr ->                                     <- Ptr
     549                 :             :                                     +------------+        +-----------+
     550                 :             :                                     | NameStart  |        | NameStart |
     551                 :             :                                     |------------|        |-----------|
     552                 :             : 
     553                 :             :   */
     554                 :       52824 :   importStatementCount = 0;
     555                 :       52824 :   M2Quads_PopTtok (&name, &tok);
     556                 :             :   /* CheckFileName(name, 'implementation') ;  */
     557                 :       52824 :   ModuleSym = M2Batch_MakeImplementationSource (tok, name);
     558                 :       52824 :   SymbolTable_SetCurrentModule (ModuleSym);
     559                 :       52824 :   SymbolTable_SetFileModule (ModuleSym);
     560                 :       52824 :   SymbolTable_StartScope (ModuleSym);
     561                 :       52824 :   if (! (SymbolTable_IsDefImp (ModuleSym)))
     562                 :             :     {
     563                 :           0 :       M2MetaError_MetaError1 ((const char *) "cannot find corresponding definition module for {%1Ea}", 54, ModuleSym);
     564                 :             :     }
     565                 :       52824 :   M2Debug_Assert (M2Comp_CompilingImplementationModule ());
     566                 :       52824 :   M2Quads_PushTtok (name, tok);
     567                 :       52824 :   P0SymBuild_EnterBlock (name);
     568                 :       52824 : }
     569                 :             : 
     570                 :       52824 : extern "C" void P1SymBuild_P1EndBuildImplementationModule (void)
     571                 :             : {
     572                 :       52824 :   unsigned int start;
     573                 :       52824 :   unsigned int end;
     574                 :       52824 :   NameKey_Name NameStart;
     575                 :       52824 :   NameKey_Name NameEnd;
     576                 :             : 
     577                 :             :   /* 
     578                 :             :    EndBuildImplementationModule - Destroys the implementation module scope and
     579                 :             :                                   checks for correct name.
     580                 :             : 
     581                 :             :                                   The Stack is expected:
     582                 :             : 
     583                 :             :                                   Entry                 Exit
     584                 :             : 
     585                 :             :                            Ptr ->
     586                 :             :                                   +------------+        +-----------+
     587                 :             :                                   | NameEnd    |        |           |
     588                 :             :                                   |------------|        |-----------|
     589                 :             :                                   | NameStart  |        |           | <- Ptr
     590                 :             :                                   |------------|        |-----------|
     591                 :             :   */
     592                 :       52824 :   SymbolTable_ResolveImports ();
     593                 :       52824 :   M2Debug_Assert (M2Comp_CompilingImplementationModule ());
     594                 :       52824 :   SymbolTable_EndScope ();
     595                 :       52824 :   M2Quads_PopTtok (&NameStart, &start);
     596                 :       52824 :   M2Quads_PopTtok (&NameEnd, &end);
     597                 :       52824 :   if (NameStart != NameEnd)
     598                 :             :     {
     599                 :           0 :       M2MetaError_MetaErrorT1 (end, (const char *) "inconsistant implementation module name {%1Wa}", 46, SymbolTable_MakeError (start, NameStart));
     600                 :             :     }
     601                 :       52824 :   P0SymBuild_LeaveBlock ();
     602                 :       52824 : }
     603                 :             : 
     604                 :       10408 : extern "C" void P1SymBuild_P1StartBuildProgramModule (void)
     605                 :             : {
     606                 :       10408 :   unsigned int tok;
     607                 :       10408 :   NameKey_Name name;
     608                 :       10408 :   unsigned int ModuleSym;
     609                 :             : 
     610                 :             :   /* 
     611                 :             :    StartBuildProgramModule - Creates a program module and starts
     612                 :             :                              a new scope.
     613                 :             : 
     614                 :             :                              The Stack is expected:
     615                 :             : 
     616                 :             :                              Entry                 Exit
     617                 :             : 
     618                 :             :                       Ptr ->                                     <- Ptr
     619                 :             :                              +------------+        +-----------+
     620                 :             :                              | NameStart  |        | NameStart |
     621                 :             :                              |------------|        |-----------|
     622                 :             : 
     623                 :             :   */
     624                 :       10408 :   importStatementCount = 0;
     625                 :       10408 :   M2Quads_PopTtok (&name, &tok);
     626                 :             :   /* CheckFileName(name, 'main') ;  */
     627                 :       10408 :   ModuleSym = M2Batch_MakeProgramSource (tok, name);
     628                 :       10408 :   SymbolTable_SetCurrentModule (ModuleSym);
     629                 :       10408 :   SymbolTable_SetFileModule (ModuleSym);
     630                 :       10408 :   SymbolTable_StartScope (ModuleSym);
     631                 :       10408 :   if ((! (M2Comp_CompilingProgramModule ())) || (SymbolTable_IsDefImp (ModuleSym)))
     632                 :             :     {
     633                 :           6 :       M2MetaError_MetaErrorT1 (tok, (const char *) "module {%1Ea} has a corresponding DEFINITION MODULE but no IMPLEMENTATION keyword in the main module", 100, ModuleSym);
     634                 :             :     }
     635                 :       10408 :   M2Quads_PushTtok (name, tok);
     636                 :       10408 :   P0SymBuild_EnterBlock (name);
     637                 :       10408 : }
     638                 :             : 
     639                 :       10408 : extern "C" void P1SymBuild_P1EndBuildProgramModule (void)
     640                 :             : {
     641                 :       10408 :   unsigned int start;
     642                 :       10408 :   unsigned int end;
     643                 :       10408 :   NameKey_Name NameStart;
     644                 :       10408 :   NameKey_Name NameEnd;
     645                 :             : 
     646                 :             :   /* 
     647                 :             :    EndBuildProgramModule - Destroys the program module scope and
     648                 :             :                            checks for correct name.
     649                 :             : 
     650                 :             :                            The Stack is expected:
     651                 :             : 
     652                 :             :                            Entry                 Exit
     653                 :             : 
     654                 :             :                     Ptr ->
     655                 :             :                            +------------+        +-----------+
     656                 :             :                            | NameEnd    |        |           |
     657                 :             :                            |------------|        |-----------|
     658                 :             :                            | NameStart  |        |           | <- Ptr
     659                 :             :                            |------------|        |-----------|
     660                 :             :   */
     661                 :       10408 :   SymbolTable_ResolveImports ();
     662                 :       10408 :   M2Debug_Assert (M2Comp_CompilingProgramModule ());
     663                 :       10402 :   SymbolTable_EndScope ();
     664                 :       10402 :   M2Quads_PopTtok (&NameStart, &start);
     665                 :       10402 :   M2Quads_PopTtok (&NameEnd, &end);
     666                 :       10402 :   if (Debugging)
     667                 :             :     {
     668                 :             :       M2Printf_printf0 ((const char *) "pass 1: ", 8);
     669                 :             :       SymbolTable_DisplayTrees (SymbolTable_GetCurrentModule ());
     670                 :             :     }
     671                 :       10402 :   if (NameStart != NameEnd)
     672                 :             :     {
     673                 :           0 :       M2MetaError_MetaErrorT1 (end, (const char *) "inconsistant program module name {%1Wa}", 39, SymbolTable_MakeError (start, NameStart));
     674                 :             :     }
     675                 :       10402 :   P0SymBuild_LeaveBlock ();
     676                 :       10402 : }
     677                 :             : 
     678                 :             : 
     679                 :             : /*
     680                 :             :    StartBuildInnerModule - Creates an Inner module and starts
     681                 :             :                            a new scope.
     682                 :             : 
     683                 :             :                            The Stack is expected:
     684                 :             : 
     685                 :             :                            Entry                 Exit
     686                 :             : 
     687                 :             :                     Ptr ->                                     <- Ptr
     688                 :             :                            +------------+        +-----------+
     689                 :             :                            | NameStart  |        | NameStart |
     690                 :             :                            |------------|        |-----------|
     691                 :             : 
     692                 :             : */
     693                 :             : 
     694                 :         420 : extern "C" void P1SymBuild_StartBuildInnerModule (void)
     695                 :             : {
     696                 :         420 :   unsigned int tok;
     697                 :         420 :   NameKey_Name name;
     698                 :         420 :   unsigned int ModuleSym;
     699                 :             : 
     700                 :         420 :   M2Quads_PopTtok (&name, &tok);
     701                 :         420 :   ModuleSym = SymbolTable_GetSym (name);
     702                 :         420 :   M2Debug_Assert (ModuleSym != SymbolTable_NulSym);
     703                 :         420 :   SymbolTable_StartScope (ModuleSym);
     704                 :         420 :   M2Debug_Assert (! (SymbolTable_IsDefImp (ModuleSym)));
     705                 :         420 :   M2Quads_PushTtok (name, tok);
     706                 :         420 :   P0SymBuild_EnterBlock (name);
     707                 :         420 : }
     708                 :             : 
     709                 :             : 
     710                 :             : /*
     711                 :             :    EndBuildInnerModule - Destroys the Inner module scope and
     712                 :             :                          checks for correct name.
     713                 :             : 
     714                 :             :                          The Stack is expected:
     715                 :             : 
     716                 :             :                          Entry                 Exit
     717                 :             : 
     718                 :             :                   Ptr ->
     719                 :             :                          +------------+        +-----------+
     720                 :             :                          | NameEnd    |        |           |
     721                 :             :                          |------------|        |-----------|
     722                 :             :                          | NameStart  |        |           | <- Ptr
     723                 :             :                          |------------|        |-----------|
     724                 :             : */
     725                 :             : 
     726                 :         420 : extern "C" void P1SymBuild_EndBuildInnerModule (void)
     727                 :             : {
     728                 :         420 :   unsigned int start;
     729                 :         420 :   unsigned int end;
     730                 :         420 :   NameKey_Name NameStart;
     731                 :         420 :   NameKey_Name NameEnd;
     732                 :             : 
     733                 :         420 :   SymbolTable_EndScope ();
     734                 :         420 :   M2Quads_PopTtok (&NameStart, &start);
     735                 :         420 :   M2Quads_PopTtok (&NameEnd, &end);
     736                 :         420 :   if (NameStart != NameEnd)
     737                 :             :     {
     738                 :           0 :       M2MetaError_MetaErrorT1 (end, (const char *) "inconsistant inner module name {%1Wa}", 37, SymbolTable_MakeError (start, NameStart));
     739                 :             :     }
     740                 :         420 :   P0SymBuild_LeaveBlock ();
     741                 :         420 : }
     742                 :             : 
     743                 :             : 
     744                 :             : /*
     745                 :             :    BuildImportOuterModule - Builds imported identifiers into an outer module
     746                 :             :                             from a definition module.
     747                 :             : 
     748                 :             :                             The Stack is expected:
     749                 :             : 
     750                 :             :                             Entry           OR    Entry
     751                 :             : 
     752                 :             :                      Ptr ->                Ptr ->
     753                 :             :                             +------------+        +-----------+
     754                 :             :                             | #          |        | #         |
     755                 :             :                             |------------|        |-----------|
     756                 :             :                             | Id1        |        | Id1       |
     757                 :             :                             |------------|        |-----------|
     758                 :             :                             .            .        .           .
     759                 :             :                             .            .        .           .
     760                 :             :                             .            .        .           .
     761                 :             :                             |------------|        |-----------|
     762                 :             :                             | Id#        |        | Id#       |
     763                 :             :                             |------------|        |-----------|
     764                 :             :                             | ImportTok  |        | Ident     |
     765                 :             :                             |------------|        |-----------|
     766                 :             : 
     767                 :             :                             IMPORT Id1, .. Id# ;  FROM Ident IMPORT Id1 .. Id# ;
     768                 :             : 
     769                 :             : 
     770                 :             :                             Exit
     771                 :             : 
     772                 :             :                             All above stack discarded
     773                 :             : */
     774                 :             : 
     775                 :      276403 : extern "C" void P1SymBuild_BuildImportOuterModule (bool definition)
     776                 :             : {
     777                 :      276403 :   unsigned int Sym;
     778                 :      276403 :   unsigned int ModSym;
     779                 :      276403 :   unsigned int i;
     780                 :      276403 :   unsigned int n;
     781                 :             : 
     782                 :      276403 :   M2Quads_PopT (&n);  /* n   = # of the Ident List  */
     783                 :      276403 :   if ((M2Quads_OperandT (n+1)) == M2Reserved_ImportTok)
     784                 :             :     {
     785                 :             :       /* Ident list contains Module Names  */
     786                 :             :       i = 1;
     787                 :       71054 :       while (i <= n)
     788                 :             :         {
     789                 :       39445 :           ModSym = M2Batch_LookupModule (M2Quads_OperandTok ((n+1)-i), M2Quads_OperandT ((n+1)-i));
     790                 :       39445 :           SymbolTable_PutImported (ModSym);
     791                 :       39445 :           if (definition)
     792                 :             :             {
     793                 :        8392 :               SymbolTable_PutIncludedByDefinition (ModSym);
     794                 :             :             }
     795                 :       39445 :           i += 1;
     796                 :             :         }
     797                 :             :     }
     798                 :             :   else
     799                 :             :     {
     800                 :             :       /* Ident List contains list of objects  */
     801                 :      244794 :       ModSym = M2Batch_LookupModule (M2Quads_OperandTok (n+1), M2Quads_OperandT (n+1));
     802                 :      244794 :       i = 1;
     803                 :             :       /* 
     804                 :             :          WriteString('Importing ') ; WriteKey(Operand(j)) ; WriteString(' from ') ; WriteKey(GetSymName(ModSym)) ; WriteLn ;
     805                 :             :   */
     806                 :     1067170 :       while (i <= n)
     807                 :             :         {
     808                 :      577582 :           Sym = SymbolTable_GetExported (M2Quads_OperandTok ((n+1)-i), ModSym, M2Quads_OperandT ((n+1)-i));
     809                 :      577582 :           SymbolTable_PutImported (Sym);
     810                 :      577582 :           i += 1;
     811                 :             :         }
     812                 :             :     }
     813                 :      276403 :   M2Quads_PopN (n+1);  /* clear stack  */
     814                 :      276403 : }
     815                 :             : 
     816                 :             : 
     817                 :             : /*
     818                 :             :    BuildExportOuterModule - Builds exported identifiers from an outer module
     819                 :             :                             to the outside world of library modules.
     820                 :             : 
     821                 :             :                             The Stack is expected:
     822                 :             : 
     823                 :             :                             Entry           OR    Entry
     824                 :             : 
     825                 :             :                      Ptr ->                Ptr ->
     826                 :             :                             +------------+        +--------------+
     827                 :             :                             | #          |        | #            |
     828                 :             :                             |------------|        |--------------|
     829                 :             :                             | Id1        |        | Id1          |
     830                 :             :                             |------------|        |--------------|
     831                 :             :                             .            .        .              .
     832                 :             :                             .            .        .              .
     833                 :             :                             .            .        .              .
     834                 :             :                             |------------|        |--------------|
     835                 :             :                             | Id#        |        | Id#          |
     836                 :             :                             |------------|        |--------------|
     837                 :             :                             | ExportTok  |        | QualifiedTok |
     838                 :             :                             |------------|        |--------------|
     839                 :             : 
     840                 :             :                             EXPORT Id1, .. Id# ;  EXPORT QUALIFIED Id1 .. Id# ;
     841                 :             : 
     842                 :             :                             Error Condition
     843                 :             : 
     844                 :             : 
     845                 :             :                             Exit
     846                 :             : 
     847                 :             :                             All above stack discarded
     848                 :             : */
     849                 :             : 
     850                 :       73615 : extern "C" void P1SymBuild_BuildExportOuterModule (void)
     851                 :             : {
     852                 :       73615 :   unsigned int i;
     853                 :       73615 :   unsigned int n;
     854                 :             : 
     855                 :       73615 :   M2Quads_PopT (&n);  /* n   = # of the Ident List  */
     856                 :       73615 :   if (((M2Quads_OperandT (n+1)) == M2Reserved_QualifiedTok) && (M2Comp_CompilingDefinitionModule ()))  /* n   = # of the Ident List  */
     857                 :             :     {
     858                 :       67459 :       SymbolTable_PutDoesNeedExportList (SymbolTable_GetCurrentModule ());
     859                 :             :       /* Ident List contains list of export qualified objects  */
     860                 :       67459 :       i = 1;
     861                 :     1572803 :       while (i <= n)
     862                 :             :         {
     863                 :     1437885 :           SymbolTable_PutExportQualified (M2Quads_OperandTok (i), M2Quads_OperandT (i));
     864                 :     1437885 :           i += 1;
     865                 :             :         }
     866                 :             :     }
     867                 :        6156 :   else if (((M2Quads_OperandT (n+1)) == M2Reserved_UnQualifiedTok) && (M2Comp_CompilingDefinitionModule ()))
     868                 :             :     {
     869                 :             :       /* avoid dangling else.  */
     870                 :        6156 :       SymbolTable_PutDoesNeedExportList (SymbolTable_GetCurrentModule ());
     871                 :             :       /* Ident List contains list of export unqualified objects  */
     872                 :        6156 :       i = 1;
     873                 :      332050 :       while (i <= n)
     874                 :             :         {
     875                 :      319738 :           SymbolTable_PutExportUnQualified (M2Quads_OperandTok (i), M2Quads_OperandT (i));
     876                 :      319738 :           i += 1;
     877                 :             :         }
     878                 :             :     }
     879                 :           0 :   else if (M2Comp_CompilingDefinitionModule ())
     880                 :             :     {
     881                 :             :       /* avoid dangling else.  */
     882                 :           0 :       M2MetaError_MetaError0 ((const char *) "the {%EkEXPORT} must be either {%kQUALIFIED} or {%kUNQUALIFIED} in a definition module", 86);
     883                 :             :     }
     884                 :             :   else
     885                 :             :     {
     886                 :             :       /* avoid dangling else.  */
     887                 :           0 :       M2MetaError_MetaError0 ((const char *) "{%E}only allowed inter module exports in a definition module", 60);
     888                 :             :     }
     889                 :       73615 :   M2Quads_PopN (n+1);  /* clear stack  */
     890                 :       73615 : }
     891                 :             : 
     892                 :             : 
     893                 :             : /*
     894                 :             :    CheckExplicitExported - checks to see whether we are compiling
     895                 :             :                            a definition module and whether the ident
     896                 :             :                            is implicitly export qualified or unqualified.
     897                 :             : 
     898                 :             : 
     899                 :             :                                   The Stack is expected:
     900                 :             : 
     901                 :             :                                   Entry                 Exit
     902                 :             : 
     903                 :             :                            Ptr ->                Ptr ->
     904                 :             :                                   +------------+        +-----------+
     905                 :             :                                   | Identname  |        | Identname |
     906                 :             :                                   |------------|        |-----------|
     907                 :             : 
     908                 :             : */
     909                 :             : 
     910                 :     4580395 : extern "C" void P1SymBuild_CheckExplicitExported (void)
     911                 :             : {
     912                 :     4580395 :   if ((M2Comp_CompilingDefinitionModule ()) && (SymbolTable_DoesNotNeedExportList (SymbolTable_GetCurrentModule ())))
     913                 :             :     {
     914                 :             :       /* printf1('exporting identifier %a
     915                 :             :       ', OperandT(1)) ;  */
     916                 :     1373830 :       SymbolTable_PutExportQualified (M2Quads_OperandTok (1), M2Quads_OperandT (1));
     917                 :             :     }
     918                 :     4580395 : }
     919                 :             : 
     920                 :             : 
     921                 :             : /*
     922                 :             :    BuildImportInnerModule - Builds imported identifiers into an inner module
     923                 :             :                             from the last level of module.
     924                 :             : 
     925                 :             :                             The Stack is expected:
     926                 :             : 
     927                 :             :                             Entry           OR    Entry
     928                 :             : 
     929                 :             :                      Ptr ->                Ptr ->
     930                 :             :                             +------------+        +-----------+
     931                 :             :                             | #          |        | #         |
     932                 :             :                             |------------|        |-----------|
     933                 :             :                             | Id1        |        | Id1       |
     934                 :             :                             |------------|        |-----------|
     935                 :             :                             .            .        .           .
     936                 :             :                             .            .        .           .
     937                 :             :                             .            .        .           .
     938                 :             :                             |------------|        |-----------|
     939                 :             :                             | Id#        |        | Id#       |
     940                 :             :                             |------------|        |-----------|
     941                 :             :                             | ImportTok  |        | Ident     |
     942                 :             :                             |------------|        |-----------|
     943                 :             : 
     944                 :             :                             IMPORT Id1, .. Id# ;  FROM Ident IMPORT Id1 .. Id# ;
     945                 :             : 
     946                 :             :                             Exit
     947                 :             : 
     948                 :             :                             All above stack discarded
     949                 :             : */
     950                 :             : 
     951                 :         222 : extern "C" void P1SymBuild_BuildImportInnerModule (void)
     952                 :             : {
     953                 :         222 :   unsigned int Sym;
     954                 :         222 :   unsigned int ModSym;
     955                 :         222 :   unsigned int i;
     956                 :         222 :   unsigned int n;
     957                 :             : 
     958                 :         222 :   M2Quads_PopT (&n);  /* n   = # of the Ident List  */
     959                 :         222 :   if ((M2Quads_OperandT (n+1)) == M2Reserved_ImportTok)
     960                 :             :     {
     961                 :             :       /* Ident List contains list of objects  */
     962                 :             :       i = 1;
     963                 :         318 :       while (i <= n)
     964                 :             :         {
     965                 :         162 :           SymbolTable_AddNameToImportList (M2Quads_OperandT (i));
     966                 :         162 :           i += 1;
     967                 :             :         }
     968                 :             :     }
     969                 :             :   else
     970                 :             :     {
     971                 :             :       /* Ident List contains list of objects  */
     972                 :          66 :       ModSym = M2Batch_LookupOuterModule (M2Quads_OperandTok (n+1), M2Quads_OperandT (n+1));
     973                 :          66 :       i = 1;
     974                 :         198 :       while (i <= n)
     975                 :             :         {
     976                 :          66 :           Sym = SymbolTable_GetExported (M2Quads_OperandTok ((n+1)-i), ModSym, M2Quads_OperandT ((n+1)-i));
     977                 :          66 :           SymbolTable_PutImported (Sym);
     978                 :          66 :           i += 1;
     979                 :             :         }
     980                 :             :     }
     981                 :         222 :   M2Quads_PopN (n+1);  /* clear stack  */
     982                 :         222 : }
     983                 :             : 
     984                 :             : 
     985                 :             : /*
     986                 :             :    BuildExportInnerModule - Builds exported identifiers from an inner module
     987                 :             :                             to the next layer module.
     988                 :             : 
     989                 :             :                             The Stack is expected:
     990                 :             : 
     991                 :             :                             Entry           OR    Entry
     992                 :             : 
     993                 :             :                      Ptr ->                Ptr ->
     994                 :             :                             +------------+        +--------------+
     995                 :             :                             | #          |        | #            |
     996                 :             :                             |------------|        |--------------|
     997                 :             :                             | Id1        |        | Id1          |
     998                 :             :                             |------------|        |--------------|
     999                 :             :                             .            .        .              .
    1000                 :             :                             .            .        .              .
    1001                 :             :                             .            .        .              .
    1002                 :             :                             |------------|        |--------------|
    1003                 :             :                             | Id#        |        | Id#          |
    1004                 :             :                             |------------|        |--------------|
    1005                 :             :                             | ExportTok  |        | QualifiedTok |
    1006                 :             :                             |------------|        |--------------|
    1007                 :             : 
    1008                 :             :                             EXPORT Id1, .. Id# ;  EXPORT QUALIFIED Id1 .. Id# ;
    1009                 :             : 
    1010                 :             : 
    1011                 :             :                             Exit
    1012                 :             : 
    1013                 :             : 
    1014                 :             :                             All above stack discarded
    1015                 :             : */
    1016                 :             : 
    1017                 :         282 : extern "C" void P1SymBuild_BuildExportInnerModule (void)
    1018                 :             : {
    1019                 :         282 :   unsigned int tok;
    1020                 :         282 :   unsigned int PrevMod;
    1021                 :         282 :   unsigned int Sym;
    1022                 :         282 :   unsigned int i;
    1023                 :         282 :   unsigned int n;
    1024                 :             : 
    1025                 :         282 :   M2Quads_PopT (&n);  /* n   = # of the Ident List  */
    1026                 :         282 :   if ((M2Quads_OperandT (n+1)) == M2Reserved_ExportTok)
    1027                 :             :     {
    1028                 :             :       /* Ident List contains list of objects  */
    1029                 :         282 :       i = 1;
    1030                 :         282 :       PrevMod = SymbolTable_GetScope (SymbolTable_GetCurrentScope ());
    1031                 :         870 :       while (i <= n)
    1032                 :             :         {
    1033                 :         306 :           tok = static_cast<unsigned int> (M2Quads_OperandTok (i));
    1034                 :         306 :           if ((PrevMod != SymbolTable_NulSym) && ((SymbolTable_IsModule (PrevMod)) || (SymbolTable_IsDefImp (PrevMod))))
    1035                 :             :             {
    1036                 :         246 :               Sym = SymbolTable_GetLocalSym (PrevMod, M2Quads_OperandT (i));
    1037                 :         246 :               if (Sym == SymbolTable_NulSym)
    1038                 :             :                 {
    1039                 :             :                   /* avoid dangling else.  */
    1040                 :         234 :                   Sym = SymbolTable_TryMoveUndeclaredSymToInnerModule (PrevMod, SymbolTable_GetCurrentScope (), M2Quads_OperandT (i));
    1041                 :         234 :                   if (Sym == SymbolTable_NulSym)
    1042                 :             :                     {
    1043                 :         216 :                       Sym = SymbolTable_RequestSym (tok, M2Quads_OperandT (i));
    1044                 :         216 :                       SymbolTable_PutExported (Sym);
    1045                 :             :                     }
    1046                 :             :                 }
    1047                 :             :               else
    1048                 :             :                 {
    1049                 :             :                   /* use Sym which has already been created in outer scope  */
    1050                 :          12 :                   SymbolTable_AddSymToModuleScope (SymbolTable_GetCurrentScope (), Sym);
    1051                 :             :                 }
    1052                 :             :             }
    1053                 :             :           else
    1054                 :             :             {
    1055                 :          60 :               Sym = SymbolTable_RequestSym (tok, M2Quads_OperandT (i));
    1056                 :          60 :               SymbolTable_PutExported (Sym);
    1057                 :             :             }
    1058                 :         306 :           i += 1;
    1059                 :             :         }
    1060                 :             :     }
    1061                 :             :   else
    1062                 :             :     {
    1063                 :           0 :       M2MetaError_MetaError0 ((const char *) "{%EkQUALIFIED} not allowed in an inner module", 45);
    1064                 :             :     }
    1065                 :         282 :   M2Quads_PopN (n+1);  /* clear stack  */
    1066                 :         282 : }
    1067                 :             : 
    1068                 :             : 
    1069                 :             : /*
    1070                 :             :    StartBuildEnumeration - Builds an Enumeration type Type.
    1071                 :             : 
    1072                 :             : 
    1073                 :             :                            Stack
    1074                 :             : 
    1075                 :             :                            Entry                 Exit
    1076                 :             : 
    1077                 :             :                     Ptr ->
    1078                 :             :                            +------------+
    1079                 :             :                            | #          |
    1080                 :             :                            |------------|
    1081                 :             :                            | en 1       |
    1082                 :             :                            |------------|
    1083                 :             :                            | en 2       |
    1084                 :             :                            |------------|
    1085                 :             :                            .            .
    1086                 :             :                            .            .
    1087                 :             :                            .            .                       <- Ptr
    1088                 :             :                            |------------|        +------------+
    1089                 :             :                            | en #       |        | Type       |
    1090                 :             :                            |------------|        |------------|
    1091                 :             :                            | Name       |        | Name       |
    1092                 :             :                            |------------|        |------------|
    1093                 :             : */
    1094                 :             : 
    1095                 :       21959 : extern "C" void P1SymBuild_StartBuildEnumeration (void)
    1096                 :             : {
    1097                 :       21959 :   NameKey_Name name;
    1098                 :       21959 :   unsigned int n;
    1099                 :       21959 :   unsigned int i;
    1100                 :       21959 :   unsigned int Type;
    1101                 :       21959 :   unsigned int tokno;
    1102                 :             : 
    1103                 :       21959 :   M2Quads_PopT (&n);  /* No := #  */
    1104                 :       21959 :   name = static_cast<NameKey_Name> (M2Quads_OperandT (n+1));  /* No := #  */
    1105                 :       21959 :   tokno = static_cast<unsigned int> (M2Quads_OperandTok (n+1));
    1106                 :       21959 :   Type = SymbolTable_MakeEnumeration (tokno, name);
    1107                 :       21959 :   i = 1;
    1108                 :      437631 :   while (i <= n)
    1109                 :             :     {
    1110                 :      393713 :       SymbolTable_PutFieldEnumeration (M2Quads_OperandTok ((n-i)+1), Type, M2Quads_OperandT ((n-i)+1));
    1111                 :      393713 :       i += 1;
    1112                 :             :     }
    1113                 :       21959 :   FifoQueue_PutEnumerationIntoFifoQueue (Type);  /* store enumeration away for pass 2  */
    1114                 :       21959 :   M2Quads_PopN (n+1);  /* store enumeration away for pass 2  */
    1115                 :       21959 :   M2Quads_PushTtok (name, tokno);
    1116                 :       21959 :   M2Quads_PushTtok (Type, tokno);
    1117                 :       21959 : }
    1118                 :             : 
    1119                 :             : 
    1120                 :             : /*
    1121                 :             :    EndBuildEnumeration - completes the construction of the enumeration type.
    1122                 :             : 
    1123                 :             : 
    1124                 :             :                          Stack
    1125                 :             : 
    1126                 :             :                          Entry                 Exit
    1127                 :             : 
    1128                 :             :                   Ptr ->
    1129                 :             :                          +------------+
    1130                 :             :                          | Type       |                          <- Ptr
    1131                 :             :                          |------------|        +---------------+
    1132                 :             :                          | Name       |        | Type  | Name  |
    1133                 :             :                          |------------|        |---------------|
    1134                 :             : 
    1135                 :             :                                                Empty
    1136                 :             : */
    1137                 :             : 
    1138                 :       21959 : extern "C" void P1SymBuild_EndBuildEnumeration (void)
    1139                 :             : {
    1140                 :       21959 :   unsigned int tokno;
    1141                 :       21959 :   unsigned int Sym;
    1142                 :       21959 :   unsigned int Type;
    1143                 :       21959 :   NameKey_Name n1;
    1144                 :       21959 :   NameKey_Name n2;
    1145                 :       21959 :   NameKey_Name name;
    1146                 :             : 
    1147                 :             :   /* 
    1148                 :             :       Two cases
    1149                 :             : 
    1150                 :             :       - the type name the same as Name, or the name is nul. - do nothing.
    1151                 :             :       - when type with a name that is different to Name. In which case
    1152                 :             :         we create a new type.
    1153                 :             :   */
    1154                 :       21959 :   M2Quads_PopTtok (&Type, &tokno);
    1155                 :       21959 :   M2Quads_PopT (&name);
    1156                 :       21959 :   if (Debugging)
    1157                 :             :     {
    1158                 :             :       n1 = SymbolTable_GetSymName (SymbolTable_GetCurrentModule ());
    1159                 :             :       M2Printf_printf2 ((const char *) "inside module %a declaring type name %a\\n", 41, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &name, (sizeof (name)-1));
    1160                 :             :       if (! (SymbolTable_IsUnknown (Type)))
    1161                 :             :         {
    1162                 :             :           n1 = SymbolTable_GetSymName (SymbolTable_GetScope (Type));
    1163                 :             :           n2 = SymbolTable_GetSymName (Type);
    1164                 :             :           M2Printf_printf2 ((const char *) "type was created inside scope %a as name %a\\n", 45, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
    1165                 :             :         }
    1166                 :             :     }
    1167                 :       21959 :   if ((name == NameKey_NulName) || ((SymbolTable_GetSymName (Type)) == name))
    1168                 :             :     {
    1169                 :             :       /* 
    1170                 :             :          Typically the declaration that causes this case is:
    1171                 :             : 
    1172                 :             :          VAR
    1173                 :             :             a: (blue, green, red) ;
    1174                 :             :              ^
    1175                 :             :              |
    1176                 :             :              +---- type has no name.
    1177                 :             : 
    1178                 :             :          in which case the constructed from StartBuildEnumeration is complete
    1179                 :             :   */
    1180                 :       21959 :       M2Quads_PushTFtok (Type, name, tokno);
    1181                 :             :     }
    1182                 :             :   else
    1183                 :             :     {
    1184                 :             :       /* in this case we are seeing:
    1185                 :             : 
    1186                 :             :          TYPE
    1187                 :             :             name = (blue, green, red)
    1188                 :             : 
    1189                 :             :          so we construct the type name and define it to have the previously
    1190                 :             :          created enumeration type
    1191                 :             :   */
    1192                 :           0 :       Sym = SymbolTable_MakeType (tokno, name);
    1193                 :           0 :       SymbolTable_PutType (Sym, Type);
    1194                 :           0 :       M2Quads_PushTFtok (Sym, name, tokno);
    1195                 :             :     }
    1196                 :       21959 : }
    1197                 :             : 
    1198                 :             : 
    1199                 :             : /*
    1200                 :             :    BuildHiddenType - Builds a Hidden Type.
    1201                 :             : 
    1202                 :             : 
    1203                 :             :                      Stack
    1204                 :             : 
    1205                 :             :                      Entry                 Exit
    1206                 :             : 
    1207                 :             :               Ptr ->
    1208                 :             :                      +------------+
    1209                 :             :                      | Name       |                          <- Ptr
    1210                 :             :                      |------------|        Empty
    1211                 :             : */
    1212                 :             : 
    1213                 :       24970 : extern "C" void P1SymBuild_BuildHiddenType (void)
    1214                 :             : {
    1215                 :       24970 :   NameKey_Name name;
    1216                 :       24970 :   unsigned int tokno;
    1217                 :             : 
    1218                 :       24970 :   M2Quads_PopTtok (&name, &tokno);
    1219                 :             :   /* WriteKey(Name) ; WriteLn ;  */
    1220                 :       24970 :   M2Debug_Assert ((SymbolTable_MakeHiddenType (tokno, name)) != SymbolTable_NulSym);
    1221                 :       24970 : }
    1222                 :             : 
    1223                 :             : 
    1224                 :             : /*
    1225                 :             :    StartBuildProcedure - Builds a Procedure.
    1226                 :             : 
    1227                 :             :                          The Stack:
    1228                 :             : 
    1229                 :             :                          Entry                 Exit
    1230                 :             : 
    1231                 :             :                   Ptr ->                                      <- Ptr
    1232                 :             :                          +------------+        +------------+
    1233                 :             :                          | Name       |        | ProcSym    |
    1234                 :             :                          |------------|        |------------|
    1235                 :             :                          | inlinetok  |        |            |
    1236                 :             :                          | or         |        |            |
    1237                 :             :                          | builtintok |        |            |
    1238                 :             :                          | or name or |        | Name       |
    1239                 :             :                          | NulTok     |        |            |
    1240                 :             :                          |------------|        |------------|
    1241                 :             : */
    1242                 :             : 
    1243                 :     2914628 : extern "C" void P1SymBuild_StartBuildProcedure (void)
    1244                 :             : {
    1245                 :     2914628 :   unsigned int tokno;
    1246                 :     2914628 :   NameKey_Name builtin;
    1247                 :     2914628 :   NameKey_Name name;
    1248                 :     2914628 :   unsigned int ProcSym;
    1249                 :             : 
    1250                 :     2914628 :   M2Quads_PopTtok (&name, &tokno);
    1251                 :     2914628 :   M2Quads_PopT (&builtin);  /* was this procedure defined as a builtin?  */
    1252                 :     2914628 :   M2Quads_PushTtok (name, tokno);  /* Name saved for the EndBuildProcedure name check  */
    1253                 :     2914628 :   ProcSym = SymbolTable_RequestSym (tokno, name);  /* Name saved for the EndBuildProcedure name check  */
    1254                 :     2914628 :   if (SymbolTable_IsUnknown (ProcSym))
    1255                 :             :     {
    1256                 :             :       /* 
    1257                 :             :          May have been compiled in DEF or IMP module, remember that IMP maybe
    1258                 :             :          compiled before corresponding DEF module.
    1259                 :             :   */
    1260                 :     2343560 :       ProcSym = SymbolTable_MakeProcedure (tokno, name);
    1261                 :             :     }
    1262                 :      571068 :   else if (SymbolTable_IsProcedure (ProcSym))
    1263                 :             :     {
    1264                 :             :       /* avoid dangling else.  */
    1265                 :             :       /* declared in the other module, we record declaration here as well  */
    1266                 :      571068 :       SymbolTable_PutDeclared (tokno, ProcSym);
    1267                 :             :     }
    1268                 :             :   else
    1269                 :             :     {
    1270                 :             :       /* avoid dangling else.  */
    1271                 :           0 :       M2MetaError_MetaError1 ((const char *) "expecting a procedure name and symbol {%1Ea} has been declared as a {%1d}", 73, ProcSym);
    1272                 :           0 :       M2Quads_PushT (ProcSym);
    1273                 :           0 :       return ;
    1274                 :             :     }
    1275                 :     2914628 :   if (builtin != M2Reserved_NulTok)
    1276                 :             :     {
    1277                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    1278                 :       92452 :       if (builtin == M2Reserved_BuiltinTok)
    1279                 :             :         {
    1280                 :       46000 :           SymbolTable_PutProcedureBuiltin (ProcSym, name);
    1281                 :             :         }
    1282                 :       46452 :       else if (builtin == M2Reserved_InlineTok)
    1283                 :             :         {
    1284                 :             :           /* avoid dangling else.  */
    1285                 :           0 :           SymbolTable_PutProcedureInline (ProcSym);
    1286                 :             :         }
    1287                 :             :       else
    1288                 :             :         {
    1289                 :             :           /* avoid dangling else.  */
    1290                 :       46452 :           SymbolTable_PutProcedureBuiltin (ProcSym, builtin);
    1291                 :             :         }
    1292                 :             :     }
    1293                 :     2914628 :   M2Quads_PushT (ProcSym);
    1294                 :     2914628 :   SymbolTable_StartScope (ProcSym);
    1295                 :     2914628 :   if (! (M2Comp_CompilingDefinitionModule ()))
    1296                 :             :     {
    1297                 :      897057 :       P0SymBuild_EnterBlock (name);
    1298                 :             :     }
    1299                 :             : }
    1300                 :             : 
    1301                 :             : 
    1302                 :             : /*
    1303                 :             :    EndBuildProcedure - Ends building a Procedure.
    1304                 :             :                        It checks the start procedure name matches the end
    1305                 :             :                        procedure name.
    1306                 :             : 
    1307                 :             :                        The Stack:
    1308                 :             : 
    1309                 :             :                        (Procedure Not Defined in definition module)
    1310                 :             : 
    1311                 :             :                        Entry                 Exit
    1312                 :             : 
    1313                 :             :                 Ptr ->
    1314                 :             :                        +------------+
    1315                 :             :                        | NameEnd    |
    1316                 :             :                        |------------|
    1317                 :             :                        | ProcSym    |
    1318                 :             :                        |------------|
    1319                 :             :                        | NameStart  |
    1320                 :             :                        |------------|
    1321                 :             :                                              Empty
    1322                 :             : */
    1323                 :             : 
    1324                 :      897057 : extern "C" void P1SymBuild_EndBuildProcedure (void)
    1325                 :             : {
    1326                 :      897057 :   unsigned int start;
    1327                 :      897057 :   unsigned int end;
    1328                 :      897057 :   unsigned int ProcSym;
    1329                 :      897057 :   NameKey_Name NameEnd;
    1330                 :      897057 :   NameKey_Name NameStart;
    1331                 :             : 
    1332                 :      897057 :   M2Quads_PopTtok (&NameEnd, &end);
    1333                 :      897057 :   M2Quads_PopT (&ProcSym);
    1334                 :      897057 :   M2Quads_PopTtok (&NameStart, &start);
    1335                 :      897057 :   if (NameEnd != NameStart)
    1336                 :             :     {
    1337                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    1338                 :           0 :       if (end != M2LexBuf_UnknownTokenNo)
    1339                 :             :         {
    1340                 :           0 :           M2MetaError_MetaErrorT1 (end, (const char *) "procedure name at end does not match name at beginning {%1EDa}", 62, ProcSym);
    1341                 :             :         }
    1342                 :           0 :       else if (start != M2LexBuf_UnknownTokenNo)
    1343                 :             :         {
    1344                 :             :           /* avoid dangling else.  */
    1345                 :           0 :           M2MetaError_MetaErrorT2 (start, (const char *) "procedure name at end {%1EDa} does not match name at beginning {%2a}", 68, SymbolTable_MakeError (end, NameEnd), ProcSym);
    1346                 :             :         }
    1347                 :             :       else
    1348                 :             :         {
    1349                 :             :           /* avoid dangling else.  */
    1350                 :           0 :           M2MetaError_MetaError1 ((const char *) "procedure name at end does not match name at beginning {%1EDa}", 62, ProcSym);
    1351                 :             :         }
    1352                 :             :     }
    1353                 :      897057 :   SymbolTable_EndScope ();
    1354                 :      897057 :   M2Debug_Assert (! (M2Comp_CompilingDefinitionModule ()));
    1355                 :      897057 :   P0SymBuild_LeaveBlock ();
    1356                 :      897057 : }
    1357                 :             : 
    1358                 :             : 
    1359                 :             : /*
    1360                 :             :    BuildProcedureHeading - Builds a procedure heading for the definition
    1361                 :             :                            module procedures.
    1362                 :             : 
    1363                 :             :                            Operation only performed if compiling a
    1364                 :             :                            definition module.
    1365                 :             : 
    1366                 :             :                            The Stack:
    1367                 :             : 
    1368                 :             :                            Entry                       Exit
    1369                 :             : 
    1370                 :             :                     Ptr ->
    1371                 :             :                            +------------+
    1372                 :             :                            | ProcSym    |
    1373                 :             :                            |------------|
    1374                 :             :                            | NameStart  |
    1375                 :             :                            |------------|
    1376                 :             :                                                        Empty
    1377                 :             : 
    1378                 :             : */
    1379                 :             : 
    1380                 :     2914628 : extern "C" void P1SymBuild_BuildProcedureHeading (void)
    1381                 :             : {
    1382                 :     2914628 :   unsigned int ProcSym;
    1383                 :     2914628 :   NameKey_Name NameStart;
    1384                 :             : 
    1385                 :     2914628 :   if (M2Comp_CompilingDefinitionModule ())
    1386                 :             :     {
    1387                 :     2017571 :       M2Quads_PopT (&ProcSym);
    1388                 :     2017571 :       M2Quads_PopT (&NameStart);
    1389                 :     2017571 :       SymbolTable_EndScope ();
    1390                 :             :     }
    1391                 :     2914628 : }
    1392                 :             : 
    1393                 :             : 
    1394                 :             : /*
    1395                 :             :    BuildNulName - Pushes a NulName onto the top of the stack.
    1396                 :             :                   The Stack:
    1397                 :             : 
    1398                 :             : 
    1399                 :             :                   Entry                    Exit
    1400                 :             : 
    1401                 :             :                                                           <- Ptr
    1402                 :             :                   Empty                    +------------+
    1403                 :             :                                            | NulName    |
    1404                 :             :                                            |------------|
    1405                 :             : */
    1406                 :             : 
    1407                 :     1043365 : extern "C" void P1SymBuild_BuildNulName (void)
    1408                 :             : {
    1409                 :     1043365 :   M2Quads_PushT (static_cast<unsigned int> (NameKey_NulName));
    1410                 :     1043365 : }
    1411                 :             : 
    1412                 :             : 
    1413                 :             : /*
    1414                 :             :    BuildTypeEnd - Pops the type Type and Name.
    1415                 :             :                   The Stack:
    1416                 :             : 
    1417                 :             : 
    1418                 :             :                   Entry                    Exit
    1419                 :             : 
    1420                 :             : 
    1421                 :             :            Ptr ->
    1422                 :             :                   +-------------+
    1423                 :             :                   | Type | Name |          Empty
    1424                 :             :                   |-------------|
    1425                 :             : */
    1426                 :             : 
    1427                 :           0 : extern "C" void P1SymBuild_BuildTypeEnd (void)
    1428                 :             : {
    1429                 :           0 :   unsigned int Type;
    1430                 :           0 :   NameKey_Name name;
    1431                 :             : 
    1432                 :           0 :   M2Quads_PopTF (&Type, &name);
    1433                 :           0 : }
    1434                 :             : 
    1435                 :             : 
    1436                 :             : /*
    1437                 :             :    BuildImportStatement - create a new import statement in the current module.
    1438                 :             :                           It ignores local modules.
    1439                 :             : 
    1440                 :             :                           The quadruple stack is not used.
    1441                 :             : */
    1442                 :             : 
    1443                 :      276625 : extern "C" void P1SymBuild_BuildImportStatement (unsigned int tok)
    1444                 :             : {
    1445                 :      276625 :   unsigned int scope;
    1446                 :             : 
    1447                 :      276625 :   scope = SymbolTable_GetCurrentScope ();
    1448                 :      276625 :   if ((SymbolTable_IsDefImp (scope)) || ((SymbolTable_IsModule (scope)) && (! (SymbolTable_IsInnerModule (scope)))))
    1449                 :             :     {
    1450                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    1451                 :      276403 :       if ((M2Comp_CompilingDefinitionModule ()) && (! (SymbolTable_IsDefImp (scope))))
    1452                 :             :         {
    1453                 :           0 :           M2MetaError_MetaError1 ((const char *) "module scope should be a definition module rather than {%1EDa}", 62, scope);
    1454                 :             :         }
    1455                 :             :       else
    1456                 :             :         {
    1457                 :      276403 :           importStatementCount += 1;
    1458                 :      276403 :           SymbolTable_AppendModuleImportStatement (scope, SymbolTable_MakeImportStatement (tok, importStatementCount));
    1459                 :             :         }
    1460                 :             :     }
    1461                 :      276625 : }
    1462                 :             : 
    1463                 :             : 
    1464                 :             : /*
    1465                 :             :    AddImportToImportStatement - the top of stack is expected to be a module name.
    1466                 :             :                                 This is looked up from the module universe and
    1467                 :             :                                 wrapped in an import symbol and placed into the
    1468                 :             :                                 current import statement.
    1469                 :             : 
    1470                 :             :                                 The quadruple stack is unchanged.
    1471                 :             : 
    1472                 :             :                                 Entry                      Exit
    1473                 :             : 
    1474                 :             : 
    1475                 :             :                          Ptr ->                                                   <- Ptr
    1476                 :             :                                 +---------------------+    +---------------------+
    1477                 :             :                                 | ImportedModuleName  |    | ImportedModuleName  |
    1478                 :             :                                 |---------------------|    |---------------------|
    1479                 :             : */
    1480                 :             : 
    1481                 :      284467 : extern "C" void P1SymBuild_AddImportToImportStatement (bool qualified)
    1482                 :             : {
    1483                 :      284467 :   unsigned int scope;
    1484                 :             : 
    1485                 :      284467 :   scope = SymbolTable_GetCurrentScope ();
    1486                 :      284467 :   if ((SymbolTable_IsDefImp (scope)) || ((SymbolTable_IsModule (scope)) && (! (SymbolTable_IsInnerModule (scope)))))
    1487                 :             :     {
    1488                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    1489                 :      284239 :       if ((M2Comp_CompilingDefinitionModule ()) && (! (SymbolTable_IsDefImp (scope))))
    1490                 :             :         {
    1491                 :           0 :           M2MetaError_MetaError1 ((const char *) "module scope should be a definition module rather than {%1EDa}", 62, scope);
    1492                 :             :         }
    1493                 :             :       else
    1494                 :             :         {
    1495                 :      284239 :           SymbolTable_AppendModuleOnImportStatement (scope, SymbolTable_MakeImport (M2Quads_OperandTok (1), M2Batch_LookupModule (M2Quads_OperandTok (1), M2Quads_OperandT (1)), importStatementCount, qualified));
    1496                 :             :         }
    1497                 :             :     }
    1498                 :      284467 : }
    1499                 :             : 
    1500                 :       16817 : extern "C" void _M2_P1SymBuild_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
    1501                 :             : {
    1502                 :       16817 : }
    1503                 :             : 
    1504                 :           0 : extern "C" void _M2_P1SymBuild_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
    1505                 :             : {
    1506                 :           0 : }
        

Generated by: LCOV version 2.1-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.