- Timestamp:
- May 23, 2019, 11:29:46 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 9d6e7fa9
- Parents:
- 342146e1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.proto.hpp
r342146e1 re4b6cf78 109 109 }; 110 110 111 /// "Short hand" to check if this is a valid previsit function 112 /// Mostly used to make the static_assert look (and print) prettier 111 113 template<typename pass_t, typename node_t> 112 114 struct is_valid_previsit { … … 117 119 }; 118 120 121 /// Used by previsit implementation 122 /// We need to reassign the result to 'node', unless the function 123 /// returns void, then we just leave 'node' unchanged 119 124 template<bool is_void> 120 125 struct __assign; … … 134 139 node = pass.previsit( node ); 135 140 assertf(node, "Previsit must not return NULL"); 141 } 142 }; 143 144 /// Used by postvisit implementation 145 /// We need to return the result unless the function 146 /// returns void, then we just return the original node 147 template<bool is_void> 148 struct __return; 149 150 template<> 151 struct __return<true> { 152 template<typename pass_t, typename node_t> 153 static inline const node_t * result( pass_t & pass, const node_t * & node ) { 154 pass.postvisit( node ); 155 return node; 156 } 157 }; 158 159 template<> 160 struct __return<false> { 161 template<typename pass_t, typename node_t> 162 static inline auto result( pass_t & pass, const node_t * & node ) { 163 return pass.postvisit( node ); 136 164 } 137 165 }; … … 174 202 decltype( pass.postvisit( node ), node->accept( *(Visitor*)nullptr ) ) 175 203 { 176 return pass.postvisit( node ); 204 return __return< 205 std::is_void< 206 decltype( pass.postvisit( node ) ) 207 >::value 208 >::result( pass, node ); 177 209 } 178 210
Note: See TracChangeset
for help on using the changeset viewer.