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