Changes in src/AST/Pass.impl.hpp [c570806:665f432]
- File:
-
- 1 edited
-
src/AST/Pass.impl.hpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
rc570806 r665f432 127 127 , decltype( node->accept(*this) ) 128 128 >::type 129 129 130 { 130 131 __pedantic_pass_assert( __visit_children() ); 131 __pedantic_pass_assert( node);132 __pedantic_pass_assert( expr ); 132 133 133 134 static_assert( !std::is_base_of<ast::Expr, node_t>::value, "ERROR"); … … 322 323 } 323 324 324 325 template< typename pass_t >326 template< typename node_t >327 void ast::Pass< pass_t >::mutate_forall( const node_t *& node ) {328 if ( auto subs = __pass::forall::subs( pass, 0 ) ) {329 // tracking TypeDecl substitution, full clone330 if ( node->forall.empty() ) return;331 332 node_t * mut = mutate( node );333 mut->forall = subs->clone( node->forall, *this );334 node = mut;335 } else {336 // not tracking TypeDecl substitution, just mutate337 maybe_accept( node, &node_t::forall );338 }339 }340 325 } 341 326 … … 444 429 guard_symtab guard { *this }; 445 430 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 446 static ast:: ptr< ast::ObjectDecl > func{ new ast::ObjectDecl{447 CodeLocation{}, "__func__",448 new ast::ArrayType {449 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 ) ), 450 435 nullptr, VariableLen, DynamicDim 451 }452 } };453 __pass::symtab::addId( pass, 0, func );436 ) 437 ); 438 __pass::symtab::addId( pass, 0, &func ); 454 439 VISIT( 455 440 maybe_accept( node, &FunctionDecl::type ); … … 625 610 VISIT({ 626 611 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 627 auto guard1 = makeFuncGuard( [this, inFunction Cpy= this->inFunction]() {628 if ( ! inFunction Cpy) __pass::symtab::enter(pass, 0);629 }, [this, inFunction Cpy= this->inFunction]() {630 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); 631 616 }); 632 617 ValueGuard< bool > guard2( inFunction ); … … 953 938 // For now this isn't visited, it is unclear if this causes problem 954 939 // if all tests are known to pass, remove this code 955 VISIT(956 maybe_accept( node, &ImplicitCtorDtorStmt::callStmt );957 )940 // VISIT( 941 // maybe_accept( node, &ImplicitCtorDtorStmt::callStmt ); 942 // ) 958 943 959 944 VISIT_END( Stmt, node ); … … 1315 1300 maybe_accept( node, &AsmExpr::result ); 1316 1301 } 1317 maybe_accept( node, &AsmExpr::inout );1318 1302 maybe_accept( node, &AsmExpr::constraint ); 1319 1303 maybe_accept( node, &AsmExpr::operand ); … … 1682 1666 VISIT_START( node ); 1683 1667 1684 VISIT({ 1685 guard_forall_subs forall_guard { *this, node }; 1686 mutate_forall( node ); 1668 VISIT( 1669 maybe_accept( node, &FunctionType::forall ); 1687 1670 maybe_accept( node, &FunctionType::returns ); 1688 1671 maybe_accept( node, &FunctionType::params ); 1689 })1672 ) 1690 1673 1691 1674 VISIT_END( Type, node ); … … 1702 1685 VISIT({ 1703 1686 guard_symtab guard { *this }; 1704 guard_forall_subs forall_guard { *this, node }; 1705 mutate_forall( node ); 1687 maybe_accept( node, &StructInstType::forall ); 1706 1688 maybe_accept( node, &StructInstType::params ); 1707 1689 }) … … 1716 1698 VISIT_START( node ); 1717 1699 1718 __pass::symtab::add Union( pass, 0, node->name );1719 1720 VISIT({1700 __pass::symtab::addStruct( pass, 0, node->name ); 1701 1702 { 1721 1703 guard_symtab guard { *this }; 1722 guard_forall_subs forall_guard { *this, node }; 1723 mutate_forall( node ); 1704 maybe_accept( node, &UnionInstType::forall ); 1724 1705 maybe_accept( node, &UnionInstType::params ); 1725 } )1706 } 1726 1707 1727 1708 VISIT_END( Type, node ); … … 1734 1715 VISIT_START( node ); 1735 1716 1736 VISIT({ 1737 guard_forall_subs forall_guard { *this, node }; 1738 mutate_forall( node ); 1717 VISIT( 1718 maybe_accept( node, &EnumInstType::forall ); 1739 1719 maybe_accept( node, &EnumInstType::params ); 1740 })1720 ) 1741 1721 1742 1722 VISIT_END( Type, node ); … … 1749 1729 VISIT_START( node ); 1750 1730 1751 VISIT({ 1752 guard_forall_subs forall_guard { *this, node }; 1753 mutate_forall( node ); 1731 VISIT( 1732 maybe_accept( node, &TraitInstType::forall ); 1754 1733 maybe_accept( node, &TraitInstType::params ); 1755 })1734 ) 1756 1735 1757 1736 VISIT_END( Type, node ); … … 1765 1744 1766 1745 VISIT( 1767 { 1768 guard_forall_subs forall_guard { *this, node }; 1769 mutate_forall( node ); 1770 maybe_accept( node, &TypeInstType::params ); 1771 } 1772 // ensure that base re-bound if doing substitution 1773 __pass::forall::replace( pass, 0, node ); 1746 maybe_accept( node, &TypeInstType::forall ); 1747 maybe_accept( node, &TypeInstType::params ); 1774 1748 ) 1775 1749 … … 1920 1894 guard_symtab guard { *this }; 1921 1895 auto new_node = p.second->accept( *this ); 1922 if (new_node != p.second) mutated = true;1896 if (new_node != p.second) mutated = false; 1923 1897 new_map.insert({ p.first, new_node }); 1924 1898 } … … 1936 1910 guard_symtab guard { *this }; 1937 1911 auto new_node = p.second->accept( *this ); 1938 if (new_node != p.second) mutated = true;1912 if (new_node != p.second) mutated = false; 1939 1913 new_map.insert({ p.first, new_node }); 1940 1914 }
Note:
See TracChangeset
for help on using the changeset viewer.