Changes in src/Common/PassVisitor.proto.h [3c398b6:522363e]
- File:
-
- 1 edited
-
src/Common/PassVisitor.proto.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.proto.h
r3c398b6 r522363e 46 46 ~bool_ref() = default; 47 47 48 operator bool() { return m_ref ? *m_ref : true; }48 operator bool() { return *m_ref; } 49 49 bool operator=( bool val ) { return *m_ref = val; } 50 50 51 51 private: 52 52 53 friend class ChildrenGuard; 54 55 bool * set( bool & val ) { 56 bool * prev = m_ref; 57 m_ref = &val; 58 return prev; 59 } 60 61 bool * m_ref = nullptr; 53 template<typename pass> 54 friend class PassVisitor; 55 56 void set( bool & val ) { m_ref = &val; }; 57 58 bool * m_ref; 62 59 }; 63 60 64 class ChildrenGuard { 65 public: 66 67 ChildrenGuard( bool_ref * ref )68 : m_val ( true )69 , m_prev( ref ? ref->set( m_val ) : nullptr )70 , m_ref ( ref )71 {}72 73 ~ChildrenGuard() { 74 if( m_ref) {75 m_ref->set( *m_prev );76 }77 }78 79 operator bool() { return m_val; }80 81 private: 82 bool m_val; 83 bool * m_prev; 84 bool_ref * m_ref;85 } ;61 template< typename TreeType, typename VisitorType > 62 inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) { 63 auto guard = makeFuncGuard( 64 [&visitor]() { visitor.indexerScopeEnter(); }, 65 [&visitor]() { visitor.indexerScopeLeave(); } 66 ); 67 maybeAccept( tree, visitor ); 68 } 69 70 template< typename TreeType, typename MutatorType > 71 inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) { 72 auto guard = makeFuncGuard( 73 [&mutator]() { mutator.indexerScopeEnter(); }, 74 [&mutator]() { mutator.indexerScopeLeave(); } 75 ); 76 tree = maybeMutate( tree, mutator ); 77 } 78 79 template< typename TreeType, typename MutatorType > 80 inline void maybeMutateRef( TreeType *& tree, MutatorType & mutator ) { 81 tree = maybeMutate( tree, mutator ); 82 } 86 83 87 84 //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.