- Timestamp:
- Oct 29, 2020, 4:46:04 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3100754
- Parents:
- 93068e53
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/AST/Pass.hpp ¶
r93068e53 rc6c682cf 296 296 private: 297 297 bool inFunction = false; 298 bool atFunctionTop = false; 298 299 }; 299 300 -
TabularUnified src/AST/Pass.impl.hpp ¶
r93068e53 rc6c682cf 502 502 // foralls are still in function type 503 503 maybe_accept( node, &FunctionDecl::type ); 504 // function body needs to have the same scope as parameters - CompoundStmt will not enter 505 // a new scope if inFunction is true 504 // First remember that we are now within a function. 506 505 ValueGuard< bool > oldInFunction( inFunction ); 507 506 inFunction = true; 507 // The function body needs to have the same scope as parameters. 508 // A CompoundStmt will not enter a new scope if atFunctionTop is true. 509 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 510 atFunctionTop = true; 508 511 maybe_accept( node, &FunctionDecl::stmts ); 509 512 maybe_accept( node, &FunctionDecl::attributes ); … … 672 675 VISIT_START( node ); 673 676 VISIT({ 674 // do not enter a new scope if inFunction is true - needs to check old state before the assignment675 auto guard1 = makeFuncGuard( [this, inFunctionCpy = this->inFunction]() {676 if ( ! inFunctionCpy) __pass::symtab::enter(core, 0);677 }, [this, inFunctionCpy = this->inFunction]() {678 if ( ! inFunctionCpy) __pass::symtab::leave(core, 0);677 // Do not enter (or leave) a new scope if atFunctionTop. Remember to save the result. 678 auto guard1 = makeFuncGuard( [this, enterScope = !this->atFunctionTop]() { 679 if ( enterScope ) __pass::symtab::enter(core, 0); 680 }, [this, leaveScope = !this->atFunctionTop]() { 681 if ( leaveScope ) __pass::symtab::leave(core, 0); 679 682 }); 680 683 ValueGuard< bool > guard2( inFunction ); -
TabularUnified src/Common/PassVisitor.h ¶
r93068e53 rc6c682cf 360 360 private: 361 361 bool inFunction = false; 362 bool atFunctionTop = false; 362 363 363 364 template<typename pass_t> friend void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor ); … … 532 533 533 534 bool isInFunction() const { 534 return visitor->i nFunction;535 return visitor->isInFunction(); 535 536 } 536 537 }; -
TabularUnified src/Common/PassVisitor.impl.h ¶
r93068e53 rc6c682cf 532 532 indexerAddId( &func ); 533 533 maybeAccept_impl( node->type, *this ); 534 // function body needs to have the same scope as parameters - CompoundStmt will not enter 535 // a new scope if inFunction is true 534 // First remember that we are now within a function. 536 535 ValueGuard< bool > oldInFunction( inFunction ); 537 536 inFunction = true; 537 // The function body needs to have the same scope as parameters. 538 // A CompoundStmt will not enter a new scope if atFunctionTop is true. 539 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 540 atFunctionTop = true; 538 541 maybeAccept_impl( node->statements, *this ); 539 542 maybeAccept_impl( node->attributes, *this ); … … 567 570 indexerAddId( &func ); 568 571 maybeAccept_impl( node->type, *this ); 569 // function body needs to have the same scope as parameters - CompoundStmt will not enter 570 // a new scope if inFunction is true 572 // First remember that we are now within a function. 571 573 ValueGuard< bool > oldInFunction( inFunction ); 572 574 inFunction = true; 575 // The function body needs to have the same scope as parameters. 576 // A CompoundStmt will not enter a new scope if atFunctionTop is true. 577 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 578 atFunctionTop = true; 573 579 maybeAccept_impl( node->statements, *this ); 574 580 maybeAccept_impl( node->attributes, *this ); … … 601 607 indexerAddId( &func ); 602 608 maybeMutate_impl( node->type, *this ); 603 // function body needs to have the same scope as parameters - CompoundStmt will not enter 604 // a new scope if inFunction is true 609 // First remember that we are now within a function. 605 610 ValueGuard< bool > oldInFunction( inFunction ); 606 611 inFunction = true; 612 // The function body needs to have the same scope as parameters. 613 // A CompoundStmt will not enter a new scope if atFunctionTop is true. 614 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 615 atFunctionTop = true; 607 616 maybeMutate_impl( node->statements, *this ); 608 617 maybeMutate_impl( node->attributes, *this ); … … 1007 1016 VISIT_START( node ); 1008 1017 { 1009 // do not enter a new scope if inFunction is true - needs to check old state before the assignment1010 ValueGuard< bool > old InFunction( inFunction);1011 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old) indexerScopeLeave(); } );1018 // Do not enter a new scope if atFunctionTop is true, don't leave one either. 1019 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 1020 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); 1012 1021 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1013 inFunction= false;1022 atFunctionTop = false; 1014 1023 visitStatementList( node->kids ); 1015 1024 } … … 1021 1030 VISIT_START( node ); 1022 1031 { 1023 // do not enter a new scope if inFunction is true - needs to check old state before the assignment1024 ValueGuard< bool > old InFunction( inFunction);1025 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old) indexerScopeLeave(); } );1032 // Do not enter a new scope if atFunctionTop is true, don't leave one either. 1033 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 1034 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); 1026 1035 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1027 inFunction= false;1036 atFunctionTop = false; 1028 1037 visitStatementList( node->kids ); 1029 1038 } … … 1035 1044 MUTATE_START( node ); 1036 1045 { 1037 // do not enter a new scope if inFunction is true - needs to check old state before the assignment1038 ValueGuard< bool > old InFunction( inFunction);1039 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old) indexerScopeLeave(); } );1046 // Do not enter a new scope if atFunctionTop is true, don't leave one either. 1047 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 1048 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); 1040 1049 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1041 inFunction= false;1050 atFunctionTop = false; 1042 1051 mutateStatementList( node->kids ); 1043 1052 }
Note: See TracChangeset
for help on using the changeset viewer.