Changes in src/Common/PassVisitor.impl.h [33a25f9:522363e]
- File:
-
- 1 edited
-
src/Common/PassVisitor.impl.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
r33a25f9 r522363e 183 183 184 184 } catch ( SemanticError &e ) { 185 e.set_location( (*i)->location );186 185 errors.append( e ); 187 186 } … … 293 292 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 294 293 295 // A NOTE ON THE ORDER OF TRAVERSAL296 //297 // Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is298 // no such thing as a recursive type or typedef.299 //300 // typedef struct { T *x; } T; // never allowed301 //302 // for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the303 // members are traversed, and then the complete type should be added (assuming the type is completed by this particular304 // declaration).305 //306 // struct T { struct T *x; }; // allowed307 //308 // It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that309 // traversal may modify the definition of the type and these modifications should be visible when the symbol table is310 // queried later in this pass.311 //312 // TODO: figure out whether recursive contexts are sensible/possible/reasonable.313 294 314 295 //-------------------------------------------------------------------------- … … 468 449 indexerAddEnum( node ); 469 450 470 // unlike structs, traits, and unions, enums inject their members into the global scope451 // unlike structs, contexts, and unions, enums inject their members into the global scope 471 452 maybeAccept( node->parameters, *this ); 472 453 maybeAccept( node->members , *this ); … … 532 513 } 533 514 534 // see A NOTE ON THE ORDER OF TRAVERSAL, above535 // note that assertions come after the type is added to the symtab, since they are not part of the type proper536 // and may depend on the type itself537 515 indexerAddType( node ); 538 516 … … 554 532 } 555 533 556 // see A NOTE ON THE ORDER OF TRAVERSAL, above557 // note that assertions come after the type is added to the symtab, since they are not part of the type proper558 // and may depend on the type itself559 534 indexerAddType( node ); 560 535 … … 683 658 void PassVisitor< pass_type >::visit( IfStmt * node ) { 684 659 VISIT_START( node ); 685 { 686 // if statements introduce a level of scope (for the initialization) 660 661 visitExpression( node->condition ); 662 node->thenPart = visitStatement( node->thenPart ); 663 node->elsePart = visitStatement( node->elsePart ); 664 665 VISIT_END( node ); 666 } 667 668 template< typename pass_type > 669 Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) { 670 MUTATE_START( node ); 671 { 687 672 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 688 acceptAll( node->get_initialization(), *this );689 visitExpression( node->condition );690 node->thenPart = visitStatement( node->thenPart );691 node->elsePart = visitStatement( node->elsePart );692 }693 VISIT_END( node );694 }695 696 template< typename pass_type >697 Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {698 MUTATE_START( node );699 {700 // if statements introduce a level of scope (for the initialization)701 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );702 maybeMutateRef( node->get_initialization(), *this );703 673 node->condition = mutateExpression( node->condition ); 704 674 node->thenPart = mutateStatement ( node->thenPart ); … … 736 706 VISIT_START( node ); 737 707 { 738 // for statements introduce a level of scope (for the initialization)739 708 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 740 709 maybeAccept( node->initialization, *this ); … … 750 719 MUTATE_START( node ); 751 720 { 752 // for statements introduce a level of scope (for the initialization)753 721 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 754 722 maybeMutateRef( node->initialization, *this ); … … 879 847 VISIT_START( node ); 880 848 { 881 // catch statements introduce a level of scope (for the caught exception)882 849 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 883 850 maybeAccept( node->decl, *this ); … … 892 859 MUTATE_START( node ); 893 860 { 894 // catch statements introduce a level of scope (for the caught exception)895 861 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 896 862 maybeMutateRef( node->decl, *this );
Note:
See TracChangeset
for help on using the changeset viewer.