Changes in src/AST/Pass.impl.hpp [37cdd97:c15085d]
- File:
-
- 1 edited
-
src/AST/Pass.impl.hpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r37cdd97 rc15085d 28 28 /* setup the scope for passes that want to run code at exit */ \ 29 29 __attribute__((unused)) ast::__pass::guard_value guard2( ast::__pass::at_cleanup (pass, 0) ); \ 30 /* begin tracing memory allocation if requested by this pass */ \ 31 __pass::beginTrace( pass, 0 ); \ 30 32 /* call the implementation of the previsit of this pass */ \ 31 33 __pass::previsit( pass, node, 0 ); … … 42 44 auto __return = __pass::postvisit( pass, node, 0 ); \ 43 45 assertf(__return, "post visit should never return null"); \ 46 /* end tracing memory allocation if requested by this pass */ \ 47 __pass::endTrace( pass, 0 ); \ 44 48 return __return; 45 49 … … 127 131 , decltype( node->accept(*this) ) 128 132 >::type 129 130 133 { 131 134 __pedantic_pass_assert( __visit_children() ); 132 __pedantic_pass_assert( expr);135 __pedantic_pass_assert( node ); 133 136 134 137 static_assert( !std::is_base_of<ast::Expr, node_t>::value, "ERROR"); … … 323 326 } 324 327 328 329 template< typename pass_t > 330 template< typename node_t > 331 void ast::Pass< pass_t >::mutate_forall( const node_t *& node ) { 332 if ( auto subs = __pass::forall::subs( pass, 0 ) ) { 333 // tracking TypeDecl substitution, full clone 334 if ( node->forall.empty() ) return; 335 336 node_t * mut = mutate( node ); 337 mut->forall = subs->clone( node->forall, *this ); 338 node = mut; 339 } else { 340 // not tracking TypeDecl substitution, just mutate 341 maybe_accept( node, &node_t::forall ); 342 } 343 } 325 344 } 326 345 … … 429 448 guard_symtab guard { *this }; 430 449 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 431 static ast:: ObjectDecl func(432 node->location, "__func__",433 new ast::ArrayType (434 new ast::BasicType ( ast::BasicType::Char, ast::CV::Qualifiers( ast::CV::Const ) ),450 static ast::ptr< ast::ObjectDecl > func{ new ast::ObjectDecl{ 451 CodeLocation{}, "__func__", 452 new ast::ArrayType{ 453 new ast::BasicType{ ast::BasicType::Char, ast::CV::Const }, 435 454 nullptr, VariableLen, DynamicDim 436 )437 );438 __pass::symtab::addId( pass, 0, &func );455 } 456 } }; 457 __pass::symtab::addId( pass, 0, func ); 439 458 VISIT( 440 459 maybe_accept( node, &FunctionDecl::type ); … … 610 629 VISIT({ 611 630 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 612 auto guard1 = makeFuncGuard( [this, inFunction = this->inFunction]() {613 if ( ! inFunction ) __pass::symtab::enter(pass, 0);614 }, [this, inFunction = this->inFunction]() {615 if ( ! inFunction ) __pass::symtab::leave(pass, 0);631 auto guard1 = makeFuncGuard( [this, inFunctionCpy = this->inFunction]() { 632 if ( ! inFunctionCpy ) __pass::symtab::enter(pass, 0); 633 }, [this, inFunctionCpy = this->inFunction]() { 634 if ( ! inFunctionCpy ) __pass::symtab::leave(pass, 0); 616 635 }); 617 636 ValueGuard< bool > guard2( inFunction ); … … 951 970 // For now this isn't visited, it is unclear if this causes problem 952 971 // if all tests are known to pass, remove this code 953 //VISIT(954 //maybe_accept( node, &ImplicitCtorDtorStmt::callStmt );955 //)972 VISIT( 973 maybe_accept( node, &ImplicitCtorDtorStmt::callStmt ); 974 ) 956 975 957 976 VISIT_END( Stmt, node ); … … 1679 1698 VISIT_START( node ); 1680 1699 1681 VISIT( 1682 maybe_accept( node, &FunctionType::forall ); 1700 VISIT({ 1701 guard_forall_subs forall_guard { *this, node }; 1702 mutate_forall( node ); 1683 1703 maybe_accept( node, &FunctionType::returns ); 1684 1704 maybe_accept( node, &FunctionType::params ); 1685 )1705 }) 1686 1706 1687 1707 VISIT_END( Type, node ); … … 1698 1718 VISIT({ 1699 1719 guard_symtab guard { *this }; 1700 maybe_accept( node, &StructInstType::forall ); 1720 guard_forall_subs forall_guard { *this, node }; 1721 mutate_forall( node ); 1701 1722 maybe_accept( node, &StructInstType::params ); 1702 1723 }) … … 1711 1732 VISIT_START( node ); 1712 1733 1713 __pass::symtab::add Struct( pass, 0, node->name );1714 1715 {1734 __pass::symtab::addUnion( pass, 0, node->name ); 1735 1736 VISIT({ 1716 1737 guard_symtab guard { *this }; 1717 maybe_accept( node, &UnionInstType::forall ); 1738 guard_forall_subs forall_guard { *this, node }; 1739 mutate_forall( node ); 1718 1740 maybe_accept( node, &UnionInstType::params ); 1719 } 1741 }) 1720 1742 1721 1743 VISIT_END( Type, node ); … … 1728 1750 VISIT_START( node ); 1729 1751 1730 VISIT( 1731 maybe_accept( node, &EnumInstType::forall ); 1752 VISIT({ 1753 guard_forall_subs forall_guard { *this, node }; 1754 mutate_forall( node ); 1732 1755 maybe_accept( node, &EnumInstType::params ); 1733 )1756 }) 1734 1757 1735 1758 VISIT_END( Type, node ); … … 1742 1765 VISIT_START( node ); 1743 1766 1744 VISIT( 1745 maybe_accept( node, &TraitInstType::forall ); 1767 VISIT({ 1768 guard_forall_subs forall_guard { *this, node }; 1769 mutate_forall( node ); 1746 1770 maybe_accept( node, &TraitInstType::params ); 1747 )1771 }) 1748 1772 1749 1773 VISIT_END( Type, node ); … … 1757 1781 1758 1782 VISIT( 1759 maybe_accept( node, &TypeInstType::forall ); 1760 maybe_accept( node, &TypeInstType::params ); 1783 { 1784 guard_forall_subs forall_guard { *this, node }; 1785 mutate_forall( node ); 1786 maybe_accept( node, &TypeInstType::params ); 1787 } 1788 // ensure that base re-bound if doing substitution 1789 __pass::forall::replace( pass, 0, node ); 1761 1790 ) 1762 1791 … … 1907 1936 guard_symtab guard { *this }; 1908 1937 auto new_node = p.second->accept( *this ); 1909 if (new_node != p.second) mutated = false;1938 if (new_node != p.second) mutated = true; 1910 1939 new_map.insert({ p.first, new_node }); 1911 1940 } … … 1923 1952 guard_symtab guard { *this }; 1924 1953 auto new_node = p.second->accept( *this ); 1925 if (new_node != p.second) mutated = false;1954 if (new_node != p.second) mutated = true; 1926 1955 new_map.insert({ p.first, new_node }); 1927 1956 }
Note:
See TracChangeset
for help on using the changeset viewer.