Changes in src/AST/Pass.proto.hpp [dff6452:b0abc8a0]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.proto.hpp
rdff6452 rb0abc8a0 107 107 bool * m_prev; 108 108 bool_ref * m_ref; 109 };110 111 template<typename pass_t, typename node_t>112 struct is_valid_previsit {113 using ret_t = decltype( ((pass_t*)nullptr)->previsit( (const node_t *)nullptr ) );114 115 static constexpr bool value = std::is_void< ret_t >::value ||116 std::is_base_of<const node_t, typename std::remove_pointer<ret_t>::type >::value;117 109 }; 118 110 … … 135 127 static inline auto previsit( pass_t & pass, const node_t * & node, int ) -> decltype( pass.previsit( node ), void() ) { 136 128 static_assert( 137 is_valid_previsit<pass_t, node_t>::value,138 "Previsit may not change the type of the node. It must return its paremeter or void."129 std::is_base_of<const node_t, typename std::remove_pointer<decltype( pass.previsit( node ) )>::type >::value, 130 "Previsit may not change the type of the node. Use postvisit instead." 139 131 ); 140 if(std::is_void< decltype( pass.previsit(node) ) >::value) { 141 pass.previsit( node ); 142 } else { 143 node = pass.previsit( node ); 144 assert(node); 145 } 132 node = pass.previsit( node ); 133 assert(node); 146 134 } 147 135 … … 151 139 // PostVisit : never mutates the passed pointer but may return a different node 152 140 template<typename pass_t, typename node_t> 153 static inline auto postvisit( pass_t & pass, const node_t * node, int ) -> 154 decltype( pass.postvisit( node ), node->accept( *(Visitor*)nullptr ) ) 155 { 141 static inline auto postvisit( pass_t & pass, const node_t * node, int ) -> decltype( pass.postvisit( node ), (const node_t *)nullptr ) { 156 142 return pass.postvisit( node ); 157 143 }
Note:
See TracChangeset
for help on using the changeset viewer.