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