Changeset 53449a4 for src/AST/Pass.impl.hpp
- Timestamp:
- Dec 16, 2020, 4:01:57 PM (2 years ago)
- Branches:
- ADT, arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8ba363e, c8025a21
- Parents:
- b3c8496 (diff), 3e5dd913 (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/AST/Pass.impl.hpp
rb3c8496 r53449a4 367 367 } 368 368 369 370 template< typename core_t >371 template< typename node_t >372 void ast::Pass< core_t >::mutate_forall( const node_t *& node ) {373 if ( auto subs = __pass::forall::subs( core, 0 ) ) {374 // tracking TypeDecl substitution, full clone375 if ( node->forall.empty() ) return;376 377 node_t * mut = __pass::mutate<core_t>( node );378 mut->forall = subs->clone( node->forall, *this );379 node = mut;380 } else {381 // not tracking TypeDecl substitution, just mutate382 maybe_accept( node, &node_t::forall );383 }384 }385 369 } 386 370 … … 504 488 __pass::symtab::addId( core, 0, func ); 505 489 VISIT( 506 // parameter declarations are now directly here490 // parameter declarations 507 491 maybe_accept( node, &FunctionDecl::params ); 508 492 maybe_accept( node, &FunctionDecl::returns ); 509 // foralls are still in function type 510 maybe_accept( node, &FunctionDecl::type ); 493 // type params and assertions 494 maybe_accept( node, &FunctionDecl::type_params ); 495 maybe_accept( node, &FunctionDecl::assertions ); 511 496 // First remember that we are now within a function. 512 497 ValueGuard< bool > oldInFunction( inFunction ); … … 609 594 VISIT({ 610 595 guard_symtab guard { *this }; 611 maybe_accept( node, &TypeDecl::params );612 596 maybe_accept( node, &TypeDecl::base ); 613 597 }) … … 638 622 VISIT({ 639 623 guard_symtab guard { *this }; 640 maybe_accept( node, &TypedefDecl::params );641 624 maybe_accept( node, &TypedefDecl::base ); 642 625 }) … … 1760 1743 1761 1744 VISIT({ 1762 guard_forall_subs forall_guard { *this, node }; 1763 mutate_forall( node ); 1745 // guard_forall_subs forall_guard { *this, node }; 1746 // mutate_forall( node ); 1747 maybe_accept( node, &FunctionType::assertions ); 1764 1748 maybe_accept( node, &FunctionType::returns ); 1765 1749 maybe_accept( node, &FunctionType::params ); … … 1779 1763 VISIT({ 1780 1764 guard_symtab guard { *this }; 1781 guard_forall_subs forall_guard { *this, node };1782 mutate_forall( node );1783 1765 maybe_accept( node, &StructInstType::params ); 1784 1766 }) … … 1797 1779 VISIT({ 1798 1780 guard_symtab guard { *this }; 1799 guard_forall_subs forall_guard { *this, node };1800 mutate_forall( node );1801 1781 maybe_accept( node, &UnionInstType::params ); 1802 1782 }) … … 1812 1792 1813 1793 VISIT({ 1814 guard_forall_subs forall_guard { *this, node };1815 mutate_forall( node );1816 1794 maybe_accept( node, &EnumInstType::params ); 1817 1795 }) … … 1827 1805 1828 1806 VISIT({ 1829 guard_forall_subs forall_guard { *this, node };1830 mutate_forall( node );1831 1807 maybe_accept( node, &TraitInstType::params ); 1832 1808 }) … … 1843 1819 VISIT( 1844 1820 { 1845 guard_forall_subs forall_guard { *this, node };1846 mutate_forall( node );1847 1821 maybe_accept( node, &TypeInstType::params ); 1848 1822 } … … 1993 1967 { 1994 1968 bool mutated = false; 1995 std::unordered_map< std::string, ast::ptr< ast::Type > > new_map;1969 std::unordered_map< ast::TypeInstType::TypeEnvKey, ast::ptr< ast::Type > > new_map; 1996 1970 for ( const auto & p : node->typeEnv ) { 1997 1971 guard_symtab guard { *this }; … … 2006 1980 } 2007 1981 } 2008 2009 {2010 bool mutated = false;2011 std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map;2012 for ( const auto & p : node->varEnv ) {2013 guard_symtab guard { *this };2014 auto new_node = p.second->accept( *this );2015 if (new_node != p.second) mutated = true;2016 new_map.insert({ p.first, new_node });2017 }2018 if (mutated) {2019 auto new_node = __pass::mutate<core_t>( node );2020 new_node->varEnv.swap( new_map );2021 node = new_node;2022 }2023 }2024 1982 ) 2025 1983
Note: See TracChangeset
for help on using the changeset viewer.