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