Changeset eef8dfb for src/Common/PassVisitor.impl.h
- Timestamp:
- Jan 7, 2021, 2:55:57 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 58fe85a
- Parents:
- bdfc032 (diff), 44e37ef (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
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
rbdfc032 reef8dfb 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 ); … … 826 835 { 827 836 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 828 maybeAccept_impl( node->parameters, *this );829 837 maybeAccept_impl( node->base , *this ); 830 838 } … … 849 857 { 850 858 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 851 maybeAccept_impl( node->parameters, *this );852 859 maybeAccept_impl( node->base , *this ); 853 860 } … … 871 878 { 872 879 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 873 maybeMutate_impl( node->parameters, *this );874 880 maybeMutate_impl( node->base , *this ); 875 881 } … … 895 901 { 896 902 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 897 maybeAccept_impl( node->parameters, *this );898 903 maybeAccept_impl( node->base , *this ); 899 904 } … … 912 917 { 913 918 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 914 maybeAccept_impl( node->parameters, *this );915 919 maybeAccept_impl( node->base , *this ); 916 920 } … … 929 933 { 930 934 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 931 maybeMutate_impl( node->parameters, *this );932 935 maybeMutate_impl( node->base , *this ); 933 936 } … … 1007 1010 VISIT_START( node ); 1008 1011 { 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(); } );1012 // Do not enter a new scope if atFunctionTop is true, don't leave one either. 1013 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 1014 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); 1012 1015 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1013 inFunction= false;1016 atFunctionTop = false; 1014 1017 visitStatementList( node->kids ); 1015 1018 } … … 1021 1024 VISIT_START( node ); 1022 1025 { 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(); } );1026 // Do not enter a new scope if atFunctionTop is true, don't leave one either. 1027 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 1028 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); 1026 1029 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1027 inFunction= false;1030 atFunctionTop = false; 1028 1031 visitStatementList( node->kids ); 1029 1032 } … … 1035 1038 MUTATE_START( node ); 1036 1039 { 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(); } );1040 // Do not enter a new scope if atFunctionTop is true, don't leave one either. 1041 ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); 1042 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); 1040 1043 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1041 inFunction= false;1044 atFunctionTop = false; 1042 1045 mutateStatementList( node->kids ); 1043 1046 } … … 1522 1525 1523 1526 //-------------------------------------------------------------------------- 1527 // SuspendStmt 1528 template< typename pass_type > 1529 void PassVisitor< pass_type >::visit( SuspendStmt * node ) { 1530 VISIT_START( node ); 1531 1532 maybeAccept_impl( node->then , *this ); 1533 1534 VISIT_END( node ); 1535 } 1536 1537 template< typename pass_type > 1538 void PassVisitor< pass_type >::visit( const SuspendStmt * node ) { 1539 VISIT_START( node ); 1540 1541 maybeAccept_impl( node->then , *this ); 1542 1543 VISIT_END( node ); 1544 } 1545 1546 template< typename pass_type > 1547 Statement * PassVisitor< pass_type >::mutate( SuspendStmt * node ) { 1548 MUTATE_START( node ); 1549 1550 maybeMutate_impl( node->then , *this ); 1551 1552 MUTATE_END( Statement, node ); 1553 } 1554 1555 //-------------------------------------------------------------------------- 1524 1556 // WaitForStmt 1525 1557 template< typename pass_type > … … 3302 3334 VISIT_START( node ); 3303 3335 3304 indexerAdd Struct( node->name );3336 indexerAddUnion( node->name ); 3305 3337 3306 3338 { … … 3317 3349 VISIT_START( node ); 3318 3350 3319 indexerAdd Struct( node->name );3351 indexerAddUnion( node->name ); 3320 3352 3321 3353 { … … 3332 3364 MUTATE_START( node ); 3333 3365 3334 indexerAdd Struct( node->name );3366 indexerAddUnion( node->name ); 3335 3367 3336 3368 {
Note:
See TracChangeset
for help on using the changeset viewer.