Changeset d24d4e1 for src/Common/PassVisitor.h
- Timestamp:
- Jun 23, 2017, 12:12:46 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 2a7b3ca
- Parents:
- ba915fb5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
rba915fb5 rd24d4e1 26 26 // stmtsToAddBefore or stmtsToAddAfter respectively. 27 27 // | WithShortCircuiting - provides the ability to skip visiting child nodes; set visit_children to false in pre{visit,mutate} to skip visiting children 28 // | With Scopes - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable28 // | WithGuards - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable 29 29 // will automatically be restored to its previous value after the corresponding postvisit/postmutate teminates. 30 30 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- … … 32 32 class PassVisitor final : public Visitor, public Mutator { 33 33 public: 34 PassVisitor() = default;35 34 36 35 template< typename... Args > … … 283 282 284 283 public: 285 TypeSubstitution * env ;284 TypeSubstitution * env = nullptr; 286 285 }; 287 286 … … 295 294 std::list< Statement* > stmtsToAddAfter; 296 295 }; 296 297 class WithDeclsToAdd { 298 protected: 299 WithDeclsToAdd() = default; 300 ~WithDeclsToAdd() = default; 301 302 public: 303 std::list< Declaration* > declsToAddBefore; 304 std::list< Declaration* > declsToAddAfter; 305 }; 306 297 307 class WithShortCircuiting { 298 308 protected: … … 304 314 }; 305 315 306 class With Scopes {307 protected: 308 With Scopes() = default;309 ~With Scopes() = default;316 class WithGuards { 317 protected: 318 WithGuards() = default; 319 ~WithGuards() = default; 310 320 311 321 public: … … 319 329 } 320 330 331 template< typename T > 332 void GuardScope( T& val ) { 333 val.beginScope(); 334 at_cleanup( []( void * val ) { 335 static_cast< T * >( val )->endScope(); 336 }, static_cast< void * >( & val ) ); 337 } 338 321 339 template< typename Func > 322 void GuardAction( Func &&func ) {323 at_cleanup( std::forward<Func>( func ));340 void GuardAction( Func func ) { 341 at_cleanup( [func](__attribute__((unused)) void *) { func(); }, nullptr ); 324 342 } 325 343 }; … … 328 346 class WithVisitorRef { 329 347 protected: 330 WithVisitorRef() = default;331 ~WithVisitorRef() = default;332 333 public: 334 PassVisitor<pass_type> * const visitor ;348 WithVisitorRef() {} 349 ~WithVisitorRef() {} 350 351 public: 352 PassVisitor<pass_type> * const visitor = nullptr; 335 353 }; 336 354
Note: See TracChangeset
for help on using the changeset viewer.