[04124c4] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
[e0016a5] | 7 | // ast::Pass.impl.hpp -- |
---|
[04124c4] | 8 | // |
---|
| 9 | // Author : Thierry Delisle |
---|
| 10 | // Created On : Thu May 09 15::37::05 2019 |
---|
| 11 | // Last Modified By : |
---|
| 12 | // Last Modified On : |
---|
| 13 | // Update Count : |
---|
| 14 | // |
---|
| 15 | |
---|
[f47f887] | 16 | #pragma once |
---|
[04124c4] | 17 | // IWYU pragma: private, include "AST/Pass.hpp" |
---|
[f47f887] | 18 | |
---|
[6d51bd7] | 19 | #include <type_traits> |
---|
| 20 | #include <unordered_map> |
---|
| 21 | |
---|
[293dc1c] | 22 | #include "AST/TranslationUnit.hpp" |
---|
[c671112] | 23 | #include "AST/TypeSubstitution.hpp" |
---|
| 24 | |
---|
[f47f887] | 25 | #define VISIT_START( node ) \ |
---|
[04124c4] | 26 | using namespace ast; \ |
---|
[a9762dc] | 27 | /* back-up the last known code location */ \ |
---|
[95e5018] | 28 | __attribute__((unused)) auto loc_guard = ast::__pass::make_location_guard( core, node, 0 ); \ |
---|
[f47f887] | 29 | /* back-up the visit children */ \ |
---|
[7ff3e522] | 30 | __attribute__((unused)) ast::__pass::visit_children_guard guard1( ast::__pass::visit_children(core, 0) ); \ |
---|
[f47f887] | 31 | /* setup the scope for passes that want to run code at exit */ \ |
---|
[7ff3e522] | 32 | __attribute__((unused)) ast::__pass::guard_value guard2( ast::__pass::at_cleanup (core, 0) ); \ |
---|
[c15085d] | 33 | /* begin tracing memory allocation if requested by this pass */ \ |
---|
[7ff3e522] | 34 | __pass::beginTrace( core, 0 ); \ |
---|
[f47f887] | 35 | /* call the implementation of the previsit of this pass */ \ |
---|
[7ff3e522] | 36 | __pass::previsit( core, node, 0 ); |
---|
[f47f887] | 37 | |
---|
| 38 | #define VISIT_END( type, node ) \ |
---|
| 39 | /* call the implementation of the postvisit of this pass */ \ |
---|
[7ff3e522] | 40 | auto __return = __pass::postvisit( core, node, 0 ); \ |
---|
[f47f887] | 41 | assertf(__return, "post visit should never return null"); \ |
---|
[c15085d] | 42 | /* end tracing memory allocation if requested by this pass */ \ |
---|
[7ff3e522] | 43 | __pass::endTrace( core, 0 ); \ |
---|
[f47f887] | 44 | return __return; |
---|
| 45 | |
---|
| 46 | #ifdef PEDANTIC_PASS_ASSERT |
---|
[6d51bd7] | 47 | #define __pedantic_pass_assert(...) assert (__VA_ARGS__) |
---|
| 48 | #define __pedantic_pass_assertf(...) assertf(__VA_ARGS__) |
---|
[f47f887] | 49 | #else |
---|
[6d51bd7] | 50 | #define __pedantic_pass_assert(...) |
---|
[f47f887] | 51 | #define __pedantic_pass_assertf(...) |
---|
| 52 | #endif |
---|
| 53 | |
---|
| 54 | namespace ast { |
---|
[d3aa64f1] | 55 | template<typename node_t> |
---|
| 56 | node_t * shallowCopy( const node_t * node ); |
---|
| 57 | |
---|
[f47f887] | 58 | namespace __pass { |
---|
| 59 | // Check if this is either a null pointer or a pointer to an empty container |
---|
| 60 | template<typename T> |
---|
| 61 | static inline bool empty( T * ptr ) { |
---|
| 62 | return !ptr || ptr->empty(); |
---|
| 63 | } |
---|
| 64 | |
---|
[d3aa64f1] | 65 | template< typename core_t, typename node_t > |
---|
| 66 | static inline node_t* mutate(const node_t *node) { |
---|
| 67 | return std::is_base_of<PureVisitor, core_t>::value ? ::ast::shallowCopy(node) : ::ast::mutate(node); |
---|
| 68 | } |
---|
| 69 | |
---|
[6d51bd7] | 70 | //------------------------------ |
---|
| 71 | template<typename it_t, template <class...> class container_t> |
---|
| 72 | static inline void take_all( it_t it, container_t<ast::ptr<ast::Decl>> * decls, bool * mutated = nullptr ) { |
---|
[f47f887] | 73 | if(empty(decls)) return; |
---|
| 74 | |
---|
[6d51bd7] | 75 | std::transform(decls->begin(), decls->end(), it, [](const ast::Decl * decl) -> auto { |
---|
[8a5530c] | 76 | return new DeclStmt( decl->location, decl ); |
---|
[f47f887] | 77 | }); |
---|
| 78 | decls->clear(); |
---|
| 79 | if(mutated) *mutated = true; |
---|
| 80 | } |
---|
| 81 | |
---|
[6d51bd7] | 82 | template<typename it_t, template <class...> class container_t> |
---|
[f8143a6] | 83 | static inline void take_all( it_t it, container_t<ast::ptr<ast::Stmt>> * stmts, bool * mutated = nullptr ) { |
---|
| 84 | if(empty(stmts)) return; |
---|
[f47f887] | 85 | |
---|
[f8143a6] | 86 | std::move(stmts->begin(), stmts->end(), it); |
---|
| 87 | stmts->clear(); |
---|
[f47f887] | 88 | if(mutated) *mutated = true; |
---|
| 89 | } |
---|
| 90 | |
---|
[6d51bd7] | 91 | //------------------------------ |
---|
| 92 | /// Check if should be skipped, different for pointers and containers |
---|
[f47f887] | 93 | template<typename node_t> |
---|
[6d51bd7] | 94 | bool skip( const ast::ptr<node_t> & val) { |
---|
| 95 | return !val; |
---|
[f47f887] | 96 | } |
---|
| 97 | |
---|
[6d51bd7] | 98 | template< template <class...> class container_t, typename node_t > |
---|
| 99 | bool skip( const container_t<ast::ptr< node_t >> & val ) { |
---|
| 100 | return val.empty(); |
---|
[f47f887] | 101 | } |
---|
| 102 | |
---|
[6d51bd7] | 103 | //------------------------------ |
---|
| 104 | /// Get the value to visit, different for pointers and containers |
---|
| 105 | template<typename node_t> |
---|
| 106 | auto get( const ast::ptr<node_t> & val, int ) -> decltype(val.get()) { |
---|
| 107 | return val.get(); |
---|
| 108 | } |
---|
[f47f887] | 109 | |
---|
[6d51bd7] | 110 | template<typename node_t> |
---|
| 111 | const node_t & get( const node_t & val, long) { |
---|
| 112 | return val; |
---|
| 113 | } |
---|
[f47f887] | 114 | |
---|
[6d51bd7] | 115 | //------------------------------ |
---|
| 116 | /// Check if value was mutated, different for pointers and containers |
---|
| 117 | template<typename lhs_t, typename rhs_t> |
---|
| 118 | bool differs( const lhs_t * old_val, const rhs_t * new_val ) { |
---|
| 119 | return old_val != new_val; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | template< template <class...> class container_t, typename node_t > |
---|
| 123 | bool differs( const container_t<ast::ptr< node_t >> &, const container_t<ast::ptr< node_t >> & new_val ) { |
---|
| 124 | return !new_val.empty(); |
---|
[f47f887] | 125 | } |
---|
| 126 | } |
---|
| 127 | |
---|
[f8143a6] | 128 | template< typename node_t > |
---|
| 129 | template< typename object_t, typename super_t, typename field_t > |
---|
[eb211bf] | 130 | void __pass::result1< node_t >::apply( object_t * object, field_t super_t::* field ) { |
---|
[f8143a6] | 131 | object->*field = value; |
---|
| 132 | } |
---|
| 133 | |
---|
[7ff3e522] | 134 | template< typename core_t > |
---|
[f47f887] | 135 | template< typename node_t > |
---|
[7ff3e522] | 136 | auto ast::Pass< core_t >::call_accept( const node_t * node ) |
---|
[eb211bf] | 137 | -> typename ast::Pass< core_t >::template generic_call_accept_result<node_t>::type |
---|
[8a5530c] | 138 | { |
---|
[f47f887] | 139 | __pedantic_pass_assert( __visit_children() ); |
---|
[e0e9a0b] | 140 | __pedantic_pass_assert( node ); |
---|
[f47f887] | 141 | |
---|
[6d51bd7] | 142 | static_assert( !std::is_base_of<ast::Expr, node_t>::value, "ERROR"); |
---|
| 143 | static_assert( !std::is_base_of<ast::Stmt, node_t>::value, "ERROR"); |
---|
| 144 | |
---|
[f8143a6] | 145 | auto nval = node->accept( *this ); |
---|
[eb211bf] | 146 | __pass::result1< |
---|
[f8143a6] | 147 | typename std::remove_pointer< decltype( node->accept(*this) ) >::type |
---|
| 148 | > res; |
---|
| 149 | res.differs = nval != node; |
---|
| 150 | res.value = nval; |
---|
| 151 | return res; |
---|
[f47f887] | 152 | } |
---|
| 153 | |
---|
[7ff3e522] | 154 | template< typename core_t > |
---|
[eb211bf] | 155 | __pass::template result1<ast::Expr> ast::Pass< core_t >::call_accept( const ast::Expr * expr ) { |
---|
[f47f887] | 156 | __pedantic_pass_assert( __visit_children() ); |
---|
| 157 | __pedantic_pass_assert( expr ); |
---|
| 158 | |
---|
[f8143a6] | 159 | auto nval = expr->accept( *this ); |
---|
| 160 | return { nval != expr, nval }; |
---|
[f47f887] | 161 | } |
---|
| 162 | |
---|
[7ff3e522] | 163 | template< typename core_t > |
---|
[eb211bf] | 164 | __pass::template result1<ast::Stmt> ast::Pass< core_t >::call_accept( const ast::Stmt * stmt ) { |
---|
[f47f887] | 165 | __pedantic_pass_assert( __visit_children() ); |
---|
| 166 | __pedantic_pass_assert( stmt ); |
---|
| 167 | |
---|
[f8143a6] | 168 | const ast::Stmt * nval = stmt->accept( *this ); |
---|
| 169 | return { nval != stmt, nval }; |
---|
[490fb92e] | 170 | } |
---|
| 171 | |
---|
[9e23b446] | 172 | template< typename core_t > |
---|
| 173 | __pass::template result1<ast::Expr> ast::Pass< core_t >::call_accept_top( const ast::Expr * expr ) { |
---|
| 174 | __pedantic_pass_assert( __visit_children() ); |
---|
| 175 | __pedantic_pass_assert( expr ); |
---|
| 176 | |
---|
| 177 | const ast::TypeSubstitution ** typeSubs_ptr = __pass::typeSubs( core, 0 ); |
---|
| 178 | if ( typeSubs_ptr && expr->env ) { |
---|
| 179 | *typeSubs_ptr = expr->env; |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | auto nval = expr->accept( *this ); |
---|
| 183 | return { nval != expr, nval }; |
---|
| 184 | } |
---|
| 185 | |
---|
[490fb92e] | 186 | template< typename core_t > |
---|
[eb211bf] | 187 | __pass::template result1<ast::Stmt> ast::Pass< core_t >::call_accept_as_compound( const ast::Stmt * stmt ) { |
---|
[490fb92e] | 188 | __pedantic_pass_assert( __visit_children() ); |
---|
| 189 | __pedantic_pass_assert( stmt ); |
---|
| 190 | |
---|
[f47f887] | 191 | // add a few useful symbols to the scope |
---|
| 192 | using __pass::empty; |
---|
| 193 | |
---|
| 194 | // get the stmts/decls that will need to be spliced in |
---|
[a8b87d3] | 195 | auto stmts_before = __pass::stmtsToAddBefore( core, 0 ); |
---|
| 196 | auto stmts_after = __pass::stmtsToAddAfter ( core, 0 ); |
---|
| 197 | auto decls_before = __pass::declsToAddBefore( core, 0 ); |
---|
| 198 | auto decls_after = __pass::declsToAddAfter ( core, 0 ); |
---|
[f47f887] | 199 | |
---|
| 200 | // These may be modified by subnode but most be restored once we exit this statemnet. |
---|
[b2a11ba] | 201 | ValueGuardPtr< const ast::TypeSubstitution * > __old_env ( __pass::typeSubs( core, 0 ) ); |
---|
[23f99e1] | 202 | ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); |
---|
| 203 | ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); |
---|
| 204 | ValueGuardPtr< typename std::remove_pointer< decltype(decls_before) >::type > __old_stmts_before( decls_before ); |
---|
| 205 | ValueGuardPtr< typename std::remove_pointer< decltype(decls_after ) >::type > __old_stmts_after ( decls_after ); |
---|
[f47f887] | 206 | |
---|
| 207 | // Now is the time to actually visit the node |
---|
[6d51bd7] | 208 | const ast::Stmt * nstmt = stmt->accept( *this ); |
---|
[f47f887] | 209 | |
---|
| 210 | // If the pass doesn't want to add anything then we are done |
---|
| 211 | if( empty(stmts_before) && empty(stmts_after) && empty(decls_before) && empty(decls_after) ) { |
---|
[f8143a6] | 212 | return { nstmt != stmt, nstmt }; |
---|
[f47f887] | 213 | } |
---|
| 214 | |
---|
| 215 | // Make sure that it is either adding statements or declartions but not both |
---|
| 216 | // this is because otherwise the order would be awkward to predict |
---|
| 217 | assert(( empty( stmts_before ) && empty( stmts_after )) |
---|
| 218 | || ( empty( decls_before ) && empty( decls_after )) ); |
---|
| 219 | |
---|
| 220 | // Create a new Compound Statement to hold the new decls/stmts |
---|
[6d51bd7] | 221 | ast::CompoundStmt * compound = new ast::CompoundStmt( stmt->location ); |
---|
[f47f887] | 222 | |
---|
| 223 | // Take all the declarations that go before |
---|
| 224 | __pass::take_all( std::back_inserter( compound->kids ), decls_before ); |
---|
| 225 | __pass::take_all( std::back_inserter( compound->kids ), stmts_before ); |
---|
| 226 | |
---|
| 227 | // Insert the original declaration |
---|
[6d51bd7] | 228 | compound->kids.emplace_back( nstmt ); |
---|
[f47f887] | 229 | |
---|
| 230 | // Insert all the declarations that go before |
---|
| 231 | __pass::take_all( std::back_inserter( compound->kids ), decls_after ); |
---|
| 232 | __pass::take_all( std::back_inserter( compound->kids ), stmts_after ); |
---|
| 233 | |
---|
[f8143a6] | 234 | return {true, compound}; |
---|
[f47f887] | 235 | } |
---|
| 236 | |
---|
[6d51bd7] | 237 | template< template <class...> class container_t > |
---|
[f8143a6] | 238 | template< typename object_t, typename super_t, typename field_t > |
---|
[eb211bf] | 239 | void __pass::resultNstmt<container_t>::apply(object_t * object, field_t super_t::* field) { |
---|
[f8143a6] | 240 | auto & container = object->*field; |
---|
| 241 | __pedantic_pass_assert( container.size() <= values.size() ); |
---|
| 242 | |
---|
| 243 | auto cit = enumerate(container).begin(); |
---|
| 244 | |
---|
| 245 | container_t<ptr<Stmt>> nvals; |
---|
[eb211bf] | 246 | for (delta & d : values) { |
---|
| 247 | if ( d.is_old ) { |
---|
[f8143a6] | 248 | __pedantic_pass_assert( cit.idx <= d.old_idx ); |
---|
| 249 | std::advance( cit, d.old_idx - cit.idx ); |
---|
| 250 | nvals.push_back( std::move( (*cit).val) ); |
---|
| 251 | } else { |
---|
[eb211bf] | 252 | nvals.push_back( std::move(d.new_val) ); |
---|
[f8143a6] | 253 | } |
---|
| 254 | } |
---|
| 255 | |
---|
[eb211bf] | 256 | container = std::move(nvals); |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | template< template <class...> class container_t > |
---|
| 260 | template< template <class...> class incontainer_t > |
---|
| 261 | void __pass::resultNstmt< container_t >::take_all( incontainer_t<ptr<Stmt>> * stmts ) { |
---|
| 262 | if (!stmts || stmts->empty()) return; |
---|
| 263 | |
---|
| 264 | std::transform(stmts->begin(), stmts->end(), std::back_inserter( values ), |
---|
| 265 | [](ast::ptr<ast::Stmt>& stmt) -> delta { |
---|
| 266 | return delta( stmt.release(), -1, false ); |
---|
| 267 | }); |
---|
| 268 | stmts->clear(); |
---|
| 269 | differs = true; |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | template< template<class...> class container_t > |
---|
| 273 | template< template<class...> class incontainer_t > |
---|
| 274 | void __pass::resultNstmt< container_t >::take_all( incontainer_t<ptr<Decl>> * decls ) { |
---|
| 275 | if (!decls || decls->empty()) return; |
---|
| 276 | |
---|
| 277 | std::transform(decls->begin(), decls->end(), std::back_inserter( values ), |
---|
| 278 | [](ast::ptr<ast::Decl>& decl) -> delta { |
---|
| 279 | auto loc = decl->location; |
---|
| 280 | auto stmt = new DeclStmt( loc, decl.release() ); |
---|
| 281 | return delta( stmt, -1, false ); |
---|
| 282 | }); |
---|
| 283 | decls->clear(); |
---|
| 284 | differs = true; |
---|
[f8143a6] | 285 | } |
---|
| 286 | |
---|
| 287 | template< typename core_t > |
---|
| 288 | template< template <class...> class container_t > |
---|
[eb211bf] | 289 | __pass::template resultNstmt<container_t> ast::Pass< core_t >::call_accept( const container_t< ptr<Stmt> > & statements ) { |
---|
[f47f887] | 290 | __pedantic_pass_assert( __visit_children() ); |
---|
| 291 | if( statements.empty() ) return {}; |
---|
| 292 | |
---|
| 293 | // We are going to aggregate errors for all these statements |
---|
| 294 | SemanticErrorException errors; |
---|
| 295 | |
---|
| 296 | // add a few useful symbols to the scope |
---|
| 297 | using __pass::empty; |
---|
| 298 | |
---|
| 299 | // get the stmts/decls that will need to be spliced in |
---|
[6739590] | 300 | auto stmts_before = __pass::stmtsToAddBefore( core, 0 ); |
---|
| 301 | auto stmts_after = __pass::stmtsToAddAfter ( core, 0 ); |
---|
| 302 | auto decls_before = __pass::declsToAddBefore( core, 0 ); |
---|
| 303 | auto decls_after = __pass::declsToAddAfter ( core, 0 ); |
---|
[f47f887] | 304 | |
---|
| 305 | // These may be modified by subnode but most be restored once we exit this statemnet. |
---|
[23f99e1] | 306 | ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); |
---|
| 307 | ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); |
---|
| 308 | ValueGuardPtr< typename std::remove_pointer< decltype(decls_before) >::type > __old_stmts_before( decls_before ); |
---|
| 309 | ValueGuardPtr< typename std::remove_pointer< decltype(decls_after ) >::type > __old_stmts_after ( decls_after ); |
---|
[f47f887] | 310 | |
---|
| 311 | // update pass statitistics |
---|
| 312 | pass_visitor_stats.depth++; |
---|
| 313 | pass_visitor_stats.max->push(pass_visitor_stats.depth); |
---|
| 314 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); |
---|
| 315 | |
---|
[eb211bf] | 316 | __pass::resultNstmt<container_t> new_kids; |
---|
[f8143a6] | 317 | for( auto value : enumerate( statements ) ) { |
---|
[f47f887] | 318 | try { |
---|
[f8143a6] | 319 | size_t i = value.idx; |
---|
| 320 | const Stmt * stmt = value.val; |
---|
[f47f887] | 321 | __pedantic_pass_assert( stmt ); |
---|
[6d51bd7] | 322 | const ast::Stmt * new_stmt = stmt->accept( *this ); |
---|
[f47f887] | 323 | assert( new_stmt ); |
---|
[f8143a6] | 324 | if(new_stmt != stmt ) { new_kids.differs = true; } |
---|
[f47f887] | 325 | |
---|
| 326 | // Make sure that it is either adding statements or declartions but not both |
---|
| 327 | // this is because otherwise the order would be awkward to predict |
---|
| 328 | assert(( empty( stmts_before ) && empty( stmts_after )) |
---|
| 329 | || ( empty( decls_before ) && empty( decls_after )) ); |
---|
| 330 | |
---|
| 331 | // Take all the statements which should have gone after, N/A for first iteration |
---|
[f8143a6] | 332 | new_kids.take_all( decls_before ); |
---|
| 333 | new_kids.take_all( stmts_before ); |
---|
[f47f887] | 334 | |
---|
| 335 | // Now add the statement if there is one |
---|
[f8143a6] | 336 | if(new_stmt != stmt) { |
---|
| 337 | new_kids.values.emplace_back( new_stmt, i, false ); |
---|
| 338 | } else { |
---|
| 339 | new_kids.values.emplace_back( nullptr, i, true ); |
---|
| 340 | } |
---|
[f47f887] | 341 | |
---|
| 342 | // Take all the declarations that go before |
---|
[f8143a6] | 343 | new_kids.take_all( decls_after ); |
---|
| 344 | new_kids.take_all( stmts_after ); |
---|
[f47f887] | 345 | } |
---|
| 346 | catch ( SemanticErrorException &e ) { |
---|
| 347 | errors.append( e ); |
---|
| 348 | } |
---|
| 349 | } |
---|
| 350 | pass_visitor_stats.depth--; |
---|
| 351 | if ( !errors.isEmpty() ) { throw errors; } |
---|
| 352 | |
---|
[f8143a6] | 353 | return new_kids; |
---|
| 354 | } |
---|
| 355 | |
---|
| 356 | template< template <class...> class container_t, typename node_t > |
---|
| 357 | template< typename object_t, typename super_t, typename field_t > |
---|
[eb211bf] | 358 | void __pass::resultN<container_t, node_t>::apply(object_t * object, field_t super_t::* field) { |
---|
[f8143a6] | 359 | auto & container = object->*field; |
---|
| 360 | __pedantic_pass_assert( container.size() == values.size() ); |
---|
| 361 | |
---|
| 362 | for(size_t i = 0; i < container.size(); i++) { |
---|
| 363 | // Take all the elements that are different in 'values' |
---|
| 364 | // and swap them into 'container' |
---|
[8631c84] | 365 | if( values[i] != nullptr ) swap(container[i], values[i]); |
---|
[f8143a6] | 366 | } |
---|
| 367 | |
---|
| 368 | // Now the original containers should still have the unchanged values |
---|
| 369 | // but also contain the new values |
---|
[f47f887] | 370 | } |
---|
| 371 | |
---|
[7ff3e522] | 372 | template< typename core_t > |
---|
[6d51bd7] | 373 | template< template <class...> class container_t, typename node_t > |
---|
[eb211bf] | 374 | __pass::template resultN<container_t, node_t> ast::Pass< core_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) { |
---|
[f47f887] | 375 | __pedantic_pass_assert( __visit_children() ); |
---|
| 376 | if( container.empty() ) return {}; |
---|
| 377 | SemanticErrorException errors; |
---|
| 378 | |
---|
| 379 | pass_visitor_stats.depth++; |
---|
| 380 | pass_visitor_stats.max->push(pass_visitor_stats.depth); |
---|
| 381 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); |
---|
| 382 | |
---|
| 383 | bool mutated = false; |
---|
[f8143a6] | 384 | container_t<ptr<node_t>> new_kids; |
---|
[f47f887] | 385 | for ( const node_t * node : container ) { |
---|
| 386 | try { |
---|
| 387 | __pedantic_pass_assert( node ); |
---|
[6d51bd7] | 388 | const node_t * new_stmt = strict_dynamic_cast< const node_t * >( node->accept( *this ) ); |
---|
[f8143a6] | 389 | if(new_stmt != node ) { |
---|
| 390 | mutated = true; |
---|
| 391 | new_kids.emplace_back( new_stmt ); |
---|
| 392 | } else { |
---|
| 393 | new_kids.emplace_back( nullptr ); |
---|
| 394 | } |
---|
[f47f887] | 395 | |
---|
| 396 | } |
---|
| 397 | catch( SemanticErrorException &e ) { |
---|
| 398 | errors.append( e ); |
---|
| 399 | } |
---|
| 400 | } |
---|
[f8143a6] | 401 | |
---|
| 402 | __pedantic_pass_assert( new_kids.size() == container.size() ); |
---|
[f47f887] | 403 | pass_visitor_stats.depth--; |
---|
| 404 | if ( ! errors.isEmpty() ) { throw errors; } |
---|
| 405 | |
---|
[eb211bf] | 406 | return ast::__pass::resultN<container_t, node_t>{ mutated, new_kids }; |
---|
[6d51bd7] | 407 | } |
---|
| 408 | |
---|
[7ff3e522] | 409 | template< typename core_t > |
---|
[2377ca2] | 410 | template<typename node_t, typename super_t, typename field_t> |
---|
[7ff3e522] | 411 | void ast::Pass< core_t >::maybe_accept( |
---|
[6d51bd7] | 412 | const node_t * & parent, |
---|
[2377ca2] | 413 | field_t super_t::*field |
---|
[6d51bd7] | 414 | ) { |
---|
[2377ca2] | 415 | static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" ); |
---|
[6d51bd7] | 416 | |
---|
[2377ca2] | 417 | if(__pass::skip(parent->*field)) return; |
---|
| 418 | const auto & old_val = __pass::get(parent->*field, 0); |
---|
[6d51bd7] | 419 | |
---|
| 420 | static_assert( !std::is_same<const ast::Node * &, decltype(old_val)>::value, "ERROR"); |
---|
| 421 | |
---|
| 422 | auto new_val = call_accept( old_val ); |
---|
| 423 | |
---|
[f8143a6] | 424 | static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value /* || std::is_same<int, decltype(old_val)>::value */, "ERROR"); |
---|
[6d51bd7] | 425 | |
---|
[f8143a6] | 426 | if( new_val.differs ) { |
---|
[d3aa64f1] | 427 | auto new_parent = __pass::mutate<core_t>(parent); |
---|
[2377ca2] | 428 | new_val.apply(new_parent, field); |
---|
[6d51bd7] | 429 | parent = new_parent; |
---|
| 430 | } |
---|
[f47f887] | 431 | } |
---|
[6d51bd7] | 432 | |
---|
[9e23b446] | 433 | template< typename core_t > |
---|
| 434 | template<typename node_t, typename super_t, typename field_t> |
---|
| 435 | void ast::Pass< core_t >::maybe_accept_top( |
---|
| 436 | const node_t * & parent, |
---|
| 437 | field_t super_t::*field |
---|
| 438 | ) { |
---|
| 439 | static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" ); |
---|
| 440 | |
---|
| 441 | if(__pass::skip(parent->*field)) return; |
---|
| 442 | const auto & old_val = __pass::get(parent->*field, 0); |
---|
| 443 | |
---|
| 444 | static_assert( !std::is_same<const ast::Node * &, decltype(old_val)>::value, "ERROR"); |
---|
| 445 | |
---|
| 446 | auto new_val = call_accept_top( old_val ); |
---|
| 447 | |
---|
| 448 | static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value /* || std::is_same<int, decltype(old_val)>::value */, "ERROR"); |
---|
| 449 | |
---|
| 450 | if( new_val.differs ) { |
---|
| 451 | auto new_parent = __pass::mutate<core_t>(parent); |
---|
| 452 | new_val.apply(new_parent, field); |
---|
| 453 | parent = new_parent; |
---|
| 454 | } |
---|
| 455 | } |
---|
| 456 | |
---|
[490fb92e] | 457 | template< typename core_t > |
---|
[2377ca2] | 458 | template<typename node_t, typename super_t, typename field_t> |
---|
[490fb92e] | 459 | void ast::Pass< core_t >::maybe_accept_as_compound( |
---|
| 460 | const node_t * & parent, |
---|
[2377ca2] | 461 | field_t super_t::*child |
---|
[490fb92e] | 462 | ) { |
---|
[2377ca2] | 463 | static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" ); |
---|
[490fb92e] | 464 | |
---|
| 465 | if(__pass::skip(parent->*child)) return; |
---|
| 466 | const auto & old_val = __pass::get(parent->*child, 0); |
---|
| 467 | |
---|
| 468 | static_assert( !std::is_same<const ast::Node * &, decltype(old_val)>::value, "ERROR"); |
---|
| 469 | |
---|
| 470 | auto new_val = call_accept_as_compound( old_val ); |
---|
| 471 | |
---|
| 472 | static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value || std::is_same<int, decltype(old_val)>::value, "ERROR"); |
---|
| 473 | |
---|
[f8143a6] | 474 | if( new_val.differs ) { |
---|
[490fb92e] | 475 | auto new_parent = __pass::mutate<core_t>(parent); |
---|
[f8143a6] | 476 | new_val.apply( new_parent, child ); |
---|
[490fb92e] | 477 | parent = new_parent; |
---|
| 478 | } |
---|
| 479 | } |
---|
| 480 | |
---|
[f47f887] | 481 | } |
---|
| 482 | |
---|
| 483 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
---|
| 484 | //======================================================================================================================================================================== |
---|
| 485 | //======================================================================================================================================================================== |
---|
| 486 | //======================================================================================================================================================================== |
---|
| 487 | //======================================================================================================================================================================== |
---|
| 488 | //======================================================================================================================================================================== |
---|
| 489 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
---|
| 490 | |
---|
[7ff3e522] | 491 | template< typename core_t > |
---|
| 492 | inline void ast::accept_all( std::list< ast::ptr<ast::Decl> > & decls, ast::Pass< core_t > & visitor ) { |
---|
[04124c4] | 493 | // We are going to aggregate errors for all these statements |
---|
| 494 | SemanticErrorException errors; |
---|
| 495 | |
---|
| 496 | // add a few useful symbols to the scope |
---|
| 497 | using __pass::empty; |
---|
| 498 | |
---|
| 499 | // get the stmts/decls that will need to be spliced in |
---|
[7ff3e522] | 500 | auto decls_before = __pass::declsToAddBefore( visitor.core, 0); |
---|
| 501 | auto decls_after = __pass::declsToAddAfter ( visitor.core, 0); |
---|
[04124c4] | 502 | |
---|
| 503 | // update pass statitistics |
---|
| 504 | pass_visitor_stats.depth++; |
---|
| 505 | pass_visitor_stats.max->push(pass_visitor_stats.depth); |
---|
| 506 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); |
---|
| 507 | |
---|
| 508 | for ( std::list< ast::ptr<ast::Decl> >::iterator i = decls.begin(); ; ++i ) { |
---|
| 509 | // splice in new declarations after previous decl |
---|
| 510 | if ( !empty( decls_after ) ) { decls.splice( i, *decls_after ); } |
---|
| 511 | |
---|
| 512 | if ( i == decls.end() ) break; |
---|
| 513 | |
---|
| 514 | try { |
---|
| 515 | // run visitor on declaration |
---|
| 516 | ast::ptr<ast::Decl> & node = *i; |
---|
| 517 | assert( node ); |
---|
| 518 | node = node->accept( visitor ); |
---|
| 519 | } |
---|
| 520 | catch( SemanticErrorException &e ) { |
---|
[e00c22f] | 521 | if (__pass::on_error (visitor.core, *i, 0)) |
---|
[0dd9a5e] | 522 | errors.append( e ); |
---|
[04124c4] | 523 | } |
---|
| 524 | |
---|
| 525 | // splice in new declarations before current decl |
---|
| 526 | if ( !empty( decls_before ) ) { decls.splice( i, *decls_before ); } |
---|
| 527 | } |
---|
| 528 | pass_visitor_stats.depth--; |
---|
| 529 | if ( !errors.isEmpty() ) { throw errors; } |
---|
| 530 | } |
---|
| 531 | |
---|
[293dc1c] | 532 | template< typename core_t > |
---|
| 533 | inline void ast::accept_all( ast::TranslationUnit & unit, ast::Pass< core_t > & visitor ) { |
---|
[c600df1] | 534 | if ( auto ptr = __pass::translation_unit::get_cptr( visitor.core, 0 ) ) { |
---|
| 535 | ValueGuard<const TranslationUnit *> guard( *ptr ); |
---|
| 536 | *ptr = &unit; |
---|
| 537 | return ast::accept_all( unit.decls, visitor ); |
---|
| 538 | } else { |
---|
| 539 | return ast::accept_all( unit.decls, visitor ); |
---|
| 540 | } |
---|
[293dc1c] | 541 | } |
---|
| 542 | |
---|
[f47f887] | 543 | // A NOTE ON THE ORDER OF TRAVERSAL |
---|
| 544 | // |
---|
| 545 | // Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is |
---|
| 546 | // no such thing as a recursive type or typedef. |
---|
| 547 | // |
---|
| 548 | // typedef struct { T *x; } T; // never allowed |
---|
| 549 | // |
---|
| 550 | // for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the |
---|
| 551 | // members are traversed, and then the complete type should be added (assuming the type is completed by this particular |
---|
| 552 | // declaration). |
---|
| 553 | // |
---|
| 554 | // struct T { struct T *x; }; // allowed |
---|
| 555 | // |
---|
| 556 | // It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that |
---|
| 557 | // traversal may modify the definition of the type and these modifications should be visible when the symbol table is |
---|
| 558 | // queried later in this pass. |
---|
| 559 | |
---|
| 560 | //-------------------------------------------------------------------------- |
---|
| 561 | // ObjectDecl |
---|
[7ff3e522] | 562 | template< typename core_t > |
---|
| 563 | const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::ObjectDecl * node ) { |
---|
[f47f887] | 564 | VISIT_START( node ); |
---|
| 565 | |
---|
[e21f253] | 566 | if ( __visit_children() ) { |
---|
[f47f887] | 567 | { |
---|
[0e42794] | 568 | guard_symtab guard { *this }; |
---|
[23f99e1] | 569 | maybe_accept( node, &ObjectDecl::type ); |
---|
[f47f887] | 570 | } |
---|
[23f99e1] | 571 | maybe_accept( node, &ObjectDecl::init ); |
---|
| 572 | maybe_accept( node, &ObjectDecl::bitfieldWidth ); |
---|
| 573 | maybe_accept( node, &ObjectDecl::attributes ); |
---|
[e21f253] | 574 | } |
---|
[f47f887] | 575 | |
---|
[7ff3e522] | 576 | __pass::symtab::addId( core, 0, node ); |
---|
[f47f887] | 577 | |
---|
[04124c4] | 578 | VISIT_END( DeclWithType, node ); |
---|
[f47f887] | 579 | } |
---|
| 580 | |
---|
[23f99e1] | 581 | //-------------------------------------------------------------------------- |
---|
| 582 | // FunctionDecl |
---|
[7ff3e522] | 583 | template< typename core_t > |
---|
| 584 | const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::FunctionDecl * node ) { |
---|
[23f99e1] | 585 | VISIT_START( node ); |
---|
| 586 | |
---|
[7ff3e522] | 587 | __pass::symtab::addId( core, 0, node ); |
---|
[23f99e1] | 588 | |
---|
[e21f253] | 589 | if ( __visit_children() ) { |
---|
| 590 | maybe_accept( node, &FunctionDecl::withExprs ); |
---|
| 591 | } |
---|
[23f99e1] | 592 | { |
---|
| 593 | // with clause introduces a level of scope (for the with expression members). |
---|
[0e42794] | 594 | // with clause exprs are added to the symbol table before parameters so that parameters |
---|
[23f99e1] | 595 | // shadow with exprs and not the other way around. |
---|
[0e42794] | 596 | guard_symtab guard { *this }; |
---|
[7ff3e522] | 597 | __pass::symtab::addWith( core, 0, node->withExprs, node ); |
---|
[23f99e1] | 598 | { |
---|
[0e42794] | 599 | guard_symtab guard { *this }; |
---|
[23f99e1] | 600 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2 |
---|
[e8616b6] | 601 | // This is a C name and so has C linkage. |
---|
[798a8b3] | 602 | static ast::ptr< ast::ObjectDecl > func{ new ast::ObjectDecl{ |
---|
[9ea38de] | 603 | CodeLocation{}, "__func__", |
---|
| 604 | new ast::ArrayType{ |
---|
| 605 | new ast::BasicType{ ast::BasicType::Char, ast::CV::Const }, |
---|
[8a5530c] | 606 | nullptr, VariableLen, DynamicDim |
---|
[e8616b6] | 607 | }, |
---|
| 608 | nullptr, |
---|
| 609 | ast::Storage::Classes(), |
---|
| 610 | ast::Linkage::C, |
---|
[9ea38de] | 611 | } }; |
---|
[7ff3e522] | 612 | __pass::symtab::addId( core, 0, func ); |
---|
[e21f253] | 613 | if ( __visit_children() ) { |
---|
[3e5dd913] | 614 | maybe_accept( node, &FunctionDecl::type_params ); |
---|
| 615 | maybe_accept( node, &FunctionDecl::assertions ); |
---|
[4ec9513] | 616 | maybe_accept( node, &FunctionDecl::params ); |
---|
| 617 | maybe_accept( node, &FunctionDecl::returns ); |
---|
| 618 | maybe_accept( node, &FunctionDecl::type ); |
---|
[f2ff0a6] | 619 | maybe_accept( node, &FunctionDecl::attributes ); |
---|
[c6c682cf] | 620 | // First remember that we are now within a function. |
---|
[23f99e1] | 621 | ValueGuard< bool > oldInFunction( inFunction ); |
---|
| 622 | inFunction = true; |
---|
[c6c682cf] | 623 | // The function body needs to have the same scope as parameters. |
---|
| 624 | // A CompoundStmt will not enter a new scope if atFunctionTop is true. |
---|
| 625 | ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); |
---|
| 626 | atFunctionTop = true; |
---|
[8a5530c] | 627 | maybe_accept( node, &FunctionDecl::stmts ); |
---|
[e21f253] | 628 | } |
---|
[23f99e1] | 629 | } |
---|
| 630 | } |
---|
| 631 | |
---|
| 632 | VISIT_END( DeclWithType, node ); |
---|
| 633 | } |
---|
| 634 | |
---|
| 635 | //-------------------------------------------------------------------------- |
---|
| 636 | // StructDecl |
---|
[7ff3e522] | 637 | template< typename core_t > |
---|
| 638 | const ast::Decl * ast::Pass< core_t >::visit( const ast::StructDecl * node ) { |
---|
[23f99e1] | 639 | VISIT_START( node ); |
---|
| 640 | |
---|
| 641 | // make up a forward declaration and add it before processing the members |
---|
| 642 | // needs to be on the heap because addStruct saves the pointer |
---|
[7ff3e522] | 643 | __pass::symtab::addStructFwd( core, 0, node ); |
---|
[23f99e1] | 644 | |
---|
[e21f253] | 645 | if ( __visit_children() ) { |
---|
[0e42794] | 646 | guard_symtab guard { * this }; |
---|
[798a8b3] | 647 | maybe_accept( node, &StructDecl::params ); |
---|
| 648 | maybe_accept( node, &StructDecl::members ); |
---|
| 649 | maybe_accept( node, &StructDecl::attributes ); |
---|
[e21f253] | 650 | } |
---|
[23f99e1] | 651 | |
---|
| 652 | // this addition replaces the forward declaration |
---|
[7ff3e522] | 653 | __pass::symtab::addStruct( core, 0, node ); |
---|
[23f99e1] | 654 | |
---|
| 655 | VISIT_END( Decl, node ); |
---|
| 656 | } |
---|
| 657 | |
---|
| 658 | //-------------------------------------------------------------------------- |
---|
| 659 | // UnionDecl |
---|
[7ff3e522] | 660 | template< typename core_t > |
---|
| 661 | const ast::Decl * ast::Pass< core_t >::visit( const ast::UnionDecl * node ) { |
---|
[23f99e1] | 662 | VISIT_START( node ); |
---|
| 663 | |
---|
| 664 | // make up a forward declaration and add it before processing the members |
---|
[7ff3e522] | 665 | __pass::symtab::addUnionFwd( core, 0, node ); |
---|
[23f99e1] | 666 | |
---|
[e21f253] | 667 | if ( __visit_children() ) { |
---|
[0e42794] | 668 | guard_symtab guard { * this }; |
---|
[798a8b3] | 669 | maybe_accept( node, &UnionDecl::params ); |
---|
| 670 | maybe_accept( node, &UnionDecl::members ); |
---|
| 671 | maybe_accept( node, &UnionDecl::attributes ); |
---|
[e21f253] | 672 | } |
---|
[23f99e1] | 673 | |
---|
[7ff3e522] | 674 | __pass::symtab::addUnion( core, 0, node ); |
---|
[23f99e1] | 675 | |
---|
| 676 | VISIT_END( Decl, node ); |
---|
| 677 | } |
---|
| 678 | |
---|
| 679 | //-------------------------------------------------------------------------- |
---|
| 680 | // EnumDecl |
---|
[7ff3e522] | 681 | template< typename core_t > |
---|
| 682 | const ast::Decl * ast::Pass< core_t >::visit( const ast::EnumDecl * node ) { |
---|
[23f99e1] | 683 | VISIT_START( node ); |
---|
| 684 | |
---|
[7ff3e522] | 685 | __pass::symtab::addEnum( core, 0, node ); |
---|
[23f99e1] | 686 | |
---|
[e21f253] | 687 | if ( __visit_children() ) { |
---|
[23f99e1] | 688 | // unlike structs, traits, and unions, enums inject their members into the global scope |
---|
[1df492a] | 689 | maybe_accept( node, &EnumDecl::base ); |
---|
[798a8b3] | 690 | maybe_accept( node, &EnumDecl::params ); |
---|
| 691 | maybe_accept( node, &EnumDecl::members ); |
---|
| 692 | maybe_accept( node, &EnumDecl::attributes ); |
---|
[e21f253] | 693 | } |
---|
[23f99e1] | 694 | |
---|
| 695 | VISIT_END( Decl, node ); |
---|
| 696 | } |
---|
| 697 | |
---|
| 698 | //-------------------------------------------------------------------------- |
---|
| 699 | // TraitDecl |
---|
[7ff3e522] | 700 | template< typename core_t > |
---|
| 701 | const ast::Decl * ast::Pass< core_t >::visit( const ast::TraitDecl * node ) { |
---|
[23f99e1] | 702 | VISIT_START( node ); |
---|
| 703 | |
---|
[e21f253] | 704 | if ( __visit_children() ) { |
---|
[0e42794] | 705 | guard_symtab guard { *this }; |
---|
[798a8b3] | 706 | maybe_accept( node, &TraitDecl::params ); |
---|
| 707 | maybe_accept( node, &TraitDecl::members ); |
---|
| 708 | maybe_accept( node, &TraitDecl::attributes ); |
---|
[e21f253] | 709 | } |
---|
[23f99e1] | 710 | |
---|
[7ff3e522] | 711 | __pass::symtab::addTrait( core, 0, node ); |
---|
[23f99e1] | 712 | |
---|
| 713 | VISIT_END( Decl, node ); |
---|
| 714 | } |
---|
| 715 | |
---|
| 716 | //-------------------------------------------------------------------------- |
---|
| 717 | // TypeDecl |
---|
[7ff3e522] | 718 | template< typename core_t > |
---|
| 719 | const ast::Decl * ast::Pass< core_t >::visit( const ast::TypeDecl * node ) { |
---|
[23f99e1] | 720 | VISIT_START( node ); |
---|
| 721 | |
---|
[e21f253] | 722 | if ( __visit_children() ) { |
---|
[0e42794] | 723 | guard_symtab guard { *this }; |
---|
[87701b6] | 724 | maybe_accept( node, &TypeDecl::base ); |
---|
[e21f253] | 725 | } |
---|
[23f99e1] | 726 | |
---|
| 727 | // see A NOTE ON THE ORDER OF TRAVERSAL, above |
---|
| 728 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper |
---|
| 729 | // and may depend on the type itself |
---|
[7ff3e522] | 730 | __pass::symtab::addType( core, 0, node ); |
---|
[23f99e1] | 731 | |
---|
[e21f253] | 732 | if ( __visit_children() ) { |
---|
[8a5530c] | 733 | maybe_accept( node, &TypeDecl::assertions ); |
---|
[23f99e1] | 734 | |
---|
| 735 | { |
---|
[0e42794] | 736 | guard_symtab guard { *this }; |
---|
[23f99e1] | 737 | maybe_accept( node, &TypeDecl::init ); |
---|
| 738 | } |
---|
[e21f253] | 739 | } |
---|
[23f99e1] | 740 | |
---|
| 741 | VISIT_END( Decl, node ); |
---|
| 742 | } |
---|
| 743 | |
---|
| 744 | //-------------------------------------------------------------------------- |
---|
| 745 | // TypedefDecl |
---|
[7ff3e522] | 746 | template< typename core_t > |
---|
| 747 | const ast::Decl * ast::Pass< core_t >::visit( const ast::TypedefDecl * node ) { |
---|
[23f99e1] | 748 | VISIT_START( node ); |
---|
| 749 | |
---|
[e21f253] | 750 | if ( __visit_children() ) { |
---|
[0e42794] | 751 | guard_symtab guard { *this }; |
---|
[87701b6] | 752 | maybe_accept( node, &TypedefDecl::base ); |
---|
[e21f253] | 753 | } |
---|
[23f99e1] | 754 | |
---|
[7ff3e522] | 755 | __pass::symtab::addType( core, 0, node ); |
---|
[23f99e1] | 756 | |
---|
[e21f253] | 757 | if ( __visit_children() ) { |
---|
| 758 | maybe_accept( node, &TypedefDecl::assertions ); |
---|
| 759 | } |
---|
[23f99e1] | 760 | |
---|
| 761 | VISIT_END( Decl, node ); |
---|
| 762 | } |
---|
| 763 | |
---|
| 764 | //-------------------------------------------------------------------------- |
---|
| 765 | // AsmDecl |
---|
[7ff3e522] | 766 | template< typename core_t > |
---|
| 767 | const ast::AsmDecl * ast::Pass< core_t >::visit( const ast::AsmDecl * node ) { |
---|
[23f99e1] | 768 | VISIT_START( node ); |
---|
| 769 | |
---|
[e21f253] | 770 | if ( __visit_children() ) { |
---|
[23f99e1] | 771 | maybe_accept( node, &AsmDecl::stmt ); |
---|
[e21f253] | 772 | } |
---|
[23f99e1] | 773 | |
---|
| 774 | VISIT_END( AsmDecl, node ); |
---|
| 775 | } |
---|
| 776 | |
---|
[2d019af] | 777 | //-------------------------------------------------------------------------- |
---|
| 778 | // DirectiveDecl |
---|
| 779 | template< typename core_t > |
---|
| 780 | const ast::DirectiveDecl * ast::Pass< core_t >::visit( const ast::DirectiveDecl * node ) { |
---|
| 781 | VISIT_START( node ); |
---|
| 782 | |
---|
[e21f253] | 783 | if ( __visit_children() ) { |
---|
[2d019af] | 784 | maybe_accept( node, &DirectiveDecl::stmt ); |
---|
[e21f253] | 785 | } |
---|
[2d019af] | 786 | |
---|
| 787 | VISIT_END( DirectiveDecl, node ); |
---|
| 788 | } |
---|
| 789 | |
---|
[23f99e1] | 790 | //-------------------------------------------------------------------------- |
---|
| 791 | // StaticAssertDecl |
---|
[7ff3e522] | 792 | template< typename core_t > |
---|
| 793 | const ast::StaticAssertDecl * ast::Pass< core_t >::visit( const ast::StaticAssertDecl * node ) { |
---|
[23f99e1] | 794 | VISIT_START( node ); |
---|
| 795 | |
---|
[e21f253] | 796 | if ( __visit_children() ) { |
---|
[9e23b446] | 797 | maybe_accept_top( node, &StaticAssertDecl::cond ); |
---|
[112fe04] | 798 | maybe_accept( node, &StaticAssertDecl::msg ); |
---|
[e21f253] | 799 | } |
---|
[23f99e1] | 800 | |
---|
| 801 | VISIT_END( StaticAssertDecl, node ); |
---|
| 802 | } |
---|
| 803 | |
---|
[e874605] | 804 | //-------------------------------------------------------------------------- |
---|
| 805 | // DeclWithType |
---|
| 806 | template< typename core_t > |
---|
| 807 | const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::InlineValueDecl * node ) { |
---|
| 808 | VISIT_START( node ); |
---|
| 809 | |
---|
| 810 | if ( __visit_children() ) { |
---|
| 811 | { |
---|
| 812 | guard_symtab guard { *this }; |
---|
| 813 | maybe_accept( node, &InlineValueDecl::type ); |
---|
| 814 | } |
---|
| 815 | } |
---|
| 816 | |
---|
| 817 | VISIT_END( DeclWithType, node ); |
---|
| 818 | } |
---|
| 819 | |
---|
[23f99e1] | 820 | //-------------------------------------------------------------------------- |
---|
| 821 | // CompoundStmt |
---|
[7ff3e522] | 822 | template< typename core_t > |
---|
| 823 | const ast::CompoundStmt * ast::Pass< core_t >::visit( const ast::CompoundStmt * node ) { |
---|
[23f99e1] | 824 | VISIT_START( node ); |
---|
[e21f253] | 825 | |
---|
| 826 | if ( __visit_children() ) { |
---|
[c6c682cf] | 827 | // Do not enter (or leave) a new scope if atFunctionTop. Remember to save the result. |
---|
| 828 | auto guard1 = makeFuncGuard( [this, enterScope = !this->atFunctionTop]() { |
---|
[16ba4a6] | 829 | if ( enterScope ) { |
---|
| 830 | __pass::symtab::enter(core, 0); |
---|
| 831 | __pass::scope::enter(core, 0); |
---|
| 832 | } |
---|
[c6c682cf] | 833 | }, [this, leaveScope = !this->atFunctionTop]() { |
---|
[16ba4a6] | 834 | if ( leaveScope ) { |
---|
| 835 | __pass::symtab::leave(core, 0); |
---|
| 836 | __pass::scope::leave(core, 0); |
---|
| 837 | } |
---|
[23f99e1] | 838 | }); |
---|
[82f791f] | 839 | ValueGuard< bool > guard2( atFunctionTop ); |
---|
| 840 | atFunctionTop = false; |
---|
[23f99e1] | 841 | guard_scope guard3 { *this }; |
---|
| 842 | maybe_accept( node, &CompoundStmt::kids ); |
---|
[e21f253] | 843 | } |
---|
| 844 | |
---|
[23f99e1] | 845 | VISIT_END( CompoundStmt, node ); |
---|
| 846 | } |
---|
| 847 | |
---|
[8a5530c] | 848 | //-------------------------------------------------------------------------- |
---|
| 849 | // ExprStmt |
---|
[7ff3e522] | 850 | template< typename core_t > |
---|
| 851 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::ExprStmt * node ) { |
---|
[8a5530c] | 852 | VISIT_START( node ); |
---|
| 853 | |
---|
[e21f253] | 854 | if ( __visit_children() ) { |
---|
[9e23b446] | 855 | maybe_accept_top( node, &ExprStmt::expr ); |
---|
[e21f253] | 856 | } |
---|
[8a5530c] | 857 | |
---|
| 858 | VISIT_END( Stmt, node ); |
---|
| 859 | } |
---|
| 860 | |
---|
| 861 | //-------------------------------------------------------------------------- |
---|
| 862 | // AsmStmt |
---|
[7ff3e522] | 863 | template< typename core_t > |
---|
| 864 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::AsmStmt * node ) { |
---|
[8a5530c] | 865 | VISIT_START( node ) |
---|
| 866 | |
---|
[e21f253] | 867 | if ( __visit_children() ) { |
---|
[8a5530c] | 868 | maybe_accept( node, &AsmStmt::instruction ); |
---|
| 869 | maybe_accept( node, &AsmStmt::output ); |
---|
| 870 | maybe_accept( node, &AsmStmt::input ); |
---|
| 871 | maybe_accept( node, &AsmStmt::clobber ); |
---|
[e21f253] | 872 | } |
---|
[8a5530c] | 873 | |
---|
| 874 | VISIT_END( Stmt, node ); |
---|
| 875 | } |
---|
| 876 | |
---|
| 877 | //-------------------------------------------------------------------------- |
---|
| 878 | // DirectiveStmt |
---|
[7ff3e522] | 879 | template< typename core_t > |
---|
| 880 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::DirectiveStmt * node ) { |
---|
[8a5530c] | 881 | VISIT_START( node ) |
---|
| 882 | |
---|
| 883 | VISIT_END( Stmt, node ); |
---|
| 884 | } |
---|
| 885 | |
---|
| 886 | //-------------------------------------------------------------------------- |
---|
| 887 | // IfStmt |
---|
[7ff3e522] | 888 | template< typename core_t > |
---|
| 889 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::IfStmt * node ) { |
---|
[8a5530c] | 890 | VISIT_START( node ); |
---|
[17a0228a] | 891 | |
---|
[e21f253] | 892 | if ( __visit_children() ) { |
---|
[8a5530c] | 893 | // if statements introduce a level of scope (for the initialization) |
---|
[0e42794] | 894 | guard_symtab guard { *this }; |
---|
[8a5530c] | 895 | maybe_accept( node, &IfStmt::inits ); |
---|
[9e23b446] | 896 | maybe_accept_top( node, &IfStmt::cond ); |
---|
[3b0bc16] | 897 | maybe_accept_as_compound( node, &IfStmt::then ); |
---|
| 898 | maybe_accept_as_compound( node, &IfStmt::else_ ); |
---|
[e21f253] | 899 | } |
---|
[17a0228a] | 900 | |
---|
[8a5530c] | 901 | VISIT_END( Stmt, node ); |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | //-------------------------------------------------------------------------- |
---|
[3b0bc16] | 905 | // WhileDoStmt |
---|
[7ff3e522] | 906 | template< typename core_t > |
---|
[3b0bc16] | 907 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::WhileDoStmt * node ) { |
---|
[8a5530c] | 908 | VISIT_START( node ); |
---|
| 909 | |
---|
[e21f253] | 910 | if ( __visit_children() ) { |
---|
[8a5530c] | 911 | // while statements introduce a level of scope (for the initialization) |
---|
[0e42794] | 912 | guard_symtab guard { *this }; |
---|
[3b0bc16] | 913 | maybe_accept( node, &WhileDoStmt::inits ); |
---|
[9e23b446] | 914 | maybe_accept_top( node, &WhileDoStmt::cond ); |
---|
[3b0bc16] | 915 | maybe_accept_as_compound( node, &WhileDoStmt::body ); |
---|
[e21f253] | 916 | } |
---|
[8a5530c] | 917 | |
---|
| 918 | VISIT_END( Stmt, node ); |
---|
| 919 | } |
---|
[23f99e1] | 920 | |
---|
[87701b6] | 921 | //-------------------------------------------------------------------------- |
---|
| 922 | // ForStmt |
---|
[7ff3e522] | 923 | template< typename core_t > |
---|
| 924 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::ForStmt * node ) { |
---|
[87701b6] | 925 | VISIT_START( node ); |
---|
| 926 | |
---|
[e21f253] | 927 | if ( __visit_children() ) { |
---|
[87701b6] | 928 | // for statements introduce a level of scope (for the initialization) |
---|
[0e42794] | 929 | guard_symtab guard { *this }; |
---|
[490fb92e] | 930 | // xxx - old ast does not create WithStmtsToAdd scope for loop inits. should revisit this later. |
---|
[87701b6] | 931 | maybe_accept( node, &ForStmt::inits ); |
---|
[9e23b446] | 932 | maybe_accept_top( node, &ForStmt::cond ); |
---|
| 933 | maybe_accept_top( node, &ForStmt::inc ); |
---|
[490fb92e] | 934 | maybe_accept_as_compound( node, &ForStmt::body ); |
---|
[e21f253] | 935 | } |
---|
[87701b6] | 936 | |
---|
| 937 | VISIT_END( Stmt, node ); |
---|
| 938 | } |
---|
| 939 | |
---|
| 940 | //-------------------------------------------------------------------------- |
---|
| 941 | // SwitchStmt |
---|
[7ff3e522] | 942 | template< typename core_t > |
---|
| 943 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::SwitchStmt * node ) { |
---|
[87701b6] | 944 | VISIT_START( node ); |
---|
| 945 | |
---|
[e21f253] | 946 | if ( __visit_children() ) { |
---|
[9e23b446] | 947 | maybe_accept_top( node, &SwitchStmt::cond ); |
---|
[400b8be] | 948 | maybe_accept( node, &SwitchStmt::cases ); |
---|
[e21f253] | 949 | } |
---|
[87701b6] | 950 | |
---|
| 951 | VISIT_END( Stmt, node ); |
---|
| 952 | } |
---|
| 953 | |
---|
| 954 | //-------------------------------------------------------------------------- |
---|
[400b8be] | 955 | // CaseClause |
---|
[7ff3e522] | 956 | template< typename core_t > |
---|
[400b8be] | 957 | const ast::CaseClause * ast::Pass< core_t >::visit( const ast::CaseClause * node ) { |
---|
[87701b6] | 958 | VISIT_START( node ); |
---|
| 959 | |
---|
[e21f253] | 960 | if ( __visit_children() ) { |
---|
[9e23b446] | 961 | maybe_accept_top( node, &CaseClause::cond ); |
---|
[400b8be] | 962 | maybe_accept( node, &CaseClause::stmts ); |
---|
[e21f253] | 963 | } |
---|
[87701b6] | 964 | |
---|
[400b8be] | 965 | VISIT_END( CaseClause, node ); |
---|
[87701b6] | 966 | } |
---|
| 967 | |
---|
| 968 | //-------------------------------------------------------------------------- |
---|
| 969 | // BranchStmt |
---|
[7ff3e522] | 970 | template< typename core_t > |
---|
| 971 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::BranchStmt * node ) { |
---|
[87701b6] | 972 | VISIT_START( node ); |
---|
| 973 | VISIT_END( Stmt, node ); |
---|
| 974 | } |
---|
| 975 | |
---|
| 976 | //-------------------------------------------------------------------------- |
---|
| 977 | // ReturnStmt |
---|
[7ff3e522] | 978 | template< typename core_t > |
---|
| 979 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::ReturnStmt * node ) { |
---|
[87701b6] | 980 | VISIT_START( node ); |
---|
| 981 | |
---|
[e21f253] | 982 | if ( __visit_children() ) { |
---|
[9e23b446] | 983 | maybe_accept_top( node, &ReturnStmt::expr ); |
---|
[e21f253] | 984 | } |
---|
[87701b6] | 985 | |
---|
| 986 | VISIT_END( Stmt, node ); |
---|
| 987 | } |
---|
| 988 | |
---|
| 989 | //-------------------------------------------------------------------------- |
---|
| 990 | // ThrowStmt |
---|
[7ff3e522] | 991 | template< typename core_t > |
---|
| 992 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::ThrowStmt * node ) { |
---|
[e61207e7] | 993 | VISIT_START( node ); |
---|
[87701b6] | 994 | |
---|
[e21f253] | 995 | if ( __visit_children() ) { |
---|
[e61207e7] | 996 | maybe_accept( node, &ThrowStmt::expr ); |
---|
| 997 | maybe_accept( node, &ThrowStmt::target ); |
---|
[e21f253] | 998 | } |
---|
[e61207e7] | 999 | |
---|
| 1000 | VISIT_END( Stmt, node ); |
---|
| 1001 | } |
---|
| 1002 | |
---|
| 1003 | //-------------------------------------------------------------------------- |
---|
| 1004 | // TryStmt |
---|
[7ff3e522] | 1005 | template< typename core_t > |
---|
| 1006 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::TryStmt * node ) { |
---|
[87701b6] | 1007 | VISIT_START( node ); |
---|
| 1008 | |
---|
[e21f253] | 1009 | if ( __visit_children() ) { |
---|
[acd80b4] | 1010 | maybe_accept( node, &TryStmt::body ); |
---|
| 1011 | maybe_accept( node, &TryStmt::handlers ); |
---|
| 1012 | maybe_accept( node, &TryStmt::finally ); |
---|
[e21f253] | 1013 | } |
---|
[87701b6] | 1014 | |
---|
[e61207e7] | 1015 | VISIT_END( Stmt, node ); |
---|
[87701b6] | 1016 | } |
---|
| 1017 | |
---|
[10a1225] | 1018 | //-------------------------------------------------------------------------- |
---|
[400b8be] | 1019 | // CatchClause |
---|
[7ff3e522] | 1020 | template< typename core_t > |
---|
[400b8be] | 1021 | const ast::CatchClause * ast::Pass< core_t >::visit( const ast::CatchClause * node ) { |
---|
[10a1225] | 1022 | VISIT_START( node ); |
---|
| 1023 | |
---|
[e21f253] | 1024 | if ( __visit_children() ) { |
---|
[10a1225] | 1025 | // catch statements introduce a level of scope (for the caught exception) |
---|
[0e42794] | 1026 | guard_symtab guard { *this }; |
---|
[400b8be] | 1027 | maybe_accept( node, &CatchClause::decl ); |
---|
[9e23b446] | 1028 | maybe_accept_top( node, &CatchClause::cond ); |
---|
[400b8be] | 1029 | maybe_accept_as_compound( node, &CatchClause::body ); |
---|
[e21f253] | 1030 | } |
---|
[10a1225] | 1031 | |
---|
[400b8be] | 1032 | VISIT_END( CatchClause, node ); |
---|
[10a1225] | 1033 | } |
---|
| 1034 | |
---|
| 1035 | //-------------------------------------------------------------------------- |
---|
[400b8be] | 1036 | // FinallyClause |
---|
[7ff3e522] | 1037 | template< typename core_t > |
---|
[400b8be] | 1038 | const ast::FinallyClause * ast::Pass< core_t >::visit( const ast::FinallyClause * node ) { |
---|
[10a1225] | 1039 | VISIT_START( node ); |
---|
| 1040 | |
---|
[e21f253] | 1041 | if ( __visit_children() ) { |
---|
[400b8be] | 1042 | maybe_accept( node, &FinallyClause::body ); |
---|
[e21f253] | 1043 | } |
---|
[10a1225] | 1044 | |
---|
[400b8be] | 1045 | VISIT_END( FinallyClause, node ); |
---|
[10a1225] | 1046 | } |
---|
| 1047 | |
---|
[37cdd97] | 1048 | //-------------------------------------------------------------------------- |
---|
| 1049 | // FinallyStmt |
---|
[7ff3e522] | 1050 | template< typename core_t > |
---|
| 1051 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::SuspendStmt * node ) { |
---|
[37cdd97] | 1052 | VISIT_START( node ); |
---|
| 1053 | |
---|
[e21f253] | 1054 | if ( __visit_children() ) { |
---|
[37cdd97] | 1055 | maybe_accept( node, &SuspendStmt::then ); |
---|
[e21f253] | 1056 | } |
---|
[37cdd97] | 1057 | |
---|
| 1058 | VISIT_END( Stmt, node ); |
---|
| 1059 | } |
---|
| 1060 | |
---|
[10a1225] | 1061 | //-------------------------------------------------------------------------- |
---|
| 1062 | // WaitForStmt |
---|
[7ff3e522] | 1063 | template< typename core_t > |
---|
| 1064 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::WaitForStmt * node ) { |
---|
[10a1225] | 1065 | VISIT_START( node ); |
---|
| 1066 | |
---|
[e21f253] | 1067 | if ( __visit_children() ) { |
---|
[f6e6a55] | 1068 | maybe_accept( node, &WaitForStmt::clauses ); |
---|
| 1069 | maybe_accept( node, &WaitForStmt::timeout_time ); |
---|
| 1070 | maybe_accept( node, &WaitForStmt::timeout_stmt ); |
---|
| 1071 | maybe_accept( node, &WaitForStmt::timeout_cond ); |
---|
| 1072 | maybe_accept( node, &WaitForStmt::else_stmt ); |
---|
| 1073 | maybe_accept( node, &WaitForStmt::else_cond ); |
---|
[e21f253] | 1074 | } |
---|
[e0016a5] | 1075 | |
---|
[f6e6a55] | 1076 | VISIT_END( Stmt, node ); |
---|
| 1077 | } |
---|
| 1078 | |
---|
| 1079 | //-------------------------------------------------------------------------- |
---|
| 1080 | // WaitForClause |
---|
| 1081 | template< typename core_t > |
---|
| 1082 | const ast::WaitForClause * ast::Pass< core_t >::visit( const ast::WaitForClause * node ) { |
---|
| 1083 | VISIT_START( node ); |
---|
[10a1225] | 1084 | |
---|
[e21f253] | 1085 | if ( __visit_children() ) { |
---|
[f6e6a55] | 1086 | maybe_accept( node, &WaitForClause::target_func ); |
---|
| 1087 | maybe_accept( node, &WaitForClause::target_args ); |
---|
| 1088 | maybe_accept( node, &WaitForClause::stmt ); |
---|
| 1089 | maybe_accept( node, &WaitForClause::cond ); |
---|
[e21f253] | 1090 | } |
---|
[10a1225] | 1091 | |
---|
[f6e6a55] | 1092 | VISIT_END( WaitForClause, node ); |
---|
[10a1225] | 1093 | } |
---|
| 1094 | |
---|
| 1095 | //-------------------------------------------------------------------------- |
---|
| 1096 | // WithStmt |
---|
[7ff3e522] | 1097 | template< typename core_t > |
---|
| 1098 | const ast::Decl * ast::Pass< core_t >::visit( const ast::WithStmt * node ) { |
---|
[10a1225] | 1099 | VISIT_START( node ); |
---|
| 1100 | |
---|
[e21f253] | 1101 | if ( __visit_children() ) { |
---|
[10a1225] | 1102 | maybe_accept( node, &WithStmt::exprs ); |
---|
| 1103 | { |
---|
| 1104 | // catch statements introduce a level of scope (for the caught exception) |
---|
[0e42794] | 1105 | guard_symtab guard { *this }; |
---|
[7ff3e522] | 1106 | __pass::symtab::addWith( core, 0, node->exprs, node ); |
---|
[10a1225] | 1107 | maybe_accept( node, &WithStmt::stmt ); |
---|
| 1108 | } |
---|
[e21f253] | 1109 | } |
---|
| 1110 | |
---|
[10a1225] | 1111 | VISIT_END( Stmt, node ); |
---|
| 1112 | } |
---|
| 1113 | |
---|
| 1114 | //-------------------------------------------------------------------------- |
---|
| 1115 | // NullStmt |
---|
[7ff3e522] | 1116 | template< typename core_t > |
---|
| 1117 | const ast::NullStmt * ast::Pass< core_t >::visit( const ast::NullStmt * node ) { |
---|
[10a1225] | 1118 | VISIT_START( node ); |
---|
| 1119 | VISIT_END( NullStmt, node ); |
---|
| 1120 | } |
---|
| 1121 | |
---|
| 1122 | //-------------------------------------------------------------------------- |
---|
| 1123 | // DeclStmt |
---|
[7ff3e522] | 1124 | template< typename core_t > |
---|
| 1125 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::DeclStmt * node ) { |
---|
[10a1225] | 1126 | VISIT_START( node ); |
---|
| 1127 | |
---|
[e21f253] | 1128 | if ( __visit_children() ) { |
---|
[10a1225] | 1129 | maybe_accept( node, &DeclStmt::decl ); |
---|
[e21f253] | 1130 | } |
---|
[10a1225] | 1131 | |
---|
| 1132 | VISIT_END( Stmt, node ); |
---|
| 1133 | } |
---|
| 1134 | |
---|
| 1135 | //-------------------------------------------------------------------------- |
---|
| 1136 | // ImplicitCtorDtorStmt |
---|
[7ff3e522] | 1137 | template< typename core_t > |
---|
| 1138 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::ImplicitCtorDtorStmt * node ) { |
---|
[10a1225] | 1139 | VISIT_START( node ); |
---|
| 1140 | |
---|
| 1141 | // For now this isn't visited, it is unclear if this causes problem |
---|
| 1142 | // if all tests are known to pass, remove this code |
---|
[e21f253] | 1143 | if ( __visit_children() ) { |
---|
[c570806] | 1144 | maybe_accept( node, &ImplicitCtorDtorStmt::callStmt ); |
---|
[e21f253] | 1145 | } |
---|
[10a1225] | 1146 | |
---|
| 1147 | VISIT_END( Stmt, node ); |
---|
| 1148 | } |
---|
| 1149 | |
---|
[6cebfef] | 1150 | //-------------------------------------------------------------------------- |
---|
| 1151 | // MutexStmt |
---|
| 1152 | template< typename core_t > |
---|
| 1153 | const ast::Stmt * ast::Pass< core_t >::visit( const ast::MutexStmt * node ) { |
---|
| 1154 | VISIT_START( node ); |
---|
| 1155 | |
---|
[e21f253] | 1156 | if ( __visit_children() ) { |
---|
[6cebfef] | 1157 | // mutex statements introduce a level of scope (for the initialization) |
---|
| 1158 | guard_symtab guard { *this }; |
---|
| 1159 | maybe_accept( node, &MutexStmt::stmt ); |
---|
| 1160 | maybe_accept( node, &MutexStmt::mutexObjs ); |
---|
[e21f253] | 1161 | } |
---|
[6cebfef] | 1162 | |
---|
| 1163 | VISIT_END( Stmt, node ); |
---|
| 1164 | } |
---|
| 1165 | |
---|
[17a0228a] | 1166 | //-------------------------------------------------------------------------- |
---|
| 1167 | // ApplicationExpr |
---|
[7ff3e522] | 1168 | template< typename core_t > |
---|
| 1169 | const ast::Expr * ast::Pass< core_t >::visit( const ast::ApplicationExpr * node ) { |
---|
[17a0228a] | 1170 | VISIT_START( node ); |
---|
| 1171 | |
---|
[e21f253] | 1172 | if ( __visit_children() ) { |
---|
[17a0228a] | 1173 | { |
---|
[0e42794] | 1174 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1175 | maybe_accept( node, &ApplicationExpr::result ); |
---|
| 1176 | } |
---|
| 1177 | maybe_accept( node, &ApplicationExpr::func ); |
---|
| 1178 | maybe_accept( node, &ApplicationExpr::args ); |
---|
[e21f253] | 1179 | } |
---|
[17a0228a] | 1180 | |
---|
| 1181 | VISIT_END( Expr, node ); |
---|
| 1182 | } |
---|
| 1183 | |
---|
| 1184 | //-------------------------------------------------------------------------- |
---|
| 1185 | // UntypedExpr |
---|
[7ff3e522] | 1186 | template< typename core_t > |
---|
| 1187 | const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedExpr * node ) { |
---|
[17a0228a] | 1188 | VISIT_START( node ); |
---|
| 1189 | |
---|
[e21f253] | 1190 | if ( __visit_children() ) { |
---|
[17a0228a] | 1191 | { |
---|
[0e42794] | 1192 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1193 | maybe_accept( node, &UntypedExpr::result ); |
---|
| 1194 | } |
---|
| 1195 | |
---|
| 1196 | maybe_accept( node, &UntypedExpr::args ); |
---|
[e21f253] | 1197 | } |
---|
[17a0228a] | 1198 | |
---|
| 1199 | VISIT_END( Expr, node ); |
---|
| 1200 | } |
---|
| 1201 | |
---|
| 1202 | //-------------------------------------------------------------------------- |
---|
| 1203 | // NameExpr |
---|
[7ff3e522] | 1204 | template< typename core_t > |
---|
| 1205 | const ast::Expr * ast::Pass< core_t >::visit( const ast::NameExpr * node ) { |
---|
[17a0228a] | 1206 | VISIT_START( node ); |
---|
| 1207 | |
---|
[e21f253] | 1208 | if ( __visit_children() ) { |
---|
[0e42794] | 1209 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1210 | maybe_accept( node, &NameExpr::result ); |
---|
[e21f253] | 1211 | } |
---|
[17a0228a] | 1212 | |
---|
| 1213 | VISIT_END( Expr, node ); |
---|
| 1214 | } |
---|
| 1215 | |
---|
[b0d9ff7] | 1216 | //-------------------------------------------------------------------------- |
---|
| 1217 | // QualifiedNameExpr |
---|
| 1218 | template< typename core_t > |
---|
| 1219 | const ast::Expr * ast::Pass< core_t >::visit( const ast::QualifiedNameExpr * node ) { |
---|
| 1220 | VISIT_START( node ); |
---|
| 1221 | if ( __visit_children() ) { |
---|
| 1222 | guard_symtab guard { *this }; |
---|
| 1223 | maybe_accept( node, &QualifiedNameExpr::type_decl ); |
---|
| 1224 | } |
---|
| 1225 | VISIT_END( Expr, node ); |
---|
| 1226 | } |
---|
| 1227 | |
---|
[17a0228a] | 1228 | //-------------------------------------------------------------------------- |
---|
| 1229 | // CastExpr |
---|
[7ff3e522] | 1230 | template< typename core_t > |
---|
| 1231 | const ast::Expr * ast::Pass< core_t >::visit( const ast::CastExpr * node ) { |
---|
[17a0228a] | 1232 | VISIT_START( node ); |
---|
| 1233 | |
---|
[e21f253] | 1234 | if ( __visit_children() ) { |
---|
| 1235 | { |
---|
[0e42794] | 1236 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1237 | maybe_accept( node, &CastExpr::result ); |
---|
| 1238 | } |
---|
| 1239 | maybe_accept( node, &CastExpr::arg ); |
---|
[e21f253] | 1240 | } |
---|
[17a0228a] | 1241 | |
---|
| 1242 | VISIT_END( Expr, node ); |
---|
| 1243 | } |
---|
| 1244 | |
---|
| 1245 | //-------------------------------------------------------------------------- |
---|
| 1246 | // KeywordCastExpr |
---|
[7ff3e522] | 1247 | template< typename core_t > |
---|
| 1248 | const ast::Expr * ast::Pass< core_t >::visit( const ast::KeywordCastExpr * node ) { |
---|
[17a0228a] | 1249 | VISIT_START( node ); |
---|
| 1250 | |
---|
[e21f253] | 1251 | if ( __visit_children() ) { |
---|
| 1252 | { |
---|
[0e42794] | 1253 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1254 | maybe_accept( node, &KeywordCastExpr::result ); |
---|
| 1255 | } |
---|
| 1256 | maybe_accept( node, &KeywordCastExpr::arg ); |
---|
[e21f253] | 1257 | } |
---|
[17a0228a] | 1258 | |
---|
| 1259 | VISIT_END( Expr, node ); |
---|
| 1260 | } |
---|
| 1261 | |
---|
| 1262 | //-------------------------------------------------------------------------- |
---|
| 1263 | // VirtualCastExpr |
---|
[7ff3e522] | 1264 | template< typename core_t > |
---|
| 1265 | const ast::Expr * ast::Pass< core_t >::visit( const ast::VirtualCastExpr * node ) { |
---|
[17a0228a] | 1266 | VISIT_START( node ); |
---|
| 1267 | |
---|
[e21f253] | 1268 | if ( __visit_children() ) { |
---|
| 1269 | { |
---|
[0e42794] | 1270 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1271 | maybe_accept( node, &VirtualCastExpr::result ); |
---|
| 1272 | } |
---|
| 1273 | maybe_accept( node, &VirtualCastExpr::arg ); |
---|
[e21f253] | 1274 | } |
---|
[17a0228a] | 1275 | |
---|
| 1276 | VISIT_END( Expr, node ); |
---|
| 1277 | } |
---|
| 1278 | |
---|
| 1279 | //-------------------------------------------------------------------------- |
---|
| 1280 | // AddressExpr |
---|
[7ff3e522] | 1281 | template< typename core_t > |
---|
| 1282 | const ast::Expr * ast::Pass< core_t >::visit( const ast::AddressExpr * node ) { |
---|
[17a0228a] | 1283 | VISIT_START( node ); |
---|
| 1284 | |
---|
[e21f253] | 1285 | if ( __visit_children() ) { |
---|
| 1286 | { |
---|
[0e42794] | 1287 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1288 | maybe_accept( node, &AddressExpr::result ); |
---|
| 1289 | } |
---|
| 1290 | maybe_accept( node, &AddressExpr::arg ); |
---|
[e21f253] | 1291 | } |
---|
[17a0228a] | 1292 | |
---|
| 1293 | VISIT_END( Expr, node ); |
---|
| 1294 | } |
---|
| 1295 | |
---|
| 1296 | //-------------------------------------------------------------------------- |
---|
| 1297 | // LabelAddressExpr |
---|
[7ff3e522] | 1298 | template< typename core_t > |
---|
| 1299 | const ast::Expr * ast::Pass< core_t >::visit( const ast::LabelAddressExpr * node ) { |
---|
[17a0228a] | 1300 | VISIT_START( node ); |
---|
| 1301 | |
---|
[e21f253] | 1302 | if ( __visit_children() ) { |
---|
[0e42794] | 1303 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1304 | maybe_accept( node, &LabelAddressExpr::result ); |
---|
[e21f253] | 1305 | } |
---|
[17a0228a] | 1306 | |
---|
| 1307 | VISIT_END( Expr, node ); |
---|
| 1308 | } |
---|
| 1309 | |
---|
| 1310 | //-------------------------------------------------------------------------- |
---|
| 1311 | // UntypedMemberExpr |
---|
[7ff3e522] | 1312 | template< typename core_t > |
---|
| 1313 | const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedMemberExpr * node ) { |
---|
[17a0228a] | 1314 | VISIT_START( node ); |
---|
| 1315 | |
---|
[e21f253] | 1316 | if ( __visit_children() ) { |
---|
| 1317 | { |
---|
[0e42794] | 1318 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1319 | maybe_accept( node, &UntypedMemberExpr::result ); |
---|
| 1320 | } |
---|
| 1321 | maybe_accept( node, &UntypedMemberExpr::aggregate ); |
---|
| 1322 | maybe_accept( node, &UntypedMemberExpr::member ); |
---|
[e21f253] | 1323 | } |
---|
[17a0228a] | 1324 | |
---|
| 1325 | VISIT_END( Expr, node ); |
---|
| 1326 | } |
---|
| 1327 | |
---|
| 1328 | //-------------------------------------------------------------------------- |
---|
| 1329 | // MemberExpr |
---|
[7ff3e522] | 1330 | template< typename core_t > |
---|
| 1331 | const ast::Expr * ast::Pass< core_t >::visit( const ast::MemberExpr * node ) { |
---|
[17a0228a] | 1332 | VISIT_START( node ); |
---|
| 1333 | |
---|
[e21f253] | 1334 | if ( __visit_children() ) { |
---|
| 1335 | { |
---|
[0e42794] | 1336 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1337 | maybe_accept( node, &MemberExpr::result ); |
---|
| 1338 | } |
---|
| 1339 | maybe_accept( node, &MemberExpr::aggregate ); |
---|
[e21f253] | 1340 | } |
---|
[17a0228a] | 1341 | |
---|
| 1342 | VISIT_END( Expr, node ); |
---|
| 1343 | } |
---|
| 1344 | |
---|
| 1345 | //-------------------------------------------------------------------------- |
---|
| 1346 | // VariableExpr |
---|
[7ff3e522] | 1347 | template< typename core_t > |
---|
| 1348 | const ast::Expr * ast::Pass< core_t >::visit( const ast::VariableExpr * node ) { |
---|
[17a0228a] | 1349 | VISIT_START( node ); |
---|
| 1350 | |
---|
[e21f253] | 1351 | if ( __visit_children() ) { |
---|
[0e42794] | 1352 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1353 | maybe_accept( node, &VariableExpr::result ); |
---|
[e21f253] | 1354 | } |
---|
[17a0228a] | 1355 | |
---|
| 1356 | VISIT_END( Expr, node ); |
---|
| 1357 | } |
---|
| 1358 | |
---|
| 1359 | //-------------------------------------------------------------------------- |
---|
| 1360 | // ConstantExpr |
---|
[7ff3e522] | 1361 | template< typename core_t > |
---|
| 1362 | const ast::Expr * ast::Pass< core_t >::visit( const ast::ConstantExpr * node ) { |
---|
[17a0228a] | 1363 | VISIT_START( node ); |
---|
| 1364 | |
---|
[e21f253] | 1365 | if ( __visit_children() ) { |
---|
[0e42794] | 1366 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1367 | maybe_accept( node, &ConstantExpr::result ); |
---|
[e21f253] | 1368 | } |
---|
[17a0228a] | 1369 | |
---|
| 1370 | VISIT_END( Expr, node ); |
---|
| 1371 | } |
---|
| 1372 | |
---|
| 1373 | //-------------------------------------------------------------------------- |
---|
| 1374 | // SizeofExpr |
---|
[7ff3e522] | 1375 | template< typename core_t > |
---|
| 1376 | const ast::Expr * ast::Pass< core_t >::visit( const ast::SizeofExpr * node ) { |
---|
[17a0228a] | 1377 | VISIT_START( node ); |
---|
| 1378 | |
---|
[e21f253] | 1379 | if ( __visit_children() ) { |
---|
| 1380 | { |
---|
[0e42794] | 1381 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1382 | maybe_accept( node, &SizeofExpr::result ); |
---|
| 1383 | } |
---|
| 1384 | if ( node->type ) { |
---|
| 1385 | maybe_accept( node, &SizeofExpr::type ); |
---|
| 1386 | } else { |
---|
| 1387 | maybe_accept( node, &SizeofExpr::expr ); |
---|
| 1388 | } |
---|
[e21f253] | 1389 | } |
---|
[17a0228a] | 1390 | |
---|
| 1391 | VISIT_END( Expr, node ); |
---|
| 1392 | } |
---|
| 1393 | |
---|
| 1394 | //-------------------------------------------------------------------------- |
---|
| 1395 | // AlignofExpr |
---|
[7ff3e522] | 1396 | template< typename core_t > |
---|
| 1397 | const ast::Expr * ast::Pass< core_t >::visit( const ast::AlignofExpr * node ) { |
---|
[17a0228a] | 1398 | VISIT_START( node ); |
---|
| 1399 | |
---|
[e21f253] | 1400 | if ( __visit_children() ) { |
---|
| 1401 | { |
---|
[0e42794] | 1402 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1403 | maybe_accept( node, &AlignofExpr::result ); |
---|
| 1404 | } |
---|
| 1405 | if ( node->type ) { |
---|
| 1406 | maybe_accept( node, &AlignofExpr::type ); |
---|
| 1407 | } else { |
---|
| 1408 | maybe_accept( node, &AlignofExpr::expr ); |
---|
| 1409 | } |
---|
[e21f253] | 1410 | } |
---|
[17a0228a] | 1411 | |
---|
| 1412 | VISIT_END( Expr, node ); |
---|
| 1413 | } |
---|
| 1414 | |
---|
| 1415 | //-------------------------------------------------------------------------- |
---|
| 1416 | // UntypedOffsetofExpr |
---|
[7ff3e522] | 1417 | template< typename core_t > |
---|
| 1418 | const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedOffsetofExpr * node ) { |
---|
[17a0228a] | 1419 | VISIT_START( node ); |
---|
| 1420 | |
---|
[e21f253] | 1421 | if ( __visit_children() ) { |
---|
| 1422 | { |
---|
[0e42794] | 1423 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1424 | maybe_accept( node, &UntypedOffsetofExpr::result ); |
---|
| 1425 | } |
---|
| 1426 | maybe_accept( node, &UntypedOffsetofExpr::type ); |
---|
[e21f253] | 1427 | } |
---|
[17a0228a] | 1428 | |
---|
| 1429 | VISIT_END( Expr, node ); |
---|
| 1430 | } |
---|
| 1431 | |
---|
| 1432 | //-------------------------------------------------------------------------- |
---|
| 1433 | // OffsetofExpr |
---|
[7ff3e522] | 1434 | template< typename core_t > |
---|
| 1435 | const ast::Expr * ast::Pass< core_t >::visit( const ast::OffsetofExpr * node ) { |
---|
[17a0228a] | 1436 | VISIT_START( node ); |
---|
| 1437 | |
---|
[e21f253] | 1438 | if ( __visit_children() ) { |
---|
| 1439 | { |
---|
[0e42794] | 1440 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1441 | maybe_accept( node, &OffsetofExpr::result ); |
---|
| 1442 | } |
---|
| 1443 | maybe_accept( node, &OffsetofExpr::type ); |
---|
[e21f253] | 1444 | } |
---|
[17a0228a] | 1445 | |
---|
| 1446 | VISIT_END( Expr, node ); |
---|
| 1447 | } |
---|
| 1448 | |
---|
| 1449 | //-------------------------------------------------------------------------- |
---|
| 1450 | // OffsetPackExpr |
---|
[7ff3e522] | 1451 | template< typename core_t > |
---|
| 1452 | const ast::Expr * ast::Pass< core_t >::visit( const ast::OffsetPackExpr * node ) { |
---|
[17a0228a] | 1453 | VISIT_START( node ); |
---|
| 1454 | |
---|
[e21f253] | 1455 | if ( __visit_children() ) { |
---|
| 1456 | { |
---|
[0e42794] | 1457 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1458 | maybe_accept( node, &OffsetPackExpr::result ); |
---|
| 1459 | } |
---|
| 1460 | maybe_accept( node, &OffsetPackExpr::type ); |
---|
[e21f253] | 1461 | } |
---|
[17a0228a] | 1462 | |
---|
| 1463 | VISIT_END( Expr, node ); |
---|
| 1464 | } |
---|
| 1465 | |
---|
| 1466 | //-------------------------------------------------------------------------- |
---|
| 1467 | // LogicalExpr |
---|
[7ff3e522] | 1468 | template< typename core_t > |
---|
| 1469 | const ast::Expr * ast::Pass< core_t >::visit( const ast::LogicalExpr * node ) { |
---|
[17a0228a] | 1470 | VISIT_START( node ); |
---|
| 1471 | |
---|
[e21f253] | 1472 | if ( __visit_children() ) { |
---|
| 1473 | { |
---|
[0e42794] | 1474 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1475 | maybe_accept( node, &LogicalExpr::result ); |
---|
| 1476 | } |
---|
| 1477 | maybe_accept( node, &LogicalExpr::arg1 ); |
---|
| 1478 | maybe_accept( node, &LogicalExpr::arg2 ); |
---|
[e21f253] | 1479 | } |
---|
[17a0228a] | 1480 | |
---|
| 1481 | VISIT_END( Expr, node ); |
---|
| 1482 | } |
---|
| 1483 | |
---|
| 1484 | //-------------------------------------------------------------------------- |
---|
| 1485 | // ConditionalExpr |
---|
[7ff3e522] | 1486 | template< typename core_t > |
---|
| 1487 | const ast::Expr * ast::Pass< core_t >::visit( const ast::ConditionalExpr * node ) { |
---|
[17a0228a] | 1488 | VISIT_START( node ); |
---|
| 1489 | |
---|
[e21f253] | 1490 | if ( __visit_children() ) { |
---|
| 1491 | { |
---|
[0e42794] | 1492 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1493 | maybe_accept( node, &ConditionalExpr::result ); |
---|
| 1494 | } |
---|
| 1495 | maybe_accept( node, &ConditionalExpr::arg1 ); |
---|
| 1496 | maybe_accept( node, &ConditionalExpr::arg2 ); |
---|
| 1497 | maybe_accept( node, &ConditionalExpr::arg3 ); |
---|
[e21f253] | 1498 | } |
---|
[17a0228a] | 1499 | |
---|
| 1500 | VISIT_END( Expr, node ); |
---|
| 1501 | } |
---|
[10a1225] | 1502 | |
---|
[17a0228a] | 1503 | //-------------------------------------------------------------------------- |
---|
| 1504 | // CommaExpr |
---|
[7ff3e522] | 1505 | template< typename core_t > |
---|
| 1506 | const ast::Expr * ast::Pass< core_t >::visit( const ast::CommaExpr * node ) { |
---|
[17a0228a] | 1507 | VISIT_START( node ); |
---|
| 1508 | |
---|
[e21f253] | 1509 | if ( __visit_children() ) { |
---|
| 1510 | { |
---|
[0e42794] | 1511 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1512 | maybe_accept( node, &CommaExpr::result ); |
---|
| 1513 | } |
---|
| 1514 | maybe_accept( node, &CommaExpr::arg1 ); |
---|
| 1515 | maybe_accept( node, &CommaExpr::arg2 ); |
---|
[e21f253] | 1516 | } |
---|
[17a0228a] | 1517 | |
---|
| 1518 | VISIT_END( Expr, node ); |
---|
| 1519 | } |
---|
| 1520 | |
---|
| 1521 | //-------------------------------------------------------------------------- |
---|
| 1522 | // TypeExpr |
---|
[7ff3e522] | 1523 | template< typename core_t > |
---|
| 1524 | const ast::Expr * ast::Pass< core_t >::visit( const ast::TypeExpr * node ) { |
---|
[17a0228a] | 1525 | VISIT_START( node ); |
---|
| 1526 | |
---|
[e21f253] | 1527 | if ( __visit_children() ) { |
---|
| 1528 | { |
---|
[0e42794] | 1529 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1530 | maybe_accept( node, &TypeExpr::result ); |
---|
| 1531 | } |
---|
| 1532 | maybe_accept( node, &TypeExpr::type ); |
---|
[e21f253] | 1533 | } |
---|
[17a0228a] | 1534 | |
---|
| 1535 | VISIT_END( Expr, node ); |
---|
| 1536 | } |
---|
| 1537 | |
---|
[4ec9513] | 1538 | //-------------------------------------------------------------------------- |
---|
| 1539 | // DimensionExpr |
---|
| 1540 | template< typename core_t > |
---|
| 1541 | const ast::Expr * ast::Pass< core_t >::visit( const ast::DimensionExpr * node ) { |
---|
| 1542 | VISIT_START( node ); |
---|
| 1543 | |
---|
| 1544 | if ( __visit_children() ) { |
---|
| 1545 | guard_symtab guard { *this }; |
---|
| 1546 | maybe_accept( node, &DimensionExpr::result ); |
---|
| 1547 | } |
---|
| 1548 | |
---|
| 1549 | VISIT_END( Expr, node ); |
---|
| 1550 | } |
---|
| 1551 | |
---|
[17a0228a] | 1552 | //-------------------------------------------------------------------------- |
---|
| 1553 | // AsmExpr |
---|
[7ff3e522] | 1554 | template< typename core_t > |
---|
| 1555 | const ast::Expr * ast::Pass< core_t >::visit( const ast::AsmExpr * node ) { |
---|
[17a0228a] | 1556 | VISIT_START( node ); |
---|
[10a1225] | 1557 | |
---|
[e21f253] | 1558 | if ( __visit_children() ) { |
---|
| 1559 | { |
---|
[0e42794] | 1560 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1561 | maybe_accept( node, &AsmExpr::result ); |
---|
| 1562 | } |
---|
| 1563 | maybe_accept( node, &AsmExpr::constraint ); |
---|
| 1564 | maybe_accept( node, &AsmExpr::operand ); |
---|
[e21f253] | 1565 | } |
---|
[10a1225] | 1566 | |
---|
[17a0228a] | 1567 | VISIT_END( Expr, node ); |
---|
| 1568 | } |
---|
[10a1225] | 1569 | |
---|
[17a0228a] | 1570 | //-------------------------------------------------------------------------- |
---|
| 1571 | // ImplicitCopyCtorExpr |
---|
[7ff3e522] | 1572 | template< typename core_t > |
---|
| 1573 | const ast::Expr * ast::Pass< core_t >::visit( const ast::ImplicitCopyCtorExpr * node ) { |
---|
[17a0228a] | 1574 | VISIT_START( node ); |
---|
| 1575 | |
---|
[e21f253] | 1576 | if ( __visit_children() ) { |
---|
| 1577 | { |
---|
[0e42794] | 1578 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1579 | maybe_accept( node, &ImplicitCopyCtorExpr::result ); |
---|
| 1580 | } |
---|
| 1581 | maybe_accept( node, &ImplicitCopyCtorExpr::callExpr ); |
---|
[e21f253] | 1582 | } |
---|
[17a0228a] | 1583 | |
---|
| 1584 | VISIT_END( Expr, node ); |
---|
| 1585 | } |
---|
| 1586 | |
---|
| 1587 | //-------------------------------------------------------------------------- |
---|
| 1588 | // ConstructorExpr |
---|
[7ff3e522] | 1589 | template< typename core_t > |
---|
| 1590 | const ast::Expr * ast::Pass< core_t >::visit( const ast::ConstructorExpr * node ) { |
---|
[17a0228a] | 1591 | VISIT_START( node ); |
---|
| 1592 | |
---|
[e21f253] | 1593 | if ( __visit_children() ) { |
---|
| 1594 | { |
---|
[0e42794] | 1595 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1596 | maybe_accept( node, &ConstructorExpr::result ); |
---|
| 1597 | } |
---|
| 1598 | maybe_accept( node, &ConstructorExpr::callExpr ); |
---|
[e21f253] | 1599 | } |
---|
[10a1225] | 1600 | |
---|
[17a0228a] | 1601 | VISIT_END( Expr, node ); |
---|
| 1602 | } |
---|
| 1603 | |
---|
| 1604 | //-------------------------------------------------------------------------- |
---|
| 1605 | // CompoundLiteralExpr |
---|
[7ff3e522] | 1606 | template< typename core_t > |
---|
| 1607 | const ast::Expr * ast::Pass< core_t >::visit( const ast::CompoundLiteralExpr * node ) { |
---|
[17a0228a] | 1608 | VISIT_START( node ); |
---|
| 1609 | |
---|
[e21f253] | 1610 | if ( __visit_children() ) { |
---|
| 1611 | { |
---|
[0e42794] | 1612 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1613 | maybe_accept( node, &CompoundLiteralExpr::result ); |
---|
| 1614 | } |
---|
| 1615 | maybe_accept( node, &CompoundLiteralExpr::init ); |
---|
[e21f253] | 1616 | } |
---|
[17a0228a] | 1617 | |
---|
| 1618 | VISIT_END( Expr, node ); |
---|
| 1619 | } |
---|
| 1620 | |
---|
| 1621 | //-------------------------------------------------------------------------- |
---|
| 1622 | // RangeExpr |
---|
[7ff3e522] | 1623 | template< typename core_t > |
---|
| 1624 | const ast::Expr * ast::Pass< core_t >::visit( const ast::RangeExpr * node ) { |
---|
[17a0228a] | 1625 | VISIT_START( node ); |
---|
| 1626 | |
---|
[e21f253] | 1627 | if ( __visit_children() ) { |
---|
| 1628 | { |
---|
[0e42794] | 1629 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1630 | maybe_accept( node, &RangeExpr::result ); |
---|
| 1631 | } |
---|
| 1632 | maybe_accept( node, &RangeExpr::low ); |
---|
| 1633 | maybe_accept( node, &RangeExpr::high ); |
---|
[e21f253] | 1634 | } |
---|
[17a0228a] | 1635 | |
---|
| 1636 | VISIT_END( Expr, node ); |
---|
| 1637 | } |
---|
| 1638 | |
---|
| 1639 | //-------------------------------------------------------------------------- |
---|
| 1640 | // UntypedTupleExpr |
---|
[7ff3e522] | 1641 | template< typename core_t > |
---|
| 1642 | const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedTupleExpr * node ) { |
---|
[17a0228a] | 1643 | VISIT_START( node ); |
---|
| 1644 | |
---|
[e21f253] | 1645 | if ( __visit_children() ) { |
---|
| 1646 | { |
---|
[0e42794] | 1647 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1648 | maybe_accept( node, &UntypedTupleExpr::result ); |
---|
| 1649 | } |
---|
| 1650 | maybe_accept( node, &UntypedTupleExpr::exprs ); |
---|
[e21f253] | 1651 | } |
---|
[17a0228a] | 1652 | |
---|
| 1653 | VISIT_END( Expr, node ); |
---|
| 1654 | } |
---|
| 1655 | |
---|
| 1656 | //-------------------------------------------------------------------------- |
---|
| 1657 | // TupleExpr |
---|
[7ff3e522] | 1658 | template< typename core_t > |
---|
| 1659 | const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleExpr * node ) { |
---|
[17a0228a] | 1660 | VISIT_START( node ); |
---|
| 1661 | |
---|
[e21f253] | 1662 | if ( __visit_children() ) { |
---|
| 1663 | { |
---|
[0e42794] | 1664 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1665 | maybe_accept( node, &TupleExpr::result ); |
---|
| 1666 | } |
---|
| 1667 | maybe_accept( node, &TupleExpr::exprs ); |
---|
[e21f253] | 1668 | } |
---|
[17a0228a] | 1669 | |
---|
| 1670 | VISIT_END( Expr, node ); |
---|
| 1671 | } |
---|
| 1672 | |
---|
| 1673 | //-------------------------------------------------------------------------- |
---|
| 1674 | // TupleIndexExpr |
---|
[7ff3e522] | 1675 | template< typename core_t > |
---|
| 1676 | const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleIndexExpr * node ) { |
---|
[17a0228a] | 1677 | VISIT_START( node ); |
---|
| 1678 | |
---|
[e21f253] | 1679 | if ( __visit_children() ) { |
---|
| 1680 | { |
---|
[0e42794] | 1681 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1682 | maybe_accept( node, &TupleIndexExpr::result ); |
---|
| 1683 | } |
---|
| 1684 | maybe_accept( node, &TupleIndexExpr::tuple ); |
---|
[e21f253] | 1685 | } |
---|
[17a0228a] | 1686 | |
---|
| 1687 | VISIT_END( Expr, node ); |
---|
| 1688 | } |
---|
| 1689 | |
---|
| 1690 | //-------------------------------------------------------------------------- |
---|
| 1691 | // TupleAssignExpr |
---|
[7ff3e522] | 1692 | template< typename core_t > |
---|
| 1693 | const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleAssignExpr * node ) { |
---|
[17a0228a] | 1694 | VISIT_START( node ); |
---|
| 1695 | |
---|
[e21f253] | 1696 | if ( __visit_children() ) { |
---|
| 1697 | { |
---|
[0e42794] | 1698 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1699 | maybe_accept( node, &TupleAssignExpr::result ); |
---|
| 1700 | } |
---|
| 1701 | maybe_accept( node, &TupleAssignExpr::stmtExpr ); |
---|
[e21f253] | 1702 | } |
---|
[17a0228a] | 1703 | |
---|
| 1704 | VISIT_END( Expr, node ); |
---|
| 1705 | } |
---|
| 1706 | |
---|
| 1707 | //-------------------------------------------------------------------------- |
---|
| 1708 | // StmtExpr |
---|
[7ff3e522] | 1709 | template< typename core_t > |
---|
| 1710 | const ast::Expr * ast::Pass< core_t >::visit( const ast::StmtExpr * node ) { |
---|
[17a0228a] | 1711 | VISIT_START( node ); |
---|
| 1712 | |
---|
[e21f253] | 1713 | if ( __visit_children() ) { |
---|
| 1714 | // don't want statements from outer CompoundStmts to be added to this StmtExpr |
---|
[17a0228a] | 1715 | // get the stmts that will need to be spliced in |
---|
[7ff3e522] | 1716 | auto stmts_before = __pass::stmtsToAddBefore( core, 0); |
---|
| 1717 | auto stmts_after = __pass::stmtsToAddAfter ( core, 0); |
---|
[17a0228a] | 1718 | |
---|
| 1719 | // These may be modified by subnode but most be restored once we exit this statemnet. |
---|
[b2a11ba] | 1720 | ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass::typeSubs( core, 0 ) ); |
---|
[17a0228a] | 1721 | ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); |
---|
| 1722 | ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); |
---|
| 1723 | |
---|
| 1724 | { |
---|
[0e42794] | 1725 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1726 | maybe_accept( node, &StmtExpr::result ); |
---|
| 1727 | } |
---|
| 1728 | maybe_accept( node, &StmtExpr::stmts ); |
---|
| 1729 | maybe_accept( node, &StmtExpr::returnDecls ); |
---|
| 1730 | maybe_accept( node, &StmtExpr::dtors ); |
---|
[e21f253] | 1731 | } |
---|
[17a0228a] | 1732 | |
---|
| 1733 | VISIT_END( Expr, node ); |
---|
| 1734 | } |
---|
| 1735 | |
---|
| 1736 | //-------------------------------------------------------------------------- |
---|
| 1737 | // UniqueExpr |
---|
[7ff3e522] | 1738 | template< typename core_t > |
---|
| 1739 | const ast::Expr * ast::Pass< core_t >::visit( const ast::UniqueExpr * node ) { |
---|
[17a0228a] | 1740 | VISIT_START( node ); |
---|
| 1741 | |
---|
[e21f253] | 1742 | if ( __visit_children() ) { |
---|
| 1743 | { |
---|
[0e42794] | 1744 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1745 | maybe_accept( node, &UniqueExpr::result ); |
---|
| 1746 | } |
---|
| 1747 | maybe_accept( node, &UniqueExpr::expr ); |
---|
[e21f253] | 1748 | } |
---|
[17a0228a] | 1749 | |
---|
| 1750 | VISIT_END( Expr, node ); |
---|
| 1751 | } |
---|
| 1752 | |
---|
| 1753 | //-------------------------------------------------------------------------- |
---|
| 1754 | // UntypedInitExpr |
---|
[7ff3e522] | 1755 | template< typename core_t > |
---|
| 1756 | const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedInitExpr * node ) { |
---|
[17a0228a] | 1757 | VISIT_START( node ); |
---|
| 1758 | |
---|
[e21f253] | 1759 | if ( __visit_children() ) { |
---|
| 1760 | { |
---|
[0e42794] | 1761 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1762 | maybe_accept( node, &UntypedInitExpr::result ); |
---|
| 1763 | } |
---|
| 1764 | maybe_accept( node, &UntypedInitExpr::expr ); |
---|
| 1765 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. |
---|
[e21f253] | 1766 | } |
---|
[17a0228a] | 1767 | |
---|
| 1768 | VISIT_END( Expr, node ); |
---|
| 1769 | } |
---|
| 1770 | |
---|
| 1771 | //-------------------------------------------------------------------------- |
---|
| 1772 | // InitExpr |
---|
[7ff3e522] | 1773 | template< typename core_t > |
---|
| 1774 | const ast::Expr * ast::Pass< core_t >::visit( const ast::InitExpr * node ) { |
---|
[17a0228a] | 1775 | VISIT_START( node ); |
---|
| 1776 | |
---|
[e21f253] | 1777 | if ( __visit_children() ) { |
---|
| 1778 | { |
---|
[0e42794] | 1779 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1780 | maybe_accept( node, &InitExpr::result ); |
---|
| 1781 | } |
---|
| 1782 | maybe_accept( node, &InitExpr::expr ); |
---|
| 1783 | maybe_accept( node, &InitExpr::designation ); |
---|
[e21f253] | 1784 | } |
---|
[17a0228a] | 1785 | |
---|
| 1786 | VISIT_END( Expr, node ); |
---|
| 1787 | } |
---|
| 1788 | |
---|
| 1789 | //-------------------------------------------------------------------------- |
---|
| 1790 | // DeletedExpr |
---|
[7ff3e522] | 1791 | template< typename core_t > |
---|
| 1792 | const ast::Expr * ast::Pass< core_t >::visit( const ast::DeletedExpr * node ) { |
---|
[17a0228a] | 1793 | VISIT_START( node ); |
---|
| 1794 | |
---|
[e21f253] | 1795 | if ( __visit_children() ) { |
---|
| 1796 | { |
---|
[0e42794] | 1797 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1798 | maybe_accept( node, &DeletedExpr::result ); |
---|
| 1799 | } |
---|
| 1800 | maybe_accept( node, &DeletedExpr::expr ); |
---|
| 1801 | // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. |
---|
[e21f253] | 1802 | } |
---|
[17a0228a] | 1803 | |
---|
| 1804 | VISIT_END( Expr, node ); |
---|
| 1805 | } |
---|
| 1806 | |
---|
| 1807 | //-------------------------------------------------------------------------- |
---|
| 1808 | // DefaultArgExpr |
---|
[7ff3e522] | 1809 | template< typename core_t > |
---|
| 1810 | const ast::Expr * ast::Pass< core_t >::visit( const ast::DefaultArgExpr * node ) { |
---|
[17a0228a] | 1811 | VISIT_START( node ); |
---|
| 1812 | |
---|
[e21f253] | 1813 | if ( __visit_children() ) { |
---|
| 1814 | { |
---|
[0e42794] | 1815 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1816 | maybe_accept( node, &DefaultArgExpr::result ); |
---|
| 1817 | } |
---|
| 1818 | maybe_accept( node, &DefaultArgExpr::expr ); |
---|
[e21f253] | 1819 | } |
---|
[17a0228a] | 1820 | |
---|
| 1821 | VISIT_END( Expr, node ); |
---|
| 1822 | } |
---|
| 1823 | |
---|
| 1824 | //-------------------------------------------------------------------------- |
---|
| 1825 | // GenericExpr |
---|
[7ff3e522] | 1826 | template< typename core_t > |
---|
| 1827 | const ast::Expr * ast::Pass< core_t >::visit( const ast::GenericExpr * node ) { |
---|
[17a0228a] | 1828 | VISIT_START( node ); |
---|
| 1829 | |
---|
[e21f253] | 1830 | if ( __visit_children() ) { |
---|
| 1831 | { |
---|
[0e42794] | 1832 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1833 | maybe_accept( node, &GenericExpr::result ); |
---|
| 1834 | } |
---|
| 1835 | maybe_accept( node, &GenericExpr::control ); |
---|
| 1836 | |
---|
| 1837 | std::vector<GenericExpr::Association> new_kids; |
---|
| 1838 | new_kids.reserve(node->associations.size()); |
---|
| 1839 | bool mutated = false; |
---|
| 1840 | for( const auto & assoc : node->associations ) { |
---|
[b0abc8a0] | 1841 | const Type * type = nullptr; |
---|
[17a0228a] | 1842 | if( assoc.type ) { |
---|
[0e42794] | 1843 | guard_symtab guard { *this }; |
---|
[17a0228a] | 1844 | type = assoc.type->accept( *this ); |
---|
| 1845 | if( type != assoc.type ) mutated = true; |
---|
| 1846 | } |
---|
[b0abc8a0] | 1847 | const Expr * expr = nullptr; |
---|
[17a0228a] | 1848 | if( assoc.expr ) { |
---|
| 1849 | expr = assoc.expr->accept( *this ); |
---|
| 1850 | if( expr != assoc.expr ) mutated = true; |
---|
| 1851 | } |
---|
| 1852 | new_kids.emplace_back( type, expr ); |
---|
| 1853 | } |
---|
| 1854 | |
---|
| 1855 | if(mutated) { |
---|
[d3aa64f1] | 1856 | auto n = __pass::mutate<core_t>(node); |
---|
[17a0228a] | 1857 | n->associations = std::move( new_kids ); |
---|
| 1858 | node = n; |
---|
| 1859 | } |
---|
[e21f253] | 1860 | } |
---|
[17a0228a] | 1861 | |
---|
| 1862 | VISIT_END( Expr, node ); |
---|
| 1863 | } |
---|
[10a1225] | 1864 | |
---|
[e0016a5] | 1865 | //-------------------------------------------------------------------------- |
---|
| 1866 | // VoidType |
---|
[7ff3e522] | 1867 | template< typename core_t > |
---|
| 1868 | const ast::Type * ast::Pass< core_t >::visit( const ast::VoidType * node ) { |
---|
[e0016a5] | 1869 | VISIT_START( node ); |
---|
[10a1225] | 1870 | |
---|
[e0016a5] | 1871 | VISIT_END( Type, node ); |
---|
| 1872 | } |
---|
[10a1225] | 1873 | |
---|
[e0016a5] | 1874 | //-------------------------------------------------------------------------- |
---|
| 1875 | // BasicType |
---|
[7ff3e522] | 1876 | template< typename core_t > |
---|
| 1877 | const ast::Type * ast::Pass< core_t >::visit( const ast::BasicType * node ) { |
---|
[e0016a5] | 1878 | VISIT_START( node ); |
---|
| 1879 | |
---|
| 1880 | VISIT_END( Type, node ); |
---|
| 1881 | } |
---|
| 1882 | |
---|
| 1883 | //-------------------------------------------------------------------------- |
---|
| 1884 | // PointerType |
---|
[7ff3e522] | 1885 | template< typename core_t > |
---|
| 1886 | const ast::Type * ast::Pass< core_t >::visit( const ast::PointerType * node ) { |
---|
[e0016a5] | 1887 | VISIT_START( node ); |
---|
| 1888 | |
---|
[e21f253] | 1889 | if ( __visit_children() ) { |
---|
[4ec9513] | 1890 | maybe_accept( node, &PointerType::dimension ); |
---|
[e0016a5] | 1891 | maybe_accept( node, &PointerType::base ); |
---|
[e21f253] | 1892 | } |
---|
[e0016a5] | 1893 | |
---|
| 1894 | VISIT_END( Type, node ); |
---|
| 1895 | } |
---|
| 1896 | |
---|
| 1897 | //-------------------------------------------------------------------------- |
---|
| 1898 | // ArrayType |
---|
[7ff3e522] | 1899 | template< typename core_t > |
---|
| 1900 | const ast::Type * ast::Pass< core_t >::visit( const ast::ArrayType * node ) { |
---|
[e0016a5] | 1901 | VISIT_START( node ); |
---|
| 1902 | |
---|
[e21f253] | 1903 | if ( __visit_children() ) { |
---|
[e0016a5] | 1904 | maybe_accept( node, &ArrayType::dimension ); |
---|
| 1905 | maybe_accept( node, &ArrayType::base ); |
---|
[e21f253] | 1906 | } |
---|
[e0016a5] | 1907 | |
---|
| 1908 | VISIT_END( Type, node ); |
---|
| 1909 | } |
---|
| 1910 | |
---|
| 1911 | //-------------------------------------------------------------------------- |
---|
| 1912 | // ReferenceType |
---|
[7ff3e522] | 1913 | template< typename core_t > |
---|
| 1914 | const ast::Type * ast::Pass< core_t >::visit( const ast::ReferenceType * node ) { |
---|
[e0016a5] | 1915 | VISIT_START( node ); |
---|
| 1916 | |
---|
[e21f253] | 1917 | if ( __visit_children() ) { |
---|
[e0016a5] | 1918 | maybe_accept( node, &ReferenceType::base ); |
---|
[e21f253] | 1919 | } |
---|
[e0016a5] | 1920 | |
---|
| 1921 | VISIT_END( Type, node ); |
---|
| 1922 | } |
---|
| 1923 | |
---|
| 1924 | //-------------------------------------------------------------------------- |
---|
| 1925 | // QualifiedType |
---|
[7ff3e522] | 1926 | template< typename core_t > |
---|
| 1927 | const ast::Type * ast::Pass< core_t >::visit( const ast::QualifiedType * node ) { |
---|
[e0016a5] | 1928 | VISIT_START( node ); |
---|
| 1929 | |
---|
[e21f253] | 1930 | if ( __visit_children() ) { |
---|
[e0016a5] | 1931 | maybe_accept( node, &QualifiedType::parent ); |
---|
| 1932 | maybe_accept( node, &QualifiedType::child ); |
---|
[e21f253] | 1933 | } |
---|
[e0016a5] | 1934 | |
---|
| 1935 | VISIT_END( Type, node ); |
---|
| 1936 | } |
---|
| 1937 | |
---|
| 1938 | //-------------------------------------------------------------------------- |
---|
| 1939 | // FunctionType |
---|
[7ff3e522] | 1940 | template< typename core_t > |
---|
| 1941 | const ast::Type * ast::Pass< core_t >::visit( const ast::FunctionType * node ) { |
---|
[e0016a5] | 1942 | VISIT_START( node ); |
---|
| 1943 | |
---|
[e21f253] | 1944 | if ( __visit_children() ) { |
---|
[3e5dd913] | 1945 | // guard_forall_subs forall_guard { *this, node }; |
---|
| 1946 | // mutate_forall( node ); |
---|
| 1947 | maybe_accept( node, &FunctionType::assertions ); |
---|
[e0016a5] | 1948 | maybe_accept( node, &FunctionType::returns ); |
---|
| 1949 | maybe_accept( node, &FunctionType::params ); |
---|
[e21f253] | 1950 | } |
---|
[e0016a5] | 1951 | |
---|
| 1952 | VISIT_END( Type, node ); |
---|
| 1953 | } |
---|
| 1954 | |
---|
| 1955 | //-------------------------------------------------------------------------- |
---|
| 1956 | // StructInstType |
---|
[7ff3e522] | 1957 | template< typename core_t > |
---|
| 1958 | const ast::Type * ast::Pass< core_t >::visit( const ast::StructInstType * node ) { |
---|
[e0016a5] | 1959 | VISIT_START( node ); |
---|
| 1960 | |
---|
[7ff3e522] | 1961 | __pass::symtab::addStruct( core, 0, node->name ); |
---|
[e0016a5] | 1962 | |
---|
[e21f253] | 1963 | if ( __visit_children() ) { |
---|
[0e42794] | 1964 | guard_symtab guard { *this }; |
---|
[e0016a5] | 1965 | maybe_accept( node, &StructInstType::params ); |
---|
[e21f253] | 1966 | } |
---|
[e0016a5] | 1967 | |
---|
| 1968 | VISIT_END( Type, node ); |
---|
| 1969 | } |
---|
| 1970 | |
---|
| 1971 | //-------------------------------------------------------------------------- |
---|
| 1972 | // UnionInstType |
---|
[7ff3e522] | 1973 | template< typename core_t > |
---|
| 1974 | const ast::Type * ast::Pass< core_t >::visit( const ast::UnionInstType * node ) { |
---|
[e0016a5] | 1975 | VISIT_START( node ); |
---|
| 1976 | |
---|
[7ff3e522] | 1977 | __pass::symtab::addUnion( core, 0, node->name ); |
---|
[e0016a5] | 1978 | |
---|
[e21f253] | 1979 | if ( __visit_children() ) { |
---|
[0e42794] | 1980 | guard_symtab guard { *this }; |
---|
[e0016a5] | 1981 | maybe_accept( node, &UnionInstType::params ); |
---|
[e21f253] | 1982 | } |
---|
[e0016a5] | 1983 | |
---|
| 1984 | VISIT_END( Type, node ); |
---|
| 1985 | } |
---|
| 1986 | |
---|
| 1987 | //-------------------------------------------------------------------------- |
---|
| 1988 | // EnumInstType |
---|
[7ff3e522] | 1989 | template< typename core_t > |
---|
| 1990 | const ast::Type * ast::Pass< core_t >::visit( const ast::EnumInstType * node ) { |
---|
[e0016a5] | 1991 | VISIT_START( node ); |
---|
| 1992 | |
---|
[e21f253] | 1993 | if ( __visit_children() ) { |
---|
[e0016a5] | 1994 | maybe_accept( node, &EnumInstType::params ); |
---|
[e21f253] | 1995 | } |
---|
[e0016a5] | 1996 | |
---|
| 1997 | VISIT_END( Type, node ); |
---|
| 1998 | } |
---|
| 1999 | |
---|
| 2000 | //-------------------------------------------------------------------------- |
---|
| 2001 | // TraitInstType |
---|
[7ff3e522] | 2002 | template< typename core_t > |
---|
| 2003 | const ast::Type * ast::Pass< core_t >::visit( const ast::TraitInstType * node ) { |
---|
[e0016a5] | 2004 | VISIT_START( node ); |
---|
| 2005 | |
---|
[e21f253] | 2006 | if ( __visit_children() ) { |
---|
[e0016a5] | 2007 | maybe_accept( node, &TraitInstType::params ); |
---|
[e21f253] | 2008 | } |
---|
[e0016a5] | 2009 | |
---|
| 2010 | VISIT_END( Type, node ); |
---|
| 2011 | } |
---|
| 2012 | |
---|
| 2013 | //-------------------------------------------------------------------------- |
---|
| 2014 | // TypeInstType |
---|
[7ff3e522] | 2015 | template< typename core_t > |
---|
| 2016 | const ast::Type * ast::Pass< core_t >::visit( const ast::TypeInstType * node ) { |
---|
[e0016a5] | 2017 | VISIT_START( node ); |
---|
| 2018 | |
---|
[e21f253] | 2019 | if ( __visit_children() ) { |
---|
[e0e9a0b] | 2020 | { |
---|
| 2021 | maybe_accept( node, &TypeInstType::params ); |
---|
| 2022 | } |
---|
| 2023 | // ensure that base re-bound if doing substitution |
---|
[7ff3e522] | 2024 | __pass::forall::replace( core, 0, node ); |
---|
[e21f253] | 2025 | } |
---|
[e0016a5] | 2026 | |
---|
| 2027 | VISIT_END( Type, node ); |
---|
| 2028 | } |
---|
| 2029 | |
---|
| 2030 | //-------------------------------------------------------------------------- |
---|
| 2031 | // TupleType |
---|
[7ff3e522] | 2032 | template< typename core_t > |
---|
| 2033 | const ast::Type * ast::Pass< core_t >::visit( const ast::TupleType * node ) { |
---|
[e0016a5] | 2034 | VISIT_START( node ); |
---|
| 2035 | |
---|
[e21f253] | 2036 | if ( __visit_children() ) { |
---|
[e0016a5] | 2037 | maybe_accept( node, &TupleType::types ); |
---|
| 2038 | maybe_accept( node, &TupleType::members ); |
---|
[e21f253] | 2039 | } |
---|
[e0016a5] | 2040 | |
---|
| 2041 | VISIT_END( Type, node ); |
---|
| 2042 | } |
---|
| 2043 | |
---|
| 2044 | //-------------------------------------------------------------------------- |
---|
| 2045 | // TypeofType |
---|
[7ff3e522] | 2046 | template< typename core_t > |
---|
| 2047 | const ast::Type * ast::Pass< core_t >::visit( const ast::TypeofType * node ) { |
---|
[e0016a5] | 2048 | VISIT_START( node ); |
---|
| 2049 | |
---|
[e21f253] | 2050 | if ( __visit_children() ) { |
---|
[e0016a5] | 2051 | maybe_accept( node, &TypeofType::expr ); |
---|
[e21f253] | 2052 | } |
---|
[e0016a5] | 2053 | |
---|
| 2054 | VISIT_END( Type, node ); |
---|
| 2055 | } |
---|
| 2056 | |
---|
[3945abe] | 2057 | //-------------------------------------------------------------------------- |
---|
| 2058 | // VTableType |
---|
| 2059 | template< typename core_t > |
---|
| 2060 | const ast::Type * ast::Pass< core_t >::visit( const ast::VTableType * node ) { |
---|
| 2061 | VISIT_START( node ); |
---|
| 2062 | |
---|
[e21f253] | 2063 | if ( __visit_children() ) { |
---|
[3945abe] | 2064 | maybe_accept( node, &VTableType::base ); |
---|
[e21f253] | 2065 | } |
---|
[3945abe] | 2066 | |
---|
| 2067 | VISIT_END( Type, node ); |
---|
| 2068 | } |
---|
| 2069 | |
---|
[e0016a5] | 2070 | //-------------------------------------------------------------------------- |
---|
| 2071 | // VarArgsType |
---|
[7ff3e522] | 2072 | template< typename core_t > |
---|
| 2073 | const ast::Type * ast::Pass< core_t >::visit( const ast::VarArgsType * node ) { |
---|
[e0016a5] | 2074 | VISIT_START( node ); |
---|
| 2075 | |
---|
| 2076 | VISIT_END( Type, node ); |
---|
| 2077 | } |
---|
| 2078 | |
---|
| 2079 | //-------------------------------------------------------------------------- |
---|
| 2080 | // ZeroType |
---|
[7ff3e522] | 2081 | template< typename core_t > |
---|
| 2082 | const ast::Type * ast::Pass< core_t >::visit( const ast::ZeroType * node ) { |
---|
[e0016a5] | 2083 | VISIT_START( node ); |
---|
| 2084 | |
---|
| 2085 | VISIT_END( Type, node ); |
---|
| 2086 | } |
---|
| 2087 | |
---|
| 2088 | //-------------------------------------------------------------------------- |
---|
| 2089 | // OneType |
---|
[7ff3e522] | 2090 | template< typename core_t > |
---|
| 2091 | const ast::Type * ast::Pass< core_t >::visit( const ast::OneType * node ) { |
---|
[e0016a5] | 2092 | VISIT_START( node ); |
---|
| 2093 | |
---|
| 2094 | VISIT_END( Type, node ); |
---|
| 2095 | } |
---|
| 2096 | |
---|
| 2097 | //-------------------------------------------------------------------------- |
---|
| 2098 | // GlobalScopeType |
---|
[7ff3e522] | 2099 | template< typename core_t > |
---|
| 2100 | const ast::Type * ast::Pass< core_t >::visit( const ast::GlobalScopeType * node ) { |
---|
[e0016a5] | 2101 | VISIT_START( node ); |
---|
| 2102 | |
---|
| 2103 | VISIT_END( Type, node ); |
---|
| 2104 | } |
---|
| 2105 | |
---|
| 2106 | |
---|
| 2107 | //-------------------------------------------------------------------------- |
---|
| 2108 | // Designation |
---|
[7ff3e522] | 2109 | template< typename core_t > |
---|
| 2110 | const ast::Designation * ast::Pass< core_t >::visit( const ast::Designation * node ) { |
---|
[e0016a5] | 2111 | VISIT_START( node ); |
---|
| 2112 | |
---|
[e21f253] | 2113 | if ( __visit_children() ) { |
---|
| 2114 | maybe_accept( node, &Designation::designators ); |
---|
| 2115 | } |
---|
[e0016a5] | 2116 | |
---|
| 2117 | VISIT_END( Designation, node ); |
---|
| 2118 | } |
---|
[10a1225] | 2119 | |
---|
[6d51bd7] | 2120 | //-------------------------------------------------------------------------- |
---|
| 2121 | // SingleInit |
---|
[7ff3e522] | 2122 | template< typename core_t > |
---|
| 2123 | const ast::Init * ast::Pass< core_t >::visit( const ast::SingleInit * node ) { |
---|
[6d51bd7] | 2124 | VISIT_START( node ); |
---|
| 2125 | |
---|
[e21f253] | 2126 | if ( __visit_children() ) { |
---|
[9e23b446] | 2127 | maybe_accept_top( node, &SingleInit::value ); |
---|
[e21f253] | 2128 | } |
---|
[6d51bd7] | 2129 | |
---|
| 2130 | VISIT_END( Init, node ); |
---|
| 2131 | } |
---|
| 2132 | |
---|
| 2133 | //-------------------------------------------------------------------------- |
---|
| 2134 | // ListInit |
---|
[7ff3e522] | 2135 | template< typename core_t > |
---|
| 2136 | const ast::Init * ast::Pass< core_t >::visit( const ast::ListInit * node ) { |
---|
[6d51bd7] | 2137 | VISIT_START( node ); |
---|
| 2138 | |
---|
[e21f253] | 2139 | if ( __visit_children() ) { |
---|
[6d51bd7] | 2140 | maybe_accept( node, &ListInit::designations ); |
---|
| 2141 | maybe_accept( node, &ListInit::initializers ); |
---|
[e21f253] | 2142 | } |
---|
[6d51bd7] | 2143 | |
---|
| 2144 | VISIT_END( Init, node ); |
---|
| 2145 | } |
---|
| 2146 | |
---|
| 2147 | //-------------------------------------------------------------------------- |
---|
| 2148 | // ConstructorInit |
---|
[7ff3e522] | 2149 | template< typename core_t > |
---|
| 2150 | const ast::Init * ast::Pass< core_t >::visit( const ast::ConstructorInit * node ) { |
---|
[6d51bd7] | 2151 | VISIT_START( node ); |
---|
| 2152 | |
---|
[e21f253] | 2153 | if ( __visit_children() ) { |
---|
[6d51bd7] | 2154 | maybe_accept( node, &ConstructorInit::ctor ); |
---|
| 2155 | maybe_accept( node, &ConstructorInit::dtor ); |
---|
| 2156 | maybe_accept( node, &ConstructorInit::init ); |
---|
[e21f253] | 2157 | } |
---|
[6d51bd7] | 2158 | |
---|
| 2159 | VISIT_END( Init, node ); |
---|
| 2160 | } |
---|
| 2161 | |
---|
[f47f887] | 2162 | //-------------------------------------------------------------------------- |
---|
| 2163 | // Attribute |
---|
[7ff3e522] | 2164 | template< typename core_t > |
---|
| 2165 | const ast::Attribute * ast::Pass< core_t >::visit( const ast::Attribute * node ) { |
---|
[6d51bd7] | 2166 | VISIT_START( node ); |
---|
[f47f887] | 2167 | |
---|
[e21f253] | 2168 | if ( __visit_children() ) { |
---|
[489bacf] | 2169 | maybe_accept( node, &Attribute::params ); |
---|
[e21f253] | 2170 | } |
---|
[f47f887] | 2171 | |
---|
[8a5530c] | 2172 | VISIT_END( Attribute, node ); |
---|
[f47f887] | 2173 | } |
---|
| 2174 | |
---|
| 2175 | //-------------------------------------------------------------------------- |
---|
| 2176 | // TypeSubstitution |
---|
[7ff3e522] | 2177 | template< typename core_t > |
---|
| 2178 | const ast::TypeSubstitution * ast::Pass< core_t >::visit( const ast::TypeSubstitution * node ) { |
---|
[6d51bd7] | 2179 | VISIT_START( node ); |
---|
[f47f887] | 2180 | |
---|
[e21f253] | 2181 | if ( __visit_children() ) { |
---|
[8631c84] | 2182 | bool mutated = false; |
---|
[a8b87d3] | 2183 | ast::TypeSubstitution::TypeMap new_map; |
---|
| 2184 | for ( const auto & p : node->typeMap ) { |
---|
[8631c84] | 2185 | guard_symtab guard { *this }; |
---|
| 2186 | auto new_node = p.second->accept( *this ); |
---|
| 2187 | if (new_node != p.second) mutated = true; |
---|
| 2188 | new_map.insert({ p.first, new_node }); |
---|
| 2189 | } |
---|
| 2190 | if (mutated) { |
---|
| 2191 | auto new_node = __pass::mutate<core_t>( node ); |
---|
[a8b87d3] | 2192 | new_node->typeMap.swap( new_map ); |
---|
[8631c84] | 2193 | node = new_node; |
---|
[6d51bd7] | 2194 | } |
---|
[e21f253] | 2195 | } |
---|
[f47f887] | 2196 | |
---|
[6d51bd7] | 2197 | VISIT_END( TypeSubstitution, node ); |
---|
[f47f887] | 2198 | } |
---|
| 2199 | |
---|
| 2200 | #undef VISIT_START |
---|
[112fe04] | 2201 | #undef VISIT_END |
---|