Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r3e5dd913 r361bf01  
    367367        }
    368368
     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        }
    369385}
    370386
     
    488504                        __pass::symtab::addId( core, 0, func );
    489505                        VISIT(
    490                                 // parameter declarations
     506                                // parameter declarations are now directly here
    491507                                maybe_accept( node, &FunctionDecl::params );
    492508                                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 );
    496511                                // First remember that we are now within a function.
    497512                                ValueGuard< bool > oldInFunction( inFunction );
     
    17431758
    17441759        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 );
    17481762                maybe_accept( node, &FunctionType::returns );
    17491763                maybe_accept( node, &FunctionType::params  );
     
    19671981                {
    19681982                        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;
    19701984                        for ( const auto & p : node->typeEnv ) {
    19711985                                guard_symtab guard { *this };
     
    19801994                        }
    19811995                }
     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                }
    19822012        )
    19832013
Note: See TracChangeset for help on using the changeset viewer.