Changeset 695e00d for src/Common
- Timestamp:
- Sep 19, 2017, 2:14:39 PM (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, stuck-waitfor-destruct, with_gc
- Children:
- 8f98b78
- Parents:
- e149f77 (diff), e06be49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/Common/PassVisitor.impl.h (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
re149f77 r695e00d 183 183 184 184 } catch ( SemanticError &e ) { 185 e.set_location( (*i)->location ); 185 186 errors.append( e ); 186 187 } … … 292 293 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 293 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. 294 313 295 314 //-------------------------------------------------------------------------- … … 449 468 indexerAddEnum( node ); 450 469 451 // 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 452 471 maybeAccept( node->parameters, *this ); 453 472 maybeAccept( node->members , *this ); … … 513 532 } 514 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 515 537 indexerAddType( node ); 516 538 … … 532 554 } 533 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 534 559 indexerAddType( node ); 535 560 … … 658 683 void PassVisitor< pass_type >::visit( IfStmt * node ) { 659 684 VISIT_START( node ); 660 661 visitExpression( node->condition ); 662 node->thenPart = visitStatement( node->thenPart ); 663 node->elsePart = visitStatement( node->elsePart ); 664 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 } 665 693 VISIT_END( node ); 666 694 } … … 670 698 MUTATE_START( node ); 671 699 { 672 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 ); 673 703 node->condition = mutateExpression( node->condition ); 674 704 node->thenPart = mutateStatement ( node->thenPart ); … … 706 736 VISIT_START( node ); 707 737 { 738 // for statements introduce a level of scope (for the initialization) 708 739 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 709 740 maybeAccept( node->initialization, *this ); … … 719 750 MUTATE_START( node ); 720 751 { 752 // for statements introduce a level of scope (for the initialization) 721 753 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 722 754 maybeMutateRef( node->initialization, *this ); … … 847 879 VISIT_START( node ); 848 880 { 881 // catch statements introduce a level of scope (for the caught exception) 849 882 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 850 883 maybeAccept( node->decl, *this ); … … 859 892 MUTATE_START( node ); 860 893 { 894 // catch statements introduce a level of scope (for the caught exception) 861 895 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 862 896 maybeMutateRef( node->decl, *this );
Note:
See TracChangeset
for help on using the changeset viewer.