Changes in src/Common/PassVisitor.proto.h [6e09f211:7b13aeb]
- File:
-
- 1 edited
-
src/Common/PassVisitor.proto.h (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.proto.h
r6e09f211 r7b13aeb 1 1 #pragma once 2 3 typedef std::function<void( void * )> cleanup_func_t;4 5 class guard_value_impl {6 public:7 guard_value_impl() = default;8 9 ~guard_value_impl() {10 while( !cleanups.empty() ) {11 auto& cleanup = cleanups.top();12 cleanup.func( cleanup.val );13 cleanups.pop();14 }15 }16 17 void push( cleanup_func_t && func, void* val ) {18 cleanups.emplace( std::move(func), val );19 }20 21 private:22 struct cleanup_t {23 cleanup_func_t func;24 void * val;25 26 cleanup_t( cleanup_func_t&& func, void * val ) : func(func), val(val) {}27 };28 29 std::stack< cleanup_t > cleanups;30 };31 32 typedef std::function< void( cleanup_func_t, void * ) > at_cleanup_t;33 2 34 3 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- … … 49 18 // Visit 50 19 template<typename pass_type, typename node_type> 51 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) {20 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.previsit( node ), void() ) { 52 21 pass.previsit( node ); 53 22 } … … 58 27 59 28 template<typename pass_type, typename node_type> 60 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) {29 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.postvisit( node ), void() ) { 61 30 pass.postvisit( node ); 62 31 } … … 67 36 // Mutate 68 37 template<typename pass_type, typename node_type> 69 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) {38 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.premutate( node ), void() ) { 70 39 return pass.premutate( node ); 71 40 } … … 76 45 77 46 template<typename return_type, typename pass_type, typename node_type> 78 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) {47 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.postmutate( node ) ) { 79 48 return pass.postmutate( node ); 80 49 } … … 85 54 // Begin/End scope 86 55 template<typename pass_type> 87 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) {56 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) ->decltype( pass.beginScope(), void() ) { 88 57 pass.beginScope(); 89 58 } … … 94 63 95 64 template<typename pass_type> 96 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) {65 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) ->decltype( pass.endScope(), void() ) { 97 66 pass.endScope(); 98 67 } … … 104 73 #define FIELD_PTR( type, name ) \ 105 74 template<typename pass_type> \ 106 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; }\75 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) ->decltype( &pass.name ) { return &pass.name; } \ 107 76 \ 108 77 template<typename pass_type> \ … … 113 82 FIELD_PTR( std::list< Statement* >, stmtsToAddAfter ) 114 83 FIELD_PTR( bool, skip_children ) 115 FIELD_PTR( at_cleanup_t, at_cleanup )
Note:
See TracChangeset
for help on using the changeset viewer.