Changes in src/AST/Pass.impl.hpp [3e5dd913:361bf01]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r3e5dd913 r361bf01 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 clone 375 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 mutate 382 maybe_accept( node, &node_t::forall ); 383 } 384 } 369 385 } 370 386 … … 488 504 __pass::symtab::addId( core, 0, func ); 489 505 VISIT( 490 // parameter declarations 506 // parameter declarations are now directly here 491 507 maybe_accept( node, &FunctionDecl::params ); 492 508 maybe_accept( node, &FunctionDecl::returns ); 493 // type params and assertions 494 maybe_accept( node, &FunctionDecl::type_params ); 495 maybe_accept( node, &FunctionDecl::assertions ); 509 // foralls are still in function type 510 maybe_accept( node, &FunctionDecl::type ); 496 511 // First remember that we are now within a function. 497 512 ValueGuard< bool > oldInFunction( inFunction ); … … 1743 1758 1744 1759 VISIT({ 1745 // guard_forall_subs forall_guard { *this, node }; 1746 // mutate_forall( node ); 1747 maybe_accept( node, &FunctionType::assertions ); 1760 guard_forall_subs forall_guard { *this, node }; 1761 mutate_forall( node ); 1748 1762 maybe_accept( node, &FunctionType::returns ); 1749 1763 maybe_accept( node, &FunctionType::params ); … … 1967 1981 { 1968 1982 bool mutated = false; 1969 std::unordered_map< ast::TypeInstType::TypeEnvKey, ast::ptr< ast::Type > > new_map;1983 std::unordered_map< std::string, ast::ptr< ast::Type > > new_map; 1970 1984 for ( const auto & p : node->typeEnv ) { 1971 1985 guard_symtab guard { *this }; … … 1980 1994 } 1981 1995 } 1996 1997 { 1998 bool mutated = false; 1999 std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map; 2000 for ( const auto & p : node->varEnv ) { 2001 guard_symtab guard { *this }; 2002 auto new_node = p.second->accept( *this ); 2003 if (new_node != p.second) mutated = true; 2004 new_map.insert({ p.first, new_node }); 2005 } 2006 if (mutated) { 2007 auto new_node = __pass::mutate<core_t>( node ); 2008 new_node->varEnv.swap( new_map ); 2009 node = new_node; 2010 } 2011 } 1982 2012 ) 1983 2013
Note: See TracChangeset
for help on using the changeset viewer.