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