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

ADT
Last change on this file since d6c464d was 561354f, checked in by JiadaL <j82liang@…>, 2 years ago

Save progress

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