Changeset 7ff3e522 for src/AST/Pass.hpp


Ignore:
Timestamp:
Aug 12, 2020, 10:31:58 AM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f8d05ee
Parents:
343d10e
Message:

{pass_t Pass::pass; => core_t Pass::core;} To avoid confusion about which pass we are talking about.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.hpp

    r343d10e r7ff3e522  
    6666// | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation
    6767//-------------------------------------------------------------------------------------------------
    68 template< typename pass_t >
     68template< typename core_t >
    6969class Pass final : public ast::Visitor {
    7070public:
     71        using core_type = core_t;
     72        using type = Pass<core_t>;
     73
    7174        /// Forward any arguments to the pass constructor
    7275        /// Propagate 'this' if necessary
    7376        template< typename... Args >
    7477        Pass( Args &&... args)
    75                 : pass( std::forward<Args>( args )... )
     78                : core( std::forward<Args>( args )... )
    7679        {
    7780                // After the pass is constructed, check if it wants the have a pointer to the wrapping visitor
    78                 typedef Pass<pass_t> this_t;
    79                 this_t * const * visitor = __pass::visitor(pass, 0);
     81                type * const * visitor = __pass::visitor(core, 0);
    8082                if(visitor) {
    81                         *const_cast<this_t **>( visitor ) = this;
     83                        *const_cast<type **>( visitor ) = this;
    8284                }
    8385        }
     
    8890        template< typename... Args >
    8991        static void run( std::list< ptr<Decl> > & decls, Args &&... args ) {
    90                 Pass<pass_t> visitor( std::forward<Args>( args )... );
     92                Pass<core_t> visitor( std::forward<Args>( args )... );
    9193                accept_all( decls, visitor );
    9294        }
    9395
    9496        /// Storage for the actual pass
    95         pass_t pass;
     97        core_t core;
    9698
    9799        /// Visit function declarations
     
    189191        const ast::TypeSubstitution * visit( const ast::TypeSubstitution     * ) override final;
    190192
    191         template<typename pass_type>
    192         friend void accept_all( std::list< ptr<Decl> > & decls, Pass<pass_type>& visitor );
     193        template<typename core_type>
     194        friend void accept_all( std::list< ptr<Decl> > & decls, Pass<core_type>& visitor );
    193195private:
    194196
    195         bool __visit_children() { __pass::bool_ref * ptr = __pass::visit_children(pass, 0); return ptr ? *ptr : true; }
     197        bool __visit_children() { __pass::bool_ref * ptr = __pass::visit_children(core, 0); return ptr ? *ptr : true; }
    196198
    197199private:
     
    224226        /// Internal RAII guard for symbol table features
    225227        struct guard_symtab {
    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;
     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;
    229231        };
    230232
    231233        /// Internal RAII guard for scope features
    232234        struct guard_scope {
    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;
     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;
    236238        };
    237239
    238240        /// Internal RAII guard for forall substitutions
    239241        struct guard_forall_subs {
    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;
     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;
    244246                const ParameterizedType * type;
    245247        };
     
    250252
    251253/// Apply a pass to an entire translation unit
    252 template<typename pass_t>
    253 void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass<pass_t> & visitor );
     254template<typename core_t>
     255void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass<core_t> & visitor );
    254256
    255257//-------------------------------------------------------------------------------------------------
     
    291293        };
    292294
    293         template< typename pass_t>
    294         friend auto __pass::at_cleanup( pass_t & pass, int ) -> decltype( &pass.at_cleanup );
     295        template< typename core_t>
     296        friend auto __pass::at_cleanup( core_t & core, int ) -> decltype( &core.at_cleanup );
    295297public:
    296298
     
    328330
    329331/// Used to get a pointer to the pass with its wrapped type
    330 template<typename pass_t>
     332template<typename core_t>
    331333struct WithVisitorRef {
    332         Pass<pass_t> * const visitor = nullptr;
     334        Pass<core_t> * const visitor = nullptr;
    333335};
    334336
Note: See TracChangeset for help on using the changeset viewer.