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