Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.impl.h

    r2f86ddf r712348a  
    2020
    2121#define MUTATE_END( type, node )                \
    22         return call_postmutate< type * >( node ); \
     22        auto __return = call_postmutate< type * >( node ); \
     23        assert( __return ); \
     24        return __return;
    2325
    2426
     
    6769        SemanticErrorException errors;
    6870
     71        pass_visitor_stats.depth++;
     72        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     73        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    6974        for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
     75
     76
    7077                // splice in new declarations after previous decl
    7178                if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
     
    8390                if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
    8491        }
     92        pass_visitor_stats.depth--;
    8593        if ( ! errors.isEmpty() ) {
    8694                throw errors;
     
    94102        SemanticErrorException errors;
    95103
     104        pass_visitor_stats.depth++;
     105        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     106        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    96107        for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
    97108                // splice in new declarations after previous decl
     
    109120                if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
    110121        }
     122        pass_visitor_stats.depth--;
    111123        if ( ! errors.isEmpty() ) {
    112124                throw errors;
     
    126138        if ( ! visitor.get_visit_children() ) return;
    127139        SemanticErrorException errors;
     140
     141        pass_visitor_stats.depth++;
     142        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     143        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    128144        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    129145                try {
     
    135151                }
    136152        }
     153        pass_visitor_stats.depth--;
    137154        if ( ! errors.isEmpty() ) {
    138155                throw errors;
     
    151168template< typename Container, typename pass_type >
    152169inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
     170
    153171        if ( ! mutator.get_visit_children() ) return;
    154172        SemanticErrorException errors;
     173
     174        pass_visitor_stats.depth++;
     175        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     176        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    155177        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    156178                try {
     
    163185                } // try
    164186        } // for
     187        pass_visitor_stats.depth--;
    165188        if ( ! errors.isEmpty() ) {
    166189                throw errors;
     
    185208        DeclList_t* afterDecls  = get_afterDecls();
    186209
     210        pass_visitor_stats.depth++;
     211        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     212        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    187213        for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
    188214
     
    192218                try {
    193219                        func( *i );
     220                        assert( *i );
    194221                        assert(( empty( beforeStmts ) && empty( afterStmts ))
    195222                            || ( empty( beforeDecls ) && empty( afterDecls )) );
     
    202229                if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
    203230        }
     231        pass_visitor_stats.depth--;
    204232
    205233        if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
     
    229257
    230258        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
    231         ValueGuardPtr< TypeSubstitution * >  oldEnv        ( get_env_ptr    () );
     259        ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() );
    232260        ValueGuardPtr< DeclList_t >          oldBeforeDecls( get_beforeDecls() );
    233261        ValueGuardPtr< DeclList_t >          oldAfterDecls ( get_afterDecls () );
     
    17781806        VISIT_START( node );
    17791807
    1780         indexerScopedAccept( node->result    , *this );
    1781         maybeAccept_impl   ( node->callExpr  , *this );
     1808        indexerScopedAccept( node->result     , *this );
     1809        maybeAccept_impl   ( node->callExpr   , *this );
     1810        maybeAccept_impl   ( node->tempDecls  , *this );
     1811        maybeAccept_impl   ( node->returnDecls, *this );
     1812        maybeAccept_impl   ( node->dtors      , *this );
    17821813
    17831814        VISIT_END( node );
     
    17881819        MUTATE_START( node );
    17891820
    1790         indexerScopedMutate( node->env       , *this );
    1791         indexerScopedMutate( node->result    , *this );
    1792         maybeMutate_impl   ( node->callExpr  , *this );
     1821        indexerScopedMutate( node->env        , *this );
     1822        indexerScopedMutate( node->result     , *this );
     1823        maybeMutate_impl   ( node->callExpr   , *this );
     1824        maybeMutate_impl   ( node->tempDecls  , *this );
     1825        maybeMutate_impl   ( node->returnDecls, *this );
     1826        maybeMutate_impl   ( node->dtors      , *this );
    17931827
    17941828        MUTATE_END( Expression, node );
     
    19651999
    19662000        // don't want statements from outer CompoundStmts to be added to this StmtExpr
    1967         ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
     2001        ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() );
    19682002        ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
    19692003        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
     
    19822016
    19832017        // don't want statements from outer CompoundStmts to be added to this StmtExpr
    1984         ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
     2018        ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() );
    19852019        ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
    19862020        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
     
    26782712
    26792713//--------------------------------------------------------------------------
    2680 // Subrange
    2681 template< typename pass_type >
    2682 void PassVisitor< pass_type >::visit( Subrange * node ) {
    2683         VISIT_START( node );
    2684 
    2685         VISIT_END( node );
    2686 }
    2687 
    2688 template< typename pass_type >
    2689 Subrange * PassVisitor< pass_type >::mutate( Subrange * node  )  {
    2690         MUTATE_START( node );
    2691 
    2692         MUTATE_END( Subrange, node );
    2693 }
    2694 
    2695 //--------------------------------------------------------------------------
    26962714// Attribute
    26972715template< typename pass_type >
Note: See TracChangeset for help on using the changeset viewer.