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