Ignore:
File:
1 edited

Legend:

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

    rc15085d r37cdd97  
    2828        /* setup the scope for passes that want to run code at exit */ \
    2929        __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 ); \
    3230        /* call the implementation of the previsit of this pass */ \
    3331        __pass::previsit( pass, node, 0 );
     
    4442        auto __return = __pass::postvisit( pass, node, 0 ); \
    4543        assertf(__return, "post visit should never return null"); \
    46         /* end tracing memory allocation if requested by this pass */ \
    47         __pass::endTrace( pass, 0 ); \
    4844        return __return;
    4945
     
    131127                        , decltype( node->accept(*this) )
    132128                >::type
     129
    133130        {
    134131                __pedantic_pass_assert( __visit_children() );
    135                 __pedantic_pass_assert( node );
     132                __pedantic_pass_assert( expr );
    136133
    137134                static_assert( !std::is_base_of<ast::Expr, node_t>::value, "ERROR");
     
    326323        }
    327324
    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 clone
    334                         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 mutate
    341                         maybe_accept( node, &node_t::forall );
    342                 }
    343         }
    344325}
    345326
     
    448429                        guard_symtab guard { *this };
    449430                        // 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 ) ),
    454435                                        nullptr, VariableLen, DynamicDim
    455                                 }
    456                         } };
    457                         __pass::symtab::addId( pass, 0, func );
     436                                )
     437                        );
     438                        __pass::symtab::addId( pass, 0, &func );
    458439                        VISIT(
    459440                                maybe_accept( node, &FunctionDecl::type );
     
    629610        VISIT({
    630611                // do not enter a new scope if inFunction is true - needs to check old state before the assignment
    631                 auto guard1 = makeFuncGuard( [this, inFunctionCpy = this->inFunction]() {
    632                         if ( ! inFunctionCpy ) __pass::symtab::enter(pass, 0);
    633                 }, [this, inFunctionCpy = this->inFunction]() {
    634                         if ( ! inFunctionCpy ) __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);
    635616                });
    636617                ValueGuard< bool > guard2( inFunction );
     
    970951        // For now this isn't visited, it is unclear if this causes problem
    971952        // 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        // )
    975956
    976957        VISIT_END( Stmt, node );
     
    16981679        VISIT_START( node );
    16991680
    1700         VISIT({
    1701                 guard_forall_subs forall_guard { *this, node };
    1702                 mutate_forall( node );
     1681        VISIT(
     1682                maybe_accept( node, &FunctionType::forall  );
    17031683                maybe_accept( node, &FunctionType::returns );
    17041684                maybe_accept( node, &FunctionType::params  );
    1705         })
     1685        )
    17061686
    17071687        VISIT_END( Type, node );
     
    17181698        VISIT({
    17191699                guard_symtab guard { *this };
    1720                 guard_forall_subs forall_guard { *this, node };
    1721                 mutate_forall( node );
     1700                maybe_accept( node, &StructInstType::forall );
    17221701                maybe_accept( node, &StructInstType::params );
    17231702        })
     
    17321711        VISIT_START( node );
    17331712
    1734         __pass::symtab::addUnion( pass, 0, node->name );
    1735 
    1736         VISIT({
     1713        __pass::symtab::addStruct( pass, 0, node->name );
     1714
     1715        {
    17371716                guard_symtab guard { *this };
    1738                 guard_forall_subs forall_guard { *this, node };
    1739                 mutate_forall( node );
     1717                maybe_accept( node, &UnionInstType::forall );
    17401718                maybe_accept( node, &UnionInstType::params );
    1741         })
     1719        }
    17421720
    17431721        VISIT_END( Type, node );
     
    17501728        VISIT_START( node );
    17511729
    1752         VISIT({
    1753                 guard_forall_subs forall_guard { *this, node };
    1754                 mutate_forall( node );
     1730        VISIT(
     1731                maybe_accept( node, &EnumInstType::forall );
    17551732                maybe_accept( node, &EnumInstType::params );
    1756         })
     1733        )
    17571734
    17581735        VISIT_END( Type, node );
     
    17651742        VISIT_START( node );
    17661743
    1767         VISIT({
    1768                 guard_forall_subs forall_guard { *this, node };
    1769                 mutate_forall( node );
     1744        VISIT(
     1745                maybe_accept( node, &TraitInstType::forall );
    17701746                maybe_accept( node, &TraitInstType::params );
    1771         })
     1747        )
    17721748
    17731749        VISIT_END( Type, node );
     
    17811757
    17821758        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 );
    17901761        )
    17911762
     
    19361907                                guard_symtab guard { *this };
    19371908                                auto new_node = p.second->accept( *this );
    1938                                 if (new_node != p.second) mutated = true;
     1909                                if (new_node != p.second) mutated = false;
    19391910                                new_map.insert({ p.first, new_node });
    19401911                        }
     
    19521923                                guard_symtab guard { *this };
    19531924                                auto new_node = p.second->accept( *this );
    1954                                 if (new_node != p.second) mutated = true;
     1925                                if (new_node != p.second) mutated = false;
    19551926                                new_map.insert({ p.first, new_node });
    19561927                        }
Note: See TracChangeset for help on using the changeset viewer.