Changes in / [676cc8c:4a58895]
- Location:
- src
- Files:
-
- 6 deleted
- 4 edited
-
Common/PassVisitor.h (modified) (3 diffs)
-
Common/PassVisitor.impl.h (modified) (20 diffs)
-
Common/PassVisitor.proto.h (deleted)
-
Common/utility.h (modified) (1 diff)
-
InitTweak/FixInit.cc (modified) (6 diffs)
-
benchmark/create_cfaCor.c (deleted)
-
benchmark/create_cfaThrd.c (deleted)
-
benchmark/create_pthrd.c (deleted)
-
benchmark/create_uCor.cpp (deleted)
-
benchmark/create_uTask.cpp (deleted)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
r676cc8c r4a58895 1 1 #pragma once 2 3 #include <stack>4 2 5 3 #include "SynTree/Mutator.h" … … 13 11 #include "SynTree/Constant.h" 14 12 15 #include "PassVisitor.proto.h" 13 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 14 // Deep magic (a.k.a template meta programming) to make the templated visitor work 15 // Basically the goal is to make 2 previsit_impl 16 // 1 - Use when a pass implements a valid previsit. This uses overloading which means the any overload of 17 // 'pass.previsit( node )' that compiles will be used for that node for that type 18 // This requires that this option only compile for passes that actually define an appropriate visit. 19 // SFINAE will make sure the compilation errors in this function don't halt the build. 20 // See http://en.cppreference.com/w/cpp/language/sfinae for details on SFINAE 21 // 2 - Since the first implementation might not be specilizable, the second implementation exists and does nothing. 22 // This is needed only to eliminate the need for passes to specify any kind of handlers. 23 // The second implementation only works because it has a lower priority. This is due to the bogus last parameter. 24 // The second implementation takes a long while the first takes an int. Since the caller always passes an literal 0 25 // the first implementation takes priority in regards to overloading. 26 // Mutator functions work along the same principal 27 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 28 // Visit 29 template<typename pass_type, typename node_type> 30 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.previsit( node ), void() ) { 31 pass.previsit( node ); 32 } 33 34 template<typename pass_type, typename node_type> 35 static inline void previsit_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {} 36 37 38 template<typename pass_type, typename node_type> 39 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.postvisit( node ), void() ) { 40 pass.postvisit( node ); 41 } 42 43 template<typename pass_type, typename node_type> 44 static inline void postvisit_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {} 45 46 // Mutate 47 template<typename pass_type, typename node_type> 48 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.premutate( node ), void() ) { 49 return pass.premutate( node ); 50 } 51 52 template<typename pass_type, typename node_type> 53 static inline void premutate_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {} 54 55 56 template<typename return_type, typename pass_type, typename node_type> 57 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.postmutate( node ) ) { 58 return pass.postmutate( node ); 59 } 60 61 template<typename return_type, typename pass_type, typename node_type> 62 static inline return_type postmutate_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) { return node; } 16 63 17 64 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- … … 209 256 210 257 private: 211 template<typename node_type> void call_previsit ( node_type * node ) { previsit_impl ( pass, node, 0 ); } 212 template<typename node_type> void call_postvisit( node_type * node ) { postvisit_impl( pass, node, 0 ); } 213 214 template<typename node_type> void call_premutate ( node_type * node ) { premutate_impl( pass, node, 0 ); } 215 template<typename return_type, typename node_type> return_type call_postmutate ( node_type * node ) { return postmutate_impl<return_type>( pass, node, 0 ); } 216 217 void call_beginScope() { begin_scope_impl( pass, 0 ); } 218 void call_endScope () { end_scope_impl ( pass, 0 ); } 219 220 void set_env( TypeSubstitution * env ) { set_env_impl( pass, env, 0); } 221 222 void visitStatementList( std::list< Statement* > &statements ); 223 void mutateStatementList( std::list< Statement* > &statements ); 224 225 Statement * visitStatement( Statement * stmt ); 226 Statement * mutateStatement( Statement * stmt ); 227 228 void visitExpression( Expression * expr ); 229 Expression * mutateExpression( Expression * expr ); 230 231 232 TypeSubstitution ** get_env_ptr () { return env_impl ( pass, 0); } 233 std::list< Statement* > * get_beforeStmts() { return stmtsToAddBefore_impl( pass, 0); } 234 std::list< Statement* > * get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); } 258 template<typename node_type> 259 auto call_previsit ( node_type * node ) 260 -> decltype( previsit_impl ( pass, node, 0 ), void() ) 261 { 262 previsit_impl ( pass, node, 0 ); 263 } 264 265 template<typename node_type> 266 auto call_postvisit( node_type * node ) 267 -> decltype( postvisit_impl( pass, node, 0 ), void() ) 268 { 269 postvisit_impl( pass, node, 0 ); 270 } 271 272 template<typename node_type> 273 auto call_premutate ( node_type * node ) 274 -> decltype( premutate_impl( pass, node, 0 ), void() ) 275 { 276 premutate_impl( pass, node, 0 ); 277 } 278 279 template<typename return_type, typename node_type> 280 auto call_postmutate ( node_type * node ) 281 -> decltype( postmutate_impl<return_type>( pass, node, 0 ) ) 282 { 283 return postmutate_impl<return_type>( pass, node, 0 ); 284 } 235 285 }; 236 286 -
src/Common/PassVisitor.impl.h
r676cc8c r4a58895 1 1 #pragma once 2 3 #define MUTATE_START( node ) \4 call_premutate( node ); \5 6 7 #define MUTATE_END( type, node ) \8 return call_postmutate< type * >( node ); \9 10 2 11 3 #define VISIT_BODY( node ) \ … … 14 6 call_postvisit( node ); \ 15 7 16 17 #define MUTATE_BODY( type, node ) \ 18 MUTATE_START( node ); \ 19 Mutator::mutate( node ); \ 20 MUTATE_END( type, node ); \ 21 22 23 24 template<typename T> 25 static inline bool empty( T * ptr ) { 26 return !ptr || ptr->empty(); 27 } 28 29 typedef std::list< Statement * > StmtList_t; 30 31 template< typename pass_type > 32 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) { 33 SemanticError errors; 34 35 StmtList_t* beforeStmts = get_beforeStmts(); 36 StmtList_t* afterStmts = get_afterStmts(); 37 38 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 39 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } 40 try { 41 *i = (*i)->accept( *this ); 42 } catch ( SemanticError &e ) { 43 errors.append( e ); 44 } 45 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 46 } 47 48 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } 49 if ( !errors.isEmpty() ) { throw errors; } 50 } 51 52 template< typename pass_type > 53 void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) { 54 SemanticError errors; 55 56 StmtList_t* beforeStmts = get_beforeStmts(); 57 StmtList_t* afterStmts = get_afterStmts(); 58 59 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 60 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } 61 try { 62 *i = (*i)->acceptMutator( *this ); 63 } catch ( SemanticError &e ) { 64 errors.append( e ); 65 } 66 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 67 } 68 69 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } 70 if ( !errors.isEmpty() ) { throw errors; } 71 } 72 73 template< typename pass_type > 74 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { 75 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 76 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 77 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 78 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 79 80 Statement *newStmt = maybeVisit( stmt, *this ); 81 82 StmtList_t* beforeStmts = get_beforeStmts(); 83 StmtList_t* afterStmts = get_afterStmts(); 84 85 if( empty(beforeStmts) && empty(afterStmts) ) { return newStmt; } 86 87 CompoundStmt *compound = new CompoundStmt( noLabels ); 88 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } 89 compound->get_kids().push_back( newStmt ); 90 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } 91 return compound; 92 } 93 94 template< typename pass_type > 95 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { 96 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 97 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 98 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 99 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 100 101 Statement *newStmt = maybeMutate( stmt, *this ); 102 103 StmtList_t* beforeStmts = get_beforeStmts(); 104 StmtList_t* afterStmts = get_afterStmts(); 105 106 if( empty(beforeStmts) && empty(afterStmts) ) { return newStmt; } 107 108 CompoundStmt *compound = new CompoundStmt( noLabels ); 109 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } 110 compound->get_kids().push_back( newStmt ); 111 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } 112 return compound; 113 } 114 115 116 117 template< typename pass_type > 118 void PassVisitor< pass_type >::visitExpression( Expression * expr ) { 119 if( !expr ) return; 120 121 auto env_ptr = get_env_ptr(); 122 if ( env_ptr && expr->get_env() ) { 123 *env_ptr = expr->get_env(); 124 } 125 // xxx - should env be cloned (or moved) onto the result of the mutate? 126 expr->accept( *this ); 127 } 128 129 template< typename pass_type > 130 Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) { 131 if( !expr ) return nullptr; 132 133 auto env_ptr = get_env_ptr(); 134 if ( env_ptr && expr->get_env() ) { 135 *env_ptr = expr->get_env(); 136 } 137 // xxx - should env be cloned (or moved) onto the result of the mutate? 138 return expr->acceptMutator( *this ); 139 } 140 141 142 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 8 #define MUTATE_BODY( type, node ) \ 9 call_premutate( node ); \ 10 Mutator::mutate( node ); \ 11 auto ret = call_postmutate< type * >( node ); \ 12 return ret; \ 13 14 15 143 16 144 17 template< typename pass_type > … … 193 66 194 67 template< typename pass_type > 195 CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {196 MUTATE_START( node );197 call_beginScope();198 199 mutateStatementList( node->get_kids() );200 201 call_endScope();202 MUTATE_END( CompoundStmt, node );203 }204 205 template< typename pass_type >206 68 void PassVisitor< pass_type >::visit( ExprStmt * node ) { 207 69 VISIT_BODY( node ); … … 209 71 210 72 template< typename pass_type > 211 Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {212 MUTATE_START( node );213 214 node->set_expr( mutateExpression( node->get_expr() ) );215 216 MUTATE_END( Statement, node );217 }218 219 template< typename pass_type >220 73 void PassVisitor< pass_type >::visit( AsmStmt * node ) { 221 74 VISIT_BODY( node ); … … 228 81 229 82 template< typename pass_type > 230 Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {231 MUTATE_START( node );232 233 node->set_condition( mutateExpression( node->get_condition() ) );234 node->set_thenPart ( mutateStatement ( node->get_thenPart() ) );235 node->set_elsePart ( mutateStatement ( node->get_elsePart() ) );236 237 MUTATE_END( Statement, node );238 }239 240 template< typename pass_type >241 83 void PassVisitor< pass_type >::visit( WhileStmt * node ) { 242 84 VISIT_BODY( node ); … … 244 86 245 87 template< typename pass_type > 246 Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {247 MUTATE_START( node );248 249 node->set_condition( mutateExpression( node->get_condition() ) );250 node->set_body( mutateStatement( node->get_body() ) );251 252 MUTATE_END( Statement, node );253 }254 255 256 template< typename pass_type >257 88 void PassVisitor< pass_type >::visit( ForStmt * node ) { 258 89 VISIT_BODY( node ); … … 260 91 261 92 template< typename pass_type > 262 Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {263 MUTATE_START( node );264 265 mutateAll( node->get_initialization(), *this );266 node->set_condition( mutateExpression( node->get_condition() ) );267 node->set_increment( mutateExpression( node->get_increment() ) );268 node->set_body( mutateStatement( node->get_body() ) );269 270 MUTATE_END( Statement, node );271 }272 273 template< typename pass_type >274 93 void PassVisitor< pass_type >::visit( SwitchStmt * node ) { 275 94 VISIT_BODY( node ); … … 277 96 278 97 template< typename pass_type > 279 Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {280 MUTATE_START( node );281 282 node->set_condition( mutateExpression( node->get_condition() ) );283 mutateStatementList( node->get_statements() );284 285 MUTATE_END( Statement, node );286 }287 288 template< typename pass_type >289 98 void PassVisitor< pass_type >::visit( CaseStmt * node ) { 290 99 VISIT_BODY( node ); … … 292 101 293 102 template< typename pass_type > 294 Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {295 MUTATE_START( node );296 297 node->set_condition( mutateExpression( node->get_condition() ) );298 mutateStatementList( node->get_statements() );299 300 MUTATE_END( Statement, node );301 }302 303 template< typename pass_type >304 103 void PassVisitor< pass_type >::visit( BranchStmt * node ) { 305 104 VISIT_BODY( node ); … … 312 111 313 112 template< typename pass_type > 314 Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {315 MUTATE_START( node );316 317 node->set_expr( mutateExpression( node->get_expr() ) );318 319 MUTATE_END( Statement, node );320 }321 322 template< typename pass_type >323 113 void PassVisitor< pass_type >::visit( TryStmt * node ) { 324 114 VISIT_BODY( node ); … … 326 116 327 117 template< typename pass_type > 328 Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {329 MUTATE_START( node );330 331 node->set_block( maybeMutate( node->get_block(), *this ) );332 mutateAll( node->get_catchers(), *this );333 334 MUTATE_END( Statement, node );335 }336 337 template< typename pass_type >338 118 void PassVisitor< pass_type >::visit( CatchStmt * node ) { 339 119 VISIT_BODY( node ); … … 341 121 342 122 template< typename pass_type > 343 Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {344 MUTATE_START( node );345 346 node->set_body( mutateStatement( node->get_body() ) );347 node->set_decl( maybeMutate( node->get_decl(), *this ) );348 349 MUTATE_END( Statement, node );350 }351 352 template< typename pass_type >353 123 void PassVisitor< pass_type >::visit( FinallyStmt * node ) { 354 124 VISIT_BODY( node ); … … 381 151 382 152 template< typename pass_type > 383 Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {384 MUTATE_START( node );385 386 for ( auto& expr : node->get_args() ) {387 expr = mutateExpression( expr );388 }389 390 MUTATE_END( Expression, node );391 }392 393 template< typename pass_type >394 153 void PassVisitor< pass_type >::visit( NameExpr * node ) { 395 154 VISIT_BODY( node ); … … 542 301 543 302 template< typename pass_type > 544 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {545 MUTATE_START( node );546 547 // don't want statements from outer CompoundStmts to be added to this StmtExpr548 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );549 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );550 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );551 552 Mutator::mutate( node );553 554 MUTATE_END( Expression, node );555 }556 557 template< typename pass_type >558 303 void PassVisitor< pass_type >::visit( UniqueExpr * node ) { 559 304 VISIT_BODY( node ); … … 643 388 void PassVisitor< pass_type >::visit( SingleInit * node ) { 644 389 VISIT_BODY( node ); 645 }646 647 template< typename pass_type >648 Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {649 MUTATE_START( node );650 651 node->set_value( mutateExpression( node->get_value() ) );652 653 MUTATE_END( Initializer, node );654 390 } 655 391 … … 722 458 723 459 template< typename pass_type > 460 CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) { 461 MUTATE_BODY( CompoundStmt, node ); 462 } 463 464 template< typename pass_type > 465 Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) { 466 MUTATE_BODY( Statement, node ); 467 } 468 469 template< typename pass_type > 724 470 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { 725 471 MUTATE_BODY( Statement, node ); … … 727 473 728 474 template< typename pass_type > 475 Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) { 476 MUTATE_BODY( Statement, node ); 477 } 478 479 template< typename pass_type > 480 Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) { 481 MUTATE_BODY( Statement, node ); 482 } 483 484 template< typename pass_type > 485 Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) { 486 MUTATE_BODY( Statement, node ); 487 } 488 489 template< typename pass_type > 490 Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) { 491 MUTATE_BODY( Statement, node ); 492 } 493 494 template< typename pass_type > 495 Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) { 496 MUTATE_BODY( Statement, node ); 497 } 498 499 template< typename pass_type > 729 500 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { 501 MUTATE_BODY( Statement, node ); 502 } 503 504 template< typename pass_type > 505 Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) { 506 MUTATE_BODY( Statement, node ); 507 } 508 509 template< typename pass_type > 510 Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) { 511 MUTATE_BODY( Statement, node ); 512 } 513 514 template< typename pass_type > 515 Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) { 730 516 MUTATE_BODY( Statement, node ); 731 517 } … … 757 543 758 544 template< typename pass_type > 545 Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) { 546 MUTATE_BODY( Expression, node ); 547 } 548 549 template< typename pass_type > 759 550 Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) { 760 551 MUTATE_BODY( Expression, node ); … … 902 693 903 694 template< typename pass_type > 695 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { 696 MUTATE_BODY( Expression, node ); 697 } 698 699 template< typename pass_type > 904 700 Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) { 905 701 MUTATE_BODY( Expression, node ); … … 984 780 Type * PassVisitor< pass_type >::mutate( OneType * node ) { 985 781 MUTATE_BODY( Type, node ); 782 } 783 784 template< typename pass_type > 785 Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) { 786 MUTATE_BODY( Initializer, node ); 986 787 } 987 788 -
src/Common/utility.h
r676cc8c r4a58895 244 244 ValueGuard(T& inRef) : old(inRef), ref(inRef) {} 245 245 ~ValueGuard() { ref = old; } 246 };247 248 template< typename T >249 struct ValueGuardPtr {250 T old;251 T* ref;252 253 ValueGuardPtr(T * inRef) : old( inRef ? *inRef : T() ), ref(inRef) {}254 ~ValueGuardPtr() { if( ref ) *ref = old; }255 };256 257 template< typename T >258 struct ValueGuardPtr< std::list< T > > {259 std::list< T > old;260 std::list< T >* ref;261 262 ValueGuardPtr( std::list< T > * inRef) : old(), ref(inRef) {263 if( ref ) { swap( *ref, old ); }264 }265 ~ValueGuardPtr() { if( ref ) { swap( *ref, old ); } }266 246 }; 267 247 -
src/InitTweak/FixInit.cc
r676cc8c r4a58895 20 20 #include <unordered_map> 21 21 #include <unordered_set> 22 23 22 #include "InitTweak.h" 24 23 #include "GenInit.h" 25 24 #include "FixInit.h" 26 25 #include "FixGlobalInit.h" 27 #include "CodeGen/GenType.h" // for warning/error messages28 #include "Common/PassVisitor.h"29 #include "GenPoly/DeclMutator.h"30 #include "GenPoly/PolyMutator.h"31 26 #include "ResolvExpr/Resolver.h" 32 27 #include "ResolvExpr/typeops.h" 33 #include "Sy mTab/Autogen.h"34 #include "Sy mTab/Indexer.h"35 #include "SynTree/ AddStmtVisitor.h"28 #include "SynTree/Declaration.h" 29 #include "SynTree/Type.h" 30 #include "SynTree/Expression.h" 36 31 #include "SynTree/Attribute.h" 37 #include "SynTree/Declaration.h" 38 #include "SynTree/Expression.h" 32 #include "SynTree/Statement.h" 39 33 #include "SynTree/Initializer.h" 40 34 #include "SynTree/Mutator.h" 41 #include "SynTree/Statement.h" 42 #include "SynTree/Type.h" 35 #include "SymTab/Indexer.h" 36 #include "SymTab/Autogen.h" 37 #include "GenPoly/PolyMutator.h" 38 #include "GenPoly/DeclMutator.h" 39 #include "SynTree/AddStmtVisitor.h" 40 #include "CodeGen/GenType.h" // for warning/error messages 43 41 #include "Tuples/Tuples.h" 44 42 … … 56 54 typedef std::unordered_map< int, int > UnqCount; 57 55 58 class InsertImplicitCalls {56 class InsertImplicitCalls final : public GenPoly::PolyMutator { 59 57 public: 60 58 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which … … 63 61 64 62 InsertImplicitCalls( EnvMap & envMap ) : envMap( envMap ) {} 65 66 Expression * postmutate( ApplicationExpr * appExpr ); 67 void premutate( StmtExpr * stmtExpr ); 63 typedef GenPoly::PolyMutator Parent; 64 using Parent::mutate; 65 virtual Expression * mutate( ApplicationExpr * appExpr ) override; 66 virtual Expression * mutate( StmtExpr * stmtExpr ) override; 68 67 69 68 // collects environments for relevant nodes 70 69 EnvMap & envMap; 71 TypeSubstitution * env; //Magically populated by the PassVisitor72 70 }; 73 71 … … 302 300 namespace { 303 301 void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit, EnvMap & envMap ) { 304 PassVisitor<InsertImplicitCalls>inserter( envMap );302 InsertImplicitCalls inserter( envMap ); 305 303 mutateAll( translationUnit, inserter ); 306 304 } … … 352 350 } 353 351 354 Expression * InsertImplicitCalls::postmutate( ApplicationExpr * appExpr ) { 352 Expression * InsertImplicitCalls::mutate( ApplicationExpr * appExpr ) { 353 appExpr = dynamic_cast< ApplicationExpr * >( Parent::mutate( appExpr ) ); 355 354 assert( appExpr ); 356 355 … … 394 393 } 395 394 396 void InsertImplicitCalls::premutate( StmtExpr * stmtExpr ) {395 Expression * InsertImplicitCalls::mutate( StmtExpr * stmtExpr ) { 397 396 assert( env ); 398 397 envMap[stmtExpr] = env; 398 return Parent::mutate( stmtExpr ); 399 399 } 400 400
Note:
See TracChangeset
for help on using the changeset viewer.