Changeset e3d7f9f
- Timestamp:
- Jul 12, 2019, 5:42:33 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- ce12e2b
- Parents:
- 6f096d2
- Location:
- src/Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
r6f096d2 re3d7f9f 410 410 void indexerScopeEnter () { indexer_impl_enterScope ( pass, 0 ); } 411 411 void indexerScopeLeave () { indexer_impl_leaveScope ( pass, 0 ); } 412 void indexerAddId ( DeclarationWithType* node ) { indexer_impl_addId ( pass, 0, node ); }413 void indexerAddType ( NamedTypeDecl* node ) { indexer_impl_addType ( pass, 0, node ); }412 void indexerAddId ( const DeclarationWithType * node ) { indexer_impl_addId ( pass, 0, node ); } 413 void indexerAddType ( const NamedTypeDecl * node ) { indexer_impl_addType ( pass, 0, node ); } 414 414 void indexerAddStruct ( const std::string & id ) { indexer_impl_addStruct ( pass, 0, id ); } 415 void indexerAddStruct ( StructDecl* node ) { indexer_impl_addStruct ( pass, 0, node ); }416 void indexerAddStructFwd( StructDecl* node ) { indexer_impl_addStructFwd( pass, 0, node ); }417 void indexerAddEnum ( EnumDecl* node ) { indexer_impl_addEnum ( pass, 0, node ); }415 void indexerAddStruct ( const StructDecl * node ) { indexer_impl_addStruct ( pass, 0, node ); } 416 void indexerAddStructFwd( const StructDecl * node ) { indexer_impl_addStructFwd( pass, 0, node ); } 417 void indexerAddEnum ( const EnumDecl * node ) { indexer_impl_addEnum ( pass, 0, node ); } 418 418 void indexerAddUnion ( const std::string & id ) { indexer_impl_addUnion ( pass, 0, id ); } 419 void indexerAddUnion ( UnionDecl* node ) { indexer_impl_addUnion ( pass, 0, node ); }420 void indexerAddUnionFwd ( UnionDecl* node ) { indexer_impl_addUnionFwd ( pass, 0, node ); }421 void indexerAddTrait ( TraitDecl* node ) { indexer_impl_addTrait ( pass, 0, node ); }422 void indexerAddWith ( std::list< Expression * > & exprs,BaseSyntaxNode * withStmt ) { indexer_impl_addWith( pass, 0, exprs, withStmt ); }419 void indexerAddUnion ( const UnionDecl * node ) { indexer_impl_addUnion ( pass, 0, node ); } 420 void indexerAddUnionFwd ( const UnionDecl * node ) { indexer_impl_addUnionFwd ( pass, 0, node ); } 421 void indexerAddTrait ( const TraitDecl * node ) { indexer_impl_addTrait ( pass, 0, node ); } 422 void indexerAddWith ( const std::list< Expression * > & exprs, const BaseSyntaxNode * withStmt ) { indexer_impl_addWith( pass, 0, exprs, withStmt ); } 423 423 424 424 425 425 template< typename TreeType, typename VisitorType > 426 friend inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor );426 friend inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ); 427 427 428 428 template< typename TreeType, typename VisitorType > 429 friend inline void indexerScopedMutate( TreeType *& tree, VisitorType &visitor ); 429 friend inline void indexerScopedAccept( const TreeType * tree, VisitorType & visitor ); 430 431 template< typename TreeType, typename VisitorType > 432 friend inline void indexerScopedMutate( TreeType *& tree, VisitorType & visitor ); 430 433 }; 431 434 -
src/Common/PassVisitor.impl.h
r6f096d2 re3d7f9f 548 548 VISIT_START( node ); 549 549 550 indexerAddId( node ); 551 550 552 maybeAccept_impl( node->withExprs, *this ); 551 553 { 552 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 553 static ObjectDecl func( 554 "__func__", noStorageClasses, LinkageSpec::C, nullptr, 555 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), 556 nullptr 557 ); 558 maybeAccept_impl( node->type, *this ); 559 // function body needs to have the same scope as parameters - CompoundStmt will not enter 560 // a new scope if inFunction is true 561 ValueGuard< bool > oldInFunction( inFunction ); 562 inFunction = true; 563 maybeAccept_impl( node->statements, *this ); 564 maybeAccept_impl( node->attributes, *this ); 554 // with clause introduces a level of scope (for the with expression members). 555 // with clause exprs are added to the indexer before parameters so that parameters 556 // shadow with exprs and not the other way around. 557 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 558 indexerAddWith( node->withExprs, node ); 559 { 560 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 561 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 562 static ObjectDecl func( 563 "__func__", noStorageClasses, LinkageSpec::C, nullptr, 564 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), 565 nullptr 566 ); 567 indexerAddId( &func ); 568 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 571 ValueGuard< bool > oldInFunction( inFunction ); 572 inFunction = true; 573 maybeAccept_impl( node->statements, *this ); 574 maybeAccept_impl( node->attributes, *this ); 575 } 565 576 } 566 577 … … 628 639 VISIT_START( node ); 629 640 630 maybeAccept_impl( node->parameters, *this );631 maybeAccept_impl( node->members , *this );632 633 VISIT_END( node );634 }635 636 template< typename pass_type >637 Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {638 MUTATE_START( node );639 640 641 // make up a forward declaration and add it before processing the members 641 642 // needs to be on the heap because addStruct saves the pointer … … 644 645 { 645 646 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 647 maybeAccept_impl( node->parameters, *this ); 648 maybeAccept_impl( node->members , *this ); 649 } 650 651 // this addition replaces the forward declaration 652 indexerAddStruct( node ); 653 654 VISIT_END( node ); 655 } 656 657 template< typename pass_type > 658 Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) { 659 MUTATE_START( node ); 660 661 // make up a forward declaration and add it before processing the members 662 // needs to be on the heap because addStruct saves the pointer 663 indexerAddStructFwd( node ); 664 665 { 666 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 646 667 maybeMutate_impl( node->parameters, *this ); 647 668 maybeMutate_impl( node->members , *this ); … … 677 698 VISIT_START( node ); 678 699 679 maybeAccept_impl( node->parameters, *this ); 680 maybeAccept_impl( node->members , *this ); 700 // make up a forward declaration and add it before processing the members 701 indexerAddUnionFwd( node ); 702 703 { 704 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 705 maybeAccept_impl( node->parameters, *this ); 706 maybeAccept_impl( node->members , *this ); 707 } 708 709 indexerAddUnion( node ); 681 710 682 711 VISIT_END( node ); … … 720 749 VISIT_START( node ); 721 750 751 indexerAddEnum( node ); 752 722 753 // unlike structs, traits, and unions, enums inject their members into the global scope 723 754 maybeAccept_impl( node->parameters, *this ); … … 761 792 VISIT_START( node ); 762 793 763 maybeAccept_impl( node->parameters, *this ); 764 maybeAccept_impl( node->members , *this ); 794 { 795 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 796 maybeAccept_impl( node->parameters, *this ); 797 maybeAccept_impl( node->members , *this ); 798 } 799 800 indexerAddTrait( node ); 765 801 766 802 VISIT_END( node ); … … 811 847 VISIT_START( node ); 812 848 813 maybeAccept_impl( node->parameters, *this );814 maybeAccept_impl( node->base , *this );815 maybeAccept_impl( node->assertions, *this );816 817 VISIT_END( node );818 }819 820 template< typename pass_type >821 Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {822 MUTATE_START( node );823 824 849 { 825 850 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 826 maybe Mutate_impl( node->parameters, *this );827 maybe Mutate_impl( node->base , *this );851 maybeAccept_impl( node->parameters, *this ); 852 maybeAccept_impl( node->base , *this ); 828 853 } 829 854 … … 833 858 indexerAddType( node ); 834 859 860 maybeAccept_impl( node->assertions, *this ); 861 862 indexerScopedAccept( node->init, *this ); 863 864 VISIT_END( node ); 865 } 866 867 template< typename pass_type > 868 Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) { 869 MUTATE_START( node ); 870 871 { 872 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 873 maybeMutate_impl( node->parameters, *this ); 874 maybeMutate_impl( node->base , *this ); 875 } 876 877 // see A NOTE ON THE ORDER OF TRAVERSAL, above 878 // note that assertions come after the type is added to the symtab, since they are not part of the type proper 879 // and may depend on the type itself 880 indexerAddType( node ); 881 835 882 maybeMutate_impl( node->assertions, *this ); 836 883 … … 863 910 VISIT_START( node ); 864 911 865 maybeAccept_impl( node->parameters, *this ); 866 maybeAccept_impl( node->base , *this ); 912 { 913 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 914 maybeAccept_impl( node->parameters, *this ); 915 maybeAccept_impl( node->base , *this ); 916 } 917 918 indexerAddType( node ); 919 867 920 maybeAccept_impl( node->assertions, *this ); 868 921 … … 1101 1154 void PassVisitor< pass_type >::visit( const IfStmt * node ) { 1102 1155 VISIT_START( node ); 1103 1104 maybeAccept_impl( node->initialization, *this ); 1105 visitExpression ( node->condition ); 1106 visitStatement( node->thenPart ); 1107 visitStatement( node->elsePart ); 1108 1156 { 1157 // if statements introduce a level of scope (for the initialization) 1158 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1159 maybeAccept_impl( node->initialization, *this ); 1160 visitExpression ( node->condition ); 1161 visitStatement ( node->thenPart ); 1162 visitStatement ( node->elsePart ); 1163 } 1109 1164 VISIT_END( node ); 1110 1165 } … … 1145 1200 VISIT_START( node ); 1146 1201 1147 maybeAccept_impl( node->initialization, *this ); 1148 visitExpression ( node->condition ); 1149 visitStatement( node->body ); 1202 { 1203 // while statements introduce a level of scope (for the initialization) 1204 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1205 maybeAccept_impl( node->initialization, *this ); 1206 visitExpression ( node->condition ); 1207 visitStatement ( node->body ); 1208 } 1150 1209 1151 1210 VISIT_END( node ); … … 1187 1246 void PassVisitor< pass_type >::visit( const ForStmt * node ) { 1188 1247 VISIT_START( node ); 1189 1190 maybeAccept_impl( node->initialization, *this ); 1191 visitExpression( node->condition ); 1192 visitExpression( node->increment ); 1193 visitStatement( node->body ); 1194 1248 { 1249 // for statements introduce a level of scope (for the initialization) 1250 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1251 maybeAccept_impl( node->initialization, *this ); 1252 visitExpression( node->condition ); 1253 visitExpression( node->increment ); 1254 visitStatement ( node->body ); 1255 } 1195 1256 VISIT_END( node ); 1196 1257 } … … 1408 1469 void PassVisitor< pass_type >::visit( const CatchStmt * node ) { 1409 1470 VISIT_START( node ); 1410 1411 maybeAccept_impl( node->decl, *this ); 1412 visitExpression( node->cond ); 1413 visitStatement ( node->body ); 1414 1471 { 1472 // catch statements introduce a level of scope (for the caught exception) 1473 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1474 maybeAccept_impl( node->decl, *this ); 1475 visitExpression ( node->cond ); 1476 visitStatement ( node->body ); 1477 } 1415 1478 VISIT_END( node ); 1416 1479 } … … 1543 1606 void PassVisitor< pass_type >::visit( const WithStmt * node ) { 1544 1607 VISIT_START( node ); 1545 1546 1608 maybeAccept_impl( node->exprs, *this ); 1547 maybeAccept_impl( node->stmt, *this ); 1548 1609 { 1610 // catch statements introduce a level of scope (for the caught exception) 1611 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1612 indexerAddWith( node->exprs, node ); 1613 maybeAccept_impl( node->stmt, *this ); 1614 } 1549 1615 VISIT_END( node ); 1550 1616 } … … 1648 1714 1649 1715 indexerScopedAccept( node->result , *this ); 1650 maybeAccept_impl 1651 maybeAccept_impl 1716 maybeAccept_impl ( node->function, *this ); 1717 maybeAccept_impl ( node->args , *this ); 1652 1718 1653 1719 VISIT_END( node ); … … 1658 1724 VISIT_START( node ); 1659 1725 1660 maybeAccept_impl( node->result , *this );1661 maybeAccept_impl ( node->function, *this );1662 maybeAccept_impl ( node->args , *this );1726 indexerScopedAccept( node->result , *this ); 1727 maybeAccept_impl ( node->function, *this ); 1728 maybeAccept_impl ( node->args , *this ); 1663 1729 1664 1730 VISIT_END( node ); … … 1697 1763 VISIT_START( node ); 1698 1764 1699 maybeAccept_impl( node->result, *this );1765 indexerScopedAccept( node->result, *this ); 1700 1766 1701 1767 for ( auto expr : node->args ) { … … 1735 1801 VISIT_START( node ); 1736 1802 1737 maybeAccept_impl( node->result, *this );1803 indexerScopedAccept( node->result, *this ); 1738 1804 1739 1805 VISIT_END( node ); … … 1757 1823 1758 1824 indexerScopedAccept( node->result, *this ); 1759 maybeAccept_impl 1825 maybeAccept_impl ( node->arg , *this ); 1760 1826 1761 1827 VISIT_END( node ); … … 1766 1832 VISIT_START( node ); 1767 1833 1768 maybeAccept_impl( node->result, *this );1769 maybeAccept_impl ( node->arg , *this );1834 indexerScopedAccept( node->result, *this ); 1835 maybeAccept_impl ( node->arg , *this ); 1770 1836 1771 1837 VISIT_END( node ); … … 1799 1865 VISIT_START( node ); 1800 1866 1801 maybeAccept_impl( node->result, *this );1802 maybeAccept_impl ( node->arg , *this );1867 indexerScopedAccept( node->result, *this ); 1868 maybeAccept_impl ( node->arg , *this ); 1803 1869 1804 1870 VISIT_END( node ); … … 1823 1889 1824 1890 indexerScopedAccept( node->result, *this ); 1825 maybeAccept_impl ( node->arg, *this );1891 maybeAccept_impl ( node->arg, *this ); 1826 1892 1827 1893 VISIT_END( node ); … … 1832 1898 VISIT_START( node ); 1833 1899 1834 maybeAccept_impl( node->result, *this );1835 maybeAccept_impl ( node->arg, *this );1900 indexerScopedAccept( node->result, *this ); 1901 maybeAccept_impl ( node->arg, *this ); 1836 1902 1837 1903 VISIT_END( node ); … … 1865 1931 VISIT_START( node ); 1866 1932 1867 maybeAccept_impl( node->result, *this );1868 maybeAccept_impl ( node->arg , *this );1933 indexerScopedAccept( node->result, *this ); 1934 maybeAccept_impl ( node->arg , *this ); 1869 1935 1870 1936 VISIT_END( node ); … … 1897 1963 VISIT_START( node ); 1898 1964 1899 maybeAccept_impl( node->result, *this );1965 indexerScopedAccept( node->result, *this ); 1900 1966 1901 1967 VISIT_END( node ); … … 1929 1995 VISIT_START( node ); 1930 1996 1931 maybeAccept_impl( node->result , *this );1932 maybeAccept_impl ( node->aggregate, *this );1933 maybeAccept_impl ( node->member , *this );1997 indexerScopedAccept( node->result , *this ); 1998 maybeAccept_impl ( node->aggregate, *this ); 1999 maybeAccept_impl ( node->member , *this ); 1934 2000 1935 2001 VISIT_END( node ); … … 1964 2030 VISIT_START( node ); 1965 2031 1966 maybeAccept_impl( node->result , *this );1967 maybeAccept_impl ( node->aggregate, *this );2032 indexerScopedAccept( node->result , *this ); 2033 maybeAccept_impl ( node->aggregate, *this ); 1968 2034 1969 2035 VISIT_END( node ); … … 1996 2062 VISIT_START( node ); 1997 2063 1998 maybeAccept_impl( node->result, *this );2064 indexerScopedAccept( node->result, *this ); 1999 2065 2000 2066 VISIT_END( node ); … … 2027 2093 VISIT_START( node ); 2028 2094 2029 maybeAccept_impl( node->result , *this );2030 maybeAccept_impl ( &node->constant, *this );2095 indexerScopedAccept( node->result , *this ); 2096 maybeAccept_impl ( &node->constant, *this ); 2031 2097 2032 2098 VISIT_END( node ); … … 2066 2132 VISIT_START( node ); 2067 2133 2068 maybeAccept_impl( node->result, *this );2134 indexerScopedAccept( node->result, *this ); 2069 2135 if ( node->get_isType() ) { 2070 2136 maybeAccept_impl( node->type, *this ); … … 2111 2177 VISIT_START( node ); 2112 2178 2113 maybeAccept_impl( node->result, *this );2179 indexerScopedAccept( node->result, *this ); 2114 2180 if ( node->get_isType() ) { 2115 2181 maybeAccept_impl( node->type, *this ); … … 2152 2218 VISIT_START( node ); 2153 2219 2154 maybeAccept_impl( node->result, *this );2155 maybeAccept_impl ( node->type , *this );2220 indexerScopedAccept( node->result, *this ); 2221 maybeAccept_impl ( node->type , *this ); 2156 2222 2157 2223 VISIT_END( node ); … … 2185 2251 VISIT_START( node ); 2186 2252 2187 maybeAccept_impl( node->result, *this );2188 maybeAccept_impl ( node->type , *this );2253 indexerScopedAccept( node->result, *this ); 2254 maybeAccept_impl ( node->type , *this ); 2189 2255 2190 2256 VISIT_END( node ); … … 2218 2284 VISIT_START( node ); 2219 2285 2220 maybeAccept_impl( node->result, *this );2221 maybeAccept_impl ( node->type , *this );2286 indexerScopedAccept( node->result, *this ); 2287 maybeAccept_impl ( node->type , *this ); 2222 2288 2223 2289 VISIT_END( node ); … … 2255 2321 VISIT_START( node ); 2256 2322 2257 maybeAccept_impl( node->result, *this );2323 indexerScopedAccept( node->result, *this ); 2258 2324 if ( node->get_isType() ) { 2259 2325 maybeAccept_impl( node->type, *this ); … … 2297 2363 VISIT_START( node ); 2298 2364 2299 maybeAccept_impl( node->result, *this );2300 maybeAccept_impl ( node->arg1 , *this );2301 maybeAccept_impl ( node->arg2 , *this );2365 indexerScopedAccept( node->result, *this ); 2366 maybeAccept_impl ( node->arg1 , *this ); 2367 maybeAccept_impl ( node->arg2 , *this ); 2302 2368 2303 2369 VISIT_END( node ); … … 2334 2400 VISIT_START( node ); 2335 2401 2336 maybeAccept_impl( node->result, *this );2337 maybeAccept_impl ( node->arg1 , *this );2338 maybeAccept_impl ( node->arg2 , *this );2339 maybeAccept_impl ( node->arg3 , *this );2402 indexerScopedAccept( node->result, *this ); 2403 maybeAccept_impl ( node->arg1 , *this ); 2404 maybeAccept_impl ( node->arg2 , *this ); 2405 maybeAccept_impl ( node->arg3 , *this ); 2340 2406 2341 2407 VISIT_END( node ); … … 2372 2438 VISIT_START( node ); 2373 2439 2374 maybeAccept_impl( node->result, *this );2375 maybeAccept_impl ( node->arg1 , *this );2376 maybeAccept_impl ( node->arg2 , *this );2440 indexerScopedAccept( node->result, *this ); 2441 maybeAccept_impl ( node->arg1 , *this ); 2442 maybeAccept_impl ( node->arg2 , *this ); 2377 2443 2378 2444 VISIT_END( node ); … … 2407 2473 VISIT_START( node ); 2408 2474 2409 maybeAccept_impl( node->result, *this );2410 maybeAccept_impl ( node->type, *this );2475 indexerScopedAccept( node->result, *this ); 2476 maybeAccept_impl ( node->type, *this ); 2411 2477 2412 2478 VISIT_END( node ); … … 2442 2508 VISIT_START( node ); 2443 2509 2444 maybeAccept_impl( node->result , *this );2445 maybeAccept_impl ( node->inout , *this );2446 maybeAccept_impl ( node->constraint, *this );2447 maybeAccept_impl ( node->operand , *this );2510 indexerScopedAccept( node->result , *this ); 2511 maybeAccept_impl ( node->inout , *this ); 2512 maybeAccept_impl ( node->constraint, *this ); 2513 maybeAccept_impl ( node->operand , *this ); 2448 2514 2449 2515 VISIT_END( node ); … … 2479 2545 VISIT_START( node ); 2480 2546 2481 maybeAccept_impl( node->result , *this );2482 maybeAccept_impl ( node->callExpr , *this );2547 indexerScopedAccept( node->result , *this ); 2548 maybeAccept_impl ( node->callExpr , *this ); 2483 2549 2484 2550 VISIT_END( node ); … … 2512 2578 VISIT_START( node ); 2513 2579 2514 maybeAccept_impl( node->result , *this );2515 maybeAccept_impl ( node->callExpr, *this );2580 indexerScopedAccept( node->result , *this ); 2581 maybeAccept_impl ( node->callExpr, *this ); 2516 2582 2517 2583 VISIT_END( node ); … … 2545 2611 VISIT_START( node ); 2546 2612 2547 maybeAccept_impl( node->result , *this );2548 maybeAccept_impl ( node->initializer, *this );2613 indexerScopedAccept( node->result , *this ); 2614 maybeAccept_impl ( node->initializer, *this ); 2549 2615 2550 2616 VISIT_END( node ); … … 2579 2645 VISIT_START( node ); 2580 2646 2581 maybeAccept_impl( node->result, *this );2582 maybeAccept_impl ( node->low , *this );2583 maybeAccept_impl ( node->high , *this );2647 indexerScopedAccept( node->result, *this ); 2648 maybeAccept_impl ( node->low , *this ); 2649 maybeAccept_impl ( node->high , *this ); 2584 2650 2585 2651 VISIT_END( node ); … … 2614 2680 VISIT_START( node ); 2615 2681 2616 maybeAccept_impl( node->result, *this );2617 maybeAccept_impl ( node->exprs , *this );2682 indexerScopedAccept( node->result, *this ); 2683 maybeAccept_impl ( node->exprs , *this ); 2618 2684 2619 2685 VISIT_END( node ); … … 2647 2713 VISIT_START( node ); 2648 2714 2649 maybeAccept_impl( node->result, *this );2650 maybeAccept_impl ( node->exprs , *this );2715 indexerScopedAccept( node->result, *this ); 2716 maybeAccept_impl ( node->exprs , *this ); 2651 2717 2652 2718 VISIT_END( node ); … … 2680 2746 VISIT_START( node ); 2681 2747 2682 maybeAccept_impl( node->result, *this );2683 maybeAccept_impl ( node->tuple , *this );2748 indexerScopedAccept( node->result, *this ); 2749 maybeAccept_impl ( node->tuple , *this ); 2684 2750 2685 2751 VISIT_END( node ); … … 2713 2779 VISIT_START( node ); 2714 2780 2715 maybeAccept_impl( node->result , *this );2781 indexerScopedAccept( node->result , *this ); 2716 2782 maybeAccept_impl( node->stmtExpr, *this ); 2717 2783 … … 2753 2819 VISIT_START( node ); 2754 2820 2755 maybeAccept_impl( node->result , *this );2756 maybeAccept_impl( node->statements , *this );2757 maybeAccept_impl( node->returnDecls, *this );2758 maybeAccept_impl( node->dtors , *this );2759 2760 VISIT_END( node );2761 }2762 2763 template< typename pass_type >2764 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {2765 MUTATE_START( node );2766 2767 2821 // don't want statements from outer CompoundStmts to be added to this StmtExpr 2768 2822 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() ); … … 2770 2824 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 2771 2825 2826 indexerScopedAccept( node->result , *this ); 2827 maybeAccept_impl ( node->statements , *this ); 2828 maybeAccept_impl ( node->returnDecls, *this ); 2829 maybeAccept_impl ( node->dtors , *this ); 2830 2831 VISIT_END( node ); 2832 } 2833 2834 template< typename pass_type > 2835 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { 2836 MUTATE_START( node ); 2837 2838 // don't want statements from outer CompoundStmts to be added to this StmtExpr 2839 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() ); 2840 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 2841 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 2842 2772 2843 indexerScopedMutate( node->result , *this ); 2773 2844 maybeMutate_impl ( node->statements , *this ); … … 2794 2865 VISIT_START( node ); 2795 2866 2796 maybeAccept_impl( node->result, *this );2797 maybeAccept_impl ( node->expr , *this );2867 indexerScopedAccept( node->result, *this ); 2868 maybeAccept_impl ( node->expr , *this ); 2798 2869 2799 2870 VISIT_END( node ); … … 2828 2899 VISIT_START( node ); 2829 2900 2830 maybeAccept_impl( node->result, *this );2831 maybeAccept_impl ( node->expr , *this );2901 indexerScopedAccept( node->result, *this ); 2902 maybeAccept_impl ( node->expr , *this ); 2832 2903 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. 2833 2904 … … 2864 2935 VISIT_START( node ); 2865 2936 2866 maybeAccept_impl( node->result, *this );2867 maybeAccept_impl ( node->expr , *this );2868 maybeAccept_impl ( node->designation, *this );2937 indexerScopedAccept( node->result, *this ); 2938 maybeAccept_impl ( node->expr , *this ); 2939 maybeAccept_impl ( node->designation, *this ); 2869 2940 2870 2941 VISIT_END( node ); … … 2890 2961 2891 2962 indexerScopedAccept( node->result, *this ); 2892 maybeAccept_impl ( node->expr, *this );2963 maybeAccept_impl ( node->expr, *this ); 2893 2964 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. 2894 2965 … … 2900 2971 VISIT_START( node ); 2901 2972 2902 maybeAccept_impl( node->result, *this );2903 maybeAccept_impl ( node->expr, *this );2973 indexerScopedAccept( node->result, *this ); 2974 maybeAccept_impl ( node->expr, *this ); 2904 2975 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. 2905 2976 … … 2925 2996 2926 2997 indexerScopedAccept( node->result, *this ); 2927 maybeAccept_impl ( node->expr, *this );2998 maybeAccept_impl ( node->expr, *this ); 2928 2999 2929 3000 VISIT_END( node ); … … 2934 3005 VISIT_START( node ); 2935 3006 2936 maybeAccept_impl( node->result, *this );2937 maybeAccept_impl ( node->expr, *this );3007 indexerScopedAccept( node->result, *this ); 3008 maybeAccept_impl ( node->expr, *this ); 2938 3009 2939 3010 VISIT_END( node ); … … 2971 3042 VISIT_START( node ); 2972 3043 2973 maybeAccept_impl( node->result, *this );3044 indexerScopedAccept( node->result, *this ); 2974 3045 maybeAccept_impl( node->control, *this ); 2975 3046 for ( const GenericExpr::Association & assoc : node->associations ) { 2976 maybeAccept_impl( assoc.type, *this );3047 indexerScopedAccept( assoc.type, *this ); 2977 3048 maybeAccept_impl( assoc.expr, *this ); 2978 3049 } … … 3247 3318 VISIT_START( node ); 3248 3319 3249 maybeAccept_impl( node->forall , *this ); 3250 maybeAccept_impl( node->parameters, *this ); 3320 indexerAddStruct( node->name ); 3321 3322 { 3323 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 3324 maybeAccept_impl( node->forall , *this ); 3325 maybeAccept_impl( node->parameters, *this ); 3326 } 3251 3327 3252 3328 VISIT_END( node ); … … 3289 3365 VISIT_START( node ); 3290 3366 3291 maybeAccept_impl( node->forall , *this ); 3292 maybeAccept_impl( node->parameters, *this ); 3367 indexerAddStruct( node->name ); 3368 3369 { 3370 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 3371 maybeAccept_impl( node->forall , *this ); 3372 maybeAccept_impl( node->parameters, *this ); 3373 } 3293 3374 3294 3375 VISIT_END( node ); -
src/Common/PassVisitor.proto.h
r6f096d2 re3d7f9f 229 229 230 230 231 INDEXER_FUNC1( addId , DeclarationWithType * );232 INDEXER_FUNC1( addType , NamedTypeDecl * );233 INDEXER_FUNC1( addStruct , StructDecl * );234 INDEXER_FUNC1( addEnum , EnumDecl * );235 INDEXER_FUNC1( addUnion , UnionDecl * );236 INDEXER_FUNC1( addTrait , TraitDecl * );237 INDEXER_FUNC2( addWith , std::list< Expression * > &,BaseSyntaxNode * );231 INDEXER_FUNC1( addId , const DeclarationWithType * ); 232 INDEXER_FUNC1( addType , const NamedTypeDecl * ); 233 INDEXER_FUNC1( addStruct , const StructDecl * ); 234 INDEXER_FUNC1( addEnum , const EnumDecl * ); 235 INDEXER_FUNC1( addUnion , const UnionDecl * ); 236 INDEXER_FUNC1( addTrait , const TraitDecl * ); 237 INDEXER_FUNC2( addWith , const std::list< Expression * > &, const BaseSyntaxNode * ); 238 238 239 239 #undef INDEXER_FUNC1 … … 241 241 242 242 template<typename pass_type> 243 static inline auto indexer_impl_addStructFwd( pass_type & pass, int, StructDecl * decl ) -> decltype( pass.indexer.addStruct( decl ), void() ) {243 static inline auto indexer_impl_addStructFwd( pass_type & pass, int, const StructDecl * decl ) -> decltype( pass.indexer.addStruct( decl ), void() ) { 244 244 StructDecl * fwd = new StructDecl( decl->name ); 245 245 cloneAll( decl->parameters, fwd->parameters ); … … 251 251 252 252 template<typename pass_type> 253 static inline auto indexer_impl_addUnionFwd( pass_type & pass, int, UnionDecl * decl ) -> decltype( pass.indexer.addUnion( decl ), void() ) {253 static inline auto indexer_impl_addUnionFwd( pass_type & pass, int, const UnionDecl * decl ) -> decltype( pass.indexer.addUnion( decl ), void() ) { 254 254 UnionDecl * fwd = new UnionDecl( decl->name ); 255 255 cloneAll( decl->parameters, fwd->parameters );
Note: See TracChangeset
for help on using the changeset viewer.