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