Changes in src/Common/PassVisitor.impl.h [2f86ddf:712348a]
- File:
-
- 1 edited
-
src/Common/PassVisitor.impl.h (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
r2f86ddf r712348a 20 20 21 21 #define MUTATE_END( type, node ) \ 22 return call_postmutate< type * >( node ); \ 22 auto __return = call_postmutate< type * >( node ); \ 23 assert( __return ); \ 24 return __return; 23 25 24 26 … … 67 69 SemanticErrorException errors; 68 70 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); 69 74 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 75 76 70 77 // splice in new declarations after previous decl 71 78 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } … … 83 90 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 84 91 } 92 pass_visitor_stats.depth--; 85 93 if ( ! errors.isEmpty() ) { 86 94 throw errors; … … 94 102 SemanticErrorException errors; 95 103 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); 96 107 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 97 108 // splice in new declarations after previous decl … … 109 120 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 110 121 } 122 pass_visitor_stats.depth--; 111 123 if ( ! errors.isEmpty() ) { 112 124 throw errors; … … 126 138 if ( ! visitor.get_visit_children() ) return; 127 139 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); 128 144 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 129 145 try { … … 135 151 } 136 152 } 153 pass_visitor_stats.depth--; 137 154 if ( ! errors.isEmpty() ) { 138 155 throw errors; … … 151 168 template< typename Container, typename pass_type > 152 169 inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) { 170 153 171 if ( ! mutator.get_visit_children() ) return; 154 172 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); 155 177 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 156 178 try { … … 163 185 } // try 164 186 } // for 187 pass_visitor_stats.depth--; 165 188 if ( ! errors.isEmpty() ) { 166 189 throw errors; … … 185 208 DeclList_t* afterDecls = get_afterDecls(); 186 209 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); 187 213 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 188 214 … … 192 218 try { 193 219 func( *i ); 220 assert( *i ); 194 221 assert(( empty( beforeStmts ) && empty( afterStmts )) 195 222 || ( empty( beforeDecls ) && empty( afterDecls )) ); … … 202 229 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 203 230 } 231 pass_visitor_stats.depth--; 204 232 205 233 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); } … … 229 257 230 258 // 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() ); 232 260 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 233 261 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); … … 1778 1806 VISIT_START( node ); 1779 1807 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 ); 1782 1813 1783 1814 VISIT_END( node ); … … 1788 1819 MUTATE_START( node ); 1789 1820 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 ); 1793 1827 1794 1828 MUTATE_END( Expression, node ); … … 1965 1999 1966 2000 // 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() ); 1968 2002 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 1969 2003 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); … … 1982 2016 1983 2017 // 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() ); 1985 2019 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 1986 2020 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); … … 2678 2712 2679 2713 //-------------------------------------------------------------------------- 2680 // Subrange2681 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 //--------------------------------------------------------------------------2696 2714 // Attribute 2697 2715 template< typename pass_type >
Note:
See TracChangeset
for help on using the changeset viewer.