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

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

WithStmt is now a Declaration

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