Changeset 1a18423


Ignore:
Timestamp:
Jun 22, 2017, 9:43:02 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
7d9c987
Parents:
405c592 (diff), e9a3b20b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/FixNames.cc

    r405c592 r1a18423  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 07:50:30 2017
    13 // Update Count     : 16
     12// Last Modified On : Wed Jun 21 14:22:59 2017
     13// Update Count     : 19
    1414//
    1515
     
    114114                                throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl);
    115115                        }
    116                         functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), "0") ) ) );
     116                        functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new ConstantExpr( Constant::from_int( 0 ) ) ) );
    117117                        CodeGen::FixMain::registerMain( functionDecl );
    118118                }
  • src/Common/PassVisitor.h

    r405c592 r1a18423  
    1818// Templated visitor type
    1919// To use declare a PassVisitor< YOUR VISITOR TYPE >
    20 // The visitor type should specify the previsit/postvisit for types that are desired.
     20// The visitor type should specify the previsit/postvisit/premutate/postmutate for types that are desired.
     21// Note: previsit/postvisit/premutate/postmutate must be **public** members
     22//
     23// Several additional features are available through inheritance
     24// | WithTypeSubstitution - provides polymorphic TypeSubstitution * env for the current expression
     25// | WithStmtsToAdd       - provides the ability to insert statements before or after the current statement by adding new statements into
     26//                          stmtsToAddBefore or stmtsToAddAfter respectively.
     27// | WithShortCircuiting  - provides the ability to skip visiting child nodes; set skip_children to true if pre{visit,mutate} to skip visiting children
     28// | WithScopes           - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable
     29//                          will automatically be restored to its previous value after the corresponding postvisit/postmutate teminates.
    2130//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    2231template< typename pass_type >
     
    8695        virtual void visit( ConstructorExpr * ctorExpr ) override final;
    8796        virtual void visit( CompoundLiteralExpr *compLitExpr ) override final;
    88         virtual void visit( UntypedValofExpr *valofExpr ) override final;
    8997        virtual void visit( RangeExpr *rangeExpr ) override final;
    9098        virtual void visit( UntypedTupleExpr *tupleExpr ) override final;
     
    172180        virtual Expression* mutate( ConstructorExpr *ctorExpr ) override final;
    173181        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ) override final;
    174         virtual Expression* mutate( UntypedValofExpr *valofExpr ) override final;
    175182        virtual Expression* mutate( RangeExpr *rangeExpr ) override final;
    176183        virtual Expression* mutate( UntypedTupleExpr *tupleExpr ) override final;
  • src/Common/PassVisitor.impl.h

    r405c592 r1a18423  
    66        call_previsit( node );                    \
    77        if( visit_children() ) {                  \
    8                 reset_visit();                      \
    98
    109#define VISIT_END( node )                       \
    1110        }                                         \
     11        reset_visit();                            \
    1212        call_postvisit( node );                   \
    1313
     
    1717        call_premutate( node );                   \
    1818        if( visit_children() ) {                  \
    19                 reset_visit();                      \
    2019
    2120#define MUTATE_END( type, node )                \
    2221        }                                         \
     22        reset_visit();                            \
    2323        return call_postmutate< type * >( node ); \
    2424
     
    159159template< typename pass_type >
    160160void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
    161         VISIT_BODY( node ); 
     161        VISIT_BODY( node );
    162162}
    163163
    164164template< typename pass_type >
    165165void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
    166         VISIT_BODY( node ); 
     166        VISIT_BODY( node );
    167167}
    168168
    169169template< typename pass_type >
    170170void PassVisitor< pass_type >::visit( StructDecl * node ) {
    171         VISIT_BODY( node ); 
     171        VISIT_BODY( node );
    172172}
    173173
    174174template< typename pass_type >
    175175void PassVisitor< pass_type >::visit( UnionDecl * node ) {
    176         VISIT_BODY( node ); 
     176        VISIT_BODY( node );
    177177}
    178178
    179179template< typename pass_type >
    180180void PassVisitor< pass_type >::visit( EnumDecl * node ) {
    181         VISIT_BODY( node ); 
     181        VISIT_BODY( node );
    182182}
    183183
    184184template< typename pass_type >
    185185void PassVisitor< pass_type >::visit( TraitDecl * node ) {
    186         VISIT_BODY( node ); 
     186        VISIT_BODY( node );
    187187}
    188188
    189189template< typename pass_type >
    190190void PassVisitor< pass_type >::visit( TypeDecl * node ) {
    191         VISIT_BODY( node ); 
     191        VISIT_BODY( node );
    192192}
    193193
    194194template< typename pass_type >
    195195void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
    196         VISIT_BODY( node ); 
     196        VISIT_BODY( node );
    197197}
    198198
    199199template< typename pass_type >
    200200void PassVisitor< pass_type >::visit( AsmDecl * node ) {
    201         VISIT_BODY( node ); 
     201        VISIT_BODY( node );
    202202}
    203203
     
    250250template< typename pass_type >
    251251void PassVisitor< pass_type >::visit( AsmStmt * node ) {
    252         VISIT_BODY( node ); 
     252        VISIT_BODY( node );
    253253}
    254254
     
    257257template< typename pass_type >
    258258void PassVisitor< pass_type >::visit( IfStmt * node ) {
    259         VISIT_START( node ); 
     259        VISIT_START( node );
    260260
    261261        visitExpression( node->get_condition() );
     
    268268template< typename pass_type >
    269269Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
    270         MUTATE_START( node ); 
     270        MUTATE_START( node );
    271271
    272272        node->set_condition( mutateExpression( node->get_condition() ) );
     
    281281template< typename pass_type >
    282282void PassVisitor< pass_type >::visit( WhileStmt * node ) {
    283         VISIT_START( node ); 
     283        VISIT_START( node );
    284284
    285285        visitExpression( node->get_condition() );
     
    291291template< typename pass_type >
    292292Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
    293         MUTATE_START( node ); 
     293        MUTATE_START( node );
    294294
    295295        node->set_condition( mutateExpression( node->get_condition() ) );
     
    303303template< typename pass_type >
    304304void PassVisitor< pass_type >::visit( ForStmt * node ) {
    305         VISIT_START( node ); 
     305        VISIT_START( node );
    306306
    307307        acceptAll( node->get_initialization(), *this );
     
    315315template< typename pass_type >
    316316Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
    317         MUTATE_START( node ); 
     317        MUTATE_START( node );
    318318
    319319        mutateAll( node->get_initialization(), *this );
     
    329329template< typename pass_type >
    330330void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
    331         VISIT_START( node ); 
     331        VISIT_START( node );
    332332
    333333        visitExpression( node->get_condition() );
     
    339339template< typename pass_type >
    340340Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
    341         MUTATE_START( node ); 
    342        
     341        MUTATE_START( node );
     342
    343343        node->set_condition( mutateExpression( node->get_condition() ) );
    344344        mutateStatementList( node->get_statements() );
    345        
     345
    346346        MUTATE_END( Statement, node );
    347347}
     
    351351template< typename pass_type >
    352352void PassVisitor< pass_type >::visit( CaseStmt * node ) {
    353         VISIT_START( node ); 
    354        
     353        VISIT_START( node );
     354
    355355        visitExpression( node->get_condition() );
    356356        visitStatementList( node->get_statements() );
    357        
     357
    358358        VISIT_END( node );
    359359}
     
    361361template< typename pass_type >
    362362Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
    363         MUTATE_START( node ); 
    364        
     363        MUTATE_START( node );
     364
    365365        node->set_condition(  mutateExpression( node->get_condition() ) );
    366366        mutateStatementList( node->get_statements() );
    367        
     367
    368368        MUTATE_END( Statement, node );
    369369}
     
    371371template< typename pass_type >
    372372void PassVisitor< pass_type >::visit( BranchStmt * node ) {
    373         VISIT_BODY( node ); 
     373        VISIT_BODY( node );
    374374}
    375375
     
    425425        node->set_block(  maybeMutate( node->get_block(), *this ) );
    426426        mutateAll( node->get_catchers(), *this );
    427        
     427
    428428        MUTATE_END( Statement, node );
    429429}
     
    444444Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
    445445        MUTATE_START( node );
    446        
     446
    447447        node->set_body(  mutateStatement( node->get_body() ) );
    448448        node->set_decl(  maybeMutate( node->get_decl(), *this ) );
    449        
     449
    450450        MUTATE_END( Statement, node );
    451451}
     
    453453template< typename pass_type >
    454454void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
    455         VISIT_BODY( node ); 
     455        VISIT_BODY( node );
    456456}
    457457
    458458template< typename pass_type >
    459459void PassVisitor< pass_type >::visit( NullStmt * node ) {
    460         VISIT_BODY( node ); 
     460        VISIT_BODY( node );
    461461}
    462462
    463463template< typename pass_type >
    464464void PassVisitor< pass_type >::visit( DeclStmt * node ) {
    465         VISIT_BODY( node ); 
     465        VISIT_BODY( node );
    466466}
    467467
    468468template< typename pass_type >
    469469void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
    470         VISIT_BODY( node ); 
     470        VISIT_BODY( node );
    471471}
    472472
    473473template< typename pass_type >
    474474void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
    475         VISIT_BODY( node ); 
     475        VISIT_BODY( node );
    476476}
    477477
     
    502502template< typename pass_type >
    503503void PassVisitor< pass_type >::visit( NameExpr * node ) {
    504         VISIT_BODY( node ); 
     504        VISIT_BODY( node );
    505505}
    506506
    507507template< typename pass_type >
    508508void PassVisitor< pass_type >::visit( CastExpr * node ) {
    509         VISIT_BODY( node ); 
     509        VISIT_BODY( node );
    510510}
    511511
    512512template< typename pass_type >
    513513void PassVisitor< pass_type >::visit( AddressExpr * node ) {
    514         VISIT_BODY( node ); 
     514        VISIT_BODY( node );
    515515}
    516516
    517517template< typename pass_type >
    518518void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
    519         VISIT_BODY( node ); 
     519        VISIT_BODY( node );
    520520}
    521521
    522522template< typename pass_type >
    523523void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
    524         VISIT_BODY( node ); 
     524        VISIT_BODY( node );
    525525}
    526526
    527527template< typename pass_type >
    528528void PassVisitor< pass_type >::visit( MemberExpr * node ) {
    529         VISIT_BODY( node ); 
     529        VISIT_BODY( node );
    530530}
    531531
    532532template< typename pass_type >
    533533void PassVisitor< pass_type >::visit( VariableExpr * node ) {
    534         VISIT_BODY( node ); 
     534        VISIT_BODY( node );
    535535}
    536536
    537537template< typename pass_type >
    538538void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
    539         VISIT_BODY( node ); 
     539        VISIT_BODY( node );
    540540}
    541541
    542542template< typename pass_type >
    543543void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
    544         VISIT_BODY( node ); 
     544        VISIT_BODY( node );
    545545}
    546546
    547547template< typename pass_type >
    548548void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
    549         VISIT_BODY( node ); 
     549        VISIT_BODY( node );
    550550}
    551551
    552552template< typename pass_type >
    553553void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
    554         VISIT_BODY( node ); 
     554        VISIT_BODY( node );
    555555}
    556556
    557557template< typename pass_type >
    558558void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
    559         VISIT_BODY( node ); 
     559        VISIT_BODY( node );
    560560}
    561561
    562562template< typename pass_type >
    563563void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
    564         VISIT_BODY( node ); 
     564        VISIT_BODY( node );
    565565}
    566566
    567567template< typename pass_type >
    568568void PassVisitor< pass_type >::visit( AttrExpr * node ) {
    569         VISIT_BODY( node ); 
     569        VISIT_BODY( node );
    570570}
    571571
    572572template< typename pass_type >
    573573void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
    574         VISIT_BODY( node ); 
     574        VISIT_BODY( node );
    575575}
    576576
    577577template< typename pass_type >
    578578void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
    579         VISIT_BODY( node ); 
     579        VISIT_BODY( node );
    580580}
    581581
    582582template< typename pass_type >
    583583void PassVisitor< pass_type >::visit( CommaExpr * node ) {
    584         VISIT_BODY( node ); 
     584        VISIT_BODY( node );
    585585}
    586586
    587587template< typename pass_type >
    588588void PassVisitor< pass_type >::visit( TypeExpr * node ) {
    589         VISIT_BODY( node ); 
     589        VISIT_BODY( node );
    590590}
    591591
    592592template< typename pass_type >
    593593void PassVisitor< pass_type >::visit( AsmExpr * node ) {
    594         VISIT_BODY( node ); 
     594        VISIT_BODY( node );
    595595}
    596596
    597597template< typename pass_type >
    598598void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
    599         VISIT_BODY( node ); 
     599        VISIT_BODY( node );
    600600}
    601601
    602602template< typename pass_type >
    603603void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
    604         VISIT_BODY( node ); 
     604        VISIT_BODY( node );
    605605}
    606606
    607607template< typename pass_type >
    608608void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
    609         VISIT_BODY( node );
    610 }
    611 
    612 template< typename pass_type >
    613 void PassVisitor< pass_type >::visit( UntypedValofExpr * node ) {
    614         VISIT_BODY( node );
     609        VISIT_BODY( node );
    615610}
    616611
    617612template< typename pass_type >
    618613void PassVisitor< pass_type >::visit( RangeExpr * node ) {
    619         VISIT_BODY( node ); 
     614        VISIT_BODY( node );
    620615}
    621616
    622617template< typename pass_type >
    623618void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
    624         VISIT_BODY( node ); 
     619        VISIT_BODY( node );
    625620}
    626621
    627622template< typename pass_type >
    628623void PassVisitor< pass_type >::visit( TupleExpr * node ) {
    629         VISIT_BODY( node ); 
     624        VISIT_BODY( node );
    630625}
    631626
    632627template< typename pass_type >
    633628void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
    634         VISIT_BODY( node ); 
     629        VISIT_BODY( node );
    635630}
    636631
    637632template< typename pass_type >
    638633void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
    639         VISIT_BODY( node ); 
     634        VISIT_BODY( node );
    640635}
    641636
     
    659654Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
    660655        MUTATE_START( node );
    661        
     656
    662657        // don't want statements from outer CompoundStmts to be added to this StmtExpr
    663658        ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
     
    672667template< typename pass_type >
    673668void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
    674         VISIT_BODY( node ); 
     669        VISIT_BODY( node );
    675670}
    676671
    677672template< typename pass_type >
    678673void PassVisitor< pass_type >::visit( VoidType * node ) {
    679         VISIT_BODY( node ); 
     674        VISIT_BODY( node );
    680675}
    681676
    682677template< typename pass_type >
    683678void PassVisitor< pass_type >::visit( BasicType * node ) {
    684         VISIT_BODY( node ); 
     679        VISIT_BODY( node );
    685680}
    686681
    687682template< typename pass_type >
    688683void PassVisitor< pass_type >::visit( PointerType * node ) {
    689         VISIT_BODY( node ); 
     684        VISIT_BODY( node );
    690685}
    691686
    692687template< typename pass_type >
    693688void PassVisitor< pass_type >::visit( ArrayType * node ) {
    694         VISIT_BODY( node ); 
     689        VISIT_BODY( node );
    695690}
    696691
    697692template< typename pass_type >
    698693void PassVisitor< pass_type >::visit( FunctionType * node ) {
    699         VISIT_BODY( node ); 
     694        VISIT_BODY( node );
    700695}
    701696
    702697template< typename pass_type >
    703698void PassVisitor< pass_type >::visit( StructInstType * node ) {
    704         VISIT_BODY( node ); 
     699        VISIT_BODY( node );
    705700}
    706701
    707702template< typename pass_type >
    708703void PassVisitor< pass_type >::visit( UnionInstType * node ) {
    709         VISIT_BODY( node ); 
     704        VISIT_BODY( node );
    710705}
    711706
    712707template< typename pass_type >
    713708void PassVisitor< pass_type >::visit( EnumInstType * node ) {
    714         VISIT_BODY( node ); 
     709        VISIT_BODY( node );
    715710}
    716711
    717712template< typename pass_type >
    718713void PassVisitor< pass_type >::visit( TraitInstType * node ) {
    719         VISIT_BODY( node ); 
     714        VISIT_BODY( node );
    720715}
    721716
    722717template< typename pass_type >
    723718void PassVisitor< pass_type >::visit( TypeInstType * node ) {
    724         VISIT_BODY( node ); 
     719        VISIT_BODY( node );
    725720}
    726721
    727722template< typename pass_type >
    728723void PassVisitor< pass_type >::visit( TupleType * node ) {
    729         VISIT_BODY( node ); 
     724        VISIT_BODY( node );
    730725}
    731726
    732727template< typename pass_type >
    733728void PassVisitor< pass_type >::visit( TypeofType * node ) {
    734         VISIT_BODY( node ); 
     729        VISIT_BODY( node );
    735730}
    736731
    737732template< typename pass_type >
    738733void PassVisitor< pass_type >::visit( AttrType * node ) {
    739         VISIT_BODY( node ); 
     734        VISIT_BODY( node );
    740735}
    741736
    742737template< typename pass_type >
    743738void PassVisitor< pass_type >::visit( VarArgsType * node ) {
    744         VISIT_BODY( node ); 
     739        VISIT_BODY( node );
    745740}
    746741
    747742template< typename pass_type >
    748743void PassVisitor< pass_type >::visit( ZeroType * node ) {
    749         VISIT_BODY( node ); 
     744        VISIT_BODY( node );
    750745}
    751746
    752747template< typename pass_type >
    753748void PassVisitor< pass_type >::visit( OneType * node ) {
    754         VISIT_BODY( node ); 
     749        VISIT_BODY( node );
    755750}
    756751
     
    777772template< typename pass_type >
    778773void PassVisitor< pass_type >::visit( ListInit * node ) {
    779         VISIT_BODY( node ); 
     774        VISIT_BODY( node );
    780775}
    781776
    782777template< typename pass_type >
    783778void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
    784         VISIT_BODY( node ); 
     779        VISIT_BODY( node );
    785780}
    786781
    787782template< typename pass_type >
    788783void PassVisitor< pass_type >::visit( Subrange * node ) {
    789         VISIT_BODY( node ); 
     784        VISIT_BODY( node );
    790785}
    791786
    792787template< typename pass_type >
    793788void PassVisitor< pass_type >::visit( Constant * node ) {
    794         VISIT_BODY( node ); 
     789        VISIT_BODY( node );
    795790}
    796791
     
    988983
    989984template< typename pass_type >
    990 Expression * PassVisitor< pass_type >::mutate( UntypedValofExpr * node ) {
    991         MUTATE_BODY( Expression, node );
    992 }
    993 
    994 template< typename pass_type >
    995985Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
    996986        MUTATE_BODY( Expression, node );
  • src/GenPoly/Box.cc

    r405c592 r1a18423  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 13 09:26:38 2017
    13 // Update Count     : 341
     12// Last Modified On : Wed Jun 21 15:49:59 2017
     13// Update Count     : 346
    1414//
    1515
     
    341341        Statement *makeAlignTo( Expression *lhs, Expression *rhs ) {
    342342                // check that the lhs is zeroed out to the level of rhs
    343                 Expression *ifCond = makeOp( "?&?", lhs, makeOp( "?-?", rhs, new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "1" ) ) ) );
     343                Expression *ifCond = makeOp( "?&?", lhs, makeOp( "?-?", rhs, new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
    344344                // if not aligned, increment to alignment
    345345                Expression *ifExpr = makeOp( "?+=?", lhs->clone(), makeOp( "?-?", rhs->clone(), ifCond->clone() ) );
     
    384384
    385385                // initialize size and alignment to 0 and 1 (will have at least one member to re-edit size)
    386                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "0" ) ) ) );
    387                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
     386                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant::from_ulong( 0 ) ) ) );
     387                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
    388388                unsigned long n_members = 0;
    389389                bool firstMember = true;
     
    441441
    442442                // calculate union layout in function body
    443                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
    444                 addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant( sizeAlignType->clone(), "1" ) ) ) );
     443                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( sizeParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
     444                addExpr( layoutDecl->get_statements(), makeOp( "?=?", derefVar( alignParam ), new ConstantExpr( Constant::from_ulong( 1 ) ) ) );
    445445                for ( std::list< Declaration* >::const_iterator member = unionDecl->get_members().begin(); member != unionDecl->get_members().end(); ++member ) {
    446446                        DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member );
     
    15641564                /// Returns an index expression into the offset array for a type
    15651565                Expression *makeOffsetIndex( Type *objectType, long i ) {
    1566                         std::stringstream offset_namer;
    1567                         offset_namer << i;
    1568                         ConstantExpr *fieldIndex = new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), offset_namer.str() ) );
     1566                        ConstantExpr *fieldIndex = new ConstantExpr( Constant::from_ulong( i ) );
    15691567                        UntypedExpr *fieldOffset = new UntypedExpr( new NameExpr( "?[?]" ) );
    15701568                        fieldOffset->get_args().push_back( new NameExpr( offsetofName( mangleType( objectType ) ) ) );
     
    17791777                                // all union members are at offset zero
    17801778                                delete offsetofExpr;
    1781                                 return new ConstantExpr( Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), "0" ) );
     1779                                return new ConstantExpr( Constant::from_ulong( 0 ) );
    17821780                        } else return offsetofExpr;
    17831781                }
  • src/InitTweak/FixInit.cc

    r405c592 r1a18423  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:13:47 2017
    13 // Update Count     : 71
     12// Last Modified On : Wed Jun 21 17:35:05 2017
     13// Update Count     : 74
    1414//
    1515
     
    5656                typedef std::unordered_map< int, int > UnqCount;
    5757
    58                 class InsertImplicitCalls {
     58                class InsertImplicitCalls : public WithTypeSubstitution {
    5959                public:
    6060                        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
     
    6969                        // collects environments for relevant nodes
    7070                        EnvMap & envMap;
    71                         TypeSubstitution * env; //Magically populated by the PassVisitor
    7271                };
    7372
     
    192191                };
    193192
    194                 class FixInit {
     193                class FixInit : public WithStmtsToAdd {
    195194                  public:
    196195                        /// expand each object declaration to use its constructor after it is declared.
     
    200199
    201200                        std::list< Declaration * > staticDtorDecls;
    202                         std::list< Statement * > stmtsToAddAfter; // found by PassVisitor
    203201                };
    204202
     
    726724                                                // static bool __objName_uninitialized = true
    727725                                                BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
    728                                                 SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators );
     726                                                SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant::from_int( 1 ) ), noDesignators );
    729727                                                ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );
    730728                                                isUninitializedVar->fixUniqueId();
     
    733731                                                UntypedExpr * setTrue = new UntypedExpr( new NameExpr( "?=?" ) );
    734732                                                setTrue->get_args().push_back( new VariableExpr( isUninitializedVar ) );
    735                                                 setTrue->get_args().push_back( new ConstantExpr( Constant( boolType->clone(), "0" ) ) );
     733                                                setTrue->get_args().push_back( new ConstantExpr( Constant::from_int( 0 ) ) );
    736734
    737735                                                // generate body of if
  • src/Parser/ExpressionNode.cc

    r405c592 r1a18423  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 17 21:31:01 2017
    13 // Update Count     : 527
     12// Last Modified On : Wed Jun 21 16:44:46 2017
     13// Update Count     : 541
    1414//
    1515
     
    6262        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
    6363        int size;                                                                                       // 0 => int, 1 => long, 2 => long long
    64         unsigned long long v;                                                           // converted integral value
     64        unsigned long long int v;                                                               // converted integral value
    6565        size_t last = str.length() - 1;                                         // last character of constant
    6666
     
    118118        } // if
    119119
    120         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str ) );
     120        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str, v ) );
    121121        delete &str;                                                                            // created by lex
    122122        return ret;
     
    133133        // floating-point constant has minimum of 2 characters: 1. or .1
    134134        size_t last = str.length() - 1;
     135        double v;
     136
     137        sscanf( str.c_str(), "%lg", &v );
    135138
    136139        if ( checkI( str[last] ) ) {                                            // imaginary ?
     
    150153        } // if
    151154
    152         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str ) );
     155        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str, v ) );
    153156        delete &str;                                                                            // created by lex
    154157        return ret;
     
    156159
    157160Expression *build_constantChar( const std::string & str ) {
    158         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str ) );
     161        Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
    159162        delete &str;                                                                            // created by lex
    160163        return ret;
     
    164167        // string should probably be a primitive type
    165168        ArrayType *at = new ArrayType( emptyQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
    166                                 new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::UnsignedInt ),
    167                                                                                         toString( str.size()+1-2 ) ) ),  // +1 for '\0' and -2 for '"'
     169                                                                   new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ),  // +1 for '\0' and -2 for '"'
    168170                                                                   false, false );
    169         ConstantExpr * ret = new ConstantExpr( Constant( at, str ) );
     171        // constant 0 is ignored for pure string value
     172        ConstantExpr * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) );
    170173        delete &str;                                                                            // created by lex
    171174        return ret;
     
    173176
    174177Expression *build_constantZeroOne( const std::string & str ) {
    175         Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str ) );
     178        Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str,
     179                                                                                                   str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );
    176180        delete &str;                                                                            // created by lex
    177181        return ret;
     
    184188        std::stringstream ss( str );
    185189        ss >> a >> dot >> b;
    186         UntypedMemberExpr * ret = new UntypedMemberExpr(
    187                 new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( b ) ) ),
    188                 new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( a ) ) ) );
     190        UntypedMemberExpr * ret = new UntypedMemberExpr( new ConstantExpr( Constant::from_int( b ) ), new ConstantExpr( Constant::from_int( a ) ) );
    189191        delete &str;
    190192        return ret;
     
    346348
    347349Expression *build_valexpr( StatementNode *s ) {
    348         return new UntypedValofExpr( maybeMoveBuild< Statement >(s), nullptr );
     350        return new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(s) ) );
    349351}
    350352Expression *build_typevalue( DeclarationNode *decl ) {
  • src/Parser/ParseNode.h

    r405c592 r1a18423  
    415415                                result->location = cur->location;
    416416                                * out++ = result;
     417                        } else {
     418                                assertf(false, "buildList unknown type");
    417419                        } // if
    418420                } catch( SemanticError &e ) {
  • src/Parser/StatementNode.cc

    r405c592 r1a18423  
    175175
    176176Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
    177         std::list< Statement * > branches;
    178         buildMoveList< Statement, StatementNode >( catch_stmt, branches );
     177        std::list< CatchStmt * > branches;
     178        buildMoveList< CatchStmt, StatementNode >( catch_stmt, branches );
    179179        CompoundStmt *tryBlock = safe_dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
    180180        FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
  • src/Parser/parseutility.cc

    r405c592 r1a18423  
    1010// Created On       : Sat May 16 15:30:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 14 23:45:03 2016
    13 // Update Count     : 3
     12// Last Modified On : Wed Jun 21 15:33:41 2017
     13// Update Count     : 5
    1414//
    1515
     
    2626        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    2727        comparison->get_args().push_back( orig );
    28         comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) ) );
     28        comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0", (unsigned long long int)0 ) ) );
    2929        return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    3030}
  • src/SymTab/Autogen.h

    r405c592 r1a18423  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:10:41 2017
    13 // Update Count     : 9
     12// Last Modified On : Wed Jun 21 17:25:26 2017
     13// Update Count     : 14
    1414//
    1515
     
    2525
    2626namespace SymTab {
    27         /// Generates assignment operators, constructors, and destructor for aggregate types as required
    28         void autogenerateRoutines( std::list< Declaration * > &translationUnit );
     27    /// Generates assignment operators, constructors, and destructor for aggregate types as required
     28    void autogenerateRoutines( std::list< Declaration * > &translationUnit );
    2929
    30         /// returns true if obj's name is the empty string and it has a bitfield width
    31         bool isUnnamedBitfield( ObjectDecl * obj );
     30    /// returns true if obj's name is the empty string and it has a bitfield width
     31    bool isUnnamedBitfield( ObjectDecl * obj );
    3232
    33         /// size_t type - set when size_t typedef is seen. Useful in a few places,
    34         /// such as in determining array dimension type
    35         extern Type * SizeType;
     33    /// size_t type - set when size_t typedef is seen. Useful in a few places,
     34    /// such as in determining array dimension type
     35    extern Type * SizeType;
    3636
    37         /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    38         template< typename OutputIterator >
     37    /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
     38    template< typename OutputIterator >
    3939        Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true );
    4040
    41         /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
    42         /// optionally returns a statement which must be inserted prior to the containing loop, if there is one
    43         template< typename OutputIterator >
     41    /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
     42    /// optionally returns a statement which must be inserted prior to the containing loop, if there is one
     43    template< typename OutputIterator >
    4444        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) {
    45                 // want to be able to generate assignment, ctor, and dtor generically,
    46                 // so fname is either ?=?, ?{}, or ^?{}
    47                 UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
     45        // want to be able to generate assignment, ctor, and dtor generically,
     46        // so fname is either ?=?, ?{}, or ^?{}
     47        UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
    4848
    49                 // do something special for unnamed members
    50                 dstParam = new AddressExpr( dstParam );
    51                 if ( addCast ) {
    52                         // cast to T* with qualifiers removed, so that qualified objects can be constructed
    53                         // and destructed with the same functions as non-qualified objects.
    54                         // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
    55                         // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
    56                         // remove lvalue as a qualifier, this can change to
    57                         //   type->get_qualifiers() = Type::Qualifiers();
    58                         assert( type );
    59                         Type * castType = type->clone();
     49        // do something special for unnamed members
     50        dstParam = new AddressExpr( dstParam );
     51        if ( addCast ) {
     52            // cast to T* with qualifiers removed, so that qualified objects can be constructed
     53            // and destructed with the same functions as non-qualified objects.
     54            // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
     55            // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
     56            // remove lvalue as a qualifier, this can change to
     57            //   type->get_qualifiers() = Type::Qualifiers();
     58            assert( type );
     59            Type * castType = type->clone();
    6060//                      castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
    61                         castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    62                         castType->set_lvalue( true ); // xxx - might not need this
    63                         dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
    64                 }
    65                 fExpr->get_args().push_back( dstParam );
     61            castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
     62            castType->set_lvalue( true ); // xxx - might not need this
     63            dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
     64        }
     65        fExpr->get_args().push_back( dstParam );
    6666
    67                 Statement * listInit = srcParam.buildListInit( fExpr );
     67        Statement * listInit = srcParam.buildListInit( fExpr );
    6868
    69                 std::list< Expression * > args = *++srcParam;
    70                 fExpr->get_args().splice( fExpr->get_args().end(), args );
     69        std::list< Expression * > args = *++srcParam;
     70        fExpr->get_args().splice( fExpr->get_args().end(), args );
    7171
    72                 *out++ = new ExprStmt( noLabels, fExpr );
     72        *out++ = new ExprStmt( noLabels, fExpr );
    7373
    74                 srcParam.clearArrayIndices();
     74        srcParam.clearArrayIndices();
    7575
    76                 return listInit;
     76        return listInit;
     77    }
     78
     79    /// Store in out a loop which calls fname on each element of the array with srcParam and dstParam as arguments.
     80    /// If forward is true, loop goes from 0 to N-1, else N-1 to 0
     81    template< typename OutputIterator >
     82        void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
     83        static UniqueName indexName( "_index" );
     84
     85        // for a flexible array member nothing is done -- user must define own assignment
     86        if ( ! array->get_dimension() ) return ;
     87
     88        Expression * begin, * end, * update, * cmp;
     89        if ( forward ) {
     90            // generate: for ( int i = 0; i < N; ++i )
     91            begin = new ConstantExpr( Constant::from_int( 0 ) );
     92            end = array->get_dimension()->clone();
     93            cmp = new NameExpr( "?<?" );
     94            update = new NameExpr( "++?" );
     95        } else {
     96            // generate: for ( int i = N-1; i >= 0; --i )
     97            begin = new UntypedExpr( new NameExpr( "?-?" ) );
     98            ((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() );
     99            ((UntypedExpr*)begin)->get_args().push_back( new ConstantExpr( Constant::from_int( 1 ) ) );
     100            end = new ConstantExpr( Constant::from_int( 0 ) );
     101            cmp = new NameExpr( "?>=?" );
     102            update = new NameExpr( "--?" );
    77103        }
    78104
    79         /// Store in out a loop which calls fname on each element of the array with srcParam and dstParam as arguments.
    80         /// If forward is true, loop goes from 0 to N-1, else N-1 to 0
    81         template< typename OutputIterator >
    82         void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
    83                 static UniqueName indexName( "_index" );
     105        ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
    84106
    85                 // for a flexible array member nothing is done -- user must define own assignment
    86                 if ( ! array->get_dimension() ) return ;
     107        UntypedExpr *cond = new UntypedExpr( cmp );
     108        cond->get_args().push_back( new VariableExpr( index ) );
     109        cond->get_args().push_back( end );
    87110
    88                 Expression * begin, * end, * update, * cmp;
    89                 if ( forward ) {
    90                         // generate: for ( int i = 0; i < 0; ++i )
    91                         begin = new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) );
    92                         end = array->get_dimension()->clone();
    93                         cmp = new NameExpr( "?<?" );
    94                         update = new NameExpr( "++?" );
    95                 } else {
    96                         // generate: for ( int i = N-1; i >= 0; --i )
    97                         begin = new UntypedExpr( new NameExpr( "?-?" ) );
    98                         ((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() );
    99                         ((UntypedExpr*)begin)->get_args().push_back( new ConstantExpr( Constant( new OneType( emptyQualifiers ), "1" ) ) );
    100                         end = new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0" ) );
    101                         cmp = new NameExpr( "?>=?" );
    102                         update = new NameExpr( "--?" );
    103                 }
     111        UntypedExpr *inc = new UntypedExpr( update );
     112        inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
    104113
    105                 ObjectDecl *index = new ObjectDecl( indexName.newName(), Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
     114        UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
     115        dstIndex->get_args().push_back( dstParam );
     116        dstIndex->get_args().push_back( new VariableExpr( index ) );
     117        dstParam = dstIndex;
    106118
    107                 UntypedExpr *cond = new UntypedExpr( cmp );
    108                 cond->get_args().push_back( new VariableExpr( index ) );
    109                 cond->get_args().push_back( end );
     119        // srcParam must keep track of the array indices to build the
     120        // source parameter and/or array list initializer
     121        srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() );
    110122
    111                 UntypedExpr *inc = new UntypedExpr( update );
    112                 inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
     123        // for stmt's body, eventually containing call
     124        CompoundStmt * body = new CompoundStmt( noLabels );
     125        Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward );
    113126
    114                 UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
    115                 dstIndex->get_args().push_back( dstParam );
    116                 dstIndex->get_args().push_back( new VariableExpr( index ) );
    117                 dstParam = dstIndex;
     127        // block containing for stmt and index variable
     128        std::list<Statement *> initList;
     129        CompoundStmt * block = new CompoundStmt( noLabels );
     130        block->get_kids().push_back( new DeclStmt( noLabels, index ) );
     131        if ( listInit ) block->get_kids().push_back( listInit );
     132        block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, body ) );
    118133
    119                 // srcParam must keep track of the array indices to build the
    120                 // source parameter and/or array list initializer
    121                 srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() );
     134        *out++ = block;
     135    }
    122136
    123                 // for stmt's body, eventually containing call
    124                 CompoundStmt * body = new CompoundStmt( noLabels );
    125                 Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward );
     137    template< typename OutputIterator >
     138        Statement * genCall( InitTweak::InitExpander &  srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) {
     139        if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
     140            genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
     141            return 0;
     142        } else {
     143            return genScalarCall( srcParam, dstParam, fname, out, type, addCast );
     144        }
     145    }
    126146
    127                 // block containing for stmt and index variable
    128                 std::list<Statement *> initList;
    129                 CompoundStmt * block = new CompoundStmt( noLabels );
    130                 block->get_kids().push_back( new DeclStmt( noLabels, index ) );
    131                 if ( listInit ) block->get_kids().push_back( listInit );
    132                 block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, body ) );
     147    /// inserts into out a generated call expression to function fname with arguments dstParam
     148    /// and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. decl is the
     149    /// object being constructed. The function wraps constructor and destructor calls in an
     150    /// ImplicitCtorDtorStmt node.
     151    template< typename OutputIterator >
     152        void genImplicitCall( InitTweak::InitExpander &  srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, DeclarationWithType * decl, bool forward = true ) {
     153        ObjectDecl *obj = dynamic_cast<ObjectDecl *>( decl );
     154        assert( obj );
     155        // unnamed bit fields are not copied as they cannot be accessed
     156        if ( isUnnamedBitfield( obj ) ) return;
    133157
    134                 *out++ = block;
     158        bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) );
     159        std::list< Statement * > stmts;
     160        genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->get_type(), addCast, forward );
     161
     162        // currently genCall should produce at most one element, but if that changes then the next line needs to be updated to grab the statement which contains the call
     163        assert( stmts.size() <= 1 );
     164        if ( stmts.size() == 1 ) {
     165            Statement * callStmt = stmts.front();
     166            if ( addCast ) {
     167                // implicitly generated ctor/dtor calls should be wrapped
     168                // so that later passes are aware they were generated.
     169                // xxx - don't mark as an implicit ctor/dtor if obj is a bitfield,
     170                // because this causes the address to be taken at codegen, which is illegal in C.
     171                callStmt = new ImplicitCtorDtorStmt( callStmt );
     172            }
     173            *out++ = callStmt;
    135174        }
    136 
    137         template< typename OutputIterator >
    138         Statement * genCall( InitTweak::InitExpander &  srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) {
    139                 if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
    140                         genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
    141                         return 0;
    142                 } else {
    143                         return genScalarCall( srcParam, dstParam, fname, out, type, addCast );
    144                 }
    145         }
    146 
    147         /// inserts into out a generated call expression to function fname with arguments dstParam
    148         /// and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. decl is the
    149         /// object being constructed. The function wraps constructor and destructor calls in an
    150         /// ImplicitCtorDtorStmt node.
    151         template< typename OutputIterator >
    152         void genImplicitCall( InitTweak::InitExpander &  srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, DeclarationWithType * decl, bool forward = true ) {
    153                 ObjectDecl *obj = dynamic_cast<ObjectDecl *>( decl );
    154                 assert( obj );
    155                 // unnamed bit fields are not copied as they cannot be accessed
    156                 if ( isUnnamedBitfield( obj ) ) return;
    157 
    158                 bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) );
    159                 std::list< Statement * > stmts;
    160                 genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->get_type(), addCast, forward );
    161 
    162                 // currently genCall should produce at most one element, but if that changes then the next line needs to be updated to grab the statement which contains the call
    163                 assert( stmts.size() <= 1 );
    164                 if ( stmts.size() == 1 ) {
    165                         Statement * callStmt = stmts.front();
    166                         if ( addCast ) {
    167                                 // implicitly generated ctor/dtor calls should be wrapped
    168                                 // so that later passes are aware they were generated.
    169                                 // xxx - don't mark as an implicit ctor/dtor if obj is a bitfield,
    170                                 // because this causes the address to be taken at codegen, which is illegal in C.
    171                                 callStmt = new ImplicitCtorDtorStmt( callStmt );
    172                         }
    173                         *out++ = callStmt;
    174                 }
    175         }
     175    }
    176176} // namespace SymTab
    177177#endif // AUTOGEN_H
  • src/SymTab/Indexer.cc

    r405c592 r1a18423  
    493493                acceptNewScope( compLitExpr->get_result(), *this );
    494494                maybeAccept( compLitExpr->get_initializer(), *this );
    495         }
    496 
    497         void Indexer::visit( UntypedValofExpr *valofExpr ) {
    498                 acceptNewScope( valofExpr->get_result(), *this );
    499                 maybeAccept( valofExpr->get_body(), *this );
    500495        }
    501496
  • src/SymTab/Indexer.h

    r405c592 r1a18423  
    6969                virtual void visit( ConstructorExpr * ctorExpr );
    7070                virtual void visit( CompoundLiteralExpr *compLitExpr );
    71                 virtual void visit( UntypedValofExpr *valofExpr );
    7271                virtual void visit( RangeExpr *rangeExpr );
    7372                virtual void visit( UntypedTupleExpr *tupleExpr );
  • src/SymTab/Validate.cc

    r405c592 r1a18423  
    115115
    116116        /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers.
    117         class EnumAndPointerDecayPass final : public Visitor {
    118                 typedef Visitor Parent;
    119                 virtual void visit( EnumDecl *aggregateDecl );
    120                 virtual void visit( FunctionType *func );
     117        class EnumAndPointerDecay {
     118        public:
     119                void previsit( EnumDecl *aggregateDecl );
     120                void previsit( FunctionType *func );
    121121        };
    122122
     
    126126          public:
    127127                LinkReferenceToTypes( bool doDebug, const Indexer *indexer );
    128           private:
    129128                using Parent::visit;
    130129                void visit( EnumInstType *enumInst ) final;
     
    136135                void visit( UnionDecl *unionDecl ) final;
    137136                void visit( TypeInstType *typeInst ) final;
    138 
     137          private:
    139138                const Indexer *indexer;
    140139
     
    147146        };
    148147
    149         /// Replaces array and function types in forall lists by appropriate pointer type
    150         class Pass3 final : public Indexer {
     148        /// Replaces array and function types in forall lists by appropriate pointer type and assigns each Object and Function declaration a unique ID.
     149        class ForallPointerDecay final : public Indexer {
    151150                typedef Indexer Parent;
    152151          public:
    153152                using Parent::visit;
    154                 Pass3( const Indexer *indexer );
    155           private:
     153                ForallPointerDecay( const Indexer *indexer );
     154
    156155                virtual void visit( ObjectDecl *object ) override;
    157156                virtual void visit( FunctionDecl *func ) override;
     
    160159        };
    161160
    162         class ReturnChecker {
     161        class ReturnChecker : public WithScopes {
    163162          public:
    164163                /// Checks that return statements return nothing if their return type is void
     
    167166          private:
    168167                void previsit( FunctionDecl * functionDecl );
    169                 void postvisit( FunctionDecl * functionDecl );
    170168                void previsit( ReturnStmt * returnStmt );
    171169
    172170                typedef std::list< DeclarationWithType * > ReturnVals;
    173171                ReturnVals returnVals;
    174                 std::stack< ReturnVals > returnValsStack;
    175172        };
    176173
     
    248245
    249246        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
    250                 EnumAndPointerDecayPass epc;
     247                PassVisitor<EnumAndPointerDecay> epc;
    251248                LinkReferenceToTypes lrt( doDebug, 0 );
    252                 Pass3 pass3( 0 );
     249                ForallPointerDecay fpd( 0 );
    253250                CompoundLiteral compoundliteral;
    254251                PassVisitor<ValidateGenericParameters> genericParams;
     
    262259                VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
    263260                Concurrency::applyKeywords( translationUnit );
    264                 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecayPass
     261                autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay
    265262                Concurrency::implementMutexFuncs( translationUnit );
    266263                Concurrency::implementThreadStarter( translationUnit );
    267264                ReturnChecker::checkFunctionReturns( translationUnit );
    268265                compoundliteral.mutateDeclarationList( translationUnit );
    269                 acceptAll( translationUnit, pass3 );
     266                acceptAll( translationUnit, fpd );
    270267                ArrayLength::computeLength( translationUnit );
    271268        }
    272269
    273270        void validateType( Type *type, const Indexer *indexer ) {
    274                 EnumAndPointerDecayPass epc;
     271                PassVisitor<EnumAndPointerDecay> epc;
    275272                LinkReferenceToTypes lrt( false, indexer );
    276                 Pass3 pass3( indexer );
     273                ForallPointerDecay fpd( indexer );
    277274                type->accept( epc );
    278275                type->accept( lrt );
    279                 type->accept( pass3 );
     276                type->accept( fpd );
    280277        }
    281278
     
    356353        }
    357354
    358         void EnumAndPointerDecayPass::visit( EnumDecl *enumDecl ) {
     355        void EnumAndPointerDecay::previsit( EnumDecl *enumDecl ) {
    359356                // Set the type of each member of the enumeration to be EnumConstant
    360357                for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) {
     
    363360                        obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->get_name() ) );
    364361                } // for
    365                 Parent::visit( enumDecl );
    366362        }
    367363
     
    370366                void fixFunctionList( DWTList & dwts, FunctionType * func ) {
    371367                        // the only case in which "void" is valid is where it is the only one in the list; then it should be removed
    372                         // entirely other fix ups are handled by the FixFunction class
     368                        // entirely. other fix ups are handled by the FixFunction class
    373369                        typedef typename DWTList::iterator DWTIterator;
    374370                        DWTIterator begin( dwts.begin() ), end( dwts.end() );
     
    389385                                for ( ; i != end; ++i ) {
    390386                                        FixFunction fixer;
    391                                         *i = (*i )->acceptMutator( fixer );
     387                                        *i = (*i)->acceptMutator( fixer );
    392388                                        if ( fixer.get_isVoid() ) {
    393389                                                throw SemanticError( "invalid type void in function type ", func );
     
    398394        }
    399395
    400         void EnumAndPointerDecayPass::visit( FunctionType *func ) {
     396        void EnumAndPointerDecay::previsit( FunctionType *func ) {
    401397                // Fix up parameters and return types
    402398                fixFunctionList( func->get_parameters(), func );
    403399                fixFunctionList( func->get_returnVals(), func );
    404                 Visitor::visit( func );
    405400        }
    406401
     
    549544        }
    550545
    551         Pass3::Pass3( const Indexer *other_indexer ) :  Indexer( false ) {
     546        ForallPointerDecay::ForallPointerDecay( const Indexer *other_indexer ) :  Indexer( false ) {
    552547                if ( other_indexer ) {
    553548                        indexer = other_indexer;
     
    587582        }
    588583
    589         void Pass3::visit( ObjectDecl *object ) {
     584        void ForallPointerDecay::visit( ObjectDecl *object ) {
    590585                forallFixer( object->get_type() );
    591586                if ( PointerType *pointer = dynamic_cast< PointerType * >( object->get_type() ) ) {
     
    596591        }
    597592
    598         void Pass3::visit( FunctionDecl *func ) {
     593        void ForallPointerDecay::visit( FunctionDecl *func ) {
    599594                forallFixer( func->get_type() );
    600595                Parent::visit( func );
     
    608603
    609604        void ReturnChecker::previsit( FunctionDecl * functionDecl ) {
    610                 returnValsStack.push( returnVals );
     605                GuardValue( returnVals );
    611606                returnVals = functionDecl->get_functionType()->get_returnVals();
    612         }
    613         void ReturnChecker::postvisit( __attribute__((unused)) FunctionDecl * functionDecl ) {
    614                 returnVals = returnValsStack.top();
    615                 returnValsStack.pop();
    616607        }
    617608
  • src/SynTree/BaseSyntaxNode.h

    r405c592 r1a18423  
    2424        CodeLocation location;
    2525
    26         virtual void accept( Visitor & v ) = 0; // temporary -- needs to be here so that BaseSyntaxNode is polymorphic and can be dynamic_cast
     26        virtual ~BaseSyntaxNode() {}
     27
     28        virtual void accept( Visitor & v ) = 0;
    2729};
    2830
  • src/SynTree/Constant.cc

    r405c592 r1a18423  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 30 15:18:38 2015
    13 // Update Count     : 12
     12// Last Modified On : Wed Jun 21 16:44:48 2017
     13// Update Count     : 27
    1414//
    1515
     
    2121#include "Type.h"
    2222
    23 Constant::Constant( Type *type_, std::string value_ ) : type( type_ ), value( value_ ) {}
     23Constant::Constant( Type * type, std::string rep, unsigned long long val ) : type( type ), rep( rep ), val( val ) {}
     24Constant::Constant( Type * type, std::string rep, double val ) : type( type ), rep( rep ), val( val ) {}
    2425
    25 Constant::Constant( const Constant &other ) {
     26Constant::Constant( const Constant &other ) : rep( other.rep ), val( other.val ) {
    2627        type = other.type->clone();
    27         value = other.value;
    2828}
    2929
     
    3131
    3232Constant Constant::from_int( int i ) {
    33         return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ) );
     33        return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ), (unsigned long long int)i );
    3434}
    3535
    3636Constant Constant::from_ulong( unsigned long i ) {
    37         return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ) );
     37        return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ), (unsigned long long int)i );
    3838}
    3939
    4040Constant Constant::from_double( double d ) {
    41         return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ) );
     41        return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ), d );
    4242}
    4343
    44 Constant *Constant::clone() const { assert( false ); return 0; }
    45 
    4644void Constant::print( std::ostream &os ) const {
    47         os << "(" << value;
     45        os << "(" << rep << " " << val.ival;
    4846        if ( type ) {
    4947                os << ": ";
  • src/SynTree/Constant.h

    r405c592 r1a18423  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 30 13:33:17 2016
    13 // Update Count     : 6
     12// Last Modified On : Wed Jun 21 16:44:48 2017
     13// Update Count     : 14
    1414//
    1515
     
    2323class Constant {
    2424  public:
    25         Constant( Type *type, std::string value );
    26         Constant( const Constant &other );
     25        Constant( Type * type, std::string rep, unsigned long long val );
     26        Constant( Type * type, std::string rep, double val );
     27        Constant( const Constant & other );
    2728        virtual ~Constant();
    2829
    29         Type *get_type() { return type; }
    30         void set_type( Type *newValue ) { type = newValue; }
    31         std::string &get_value() { return value; }
    32         void set_value( std::string newValue ) { value = newValue; }
     30        Type * get_type() { return type; }
     31        void set_type( Type * newValue ) { type = newValue; }
     32        std::string & get_value() { return rep; }
     33        void set_value( std::string newValue ) { rep = newValue; }
    3334
    3435        /// generates an integer constant of the given int
     
    3940        static Constant from_double( double d );
    4041
    41         virtual Constant *clone() const;
    42         virtual void accept( Visitor &v ) { v.visit( this ); }
    43         virtual Constant *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    44         virtual void print( std::ostream &os ) const;
     42        virtual void accept( Visitor & v ) { v.visit( this ); }
     43        virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     44        virtual void print( std::ostream & os ) const;
    4545  private:
    46         Type *type;
    47         std::string value;
     46        Type * type;
     47        std::string rep;
     48        union Val {
     49                unsigned long long ival;
     50                double dval;
     51                Val( unsigned long long ival ) : ival( ival ) {}
     52                Val( double dval ) : dval( dval ) {}
     53        } val;
    4854};
    4955
  • src/SynTree/Expression.cc

    r405c592 r1a18423  
    288288}
    289289
    290 // CastExpr *CastExpr::clone() const { return 0; }
    291 
    292290void CastExpr::print( std::ostream &os, int indent ) const {
    293291        os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
     
    355353}
    356354
    357 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...
    358355MemberExpr::MemberExpr( const MemberExpr &other ) :
    359356                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     
    361358
    362359MemberExpr::~MemberExpr() {
    363         // delete member;
     360        // don't delete the member declaration, since it points somewhere else in the tree
    364361        delete aggregate;
    365362}
     
    591588}
    592589
    593 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    594 
    595 UntypedValofExpr::~UntypedValofExpr() { delete body; }
    596 
    597 void UntypedValofExpr::print( std::ostream &os, int indent ) const {
    598         os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;
    599         if ( get_body() != 0 )
    600                 get_body()->print( os, indent + 2 );
    601 }
    602 
    603590RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    604591RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
  • src/SynTree/Expression.h

    r405c592 r1a18423  
    226226};
    227227
    228 /// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer
     228/// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer.
     229/// Does not take ownership of member.
    229230class MemberExpr : public Expression {
    230231  public:
     
    247248};
    248249
    249 /// VariableExpr represents an expression that simply refers to the value of a named variable
     250/// VariableExpr represents an expression that simply refers to the value of a named variable.
     251/// Does not take ownership of var.
    250252class VariableExpr : public Expression {
    251253  public:
     
    598600};
    599601
    600 /// ValofExpr represents a GCC 'lambda expression'
    601 class UntypedValofExpr : public Expression {
    602   public:
    603         UntypedValofExpr( Statement *_body, Expression *_aname = nullptr ) : Expression( _aname ), body ( _body ) {}
    604         UntypedValofExpr( const UntypedValofExpr & other );
    605         virtual ~UntypedValofExpr();
    606 
    607         Expression * get_value();
    608         Statement * get_body() const { return body; }
    609 
    610         virtual UntypedValofExpr * clone() const { return new UntypedValofExpr( * this ); }
    611         virtual void accept( Visitor & v ) { v.visit( this ); }
    612         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    613         virtual void print( std::ostream & os, int indent = 0 ) const;
    614   private:
    615         Statement * body;
    616 };
    617 
    618602/// RangeExpr represents a range e.g. '3 ... 5' or '1~10'
    619603class RangeExpr : public Expression {
  • src/SynTree/Mutator.cc

    r405c592 r1a18423  
    380380}
    381381
    382 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
    383         valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) );
    384         valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) );
    385         return valofExpr;
    386 }
    387 
    388382Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
    389383        rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
  • src/SynTree/Mutator.h

    r405c592 r1a18423  
    7878        virtual Expression* mutate( ConstructorExpr *ctorExpr );
    7979        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    80         virtual Expression* mutate( UntypedValofExpr *valofExpr );
    8180        virtual Expression* mutate( RangeExpr *rangeExpr );
    8281        virtual Expression* mutate( UntypedTupleExpr *tupleExpr );
  • src/SynTree/ObjectDecl.cc

    r405c592 r1a18423  
    5656
    5757        if ( init ) {
    58                 os << " with initializer ";
    59                 init->print( os, indent );
    60                 os << std::endl << std::string(indent, ' ');
     58                os << " with initializer " << std::endl;
     59                init->print( os, indent+2 );
     60                os << std::endl << std::string(indent+2, ' ');
    6161                os << "maybeConstructed? " << init->get_maybeConstructed();
    6262        } // if
  • src/SynTree/Statement.cc

    r405c592 r1a18423  
    313313}
    314314
    315 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) :
     315TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &_handlers, FinallyStmt *_finallyBlock ) :
    316316        Statement( labels ), block( tryBlock ),  handlers( _handlers ), finallyBlock( _finallyBlock ) {
    317317}
     
    334334        // handlers
    335335        os << string( indent + 2, ' ' ) << "and handlers: " << endl;
    336         for ( std::list<Statement *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
     336        for ( std::list<CatchStmt *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
    337337                (*i )->print( os, indent + 4 );
    338338
  • src/SynTree/Statement.h

    r405c592 r1a18423  
    315315class TryStmt : public Statement {
    316316  public:
    317         TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 );
     317        TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    318318        TryStmt( const TryStmt &other );
    319319        virtual ~TryStmt();
     
    321321        CompoundStmt *get_block() const { return block; }
    322322        void set_block( CompoundStmt *newValue ) { block = newValue; }
    323         std::list<Statement *>& get_catchers() { return handlers; }
     323        std::list<CatchStmt *>& get_catchers() { return handlers; }
    324324
    325325        FinallyStmt *get_finally() const { return finallyBlock; }
     
    333333  private:
    334334        CompoundStmt *block;
    335         std::list<Statement *> handlers;
     335        std::list<CatchStmt *> handlers;
    336336        FinallyStmt *finallyBlock;
    337337};
  • src/SynTree/Visitor.cc

    r405c592 r1a18423  
    301301}
    302302
    303 void Visitor::visit( UntypedValofExpr *valofExpr ) {
    304         maybeAccept( valofExpr->get_result(), *this );
    305         maybeAccept( valofExpr->get_body(), *this );
    306 }
    307 
    308303void Visitor::visit( RangeExpr *rangeExpr ) {
    309304        maybeAccept( rangeExpr->get_low(), *this );
  • src/SynTree/Visitor.h

    r405c592 r1a18423  
    8181        virtual void visit( ConstructorExpr * ctorExpr );
    8282        virtual void visit( CompoundLiteralExpr *compLitExpr );
    83         virtual void visit( UntypedValofExpr *valofExpr );
    8483        virtual void visit( RangeExpr *rangeExpr );
    8584        virtual void visit( UntypedTupleExpr *tupleExpr );
     
    163162                        } // if
    164163                } catch( SemanticError &e ) {
    165                         e.set_location( (*i)->location );                       
     164                        e.set_location( (*i)->location );
    166165                        errors.append( e );
    167166                } // try
  • src/Tuples/TupleExpansion.cc

    r405c592 r1a18423  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:05:17 2017
    13 // Update Count     : 15
     12// Last Modified On : Wed Jun 21 17:35:04 2017
     13// Update Count     : 19
    1414//
    1515
     
    191191                                commaExpr->set_arg1( nullptr );
    192192                        }
    193                         BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
    194                         ObjectDecl * finished = new ObjectDecl( toString( "_unq", id, "_finished_" ), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ), new SingleInit( new ConstantExpr( Constant( boolType->clone(), "0" ) ), noDesignators ) );
     193                        ObjectDecl * finished = new ObjectDecl( toString( "_unq", id, "_finished_" ), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::Bool ),
     194                                                                                                        new SingleInit( new ConstantExpr( Constant::from_int( 0 ) ), noDesignators ) );
    195195                        addDeclaration( finished );
    196196                        // (finished ? _unq_expr_N : (_unq_expr_N = <unqExpr->get_expr()>, finished = 1, _unq_expr_N))
    197197                        // This pattern ensures that each unique expression is evaluated once, regardless of evaluation order of the generated C code.
    198                         Expression * assignFinished = UntypedExpr::createAssign( new VariableExpr(finished), new ConstantExpr( Constant( boolType->clone(), "1" ) ) );
     198                        Expression * assignFinished = UntypedExpr::createAssign( new VariableExpr(finished), new ConstantExpr( Constant::from_int( 1 ) ) );
    199199                        ConditionalExpr * condExpr = new ConditionalExpr( new VariableExpr( finished ), var->clone(),
    200200                                new CommaExpr( new CommaExpr( assignUnq, assignFinished ), var->clone() ) );
Note: See TracChangeset for help on using the changeset viewer.