LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2ALU.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 65.0 % 2359 1534
Test Date: 2026-02-28 14:20:25 Functions: 72.8 % 184 134
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* do not edit automatically generated by mc from M2ALU.  */
       2              : /* M2ALU.mod gcc implementation of the M2ALU module.
       3              : 
       4              : Copyright (C) 2001-2026 Free Software Foundation, Inc.
       5              : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6              : 
       7              : This file is part of GNU Modula-2.
       8              : 
       9              : GNU Modula-2 is free software; you can redistribute it and/or modify
      10              : it under the terms of the GNU General Public License as published by
      11              : the Free Software Foundation; either version 3, or (at your option)
      12              : any later version.
      13              : 
      14              : GNU Modula-2 is distributed in the hope that it will be useful, but
      15              : WITHOUT ANY WARRANTY; without even the implied warranty of
      16              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17              : General Public License for more details.
      18              : 
      19              : You should have received a copy of the GNU General Public License
      20              : along with GNU Modula-2; see the file COPYING3.  If not see
      21              : <http://www.gnu.org/licenses/>.  */
      22              : 
      23              : #include "config.h"
      24              : #include "system.h"
      25              : #include "gcc-consolidation.h"
      26              : 
      27              : #include <stdbool.h>
      28              : #   if !defined (PROC_D)
      29              : #      define PROC_D
      30              :        typedef void (*PROC_t) (void);
      31              :        typedef struct { PROC_t proc; } PROC;
      32              : #   endif
      33              : 
      34              : #   if !defined (TRUE)
      35              : #      define TRUE (1==1)
      36              : #   endif
      37              : 
      38              : #   if !defined (FALSE)
      39              : #      define FALSE (1==0)
      40              : #   endif
      41              : 
      42              : #   include "GStorage.h"
      43              : #   include "Gmcrts.h"
      44              : #if defined(__cplusplus)
      45              : #   undef NULL
      46              : #   define NULL 0
      47              : #endif
      48              : #define _M2ALU_C
      49              : 
      50              : #include "GM2ALU.h"
      51              : #   include "GASCII.h"
      52              : #   include "GSYSTEM.h"
      53              : #   include "GNameKey.h"
      54              : #   include "GM2Error.h"
      55              : #   include "GM2Debug.h"
      56              : #   include "GStorage.h"
      57              : #   include "GStringConvert.h"
      58              : #   include "GM2GCCDeclare.h"
      59              : #   include "GM2GenGCC.h"
      60              : #   include "GM2Bitset.h"
      61              : #   include "GSymbolConversion.h"
      62              : #   include "GM2Printf.h"
      63              : #   include "GM2Base.h"
      64              : #   include "GDynamicStrings.h"
      65              : #   include "GM2LexBuf.h"
      66              : #   include "GM2MetaError.h"
      67              : #   include "GSymbolTable.h"
      68              : #   include "Ggcctypes.h"
      69              : #   include "Gm2linemap.h"
      70              : #   include "Gm2expr.h"
      71              : #   include "Gm2decl.h"
      72              : #   include "Gm2misc.h"
      73              : #   include "Gm2type.h"
      74              : #   include "Gm2convert.h"
      75              : #   include "Gm2block.h"
      76              : #   include "GM2Diagnostic.h"
      77              : 
      78              : #   define Debugging false
      79              : #   define DebugGarbage true
      80              : typedef struct M2ALU_rList_r M2ALU_rList;
      81              : 
      82              : typedef M2ALU_rList *M2ALU_listOfRange;
      83              : 
      84              : typedef struct M2ALU_fList_r M2ALU_fList;
      85              : 
      86              : typedef M2ALU_fList *M2ALU_listOfFields;
      87              : 
      88              : typedef struct M2ALU_eList_r M2ALU_eList;
      89              : 
      90              : typedef M2ALU_eList *M2ALU_listOfElements;
      91              : 
      92              : typedef struct M2ALU_cell_r M2ALU_cell;
      93              : 
      94              : typedef struct M2ALU_DoSetProcedure_p M2ALU_DoSetProcedure;
      95              : 
      96              : typedef enum {M2ALU_none, M2ALU_integer, M2ALU_real, M2ALU_complex, M2ALU_set, M2ALU_constructor, M2ALU_array, M2ALU_record} M2ALU_cellType;
      97              : 
      98              : typedef M2ALU_cell *M2ALU_PtrToValue__opaque;
      99              : 
     100              : struct M2ALU_rList_r {
     101              :                        unsigned int low;
     102              :                        unsigned int high;
     103              :                        M2ALU_listOfRange next;
     104              :                      };
     105              : 
     106              : struct M2ALU_fList_r {
     107              :                        unsigned int field;
     108              :                        M2ALU_listOfFields next;
     109              :                      };
     110              : 
     111              : struct M2ALU_eList_r {
     112              :                        unsigned int element;
     113              :                        unsigned int by;
     114              :                        M2ALU_listOfElements next;
     115              :                      };
     116              : 
     117              : struct M2ALU_cell_r {
     118              :                       location_t location;
     119              :                       bool areAllConstants;
     120              :                       bool solved;
     121              :                       unsigned int constructorType;
     122              :                       M2ALU_PtrToValue__opaque next;
     123              :                       tree numberValue;
     124              :                       M2ALU_cellType type;  /* case tag */
     125              :                       union {
     126              :                               M2ALU_listOfRange setValue;
     127              :                               M2ALU_listOfFields fieldValues;
     128              :                               M2ALU_listOfElements arrayValues;
     129              :                             };
     130              :                     };
     131              : 
     132              : typedef M2ALU_listOfRange (*M2ALU_DoSetProcedure_t) (unsigned int, M2ALU_listOfRange, M2ALU_listOfRange);
     133              : struct M2ALU_DoSetProcedure_p { M2ALU_DoSetProcedure_t proc; };
     134              : 
     135              : static M2ALU_listOfElements ElementFreeList;
     136              : static M2ALU_listOfFields FieldFreeList;
     137              : static M2ALU_listOfRange RangeFreeList;
     138              : static M2ALU_PtrToValue__opaque FreeList;
     139              : static M2ALU_PtrToValue__opaque TopOfStack;
     140              : static tree EnumerationValue;
     141              : static unsigned int EnumerationField;
     142              : static unsigned int CurrentTokenNo;
     143              : static M2Diagnostic_Diagnostic StackMemDiag;
     144              : static M2Diagnostic_Diagnostic RangeMemDiag;
     145              : 
     146              : /*
     147              :    InitValue - initializes and returns a memory cell.
     148              : */
     149              : 
     150              : extern "C" M2ALU_PtrToValue M2ALU_InitValue (void);
     151              : 
     152              : /*
     153              :    KillValue - deconstructor for value.  value is set to NIL upon return.
     154              : */
     155              : 
     156              : extern "C" void M2ALU_KillValue (M2ALU_PtrToValue *value);
     157              : 
     158              : /*
     159              :    IsValueTypeNone - returns TRUE if the value on the top stack has no value.
     160              : */
     161              : 
     162              : extern "C" bool M2ALU_IsValueTypeNone (void);
     163              : 
     164              : /*
     165              :    IsValueTypeInteger - returns TRUE if the value on the top stack is an integer.
     166              : */
     167              : 
     168              : extern "C" bool M2ALU_IsValueTypeInteger (void);
     169              : 
     170              : /*
     171              :    IsValueTypeReal - returns TRUE if the value on the top stack is a real.
     172              : */
     173              : 
     174              : extern "C" bool M2ALU_IsValueTypeReal (void);
     175              : 
     176              : /*
     177              :    IsValueTypeComplex - returns TRUE if the value on the top stack is a complex.
     178              : */
     179              : 
     180              : extern "C" bool M2ALU_IsValueTypeComplex (void);
     181              : 
     182              : /*
     183              :    IsValueTypeSet - returns TRUE if the value on the top stack is a set.
     184              : */
     185              : 
     186              : extern "C" bool M2ALU_IsValueTypeSet (void);
     187              : 
     188              : /*
     189              :    IsValueTypeConstructor - returns TRUE if the value on the top
     190              :                             stack is a constructor.
     191              : */
     192              : 
     193              : extern "C" bool M2ALU_IsValueTypeConstructor (void);
     194              : 
     195              : /*
     196              :    IsValueTypeArray - returns TRUE if the value on the top stack is
     197              :                       an array.
     198              : */
     199              : 
     200              : extern "C" bool M2ALU_IsValueTypeArray (void);
     201              : 
     202              : /*
     203              :    IsValueTypeRecord - returns TRUE if the value on the top stack is
     204              :                        a record.
     205              : */
     206              : 
     207              : extern "C" bool M2ALU_IsValueTypeRecord (void);
     208              : 
     209              : /*
     210              :    GetSetValueType - returns the set type on top of the ALU stack.
     211              : */
     212              : 
     213              : extern "C" unsigned int M2ALU_GetSetValueType (void);
     214              : 
     215              : /*
     216              :    PushIntegerTree - pushes a gcc tree value onto the ALU stack.
     217              : */
     218              : 
     219              : extern "C" void M2ALU_PushIntegerTree (tree t);
     220              : 
     221              : /*
     222              :    PopIntegerTree - pops a gcc tree value from the ALU stack.
     223              : */
     224              : 
     225              : extern "C" tree M2ALU_PopIntegerTree (void);
     226              : 
     227              : /*
     228              :    PushRealTree - pushes a gcc tree value onto the ALU stack.
     229              : */
     230              : 
     231              : extern "C" void M2ALU_PushRealTree (tree t);
     232              : 
     233              : /*
     234              :    PopRealTree - pops a gcc tree value from the ALU stack.
     235              : */
     236              : 
     237              : extern "C" tree M2ALU_PopRealTree (void);
     238              : 
     239              : /*
     240              :    PushComplexTree - pushes a gcc tree value onto the ALU stack.
     241              : */
     242              : 
     243              : extern "C" void M2ALU_PushComplexTree (tree t);
     244              : 
     245              : /*
     246              :    PopComplexTree - pops a gcc tree value from the ALU stack.
     247              : */
     248              : 
     249              : extern "C" tree M2ALU_PopComplexTree (void);
     250              : 
     251              : /*
     252              :    PushSetTree - pushes a gcc tree onto the ALU stack.
     253              :                  The tree value is expected to contain a
     254              :                  word sized or less value.  It is converted into a set
     255              :                  type (sym). Bit 0 maps onto MIN (sym).
     256              : */
     257              : 
     258              : extern "C" void M2ALU_PushSetTree (unsigned int tokenno, tree value, unsigned int sym);
     259              : 
     260              : /*
     261              :    PopSetTree - pops a gcc tree from the ALU stack.
     262              : */
     263              : 
     264              : extern "C" tree M2ALU_PopSetTree (unsigned int tokenno);
     265              : 
     266              : /*
     267              :    PopConstructorTree - returns a tree containing the compound literal.
     268              : */
     269              : 
     270              : extern "C" tree M2ALU_PopConstructorTree (unsigned int tokenno);
     271              : 
     272              : /*
     273              :    PushFrom - pushes a copy of the contents of, v, onto stack.
     274              : */
     275              : 
     276              : extern "C" void M2ALU_PushFrom (M2ALU_PtrToValue v);
     277              : 
     278              : /*
     279              :    PopInto - pops the top element from the stack and places it into, v.
     280              : */
     281              : 
     282              : extern "C" void M2ALU_PopInto (M2ALU_PtrToValue v);
     283              : 
     284              : /*
     285              :    PushCard - pushes a cardinal onto the stack.
     286              : */
     287              : 
     288              : extern "C" void M2ALU_PushCard (unsigned int c);
     289              : 
     290              : /*
     291              :    PushInt - pushes an integer onto the stack.
     292              : */
     293              : 
     294              : extern "C" void M2ALU_PushInt (int i);
     295              : 
     296              : /*
     297              :    PushChar - pushes a char onto the stack.
     298              : */
     299              : 
     300              : extern "C" void M2ALU_PushChar (char c);
     301              : 
     302              : /*
     303              :    PopChar - pops a char from the stack.
     304              : */
     305              : 
     306              : extern "C" char M2ALU_PopChar (unsigned int tokenno);
     307              : 
     308              : /*
     309              :    PushString - pushes the numerical value of the string onto the stack.
     310              : */
     311              : 
     312              : extern "C" void M2ALU_PushString (unsigned int tokenno, NameKey_Name s, bool issueError);
     313              : 
     314              : /*
     315              :    CoerseLongRealToCard - performs a coersion between a REAL to a CARDINAL
     316              : */
     317              : 
     318              : extern "C" void M2ALU_CoerseLongRealToCard (void);
     319              : 
     320              : /*
     321              :    ConvertRealToInt - converts a REAL into an INTEGER
     322              : */
     323              : 
     324              : extern "C" void M2ALU_ConvertRealToInt (void);
     325              : 
     326              : /*
     327              :    ConvertToInt - converts the value into an INTEGER. This should be used
     328              :                   if we are computing the number of elements in a char set to
     329              :                   avoid an overflow.
     330              : */
     331              : 
     332              : extern "C" void M2ALU_ConvertToInt (void);
     333              : 
     334              : /*
     335              :    ConvertToType - converts the top of stack to type, t.
     336              : */
     337              : 
     338              : extern "C" void M2ALU_ConvertToType (unsigned int t);
     339              : 
     340              : /*
     341              :    IsSolved - returns true if the memory cell indicated by v
     342              :               has a known value.
     343              : */
     344              : 
     345              : extern "C" bool M2ALU_IsSolved (M2ALU_PtrToValue v);
     346              : 
     347              : /*
     348              :    PutConstructorSolved - records that this constructor is solved.
     349              : */
     350              : 
     351              : extern "C" void M2ALU_PutConstructorSolved (unsigned int sym);
     352              : 
     353              : /*
     354              :    EvaluateValue - attempts to evaluate the symbol, sym, value.
     355              : */
     356              : 
     357              : extern "C" void M2ALU_EvaluateValue (unsigned int sym);
     358              : 
     359              : /*
     360              :    TryEvaluateValue - attempts to evaluate the symbol, sym, value.
     361              : */
     362              : 
     363              : extern "C" void M2ALU_TryEvaluateValue (unsigned int sym);
     364              : extern "C" void M2ALU_Addn (void);
     365              : 
     366              : /*
     367              :    Sub - subtracts the top two elements on the stack.
     368              : 
     369              :          The Stack:
     370              : 
     371              :          Entry             Exit
     372              : 
     373              :   Ptr ->
     374              :          +------------+
     375              :          | Op1        |                   <- Ptr
     376              :          |------------|    +------------+
     377              :          | Op2        |    | Op2 - Op1  |
     378              :          |------------|    |------------|
     379              : */
     380              : 
     381              : extern "C" void M2ALU_Sub (void);
     382              : extern "C" void M2ALU_Multn (void);
     383              : 
     384              : /*
     385              :    DivFloor - divides the top two elements on the stack.
     386              : 
     387              :               The Stack:
     388              : 
     389              :               Entry             Exit
     390              : 
     391              :        Ptr ->
     392              :               +------------+
     393              :               | Op1        |                     <- Ptr
     394              :               |------------|    +--------------+
     395              :               | Op2        |    | Op2 DIV Op1  |
     396              :               |------------|    |--------------|
     397              : */
     398              : 
     399              : extern "C" void M2ALU_DivFloor (void);
     400              : 
     401              : /*
     402              :    ModFloor - modulus of the top two elements on the stack.
     403              : 
     404              :               The Stack:
     405              : 
     406              :               Entry             Exit
     407              : 
     408              :        Ptr ->
     409              :               +------------+
     410              :               | Op1        |                     <- Ptr
     411              :               |------------|    +--------------+
     412              :               | Op2        |    | Op2 MOD Op1  |
     413              :               |------------|    |--------------|
     414              : */
     415              : 
     416              : extern "C" void M2ALU_ModFloor (void);
     417              : 
     418              : /*
     419              :    DivTrunc - divides the top two elements on the stack.
     420              : 
     421              :               The Stack:
     422              : 
     423              :               Entry             Exit
     424              : 
     425              :        Ptr ->
     426              :               +------------+
     427              :               | Op1        |                     <- Ptr
     428              :               |------------|    +--------------+
     429              :               | Op2        |    | Op2 DIV Op1  |
     430              :               |------------|    |--------------|
     431              : */
     432              : 
     433              : extern "C" void M2ALU_DivTrunc (void);
     434              : 
     435              : /*
     436              :    ModTrunc - modulus of the top two elements on the stack.
     437              : 
     438              :               The Stack:
     439              : 
     440              :               Entry             Exit
     441              : 
     442              :        Ptr ->
     443              :               +------------+
     444              :               | Op1        |                     <- Ptr
     445              :               |------------|    +--------------+
     446              :               | Op2        |    | Op2 MOD Op1  |
     447              :               |------------|    |--------------|
     448              : */
     449              : 
     450              : extern "C" void M2ALU_ModTrunc (void);
     451              : 
     452              : /*
     453              :    Equ - returns true if the top two elements on the stack
     454              :          are identical.
     455              : 
     456              :          The Stack:
     457              : 
     458              :          Entry             Exit
     459              : 
     460              :   Ptr ->
     461              :          +------------+
     462              :          | Op1        |
     463              :          |------------|
     464              :          | Op2        |
     465              :          |------------|    Empty
     466              : 
     467              :          RETURN( Op2 = Op1 )
     468              : */
     469              : 
     470              : extern "C" bool M2ALU_Equ (unsigned int tokenno);
     471              : 
     472              : /*
     473              :    NotEqu - returns true if the top two elements on the stack
     474              :             are not identical.
     475              : 
     476              :             The Stack:
     477              : 
     478              :             Entry             Exit
     479              : 
     480              :      Ptr ->
     481              :             +------------+
     482              :             | Op1        |
     483              :             |------------|
     484              :             | Op2        |
     485              :             |------------|    Empty
     486              : 
     487              :             RETURN( Op2 # Op1 )
     488              : */
     489              : 
     490              : extern "C" bool M2ALU_NotEqu (unsigned int tokenno);
     491              : 
     492              : /*
     493              :    Less - returns true if Op2 < Op1
     494              : 
     495              :           The Stack:
     496              : 
     497              :           Entry             Exit
     498              : 
     499              :    Ptr ->
     500              :           +------------+
     501              :           | Op1        |
     502              :           |------------|
     503              :           | Op2        |
     504              :           |------------|    Empty
     505              : 
     506              :           RETURN( Op2 < Op1 )
     507              : */
     508              : 
     509              : extern "C" bool M2ALU_Less (unsigned int tokenno);
     510              : 
     511              : /*
     512              :    Gre - returns true if Op2 > Op1
     513              : 
     514              :          The Stack:
     515              : 
     516              :          Entry             Exit
     517              : 
     518              :   Ptr ->
     519              :          +------------+
     520              :          | Op1        |
     521              :          |------------|
     522              :          | Op2        |
     523              :          |------------|    Empty
     524              : 
     525              :          RETURN( Op2 > Op1 )
     526              : */
     527              : 
     528              : extern "C" bool M2ALU_Gre (unsigned int tokenno);
     529              : 
     530              : /*
     531              :    LessEqu - returns true if Op2<Op1
     532              : 
     533              :              The Stack:
     534              : 
     535              :              Entry             Exit
     536              : 
     537              :       Ptr ->
     538              :              +------------+
     539              :              | Op1        |
     540              :              |------------|
     541              :              | Op2        |
     542              :              |------------|    Empty
     543              : 
     544              :              RETURN( Op2 <= Op1 )
     545              : */
     546              : 
     547              : extern "C" bool M2ALU_LessEqu (unsigned int tokenno);
     548              : 
     549              : /*
     550              :    GreEqu - returns true if Op2 >= Op1
     551              :             are not identical.
     552              : 
     553              :             The Stack:
     554              : 
     555              :             Entry             Exit
     556              : 
     557              :      Ptr ->
     558              :             +------------+
     559              :             | Op1        |
     560              :             |------------|
     561              :             | Op2        |
     562              :             |------------|    Empty
     563              : 
     564              :             RETURN( Op2 >= Op1 )
     565              : */
     566              : 
     567              : extern "C" bool M2ALU_GreEqu (unsigned int tokenno);
     568              : 
     569              : /*
     570              :    IsNulSet - returns TRUE if the top element is the nul set constant, {}.
     571              : */
     572              : 
     573              : extern "C" bool M2ALU_IsNulSet (void);
     574              : 
     575              : /*
     576              :    IsGenericNulSet - returns TRUE if the top element is the generic nul set constant, {}.
     577              : */
     578              : 
     579              : extern "C" bool M2ALU_IsGenericNulSet (void);
     580              : 
     581              : /*
     582              :    PushNulSet - pushes an empty set {} onto the ALU stack. The subrange type used
     583              :                 to construct the set is defined by, constructorType.
     584              :                 If this is NulSym then
     585              :                 the set is generic and compatible with all sets.
     586              : 
     587              :                 The Stack:
     588              : 
     589              :                 Entry             Exit
     590              : 
     591              :                                                  <- Ptr
     592              :                                   +------------+
     593              :                                   | {}         |
     594              :                 Ptr ->            |------------|
     595              : 
     596              : */
     597              : 
     598              : extern "C" void M2ALU_PushNulSet (unsigned int settype);
     599              : 
     600              : /*
     601              :    AddBitRange - adds the range op1..op2 to the underlying set.
     602              : 
     603              :                  Ptr ->
     604              :                                                            <- Ptr
     605              :                         +------------+      +------------+
     606              :                         | Set        |      | Set        |
     607              :                         |------------|      |------------|
     608              : 
     609              : */
     610              : 
     611              : extern "C" void M2ALU_AddBitRange (unsigned int tokenno, unsigned int op1, unsigned int op2);
     612              : 
     613              : /*
     614              :    AddBit - adds the bit op1 to the underlying set. INCL(Set, op1)
     615              : 
     616              :             Ptr ->
     617              :                                                       <- Ptr
     618              :                    +------------+      +------------+
     619              :                    | Set        |      | Set        |
     620              :                    |------------|      |------------|
     621              : */
     622              : 
     623              : extern "C" void M2ALU_AddBit (unsigned int tokenno, unsigned int op1);
     624              : 
     625              : /*
     626              :    SubBit - removes a bit op1 from the underlying set. EXCL(Set, Op1)
     627              : 
     628              :             Ptr ->
     629              :                                                       <- Ptr
     630              :                    +------------+      +------------+
     631              :                    | Set        |      | Set        |
     632              :                    |------------|      |------------|
     633              : */
     634              : 
     635              : extern "C" void M2ALU_SubBit (unsigned int tokenno, unsigned int op1);
     636              : 
     637              : /*
     638              :    SetIn - returns true if Op2 IN Op1
     639              : 
     640              :            The Stack:
     641              : 
     642              :            Entry             Exit
     643              : 
     644              :     Ptr ->
     645              :            +------------+
     646              :            | Set        |
     647              :            |------------|    Empty
     648              : 
     649              :            RETURN( Op1 IN Set )
     650              : */
     651              : 
     652              : extern "C" bool M2ALU_SetIn (unsigned int tokenno, unsigned int Op1);
     653              : 
     654              : /*
     655              :    SetOr -  performs an inclusive OR of the top two elements on the stack.
     656              : 
     657              :             The Stack:
     658              : 
     659              :             Entry             Exit
     660              : 
     661              :      Ptr ->
     662              :             +------------+
     663              :             | Set1       |                   <- Ptr
     664              :             |------------|    +------------+
     665              :             | Set2       |    | Set1 + Set2|
     666              :             |------------|    |------------|
     667              : 
     668              : */
     669              : 
     670              : extern "C" void M2ALU_SetOr (unsigned int tokenno);
     671              : 
     672              : /*
     673              :    SetAnd - performs a set AND the top two elements on the stack.
     674              : 
     675              :             The Stack:
     676              : 
     677              :             Entry             Exit
     678              : 
     679              :      Ptr ->
     680              :             +------------+
     681              :             | Op1        |                   <- Ptr
     682              :             |------------|    +------------+
     683              :             | Op2        |    | Op2 * Op1  |
     684              :             |------------|    |------------|
     685              : */
     686              : 
     687              : extern "C" void M2ALU_SetAnd (unsigned int tokenno);
     688              : 
     689              : /*
     690              :    SetDifference - performs a set difference of the top two elements on the stack.
     691              :                    For each member in the set
     692              :                       if member in Op2 and not member in Op1
     693              : 
     694              :                    The Stack:
     695              : 
     696              :                    Entry             Exit
     697              : 
     698              :             Ptr ->
     699              :                    +------------+
     700              :                    | Op1        |                   <- Ptr
     701              :                    |------------|    +-------------------+
     702              :                    | Op2        |    | Op2 and (not Op1) |
     703              :                    |------------|    |-------------------|
     704              : */
     705              : 
     706              : extern "C" void M2ALU_SetDifference (unsigned int tokenno);
     707              : 
     708              : /*
     709              :    SetSymmetricDifference - performs a set difference of the top two elements on the stack.
     710              : 
     711              :                             The Stack:
     712              : 
     713              :                             Entry             Exit
     714              : 
     715              :                      Ptr ->
     716              :                             +------------+
     717              :                             | Op1        |                    <- Ptr
     718              :                             |------------|    +-------------+
     719              :                             | Op2        |    | Op2 xor Op1 |
     720              :                             |------------|    |-------------|
     721              : */
     722              : 
     723              : extern "C" void M2ALU_SetSymmetricDifference (unsigned int tokenno);
     724              : 
     725              : /*
     726              :    SetNegate - negates the top set on the stack.
     727              : 
     728              :                Ptr ->                                               <- Ptr
     729              :                       +-----------+                  +------------+
     730              :                       | Set       |                  | Set        |
     731              :                       |-----------|                  |------------|
     732              : */
     733              : 
     734              : extern "C" void M2ALU_SetNegate (unsigned int tokenno);
     735              : 
     736              : /*
     737              :    SetShift - if op1 is positive
     738              :               then
     739              :                  result := op2 << op1
     740              :               else
     741              :                  result := op2 >> op1
     742              :               fi
     743              : 
     744              : 
     745              :               The Stack:
     746              : 
     747              :                      Entry             Exit
     748              : 
     749              :               Ptr ->
     750              :                      +------------+
     751              :                      | Op1        |                   <- Ptr
     752              :                      |------------|    +------------+
     753              :                      | Op2        |    | result     |
     754              :                      |------------|    |------------|
     755              : 
     756              : */
     757              : 
     758              : extern "C" void M2ALU_SetShift (unsigned int tokenno);
     759              : 
     760              : /*
     761              :    SetRotate - if op1 is positive
     762              :                then
     763              :                   result := ROTATERIGHT(op2, op1)
     764              :                else
     765              :                   result := ROTATELEFT(op2, op1)
     766              :                fi
     767              : 
     768              : 
     769              :                The Stack:
     770              : 
     771              :                       Entry             Exit
     772              : 
     773              :                Ptr ->
     774              :                       +------------+
     775              :                       | Op1        |                   <- Ptr
     776              :                       |------------|    +------------+
     777              :                       | Op2        |    | result     |
     778              :                       |------------|    |------------|
     779              : */
     780              : 
     781              : extern "C" void M2ALU_SetRotate (unsigned int tokenno);
     782              : 
     783              : /*
     784              :    GetValue - returns and pops the value from the top of stack.
     785              : */
     786              : 
     787              : extern "C" M2ALU_PtrToValue M2ALU_GetValue (unsigned int tokenno);
     788              : 
     789              : /*
     790              :    GetRange - returns TRUE if range number, n, exists in the value, v.
     791              :               A non empty set is defined by having 1..N ranges
     792              : */
     793              : 
     794              : extern "C" bool M2ALU_GetRange (M2ALU_PtrToValue v, unsigned int n, unsigned int *low, unsigned int *high);
     795              : 
     796              : /*
     797              :    ConstructSetConstant - builds an array of bytes which represents the
     798              :                           set const as defined by v.
     799              : */
     800              : 
     801              : extern "C" tree M2ALU_ConstructSetConstant (unsigned int tokenno, M2ALU_PtrToValue v);
     802              : 
     803              : /*
     804              :    BuildRange - returns a integer sized constant which represents the
     805              :                 value  {e1..e2}.
     806              : */
     807              : 
     808              : extern "C" tree M2ALU_BuildRange (unsigned int tokenno, tree e1, tree e2);
     809              : 
     810              : /*
     811              :    IsConstructorDependants - return TRUE if all q(dependants) of,
     812              :                              sym, return TRUE.
     813              : */
     814              : 
     815              : extern "C" bool M2ALU_IsConstructorDependants (unsigned int sym, M2GCCDeclare_IsAction q);
     816              : 
     817              : /*
     818              :    WalkConstructorDependants - walk the constructor, sym, calling
     819              :                                p for each dependant.
     820              : */
     821              : 
     822              : extern "C" void M2ALU_WalkConstructorDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
     823              : 
     824              : /*
     825              :    IsValueAndTreeKnown - returns TRUE if the value is known and the gcc tree
     826              :                          is defined.
     827              : 
     828              :                          The Stack:
     829              : 
     830              :                                 Entry             Exit
     831              : 
     832              :                          Ptr ->
     833              :                                 +------------+
     834              :                                 | Op1        |                   <- Ptr
     835              :                                 |------------|    +------------+
     836              : */
     837              : 
     838              : extern "C" bool M2ALU_IsValueAndTreeKnown (void);
     839              : 
     840              : /*
     841              :    CheckOrResetOverflow - tests to see whether the tree, t, has caused
     842              :                           an overflow error and if so it generates an
     843              :                           error message.
     844              : */
     845              : 
     846              : extern "C" void M2ALU_CheckOrResetOverflow (unsigned int tokenno, tree t, bool check);
     847              : 
     848              : /*
     849              :    AddElements - adds the elements, el BY, n, to the array constant.
     850              : 
     851              :                  Ptr ->
     852              :                                                            <- Ptr
     853              :                         +------------+      +------------+
     854              :                         | Array      |      | Array      |
     855              :                         |------------|      |------------|
     856              : 
     857              : */
     858              : 
     859              : extern "C" void M2ALU_AddElements (unsigned int tokenno, unsigned int el, unsigned int n);
     860              : 
     861              : /*
     862              :    AddField - adds the field op1 to the underlying constructor.
     863              : 
     864              :                  Ptr ->
     865              :                                                            <- Ptr
     866              :                         +------------+      +------------+
     867              :                         | const      |      | const      |
     868              :                         |------------|      |------------|
     869              : 
     870              : */
     871              : 
     872              : extern "C" void M2ALU_AddField (unsigned int tokenno, unsigned int op1);
     873              : 
     874              : /*
     875              :    PushEmptyConstructor - pushes an empty constructor {} onto the ALU stack.
     876              :                           This is expected to be filled in by subsequent
     877              :                           calls to AddElements, AddRange or AddField.
     878              : 
     879              :                           The Stack:
     880              : 
     881              :                           Entry             Exit
     882              : 
     883              :                                                        <- Ptr
     884              :                                         +------------+
     885              :                                         | {}         |
     886              :                    Ptr ->               |------------|
     887              : 
     888              : */
     889              : 
     890              : extern "C" void M2ALU_PushEmptyConstructor (unsigned int constype);
     891              : 
     892              : /*
     893              :    PushEmptyArray - pushes an empty array {} onto the ALU stack.
     894              :                     This is expected to be filled in by subsequent
     895              :                     calls to AddElements.
     896              : 
     897              :                     The Stack:
     898              : 
     899              :                     Entry             Exit
     900              : 
     901              :                                                      <- Ptr
     902              :                                       +------------+
     903              :                                       | {}         |
     904              :              Ptr ->                   |------------|
     905              : 
     906              : */
     907              : 
     908              : extern "C" void M2ALU_PushEmptyArray (unsigned int arraytype);
     909              : 
     910              : /*
     911              :    PushEmptyRecord - pushes an empty record {} onto the ALU stack.
     912              :                      This is expected to be filled in by subsequent
     913              :                      calls to AddField.
     914              : 
     915              :                      The Stack:
     916              : 
     917              :                      Entry             Exit
     918              : 
     919              :                                                       <- Ptr
     920              :                                        +------------+
     921              :                                        | {}         |
     922              :               Ptr ->                   |------------|
     923              : 
     924              : */
     925              : 
     926              : extern "C" void M2ALU_PushEmptyRecord (unsigned int recordtype);
     927              : 
     928              : /*
     929              :    ChangeToConstructor - change the top of stack value to a constructor, type.
     930              :                          (Constructor, Set, Array or Record).
     931              : */
     932              : 
     933              : extern "C" void M2ALU_ChangeToConstructor (unsigned int tokenno, unsigned int constype);
     934              : 
     935              : /*
     936              :    IsValueConst - returns true if the memory cell indicated by v
     937              :                   is only defined by constants.  For example
     938              :                   no variables are used in the constructor.
     939              : */
     940              : 
     941              : extern "C" bool M2ALU_IsValueConst (M2ALU_PtrToValue v);
     942              : 
     943              : /*
     944              :    PushTypeOfTree - pushes tree, gcc, to the stack and records the
     945              :                     front end type.
     946              : */
     947              : 
     948              : extern "C" void M2ALU_PushTypeOfTree (unsigned int sym, tree gcc);
     949              : 
     950              : /*
     951              :    New - allocate a PtrToValue. Firstly check the FreeList, if empty call upon New.
     952              : */
     953              : 
     954              : static M2ALU_PtrToValue__opaque New (void);
     955              : 
     956              : /*
     957              :    InitRecord - initialize the non variant fields of, v.  Return v.
     958              : */
     959              : 
     960              : static M2ALU_PtrToValue__opaque InitRecord (M2ALU_PtrToValue__opaque v);
     961              : 
     962              : /*
     963              :    NewRange - assigns, v, to a new area of memory.
     964              : */
     965              : 
     966              : static void NewRange (M2ALU_listOfRange *v);
     967              : 
     968              : /*
     969              :    DisposeRange - adds the list, v, to the free list.
     970              : */
     971              : 
     972              : static void DisposeRange (M2ALU_listOfRange *v);
     973              : 
     974              : /*
     975              :    IsOnFieldFreeList - returns TRUE if, r, is on the FieldFreeList.
     976              : */
     977              : 
     978              : static bool IsOnFieldFreeList (M2ALU_listOfFields r);
     979              : 
     980              : /*
     981              :    IsOnElementFreeList - returns TRUE if, r, is on the ElementFreeList.
     982              : */
     983              : 
     984              : static bool IsOnElementFreeList (M2ALU_listOfElements r);
     985              : 
     986              : /*
     987              :    DisposeFields - adds the list, v, to the free list.
     988              : */
     989              : 
     990              : static void DisposeFields (M2ALU_listOfFields *v);
     991              : 
     992              : /*
     993              :    NewField - adds the list, v, to the free list.
     994              : */
     995              : 
     996              : static void NewField (M2ALU_listOfFields *v);
     997              : 
     998              : /*
     999              :    NewElement - returns a new element record.
    1000              : */
    1001              : 
    1002              : static void NewElement (M2ALU_listOfElements *e);
    1003              : 
    1004              : /*
    1005              :    DisposeElements - returns the list, e, to the free list.
    1006              : */
    1007              : 
    1008              : static void DisposeElements (M2ALU_listOfElements *e);
    1009              : 
    1010              : /*
    1011              :    CheckNotAlreadyOnFreeList - checks to see whether, v, is already on the free list
    1012              :                                and aborts if this is the case.
    1013              : */
    1014              : 
    1015              : static void CheckNotAlreadyOnFreeList (M2ALU_PtrToValue__opaque v);
    1016              : 
    1017              : /*
    1018              :    CheckNotOnStack - checks to see whether, v, is already on the stack
    1019              :                      and aborts if this is the case.
    1020              : */
    1021              : 
    1022              : static void CheckNotOnStack (M2ALU_PtrToValue__opaque v);
    1023              : 
    1024              : /*
    1025              :    Dispose - place, v, onto the FreeList.
    1026              : */
    1027              : 
    1028              : static void Dispose (M2ALU_PtrToValue__opaque v);
    1029              : 
    1030              : /*
    1031              :    AddRange - returns a ListOfRange which is prepended to the front of the current list.
    1032              : */
    1033              : 
    1034              : static M2ALU_listOfRange AddRange (M2ALU_listOfRange head, unsigned int l, unsigned int h);
    1035              : 
    1036              : /*
    1037              :    DupRange - duplicates and returns the list, t.
    1038              : */
    1039              : 
    1040              : static M2ALU_listOfRange DupRange (M2ALU_listOfRange r);
    1041              : 
    1042              : /*
    1043              :    Pop - pops and returns top element from the stack.
    1044              : */
    1045              : 
    1046              : static M2ALU_PtrToValue__opaque Pop (void);
    1047              : 
    1048              : /*
    1049              :    Push - pushes the value onto the stack.
    1050              : */
    1051              : 
    1052              : static void Push (M2ALU_PtrToValue__opaque v);
    1053              : 
    1054              : /*
    1055              :    Reduce - remove the top element of the stack.
    1056              : */
    1057              : 
    1058              : static void Reduce (void);
    1059              : 
    1060              : /*
    1061              :    PrintValue - debugging procedure to display the value on the top of the stack.
    1062              : */
    1063              : 
    1064              : static void PrintValue (void);
    1065              : 
    1066              : /*
    1067              :    DupFields - duplicates the field list in order.
    1068              : */
    1069              : 
    1070              : static M2ALU_listOfFields DupFields (M2ALU_listOfFields f);
    1071              : 
    1072              : /*
    1073              :    DupElements - duplicates the array list in order.
    1074              : */
    1075              : 
    1076              : static M2ALU_listOfElements DupElements (M2ALU_listOfElements f);
    1077              : 
    1078              : /*
    1079              :    IsReal - returns TRUE if a is a REAL number.
    1080              : */
    1081              : 
    1082              : static bool IsReal (DynamicStrings_String a);
    1083              : 
    1084              : /*
    1085              :    IsSolvedGCC - returns TRUE if the value, sym, is solved.
    1086              :                  If TRUE then it also ensures this symbol is
    1087              :                  entered into the double book keeping table
    1088              :                  for GM2 <-> GCC.
    1089              : */
    1090              : 
    1091              : static bool IsSolvedGCC (unsigned int sym);
    1092              : 
    1093              : /*
    1094              :    ConvertIntToReal - converts a INTEGER into a LONGREAL
    1095              : */
    1096              : 
    1097              : static void ConvertIntToReal (void);
    1098              : 
    1099              : /*
    1100              :    EitherReal - returns TRUE if either, Op1, or, Op2, are Real.
    1101              : */
    1102              : 
    1103              : static bool EitherReal (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1104              : 
    1105              : /*
    1106              :    EitherComplex - returns TRUE if either, Op1, or, Op2, are Real.
    1107              : */
    1108              : 
    1109              : static bool EitherComplex (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1110              : 
    1111              : /*
    1112              :    RealAdd - adds two numbers. One of which is a Real.
    1113              : */
    1114              : 
    1115              : static void RealAdd (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1116              : 
    1117              : /*
    1118              :    ComplexAdd - adds two complex numbers.
    1119              : */
    1120              : 
    1121              : static void ComplexAdd (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1122              : 
    1123              : /*
    1124              :    RealSub - subtracts two numbers. One of which is a Real.
    1125              : */
    1126              : 
    1127              : static void RealSub (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1128              : 
    1129              : /*
    1130              :    ComplexSub - subtracts two complex numbers.
    1131              : */
    1132              : 
    1133              : static void ComplexSub (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1134              : 
    1135              : /*
    1136              :    RealMult - multiplies two numbers. One of which is a Real.
    1137              : */
    1138              : 
    1139              : static void RealMult (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1140              : 
    1141              : /*
    1142              :    ComplexMult - multiplies two complex numbers.
    1143              : */
    1144              : 
    1145              : static void ComplexMult (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1146              : 
    1147              : /*
    1148              :    RealDiv - divides two numbers. One of which is a Real.
    1149              : */
    1150              : 
    1151              : static void RealDiv (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1152              : 
    1153              : /*
    1154              :    ComplexDiv - divides two complex numbers.
    1155              : */
    1156              : 
    1157              : static void ComplexDiv (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2);
    1158              : 
    1159              : /*
    1160              :    AreSetsEqual - returns TRUE if sets, op1, and, op2, contain the same
    1161              :                   members.
    1162              : */
    1163              : 
    1164              : static bool AreSetsEqual (unsigned int tokenno, M2ALU_PtrToValue__opaque op1, M2ALU_PtrToValue__opaque op2);
    1165              : 
    1166              : /*
    1167              :    IsSubset - returns TRUE if the set as defined by, s1, is a subset of set, s2.
    1168              : */
    1169              : 
    1170              : static bool IsSubset (unsigned int tokenno, M2ALU_PtrToValue__opaque s1, M2ALU_PtrToValue__opaque s2);
    1171              : 
    1172              : /*
    1173              :    IsSuperset - returns TRUE if the set as defined by, s1, is a superset of set, s2.
    1174              : */
    1175              : 
    1176              : static bool IsSuperset (unsigned int tokenno, M2ALU_PtrToValue__opaque s1, M2ALU_PtrToValue__opaque s2);
    1177              : 
    1178              : /*
    1179              :    cellTypeString - returns a string corresponding to, s.
    1180              : */
    1181              : 
    1182              : static DynamicStrings_String cellTypeString (M2ALU_cellType s);
    1183              : 
    1184              : /*
    1185              :    ToSetValue - converts a list of fields into a list of ranges.
    1186              :                 In effect it turns a generic constructor into
    1187              :                 a set type.
    1188              : */
    1189              : 
    1190              : static M2ALU_listOfRange ToSetValue (M2ALU_listOfFields f);
    1191              : 
    1192              : /*
    1193              :    ToArrayValue - converts a list of fields into an array initialiser.
    1194              :                   In effect it turns a generic constructor into
    1195              :                   an array type.
    1196              : */
    1197              : 
    1198              : static M2ALU_listOfElements ToArrayValue (unsigned int tok, M2ALU_listOfFields f);
    1199              : 
    1200              : /*
    1201              :    CoerseTo - attempts to coerses a cellType, v, into, type, t.
    1202              :               Normally this will be a generic constructors converting
    1203              :               into set or array.
    1204              : */
    1205              : 
    1206              : static M2ALU_PtrToValue__opaque CoerseTo (unsigned int tokenno, M2ALU_cellType t, M2ALU_PtrToValue__opaque v);
    1207              : 
    1208              : /*
    1209              :    AddElementToEnd - appends, e, to the end of list, v.
    1210              : */
    1211              : 
    1212              : static void AddElementToEnd (M2ALU_PtrToValue__opaque v, M2ALU_listOfElements e);
    1213              : 
    1214              : /*
    1215              :    AddFieldToEnd - appends, f, to the end of list, v.
    1216              : */
    1217              : 
    1218              : static void AddFieldToEnd (M2ALU_PtrToValue__opaque v, M2ALU_listOfFields f);
    1219              : 
    1220              : /*
    1221              :    ElementsSolved - returns TRUE if all ranges in the set have been solved.
    1222              : */
    1223              : 
    1224              : static bool ElementsSolved (unsigned int tokenno, M2ALU_listOfRange r);
    1225              : 
    1226              : /*
    1227              :    ArrayElementsSolved - returns TRUE if all ranges in the set have been solved.
    1228              : */
    1229              : 
    1230              : static bool ArrayElementsSolved (M2ALU_listOfElements e);
    1231              : 
    1232              : /*
    1233              :    EvalFieldValues - returns TRUE if all fields in the record have been solved.
    1234              : */
    1235              : 
    1236              : static bool EvalFieldValues (M2ALU_listOfFields e);
    1237              : 
    1238              : /*
    1239              :    Swap - swaps the contents of, i, and, j.
    1240              : */
    1241              : 
    1242              : static void Swap (M2ALU_listOfRange i, M2ALU_listOfRange j);
    1243              : 
    1244              : /*
    1245              :    DisplayElements -
    1246              : */
    1247              : 
    1248              : static void DisplayElements (M2ALU_listOfRange i);
    1249              : 
    1250              : /*
    1251              :    SortElements - sorts the list as defined by, h, into ascending range order.
    1252              :                   The low element is the sort key.
    1253              : */
    1254              : 
    1255              : static void SortElements (unsigned int tokenno, M2ALU_listOfRange h);
    1256              : 
    1257              : /*
    1258              :    CombineElements - given a sorted list determine whether there is any
    1259              :                      overlap in the low..high bounds. If overlap exists
    1260              :                      then remove it.
    1261              : */
    1262              : 
    1263              : static void CombineElements (unsigned int tokenno, M2ALU_listOfRange r);
    1264              : 
    1265              : /*
    1266              :    EvalSetValues - returns TRUE if all elements in this set have been resolved.
    1267              : */
    1268              : 
    1269              : static bool EvalSetValues (unsigned int tokenno, M2ALU_listOfRange r);
    1270              : 
    1271              : /*
    1272              :    Eval - attempts to solve a constructor type.
    1273              : */
    1274              : 
    1275              : static void Eval (unsigned int tokenno, M2ALU_PtrToValue__opaque v);
    1276              : 
    1277              : /*
    1278              :    WalkSetValueDependants -
    1279              : */
    1280              : 
    1281              : static void WalkSetValueDependants (M2ALU_listOfRange r, M2GCCDeclare_WalkAction p);
    1282              : 
    1283              : /*
    1284              :    IsSetValueDependants -
    1285              : */
    1286              : 
    1287              : static bool IsSetValueDependants (M2ALU_listOfRange r, M2GCCDeclare_IsAction q);
    1288              : 
    1289              : /*
    1290              :    WalkFieldValueDependants -
    1291              : */
    1292              : 
    1293              : static void WalkFieldValueDependants (M2ALU_listOfFields f, M2GCCDeclare_WalkAction p);
    1294              : 
    1295              : /*
    1296              :    IsFieldValueDependants -
    1297              : */
    1298              : 
    1299              : static bool IsFieldValueDependants (M2ALU_listOfFields f, M2GCCDeclare_IsAction q);
    1300              : 
    1301              : /*
    1302              :    WalkArrayValueDependants -
    1303              : */
    1304              : 
    1305              : static void WalkArrayValueDependants (M2ALU_listOfElements a, M2GCCDeclare_WalkAction p);
    1306              : 
    1307              : /*
    1308              :    IsArrayValueDependants -
    1309              : */
    1310              : 
    1311              : static bool IsArrayValueDependants (M2ALU_listOfElements a, M2GCCDeclare_IsAction q);
    1312              : 
    1313              : /*
    1314              :    DefinedByConstants - returns TRUE if the value, v, is defined by constants.
    1315              :                         It assigns, v^.areAllConstants, with the result.
    1316              : */
    1317              : 
    1318              : static bool DefinedByConstants (M2ALU_PtrToValue__opaque v);
    1319              : 
    1320              : /*
    1321              :    rangeConstant - returns TRUE if all the range entities are constant.
    1322              : */
    1323              : 
    1324              : static bool rangeConstant (M2ALU_listOfRange r);
    1325              : 
    1326              : /*
    1327              :    fieldsConstant - returns TRUE if all the field entities are constant.
    1328              : */
    1329              : 
    1330              : static bool fieldsConstant (M2ALU_listOfFields f);
    1331              : 
    1332              : /*
    1333              :    arrayConstant - returns TRUE if the, element, and, by, components
    1334              :                    of an array constructor are constant.
    1335              : */
    1336              : 
    1337              : static bool arrayConstant (M2ALU_listOfElements e);
    1338              : 
    1339              : /*
    1340              :    FindValueEnum -
    1341              : */
    1342              : 
    1343              : static void FindValueEnum (unsigned int field);
    1344              : 
    1345              : /*
    1346              :    Val - returns a GCC symbol enumeration or a GCC constant which has, value, and which is
    1347              :          of type, type.
    1348              : */
    1349              : 
    1350              : static unsigned int Val (unsigned int tokenno, unsigned int type, tree value);
    1351              : 
    1352              : /*
    1353              :    DupConst - duplicates and returns a constant, sym, but adds, offset to its value.
    1354              : */
    1355              : 
    1356              : static unsigned int DupConst (unsigned int tokenno, unsigned int sym, int offset);
    1357              : 
    1358              : /*
    1359              :    DupConstAndAdd - duplicates and returns a constant, sym,
    1360              :                     but adds the symbol, extra.
    1361              : */
    1362              : 
    1363              : static unsigned int DupConstAndAdd (unsigned int tokenno, unsigned int sym, tree extra);
    1364              : 
    1365              : /*
    1366              :    DupConstAndAddMod - duplicates and returns a constant, sym,
    1367              :                        but adds the symbol, extra, and ensures that
    1368              :                        the result in within limits: min..max using
    1369              :                        modulo arithmetic.
    1370              : */
    1371              : 
    1372              : static unsigned int DupConstAndAddMod (unsigned int tokenno, unsigned int sym, tree extra, unsigned int l, unsigned int h);
    1373              : 
    1374              : /*
    1375              :    Remove - removes, v, from list, h.
    1376              : */
    1377              : 
    1378              : static void Remove (M2ALU_listOfRange *h, M2ALU_listOfRange v);
    1379              : 
    1380              : /*
    1381              :    RemoveBit - remove bit, op1, from range, v, on list, h.
    1382              : */
    1383              : 
    1384              : static void RemoveBit (unsigned int tokenno, M2ALU_listOfRange *h, M2ALU_listOfRange v, unsigned int op1);
    1385              : 
    1386              : /*
    1387              :    PerformSubBit -
    1388              : */
    1389              : 
    1390              : static void PerformSubBit (unsigned int tokenno, M2ALU_listOfRange *h, unsigned int op1);
    1391              : 
    1392              : /*
    1393              :    PerformSetIn - returns TRUE if op1 is in set.
    1394              : */
    1395              : 
    1396              : static bool PerformSetIn (unsigned int tokenno, unsigned int op1, M2ALU_listOfRange h);
    1397              : 
    1398              : /*
    1399              :    SetOp - perform the function doOp on the top two elements of the stack.
    1400              : */
    1401              : 
    1402              : static void SetOp (unsigned int tokenno, M2ALU_DoSetProcedure doOp);
    1403              : 
    1404              : /*
    1405              :    PerformOr - performs a logical OR between the two ranges.
    1406              :                The ranges, r1, r2, are destroyed.
    1407              : */
    1408              : 
    1409              : static M2ALU_listOfRange PerformOr (unsigned int tokenno, M2ALU_listOfRange r1, M2ALU_listOfRange r2);
    1410              : 
    1411              : /*
    1412              :    Min - returns the symbol which has the least value.
    1413              : */
    1414              : 
    1415              : static unsigned int Min (unsigned int tokenno, unsigned int a, unsigned int b);
    1416              : 
    1417              : /*
    1418              :    Max - returns the symbol which has the greatest value.
    1419              : */
    1420              : 
    1421              : static unsigned int Max (unsigned int tokenno, unsigned int a, unsigned int b);
    1422              : 
    1423              : /*
    1424              :    IsRangeIntersection - returns TRUE if ranges, r1, and, r2, intersect.
    1425              : */
    1426              : 
    1427              : static bool IsRangeIntersection (unsigned int tokenno, M2ALU_listOfRange r1, M2ALU_listOfRange r2);
    1428              : 
    1429              : /*
    1430              :    IsRangeLess - returns TRUE if r1^.low is < r2^.low
    1431              : */
    1432              : 
    1433              : static bool IsRangeLess (unsigned int tokenno, M2ALU_listOfRange r1, M2ALU_listOfRange r2);
    1434              : 
    1435              : /*
    1436              :    MinTree - returns the tree symbol which has the least value.
    1437              : */
    1438              : 
    1439              : static tree MinTree (unsigned int tokenno, tree a, tree b);
    1440              : 
    1441              : /*
    1442              :    MaxTree - returns the symbol which has the greatest value.
    1443              : */
    1444              : 
    1445              : static tree MaxTree (unsigned int tokenno, tree a, tree b);
    1446              : 
    1447              : /*
    1448              :    IsIntersectionTree - returns TRUE if ranges, a..b, and, c..d, intersect.
    1449              : */
    1450              : 
    1451              : static bool IsIntersectionTree (unsigned int tokenno, tree a, tree b, tree c, tree d);
    1452              : 
    1453              : /*
    1454              :    SubTree - returns the tree value containing (a-b)
    1455              : */
    1456              : 
    1457              : static tree SubTree (tree a, tree b);
    1458              : 
    1459              : /*
    1460              :    PerformAnd - performs a logical AND between the two ranges.
    1461              :                 The ranges, r1, r2, are unaltered.
    1462              : */
    1463              : 
    1464              : static M2ALU_listOfRange PerformAnd (unsigned int tokenno, M2ALU_listOfRange r1, M2ALU_listOfRange r2);
    1465              : 
    1466              : /*
    1467              :    ConstructLargeOrSmallSet - generates a constant representing the set value of the symbol, sym.
    1468              :                               We manufacture the constant by using a initialization
    1469              :                               structure of cardinals.
    1470              : 
    1471              :                               { (cardinal), (cardinal) etc }
    1472              : */
    1473              : 
    1474              : static tree ConstructLargeOrSmallSet (unsigned int tokenno, M2ALU_PtrToValue__opaque v, unsigned int low, unsigned int high);
    1475              : 
    1476              : /*
    1477              :    BuildArrayByteset - v is the PtrToValue.
    1478              :                        low and high are the limits of the subrange.
    1479              : */
    1480              : 
    1481              : static tree BuildArrayByteset (unsigned int tokenno, M2ALU_PtrToValue__opaque v, tree low, tree high);
    1482              : 
    1483              : /*
    1484              :    ConvertConstToType - returns a Tree containing an initialiser,
    1485              :                         init, ready to be assigned to a record or
    1486              :                         array constructor.
    1487              : */
    1488              : 
    1489              : static tree ConvertConstToType (unsigned int tokenno, unsigned int field, unsigned int init);
    1490              : 
    1491              : /*
    1492              :    ConstructRecordConstant - builds a struct initializer, as defined by, v.
    1493              : */
    1494              : 
    1495              : static tree ConstructRecordConstant (unsigned int tokenno, M2ALU_PtrToValue__opaque v);
    1496              : 
    1497              : /*
    1498              :    GetConstructorField - returns a symbol containing the constructor field, i.
    1499              : */
    1500              : 
    1501              : static unsigned int GetConstructorField (M2ALU_PtrToValue__opaque v, unsigned int i);
    1502              : 
    1503              : /*
    1504              :    GetConstructorElement - returns a symbol containing the array constructor element, i.
    1505              : */
    1506              : 
    1507              : static unsigned int GetConstructorElement (unsigned int tokenno, M2ALU_PtrToValue__opaque v, unsigned int i);
    1508              : 
    1509              : /*
    1510              :    IsString - returns TRUE if sym is an ARRAY [..] OF CHAR
    1511              : */
    1512              : 
    1513              : static bool IsString (unsigned int sym);
    1514              : 
    1515              : /*
    1516              :    StringFitsArray -
    1517              : */
    1518              : 
    1519              : static bool StringFitsArray (unsigned int arrayType, unsigned int el, unsigned int tokenno);
    1520              : 
    1521              : /*
    1522              :    GetArrayLimits -
    1523              : */
    1524              : 
    1525              : static void GetArrayLimits (unsigned int array, unsigned int *low, unsigned int *high);
    1526              : 
    1527              : /*
    1528              :    InitialiseArrayOfCharWithString -
    1529              : */
    1530              : 
    1531              : static tree InitialiseArrayOfCharWithString (unsigned int tokenno, void * cons, unsigned int el, unsigned int baseType, unsigned int arrayType);
    1532              : 
    1533              : /*
    1534              :    CheckElementString -
    1535              : */
    1536              : 
    1537              : static tree CheckElementString (unsigned int el, unsigned int arrayType, unsigned int tokenno);
    1538              : 
    1539              : /*
    1540              :    InitialiseArrayWith -
    1541              : */
    1542              : 
    1543              : static tree InitialiseArrayWith (unsigned int tokenno, void * cons, M2ALU_PtrToValue__opaque v, unsigned int el, unsigned int high, unsigned int low, unsigned int arrayType);
    1544              : 
    1545              : /*
    1546              :    CheckGetCharFromString - return TRUE if a char from the position arrayIndex in the list of
    1547              :                             constDecl elements can be extracted.  The character is returned
    1548              :                             in value.
    1549              : */
    1550              : 
    1551              : static bool CheckGetCharFromString (location_t location, unsigned int tokenno, M2ALU_PtrToValue__opaque constDecl, unsigned int consType, unsigned int arrayIndex, tree *value);
    1552              : 
    1553              : /*
    1554              :    InitialiseArrayOfCharWith -
    1555              : */
    1556              : 
    1557              : static tree InitialiseArrayOfCharWith (unsigned int tokenno, void * cons, M2ALU_PtrToValue__opaque constDecl, unsigned int el, unsigned int high, unsigned int low, unsigned int consType, unsigned int arrayType);
    1558              : 
    1559              : /*
    1560              :    ConstructArrayConstant - builds a struct initializer, as defined by, v.
    1561              : */
    1562              : 
    1563              : static tree ConstructArrayConstant (unsigned int tokenno, M2ALU_PtrToValue__opaque v);
    1564              : 
    1565              : /*
    1566              :    BuildBitset - given a set, v, construct the bitmask for its
    1567              :                  constant value which lie in the range low..high.
    1568              : */
    1569              : 
    1570              : static tree BuildBitset (unsigned int tokenno, M2ALU_PtrToValue__opaque v, tree low, tree high);
    1571              : 
    1572              : /*
    1573              :    BuildByte - given a set v construct the bitmask for its
    1574              :                constant value which lie in the range low..high.
    1575              : */
    1576              : 
    1577              : static tree BuildByte (unsigned int tokenno, M2ALU_PtrToValue__opaque v, tree low, tree high);
    1578              : 
    1579              : /*
    1580              :    CheckOverflow - tests to see whether the tree, t, has caused
    1581              :                    an overflow error and if so it generates an
    1582              :                    error message.
    1583              : */
    1584              : 
    1585              : static void CheckOverflow (unsigned int tokenno, tree t);
    1586              : 
    1587              : /*
    1588              :    PushGCCArrayTree - pushes a gcc tree value onto the ALU stack.
    1589              : */
    1590              : 
    1591              : static void PushGCCArrayTree (tree gcc, unsigned int t);
    1592              : 
    1593              : /*
    1594              :    PushGCCSetTree - pushes a gcc tree value onto the ALU stack.
    1595              : */
    1596              : 
    1597              : static void PushGCCSetTree (tree gcc, unsigned int t);
    1598              : 
    1599              : /*
    1600              :    PushGCCRecordTree - pushes a gcc tree value onto the ALU stack.
    1601              : */
    1602              : 
    1603              : static void PushGCCRecordTree (tree gcc, unsigned int t);
    1604              : 
    1605              : /*
    1606              :    Init - initialises the stack and the free list.
    1607              : */
    1608              : 
    1609              : static void Init (void);
    1610              : 
    1611              : 
    1612              : /*
    1613              :    New - allocate a PtrToValue. Firstly check the FreeList, if empty call upon New.
    1614              : */
    1615              : 
    1616     85201673 : static M2ALU_PtrToValue__opaque New (void)
    1617              : {
    1618     85201673 :   M2ALU_PtrToValue__opaque v;
    1619              : 
    1620     85201673 :   if (FreeList == NULL)
    1621              :     {
    1622     49429334 :       Storage_ALLOCATE ((void **) &v, sizeof (M2ALU_cell));
    1623     49429334 :       M2Diagnostic_MemIncr (StackMemDiag, 1, 1);
    1624     49429334 :       M2Diagnostic_MemIncr (StackMemDiag, 2, sizeof ((*v)));
    1625              :     }
    1626              :   else
    1627              :     {
    1628     35772339 :       v = FreeList;
    1629     35772339 :       FreeList = FreeList->next;
    1630              :     }
    1631     85201673 :   v->numberValue = NULL;
    1632    170403346 :   return InitRecord (v);
    1633              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1634              :   __builtin_unreachable ();
    1635              : }
    1636              : 
    1637              : 
    1638              : /*
    1639              :    InitRecord - initialize the non variant fields of, v.  Return v.
    1640              : */
    1641              : 
    1642     85201673 : static M2ALU_PtrToValue__opaque InitRecord (M2ALU_PtrToValue__opaque v)
    1643              : {
    1644     85201673 :   v->location = m2linemap_UnknownLocation ();
    1645     85201673 :   v->areAllConstants = false;
    1646     85201673 :   v->solved = false;
    1647     85201673 :   v->constructorType = SymbolTable_NulSym;
    1648     85201673 :   v->numberValue = NULL;
    1649     85201673 :   return v;
    1650              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1651              :   __builtin_unreachable ();
    1652              : }
    1653              : 
    1654              : 
    1655              : /*
    1656              :    NewRange - assigns, v, to a new area of memory.
    1657              : */
    1658              : 
    1659       735338 : static void NewRange (M2ALU_listOfRange *v)
    1660              : {
    1661       735338 :   if (RangeFreeList == NULL)
    1662              :     {
    1663       718602 :       Storage_ALLOCATE ((void **) &(*v), sizeof (M2ALU_rList));
    1664       718602 :       if ((*v) == NULL)
    1665              :         {
    1666            0 :           M2Error_InternalError ((const char *) "out of memory error", 19);
    1667              :         }
    1668       718602 :       M2Diagnostic_MemIncr (RangeMemDiag, 1, 1);
    1669       718602 :       M2Diagnostic_MemIncr (RangeMemDiag, 2, sizeof ((*(*v))));
    1670              :     }
    1671              :   else
    1672              :     {
    1673        16736 :       (*v) = RangeFreeList;
    1674        16736 :       RangeFreeList = RangeFreeList->next;
    1675              :     }
    1676       735338 : }
    1677              : 
    1678              : 
    1679              : /*
    1680              :    DisposeRange - adds the list, v, to the free list.
    1681              : */
    1682              : 
    1683        95150 : static void DisposeRange (M2ALU_listOfRange *v)
    1684              : {
    1685        95150 :   M2ALU_listOfRange r;
    1686              : 
    1687        95150 :   if ((*v) != NULL)
    1688              :     {
    1689              :       r = (*v);
    1690        16754 :       while ((r != NULL) && (r->next != NULL))
    1691              :         {
    1692              :           r = r->next;
    1693              :         }
    1694        14438 :       if (r != NULL)
    1695              :         {
    1696        14438 :           r->next = RangeFreeList;
    1697              :         }
    1698        14438 :       RangeFreeList = (*v);
    1699        14438 :       (*v) = NULL;
    1700              :     }
    1701        95150 : }
    1702              : 
    1703              : 
    1704              : /*
    1705              :    IsOnFieldFreeList - returns TRUE if, r, is on the FieldFreeList.
    1706              : */
    1707              : 
    1708         7388 : static bool IsOnFieldFreeList (M2ALU_listOfFields r)
    1709              : {
    1710         7388 :   M2ALU_listOfFields s;
    1711              : 
    1712         7388 :   s = FieldFreeList;
    1713         7388 :   while (s != NULL)
    1714              :     {
    1715            0 :       if (s == r)
    1716              :         {
    1717              :           return true;
    1718              :         }
    1719              :       else
    1720              :         {
    1721            0 :           s = s->next;
    1722              :         }
    1723              :     }
    1724              :   return false;
    1725              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1726              :   __builtin_unreachable ();
    1727              : }
    1728              : 
    1729              : 
    1730              : /*
    1731              :    IsOnElementFreeList - returns TRUE if, r, is on the ElementFreeList.
    1732              : */
    1733              : 
    1734         5572 : static bool IsOnElementFreeList (M2ALU_listOfElements r)
    1735              : {
    1736         5572 :   M2ALU_listOfElements s;
    1737              : 
    1738         5572 :   s = ElementFreeList;
    1739         5572 :   while (s != NULL)
    1740              :     {
    1741            0 :       if (s == r)
    1742              :         {
    1743              :           return true;
    1744              :         }
    1745              :       else
    1746              :         {
    1747            0 :           s = s->next;
    1748              :         }
    1749              :     }
    1750              :   return false;
    1751              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1752              :   __builtin_unreachable ();
    1753              : }
    1754              : 
    1755              : 
    1756              : /*
    1757              :    DisposeFields - adds the list, v, to the free list.
    1758              : */
    1759              : 
    1760        79428 : static void DisposeFields (M2ALU_listOfFields *v)
    1761              : {
    1762        79428 :   M2ALU_listOfFields r;
    1763              : 
    1764        79428 :   if ((*v) != NULL)
    1765              :     {
    1766              :       r = (*v);
    1767         9768 :       while (r->next != NULL)
    1768              :         {
    1769        14776 :           M2Debug_Assert (! (IsOnFieldFreeList (r)));
    1770         7388 :           r = r->next;
    1771              :         }
    1772         2380 :       r->next = FieldFreeList;
    1773         2380 :       FieldFreeList = (*v);
    1774         2380 :       (*v) = NULL;
    1775              :     }
    1776        79428 : }
    1777              : 
    1778              : 
    1779              : /*
    1780              :    NewField - adds the list, v, to the free list.
    1781              : */
    1782              : 
    1783      3189774 : static void NewField (M2ALU_listOfFields *v)
    1784              : {
    1785      3189774 :   if (FieldFreeList == NULL)
    1786              :     {
    1787              :       /* avoid dangling else.  */
    1788      3180042 :       Storage_ALLOCATE ((void **) &(*v), sizeof (M2ALU_fList));
    1789      3180042 :       if ((*v) == NULL)
    1790              :         {
    1791            0 :           M2Error_InternalError ((const char *) "out of memory error", 19);
    1792              :         }
    1793              :     }
    1794              :   else
    1795              :     {
    1796         9732 :       (*v) = FieldFreeList;
    1797         9732 :       FieldFreeList = FieldFreeList->next;
    1798              :     }
    1799      3189774 : }
    1800              : 
    1801              : 
    1802              : /*
    1803              :    NewElement - returns a new element record.
    1804              : */
    1805              : 
    1806      1692394 : static void NewElement (M2ALU_listOfElements *e)
    1807              : {
    1808      1692394 :   if (ElementFreeList == NULL)
    1809              :     {
    1810              :       /* avoid dangling else.  */
    1811      1686032 :       Storage_ALLOCATE ((void **) &(*e), sizeof (M2ALU_eList));
    1812      1686032 :       if ((*e) == NULL)
    1813              :         {
    1814            0 :           M2Error_InternalError ((const char *) "out of memory error", 19);
    1815              :         }
    1816              :     }
    1817              :   else
    1818              :     {
    1819         6362 :       (*e) = ElementFreeList;
    1820         6362 :       ElementFreeList = ElementFreeList->next;
    1821              :     }
    1822      1692394 : }
    1823              : 
    1824              : 
    1825              : /*
    1826              :    DisposeElements - returns the list, e, to the free list.
    1827              : */
    1828              : 
    1829         8430 : static void DisposeElements (M2ALU_listOfElements *e)
    1830              : {
    1831         8430 :   M2ALU_listOfElements r;
    1832              : 
    1833         8430 :   if ((*e) != NULL)
    1834              :     {
    1835              :       r = (*e);
    1836         6362 :       while (r->next != NULL)
    1837              :         {
    1838        11144 :           M2Debug_Assert (! (IsOnElementFreeList (r)));
    1839         5572 :           r = r->next;
    1840              :         }
    1841          790 :       r->next = ElementFreeList;
    1842          790 :       ElementFreeList = (*e);
    1843          790 :       (*e) = NULL;
    1844              :     }
    1845         8430 : }
    1846              : 
    1847              : 
    1848              : /*
    1849              :    CheckNotAlreadyOnFreeList - checks to see whether, v, is already on the free list
    1850              :                                and aborts if this is the case.
    1851              : */
    1852              : 
    1853    146550871 : static void CheckNotAlreadyOnFreeList (M2ALU_PtrToValue__opaque v)
    1854              : {
    1855    146550871 :   M2ALU_PtrToValue__opaque l;
    1856              : 
    1857    146550871 :   if (DebugGarbage)
    1858              :     {
    1859    146550871 :       l = FreeList;
    1860    257226349 :       while (l != NULL)
    1861              :         {
    1862    110675478 :           if (l == v)
    1863              :             {
    1864            0 :               M2Error_InternalError ((const char *) "value is already on the free list", 33);
    1865              :             }
    1866    110675478 :           l = l->next;
    1867              :         }
    1868              :     }
    1869    146550871 : }
    1870              : 
    1871              : 
    1872              : /*
    1873              :    CheckNotOnStack - checks to see whether, v, is already on the stack
    1874              :                      and aborts if this is the case.
    1875              : */
    1876              : 
    1877     78290100 : static void CheckNotOnStack (M2ALU_PtrToValue__opaque v)
    1878              : {
    1879     78290100 :   M2ALU_PtrToValue__opaque l;
    1880              : 
    1881     78290100 :   if (DebugGarbage)
    1882              :     {
    1883     78290100 :       l = TopOfStack;
    1884    119466645 :       while (l != NULL)
    1885              :         {
    1886     41176545 :           if (l == v)
    1887              :             {
    1888            0 :               M2Error_InternalError ((const char *) "value is already on the stack", 29);
    1889              :             }
    1890     41176545 :           l = l->next;
    1891              :         }
    1892              :     }
    1893     78290100 : }
    1894              : 
    1895              : 
    1896              : /*
    1897              :    Dispose - place, v, onto the FreeList.
    1898              : */
    1899              : 
    1900     35800395 : static void Dispose (M2ALU_PtrToValue__opaque v)
    1901              : {
    1902     35800395 :   CheckNotAlreadyOnFreeList (v);
    1903     35800395 :   CheckNotOnStack (v);
    1904     35800395 :   switch (v->type)
    1905              :     {
    1906        91814 :       case M2ALU_set:
    1907        91814 :         DisposeRange (&v->setValue);
    1908        91814 :         break;
    1909              : 
    1910        45252 :       case M2ALU_constructor:
    1911        45252 :       case M2ALU_record:
    1912        45252 :         DisposeFields (&v->fieldValues);
    1913        45252 :         break;
    1914              : 
    1915         8430 :       case M2ALU_array:
    1916         8430 :         DisposeElements (&v->arrayValues);
    1917         8430 :         break;
    1918              : 
    1919              : 
    1920              :       default:
    1921              :         break;
    1922              :     }
    1923     35800395 :   v->next = FreeList;
    1924     35800395 :   FreeList = v;
    1925     35800395 : }
    1926              : 
    1927              : 
    1928              : /*
    1929              :    AddRange - returns a ListOfRange which is prepended to the front of the current list.
    1930              : */
    1931              : 
    1932       735338 : static M2ALU_listOfRange AddRange (M2ALU_listOfRange head, unsigned int l, unsigned int h)
    1933              : {
    1934       735338 :   M2ALU_listOfRange r;
    1935              : 
    1936            0 :   NewRange (&r);
    1937       735338 :   r->low = l;
    1938       735338 :   r->high = h;
    1939       735338 :   r->next = head;
    1940       735338 :   return r;
    1941              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1942              :   __builtin_unreachable ();
    1943              : }
    1944              : 
    1945              : 
    1946              : /*
    1947              :    DupRange - duplicates and returns the list, t.
    1948              : */
    1949              : 
    1950       558770 : static M2ALU_listOfRange DupRange (M2ALU_listOfRange r)
    1951              : {
    1952       558770 :   M2ALU_listOfRange s;
    1953              : 
    1954       558770 :   s = NULL;
    1955      1281958 :   while (r != NULL)
    1956              :     {
    1957       723188 :       s = AddRange (s, r->low, r->high);
    1958       723188 :       r = r->next;
    1959              :     }
    1960       558770 :   return s;
    1961              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1962              :   __builtin_unreachable ();
    1963              : }
    1964              : 
    1965              : 
    1966              : /*
    1967              :    Pop - pops and returns top element from the stack.
    1968              : */
    1969              : 
    1970     42486085 : static M2ALU_PtrToValue__opaque Pop (void)
    1971              : {
    1972     42486085 :   M2ALU_PtrToValue__opaque v;
    1973              : 
    1974     42486085 :   if (TopOfStack == NULL)
    1975              :     {
    1976            0 :       M2Error_InternalError ((const char *) "stack underflow error", 21);
    1977              :     }
    1978              :   else
    1979              :     {
    1980     42486085 :       v = TopOfStack;
    1981     42486085 :       TopOfStack = TopOfStack->next;
    1982              :     }
    1983     42486085 :   CheckNotAlreadyOnFreeList (v);
    1984     42486085 :   return v;
    1985              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1986              :   __builtin_unreachable ();
    1987              : }
    1988              : 
    1989              : 
    1990              : /*
    1991              :    Push - pushes the value onto the stack.
    1992              : */
    1993              : 
    1994     42489705 : static void Push (M2ALU_PtrToValue__opaque v)
    1995              : {
    1996     42489705 :   CheckNotAlreadyOnFreeList (v);
    1997     42489705 :   CheckNotOnStack (v);
    1998     42489705 :   v->next = TopOfStack;
    1999     42489705 :   TopOfStack = v;
    2000     42489705 : }
    2001              : 
    2002              : 
    2003              : /*
    2004              :    Reduce - remove the top element of the stack.
    2005              : */
    2006              : 
    2007            0 : static void Reduce (void)
    2008              : {
    2009            0 :   Dispose (Pop ());
    2010            0 : }
    2011              : 
    2012              : 
    2013              : /*
    2014              :    PrintValue - debugging procedure to display the value on the top of the stack.
    2015              : */
    2016              : 
    2017            0 : static void PrintValue (void)
    2018              : {
    2019            0 :   M2ALU_PtrToValue__opaque v;
    2020              : 
    2021            0 :   v = Pop ();
    2022            0 :   if (v->type == M2ALU_integer)
    2023              :     {
    2024            0 :       m2misc_DebugTree (v->numberValue);
    2025              :     }
    2026            0 :   Push (v);
    2027            0 : }
    2028              : 
    2029              : 
    2030              : /*
    2031              :    DupFields - duplicates the field list in order.
    2032              : */
    2033              : 
    2034       772908 : static M2ALU_listOfFields DupFields (M2ALU_listOfFields f)
    2035              : {
    2036       772908 :   M2ALU_listOfFields p;
    2037       772908 :   M2ALU_listOfFields q;
    2038       772908 :   M2ALU_listOfFields l;
    2039              : 
    2040       772908 :   p = NULL;
    2041       772908 :   l = NULL;
    2042      3953178 :   while (f != NULL)
    2043              :     {
    2044      3180270 :       NewField (&q);
    2045      3180270 :       if (p == NULL)
    2046              :         {
    2047       770626 :           p = q;
    2048              :         }
    2049      3180270 :       q->field = f->field;
    2050      3180270 :       q->next = NULL;
    2051      3180270 :       if (l != NULL)
    2052              :         {
    2053      2409644 :           l->next = q;
    2054              :         }
    2055      3180270 :       l = q;
    2056      3180270 :       f = f->next;
    2057              :     }
    2058       772908 :   return p;
    2059              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2060              :   __builtin_unreachable ();
    2061              : }
    2062              : 
    2063              : 
    2064              : /*
    2065              :    DupElements - duplicates the array list in order.
    2066              : */
    2067              : 
    2068       166252 : static M2ALU_listOfElements DupElements (M2ALU_listOfElements f)
    2069              : {
    2070       166252 :   M2ALU_listOfElements p;
    2071       166252 :   M2ALU_listOfElements q;
    2072       166252 :   M2ALU_listOfElements l;
    2073              : 
    2074       166252 :   p = NULL;
    2075       166252 :   l = NULL;
    2076      1854378 :   while (f != NULL)
    2077              :     {
    2078      1688126 :       NewElement (&q);
    2079      1688126 :       if (p == NULL)
    2080              :         {
    2081       165756 :           p = q;
    2082              :         }
    2083      1688126 :       q->element = f->element;
    2084      1688126 :       q->by = f->by;
    2085      1688126 :       q->next = NULL;
    2086      1688126 :       if (l != NULL)
    2087              :         {
    2088      1522370 :           l->next = q;
    2089              :         }
    2090      1688126 :       l = q;
    2091      1688126 :       f = f->next;
    2092              :     }
    2093       166252 :   return p;
    2094              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2095              :   __builtin_unreachable ();
    2096              : }
    2097              : 
    2098              : 
    2099              : /*
    2100              :    IsReal - returns TRUE if a is a REAL number.
    2101              : */
    2102              : 
    2103       487693 : static bool IsReal (DynamicStrings_String a)
    2104              : {
    2105            0 :   return (DynamicStrings_Index (a, '.', 0)) != -1;
    2106              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2107              :   __builtin_unreachable ();
    2108              : }
    2109              : 
    2110              : 
    2111              : /*
    2112              :    IsSolvedGCC - returns TRUE if the value, sym, is solved.
    2113              :                  If TRUE then it also ensures this symbol is
    2114              :                  entered into the double book keeping table
    2115              :                  for GM2 <-> GCC.
    2116              : */
    2117              : 
    2118        42558 : static bool IsSolvedGCC (unsigned int sym)
    2119              : {
    2120        42558 :   if (SymbolTable_IsValueSolved (sym))
    2121              :     {
    2122        42552 :       if (! (SymbolConversion_GccKnowsAbout (sym)))
    2123              :         {
    2124         3070 :           M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), sym);
    2125              :         }
    2126        42552 :       return true;
    2127              :     }
    2128              :   else
    2129              :     {
    2130              :       return false;
    2131              :     }
    2132              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2133              :   __builtin_unreachable ();
    2134              : }
    2135              : 
    2136              : 
    2137              : /*
    2138              :    ConvertIntToReal - converts a INTEGER into a LONGREAL
    2139              : */
    2140              : 
    2141            0 : static void ConvertIntToReal (void)
    2142              : {
    2143            0 :   M2ALU_PtrToValue__opaque v;
    2144              : 
    2145            0 :   v = Pop ();
    2146            0 :   if (v->type == M2ALU_integer)
    2147              :     {
    2148            0 :       v->numberValue = m2convert_ConvertConstantAndCheck (v->location, m2type_GetLongRealType (), v->numberValue);
    2149            0 :       v->type = M2ALU_real;
    2150            0 :       v->areAllConstants = true;
    2151            0 :       v->solved = true;
    2152              :     }
    2153              :   else
    2154              :     {
    2155            0 :       M2Error_InternalError ((const char *) "expecting an INTEGER number", 27);
    2156              :     }
    2157            0 :   Push (v);
    2158            0 : }
    2159              : 
    2160              : 
    2161              : /*
    2162              :    EitherReal - returns TRUE if either, Op1, or, Op2, are Real.
    2163              : */
    2164              : 
    2165       912972 : static bool EitherReal (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2166              : {
    2167       912972 :   return (Op1->type == M2ALU_real) || (Op2->type == M2ALU_real);
    2168              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2169              :   __builtin_unreachable ();
    2170              : }
    2171              : 
    2172              : 
    2173              : /*
    2174              :    EitherComplex - returns TRUE if either, Op1, or, Op2, are Real.
    2175              : */
    2176              : 
    2177       912972 : static bool EitherComplex (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2178              : {
    2179       912972 :   return (Op1->type == M2ALU_complex) || (Op2->type == M2ALU_complex);
    2180              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2181              :   __builtin_unreachable ();
    2182              : }
    2183              : 
    2184              : 
    2185              : /*
    2186              :    RealAdd - adds two numbers. One of which is a Real.
    2187              : */
    2188              : 
    2189            0 : static void RealAdd (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2190              : {
    2191            0 :   M2ALU_PtrToValue__opaque Temp;
    2192              : 
    2193            0 :   if (Op1->type == M2ALU_integer)
    2194              :     {
    2195            0 :       Push (Op1);
    2196            0 :       ConvertIntToReal ();
    2197            0 :       Op1 = Pop ();
    2198              :     }
    2199            0 :   if (Op2->type == M2ALU_integer)
    2200              :     {
    2201            0 :       Push (Op2);
    2202            0 :       ConvertIntToReal ();
    2203            0 :       Op2 = Pop ();
    2204              :     }
    2205            0 :   Temp = New ();
    2206            0 :   Temp->location = Op1->location;
    2207            0 :   Temp->numberValue = m2expr_BuildAdd (Temp->location, Op1->numberValue, Op2->numberValue, false);
    2208            0 :   Temp->type = M2ALU_real;
    2209            0 :   Temp->solved = true;
    2210            0 :   Push (Temp);
    2211            0 : }
    2212              : 
    2213              : 
    2214              : /*
    2215              :    ComplexAdd - adds two complex numbers.
    2216              : */
    2217              : 
    2218            0 : static void ComplexAdd (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2219              : {
    2220            0 :   M2ALU_PtrToValue__opaque Temp;
    2221              : 
    2222            0 :   if ((Op1->type == M2ALU_complex) && (Op2->type == M2ALU_complex))
    2223              :     {
    2224            0 :       Temp = New ();
    2225            0 :       Temp->location = Op1->location;
    2226            0 :       Temp->numberValue = m2expr_BuildAdd (Temp->location, Op1->numberValue, Op2->numberValue, false);
    2227            0 :       Temp->type = M2ALU_complex;
    2228            0 :       Temp->solved = true;
    2229            0 :       Push (Temp);
    2230              :     }
    2231              :   else
    2232              :     {
    2233            0 :       M2Error_InternalError ((const char *) "expecting both operands to be of type COMPLEX", 45);
    2234              :     }
    2235            0 : }
    2236              : 
    2237              : 
    2238              : /*
    2239              :    RealSub - subtracts two numbers. One of which is a Real.
    2240              : */
    2241              : 
    2242            0 : static void RealSub (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2243              : {
    2244            0 :   M2ALU_PtrToValue__opaque Temp;
    2245              : 
    2246            0 :   if (Op1->type == M2ALU_integer)
    2247              :     {
    2248            0 :       Push (Op1);
    2249            0 :       ConvertIntToReal ();
    2250            0 :       Op1 = Pop ();
    2251              :     }
    2252            0 :   if (Op2->type == M2ALU_integer)
    2253              :     {
    2254            0 :       Push (Op2);
    2255            0 :       ConvertIntToReal ();
    2256            0 :       Op2 = Pop ();
    2257              :     }
    2258            0 :   Temp = New ();
    2259            0 :   Temp->location = Op1->location;
    2260            0 :   Temp->numberValue = m2expr_BuildSub (Temp->location, Op2->numberValue, Op1->numberValue, false);
    2261            0 :   Temp->type = M2ALU_real;
    2262            0 :   Temp->solved = true;
    2263            0 :   Push (Temp);
    2264            0 : }
    2265              : 
    2266              : 
    2267              : /*
    2268              :    ComplexSub - subtracts two complex numbers.
    2269              : */
    2270              : 
    2271            0 : static void ComplexSub (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2272              : {
    2273            0 :   M2ALU_PtrToValue__opaque Temp;
    2274              : 
    2275            0 :   if ((Op1->type == M2ALU_complex) && (Op2->type == M2ALU_complex))
    2276              :     {
    2277            0 :       Temp = New ();
    2278            0 :       Temp->location = Op1->location;
    2279            0 :       Temp->numberValue = m2expr_BuildSub (Temp->location, Op2->numberValue, Op1->numberValue, false);
    2280            0 :       Temp->type = M2ALU_complex;
    2281            0 :       Temp->solved = true;
    2282            0 :       Push (Temp);
    2283              :     }
    2284              :   else
    2285              :     {
    2286            0 :       M2Error_InternalError ((const char *) "expecting both operands to be of type COMPLEX", 45);
    2287              :     }
    2288            0 : }
    2289              : 
    2290              : 
    2291              : /*
    2292              :    RealMult - multiplies two numbers. One of which is a Real.
    2293              : */
    2294              : 
    2295            0 : static void RealMult (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2296              : {
    2297            0 :   M2ALU_PtrToValue__opaque Temp;
    2298              : 
    2299            0 :   if (Op1->type == M2ALU_integer)
    2300              :     {
    2301            0 :       Push (Op1);
    2302            0 :       ConvertIntToReal ();
    2303            0 :       Op1 = Pop ();
    2304              :     }
    2305            0 :   if (Op2->type == M2ALU_integer)
    2306              :     {
    2307            0 :       Push (Op2);
    2308            0 :       ConvertIntToReal ();
    2309            0 :       Op2 = Pop ();
    2310              :     }
    2311            0 :   Temp = New ();  /* as it is a temp  */
    2312            0 :   Temp->location = Op1->location;  /* as it is a temp  */
    2313            0 :   Temp->numberValue = m2expr_BuildMult (Temp->location, Op2->numberValue, Op1->numberValue, false);
    2314            0 :   Temp->type = M2ALU_real;
    2315            0 :   Temp->solved = true;
    2316            0 :   Push (Temp);
    2317            0 : }
    2318              : 
    2319              : 
    2320              : /*
    2321              :    ComplexMult - multiplies two complex numbers.
    2322              : */
    2323              : 
    2324            0 : static void ComplexMult (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2325              : {
    2326            0 :   M2ALU_PtrToValue__opaque Temp;
    2327              : 
    2328            0 :   if ((Op1->type == M2ALU_complex) && (Op2->type == M2ALU_complex))
    2329              :     {
    2330            0 :       Temp = New ();
    2331            0 :       Temp->location = Op1->location;
    2332            0 :       Temp->numberValue = m2expr_BuildMult (Temp->location, Op2->numberValue, Op1->numberValue, false);
    2333            0 :       Temp->type = M2ALU_complex;
    2334            0 :       Temp->solved = true;
    2335            0 :       Push (Temp);
    2336              :     }
    2337              :   else
    2338              :     {
    2339            0 :       M2Error_InternalError ((const char *) "expecting both operands to be of type COMPLEX", 45);
    2340              :     }
    2341            0 : }
    2342              : 
    2343              : 
    2344              : /*
    2345              :    RealDiv - divides two numbers. One of which is a Real.
    2346              : */
    2347              : 
    2348            0 : static void RealDiv (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2349              : {
    2350            0 :   M2ALU_PtrToValue__opaque Temp;
    2351              : 
    2352            0 :   if (Op1->type == M2ALU_integer)
    2353              :     {
    2354            0 :       Push (Op1);
    2355            0 :       ConvertIntToReal ();
    2356            0 :       Op1 = Pop ();
    2357              :     }
    2358            0 :   if (Op2->type == M2ALU_integer)
    2359              :     {
    2360            0 :       Push (Op2);
    2361            0 :       ConvertIntToReal ();
    2362            0 :       Op2 = Pop ();
    2363              :     }
    2364            0 :   Temp = New ();  /* as it is a temp  */
    2365            0 :   Temp->location = Op1->location;  /* as it is a temp  */
    2366            0 :   Temp->numberValue = m2expr_BuildDivTrunc (Temp->location, Op2->numberValue, Op1->numberValue, false);
    2367            0 :   Temp->type = M2ALU_real;
    2368            0 :   Temp->solved = true;
    2369            0 :   Push (Temp);
    2370            0 : }
    2371              : 
    2372              : 
    2373              : /*
    2374              :    ComplexDiv - divides two complex numbers.
    2375              : */
    2376              : 
    2377            0 : static void ComplexDiv (M2ALU_PtrToValue__opaque Op1, M2ALU_PtrToValue__opaque Op2)
    2378              : {
    2379            0 :   M2ALU_PtrToValue__opaque Temp;
    2380              : 
    2381            0 :   if ((Op1->type == M2ALU_complex) && (Op2->type == M2ALU_complex))
    2382              :     {
    2383            0 :       Temp = New ();
    2384            0 :       Temp->location = Op1->location;
    2385            0 :       Temp->numberValue = m2expr_BuildDivTrunc (Temp->location, Op2->numberValue, Op1->numberValue, false);
    2386            0 :       Temp->type = M2ALU_complex;
    2387            0 :       Temp->solved = true;
    2388            0 :       Push (Temp);
    2389              :     }
    2390              :   else
    2391              :     {
    2392            0 :       M2Error_InternalError ((const char *) "expecting both operands to be of type COMPLEX", 45);
    2393              :     }
    2394            0 : }
    2395              : 
    2396              : 
    2397              : /*
    2398              :    AreSetsEqual - returns TRUE if sets, op1, and, op2, contain the same
    2399              :                   members.
    2400              : */
    2401              : 
    2402           48 : static bool AreSetsEqual (unsigned int tokenno, M2ALU_PtrToValue__opaque op1, M2ALU_PtrToValue__opaque op2)
    2403              : {
    2404           48 :   unsigned int low1;
    2405           48 :   unsigned int low2;
    2406           48 :   unsigned int high1;
    2407           48 :   unsigned int high2;
    2408           48 :   unsigned int i;
    2409              : 
    2410           48 :   i = 1;
    2411           48 :   Eval (tokenno, op1);
    2412           48 :   Eval (tokenno, op2);
    2413           48 :   if (! (op1->solved && op2->solved))
    2414              :     {
    2415            0 :       M2Error_InternalError ((const char *) "can only compare set values when they are known", 47);
    2416              :     }
    2417           96 :   for (;;)
    2418              :   {
    2419           72 :     if (M2ALU_GetRange (static_cast<M2ALU_PtrToValue> (op1), i, &low1, &high1))
    2420              :       {
    2421           48 :         if (M2ALU_GetRange (static_cast<M2ALU_PtrToValue> (op2), i, &low2, &high2))
    2422              :           {
    2423           48 :             SymbolTable_PushValue (low1);
    2424           48 :             SymbolTable_PushValue (low2);
    2425           48 :             if (M2ALU_NotEqu (tokenno))
    2426              :               {
    2427              :                 return false;
    2428              :               }
    2429           24 :             SymbolTable_PushValue (high1);
    2430           24 :             SymbolTable_PushValue (high2);
    2431           24 :             if (M2ALU_NotEqu (tokenno))
    2432              :               {
    2433              :                 return false;
    2434              :               }
    2435           24 :             i += 1;
    2436              :           }
    2437              :         else
    2438              :           {
    2439              :             /* op2 is out of ranges, but op1 still has >= 1 range left  */
    2440              :             return false;
    2441              :           }
    2442              :       }
    2443              :     else
    2444              :       {
    2445           24 :         if (M2ALU_GetRange (static_cast<M2ALU_PtrToValue> (op2), i, &low2, &high2))
    2446              :           {
    2447              :             /* op1 is out of ranges, but op2 still has >= 1 range left  */
    2448              :             return false;
    2449              :           }
    2450              :         else
    2451              :           {
    2452              :             /* both out of ranges and they were the same  */
    2453              :             return true;
    2454              :           }
    2455              :       }
    2456              :   }
    2457              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    2458              :   __builtin_unreachable ();
    2459              : }
    2460              : 
    2461              : 
    2462              : /*
    2463              :    IsSubset - returns TRUE if the set as defined by, s1, is a subset of set, s2.
    2464              : */
    2465              : 
    2466            0 : static bool IsSubset (unsigned int tokenno, M2ALU_PtrToValue__opaque s1, M2ALU_PtrToValue__opaque s2)
    2467              : {
    2468            0 :   Push (s1);
    2469            0 :   Push (s2);
    2470            0 :   M2ALU_SetAnd (tokenno);
    2471            0 :   Push (s1);
    2472            0 :   return M2ALU_Equ (tokenno);
    2473              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2474              :   __builtin_unreachable ();
    2475              : }
    2476              : 
    2477              : 
    2478              : /*
    2479              :    IsSuperset - returns TRUE if the set as defined by, s1, is a superset of set, s2.
    2480              : */
    2481              : 
    2482            0 : static bool IsSuperset (unsigned int tokenno, M2ALU_PtrToValue__opaque s1, M2ALU_PtrToValue__opaque s2)
    2483              : {
    2484            0 :   M2ALU_PushFrom (static_cast<M2ALU_PtrToValue> (s1));
    2485            0 :   M2ALU_PushFrom (static_cast<M2ALU_PtrToValue> (s2));
    2486            0 :   M2ALU_SetAnd (tokenno);
    2487            0 :   M2ALU_PushFrom (static_cast<M2ALU_PtrToValue> (s2));
    2488            0 :   return M2ALU_Equ (tokenno);
    2489              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2490              :   __builtin_unreachable ();
    2491              : }
    2492              : 
    2493              : 
    2494              : /*
    2495              :    cellTypeString - returns a string corresponding to, s.
    2496              : */
    2497              : 
    2498            0 : static DynamicStrings_String cellTypeString (M2ALU_cellType s)
    2499              : {
    2500            0 :   switch (s)
    2501              :     {
    2502            0 :       case M2ALU_none:
    2503            0 :         return DynamicStrings_InitString ((const char *) "none", 4);
    2504            0 :         break;
    2505              : 
    2506            0 :       case M2ALU_integer:
    2507            0 :         return DynamicStrings_InitString ((const char *) "integer", 7);
    2508            0 :         break;
    2509              : 
    2510            0 :       case M2ALU_real:
    2511            0 :         return DynamicStrings_InitString ((const char *) "real", 4);
    2512            0 :         break;
    2513              : 
    2514            0 :       case M2ALU_complex:
    2515            0 :         return DynamicStrings_InitString ((const char *) "complex", 7);
    2516            0 :         break;
    2517              : 
    2518            0 :       case M2ALU_set:
    2519            0 :         return DynamicStrings_InitString ((const char *) "set", 3);
    2520            0 :         break;
    2521              : 
    2522            0 :       case M2ALU_constructor:
    2523            0 :         return DynamicStrings_InitString ((const char *) "constructor", 11);
    2524            0 :         break;
    2525              : 
    2526            0 :       case M2ALU_array:
    2527            0 :         return DynamicStrings_InitString ((const char *) "array", 5);
    2528            0 :         break;
    2529              : 
    2530            0 :       case M2ALU_record:
    2531            0 :         return DynamicStrings_InitString ((const char *) "record", 6);
    2532            0 :         break;
    2533              : 
    2534              : 
    2535            0 :       default:
    2536            0 :         M2Error_InternalError ((const char *) "unexpected value of s", 21);
    2537              :         break;
    2538              :     }
    2539              :   return static_cast<DynamicStrings_String> (NULL);
    2540              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2541              :   __builtin_unreachable ();
    2542              : }
    2543              : 
    2544              : 
    2545              : /*
    2546              :    ToSetValue - converts a list of fields into a list of ranges.
    2547              :                 In effect it turns a generic constructor into
    2548              :                 a set type.
    2549              : */
    2550              : 
    2551        33232 : static M2ALU_listOfRange ToSetValue (M2ALU_listOfFields f)
    2552              : {
    2553        33232 :   M2ALU_listOfFields g;
    2554        33232 :   M2ALU_listOfRange r;
    2555        33232 :   M2ALU_listOfRange s;
    2556              : 
    2557        33232 :   g = f;
    2558        33232 :   r = NULL;
    2559        33232 :   while (f != NULL)
    2560              :     {
    2561            0 :       NewRange (&s);
    2562            0 :       s->low = f->field;
    2563            0 :       s->high = s->low;
    2564            0 :       s->next = r;
    2565            0 :       if (r == NULL)
    2566              :         {
    2567            0 :           r = s;
    2568              :         }
    2569            0 :       f = f->next;
    2570              :     }
    2571        33232 :   DisposeFields (&g);
    2572        33232 :   return r;
    2573              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2574              :   __builtin_unreachable ();
    2575              : }
    2576              : 
    2577              : 
    2578              : /*
    2579              :    ToArrayValue - converts a list of fields into an array initialiser.
    2580              :                   In effect it turns a generic constructor into
    2581              :                   an array type.
    2582              : */
    2583              : 
    2584          944 : static M2ALU_listOfElements ToArrayValue (unsigned int tok, M2ALU_listOfFields f)
    2585              : {
    2586          944 :   M2ALU_listOfFields g;
    2587          944 :   M2ALU_listOfElements r;
    2588          944 :   M2ALU_listOfElements s;
    2589              : 
    2590          944 :   g = f;
    2591          944 :   r = NULL;
    2592          944 :   while (f != NULL)
    2593              :     {
    2594            0 :       NewElement (&s);
    2595            0 :       s->element = f->field;
    2596            0 :       s->by = SymbolTable_MakeConstLit (tok, NameKey_MakeKey ((const char *) "1", 1), M2Base_ZType);
    2597            0 :       s->next = r;
    2598            0 :       if (r == NULL)
    2599              :         {
    2600            0 :           r = s;
    2601              :         }
    2602            0 :       f = f->next;
    2603              :     }
    2604          944 :   DisposeFields (&g);
    2605          944 :   return r;
    2606              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2607              :   __builtin_unreachable ();
    2608              : }
    2609              : 
    2610              : 
    2611              : /*
    2612              :    CoerseTo - attempts to coerses a cellType, v, into, type, t.
    2613              :               Normally this will be a generic constructors converting
    2614              :               into set or array.
    2615              : */
    2616              : 
    2617        80484 : static M2ALU_PtrToValue__opaque CoerseTo (unsigned int tokenno, M2ALU_cellType t, M2ALU_PtrToValue__opaque v)
    2618              : {
    2619        80484 :   DynamicStrings_String s1;
    2620        80484 :   DynamicStrings_String s2;
    2621        80484 :   DynamicStrings_String s3;
    2622              : 
    2623        80484 :   if (t == v->type)
    2624              :     {
    2625              :       return v;
    2626              :     }
    2627        36458 :   else if ((v->type == M2ALU_constructor) && (t == M2ALU_set))
    2628              :     {
    2629              :       /* avoid dangling else.  */
    2630        33232 :       v->type = M2ALU_set;
    2631        33232 :       v->setValue = ToSetValue (v->fieldValues);
    2632        33232 :       return v;
    2633              :     }
    2634         3226 :   else if ((v->type == M2ALU_constructor) && (t == M2ALU_array))
    2635              :     {
    2636              :       /* avoid dangling else.  */
    2637          944 :       v->type = M2ALU_array;
    2638          944 :       v->arrayValues = ToArrayValue (tokenno, v->fieldValues);
    2639          944 :       return v;
    2640              :     }
    2641         2282 :   else if ((v->type == M2ALU_constructor) && (t == M2ALU_record))
    2642              :     {
    2643              :       /* avoid dangling else.  */
    2644              :       /* nothing to do other than change tag  */
    2645         2282 :       v->type = M2ALU_record;
    2646         2282 :       return v;
    2647              :     }
    2648              :   else
    2649              :     {
    2650              :       /* avoid dangling else.  */
    2651            0 :       s1 = cellTypeString (t);
    2652            0 :       s2 = cellTypeString (v->type);
    2653            0 :       s3 = DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "cannot mix construction of a ", 29), DynamicStrings_Mark (DynamicStrings_ConCat (DynamicStrings_Mark (s1), DynamicStrings_Mark (DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) " with a ", 8), DynamicStrings_Mark (s2))))));
    2654            0 :       M2MetaError_MetaErrorStringT0 (tokenno, s3);
    2655            0 :       return v;
    2656              :     }
    2657              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2658              :   __builtin_unreachable ();
    2659              : }
    2660              : 
    2661              : 
    2662              : /*
    2663              :    AddElementToEnd - appends, e, to the end of list, v.
    2664              : */
    2665              : 
    2666         4268 : static void AddElementToEnd (M2ALU_PtrToValue__opaque v, M2ALU_listOfElements e)
    2667              : {
    2668         4268 :   M2ALU_listOfElements a;
    2669              : 
    2670            0 :   if (v->arrayValues == NULL)
    2671              :     {
    2672          496 :       v->arrayValues = e;
    2673              :     }
    2674              :   else
    2675              :     {
    2676              :       a = v->arrayValues;
    2677        51960 :       while (a->next != NULL)
    2678              :         {
    2679              :           a = a->next;
    2680              :         }
    2681         3772 :       a->next = e;
    2682              :     }
    2683            0 : }
    2684              : 
    2685              : 
    2686              : /*
    2687              :    AddFieldToEnd - appends, f, to the end of list, v.
    2688              : */
    2689              : 
    2690         9504 : static void AddFieldToEnd (M2ALU_PtrToValue__opaque v, M2ALU_listOfFields f)
    2691              : {
    2692         9504 :   M2ALU_listOfFields a;
    2693              : 
    2694            0 :   if (v->fieldValues == NULL)
    2695              :     {
    2696         2282 :       v->fieldValues = f;
    2697              :     }
    2698              :   else
    2699              :     {
    2700              :       a = v->fieldValues;
    2701        16326 :       while (a->next != NULL)
    2702              :         {
    2703              :           a = a->next;
    2704              :         }
    2705         7222 :       a->next = f;
    2706              :     }
    2707            0 : }
    2708              : 
    2709              : 
    2710              : /*
    2711              :    ElementsSolved - returns TRUE if all ranges in the set have been solved.
    2712              : */
    2713              : 
    2714         8370 : static bool ElementsSolved (unsigned int tokenno, M2ALU_listOfRange r)
    2715              : {
    2716        20776 :   while (r != NULL)
    2717              :     {
    2718        12412 :       if (! (SymbolTable_IsConst (r->low)))
    2719              :         {
    2720            0 :           M2MetaError_MetaErrorT1 (tokenno, (const char *) "a constant set can only contain constant set elements, {%1Ead} is not a constant", 80, r->low);
    2721              :         }
    2722        12412 :       if ((r->high != r->low) && (! (SymbolTable_IsConst (r->high))))
    2723              :         {
    2724            6 :           M2MetaError_MetaErrorT1 (tokenno, (const char *) "a constant set can only contain constant set elements, {%1Ead} is not a constant", 80, r->high);
    2725              :         }
    2726        12412 :       if (! ((IsSolvedGCC (r->low)) && (IsSolvedGCC (r->high))))
    2727              :         {
    2728            0 :           return false;
    2729              :         }
    2730        12406 :       r = r->next;
    2731              :     }
    2732              :   return true;
    2733              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2734              :   __builtin_unreachable ();
    2735              : }
    2736              : 
    2737              : 
    2738              : /*
    2739              :    ArrayElementsSolved - returns TRUE if all ranges in the set have been solved.
    2740              : */
    2741              : 
    2742          478 : static bool ArrayElementsSolved (M2ALU_listOfElements e)
    2743              : {
    2744         4692 :   while (e != NULL)
    2745              :     {
    2746         4214 :       if (! ((IsSolvedGCC (e->element)) && (IsSolvedGCC (e->by))))
    2747              :         {
    2748            0 :           return false;
    2749              :         }
    2750         4214 :       e = e->next;
    2751              :     }
    2752              :   return true;
    2753              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2754              :   __builtin_unreachable ();
    2755              : }
    2756              : 
    2757              : 
    2758              : /*
    2759              :    EvalFieldValues - returns TRUE if all fields in the record have been solved.
    2760              : */
    2761              : 
    2762         2264 : static bool EvalFieldValues (M2ALU_listOfFields e)
    2763              : {
    2764        11714 :   while (e != NULL)
    2765              :     {
    2766         9450 :       if (SymbolTable_IsConst (e->field))
    2767              :         {
    2768              :           /* avoid dangling else.  */
    2769         9306 :           if (! (IsSolvedGCC (e->field)))
    2770              :             {
    2771              :               return false;
    2772              :             }
    2773              :         }
    2774              :       /* RETURN( FALSE )  */
    2775         9450 :       e = e->next;
    2776              :     }
    2777              :   return true;
    2778              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2779              :   __builtin_unreachable ();
    2780              : }
    2781              : 
    2782              : 
    2783              : /*
    2784              :    Swap - swaps the contents of, i, and, j.
    2785              : */
    2786              : 
    2787        12890 : static void Swap (M2ALU_listOfRange i, M2ALU_listOfRange j)
    2788              : {
    2789        12890 :   unsigned int t;
    2790              : 
    2791        12890 :   t = i->low;
    2792        12890 :   i->low = j->low;
    2793        12890 :   j->low = t;
    2794        12890 :   t = i->high;
    2795        12890 :   i->high = j->high;
    2796        12890 :   j->high = t;
    2797            0 : }
    2798              : 
    2799              : 
    2800              : /*
    2801              :    DisplayElements -
    2802              : */
    2803              : 
    2804            0 : static void DisplayElements (M2ALU_listOfRange i)
    2805              : {
    2806            0 :   while (i != NULL)
    2807              :     {
    2808            0 :       SymbolTable_PushValue (i->low);
    2809            0 :       PrintValue ();
    2810            0 :       Reduce ();
    2811            0 :       SymbolTable_PushValue (i->high);
    2812            0 :       PrintValue ();
    2813            0 :       Reduce ();
    2814            0 :       i = i->next;
    2815              :     }
    2816            0 : }
    2817              : 
    2818              : 
    2819              : /*
    2820              :    SortElements - sorts the list as defined by, h, into ascending range order.
    2821              :                   The low element is the sort key.
    2822              : */
    2823              : 
    2824         8588 : static void SortElements (unsigned int tokenno, M2ALU_listOfRange h)
    2825              : {
    2826         8588 :   M2ALU_listOfRange i;
    2827         8588 :   M2ALU_listOfRange j;
    2828         8588 :   M2ALU_listOfRange k;
    2829              : 
    2830         8588 :   i = h;
    2831        21478 :   while (i != NULL)
    2832              :     {
    2833        12890 :       j = i;
    2834        12890 :       k = i->next;
    2835        32804 :       while (k != NULL)
    2836              :         {
    2837        19914 :           SymbolTable_PushValue (k->low);
    2838        19914 :           M2ALU_ConvertToInt ();
    2839        19914 :           SymbolTable_PushValue (j->low);
    2840        19914 :           M2ALU_ConvertToInt ();
    2841        19914 :           if (M2ALU_Less (tokenno))
    2842              :             {
    2843         7166 :               j = k;
    2844              :             }
    2845        19914 :           k = k->next;
    2846              :         }
    2847        12890 :       Swap (i, j);
    2848        12890 :       i = i->next;
    2849              :     }
    2850         8588 : }
    2851              : 
    2852              : 
    2853              : /*
    2854              :    CombineElements - given a sorted list determine whether there is any
    2855              :                      overlap in the low..high bounds. If overlap exists
    2856              :                      then remove it.
    2857              : */
    2858              : 
    2859         8588 : static void CombineElements (unsigned int tokenno, M2ALU_listOfRange r)
    2860              : {
    2861         8588 :   M2ALU_listOfRange t;
    2862         8588 :   M2ALU_listOfRange j;
    2863              : 
    2864        18202 :   while (r != NULL)
    2865              :     {
    2866         9614 :       j = r->next;
    2867        15178 :       while (j != NULL)
    2868              :         {
    2869         5564 :           SymbolTable_PushValue (r->high);
    2870         5564 :           M2ALU_ConvertToInt ();
    2871         5564 :           M2ALU_PushCard (1);
    2872         5564 :           M2ALU_Addn ();
    2873         5564 :           SymbolTable_PushValue (j->low);
    2874         5564 :           M2ALU_ConvertToInt ();
    2875         5564 :           if (M2ALU_GreEqu (tokenno))
    2876              :             {
    2877         3276 :               r->high = j->high;
    2878         3276 :               t = j->next;
    2879         3276 :               r->next = j->next;
    2880         3276 :               j->next = NULL;
    2881         3276 :               DisposeRange (&j);
    2882         3276 :               j = t;
    2883              :             }
    2884              :           else
    2885              :             {
    2886         2288 :               j = NULL;
    2887              :             }
    2888              :         }
    2889         9614 :       r = r->next;
    2890              :     }
    2891         8588 : }
    2892              : 
    2893              : 
    2894              : /*
    2895              :    EvalSetValues - returns TRUE if all elements in this set have been resolved.
    2896              : */
    2897              : 
    2898         8370 : static bool EvalSetValues (unsigned int tokenno, M2ALU_listOfRange r)
    2899              : {
    2900         8370 :   if (ElementsSolved (tokenno, r))
    2901              :     {
    2902         8364 :       SortElements (tokenno, r);
    2903         8364 :       CombineElements (tokenno, r);
    2904         8364 :       return true;
    2905              :     }
    2906              :   else
    2907              :     {
    2908              :       return false;
    2909              :     }
    2910              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2911              :   __builtin_unreachable ();
    2912              : }
    2913              : 
    2914              : 
    2915              : /*
    2916              :    Eval - attempts to solve a constructor type.
    2917              : */
    2918              : 
    2919        82922 : static void Eval (unsigned int tokenno, M2ALU_PtrToValue__opaque v)
    2920              : {
    2921        82922 :   CheckNotAlreadyOnFreeList (v);
    2922        82922 :   if (! v->solved)
    2923              :     {
    2924        31918 :       if (SymbolTable_IsSet (SymbolTable_SkipType (v->constructorType)))
    2925              :         {
    2926        25596 :           v = CoerseTo (tokenno, M2ALU_set, v);
    2927              :         }
    2928         6322 :       else if (SymbolTable_IsRecord (SymbolTable_SkipType (v->constructorType)))
    2929              :         {
    2930              :           /* avoid dangling else.  */
    2931         3448 :           v = CoerseTo (tokenno, M2ALU_record, v);
    2932              :         }
    2933         2874 :       else if (SymbolTable_IsArray (SymbolTable_SkipType (v->constructorType)))
    2934              :         {
    2935              :           /* avoid dangling else.  */
    2936         2874 :           v = CoerseTo (tokenno, M2ALU_array, v);
    2937              :         }
    2938        31918 :       v->areAllConstants = DefinedByConstants (v);
    2939        31918 :       switch (v->type)
    2940              :         {
    2941        25596 :           case M2ALU_set:
    2942        51192 :             M2Debug_Assert ((v->constructorType == SymbolTable_NulSym) || (SymbolTable_IsSet (SymbolTable_SkipType (v->constructorType))));
    2943        25596 :             v->solved = (M2GCCDeclare_CompletelyResolved (v->constructorType)) && (EvalSetValues (tokenno, v->setValue));
    2944        25590 :             break;
    2945              : 
    2946         2874 :           case M2ALU_array:
    2947         5748 :             M2Debug_Assert ((v->constructorType == SymbolTable_NulSym) || (SymbolTable_IsArray (SymbolTable_SkipType (v->constructorType))));
    2948         2874 :             v->solved = (M2GCCDeclare_CompletelyResolved (v->constructorType)) && (ArrayElementsSolved (v->arrayValues));
    2949         2874 :             break;
    2950              : 
    2951         3448 :           case M2ALU_record:
    2952         6896 :             M2Debug_Assert ((v->constructorType == SymbolTable_NulSym) || (SymbolTable_IsRecord (SymbolTable_SkipType (v->constructorType))));
    2953         3448 :             v->solved = (M2GCCDeclare_CompletelyResolved (v->constructorType)) && (EvalFieldValues (v->fieldValues));
    2954         3448 :             break;
    2955              : 
    2956              : 
    2957              :           default:
    2958              :             break;
    2959              :         }
    2960              :     }
    2961              :   /* do nothing  */
    2962        82916 : }
    2963              : 
    2964              : 
    2965              : /*
    2966              :    WalkSetValueDependants -
    2967              : */
    2968              : 
    2969       453944 : static void WalkSetValueDependants (M2ALU_listOfRange r, M2GCCDeclare_WalkAction p)
    2970              : {
    2971      1040388 :   while (r != NULL)
    2972              :     {
    2973       586444 :       (*p.proc) (r->low);
    2974       586444 :       (*p.proc) (r->high);
    2975       586444 :       r = r->next;
    2976              :     }
    2977       453944 : }
    2978              : 
    2979              : 
    2980              : /*
    2981              :    IsSetValueDependants -
    2982              : */
    2983              : 
    2984        29186 : static bool IsSetValueDependants (M2ALU_listOfRange r, M2GCCDeclare_IsAction q)
    2985              : {
    2986        29186 :   bool result;
    2987              : 
    2988        29186 :   result = true;
    2989        67680 :   while (r != NULL)
    2990              :     {
    2991        38494 :       if (! ((*q.proc) (r->low)))
    2992              :         {
    2993        23484 :           result = false;
    2994              :         }
    2995        38494 :       if (! ((*q.proc) (r->high)))
    2996              :         {
    2997        23484 :           result = false;
    2998              :         }
    2999        38494 :       r = r->next;
    3000              :     }
    3001        29186 :   return result;
    3002              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3003              :   __builtin_unreachable ();
    3004              : }
    3005              : 
    3006              : 
    3007              : /*
    3008              :    WalkFieldValueDependants -
    3009              : */
    3010              : 
    3011       703116 : static void WalkFieldValueDependants (M2ALU_listOfFields f, M2GCCDeclare_WalkAction p)
    3012              : {
    3013      3698016 :   while (f != NULL)
    3014              :     {
    3015      2994900 :       (*p.proc) (f->field);
    3016      2994900 :       f = f->next;
    3017              :     }
    3018            0 : }
    3019              : 
    3020              : 
    3021              : /*
    3022              :    IsFieldValueDependants -
    3023              : */
    3024              : 
    3025        25644 : static bool IsFieldValueDependants (M2ALU_listOfFields f, M2GCCDeclare_IsAction q)
    3026              : {
    3027        25644 :   bool result;
    3028              : 
    3029        25644 :   result = true;
    3030        91308 :   while (f != NULL)
    3031              :     {
    3032        65664 :       if (! ((*q.proc) (f->field)))
    3033              :         {
    3034        42616 :           result = false;
    3035              :         }
    3036        65664 :       f = f->next;
    3037              :     }
    3038        25644 :   return result;
    3039              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3040              :   __builtin_unreachable ();
    3041              : }
    3042              : 
    3043              : 
    3044              : /*
    3045              :    WalkArrayValueDependants -
    3046              : */
    3047              : 
    3048       153184 : static void WalkArrayValueDependants (M2ALU_listOfElements a, M2GCCDeclare_WalkAction p)
    3049              : {
    3050      1705766 :   while (a != NULL)
    3051              :     {
    3052      1552582 :       (*p.proc) (a->element);
    3053      1552582 :       (*p.proc) (a->by);
    3054      1552582 :       a = a->next;
    3055              :     }
    3056       153184 : }
    3057              : 
    3058              : 
    3059              : /*
    3060              :    IsArrayValueDependants -
    3061              : */
    3062              : 
    3063         3186 : static bool IsArrayValueDependants (M2ALU_listOfElements a, M2GCCDeclare_IsAction q)
    3064              : {
    3065         3186 :   bool result;
    3066              : 
    3067         3186 :   result = true;
    3068        34708 :   while (a != NULL)
    3069              :     {
    3070        31522 :       if (! ((*q.proc) (a->element)))
    3071              :         {
    3072        24216 :           result = false;
    3073              :         }
    3074        31522 :       if (! ((*q.proc) (a->by)))
    3075              :         {
    3076        25160 :           result = false;
    3077              :         }
    3078        31522 :       a = a->next;
    3079              :     }
    3080         3186 :   return result;
    3081              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3082              :   __builtin_unreachable ();
    3083              : }
    3084              : 
    3085              : 
    3086              : /*
    3087              :    DefinedByConstants - returns TRUE if the value, v, is defined by constants.
    3088              :                         It assigns, v^.areAllConstants, with the result.
    3089              : */
    3090              : 
    3091        31918 : static bool DefinedByConstants (M2ALU_PtrToValue__opaque v)
    3092              : {
    3093        31918 :   switch (v->type)
    3094              :     {
    3095            0 :       case M2ALU_none:
    3096            0 :       case M2ALU_integer:
    3097            0 :       case M2ALU_real:
    3098            0 :       case M2ALU_complex:
    3099            0 :         v->areAllConstants = true;
    3100            0 :         break;
    3101              : 
    3102        25596 :       case M2ALU_set:
    3103        25596 :         v->areAllConstants = rangeConstant (v->setValue);
    3104        25596 :         break;
    3105              : 
    3106         3448 :       case M2ALU_constructor:
    3107         3448 :       case M2ALU_record:
    3108         3448 :         v->areAllConstants = fieldsConstant (v->fieldValues);
    3109         3448 :         break;
    3110              : 
    3111         2874 :       case M2ALU_array:
    3112         2874 :         v->areAllConstants = arrayConstant (v->arrayValues);
    3113         2874 :         break;
    3114              : 
    3115              : 
    3116            0 :       default:
    3117            0 :         M2Error_InternalError ((const char *) "unexpected type", 15);
    3118        31918 :         break;
    3119              :     }
    3120        31918 :   return v->areAllConstants;
    3121              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3122              :   __builtin_unreachable ();
    3123              : }
    3124              : 
    3125              : 
    3126              : /*
    3127              :    rangeConstant - returns TRUE if all the range entities are constant.
    3128              : */
    3129              : 
    3130        25596 : static bool rangeConstant (M2ALU_listOfRange r)
    3131              : {
    3132        61744 :   while (r != NULL)
    3133              :     {
    3134        36154 :       if ((! (SymbolTable_IsConst (r->low))) || (! (SymbolTable_IsConst (r->high))))
    3135              :         {
    3136            6 :           return false;
    3137              :         }
    3138        36148 :       r = r->next;
    3139              :     }
    3140              :   return true;
    3141              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3142              :   __builtin_unreachable ();
    3143              : }
    3144              : 
    3145              : 
    3146              : /*
    3147              :    fieldsConstant - returns TRUE if all the field entities are constant.
    3148              : */
    3149              : 
    3150         3448 : static bool fieldsConstant (M2ALU_listOfFields f)
    3151              : {
    3152        15226 :   while (f != NULL)
    3153              :     {
    3154        12090 :       if (! (SymbolTable_IsConst (f->field)))
    3155              :         {
    3156              :           return false;
    3157              :         }
    3158        11778 :       f = f->next;
    3159              :     }
    3160              :   return true;
    3161              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3162              :   __builtin_unreachable ();
    3163              : }
    3164              : 
    3165              : 
    3166              : /*
    3167              :    arrayConstant - returns TRUE if the, element, and, by, components
    3168              :                    of an array constructor are constant.
    3169              : */
    3170              : 
    3171         2874 : static bool arrayConstant (M2ALU_listOfElements e)
    3172              : {
    3173        32248 :   while (e != NULL)
    3174              :     {
    3175        29374 :       if ((! (SymbolTable_IsConst (e->element))) && (! (SymbolTable_IsConst (e->by))))
    3176              :         {
    3177              :           return false;
    3178              :         }
    3179        29374 :       e = e->next;
    3180              :     }
    3181              :   return true;
    3182              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3183              :   __builtin_unreachable ();
    3184              : }
    3185              : 
    3186              : 
    3187              : /*
    3188              :    FindValueEnum -
    3189              : */
    3190              : 
    3191            0 : static void FindValueEnum (unsigned int field)
    3192              : {
    3193            0 :   SymbolTable_PushValue (field);
    3194            0 :   M2ALU_PushIntegerTree (EnumerationValue);
    3195            0 :   if (M2ALU_Equ (CurrentTokenNo))
    3196              :     {
    3197            0 :       EnumerationField = static_cast<unsigned int> (field);
    3198              :     }
    3199            0 : }
    3200              : 
    3201              : 
    3202              : /*
    3203              :    Val - returns a GCC symbol enumeration or a GCC constant which has, value, and which is
    3204              :          of type, type.
    3205              : */
    3206              : 
    3207            0 : static unsigned int Val (unsigned int tokenno, unsigned int type, tree value)
    3208              : {
    3209            0 :   unsigned int sym;
    3210              : 
    3211            0 :   if (SymbolTable_IsEnumeration (type))
    3212              :     {
    3213            0 :       EnumerationField = SymbolTable_NulSym;
    3214            0 :       EnumerationValue = value;
    3215            0 :       CurrentTokenNo = tokenno;
    3216            0 :       SymbolTable_ForeachFieldEnumerationDo (type, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) FindValueEnum});
    3217            0 :       if (EnumerationField == SymbolTable_NulSym)
    3218              :         {
    3219            0 :           M2Error_InternalError ((const char *) "enumeration value exceeds range", 31);
    3220              :         }
    3221              :       return EnumerationField;
    3222              :     }
    3223              :   else
    3224              :     {
    3225            0 :       sym = SymbolTable_MakeTemporary (tokenno, SymbolTable_ImmediateValue);
    3226            0 :       SymbolTable_PutVar (sym, type);
    3227            0 :       CheckOverflow (tokenno, value);
    3228            0 :       M2ALU_PushIntegerTree (value);
    3229            0 :       SymbolTable_PopValue (sym);
    3230            0 :       return sym;
    3231              :     }
    3232              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3233              :   __builtin_unreachable ();
    3234              : }
    3235              : 
    3236              : 
    3237              : /*
    3238              :    DupConst - duplicates and returns a constant, sym, but adds, offset to its value.
    3239              : */
    3240              : 
    3241            0 : static unsigned int DupConst (unsigned int tokenno, unsigned int sym, int offset)
    3242              : {
    3243            0 :   SymbolTable_PushValue (sym);
    3244            0 :   M2ALU_PushInt (offset);
    3245            0 :   M2ALU_Addn ();
    3246            0 :   return Val (tokenno, SymbolTable_GetType (sym), M2ALU_PopIntegerTree ());
    3247              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3248              :   __builtin_unreachable ();
    3249              : }
    3250              : 
    3251              : 
    3252              : /*
    3253              :    DupConstAndAdd - duplicates and returns a constant, sym,
    3254              :                     but adds the symbol, extra.
    3255              : */
    3256              : 
    3257            0 : static unsigned int DupConstAndAdd (unsigned int tokenno, unsigned int sym, tree extra)
    3258              : {
    3259            0 :   SymbolTable_PushValue (sym);
    3260            0 :   M2ALU_PushIntegerTree (extra);
    3261            0 :   M2ALU_Addn ();
    3262            0 :   return Val (tokenno, SymbolTable_GetType (sym), M2ALU_PopIntegerTree ());
    3263              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3264              :   __builtin_unreachable ();
    3265              : }
    3266              : 
    3267              : 
    3268              : /*
    3269              :    DupConstAndAddMod - duplicates and returns a constant, sym,
    3270              :                        but adds the symbol, extra, and ensures that
    3271              :                        the result in within limits: min..max using
    3272              :                        modulo arithmetic.
    3273              : */
    3274              : 
    3275            0 : static unsigned int DupConstAndAddMod (unsigned int tokenno, unsigned int sym, tree extra, unsigned int l, unsigned int h)
    3276              : {
    3277              :   /* result := (((sym-l) + extra) MOD (h-l)) + l)  */
    3278            0 :   SymbolTable_PushValue (sym);
    3279            0 :   SymbolTable_PushValue (l);
    3280            0 :   M2ALU_Sub ();
    3281            0 :   M2ALU_PushIntegerTree (extra);
    3282            0 :   M2ALU_Addn ();
    3283            0 :   SymbolTable_PushValue (h);
    3284            0 :   SymbolTable_PushValue (l);
    3285            0 :   M2ALU_Sub ();
    3286            0 :   M2ALU_ModTrunc ();
    3287            0 :   SymbolTable_PushValue (l);
    3288            0 :   M2ALU_Addn ();
    3289            0 :   return Val (tokenno, SymbolTable_GetType (sym), M2ALU_PopIntegerTree ());
    3290              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3291              :   __builtin_unreachable ();
    3292              : }
    3293              : 
    3294              : 
    3295              : /*
    3296              :    Remove - removes, v, from list, h.
    3297              : */
    3298              : 
    3299            0 : static void Remove (M2ALU_listOfRange *h, M2ALU_listOfRange v)
    3300              : {
    3301            0 :   M2ALU_listOfRange i;
    3302              : 
    3303            0 :   if ((*h) == v)
    3304              :     {
    3305            0 :       (*h) = (*h)->next;
    3306              :     }
    3307              :   else
    3308              :     {
    3309              :       i = (*h);
    3310            0 :       while ((i != NULL) && (i->next != v))
    3311              :         {
    3312              :           i = i->next;
    3313              :         }
    3314            0 :       if (i == NULL)
    3315              :         {
    3316            0 :           M2Error_InternalError ((const char *) "expecting v to be on the list", 29);
    3317              :         }
    3318              :       else
    3319              :         {
    3320            0 :           i = v->next;
    3321              :         }
    3322              :     }
    3323            0 :   v->next = NULL;
    3324            0 :   DisposeRange (&v);
    3325            0 : }
    3326              : 
    3327              : 
    3328              : /*
    3329              :    RemoveBit - remove bit, op1, from range, v, on list, h.
    3330              : */
    3331              : 
    3332            0 : static void RemoveBit (unsigned int tokenno, M2ALU_listOfRange *h, M2ALU_listOfRange v, unsigned int op1)
    3333              : {
    3334            0 :   SymbolTable_PushValue (v->low);
    3335            0 :   SymbolTable_PushValue (v->high);
    3336            0 :   if (M2ALU_Equ (tokenno))
    3337              :     {
    3338              :       /* avoid dangling else.  */
    3339              :       /* single bit in this range  */
    3340            0 :       SymbolTable_PushValue (v->low);
    3341            0 :       SymbolTable_PushValue (op1);
    3342            0 :       if (M2ALU_Equ (tokenno))
    3343              :         {
    3344              :           /* remove entry  */
    3345            0 :           Remove (h, v);
    3346            0 :           return;
    3347              :         }
    3348              :     }
    3349              :   else
    3350              :     {
    3351              :       /* is op1 equal to low?  */
    3352            0 :       SymbolTable_PushValue (op1);
    3353            0 :       SymbolTable_PushValue (v->low);
    3354            0 :       if (M2ALU_Equ (tokenno))
    3355              :         {
    3356            0 :           v->low = DupConst (tokenno, v->low, 1);
    3357              :         }
    3358              :       else
    3359              :         {
    3360            0 :           SymbolTable_PushValue (op1);
    3361            0 :           SymbolTable_PushValue (v->high);
    3362            0 :           if (M2ALU_Equ (tokenno))
    3363              :             {
    3364            0 :               v->high = DupConst (tokenno, v->high, -1);
    3365              :             }
    3366              :           else
    3367              :             {
    3368            0 :               v->high = DupConst (tokenno, op1, -1);
    3369            0 :               (*h) = AddRange ((*h), DupConst (tokenno, op1, 1), v->high);
    3370            0 :               SortElements (tokenno, (*h));
    3371              :             }
    3372              :         }
    3373              :     }
    3374              : }
    3375              : 
    3376              : 
    3377              : /*
    3378              :    PerformSubBit -
    3379              : */
    3380              : 
    3381            0 : static void PerformSubBit (unsigned int tokenno, M2ALU_listOfRange *h, unsigned int op1)
    3382              : {
    3383            0 :   M2ALU_listOfRange v;
    3384              : 
    3385            0 :   v = (*h);
    3386            0 :   while (v != NULL)
    3387              :     {
    3388            0 :       SymbolTable_PushValue (v->low);
    3389            0 :       SymbolTable_PushValue (op1);
    3390            0 :       if (M2ALU_LessEqu (tokenno))
    3391              :         {
    3392            0 :           SymbolTable_PushValue (op1);
    3393            0 :           SymbolTable_PushValue (v->high);
    3394            0 :           if (M2ALU_LessEqu (tokenno))
    3395              :             {
    3396            0 :               RemoveBit (tokenno, h, v, op1);
    3397            0 :               return;
    3398              :             }
    3399              :         }
    3400            0 :       v = v->next;
    3401              :     }
    3402              : }
    3403              : 
    3404              : 
    3405              : /*
    3406              :    PerformSetIn - returns TRUE if op1 is in set.
    3407              : */
    3408              : 
    3409            0 : static bool PerformSetIn (unsigned int tokenno, unsigned int op1, M2ALU_listOfRange h)
    3410              : {
    3411            0 :   while (h != NULL)
    3412              :     {
    3413            0 :       SymbolTable_PushValue (op1);
    3414            0 :       M2ALU_ConvertToInt ();
    3415            0 :       SymbolTable_PushValue (h->low);
    3416            0 :       M2ALU_ConvertToInt ();
    3417            0 :       if (M2ALU_GreEqu (tokenno))
    3418              :         {
    3419              :           /* avoid dangling else.  */
    3420            0 :           SymbolTable_PushValue (op1);
    3421            0 :           SymbolTable_PushValue (h->high);
    3422            0 :           if (M2ALU_LessEqu (tokenno))
    3423              :             {
    3424              :               return true;
    3425              :             }
    3426              :         }
    3427              :       else
    3428              :         {
    3429              :           /* op1 is smaller than this and all subsequent ranges  */
    3430              :           return false;
    3431              :         }
    3432            0 :       h = h->next;
    3433              :     }
    3434              :   return false;
    3435              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3436              :   __builtin_unreachable ();
    3437              : }
    3438              : 
    3439              : 
    3440              : /*
    3441              :    SetOp - perform the function doOp on the top two elements of the stack.
    3442              : */
    3443              : 
    3444          230 : static void SetOp (unsigned int tokenno, M2ALU_DoSetProcedure doOp)
    3445              : {
    3446          230 :   M2ALU_PtrToValue__opaque Result;
    3447          230 :   M2ALU_PtrToValue__opaque Set1;
    3448          230 :   M2ALU_PtrToValue__opaque Set2;
    3449              : 
    3450          230 :   Set1 = Pop ();
    3451          230 :   Set2 = Pop ();
    3452          230 :   Eval (tokenno, Set1);
    3453          230 :   Eval (tokenno, Set2);
    3454          230 :   if (! (Set1->solved && Set2->solved))
    3455              :     {
    3456            0 :       M2Error_InternalError ((const char *) "one or more operands have not been resolved", 43);
    3457              :     }
    3458          230 :   if (Set1->type != M2ALU_set)
    3459              :     {
    3460            0 :       M2Error_InternalError ((const char *) "expecting type of constant to be a set", 38);
    3461              :     }
    3462          230 :   if (Set2->type != M2ALU_set)
    3463              :     {
    3464            0 :       M2Error_InternalError ((const char *) "expecting type of constant to be a set", 38);
    3465              :     }
    3466          230 :   Result = New ();
    3467          230 :   Result->type = M2ALU_set;
    3468          230 :   Result->setValue = (*doOp.proc) (tokenno, Set1->setValue, Set2->setValue);
    3469          230 :   Result->constructorType = M2Base_MixTypes (Set1->constructorType, Set2->constructorType, tokenno);
    3470          230 :   Result->solved = false;
    3471              :   /* Set1 and Set2 have given their range lists to the Result  */
    3472          230 :   Set1->setValue = NULL;
    3473          230 :   Set2->setValue = NULL;
    3474          230 :   Eval (tokenno, Result);
    3475          230 :   Push (Result);
    3476          230 :   Dispose (Set1);
    3477          230 :   Dispose (Set2);
    3478          230 : }
    3479              : 
    3480              : 
    3481              : /*
    3482              :    PerformOr - performs a logical OR between the two ranges.
    3483              :                The ranges, r1, r2, are destroyed.
    3484              : */
    3485              : 
    3486          224 : static M2ALU_listOfRange PerformOr (unsigned int tokenno, M2ALU_listOfRange r1, M2ALU_listOfRange r2)
    3487              : {
    3488          224 :   M2ALU_listOfRange i;
    3489              : 
    3490          224 :   i = r1;
    3491          224 :   while ((i != NULL) && (i->next != NULL))
    3492              :     {
    3493              :       i = i->next;
    3494              :     }
    3495          224 :   if (i == NULL)
    3496              :     {
    3497              :       r1 = r2;
    3498              :     }
    3499              :   else
    3500              :     {
    3501          224 :       i->next = r2;
    3502              :     }
    3503          224 :   SortElements (tokenno, r1);
    3504          224 :   CombineElements (tokenno, r1);
    3505          224 :   return r1;
    3506              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3507              :   __builtin_unreachable ();
    3508              : }
    3509              : 
    3510              : 
    3511              : /*
    3512              :    Min - returns the symbol which has the least value.
    3513              : */
    3514              : 
    3515           12 : static unsigned int Min (unsigned int tokenno, unsigned int a, unsigned int b)
    3516              : {
    3517           12 :   SymbolTable_PushValue (a);
    3518           12 :   M2ALU_ConvertToInt ();
    3519           12 :   SymbolTable_PushValue (b);
    3520           12 :   M2ALU_ConvertToInt ();
    3521           12 :   if (M2ALU_Less (tokenno))
    3522              :     {
    3523              :       return a;
    3524              :     }
    3525              :   else
    3526              :     {
    3527            0 :       return b;
    3528              :     }
    3529              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3530              :   __builtin_unreachable ();
    3531              : }
    3532              : 
    3533              : 
    3534              : /*
    3535              :    Max - returns the symbol which has the greatest value.
    3536              : */
    3537              : 
    3538           12 : static unsigned int Max (unsigned int tokenno, unsigned int a, unsigned int b)
    3539              : {
    3540           12 :   SymbolTable_PushValue (a);
    3541           12 :   M2ALU_ConvertToInt ();
    3542           12 :   SymbolTable_PushValue (b);
    3543           12 :   M2ALU_ConvertToInt ();
    3544           12 :   if (M2ALU_Gre (tokenno))
    3545              :     {
    3546              :       return a;
    3547              :     }
    3548              :   else
    3549              :     {
    3550            0 :       return b;
    3551              :     }
    3552              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3553              :   __builtin_unreachable ();
    3554              : }
    3555              : 
    3556              : 
    3557              : /*
    3558              :    IsRangeIntersection - returns TRUE if ranges, r1, and, r2, intersect.
    3559              : */
    3560              : 
    3561           12 : static bool IsRangeIntersection (unsigned int tokenno, M2ALU_listOfRange r1, M2ALU_listOfRange r2)
    3562              : {
    3563           12 :   if ((r1 == NULL) || (r2 == NULL))
    3564              :     {
    3565              :       return false;
    3566              :     }
    3567              :   else
    3568              :     {
    3569              :       /* easier to prove NOT outside limits  */
    3570           12 :       SymbolTable_PushValue (r1->low);
    3571           12 :       M2ALU_ConvertToInt ();
    3572           12 :       SymbolTable_PushValue (r2->high);
    3573           12 :       M2ALU_ConvertToInt ();
    3574           12 :       if (M2ALU_Gre (tokenno))
    3575              :         {
    3576              :           return false;
    3577              :         }
    3578              :       else
    3579              :         {
    3580           12 :           SymbolTable_PushValue (r1->high);
    3581           12 :           M2ALU_ConvertToInt ();
    3582           12 :           SymbolTable_PushValue (r2->low);
    3583           12 :           M2ALU_ConvertToInt ();
    3584           12 :           if (M2ALU_Less (tokenno))
    3585              :             {
    3586              :               return false;
    3587              :             }
    3588              :           else
    3589              :             {
    3590              :               return true;
    3591              :             }
    3592              :         }
    3593              :     }
    3594              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3595              :   __builtin_unreachable ();
    3596              : }
    3597              : 
    3598              : 
    3599              : /*
    3600              :    IsRangeLess - returns TRUE if r1^.low is < r2^.low
    3601              : */
    3602              : 
    3603            0 : static bool IsRangeLess (unsigned int tokenno, M2ALU_listOfRange r1, M2ALU_listOfRange r2)
    3604              : {
    3605            0 :   if ((r1 == NULL) || (r2 == NULL))
    3606              :     {
    3607            0 :       M2Error_InternalError ((const char *) "not expecting NIL ranges", 24);
    3608              :     }
    3609            0 :   SymbolTable_PushValue (r1->high);
    3610            0 :   M2ALU_ConvertToInt ();
    3611            0 :   SymbolTable_PushValue (r2->low);
    3612            0 :   M2ALU_ConvertToInt ();
    3613            0 :   return M2ALU_Less (tokenno);
    3614              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3615              :   __builtin_unreachable ();
    3616              : }
    3617              : 
    3618              : 
    3619              : /*
    3620              :    MinTree - returns the tree symbol which has the least value.
    3621              : */
    3622              : 
    3623        14098 : static tree MinTree (unsigned int tokenno, tree a, tree b)
    3624              : {
    3625        14098 :   M2ALU_PushIntegerTree (a);
    3626        14098 :   M2ALU_ConvertToInt ();
    3627        14098 :   M2ALU_PushIntegerTree (b);
    3628        14098 :   M2ALU_ConvertToInt ();
    3629        14098 :   if (M2ALU_Less (tokenno))
    3630              :     {
    3631              :       return a;
    3632              :     }
    3633              :   else
    3634              :     {
    3635         2062 :       return b;
    3636              :     }
    3637              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3638              :   __builtin_unreachable ();
    3639              : }
    3640              : 
    3641              : 
    3642              : /*
    3643              :    MaxTree - returns the symbol which has the greatest value.
    3644              : */
    3645              : 
    3646        14098 : static tree MaxTree (unsigned int tokenno, tree a, tree b)
    3647              : {
    3648        14098 :   M2ALU_PushIntegerTree (a);
    3649        14098 :   M2ALU_ConvertToInt ();
    3650        14098 :   M2ALU_PushIntegerTree (b);
    3651        14098 :   M2ALU_ConvertToInt ();
    3652        14098 :   if (M2ALU_Gre (tokenno))
    3653              :     {
    3654              :       return a;
    3655              :     }
    3656              :   else
    3657              :     {
    3658         3188 :       return b;
    3659              :     }
    3660              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3661              :   __builtin_unreachable ();
    3662              : }
    3663              : 
    3664              : 
    3665              : /*
    3666              :    IsIntersectionTree - returns TRUE if ranges, a..b, and, c..d, intersect.
    3667              : */
    3668              : 
    3669       156256 : static bool IsIntersectionTree (unsigned int tokenno, tree a, tree b, tree c, tree d)
    3670              : {
    3671              :   /* easier to prove NOT outside limits  */
    3672       156256 :   M2ALU_PushIntegerTree (a);
    3673       156256 :   M2ALU_ConvertToInt ();
    3674       156256 :   M2ALU_PushIntegerTree (d);
    3675       156256 :   M2ALU_ConvertToInt ();
    3676       156256 :   if (M2ALU_Gre (tokenno))
    3677              :     {
    3678              :       return false;
    3679              :     }
    3680              :   else
    3681              :     {
    3682       130360 :       M2ALU_PushIntegerTree (b);
    3683       130360 :       M2ALU_ConvertToInt ();
    3684       130360 :       M2ALU_PushIntegerTree (c);
    3685       130360 :       M2ALU_ConvertToInt ();
    3686       130360 :       if (M2ALU_Less (tokenno))
    3687              :         {
    3688              :           return false;
    3689              :         }
    3690              :       else
    3691              :         {
    3692              :           return true;
    3693              :         }
    3694              :     }
    3695              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3696              :   __builtin_unreachable ();
    3697              : }
    3698              : 
    3699              : 
    3700              : /*
    3701              :    SubTree - returns the tree value containing (a-b)
    3702              : */
    3703              : 
    3704        28196 : static tree SubTree (tree a, tree b)
    3705              : {
    3706        28196 :   M2ALU_PushIntegerTree (a);
    3707        28196 :   M2ALU_PushIntegerTree (b);
    3708        28196 :   M2ALU_Sub ();
    3709        28196 :   return M2ALU_PopIntegerTree ();
    3710              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3711              :   __builtin_unreachable ();
    3712              : }
    3713              : 
    3714              : 
    3715              : /*
    3716              :    PerformAnd - performs a logical AND between the two ranges.
    3717              :                 The ranges, r1, r2, are unaltered.
    3718              : */
    3719              : 
    3720            6 : static M2ALU_listOfRange PerformAnd (unsigned int tokenno, M2ALU_listOfRange r1, M2ALU_listOfRange r2)
    3721              : {
    3722            6 :   M2ALU_listOfRange r;
    3723              : 
    3724            6 :   r = NULL;
    3725           18 :   while ((r1 != NULL) && (r2 != NULL))
    3726              :     {
    3727           12 :       if (IsRangeIntersection (tokenno, r1, r2))
    3728              :         {
    3729           12 :           r = AddRange (r, Max (tokenno, r1->low, r2->low), Min (tokenno, r1->high, r2->high));
    3730           12 :           if (r->high == r1->high)
    3731              :             {
    3732           12 :               r1 = r1->next;
    3733              :             }
    3734              :           else
    3735              :             {
    3736            0 :               r2 = r2->next;
    3737              :             }
    3738              :         }
    3739            0 :       else if (IsRangeLess (tokenno, r1, r2))
    3740              :         {
    3741              :           /* avoid dangling else.  */
    3742              :           /* move r1 onto the next range  */
    3743            0 :           r1 = r1->next;
    3744              :         }
    3745              :       else
    3746              :         {
    3747              :           /* avoid dangling else.  */
    3748              :           /* move r2 onto the next range  */
    3749            0 :           r2 = r2->next;
    3750              :         }
    3751              :     }
    3752            6 :   return r;
    3753              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3754              :   __builtin_unreachable ();
    3755              : }
    3756              : 
    3757              : 
    3758              : /*
    3759              :    ConstructLargeOrSmallSet - generates a constant representing the set value of the symbol, sym.
    3760              :                               We manufacture the constant by using a initialization
    3761              :                               structure of cardinals.
    3762              : 
    3763              :                               { (cardinal), (cardinal) etc }
    3764              : */
    3765              : 
    3766        12328 : static tree ConstructLargeOrSmallSet (unsigned int tokenno, M2ALU_PtrToValue__opaque v, unsigned int low, unsigned int high)
    3767              : {
    3768        12328 :   unsigned int settype;
    3769              : 
    3770        12328 :   M2Debug_Assert (v->constructorType != SymbolTable_NulSym);
    3771        12328 :   settype = SymbolTable_SkipType (v->constructorType);
    3772        12328 :   M2Debug_Assert (SymbolTable_IsSet (settype));
    3773        12328 :   if (SymbolTable_GetSetInWord (settype))
    3774              :     {
    3775              :       /* Narrow set.  */
    3776        10406 :       return m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (settype), BuildBitset (tokenno, v, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high)), false);
    3777              :     }
    3778              :   else
    3779              :     {
    3780              :       /* Wide set.  */
    3781         1922 :       return BuildArrayByteset (tokenno, v, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
    3782              :     }
    3783              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3784              :   __builtin_unreachable ();
    3785              : }
    3786              : 
    3787              : 
    3788              : /*
    3789              :    BuildArrayByteset - v is the PtrToValue.
    3790              :                        low and high are the limits of the subrange.
    3791              : */
    3792              : 
    3793         1922 : static tree BuildArrayByteset (unsigned int tokenno, M2ALU_PtrToValue__opaque v, tree low, tree high)
    3794              : {
    3795         1922 :   location_t location;
    3796         1922 :   tree BitsInSet;
    3797         1922 :   unsigned int BitsPerByte;
    3798         1922 :   m2type_Constructor cons;
    3799              : 
    3800         1922 :   location = M2LexBuf_TokenToLocation (tokenno);
    3801         1922 :   M2ALU_PushIntegerTree (low);
    3802         1922 :   M2ALU_ConvertToInt ();
    3803         1922 :   low = M2ALU_PopIntegerTree ();
    3804         1922 :   M2ALU_PushIntegerTree (high);
    3805         1922 :   M2ALU_ConvertToInt ();
    3806         1922 :   high = M2ALU_PopIntegerTree ();
    3807         1922 :   BitsPerByte = m2decl_GetBitsPerUnit ();
    3808         1922 :   M2ALU_PushIntegerTree (high);
    3809         1922 :   M2ALU_PushIntegerTree (low);
    3810         1922 :   M2ALU_Sub ();
    3811         1922 :   M2ALU_PushCard (1);
    3812         1922 :   M2ALU_Addn ();
    3813         1922 :   BitsInSet = M2ALU_PopIntegerTree ();
    3814         1922 :   cons = m2type_BuildStartSetConstructor (SymbolConversion_Mod2Gcc (v->constructorType));
    3815         1922 :   M2ALU_PushIntegerTree (BitsInSet);
    3816         1922 :   M2ALU_PushCard (0);
    3817        87182 :   while (M2ALU_Gre (tokenno))
    3818              :     {
    3819        83338 :       M2ALU_PushIntegerTree (BitsInSet);
    3820        83338 :       M2ALU_PushCard (BitsPerByte-1);
    3821        83338 :       if (M2ALU_GreEqu (tokenno))
    3822              :         {
    3823        83206 :           M2ALU_PushIntegerTree (low);
    3824        83206 :           M2ALU_PushCard (BitsPerByte-1);
    3825        83206 :           M2ALU_Addn ();
    3826        83206 :           m2type_BuildSetConstructorElement (location, cons, BuildByte (tokenno, v, low, M2ALU_PopIntegerTree ()));
    3827        83206 :           M2ALU_PushIntegerTree (low);
    3828        83206 :           M2ALU_PushCard (BitsPerByte);
    3829        83206 :           M2ALU_Addn ();
    3830        83206 :           low = M2ALU_PopIntegerTree ();
    3831        83206 :           M2ALU_PushIntegerTree (BitsInSet);
    3832        83206 :           M2ALU_PushCard (BitsPerByte);
    3833        83206 :           M2ALU_Sub ();
    3834        83206 :           BitsInSet = M2ALU_PopIntegerTree ();
    3835              :         }
    3836              :       else
    3837              :         {
    3838          132 :           m2type_BuildSetConstructorElement (location, cons, BuildByte (tokenno, v, low, high));
    3839          132 :           M2ALU_PushCard (0);
    3840          132 :           BitsInSet = M2ALU_PopIntegerTree ();
    3841              :         }
    3842        83338 :       M2ALU_PushIntegerTree (BitsInSet);
    3843        83338 :       M2ALU_PushCard (0);
    3844              :     }
    3845         1922 :   return m2type_BuildEndSetConstructor (cons);
    3846              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3847              :   __builtin_unreachable ();
    3848              : }
    3849              : 
    3850              : 
    3851              : /*
    3852              :    ConvertConstToType - returns a Tree containing an initialiser,
    3853              :                         init, ready to be assigned to a record or
    3854              :                         array constructor.
    3855              : */
    3856              : 
    3857         9768 : static tree ConvertConstToType (unsigned int tokenno, unsigned int field, unsigned int init)
    3858              : {
    3859         9768 :   tree initT;
    3860         9768 :   tree nBytes;
    3861              : 
    3862         9768 :   if (((SymbolTable_IsConstString (init)) && (SymbolTable_IsArray (SymbolTable_SkipType (SymbolTable_GetType (field))))) && ((SymbolTable_SkipTypeAndSubrange (SymbolTable_GetType (SymbolTable_GetType (field)))) == M2Base_Char))
    3863              :     {
    3864         2700 :       if (! (M2GenGCC_PrepareCopyString (tokenno, &nBytes, &initT, init, SymbolTable_GetType (field))))
    3865              :         {
    3866            0 :           M2MetaError_MetaErrorT2 (tokenno, (const char *) "string constant {%1Ea} is too large to be assigned to the {%2d} {%2a}", 69, init, field);
    3867              :         }
    3868         2700 :       return initT;
    3869              :     }
    3870              :   else
    3871              :     {
    3872         7068 :       return m2convert_ConvertConstantAndCheck (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (SymbolTable_GetType (field)), SymbolConversion_Mod2Gcc (init));
    3873              :     }
    3874              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3875              :   __builtin_unreachable ();
    3876              : }
    3877              : 
    3878              : 
    3879              : /*
    3880              :    ConstructRecordConstant - builds a struct initializer, as defined by, v.
    3881              : */
    3882              : 
    3883         2380 : static tree ConstructRecordConstant (unsigned int tokenno, M2ALU_PtrToValue__opaque v)
    3884              : {
    3885         2380 :   NameKey_Name n1;
    3886         2380 :   NameKey_Name n2;
    3887         2380 :   unsigned int i;
    3888         2380 :   unsigned int Field;
    3889         2380 :   unsigned int baseType;
    3890         2380 :   m2type_Constructor cons;
    3891              : 
    3892         2380 :   if (v->constructorType == SymbolTable_NulSym)
    3893              :     {
    3894            0 :       M2Error_InternalError ((const char *) "record type must be known in order to generate a constant", 57);
    3895              :     }
    3896              :   else
    3897              :     {
    3898         2380 :       baseType = SymbolTable_SkipType (v->constructorType);
    3899         2380 :       if (Debugging)
    3900              :         {
    3901              :           n1 = SymbolTable_GetSymName (v->constructorType);
    3902              :           n2 = SymbolTable_GetSymName (baseType);
    3903              :           M2Printf_printf2 ((const char *) "ConstructRecordConstant of type %a and baseType %a\\n", 52, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
    3904              :         }
    3905         2380 :       cons = m2type_BuildStartRecordConstructor (SymbolConversion_Mod2Gcc (baseType));
    3906         2380 :       i = 1;
    3907        12148 :       do {
    3908        12148 :         Field = SymbolTable_GetNth (baseType, i);
    3909        12148 :         if (Field != SymbolTable_NulSym)
    3910              :           {
    3911              :             /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    3912         9768 :             if (SymbolConversion_GccKnowsAbout (SymbolTable_GetType (Field)))
    3913              :               {
    3914         9768 :                 m2type_BuildRecordConstructorElement (cons, ConvertConstToType (tokenno, Field, GetConstructorField (v, i)));
    3915              :               }
    3916              :             else
    3917              :               {
    3918            0 :                 M2MetaError_MetaErrorT0 (tokenno, (const char *) "trying to construct a compound literal and using a record field which does not exist", 84);
    3919              :               }
    3920              :           }
    3921        12148 :         i += 1;
    3922        12148 :       } while (! (Field == SymbolTable_NulSym));
    3923         2380 :       return m2type_BuildEndRecordConstructor (cons);
    3924              :     }
    3925              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    3926              :   __builtin_unreachable ();
    3927              : }
    3928              : 
    3929              : 
    3930              : /*
    3931              :    GetConstructorField - returns a symbol containing the constructor field, i.
    3932              : */
    3933              : 
    3934         9768 : static unsigned int GetConstructorField (M2ALU_PtrToValue__opaque v, unsigned int i)
    3935              : {
    3936         9768 :   unsigned int j;
    3937         9768 :   M2ALU_listOfFields f;
    3938              : 
    3939         9768 :   if (v->type != M2ALU_record)
    3940              :     {
    3941            0 :       M2Error_InternalError ((const char *) "constructor type must be a record in order to push a field", 58);
    3942              :     }
    3943              :   else
    3944              :     {
    3945         9768 :       if (v->constructorType == SymbolTable_NulSym)
    3946              :         {
    3947            0 :           M2Error_InternalError ((const char *) "constructor type must be a record in order to push a field", 58);
    3948              :         }
    3949              :       else
    3950              :         {
    3951         9768 :           j = 1;
    3952         9768 :           f = v->fieldValues;
    3953        26364 :           while ((j < i) && (f != NULL))
    3954              :             {
    3955        16596 :               f = f->next;
    3956        16596 :               j += 1;
    3957              :             }
    3958         9768 :           if (f == NULL)
    3959              :             {
    3960            0 :               M2MetaError_MetaError1 ((const char *) "the {%1EN} element does not exist in the constant compound literal", 66, i);
    3961            0 :               return SymbolTable_NulSym;
    3962              :             }
    3963              :           else
    3964              :             {
    3965         9768 :               return f->field;
    3966              :             }
    3967              :         }
    3968              :     }
    3969              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    3970              :   __builtin_unreachable ();
    3971              : }
    3972              : 
    3973              : 
    3974              : /*
    3975              :    GetConstructorElement - returns a symbol containing the array constructor element, i.
    3976              : */
    3977              : 
    3978       306186 : static unsigned int GetConstructorElement (unsigned int tokenno, M2ALU_PtrToValue__opaque v, unsigned int i)
    3979              : {
    3980       306186 :   tree j;
    3981       306186 :   M2ALU_listOfElements e;
    3982              : 
    3983       306186 :   if (v->type != M2ALU_array)
    3984              :     {
    3985            0 :       M2Error_InternalError ((const char *) "constructor type must be an array", 33);
    3986              :     }
    3987              :   else
    3988              :     {
    3989       306186 :       if (v->constructorType == SymbolTable_NulSym)
    3990              :         {
    3991            0 :           M2Error_InternalError ((const char *) "constructor type must be an array", 33);
    3992              :         }
    3993              :       else
    3994              :         {
    3995       306186 :           M2ALU_PushCard (i);
    3996       306186 :           j = M2ALU_PopIntegerTree ();
    3997       306186 :           e = v->arrayValues;
    3998       688114 :           while (e != NULL)
    3999              :             {
    4000       571318 :               SymbolTable_PushValue (e->by);
    4001       571318 :               M2ALU_PushIntegerTree (j);
    4002       571318 :               if (M2ALU_GreEqu (tokenno))
    4003              :                 {
    4004       189390 :                   return e->element;
    4005              :                 }
    4006       381928 :               M2ALU_PushIntegerTree (j);
    4007       381928 :               M2ALU_ConvertToInt ();
    4008       381928 :               SymbolTable_PushValue (e->by);
    4009       381928 :               M2ALU_ConvertToInt ();
    4010       381928 :               M2ALU_Sub ();
    4011       381928 :               j = M2ALU_PopIntegerTree ();
    4012       381928 :               e = e->next;
    4013              :             }
    4014       116796 :           if (e == NULL)
    4015              :             {
    4016              :               /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    4017       116796 :               if ((SymbolTable_IsArray (SymbolTable_SkipType (v->constructorType))) && ((SymbolTable_GetType (SymbolTable_SkipType (v->constructorType))) == M2Base_Char))
    4018              :                 {
    4019       116796 :                   return SymbolTable_MakeConstLit (tokenno, NameKey_MakeKey ((const char *) "0", 1), M2Base_Char);
    4020              :                 }
    4021              :               else
    4022              :                 {
    4023            0 :                   M2MetaError_MetaErrorT2 (tokenno, (const char *) "the {%1EN} element does not exist in the {%2ad} array declaration used by the compound literal", 94, i, v->constructorType);
    4024              :                 }
    4025              :             }
    4026              :         }
    4027              :     }
    4028            0 :   return SymbolTable_NulSym;
    4029              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4030              :   __builtin_unreachable ();
    4031              : }
    4032              : 
    4033              : 
    4034              : /*
    4035              :    IsString - returns TRUE if sym is an ARRAY [..] OF CHAR
    4036              : */
    4037              : 
    4038         4544 : static bool IsString (unsigned int sym)
    4039              : {
    4040         4544 :   return (((SymbolTable_IsArray (sym)) && ((SymbolTable_SkipType (SymbolTable_GetType (sym))) == M2Base_Char)) || (SymbolTable_IsConstString (sym))) || ((SymbolTable_IsConst (sym)) && ((SymbolTable_SkipType (SymbolTable_GetType (sym))) == M2Base_Char));
    4041              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4042              :   __builtin_unreachable ();
    4043              : }
    4044              : 
    4045              : 
    4046              : /*
    4047              :    StringFitsArray -
    4048              : */
    4049              : 
    4050          456 : static bool StringFitsArray (unsigned int arrayType, unsigned int el, unsigned int tokenno)
    4051              : {
    4052          456 :   location_t location;
    4053              : 
    4054          456 :   location = M2LexBuf_TokenToLocation (tokenno);
    4055          456 :   M2ALU_PushIntegerTree (m2type_BuildNumberOfArrayElements (location, SymbolConversion_Mod2Gcc (arrayType)));
    4056          456 :   if (SymbolTable_IsConstString (el))
    4057              :     {
    4058          456 :       M2ALU_PushCard (SymbolTable_GetStringLength (tokenno, el));
    4059              :     }
    4060            0 :   else if (((SymbolTable_IsConst (el)) && ((SymbolTable_SkipType (SymbolTable_GetType (el))) == M2Base_Char)) && (SymbolTable_IsValueSolved (el)))
    4061              :     {
    4062              :       /* avoid dangling else.  */
    4063            0 :       M2ALU_PushCard (1);
    4064              :     }
    4065              :   else
    4066              :     {
    4067              :       /* avoid dangling else.  */
    4068            0 :       M2ALU_PushCard (0);
    4069            0 :       M2MetaError_MetaError1 ((const char *) "cannot build a string using {%1Ead}", 35, el);
    4070              :     }
    4071          456 :   return M2ALU_GreEqu (tokenno);
    4072              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4073              :   __builtin_unreachable ();
    4074              : }
    4075              : 
    4076              : 
    4077              : /*
    4078              :    GetArrayLimits -
    4079              : */
    4080              : 
    4081         1246 : static void GetArrayLimits (unsigned int array, unsigned int *low, unsigned int *high)
    4082              : {
    4083         1246 :   unsigned int Subscript;
    4084         1246 :   unsigned int Subrange;
    4085              : 
    4086         1246 :   Subscript = SymbolTable_GetArraySubscript (array);
    4087         1246 :   Subrange = SymbolTable_SkipType (SymbolTable_GetType (Subscript));
    4088         1246 :   if (SymbolTable_IsEnumeration (Subrange))
    4089              :     {
    4090           32 :       M2Base_GetBaseTypeMinMax (Subrange, low, high);
    4091              :     }
    4092              :   else
    4093              :     {
    4094         1214 :       SymbolTable_GetSubrange (Subrange, high, low);
    4095              :     }
    4096         1246 : }
    4097              : 
    4098              : 
    4099              : /*
    4100              :    InitialiseArrayOfCharWithString -
    4101              : */
    4102              : 
    4103          456 : static tree InitialiseArrayOfCharWithString (unsigned int tokenno, void * cons, unsigned int el, unsigned int baseType, unsigned int arrayType)
    4104              : {
    4105          456 :   bool isChar;
    4106          456 :   DynamicStrings_String s;
    4107          456 :   DynamicStrings_String letter;
    4108          456 :   unsigned int i;
    4109          456 :   unsigned int l;
    4110          456 :   unsigned int high;
    4111          456 :   unsigned int low;
    4112          456 :   tree value;
    4113          456 :   tree indice;
    4114          456 :   location_t location;
    4115              : 
    4116          456 :   location = M2LexBuf_TokenToLocation (tokenno);
    4117          456 :   GetArrayLimits (baseType, &low, &high);
    4118          456 :   l = 0;
    4119          456 :   s = static_cast<DynamicStrings_String> (NULL);
    4120          456 :   if (SymbolTable_IsConstString (el))
    4121              :     {
    4122          456 :       isChar = false;
    4123          456 :       s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetString (el)));
    4124          456 :       l = SymbolTable_GetStringLength (tokenno, el);
    4125              :     }
    4126            0 :   else if (((SymbolTable_IsConst (el)) && ((SymbolTable_SkipType (SymbolTable_GetType (el))) == M2Base_Char)) && (SymbolTable_IsValueSolved (el)))
    4127              :     {
    4128              :       /* avoid dangling else.  */
    4129              :       isChar = true;
    4130              :     }
    4131              :   else
    4132              :     {
    4133              :       /* avoid dangling else.  */
    4134            0 :       M2MetaError_MetaError1 ((const char *) "cannot build a string using {%1Ead}", 35, el);
    4135            0 :       isChar = false;
    4136              :     }
    4137          456 :   i = 0;
    4138         1824 :   do {
    4139         1824 :     SymbolTable_PushValue (low);
    4140         1824 :     M2ALU_PushCard (i);
    4141         1824 :     M2ALU_Addn ();
    4142         1824 :     indice = M2ALU_PopIntegerTree ();
    4143         1824 :     letter = static_cast<DynamicStrings_String> (NULL);
    4144         1824 :     if (isChar)
    4145              :       {
    4146            0 :         isChar = false;
    4147            0 :         SymbolTable_PushValue (el);
    4148            0 :         value = M2ALU_PopIntegerTree ();
    4149              :       }
    4150         1824 :     else if (i < l)
    4151              :       {
    4152              :         /* avoid dangling else.  */
    4153         1368 :         if ((i+1) < l)
    4154              :           {
    4155          912 :             letter = DynamicStrings_Slice (s, static_cast<int> (i), static_cast<int> (i+1));
    4156              :           }
    4157              :         else
    4158              :           {
    4159          456 :             letter = DynamicStrings_Slice (s, static_cast<int> (i), 0);
    4160              :           }
    4161         1368 :         value = m2type_BuildCharConstant (location, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (letter))));
    4162              :       }
    4163              :     else
    4164              :       {
    4165              :         /* avoid dangling else.  */
    4166          456 :         letter = DynamicStrings_InitStringChar (ASCII_nul);
    4167          456 :         value = m2type_BuildCharConstant (location, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (letter))));
    4168              :       }
    4169         1824 :     value = m2convert_ConvertConstantAndCheck (location, SymbolConversion_Mod2Gcc (arrayType), value);
    4170         1824 :     letter = DynamicStrings_KillString (letter);
    4171         1824 :     m2type_BuildArrayConstructorElement (cons, value, indice);
    4172         1824 :     SymbolTable_PushValue (low);
    4173         1824 :     M2ALU_PushCard (i);
    4174         1824 :     M2ALU_Addn ();
    4175         1824 :     SymbolTable_PushValue (high);
    4176         1824 :     i += 1;
    4177         1824 :   } while (! (M2ALU_GreEqu (tokenno)));
    4178          456 :   s = DynamicStrings_KillString (s);
    4179          456 :   if (! (StringFitsArray (baseType, el, tokenno)))
    4180              :     {
    4181            0 :       M2MetaError_MetaError2 ((const char *) "string {%1Ea} is too large to fit into array {%2ad}", 51, el, baseType);
    4182              :     }
    4183              :   /* 
    4184              :    IF v#NIL
    4185              :    THEN
    4186              :       el := GetConstructorElement(tokenno, v, 2) ;
    4187              :       IF el#NulSym
    4188              :       THEN
    4189              :          MetaError1('not allowed to have multiple strings to initialise an array of characters {%1Ua}', el)
    4190              :       END
    4191              :    END ;
    4192              :   */
    4193          456 :   return m2type_BuildEndArrayConstructor (cons);
    4194              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4195              :   __builtin_unreachable ();
    4196              : }
    4197              : 
    4198              : 
    4199              : /*
    4200              :    CheckElementString -
    4201              : */
    4202              : 
    4203         4088 : static tree CheckElementString (unsigned int el, unsigned int arrayType, unsigned int tokenno)
    4204              : {
    4205         4088 :   void * cons;
    4206              : 
    4207         4088 :   if ((IsString (arrayType)) && (IsString (el)))
    4208              :     {
    4209          456 :       cons = m2type_BuildStartArrayConstructor (SymbolConversion_Mod2Gcc (arrayType));
    4210          456 :       return InitialiseArrayOfCharWithString (tokenno, cons, el, arrayType, SymbolTable_SkipType (SymbolTable_GetType (arrayType)));
    4211              :     }
    4212              :   else
    4213              :     {
    4214         3632 :       return SymbolConversion_Mod2Gcc (el);
    4215              :     }
    4216              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4217              :   __builtin_unreachable ();
    4218              : }
    4219              : 
    4220              : 
    4221              : /*
    4222              :    InitialiseArrayWith -
    4223              : */
    4224              : 
    4225          538 : static tree InitialiseArrayWith (unsigned int tokenno, void * cons, M2ALU_PtrToValue__opaque v, unsigned int el, unsigned int high, unsigned int low, unsigned int arrayType)
    4226              : {
    4227          538 :   location_t location;
    4228          538 :   unsigned int i;
    4229          538 :   tree indice;
    4230          538 :   tree value;
    4231              : 
    4232          538 :   location = M2LexBuf_TokenToLocation (tokenno);
    4233          538 :   i = 0;
    4234         4626 :   while (el != SymbolTable_NulSym)
    4235              :     {
    4236         4088 :       SymbolTable_PushValue (low);
    4237         4088 :       M2ALU_ConvertToInt ();
    4238         4088 :       M2ALU_PushInt (static_cast<int> (i));
    4239         4088 :       M2ALU_Addn ();
    4240         4088 :       indice = M2ALU_PopIntegerTree ();
    4241         4088 :       value = CheckElementString (el, arrayType, tokenno);
    4242         4088 :       if (value == NULL)
    4243              :         {
    4244            0 :           M2MetaError_MetaErrorT0 (tokenno, (const char *) "{%W}too few characters found when trying to construct a compound literal array", 78);
    4245            0 :           value = m2expr_GetCardinalZero (location);
    4246              :         }
    4247         4088 :       value = m2convert_ConvertConstantAndCheck (location, SymbolConversion_Mod2Gcc (arrayType), value);
    4248         4088 :       m2type_BuildArrayConstructorElement (cons, value, indice);
    4249         4088 :       SymbolTable_PushValue (low);
    4250         4088 :       M2ALU_ConvertToInt ();
    4251         4088 :       M2ALU_PushInt (static_cast<int> (i));
    4252         4088 :       M2ALU_Addn ();
    4253         4088 :       SymbolTable_PushValue (high);
    4254         4088 :       M2ALU_ConvertToInt ();
    4255         4088 :       if (M2ALU_GreEqu (tokenno))
    4256              :         {
    4257          538 :           return m2type_BuildEndArrayConstructor (cons);
    4258              :         }
    4259         3550 :       i += 1;
    4260         3550 :       el = GetConstructorElement (tokenno, v, i+1);
    4261              :     }
    4262            0 :   return m2type_BuildEndArrayConstructor (cons);
    4263              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4264              :   __builtin_unreachable ();
    4265              : }
    4266              : 
    4267              : 
    4268              : /*
    4269              :    CheckGetCharFromString - return TRUE if a char from the position arrayIndex in the list of
    4270              :                             constDecl elements can be extracted.  The character is returned
    4271              :                             in value.
    4272              : */
    4273              : 
    4274         7308 : static bool CheckGetCharFromString (location_t location, unsigned int tokenno, M2ALU_PtrToValue__opaque constDecl, unsigned int consType, unsigned int arrayIndex, tree *value)
    4275              : {
    4276         7308 :   unsigned int elementIndex;
    4277         7308 :   unsigned int element;
    4278         7308 :   unsigned int offset;
    4279         7308 :   unsigned int totalLength;
    4280         7308 :   NameKey_Name key;
    4281              : 
    4282         7308 :   totalLength = 0;
    4283         7308 :   elementIndex = 1;
    4284       301056 :   do {
    4285       301056 :     element = GetConstructorElement (tokenno, constDecl, elementIndex);
    4286       301056 :     offset = totalLength;
    4287       301056 :     if (SymbolTable_IsConstString (element))
    4288              :       {
    4289              :         /* avoid dangling else.  */
    4290       184236 :         totalLength += SymbolTable_GetStringLength (tokenno, element);
    4291       184236 :         if (totalLength > arrayIndex)
    4292              :           {
    4293         4320 :             key = SymbolTable_GetString (element);
    4294         4320 :             arrayIndex -= offset;
    4295         4320 :             (*value) = m2type_BuildCharConstantChar (location, NameKey_CharKey (key, arrayIndex));
    4296         4320 :             return true;
    4297              :           }
    4298              :       }
    4299       116820 :     else if (((SymbolTable_IsConst (element)) && ((SymbolTable_SkipType (SymbolTable_GetType (element))) == M2Base_Char)) && (SymbolTable_IsValueSolved (element)))
    4300              :       {
    4301              :         /* avoid dangling else.  */
    4302       116700 :         totalLength += 1;
    4303       116700 :         if (totalLength > arrayIndex)
    4304              :           {
    4305         2940 :             SymbolTable_PushValue (element);
    4306         2940 :             (*value) = m2convert_ConvertConstantAndCheck (location, m2type_GetM2CharType (), M2ALU_PopIntegerTree ());
    4307         2940 :             return true;
    4308              :           }
    4309              :       }
    4310              :     else
    4311              :       {
    4312              :         /* avoid dangling else.  */
    4313          120 :         totalLength += 1;
    4314          120 :         if (totalLength > arrayIndex)
    4315              :           {
    4316           48 :             M2MetaError_MetaErrorT3 (tokenno, (const char *) "expecting {%kCHAR} datatype and not {%1Ea} a {%1tad} in the {%2N} component of the {%3a} {%3d}", 94, element, arrayIndex, consType);
    4317           48 :             (*value) = m2expr_GetCardinalZero (location);
    4318           48 :             return false;
    4319              :           }
    4320              :       }
    4321       293748 :     elementIndex += 1;
    4322       293748 :   } while (! (element == SymbolTable_NulSym));
    4323            0 :   (*value) = m2expr_GetCardinalZero (location);
    4324            0 :   M2MetaError_MetaErrorT2 (tokenno, (const char *) "unable to obtain a {%kCHAR} at the {%1EN} position in {%2ad}", 60, arrayIndex, consType);
    4325            0 :   return false;
    4326              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4327              :   __builtin_unreachable ();
    4328              : }
    4329              : 
    4330              : 
    4331              : /*
    4332              :    InitialiseArrayOfCharWith -
    4333              : */
    4334              : 
    4335          252 : static tree InitialiseArrayOfCharWith (unsigned int tokenno, void * cons, M2ALU_PtrToValue__opaque constDecl, unsigned int el, unsigned int high, unsigned int low, unsigned int consType, unsigned int arrayType)
    4336              : {
    4337          252 :   location_t location;
    4338          252 :   unsigned int arrayIndex;
    4339          252 :   tree indice;
    4340          252 :   tree value;
    4341              : 
    4342          252 :   location = M2LexBuf_TokenToLocation (tokenno);  /* arrayIndex is the char position index of the final string.  */
    4343          252 :   arrayIndex = 0;
    4344         7560 :   while (el != SymbolTable_NulSym)
    4345              :     {
    4346         7308 :       SymbolTable_PushValue (low);
    4347         7308 :       M2ALU_ConvertToInt ();
    4348         7308 :       M2ALU_PushInt (static_cast<int> (arrayIndex));
    4349         7308 :       M2ALU_Addn ();
    4350         7308 :       indice = M2ALU_PopIntegerTree ();
    4351         7308 :       if (! (CheckGetCharFromString (location, tokenno, constDecl, consType, arrayIndex, &value)))
    4352              :         {}  /* empty.  */
    4353              :       /* 
    4354              :          MetaErrorT2 (tokenno,
    4355              :                       'unable to obtain a {%kCHAR} at the {%1EN} position in {%2ad}',
    4356              :                       arrayIndex, consType) ;
    4357              :   */
    4358         7308 :       value = m2convert_ConvertConstantAndCheck (location, SymbolConversion_Mod2Gcc (arrayType), value);
    4359         7308 :       m2type_BuildArrayConstructorElement (cons, value, indice);
    4360         7308 :       SymbolTable_PushValue (low);
    4361         7308 :       M2ALU_ConvertToInt ();
    4362         7308 :       M2ALU_PushInt (static_cast<int> (arrayIndex));
    4363         7308 :       M2ALU_Addn ();
    4364         7308 :       SymbolTable_PushValue (high);
    4365         7308 :       M2ALU_ConvertToInt ();
    4366         7308 :       if (M2ALU_GreEqu (tokenno))
    4367              :         {
    4368          252 :           return m2type_BuildEndArrayConstructor (cons);
    4369              :         }
    4370         7056 :       arrayIndex += 1;
    4371              :     }
    4372            0 :   return m2type_BuildEndArrayConstructor (cons);
    4373              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4374              :   __builtin_unreachable ();
    4375              : }
    4376              : 
    4377              : 
    4378              : /*
    4379              :    ConstructArrayConstant - builds a struct initializer, as defined by, v.
    4380              : */
    4381              : 
    4382          790 : static tree ConstructArrayConstant (unsigned int tokenno, M2ALU_PtrToValue__opaque v)
    4383              : {
    4384          790 :   NameKey_Name n1;
    4385          790 :   NameKey_Name n2;
    4386          790 :   unsigned int el1;
    4387          790 :   unsigned int el2;
    4388          790 :   unsigned int baseType;
    4389          790 :   unsigned int arrayType;
    4390          790 :   unsigned int high;
    4391          790 :   unsigned int low;
    4392          790 :   void * cons;
    4393              : 
    4394          790 :   if (v->constructorType == SymbolTable_NulSym)
    4395              :     {
    4396            0 :       M2Error_InternalError ((const char *) "array type must be known in order to generate a constant", 56);
    4397              :     }
    4398              :   else
    4399              :     {
    4400          790 :       baseType = SymbolTable_SkipType (v->constructorType);
    4401          790 :       if (Debugging)
    4402              :         {
    4403              :           n1 = SymbolTable_GetSymName (v->constructorType);
    4404              :           n2 = SymbolTable_GetSymName (baseType);
    4405              :           M2Printf_printf2 ((const char *) "ConstructArrayConstant of type %a and baseType %a\\n", 51, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
    4406              :         }
    4407          790 :       cons = m2type_BuildStartArrayConstructor (SymbolConversion_Mod2Gcc (baseType));
    4408          790 :       GetArrayLimits (baseType, &low, &high);
    4409          790 :       arrayType = SymbolTable_GetType (baseType);
    4410          790 :       el1 = GetConstructorElement (tokenno, v, 1);
    4411          790 :       el2 = GetConstructorElement (tokenno, v, 2);
    4412          790 :       if (((el2 == SymbolTable_NulSym) && (IsString (baseType))) && (IsString (el1)))
    4413              :         {
    4414              :           /* constructorType is ARRAY [low..high] OF CHAR and using a string to initialise it  */
    4415            0 :           return InitialiseArrayOfCharWithString (tokenno, cons, el1, baseType, arrayType);
    4416              :         }
    4417          790 :       else if ((SymbolTable_SkipType (arrayType)) == M2Base_Char)
    4418              :         {
    4419              :           /* avoid dangling else.  */
    4420          252 :           return InitialiseArrayOfCharWith (tokenno, cons, v, el1, high, low, baseType, arrayType);
    4421              :         }
    4422              :       else
    4423              :         {
    4424              :           /* avoid dangling else.  */
    4425          538 :           return InitialiseArrayWith (tokenno, cons, v, el1, high, low, arrayType);
    4426              :         }
    4427              :     }
    4428              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    4429              :   __builtin_unreachable ();
    4430              : }
    4431              : 
    4432              : 
    4433              : /*
    4434              :    BuildBitset - given a set, v, construct the bitmask for its
    4435              :                  constant value which lie in the range low..high.
    4436              : */
    4437              : 
    4438        10406 : static tree BuildBitset (unsigned int tokenno, M2ALU_PtrToValue__opaque v, tree low, tree high)
    4439              : {
    4440        10406 :   tree tl;
    4441        10406 :   tree th;
    4442        10406 :   tree t;
    4443        10406 :   unsigned int n;
    4444        10406 :   unsigned int r1;
    4445        10406 :   unsigned int r2;
    4446        10406 :   location_t location;
    4447              : 
    4448        10406 :   location = M2LexBuf_TokenToLocation (tokenno);
    4449        10406 :   low = m2convert_ToInteger (location, low);
    4450        10406 :   high = m2convert_ToInteger (location, high);
    4451        10406 :   n = 1;
    4452        10406 :   t = m2expr_GetCardinalZero (location);
    4453        31306 :   while (M2ALU_GetRange (static_cast<M2ALU_PtrToValue> (v), n, &r1, &r2))
    4454              :     {
    4455        10494 :       SymbolTable_PushValue (r1);
    4456        10494 :       tl = m2convert_ToInteger (location, M2ALU_PopIntegerTree ());
    4457        10494 :       SymbolTable_PushValue (r2);
    4458        10494 :       th = m2convert_ToInteger (location, M2ALU_PopIntegerTree ());
    4459        10494 :       if (IsIntersectionTree (tokenno, tl, th, low, high))
    4460              :         {
    4461        10494 :           tl = m2convert_ToCardinal (location, SubTree (MaxTree (tokenno, tl, low), low));
    4462        10494 :           th = m2convert_ToCardinal (location, SubTree (MinTree (tokenno, th, high), low));
    4463        10494 :           t = m2expr_BuildLogicalOr (location, t, M2ALU_BuildRange (tokenno, tl, th));
    4464              :         }
    4465        10494 :       n += 1;
    4466              :     }
    4467        10406 :   return m2convert_ToBitset (location, t);
    4468              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4469              :   __builtin_unreachable ();
    4470              : }
    4471              : 
    4472              : 
    4473              : /*
    4474              :    BuildByte - given a set v construct the bitmask for its
    4475              :                constant value which lie in the range low..high.
    4476              : */
    4477              : 
    4478        83338 : static tree BuildByte (unsigned int tokenno, M2ALU_PtrToValue__opaque v, tree low, tree high)
    4479              : {
    4480        83338 :   tree tl;
    4481        83338 :   tree th;
    4482        83338 :   tree t;
    4483        83338 :   unsigned int n;
    4484        83338 :   unsigned int r1;
    4485        83338 :   unsigned int r2;
    4486        83338 :   location_t location;
    4487              : 
    4488        83338 :   location = M2LexBuf_TokenToLocation (tokenno);
    4489        83338 :   low = m2convert_ToInteger (location, low);
    4490        83338 :   high = m2convert_ToInteger (location, high);
    4491        83338 :   n = 1;
    4492        83338 :   t = m2expr_GetCardinalZero (location);
    4493       312438 :   while (M2ALU_GetRange (static_cast<M2ALU_PtrToValue> (v), n, &r1, &r2))
    4494              :     {
    4495       145762 :       SymbolTable_PushValue (r1);
    4496       145762 :       tl = m2convert_ToInteger (location, M2ALU_PopIntegerTree ());
    4497       145762 :       SymbolTable_PushValue (r2);
    4498       145762 :       th = m2convert_ToInteger (location, M2ALU_PopIntegerTree ());
    4499       145762 :       if (IsIntersectionTree (tokenno, tl, th, low, high))
    4500              :         {
    4501         3604 :           tl = m2convert_ToCardinal (location, SubTree (MaxTree (tokenno, tl, low), low));
    4502         3604 :           th = m2convert_ToCardinal (location, SubTree (MinTree (tokenno, th, high), low));
    4503         3604 :           t = m2expr_BuildLogicalOr (location, t, M2ALU_BuildRange (tokenno, tl, th));
    4504              :         }
    4505       145762 :       n += 1;
    4506              :     }
    4507        83338 :   return m2convert_ToPIMByte (location, t);
    4508              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4509              :   __builtin_unreachable ();
    4510              : }
    4511              : 
    4512              : 
    4513              : /*
    4514              :    CheckOverflow - tests to see whether the tree, t, has caused
    4515              :                    an overflow error and if so it generates an
    4516              :                    error message.
    4517              : */
    4518              : 
    4519       396571 : static void CheckOverflow (unsigned int tokenno, tree t)
    4520              : {
    4521       396571 :   if (m2expr_TreeOverflow (t))
    4522              :     {
    4523           12 :       M2MetaError_MetaErrorT0 (tokenno, (const char *) "constant overflow error", 23);
    4524           12 :       M2Error_FlushErrors ();
    4525              :     }
    4526       396559 : }
    4527              : 
    4528              : 
    4529              : /*
    4530              :    PushGCCArrayTree - pushes a gcc tree value onto the ALU stack.
    4531              : */
    4532              : 
    4533            0 : static void PushGCCArrayTree (tree gcc, unsigned int t)
    4534              : {
    4535            0 :   M2ALU_PtrToValue__opaque v;
    4536              : 
    4537            0 :   v = New ();
    4538            0 :   v->constructorType = t;
    4539            0 :   v->type = M2ALU_array;
    4540            0 :   v->numberValue = gcc;
    4541            0 :   v->arrayValues = NULL;
    4542            0 :   v->areAllConstants = true;
    4543            0 :   v->solved = true;
    4544            0 :   Push (v);
    4545            0 : }
    4546              : 
    4547              : 
    4548              : /*
    4549              :    PushGCCSetTree - pushes a gcc tree value onto the ALU stack.
    4550              : */
    4551              : 
    4552           18 : static void PushGCCSetTree (tree gcc, unsigned int t)
    4553              : {
    4554           18 :   M2ALU_PtrToValue__opaque v;
    4555              : 
    4556           18 :   v = New ();
    4557           18 :   v->constructorType = t;
    4558           18 :   v->type = M2ALU_set;
    4559           18 :   v->numberValue = gcc;
    4560           18 :   v->setValue = NULL;
    4561           18 :   v->areAllConstants = true;
    4562           18 :   v->solved = true;
    4563           18 :   Push (v);
    4564           18 : }
    4565              : 
    4566              : 
    4567              : /*
    4568              :    PushGCCRecordTree - pushes a gcc tree value onto the ALU stack.
    4569              : */
    4570              : 
    4571            0 : static void PushGCCRecordTree (tree gcc, unsigned int t)
    4572              : {
    4573            0 :   M2ALU_PtrToValue__opaque v;
    4574              : 
    4575            0 :   v = New ();
    4576            0 :   v->constructorType = t;
    4577            0 :   v->type = M2ALU_record;
    4578            0 :   v->numberValue = gcc;
    4579            0 :   v->fieldValues = NULL;
    4580            0 :   v->areAllConstants = true;
    4581            0 :   v->solved = true;
    4582            0 :   Push (v);
    4583            0 : }
    4584              : 
    4585              : 
    4586              : /*
    4587              :    Init - initialises the stack and the free list.
    4588              : */
    4589              : 
    4590        14952 : static void Init (void)
    4591              : {
    4592        14952 :   FreeList = static_cast<M2ALU_PtrToValue__opaque> (NULL);
    4593        14952 :   TopOfStack = static_cast<M2ALU_PtrToValue__opaque> (NULL);
    4594        14952 :   RangeFreeList = NULL;
    4595        14952 :   FieldFreeList = NULL;
    4596        14952 :   ElementFreeList = NULL;
    4597        14952 :   StackMemDiag = M2Diagnostic_InitMemDiagnostic ((const char *) "M2ALU:Stack", 11, (const char *) "{0N} total symbols {1d} consuming {2M} ram {0M} ({2P})", 54);
    4598        14952 :   RangeMemDiag = M2Diagnostic_InitMemDiagnostic ((const char *) "M2ALU:Range", 11, (const char *) "{0N} total symbols {1d} consuming {2M} ram {0M} ({2P})", 54);
    4599        14952 : }
    4600              : 
    4601              : 
    4602              : /*
    4603              :    InitValue - initializes and returns a memory cell.
    4604              : */
    4605              : 
    4606     56967092 : extern "C" M2ALU_PtrToValue M2ALU_InitValue (void)
    4607              : {
    4608     56967092 :   M2ALU_PtrToValue__opaque v;
    4609              : 
    4610     56967092 :   v = New ();
    4611     56967092 :   if (v == NULL)
    4612              :     {
    4613              :       M2Error_InternalError ((const char *) "out of memory error", 19);
    4614              :     }
    4615              :   else
    4616              :     {
    4617     56967092 :       v->location = m2linemap_UnknownLocation ();
    4618     56967092 :       v->type = M2ALU_none;
    4619     56967092 :       v->areAllConstants = true;
    4620     56967092 :       v->solved = false;
    4621     56967092 :       v->next = static_cast<M2ALU_PtrToValue__opaque> (NULL);
    4622     56967092 :       v->constructorType = SymbolTable_NulSym;
    4623     56967092 :       return static_cast<M2ALU_PtrToValue> (v);
    4624              :     }
    4625              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    4626              :   __builtin_unreachable ();
    4627              : }
    4628              : 
    4629              : 
    4630              : /*
    4631              :    KillValue - deconstructor for value.  value is set to NIL upon return.
    4632              : */
    4633              : 
    4634            0 : extern "C" void M2ALU_KillValue (M2ALU_PtrToValue *value)
    4635              : {
    4636            0 :   Dispose (static_cast<M2ALU_PtrToValue__opaque> ((*value)));
    4637            0 :   (*value) = static_cast<M2ALU_PtrToValue> (NULL);
    4638            0 : }
    4639              : 
    4640              : 
    4641              : /*
    4642              :    IsValueTypeNone - returns TRUE if the value on the top stack has no value.
    4643              : */
    4644              : 
    4645      1478652 : extern "C" bool M2ALU_IsValueTypeNone (void)
    4646              : {
    4647      1478652 :   M2ALU_PtrToValue__opaque v;
    4648              : 
    4649      1478652 :   v = Pop ();
    4650      1478652 :   if (v->type == M2ALU_none)
    4651              :     {
    4652       110392 :       Push (v);
    4653       110392 :       return true;
    4654              :     }
    4655              :   else
    4656              :     {
    4657      1368260 :       Push (v);
    4658      1368260 :       return false;
    4659              :     }
    4660              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4661              :   __builtin_unreachable ();
    4662              : }
    4663              : 
    4664              : 
    4665              : /*
    4666              :    IsValueTypeInteger - returns TRUE if the value on the top stack is an integer.
    4667              : */
    4668              : 
    4669            0 : extern "C" bool M2ALU_IsValueTypeInteger (void)
    4670              : {
    4671            0 :   M2ALU_PtrToValue__opaque v;
    4672              : 
    4673            0 :   v = Pop ();
    4674            0 :   if (v->type == M2ALU_integer)
    4675              :     {
    4676            0 :       Push (v);
    4677            0 :       return true;
    4678              :     }
    4679              :   else
    4680              :     {
    4681            0 :       Push (v);
    4682            0 :       return false;
    4683              :     }
    4684              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4685              :   __builtin_unreachable ();
    4686              : }
    4687              : 
    4688              : 
    4689              : /*
    4690              :    IsValueTypeReal - returns TRUE if the value on the top stack is a real.
    4691              : */
    4692              : 
    4693       289708 : extern "C" bool M2ALU_IsValueTypeReal (void)
    4694              : {
    4695       289708 :   M2ALU_PtrToValue__opaque v;
    4696              : 
    4697       289708 :   v = Pop ();
    4698       289708 :   if (v->type == M2ALU_real)
    4699              :     {
    4700          504 :       Push (v);
    4701          504 :       return true;
    4702              :     }
    4703              :   else
    4704              :     {
    4705       289204 :       Push (v);
    4706       289204 :       return false;
    4707              :     }
    4708              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4709              :   __builtin_unreachable ();
    4710              : }
    4711              : 
    4712              : 
    4713              : /*
    4714              :    IsValueTypeComplex - returns TRUE if the value on the top stack is a complex.
    4715              : */
    4716              : 
    4717       284896 : extern "C" bool M2ALU_IsValueTypeComplex (void)
    4718              : {
    4719       284896 :   M2ALU_PtrToValue__opaque v;
    4720              : 
    4721       284896 :   v = Pop ();
    4722       284896 :   if (v->type == M2ALU_complex)
    4723              :     {
    4724          330 :       Push (v);
    4725          330 :       return true;
    4726              :     }
    4727              :   else
    4728              :     {
    4729       284566 :       Push (v);
    4730       284566 :       return false;
    4731              :     }
    4732              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4733              :   __builtin_unreachable ();
    4734              : }
    4735              : 
    4736              : 
    4737              : /*
    4738              :    IsValueTypeSet - returns TRUE if the value on the top stack is a set.
    4739              : */
    4740              : 
    4741       334102 : extern "C" bool M2ALU_IsValueTypeSet (void)
    4742              : {
    4743       334102 :   M2ALU_PtrToValue__opaque v;
    4744              : 
    4745       334102 :   v = Pop ();
    4746       334102 :   if (v->type == M2ALU_set)
    4747              :     {
    4748         9704 :       Push (v);
    4749         9704 :       return true;
    4750              :     }
    4751              :   else
    4752              :     {
    4753       324398 :       Push (v);
    4754       324398 :       return false;
    4755              :     }
    4756              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4757              :   __builtin_unreachable ();
    4758              : }
    4759              : 
    4760              : 
    4761              : /*
    4762              :    IsValueTypeConstructor - returns TRUE if the value on the top
    4763              :                             stack is a constructor.
    4764              : */
    4765              : 
    4766       330222 : extern "C" bool M2ALU_IsValueTypeConstructor (void)
    4767              : {
    4768       330222 :   M2ALU_PtrToValue__opaque v;
    4769              : 
    4770       330222 :   v = Pop ();
    4771       330222 :   if (v->type == M2ALU_constructor)
    4772              :     {
    4773            0 :       Push (v);
    4774            0 :       return true;
    4775              :     }
    4776              :   else
    4777              :     {
    4778       330222 :       Push (v);
    4779       330222 :       return false;
    4780              :     }
    4781              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4782              :   __builtin_unreachable ();
    4783              : }
    4784              : 
    4785              : 
    4786              : /*
    4787              :    IsValueTypeArray - returns TRUE if the value on the top stack is
    4788              :                       an array.
    4789              : */
    4790              : 
    4791       324398 : extern "C" bool M2ALU_IsValueTypeArray (void)
    4792              : {
    4793       324398 :   M2ALU_PtrToValue__opaque v;
    4794              : 
    4795       324398 :   v = Pop ();
    4796       324398 :   if (v->type == M2ALU_array)
    4797              :     {
    4798          754 :       Push (v);
    4799          754 :       return true;
    4800              :     }
    4801              :   else
    4802              :     {
    4803       323644 :       Push (v);
    4804       323644 :       return false;
    4805              :     }
    4806              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4807              :   __builtin_unreachable ();
    4808              : }
    4809              : 
    4810              : 
    4811              : /*
    4812              :    IsValueTypeRecord - returns TRUE if the value on the top stack is
    4813              :                        a record.
    4814              : */
    4815              : 
    4816       323644 : extern "C" bool M2ALU_IsValueTypeRecord (void)
    4817              : {
    4818       323644 :   M2ALU_PtrToValue__opaque v;
    4819              : 
    4820       323644 :   v = Pop ();
    4821       323644 :   if (v->type == M2ALU_record)
    4822              :     {
    4823         2284 :       Push (v);
    4824         2284 :       return true;
    4825              :     }
    4826              :   else
    4827              :     {
    4828       321360 :       Push (v);
    4829       321360 :       return false;
    4830              :     }
    4831              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4832              :   __builtin_unreachable ();
    4833              : }
    4834              : 
    4835              : 
    4836              : /*
    4837              :    GetSetValueType - returns the set type on top of the ALU stack.
    4838              : */
    4839              : 
    4840            0 : extern "C" unsigned int M2ALU_GetSetValueType (void)
    4841              : {
    4842            0 :   M2ALU_PtrToValue__opaque v;
    4843              : 
    4844            0 :   v = Pop ();
    4845            0 :   Push (v);
    4846            0 :   if (v->type == M2ALU_set)
    4847              :     {
    4848            0 :       return v->constructorType;
    4849              :     }
    4850              :   else
    4851              :     {
    4852            0 :       M2Error_InternalError ((const char *) "expecting set type", 18);
    4853              :     }
    4854              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    4855              :   __builtin_unreachable ();
    4856              : }
    4857              : 
    4858              : 
    4859              : /*
    4860              :    PushIntegerTree - pushes a gcc tree value onto the ALU stack.
    4861              : */
    4862              : 
    4863      9032802 : extern "C" void M2ALU_PushIntegerTree (tree t)
    4864              : {
    4865      9032802 :   M2ALU_PtrToValue__opaque v;
    4866              : 
    4867      9032802 :   v = static_cast<M2ALU_PtrToValue__opaque> (M2ALU_InitValue ());
    4868      9032802 :   v->type = M2ALU_integer;
    4869      9032802 :   v->numberValue = t;
    4870      9032802 :   v->areAllConstants = true;
    4871      9032802 :   v->solved = true;
    4872      9032802 :   Push (v);
    4873      9032802 : }
    4874              : 
    4875              : 
    4876              : /*
    4877              :    PopIntegerTree - pops a gcc tree value from the ALU stack.
    4878              : */
    4879              : 
    4880      3117730 : extern "C" tree M2ALU_PopIntegerTree (void)
    4881              : {
    4882      3117730 :   M2ALU_PtrToValue__opaque v;
    4883      3117730 :   tree t;
    4884              : 
    4885      3117730 :   v = Pop ();
    4886      3117730 :   if (v->type == M2ALU_integer)
    4887              :     {
    4888      3117730 :       t = v->numberValue;
    4889              :     }
    4890              :   else
    4891              :     {
    4892            0 :       M2Error_InternalError ((const char *) "expecting type of constant to be a whole number", 47);
    4893              :     }
    4894      3117730 :   Dispose (v);
    4895      3117730 :   return t;
    4896              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4897              :   __builtin_unreachable ();
    4898              : }
    4899              : 
    4900              : 
    4901              : /*
    4902              :    PushRealTree - pushes a gcc tree value onto the ALU stack.
    4903              : */
    4904              : 
    4905       187402 : extern "C" void M2ALU_PushRealTree (tree t)
    4906              : {
    4907       187402 :   M2ALU_PtrToValue__opaque v;
    4908              : 
    4909       187402 :   v = New ();
    4910       187402 :   v->type = M2ALU_real;
    4911       187402 :   v->numberValue = t;
    4912       187402 :   v->areAllConstants = true;
    4913       187402 :   v->solved = true;
    4914       187402 :   Push (v);
    4915       187402 : }
    4916              : 
    4917              : 
    4918              : /*
    4919              :    PopRealTree - pops a gcc tree value from the ALU stack.
    4920              : */
    4921              : 
    4922         7696 : extern "C" tree M2ALU_PopRealTree (void)
    4923              : {
    4924         7696 :   M2ALU_PtrToValue__opaque v;
    4925         7696 :   tree t;
    4926              : 
    4927         7696 :   v = Pop ();
    4928         7696 :   if (v->type == M2ALU_real)
    4929              :     {
    4930         7696 :       t = v->numberValue;
    4931              :     }
    4932              :   else
    4933              :     {
    4934            0 :       M2Error_InternalError ((const char *) "expecting type of constant to be a real number", 46);
    4935              :     }
    4936         7696 :   Dispose (v);
    4937         7696 :   return t;
    4938              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4939              :   __builtin_unreachable ();
    4940              : }
    4941              : 
    4942              : 
    4943              : /*
    4944              :    PushComplexTree - pushes a gcc tree value onto the ALU stack.
    4945              : */
    4946              : 
    4947          708 : extern "C" void M2ALU_PushComplexTree (tree t)
    4948              : {
    4949          708 :   M2ALU_PtrToValue__opaque v;
    4950              : 
    4951          708 :   v = New ();
    4952          708 :   v->type = M2ALU_complex;
    4953          708 :   v->numberValue = t;
    4954          708 :   v->areAllConstants = true;
    4955          708 :   v->solved = true;
    4956          708 :   Push (v);
    4957          708 : }
    4958              : 
    4959              : 
    4960              : /*
    4961              :    PopComplexTree - pops a gcc tree value from the ALU stack.
    4962              : */
    4963              : 
    4964          660 : extern "C" tree M2ALU_PopComplexTree (void)
    4965              : {
    4966          660 :   M2ALU_PtrToValue__opaque v;
    4967          660 :   tree t;
    4968              : 
    4969          660 :   v = Pop ();
    4970          660 :   if (v->type == M2ALU_complex)
    4971              :     {
    4972          660 :       t = v->numberValue;
    4973              :     }
    4974              :   else
    4975              :     {
    4976            0 :       M2Error_InternalError ((const char *) "expecting type of constant to be a complex number", 49);
    4977              :     }
    4978          660 :   Dispose (v);
    4979          660 :   return t;
    4980              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4981              :   __builtin_unreachable ();
    4982              : }
    4983              : 
    4984              : 
    4985              : /*
    4986              :    PushSetTree - pushes a gcc tree onto the ALU stack.
    4987              :                  The tree value is expected to contain a
    4988              :                  word sized or less value.  It is converted into a set
    4989              :                  type (sym). Bit 0 maps onto MIN (sym).
    4990              : */
    4991              : 
    4992            0 : extern "C" void M2ALU_PushSetTree (unsigned int tokenno, tree value, unsigned int sym)
    4993              : {
    4994            0 :   M2ALU_PtrToValue__opaque newVal;
    4995            0 :   int c;
    4996            0 :   int i;
    4997            0 :   M2ALU_listOfRange range;
    4998            0 :   location_t loc;
    4999              : 
    5000            0 :   loc = M2LexBuf_TokenToLocation (tokenno);
    5001            0 :   range = NULL;
    5002            0 :   i = 0;
    5003            0 :   while ((i < (m2decl_GetBitsPerBitset ())) && ((m2expr_CompareTrees (m2expr_GetIntegerZero (loc), value)) != 0))
    5004              :     {
    5005            0 :       if ((m2expr_CompareTrees (m2expr_GetIntegerOne (loc), m2expr_BuildLogicalAnd (loc, value, m2expr_GetIntegerOne (loc)))) == 0)
    5006              :         {
    5007            0 :           M2ALU_PushCard (static_cast<unsigned int> (i));
    5008            0 :           c = Val (tokenno, SymbolTable_SkipType (sym), M2ALU_PopIntegerTree ());
    5009            0 :           M2GCCDeclare_DeclareConstant (tokenno, static_cast<unsigned int> (c));
    5010            0 :           range = AddRange (range, static_cast<unsigned int> (c), static_cast<unsigned int> (c));
    5011              :         }
    5012            0 :       value = m2expr_BuildLSR (loc, value, m2expr_GetIntegerOne (loc), false);
    5013            0 :       i += 1;
    5014              :     }
    5015            0 :   SortElements (tokenno, range);
    5016            0 :   CombineElements (tokenno, range);
    5017            0 :   newVal = New ();
    5018            0 :   newVal->location = loc;
    5019            0 :   newVal->type = M2ALU_set;
    5020            0 :   newVal->constructorType = sym;
    5021            0 :   newVal->areAllConstants = false;
    5022            0 :   newVal->solved = false;
    5023            0 :   newVal->setValue = range;
    5024            0 :   Eval (tokenno, newVal);
    5025            0 :   Push (newVal);
    5026            0 : }
    5027              : 
    5028              : 
    5029              : /*
    5030              :    PopSetTree - pops a gcc tree from the ALU stack.
    5031              : */
    5032              : 
    5033         6204 : extern "C" tree M2ALU_PopSetTree (unsigned int tokenno)
    5034              : {
    5035         6204 :   M2ALU_PtrToValue__opaque v;
    5036         6204 :   tree t;
    5037              : 
    5038         6204 :   v = Pop ();
    5039         6204 :   if (v->type == M2ALU_set)
    5040              :     {
    5041         6204 :       Eval (tokenno, v);
    5042         6204 :       if (! v->solved)
    5043              :         {
    5044            0 :           M2Error_InternalError ((const char *) "the set has not been resolved", 29);
    5045              :         }
    5046         6204 :       if (! v->areAllConstants)
    5047              :         {
    5048            0 :           M2Error_InternalError ((const char *) "the set must only contain constants", 35);
    5049              :         }
    5050         6204 :       t = M2ALU_ConstructSetConstant (tokenno, static_cast<M2ALU_PtrToValue> (v));
    5051              :     }
    5052              :   else
    5053              :     {
    5054            0 :       M2Error_InternalError ((const char *) "expecting type of constant to be a set", 38);
    5055              :     }
    5056         6204 :   Dispose (v);
    5057         6204 :   return t;
    5058              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5059              :   __builtin_unreachable ();
    5060              : }
    5061              : 
    5062              : 
    5063              : /*
    5064              :    PopConstructorTree - returns a tree containing the compound literal.
    5065              : */
    5066              : 
    5067         9294 : extern "C" tree M2ALU_PopConstructorTree (unsigned int tokenno)
    5068              : {
    5069         9294 :   M2ALU_PtrToValue__opaque v;
    5070         9294 :   tree t;
    5071              : 
    5072         9294 :   v = Pop ();
    5073         9294 :   Eval (tokenno, v);
    5074         9294 :   if (! v->solved)
    5075              :     {
    5076            0 :       M2Error_InternalError ((const char *) "the constructor has not been resolved", 37);
    5077              :     }
    5078         9294 :   switch (v->type)
    5079              :     {
    5080            0 :       case M2ALU_constructor:
    5081            0 :         M2Error_InternalError ((const char *) "expecting constructor to be resolved into specific type", 55);
    5082          790 :         break;
    5083              : 
    5084          790 :       case M2ALU_array:
    5085          790 :         t = ConstructArrayConstant (tokenno, v);
    5086          790 :         break;
    5087              : 
    5088         2380 :       case M2ALU_record:
    5089         2380 :         t = ConstructRecordConstant (tokenno, v);
    5090         2380 :         break;
    5091              : 
    5092         6124 :       case M2ALU_set:
    5093         6124 :         t = M2ALU_ConstructSetConstant (tokenno, static_cast<M2ALU_PtrToValue> (v));
    5094         6124 :         break;
    5095              : 
    5096              : 
    5097            0 :       default:
    5098            0 :         M2Error_InternalError ((const char *) "expecting type to be a constructor", 34);
    5099         9294 :         break;
    5100              :     }
    5101         9294 :   Dispose (v);
    5102         9294 :   return t;
    5103              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5104              :   __builtin_unreachable ();
    5105              : }
    5106              : 
    5107              : 
    5108              : /*
    5109              :    PushFrom - pushes a copy of the contents of, v, onto stack.
    5110              : */
    5111              : 
    5112     25691764 : extern "C" void M2ALU_PushFrom (M2ALU_PtrToValue v)
    5113              : {
    5114     25691764 :   M2ALU_PtrToValue__opaque t;
    5115              : 
    5116     25691764 :   CheckNotAlreadyOnFreeList (static_cast<M2ALU_PtrToValue__opaque> (v));
    5117     25691764 :   t = New ();  /* as it is a copy  */
    5118     25691764 :   (*t) = (*static_cast<M2ALU_PtrToValue__opaque> (v));  /* as it is a copy  */
    5119     25691764 :   switch (static_cast<M2ALU_PtrToValue__opaque> (v)->type)
    5120              :     {
    5121       558770 :       case M2ALU_set:
    5122       558770 :         t->setValue = DupRange (static_cast<M2ALU_PtrToValue__opaque> (v)->setValue);
    5123       558770 :         break;
    5124              : 
    5125       772908 :       case M2ALU_constructor:
    5126       772908 :       case M2ALU_record:
    5127       772908 :         t->fieldValues = DupFields (static_cast<M2ALU_PtrToValue__opaque> (v)->fieldValues);
    5128       772908 :         break;
    5129              : 
    5130       166252 :       case M2ALU_array:
    5131       166252 :         t->arrayValues = DupElements (static_cast<M2ALU_PtrToValue__opaque> (v)->arrayValues);
    5132       166252 :         break;
    5133              : 
    5134              : 
    5135              :       default:
    5136              :         break;
    5137              :     }
    5138     25691764 :   Push (t);
    5139     25691764 : }
    5140              : 
    5141              : 
    5142              : /*
    5143              :    PopInto - pops the top element from the stack and places it into, v.
    5144              : */
    5145              : 
    5146      3361423 : extern "C" void M2ALU_PopInto (M2ALU_PtrToValue v)
    5147              : {
    5148      3361423 :   M2ALU_PtrToValue__opaque t;
    5149              : 
    5150      3361423 :   t = Pop ();
    5151      3361423 :   (*static_cast<M2ALU_PtrToValue__opaque> (v)) = (*t);
    5152      3361423 :   switch (static_cast<M2ALU_PtrToValue__opaque> (v)->type)
    5153              :     {
    5154        78930 :       case M2ALU_set:
    5155        78930 :         t->setValue = NULL;
    5156        78930 :         break;
    5157              : 
    5158        42872 :       case M2ALU_record:
    5159        42872 :       case M2ALU_constructor:
    5160        42872 :         t->fieldValues = NULL;
    5161        42872 :         break;
    5162              : 
    5163         7640 :       case M2ALU_array:
    5164         7640 :         t->arrayValues = NULL;
    5165         7640 :         break;
    5166              : 
    5167      3231981 :       case M2ALU_none:
    5168      3231981 :       case M2ALU_integer:
    5169      3231981 :       case M2ALU_real:
    5170      3231981 :       case M2ALU_complex:
    5171      3231981 :         static_cast<M2ALU_PtrToValue__opaque> (v)->numberValue = m2block_RememberConstant (m2expr_FoldAndStrip (t->numberValue));
    5172      3231981 :         break;
    5173              : 
    5174              : 
    5175            0 :       default:
    5176            0 :         M2Error_InternalError ((const char *) "not expecting this value", 24);
    5177      3361423 :         break;
    5178              :     }
    5179      3361423 :   Dispose (t);
    5180      3361423 : }
    5181              : 
    5182              : 
    5183              : /*
    5184              :    PushCard - pushes a cardinal onto the stack.
    5185              : */
    5186              : 
    5187      1381351 : extern "C" void M2ALU_PushCard (unsigned int c)
    5188              : {
    5189      1381351 :   M2ALU_PtrToValue__opaque v;
    5190              : 
    5191      1381351 :   v = New ();
    5192      1381351 :   v->type = M2ALU_integer;
    5193      1381351 :   v->numberValue = m2decl_BuildIntegerConstant ((int ) (c));
    5194      1381351 :   v->areAllConstants = true;
    5195      1381351 :   v->solved = true;
    5196      1381351 :   Push (v);
    5197      1381351 : }
    5198              : 
    5199              : 
    5200              : /*
    5201              :    PushInt - pushes an integer onto the stack.
    5202              : */
    5203              : 
    5204        27212 : extern "C" void M2ALU_PushInt (int i)
    5205              : {
    5206        27212 :   M2ALU_PtrToValue__opaque v;
    5207              : 
    5208        27212 :   v = New ();
    5209        27212 :   v->type = M2ALU_integer;
    5210        27212 :   v->numberValue = m2decl_BuildIntegerConstant (i);
    5211        27212 :   v->areAllConstants = true;
    5212        27212 :   v->solved = true;
    5213        27212 :   Push (v);
    5214        27212 : }
    5215              : 
    5216              : 
    5217              : /*
    5218              :    PushChar - pushes a char onto the stack.
    5219              : */
    5220              : 
    5221        32924 : extern "C" void M2ALU_PushChar (char c)
    5222              : {
    5223        32924 :   M2ALU_PtrToValue__opaque v;
    5224              : 
    5225        32924 :   v = New ();
    5226        32924 :   v->type = M2ALU_integer;
    5227        32924 :   v->numberValue = m2decl_BuildIntegerConstant (static_cast<int> ( ((unsigned int) (c))));
    5228        32924 :   v->areAllConstants = true;
    5229        32924 :   v->solved = true;
    5230        32924 :   Push (v);
    5231        32924 : }
    5232              : 
    5233              : 
    5234              : /*
    5235              :    PopChar - pops a char from the stack.
    5236              : */
    5237              : 
    5238         1996 : extern "C" char M2ALU_PopChar (unsigned int tokenno)
    5239              : {
    5240         1996 :   M2ALU_PtrToValue__opaque v;
    5241         1996 :   char ch;
    5242              : 
    5243         1996 :   v = Pop ();
    5244         1996 :   ch = (char) 0;
    5245         1996 :   if (v->type == M2ALU_integer)
    5246              :     {
    5247         1996 :       ch = (char ) (m2expr_GetCstInteger (v->numberValue));
    5248              :     }
    5249              :   else
    5250              :     {
    5251            0 :       M2MetaError_MetaErrorT0 (tokenno, (const char *) "{%E}cannot convert constant to a CHAR", 37);
    5252              :     }
    5253         1996 :   Push (v);
    5254         1996 :   return ch;
    5255              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5256              :   __builtin_unreachable ();
    5257              : }
    5258              : 
    5259              : 
    5260              : /*
    5261              :    PushString - pushes the numerical value of the string onto the stack.
    5262              : */
    5263              : 
    5264       610547 : extern "C" void M2ALU_PushString (unsigned int tokenno, NameKey_Name s, bool issueError)
    5265              : {
    5266       610547 :   char ch;
    5267       610547 :   DynamicStrings_String a;
    5268       610547 :   DynamicStrings_String b;
    5269       610547 :   unsigned int length;
    5270       610547 :   location_t location;
    5271              : 
    5272       610547 :   a = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (s));
    5273       610547 :   b = static_cast<DynamicStrings_String> (NULL);
    5274       610547 :   length = DynamicStrings_Length (a);
    5275       610547 :   if (length > 0)
    5276              :     {
    5277       610547 :       length -= 1;
    5278       610547 :       ch = DynamicStrings_char (a, static_cast<int> (length));
    5279       610547 :       location = M2LexBuf_TokenToLocation (tokenno);
    5280       610547 :       switch (ch)
    5281              :         {
    5282          690 :           case 'H':
    5283          690 :             b = DynamicStrings_Slice (a, 0, -1);  /* hexadecimal  */
    5284          690 :             M2ALU_PushIntegerTree (m2decl_BuildConstLiteralNumber (location, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (b))), 16, issueError));
    5285          690 :             break;
    5286              : 
    5287           24 :           case 'A':
    5288           24 :             b = DynamicStrings_Slice (a, 0, -1);  /* binary  */
    5289           24 :             M2ALU_PushIntegerTree (m2decl_BuildConstLiteralNumber (location, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (b))), 2, issueError));
    5290           24 :             break;
    5291              : 
    5292       122140 :           case 'C':
    5293       122140 :           case 'B':
    5294       122140 :             b = DynamicStrings_Slice (a, 0, -1);  /* octal  */
    5295       122140 :             M2ALU_PushIntegerTree (m2decl_BuildConstLiteralNumber (location, const_cast <const char * > (static_cast <char * > (DynamicStrings_string (b))), 8, issueError));
    5296       122140 :             break;
    5297              : 
    5298              : 
    5299       487693 :           default:
    5300       487693 :             if (IsReal (a))
    5301              :               {
    5302         6676 :                 M2ALU_PushRealTree (m2type_RealToTree (reinterpret_cast <char * > (NameKey_KeyToCharStar (s))));
    5303              :               }
    5304              :             else
    5305              :               {
    5306       481017 :                 M2ALU_PushIntegerTree (m2decl_BuildConstLiteralNumber (location, const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (s))), 10, issueError));
    5307              :               }
    5308              :             break;
    5309              :         }
    5310              :     }
    5311              :   else
    5312              :     {
    5313            0 :       M2Error_InternalError ((const char *) "expecting constant literal", 26);
    5314              :     }
    5315       610547 :   a = DynamicStrings_KillString (a);
    5316       610547 :   b = DynamicStrings_KillString (b);
    5317       610547 : }
    5318              : 
    5319              : 
    5320              : /*
    5321              :    CoerseLongRealToCard - performs a coersion between a REAL to a CARDINAL
    5322              : */
    5323              : 
    5324            0 : extern "C" void M2ALU_CoerseLongRealToCard (void)
    5325              : {
    5326            0 :   M2ALU_PtrToValue__opaque v;
    5327              : 
    5328            0 :   v = Pop ();
    5329            0 :   if (v->type == M2ALU_real)
    5330              :     {
    5331            0 :       v->numberValue = m2convert_ConvertConstantAndCheck (v->location, m2type_GetIntegerType (), v->numberValue);
    5332            0 :       v->type = M2ALU_integer;
    5333            0 :       v->areAllConstants = true;
    5334            0 :       v->solved = true;
    5335              :     }
    5336              :   else
    5337              :     {
    5338            0 :       M2Error_InternalError ((const char *) "expecting a REAL number", 23);
    5339              :     }
    5340            0 :   Push (v);
    5341            0 : }
    5342              : 
    5343              : 
    5344              : /*
    5345              :    ConvertRealToInt - converts a REAL into an INTEGER
    5346              : */
    5347              : 
    5348            0 : extern "C" void M2ALU_ConvertRealToInt (void)
    5349              : {
    5350            0 :   M2ALU_PtrToValue__opaque v;
    5351              : 
    5352            0 :   v = Pop ();
    5353            0 :   if (v->type == M2ALU_real)
    5354              :     {
    5355            0 :       v->numberValue = m2convert_ConvertConstantAndCheck (v->location, m2type_GetIntegerType (), v->numberValue);
    5356            0 :       v->type = M2ALU_integer;
    5357            0 :       v->areAllConstants = true;
    5358            0 :       v->solved = true;
    5359              :     }
    5360              :   else
    5361              :     {
    5362            0 :       M2Error_InternalError ((const char *) "expecting a REAL number", 23);
    5363              :     }
    5364            0 :   Push (v);
    5365            0 : }
    5366              : 
    5367              : 
    5368              : /*
    5369              :    ConvertToInt - converts the value into an INTEGER. This should be used
    5370              :                   if we are computing the number of elements in a char set to
    5371              :                   avoid an overflow.
    5372              : */
    5373              : 
    5374      1724260 : extern "C" void M2ALU_ConvertToInt (void)
    5375              : {
    5376      1724260 :   M2ALU_PtrToValue__opaque v;
    5377              : 
    5378      1724260 :   v = Pop ();
    5379      1724260 :   if (v->type == M2ALU_integer)
    5380              :     {
    5381      1724260 :       v->numberValue = m2convert_ConvertConstantAndCheck (v->location, m2type_GetIntegerType (), v->numberValue);
    5382      1724260 :       v->solved = true;
    5383      1724260 :       v->areAllConstants = true;
    5384              :     }
    5385              :   else
    5386              :     {
    5387            0 :       M2Error_InternalError ((const char *) "expecting an INTEGER number", 27);
    5388              :     }
    5389      1724260 :   Push (v);
    5390      1724260 : }
    5391              : 
    5392              : 
    5393              : /*
    5394              :    ConvertToType - converts the top of stack to type, t.
    5395              : */
    5396              : 
    5397        13992 : extern "C" void M2ALU_ConvertToType (unsigned int t)
    5398              : {
    5399        13992 :   M2ALU_PtrToValue__opaque v;
    5400              : 
    5401        13992 :   v = Pop ();
    5402        13992 :   if (t != SymbolTable_NulSym)
    5403              :     {
    5404        13992 :       if (v->type == M2ALU_integer)
    5405              :         {
    5406        13992 :           v->numberValue = m2convert_ConvertConstantAndCheck (v->location, SymbolConversion_Mod2Gcc (t), v->numberValue);
    5407        13992 :           v->solved = true;
    5408        13992 :           v->areAllConstants = true;
    5409              :         }
    5410              :       else
    5411              :         {
    5412            0 :           M2Error_InternalError ((const char *) "expecting an INTEGER number", 27);
    5413              :         }
    5414              :     }
    5415        13992 :   Push (v);
    5416        13992 : }
    5417              : 
    5418              : 
    5419              : /*
    5420              :    IsSolved - returns true if the memory cell indicated by v
    5421              :               has a known value.
    5422              : */
    5423              : 
    5424      3413529 : extern "C" bool M2ALU_IsSolved (M2ALU_PtrToValue v)
    5425              : {
    5426      3413529 :   if (v == NULL)
    5427              :     {
    5428            0 :       M2Error_InternalError ((const char *) "uninitialized value", 19);
    5429              :     }
    5430              :   else
    5431              :     {
    5432      3413529 :       return static_cast<M2ALU_PtrToValue__opaque> (v)->solved;
    5433              :     }
    5434              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    5435              :   __builtin_unreachable ();
    5436              : }
    5437              : 
    5438              : 
    5439              : /*
    5440              :    PutConstructorSolved - records that this constructor is solved.
    5441              : */
    5442              : 
    5443         8434 : extern "C" void M2ALU_PutConstructorSolved (unsigned int sym)
    5444              : {
    5445         8434 :   M2ALU_PtrToValue__opaque v;
    5446              : 
    5447         8434 :   SymbolTable_PushValue (sym);
    5448         8434 :   v = Pop ();
    5449         8434 :   v->solved = true;
    5450         8434 :   Push (v);
    5451         8434 :   SymbolTable_PopValue (sym);
    5452         8434 : }
    5453              : 
    5454              : 
    5455              : /*
    5456              :    EvaluateValue - attempts to evaluate the symbol, sym, value.
    5457              : */
    5458              : 
    5459        16868 : extern "C" void M2ALU_EvaluateValue (unsigned int sym)
    5460              : {
    5461        16868 :   M2ALU_PtrToValue__opaque v;
    5462              : 
    5463        16868 :   SymbolTable_PushValue (sym);
    5464        16868 :   v = Pop ();
    5465        16868 :   Eval (SymbolTable_GetDeclaredMod (sym), v);
    5466        16868 :   Push (v);
    5467        16868 :   SymbolTable_PopValue (sym);
    5468        16868 : }
    5469              : 
    5470              : 
    5471              : /*
    5472              :    TryEvaluateValue - attempts to evaluate the symbol, sym, value.
    5473              : */
    5474              : 
    5475        49894 : extern "C" void M2ALU_TryEvaluateValue (unsigned int sym)
    5476              : {
    5477        49894 :   M2ALU_PtrToValue__opaque v;
    5478              : 
    5479        49894 :   SymbolTable_PushValue (sym);
    5480        49894 :   v = Pop ();
    5481        49894 :   switch (v->type)
    5482              :     {
    5483        49588 :       case M2ALU_set:
    5484        49588 :       case M2ALU_array:
    5485        49588 :       case M2ALU_record:
    5486        49588 :         if (v->constructorType == SymbolTable_NulSym)
    5487              :           {
    5488              :             /* must wait  */
    5489              :             return;
    5490              :           }
    5491              :         else
    5492              :           {
    5493        49588 :             Eval (SymbolTable_GetDeclaredMod (sym), v);
    5494              :           }
    5495        49588 :         break;
    5496              : 
    5497              : 
    5498              :       default:
    5499              :         break;
    5500              :     }
    5501              :   /* nothing to do  */
    5502        49888 :   if (v->solved)
    5503              :     {
    5504        28776 :       Push (v);
    5505        28776 :       SymbolTable_PopValue (sym);
    5506              :     }
    5507              : }
    5508              : 
    5509       227358 : extern "C" void M2ALU_Addn (void)
    5510              : {
    5511       227358 :   M2ALU_PtrToValue__opaque Temp;
    5512       227358 :   M2ALU_PtrToValue__opaque Op1;
    5513       227358 :   M2ALU_PtrToValue__opaque Op2;
    5514              : 
    5515              :   /* 
    5516              :    Add - adds the top two elements on the stack.
    5517              : 
    5518              :          The Stack:
    5519              : 
    5520              :          Entry             Exit
    5521              : 
    5522              :   Ptr ->
    5523              :          +------------+
    5524              :          | Op1        |                   <- Ptr
    5525              :          |------------|    +------------+
    5526              :          | Op2        |    | Op2 + Op1  |
    5527              :          |------------|    |------------|
    5528              :   */
    5529       227358 :   Op1 = Pop ();
    5530       227358 :   Op2 = Pop ();
    5531       227358 :   if (EitherReal (Op1, Op2))
    5532              :     {
    5533            0 :       RealAdd (Op1, Op2);
    5534              :     }
    5535       227358 :   else if (EitherComplex (Op1, Op2))
    5536              :     {
    5537              :       /* avoid dangling else.  */
    5538            0 :       ComplexAdd (Op1, Op2);
    5539              :     }
    5540              :   else
    5541              :     {
    5542              :       /* avoid dangling else.  */
    5543       227358 :       Temp = New ();  /* as it is a temp  */
    5544       227358 :       Temp->location = Op1->location;  /* as it is a temp  */
    5545       227358 :       Temp->type = M2ALU_integer;
    5546       227358 :       Temp->numberValue = m2expr_BuildAdd (Temp->location, Op1->numberValue, Op2->numberValue, false);
    5547       227358 :       Temp->solved = true;
    5548       227358 :       Push (Temp);
    5549              :     }
    5550       227358 :   Dispose (Op1);
    5551       227358 :   Dispose (Op2);
    5552       227358 : }
    5553              : 
    5554              : 
    5555              : /*
    5556              :    Sub - subtracts the top two elements on the stack.
    5557              : 
    5558              :          The Stack:
    5559              : 
    5560              :          Entry             Exit
    5561              : 
    5562              :   Ptr ->
    5563              :          +------------+
    5564              :          | Op1        |                   <- Ptr
    5565              :          |------------|    +------------+
    5566              :          | Op2        |    | Op2 - Op1  |
    5567              :          |------------|    |------------|
    5568              : */
    5569              : 
    5570       625190 : extern "C" void M2ALU_Sub (void)
    5571              : {
    5572       625190 :   M2ALU_PtrToValue__opaque Temp;
    5573       625190 :   M2ALU_PtrToValue__opaque Op1;
    5574       625190 :   M2ALU_PtrToValue__opaque Op2;
    5575              : 
    5576       625190 :   Op1 = Pop ();
    5577       625190 :   Op2 = Pop ();
    5578       625190 :   if (EitherReal (Op1, Op2))
    5579              :     {
    5580            0 :       RealSub (Op1, Op2);
    5581              :     }
    5582       625190 :   else if (EitherComplex (Op1, Op2))
    5583              :     {
    5584              :       /* avoid dangling else.  */
    5585            0 :       ComplexSub (Op1, Op2);
    5586              :     }
    5587              :   else
    5588              :     {
    5589              :       /* avoid dangling else.  */
    5590       625190 :       Temp = New ();  /* as it is a temp  */
    5591       625190 :       Temp->location = Op1->location;  /* as it is a temp  */
    5592       625190 :       Temp->type = M2ALU_integer;
    5593       625190 :       Temp->numberValue = m2expr_BuildSub (Temp->location, Op2->numberValue, Op1->numberValue, true);
    5594       625190 :       Temp->solved = true;
    5595       625190 :       Push (Temp);
    5596              :     }
    5597       625190 :   Dispose (Op1);
    5598       625190 :   Dispose (Op2);
    5599       625190 : }
    5600              : 
    5601            0 : extern "C" void M2ALU_Multn (void)
    5602              : {
    5603            0 :   M2ALU_PtrToValue__opaque Temp;
    5604            0 :   M2ALU_PtrToValue__opaque Op1;
    5605            0 :   M2ALU_PtrToValue__opaque Op2;
    5606              : 
    5607              :   /* 
    5608              :    Mult - multiplies the top two elements on the stack.
    5609              : 
    5610              :           The Stack:
    5611              : 
    5612              :           Entry             Exit
    5613              : 
    5614              :    Ptr ->
    5615              :           +------------+
    5616              :           | Op1        |                   <- Ptr
    5617              :           |------------|    +------------+
    5618              :           | Op2        |    | Op2 * Op1  |
    5619              :           |------------|    |------------|
    5620              :   */
    5621            0 :   Op1 = Pop ();
    5622            0 :   Op2 = Pop ();
    5623            0 :   if (EitherReal (Op1, Op2))
    5624              :     {
    5625            0 :       RealMult (Op1, Op2);
    5626              :     }
    5627            0 :   else if (EitherComplex (Op1, Op2))
    5628              :     {
    5629              :       /* avoid dangling else.  */
    5630            0 :       ComplexMult (Op1, Op2);
    5631              :     }
    5632              :   else
    5633              :     {
    5634              :       /* avoid dangling else.  */
    5635            0 :       Temp = New ();  /* as it is a temp  */
    5636            0 :       Temp->location = Op1->location;  /* as it is a temp  */
    5637            0 :       Temp->type = M2ALU_integer;
    5638            0 :       Temp->numberValue = m2expr_BuildMult (Temp->location, Op2->numberValue, Op1->numberValue, false);
    5639            0 :       Temp->solved = true;
    5640            0 :       Push (Temp);
    5641              :     }
    5642            0 :   Dispose (Op1);
    5643            0 :   Dispose (Op2);
    5644            0 : }
    5645              : 
    5646              : 
    5647              : /*
    5648              :    DivFloor - divides the top two elements on the stack.
    5649              : 
    5650              :               The Stack:
    5651              : 
    5652              :               Entry             Exit
    5653              : 
    5654              :        Ptr ->
    5655              :               +------------+
    5656              :               | Op1        |                     <- Ptr
    5657              :               |------------|    +--------------+
    5658              :               | Op2        |    | Op2 DIV Op1  |
    5659              :               |------------|    |--------------|
    5660              : */
    5661              : 
    5662            0 : extern "C" void M2ALU_DivFloor (void)
    5663              : {
    5664            0 :   M2ALU_PtrToValue__opaque Temp;
    5665            0 :   M2ALU_PtrToValue__opaque Op1;
    5666            0 :   M2ALU_PtrToValue__opaque Op2;
    5667              : 
    5668            0 :   Op1 = Pop ();
    5669            0 :   Op2 = Pop ();
    5670            0 :   if (EitherReal (Op1, Op2))
    5671              :     {
    5672            0 :       RealDiv (Op1, Op2);
    5673              :     }
    5674            0 :   else if (EitherComplex (Op1, Op2))
    5675              :     {
    5676              :       /* avoid dangling else.  */
    5677            0 :       ComplexDiv (Op1, Op2);
    5678              :     }
    5679              :   else
    5680              :     {
    5681              :       /* avoid dangling else.  */
    5682            0 :       Temp = New ();  /* as it is a temp  */
    5683            0 :       Temp->location = Op1->location;  /* as it is a temp  */
    5684            0 :       Temp->type = M2ALU_integer;
    5685            0 :       Temp->numberValue = m2expr_BuildDivFloor (Temp->location, Op2->numberValue, Op1->numberValue, false);
    5686            0 :       Temp->solved = true;
    5687            0 :       Push (Temp);
    5688              :     }
    5689            0 :   Dispose (Op1);
    5690            0 :   Dispose (Op2);
    5691            0 : }
    5692              : 
    5693              : 
    5694              : /*
    5695              :    ModFloor - modulus of the top two elements on the stack.
    5696              : 
    5697              :               The Stack:
    5698              : 
    5699              :               Entry             Exit
    5700              : 
    5701              :        Ptr ->
    5702              :               +------------+
    5703              :               | Op1        |                     <- Ptr
    5704              :               |------------|    +--------------+
    5705              :               | Op2        |    | Op2 MOD Op1  |
    5706              :               |------------|    |--------------|
    5707              : */
    5708              : 
    5709            0 : extern "C" void M2ALU_ModFloor (void)
    5710              : {
    5711            0 :   M2ALU_PtrToValue__opaque Temp;
    5712            0 :   M2ALU_PtrToValue__opaque Op1;
    5713            0 :   M2ALU_PtrToValue__opaque Op2;
    5714              : 
    5715            0 :   Op1 = Pop ();
    5716            0 :   Op2 = Pop ();
    5717            0 :   if (EitherReal (Op1, Op2))
    5718              :     {
    5719            0 :       M2MetaError_MetaError0 ((const char *) "cannot perform {%EkMOD} on REAL types", 37);
    5720              :     }
    5721            0 :   else if (EitherComplex (Op1, Op2))
    5722              :     {
    5723              :       /* avoid dangling else.  */
    5724            0 :       M2MetaError_MetaError0 ((const char *) "cannot perform {%EkMOD} on COMPLEX types", 40);
    5725              :     }
    5726              :   else
    5727              :     {
    5728              :       /* avoid dangling else.  */
    5729            0 :       Temp = New ();  /* as it is a temp  */
    5730            0 :       Temp->location = Op1->location;  /* as it is a temp  */
    5731            0 :       Temp->type = M2ALU_integer;
    5732            0 :       Temp->numberValue = m2expr_BuildModFloor (Temp->location, Op2->numberValue, Op1->numberValue, false);
    5733            0 :       Temp->solved = true;
    5734            0 :       Push (Temp);
    5735              :     }
    5736            0 :   Dispose (Op1);
    5737            0 :   Dispose (Op2);
    5738            0 : }
    5739              : 
    5740              : 
    5741              : /*
    5742              :    DivTrunc - divides the top two elements on the stack.
    5743              : 
    5744              :               The Stack:
    5745              : 
    5746              :               Entry             Exit
    5747              : 
    5748              :        Ptr ->
    5749              :               +------------+
    5750              :               | Op1        |                     <- Ptr
    5751              :               |------------|    +--------------+
    5752              :               | Op2        |    | Op2 DIV Op1  |
    5753              :               |------------|    |--------------|
    5754              : */
    5755              : 
    5756        60424 : extern "C" void M2ALU_DivTrunc (void)
    5757              : {
    5758        60424 :   M2ALU_PtrToValue__opaque Temp;
    5759        60424 :   M2ALU_PtrToValue__opaque Op1;
    5760        60424 :   M2ALU_PtrToValue__opaque Op2;
    5761              : 
    5762        60424 :   Op1 = Pop ();
    5763        60424 :   Op2 = Pop ();
    5764        60424 :   if (EitherReal (Op1, Op2))
    5765              :     {
    5766            0 :       RealDiv (Op1, Op2);
    5767              :     }
    5768        60424 :   else if (EitherComplex (Op1, Op2))
    5769              :     {
    5770              :       /* avoid dangling else.  */
    5771            0 :       ComplexDiv (Op1, Op2);
    5772              :     }
    5773              :   else
    5774              :     {
    5775              :       /* avoid dangling else.  */
    5776        60424 :       Temp = New ();  /* as it is a temp  */
    5777        60424 :       Temp->location = Op1->location;  /* as it is a temp  */
    5778        60424 :       Temp->type = M2ALU_integer;
    5779        60424 :       Temp->numberValue = m2expr_BuildDivTrunc (Temp->location, Op2->numberValue, Op1->numberValue, false);
    5780        60424 :       Temp->solved = true;
    5781        60424 :       Push (Temp);
    5782              :     }
    5783        60424 :   Dispose (Op1);
    5784        60424 :   Dispose (Op2);
    5785        60424 : }
    5786              : 
    5787              : 
    5788              : /*
    5789              :    ModTrunc - modulus of the top two elements on the stack.
    5790              : 
    5791              :               The Stack:
    5792              : 
    5793              :               Entry             Exit
    5794              : 
    5795              :        Ptr ->
    5796              :               +------------+
    5797              :               | Op1        |                     <- Ptr
    5798              :               |------------|    +--------------+
    5799              :               | Op2        |    | Op2 MOD Op1  |
    5800              :               |------------|    |--------------|
    5801              : */
    5802              : 
    5803            0 : extern "C" void M2ALU_ModTrunc (void)
    5804              : {
    5805            0 :   M2ALU_PtrToValue__opaque Temp;
    5806            0 :   M2ALU_PtrToValue__opaque Op1;
    5807            0 :   M2ALU_PtrToValue__opaque Op2;
    5808              : 
    5809            0 :   Op1 = Pop ();
    5810            0 :   Op2 = Pop ();
    5811            0 :   if (EitherReal (Op1, Op2))
    5812              :     {
    5813            0 :       M2MetaError_MetaError0 ((const char *) "cannot perform {%EkMOD} on REAL types", 37);
    5814              :     }
    5815            0 :   else if (EitherComplex (Op1, Op2))
    5816              :     {
    5817              :       /* avoid dangling else.  */
    5818            0 :       M2MetaError_MetaError0 ((const char *) "cannot perform {%EkMOD} on COMPLEX types", 40);
    5819              :     }
    5820              :   else
    5821              :     {
    5822              :       /* avoid dangling else.  */
    5823            0 :       Temp = New ();  /* as it is a temp  */
    5824            0 :       Temp->location = Op1->location;  /* as it is a temp  */
    5825            0 :       Temp->type = M2ALU_integer;
    5826            0 :       Temp->numberValue = m2expr_BuildModTrunc (Temp->location, Op2->numberValue, Op1->numberValue, false);
    5827            0 :       Temp->solved = true;
    5828            0 :       Push (Temp);
    5829              :     }
    5830            0 :   Dispose (Op1);
    5831            0 :   Dispose (Op2);
    5832            0 : }
    5833              : 
    5834              : 
    5835              : /*
    5836              :    Equ - returns true if the top two elements on the stack
    5837              :          are identical.
    5838              : 
    5839              :          The Stack:
    5840              : 
    5841              :          Entry             Exit
    5842              : 
    5843              :   Ptr ->
    5844              :          +------------+
    5845              :          | Op1        |
    5846              :          |------------|
    5847              :          | Op2        |
    5848              :          |------------|    Empty
    5849              : 
    5850              :          RETURN( Op2 = Op1 )
    5851              : */
    5852              : 
    5853      1181877 : extern "C" bool M2ALU_Equ (unsigned int tokenno)
    5854              : {
    5855      1181877 :   M2ALU_PtrToValue__opaque Op1;
    5856      1181877 :   M2ALU_PtrToValue__opaque Op2;
    5857      1181877 :   bool result;
    5858              : 
    5859      1181877 :   Op1 = Pop ();
    5860      1181877 :   Op2 = Pop ();
    5861      1181877 :   if ((Op1->type == M2ALU_set) && (Op2->type == M2ALU_set))
    5862              :     {
    5863           48 :       result = AreSetsEqual (tokenno, Op1, Op2);
    5864              :     }
    5865      1181829 :   else if ((Op1->type == M2ALU_set) || (Op2->type == M2ALU_set))
    5866              :     {
    5867              :       /* avoid dangling else.  */
    5868            0 :       M2MetaError_MetaErrorT0 (tokenno, (const char *) "cannot perform a comparison between a number and a set", 54);
    5869            0 :       result = false;
    5870              :     }
    5871              :   else
    5872              :     {
    5873              :       /* avoid dangling else.  */
    5874      1181829 :       if (Op1->type != Op2->type)
    5875              :         {
    5876            0 :           M2MetaError_MetaErrorT0 (tokenno, (const char *) "cannot perform a comparison between a different type constants", 62);
    5877            0 :           result = false;
    5878              :         }
    5879      1181829 :       else if ((Op1->type == M2ALU_complex) || (Op1->type == M2ALU_real))
    5880              :         {
    5881              :           /* avoid dangling else.  */
    5882           54 :           result = m2expr_AreRealOrComplexConstantsEqual (Op1->numberValue, Op2->numberValue);
    5883              :         }
    5884              :       else
    5885              :         {
    5886              :           /* avoid dangling else.  */
    5887      1181775 :           result = m2expr_AreConstantsEqual (Op1->numberValue, Op2->numberValue);
    5888              :         }
    5889              :     }
    5890      1181877 :   Dispose (Op1);
    5891      1181877 :   Dispose (Op2);
    5892      1181877 :   return result;
    5893              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5894              :   __builtin_unreachable ();
    5895              : }
    5896              : 
    5897              : 
    5898              : /*
    5899              :    NotEqu - returns true if the top two elements on the stack
    5900              :             are not identical.
    5901              : 
    5902              :             The Stack:
    5903              : 
    5904              :             Entry             Exit
    5905              : 
    5906              :      Ptr ->
    5907              :             +------------+
    5908              :             | Op1        |
    5909              :             |------------|
    5910              :             | Op2        |
    5911              :             |------------|    Empty
    5912              : 
    5913              :             RETURN( Op2 # Op1 )
    5914              : */
    5915              : 
    5916         3576 : extern "C" bool M2ALU_NotEqu (unsigned int tokenno)
    5917              : {
    5918         3576 :   return ! (M2ALU_Equ (tokenno));
    5919              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5920              :   __builtin_unreachable ();
    5921              : }
    5922              : 
    5923              : 
    5924              : /*
    5925              :    Less - returns true if Op2 < Op1
    5926              : 
    5927              :           The Stack:
    5928              : 
    5929              :           Entry             Exit
    5930              : 
    5931              :    Ptr ->
    5932              :           +------------+
    5933              :           | Op1        |
    5934              :           |------------|
    5935              :           | Op2        |
    5936              :           |------------|    Empty
    5937              : 
    5938              :           RETURN( Op2 < Op1 )
    5939              : */
    5940              : 
    5941      5908736 : extern "C" bool M2ALU_Less (unsigned int tokenno)
    5942              : {
    5943      5908736 :   M2ALU_PtrToValue__opaque v1;
    5944      5908736 :   M2ALU_PtrToValue__opaque v2;
    5945      5908736 :   bool result;
    5946      5908736 :   int res;
    5947              : 
    5948      5908736 :   v1 = Pop ();
    5949      5908736 :   v2 = Pop ();
    5950      5908736 :   if ((v1->type == M2ALU_set) && (v2->type == M2ALU_set))
    5951              :     {
    5952            0 :       result = ! (IsSuperset (tokenno, v2, v1));
    5953              :     }
    5954      5908736 :   else if ((v1->type == M2ALU_set) || (v2->type == M2ALU_set))
    5955              :     {
    5956              :       /* avoid dangling else.  */
    5957            0 :       M2MetaError_MetaErrorT0 (tokenno, (const char *) "cannot perform a comparison between a number and a set", 54);
    5958            0 :       result = false;
    5959              :     }
    5960              :   else
    5961              :     {
    5962              :       /* avoid dangling else.  */
    5963      5908736 :       res = m2expr_CompareTrees (v2->numberValue, v1->numberValue);
    5964      5908736 :       if (res == -1)
    5965              :         {
    5966              :           result = true;
    5967              :         }
    5968              :       else
    5969              :         {
    5970      1585577 :           result = false;
    5971              :         }
    5972              :     }
    5973              :   /* result := (CompareTrees(v2^.numberValue, v1^.numberValue)=-1)  */
    5974      5908736 :   Dispose (v1);
    5975      5908736 :   Dispose (v2);
    5976      5908736 :   return result;
    5977              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5978              :   __builtin_unreachable ();
    5979              : }
    5980              : 
    5981              : 
    5982              : /*
    5983              :    Gre - returns true if Op2 > Op1
    5984              : 
    5985              :          The Stack:
    5986              : 
    5987              :          Entry             Exit
    5988              : 
    5989              :   Ptr ->
    5990              :          +------------+
    5991              :          | Op1        |
    5992              :          |------------|
    5993              :          | Op2        |
    5994              :          |------------|    Empty
    5995              : 
    5996              :          RETURN( Op2 > Op1 )
    5997              : */
    5998              : 
    5999      5964510 : extern "C" bool M2ALU_Gre (unsigned int tokenno)
    6000              : {
    6001      5964510 :   M2ALU_PtrToValue__opaque v1;
    6002      5964510 :   M2ALU_PtrToValue__opaque v2;
    6003      5964510 :   bool result;
    6004              : 
    6005      5964510 :   v1 = Pop ();
    6006      5964510 :   v2 = Pop ();
    6007      5964510 :   if ((v1->type == M2ALU_set) && (v2->type == M2ALU_set))
    6008              :     {
    6009            0 :       result = ! (IsSubset (tokenno, v2, v1));
    6010              :     }
    6011      5964510 :   else if ((v1->type == M2ALU_set) || (v2->type == M2ALU_set))
    6012              :     {
    6013              :       /* avoid dangling else.  */
    6014            0 :       M2MetaError_MetaErrorT0 (tokenno, (const char *) "cannot perform a comparison between a number and a set", 54);
    6015            0 :       M2Error_FlushErrors ();
    6016            0 :       result = false;
    6017              :     }
    6018              :   else
    6019              :     {
    6020              :       /* avoid dangling else.  */
    6021      5964510 :       result = (m2expr_CompareTrees (v2->numberValue, v1->numberValue)) == 1;
    6022              :     }
    6023      5964510 :   Dispose (v1);
    6024      5964510 :   Dispose (v2);
    6025      5964510 :   return result;
    6026              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6027              :   __builtin_unreachable ();
    6028              : }
    6029              : 
    6030              : 
    6031              : /*
    6032              :    LessEqu - returns true if Op2<Op1
    6033              : 
    6034              :              The Stack:
    6035              : 
    6036              :              Entry             Exit
    6037              : 
    6038              :       Ptr ->
    6039              :              +------------+
    6040              :              | Op1        |
    6041              :              |------------|
    6042              :              | Op2        |
    6043              :              |------------|    Empty
    6044              : 
    6045              :              RETURN( Op2 <= Op1 )
    6046              : */
    6047              : 
    6048          102 : extern "C" bool M2ALU_LessEqu (unsigned int tokenno)
    6049              : {
    6050          102 :   M2ALU_PtrToValue__opaque v1;
    6051          102 :   M2ALU_PtrToValue__opaque v2;
    6052          102 :   bool result;
    6053              : 
    6054          102 :   v1 = Pop ();
    6055          102 :   v2 = Pop ();
    6056          102 :   if ((v1->type == M2ALU_set) && (v2->type == M2ALU_set))
    6057              :     {
    6058            0 :       result = IsSubset (tokenno, v2, v1);
    6059              :     }
    6060          102 :   else if ((v1->type == M2ALU_set) || (v2->type == M2ALU_set))
    6061              :     {
    6062              :       /* avoid dangling else.  */
    6063            0 :       M2MetaError_MetaErrorT0 (tokenno, (const char *) "cannot perform a comparison between a number and a set", 54);
    6064            0 :       M2Error_FlushErrors ();
    6065            0 :       result = false;
    6066              :     }
    6067              :   else
    6068              :     {
    6069              :       /* avoid dangling else.  */
    6070          102 :       result = (m2expr_CompareTrees (v2->numberValue, v1->numberValue)) <= 0;
    6071              :     }
    6072          102 :   Dispose (v1);
    6073          102 :   Dispose (v2);
    6074          102 :   return result;
    6075              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6076              :   __builtin_unreachable ();
    6077              : }
    6078              : 
    6079              : 
    6080              : /*
    6081              :    GreEqu - returns true if Op2 >= Op1
    6082              :             are not identical.
    6083              : 
    6084              :             The Stack:
    6085              : 
    6086              :             Entry             Exit
    6087              : 
    6088              :      Ptr ->
    6089              :             +------------+
    6090              :             | Op1        |
    6091              :             |------------|
    6092              :             | Op2        |
    6093              :             |------------|    Empty
    6094              : 
    6095              :             RETURN( Op2 >= Op1 )
    6096              : */
    6097              : 
    6098       680216 : extern "C" bool M2ALU_GreEqu (unsigned int tokenno)
    6099              : {
    6100       680216 :   M2ALU_PtrToValue__opaque v1;
    6101       680216 :   M2ALU_PtrToValue__opaque v2;
    6102       680216 :   bool result;
    6103              : 
    6104       680216 :   v1 = Pop ();
    6105       680216 :   v2 = Pop ();
    6106       680216 :   if ((v1->type == M2ALU_set) && (v2->type == M2ALU_set))
    6107              :     {
    6108            0 :       result = IsSuperset (tokenno, v2, v1);
    6109              :     }
    6110       680216 :   else if ((v1->type == M2ALU_set) || (v2->type == M2ALU_set))
    6111              :     {
    6112              :       /* avoid dangling else.  */
    6113            0 :       M2MetaError_MetaErrorT0 (tokenno, (const char *) "cannot perform a comparison between a number and a set", 54);
    6114            0 :       M2Error_FlushErrors ();
    6115            0 :       result = false;
    6116              :     }
    6117              :   else
    6118              :     {
    6119              :       /* avoid dangling else.  */
    6120       680216 :       result = (m2expr_CompareTrees (v2->numberValue, v1->numberValue)) >= 0;
    6121              :     }
    6122       680216 :   Dispose (v1);
    6123       680216 :   Dispose (v2);
    6124       680216 :   return result;
    6125              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6126              :   __builtin_unreachable ();
    6127              : }
    6128              : 
    6129              : 
    6130              : /*
    6131              :    IsNulSet - returns TRUE if the top element is the nul set constant, {}.
    6132              : */
    6133              : 
    6134            0 : extern "C" bool M2ALU_IsNulSet (void)
    6135              : {
    6136            0 :   M2ALU_PtrToValue__opaque v;
    6137            0 :   bool r;
    6138              : 
    6139            0 :   v = Pop ();
    6140            0 :   r = (v->type == M2ALU_set) && (v->setValue == NULL);
    6141            0 :   Push (v);
    6142            0 :   return r;
    6143              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6144              :   __builtin_unreachable ();
    6145              : }
    6146              : 
    6147              : 
    6148              : /*
    6149              :    IsGenericNulSet - returns TRUE if the top element is the generic nul set constant, {}.
    6150              : */
    6151              : 
    6152            0 : extern "C" bool M2ALU_IsGenericNulSet (void)
    6153              : {
    6154            0 :   M2ALU_PtrToValue__opaque v;
    6155            0 :   bool r;
    6156              : 
    6157            0 :   v = Pop ();
    6158            0 :   r = ((v->type == M2ALU_set) && (v->setValue == NULL)) && (v->constructorType == SymbolTable_NulSym);
    6159            0 :   Push (v);
    6160            0 :   return r;
    6161              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6162              :   __builtin_unreachable ();
    6163              : }
    6164              : 
    6165              : 
    6166              : /*
    6167              :    PushNulSet - pushes an empty set {} onto the ALU stack. The subrange type used
    6168              :                 to construct the set is defined by, constructorType.
    6169              :                 If this is NulSym then
    6170              :                 the set is generic and compatible with all sets.
    6171              : 
    6172              :                 The Stack:
    6173              : 
    6174              :                 Entry             Exit
    6175              : 
    6176              :                                                  <- Ptr
    6177              :                                   +------------+
    6178              :                                   | {}         |
    6179              :                 Ptr ->            |------------|
    6180              : 
    6181              : */
    6182              : 
    6183            0 : extern "C" void M2ALU_PushNulSet (unsigned int settype)
    6184              : {
    6185            0 :   M2ALU_PtrToValue__opaque v;
    6186              : 
    6187            0 :   v = static_cast<M2ALU_PtrToValue__opaque> (M2ALU_InitValue ());
    6188            0 :   v->type = M2ALU_set;
    6189            0 :   v->constructorType = settype;
    6190            0 :   v->areAllConstants = true;
    6191            0 :   v->solved = M2GCCDeclare_CompletelyResolved (settype);
    6192            0 :   v->setValue = NULL;
    6193            0 :   v->next = static_cast<M2ALU_PtrToValue__opaque> (NULL);
    6194            0 :   Push (v);
    6195            0 : }
    6196              : 
    6197              : 
    6198              : /*
    6199              :    AddBitRange - adds the range op1..op2 to the underlying set.
    6200              : 
    6201              :                  Ptr ->
    6202              :                                                            <- Ptr
    6203              :                         +------------+      +------------+
    6204              :                         | Set        |      | Set        |
    6205              :                         |------------|      |------------|
    6206              : 
    6207              : */
    6208              : 
    6209        12078 : extern "C" void M2ALU_AddBitRange (unsigned int tokenno, unsigned int op1, unsigned int op2)
    6210              : {
    6211        12078 :   M2ALU_PtrToValue__opaque v;
    6212              : 
    6213        12078 :   v = Pop ();
    6214        12078 :   v = CoerseTo (tokenno, M2ALU_set, v);
    6215        12078 :   if (v->type == M2ALU_set)
    6216              :     {
    6217        12078 :       v->setValue = AddRange (v->setValue, op1, op2);
    6218        12078 :       v->solved = (v->solved && (IsSolvedGCC (op1))) && (IsSolvedGCC (op2));
    6219        12084 :       v->areAllConstants = (v->areAllConstants && (SymbolTable_IsConst (op1))) && (SymbolTable_IsConst (op2));
    6220              :     }
    6221        12078 :   Push (v);
    6222        12078 : }
    6223              : 
    6224              : 
    6225              : /*
    6226              :    AddBit - adds the bit op1 to the underlying set. INCL(Set, op1)
    6227              : 
    6228              :             Ptr ->
    6229              :                                                       <- Ptr
    6230              :                    +------------+      +------------+
    6231              :                    | Set        |      | Set        |
    6232              :                    |------------|      |------------|
    6233              : */
    6234              : 
    6235        11836 : extern "C" void M2ALU_AddBit (unsigned int tokenno, unsigned int op1)
    6236              : {
    6237        11836 :   M2ALU_AddBitRange (tokenno, op1, op1);
    6238        11836 : }
    6239              : 
    6240              : 
    6241              : /*
    6242              :    SubBit - removes a bit op1 from the underlying set. EXCL(Set, Op1)
    6243              : 
    6244              :             Ptr ->
    6245              :                                                       <- Ptr
    6246              :                    +------------+      +------------+
    6247              :                    | Set        |      | Set        |
    6248              :                    |------------|      |------------|
    6249              : */
    6250              : 
    6251            0 : extern "C" void M2ALU_SubBit (unsigned int tokenno, unsigned int op1)
    6252              : {
    6253            0 :   M2ALU_PtrToValue__opaque v;
    6254              : 
    6255            0 :   v = Pop ();
    6256            0 :   if (v->type == M2ALU_set)
    6257              :     {
    6258            0 :       Eval (tokenno, v);
    6259            0 :       if (v->solved)
    6260              :         {
    6261            0 :           if (IsSolvedGCC (op1))
    6262              :             {
    6263            0 :               PerformSubBit (tokenno, &v->setValue, op1);
    6264            0 :               v->solved = false;
    6265              :             }
    6266              :           else
    6267              :             {
    6268            0 :               M2Error_InternalError ((const char *) "can only subtract a bit from a set when the bit value is known", 62);
    6269              :             }
    6270              :         }
    6271              :       else
    6272              :         {
    6273            0 :           M2Error_InternalError ((const char *) "can only subtract a bit from a set when the set value is known", 62);
    6274              :         }
    6275            0 :       Eval (tokenno, v);
    6276              :     }
    6277              :   else
    6278              :     {
    6279            0 :       M2Error_InternalError ((const char *) "expecting set type constant", 27);
    6280              :     }
    6281            0 :   Push (v);
    6282            0 : }
    6283              : 
    6284              : 
    6285              : /*
    6286              :    SetIn - returns true if Op2 IN Op1
    6287              : 
    6288              :            The Stack:
    6289              : 
    6290              :            Entry             Exit
    6291              : 
    6292              :     Ptr ->
    6293              :            +------------+
    6294              :            | Set        |
    6295              :            |------------|    Empty
    6296              : 
    6297              :            RETURN( Op1 IN Set )
    6298              : */
    6299              : 
    6300            0 : extern "C" bool M2ALU_SetIn (unsigned int tokenno, unsigned int Op1)
    6301              : {
    6302            0 :   M2ALU_PtrToValue__opaque Set;
    6303            0 :   bool result;
    6304              : 
    6305            0 :   Set = Pop ();
    6306            0 :   if (Set->type != M2ALU_set)
    6307              :     {
    6308            0 :       M2Error_InternalError ((const char *) "expecting ALU operand to be a set", 33);
    6309              :     }
    6310            0 :   Eval (tokenno, Set);
    6311            0 :   if ((IsSolvedGCC (Op1)) && Set->solved)
    6312              :     {
    6313            0 :       result = PerformSetIn (tokenno, Op1, Set->setValue);
    6314              :     }
    6315              :   else
    6316              :     {
    6317            0 :       M2Error_InternalError ((const char *) "one or more operands have not been resolved", 43);
    6318              :     }
    6319            0 :   Dispose (Set);
    6320            0 :   return result;
    6321              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6322              :   __builtin_unreachable ();
    6323              : }
    6324              : 
    6325              : 
    6326              : /*
    6327              :    SetOr -  performs an inclusive OR of the top two elements on the stack.
    6328              : 
    6329              :             The Stack:
    6330              : 
    6331              :             Entry             Exit
    6332              : 
    6333              :      Ptr ->
    6334              :             +------------+
    6335              :             | Set1       |                   <- Ptr
    6336              :             |------------|    +------------+
    6337              :             | Set2       |    | Set1 + Set2|
    6338              :             |------------|    |------------|
    6339              : 
    6340              : */
    6341              : 
    6342          224 : extern "C" void M2ALU_SetOr (unsigned int tokenno)
    6343              : {
    6344          224 :   SetOp (tokenno, (M2ALU_DoSetProcedure) {(M2ALU_DoSetProcedure_t) PerformOr});
    6345          224 : }
    6346              : 
    6347              : 
    6348              : /*
    6349              :    SetAnd - performs a set AND the top two elements on the stack.
    6350              : 
    6351              :             The Stack:
    6352              : 
    6353              :             Entry             Exit
    6354              : 
    6355              :      Ptr ->
    6356              :             +------------+
    6357              :             | Op1        |                   <- Ptr
    6358              :             |------------|    +------------+
    6359              :             | Op2        |    | Op2 * Op1  |
    6360              :             |------------|    |------------|
    6361              : */
    6362              : 
    6363            6 : extern "C" void M2ALU_SetAnd (unsigned int tokenno)
    6364              : {
    6365            6 :   SetOp (tokenno, (M2ALU_DoSetProcedure) {(M2ALU_DoSetProcedure_t) PerformAnd});
    6366            6 : }
    6367              : 
    6368              : 
    6369              : /*
    6370              :    SetDifference - performs a set difference of the top two elements on the stack.
    6371              :                    For each member in the set
    6372              :                       if member in Op2 and not member in Op1
    6373              : 
    6374              :                    The Stack:
    6375              : 
    6376              :                    Entry             Exit
    6377              : 
    6378              :             Ptr ->
    6379              :                    +------------+
    6380              :                    | Op1        |                   <- Ptr
    6381              :                    |------------|    +-------------------+
    6382              :                    | Op2        |    | Op2 and (not Op1) |
    6383              :                    |------------|    |-------------------|
    6384              : */
    6385              : 
    6386            0 : extern "C" void M2ALU_SetDifference (unsigned int tokenno)
    6387              : {
    6388            0 :   M2ALU_PtrToValue__opaque Set1;
    6389            0 :   M2ALU_PtrToValue__opaque Set2;
    6390              : 
    6391            0 :   Set1 = Pop ();
    6392            0 :   Set2 = Pop ();
    6393            0 :   Eval (tokenno, Set1);
    6394            0 :   Eval (tokenno, Set2);
    6395            0 :   if (! (Set1->solved && Set2->solved))
    6396              :     {
    6397            0 :       M2Error_InternalError ((const char *) "one or more operands have not been resolved", 43);
    6398              :     }
    6399            0 :   if (Set1->setValue == NULL)
    6400              :     {
    6401              :       /* null set, return Set2  */
    6402            0 :       Push (Set1);
    6403              :     }
    6404              :   else
    6405              :     {
    6406            0 :       Push (Set1);
    6407            0 :       M2ALU_SetNegate (tokenno);
    6408            0 :       Push (Set2);
    6409            0 :       M2ALU_SetAnd (tokenno);
    6410              :     }
    6411            0 : }
    6412              : 
    6413              : 
    6414              : /*
    6415              :    SetSymmetricDifference - performs a set difference of the top two elements on the stack.
    6416              : 
    6417              :                             The Stack:
    6418              : 
    6419              :                             Entry             Exit
    6420              : 
    6421              :                      Ptr ->
    6422              :                             +------------+
    6423              :                             | Op1        |                    <- Ptr
    6424              :                             |------------|    +-------------+
    6425              :                             | Op2        |    | Op2 xor Op1 |
    6426              :                             |------------|    |-------------|
    6427              : */
    6428              : 
    6429            0 : extern "C" void M2ALU_SetSymmetricDifference (unsigned int tokenno)
    6430              : {
    6431            0 :   M2ALU_PtrToValue__opaque Set1;
    6432            0 :   M2ALU_PtrToValue__opaque Set2;
    6433              : 
    6434            0 :   Set1 = Pop ();
    6435            0 :   Set2 = Pop ();
    6436            0 :   Eval (tokenno, Set1);
    6437            0 :   Eval (tokenno, Set2);
    6438            0 :   if (! (Set1->solved && Set2->solved))
    6439              :     {
    6440            0 :       M2Error_InternalError ((const char *) "one or more operands have not been resolved", 43);
    6441              :     }
    6442            0 :   if (Set1->setValue == NULL)
    6443              :     {
    6444            0 :       Dispose (Set1);
    6445            0 :       Push (Set2);
    6446              :     }
    6447            0 :   else if (Set2->setValue == NULL)
    6448              :     {
    6449              :       /* avoid dangling else.  */
    6450            0 :       Dispose (Set2);
    6451            0 :       Push (Set1);
    6452              :     }
    6453              :   else
    6454              :     {
    6455              :       /* avoid dangling else.  */
    6456              :       /* Set1 or Set2 and (not (Set1 and Set2))  */
    6457            0 :       M2ALU_PushFrom (static_cast<M2ALU_PtrToValue> (Set1));
    6458            0 :       M2ALU_PushFrom (static_cast<M2ALU_PtrToValue> (Set2));
    6459            0 :       M2ALU_SetAnd (tokenno);
    6460            0 :       M2ALU_SetNegate (tokenno);
    6461            0 :       Push (Set1);
    6462            0 :       Push (Set2);
    6463            0 :       M2ALU_SetOr (tokenno);
    6464            0 :       M2ALU_SetAnd (tokenno);
    6465              :     }
    6466            0 : }
    6467              : 
    6468              : 
    6469              : /*
    6470              :    SetNegate - negates the top set on the stack.
    6471              : 
    6472              :                Ptr ->                                               <- Ptr
    6473              :                       +-----------+                  +------------+
    6474              :                       | Set       |                  | Set        |
    6475              :                       |-----------|                  |------------|
    6476              : */
    6477              : 
    6478           60 : extern "C" void M2ALU_SetNegate (unsigned int tokenno)
    6479              : {
    6480           60 :   unsigned int min;
    6481           60 :   unsigned int max;
    6482           60 :   M2ALU_listOfRange r;
    6483           60 :   M2ALU_listOfRange s;
    6484           60 :   M2ALU_PtrToValue__opaque v;
    6485           60 :   unsigned int i;
    6486              : 
    6487           60 :   v = Pop ();
    6488           60 :   Eval (tokenno, v);
    6489           60 :   if (v->constructorType == SymbolTable_NulSym)
    6490              :     {
    6491            0 :       M2MetaError_MetaError0 ((const char *) "cannot negate a generic set, set should be prefixed by a simple type", 68);
    6492              :     }
    6493           60 :   r = NULL;
    6494           60 :   min = M2GCCDeclare_GetTypeMin (SymbolTable_GetType (v->constructorType));
    6495           60 :   max = M2GCCDeclare_GetTypeMax (SymbolTable_GetType (v->constructorType));
    6496           60 :   i = min;
    6497           60 :   s = v->setValue;
    6498           60 :   if (Debugging)
    6499              :     {
    6500              :       M2Printf_printf0 ((const char *) "attempting to negate set\\n", 26);
    6501              :       DisplayElements (s);
    6502              :     }
    6503           60 :   while (s != NULL)
    6504              :     {
    6505            0 :       SymbolTable_PushValue (s->low);
    6506            0 :       SymbolTable_PushValue (min);
    6507            0 :       if (M2ALU_Gre (tokenno))
    6508              :         {
    6509            0 :           SymbolTable_PushValue (i);
    6510            0 :           SymbolTable_PushValue (max);
    6511            0 :           if (M2ALU_LessEqu (tokenno))
    6512              :             {
    6513            0 :               r = AddRange (r, i, DupConst (tokenno, s->low, -1));
    6514              :             }
    6515              :         }
    6516            0 :       SymbolTable_PushValue (s->high);
    6517            0 :       SymbolTable_PushValue (max);
    6518            0 :       if (M2ALU_Less (tokenno))
    6519              :         {
    6520            0 :           i = DupConst (tokenno, s->high, 1);
    6521            0 :           s = s->next;
    6522              :         }
    6523              :       else
    6524              :         {
    6525              :           s = NULL;
    6526              :         }
    6527              :     }
    6528           60 :   if (Debugging)
    6529              :     {
    6530              :       M2Printf_printf0 ((const char *) "negated set so far\\n", 20);
    6531              :       DisplayElements (r);
    6532              :     }
    6533           60 :   DisposeRange (&v->setValue);
    6534           60 :   SymbolTable_PushValue (i);
    6535           60 :   SymbolTable_PushValue (max);
    6536           60 :   if (M2ALU_LessEqu (tokenno))
    6537              :     {
    6538           60 :       r = AddRange (r, i, max);
    6539              :     }
    6540           60 :   if (Debugging)
    6541              :     {
    6542              :       M2Printf_printf0 ((const char *) "final negated set value\\n", 25);
    6543              :       DisplayElements (r);
    6544              :     }
    6545           60 :   v->solved = false;
    6546           60 :   v->setValue = r;
    6547           60 :   Eval (tokenno, v);
    6548           60 :   Push (v);
    6549           60 : }
    6550              : 
    6551              : 
    6552              : /*
    6553              :    SetShift - if op1 is positive
    6554              :               then
    6555              :                  result := op2 << op1
    6556              :               else
    6557              :                  result := op2 >> op1
    6558              :               fi
    6559              : 
    6560              : 
    6561              :               The Stack:
    6562              : 
    6563              :                      Entry             Exit
    6564              : 
    6565              :               Ptr ->
    6566              :                      +------------+
    6567              :                      | Op1        |                   <- Ptr
    6568              :                      |------------|    +------------+
    6569              :                      | Op2        |    | result     |
    6570              :                      |------------|    |------------|
    6571              : 
    6572              : */
    6573              : 
    6574            0 : extern "C" void M2ALU_SetShift (unsigned int tokenno)
    6575              : {
    6576            0 :   M2ALU_PtrToValue__opaque res;
    6577            0 :   M2ALU_PtrToValue__opaque Shift;
    6578            0 :   M2ALU_PtrToValue__opaque Set;
    6579            0 :   unsigned int n;
    6580            0 :   unsigned int r1;
    6581            0 :   unsigned int r2;
    6582              : 
    6583            0 :   if (! (M2ALU_IsValueTypeInteger ()))
    6584              :     {
    6585            0 :       M2Error_InternalError ((const char *) "expecting integer type", 22);
    6586              :     }
    6587            0 :   Shift = Pop ();
    6588            0 :   if (! (M2ALU_IsValueTypeSet ()))
    6589              :     {
    6590            0 :       M2Error_InternalError ((const char *) "expecting set type", 18);
    6591              :     }
    6592            0 :   Set = Pop ();
    6593            0 :   Eval (tokenno, Set);
    6594            0 :   if (! Set->solved)
    6595              :     {
    6596            0 :       M2Error_InternalError ((const char *) "set has not been resolved", 25);
    6597              :     }
    6598            0 :   if (Set->setValue == NULL)
    6599              :     {
    6600            0 :       Push (Set);
    6601              :     }
    6602              :   else
    6603              :     {
    6604            0 :       res = New ();
    6605            0 :       (*res) = (*Set);
    6606            0 :       res->setValue = NULL;
    6607            0 :       n = 1;
    6608            0 :       while (M2ALU_GetRange (static_cast<M2ALU_PtrToValue> (Set), n, &r1, &r2))
    6609              :         {
    6610            0 :           res->setValue = AddRange (res->setValue, DupConstAndAdd (tokenno, r1, reinterpret_cast <tree> (Shift)), DupConstAndAdd (tokenno, r2, reinterpret_cast <tree> (Shift)));
    6611            0 :           n += 1;
    6612              :         }
    6613            0 :       Push (res);
    6614            0 :       if (res->constructorType != SymbolTable_NulSym)
    6615              :         {
    6616            0 :           M2ALU_PushNulSet (res->constructorType);
    6617            0 :           M2ALU_SetNegate (tokenno);
    6618            0 :           M2ALU_SetAnd (tokenno);
    6619              :         }
    6620            0 :       Dispose (Set);
    6621              :     }
    6622            0 : }
    6623              : 
    6624              : 
    6625              : /*
    6626              :    SetRotate - if op1 is positive
    6627              :                then
    6628              :                   result := ROTATERIGHT(op2, op1)
    6629              :                else
    6630              :                   result := ROTATELEFT(op2, op1)
    6631              :                fi
    6632              : 
    6633              : 
    6634              :                The Stack:
    6635              : 
    6636              :                       Entry             Exit
    6637              : 
    6638              :                Ptr ->
    6639              :                       +------------+
    6640              :                       | Op1        |                   <- Ptr
    6641              :                       |------------|    +------------+
    6642              :                       | Op2        |    | result     |
    6643              :                       |------------|    |------------|
    6644              : */
    6645              : 
    6646            0 : extern "C" void M2ALU_SetRotate (unsigned int tokenno)
    6647              : {
    6648            0 :   M2ALU_PtrToValue__opaque res;
    6649            0 :   M2ALU_PtrToValue__opaque Rotate;
    6650            0 :   M2ALU_PtrToValue__opaque Set;
    6651            0 :   unsigned int n;
    6652            0 :   unsigned int l;
    6653            0 :   unsigned int h;
    6654            0 :   unsigned int type;
    6655            0 :   unsigned int r1;
    6656            0 :   unsigned int r2;
    6657              : 
    6658            0 :   if (! (M2ALU_IsValueTypeInteger ()))
    6659              :     {
    6660            0 :       M2Error_InternalError ((const char *) "expecting integer type", 22);
    6661              :     }
    6662            0 :   Rotate = Pop ();
    6663            0 :   if (! (M2ALU_IsValueTypeSet ()))
    6664              :     {
    6665            0 :       M2Error_InternalError ((const char *) "expecting set type", 18);
    6666              :     }
    6667            0 :   Set = Pop ();
    6668            0 :   Eval (tokenno, Set);
    6669            0 :   if (! Set->solved)
    6670              :     {
    6671            0 :       M2Error_InternalError ((const char *) "set has not been resolved", 25);
    6672              :     }
    6673            0 :   if (Set->setValue == NULL)
    6674              :     {
    6675            0 :       Push (Set);
    6676              :     }
    6677              :   else
    6678              :     {
    6679            0 :       type = Set->constructorType;
    6680            0 :       if (type == SymbolTable_NulSym)
    6681              :         {
    6682            0 :           M2MetaError_MetaErrorT0 (tokenno, (const char *) "cannot perform a ROTATE on a generic set", 40);
    6683            0 :           Push (Set);
    6684            0 :           return;
    6685              :         }
    6686            0 :       l = M2GCCDeclare_GetTypeMin (type);
    6687            0 :       h = M2GCCDeclare_GetTypeMax (type);
    6688            0 :       res = New ();
    6689            0 :       (*res) = (*Set);
    6690            0 :       res->setValue = NULL;
    6691            0 :       n = 1;
    6692            0 :       while (M2ALU_GetRange (static_cast<M2ALU_PtrToValue> (Set), n, &r1, &r2))
    6693              :         {
    6694            0 :           res->setValue = AddRange (res->setValue, DupConstAndAddMod (tokenno, r1, reinterpret_cast <tree> (Rotate), l, h), DupConstAndAddMod (tokenno, r2, reinterpret_cast <tree> (Rotate), l, h));
    6695            0 :           n += 1;
    6696              :         }
    6697            0 :       Push (res);
    6698            0 :       Dispose (Set);
    6699              :     }
    6700              : }
    6701              : 
    6702              : 
    6703              : /*
    6704              :    GetValue - returns and pops the value from the top of stack.
    6705              : */
    6706              : 
    6707           62 : extern "C" M2ALU_PtrToValue M2ALU_GetValue (unsigned int tokenno)
    6708              : {
    6709           62 :   M2ALU_PtrToValue__opaque v;
    6710              : 
    6711           62 :   v = Pop ();
    6712           62 :   Eval (tokenno, v);
    6713           62 :   return static_cast<M2ALU_PtrToValue> (v);
    6714              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6715              :   __builtin_unreachable ();
    6716              : }
    6717              : 
    6718              : 
    6719              : /*
    6720              :    GetRange - returns TRUE if range number, n, exists in the value, v.
    6721              :               A non empty set is defined by having 1..N ranges
    6722              : */
    6723              : 
    6724       250410 : extern "C" bool M2ALU_GetRange (M2ALU_PtrToValue v, unsigned int n, unsigned int *low, unsigned int *high)
    6725              : {
    6726       250410 :   M2ALU_listOfRange l;
    6727              : 
    6728       250410 :   if (static_cast<M2ALU_PtrToValue__opaque> (v)->type != M2ALU_set)
    6729              :     {
    6730            0 :       M2Error_InternalError ((const char *) "expecting set constant", 22);
    6731              :     }
    6732       250410 :   l = static_cast<M2ALU_PtrToValue__opaque> (v)->setValue;
    6733       580278 :   while (n > 1)
    6734              :     {
    6735       329868 :       if (l == NULL)
    6736              :         {
    6737              :           return false;
    6738              :         }
    6739       329868 :       l = l->next;
    6740       329868 :       n -= 1;
    6741              :     }
    6742       250410 :   if (l == NULL)
    6743              :     {
    6744              :       return false;
    6745              :     }
    6746       156524 :   (*low) = l->low;
    6747       156524 :   (*high) = l->high;
    6748       156524 :   return true;
    6749              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6750              :   __builtin_unreachable ();
    6751              : }
    6752              : 
    6753              : 
    6754              : /*
    6755              :    ConstructSetConstant - builds an array of bytes which represents the
    6756              :                           set const as defined by v.
    6757              : */
    6758              : 
    6759        12328 : extern "C" tree M2ALU_ConstructSetConstant (unsigned int tokenno, M2ALU_PtrToValue v)
    6760              : {
    6761        12328 :   NameKey_Name n1;
    6762        12328 :   NameKey_Name n2;
    6763        12328 :   unsigned int baseType;
    6764              : 
    6765        12328 :   if (static_cast<M2ALU_PtrToValue__opaque> (v)->constructorType == SymbolTable_NulSym)
    6766              :     {
    6767            0 :       M2Error_InternalError ((const char *) "set type must be known in order to generate a constant", 54);
    6768              :     }
    6769              :   else
    6770              :     {
    6771        12328 :       baseType = SymbolTable_SkipType (SymbolTable_GetType (static_cast<M2ALU_PtrToValue__opaque> (v)->constructorType));
    6772        12328 :       if (Debugging)
    6773              :         {
    6774              :           n1 = SymbolTable_GetSymName (static_cast<M2ALU_PtrToValue__opaque> (v)->constructorType);
    6775              :           n2 = SymbolTable_GetSymName (baseType);
    6776              :           M2Printf_printf2 ((const char *) "ConstructSetConstant of type %a and baseType %a\\n", 49, (const unsigned char *) &n1, (sizeof (n1)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
    6777              :         }
    6778        12328 :       return ConstructLargeOrSmallSet (tokenno, static_cast<M2ALU_PtrToValue__opaque> (v), M2GCCDeclare_GetTypeMin (baseType), M2GCCDeclare_GetTypeMax (baseType));
    6779              :     }
    6780              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    6781              :   __builtin_unreachable ();
    6782              : }
    6783              : 
    6784              : 
    6785              : /*
    6786              :    BuildRange - returns a integer sized constant which represents the
    6787              :                 value  {e1..e2}.
    6788              : */
    6789              : 
    6790        14098 : extern "C" tree M2ALU_BuildRange (unsigned int tokenno, tree e1, tree e2)
    6791              : {
    6792        14098 :   tree c;
    6793        14098 :   tree i;
    6794        14098 :   tree t;
    6795        14098 :   location_t location;
    6796              : 
    6797        14098 :   location = M2LexBuf_TokenToLocation (tokenno);
    6798        14098 :   M2ALU_PushIntegerTree (e1);
    6799        14098 :   M2ALU_PushIntegerTree (e2);
    6800        14098 :   if (M2ALU_Gre (tokenno))
    6801              :     {
    6802            0 :       c = e1;
    6803            0 :       e1 = e2;
    6804            0 :       e2 = c;
    6805              :     }
    6806        14098 :   t = (tree) (NULL);
    6807        14098 :   M2ALU_PushIntegerTree (e1);
    6808        14098 :   i = M2ALU_PopIntegerTree ();
    6809        20642 :   do {
    6810        20642 :     if (t == ((tree) (NULL)))
    6811              :       {
    6812        14098 :         t = m2expr_BuildLSL (location, m2expr_GetWordOne (location), m2convert_ToWord (location, i), false);
    6813              :       }
    6814              :     else
    6815              :       {
    6816         6544 :         t = m2expr_BuildLogicalOr (location, t, m2expr_BuildLSL (location, m2expr_GetWordOne (location), m2convert_ToWord (location, i), false));
    6817              :       }
    6818        20642 :     M2ALU_PushIntegerTree (i);
    6819        20642 :     M2ALU_PushIntegerTree (m2expr_GetIntegerOne (location));
    6820        20642 :     M2ALU_Addn ();
    6821        20642 :     i = M2ALU_PopIntegerTree ();
    6822        20642 :     M2ALU_PushIntegerTree (i);
    6823        20642 :     M2ALU_PushIntegerTree (e2);
    6824        20642 :   } while (! (M2ALU_Gre (tokenno)));
    6825        14098 :   return t;
    6826              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6827              :   __builtin_unreachable ();
    6828              : }
    6829              : 
    6830              : 
    6831              : /*
    6832              :    IsConstructorDependants - return TRUE if all q(dependants) of,
    6833              :                              sym, return TRUE.
    6834              : */
    6835              : 
    6836        97552 : extern "C" bool M2ALU_IsConstructorDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    6837              : {
    6838        97552 :   M2ALU_PtrToValue__opaque v;
    6839        97552 :   bool typeResult;
    6840        97552 :   bool result;
    6841              : 
    6842        97552 :   SymbolTable_PushValue (sym);
    6843        97552 :   if (M2ALU_IsValueTypeNone ())
    6844              :     {
    6845        39536 :       v = Pop ();
    6846        39536 :       result = false;
    6847              :     }
    6848              :   else
    6849              :     {
    6850        58016 :       v = Pop ();
    6851        58016 :       typeResult = (*q.proc) (v->constructorType);
    6852        58016 :       switch (v->type)
    6853              :         {
    6854              :           case M2ALU_none:
    6855              :             result = false;
    6856              :             break;
    6857              : 
    6858        29186 :           case M2ALU_set:
    6859        29186 :             result = IsSetValueDependants (v->setValue, q);
    6860        29186 :             break;
    6861              : 
    6862        25644 :           case M2ALU_constructor:
    6863        25644 :           case M2ALU_record:
    6864        25644 :             result = IsFieldValueDependants (v->fieldValues, q);
    6865        25644 :             break;
    6866              : 
    6867         3186 :           case M2ALU_array:
    6868         3186 :             result = IsArrayValueDependants (v->arrayValues, q);
    6869         3186 :             break;
    6870              : 
    6871              : 
    6872            0 :           default:
    6873            0 :             M2Error_InternalError ((const char *) "not expecting this type", 23);
    6874        58016 :             break;
    6875              :         }
    6876        58016 :       result = result && typeResult;
    6877              :     }
    6878        97552 :   return result;
    6879              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6880              :   __builtin_unreachable ();
    6881              : }
    6882              : 
    6883              : 
    6884              : /*
    6885              :    WalkConstructorDependants - walk the constructor, sym, calling
    6886              :                                p for each dependant.
    6887              : */
    6888              : 
    6889      1344636 : extern "C" void M2ALU_WalkConstructorDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    6890              : {
    6891      1344636 :   M2ALU_PtrToValue__opaque v;
    6892              : 
    6893      1344636 :   SymbolTable_PushValue (sym);
    6894      1344636 :   if (M2ALU_IsValueTypeNone ())
    6895              :     {
    6896        34392 :       v = Pop ();
    6897              :     }
    6898              :   else
    6899              :     {
    6900      1310244 :       v = Pop ();
    6901      1310244 :       (*p.proc) (v->constructorType);
    6902      1310244 :       switch (v->type)
    6903              :         {
    6904              :           case M2ALU_none:
    6905              :             break;
    6906              : 
    6907       453944 :           case M2ALU_set:
    6908       453944 :             WalkSetValueDependants (v->setValue, p);
    6909       453944 :             break;
    6910              : 
    6911       703116 :           case M2ALU_constructor:
    6912       703116 :           case M2ALU_record:
    6913       703116 :             WalkFieldValueDependants (v->fieldValues, p);
    6914              :             break;
    6915              : 
    6916       153184 :           case M2ALU_array:
    6917       153184 :             WalkArrayValueDependants (v->arrayValues, p);
    6918       153184 :             break;
    6919              : 
    6920              : 
    6921            0 :           default:
    6922            0 :             M2Error_InternalError ((const char *) "not expecting this type", 23);
    6923      1344636 :             break;
    6924              :         }
    6925              :     }
    6926      1344636 : }
    6927              : 
    6928              : 
    6929              : /*
    6930              :    IsValueAndTreeKnown - returns TRUE if the value is known and the gcc tree
    6931              :                          is defined.
    6932              : 
    6933              :                          The Stack:
    6934              : 
    6935              :                                 Entry             Exit
    6936              : 
    6937              :                          Ptr ->
    6938              :                                 +------------+
    6939              :                                 | Op1        |                   <- Ptr
    6940              :                                 |------------|    +------------+
    6941              : */
    6942              : 
    6943          102 : extern "C" bool M2ALU_IsValueAndTreeKnown (void)
    6944              : {
    6945          102 :   M2ALU_PtrToValue__opaque v;
    6946              : 
    6947          102 :   v = Pop ();
    6948          102 :   if (v != NULL)
    6949              :     {
    6950          102 :       if (v->solved)
    6951              :         {
    6952          102 :           switch (v->type)
    6953              :             {
    6954          102 :               case M2ALU_integer:
    6955          102 :               case M2ALU_real:
    6956          102 :               case M2ALU_complex:
    6957          102 :                 if (v->numberValue == NULL)
    6958              :                   {
    6959            0 :                     Dispose (v);
    6960            0 :                     return false;
    6961              :                   }
    6962              :                 break;
    6963              : 
    6964              : 
    6965              :               default:
    6966              :                 break;
    6967              :             }
    6968              :         }
    6969              :       else
    6970              :         {
    6971            0 :           Dispose (v);
    6972            0 :           return false;
    6973              :         }
    6974          102 :       Dispose (v);
    6975              :     }
    6976          102 :   return true;
    6977              :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6978              :   __builtin_unreachable ();
    6979              : }
    6980              : 
    6981              : 
    6982              : /*
    6983              :    CheckOrResetOverflow - tests to see whether the tree, t, has caused
    6984              :                           an overflow error and if so it generates an
    6985              :                           error message.
    6986              : */
    6987              : 
    6988       407731 : extern "C" void M2ALU_CheckOrResetOverflow (unsigned int tokenno, tree t, bool check)
    6989              : {
    6990       407731 :   if (check)
    6991              :     {
    6992       396571 :       CheckOverflow (tokenno, t);
    6993              :     }
    6994              :   else
    6995              :     {
    6996        11160 :       t = m2expr_RemoveOverflow (t);
    6997              :     }
    6998       407719 : }
    6999              : 
    7000              : 
    7001              : /*
    7002              :    AddElements - adds the elements, el BY, n, to the array constant.
    7003              : 
    7004              :                  Ptr ->
    7005              :                                                            <- Ptr
    7006              :                         +------------+      +------------+
    7007              :                         | Array      |      | Array      |
    7008              :                         |------------|      |------------|
    7009              : 
    7010              : */
    7011              : 
    7012           30 : extern "C" void M2ALU_AddElements (unsigned int tokenno, unsigned int el, unsigned int n)
    7013              : {
    7014           30 :   M2ALU_PtrToValue__opaque v;
    7015           30 :   M2ALU_listOfElements e;
    7016              : 
    7017           30 :   v = Pop ();
    7018           30 :   v = CoerseTo (tokenno, M2ALU_array, v);
    7019           30 :   if (v->type == M2ALU_array)
    7020              :     {
    7021           30 :       NewElement (&e);
    7022           30 :       e->element = el;
    7023           30 :       e->by = n;
    7024           30 :       e->next = NULL;
    7025           30 :       AddElementToEnd (v, e);
    7026           30 :       v->solved = (v->solved && (IsSolvedGCC (el))) && (IsSolvedGCC (n));
    7027              :     }
    7028              :   else
    7029              :     {
    7030            0 :       M2Error_InternalError ((const char *) "expecting array type", 20);
    7031              :     }
    7032           30 :   Push (v);
    7033           30 : }
    7034              : 
    7035              : 
    7036              : /*
    7037              :    AddField - adds the field op1 to the underlying constructor.
    7038              : 
    7039              :                  Ptr ->
    7040              :                                                            <- Ptr
    7041              :                         +------------+      +------------+
    7042              :                         | const      |      | const      |
    7043              :                         |------------|      |------------|
    7044              : 
    7045              : */
    7046              : 
    7047        13742 : extern "C" void M2ALU_AddField (unsigned int tokenno, unsigned int op1)
    7048              : {
    7049        13742 :   M2ALU_PtrToValue__opaque v;
    7050        13742 :   M2ALU_listOfFields f;
    7051        13742 :   M2ALU_listOfElements e;
    7052              : 
    7053        13742 :   v = Pop ();
    7054        13742 :   switch (v->type)
    7055              :     {
    7056            0 :       case M2ALU_set:
    7057            0 :         Push (v);
    7058            0 :         M2ALU_AddBit (tokenno, op1);
    7059            0 :         return;
    7060         4238 :         break;
    7061              : 
    7062         4238 :       case M2ALU_array:
    7063         4238 :         v->solved = v->solved && (IsSolvedGCC (op1));
    7064         4238 :         v->areAllConstants = v->areAllConstants && (SymbolTable_IsConst (op1));
    7065         4238 :         NewElement (&e);
    7066         4238 :         e->element = op1;
    7067         4238 :         e->by = SymbolTable_MakeConstLit (tokenno, NameKey_MakeKey ((const char *) "1", 1), M2Base_ZType);
    7068         4238 :         e->next = NULL;
    7069         4238 :         AddElementToEnd (v, e);
    7070              :         break;
    7071              : 
    7072         9504 :       case M2ALU_constructor:
    7073         9504 :       case M2ALU_record:
    7074         9504 :         v->solved = v->solved && (IsSolvedGCC (op1));
    7075         9504 :         v->areAllConstants = v->areAllConstants && (SymbolTable_IsConst (op1));
    7076         9504 :         NewField (&f);
    7077         9504 :         f->field = op1;
    7078         9504 :         f->next = NULL;
    7079         9504 :         AddFieldToEnd (v, f);
    7080              :         break;
    7081              : 
    7082              : 
    7083            0 :       default:
    7084            0 :         M2Error_InternalError ((const char *) "not expecting this constant type", 32);
    7085        13742 :         break;
    7086              :     }
    7087        13742 :   Push (v);
    7088              : }
    7089              : 
    7090              : 
    7091              : /*
    7092              :    PushEmptyConstructor - pushes an empty constructor {} onto the ALU stack.
    7093              :                           This is expected to be filled in by subsequent
    7094              :                           calls to AddElements, AddRange or AddField.
    7095              : 
    7096              :                           The Stack:
    7097              : 
    7098              :                           Entry             Exit
    7099              : 
    7100              :                                                        <- Ptr
    7101              :                                         +------------+
    7102              :                                         | {}         |
    7103              :                    Ptr ->               |------------|
    7104              : 
    7105              : */
    7106              : 
    7107            0 : extern "C" void M2ALU_PushEmptyConstructor (unsigned int constype)
    7108              : {
    7109            0 :   M2ALU_PtrToValue__opaque v;
    7110              : 
    7111            0 :   v = static_cast<M2ALU_PtrToValue__opaque> (M2ALU_InitValue ());
    7112            0 :   v->type = M2ALU_constructor;
    7113            0 :   v->constructorType = constype;
    7114            0 :   v->areAllConstants = true;
    7115            0 :   v->solved = M2GCCDeclare_CompletelyResolved (constype);
    7116            0 :   v->fieldValues = NULL;
    7117            0 :   v->next = static_cast<M2ALU_PtrToValue__opaque> (NULL);
    7118            0 :   Push (v);
    7119            0 : }
    7120              : 
    7121              : 
    7122              : /*
    7123              :    PushEmptyArray - pushes an empty array {} onto the ALU stack.
    7124              :                     This is expected to be filled in by subsequent
    7125              :                     calls to AddElements.
    7126              : 
    7127              :                     The Stack:
    7128              : 
    7129              :                     Entry             Exit
    7130              : 
    7131              :                                                      <- Ptr
    7132              :                                       +------------+
    7133              :                                       | {}         |
    7134              :              Ptr ->                   |------------|
    7135              : 
    7136              : */
    7137              : 
    7138            0 : extern "C" void M2ALU_PushEmptyArray (unsigned int arraytype)
    7139              : {
    7140            0 :   M2ALU_PtrToValue__opaque v;
    7141              : 
    7142            0 :   v = static_cast<M2ALU_PtrToValue__opaque> (M2ALU_InitValue ());
    7143            0 :   v->type = M2ALU_array;
    7144            0 :   v->constructorType = arraytype;
    7145            0 :   v->areAllConstants = true;
    7146            0 :   v->solved = M2GCCDeclare_CompletelyResolved (arraytype);
    7147            0 :   v->arrayValues = NULL;
    7148            0 :   v->next = static_cast<M2ALU_PtrToValue__opaque> (NULL);
    7149            0 :   Push (v);
    7150            0 : }
    7151              : 
    7152              : 
    7153              : /*
    7154              :    PushEmptyRecord - pushes an empty record {} onto the ALU stack.
    7155              :                      This is expected to be filled in by subsequent
    7156              :                      calls to AddField.
    7157              : 
    7158              :                      The Stack:
    7159              : 
    7160              :                      Entry             Exit
    7161              : 
    7162              :                                                       <- Ptr
    7163              :                                        +------------+
    7164              :                                        | {}         |
    7165              :               Ptr ->                   |------------|
    7166              : 
    7167              : */
    7168              : 
    7169            0 : extern "C" void M2ALU_PushEmptyRecord (unsigned int recordtype)
    7170              : {
    7171            0 :   M2ALU_PtrToValue__opaque v;
    7172              : 
    7173            0 :   v = static_cast<M2ALU_PtrToValue__opaque> (M2ALU_InitValue ());
    7174            0 :   v->type = M2ALU_record;
    7175            0 :   v->constructorType = recordtype;
    7176            0 :   v->areAllConstants = true;
    7177            0 :   v->solved = M2GCCDeclare_CompletelyResolved (recordtype);
    7178            0 :   v->arrayValues = NULL;
    7179            0 :   v->next = static_cast<M2ALU_PtrToValue__opaque> (NULL);
    7180            0 :   Push (v);
    7181            0 : }
    7182              : 
    7183              : 
    7184              : /*
    7185              :    ChangeToConstructor - change the top of stack value to a constructor, type.
    7186              :                          (Constructor, Set, Array or Record).
    7187              : */
    7188              : 
    7189        44898 : extern "C" void M2ALU_ChangeToConstructor (unsigned int tokenno, unsigned int constype)
    7190              : {
    7191        44898 :   M2ALU_PtrToValue__opaque v;
    7192              : 
    7193        44898 :   if ((((M2ALU_IsValueTypeConstructor ()) || (M2ALU_IsValueTypeSet ())) || (M2ALU_IsValueTypeArray ())) || (M2ALU_IsValueTypeRecord ()))
    7194              :     {
    7195         8434 :       return;
    7196              :     }
    7197        36464 :   else if (M2ALU_IsValueTypeNone ())
    7198              :     {
    7199              :       /* avoid dangling else.  */
    7200        36464 :       v = Pop ();
    7201        36464 :       v->type = M2ALU_constructor;
    7202        36464 :       v->constructorType = constype;
    7203        36464 :       v->solved = M2GCCDeclare_CompletelyResolved (constype);
    7204        36464 :       v->fieldValues = NULL;
    7205        36464 :       v->next = static_cast<M2ALU_PtrToValue__opaque> (NULL);
    7206        36464 :       if (SymbolTable_IsSet (SymbolTable_SkipType (constype)))
    7207              :         {
    7208        33232 :           v = CoerseTo (tokenno, M2ALU_set, v);
    7209              :         }
    7210         3232 :       else if (SymbolTable_IsRecord (SymbolTable_SkipType (constype)))
    7211              :         {
    7212              :           /* avoid dangling else.  */
    7213         2282 :           v = CoerseTo (tokenno, M2ALU_record, v);
    7214              :         }
    7215          950 :       else if (SymbolTable_IsArray (SymbolTable_SkipType (constype)))
    7216              :         {
    7217              :           /* avoid dangling else.  */
    7218          944 :           v = CoerseTo (tokenno, M2ALU_array, v);
    7219              :         }
    7220        36464 :       Push (v);
    7221              :     }
    7222              :   else
    7223              :     {
    7224              :       /* avoid dangling else.  */
    7225            0 :       M2Error_InternalError ((const char *) "cannot change constant to a constructor type", 44);
    7226              :     }
    7227              : }
    7228              : 
    7229              : 
    7230              : /*
    7231              :    IsValueConst - returns true if the memory cell indicated by v
    7232              :                   is only defined by constants.  For example
    7233              :                   no variables are used in the constructor.
    7234              : */
    7235              : 
    7236      4191942 : extern "C" bool M2ALU_IsValueConst (M2ALU_PtrToValue v)
    7237              : {
    7238      4191942 :   if (v == NULL)
    7239              :     {
    7240            0 :       M2Error_InternalError ((const char *) "uninitialized value", 19);
    7241              :     }
    7242              :   else
    7243              :     {
    7244      4191942 :       return static_cast<M2ALU_PtrToValue__opaque> (v)->areAllConstants;
    7245              :     }
    7246              :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2ALU.def", 20, 1);
    7247              :   __builtin_unreachable ();
    7248              : }
    7249              : 
    7250              : 
    7251              : /*
    7252              :    PushTypeOfTree - pushes tree, gcc, to the stack and records the
    7253              :                     front end type.
    7254              : */
    7255              : 
    7256       460517 : extern "C" void M2ALU_PushTypeOfTree (unsigned int sym, tree gcc)
    7257              : {
    7258       460517 :   unsigned int t;
    7259              : 
    7260       460517 :   t = SymbolTable_SkipType (SymbolTable_GetType (sym));
    7261       460517 :   if (t == SymbolTable_NulSym)
    7262              :     {
    7263         6376 :       M2ALU_PushIntegerTree (gcc);
    7264              :     }
    7265       454141 :   else if (M2Base_IsComplexType (t))
    7266              :     {
    7267              :       /* avoid dangling else.  */
    7268          708 :       M2ALU_PushComplexTree (gcc);
    7269              :     }
    7270       453433 :   else if (SymbolTable_IsArray (t))
    7271              :     {
    7272              :       /* avoid dangling else.  */
    7273            0 :       PushGCCArrayTree (gcc, t);
    7274              :     }
    7275       453433 :   else if (SymbolTable_IsSet (t))
    7276              :     {
    7277              :       /* avoid dangling else.  */
    7278           18 :       PushGCCSetTree (gcc, t);
    7279              :     }
    7280       453415 :   else if (SymbolTable_IsRecord (t))
    7281              :     {
    7282              :       /* avoid dangling else.  */
    7283            0 :       PushGCCRecordTree (gcc, t);
    7284              :     }
    7285       453415 :   else if (M2Base_IsRealType (t))
    7286              :     {
    7287              :       /* avoid dangling else.  */
    7288         1242 :       M2ALU_PushRealTree (gcc);
    7289              :     }
    7290              :   else
    7291              :     {
    7292              :       /* avoid dangling else.  */
    7293       452173 :       M2ALU_PushIntegerTree (gcc);
    7294              :     }
    7295       460517 : }
    7296              : 
    7297        14952 : extern "C" void _M2_M2ALU_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
    7298              : {
    7299        14952 :   Init ();
    7300        14952 : }
    7301              : 
    7302            0 : extern "C" void _M2_M2ALU_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
    7303              : {
    7304            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.