source: src/Common/PassVisitor.impl.h@ ddcedfe

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since ddcedfe was c6c682cf, checked in by Andrew Beach <ajbeach@…>, 5 years ago

This should make the value of Pass[Visitor]::inFunction match the expected value.

  • Property mode set to 100644
File size: 108.3 KB
RevLine 
[13932f14]1#pragma once
[3268a58]2// IWYU pragma: private, include "PassVisitor.h"
[13932f14]3
[3c398b6]4#define VISIT_START( node ) \
5 __attribute__((unused)) \
6 ChildrenGuard children_guard( get_visit_children_ptr() ); \
7 __attribute__((unused)) \
[62423350]8 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
[3c398b6]9 call_previsit( node ); \
[6e09f211]10
11#define VISIT_END( node ) \
12 call_postvisit( node ); \
[9c1600c]13
[3c398b6]14#define MUTATE_START( node ) \
15 __attribute__((unused)) \
16 ChildrenGuard children_guard( get_visit_children_ptr() ); \
17 __attribute__((unused)) \
[62423350]18 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
[3c398b6]19 call_premutate( node ); \
[296b2be]20
21#define MUTATE_END( type, node ) \
[6a625de]22 auto __return = call_postmutate< type * >( node ); \
23 assert( __return ); \
24 return __return;
[296b2be]25
26
[134322e]27template<typename T>
28static inline bool empty( T * ptr ) {
29 return !ptr || ptr->empty();
30}
31
[6ca154b]32typedef std::list< Statement * > StmtList_t;
33typedef std::list< Declaration * > DeclList_t;
34
35template<typename iterator_t>
36static inline void splice( iterator_t it, DeclList_t * decls ) {
37 std::transform(
38 decls->begin(),
39 decls->end(),
40 it,
41 [](Declaration * decl) -> auto {
[ba3706f]42 return new DeclStmt( decl );
[6ca154b]43 }
44 );
45 decls->clear();
46}
[134322e]47
48template< typename pass_type >
[07c178f0]49inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
[6ca154b]50 DeclList_t* beforeDecls = visitor.get_beforeDecls();
51 DeclList_t* afterDecls = visitor.get_afterDecls();
[a16764a6]52 SemanticErrorException errors;
[134322e]53
[675716e]54 pass_visitor_stats.depth++;
55 pass_visitor_stats.max->push(pass_visitor_stats.depth);
56 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[6ca154b]57 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
[675716e]58
59
[6ca154b]60 // splice in new declarations after previous decl
[d24d4e1]61 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
[6ca154b]62
63 if ( i == decls.end() ) break;
64
[522363e]65 try {
66 // run visitor on declaration
[3c398b6]67 maybeAccept_impl( *i, visitor );
[a16764a6]68 } catch( SemanticErrorException &e ) {
[522363e]69 errors.append( e );
70 }
[6ca154b]71
72 // splice in new declarations before current decl
73 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
[134322e]74 }
[675716e]75 pass_visitor_stats.depth--;
[522363e]76 if ( ! errors.isEmpty() ) {
77 throw errors;
78 }
[6ca154b]79}
[134322e]80
[7870799]81template< typename pass_type >
82inline void acceptAll( const std::list< const Declaration * > & decls, PassVisitor< pass_type >& visitor ) {
83 SemanticErrorException errors;
84
85 pass_visitor_stats.depth++;
86 pass_visitor_stats.max->push(pass_visitor_stats.depth);
87 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
88 for ( const Declaration * decl : decls ) {
89 try {
90 // run visitor on declaration
91 maybeAccept_impl( decl, visitor );
92 }
93 catch( SemanticErrorException &e ) {
94 errors.append( e );
95 }
96 }
97 pass_visitor_stats.depth--;
98 if ( ! errors.isEmpty() ) {
99 throw errors;
100 }
101}
102
[6ca154b]103template< typename pass_type >
[07c178f0]104inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
[6ca154b]105 DeclList_t* beforeDecls = mutator.get_beforeDecls();
106 DeclList_t* afterDecls = mutator.get_afterDecls();
[a16764a6]107 SemanticErrorException errors;
[6ca154b]108
[675716e]109 pass_visitor_stats.depth++;
110 pass_visitor_stats.max->push(pass_visitor_stats.depth);
111 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[6ca154b]112 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
113 // splice in new declarations after previous decl
[d24d4e1]114 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
[6ca154b]115
116 if ( i == decls.end() ) break;
[522363e]117 try {
118 // run mutator on declaration
[3c398b6]119 maybeMutate_impl( *i, mutator );
[a16764a6]120 } catch( SemanticErrorException &e ) {
[522363e]121 errors.append( e );
122 }
[6ca154b]123
124 // splice in new declarations before current decl
125 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
126 }
[675716e]127 pass_visitor_stats.depth--;
[522363e]128 if ( ! errors.isEmpty() ) {
129 throw errors;
130 }
[134322e]131}
132
[3c398b6]133template< typename TreeType, typename pass_type >
134inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
135 if ( ! visitor.get_visit_children() ) return;
136 if ( tree ) {
137 tree->accept( visitor );
138 }
139}
140
[7870799]141template< typename TreeType, typename pass_type >
142inline void maybeAccept_impl( const TreeType * tree, PassVisitor< pass_type > & visitor ) {
143 if ( ! visitor.get_visit_children() ) return;
144 if ( tree ) {
145 tree->accept( visitor );
146 }
147}
148
[3c398b6]149template< typename Container, typename pass_type >
150inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
151 if ( ! visitor.get_visit_children() ) return;
[a16764a6]152 SemanticErrorException errors;
[675716e]153
154 pass_visitor_stats.depth++;
155 pass_visitor_stats.max->push(pass_visitor_stats.depth);
156 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[e0886db]157 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
158 try {
159 if ( *i ) {
160 (*i)->accept( visitor );
161 }
[a16764a6]162 } catch( SemanticErrorException &e ) {
[e0886db]163 errors.append( e );
164 }
165 }
[675716e]166 pass_visitor_stats.depth--;
[e0886db]167 if ( ! errors.isEmpty() ) {
168 throw errors;
169 }
170}
171
[7870799]172template< typename Container, typename pass_type >
173inline void maybeAccept_impl( const Container & container, PassVisitor< pass_type > & visitor ) {
174 if ( ! visitor.get_visit_children() ) return;
175 SemanticErrorException errors;
176
177 pass_visitor_stats.depth++;
178 pass_visitor_stats.max->push(pass_visitor_stats.depth);
179 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
180 for ( const auto & i : container ) {
181 try {
182 if ( i ) {
183 i->accept( visitor );
184 }
185 } catch( SemanticErrorException &e ) {
186 errors.append( e );
187 }
188 }
189 pass_visitor_stats.depth--;
190 if ( ! errors.isEmpty() ) {
191 throw errors;
192 }
193}
194
[3c398b6]195template< typename TreeType, typename pass_type >
196inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
197 if ( ! mutator.get_visit_children() ) return;
198
199 if ( tree ) {
200 tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
201 }
202}
203
204template< typename Container, typename pass_type >
205inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
[37e3af4]206
[3c398b6]207 if ( ! mutator.get_visit_children() ) return;
[a16764a6]208 SemanticErrorException errors;
[675716e]209
210 pass_visitor_stats.depth++;
211 pass_visitor_stats.max->push(pass_visitor_stats.depth);
212 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[e0886db]213 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
214 try {
215 if ( *i ) {
216 *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
217 assert( *i );
218 } // if
[a16764a6]219 } catch( SemanticErrorException &e ) {
[e0886db]220 errors.append( e );
221 } // try
222 } // for
[675716e]223 pass_visitor_stats.depth--;
[e0886db]224 if ( ! errors.isEmpty() ) {
225 throw errors;
226 } // if
227}
228
[296b2be]229template< typename pass_type >
[6ca154b]230template< typename func_t >
231void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
[3c398b6]232 if ( ! get_visit_children() ) return;
[a16764a6]233 SemanticErrorException errors;
[296b2be]234
[2a7b3ca]235 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
236 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
237 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
238 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
239 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
240
[134322e]241 StmtList_t* beforeStmts = get_beforeStmts();
242 StmtList_t* afterStmts = get_afterStmts();
[6ca154b]243 DeclList_t* beforeDecls = get_beforeDecls();
244 DeclList_t* afterDecls = get_afterDecls();
[134322e]245
[675716e]246 pass_visitor_stats.depth++;
247 pass_visitor_stats.max->push(pass_visitor_stats.depth);
248 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[296b2be]249 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
[6ca154b]250
251 if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }
[134322e]252 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
[6ca154b]253
[296b2be]254 try {
[6ca154b]255 func( *i );
[37e3af4]256 assert( *i );
[6ca154b]257 assert(( empty( beforeStmts ) && empty( afterStmts ))
258 || ( empty( beforeDecls ) && empty( afterDecls )) );
259
[a16764a6]260 } catch ( SemanticErrorException &e ) {
[296b2be]261 errors.append( e );
[134322e]262 }
[6ca154b]263
264 if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }
[134322e]265 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
[296b2be]266 }
[675716e]267 pass_visitor_stats.depth--;
[134322e]268
[6ca154b]269 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
[134322e]270 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
271 if ( !errors.isEmpty() ) { throw errors; }
[296b2be]272}
273
274template< typename pass_type >
[6ca154b]275void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
276 handleStatementList( statements, [this]( Statement * stmt) {
[3c398b6]277 maybeAccept_impl( stmt, *this );
[6ca154b]278 });
279}
[134322e]280
[7870799]281template< typename pass_type >
282void PassVisitor< pass_type >::visitStatementList( const std::list< Statement * > & statements ) {
283 if ( ! get_visit_children() ) return;
284 SemanticErrorException errors;
285
286 pass_visitor_stats.depth++;
287 pass_visitor_stats.max->push(pass_visitor_stats.depth);
288 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
289 for ( const Statement * i : statements ) {
290 try {
291 maybeAccept_impl( i, *this );
292 } catch ( SemanticErrorException &e ) {
293 errors.append( e );
294 }
295 }
296 pass_visitor_stats.depth--;
297 if ( !errors.isEmpty() ) { throw errors; }
298}
299
[6ca154b]300template< typename pass_type >
301void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
302 handleStatementList( statements, [this]( Statement *& stmt) {
[3c398b6]303 maybeMutate_impl( stmt, *this );
[6ca154b]304 });
[134322e]305}
306
[6ca154b]307
[134322e]308template< typename pass_type >
[6ca154b]309template< typename func_t >
310Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
[3c398b6]311 if ( ! get_visit_children() ) return stmt;
312
[134322e]313 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
[02fdb8e]314 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
[6ca154b]315 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
316 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
317 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
318 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
[296b2be]319
[6ca154b]320 Statement *newStmt = func( stmt );
[134322e]321
322 StmtList_t* beforeStmts = get_beforeStmts();
323 StmtList_t* afterStmts = get_afterStmts();
[6ca154b]324 DeclList_t* beforeDecls = get_beforeDecls();
325 DeclList_t* afterDecls = get_afterDecls();
[134322e]326
[6ca154b]327 if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; }
328 assert(( empty( beforeStmts ) && empty( afterStmts ))
329 || ( empty( beforeDecls ) && empty( afterDecls )) );
[134322e]330
[ba3706f]331 CompoundStmt *compound = new CompoundStmt();
[6ca154b]332 if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); }
[134322e]333 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
334 compound->get_kids().push_back( newStmt );
[6ca154b]335 if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }
[134322e]336 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
337 return compound;
338}
339
340template< typename pass_type >
[6ca154b]341Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
342 return handleStatement( stmt, [this]( Statement * stmt ) {
[3c398b6]343 maybeAccept_impl( stmt, *this );
[6ca154b]344 return stmt;
345 });
346}
[134322e]347
[7870799]348template< typename pass_type >
349void PassVisitor< pass_type >::visitStatement( const Statement * stmt ) {
350 if ( ! get_visit_children() ) return;
351
352 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
353 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
354
355 maybeAccept_impl( stmt, *this );
356}
357
[6ca154b]358template< typename pass_type >
359Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
360 return handleStatement( stmt, [this]( Statement * stmt ) {
[3c398b6]361 maybeMutate_impl( stmt, *this );
362 return stmt;
[6ca154b]363 });
[296b2be]364}
365
366template< typename pass_type >
[6ca154b]367template< typename func_t >
368Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
[3c398b6]369 if ( ! get_visit_children() ) return expr;
[296b2be]370 if( !expr ) return nullptr;
371
[134322e]372 auto env_ptr = get_env_ptr();
373 if ( env_ptr && expr->get_env() ) {
374 *env_ptr = expr->get_env();
[296b2be]375 }
[6ca154b]376
[3c398b6]377 // should env be moved onto the result of the mutate?
[6ca154b]378 return func( expr );
379}
380
381template< typename pass_type >
382Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
383 return handleExpression(expr, [this]( Expression * expr ) {
[3c398b6]384 maybeAccept_impl( expr, *this );
[6ca154b]385 return expr;
[d24d4e1]386 });
[296b2be]387}
[ab904dc]388
[7870799]389template< typename pass_type >
390void PassVisitor< pass_type >::visitExpression( const Expression * expr ) {
391 if ( ! get_visit_children() ) return;
392 if( !expr ) return;
393
394 auto env_ptr = get_env_ptr();
395 if ( env_ptr && expr->get_env() ) {
396 *env_ptr = expr->get_env();
397 }
398
399 maybeAccept_impl( expr, *this );
400}
401
[6ca154b]402template< typename pass_type >
403Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
404 return handleExpression(expr, [this]( Expression * expr ) {
[3c398b6]405 maybeMutate_impl( expr, *this );
406 return expr;
[6ca154b]407 });
408}
[ab904dc]409
[3c398b6]410template< typename TreeType, typename VisitorType >
411inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
412 if ( ! visitor.get_visit_children() ) return;
413 auto guard = makeFuncGuard(
414 [&visitor]() { visitor.indexerScopeEnter(); },
415 [&visitor]() { visitor.indexerScopeLeave(); }
416 );
417 maybeAccept_impl( tree, visitor );
418}
419
[7870799]420template< typename TreeType, typename VisitorType >
421inline void indexerScopedAccept( const TreeType * tree, VisitorType & visitor ) {
422 if ( ! visitor.get_visit_children() ) return;
423 auto guard = makeFuncGuard(
424 [&visitor]() { visitor.indexerScopeEnter(); },
425 [&visitor]() { visitor.indexerScopeLeave(); }
426 );
427 maybeAccept_impl( tree, visitor );
428}
429
[3c398b6]430template< typename TreeType, typename MutatorType >
431inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
432 if ( ! mutator.get_visit_children() ) return;
433 auto guard = makeFuncGuard(
434 [&mutator]() { mutator.indexerScopeEnter(); },
435 [&mutator]() { mutator.indexerScopeLeave(); }
436 );
437 maybeMutate_impl( tree, mutator );
438}
439
[296b2be]440//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[e0886db]441//========================================================================================================================================================================
442//========================================================================================================================================================================
443//========================================================================================================================================================================
444//========================================================================================================================================================================
445//========================================================================================================================================================================
446//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[13932f14]447
[33a25f9]448// A NOTE ON THE ORDER OF TRAVERSAL
449//
450// Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is
451// no such thing as a recursive type or typedef.
452//
453// typedef struct { T *x; } T; // never allowed
454//
455// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
456// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
457// declaration).
458//
459// struct T { struct T *x; }; // allowed
460//
461// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
462// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
463// queried later in this pass.
464//
465// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
[e0886db]466
467//--------------------------------------------------------------------------
468// ObjectDecl
[13932f14]469template< typename pass_type >
[ab904dc]470void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
[e0886db]471 VISIT_START( node );
472
473 indexerScopedAccept( node->type , *this );
[3c398b6]474 maybeAccept_impl ( node->init , *this );
475 maybeAccept_impl ( node->bitfieldWidth, *this );
476 maybeAccept_impl ( node->attributes , *this );
[e0886db]477
[2cb70aa]478 indexerAddId( node );
[e0886db]479
480 VISIT_END( node );
481}
482
[7870799]483template< typename pass_type >
484void PassVisitor< pass_type >::visit( const ObjectDecl * node ) {
485 VISIT_START( node );
486
487 maybeAccept_impl( node->type , *this );
488 maybeAccept_impl( node->init , *this );
489 maybeAccept_impl( node->bitfieldWidth, *this );
490 maybeAccept_impl( node->attributes , *this );
491
492 VISIT_END( node );
493}
494
[e0886db]495template< typename pass_type >
496DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) {
497 MUTATE_START( node );
498
499 indexerScopedMutate( node->type , *this );
[3c398b6]500 maybeMutate_impl ( node->init , *this );
501 maybeMutate_impl ( node->bitfieldWidth, *this );
502 maybeMutate_impl ( node->attributes , *this );
[e0886db]503
[2cb70aa]504 indexerAddId( node );
[e0886db]505
506 MUTATE_END( DeclarationWithType, node );
[13932f14]507}
508
[e0886db]509//--------------------------------------------------------------------------
510// FunctionDecl
[13932f14]511template< typename pass_type >
[ab904dc]512void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
[e0886db]513 VISIT_START( node );
514
[2cb70aa]515 indexerAddId( node );
[e0886db]516
[7aaec67]517 maybeAccept_impl( node->withExprs, *this );
[e0886db]518 {
[2cb70aa]519 // with clause introduces a level of scope (for the with expression members).
520 // with clause exprs are added to the indexer before parameters so that parameters
521 // shadow with exprs and not the other way around.
[e0886db]522 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]523 indexerAddWith( node->withExprs, node );
[7aaec67]524 {
525 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
526 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
527 static ObjectDecl func(
528 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
529 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
530 nullptr
531 );
532 indexerAddId( &func );
533 maybeAccept_impl( node->type, *this );
[c6c682cf]534 // First remember that we are now within a function.
[61d9b4b]535 ValueGuard< bool > oldInFunction( inFunction );
536 inFunction = true;
[c6c682cf]537 // The function body needs to have the same scope as parameters.
538 // A CompoundStmt will not enter a new scope if atFunctionTop is true.
539 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
540 atFunctionTop = true;
[7aaec67]541 maybeAccept_impl( node->statements, *this );
542 maybeAccept_impl( node->attributes, *this );
543 }
[e0886db]544 }
545
546 VISIT_END( node );
547}
548
[7870799]549template< typename pass_type >
550void PassVisitor< pass_type >::visit( const FunctionDecl * node ) {
551 VISIT_START( node );
552
[e3d7f9f]553 indexerAddId( node );
554
[7870799]555 maybeAccept_impl( node->withExprs, *this );
556 {
[e3d7f9f]557 // with clause introduces a level of scope (for the with expression members).
558 // with clause exprs are added to the indexer before parameters so that parameters
559 // shadow with exprs and not the other way around.
560 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
561 indexerAddWith( node->withExprs, node );
562 {
563 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
564 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
565 static ObjectDecl func(
566 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
567 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
568 nullptr
569 );
570 indexerAddId( &func );
571 maybeAccept_impl( node->type, *this );
[c6c682cf]572 // First remember that we are now within a function.
[e3d7f9f]573 ValueGuard< bool > oldInFunction( inFunction );
574 inFunction = true;
[c6c682cf]575 // The function body needs to have the same scope as parameters.
576 // A CompoundStmt will not enter a new scope if atFunctionTop is true.
577 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
578 atFunctionTop = true;
[e3d7f9f]579 maybeAccept_impl( node->statements, *this );
580 maybeAccept_impl( node->attributes, *this );
581 }
[7870799]582 }
583
584 VISIT_END( node );
585}
586
[e0886db]587template< typename pass_type >
588DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
589 MUTATE_START( node );
590
[2cb70aa]591 indexerAddId( node );
[e0886db]592
593 {
[2cb70aa]594 // with clause introduces a level of scope (for the with expression members).
595 // with clause exprs are added to the indexer before parameters so that parameters
596 // shadow with exprs and not the other way around.
[e0886db]597 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]598 indexerAddWith( node->withExprs, node );
[7aaec67]599 {
600 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
601 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
602 static ObjectDecl func(
603 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
604 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
605 nullptr
606 );
607 indexerAddId( &func );
608 maybeMutate_impl( node->type, *this );
[c6c682cf]609 // First remember that we are now within a function.
[61d9b4b]610 ValueGuard< bool > oldInFunction( inFunction );
611 inFunction = true;
[c6c682cf]612 // The function body needs to have the same scope as parameters.
613 // A CompoundStmt will not enter a new scope if atFunctionTop is true.
614 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
615 atFunctionTop = true;
[7aaec67]616 maybeMutate_impl( node->statements, *this );
617 maybeMutate_impl( node->attributes, *this );
618 }
[e0886db]619 }
620
621 MUTATE_END( DeclarationWithType, node );
[13932f14]622}
623
[e0886db]624//--------------------------------------------------------------------------
625// StructDecl
[13932f14]626template< typename pass_type >
[ab904dc]627void PassVisitor< pass_type >::visit( StructDecl * node ) {
[e0886db]628 VISIT_START( node );
629
630 // make up a forward declaration and add it before processing the members
631 // needs to be on the heap because addStruct saves the pointer
632 indexerAddStructFwd( node );
633
634 {
635 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]636 maybeAccept_impl( node->parameters, *this );
637 maybeAccept_impl( node->members , *this );
[e0886db]638 }
639
640 // this addition replaces the forward declaration
641 indexerAddStruct( node );
642
643 VISIT_END( node );
644}
645
[7870799]646template< typename pass_type >
647void PassVisitor< pass_type >::visit( const StructDecl * node ) {
648 VISIT_START( node );
649
[e3d7f9f]650 // make up a forward declaration and add it before processing the members
651 // needs to be on the heap because addStruct saves the pointer
652 indexerAddStructFwd( node );
653
654 {
655 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
656 maybeAccept_impl( node->parameters, *this );
657 maybeAccept_impl( node->members , *this );
658 }
659
660 // this addition replaces the forward declaration
661 indexerAddStruct( node );
[7870799]662
663 VISIT_END( node );
664}
665
[e0886db]666template< typename pass_type >
667Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
668 MUTATE_START( node );
669
670 // make up a forward declaration and add it before processing the members
671 // needs to be on the heap because addStruct saves the pointer
672 indexerAddStructFwd( node );
673
674 {
675 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]676 maybeMutate_impl( node->parameters, *this );
677 maybeMutate_impl( node->members , *this );
[e0886db]678 }
679
680 // this addition replaces the forward declaration
681 indexerAddStruct( node );
682
683 MUTATE_END( Declaration, node );
[13932f14]684}
685
[e0886db]686//--------------------------------------------------------------------------
687// UnionDecl
[13932f14]688template< typename pass_type >
[ab904dc]689void PassVisitor< pass_type >::visit( UnionDecl * node ) {
[e0886db]690 VISIT_START( node );
691
692 // make up a forward declaration and add it before processing the members
693 indexerAddUnionFwd( node );
694
695 {
696 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]697 maybeAccept_impl( node->parameters, *this );
698 maybeAccept_impl( node->members , *this );
[e0886db]699 }
700
701 indexerAddUnion( node );
702
703 VISIT_END( node );
704}
[7870799]705template< typename pass_type >
706void PassVisitor< pass_type >::visit( const UnionDecl * node ) {
707 VISIT_START( node );
708
[e3d7f9f]709 // make up a forward declaration and add it before processing the members
710 indexerAddUnionFwd( node );
711
712 {
713 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
714 maybeAccept_impl( node->parameters, *this );
715 maybeAccept_impl( node->members , *this );
716 }
717
718 indexerAddUnion( node );
[7870799]719
720 VISIT_END( node );
721}
[e0886db]722
723template< typename pass_type >
724Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
725 MUTATE_START( node );
726
727 // make up a forward declaration and add it before processing the members
728 indexerAddUnionFwd( node );
729
730 {
731 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]732 maybeMutate_impl( node->parameters, *this );
733 maybeMutate_impl( node->members , *this );
[e0886db]734 }
735
736 indexerAddUnion( node );
737
738 MUTATE_END( Declaration, node );
[13932f14]739}
740
[e0886db]741//--------------------------------------------------------------------------
742// EnumDecl
[13932f14]743template< typename pass_type >
[ab904dc]744void PassVisitor< pass_type >::visit( EnumDecl * node ) {
[e0886db]745 VISIT_START( node );
746
747 indexerAddEnum( node );
748
[33a25f9]749 // unlike structs, traits, and unions, enums inject their members into the global scope
[3c398b6]750 maybeAccept_impl( node->parameters, *this );
751 maybeAccept_impl( node->members , *this );
[e0886db]752
753 VISIT_END( node );
[13932f14]754}
755
[7870799]756template< typename pass_type >
757void PassVisitor< pass_type >::visit( const EnumDecl * node ) {
758 VISIT_START( node );
759
[e3d7f9f]760 indexerAddEnum( node );
761
[7870799]762 // unlike structs, traits, and unions, enums inject their members into the global scope
763 maybeAccept_impl( node->parameters, *this );
764 maybeAccept_impl( node->members , *this );
765
766 VISIT_END( node );
767}
768
[e0886db]769template< typename pass_type >
770Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
771 MUTATE_START( node );
772
773 indexerAddEnum( node );
774
[522363e]775 // unlike structs, traits, and unions, enums inject their members into the global scope
[3c398b6]776 maybeMutate_impl( node->parameters, *this );
777 maybeMutate_impl( node->members , *this );
[e0886db]778
779 MUTATE_END( Declaration, node );
780}
781
782//--------------------------------------------------------------------------
783// TraitDecl
[13932f14]784template< typename pass_type >
[ab904dc]785void PassVisitor< pass_type >::visit( TraitDecl * node ) {
[e0886db]786 VISIT_START( node );
787
788 {
789 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]790 maybeAccept_impl( node->parameters, *this );
791 maybeAccept_impl( node->members , *this );
[e0886db]792 }
793
794 indexerAddTrait( node );
795
796 VISIT_END( node );
[13932f14]797}
798
[7870799]799template< typename pass_type >
800void PassVisitor< pass_type >::visit( const TraitDecl * node ) {
801 VISIT_START( node );
802
[e3d7f9f]803 {
804 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
805 maybeAccept_impl( node->parameters, *this );
806 maybeAccept_impl( node->members , *this );
807 }
808
809 indexerAddTrait( node );
[7870799]810
811 VISIT_END( node );
812}
813
[e0886db]814template< typename pass_type >
815Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
816 MUTATE_START( node );
817
818 {
819 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]820 maybeMutate_impl( node->parameters, *this );
821 maybeMutate_impl( node->members , *this );
[e0886db]822 }
823
824 indexerAddTrait( node );
825
826 MUTATE_END( Declaration, node );
827}
828
829//--------------------------------------------------------------------------
830// TypeDecl
[13932f14]831template< typename pass_type >
[ab904dc]832void PassVisitor< pass_type >::visit( TypeDecl * node ) {
[e0886db]833 VISIT_START( node );
834
835 {
836 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]837 maybeAccept_impl( node->parameters, *this );
838 maybeAccept_impl( node->base , *this );
[e0886db]839 }
840
[33a25f9]841 // see A NOTE ON THE ORDER OF TRAVERSAL, above
842 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
843 // and may depend on the type itself
[e0886db]844 indexerAddType( node );
845
[3c398b6]846 maybeAccept_impl( node->assertions, *this );
[e0886db]847
848 indexerScopedAccept( node->init, *this );
849
850 VISIT_END( node );
851}
852
[7870799]853
854template< typename pass_type >
855void PassVisitor< pass_type >::visit( const TypeDecl * node ) {
856 VISIT_START( node );
857
[e3d7f9f]858 {
859 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
860 maybeAccept_impl( node->parameters, *this );
861 maybeAccept_impl( node->base , *this );
862 }
863
864 // see A NOTE ON THE ORDER OF TRAVERSAL, above
865 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
866 // and may depend on the type itself
867 indexerAddType( node );
868
[7870799]869 maybeAccept_impl( node->assertions, *this );
870
[e3d7f9f]871 indexerScopedAccept( node->init, *this );
872
[7870799]873 VISIT_END( node );
874}
875
[e0886db]876template< typename pass_type >
[982832e]877Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
[e0886db]878 MUTATE_START( node );
879
880 {
881 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]882 maybeMutate_impl( node->parameters, *this );
883 maybeMutate_impl( node->base , *this );
[e0886db]884 }
885
[33a25f9]886 // see A NOTE ON THE ORDER OF TRAVERSAL, above
887 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
888 // and may depend on the type itself
[e0886db]889 indexerAddType( node );
890
[3c398b6]891 maybeMutate_impl( node->assertions, *this );
[e0886db]892
893 indexerScopedMutate( node->init, *this );
894
[982832e]895 MUTATE_END( Declaration, node );
[13932f14]896}
897
[e0886db]898//--------------------------------------------------------------------------
899// TypedefDecl
[13932f14]900template< typename pass_type >
[ab904dc]901void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
[e0886db]902 VISIT_START( node );
903
904 {
905 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]906 maybeAccept_impl( node->parameters, *this );
907 maybeAccept_impl( node->base , *this );
[e0886db]908 }
909
910 indexerAddType( node );
911
[3c398b6]912 maybeAccept_impl( node->assertions, *this );
[e0886db]913
914 VISIT_END( node );
[13932f14]915}
916
[7870799]917template< typename pass_type >
918void PassVisitor< pass_type >::visit( const TypedefDecl * node ) {
919 VISIT_START( node );
920
[e3d7f9f]921 {
922 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
923 maybeAccept_impl( node->parameters, *this );
924 maybeAccept_impl( node->base , *this );
925 }
926
927 indexerAddType( node );
928
[7870799]929 maybeAccept_impl( node->assertions, *this );
930
931 VISIT_END( node );
932}
933
[13932f14]934template< typename pass_type >
[e0886db]935Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
936 MUTATE_START( node );
937
938 {
939 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]940 maybeMutate_impl( node->parameters, *this );
941 maybeMutate_impl( node->base , *this );
[e0886db]942 }
943
944 indexerAddType( node );
945
[3c398b6]946 maybeMutate_impl( node->assertions, *this );
[e0886db]947
948 MUTATE_END( Declaration, node );
[13932f14]949}
950
[9c1600c]951//--------------------------------------------------------------------------
[e0886db]952// AsmDecl
[13932f14]953template< typename pass_type >
[e0886db]954void PassVisitor< pass_type >::visit( AsmDecl * node ) {
[9c1600c]955 VISIT_START( node );
956
[3c398b6]957 maybeAccept_impl( node->stmt, *this );
[9c1600c]958
959 VISIT_END( node );
[13932f14]960}
961
[7870799]962template< typename pass_type >
963void PassVisitor< pass_type >::visit( const AsmDecl * node ) {
964 VISIT_START( node );
965
966 maybeAccept_impl( node->stmt, *this );
967
968 VISIT_END( node );
969}
970
[296b2be]971template< typename pass_type >
[e0886db]972AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
[296b2be]973 MUTATE_START( node );
974
[3c398b6]975 maybeMutate_impl( node->stmt, *this );
[e0886db]976
977 MUTATE_END( AsmDecl, node );
978}
979
[f6e3e34]980//--------------------------------------------------------------------------
981// StaticAssertDecl
982template< typename pass_type >
983void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) {
984 VISIT_START( node );
985
[842c3d3]986 node->condition = visitExpression( node->condition );
987 maybeAccept_impl( node->message, *this );
[f6e3e34]988
989 VISIT_END( node );
990}
991
[7870799]992template< typename pass_type >
993void PassVisitor< pass_type >::visit( const StaticAssertDecl * node ) {
994 VISIT_START( node );
995
996 visitExpression( node->condition );
997 maybeAccept_impl( node->message, *this );
998
999 VISIT_END( node );
1000}
1001
[f6e3e34]1002template< typename pass_type >
1003StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) {
1004 MUTATE_START( node );
1005
[842c3d3]1006 node->condition = mutateExpression( node->condition );
1007 maybeMutate_impl( node->message, *this );
[f6e3e34]1008
1009 MUTATE_END( StaticAssertDecl, node );
1010}
1011
[e0886db]1012//--------------------------------------------------------------------------
1013// CompoundStmt
1014template< typename pass_type >
1015void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
1016 VISIT_START( node );
1017 {
[c6c682cf]1018 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1019 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1020 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
[e0886db]1021 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
[c6c682cf]1022 atFunctionTop = false;
[e0886db]1023 visitStatementList( node->kids );
1024 }
1025 VISIT_END( node );
1026}
[296b2be]1027
[7870799]1028template< typename pass_type >
1029void PassVisitor< pass_type >::visit( const CompoundStmt * node ) {
1030 VISIT_START( node );
1031 {
[c6c682cf]1032 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1033 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1034 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
[7870799]1035 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
[c6c682cf]1036 atFunctionTop = false;
[7870799]1037 visitStatementList( node->kids );
1038 }
1039 VISIT_END( node );
1040}
1041
[e0886db]1042template< typename pass_type >
1043CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
1044 MUTATE_START( node );
1045 {
[c6c682cf]1046 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1047 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1048 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
[e0886db]1049 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
[c6c682cf]1050 atFunctionTop = false;
[e0886db]1051 mutateStatementList( node->kids );
1052 }
[296b2be]1053 MUTATE_END( CompoundStmt, node );
1054}
1055
[9c1600c]1056//--------------------------------------------------------------------------
1057// ExprStmt
[13932f14]1058template< typename pass_type >
[ab904dc]1059void PassVisitor< pass_type >::visit( ExprStmt * node ) {
[9c1600c]1060 VISIT_START( node );
1061
[e0886db]1062 visitExpression( node->expr );
[9c1600c]1063
1064 VISIT_END( node );
[13932f14]1065}
1066
[7870799]1067template< typename pass_type >
1068void PassVisitor< pass_type >::visit( const ExprStmt * node ) {
1069 VISIT_START( node );
1070
1071 visitExpression( node->expr );
1072
1073 VISIT_END( node );
1074}
1075
[296b2be]1076template< typename pass_type >
1077Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
1078 MUTATE_START( node );
1079
[e0886db]1080 node->expr = mutateExpression( node->expr );
[296b2be]1081
1082 MUTATE_END( Statement, node );
1083}
1084
[6ca154b]1085//--------------------------------------------------------------------------
1086// AsmStmt
[13932f14]1087template< typename pass_type >
[ab904dc]1088void PassVisitor< pass_type >::visit( AsmStmt * node ) {
[bc6f918]1089 VISIT_START( node )
1090
1091 maybeAccept_impl( node->instruction, *this );
1092 maybeAccept_impl( node->output, *this );
1093 maybeAccept_impl( node->input, *this );
1094 maybeAccept_impl( node->clobber, *this );
1095
1096 VISIT_END( node );
[13932f14]1097}
1098
[7870799]1099template< typename pass_type >
1100void PassVisitor< pass_type >::visit( const AsmStmt * node ) {
1101 VISIT_START( node )
1102
1103 maybeAccept_impl( node->instruction, *this );
1104 maybeAccept_impl( node->output, *this );
1105 maybeAccept_impl( node->input, *this );
1106 maybeAccept_impl( node->clobber, *this );
1107
1108 VISIT_END( node );
1109}
1110
[6ca154b]1111template< typename pass_type >
1112Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
[bc6f918]1113 MUTATE_START( node );
1114
1115 maybeMutate_impl( node->instruction, *this );
1116 maybeMutate_impl( node->output, *this );
1117 maybeMutate_impl( node->input, *this );
1118 maybeMutate_impl( node->clobber, *this );
1119
1120 MUTATE_END( Statement, node );
[6ca154b]1121}
1122
[cc32d83]1123//--------------------------------------------------------------------------
1124// AsmStmt
1125template< typename pass_type >
1126void PassVisitor< pass_type >::visit( DirectiveStmt * node ) {
1127 VISIT_START( node )
1128
1129 VISIT_END( node );
1130}
1131
[7870799]1132template< typename pass_type >
1133void PassVisitor< pass_type >::visit( const DirectiveStmt * node ) {
1134 VISIT_START( node )
1135
1136 VISIT_END( node );
1137}
1138
[cc32d83]1139template< typename pass_type >
1140Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) {
1141 MUTATE_START( node );
1142
1143 MUTATE_END( Statement, node );
1144}
1145
[9c1600c]1146//--------------------------------------------------------------------------
1147// IfStmt
[13932f14]1148template< typename pass_type >
[ab904dc]1149void PassVisitor< pass_type >::visit( IfStmt * node ) {
[4551a6e]1150 VISIT_START( node );
[33a25f9]1151 {
1152 // if statements introduce a level of scope (for the initialization)
1153 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[7870799]1154 maybeAccept_impl( node->initialization, *this );
[3c398b6]1155 visitExpression ( node->condition );
[33a25f9]1156 node->thenPart = visitStatement( node->thenPart );
1157 node->elsePart = visitStatement( node->elsePart );
1158 }
[9c1600c]1159 VISIT_END( node );
[13932f14]1160}
1161
[7870799]1162template< typename pass_type >
1163void PassVisitor< pass_type >::visit( const IfStmt * node ) {
1164 VISIT_START( node );
[e3d7f9f]1165 {
1166 // if statements introduce a level of scope (for the initialization)
1167 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1168 maybeAccept_impl( node->initialization, *this );
1169 visitExpression ( node->condition );
1170 visitStatement ( node->thenPart );
1171 visitStatement ( node->elsePart );
1172 }
[7870799]1173 VISIT_END( node );
1174}
1175
[296b2be]1176template< typename pass_type >
1177Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
[4551a6e]1178 MUTATE_START( node );
[e0886db]1179 {
[33a25f9]1180 // if statements introduce a level of scope (for the initialization)
[e0886db]1181 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[7870799]1182 maybeMutate_impl( node->initialization, *this );
[e0886db]1183 node->condition = mutateExpression( node->condition );
1184 node->thenPart = mutateStatement ( node->thenPart );
1185 node->elsePart = mutateStatement ( node->elsePart );
1186 }
[296b2be]1187 MUTATE_END( Statement, node );
1188}
1189
[9c1600c]1190//--------------------------------------------------------------------------
1191// WhileStmt
[13932f14]1192template< typename pass_type >
[ab904dc]1193void PassVisitor< pass_type >::visit( WhileStmt * node ) {
[4551a6e]1194 VISIT_START( node );
[9c1600c]1195
[ee3c93d]1196 {
1197 // while statements introduce a level of scope (for the initialization)
1198 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1199 maybeAccept_impl( node->initialization, *this );
1200 visitExpression ( node->condition );
1201 node->body = visitStatement( node->body );
1202 }
[9c1600c]1203
1204 VISIT_END( node );
[13932f14]1205}
1206
[7870799]1207template< typename pass_type >
1208void PassVisitor< pass_type >::visit( const WhileStmt * node ) {
1209 VISIT_START( node );
1210
[e3d7f9f]1211 {
1212 // while statements introduce a level of scope (for the initialization)
1213 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1214 maybeAccept_impl( node->initialization, *this );
1215 visitExpression ( node->condition );
1216 visitStatement ( node->body );
1217 }
[7870799]1218
1219 VISIT_END( node );
1220}
1221
[296b2be]1222template< typename pass_type >
1223Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
[4551a6e]1224 MUTATE_START( node );
[296b2be]1225
[ee3c93d]1226 {
1227 // while statements introduce a level of scope (for the initialization)
1228 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1229 maybeMutate_impl( node->initialization, *this );
1230 node->condition = mutateExpression( node->condition );
1231 node->body = mutateStatement ( node->body );
1232 }
1233
[296b2be]1234
1235 MUTATE_END( Statement, node );
1236}
1237
[9c1600c]1238//--------------------------------------------------------------------------
[6ca154b]1239// ForStmt
[13932f14]1240template< typename pass_type >
[ab904dc]1241void PassVisitor< pass_type >::visit( ForStmt * node ) {
[4551a6e]1242 VISIT_START( node );
[e0886db]1243 {
[33a25f9]1244 // for statements introduce a level of scope (for the initialization)
[e0886db]1245 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1246 maybeAccept_impl( node->initialization, *this );
[e0886db]1247 visitExpression( node->condition );
1248 visitExpression( node->increment );
1249 node->body = visitStatement( node->body );
1250 }
[9c1600c]1251 VISIT_END( node );
[13932f14]1252}
1253
[7870799]1254template< typename pass_type >
1255void PassVisitor< pass_type >::visit( const ForStmt * node ) {
1256 VISIT_START( node );
[e3d7f9f]1257 {
1258 // for statements introduce a level of scope (for the initialization)
1259 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1260 maybeAccept_impl( node->initialization, *this );
1261 visitExpression( node->condition );
1262 visitExpression( node->increment );
1263 visitStatement ( node->body );
1264 }
[7870799]1265 VISIT_END( node );
1266}
1267
[296b2be]1268template< typename pass_type >
1269Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
[4551a6e]1270 MUTATE_START( node );
[e0886db]1271 {
[33a25f9]1272 // for statements introduce a level of scope (for the initialization)
[e0886db]1273 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1274 maybeMutate_impl( node->initialization, *this );
[e0886db]1275 node->condition = mutateExpression( node->condition );
1276 node->increment = mutateExpression( node->increment );
1277 node->body = mutateStatement ( node->body );
1278 }
[296b2be]1279 MUTATE_END( Statement, node );
1280}
1281
[9c1600c]1282//--------------------------------------------------------------------------
1283// SwitchStmt
[13932f14]1284template< typename pass_type >
[ab904dc]1285void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
[4551a6e]1286 VISIT_START( node );
[9c1600c]1287
[e0886db]1288 visitExpression ( node->condition );
1289 visitStatementList( node->statements );
[9c1600c]1290
1291 VISIT_END( node );
[13932f14]1292}
1293
[7870799]1294template< typename pass_type >
1295void PassVisitor< pass_type >::visit( const SwitchStmt * node ) {
1296 VISIT_START( node );
1297
1298 visitExpression ( node->condition );
1299 visitStatementList( node->statements );
1300
1301 VISIT_END( node );
1302}
1303
[296b2be]1304template< typename pass_type >
1305Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
[4551a6e]1306 MUTATE_START( node );
1307
[e0886db]1308 node->condition = mutateExpression( node->condition );
1309 mutateStatementList( node->statements );
[4551a6e]1310
[296b2be]1311 MUTATE_END( Statement, node );
1312}
1313
[9c1600c]1314//--------------------------------------------------------------------------
[35df560]1315// CaseStmt
[13932f14]1316template< typename pass_type >
[ab904dc]1317void PassVisitor< pass_type >::visit( CaseStmt * node ) {
[4551a6e]1318 VISIT_START( node );
1319
[e0886db]1320 visitExpression ( node->condition );
1321 visitStatementList( node->stmts );
[4551a6e]1322
[9c1600c]1323 VISIT_END( node );
[13932f14]1324}
1325
[7870799]1326template< typename pass_type >
1327void PassVisitor< pass_type >::visit( const CaseStmt * node ) {
1328 VISIT_START( node );
1329
1330 visitExpression ( node->condition );
1331 visitStatementList( node->stmts );
1332
1333 VISIT_END( node );
1334}
1335
[296b2be]1336template< typename pass_type >
1337Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
[4551a6e]1338 MUTATE_START( node );
1339
[e0886db]1340 node->condition = mutateExpression( node->condition );
1341 mutateStatementList( node->stmts );
[4551a6e]1342
[296b2be]1343 MUTATE_END( Statement, node );
1344}
1345
[6ca154b]1346//--------------------------------------------------------------------------
1347// BranchStmt
[13932f14]1348template< typename pass_type >
[ab904dc]1349void PassVisitor< pass_type >::visit( BranchStmt * node ) {
[33c0ce8]1350 VISIT_START( node );
1351 VISIT_END( node );
[13932f14]1352}
1353
[7870799]1354template< typename pass_type >
1355void PassVisitor< pass_type >::visit( const BranchStmt * node ) {
1356 VISIT_START( node );
1357 VISIT_END( node );
1358}
1359
[6ca154b]1360template< typename pass_type >
1361Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
[33c0ce8]1362 MUTATE_START( node );
1363 MUTATE_END( Statement, node );
[6ca154b]1364}
1365
[9c1600c]1366//--------------------------------------------------------------------------
1367// ReturnStmt
[13932f14]1368template< typename pass_type >
[ab904dc]1369void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
[9c1600c]1370 VISIT_START( node );
1371
[e0886db]1372 visitExpression( node->expr );
[9c1600c]1373
1374 VISIT_END( node );
[13932f14]1375}
1376
[7870799]1377template< typename pass_type >
1378void PassVisitor< pass_type >::visit( const ReturnStmt * node ) {
1379 VISIT_START( node );
1380
1381 visitExpression( node->expr );
1382
1383 VISIT_END( node );
1384}
1385
[296b2be]1386template< typename pass_type >
1387Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
1388 MUTATE_START( node );
1389
[e0886db]1390 node->expr = mutateExpression( node->expr );
[296b2be]1391
1392 MUTATE_END( Statement, node );
1393}
1394
[6e09f211]1395//--------------------------------------------------------------------------
1396// ThrowStmt
1397template< typename pass_type >
1398void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
[33c0ce8]1399 VISIT_START( node );
1400
1401 maybeAccept_impl( node->expr, *this );
1402 maybeAccept_impl( node->target, *this );
1403
1404 VISIT_END( node );
[6e09f211]1405}
1406
[7870799]1407template< typename pass_type >
1408void PassVisitor< pass_type >::visit( const ThrowStmt * node ) {
1409 VISIT_START( node );
1410
1411 maybeAccept_impl( node->expr, *this );
1412 maybeAccept_impl( node->target, *this );
1413
1414 VISIT_END( node );
1415}
1416
[6e09f211]1417template< typename pass_type >
1418Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
[33c0ce8]1419 MUTATE_START( node );
1420
1421 maybeMutate_impl( node->expr, *this );
1422 maybeMutate_impl( node->target, *this );
1423
1424 MUTATE_END( Statement, node );
[6e09f211]1425}
1426
[9c1600c]1427//--------------------------------------------------------------------------
1428// TryStmt
[13932f14]1429template< typename pass_type >
[ab904dc]1430void PassVisitor< pass_type >::visit( TryStmt * node ) {
[9c1600c]1431 VISIT_START( node );
1432
[3c398b6]1433 maybeAccept_impl( node->block , *this );
1434 maybeAccept_impl( node->handlers , *this );
1435 maybeAccept_impl( node->finallyBlock, *this );
[9c1600c]1436
1437 VISIT_END( node );
[13932f14]1438}
1439
[7870799]1440template< typename pass_type >
1441void PassVisitor< pass_type >::visit( const TryStmt * node ) {
1442 VISIT_START( node );
1443
1444 maybeAccept_impl( node->block , *this );
1445 maybeAccept_impl( node->handlers , *this );
1446 maybeAccept_impl( node->finallyBlock, *this );
1447
1448 VISIT_END( node );
1449}
1450
[296b2be]1451template< typename pass_type >
1452Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
1453 MUTATE_START( node );
1454
[3c398b6]1455 maybeMutate_impl( node->block , *this );
1456 maybeMutate_impl( node->handlers , *this );
1457 maybeMutate_impl( node->finallyBlock, *this );
[4551a6e]1458
[296b2be]1459 MUTATE_END( Statement, node );
1460}
1461
[9c1600c]1462//--------------------------------------------------------------------------
1463// CatchStmt
[13932f14]1464template< typename pass_type >
[ab904dc]1465void PassVisitor< pass_type >::visit( CatchStmt * node ) {
[9c1600c]1466 VISIT_START( node );
[e0886db]1467 {
[33a25f9]1468 // catch statements introduce a level of scope (for the caught exception)
[e0886db]1469 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1470 maybeAccept_impl( node->decl, *this );
[e0886db]1471 node->cond = visitExpression( node->cond );
1472 node->body = visitStatement ( node->body );
1473 }
[9c1600c]1474 VISIT_END( node );
[13932f14]1475}
1476
[7870799]1477template< typename pass_type >
1478void PassVisitor< pass_type >::visit( const CatchStmt * node ) {
1479 VISIT_START( node );
[e3d7f9f]1480 {
1481 // catch statements introduce a level of scope (for the caught exception)
1482 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1483 maybeAccept_impl( node->decl, *this );
1484 visitExpression ( node->cond );
1485 visitStatement ( node->body );
1486 }
[7870799]1487 VISIT_END( node );
1488}
1489
[296b2be]1490template< typename pass_type >
1491Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
1492 MUTATE_START( node );
[e0886db]1493 {
[33a25f9]1494 // catch statements introduce a level of scope (for the caught exception)
[e0886db]1495 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1496 maybeMutate_impl( node->decl, *this );
[e0886db]1497 node->cond = mutateExpression( node->cond );
1498 node->body = mutateStatement ( node->body );
1499 }
[296b2be]1500 MUTATE_END( Statement, node );
1501}
1502
[2065609]1503//--------------------------------------------------------------------------
1504// FinallyStmt
[13932f14]1505template< typename pass_type >
[ab904dc]1506void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
[11b7028]1507 VISIT_START( node );
1508
1509 maybeAccept_impl( node->block, *this );
1510
1511 VISIT_END( node );
[13932f14]1512}
1513
[7870799]1514template< typename pass_type >
1515void PassVisitor< pass_type >::visit( const FinallyStmt * node ) {
1516 VISIT_START( node );
1517
1518 maybeAccept_impl( node->block, *this );
1519
1520 VISIT_END( node );
1521}
1522
[2065609]1523template< typename pass_type >
1524Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
[11b7028]1525 MUTATE_START( node );
1526
1527 maybeMutate_impl( node->block, *this );
1528
1529 MUTATE_END( Statement, node );
[2065609]1530}
1531
[37cdd97]1532//--------------------------------------------------------------------------
1533// SuspendStmt
1534template< typename pass_type >
1535void PassVisitor< pass_type >::visit( SuspendStmt * node ) {
1536 VISIT_START( node );
1537
1538 maybeAccept_impl( node->then , *this );
1539
1540 VISIT_END( node );
1541}
1542
1543template< typename pass_type >
1544void PassVisitor< pass_type >::visit( const SuspendStmt * node ) {
1545 VISIT_START( node );
1546
1547 maybeAccept_impl( node->then , *this );
1548
1549 VISIT_END( node );
1550}
1551
1552template< typename pass_type >
1553Statement * PassVisitor< pass_type >::mutate( SuspendStmt * node ) {
1554 MUTATE_START( node );
1555
1556 maybeMutate_impl( node->then , *this );
1557
1558 MUTATE_END( Statement, node );
1559}
1560
[2065609]1561//--------------------------------------------------------------------------
1562// WaitForStmt
1563template< typename pass_type >
1564void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
[834b892]1565 VISIT_START( node );
1566
1567 for( auto & clause : node->clauses ) {
1568 maybeAccept_impl( clause.target.function, *this );
1569 maybeAccept_impl( clause.target.arguments, *this );
1570
1571 maybeAccept_impl( clause.statement, *this );
1572 maybeAccept_impl( clause.condition, *this );
1573 }
1574
1575 maybeAccept_impl( node->timeout.time, *this );
1576 maybeAccept_impl( node->timeout.statement, *this );
1577 maybeAccept_impl( node->timeout.condition, *this );
1578 maybeAccept_impl( node->orelse.statement, *this );
1579 maybeAccept_impl( node->orelse.condition, *this );
1580
1581 VISIT_END( node );
[2065609]1582}
1583
[7870799]1584template< typename pass_type >
1585void PassVisitor< pass_type >::visit( const WaitForStmt * node ) {
1586 VISIT_START( node );
1587
1588 for( auto & clause : node->clauses ) {
1589 maybeAccept_impl( clause.target.function, *this );
1590 maybeAccept_impl( clause.target.arguments, *this );
1591
1592 maybeAccept_impl( clause.statement, *this );
1593 maybeAccept_impl( clause.condition, *this );
1594 }
1595
1596 maybeAccept_impl( node->timeout.time, *this );
1597 maybeAccept_impl( node->timeout.statement, *this );
1598 maybeAccept_impl( node->timeout.condition, *this );
1599 maybeAccept_impl( node->orelse.statement, *this );
1600 maybeAccept_impl( node->orelse.condition, *this );
1601
1602 VISIT_END( node );
1603}
1604
[2065609]1605template< typename pass_type >
1606Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
[834b892]1607 MUTATE_START( node );
1608
1609 for( auto & clause : node->clauses ) {
1610 maybeMutate_impl( clause.target.function, *this );
1611 maybeMutate_impl( clause.target.arguments, *this );
1612
1613 maybeMutate_impl( clause.statement, *this );
1614 maybeMutate_impl( clause.condition, *this );
1615 }
1616
1617 maybeMutate_impl( node->timeout.time, *this );
1618 maybeMutate_impl( node->timeout.statement, *this );
1619 maybeMutate_impl( node->timeout.condition, *this );
1620 maybeMutate_impl( node->orelse.statement, *this );
1621 maybeMutate_impl( node->orelse.condition, *this );
1622
1623 MUTATE_END( Statement, node );
[2065609]1624}
1625
[d8893ca]1626
1627
[61255ad]1628//--------------------------------------------------------------------------
[7870799]1629// WithStmt
[61255ad]1630template< typename pass_type >
1631void PassVisitor< pass_type >::visit( WithStmt * node ) {
[d8893ca]1632 VISIT_START( node );
1633 maybeAccept_impl( node->exprs, *this );
1634 {
1635 // catch statements introduce a level of scope (for the caught exception)
1636 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]1637 indexerAddWith( node->exprs, node );
[d8893ca]1638 maybeAccept_impl( node->stmt, *this );
1639 }
1640 VISIT_END( node );
[61255ad]1641}
1642
[7870799]1643template< typename pass_type >
1644void PassVisitor< pass_type >::visit( const WithStmt * node ) {
1645 VISIT_START( node );
1646 maybeAccept_impl( node->exprs, *this );
[e3d7f9f]1647 {
1648 // catch statements introduce a level of scope (for the caught exception)
1649 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1650 indexerAddWith( node->exprs, node );
1651 maybeAccept_impl( node->stmt, *this );
1652 }
[7870799]1653 VISIT_END( node );
1654}
1655
[61255ad]1656template< typename pass_type >
[e67991f]1657Declaration * PassVisitor< pass_type >::mutate( WithStmt * node ) {
[d8893ca]1658 MUTATE_START( node );
1659 maybeMutate_impl( node->exprs, *this );
1660 {
1661 // catch statements introduce a level of scope (for the caught exception)
1662 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]1663 indexerAddWith( node->exprs, node );
[d8893ca]1664 maybeMutate_impl( node->stmt, *this );
1665 }
[e67991f]1666 MUTATE_END( Declaration, node );
[61255ad]1667}
1668
[2065609]1669//--------------------------------------------------------------------------
1670// NullStmt
[13932f14]1671template< typename pass_type >
[ab904dc]1672void PassVisitor< pass_type >::visit( NullStmt * node ) {
[5964127]1673 VISIT_START( node );
1674 VISIT_END( node );
[13932f14]1675}
1676
[7870799]1677template< typename pass_type >
1678void PassVisitor< pass_type >::visit( const NullStmt * node ) {
1679 VISIT_START( node );
1680 VISIT_END( node );
1681}
1682
[2065609]1683template< typename pass_type >
1684NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
[5964127]1685 MUTATE_START( node );
1686 MUTATE_END( NullStmt, node );
[2065609]1687}
1688
1689//--------------------------------------------------------------------------
1690// DeclStmt
[13932f14]1691template< typename pass_type >
[ab904dc]1692void PassVisitor< pass_type >::visit( DeclStmt * node ) {
[5964127]1693 VISIT_START( node );
1694
1695 maybeAccept_impl( node->decl, *this );
1696
1697 VISIT_END( node );
[13932f14]1698}
1699
[7870799]1700template< typename pass_type >
1701void PassVisitor< pass_type >::visit( const DeclStmt * node ) {
1702 VISIT_START( node );
1703
1704 maybeAccept_impl( node->decl, *this );
1705
1706 VISIT_END( node );
1707}
1708
[2065609]1709template< typename pass_type >
1710Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
[5964127]1711 MUTATE_START( node );
1712
1713 maybeMutate_impl( node->decl, *this );
1714
1715 MUTATE_END( Statement, node );
[2065609]1716}
1717
1718//--------------------------------------------------------------------------
1719// ImplicitCtorDtorStmt
[13932f14]1720template< typename pass_type >
[ab904dc]1721void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
[599fbb6]1722 VISIT_START( node );
1723
1724 maybeAccept_impl( node->callStmt, *this );
1725
1726 VISIT_END( node );
[13932f14]1727}
1728
[7870799]1729template< typename pass_type >
1730void PassVisitor< pass_type >::visit( const ImplicitCtorDtorStmt * node ) {
1731 VISIT_START( node );
1732
1733 maybeAccept_impl( node->callStmt, *this );
1734
1735 VISIT_END( node );
1736}
1737
[2065609]1738template< typename pass_type >
1739Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
[599fbb6]1740 MUTATE_START( node );
1741
1742 maybeMutate_impl( node->callStmt, *this );
1743
1744 MUTATE_END( Statement, node );
[2065609]1745}
1746
1747//--------------------------------------------------------------------------
1748// ApplicationExpr
[13932f14]1749template< typename pass_type >
[ab904dc]1750void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
[e0886db]1751 VISIT_START( node );
1752
1753 indexerScopedAccept( node->result , *this );
[e3d7f9f]1754 maybeAccept_impl ( node->function, *this );
1755 maybeAccept_impl ( node->args , *this );
[e0886db]1756
1757 VISIT_END( node );
[13932f14]1758}
1759
[7870799]1760template< typename pass_type >
1761void PassVisitor< pass_type >::visit( const ApplicationExpr * node ) {
1762 VISIT_START( node );
1763
[e3d7f9f]1764 indexerScopedAccept( node->result , *this );
1765 maybeAccept_impl ( node->function, *this );
1766 maybeAccept_impl ( node->args , *this );
[7870799]1767
1768 VISIT_END( node );
1769}
1770
[2065609]1771template< typename pass_type >
1772Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
[e0886db]1773 MUTATE_START( node );
1774
1775 indexerScopedMutate( node->env , *this );
1776 indexerScopedMutate( node->result , *this );
[3c398b6]1777 maybeMutate_impl ( node->function, *this );
1778 maybeMutate_impl ( node->args , *this );
[e0886db]1779
1780 MUTATE_END( Expression, node );
[2065609]1781}
1782
[9c1600c]1783//--------------------------------------------------------------------------
1784// UntypedExpr
[13932f14]1785template< typename pass_type >
[ab904dc]1786void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
[9c1600c]1787 VISIT_START( node );
1788
[3c398b6]1789 // maybeAccept_impl( node->get_env(), *this );
[e0886db]1790 indexerScopedAccept( node->result, *this );
[2a7b3ca]1791
[e0886db]1792 for ( auto expr : node->args ) {
[9c1600c]1793 visitExpression( expr );
1794 }
1795
1796 VISIT_END( node );
[13932f14]1797}
1798
[7870799]1799template< typename pass_type >
1800void PassVisitor< pass_type >::visit( const UntypedExpr * node ) {
1801 VISIT_START( node );
1802
[e3d7f9f]1803 indexerScopedAccept( node->result, *this );
[7870799]1804
1805 for ( auto expr : node->args ) {
1806 visitExpression( expr );
1807 }
1808
1809 VISIT_END( node );
1810}
1811
[296b2be]1812template< typename pass_type >
1813Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
1814 MUTATE_START( node );
1815
[e0886db]1816 indexerScopedMutate( node->env , *this );
1817 indexerScopedMutate( node->result, *this );
[2a7b3ca]1818
[e0886db]1819 for ( auto& expr : node->args ) {
[296b2be]1820 expr = mutateExpression( expr );
1821 }
1822
1823 MUTATE_END( Expression, node );
1824}
1825
[e0886db]1826//--------------------------------------------------------------------------
1827// NameExpr
[13932f14]1828template< typename pass_type >
[ab904dc]1829void PassVisitor< pass_type >::visit( NameExpr * node ) {
[e0886db]1830 VISIT_START( node );
1831
1832 indexerScopedAccept( node->result, *this );
1833
1834 VISIT_END( node );
[13932f14]1835}
1836
[7870799]1837template< typename pass_type >
1838void PassVisitor< pass_type >::visit( const NameExpr * node ) {
1839 VISIT_START( node );
1840
[e3d7f9f]1841 indexerScopedAccept( node->result, *this );
[7870799]1842
1843 VISIT_END( node );
1844}
1845
[13932f14]1846template< typename pass_type >
[e0886db]1847Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
1848 MUTATE_START( node );
1849
1850 indexerScopedMutate( node->env , *this );
1851 indexerScopedMutate( node->result, *this );
1852
1853 MUTATE_END( Expression, node );
[13932f14]1854}
1855
[e0886db]1856//--------------------------------------------------------------------------
1857// CastExpr
[a5f0529]1858template< typename pass_type >
[e0886db]1859void PassVisitor< pass_type >::visit( CastExpr * node ) {
1860 VISIT_START( node );
1861
1862 indexerScopedAccept( node->result, *this );
[e3d7f9f]1863 maybeAccept_impl ( node->arg , *this );
[e0886db]1864
1865 VISIT_END( node );
[a5f0529]1866}
1867
[7870799]1868template< typename pass_type >
1869void PassVisitor< pass_type >::visit( const CastExpr * node ) {
1870 VISIT_START( node );
1871
[e3d7f9f]1872 indexerScopedAccept( node->result, *this );
1873 maybeAccept_impl ( node->arg , *this );
[7870799]1874
1875 VISIT_END( node );
1876}
1877
[13932f14]1878template< typename pass_type >
[e0886db]1879Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
1880 MUTATE_START( node );
1881
1882 indexerScopedMutate( node->env , *this );
1883 indexerScopedMutate( node->result, *this );
[3c398b6]1884 maybeMutate_impl ( node->arg , *this );
[e0886db]1885
1886 MUTATE_END( Expression, node );
[13932f14]1887}
1888
[e0886db]1889//--------------------------------------------------------------------------
[9a705dc8]1890// KeywordCastExpr
1891template< typename pass_type >
1892void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
1893 VISIT_START( node );
1894
1895 indexerScopedAccept( node->result, *this );
1896 maybeAccept_impl ( node->arg , *this );
1897
1898 VISIT_END( node );
1899}
1900
[7870799]1901template< typename pass_type >
1902void PassVisitor< pass_type >::visit( const KeywordCastExpr * node ) {
1903 VISIT_START( node );
1904
[e3d7f9f]1905 indexerScopedAccept( node->result, *this );
1906 maybeAccept_impl ( node->arg , *this );
[7870799]1907
1908 VISIT_END( node );
1909}
1910
[9a705dc8]1911template< typename pass_type >
1912Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
1913 MUTATE_START( node );
1914
1915 indexerScopedMutate( node->env , *this );
1916 indexerScopedMutate( node->result, *this );
1917 maybeMutate_impl ( node->arg , *this );
1918
1919 MUTATE_END( Expression, node );
1920}
1921
1922//--------------------------------------------------------------------------
[e0886db]1923// VirtualCastExpr
[13932f14]1924template< typename pass_type >
[e0886db]1925void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
1926 VISIT_START( node );
1927
1928 indexerScopedAccept( node->result, *this );
[e3d7f9f]1929 maybeAccept_impl ( node->arg, *this );
[e0886db]1930
1931 VISIT_END( node );
[13932f14]1932}
1933
[7870799]1934template< typename pass_type >
1935void PassVisitor< pass_type >::visit( const VirtualCastExpr * node ) {
1936 VISIT_START( node );
1937
[e3d7f9f]1938 indexerScopedAccept( node->result, *this );
1939 maybeAccept_impl ( node->arg, *this );
[7870799]1940
1941 VISIT_END( node );
1942}
1943
[13932f14]1944template< typename pass_type >
[e0886db]1945Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
1946 MUTATE_START( node );
1947
1948 indexerScopedMutate( node->env , *this );
1949 indexerScopedMutate( node->result, *this );
[3c398b6]1950 maybeMutate_impl ( node->arg , *this );
[e0886db]1951
1952 MUTATE_END( Expression, node );
[13932f14]1953}
1954
[e0886db]1955//--------------------------------------------------------------------------
1956// AddressExpr
[13932f14]1957template< typename pass_type >
[e0886db]1958void PassVisitor< pass_type >::visit( AddressExpr * node ) {
1959 VISIT_START( node );
1960
1961 indexerScopedAccept( node->result, *this );
[3c398b6]1962 maybeAccept_impl ( node->arg , *this );
[e0886db]1963
1964 VISIT_END( node );
[13932f14]1965}
1966
[7870799]1967template< typename pass_type >
1968void PassVisitor< pass_type >::visit( const AddressExpr * node ) {
1969 VISIT_START( node );
1970
[e3d7f9f]1971 indexerScopedAccept( node->result, *this );
1972 maybeAccept_impl ( node->arg , *this );
[7870799]1973
1974 VISIT_END( node );
1975}
1976
[13932f14]1977template< typename pass_type >
[e0886db]1978Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
1979 MUTATE_START( node );
1980
1981 indexerScopedMutate( node->env , *this );
1982 indexerScopedMutate( node->result, *this );
[3c398b6]1983 maybeMutate_impl ( node->arg , *this );
[e0886db]1984
1985 MUTATE_END( Expression, node );
1986}
1987
1988//--------------------------------------------------------------------------
1989// LabelAddressExpr
1990template< typename pass_type >
1991void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
1992 VISIT_START( node );
1993
1994 indexerScopedAccept( node->result, *this );
1995
1996 VISIT_END( node );
1997}
1998
[7870799]1999template< typename pass_type >
2000void PassVisitor< pass_type >::visit( const LabelAddressExpr * node ) {
2001 VISIT_START( node );
2002
[e3d7f9f]2003 indexerScopedAccept( node->result, *this );
[7870799]2004
2005 VISIT_END( node );
2006}
2007
[e0886db]2008template< typename pass_type >
2009Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
2010 MUTATE_START( node );
2011
2012 indexerScopedMutate( node->env , *this );
2013 indexerScopedMutate( node->result, *this );
2014
2015 MUTATE_END( Expression, node );
2016}
2017
2018//--------------------------------------------------------------------------
2019// UntypedMemberExpr
2020template< typename pass_type >
2021void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
2022 VISIT_START( node );
2023
2024 indexerScopedAccept( node->result , *this );
[3c398b6]2025 maybeAccept_impl ( node->aggregate, *this );
2026 maybeAccept_impl ( node->member , *this );
[e0886db]2027
2028 VISIT_END( node );
[13932f14]2029}
2030
[7870799]2031template< typename pass_type >
2032void PassVisitor< pass_type >::visit( const UntypedMemberExpr * node ) {
2033 VISIT_START( node );
2034
[e3d7f9f]2035 indexerScopedAccept( node->result , *this );
2036 maybeAccept_impl ( node->aggregate, *this );
2037 maybeAccept_impl ( node->member , *this );
[7870799]2038
2039 VISIT_END( node );
2040}
2041
[e0886db]2042template< typename pass_type >
2043Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
2044 MUTATE_START( node );
2045
2046 indexerScopedMutate( node->env , *this );
2047 indexerScopedMutate( node->result , *this );
[3c398b6]2048 maybeMutate_impl ( node->aggregate, *this );
2049 maybeMutate_impl ( node->member , *this );
[e0886db]2050
2051 MUTATE_END( Expression, node );
2052}
2053
2054//--------------------------------------------------------------------------
2055// MemberExpr
2056template< typename pass_type >
2057void PassVisitor< pass_type >::visit( MemberExpr * node ) {
2058 VISIT_START( node );
2059
2060 indexerScopedAccept( node->result , *this );
[3c398b6]2061 maybeAccept_impl ( node->aggregate, *this );
[e0886db]2062
2063 VISIT_END( node );
2064}
2065
[7870799]2066template< typename pass_type >
2067void PassVisitor< pass_type >::visit( const MemberExpr * node ) {
2068 VISIT_START( node );
2069
[e3d7f9f]2070 indexerScopedAccept( node->result , *this );
2071 maybeAccept_impl ( node->aggregate, *this );
[7870799]2072
2073 VISIT_END( node );
2074}
2075
[e0886db]2076template< typename pass_type >
2077Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
2078 MUTATE_START( node );
2079
2080 indexerScopedMutate( node->env , *this );
2081 indexerScopedMutate( node->result , *this );
[3c398b6]2082 maybeMutate_impl ( node->aggregate, *this );
[e0886db]2083
2084 MUTATE_END( Expression, node );
2085}
2086
2087//--------------------------------------------------------------------------
2088// VariableExpr
2089template< typename pass_type >
2090void PassVisitor< pass_type >::visit( VariableExpr * node ) {
2091 VISIT_START( node );
2092
2093 indexerScopedAccept( node->result, *this );
2094
2095 VISIT_END( node );
2096}
2097
[7870799]2098template< typename pass_type >
2099void PassVisitor< pass_type >::visit( const VariableExpr * node ) {
2100 VISIT_START( node );
2101
[e3d7f9f]2102 indexerScopedAccept( node->result, *this );
[7870799]2103
2104 VISIT_END( node );
2105}
2106
[e0886db]2107template< typename pass_type >
2108Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
2109 MUTATE_START( node );
2110
2111 indexerScopedMutate( node->env , *this );
2112 indexerScopedMutate( node->result, *this );
2113
2114 MUTATE_END( Expression, node );
2115}
2116
2117//--------------------------------------------------------------------------
2118// ConstantExpr
[13932f14]2119template< typename pass_type >
[ab904dc]2120void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
[e0886db]2121 VISIT_START( node );
2122
2123 indexerScopedAccept( node->result , *this );
[3c398b6]2124 maybeAccept_impl ( &node->constant, *this );
[e0886db]2125
2126 VISIT_END( node );
[13932f14]2127}
2128
[7870799]2129template< typename pass_type >
2130void PassVisitor< pass_type >::visit( const ConstantExpr * node ) {
2131 VISIT_START( node );
2132
[e3d7f9f]2133 indexerScopedAccept( node->result , *this );
2134 maybeAccept_impl ( &node->constant, *this );
[7870799]2135
2136 VISIT_END( node );
2137}
2138
[e0886db]2139template< typename pass_type >
2140Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
2141 MUTATE_START( node );
2142
2143 indexerScopedMutate( node->env , *this );
2144 indexerScopedMutate( node->result, *this );
[3c398b6]2145 Constant * ptr = &node->constant;
2146 maybeMutate_impl( ptr, *this );
2147 node->constant = *ptr;
[e0886db]2148
2149 MUTATE_END( Expression, node );
2150}
2151
2152//--------------------------------------------------------------------------
2153// SizeofExpr
[13932f14]2154template< typename pass_type >
[ab904dc]2155void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
[e0886db]2156 VISIT_START( node );
2157
2158 indexerScopedAccept( node->result, *this );
2159 if ( node->get_isType() ) {
[3c398b6]2160 maybeAccept_impl( node->type, *this );
[e0886db]2161 } else {
[3c398b6]2162 maybeAccept_impl( node->expr, *this );
[e0886db]2163 }
2164
2165 VISIT_END( node );
[13932f14]2166}
2167
[7870799]2168template< typename pass_type >
2169void PassVisitor< pass_type >::visit( const SizeofExpr * node ) {
2170 VISIT_START( node );
2171
[e3d7f9f]2172 indexerScopedAccept( node->result, *this );
[7870799]2173 if ( node->get_isType() ) {
2174 maybeAccept_impl( node->type, *this );
2175 } else {
2176 maybeAccept_impl( node->expr, *this );
2177 }
2178
2179 VISIT_END( node );
2180}
2181
[e0886db]2182template< typename pass_type >
2183Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
2184 MUTATE_START( node );
2185
2186 indexerScopedMutate( node->env , *this );
2187 indexerScopedMutate( node->result, *this );
2188 if ( node->get_isType() ) {
[3c398b6]2189 maybeMutate_impl( node->type, *this );
[e0886db]2190 } else {
[3c398b6]2191 maybeMutate_impl( node->expr, *this );
[e0886db]2192 }
2193
2194 MUTATE_END( Expression, node );
2195}
2196
2197//--------------------------------------------------------------------------
2198// AlignofExpr
[13932f14]2199template< typename pass_type >
[ab904dc]2200void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
[e0886db]2201 VISIT_START( node );
2202
2203 indexerScopedAccept( node->result, *this );
2204 if ( node->get_isType() ) {
[3c398b6]2205 maybeAccept_impl( node->type, *this );
[e0886db]2206 } else {
[3c398b6]2207 maybeAccept_impl( node->expr, *this );
[e0886db]2208 }
2209
2210 VISIT_END( node );
[13932f14]2211}
2212
[7870799]2213template< typename pass_type >
2214void PassVisitor< pass_type >::visit( const AlignofExpr * node ) {
2215 VISIT_START( node );
2216
[e3d7f9f]2217 indexerScopedAccept( node->result, *this );
[7870799]2218 if ( node->get_isType() ) {
2219 maybeAccept_impl( node->type, *this );
2220 } else {
2221 maybeAccept_impl( node->expr, *this );
2222 }
2223
2224 VISIT_END( node );
2225}
2226
[e0886db]2227template< typename pass_type >
2228Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
2229 MUTATE_START( node );
2230
2231 indexerScopedMutate( node->env , *this );
2232 indexerScopedMutate( node->result, *this );
2233 if ( node->get_isType() ) {
[3c398b6]2234 maybeMutate_impl( node->type, *this );
[e0886db]2235 } else {
[3c398b6]2236 maybeMutate_impl( node->expr, *this );
[e0886db]2237 }
2238
2239 MUTATE_END( Expression, node );
2240}
2241
2242//--------------------------------------------------------------------------
2243// UntypedOffsetofExpr
[13932f14]2244template< typename pass_type >
[ab904dc]2245void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
[e0886db]2246 VISIT_START( node );
2247
2248 indexerScopedAccept( node->result, *this );
[3c398b6]2249 maybeAccept_impl ( node->type , *this );
[e0886db]2250
2251 VISIT_END( node );
[13932f14]2252}
2253
[7870799]2254template< typename pass_type >
2255void PassVisitor< pass_type >::visit( const UntypedOffsetofExpr * node ) {
2256 VISIT_START( node );
2257
[e3d7f9f]2258 indexerScopedAccept( node->result, *this );
2259 maybeAccept_impl ( node->type , *this );
[7870799]2260
2261 VISIT_END( node );
2262}
2263
[e0886db]2264template< typename pass_type >
2265Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
2266 MUTATE_START( node );
2267
2268 indexerScopedMutate( node->env , *this );
2269 indexerScopedMutate( node->result, *this );
[3c398b6]2270 maybeMutate_impl ( node->type , *this );
[e0886db]2271
2272 MUTATE_END( Expression, node );
2273}
2274
2275//--------------------------------------------------------------------------
2276// OffsetofExpr
[13932f14]2277template< typename pass_type >
[ab904dc]2278void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
[e0886db]2279 VISIT_START( node );
2280
2281 indexerScopedAccept( node->result, *this );
[3c398b6]2282 maybeAccept_impl ( node->type , *this );
[e0886db]2283
2284 VISIT_END( node );
[13932f14]2285}
2286
[7870799]2287template< typename pass_type >
2288void PassVisitor< pass_type >::visit( const OffsetofExpr * node ) {
2289 VISIT_START( node );
2290
[e3d7f9f]2291 indexerScopedAccept( node->result, *this );
2292 maybeAccept_impl ( node->type , *this );
[7870799]2293
2294 VISIT_END( node );
2295}
2296
[e0886db]2297template< typename pass_type >
2298Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
2299 MUTATE_START( node );
2300
2301 indexerScopedMutate( node->env , *this );
2302 indexerScopedMutate( node->result, *this );
[3c398b6]2303 maybeMutate_impl ( node->type , *this );
[e0886db]2304
2305 MUTATE_END( Expression, node );
2306}
2307
2308//--------------------------------------------------------------------------
2309// OffsetPackExpr
[13932f14]2310template< typename pass_type >
[ab904dc]2311void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
[e0886db]2312 VISIT_START( node );
2313
2314 indexerScopedAccept( node->result, *this );
[3c398b6]2315 maybeAccept_impl ( node->type , *this );
[e0886db]2316
2317 VISIT_END( node );
[13932f14]2318}
2319
[7870799]2320template< typename pass_type >
2321void PassVisitor< pass_type >::visit( const OffsetPackExpr * node ) {
2322 VISIT_START( node );
2323
[e3d7f9f]2324 indexerScopedAccept( node->result, *this );
2325 maybeAccept_impl ( node->type , *this );
[7870799]2326
2327 VISIT_END( node );
2328}
2329
[e0886db]2330template< typename pass_type >
2331Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
2332 MUTATE_START( node );
2333
2334 indexerScopedMutate( node->env , *this );
2335 indexerScopedMutate( node->result, *this );
[3c398b6]2336 maybeMutate_impl ( node->type , *this );
[e0886db]2337
2338 MUTATE_END( Expression, node );
2339}
2340
2341//--------------------------------------------------------------------------
2342// LogicalExpr
[13932f14]2343template< typename pass_type >
[ab904dc]2344void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
[e0886db]2345 VISIT_START( node );
2346
2347 indexerScopedAccept( node->result, *this );
[3c398b6]2348 maybeAccept_impl ( node->arg1 , *this );
2349 maybeAccept_impl ( node->arg2 , *this );
[e0886db]2350
2351 VISIT_END( node );
2352}
2353
[7870799]2354template< typename pass_type >
2355void PassVisitor< pass_type >::visit( const LogicalExpr * node ) {
2356 VISIT_START( node );
2357
[e3d7f9f]2358 indexerScopedAccept( node->result, *this );
2359 maybeAccept_impl ( node->arg1 , *this );
2360 maybeAccept_impl ( node->arg2 , *this );
[7870799]2361
2362 VISIT_END( node );
2363}
2364
[e0886db]2365template< typename pass_type >
2366Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
2367 MUTATE_START( node );
2368
2369 indexerScopedMutate( node->env , *this );
2370 indexerScopedMutate( node->result, *this );
[3c398b6]2371 maybeMutate_impl ( node->arg1 , *this );
2372 maybeMutate_impl ( node->arg2 , *this );
[e0886db]2373
2374 MUTATE_END( Expression, node );
[13932f14]2375}
2376
[e0886db]2377//--------------------------------------------------------------------------
2378// ConditionalExpr
[13932f14]2379template< typename pass_type >
[ab904dc]2380void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
[e0886db]2381 VISIT_START( node );
2382
2383 indexerScopedAccept( node->result, *this );
[3c398b6]2384 maybeAccept_impl ( node->arg1 , *this );
2385 maybeAccept_impl ( node->arg2 , *this );
2386 maybeAccept_impl ( node->arg3 , *this );
[e0886db]2387
2388 VISIT_END( node );
[13932f14]2389}
2390
[e0886db]2391template< typename pass_type >
[7870799]2392void PassVisitor< pass_type >::visit( const ConditionalExpr * node ) {
2393 VISIT_START( node );
2394
[e3d7f9f]2395 indexerScopedAccept( node->result, *this );
2396 maybeAccept_impl ( node->arg1 , *this );
2397 maybeAccept_impl ( node->arg2 , *this );
2398 maybeAccept_impl ( node->arg3 , *this );
[7870799]2399
2400 VISIT_END( node );
2401}
2402
2403template< typename pass_type >
2404Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
2405 MUTATE_START( node );
[e0886db]2406
2407 indexerScopedMutate( node->env , *this );
2408 indexerScopedMutate( node->result, *this );
[3c398b6]2409 maybeMutate_impl ( node->arg1 , *this );
2410 maybeMutate_impl ( node->arg2 , *this );
2411 maybeMutate_impl ( node->arg3 , *this );
[e0886db]2412
2413 MUTATE_END( Expression, node );
2414}
2415
2416//--------------------------------------------------------------------------
2417// CommaExpr
[13932f14]2418template< typename pass_type >
[ab904dc]2419void PassVisitor< pass_type >::visit( CommaExpr * node ) {
[e0886db]2420 VISIT_START( node );
2421
2422 indexerScopedAccept( node->result, *this );
[3c398b6]2423 maybeAccept_impl ( node->arg1 , *this );
2424 maybeAccept_impl ( node->arg2 , *this );
[e0886db]2425
2426 VISIT_END( node );
2427}
2428
[7870799]2429template< typename pass_type >
2430void PassVisitor< pass_type >::visit( const CommaExpr * node ) {
2431 VISIT_START( node );
2432
[e3d7f9f]2433 indexerScopedAccept( node->result, *this );
2434 maybeAccept_impl ( node->arg1 , *this );
2435 maybeAccept_impl ( node->arg2 , *this );
[7870799]2436
2437 VISIT_END( node );
2438}
2439
[e0886db]2440template< typename pass_type >
2441Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
2442 MUTATE_START( node );
2443
2444 indexerScopedMutate( node->env , *this );
2445 indexerScopedMutate( node->result, *this );
[3c398b6]2446 maybeMutate_impl ( node->arg1 , *this );
2447 maybeMutate_impl ( node->arg2 , *this );
[e0886db]2448
2449 MUTATE_END( Expression, node );
[13932f14]2450}
2451
[e0886db]2452//--------------------------------------------------------------------------
2453// TypeExpr
[13932f14]2454template< typename pass_type >
[ab904dc]2455void PassVisitor< pass_type >::visit( TypeExpr * node ) {
[e0886db]2456 VISIT_START( node );
2457
2458 indexerScopedAccept( node->result, *this );
[3c398b6]2459 maybeAccept_impl ( node->type, *this );
[e0886db]2460
2461 VISIT_END( node );
[13932f14]2462}
2463
[7870799]2464template< typename pass_type >
2465void PassVisitor< pass_type >::visit( const TypeExpr * node ) {
2466 VISIT_START( node );
2467
[e3d7f9f]2468 indexerScopedAccept( node->result, *this );
2469 maybeAccept_impl ( node->type, *this );
[7870799]2470
2471 VISIT_END( node );
2472}
2473
[e0886db]2474template< typename pass_type >
2475Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
2476 MUTATE_START( node );
2477
2478 indexerScopedMutate( node->env , *this );
2479 indexerScopedMutate( node->result, *this );
[3c398b6]2480 maybeMutate_impl ( node->type , *this );
[e0886db]2481
2482 MUTATE_END( Expression, node );
2483}
2484
2485//--------------------------------------------------------------------------
2486// AsmExpr
[13932f14]2487template< typename pass_type >
[ab904dc]2488void PassVisitor< pass_type >::visit( AsmExpr * node ) {
[e0886db]2489 VISIT_START( node );
2490
2491 indexerScopedAccept( node->result , *this );
[3c398b6]2492 maybeAccept_impl ( node->constraint, *this );
2493 maybeAccept_impl ( node->operand , *this );
[e0886db]2494
2495 VISIT_END( node );
[13932f14]2496}
2497
[7870799]2498template< typename pass_type >
2499void PassVisitor< pass_type >::visit( const AsmExpr * node ) {
2500 VISIT_START( node );
2501
[e3d7f9f]2502 indexerScopedAccept( node->result , *this );
2503 maybeAccept_impl ( node->constraint, *this );
2504 maybeAccept_impl ( node->operand , *this );
[7870799]2505
2506 VISIT_END( node );
2507}
2508
[e0886db]2509template< typename pass_type >
2510Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
2511 MUTATE_START( node );
2512
2513 indexerScopedMutate( node->env , *this );
2514 indexerScopedMutate( node->result , *this );
[3c398b6]2515 maybeMutate_impl ( node->constraint, *this );
2516 maybeMutate_impl ( node->operand , *this );
[e0886db]2517
2518 MUTATE_END( Expression, node );
2519}
2520
2521//--------------------------------------------------------------------------
2522// ImplicitCopyCtorExpr
[13932f14]2523template< typename pass_type >
[ab904dc]2524void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
[e0886db]2525 VISIT_START( node );
2526
[2f86ddf]2527 indexerScopedAccept( node->result , *this );
2528 maybeAccept_impl ( node->callExpr , *this );
[e0886db]2529
2530 VISIT_END( node );
2531}
2532
[7870799]2533template< typename pass_type >
2534void PassVisitor< pass_type >::visit( const ImplicitCopyCtorExpr * node ) {
2535 VISIT_START( node );
2536
[e3d7f9f]2537 indexerScopedAccept( node->result , *this );
2538 maybeAccept_impl ( node->callExpr , *this );
[7870799]2539
2540 VISIT_END( node );
2541}
2542
[e0886db]2543template< typename pass_type >
2544Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
2545 MUTATE_START( node );
2546
[2f86ddf]2547 indexerScopedMutate( node->env , *this );
2548 indexerScopedMutate( node->result , *this );
2549 maybeMutate_impl ( node->callExpr , *this );
[e0886db]2550
2551 MUTATE_END( Expression, node );
[13932f14]2552}
2553
[e0886db]2554//--------------------------------------------------------------------------
2555// ConstructorExpr
[13932f14]2556template< typename pass_type >
[ab904dc]2557void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
[e0886db]2558 VISIT_START( node );
2559
2560 indexerScopedAccept( node->result , *this );
[3c398b6]2561 maybeAccept_impl ( node->callExpr, *this );
[e0886db]2562
2563 VISIT_END( node );
2564}
2565
[7870799]2566template< typename pass_type >
2567void PassVisitor< pass_type >::visit( const ConstructorExpr * node ) {
2568 VISIT_START( node );
2569
[e3d7f9f]2570 indexerScopedAccept( node->result , *this );
2571 maybeAccept_impl ( node->callExpr, *this );
[7870799]2572
2573 VISIT_END( node );
2574}
2575
[e0886db]2576template< typename pass_type >
2577Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
2578 MUTATE_START( node );
2579
2580 indexerScopedMutate( node->env , *this );
2581 indexerScopedMutate( node->result , *this );
[3c398b6]2582 maybeMutate_impl ( node->callExpr, *this );
[e0886db]2583
2584 MUTATE_END( Expression, node );
[13932f14]2585}
2586
[e0886db]2587//--------------------------------------------------------------------------
2588// CompoundLiteralExpr
[13932f14]2589template< typename pass_type >
[ab904dc]2590void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
[e0886db]2591 VISIT_START( node );
2592
2593 indexerScopedAccept( node->result , *this );
[3c398b6]2594 maybeAccept_impl ( node->initializer, *this );
[e0886db]2595
2596 VISIT_END( node );
[13932f14]2597}
2598
[7870799]2599template< typename pass_type >
2600void PassVisitor< pass_type >::visit( const CompoundLiteralExpr * node ) {
2601 VISIT_START( node );
2602
[e3d7f9f]2603 indexerScopedAccept( node->result , *this );
2604 maybeAccept_impl ( node->initializer, *this );
[7870799]2605
2606 VISIT_END( node );
2607}
2608
[e0886db]2609template< typename pass_type >
2610Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
2611 MUTATE_START( node );
2612
2613 indexerScopedMutate( node->env , *this );
2614 indexerScopedMutate( node->result , *this );
[3c398b6]2615 maybeMutate_impl ( node->initializer, *this );
[e0886db]2616
2617 MUTATE_END( Expression, node );
2618}
2619
2620//--------------------------------------------------------------------------
2621// RangeExpr
[13932f14]2622template< typename pass_type >
[ab904dc]2623void PassVisitor< pass_type >::visit( RangeExpr * node ) {
[e0886db]2624 VISIT_START( node );
2625
2626 indexerScopedAccept( node->result, *this );
[3c398b6]2627 maybeAccept_impl ( node->low , *this );
2628 maybeAccept_impl ( node->high , *this );
[e0886db]2629
2630 VISIT_END( node );
[13932f14]2631}
2632
[7870799]2633template< typename pass_type >
2634void PassVisitor< pass_type >::visit( const RangeExpr * node ) {
2635 VISIT_START( node );
2636
[e3d7f9f]2637 indexerScopedAccept( node->result, *this );
2638 maybeAccept_impl ( node->low , *this );
2639 maybeAccept_impl ( node->high , *this );
[7870799]2640
2641 VISIT_END( node );
2642}
2643
[e0886db]2644template< typename pass_type >
2645Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
2646 MUTATE_START( node );
2647
2648 indexerScopedMutate( node->env , *this );
2649 indexerScopedMutate( node->result, *this );
[3c398b6]2650 maybeMutate_impl ( node->low , *this );
2651 maybeMutate_impl ( node->high , *this );
[e0886db]2652
2653 MUTATE_END( Expression, node );
2654}
2655
2656//--------------------------------------------------------------------------
2657// UntypedTupleExpr
[13932f14]2658template< typename pass_type >
[ab904dc]2659void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
[e0886db]2660 VISIT_START( node );
2661
2662 indexerScopedAccept( node->result, *this );
[3c398b6]2663 maybeAccept_impl ( node->exprs , *this );
[e0886db]2664
2665 VISIT_END( node );
2666}
2667
[7870799]2668template< typename pass_type >
2669void PassVisitor< pass_type >::visit( const UntypedTupleExpr * node ) {
2670 VISIT_START( node );
2671
[e3d7f9f]2672 indexerScopedAccept( node->result, *this );
2673 maybeAccept_impl ( node->exprs , *this );
[7870799]2674
2675 VISIT_END( node );
2676}
2677
[e0886db]2678template< typename pass_type >
2679Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
2680 MUTATE_START( node );
2681
2682 indexerScopedMutate( node->env , *this );
2683 indexerScopedMutate( node->result, *this );
[3c398b6]2684 maybeMutate_impl ( node->exprs , *this );
[e0886db]2685
2686 MUTATE_END( Expression, node );
2687}
2688
2689//--------------------------------------------------------------------------
2690// TupleExpr
2691template< typename pass_type >
2692void PassVisitor< pass_type >::visit( TupleExpr * node ) {
2693 VISIT_START( node );
2694
2695 indexerScopedAccept( node->result, *this );
[3c398b6]2696 maybeAccept_impl ( node->exprs , *this );
[e0886db]2697
2698 VISIT_END( node );
2699}
2700
[7870799]2701template< typename pass_type >
2702void PassVisitor< pass_type >::visit( const TupleExpr * node ) {
2703 VISIT_START( node );
2704
[e3d7f9f]2705 indexerScopedAccept( node->result, *this );
2706 maybeAccept_impl ( node->exprs , *this );
[7870799]2707
2708 VISIT_END( node );
2709}
2710
[e0886db]2711template< typename pass_type >
2712Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
2713 MUTATE_START( node );
2714
2715 indexerScopedMutate( node->env , *this );
2716 indexerScopedMutate( node->result, *this );
[3c398b6]2717 maybeMutate_impl ( node->exprs , *this );
[e0886db]2718
2719 MUTATE_END( Expression, node );
2720}
2721
2722//--------------------------------------------------------------------------
2723// TupleIndexExpr
2724template< typename pass_type >
2725void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
2726 VISIT_START( node );
2727
2728 indexerScopedAccept( node->result, *this );
[3c398b6]2729 maybeAccept_impl ( node->tuple , *this );
[e0886db]2730
2731 VISIT_END( node );
2732}
2733
[7870799]2734template< typename pass_type >
2735void PassVisitor< pass_type >::visit( const TupleIndexExpr * node ) {
2736 VISIT_START( node );
2737
[e3d7f9f]2738 indexerScopedAccept( node->result, *this );
2739 maybeAccept_impl ( node->tuple , *this );
[7870799]2740
2741 VISIT_END( node );
2742}
2743
[e0886db]2744template< typename pass_type >
2745Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
2746 MUTATE_START( node );
2747
2748 indexerScopedMutate( node->env , *this );
2749 indexerScopedMutate( node->result, *this );
[3c398b6]2750 maybeMutate_impl ( node->tuple , *this );
[e0886db]2751
2752 MUTATE_END( Expression, node );
2753}
2754
2755//--------------------------------------------------------------------------
2756// TupleAssignExpr
2757template< typename pass_type >
2758void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
2759 VISIT_START( node );
2760
2761 indexerScopedAccept( node->result , *this );
[3c398b6]2762 maybeAccept_impl ( node->stmtExpr, *this );
[e0886db]2763
2764 VISIT_END( node );
[13932f14]2765}
2766
[7870799]2767template< typename pass_type >
2768void PassVisitor< pass_type >::visit( const TupleAssignExpr * node ) {
2769 VISIT_START( node );
2770
[e3d7f9f]2771 indexerScopedAccept( node->result , *this );
[7870799]2772 maybeAccept_impl( node->stmtExpr, *this );
2773
2774 VISIT_END( node );
2775}
2776
[13932f14]2777template< typename pass_type >
[e0886db]2778Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
2779 MUTATE_START( node );
[13932f14]2780
[e0886db]2781 indexerScopedMutate( node->env , *this );
2782 indexerScopedMutate( node->result , *this );
[3c398b6]2783 maybeMutate_impl ( node->stmtExpr, *this );
[13932f14]2784
[e0886db]2785 MUTATE_END( Expression, node );
[13932f14]2786}
2787
[9c1600c]2788//--------------------------------------------------------------------------
[e0886db]2789// StmtExpr
[13932f14]2790template< typename pass_type >
[ab904dc]2791void PassVisitor< pass_type >::visit( StmtExpr * node ) {
[9c1600c]2792 VISIT_START( node );
2793
2794 // don't want statements from outer CompoundStmts to be added to this StmtExpr
[02fdb8e]2795 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
[9c1600c]2796 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2797 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
2798
[e0886db]2799 indexerScopedAccept( node->result , *this );
[3c398b6]2800 maybeAccept_impl ( node->statements , *this );
2801 maybeAccept_impl ( node->returnDecls, *this );
2802 maybeAccept_impl ( node->dtors , *this );
[9c1600c]2803
2804 VISIT_END( node );
[13932f14]2805}
2806
[7870799]2807template< typename pass_type >
2808void PassVisitor< pass_type >::visit( const StmtExpr * node ) {
2809 VISIT_START( node );
2810
[e3d7f9f]2811 // don't want statements from outer CompoundStmts to be added to this StmtExpr
2812 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
2813 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2814 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
2815
2816 indexerScopedAccept( node->result , *this );
2817 maybeAccept_impl ( node->statements , *this );
2818 maybeAccept_impl ( node->returnDecls, *this );
2819 maybeAccept_impl ( node->dtors , *this );
[7870799]2820
2821 VISIT_END( node );
2822}
2823
[296b2be]2824template< typename pass_type >
2825Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
2826 MUTATE_START( node );
[4551a6e]2827
[296b2be]2828 // don't want statements from outer CompoundStmts to be added to this StmtExpr
[02fdb8e]2829 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
[134322e]2830 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2831 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
[296b2be]2832
[e0886db]2833 indexerScopedMutate( node->result , *this );
[3c398b6]2834 maybeMutate_impl ( node->statements , *this );
2835 maybeMutate_impl ( node->returnDecls, *this );
2836 maybeMutate_impl ( node->dtors , *this );
[296b2be]2837
2838 MUTATE_END( Expression, node );
2839}
2840
[e0886db]2841//--------------------------------------------------------------------------
2842// UniqueExpr
[13932f14]2843template< typename pass_type >
[ab904dc]2844void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
[e0886db]2845 VISIT_START( node );
2846
2847 indexerScopedAccept( node->result, *this );
[3c398b6]2848 maybeAccept_impl ( node->expr , *this );
[e0886db]2849
2850 VISIT_END( node );
2851}
2852
[7870799]2853template< typename pass_type >
2854void PassVisitor< pass_type >::visit( const UniqueExpr * node ) {
2855 VISIT_START( node );
2856
[e3d7f9f]2857 indexerScopedAccept( node->result, *this );
2858 maybeAccept_impl ( node->expr , *this );
[7870799]2859
2860 VISIT_END( node );
2861}
2862
[e0886db]2863template< typename pass_type >
2864Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
2865 MUTATE_START( node );
2866
2867 indexerScopedMutate( node->env , *this );
2868 indexerScopedMutate( node->result, *this );
[3c398b6]2869 maybeMutate_impl ( node->expr , *this );
[e0886db]2870
2871 MUTATE_END( Expression, node );
[13932f14]2872}
2873
[73367a8]2874//--------------------------------------------------------------------------
2875// UntypedInitExpr
2876template< typename pass_type >
2877void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
2878 VISIT_START( node );
2879
2880 indexerScopedAccept( node->result, *this );
2881 maybeAccept_impl ( node->expr , *this );
2882 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2883
2884 VISIT_END( node );
2885}
2886
[7870799]2887template< typename pass_type >
2888void PassVisitor< pass_type >::visit( const UntypedInitExpr * node ) {
2889 VISIT_START( node );
2890
[e3d7f9f]2891 indexerScopedAccept( node->result, *this );
2892 maybeAccept_impl ( node->expr , *this );
[7870799]2893 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2894
2895 VISIT_END( node );
2896}
2897
[73367a8]2898template< typename pass_type >
2899Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
2900 MUTATE_START( node );
2901
2902 indexerScopedMutate( node->env , *this );
2903 indexerScopedMutate( node->result, *this );
2904 maybeMutate_impl ( node->expr , *this );
2905 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2906
2907 MUTATE_END( Expression, node );
2908}
2909
2910//--------------------------------------------------------------------------
2911// InitExpr
2912template< typename pass_type >
2913void PassVisitor< pass_type >::visit( InitExpr * node ) {
2914 VISIT_START( node );
2915
2916 indexerScopedAccept( node->result, *this );
2917 maybeAccept_impl ( node->expr , *this );
2918 maybeAccept_impl ( node->designation, *this );
2919
2920 VISIT_END( node );
2921}
2922
[7870799]2923template< typename pass_type >
2924void PassVisitor< pass_type >::visit( const InitExpr * node ) {
2925 VISIT_START( node );
2926
[e3d7f9f]2927 indexerScopedAccept( node->result, *this );
2928 maybeAccept_impl ( node->expr , *this );
2929 maybeAccept_impl ( node->designation, *this );
[7870799]2930
2931 VISIT_END( node );
2932}
2933
[73367a8]2934template< typename pass_type >
2935Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
2936 MUTATE_START( node );
2937
2938 indexerScopedMutate( node->env , *this );
2939 indexerScopedMutate( node->result, *this );
2940 maybeMutate_impl ( node->expr , *this );
2941 maybeMutate_impl ( node->designation, *this );
2942
2943 MUTATE_END( Expression, node );
2944}
2945
[44b4114]2946//--------------------------------------------------------------------------
2947// DeletedExpr
2948template< typename pass_type >
2949void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
2950 VISIT_START( node );
2951
2952 indexerScopedAccept( node->result, *this );
[e3d7f9f]2953 maybeAccept_impl ( node->expr, *this );
[44b4114]2954 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
2955
2956 VISIT_END( node );
2957}
2958
[7870799]2959template< typename pass_type >
2960void PassVisitor< pass_type >::visit( const DeletedExpr * node ) {
2961 VISIT_START( node );
2962
[e3d7f9f]2963 indexerScopedAccept( node->result, *this );
2964 maybeAccept_impl ( node->expr, *this );
[7870799]2965 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
2966
2967 VISIT_END( node );
2968}
2969
[44b4114]2970template< typename pass_type >
2971Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
2972 MUTATE_START( node );
2973
2974 indexerScopedMutate( node->env, *this );
2975 indexerScopedMutate( node->result, *this );
2976 maybeMutate_impl( node->expr, *this );
2977
2978 MUTATE_END( Expression, node );
2979}
2980
[0f79853]2981//--------------------------------------------------------------------------
2982// DefaultArgExpr
2983template< typename pass_type >
2984void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) {
2985 VISIT_START( node );
2986
2987 indexerScopedAccept( node->result, *this );
[e3d7f9f]2988 maybeAccept_impl ( node->expr, *this );
[0f79853]2989
2990 VISIT_END( node );
2991}
2992
[7870799]2993template< typename pass_type >
2994void PassVisitor< pass_type >::visit( const DefaultArgExpr * node ) {
2995 VISIT_START( node );
2996
[e3d7f9f]2997 indexerScopedAccept( node->result, *this );
2998 maybeAccept_impl ( node->expr, *this );
[7870799]2999
3000 VISIT_END( node );
3001}
3002
[0f79853]3003template< typename pass_type >
3004Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) {
3005 MUTATE_START( node );
3006
3007 indexerScopedMutate( node->env, *this );
3008 indexerScopedMutate( node->result, *this );
3009 maybeMutate_impl( node->expr, *this );
3010
3011 MUTATE_END( Expression, node );
3012}
3013
[d807ca28]3014//--------------------------------------------------------------------------
3015// GenericExpr
3016template< typename pass_type >
3017void PassVisitor< pass_type >::visit( GenericExpr * node ) {
3018 VISIT_START( node );
3019
3020 indexerScopedAccept( node->result, *this );
3021 maybeAccept_impl( node->control, *this );
3022 for ( GenericExpr::Association & assoc : node->associations ) {
3023 indexerScopedAccept( assoc.type, *this );
3024 maybeAccept_impl( assoc.expr, *this );
3025 }
3026
3027 VISIT_END( node );
3028}
3029
[7870799]3030template< typename pass_type >
3031void PassVisitor< pass_type >::visit( const GenericExpr * node ) {
3032 VISIT_START( node );
3033
[e3d7f9f]3034 indexerScopedAccept( node->result, *this );
[7870799]3035 maybeAccept_impl( node->control, *this );
3036 for ( const GenericExpr::Association & assoc : node->associations ) {
[e3d7f9f]3037 indexerScopedAccept( assoc.type, *this );
[7870799]3038 maybeAccept_impl( assoc.expr, *this );
3039 }
3040
3041 VISIT_END( node );
3042}
3043
[d807ca28]3044template< typename pass_type >
3045Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) {
3046 MUTATE_START( node );
3047
3048 indexerScopedMutate( node->env, *this );
3049 indexerScopedMutate( node->result, *this );
3050 maybeMutate_impl( node->control, *this );
3051 for ( GenericExpr::Association & assoc : node->associations ) {
3052 indexerScopedMutate( assoc.type, *this );
3053 maybeMutate_impl( assoc.expr, *this );
3054 }
3055
3056 MUTATE_END( Expression, node );
3057}
3058
[17fc7a5]3059//--------------------------------------------------------------------------
3060// VoidType
[13932f14]3061template< typename pass_type >
[ab904dc]3062void PassVisitor< pass_type >::visit( VoidType * node ) {
[599fbb6]3063 VISIT_START( node );
3064
3065 maybeAccept_impl( node->forall, *this );
3066
3067 VISIT_END( node );
3068}
3069
[7870799]3070template< typename pass_type >
3071void PassVisitor< pass_type >::visit( const VoidType * node ) {
3072 VISIT_START( node );
3073
3074 maybeAccept_impl( node->forall, *this );
3075
3076 VISIT_END( node );
3077}
3078
[599fbb6]3079template< typename pass_type >
3080Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
3081 MUTATE_START( node );
3082
3083 maybeMutate_impl( node->forall, *this );
3084
3085 MUTATE_END( Type, node );
[13932f14]3086}
3087
[17fc7a5]3088//--------------------------------------------------------------------------
3089// BasicType
[13932f14]3090template< typename pass_type >
[ab904dc]3091void PassVisitor< pass_type >::visit( BasicType * node ) {
[17fc7a5]3092 VISIT_START( node );
3093
3094 maybeAccept_impl( node->forall, *this );
3095
3096 VISIT_END( node );
3097}
3098
[7870799]3099template< typename pass_type >
3100void PassVisitor< pass_type >::visit( const BasicType * node ) {
3101 VISIT_START( node );
3102
3103 maybeAccept_impl( node->forall, *this );
3104
3105 VISIT_END( node );
3106}
3107
[17fc7a5]3108template< typename pass_type >
3109Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
3110 MUTATE_START( node );
3111
3112 maybeMutate_impl( node->forall, *this );
3113
3114 MUTATE_END( Type, node );
[13932f14]3115}
3116
[17fc7a5]3117//--------------------------------------------------------------------------
3118// PointerType
[13932f14]3119template< typename pass_type >
[ab904dc]3120void PassVisitor< pass_type >::visit( PointerType * node ) {
[17fc7a5]3121 VISIT_START( node );
3122
3123 maybeAccept_impl( node->forall, *this );
[cfaf9be]3124 // xxx - should PointerType visit/mutate dimension?
[17fc7a5]3125 maybeAccept_impl( node->base, *this );
3126
3127 VISIT_END( node );
[13932f14]3128}
3129
[7870799]3130template< typename pass_type >
3131void PassVisitor< pass_type >::visit( const PointerType * node ) {
3132 VISIT_START( node );
3133
3134 maybeAccept_impl( node->forall, *this );
3135 // xxx - should PointerType visit/mutate dimension?
3136 maybeAccept_impl( node->base, *this );
3137
3138 VISIT_END( node );
3139}
3140
[17fc7a5]3141template< typename pass_type >
3142Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
3143 MUTATE_START( node );
3144
3145 maybeMutate_impl( node->forall, *this );
[cfaf9be]3146 // xxx - should PointerType visit/mutate dimension?
[17fc7a5]3147 maybeMutate_impl( node->base, *this );
3148
3149 MUTATE_END( Type, node );
3150}
3151
3152//--------------------------------------------------------------------------
3153// ArrayType
[13932f14]3154template< typename pass_type >
[ab904dc]3155void PassVisitor< pass_type >::visit( ArrayType * node ) {
[17fc7a5]3156 VISIT_START( node );
3157
3158 maybeAccept_impl( node->forall, *this );
3159 maybeAccept_impl( node->dimension, *this );
3160 maybeAccept_impl( node->base, *this );
3161
3162 VISIT_END( node );
[13932f14]3163}
3164
[7870799]3165template< typename pass_type >
3166void PassVisitor< pass_type >::visit( const ArrayType * node ) {
3167 VISIT_START( node );
3168
3169 maybeAccept_impl( node->forall, *this );
3170 maybeAccept_impl( node->dimension, *this );
3171 maybeAccept_impl( node->base, *this );
3172
3173 VISIT_END( node );
3174}
3175
[17fc7a5]3176template< typename pass_type >
3177Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
3178 MUTATE_START( node );
3179
3180 maybeMutate_impl( node->forall, *this );
3181 maybeMutate_impl( node->dimension, *this );
3182 maybeMutate_impl( node->base, *this );
3183
3184 MUTATE_END( Type, node );
3185}
3186
3187//--------------------------------------------------------------------------
3188// ReferenceType
[6b9b047]3189template< typename pass_type >
3190void PassVisitor< pass_type >::visit( ReferenceType * node ) {
[17fc7a5]3191 VISIT_START( node );
3192
3193 maybeAccept_impl( node->forall, *this );
3194 maybeAccept_impl( node->base, *this );
3195
3196 VISIT_END( node );
3197}
3198
[7870799]3199template< typename pass_type >
3200void PassVisitor< pass_type >::visit( const ReferenceType * node ) {
3201 VISIT_START( node );
3202
3203 maybeAccept_impl( node->forall, *this );
3204 maybeAccept_impl( node->base, *this );
3205
3206 VISIT_END( node );
3207}
3208
[17fc7a5]3209template< typename pass_type >
3210Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
3211 MUTATE_START( node );
3212
3213 maybeMutate_impl( node->forall, *this );
3214 maybeMutate_impl( node->base, *this );
3215
3216 MUTATE_END( Type, node );
[6b9b047]3217}
3218
[c5d7701]3219//--------------------------------------------------------------------------
3220// QualifiedType
3221template< typename pass_type >
3222void PassVisitor< pass_type >::visit( QualifiedType * node ) {
3223 VISIT_START( node );
3224
3225 maybeAccept_impl( node->forall, *this );
[c194661]3226 maybeAccept_impl( node->parent, *this );
3227 maybeAccept_impl( node->child, *this );
[c5d7701]3228
3229 VISIT_END( node );
3230}
3231
[7870799]3232template< typename pass_type >
3233void PassVisitor< pass_type >::visit( const QualifiedType * node ) {
3234 VISIT_START( node );
3235
3236 maybeAccept_impl( node->forall, *this );
3237 maybeAccept_impl( node->parent, *this );
3238 maybeAccept_impl( node->child, *this );
3239
3240 VISIT_END( node );
3241}
3242
[c5d7701]3243template< typename pass_type >
3244Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) {
3245 MUTATE_START( node );
3246
3247 maybeMutate_impl( node->forall, *this );
[c194661]3248 maybeMutate_impl( node->parent, *this );
3249 maybeMutate_impl( node->child, *this );
[c5d7701]3250
3251 MUTATE_END( Type, node );
3252}
3253
[17fc7a5]3254//--------------------------------------------------------------------------
3255// FunctionType
[13932f14]3256template< typename pass_type >
[ab904dc]3257void PassVisitor< pass_type >::visit( FunctionType * node ) {
[17fc7a5]3258 VISIT_START( node );
3259
3260 maybeAccept_impl( node->forall, *this );
3261 maybeAccept_impl( node->returnVals, *this );
3262 maybeAccept_impl( node->parameters, *this );
3263
3264 VISIT_END( node );
3265}
3266
[7870799]3267template< typename pass_type >
3268void PassVisitor< pass_type >::visit( const FunctionType * node ) {
3269 VISIT_START( node );
3270
3271 maybeAccept_impl( node->forall, *this );
3272 maybeAccept_impl( node->returnVals, *this );
3273 maybeAccept_impl( node->parameters, *this );
3274
3275 VISIT_END( node );
3276}
3277
[17fc7a5]3278template< typename pass_type >
3279Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
3280 MUTATE_START( node );
3281
3282 maybeMutate_impl( node->forall, *this );
3283 maybeMutate_impl( node->returnVals, *this );
3284 maybeMutate_impl( node->parameters, *this );
3285
3286 MUTATE_END( Type, node );
[13932f14]3287}
3288
[e0886db]3289//--------------------------------------------------------------------------
3290// StructInstType
[13932f14]3291template< typename pass_type >
[ab904dc]3292void PassVisitor< pass_type >::visit( StructInstType * node ) {
[e0886db]3293 VISIT_START( node );
3294
3295 indexerAddStruct( node->name );
3296
3297 {
3298 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]3299 maybeAccept_impl( node->forall , *this );
3300 maybeAccept_impl( node->parameters, *this );
[e0886db]3301 }
3302
3303 VISIT_END( node );
3304}
3305
[7870799]3306template< typename pass_type >
3307void PassVisitor< pass_type >::visit( const StructInstType * node ) {
3308 VISIT_START( node );
3309
[e3d7f9f]3310 indexerAddStruct( node->name );
3311
3312 {
3313 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3314 maybeAccept_impl( node->forall , *this );
3315 maybeAccept_impl( node->parameters, *this );
3316 }
[7870799]3317
3318 VISIT_END( node );
3319}
3320
[e0886db]3321template< typename pass_type >
3322Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
3323 MUTATE_START( node );
3324
3325 indexerAddStruct( node->name );
3326
3327 {
3328 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]3329 maybeMutate_impl( node->forall , *this );
3330 maybeMutate_impl( node->parameters, *this );
[e0886db]3331 }
3332
3333 MUTATE_END( Type, node );
[13932f14]3334}
3335
[e0886db]3336//--------------------------------------------------------------------------
3337// UnionInstType
[13932f14]3338template< typename pass_type >
[ab904dc]3339void PassVisitor< pass_type >::visit( UnionInstType * node ) {
[e0886db]3340 VISIT_START( node );
3341
[74e3263]3342 indexerAddUnion( node->name );
[e0886db]3343
3344 {
3345 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]3346 maybeAccept_impl( node->forall , *this );
3347 maybeAccept_impl( node->parameters, *this );
[e0886db]3348 }
3349
3350 VISIT_END( node );
3351}
3352
[7870799]3353template< typename pass_type >
3354void PassVisitor< pass_type >::visit( const UnionInstType * node ) {
3355 VISIT_START( node );
3356
[74e3263]3357 indexerAddUnion( node->name );
[e3d7f9f]3358
3359 {
3360 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3361 maybeAccept_impl( node->forall , *this );
3362 maybeAccept_impl( node->parameters, *this );
3363 }
[7870799]3364
3365 VISIT_END( node );
3366}
3367
[e0886db]3368template< typename pass_type >
3369Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
3370 MUTATE_START( node );
3371
[74e3263]3372 indexerAddUnion( node->name );
[e0886db]3373
3374 {
3375 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]3376 maybeMutate_impl( node->forall , *this );
3377 maybeMutate_impl( node->parameters, *this );
[e0886db]3378 }
3379
3380 MUTATE_END( Type, node );
[13932f14]3381}
3382
[e0886db]3383//--------------------------------------------------------------------------
3384// EnumInstType
[13932f14]3385template< typename pass_type >
[ab904dc]3386void PassVisitor< pass_type >::visit( EnumInstType * node ) {
[86e84e4]3387 VISIT_START( node );
3388
3389 maybeAccept_impl( node->forall, *this );
3390 maybeAccept_impl( node->parameters, *this );
3391
3392 VISIT_END( node );
[13932f14]3393}
3394
[7870799]3395template< typename pass_type >
3396void PassVisitor< pass_type >::visit( const EnumInstType * node ) {
3397 VISIT_START( node );
3398
3399 maybeAccept_impl( node->forall, *this );
3400 maybeAccept_impl( node->parameters, *this );
3401
3402 VISIT_END( node );
3403}
3404
[e0886db]3405template< typename pass_type >
3406Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
[86e84e4]3407 MUTATE_START( node );
3408
3409 maybeMutate_impl( node->forall, *this );
3410 maybeMutate_impl( node->parameters, *this );
3411
3412 MUTATE_END( Type, node );
[e0886db]3413}
3414
3415//--------------------------------------------------------------------------
3416// TraitInstType
[13932f14]3417template< typename pass_type >
[ab904dc]3418void PassVisitor< pass_type >::visit( TraitInstType * node ) {
[e0886db]3419 VISIT_START( node );
3420
[3c398b6]3421 maybeAccept_impl( node->forall , *this );
3422 maybeAccept_impl( node->parameters, *this );
[e0886db]3423
3424 VISIT_END( node );
3425}
3426
[7870799]3427template< typename pass_type >
3428void PassVisitor< pass_type >::visit( const TraitInstType * node ) {
3429 VISIT_START( node );
3430
3431 maybeAccept_impl( node->forall , *this );
3432 maybeAccept_impl( node->parameters, *this );
3433
3434 VISIT_END( node );
3435}
3436
[e0886db]3437template< typename pass_type >
3438Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
3439 MUTATE_START( node );
3440
[3c398b6]3441 maybeMutate_impl( node->forall , *this );
3442 maybeMutate_impl( node->parameters, *this );
[e0886db]3443
3444 MUTATE_END( Type, node );
[13932f14]3445}
3446
[e0886db]3447//--------------------------------------------------------------------------
3448// TypeInstType
[13932f14]3449template< typename pass_type >
[ab904dc]3450void PassVisitor< pass_type >::visit( TypeInstType * node ) {
[86e84e4]3451 VISIT_START( node );
3452
3453 maybeAccept_impl( node->forall , *this );
3454 maybeAccept_impl( node->parameters, *this );
3455
3456 VISIT_END( node );
3457}
3458
[7870799]3459template< typename pass_type >
3460void PassVisitor< pass_type >::visit( const TypeInstType * node ) {
3461 VISIT_START( node );
3462
3463 maybeAccept_impl( node->forall , *this );
3464 maybeAccept_impl( node->parameters, *this );
3465
3466 VISIT_END( node );
3467}
3468
[86e84e4]3469template< typename pass_type >
3470Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
3471 MUTATE_START( node );
3472
3473 maybeMutate_impl( node->forall , *this );
3474 maybeMutate_impl( node->parameters, *this );
3475
3476 MUTATE_END( Type, node );
[13932f14]3477}
3478
[a8a2b0a]3479//--------------------------------------------------------------------------
3480// TupleType
[13932f14]3481template< typename pass_type >
[ab904dc]3482void PassVisitor< pass_type >::visit( TupleType * node ) {
[a8a2b0a]3483 VISIT_START( node );
3484
3485 maybeAccept_impl( node->forall, *this );
3486 maybeAccept_impl( node->types, *this );
3487 maybeAccept_impl( node->members, *this );
3488
3489 VISIT_END( node );
[13932f14]3490}
3491
[7870799]3492template< typename pass_type >
3493void PassVisitor< pass_type >::visit( const TupleType * node ) {
3494 VISIT_START( node );
3495
3496 maybeAccept_impl( node->forall, *this );
3497 maybeAccept_impl( node->types, *this );
3498 maybeAccept_impl( node->members, *this );
3499
3500 VISIT_END( node );
3501}
3502
[a8a2b0a]3503template< typename pass_type >
3504Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
3505 MUTATE_START( node );
3506
3507 maybeMutate_impl( node->forall, *this );
3508 maybeMutate_impl( node->types, *this );
3509 maybeMutate_impl( node->members, *this );
3510
3511 MUTATE_END( Type, node );
3512}
3513
3514//--------------------------------------------------------------------------
3515// TypeofType
[13932f14]3516template< typename pass_type >
[ab904dc]3517void PassVisitor< pass_type >::visit( TypeofType * node ) {
[a8a2b0a]3518 VISIT_START( node );
3519
3520 assert( node->expr );
3521 maybeAccept_impl( node->expr, *this );
3522
3523 VISIT_END( node );
[13932f14]3524}
3525
[7870799]3526template< typename pass_type >
3527void PassVisitor< pass_type >::visit( const TypeofType * node ) {
3528 VISIT_START( node );
3529
3530 assert( node->expr );
3531 maybeAccept_impl( node->expr, *this );
3532
3533 VISIT_END( node );
3534}
3535
[a8a2b0a]3536template< typename pass_type >
3537Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
3538 MUTATE_START( node );
3539
3540 assert( node->expr );
3541 maybeMutate_impl( node->expr, *this );
3542
3543 MUTATE_END( Type, node );
3544}
3545
3546//--------------------------------------------------------------------------
3547// AttrType
[13932f14]3548template< typename pass_type >
[ab904dc]3549void PassVisitor< pass_type >::visit( AttrType * node ) {
[a8a2b0a]3550 VISIT_START( node );
3551
3552 if ( node->isType ) {
3553 assert( node->type );
3554 maybeAccept_impl( node->type, *this );
3555 } else {
3556 assert( node->expr );
3557 maybeAccept_impl( node->expr, *this );
3558 } // if
3559
3560 VISIT_END( node );
[13932f14]3561}
3562
[7870799]3563template< typename pass_type >
3564void PassVisitor< pass_type >::visit( const AttrType * node ) {
3565 VISIT_START( node );
3566
3567 if ( node->isType ) {
3568 assert( node->type );
3569 maybeAccept_impl( node->type, *this );
3570 } else {
3571 assert( node->expr );
3572 maybeAccept_impl( node->expr, *this );
3573 } // if
3574
3575 VISIT_END( node );
3576}
3577
[a8a2b0a]3578template< typename pass_type >
3579Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
3580 MUTATE_START( node );
3581
3582 if ( node->isType ) {
3583 assert( node->type );
3584 maybeMutate_impl( node->type, *this );
3585 } else {
3586 assert( node->expr );
3587 maybeMutate_impl( node->expr, *this );
3588 } // if
3589
3590 MUTATE_END( Type, node );
3591}
3592
3593//--------------------------------------------------------------------------
3594// VarArgsType
[13932f14]3595template< typename pass_type >
[ab904dc]3596void PassVisitor< pass_type >::visit( VarArgsType * node ) {
[a8a2b0a]3597 VISIT_START( node );
3598
3599 maybeAccept_impl( node->forall, *this );
3600
3601 VISIT_END( node );
[13932f14]3602}
3603
[7870799]3604template< typename pass_type >
3605void PassVisitor< pass_type >::visit( const VarArgsType * node ) {
3606 VISIT_START( node );
3607
3608 maybeAccept_impl( node->forall, *this );
3609
3610 VISIT_END( node );
3611}
3612
[a8a2b0a]3613template< typename pass_type >
3614Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
3615 MUTATE_START( node );
3616
3617 maybeMutate_impl( node->forall, *this );
3618
3619 MUTATE_END( Type, node );
3620}
3621
3622//--------------------------------------------------------------------------
3623// ZeroType
[13932f14]3624template< typename pass_type >
[ab904dc]3625void PassVisitor< pass_type >::visit( ZeroType * node ) {
[a8a2b0a]3626 VISIT_START( node );
3627
3628 maybeAccept_impl( node->forall, *this );
3629
3630 VISIT_END( node );
[13932f14]3631}
3632
[7870799]3633template< typename pass_type >
3634void PassVisitor< pass_type >::visit( const ZeroType * node ) {
3635 VISIT_START( node );
3636
3637 maybeAccept_impl( node->forall, *this );
3638
3639 VISIT_END( node );
3640}
3641
[a8a2b0a]3642template< typename pass_type >
3643Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
3644 MUTATE_START( node );
3645
3646 maybeMutate_impl( node->forall, *this );
3647
3648 MUTATE_END( Type, node );
3649}
3650
3651//--------------------------------------------------------------------------
3652// OneType
[13932f14]3653template< typename pass_type >
[ab904dc]3654void PassVisitor< pass_type >::visit( OneType * node ) {
[a8a2b0a]3655 VISIT_START( node );
3656
3657 maybeAccept_impl( node->forall, *this );
3658
3659 VISIT_END( node );
[13932f14]3660}
3661
[7870799]3662template< typename pass_type >
3663void PassVisitor< pass_type >::visit( const OneType * node ) {
3664 VISIT_START( node );
3665
3666 maybeAccept_impl( node->forall, *this );
3667
3668 VISIT_END( node );
3669}
3670
[a8a2b0a]3671template< typename pass_type >
3672Type * PassVisitor< pass_type >::mutate( OneType * node ) {
3673 MUTATE_START( node );
3674
3675 maybeMutate_impl( node->forall, *this );
3676
3677 MUTATE_END( Type, node );
3678}
3679
[47498bd]3680//--------------------------------------------------------------------------
3681// GlobalScopeType
3682template< typename pass_type >
3683void PassVisitor< pass_type >::visit( GlobalScopeType * node ) {
3684 VISIT_START( node );
3685
3686 maybeAccept_impl( node->forall, *this );
3687
3688 VISIT_END( node );
3689}
3690
[7870799]3691template< typename pass_type >
3692void PassVisitor< pass_type >::visit( const GlobalScopeType * node ) {
3693 VISIT_START( node );
3694
3695 maybeAccept_impl( node->forall, *this );
3696
3697 VISIT_END( node );
3698}
3699
[47498bd]3700template< typename pass_type >
3701Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) {
3702 MUTATE_START( node );
3703
3704 maybeMutate_impl( node->forall, *this );
3705
3706 MUTATE_END( Type, node );
3707}
3708
[a8a2b0a]3709//--------------------------------------------------------------------------
3710// Designation
[b11d8e2]3711template< typename pass_type >
3712void PassVisitor< pass_type >::visit( Designation * node ) {
3713 VISIT_START( node );
3714
[a8a2b0a]3715 maybeAccept_impl( node->designators, *this );
[b11d8e2]3716
3717 VISIT_END( node );
3718}
3719
[7870799]3720template< typename pass_type >
3721void PassVisitor< pass_type >::visit( const Designation * node ) {
3722 VISIT_START( node );
3723
3724 maybeAccept_impl( node->designators, *this );
3725
3726 VISIT_END( node );
3727}
3728
[b11d8e2]3729template< typename pass_type >
3730Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
3731 MUTATE_START( node );
3732
[a8a2b0a]3733 maybeMutate_impl( node->designators, *this );
[b11d8e2]3734
3735 MUTATE_END( Designation, node );
3736}
3737
[9c1600c]3738//--------------------------------------------------------------------------
[e0886db]3739// SingleInit
[13932f14]3740template< typename pass_type >
[ab904dc]3741void PassVisitor< pass_type >::visit( SingleInit * node ) {
[9c1600c]3742 VISIT_START( node );
3743
[a8a2b0a]3744 visitExpression( node->value );
[9c1600c]3745
3746 VISIT_END( node );
[13932f14]3747}
3748
[7870799]3749template< typename pass_type >
3750void PassVisitor< pass_type >::visit( const SingleInit * node ) {
3751 VISIT_START( node );
3752
3753 visitExpression( node->value );
3754
3755 VISIT_END( node );
3756}
3757
[296b2be]3758template< typename pass_type >
3759Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
3760 MUTATE_START( node );
3761
[a8a2b0a]3762 node->value = mutateExpression( node->value );
[296b2be]3763
3764 MUTATE_END( Initializer, node );
3765}
3766
[a8a2b0a]3767//--------------------------------------------------------------------------
3768// ListInit
[13932f14]3769template< typename pass_type >
[ab904dc]3770void PassVisitor< pass_type >::visit( ListInit * node ) {
[a8a2b0a]3771 VISIT_START( node );
[13932f14]3772
[a8a2b0a]3773 maybeAccept_impl( node->designations, *this );
3774 maybeAccept_impl( node->initializers, *this );
[13932f14]3775
[a8a2b0a]3776 VISIT_END( node );
[13932f14]3777}
3778
[7870799]3779template< typename pass_type >
3780void PassVisitor< pass_type >::visit( const ListInit * node ) {
3781 VISIT_START( node );
3782
3783 maybeAccept_impl( node->designations, *this );
3784 maybeAccept_impl( node->initializers, *this );
3785
3786 VISIT_END( node );
3787}
3788
[13932f14]3789template< typename pass_type >
[a8a2b0a]3790Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
3791 MUTATE_START( node );
3792
3793 maybeMutate_impl( node->designations, *this );
3794 maybeMutate_impl( node->initializers, *this );
3795
3796 MUTATE_END( Initializer, node );
[13932f14]3797}
[ab904dc]3798
[a8a2b0a]3799//--------------------------------------------------------------------------
3800// ConstructorInit
[5ea7a22]3801template< typename pass_type >
[a8a2b0a]3802void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
3803 VISIT_START( node );
[5ea7a22]3804
[a8a2b0a]3805 maybeAccept_impl( node->ctor, *this );
3806 maybeAccept_impl( node->dtor, *this );
3807 maybeAccept_impl( node->init, *this );
[ab904dc]3808
[a8a2b0a]3809 VISIT_END( node );
[ab904dc]3810}
3811
[7870799]3812template< typename pass_type >
3813void PassVisitor< pass_type >::visit( const ConstructorInit * node ) {
3814 VISIT_START( node );
3815
3816 maybeAccept_impl( node->ctor, *this );
3817 maybeAccept_impl( node->dtor, *this );
3818 maybeAccept_impl( node->init, *this );
3819
3820 VISIT_END( node );
3821}
3822
[ab904dc]3823template< typename pass_type >
[a8a2b0a]3824Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
3825 MUTATE_START( node );
[ab904dc]3826
[a8a2b0a]3827 maybeMutate_impl( node->ctor, *this );
3828 maybeMutate_impl( node->dtor, *this );
3829 maybeMutate_impl( node->init, *this );
[ab904dc]3830
[a8a2b0a]3831 MUTATE_END( Initializer, node );
[ab904dc]3832}
3833
[a8a2b0a]3834//--------------------------------------------------------------------------
3835// Attribute
[ab904dc]3836template< typename pass_type >
[a8a2b0a]3837void PassVisitor< pass_type >::visit( Constant * node ) {
3838 VISIT_START( node );
3839
3840 VISIT_END( node );
[ab904dc]3841}
3842
[7870799]3843template< typename pass_type >
3844void PassVisitor< pass_type >::visit( const Constant * node ) {
3845 VISIT_START( node );
3846
3847 VISIT_END( node );
3848}
3849
[ab904dc]3850template< typename pass_type >
[a8a2b0a]3851Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
3852 MUTATE_START( node );
3853
3854 MUTATE_END( Constant, node );
[ab904dc]3855}
3856
[a8a2b0a]3857//--------------------------------------------------------------------------
3858// Attribute
[ab904dc]3859template< typename pass_type >
[a8a2b0a]3860void PassVisitor< pass_type >::visit( Attribute * node ) {
3861 VISIT_START( node );
3862
3863 maybeAccept_impl( node->parameters, *this );
3864
3865 VISIT_END( node );
[4551a6e]3866}
[5ea7a22]3867
[7870799]3868template< typename pass_type >
3869void PassVisitor< pass_type >::visit( const Attribute * node ) {
3870 VISIT_START( node );
3871
3872 maybeAccept_impl( node->parameters, *this );
3873
3874 VISIT_END( node );
3875}
3876
[5ea7a22]3877template< typename pass_type >
3878Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
[a8a2b0a]3879 MUTATE_START( node );
3880
3881 maybeMutate_impl( node->parameters, *this );
3882
3883 MUTATE_END( Attribute, node );
[5ea7a22]3884}
[447c356]3885
[a8a2b0a]3886//--------------------------------------------------------------------------
3887// TypeSubstitution
[447c356]3888template< typename pass_type >
3889TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
3890 MUTATE_START( node );
3891
3892 for ( auto & p : node->typeEnv ) {
3893 indexerScopedMutate( p.second, *this );
3894 }
3895 for ( auto & p : node->varEnv ) {
3896 indexerScopedMutate( p.second, *this );
3897 }
3898
3899 MUTATE_END( TypeSubstitution, node );
3900}
[342146e1]3901
3902#undef VISIT_START
3903#undef VISIT_END
3904
3905#undef MUTATE_START
[033ff37]3906#undef MUTATE_END
Note: See TracBrowser for help on using the repository browser.