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

ADT ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since cf85f96 was 798a8b3, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Attributes are now correctly visited when replacing typedefs

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