source: src/Common/PassVisitor.impl.h@ 199894e

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

Implemented old ast boiler-plate for vtabletype.

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