Changeset 33a25f9 for src/Common
- Timestamp:
- Sep 16, 2017, 8:52:23 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 5f782f7
- Parents:
- c0714bf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
rc0714bf r33a25f9 293 293 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 294 294 295 // A NOTE ON THE ORDER OF TRAVERSAL 296 // 297 // Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is 298 // no such thing as a recursive type or typedef. 299 // 300 // typedef struct { T *x; } T; // never allowed 301 // 302 // for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the 303 // members are traversed, and then the complete type should be added (assuming the type is completed by this particular 304 // declaration). 305 // 306 // struct T { struct T *x; }; // allowed 307 // 308 // It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that 309 // traversal may modify the definition of the type and these modifications should be visible when the symbol table is 310 // queried later in this pass. 311 // 312 // TODO: figure out whether recursive contexts are sensible/possible/reasonable. 295 313 296 314 //-------------------------------------------------------------------------- … … 450 468 indexerAddEnum( node ); 451 469 452 // unlike structs, contexts, and unions, enums inject their members into the global scope470 // unlike structs, traits, and unions, enums inject their members into the global scope 453 471 maybeAccept( node->parameters, *this ); 454 472 maybeAccept( node->members , *this ); … … 514 532 } 515 533 534 // see A NOTE ON THE ORDER OF TRAVERSAL, above 535 // note that assertions come after the type is added to the symtab, since they are not part of the type proper 536 // and may depend on the type itself 516 537 indexerAddType( node ); 517 538 … … 533 554 } 534 555 556 // see A NOTE ON THE ORDER OF TRAVERSAL, above 557 // note that assertions come after the type is added to the symtab, since they are not part of the type proper 558 // and may depend on the type itself 535 559 indexerAddType( node ); 536 560 … … 659 683 void PassVisitor< pass_type >::visit( IfStmt * node ) { 660 684 VISIT_START( node ); 661 662 visitExpression( node->condition ); 663 node->thenPart = visitStatement( node->thenPart ); 664 node->elsePart = visitStatement( node->elsePart ); 665 685 { 686 // if statements introduce a level of scope (for the initialization) 687 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 } 666 693 VISIT_END( node ); 667 694 } … … 671 698 MUTATE_START( node ); 672 699 { 673 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 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 ); 674 703 node->condition = mutateExpression( node->condition ); 675 704 node->thenPart = mutateStatement ( node->thenPart ); … … 707 736 VISIT_START( node ); 708 737 { 738 // for statements introduce a level of scope (for the initialization) 709 739 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 710 740 maybeAccept( node->initialization, *this ); … … 720 750 MUTATE_START( node ); 721 751 { 752 // for statements introduce a level of scope (for the initialization) 722 753 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 723 754 maybeMutateRef( node->initialization, *this ); … … 848 879 VISIT_START( node ); 849 880 { 881 // catch statements introduce a level of scope (for the caught exception) 850 882 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 851 883 maybeAccept( node->decl, *this ); … … 860 892 MUTATE_START( node ); 861 893 { 894 // catch statements introduce a level of scope (for the caught exception) 862 895 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 863 896 maybeMutateRef( node->decl, *this );
Note:
See TracChangeset
for help on using the changeset viewer.