Changes in / [9c90718:186b398]
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
r9c90718 r186b398 37 37 PassVisitor(Args &&... args) 38 38 : pass( std::forward<Args>( args )... ) 39 {} 39 { 40 typedef PassVisitor<pass_type> this_t; 41 this_t * const * visitor = visitor_impl(pass, 0); 42 if(visitor) { 43 *const_cast<this_t **>( visitor ) = this; 44 } 45 } 40 46 41 47 virtual ~PassVisitor() = default; … … 238 244 std::list< Statement* > * get_beforeStmts() { return stmtsToAddBefore_impl( pass, 0); } 239 245 std::list< Statement* > * get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); } 240 bool visit_children() { bool* skip = skip_children_impl(pass, 0); return ! (skip && *skip); } 241 void reset_visit() { bool* skip = skip_children_impl(pass, 0); if(skip) *skip = false; } 246 std::list< Declaration* > * get_beforeDecls() { return declsToAddBefore_impl( pass, 0); } 247 std::list< Declaration* > * get_afterDecls () { return declsToAddAfter_impl ( pass, 0); } 248 249 void set_visit_children( bool& ref ) { bool_ref * ptr = visit_children_impl(pass, 0); if(ptr) ptr->set( ref ); } 242 250 243 251 guard_value_impl init_guard() { … … 278 286 std::list< Statement* > stmtsToAddAfter; 279 287 }; 280 281 288 class WithShortCircuiting { 282 289 protected: … … 285 292 286 293 public: 287 bool skip_children;294 bool_ref visit_children; 288 295 }; 289 296 … … 304 311 }; 305 312 313 template<typename pass_type> 314 class WithVisitorRef { 315 protected: 316 WithVisitorRef() = default; 317 ~WithVisitorRef() = default; 318 319 public: 320 PassVisitor<pass_type> * const visitor; 321 }; 306 322 307 323 #include "PassVisitor.impl.h" -
src/Common/PassVisitor.impl.h
r9c90718 r186b398 4 4 __attribute__((unused)) \ 5 5 const auto & guard = init_guard(); \ 6 bool visit_children = true; \ 7 set_visit_children( visit_children ); \ 6 8 call_previsit( node ); \ 7 if( visit_children () ) {\9 if( visit_children ) { \ 8 10 9 11 #define VISIT_END( node ) \ 10 12 } \ 11 reset_visit(); \12 13 call_postvisit( node ); \ 13 14 … … 15 16 __attribute__((unused)) \ 16 17 const auto & guard = init_guard(); \ 18 bool visit_children = true; \ 19 set_visit_children( visit_children ); \ 17 20 call_premutate( node ); \ 18 if( visit_children () ) {\21 if( visit_children ) { \ 19 22 20 23 #define MUTATE_END( type, node ) \ 21 24 } \ 22 reset_visit(); \23 25 return call_postmutate< type * >( node ); \ 24 26 … … 348 350 349 351 //-------------------------------------------------------------------------- 350 // SwitchStmt352 // CaseStmt 351 353 template< typename pass_type > 352 354 void PassVisitor< pass_type >::visit( CaseStmt * node ) { -
src/Common/PassVisitor.proto.h
r9c90718 r186b398 1 1 #pragma once 2 3 template<typename pass_type> 4 class PassVisitor; 2 5 3 6 typedef std::function<void( void * )> cleanup_func_t; … … 31 34 32 35 typedef std::function< void( cleanup_func_t, void * ) > at_cleanup_t; 36 37 class bool_ref { 38 public: 39 bool_ref() = default; 40 ~bool_ref() = default; 41 42 operator bool() { return *m_ref; } 43 bool operator=( bool val ) { return *m_ref = val; } 44 45 private: 46 47 template<typename pass> 48 friend class PassVisitor; 49 50 void set( bool & val ) { m_ref = &val; }; 51 52 bool * m_ref; 53 }; 33 54 34 55 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- … … 112 133 FIELD_PTR( std::list< Statement* >, stmtsToAddBefore ) 113 134 FIELD_PTR( std::list< Statement* >, stmtsToAddAfter ) 114 FIELD_PTR( bool, skip_children ) 135 FIELD_PTR( std::list< Declaration* >, declsToAddBefore ) 136 FIELD_PTR( std::list< Declaration* >, declsToAddAfter ) 137 FIELD_PTR( bool_ref, visit_children ) 115 138 FIELD_PTR( at_cleanup_t, at_cleanup ) 139 FIELD_PTR( PassVisitor<pass_type> * const, visitor ) -
src/InitTweak/InitTweak.cc
r9c90718 r186b398 474 474 public: 475 475 ConstExprChecker() : isConstExpr( true ) {} 476 477 using Visitor::visit; 476 478 477 479 virtual void visit( __attribute((unused)) ApplicationExpr *applicationExpr ) { isConstExpr = false; }
Note: See TracChangeset
for help on using the changeset viewer.