Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.hpp

    r7ff3e522 ra86b2ca6  
    6666// | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation
    6767//-------------------------------------------------------------------------------------------------
    68 template< typename core_t >
     68template< typename pass_t >
    6969class Pass final : public ast::Visitor {
    7070public:
    71         using core_type = core_t;
    72         using type = Pass<core_t>;
    73 
    7471        /// Forward any arguments to the pass constructor
    7572        /// Propagate 'this' if necessary
    7673        template< typename... Args >
    7774        Pass( Args &&... args)
    78                 : core( std::forward<Args>( args )... )
     75                : pass( std::forward<Args>( args )... )
    7976        {
    8077                // After the pass is constructed, check if it wants the have a pointer to the wrapping visitor
    81                 type * const * visitor = __pass::visitor(core, 0);
     78                typedef Pass<pass_t> this_t;
     79                this_t * const * visitor = __pass::visitor(pass, 0);
    8280                if(visitor) {
    83                         *const_cast<type **>( visitor ) = this;
     81                        *const_cast<this_t **>( visitor ) = this;
    8482                }
    8583        }
     
    9088        template< typename... Args >
    9189        static void run( std::list< ptr<Decl> > & decls, Args &&... args ) {
    92                 Pass<core_t> visitor( std::forward<Args>( args )... );
     90                Pass<pass_t> visitor( std::forward<Args>( args )... );
    9391                accept_all( decls, visitor );
    9492        }
    9593
    9694        /// Storage for the actual pass
    97         core_t core;
     95        pass_t pass;
    9896
    9997        /// Visit function declarations
     
    191189        const ast::TypeSubstitution * visit( const ast::TypeSubstitution     * ) override final;
    192190
    193         template<typename core_type>
    194         friend void accept_all( std::list< ptr<Decl> > & decls, Pass<core_type>& visitor );
     191        template<typename pass_type>
     192        friend void accept_all( std::list< ptr<Decl> > & decls, Pass<pass_type>& visitor );
    195193private:
    196194
    197         bool __visit_children() { __pass::bool_ref * ptr = __pass::visit_children(core, 0); return ptr ? *ptr : true; }
     195        bool __visit_children() { __pass::bool_ref * ptr = __pass::visit_children(pass, 0); return ptr ? *ptr : true; }
    198196
    199197private:
     
    226224        /// Internal RAII guard for symbol table features
    227225        struct guard_symtab {
    228                 guard_symtab( Pass<core_t> & pass ): pass( pass ) { __pass::symtab::enter(pass.core, 0); }
    229                 ~guard_symtab()                                   { __pass::symtab::leave(pass.core, 0); }
    230                 Pass<core_t> & pass;
     226                guard_symtab( Pass<pass_t> & pass ): pass( pass ) { __pass::symtab::enter(pass.pass, 0); }
     227                ~guard_symtab()                                   { __pass::symtab::leave(pass.pass, 0); }
     228                Pass<pass_t> & pass;
    231229        };
    232230
    233231        /// Internal RAII guard for scope features
    234232        struct guard_scope {
    235                 guard_scope( Pass<core_t> & pass ): pass( pass ) { __pass::scope::enter(pass.core, 0); }
    236                 ~guard_scope()                                   { __pass::scope::leave(pass.core, 0); }
    237                 Pass<core_t> & pass;
     233                guard_scope( Pass<pass_t> & pass ): pass( pass ) { __pass::scope::enter(pass.pass, 0); }
     234                ~guard_scope()                                   { __pass::scope::leave(pass.pass, 0); }
     235                Pass<pass_t> & pass;
    238236        };
    239237
    240238        /// Internal RAII guard for forall substitutions
    241239        struct guard_forall_subs {
    242                 guard_forall_subs( Pass<core_t> & pass, const ParameterizedType * type )
    243                 : pass( pass ), type( type ) { __pass::forall::enter(pass.core, 0, type ); }
    244                 ~guard_forall_subs()         { __pass::forall::leave(pass.core, 0, type ); }
    245                 Pass<core_t> & pass;
     240                guard_forall_subs( Pass<pass_t> & pass, const ParameterizedType * type )
     241                : pass( pass ), type( type ) { __pass::forall::enter(pass.pass, 0, type ); }
     242                ~guard_forall_subs()         { __pass::forall::leave(pass.pass, 0, type ); }
     243                Pass<pass_t> & pass;
    246244                const ParameterizedType * type;
    247245        };
     
    252250
    253251/// Apply a pass to an entire translation unit
    254 template<typename core_t>
    255 void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass<core_t> & visitor );
     252template<typename pass_t>
     253void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass<pass_t> & visitor );
    256254
    257255//-------------------------------------------------------------------------------------------------
     
    293291        };
    294292
    295         template< typename core_t>
    296         friend auto __pass::at_cleanup( core_t & core, int ) -> decltype( &core.at_cleanup );
     293        template< typename pass_t>
     294        friend auto __pass::at_cleanup( pass_t & pass, int ) -> decltype( &pass.at_cleanup );
    297295public:
    298296
     
    330328
    331329/// Used to get a pointer to the pass with its wrapped type
    332 template<typename core_t>
     330template<typename pass_t>
    333331struct WithVisitorRef {
    334         Pass<core_t> * const visitor = nullptr;
     332        Pass<pass_t> * const visitor = nullptr;
    335333};
    336334
Note: See TracChangeset for help on using the changeset viewer.