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