Changeset 7821d6c for src


Ignore:
Timestamp:
Oct 3, 2017, 2:55:17 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
680620d
Parents:
21b7161 (diff), e1ff775 (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:/u/cforall/software/cfa/cfa-cc

Location:
src
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    r21b7161 r7821d6c  
    44
    55#include <stack>
     6
     7#include "Common/utility.h"
    68
    79#include "SynTree/Mutator.h"
     
    239241        template<typename pass_t> friend void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );
    240242        template<typename pass_t> friend void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );
     243        template< typename TreeType, typename pass_t > friend void maybeAccept_impl( TreeType * tree, PassVisitor< pass_t > & visitor );
     244        template< typename TreeType, typename pass_t > friend void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_t > & mutator );
     245        template< typename Container, typename pass_t > friend void maybeAccept_impl( Container & container, PassVisitor< pass_t > & visitor );
     246        template< typename Container, typename pass_t > friend void maybeMutate_impl( Container & container, PassVisitor< pass_t > & mutator );
    241247
    242248        template<typename node_type> void call_previsit ( node_type * node ) { previsit_impl ( pass, node, 0 ); }
     
    273279        std::list< Declaration* > *     get_afterDecls () { return declsToAddAfter_impl ( pass, 0); }
    274280
    275         void set_visit_children( bool& ref ) { bool_ref * ptr = visit_children_impl(pass, 0); if(ptr) ptr->set( ref ); }
     281        bool       get_visit_children    () { bool_ref * ptr = visit_children_impl(pass, 0); return ptr ? *ptr : true; }
     282        bool_ref * get_visit_children_ptr() { return visit_children_impl(pass, 0); }
    276283
    277284        void indexerScopeEnter  ()                             { indexer_impl_enterScope  ( pass, 0       ); }
  • src/Common/PassVisitor.impl.h

    r21b7161 r7821d6c  
    22// IWYU pragma: private, include "PassVisitor.h"
    33
    4 #define VISIT_START( node )                     \
    5         __attribute__((unused))                   \
     4#define VISIT_START( node )                                     \
     5        __attribute__((unused))                                   \
     6        ChildrenGuard children_guard( get_visit_children_ptr() ); \
     7        __attribute__((unused))                                   \
    68        guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
    7         bool visit_children = true;               \
    8         set_visit_children( visit_children );   \
    9         call_previsit( node );                    \
    10         if( visit_children ) {                    \
     9        call_previsit( node );                                    \
    1110
    1211#define VISIT_END( node )                       \
    13         }                                         \
    1412        call_postvisit( node );                   \
    1513
    16 #define MUTATE_START( node )                    \
    17         __attribute__((unused))                   \
     14#define MUTATE_START( node )                                    \
     15        __attribute__((unused))                                   \
     16        ChildrenGuard children_guard( get_visit_children_ptr() ); \
     17        __attribute__((unused))                                   \
    1818        guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
    19         bool visit_children = true;               \
    20         set_visit_children( visit_children );   \
    21         call_premutate( node );                   \
    22         if( visit_children ) {                    \
     19        call_premutate( node );                                   \
    2320
    2421#define MUTATE_END( type, node )                \
    25         }                                         \
    2622        return call_postmutate< type * >( node ); \
    2723
    2824
    29 #define VISIT_BODY( node )        \
    30         VISIT_START( node );        \
    31         Visitor::visit( node );     \
    32         VISIT_END( node );          \
    33 
    34 
    35 #define MUTATE_BODY( type, node ) \
    36         MUTATE_START( node );       \
    37         Mutator::mutate( node );    \
    38         MUTATE_END( type, node );   \
     25#define VISIT_BODY( node )          \
     26        VISIT_START( node );          \
     27        if( children_guard ) {        \
     28                Visitor::visit( node ); \
     29        }                             \
     30        VISIT_END( node );            \
     31
     32
     33#define MUTATE_BODY( type, node )    \
     34        MUTATE_START( node );          \
     35        if( children_guard ) {         \
     36                Mutator::mutate( node ); \
     37        }                              \
     38        MUTATE_END( type, node );      \
    3939
    4040
     
    6363template< typename pass_type >
    6464static inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
    65 
    6665        DeclList_t* beforeDecls = visitor.get_beforeDecls();
    6766        DeclList_t* afterDecls  = visitor.get_afterDecls();
     
    7675                try {
    7776                        // run visitor on declaration
    78                         maybeAccept( *i, visitor );
     77                        maybeAccept_impl( *i, visitor );
    7978                } catch( SemanticError &e ) {
    8079                        e.set_location( (*i)->location );
     
    9291template< typename pass_type >
    9392static inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
    94 
    9593        DeclList_t* beforeDecls = mutator.get_beforeDecls();
    9694        DeclList_t* afterDecls  = mutator.get_afterDecls();
     
    104102                try {
    105103                        // run mutator on declaration
    106                         *i = maybeMutate( *i, mutator );
     104                        maybeMutate_impl( *i, mutator );
    107105                } catch( SemanticError &e ) {
    108106                        e.set_location( (*i)->location );
     
    118116}
    119117
    120 template< typename Container, typename VisitorType >
    121 inline void maybeAccept( Container &container, VisitorType &visitor ) {
     118template< typename TreeType, typename pass_type >
     119inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
     120        if ( ! visitor.get_visit_children() ) return;
     121        if ( tree ) {
     122                tree->accept( visitor );
     123        }
     124}
     125
     126template< typename Container, typename pass_type >
     127inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
     128        if ( ! visitor.get_visit_children() ) return;
    122129        SemanticError errors;
    123130        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
     
    136143}
    137144
    138 template< typename Container, typename MutatorType >
    139 inline void maybeMutateRef( Container &container, MutatorType &mutator ) {
     145template< typename TreeType, typename pass_type >
     146inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
     147        if ( ! mutator.get_visit_children() ) return;
     148
     149        if ( tree ) {
     150                tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
     151        }
     152}
     153
     154template< typename Container, typename pass_type >
     155inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
     156        if ( ! mutator.get_visit_children() ) return;
    140157        SemanticError errors;
    141158        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    142159                try {
    143160                        if ( *i ) {
    144 ///                 *i = (*i)->acceptMutator( mutator );
    145161                                *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
    146162                                assert( *i );
     
    159175template< typename func_t >
    160176void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
     177        if ( ! get_visit_children() ) return;
    161178        SemanticError errors;
    162179
     
    199216void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
    200217        handleStatementList( statements, [this]( Statement * stmt) {
    201                 stmt->accept( *this );
     218                maybeAccept_impl( stmt, *this );
    202219        });
    203220}
     
    206223void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
    207224        handleStatementList( statements, [this]( Statement *& stmt) {
    208                 stmt = stmt->acceptMutator( *this );
     225                maybeMutate_impl( stmt, *this );
    209226        });
    210227}
     
    214231template< typename func_t >
    215232Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
     233        if ( ! get_visit_children() ) return stmt;
     234
    216235        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
    217236        ValueGuardPtr< TypeSubstitution * >  oldEnv        ( get_env_ptr    () );
     
    244263Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
    245264        return handleStatement( stmt, [this]( Statement * stmt ) {
    246                 maybeAccept( stmt, *this );
     265                maybeAccept_impl( stmt, *this );
    247266                return stmt;
    248267        });
     
    252271Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
    253272        return handleStatement( stmt, [this]( Statement * stmt ) {
    254                 return maybeMutate( stmt, *this );
     273                maybeMutate_impl( stmt, *this );
     274                return stmt;
    255275        });
    256276}
     
    259279template< typename func_t >
    260280Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
     281        if ( ! get_visit_children() ) return expr;
    261282        if( !expr ) return nullptr;
    262283
     
    266287        }
    267288
    268         // should env be cloned (or moved) onto the result of the mutate?
     289        // should env be moved onto the result of the mutate?
    269290        return func( expr );
    270291}
     
    273294Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
    274295        return handleExpression(expr, [this]( Expression * expr ) {
    275                 expr->accept( *this );
     296                maybeAccept_impl( expr, *this );
    276297                return expr;
    277298        });
     
    281302Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
    282303        return handleExpression(expr, [this]( Expression * expr ) {
    283                 return expr->acceptMutator( *this );
     304                maybeMutate_impl( expr, *this );
     305                return expr;
    284306        });
     307}
     308
     309template< typename TreeType, typename VisitorType >
     310inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
     311        if ( ! visitor.get_visit_children() ) return;
     312        auto guard = makeFuncGuard(
     313                [&visitor]() { visitor.indexerScopeEnter(); },
     314                [&visitor]() { visitor.indexerScopeLeave(); }
     315        );
     316        maybeAccept_impl( tree, visitor );
     317}
     318
     319template< typename TreeType, typename MutatorType >
     320inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
     321        if ( ! mutator.get_visit_children() ) return;
     322        auto guard = makeFuncGuard(
     323                [&mutator]() { mutator.indexerScopeEnter(); },
     324                [&mutator]() { mutator.indexerScopeLeave(); }
     325        );
     326        maybeMutate_impl( tree, mutator );
    285327}
    286328
     
    319361
    320362        indexerScopedAccept( node->type         , *this );
    321         maybeAccept        ( node->init         , *this );
    322         maybeAccept        ( node->bitfieldWidth, *this );
    323         maybeAccept        ( node->attributes   , *this );
     363        maybeAccept_impl   ( node->init         , *this );
     364        maybeAccept_impl   ( node->bitfieldWidth, *this );
     365        maybeAccept_impl   ( node->attributes   , *this );
    324366
    325367        if ( node->name != "" ) {
     
    335377
    336378        indexerScopedMutate( node->type         , *this );
    337         maybeMutateRef     ( node->init         , *this );
    338         maybeMutateRef     ( node->bitfieldWidth, *this );
    339         maybeMutateRef     ( node->attributes   , *this );
     379        maybeMutate_impl   ( node->init         , *this );
     380        maybeMutate_impl   ( node->bitfieldWidth, *this );
     381        maybeMutate_impl   ( node->attributes   , *this );
    340382
    341383        if ( node->name != "" ) {
     
    358400        {
    359401                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    360                 maybeAccept( node->type, *this );
    361                 maybeAccept( node->statements, *this );
    362                 maybeAccept( node->attributes, *this );
     402                maybeAccept_impl( node->type, *this );
     403                maybeAccept_impl( node->statements, *this );
     404                maybeAccept_impl( node->attributes, *this );
    363405        }
    364406
     
    376418        {
    377419                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    378                 maybeMutateRef( node->type, *this );
    379                 maybeMutateRef( node->statements, *this );
    380                 maybeMutateRef( node->attributes, *this );
     420                maybeMutate_impl( node->type, *this );
     421                maybeMutate_impl( node->statements, *this );
     422                maybeMutate_impl( node->attributes, *this );
    381423        }
    382424
     
    396438        {
    397439                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    398                 maybeAccept( node->parameters, *this );
    399                 maybeAccept( node->members   , *this );
     440                maybeAccept_impl( node->parameters, *this );
     441                maybeAccept_impl( node->members   , *this );
    400442        }
    401443
     
    416458        {
    417459                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    418                 maybeMutateRef( node->parameters, *this );
    419                 maybeMutateRef( node->members   , *this );
     460                maybeMutate_impl( node->parameters, *this );
     461                maybeMutate_impl( node->members   , *this );
    420462        }
    421463
     
    437479        {
    438480                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    439                 maybeAccept( node->parameters, *this );
    440                 maybeAccept( node->members   , *this );
     481                maybeAccept_impl( node->parameters, *this );
     482                maybeAccept_impl( node->members   , *this );
    441483        }
    442484
     
    455497        {
    456498                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    457                 maybeMutateRef( node->parameters, *this );
    458                 maybeMutateRef( node->members   , *this );
     499                maybeMutate_impl( node->parameters, *this );
     500                maybeMutate_impl( node->members   , *this );
    459501        }
    460502
     
    473515
    474516        // unlike structs, traits, and unions, enums inject their members into the global scope
    475         maybeAccept( node->parameters, *this );
    476         maybeAccept( node->members   , *this );
     517        maybeAccept_impl( node->parameters, *this );
     518        maybeAccept_impl( node->members   , *this );
    477519
    478520        VISIT_END( node );
     
    486528
    487529        // unlike structs, traits, and unions, enums inject their members into the global scope
    488         maybeMutateRef( node->parameters, *this );
    489         maybeMutateRef( node->members   , *this );
     530        maybeMutate_impl( node->parameters, *this );
     531        maybeMutate_impl( node->members   , *this );
    490532
    491533        MUTATE_END( Declaration, node );
     
    500542        {
    501543                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    502                 maybeAccept( node->parameters, *this );
    503                 maybeAccept( node->members   , *this );
     544                maybeAccept_impl( node->parameters, *this );
     545                maybeAccept_impl( node->members   , *this );
    504546        }
    505547
     
    515557        {
    516558                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    517                 maybeMutateRef( node->parameters, *this );
    518                 maybeMutateRef( node->members   , *this );
     559                maybeMutate_impl( node->parameters, *this );
     560                maybeMutate_impl( node->members   , *this );
    519561        }
    520562
     
    532574        {
    533575                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    534                 maybeAccept( node->parameters, *this );
    535                 maybeAccept( node->base      , *this );
     576                maybeAccept_impl( node->parameters, *this );
     577                maybeAccept_impl( node->base      , *this );
    536578        }
    537579
     
    541583        indexerAddType( node );
    542584
    543         maybeAccept( node->assertions, *this );
     585        maybeAccept_impl( node->assertions, *this );
    544586
    545587        indexerScopedAccept( node->init, *this );
     
    554596        {
    555597                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    556                 maybeMutateRef( node->parameters, *this );
    557                 maybeMutateRef( node->base      , *this );
     598                maybeMutate_impl( node->parameters, *this );
     599                maybeMutate_impl( node->base      , *this );
    558600        }
    559601
     
    563605        indexerAddType( node );
    564606
    565         maybeMutateRef( node->assertions, *this );
     607        maybeMutate_impl( node->assertions, *this );
    566608
    567609        indexerScopedMutate( node->init, *this );
     
    578620        {
    579621                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    580                 maybeAccept( node->parameters, *this );
    581                 maybeAccept( node->base      , *this );
     622                maybeAccept_impl( node->parameters, *this );
     623                maybeAccept_impl( node->base      , *this );
    582624        }
    583625
    584626        indexerAddType( node );
    585627
    586         maybeAccept( node->assertions, *this );
     628        maybeAccept_impl( node->assertions, *this );
    587629
    588630        VISIT_END( node );
     
    595637        {
    596638                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    597                 maybeMutateRef     ( node->parameters, *this );
    598                 maybeMutateRef( node->base      , *this );
     639                maybeMutate_impl( node->parameters, *this );
     640                maybeMutate_impl( node->base      , *this );
    599641        }
    600642
    601643        indexerAddType( node );
    602644
    603         maybeMutateRef( node->assertions, *this );
     645        maybeMutate_impl( node->assertions, *this );
    604646
    605647        MUTATE_END( Declaration, node );
     
    612654        VISIT_START( node );
    613655
    614         maybeAccept( node->stmt, *this );
     656        maybeAccept_impl( node->stmt, *this );
    615657
    616658        VISIT_END( node );
     
    621663        MUTATE_START( node );
    622664
    623         maybeMutateRef( node->stmt, *this );
     665        maybeMutate_impl( node->stmt, *this );
    624666
    625667        MUTATE_END( AsmDecl, node );
     
    690732                // if statements introduce a level of scope (for the initialization)
    691733                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    692                 acceptAll( node->get_initialization(), *this );
    693                 visitExpression( node->condition );
     734                maybeAccept_impl( node->get_initialization(), *this );
     735                visitExpression ( node->condition );
    694736                node->thenPart = visitStatement( node->thenPart );
    695737                node->elsePart = visitStatement( node->elsePart );
     
    704746                // if statements introduce a level of scope (for the initialization)
    705747                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    706                 maybeMutateRef( node->get_initialization(), *this );
     748                maybeMutate_impl( node->get_initialization(), *this );
    707749                node->condition = mutateExpression( node->condition );
    708750                node->thenPart  = mutateStatement ( node->thenPart  );
     
    742784                // for statements introduce a level of scope (for the initialization)
    743785                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    744                 maybeAccept( node->initialization, *this );
     786                maybeAccept_impl( node->initialization, *this );
    745787                visitExpression( node->condition );
    746788                visitExpression( node->increment );
     
    756798                // for statements introduce a level of scope (for the initialization)
    757799                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    758                 maybeMutateRef( node->initialization, *this );
     800                maybeMutate_impl( node->initialization, *this );
    759801                node->condition = mutateExpression( node->condition );
    760802                node->increment = mutateExpression( node->increment );
     
    859901        VISIT_START( node );
    860902
    861         maybeAccept( node->block       , *this );
    862         maybeAccept( node->handlers    , *this );
    863         maybeAccept( node->finallyBlock, *this );
     903        maybeAccept_impl( node->block       , *this );
     904        maybeAccept_impl( node->handlers    , *this );
     905        maybeAccept_impl( node->finallyBlock, *this );
    864906
    865907        VISIT_END( node );
     
    870912        MUTATE_START( node );
    871913
    872         maybeMutateRef( node->block       , *this );
    873         maybeMutateRef( node->handlers    , *this );
    874         maybeMutateRef( node->finallyBlock, *this );
     914        maybeMutate_impl( node->block       , *this );
     915        maybeMutate_impl( node->handlers    , *this );
     916        maybeMutate_impl( node->finallyBlock, *this );
    875917
    876918        MUTATE_END( Statement, node );
     
    885927                // catch statements introduce a level of scope (for the caught exception)
    886928                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    887                 maybeAccept( node->decl, *this );
     929                maybeAccept_impl( node->decl, *this );
    888930                node->cond = visitExpression( node->cond );
    889931                node->body = visitStatement ( node->body );
     
    898940                // catch statements introduce a level of scope (for the caught exception)
    899941                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    900                 maybeMutateRef( node->decl, *this );
     942                maybeMutate_impl( node->decl, *this );
    901943                node->cond = mutateExpression( node->cond );
    902944                node->body = mutateStatement ( node->body );
     
    9721014
    9731015        indexerScopedAccept( node->result  , *this );
    974         maybeAccept        ( node->function, *this );
    975         maybeAccept        ( node->args    , *this );
     1016        maybeAccept_impl        ( node->function, *this );
     1017        maybeAccept_impl        ( node->args    , *this );
    9761018
    9771019        VISIT_END( node );
     
    9841026        indexerScopedMutate( node->env     , *this );
    9851027        indexerScopedMutate( node->result  , *this );
    986         maybeMutateRef     ( node->function, *this );
    987         maybeMutateRef     ( node->args    , *this );
     1028        maybeMutate_impl   ( node->function, *this );
     1029        maybeMutate_impl   ( node->args    , *this );
    9881030
    9891031        MUTATE_END( Expression, node );
     
    9961038        VISIT_START( node );
    9971039
    998         // maybeAccept( node->get_env(), *this );
     1040        // maybeAccept_impl( node->get_env(), *this );
    9991041        indexerScopedAccept( node->result, *this );
    10001042
     
    10481090
    10491091        indexerScopedAccept( node->result, *this );
    1050         maybeAccept        ( node->arg   , *this );
     1092        maybeAccept_impl        ( node->arg   , *this );
    10511093
    10521094        VISIT_END( node );
     
    10591101        indexerScopedMutate( node->env   , *this );
    10601102        indexerScopedMutate( node->result, *this );
    1061         maybeMutateRef     ( node->arg   , *this );
     1103        maybeMutate_impl   ( node->arg   , *this );
    10621104
    10631105        MUTATE_END( Expression, node );
     
    10711113
    10721114        indexerScopedAccept( node->result, *this );
    1073         maybeAccept( node->arg, *this );
     1115        maybeAccept_impl( node->arg, *this );
    10741116
    10751117        VISIT_END( node );
     
    10821124        indexerScopedMutate( node->env   , *this );
    10831125        indexerScopedMutate( node->result, *this );
    1084         maybeMutateRef     ( node->arg   , *this );
     1126        maybeMutate_impl   ( node->arg   , *this );
    10851127
    10861128        MUTATE_END( Expression, node );
     
    10941136
    10951137        indexerScopedAccept( node->result, *this );
    1096         maybeAccept        ( node->arg   , *this );
     1138        maybeAccept_impl   ( node->arg   , *this );
    10971139
    10981140        VISIT_END( node );
     
    11051147        indexerScopedMutate( node->env   , *this );
    11061148        indexerScopedMutate( node->result, *this );
    1107         maybeMutateRef     ( node->arg   , *this );
     1149        maybeMutate_impl   ( node->arg   , *this );
    11081150
    11091151        MUTATE_END( Expression, node );
     
    11381180
    11391181        indexerScopedAccept( node->result   , *this );
    1140         maybeAccept        ( node->aggregate, *this );
    1141         maybeAccept        ( node->member   , *this );
     1182        maybeAccept_impl   ( node->aggregate, *this );
     1183        maybeAccept_impl   ( node->member   , *this );
    11421184
    11431185        VISIT_END( node );
     
    11501192        indexerScopedMutate( node->env      , *this );
    11511193        indexerScopedMutate( node->result   , *this );
    1152         maybeMutateRef     ( node->aggregate, *this );
    1153         maybeMutateRef     ( node->member   , *this );
     1194        maybeMutate_impl   ( node->aggregate, *this );
     1195        maybeMutate_impl   ( node->member   , *this );
    11541196
    11551197        MUTATE_END( Expression, node );
     
    11631205
    11641206        indexerScopedAccept( node->result   , *this );
    1165         maybeAccept        ( node->aggregate, *this );
     1207        maybeAccept_impl   ( node->aggregate, *this );
    11661208
    11671209        VISIT_END( node );
     
    11741216        indexerScopedMutate( node->env      , *this );
    11751217        indexerScopedMutate( node->result   , *this );
    1176         maybeMutateRef     ( node->aggregate, *this );
     1218        maybeMutate_impl   ( node->aggregate, *this );
    11771219
    11781220        MUTATE_END( Expression, node );
     
    12071249
    12081250        indexerScopedAccept( node->result   , *this );
    1209         maybeAccept        ( &node->constant, *this );
     1251        maybeAccept_impl   ( &node->constant, *this );
    12101252
    12111253        VISIT_END( node );
     
    12181260        indexerScopedMutate( node->env   , *this );
    12191261        indexerScopedMutate( node->result, *this );
    1220         node->constant = *maybeMutate( &node->constant, *this );
     1262        Constant * ptr = &node->constant;
     1263        maybeMutate_impl( ptr, *this );
     1264        node->constant = *ptr;
    12211265
    12221266        MUTATE_END( Expression, node );
     
    12311275        indexerScopedAccept( node->result, *this );
    12321276        if ( node->get_isType() ) {
    1233                 maybeAccept( node->type, *this );
     1277                maybeAccept_impl( node->type, *this );
    12341278        } else {
    1235                 maybeAccept( node->expr, *this );
     1279                maybeAccept_impl( node->expr, *this );
    12361280        }
    12371281
     
    12461290        indexerScopedMutate( node->result, *this );
    12471291        if ( node->get_isType() ) {
    1248                 maybeMutateRef( node->type, *this );
     1292                maybeMutate_impl( node->type, *this );
    12491293        } else {
    1250                 maybeMutateRef( node->expr, *this );
     1294                maybeMutate_impl( node->expr, *this );
    12511295        }
    12521296
     
    12621306        indexerScopedAccept( node->result, *this );
    12631307        if ( node->get_isType() ) {
    1264                 maybeAccept( node->type, *this );
     1308                maybeAccept_impl( node->type, *this );
    12651309        } else {
    1266                 maybeAccept( node->expr, *this );
     1310                maybeAccept_impl( node->expr, *this );
    12671311        }
    12681312
     
    12771321        indexerScopedMutate( node->result, *this );
    12781322        if ( node->get_isType() ) {
    1279                 maybeMutateRef( node->type, *this );
     1323                maybeMutate_impl( node->type, *this );
    12801324        } else {
    1281                 maybeMutateRef( node->expr, *this );
     1325                maybeMutate_impl( node->expr, *this );
    12821326        }
    12831327
     
    12921336
    12931337        indexerScopedAccept( node->result, *this );
    1294         maybeAccept        ( node->type  , *this );
     1338        maybeAccept_impl   ( node->type  , *this );
    12951339
    12961340        VISIT_END( node );
     
    13031347        indexerScopedMutate( node->env   , *this );
    13041348        indexerScopedMutate( node->result, *this );
    1305         maybeMutateRef     ( node->type  , *this );
     1349        maybeMutate_impl   ( node->type  , *this );
    13061350
    13071351        MUTATE_END( Expression, node );
     
    13151359
    13161360        indexerScopedAccept( node->result, *this );
    1317         maybeAccept        ( node->type  , *this );
    1318         maybeAccept        ( node->member, *this );
     1361        maybeAccept_impl   ( node->type  , *this );
     1362        maybeAccept_impl   ( node->member, *this );
    13191363
    13201364        VISIT_END( node );
     
    13271371        indexerScopedMutate( node->env   , *this );
    13281372        indexerScopedMutate( node->result, *this );
    1329         maybeMutateRef     ( node->type  , *this );
    1330         maybeMutateRef     ( node->member, *this );
     1373        maybeMutate_impl   ( node->type  , *this );
     1374        maybeMutate_impl   ( node->member, *this );
    13311375
    13321376        MUTATE_END( Expression, node );
     
    13401384
    13411385        indexerScopedAccept( node->result, *this );
    1342         maybeAccept        ( node->type  , *this );
     1386        maybeAccept_impl   ( node->type  , *this );
    13431387
    13441388        VISIT_END( node );
     
    13511395        indexerScopedMutate( node->env   , *this );
    13521396        indexerScopedMutate( node->result, *this );
    1353         maybeMutateRef     ( node->type  , *this );
     1397        maybeMutate_impl   ( node->type  , *this );
    13541398
    13551399        MUTATE_END( Expression, node );
     
    13641408        indexerScopedAccept( node->result, *this );
    13651409        if ( node->get_isType() ) {
    1366                 maybeAccept( node->type, *this );
     1410                maybeAccept_impl( node->type, *this );
    13671411        } else {
    1368                 maybeAccept( node->expr, *this );
     1412                maybeAccept_impl( node->expr, *this );
    13691413        }
    13701414
     
    13791423        indexerScopedMutate( node->result, *this );
    13801424        if ( node->get_isType() ) {
    1381                 maybeMutateRef( node->type, *this );
     1425                maybeMutate_impl( node->type, *this );
    13821426        } else {
    1383                 maybeMutateRef( node->expr, *this );
     1427                maybeMutate_impl( node->expr, *this );
    13841428        }
    13851429
     
    13941438
    13951439        indexerScopedAccept( node->result, *this );
    1396         maybeAccept        ( node->arg1  , *this );
    1397         maybeAccept        ( node->arg2  , *this );
     1440        maybeAccept_impl   ( node->arg1  , *this );
     1441        maybeAccept_impl   ( node->arg2  , *this );
    13981442
    13991443        VISIT_END( node );
     
    14061450        indexerScopedMutate( node->env   , *this );
    14071451        indexerScopedMutate( node->result, *this );
    1408         maybeMutateRef     ( node->arg1  , *this );
    1409         maybeMutateRef     ( node->arg2  , *this );
     1452        maybeMutate_impl   ( node->arg1  , *this );
     1453        maybeMutate_impl   ( node->arg2  , *this );
    14101454
    14111455        MUTATE_END( Expression, node );
     
    14191463
    14201464        indexerScopedAccept( node->result, *this );
    1421         maybeAccept        ( node->arg1  , *this );
    1422         maybeAccept        ( node->arg2  , *this );
    1423         maybeAccept        ( node->arg3  , *this );
     1465        maybeAccept_impl        ( node->arg1  , *this );
     1466        maybeAccept_impl        ( node->arg2  , *this );
     1467        maybeAccept_impl        ( node->arg3  , *this );
    14241468
    14251469        VISIT_END( node );
     
    14321476        indexerScopedMutate( node->env   , *this );
    14331477        indexerScopedMutate( node->result, *this );
    1434         maybeMutateRef     ( node->arg1  , *this );
    1435         maybeMutateRef     ( node->arg2  , *this );
    1436         maybeMutateRef     ( node->arg3  , *this );
     1478        maybeMutate_impl   ( node->arg1  , *this );
     1479        maybeMutate_impl   ( node->arg2  , *this );
     1480        maybeMutate_impl   ( node->arg3  , *this );
    14371481
    14381482        MUTATE_END( Expression, node );
     
    14461490
    14471491        indexerScopedAccept( node->result, *this );
    1448         maybeAccept        ( node->arg1  , *this );
    1449         maybeAccept        ( node->arg2  , *this );
     1492        maybeAccept_impl   ( node->arg1  , *this );
     1493        maybeAccept_impl   ( node->arg2  , *this );
    14501494
    14511495        VISIT_END( node );
     
    14581502        indexerScopedMutate( node->env   , *this );
    14591503        indexerScopedMutate( node->result, *this );
    1460         maybeMutateRef     ( node->arg1  , *this );
    1461         maybeMutateRef     ( node->arg2  , *this );
     1504        maybeMutate_impl   ( node->arg1  , *this );
     1505        maybeMutate_impl   ( node->arg2  , *this );
    14621506
    14631507        MUTATE_END( Expression, node );
     
    14711515
    14721516        indexerScopedAccept( node->result, *this );
    1473         maybeAccept        ( node->type, *this );
     1517        maybeAccept_impl   ( node->type, *this );
    14741518
    14751519        VISIT_END( node );
     
    14821526        indexerScopedMutate( node->env   , *this );
    14831527        indexerScopedMutate( node->result, *this );
    1484         maybeMutateRef     ( node->type  , *this );
     1528        maybeMutate_impl   ( node->type  , *this );
    14851529
    14861530        MUTATE_END( Expression, node );
     
    14941538
    14951539        indexerScopedAccept( node->result    , *this );
    1496         maybeAccept        ( node->inout     , *this );
    1497         maybeAccept        ( node->constraint, *this );
    1498         maybeAccept        ( node->operand   , *this );
     1540        maybeAccept_impl   ( node->inout     , *this );
     1541        maybeAccept_impl   ( node->constraint, *this );
     1542        maybeAccept_impl   ( node->operand   , *this );
    14991543
    15001544        VISIT_END( node );
     
    15071551        indexerScopedMutate( node->env       , *this );
    15081552        indexerScopedMutate( node->result    , *this );
    1509         maybeMutateRef     ( node->inout     , *this );
    1510         maybeMutateRef     ( node->constraint, *this );
    1511         maybeMutateRef     ( node->operand   , *this );
     1553        maybeMutate_impl   ( node->inout     , *this );
     1554        maybeMutate_impl   ( node->constraint, *this );
     1555        maybeMutate_impl   ( node->operand   , *this );
    15121556
    15131557        MUTATE_END( Expression, node );
     
    15211565
    15221566        indexerScopedAccept( node->result     , *this );
    1523         maybeAccept        ( node->callExpr   , *this );
    1524         maybeAccept        ( node->tempDecls  , *this );
    1525         maybeAccept        ( node->returnDecls, *this );
    1526         maybeAccept        ( node->dtors      , *this );
     1567        maybeAccept_impl   ( node->callExpr   , *this );
     1568        maybeAccept_impl   ( node->tempDecls  , *this );
     1569        maybeAccept_impl   ( node->returnDecls, *this );
     1570        maybeAccept_impl   ( node->dtors      , *this );
    15271571
    15281572        VISIT_END( node );
     
    15351579        indexerScopedMutate( node->env        , *this );
    15361580        indexerScopedMutate( node->result     , *this );
    1537         maybeMutateRef     ( node->callExpr   , *this );
    1538         maybeMutateRef     ( node->tempDecls  , *this );
    1539         maybeMutateRef     ( node->returnDecls, *this );
    1540         maybeMutateRef     ( node->dtors      , *this );
     1581        maybeMutate_impl   ( node->callExpr   , *this );
     1582        maybeMutate_impl   ( node->tempDecls  , *this );
     1583        maybeMutate_impl   ( node->returnDecls, *this );
     1584        maybeMutate_impl   ( node->dtors      , *this );
    15411585
    15421586        MUTATE_END( Expression, node );
     
    15501594
    15511595        indexerScopedAccept( node->result  , *this );
    1552         maybeAccept        ( node->callExpr, *this );
     1596        maybeAccept_impl   ( node->callExpr, *this );
    15531597
    15541598        VISIT_END( node );
     
    15611605        indexerScopedMutate( node->env     , *this );
    15621606        indexerScopedMutate( node->result  , *this );
    1563         maybeMutateRef     ( node->callExpr, *this );
     1607        maybeMutate_impl   ( node->callExpr, *this );
    15641608
    15651609        MUTATE_END( Expression, node );
     
    15731617
    15741618        indexerScopedAccept( node->result     , *this );
    1575         maybeAccept        ( node->initializer, *this );
     1619        maybeAccept_impl   ( node->initializer, *this );
    15761620
    15771621        VISIT_END( node );
     
    15841628        indexerScopedMutate( node->env        , *this );
    15851629        indexerScopedMutate( node->result     , *this );
    1586         maybeMutateRef     ( node->initializer, *this );
     1630        maybeMutate_impl     ( node->initializer, *this );
    15871631
    15881632        MUTATE_END( Expression, node );
     
    15961640
    15971641        indexerScopedAccept( node->result, *this );
    1598         maybeAccept        ( node->low   , *this );
    1599         maybeAccept        ( node->high  , *this );
     1642        maybeAccept_impl   ( node->low   , *this );
     1643        maybeAccept_impl   ( node->high  , *this );
    16001644
    16011645        VISIT_END( node );
     
    16081652        indexerScopedMutate( node->env   , *this );
    16091653        indexerScopedMutate( node->result, *this );
    1610         maybeMutateRef     ( node->low   , *this );
    1611         maybeMutateRef     ( node->high  , *this );
     1654        maybeMutate_impl   ( node->low   , *this );
     1655        maybeMutate_impl   ( node->high  , *this );
    16121656
    16131657        MUTATE_END( Expression, node );
     
    16211665
    16221666        indexerScopedAccept( node->result, *this );
    1623         maybeAccept        ( node->exprs , *this );
     1667        maybeAccept_impl   ( node->exprs , *this );
    16241668
    16251669        VISIT_END( node );
     
    16321676        indexerScopedMutate( node->env   , *this );
    16331677        indexerScopedMutate( node->result, *this );
    1634         maybeMutateRef     ( node->exprs , *this );
     1678        maybeMutate_impl   ( node->exprs , *this );
    16351679
    16361680        MUTATE_END( Expression, node );
     
    16441688
    16451689        indexerScopedAccept( node->result, *this );
    1646         maybeAccept          ( node->exprs , *this );
     1690        maybeAccept_impl   ( node->exprs , *this );
    16471691
    16481692        VISIT_END( node );
     
    16551699        indexerScopedMutate( node->env   , *this );
    16561700        indexerScopedMutate( node->result, *this );
    1657         maybeMutateRef     ( node->exprs , *this );
     1701        maybeMutate_impl   ( node->exprs , *this );
    16581702
    16591703        MUTATE_END( Expression, node );
     
    16671711
    16681712        indexerScopedAccept( node->result, *this );
    1669         maybeAccept        ( node->tuple , *this );
     1713        maybeAccept_impl   ( node->tuple , *this );
    16701714
    16711715        VISIT_END( node );
     
    16781722        indexerScopedMutate( node->env   , *this );
    16791723        indexerScopedMutate( node->result, *this );
    1680         maybeMutateRef     ( node->tuple , *this );
     1724        maybeMutate_impl   ( node->tuple , *this );
    16811725
    16821726        MUTATE_END( Expression, node );
     
    16901734
    16911735        indexerScopedAccept( node->result  , *this );
    1692         maybeAccept        ( node->stmtExpr, *this );
     1736        maybeAccept_impl   ( node->stmtExpr, *this );
    16931737
    16941738        VISIT_END( node );
     
    17011745        indexerScopedMutate( node->env     , *this );
    17021746        indexerScopedMutate( node->result  , *this );
    1703         maybeMutateRef     ( node->stmtExpr, *this );
     1747        maybeMutate_impl   ( node->stmtExpr, *this );
    17041748
    17051749        MUTATE_END( Expression, node );
     
    17181762
    17191763        indexerScopedAccept( node->result     , *this );
    1720         maybeAccept        ( node->statements , *this );
    1721         maybeAccept        ( node->returnDecls, *this );
    1722         maybeAccept        ( node->dtors      , *this );
     1764        maybeAccept_impl   ( node->statements , *this );
     1765        maybeAccept_impl   ( node->returnDecls, *this );
     1766        maybeAccept_impl   ( node->dtors      , *this );
    17231767
    17241768        VISIT_END( node );
     
    17351779
    17361780        indexerScopedMutate( node->result     , *this );
    1737         maybeMutateRef     ( node->statements , *this );
    1738         maybeMutateRef     ( node->returnDecls, *this );
    1739         maybeMutateRef     ( node->dtors      , *this );
     1781        maybeMutate_impl   ( node->statements , *this );
     1782        maybeMutate_impl   ( node->returnDecls, *this );
     1783        maybeMutate_impl   ( node->dtors      , *this );
    17401784
    17411785        MUTATE_END( Expression, node );
     
    17491793
    17501794        indexerScopedAccept( node->result, *this );
    1751         maybeAccept        ( node->expr  , *this );
     1795        maybeAccept_impl   ( node->expr  , *this );
    17521796
    17531797        VISIT_END( node );
     
    17601804        indexerScopedMutate( node->env   , *this );
    17611805        indexerScopedMutate( node->result, *this );
    1762         maybeMutateRef     ( node->expr  , *this );
     1806        maybeMutate_impl   ( node->expr  , *this );
    17631807
    17641808        MUTATE_END( Expression, node );
     
    18051849        {
    18061850                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1807                 maybeAccept( node->forall    , *this );
    1808                 maybeAccept( node->parameters, *this );
     1851                maybeAccept_impl( node->forall    , *this );
     1852                maybeAccept_impl( node->parameters, *this );
    18091853        }
    18101854
     
    18201864        {
    18211865                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1822                 maybeMutateRef( node->forall    , *this );
    1823                 maybeMutateRef( node->parameters, *this );
     1866                maybeMutate_impl( node->forall    , *this );
     1867                maybeMutate_impl( node->parameters, *this );
    18241868        }
    18251869
     
    18371881        {
    18381882                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1839                 maybeAccept( node->forall    , *this );
    1840                 maybeAccept( node->parameters, *this );
     1883                maybeAccept_impl( node->forall    , *this );
     1884                maybeAccept_impl( node->parameters, *this );
    18411885        }
    18421886
     
    18521896        {
    18531897                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1854                 maybeMutateRef( node->forall    , *this );
    1855                 maybeMutateRef( node->parameters, *this );
     1898                maybeMutate_impl( node->forall    , *this );
     1899                maybeMutate_impl( node->parameters, *this );
    18561900        }
    18571901
     
    18771921        VISIT_START( node );
    18781922
    1879         maybeAccept( node->forall    , *this );
    1880         maybeAccept( node->parameters, *this );
     1923        maybeAccept_impl( node->forall    , *this );
     1924        maybeAccept_impl( node->parameters, *this );
    18811925
    18821926        VISIT_END( node );
     
    18871931        MUTATE_START( node );
    18881932
    1889         maybeMutateRef( node->forall    , *this );
    1890         maybeMutateRef( node->parameters, *this );
     1933        maybeMutate_impl( node->forall    , *this );
     1934        maybeMutate_impl( node->parameters, *this );
    18911935
    18921936        MUTATE_END( Type, node );
     
    19341978        VISIT_START( node );
    19351979
    1936         maybeAccept( node->get_designators(), *this );
     1980        maybeAccept_impl( node->get_designators(), *this );
    19371981
    19381982        VISIT_END( node );
     
    19431987        MUTATE_START( node );
    19441988
    1945         maybeMutateRef( node->get_designators(), *this );
     1989        maybeMutate_impl( node->get_designators(), *this );
    19461990
    19471991        MUTATE_END( Designation, node );
  • src/Common/PassVisitor.proto.h

    r21b7161 r7821d6c  
    4646        ~bool_ref() = default;
    4747
    48         operator bool() { return *m_ref; }
     48        operator bool() { return m_ref ? *m_ref : true; }
    4949        bool operator=( bool val ) { return *m_ref = val; }
    5050
    5151private:
    5252
    53         template<typename pass>
    54         friend class PassVisitor;
    55 
    56         void set( bool & val ) { m_ref = &val; };
    57 
    58         bool * m_ref;
     53        friend class ChildrenGuard;
     54
     55        bool * set( bool & val ) {
     56                bool * prev = m_ref;
     57                m_ref = &val;
     58                return prev;
     59        }
     60
     61        bool * m_ref = nullptr;
    5962};
    6063
    61 template< typename TreeType, typename VisitorType >
    62 inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
    63         auto guard = makeFuncGuard(
    64                 [&visitor]() { visitor.indexerScopeEnter(); },
    65                 [&visitor]() { visitor.indexerScopeLeave(); }
    66         );
    67         maybeAccept( tree, visitor );
    68 }
    69 
    70 template< typename TreeType, typename MutatorType >
    71 inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
    72         auto guard = makeFuncGuard(
    73                 [&mutator]() { mutator.indexerScopeEnter(); },
    74                 [&mutator]() { mutator.indexerScopeLeave(); }
    75         );
    76         tree = maybeMutate( tree, mutator );
    77 }
    78 
    79 template< typename TreeType, typename MutatorType >
    80 inline void maybeMutateRef( TreeType *& tree, MutatorType & mutator ) {
    81         tree = maybeMutate( tree, mutator );
    82 }
     64class ChildrenGuard {
     65public:
     66
     67        ChildrenGuard( bool_ref * ref )
     68                : m_val ( true )
     69                , m_prev( ref ? ref->set( m_val ) : nullptr )
     70                , m_ref ( ref )
     71        {}
     72
     73        ~ChildrenGuard() {
     74                if( m_ref ) {
     75                        m_ref->set( *m_prev );
     76                }
     77        }
     78
     79        operator bool() { return m_val; }
     80
     81private:
     82        bool       m_val;
     83        bool     * m_prev;
     84        bool_ref * m_ref;
     85};
    8386
    8487//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  • src/InitTweak/FixInit.cc

    r21b7161 r7821d6c  
    289289                        for ( std::list< Declaration * >::iterator i = translationUnit.begin(); i != translationUnit.end(); ++i ) {
    290290                                try {
    291                                         *i = maybeMutate( *i, fixer );
     291                                        maybeMutate( *i, fixer );
    292292                                        translationUnit.splice( i, fixer.pass.staticDtorDecls );
    293293                                } catch( SemanticError &e ) {
  • src/Parser/parser.yy

    r21b7161 r7821d6c  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Sep 23 17:43:15 2017
    13 // Update Count     : 2829
     12// Last Modified On : Mon Oct  2 18:18:55 2017
     13// Update Count     : 2835
    1414//
    1515
     
    456456        | '(' compound_statement ')'                                            // GCC, lambda expression
    457457                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
    458         | primary_expression '{' argument_expression_list '}' // CFA, constructor call
    459                 {
    460                         Token fn;
    461                         fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
    462                         $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    463                 }
    464458        | type_name '.' no_attr_identifier                                      // CFA, nested type
    465459                { $$ = nullptr; }                                                               // FIX ME
     
    476470                // equivalent to the old x[i,j].
    477471                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $4 ) ); }
     472        | postfix_expression '{' argument_expression_list '}' // CFA, constructor call
     473                {
     474                        Token fn;
     475                        fn.str = new std::string( "?{}" );                      // location undefined - use location of '{'?
     476                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
     477                }
    478478        | postfix_expression '(' argument_expression_list ')'
    479479                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
  • src/ResolvExpr/Resolver.cc

    r21b7161 r7821d6c  
    5353                void previsit( FunctionDecl *functionDecl );
    5454                void postvisit( FunctionDecl *functionDecl );
    55                 void previsit( ObjectDecl *functionDecl );
     55                void previsit( ObjectDecl *objectDecll );
    5656                void previsit( TypeDecl *typeDecl );
    5757                void previsit( EnumDecl * enumDecl );
     
    246246        }
    247247
    248 
    249248        void Resolver::postvisit( FunctionDecl *functionDecl ) {
    250249                // default value expressions have an environment which shouldn't be there and trips up later passes.
  • src/SynTree/Constant.cc

    r21b7161 r7821d6c  
    7171}
    7272
    73 void Constant::print( std::ostream &os ) const {
     73void Constant::print( std::ostream &os, int indent ) const {
    7474        os << "(" << rep << " " << val.ival;
    7575        if ( type ) {
  • src/SynTree/Constant.h

    r21b7161 r7821d6c  
    1919#include <string>     // for string
    2020
     21#include "BaseSyntaxNode.h"
    2122#include "Mutator.h"  // for Mutator
    2223#include "Visitor.h"  // for Visitor
     
    2425class Type;
    2526
    26 class Constant {
     27class Constant : public BaseSyntaxNode {
    2728  public:
    2829        Constant( Type * type, std::string rep, unsigned long long val );
     
    3031        Constant( const Constant & other );
    3132        virtual ~Constant();
     33
     34        virtual Constant * clone() const { return new Constant( *this ); }
    3235
    3336        Type * get_type() { return type; }
     
    5457        virtual void accept( Visitor & v ) { v.visit( this ); }
    5558        virtual Constant * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    56         virtual void print( std::ostream & os ) const;
     59        virtual void print( std::ostream & os, int indent = 0 ) const;
    5760  private:
    5861        Type * type;
Note: See TracChangeset for help on using the changeset viewer.