Changes in src/Common/PassVisitor.impl.h [7b13aeb:2a7b3ca]
- File:
-
- 1 edited
-
src/Common/PassVisitor.impl.h (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
r7b13aeb r2a7b3ca 1 1 #pragma once 2 2 3 #define VISIT_START( node ) \ 4 call_previsit( node ); \ 5 if( visit_children() ) { \ 6 7 #define VISIT_END( node ) \ 8 } \ 9 return call_postvisit( node ); \ 10 11 #define MUTATE_START( node ) \ 12 call_premutate( node ); \ 13 if( visit_children() ) { \ 3 #define VISIT_START( node ) \ 4 __attribute__((unused)) \ 5 const auto & guard = init_guard(); \ 6 bool visit_children = true; \ 7 set_visit_children( visit_children ); \ 8 call_previsit( node ); \ 9 if( visit_children ) { \ 10 11 #define VISIT_END( node ) \ 12 } \ 13 call_postvisit( node ); \ 14 15 #define MUTATE_START( node ) \ 16 __attribute__((unused)) \ 17 const auto & guard = init_guard(); \ 18 bool visit_children = true; \ 19 set_visit_children( visit_children ); \ 20 call_premutate( node ); \ 21 if( visit_children ) { \ 14 22 15 23 #define MUTATE_END( type, node ) \ … … 18 26 19 27 20 #define VISIT_BODY( node ) \21 VISIT_START( node ); \22 Visitor::visit( node ); \23 VISIT_END( node ); \28 #define VISIT_BODY( node ) \ 29 VISIT_START( node ); \ 30 Visitor::visit( node ); \ 31 VISIT_END( node ); \ 24 32 25 33 … … 36 44 } 37 45 38 typedef std::list< Statement * > StmtList_t; 39 40 template< typename pass_type > 41 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) { 46 typedef std::list< Statement * > StmtList_t; 47 typedef std::list< Declaration * > DeclList_t; 48 49 template<typename iterator_t> 50 static inline void splice( iterator_t it, DeclList_t * decls ) { 51 std::transform( 52 decls->begin(), 53 decls->end(), 54 it, 55 [](Declaration * decl) -> auto { 56 return new DeclStmt( noLabels, decl ); 57 } 58 ); 59 decls->clear(); 60 } 61 62 template< typename pass_type > 63 static inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) { 64 65 DeclList_t* beforeDecls = visitor.get_beforeDecls(); 66 DeclList_t* afterDecls = visitor.get_afterDecls(); 67 68 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 69 // splice in new declarations after previous decl 70 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } 71 72 if ( i == decls.end() ) break; 73 74 // run mutator on declaration 75 maybeAccept( *i, visitor ); 76 77 // splice in new declarations before current decl 78 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 79 } 80 } 81 82 template< typename pass_type > 83 static inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) { 84 85 DeclList_t* beforeDecls = mutator.get_beforeDecls(); 86 DeclList_t* afterDecls = mutator.get_afterDecls(); 87 88 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 89 // splice in new declarations after previous decl 90 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } 91 92 if ( i == decls.end() ) break; 93 94 // run mutator on declaration 95 *i = maybeMutate( *i, mutator ); 96 97 // splice in new declarations before current decl 98 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 99 } 100 } 101 102 template< typename pass_type > 103 template< typename func_t > 104 void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) { 42 105 SemanticError errors; 106 107 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 108 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() ); 109 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () ); 110 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 111 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); 43 112 44 113 StmtList_t* beforeStmts = get_beforeStmts(); 45 114 StmtList_t* afterStmts = get_afterStmts(); 115 DeclList_t* beforeDecls = get_beforeDecls(); 116 DeclList_t* afterDecls = get_afterDecls(); 46 117 47 118 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 119 120 if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); } 48 121 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } 122 49 123 try { 50 (*i)->accept( *this ); 124 func( *i ); 125 assert(( empty( beforeStmts ) && empty( afterStmts )) 126 || ( empty( beforeDecls ) && empty( afterDecls )) ); 127 51 128 } catch ( SemanticError &e ) { 52 129 errors.append( e ); 53 130 } 131 132 if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); } 54 133 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 55 134 } 56 135 136 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); } 57 137 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } 58 138 if ( !errors.isEmpty() ) { throw errors; } … … 60 140 61 141 template< typename pass_type > 142 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) { 143 handleStatementList( statements, [this]( Statement * stmt) { 144 stmt->accept( *this ); 145 }); 146 } 147 148 template< typename pass_type > 62 149 void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) { 63 SemanticError errors; 150 handleStatementList( statements, [this]( Statement *& stmt) { 151 stmt = stmt->acceptMutator( *this ); 152 }); 153 } 154 155 156 template< typename pass_type > 157 template< typename func_t > 158 Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) { 159 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 160 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () ); 161 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 162 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); 163 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() ); 164 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () ); 165 166 Statement *newStmt = func( stmt ); 64 167 65 168 StmtList_t* beforeStmts = get_beforeStmts(); 66 169 StmtList_t* afterStmts = get_afterStmts(); 67 68 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 69 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } 70 try { 71 *i = (*i)->acceptMutator( *this ); 72 } catch ( SemanticError &e ) { 73 errors.append( e ); 74 } 75 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 76 } 77 78 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } 79 if ( !errors.isEmpty() ) { throw errors; } 80 } 81 82 template< typename pass_type > 83 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { 84 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 85 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 86 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 87 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 88 89 maybeAccept( stmt, *this ); 90 91 StmtList_t* beforeStmts = get_beforeStmts(); 92 StmtList_t* afterStmts = get_afterStmts(); 93 94 if( empty(beforeStmts) && empty(afterStmts) ) { return stmt; } 170 DeclList_t* beforeDecls = get_beforeDecls(); 171 DeclList_t* afterDecls = get_afterDecls(); 172 173 if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; } 174 assert(( empty( beforeStmts ) && empty( afterStmts )) 175 || ( empty( beforeDecls ) && empty( afterDecls )) ); 95 176 96 177 CompoundStmt *compound = new CompoundStmt( noLabels ); 178 if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); } 97 179 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } 98 compound->get_kids().push_back( stmt ); 180 compound->get_kids().push_back( newStmt ); 181 if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); } 99 182 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } 100 183 return compound; … … 102 185 103 186 template< typename pass_type > 187 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { 188 return handleStatement( stmt, [this]( Statement * stmt ) { 189 maybeAccept( stmt, *this ); 190 return stmt; 191 }); 192 } 193 194 template< typename pass_type > 104 195 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { 105 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 106 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 107 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 108 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 109 110 Statement *newStmt = maybeMutate( stmt, *this ); 111 112 StmtList_t* beforeStmts = get_beforeStmts(); 113 StmtList_t* afterStmts = get_afterStmts(); 114 115 if( empty(beforeStmts) && empty(afterStmts) ) { return newStmt; } 116 117 CompoundStmt *compound = new CompoundStmt( noLabels ); 118 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } 119 compound->get_kids().push_back( newStmt ); 120 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } 121 return compound; 122 } 123 124 125 126 template< typename pass_type > 127 void PassVisitor< pass_type >::visitExpression( Expression * expr ) { 128 if( !expr ) return; 196 return handleStatement( stmt, [this]( Statement * stmt ) { 197 return maybeMutate( stmt, *this ); 198 }); 199 } 200 201 template< typename pass_type > 202 template< typename func_t > 203 Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) { 204 if( !expr ) return nullptr; 129 205 130 206 auto env_ptr = get_env_ptr(); … … 132 208 *env_ptr = expr->get_env(); 133 209 } 134 // xxx - should env be cloned (or moved) onto the result of the mutate? 135 expr->accept( *this ); 210 211 // should env be cloned (or moved) onto the result of the mutate? 212 return func( expr ); 213 } 214 215 template< typename pass_type > 216 Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) { 217 return handleExpression(expr, [this]( Expression * expr ) { 218 expr->accept( *this ); 219 return expr; 220 }); 136 221 } 137 222 138 223 template< typename pass_type > 139 224 Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) { 140 if( !expr ) return nullptr; 141 142 auto env_ptr = get_env_ptr(); 143 if ( env_ptr && expr->get_env() ) { 144 *env_ptr = expr->get_env(); 145 } 146 // xxx - should env be cloned (or moved) onto the result of the mutate? 147 return expr->acceptMutator( *this ); 148 } 149 225 return handleExpression(expr, [this]( Expression * expr ) { 226 return expr->acceptMutator( *this ); 227 }); 228 } 150 229 151 230 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ … … 153 232 template< typename pass_type > 154 233 void PassVisitor< pass_type >::visit( ObjectDecl * node ) { 155 VISIT_BODY( node ); 234 VISIT_BODY( node ); 156 235 } 157 236 158 237 template< typename pass_type > 159 238 void PassVisitor< pass_type >::visit( FunctionDecl * node ) { 160 VISIT_BODY( node ); 239 VISIT_BODY( node ); 161 240 } 162 241 163 242 template< typename pass_type > 164 243 void PassVisitor< pass_type >::visit( StructDecl * node ) { 165 VISIT_BODY( node ); 244 VISIT_BODY( node ); 166 245 } 167 246 168 247 template< typename pass_type > 169 248 void PassVisitor< pass_type >::visit( UnionDecl * node ) { 170 VISIT_BODY( node ); 249 VISIT_BODY( node ); 171 250 } 172 251 173 252 template< typename pass_type > 174 253 void PassVisitor< pass_type >::visit( EnumDecl * node ) { 175 VISIT_BODY( node ); 254 VISIT_BODY( node ); 176 255 } 177 256 178 257 template< typename pass_type > 179 258 void PassVisitor< pass_type >::visit( TraitDecl * node ) { 180 VISIT_BODY( node ); 259 VISIT_BODY( node ); 181 260 } 182 261 183 262 template< typename pass_type > 184 263 void PassVisitor< pass_type >::visit( TypeDecl * node ) { 185 VISIT_BODY( node ); 264 VISIT_BODY( node ); 186 265 } 187 266 188 267 template< typename pass_type > 189 268 void PassVisitor< pass_type >::visit( TypedefDecl * node ) { 190 VISIT_BODY( node ); 269 VISIT_BODY( node ); 191 270 } 192 271 193 272 template< typename pass_type > 194 273 void PassVisitor< pass_type >::visit( AsmDecl * node ) { 195 VISIT_BODY( node ); 274 VISIT_BODY( node ); 196 275 } 197 276 … … 225 304 void PassVisitor< pass_type >::visit( ExprStmt * node ) { 226 305 VISIT_START( node ); 227 call_beginScope();228 306 229 307 visitExpression( node->get_expr() ); 230 308 231 call_endScope();232 309 VISIT_END( node ); 233 310 } … … 242 319 } 243 320 321 //-------------------------------------------------------------------------- 322 // AsmStmt 244 323 template< typename pass_type > 245 324 void PassVisitor< pass_type >::visit( AsmStmt * node ) { 246 VISIT_BODY( node ); 325 VISIT_BODY( node ); 326 } 327 328 template< typename pass_type > 329 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { 330 MUTATE_BODY( Statement, node ); 247 331 } 248 332 … … 251 335 template< typename pass_type > 252 336 void PassVisitor< pass_type >::visit( IfStmt * node ) { 253 VISIT_START( node ); 337 VISIT_START( node ); 254 338 255 339 visitExpression( node->get_condition() ); … … 262 346 template< typename pass_type > 263 347 Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) { 264 MUTATE_START( node ); 348 MUTATE_START( node ); 265 349 266 350 node->set_condition( mutateExpression( node->get_condition() ) ); … … 275 359 template< typename pass_type > 276 360 void PassVisitor< pass_type >::visit( WhileStmt * node ) { 277 VISIT_START( node ); 361 VISIT_START( node ); 278 362 279 363 visitExpression( node->get_condition() ); … … 285 369 template< typename pass_type > 286 370 Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) { 287 MUTATE_START( node ); 371 MUTATE_START( node ); 288 372 289 373 node->set_condition( mutateExpression( node->get_condition() ) ); … … 294 378 295 379 //-------------------------------------------------------------------------- 296 // WhileStmt380 // ForStmt 297 381 template< typename pass_type > 298 382 void PassVisitor< pass_type >::visit( ForStmt * node ) { 299 VISIT_START( node ); 383 VISIT_START( node ); 300 384 301 385 acceptAll( node->get_initialization(), *this ); … … 309 393 template< typename pass_type > 310 394 Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) { 311 MUTATE_START( node ); 395 MUTATE_START( node ); 312 396 313 397 mutateAll( node->get_initialization(), *this ); … … 323 407 template< typename pass_type > 324 408 void PassVisitor< pass_type >::visit( SwitchStmt * node ) { 325 VISIT_START( node ); 409 VISIT_START( node ); 326 410 327 411 visitExpression( node->get_condition() ); … … 333 417 template< typename pass_type > 334 418 Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) { 335 MUTATE_START( node ); 336 419 MUTATE_START( node ); 420 337 421 node->set_condition( mutateExpression( node->get_condition() ) ); 338 422 mutateStatementList( node->get_statements() ); 339 423 340 424 MUTATE_END( Statement, node ); 341 425 } 342 426 343 427 //-------------------------------------------------------------------------- 344 // SwitchStmt428 // CaseStmt 345 429 template< typename pass_type > 346 430 void PassVisitor< pass_type >::visit( CaseStmt * node ) { 347 VISIT_START( node ); 348 431 VISIT_START( node ); 432 349 433 visitExpression( node->get_condition() ); 350 434 visitStatementList( node->get_statements() ); 351 435 352 436 VISIT_END( node ); 353 437 } … … 355 439 template< typename pass_type > 356 440 Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) { 357 MUTATE_START( node ); 358 441 MUTATE_START( node ); 442 359 443 node->set_condition( mutateExpression( node->get_condition() ) ); 360 444 mutateStatementList( node->get_statements() ); 361 445 362 446 MUTATE_END( Statement, node ); 363 447 } 364 448 449 //-------------------------------------------------------------------------- 450 // BranchStmt 365 451 template< typename pass_type > 366 452 void PassVisitor< pass_type >::visit( BranchStmt * node ) { 367 VISIT_BODY( node ); 453 VISIT_BODY( node ); 454 } 455 456 template< typename pass_type > 457 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { 458 MUTATE_BODY( Statement, node ); 368 459 } 369 460 … … 386 477 387 478 MUTATE_END( Statement, node ); 479 } 480 481 //-------------------------------------------------------------------------- 482 // ThrowStmt 483 484 template< typename pass_type > 485 void PassVisitor< pass_type >::visit( ThrowStmt * node ) { 486 VISIT_BODY( node ); 487 } 488 489 template< typename pass_type > 490 Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) { 491 MUTATE_BODY( Statement, node ); 388 492 } 389 493 … … 396 500 maybeAccept( node->get_block(), *this ); 397 501 acceptAll( node->get_catchers(), *this ); 502 maybeAccept( node->get_finally(), *this ); 398 503 399 504 VISIT_END( node ); … … 406 511 node->set_block( maybeMutate( node->get_block(), *this ) ); 407 512 mutateAll( node->get_catchers(), *this ); 408 513 node->set_finally( maybeMutate( node->get_finally(), *this ) ); 514 409 515 MUTATE_END( Statement, node ); 410 516 } … … 416 522 VISIT_START( node ); 417 523 524 maybeAccept( node->get_decl(), *this ); 525 node->set_cond( visitExpression( node->get_cond() ) ); 418 526 node->set_body( visitStatement( node->get_body() ) ); 419 maybeAccept( node->get_decl(), *this );420 527 421 528 VISIT_END( node ); … … 425 532 Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) { 426 533 MUTATE_START( node ); 427 428 node->set_body( mutateStatement( node->get_body() ) ); 429 node->set_decl( maybeMutate( node->get_decl(), *this ) ); 430 534 535 node->set_decl( maybeMutate( node->get_decl(), *this ) ); 536 node->set_cond( mutateExpression( node->get_cond() ) ); 537 node->set_body( mutateStatement( node->get_body() ) ); 538 431 539 MUTATE_END( Statement, node ); 432 540 } … … 434 542 template< typename pass_type > 435 543 void PassVisitor< pass_type >::visit( FinallyStmt * node ) { 436 VISIT_BODY( node ); 544 VISIT_BODY( node ); 437 545 } 438 546 439 547 template< typename pass_type > 440 548 void PassVisitor< pass_type >::visit( NullStmt * node ) { 441 VISIT_BODY( node ); 549 VISIT_BODY( node ); 442 550 } 443 551 444 552 template< typename pass_type > 445 553 void PassVisitor< pass_type >::visit( DeclStmt * node ) { 446 VISIT_BODY( node ); 554 VISIT_BODY( node ); 447 555 } 448 556 449 557 template< typename pass_type > 450 558 void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) { 451 VISIT_BODY( node ); 559 VISIT_BODY( node ); 452 560 } 453 561 454 562 template< typename pass_type > 455 563 void PassVisitor< pass_type >::visit( ApplicationExpr * node ) { 456 VISIT_BODY( node ); 564 VISIT_BODY( node ); 457 565 } 458 566 … … 462 570 void PassVisitor< pass_type >::visit( UntypedExpr * node ) { 463 571 VISIT_START( node ); 572 573 // maybeAccept( node->get_env(), *this ); 574 maybeAccept( node->get_result(), *this ); 464 575 465 576 for ( auto expr : node->get_args() ) { … … 474 585 MUTATE_START( node ); 475 586 587 node->set_env( maybeMutate( node->get_env(), *this ) ); 588 node->set_result( maybeMutate( node->get_result(), *this ) ); 589 476 590 for ( auto& expr : node->get_args() ) { 477 591 expr = mutateExpression( expr ); … … 483 597 template< typename pass_type > 484 598 void PassVisitor< pass_type >::visit( NameExpr * node ) { 485 VISIT_BODY( node ); 599 VISIT_BODY( node ); 486 600 } 487 601 488 602 template< typename pass_type > 489 603 void PassVisitor< pass_type >::visit( CastExpr * node ) { 490 VISIT_BODY( node ); 604 VISIT_BODY( node ); 491 605 } 492 606 493 607 template< typename pass_type > 494 608 void PassVisitor< pass_type >::visit( AddressExpr * node ) { 495 VISIT_BODY( node ); 609 VISIT_BODY( node ); 496 610 } 497 611 498 612 template< typename pass_type > 499 613 void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) { 500 VISIT_BODY( node ); 614 VISIT_BODY( node ); 501 615 } 502 616 503 617 template< typename pass_type > 504 618 void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) { 505 VISIT_BODY( node ); 619 VISIT_BODY( node ); 506 620 } 507 621 508 622 template< typename pass_type > 509 623 void PassVisitor< pass_type >::visit( MemberExpr * node ) { 510 VISIT_BODY( node ); 624 VISIT_BODY( node ); 511 625 } 512 626 513 627 template< typename pass_type > 514 628 void PassVisitor< pass_type >::visit( VariableExpr * node ) { 515 VISIT_BODY( node ); 629 VISIT_BODY( node ); 516 630 } 517 631 518 632 template< typename pass_type > 519 633 void PassVisitor< pass_type >::visit( ConstantExpr * node ) { 520 VISIT_BODY( node ); 634 VISIT_BODY( node ); 521 635 } 522 636 523 637 template< typename pass_type > 524 638 void PassVisitor< pass_type >::visit( SizeofExpr * node ) { 525 VISIT_BODY( node ); 639 VISIT_BODY( node ); 526 640 } 527 641 528 642 template< typename pass_type > 529 643 void PassVisitor< pass_type >::visit( AlignofExpr * node ) { 530 VISIT_BODY( node ); 644 VISIT_BODY( node ); 531 645 } 532 646 533 647 template< typename pass_type > 534 648 void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) { 535 VISIT_BODY( node ); 649 VISIT_BODY( node ); 536 650 } 537 651 538 652 template< typename pass_type > 539 653 void PassVisitor< pass_type >::visit( OffsetofExpr * node ) { 540 VISIT_BODY( node ); 654 VISIT_BODY( node ); 541 655 } 542 656 543 657 template< typename pass_type > 544 658 void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) { 545 VISIT_BODY( node ); 659 VISIT_BODY( node ); 546 660 } 547 661 548 662 template< typename pass_type > 549 663 void PassVisitor< pass_type >::visit( AttrExpr * node ) { 550 VISIT_BODY( node ); 664 VISIT_BODY( node ); 551 665 } 552 666 553 667 template< typename pass_type > 554 668 void PassVisitor< pass_type >::visit( LogicalExpr * node ) { 555 VISIT_BODY( node ); 669 VISIT_BODY( node ); 556 670 } 557 671 558 672 template< typename pass_type > 559 673 void PassVisitor< pass_type >::visit( ConditionalExpr * node ) { 560 VISIT_BODY( node ); 674 VISIT_BODY( node ); 561 675 } 562 676 563 677 template< typename pass_type > 564 678 void PassVisitor< pass_type >::visit( CommaExpr * node ) { 565 VISIT_BODY( node ); 679 VISIT_BODY( node ); 566 680 } 567 681 568 682 template< typename pass_type > 569 683 void PassVisitor< pass_type >::visit( TypeExpr * node ) { 570 VISIT_BODY( node ); 684 VISIT_BODY( node ); 571 685 } 572 686 573 687 template< typename pass_type > 574 688 void PassVisitor< pass_type >::visit( AsmExpr * node ) { 575 VISIT_BODY( node ); 689 VISIT_BODY( node ); 576 690 } 577 691 578 692 template< typename pass_type > 579 693 void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) { 580 VISIT_BODY( node ); 694 VISIT_BODY( node ); 581 695 } 582 696 583 697 template< typename pass_type > 584 698 void PassVisitor< pass_type >::visit( ConstructorExpr * node ) { 585 VISIT_BODY( node ); 699 VISIT_BODY( node ); 586 700 } 587 701 588 702 template< typename pass_type > 589 703 void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) { 590 VISIT_BODY( node ); 591 } 592 593 template< typename pass_type > 594 void PassVisitor< pass_type >::visit( UntypedValofExpr * node ) { 595 VISIT_BODY( node ); 704 VISIT_BODY( node ); 596 705 } 597 706 598 707 template< typename pass_type > 599 708 void PassVisitor< pass_type >::visit( RangeExpr * node ) { 600 VISIT_BODY( node ); 709 VISIT_BODY( node ); 601 710 } 602 711 603 712 template< typename pass_type > 604 713 void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) { 605 VISIT_BODY( node ); 714 VISIT_BODY( node ); 606 715 } 607 716 608 717 template< typename pass_type > 609 718 void PassVisitor< pass_type >::visit( TupleExpr * node ) { 610 VISIT_BODY( node ); 719 VISIT_BODY( node ); 611 720 } 612 721 613 722 template< typename pass_type > 614 723 void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) { 615 VISIT_BODY( node ); 616 } 617 618 template< typename pass_type > 619 void PassVisitor< pass_type >::visit( MemberTupleExpr * node ) { 620 VISIT_BODY( node ); 724 VISIT_BODY( node ); 621 725 } 622 726 623 727 template< typename pass_type > 624 728 void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) { 625 VISIT_BODY( node ); 729 VISIT_BODY( node ); 626 730 } 627 731 … … 645 749 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { 646 750 MUTATE_START( node ); 647 751 648 752 // don't want statements from outer CompoundStmts to be added to this StmtExpr 649 753 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); … … 658 762 template< typename pass_type > 659 763 void PassVisitor< pass_type >::visit( UniqueExpr * node ) { 660 VISIT_BODY( node ); 764 VISIT_BODY( node ); 661 765 } 662 766 663 767 template< typename pass_type > 664 768 void PassVisitor< pass_type >::visit( VoidType * node ) { 665 VISIT_BODY( node ); 769 VISIT_BODY( node ); 666 770 } 667 771 668 772 template< typename pass_type > 669 773 void PassVisitor< pass_type >::visit( BasicType * node ) { 670 VISIT_BODY( node ); 774 VISIT_BODY( node ); 671 775 } 672 776 673 777 template< typename pass_type > 674 778 void PassVisitor< pass_type >::visit( PointerType * node ) { 675 VISIT_BODY( node ); 779 VISIT_BODY( node ); 676 780 } 677 781 678 782 template< typename pass_type > 679 783 void PassVisitor< pass_type >::visit( ArrayType * node ) { 680 VISIT_BODY( node ); 784 VISIT_BODY( node ); 681 785 } 682 786 683 787 template< typename pass_type > 684 788 void PassVisitor< pass_type >::visit( FunctionType * node ) { 685 VISIT_BODY( node ); 789 VISIT_BODY( node ); 686 790 } 687 791 688 792 template< typename pass_type > 689 793 void PassVisitor< pass_type >::visit( StructInstType * node ) { 690 VISIT_BODY( node ); 794 VISIT_BODY( node ); 691 795 } 692 796 693 797 template< typename pass_type > 694 798 void PassVisitor< pass_type >::visit( UnionInstType * node ) { 695 VISIT_BODY( node ); 799 VISIT_BODY( node ); 696 800 } 697 801 698 802 template< typename pass_type > 699 803 void PassVisitor< pass_type >::visit( EnumInstType * node ) { 700 VISIT_BODY( node ); 804 VISIT_BODY( node ); 701 805 } 702 806 703 807 template< typename pass_type > 704 808 void PassVisitor< pass_type >::visit( TraitInstType * node ) { 705 VISIT_BODY( node ); 809 VISIT_BODY( node ); 706 810 } 707 811 708 812 template< typename pass_type > 709 813 void PassVisitor< pass_type >::visit( TypeInstType * node ) { 710 VISIT_BODY( node ); 814 VISIT_BODY( node ); 711 815 } 712 816 713 817 template< typename pass_type > 714 818 void PassVisitor< pass_type >::visit( TupleType * node ) { 715 VISIT_BODY( node ); 819 VISIT_BODY( node ); 716 820 } 717 821 718 822 template< typename pass_type > 719 823 void PassVisitor< pass_type >::visit( TypeofType * node ) { 720 VISIT_BODY( node ); 824 VISIT_BODY( node ); 721 825 } 722 826 723 827 template< typename pass_type > 724 828 void PassVisitor< pass_type >::visit( AttrType * node ) { 725 VISIT_BODY( node ); 829 VISIT_BODY( node ); 726 830 } 727 831 728 832 template< typename pass_type > 729 833 void PassVisitor< pass_type >::visit( VarArgsType * node ) { 730 VISIT_BODY( node ); 834 VISIT_BODY( node ); 731 835 } 732 836 733 837 template< typename pass_type > 734 838 void PassVisitor< pass_type >::visit( ZeroType * node ) { 735 VISIT_BODY( node ); 839 VISIT_BODY( node ); 736 840 } 737 841 738 842 template< typename pass_type > 739 843 void PassVisitor< pass_type >::visit( OneType * node ) { 740 VISIT_BODY( node ); 844 VISIT_BODY( node ); 741 845 } 742 846 … … 763 867 template< typename pass_type > 764 868 void PassVisitor< pass_type >::visit( ListInit * node ) { 765 VISIT_BODY( node ); 869 VISIT_BODY( node ); 766 870 } 767 871 768 872 template< typename pass_type > 769 873 void PassVisitor< pass_type >::visit( ConstructorInit * node ) { 770 VISIT_BODY( node ); 874 VISIT_BODY( node ); 771 875 } 772 876 773 877 template< typename pass_type > 774 878 void PassVisitor< pass_type >::visit( Subrange * node ) { 775 VISIT_BODY( node ); 879 VISIT_BODY( node ); 776 880 } 777 881 778 882 template< typename pass_type > 779 883 void PassVisitor< pass_type >::visit( Constant * node ) { 780 VISIT_BODY( node ); 884 VISIT_BODY( node ); 781 885 } 782 886 … … 829 933 830 934 template< typename pass_type > 831 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {832 MUTATE_BODY( Statement, node );833 }834 835 template< typename pass_type >836 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {837 MUTATE_BODY( Statement, node );838 }839 840 template< typename pass_type >841 935 Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) { 842 936 MUTATE_BODY( Statement, node ); … … 974 1068 975 1069 template< typename pass_type > 976 Expression * PassVisitor< pass_type >::mutate( UntypedValofExpr * node ) {977 MUTATE_BODY( Expression, node );978 }979 980 template< typename pass_type >981 1070 Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) { 982 1071 MUTATE_BODY( Expression, node ); … … 995 1084 template< typename pass_type > 996 1085 Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) { 997 MUTATE_BODY( Expression, node );998 }999 1000 template< typename pass_type >1001 Expression * PassVisitor< pass_type >::mutate( MemberTupleExpr * node ) {1002 1086 MUTATE_BODY( Expression, node ); 1003 1087 }
Note:
See TracChangeset
for help on using the changeset viewer.