Changes in src/AST/Pass.hpp [7ff3e522:a86b2ca6]
- File:
-
- 1 edited
-
src/AST/Pass.hpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.hpp
r7ff3e522 ra86b2ca6 66 66 // | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation 67 67 //------------------------------------------------------------------------------------------------- 68 template< typename core_t >68 template< typename pass_t > 69 69 class Pass final : public ast::Visitor { 70 70 public: 71 using core_type = core_t;72 using type = Pass<core_t>;73 74 71 /// Forward any arguments to the pass constructor 75 72 /// Propagate 'this' if necessary 76 73 template< typename... Args > 77 74 Pass( Args &&... args) 78 : core( std::forward<Args>( args )... )75 : pass( std::forward<Args>( args )... ) 79 76 { 80 77 // 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); 82 80 if(visitor) { 83 *const_cast<t ype**>( visitor ) = this;81 *const_cast<this_t **>( visitor ) = this; 84 82 } 85 83 } … … 90 88 template< typename... Args > 91 89 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 )... ); 93 91 accept_all( decls, visitor ); 94 92 } 95 93 96 94 /// Storage for the actual pass 97 core_t core;95 pass_t pass; 98 96 99 97 /// Visit function declarations … … 191 189 const ast::TypeSubstitution * visit( const ast::TypeSubstitution * ) override final; 192 190 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 ); 195 193 private: 196 194 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; } 198 196 199 197 private: … … 226 224 /// Internal RAII guard for symbol table features 227 225 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; 231 229 }; 232 230 233 231 /// Internal RAII guard for scope features 234 232 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; 238 236 }; 239 237 240 238 /// Internal RAII guard for forall substitutions 241 239 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; 246 244 const ParameterizedType * type; 247 245 }; … … 252 250 253 251 /// 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 );252 template<typename pass_t> 253 void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass<pass_t> & visitor ); 256 254 257 255 //------------------------------------------------------------------------------------------------- … … 293 291 }; 294 292 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 ); 297 295 public: 298 296 … … 330 328 331 329 /// Used to get a pointer to the pass with its wrapped type 332 template<typename core_t>330 template<typename pass_t> 333 331 struct WithVisitorRef { 334 Pass< core_t> * const visitor = nullptr;332 Pass<pass_t> * const visitor = nullptr; 335 333 }; 336 334
Note:
See TracChangeset
for help on using the changeset viewer.