LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2Scope.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 76.7 % 249 191
Test Date: 2026-02-28 14:20:25 Functions: 75.0 % 16 12
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* do not edit automatically generated by mc from M2Scope.  */
       2              : /* M2Scope.mod derive the subset of quadruples for each scope.
       3              : 
       4              : Copyright (C) 2003-2026 Free Software Foundation, Inc.
       5              : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6              : 
       7              : This file is part of GNU Modula-2.
       8              : 
       9              : GNU Modula-2 is free software; you can redistribute it and/or modify
      10              : it under the terms of the GNU General Public License as published by
      11              : the Free Software Foundation; either version 3, or (at your option)
      12              : any later version.
      13              : 
      14              : GNU Modula-2 is distributed in the hope that it will be useful, but
      15              : WITHOUT ANY WARRANTY; without even the implied warranty of
      16              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17              : General Public License for more details.
      18              : 
      19              : You should have received a copy of the GNU General Public License
      20              : along with GNU Modula-2; see the file COPYING3.  If not see
      21              : <http://www.gnu.org/licenses/>.  */
      22              : 
      23              : #include "config.h"
      24              : #include "system.h"
      25              : #include "gcc-consolidation.h"
      26              : 
      27              : #include <stdbool.h>
      28              : #   if !defined (PROC_D)
      29              : #      define PROC_D
      30              :        typedef void (*PROC_t) (void);
      31              :        typedef struct { PROC_t proc; } PROC;
      32              : #   endif
      33              : 
      34              : #   if !defined (TRUE)
      35              : #      define TRUE (1==1)
      36              : #   endif
      37              : 
      38              : #   if !defined (FALSE)
      39              : #      define FALSE (1==0)
      40              : #   endif
      41              : 
      42              : #   include "GStorage.h"
      43              : #   include "Gmcrts.h"
      44              : #if defined(__cplusplus)
      45              : #   undef NULL
      46              : #   define NULL 0
      47              : #endif
      48              : #define _M2Scope_C
      49              : 
      50              : #include "GM2Scope.h"
      51              : #   include "GStorage.h"
      52              : #   include "GM2Debug.h"
      53              : #   include "GNameKey.h"
      54              : #   include "GSymbolTable.h"
      55              : #   include "GM2Printf.h"
      56              : #   include "GM2Quads.h"
      57              : #   include "GM2StackWord.h"
      58              : #   include "GM2Error.h"
      59              : 
      60              : typedef struct M2Scope_ScopeProcedure2_p M2Scope_ScopeProcedure2;
      61              : 
      62              : typedef struct M2Scope_ScopeProcedure3_p M2Scope_ScopeProcedure3;
      63              : 
      64              : #   define Debugging false
      65              : #   define TraceQuadruples false
      66              : typedef struct M2Scope__T1_r M2Scope__T1;
      67              : 
      68              : typedef enum {M2Scope_unsetscope, M2Scope_ignorescope, M2Scope_procedurescope, M2Scope_modulescope, M2Scope_definitionscope, M2Scope_implementationscope, M2Scope_programscope} M2Scope_scopeKind;
      69              : 
      70              : typedef M2Scope__T1 *M2Scope_ScopeBlock__opaque;
      71              : 
      72              : struct M2Scope__T1_r {
      73              :                        unsigned int scopeSym;
      74              :                        M2Scope_scopeKind kindScope;
      75              :                        unsigned int low;
      76              :                        unsigned int high;
      77              :                        M2Scope_ScopeBlock__opaque next;
      78              :                      };
      79              : 
      80              : static M2Scope_ScopeBlock__opaque FreeList;
      81              : 
      82              : /*
      83              :    InitScopeBlock -
      84              : */
      85              : 
      86              : extern "C" M2Scope_ScopeBlock M2Scope_InitScopeBlock (unsigned int scope);
      87              : 
      88              : /*
      89              :    KillScopeBlock - destroys the ScopeBlock sb and assign sb to NIL.
      90              : */
      91              : 
      92              : extern "C" void M2Scope_KillScopeBlock (M2Scope_ScopeBlock *sb);
      93              : 
      94              : /*
      95              :    ForeachScopeBlockDo2 - calls a procedure p for each block of contigeous quadruples
      96              :                           defining an outer scope sb.
      97              : */
      98              : 
      99              : extern "C" void M2Scope_ForeachScopeBlockDo2 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure2 p);
     100              : 
     101              : /*
     102              :    ForeachScopeBlockDo3 - calls a procedure p for each block of contigeous quadruples
     103              :                           defining an outer scope sb.
     104              : */
     105              : 
     106              : extern "C" void M2Scope_ForeachScopeBlockDo3 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure3 p);
     107              : 
     108              : /*
     109              :    New -
     110              : */
     111              : 
     112              : static void New (M2Scope_ScopeBlock__opaque *sb);
     113              : 
     114              : /*
     115              :    Dispose -
     116              : */
     117              : 
     118              : static void Dispose (M2Scope_ScopeBlock__opaque *sb);
     119              : 
     120              : /*
     121              :    SetScope - assigns the scopeSym and kindScope.
     122              : */
     123              : 
     124              : static void SetScope (M2Scope_ScopeBlock__opaque sb, unsigned int sym, M2Scope_scopeKind kindScope);
     125              : 
     126              : /*
     127              :    AddToRange - returns a ScopeBlock pointer to the last block. The,
     128              :                 quad, will be added to the end of sb or a later block
     129              :                 if First is TRUE.
     130              : */
     131              : 
     132              : static M2Scope_ScopeBlock__opaque AddToRange (M2Scope_ScopeBlock__opaque sb, bool First, unsigned int quad);
     133              : 
     134              : /*
     135              :    GetGlobalQuads -
     136              : */
     137              : 
     138              : static M2Scope_ScopeBlock__opaque GetGlobalQuads (M2Scope_ScopeBlock__opaque sb, unsigned int scope);
     139              : 
     140              : /*
     141              :    GetProcQuads -
     142              : */
     143              : 
     144              : static M2Scope_ScopeBlock__opaque GetProcQuads (M2Scope_ScopeBlock__opaque sb, unsigned int proc);
     145              : 
     146              : /*
     147              :    DisplayScope -
     148              : */
     149              : 
     150              : static void DisplayScope (M2Scope_ScopeBlock__opaque sb);
     151              : 
     152              : /*
     153              :    enter -
     154              : */
     155              : 
     156              : static void enter (M2Scope_ScopeBlock__opaque sb);
     157              : 
     158              : /*
     159              :    leave -
     160              : */
     161              : 
     162              : static void leave (M2Scope_ScopeBlock__opaque sb);
     163              : 
     164              : /*
     165              :    Init - initializes the global variables for this module.
     166              : */
     167              : 
     168              : static void Init (void);
     169              : 
     170              : 
     171              : /*
     172              :    New -
     173              : */
     174              : 
     175     50350211 : static void New (M2Scope_ScopeBlock__opaque *sb)
     176              : {
     177     50350211 :   if (FreeList == NULL)
     178              :     {
     179       678692 :       Storage_ALLOCATE ((void **) &(*sb), sizeof (M2Scope__T1));
     180              :     }
     181              :   else
     182              :     {
     183     49671519 :       (*sb) = FreeList;
     184     49671519 :       FreeList = FreeList->next;
     185              :     }
     186     50350211 : }
     187              : 
     188              : 
     189              : /*
     190              :    Dispose -
     191              : */
     192              : 
     193     50348537 : static void Dispose (M2Scope_ScopeBlock__opaque *sb)
     194              : {
     195     50348537 :   (*sb)->next = FreeList;
     196     50348537 :   FreeList = (*sb);
     197     50348537 :   (*sb) = static_cast<M2Scope_ScopeBlock__opaque> (NULL);
     198     50348537 : }
     199              : 
     200              : 
     201              : /*
     202              :    SetScope - assigns the scopeSym and kindScope.
     203              : */
     204              : 
     205     64120297 : static void SetScope (M2Scope_ScopeBlock__opaque sb, unsigned int sym, M2Scope_scopeKind kindScope)
     206              : {
     207     64120297 :   sb->scopeSym = sym;
     208     64120297 :   sb->kindScope = kindScope;
     209     43594465 : }
     210              : 
     211              : 
     212              : /*
     213              :    AddToRange - returns a ScopeBlock pointer to the last block. The,
     214              :                 quad, will be added to the end of sb or a later block
     215              :                 if First is TRUE.
     216              : */
     217              : 
     218    175702363 : static M2Scope_ScopeBlock__opaque AddToRange (M2Scope_ScopeBlock__opaque sb, bool First, unsigned int quad)
     219              : {
     220    175702363 :   if (First)
     221              :     {
     222     48917504 :       if (sb->high == 0)
     223              :         {
     224       766152 :           sb->high = sb->low;
     225              :         }
     226     48917504 :       sb->next = static_cast<M2Scope_ScopeBlock__opaque> (M2Scope_InitScopeBlock (SymbolTable_NulSym));
     227     48917504 :       sb = sb->next;
     228              :     }
     229    175702363 :   if (sb->low == 0)
     230              :     {
     231     48918770 :       sb->low = quad;
     232              :     }
     233    175702363 :   sb->high = quad;
     234    175702363 :   return sb;
     235              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     236              :   __builtin_unreachable ();
     237              : }
     238              : 
     239              : 
     240              : /*
     241              :    GetGlobalQuads -
     242              : */
     243              : 
     244       765006 : static M2Scope_ScopeBlock__opaque GetGlobalQuads (M2Scope_ScopeBlock__opaque sb, unsigned int scope)
     245              : {
     246       765006 :   M2Scope_ScopeBlock__opaque prev;
     247       765006 :   M2Scope_ScopeBlock__opaque nb;
     248       765006 :   unsigned int NestedLevel;
     249       765006 :   unsigned int i;
     250       765006 :   M2Quads_QuadOperator op;
     251       765006 :   unsigned int op1;
     252       765006 :   unsigned int op2;
     253       765006 :   unsigned int op3;
     254       765006 :   bool First;
     255       765006 :   unsigned int start;
     256       765006 :   unsigned int end;
     257              : 
     258       765006 :   NestedLevel = 0;
     259       765006 :   prev = static_cast<M2Scope_ScopeBlock__opaque> (NULL);
     260       765006 :   First = false;
     261       765006 :   if (((SymbolTable_GetScope (scope)) != SymbolTable_NulSym) && ((SymbolTable_IsProcedure (SymbolTable_GetScope (scope))) || ((SymbolTable_IsModule (scope)) && (SymbolTable_IsModuleWithinProcedure (scope)))))
     262              :     {
     263         1266 :       SymbolTable_GetProcedureQuads (SymbolTable_GetProcedureScope (scope), &i, &start, &end);
     264         1266 :       M2Quads_GetQuad (i, &op, &op1, &op2, &op3);
     265         5748 :       while ((op != M2Quads_ModuleScopeOp) || (op3 != scope))
     266              :         {
     267         3216 :           i = M2Quads_GetNextQuad (i);
     268         3216 :           M2Quads_GetQuad (i, &op, &op1, &op2, &op3);
     269              :         }
     270         1266 :       end = i;
     271         1266 :       M2Quads_GetQuad (end, &op, &op1, &op2, &op3);
     272        14472 :       while ((op != M2Quads_FinallyEndOp) || (op3 != scope))
     273              :         {
     274        11940 :           end = M2Quads_GetNextQuad (end);
     275        11940 :           M2Quads_GetQuad (end, &op, &op1, &op2, &op3);
     276              :         }
     277              :     }
     278              :   else
     279              :     {
     280       763740 :       i = M2Quads_GetFirstQuad ();
     281       763740 :       end = 0;
     282              :     }
     283       765006 :   nb = sb;
     284       765006 :   sb->low = 0;
     285       765006 :   sb->high = 0;
     286   5252496650 :   for (;;)
     287              :   {
     288   2626630828 :     if (i == 0)
     289              :       {
     290              :         if (Debugging)
     291              :           {
     292              :             DisplayScope (sb);
     293              :           }
     294              :         return sb;
     295              :       }
     296   2625867088 :     M2Quads_GetQuad (i, &op, &op1, &op2, &op3);
     297   2625867088 :     if (op == M2Quads_ProcedureScopeOp)
     298              :       {
     299     38093854 :         NestedLevel += 1;
     300              :       }
     301   2587773234 :     else if (op == M2Quads_ReturnOp)
     302              :       {
     303              :         /* avoid dangling else.  */
     304     38093854 :         if (NestedLevel > 0)
     305              :           {
     306     38093854 :             NestedLevel -= 1;
     307              :           }
     308     38093854 :         if (NestedLevel == 0)
     309              :           {
     310     38068480 :             First = true;
     311              :           }
     312              :       }
     313   2549679380 :     else if (NestedLevel == 0)
     314              :       {
     315              :         /* avoid dangling else.  */
     316    158815172 :         if (op == M2Quads_StartDefFileOp)
     317              :           {
     318     20525832 :             nb = AddToRange (nb, true, i);
     319     20525832 :             SetScope (nb, op3, M2Scope_definitionscope);
     320     20525832 :             prev = nb;
     321              :           }
     322    138289340 :         else if ((op == M2Quads_StartModFileOp) || (op == M2Quads_InitStartOp))
     323              :           {
     324              :             /* avoid dangling else.  */
     325     28306410 :             nb = AddToRange (nb, true, i);
     326     28306410 :             if (SymbolTable_IsDefImp (op3))
     327              :               {
     328     26901344 :                 SetScope (nb, op3, M2Scope_implementationscope);
     329              :               }
     330              :             else
     331              :               {
     332      1405066 :                 SetScope (nb, op3, M2Scope_programscope);
     333              :               }
     334              :             prev = nb;
     335              :           }
     336              :         else
     337              :           {
     338              :             /* avoid dangling else.  */
     339    109982930 :             nb = AddToRange (nb, First, i);
     340    109982930 :             if (op == M2Quads_InitEndOp)
     341              :               {
     342     14176098 :                 if (SymbolTable_IsDefImp (op3))
     343              :                   {
     344     13450672 :                     SetScope (nb, op3, M2Scope_implementationscope);
     345              :                   }
     346              :                 else
     347              :                   {
     348       725426 :                     SetScope (nb, op3, M2Scope_programscope);
     349              :                   }
     350              :                 prev = nb;
     351              :               }
     352     95806832 :             else if (First)
     353              :               {
     354              :                 /* avoid dangling else.  */
     355        82778 :                 M2Debug_Assert (prev != NULL);
     356        82778 :                 SetScope (nb, prev->scopeSym, prev->kindScope);
     357              :               }
     358              :           }
     359              :         First = false;
     360              :       }
     361   2625867088 :     if (i == end)
     362              :       {
     363              :         if (Debugging)
     364              :           {
     365              :             DisplayScope (sb);
     366              :           }
     367              :         return sb;
     368              :       }
     369   2625865822 :     i = M2Quads_GetNextQuad (i);
     370              :   }
     371              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Scope.def", 20, 1);
     372              :   __builtin_unreachable ();
     373              : }
     374              : 
     375              : 
     376              : /*
     377              :    GetProcQuads -
     378              : */
     379              : 
     380       667701 : static M2Scope_ScopeBlock__opaque GetProcQuads (M2Scope_ScopeBlock__opaque sb, unsigned int proc)
     381              : {
     382       667701 :   M2Scope_ScopeBlock__opaque nb;
     383       667701 :   unsigned int scope;
     384       667701 :   unsigned int start;
     385       667701 :   unsigned int end;
     386       667701 :   unsigned int i;
     387       667701 :   unsigned int last;
     388       667701 :   M2Quads_QuadOperator op;
     389       667701 :   unsigned int op1;
     390       667701 :   unsigned int op2;
     391       667701 :   unsigned int op3;
     392       667701 :   bool First;
     393       667701 :   M2StackWord_StackOfWord s;
     394       667701 :   NameKey_Name n;
     395              : 
     396       667701 :   s = M2StackWord_InitStackWord ();
     397       667701 :   if (Debugging)
     398              :     {
     399              :       n = SymbolTable_GetSymName (proc);
     400              :       M2Printf_printf1 ((const char *) "GetProcQuads for %a\\n", 21, (const unsigned char *) &n, (sizeof (n)-1));
     401              :     }
     402       667701 :   M2Debug_Assert (SymbolTable_IsProcedure (proc));
     403       667701 :   SymbolTable_GetProcedureQuads (proc, &scope, &start, &end);
     404       667701 :   if (Debugging)
     405              :     {
     406              :       M2Printf_printf1 ((const char *) " proc %d\\n", 10, (const unsigned char *) &proc, (sizeof (proc)-1));
     407              :       M2Printf_printf1 ((const char *) " scope %d\\n", 11, (const unsigned char *) &scope, (sizeof (scope)-1));
     408              :       M2Printf_printf1 ((const char *) " start %d\\n", 11, (const unsigned char *) &start, (sizeof (start)-1));
     409              :       M2Printf_printf1 ((const char *) " end %d\\n", 9, (const unsigned char *) &end, (sizeof (end)-1));
     410              :     }
     411       667701 :   M2StackWord_PushWord (s, static_cast<unsigned int> (0));
     412       667701 :   First = false;
     413       667701 :   i = scope;
     414       667701 :   last = scope;
     415       667701 :   nb = sb;
     416       667701 :   sb->low = scope;
     417       667701 :   sb->high = 0;
     418       667701 :   SetScope (sb, proc, M2Scope_procedurescope);
     419     18315540 :   while ((i <= end) && (start != 0))
     420              :     {
     421     17647839 :       M2Quads_GetQuad (i, &op, &op1, &op2, &op3);
     422     17647839 :       if ((op == M2Quads_ProcedureScopeOp) || (op == M2Quads_ModuleScopeOp))
     423              :         {
     424       361478 :           if (((M2StackWord_PeepWord (s, 1)) == proc) && (op3 == proc))
     425              :             {
     426            0 :               nb = AddToRange (nb, First, last);
     427            0 :               First = false;
     428              :             }
     429       361478 :           M2StackWord_PushWord (s, op3);
     430       361478 :           if (op == M2Quads_ProcedureScopeOp)
     431              :             {
     432       360596 :               SetScope (nb, proc, M2Scope_procedurescope);
     433              :             }
     434              :           else
     435              :             {
     436          882 :               SetScope (nb, proc, M2Scope_modulescope);
     437              :             }
     438              :         }
     439     17286361 :       else if ((op == M2Quads_ReturnOp) || (op == M2Quads_FinallyEndOp))
     440              :         {
     441              :           /* avoid dangling else.  */
     442       361478 :           op3 = static_cast<unsigned int> (M2StackWord_PopWord (s));
     443       361478 :           if ((M2StackWord_PeepWord (s, 1)) == proc)
     444              :             {
     445     17647839 :               First = true;
     446              :             }
     447              :         }
     448              :       else
     449              :         {
     450              :           /* avoid dangling else.  */
     451     16924883 :           if ((M2StackWord_PeepWord (s, 1)) == proc)
     452              :             {
     453     16887191 :               nb = AddToRange (nb, First, i);
     454     16887191 :               First = false;
     455              :             }
     456              :         }
     457     17647839 :       last = i;
     458     17647839 :       i = M2Quads_GetNextQuad (i);
     459              :     }
     460       667701 :   if (start <= nb->high)
     461              :     {
     462       667701 :       nb->high = end;
     463              :     }
     464              :   else
     465              :     {
     466            0 :       nb->next = static_cast<M2Scope_ScopeBlock__opaque> (M2Scope_InitScopeBlock (SymbolTable_NulSym));
     467            0 :       nb = nb->next;
     468            0 :       SetScope (nb, proc, M2Scope_unsetscope);
     469            0 :       nb->low = start;
     470            0 :       nb->high = end;
     471              :     }
     472       667701 :   s = M2StackWord_KillStackWord (s);
     473       667701 :   return sb;
     474              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     475              :   __builtin_unreachable ();
     476              : }
     477              : 
     478              : 
     479              : /*
     480              :    DisplayScope -
     481              : */
     482              : 
     483            0 : static void DisplayScope (M2Scope_ScopeBlock__opaque sb)
     484              : {
     485            0 :   NameKey_Name name;
     486              : 
     487            0 :   M2Printf_printf0 ((const char *) "scope: ", 7);
     488            0 :   switch (sb->kindScope)
     489              :     {
     490            0 :       case M2Scope_unsetscope:
     491            0 :         M2Printf_printf0 ((const char *) "unset", 5);
     492            0 :         break;
     493              : 
     494            0 :       case M2Scope_ignorescope:
     495            0 :         M2Printf_printf0 ((const char *) "ignore", 6);
     496            0 :         break;
     497              : 
     498            0 :       case M2Scope_procedurescope:
     499            0 :         name = SymbolTable_GetSymName (sb->scopeSym);
     500            0 :         M2Printf_printf1 ((const char *) "procedure %a", 12, (const unsigned char *) &name, (sizeof (name)-1));
     501            0 :         break;
     502              : 
     503            0 :       case M2Scope_modulescope:
     504            0 :         name = SymbolTable_GetSymName (sb->scopeSym);
     505            0 :         M2Printf_printf1 ((const char *) "inner module %a", 15, (const unsigned char *) &name, (sizeof (name)-1));
     506            0 :         break;
     507              : 
     508            0 :       case M2Scope_definitionscope:
     509            0 :         name = SymbolTable_GetSymName (sb->scopeSym);
     510            0 :         M2Printf_printf1 ((const char *) "definition module %a", 20, (const unsigned char *) &name, (sizeof (name)-1));
     511            0 :         break;
     512              : 
     513            0 :       case M2Scope_implementationscope:
     514            0 :         name = SymbolTable_GetSymName (sb->scopeSym);
     515            0 :         M2Printf_printf1 ((const char *) "implementation module %a", 24, (const unsigned char *) &name, (sizeof (name)-1));
     516            0 :         break;
     517              : 
     518            0 :       case M2Scope_programscope:
     519            0 :         name = SymbolTable_GetSymName (sb->scopeSym);
     520            0 :         M2Printf_printf1 ((const char *) "program module %a", 17, (const unsigned char *) &name, (sizeof (name)-1));
     521            0 :         break;
     522              : 
     523              : 
     524            0 :       default:
     525            0 :         CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Scope.def", 20, 1);
     526            0 :         __builtin_unreachable ();
     527              :     }
     528            0 :   M2Printf_printf0 ((const char *) "\\n", 2);
     529            0 :   M2Quads_DisplayQuadRange (sb->scopeSym, sb->low, sb->high);
     530            0 :   if (sb->next != NULL)
     531              :     {
     532            0 :       DisplayScope (sb->next);
     533              :     }
     534            0 : }
     535              : 
     536              : 
     537              : /*
     538              :    enter -
     539              : */
     540              : 
     541    150110124 : static void enter (M2Scope_ScopeBlock__opaque sb)
     542              : {
     543    150110124 :   switch (sb->kindScope)
     544              :     {
     545              :       case M2Scope_unsetscope:
     546              :       case M2Scope_ignorescope:
     547              :         break;
     548              : 
     549    147826314 :       case M2Scope_procedurescope:
     550    147826314 :       case M2Scope_modulescope:
     551    147826314 :       case M2Scope_definitionscope:
     552    147826314 :       case M2Scope_implementationscope:
     553    147826314 :       case M2Scope_programscope:
     554    147826314 :         M2Error_EnterErrorScope (SymbolTable_GetErrorScope (sb->scopeSym));
     555    147826314 :         break;
     556              : 
     557              : 
     558            0 :       default:
     559            0 :         CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Scope.def", 20, 1);
     560            0 :         __builtin_unreachable ();
     561              :     }
     562    150110124 : }
     563              : 
     564              : 
     565              : /*
     566              :    leave -
     567              : */
     568              : 
     569    150109938 : static void leave (M2Scope_ScopeBlock__opaque sb)
     570              : {
     571            0 :   switch (sb->kindScope)
     572              :     {
     573              :       case M2Scope_unsetscope:
     574              :       case M2Scope_ignorescope:
     575              :         break;
     576              : 
     577              : 
     578    147826128 :       default:
     579    147826128 :         M2Error_LeaveErrorScope ();
     580    147826128 :         break;
     581              :     }
     582            0 : }
     583              : 
     584              : 
     585              : /*
     586              :    Init - initializes the global variables for this module.
     587              : */
     588              : 
     589            0 : static void Init (void)
     590              : {
     591            0 :   FreeList = static_cast<M2Scope_ScopeBlock__opaque> (NULL);
     592            0 : }
     593              : 
     594              : 
     595              : /*
     596              :    InitScopeBlock -
     597              : */
     598              : 
     599     50350211 : extern "C" M2Scope_ScopeBlock M2Scope_InitScopeBlock (unsigned int scope)
     600              : {
     601     50350211 :   M2Scope_ScopeBlock__opaque sb;
     602              : 
     603     50350211 :   New (&sb);
     604     50350211 :   sb->next = static_cast<M2Scope_ScopeBlock__opaque> (NULL);
     605     50350211 :   sb->kindScope = M2Scope_unsetscope;
     606     50350211 :   if (scope == SymbolTable_NulSym)
     607              :     {
     608     48917504 :       sb->low = 0;
     609     48917504 :       sb->high = 0;
     610              :     }
     611              :   else
     612              :     {
     613      1432707 :       if (SymbolTable_IsProcedure (scope))
     614              :         {
     615       667701 :           sb = GetProcQuads (sb, scope);
     616              :         }
     617              :       else
     618              :         {
     619       765006 :           sb = GetGlobalQuads (sb, scope);
     620              :         }
     621              :       if (TraceQuadruples)
     622              :         {
     623              :           DisplayScope (sb);
     624              :         }
     625              :     }
     626     50350211 :   return static_cast<M2Scope_ScopeBlock> (sb);
     627              :   /* static analysis guarentees a RETURN statement will be used before here.  */
     628              :   __builtin_unreachable ();
     629              : }
     630              : 
     631              : 
     632              : /*
     633              :    KillScopeBlock - destroys the ScopeBlock sb and assign sb to NIL.
     634              : */
     635              : 
     636      1432461 : extern "C" void M2Scope_KillScopeBlock (M2Scope_ScopeBlock *sb)
     637              : {
     638      1432461 :   M2Scope_ScopeBlock__opaque t;
     639              : 
     640      1432461 :   t = static_cast<M2Scope_ScopeBlock__opaque> ((*sb));
     641     51780998 :   while (t != NULL)
     642              :     {
     643     50348537 :       (*sb) = static_cast<M2Scope_ScopeBlock> (t);
     644     50348537 :       t = t->next;
     645     50348537 :       Dispose (reinterpret_cast<M2Scope_ScopeBlock__opaque *> (&(*sb)));
     646              :     }
     647      1432461 :   (*sb) = static_cast<M2Scope_ScopeBlock> (NULL);
     648      1432461 : }
     649              : 
     650              : 
     651              : /*
     652              :    ForeachScopeBlockDo2 - calls a procedure p for each block of contigeous quadruples
     653              :                           defining an outer scope sb.
     654              : */
     655              : 
     656       314170 : extern "C" void M2Scope_ForeachScopeBlockDo2 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure2 p)
     657              : {
     658       314170 :   if (TraceQuadruples)
     659              :     {
     660              :       M2Printf_printf0 ((const char *) "ForeachScopeBlockDo\\n", 21);
     661              :     }
     662      1328330 :   while (sb != NULL)
     663              :     {
     664      1014172 :       if (TraceQuadruples)
     665              :         {
     666              :           DisplayScope (static_cast<M2Scope_ScopeBlock__opaque> (sb));
     667              :         }
     668      1014172 :       enter (static_cast<M2Scope_ScopeBlock__opaque> (sb));
     669      1014172 :       if ((static_cast<M2Scope_ScopeBlock__opaque> (sb)->low != 0) && (static_cast<M2Scope_ScopeBlock__opaque> (sb)->high != 0))
     670              :         {
     671       816479 :           (*p.proc) (static_cast<M2Scope_ScopeBlock__opaque> (sb)->low, static_cast<M2Scope_ScopeBlock__opaque> (sb)->high);
     672              :         }
     673      1014160 :       leave (static_cast<M2Scope_ScopeBlock__opaque> (sb));
     674      1014160 :       sb = static_cast<M2Scope_ScopeBlock> (static_cast<M2Scope_ScopeBlock__opaque> (sb)->next);
     675              :     }
     676       314158 :   if (TraceQuadruples)
     677              :     {
     678              :       M2Printf_printf0 ((const char *) "end ForeachScopeBlockDo\\n\\n", 27);
     679              :     }
     680       314158 : }
     681              : 
     682              : 
     683              : /*
     684              :    ForeachScopeBlockDo3 - calls a procedure p for each block of contigeous quadruples
     685              :                           defining an outer scope sb.
     686              : */
     687              : 
     688      3555101 : extern "C" void M2Scope_ForeachScopeBlockDo3 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure3 p)
     689              : {
     690      3555101 :   if (TraceQuadruples)
     691              :     {
     692              :       M2Printf_printf0 ((const char *) "ForeachScopeBlockDo\\n", 21);
     693              :     }
     694    152650879 :   while (sb != NULL)
     695              :     {
     696    149095952 :       if (TraceQuadruples)
     697              :         {
     698              :           DisplayScope (static_cast<M2Scope_ScopeBlock__opaque> (sb));
     699              :         }
     700    149095952 :       enter (static_cast<M2Scope_ScopeBlock__opaque> (sb));
     701    149095952 :       if ((static_cast<M2Scope_ScopeBlock__opaque> (sb)->low != 0) && (static_cast<M2Scope_ScopeBlock__opaque> (sb)->high != 0))
     702              :         {
     703    146292198 :           (*p.proc) (static_cast<M2Scope_ScopeBlock__opaque> (sb)->scopeSym, static_cast<M2Scope_ScopeBlock__opaque> (sb)->low, static_cast<M2Scope_ScopeBlock__opaque> (sb)->high);
     704              :         }
     705    149095778 :       leave (static_cast<M2Scope_ScopeBlock__opaque> (sb));
     706    149095778 :       sb = static_cast<M2Scope_ScopeBlock> (static_cast<M2Scope_ScopeBlock__opaque> (sb)->next);
     707              :     }
     708      3554927 :   if (TraceQuadruples)
     709              :     {
     710              :       M2Printf_printf0 ((const char *) "end ForeachScopeBlockDo\\n\\n", 27);
     711              :     }
     712      3554927 : }
     713              : 
     714            0 : extern "C" void _M2_M2Scope_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
     715              : {
     716            0 :   Init ();
     717            0 : }
     718              : 
     719            0 : extern "C" void _M2_M2Scope_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
     720              : {
     721            0 : }
        

Generated by: LCOV version 2.4-beta

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