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