Changes in src/AST/Pass.impl.hpp [c15085d:37cdd97]
- File:
-
- 1 edited
-
src/AST/Pass.impl.hpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
rc15085d r37cdd97 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 ); \32 30 /* call the implementation of the previsit of this pass */ \ 33 31 __pass::previsit( pass, node, 0 ); … … 44 42 auto __return = __pass::postvisit( pass, node, 0 ); \ 45 43 assertf(__return, "post visit should never return null"); \ 46 /* end tracing memory allocation if requested by this pass */ \47 __pass::endTrace( pass, 0 ); \48 44 return __return; 49 45 … … 131 127 , decltype( node->accept(*this) ) 132 128 >::type 129 133 130 { 134 131 __pedantic_pass_assert( __visit_children() ); 135 __pedantic_pass_assert( node);132 __pedantic_pass_assert( expr ); 136 133 137 134 static_assert( !std::is_base_of<ast::Expr, node_t>::value, "ERROR"); … … 326 323 } 327 324 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 clone334 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 mutate341 maybe_accept( node, &node_t::forall );342 }343 }344 325 } 345 326 … … 448 429 guard_symtab guard { *this }; 449 430 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 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 },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 ) ), 454 435 nullptr, VariableLen, DynamicDim 455 }456 } };457 __pass::symtab::addId( pass, 0, func );436 ) 437 ); 438 __pass::symtab::addId( pass, 0, &func ); 458 439 VISIT( 459 440 maybe_accept( node, &FunctionDecl::type ); … … 629 610 VISIT({ 630 611 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 631 auto guard1 = makeFuncGuard( [this, inFunction Cpy= this->inFunction]() {632 if ( ! inFunction Cpy) __pass::symtab::enter(pass, 0);633 }, [this, inFunction Cpy= this->inFunction]() {634 if ( ! inFunction Cpy) __pass::symtab::leave(pass, 0);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); 635 616 }); 636 617 ValueGuard< bool > guard2( inFunction ); … … 970 951 // For now this isn't visited, it is unclear if this causes problem 971 952 // if all tests are known to pass, remove this code 972 VISIT(973 maybe_accept( node, &ImplicitCtorDtorStmt::callStmt );974 )953 // VISIT( 954 // maybe_accept( node, &ImplicitCtorDtorStmt::callStmt ); 955 // ) 975 956 976 957 VISIT_END( Stmt, node ); … … 1698 1679 VISIT_START( node ); 1699 1680 1700 VISIT({ 1701 guard_forall_subs forall_guard { *this, node }; 1702 mutate_forall( node ); 1681 VISIT( 1682 maybe_accept( node, &FunctionType::forall ); 1703 1683 maybe_accept( node, &FunctionType::returns ); 1704 1684 maybe_accept( node, &FunctionType::params ); 1705 })1685 ) 1706 1686 1707 1687 VISIT_END( Type, node ); … … 1718 1698 VISIT({ 1719 1699 guard_symtab guard { *this }; 1720 guard_forall_subs forall_guard { *this, node }; 1721 mutate_forall( node ); 1700 maybe_accept( node, &StructInstType::forall ); 1722 1701 maybe_accept( node, &StructInstType::params ); 1723 1702 }) … … 1732 1711 VISIT_START( node ); 1733 1712 1734 __pass::symtab::add Union( pass, 0, node->name );1735 1736 VISIT({1713 __pass::symtab::addStruct( pass, 0, node->name ); 1714 1715 { 1737 1716 guard_symtab guard { *this }; 1738 guard_forall_subs forall_guard { *this, node }; 1739 mutate_forall( node ); 1717 maybe_accept( node, &UnionInstType::forall ); 1740 1718 maybe_accept( node, &UnionInstType::params ); 1741 } )1719 } 1742 1720 1743 1721 VISIT_END( Type, node ); … … 1750 1728 VISIT_START( node ); 1751 1729 1752 VISIT({ 1753 guard_forall_subs forall_guard { *this, node }; 1754 mutate_forall( node ); 1730 VISIT( 1731 maybe_accept( node, &EnumInstType::forall ); 1755 1732 maybe_accept( node, &EnumInstType::params ); 1756 })1733 ) 1757 1734 1758 1735 VISIT_END( Type, node ); … … 1765 1742 VISIT_START( node ); 1766 1743 1767 VISIT({ 1768 guard_forall_subs forall_guard { *this, node }; 1769 mutate_forall( node ); 1744 VISIT( 1745 maybe_accept( node, &TraitInstType::forall ); 1770 1746 maybe_accept( node, &TraitInstType::params ); 1771 })1747 ) 1772 1748 1773 1749 VISIT_END( Type, node ); … … 1781 1757 1782 1758 VISIT( 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 ); 1759 maybe_accept( node, &TypeInstType::forall ); 1760 maybe_accept( node, &TypeInstType::params ); 1790 1761 ) 1791 1762 … … 1936 1907 guard_symtab guard { *this }; 1937 1908 auto new_node = p.second->accept( *this ); 1938 if (new_node != p.second) mutated = true;1909 if (new_node != p.second) mutated = false; 1939 1910 new_map.insert({ p.first, new_node }); 1940 1911 } … … 1952 1923 guard_symtab guard { *this }; 1953 1924 auto new_node = p.second->accept( *this ); 1954 if (new_node != p.second) mutated = true;1925 if (new_node != p.second) mutated = false; 1955 1926 new_map.insert({ p.first, new_node }); 1956 1927 }
Note:
See TracChangeset
for help on using the changeset viewer.