Changes in src/Common/PassVisitor.proto.h [7b13aeb:6e09f211]
- File:
-
- 1 edited
-
src/Common/PassVisitor.proto.h (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.proto.h
r7b13aeb r6e09f211 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; 2 33 3 34 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- … … 18 49 // Visit 19 50 template<typename pass_type, typename node_type> 20 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) {51 static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.previsit( node ), void() ) { 21 52 pass.previsit( node ); 22 53 } … … 27 58 28 59 template<typename pass_type, typename node_type> 29 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) {60 static inline auto postvisit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postvisit( node ), void() ) { 30 61 pass.postvisit( node ); 31 62 } … … 36 67 // Mutate 37 68 template<typename pass_type, typename node_type> 38 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) {69 static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.premutate( node ), void() ) { 39 70 return pass.premutate( node ); 40 71 } … … 45 76 46 77 template<typename return_type, typename pass_type, typename node_type> 47 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) {78 static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) -> decltype( pass.postmutate( node ) ) { 48 79 return pass.postmutate( node ); 49 80 } … … 54 85 // Begin/End scope 55 86 template<typename pass_type> 56 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) {87 static inline auto begin_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.beginScope(), void() ) { 57 88 pass.beginScope(); 58 89 } … … 63 94 64 95 template<typename pass_type> 65 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) {96 static inline auto end_scope_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( pass.endScope(), void() ) { 66 97 pass.endScope(); 67 98 } … … 73 104 #define FIELD_PTR( type, name ) \ 74 105 template<typename pass_type> \ 75 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; }\106 static inline auto name##_impl( pass_type& pass, __attribute__((unused)) int unused ) -> decltype( &pass.name ) { return &pass.name; } \ 76 107 \ 77 108 template<typename pass_type> \ … … 82 113 FIELD_PTR( std::list< Statement* >, stmtsToAddAfter ) 83 114 FIELD_PTR( bool, skip_children ) 115 FIELD_PTR( at_cleanup_t, at_cleanup )
Note:
See TracChangeset
for help on using the changeset viewer.