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

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

Merge branch 'master' into cleanup-dtors

  • Property mode set to 100644
File size: 78.7 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
[6ca154b]81template< typename pass_type >
[07c178f0]82inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
[6ca154b]83 DeclList_t* beforeDecls = mutator.get_beforeDecls();
84 DeclList_t* afterDecls = mutator.get_afterDecls();
[a16764a6]85 SemanticErrorException errors;
[6ca154b]86
[675716e]87 pass_visitor_stats.depth++;
88 pass_visitor_stats.max->push(pass_visitor_stats.depth);
89 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[6ca154b]90 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
91 // splice in new declarations after previous decl
[d24d4e1]92 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
[6ca154b]93
94 if ( i == decls.end() ) break;
[522363e]95 try {
96 // run mutator on declaration
[3c398b6]97 maybeMutate_impl( *i, mutator );
[a16764a6]98 } catch( SemanticErrorException &e ) {
[522363e]99 errors.append( e );
100 }
[6ca154b]101
102 // splice in new declarations before current decl
103 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
104 }
[675716e]105 pass_visitor_stats.depth--;
[522363e]106 if ( ! errors.isEmpty() ) {
107 throw errors;
108 }
[134322e]109}
110
[3c398b6]111template< typename TreeType, typename pass_type >
112inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
113 if ( ! visitor.get_visit_children() ) return;
114 if ( tree ) {
115 tree->accept( visitor );
116 }
117}
118
119template< typename Container, typename pass_type >
120inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
121 if ( ! visitor.get_visit_children() ) return;
[a16764a6]122 SemanticErrorException errors;
[675716e]123
124 pass_visitor_stats.depth++;
125 pass_visitor_stats.max->push(pass_visitor_stats.depth);
126 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[e0886db]127 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
128 try {
129 if ( *i ) {
130 (*i)->accept( visitor );
131 }
[a16764a6]132 } catch( SemanticErrorException &e ) {
[e0886db]133 errors.append( e );
134 }
135 }
[675716e]136 pass_visitor_stats.depth--;
[e0886db]137 if ( ! errors.isEmpty() ) {
138 throw errors;
139 }
140}
141
[3c398b6]142template< typename TreeType, typename pass_type >
143inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
144 if ( ! mutator.get_visit_children() ) return;
145
146 if ( tree ) {
147 tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
148 }
149}
150
151template< typename Container, typename pass_type >
152inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
[37e3af4]153
[3c398b6]154 if ( ! mutator.get_visit_children() ) return;
[a16764a6]155 SemanticErrorException errors;
[675716e]156
157 pass_visitor_stats.depth++;
158 pass_visitor_stats.max->push(pass_visitor_stats.depth);
159 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[e0886db]160 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
161 try {
162 if ( *i ) {
163 *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
164 assert( *i );
165 } // if
[a16764a6]166 } catch( SemanticErrorException &e ) {
[e0886db]167 errors.append( e );
168 } // try
169 } // for
[675716e]170 pass_visitor_stats.depth--;
[e0886db]171 if ( ! errors.isEmpty() ) {
172 throw errors;
173 } // if
174}
175
[296b2be]176template< typename pass_type >
[6ca154b]177template< typename func_t >
178void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
[3c398b6]179 if ( ! get_visit_children() ) return;
[a16764a6]180 SemanticErrorException errors;
[296b2be]181
[2a7b3ca]182 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
183 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
184 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
185 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
186 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
187
[134322e]188 StmtList_t* beforeStmts = get_beforeStmts();
189 StmtList_t* afterStmts = get_afterStmts();
[6ca154b]190 DeclList_t* beforeDecls = get_beforeDecls();
191 DeclList_t* afterDecls = get_afterDecls();
[134322e]192
[675716e]193 pass_visitor_stats.depth++;
194 pass_visitor_stats.max->push(pass_visitor_stats.depth);
195 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
[296b2be]196 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
[6ca154b]197
198 if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }
[134322e]199 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
[6ca154b]200
[296b2be]201 try {
[6ca154b]202 func( *i );
[37e3af4]203 assert( *i );
[6ca154b]204 assert(( empty( beforeStmts ) && empty( afterStmts ))
205 || ( empty( beforeDecls ) && empty( afterDecls )) );
206
[a16764a6]207 } catch ( SemanticErrorException &e ) {
[296b2be]208 errors.append( e );
[134322e]209 }
[6ca154b]210
211 if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }
[134322e]212 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
[296b2be]213 }
[675716e]214 pass_visitor_stats.depth--;
[134322e]215
[6ca154b]216 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
[134322e]217 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
218 if ( !errors.isEmpty() ) { throw errors; }
[296b2be]219}
220
221template< typename pass_type >
[6ca154b]222void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
223 handleStatementList( statements, [this]( Statement * stmt) {
[3c398b6]224 maybeAccept_impl( stmt, *this );
[6ca154b]225 });
226}
[134322e]227
[6ca154b]228template< typename pass_type >
229void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
230 handleStatementList( statements, [this]( Statement *& stmt) {
[3c398b6]231 maybeMutate_impl( stmt, *this );
[6ca154b]232 });
[134322e]233}
234
[6ca154b]235
[134322e]236template< typename pass_type >
[6ca154b]237template< typename func_t >
238Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
[3c398b6]239 if ( ! get_visit_children() ) return stmt;
240
[134322e]241 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
[02fdb8e]242 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
[6ca154b]243 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
244 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
245 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
246 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
[296b2be]247
[6ca154b]248 Statement *newStmt = func( stmt );
[134322e]249
250 StmtList_t* beforeStmts = get_beforeStmts();
251 StmtList_t* afterStmts = get_afterStmts();
[6ca154b]252 DeclList_t* beforeDecls = get_beforeDecls();
253 DeclList_t* afterDecls = get_afterDecls();
[134322e]254
[6ca154b]255 if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; }
256 assert(( empty( beforeStmts ) && empty( afterStmts ))
257 || ( empty( beforeDecls ) && empty( afterDecls )) );
[134322e]258
[ba3706f]259 CompoundStmt *compound = new CompoundStmt();
[6ca154b]260 if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); }
[134322e]261 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
262 compound->get_kids().push_back( newStmt );
[6ca154b]263 if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }
[134322e]264 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
265 return compound;
266}
267
268template< typename pass_type >
[6ca154b]269Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
270 return handleStatement( stmt, [this]( Statement * stmt ) {
[3c398b6]271 maybeAccept_impl( stmt, *this );
[6ca154b]272 return stmt;
273 });
274}
[134322e]275
[6ca154b]276template< typename pass_type >
277Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
278 return handleStatement( stmt, [this]( Statement * stmt ) {
[3c398b6]279 maybeMutate_impl( stmt, *this );
280 return stmt;
[6ca154b]281 });
[296b2be]282}
283
284template< typename pass_type >
[6ca154b]285template< typename func_t >
286Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
[3c398b6]287 if ( ! get_visit_children() ) return expr;
[296b2be]288 if( !expr ) return nullptr;
289
[134322e]290 auto env_ptr = get_env_ptr();
291 if ( env_ptr && expr->get_env() ) {
292 *env_ptr = expr->get_env();
[296b2be]293 }
[6ca154b]294
[3c398b6]295 // should env be moved onto the result of the mutate?
[6ca154b]296 return func( expr );
297}
298
299template< typename pass_type >
300Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
301 return handleExpression(expr, [this]( Expression * expr ) {
[3c398b6]302 maybeAccept_impl( expr, *this );
[6ca154b]303 return expr;
[d24d4e1]304 });
[296b2be]305}
[ab904dc]306
[6ca154b]307template< typename pass_type >
308Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
309 return handleExpression(expr, [this]( Expression * expr ) {
[3c398b6]310 maybeMutate_impl( expr, *this );
311 return expr;
[6ca154b]312 });
313}
[ab904dc]314
[3c398b6]315template< typename TreeType, typename VisitorType >
316inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
317 if ( ! visitor.get_visit_children() ) return;
318 auto guard = makeFuncGuard(
319 [&visitor]() { visitor.indexerScopeEnter(); },
320 [&visitor]() { visitor.indexerScopeLeave(); }
321 );
322 maybeAccept_impl( tree, visitor );
323}
324
325template< typename TreeType, typename MutatorType >
326inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
327 if ( ! mutator.get_visit_children() ) return;
328 auto guard = makeFuncGuard(
329 [&mutator]() { mutator.indexerScopeEnter(); },
330 [&mutator]() { mutator.indexerScopeLeave(); }
331 );
332 maybeMutate_impl( tree, mutator );
333}
334
[296b2be]335//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[e0886db]336//========================================================================================================================================================================
337//========================================================================================================================================================================
338//========================================================================================================================================================================
339//========================================================================================================================================================================
340//========================================================================================================================================================================
341//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[13932f14]342
[33a25f9]343// A NOTE ON THE ORDER OF TRAVERSAL
344//
345// Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is
346// no such thing as a recursive type or typedef.
347//
348// typedef struct { T *x; } T; // never allowed
349//
350// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
351// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
352// declaration).
353//
354// struct T { struct T *x; }; // allowed
355//
356// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
357// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
358// queried later in this pass.
359//
360// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
[e0886db]361
362//--------------------------------------------------------------------------
363// ObjectDecl
[13932f14]364template< typename pass_type >
[ab904dc]365void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
[e0886db]366 VISIT_START( node );
367
368 indexerScopedAccept( node->type , *this );
[3c398b6]369 maybeAccept_impl ( node->init , *this );
370 maybeAccept_impl ( node->bitfieldWidth, *this );
371 maybeAccept_impl ( node->attributes , *this );
[e0886db]372
[2cb70aa]373 indexerAddId( node );
[e0886db]374
375 VISIT_END( node );
376}
377
378template< typename pass_type >
379DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) {
380 MUTATE_START( node );
381
382 indexerScopedMutate( node->type , *this );
[3c398b6]383 maybeMutate_impl ( node->init , *this );
384 maybeMutate_impl ( node->bitfieldWidth, *this );
385 maybeMutate_impl ( node->attributes , *this );
[e0886db]386
[2cb70aa]387 indexerAddId( node );
[e0886db]388
389 MUTATE_END( DeclarationWithType, node );
[13932f14]390}
391
[e0886db]392//--------------------------------------------------------------------------
393// FunctionDecl
[13932f14]394template< typename pass_type >
[ab904dc]395void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
[e0886db]396 VISIT_START( node );
397
[2cb70aa]398 indexerAddId( node );
[e0886db]399
[7aaec67]400 maybeAccept_impl( node->withExprs, *this );
[e0886db]401 {
[2cb70aa]402 // with clause introduces a level of scope (for the with expression members).
403 // with clause exprs are added to the indexer before parameters so that parameters
404 // shadow with exprs and not the other way around.
[e0886db]405 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]406 indexerAddWith( node->withExprs, node );
[7aaec67]407 {
408 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
409 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
410 static ObjectDecl func(
411 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
412 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
413 nullptr
414 );
415 indexerAddId( &func );
416 maybeAccept_impl( node->type, *this );
[61d9b4b]417 // function body needs to have the same scope as parameters - CompoundStmt will not enter
418 // a new scope if inFunction is true
419 ValueGuard< bool > oldInFunction( inFunction );
420 inFunction = true;
[7aaec67]421 maybeAccept_impl( node->statements, *this );
422 maybeAccept_impl( node->attributes, *this );
423 }
[e0886db]424 }
425
426 VISIT_END( node );
427}
428
429template< typename pass_type >
430DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
431 MUTATE_START( node );
432
[2cb70aa]433 indexerAddId( node );
[e0886db]434
435 {
[2cb70aa]436 // with clause introduces a level of scope (for the with expression members).
437 // with clause exprs are added to the indexer before parameters so that parameters
438 // shadow with exprs and not the other way around.
[e0886db]439 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]440 indexerAddWith( node->withExprs, node );
[7aaec67]441 {
442 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
443 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
444 static ObjectDecl func(
445 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
446 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
447 nullptr
448 );
449 indexerAddId( &func );
450 maybeMutate_impl( node->type, *this );
[61d9b4b]451 // function body needs to have the same scope as parameters - CompoundStmt will not enter
452 // a new scope if inFunction is true
453 ValueGuard< bool > oldInFunction( inFunction );
454 inFunction = true;
[7aaec67]455 maybeMutate_impl( node->statements, *this );
456 maybeMutate_impl( node->attributes, *this );
457 }
[e0886db]458 }
459
460 MUTATE_END( DeclarationWithType, node );
[13932f14]461}
462
[e0886db]463//--------------------------------------------------------------------------
464// StructDecl
[13932f14]465template< typename pass_type >
[ab904dc]466void PassVisitor< pass_type >::visit( StructDecl * node ) {
[e0886db]467 VISIT_START( node );
468
469 // make up a forward declaration and add it before processing the members
470 // needs to be on the heap because addStruct saves the pointer
471 indexerAddStructFwd( node );
472
473 {
474 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]475 maybeAccept_impl( node->parameters, *this );
476 maybeAccept_impl( node->members , *this );
[e0886db]477 }
478
479 // this addition replaces the forward declaration
480 indexerAddStruct( node );
481
482 VISIT_END( node );
483}
484
485template< typename pass_type >
486Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
487 MUTATE_START( node );
488
489 // make up a forward declaration and add it before processing the members
490 // needs to be on the heap because addStruct saves the pointer
491 indexerAddStructFwd( node );
492
493 {
494 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]495 maybeMutate_impl( node->parameters, *this );
496 maybeMutate_impl( node->members , *this );
[e0886db]497 }
498
499 // this addition replaces the forward declaration
500 indexerAddStruct( node );
501
502 MUTATE_END( Declaration, node );
[13932f14]503}
504
[e0886db]505//--------------------------------------------------------------------------
506// UnionDecl
[13932f14]507template< typename pass_type >
[ab904dc]508void PassVisitor< pass_type >::visit( UnionDecl * node ) {
[e0886db]509 VISIT_START( node );
510
511 // make up a forward declaration and add it before processing the members
512 indexerAddUnionFwd( node );
513
514 {
515 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]516 maybeAccept_impl( node->parameters, *this );
517 maybeAccept_impl( node->members , *this );
[e0886db]518 }
519
520 indexerAddUnion( node );
521
522 VISIT_END( node );
523}
524
525template< typename pass_type >
526Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
527 MUTATE_START( node );
528
529 // make up a forward declaration and add it before processing the members
530 indexerAddUnionFwd( node );
531
532 {
533 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]534 maybeMutate_impl( node->parameters, *this );
535 maybeMutate_impl( node->members , *this );
[e0886db]536 }
537
538 indexerAddUnion( node );
539
540 MUTATE_END( Declaration, node );
[13932f14]541}
542
[e0886db]543//--------------------------------------------------------------------------
544// EnumDecl
[13932f14]545template< typename pass_type >
[ab904dc]546void PassVisitor< pass_type >::visit( EnumDecl * node ) {
[e0886db]547 VISIT_START( node );
548
549 indexerAddEnum( node );
550
[33a25f9]551 // unlike structs, traits, and unions, enums inject their members into the global scope
[3c398b6]552 maybeAccept_impl( node->parameters, *this );
553 maybeAccept_impl( node->members , *this );
[e0886db]554
555 VISIT_END( node );
[13932f14]556}
557
[e0886db]558template< typename pass_type >
559Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
560 MUTATE_START( node );
561
562 indexerAddEnum( node );
563
[522363e]564 // unlike structs, traits, and unions, enums inject their members into the global scope
[3c398b6]565 maybeMutate_impl( node->parameters, *this );
566 maybeMutate_impl( node->members , *this );
[e0886db]567
568 MUTATE_END( Declaration, node );
569}
570
571//--------------------------------------------------------------------------
572// TraitDecl
[13932f14]573template< typename pass_type >
[ab904dc]574void PassVisitor< pass_type >::visit( TraitDecl * node ) {
[e0886db]575 VISIT_START( node );
576
577 {
578 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]579 maybeAccept_impl( node->parameters, *this );
580 maybeAccept_impl( node->members , *this );
[e0886db]581 }
582
583 indexerAddTrait( node );
584
585 VISIT_END( node );
[13932f14]586}
587
[e0886db]588template< typename pass_type >
589Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
590 MUTATE_START( node );
591
592 {
593 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]594 maybeMutate_impl( node->parameters, *this );
595 maybeMutate_impl( node->members , *this );
[e0886db]596 }
597
598 indexerAddTrait( node );
599
600 MUTATE_END( Declaration, node );
601}
602
603//--------------------------------------------------------------------------
604// TypeDecl
[13932f14]605template< typename pass_type >
[ab904dc]606void PassVisitor< pass_type >::visit( TypeDecl * node ) {
[e0886db]607 VISIT_START( node );
608
609 {
610 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]611 maybeAccept_impl( node->parameters, *this );
612 maybeAccept_impl( node->base , *this );
[e0886db]613 }
614
[33a25f9]615 // see A NOTE ON THE ORDER OF TRAVERSAL, above
616 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
617 // and may depend on the type itself
[e0886db]618 indexerAddType( node );
619
[3c398b6]620 maybeAccept_impl( node->assertions, *this );
[e0886db]621
622 indexerScopedAccept( node->init, *this );
623
624 VISIT_END( node );
625}
626
627template< typename pass_type >
[982832e]628Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
[e0886db]629 MUTATE_START( node );
630
631 {
632 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]633 maybeMutate_impl( node->parameters, *this );
634 maybeMutate_impl( node->base , *this );
[e0886db]635 }
636
[33a25f9]637 // see A NOTE ON THE ORDER OF TRAVERSAL, above
638 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
639 // and may depend on the type itself
[e0886db]640 indexerAddType( node );
641
[3c398b6]642 maybeMutate_impl( node->assertions, *this );
[e0886db]643
644 indexerScopedMutate( node->init, *this );
645
[982832e]646 MUTATE_END( Declaration, node );
[13932f14]647}
648
[e0886db]649//--------------------------------------------------------------------------
650// TypedefDecl
[13932f14]651template< typename pass_type >
[ab904dc]652void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
[e0886db]653 VISIT_START( node );
654
655 {
656 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]657 maybeAccept_impl( node->parameters, *this );
658 maybeAccept_impl( node->base , *this );
[e0886db]659 }
660
661 indexerAddType( node );
662
[3c398b6]663 maybeAccept_impl( node->assertions, *this );
[e0886db]664
665 VISIT_END( node );
[13932f14]666}
667
668template< typename pass_type >
[e0886db]669Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
670 MUTATE_START( node );
671
672 {
673 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]674 maybeMutate_impl( node->parameters, *this );
675 maybeMutate_impl( node->base , *this );
[e0886db]676 }
677
678 indexerAddType( node );
679
[3c398b6]680 maybeMutate_impl( node->assertions, *this );
[e0886db]681
682 MUTATE_END( Declaration, node );
[13932f14]683}
684
[9c1600c]685//--------------------------------------------------------------------------
[e0886db]686// AsmDecl
[13932f14]687template< typename pass_type >
[e0886db]688void PassVisitor< pass_type >::visit( AsmDecl * node ) {
[9c1600c]689 VISIT_START( node );
690
[3c398b6]691 maybeAccept_impl( node->stmt, *this );
[9c1600c]692
693 VISIT_END( node );
[13932f14]694}
695
[296b2be]696template< typename pass_type >
[e0886db]697AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
[296b2be]698 MUTATE_START( node );
699
[3c398b6]700 maybeMutate_impl( node->stmt, *this );
[e0886db]701
702 MUTATE_END( AsmDecl, node );
703}
704
[f6e3e34]705//--------------------------------------------------------------------------
706// StaticAssertDecl
707template< typename pass_type >
708void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) {
709 VISIT_START( node );
710
[842c3d3]711 node->condition = visitExpression( node->condition );
712 maybeAccept_impl( node->message, *this );
[f6e3e34]713
714 VISIT_END( node );
715}
716
717template< typename pass_type >
718StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) {
719 MUTATE_START( node );
720
[842c3d3]721 node->condition = mutateExpression( node->condition );
722 maybeMutate_impl( node->message, *this );
[f6e3e34]723
724 MUTATE_END( StaticAssertDecl, node );
725}
726
[e0886db]727//--------------------------------------------------------------------------
728// CompoundStmt
729template< typename pass_type >
730void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
731 VISIT_START( node );
732 {
[61d9b4b]733 // do not enter a new scope if inFunction is true - needs to check old state before the assignment
734 ValueGuard< bool > oldInFunction( inFunction );
735 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } );
[e0886db]736 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
[61d9b4b]737 inFunction = false;
[e0886db]738 visitStatementList( node->kids );
739 }
740 VISIT_END( node );
741}
[296b2be]742
[e0886db]743template< typename pass_type >
744CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
745 MUTATE_START( node );
746 {
[61d9b4b]747 // do not enter a new scope if inFunction is true - needs to check old state before the assignment
748 ValueGuard< bool > oldInFunction( inFunction );
749 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } );
[e0886db]750 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
[61d9b4b]751 inFunction = false;
[e0886db]752 mutateStatementList( node->kids );
753 }
[296b2be]754 MUTATE_END( CompoundStmt, node );
755}
756
[9c1600c]757//--------------------------------------------------------------------------
758// ExprStmt
[13932f14]759template< typename pass_type >
[ab904dc]760void PassVisitor< pass_type >::visit( ExprStmt * node ) {
[9c1600c]761 VISIT_START( node );
762
[e0886db]763 visitExpression( node->expr );
[9c1600c]764
765 VISIT_END( node );
[13932f14]766}
767
[296b2be]768template< typename pass_type >
769Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
770 MUTATE_START( node );
771
[e0886db]772 node->expr = mutateExpression( node->expr );
[296b2be]773
774 MUTATE_END( Statement, node );
775}
776
[6ca154b]777//--------------------------------------------------------------------------
778// AsmStmt
[13932f14]779template< typename pass_type >
[ab904dc]780void PassVisitor< pass_type >::visit( AsmStmt * node ) {
[bc6f918]781 VISIT_START( node )
782
783 maybeAccept_impl( node->instruction, *this );
784 maybeAccept_impl( node->output, *this );
785 maybeAccept_impl( node->input, *this );
786 maybeAccept_impl( node->clobber, *this );
787
788 VISIT_END( node );
[13932f14]789}
790
[6ca154b]791template< typename pass_type >
792Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
[bc6f918]793 MUTATE_START( node );
794
795 maybeMutate_impl( node->instruction, *this );
796 maybeMutate_impl( node->output, *this );
797 maybeMutate_impl( node->input, *this );
798 maybeMutate_impl( node->clobber, *this );
799
800 MUTATE_END( Statement, node );
[6ca154b]801}
802
[cc32d83]803//--------------------------------------------------------------------------
804// AsmStmt
805template< typename pass_type >
806void PassVisitor< pass_type >::visit( DirectiveStmt * node ) {
807 VISIT_START( node )
808
809 VISIT_END( node );
810}
811
812template< typename pass_type >
813Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) {
814 MUTATE_START( node );
815
816 MUTATE_END( Statement, node );
817}
818
[9c1600c]819//--------------------------------------------------------------------------
820// IfStmt
[13932f14]821template< typename pass_type >
[ab904dc]822void PassVisitor< pass_type >::visit( IfStmt * node ) {
[4551a6e]823 VISIT_START( node );
[33a25f9]824 {
825 // if statements introduce a level of scope (for the initialization)
826 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]827 maybeAccept_impl( node->get_initialization(), *this );
828 visitExpression ( node->condition );
[33a25f9]829 node->thenPart = visitStatement( node->thenPart );
830 node->elsePart = visitStatement( node->elsePart );
831 }
[9c1600c]832 VISIT_END( node );
[13932f14]833}
834
[296b2be]835template< typename pass_type >
836Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
[4551a6e]837 MUTATE_START( node );
[e0886db]838 {
[33a25f9]839 // if statements introduce a level of scope (for the initialization)
[e0886db]840 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]841 maybeMutate_impl( node->get_initialization(), *this );
[e0886db]842 node->condition = mutateExpression( node->condition );
843 node->thenPart = mutateStatement ( node->thenPart );
844 node->elsePart = mutateStatement ( node->elsePart );
845 }
[296b2be]846 MUTATE_END( Statement, node );
847}
848
[9c1600c]849//--------------------------------------------------------------------------
850// WhileStmt
[13932f14]851template< typename pass_type >
[ab904dc]852void PassVisitor< pass_type >::visit( WhileStmt * node ) {
[4551a6e]853 VISIT_START( node );
[9c1600c]854
[ee3c93d]855 {
856 // while statements introduce a level of scope (for the initialization)
857 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
858 maybeAccept_impl( node->initialization, *this );
859 visitExpression ( node->condition );
860 node->body = visitStatement( node->body );
861 }
[9c1600c]862
863 VISIT_END( node );
[13932f14]864}
865
[296b2be]866template< typename pass_type >
867Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
[4551a6e]868 MUTATE_START( node );
[296b2be]869
[ee3c93d]870 {
871 // while statements introduce a level of scope (for the initialization)
872 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
873 maybeMutate_impl( node->initialization, *this );
874 node->condition = mutateExpression( node->condition );
875 node->body = mutateStatement ( node->body );
876 }
877
[296b2be]878
879 MUTATE_END( Statement, node );
880}
881
[9c1600c]882//--------------------------------------------------------------------------
[6ca154b]883// ForStmt
[13932f14]884template< typename pass_type >
[ab904dc]885void PassVisitor< pass_type >::visit( ForStmt * node ) {
[4551a6e]886 VISIT_START( node );
[e0886db]887 {
[33a25f9]888 // for statements introduce a level of scope (for the initialization)
[e0886db]889 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]890 maybeAccept_impl( node->initialization, *this );
[e0886db]891 visitExpression( node->condition );
892 visitExpression( node->increment );
893 node->body = visitStatement( node->body );
894 }
[9c1600c]895 VISIT_END( node );
[13932f14]896}
897
[296b2be]898template< typename pass_type >
899Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
[4551a6e]900 MUTATE_START( node );
[e0886db]901 {
[33a25f9]902 // for statements introduce a level of scope (for the initialization)
[e0886db]903 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]904 maybeMutate_impl( node->initialization, *this );
[e0886db]905 node->condition = mutateExpression( node->condition );
906 node->increment = mutateExpression( node->increment );
907 node->body = mutateStatement ( node->body );
908 }
[296b2be]909 MUTATE_END( Statement, node );
910}
911
[9c1600c]912//--------------------------------------------------------------------------
913// SwitchStmt
[13932f14]914template< typename pass_type >
[ab904dc]915void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
[4551a6e]916 VISIT_START( node );
[9c1600c]917
[e0886db]918 visitExpression ( node->condition );
919 visitStatementList( node->statements );
[9c1600c]920
921 VISIT_END( node );
[13932f14]922}
923
[296b2be]924template< typename pass_type >
925Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
[4551a6e]926 MUTATE_START( node );
927
[e0886db]928 node->condition = mutateExpression( node->condition );
929 mutateStatementList( node->statements );
[4551a6e]930
[296b2be]931 MUTATE_END( Statement, node );
932}
933
[9c1600c]934//--------------------------------------------------------------------------
[35df560]935// CaseStmt
[13932f14]936template< typename pass_type >
[ab904dc]937void PassVisitor< pass_type >::visit( CaseStmt * node ) {
[4551a6e]938 VISIT_START( node );
939
[e0886db]940 visitExpression ( node->condition );
941 visitStatementList( node->stmts );
[4551a6e]942
[9c1600c]943 VISIT_END( node );
[13932f14]944}
945
[296b2be]946template< typename pass_type >
947Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
[4551a6e]948 MUTATE_START( node );
949
[e0886db]950 node->condition = mutateExpression( node->condition );
951 mutateStatementList( node->stmts );
[4551a6e]952
[296b2be]953 MUTATE_END( Statement, node );
954}
955
[6ca154b]956//--------------------------------------------------------------------------
957// BranchStmt
[13932f14]958template< typename pass_type >
[ab904dc]959void PassVisitor< pass_type >::visit( BranchStmt * node ) {
[33c0ce8]960 VISIT_START( node );
961 VISIT_END( node );
[13932f14]962}
963
[6ca154b]964template< typename pass_type >
965Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
[33c0ce8]966 MUTATE_START( node );
967 MUTATE_END( Statement, node );
[6ca154b]968}
969
[9c1600c]970//--------------------------------------------------------------------------
971// ReturnStmt
[13932f14]972template< typename pass_type >
[ab904dc]973void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
[9c1600c]974 VISIT_START( node );
975
[e0886db]976 visitExpression( node->expr );
[9c1600c]977
978 VISIT_END( node );
[13932f14]979}
980
[296b2be]981template< typename pass_type >
982Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
983 MUTATE_START( node );
984
[e0886db]985 node->expr = mutateExpression( node->expr );
[296b2be]986
987 MUTATE_END( Statement, node );
988}
989
[6e09f211]990//--------------------------------------------------------------------------
991// ThrowStmt
992
993template< typename pass_type >
994void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
[33c0ce8]995 VISIT_START( node );
996
997 maybeAccept_impl( node->expr, *this );
998 maybeAccept_impl( node->target, *this );
999
1000 VISIT_END( node );
[6e09f211]1001}
1002
1003template< typename pass_type >
1004Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
[33c0ce8]1005 MUTATE_START( node );
1006
1007 maybeMutate_impl( node->expr, *this );
1008 maybeMutate_impl( node->target, *this );
1009
1010 MUTATE_END( Statement, node );
[6e09f211]1011}
1012
[9c1600c]1013//--------------------------------------------------------------------------
1014// TryStmt
[13932f14]1015template< typename pass_type >
[ab904dc]1016void PassVisitor< pass_type >::visit( TryStmt * node ) {
[9c1600c]1017 VISIT_START( node );
1018
[3c398b6]1019 maybeAccept_impl( node->block , *this );
1020 maybeAccept_impl( node->handlers , *this );
1021 maybeAccept_impl( node->finallyBlock, *this );
[9c1600c]1022
1023 VISIT_END( node );
[13932f14]1024}
1025
[296b2be]1026template< typename pass_type >
1027Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
1028 MUTATE_START( node );
1029
[3c398b6]1030 maybeMutate_impl( node->block , *this );
1031 maybeMutate_impl( node->handlers , *this );
1032 maybeMutate_impl( node->finallyBlock, *this );
[4551a6e]1033
[296b2be]1034 MUTATE_END( Statement, node );
1035}
1036
[9c1600c]1037//--------------------------------------------------------------------------
1038// CatchStmt
[13932f14]1039template< typename pass_type >
[ab904dc]1040void PassVisitor< pass_type >::visit( CatchStmt * node ) {
[9c1600c]1041 VISIT_START( node );
[e0886db]1042 {
[33a25f9]1043 // catch statements introduce a level of scope (for the caught exception)
[e0886db]1044 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1045 maybeAccept_impl( node->decl, *this );
[e0886db]1046 node->cond = visitExpression( node->cond );
1047 node->body = visitStatement ( node->body );
1048 }
[9c1600c]1049 VISIT_END( node );
[13932f14]1050}
1051
[296b2be]1052template< typename pass_type >
1053Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
1054 MUTATE_START( node );
[e0886db]1055 {
[33a25f9]1056 // catch statements introduce a level of scope (for the caught exception)
[e0886db]1057 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1058 maybeMutate_impl( node->decl, *this );
[e0886db]1059 node->cond = mutateExpression( node->cond );
1060 node->body = mutateStatement ( node->body );
1061 }
[296b2be]1062 MUTATE_END( Statement, node );
1063}
1064
[2065609]1065//--------------------------------------------------------------------------
1066// FinallyStmt
[13932f14]1067template< typename pass_type >
[ab904dc]1068void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
[11b7028]1069 VISIT_START( node );
1070
1071 maybeAccept_impl( node->block, *this );
1072
1073 VISIT_END( node );
[13932f14]1074}
1075
[2065609]1076template< typename pass_type >
1077Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
[11b7028]1078 MUTATE_START( node );
1079
1080 maybeMutate_impl( node->block, *this );
1081
1082 MUTATE_END( Statement, node );
[2065609]1083}
1084
1085//--------------------------------------------------------------------------
1086// WaitForStmt
1087template< typename pass_type >
1088void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
[834b892]1089 VISIT_START( node );
1090
1091 for( auto & clause : node->clauses ) {
1092 maybeAccept_impl( clause.target.function, *this );
1093 maybeAccept_impl( clause.target.arguments, *this );
1094
1095 maybeAccept_impl( clause.statement, *this );
1096 maybeAccept_impl( clause.condition, *this );
1097 }
1098
1099 maybeAccept_impl( node->timeout.time, *this );
1100 maybeAccept_impl( node->timeout.statement, *this );
1101 maybeAccept_impl( node->timeout.condition, *this );
1102 maybeAccept_impl( node->orelse.statement, *this );
1103 maybeAccept_impl( node->orelse.condition, *this );
1104
1105 VISIT_END( node );
[2065609]1106}
1107
1108template< typename pass_type >
1109Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
[834b892]1110 MUTATE_START( node );
1111
1112 for( auto & clause : node->clauses ) {
1113 maybeMutate_impl( clause.target.function, *this );
1114 maybeMutate_impl( clause.target.arguments, *this );
1115
1116 maybeMutate_impl( clause.statement, *this );
1117 maybeMutate_impl( clause.condition, *this );
1118 }
1119
1120 maybeMutate_impl( node->timeout.time, *this );
1121 maybeMutate_impl( node->timeout.statement, *this );
1122 maybeMutate_impl( node->timeout.condition, *this );
1123 maybeMutate_impl( node->orelse.statement, *this );
1124 maybeMutate_impl( node->orelse.condition, *this );
1125
1126 MUTATE_END( Statement, node );
[2065609]1127}
1128
[d8893ca]1129
1130
[61255ad]1131//--------------------------------------------------------------------------
1132// NullStmt
1133template< typename pass_type >
1134void PassVisitor< pass_type >::visit( WithStmt * node ) {
[d8893ca]1135 VISIT_START( node );
1136 maybeAccept_impl( node->exprs, *this );
1137 {
1138 // catch statements introduce a level of scope (for the caught exception)
1139 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]1140 indexerAddWith( node->exprs, node );
[d8893ca]1141 maybeAccept_impl( node->stmt, *this );
1142 }
1143 VISIT_END( node );
[61255ad]1144}
1145
1146template< typename pass_type >
1147Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
[d8893ca]1148 MUTATE_START( node );
1149 maybeMutate_impl( node->exprs, *this );
1150 {
1151 // catch statements introduce a level of scope (for the caught exception)
1152 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]1153 indexerAddWith( node->exprs, node );
[d8893ca]1154 maybeMutate_impl( node->stmt, *this );
1155 }
1156 MUTATE_END( Statement, node );
[61255ad]1157}
1158
[2065609]1159//--------------------------------------------------------------------------
1160// NullStmt
[13932f14]1161template< typename pass_type >
[ab904dc]1162void PassVisitor< pass_type >::visit( NullStmt * node ) {
[5964127]1163 VISIT_START( node );
1164 VISIT_END( node );
[13932f14]1165}
1166
[2065609]1167template< typename pass_type >
1168NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
[5964127]1169 MUTATE_START( node );
1170 MUTATE_END( NullStmt, node );
[2065609]1171}
1172
1173//--------------------------------------------------------------------------
1174// DeclStmt
[13932f14]1175template< typename pass_type >
[ab904dc]1176void PassVisitor< pass_type >::visit( DeclStmt * node ) {
[5964127]1177 VISIT_START( node );
1178
1179 maybeAccept_impl( node->decl, *this );
1180
1181 VISIT_END( node );
[13932f14]1182}
1183
[2065609]1184template< typename pass_type >
1185Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
[5964127]1186 MUTATE_START( node );
1187
1188 maybeMutate_impl( node->decl, *this );
1189
1190 MUTATE_END( Statement, node );
[2065609]1191}
1192
1193//--------------------------------------------------------------------------
1194// ImplicitCtorDtorStmt
[13932f14]1195template< typename pass_type >
[ab904dc]1196void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
[599fbb6]1197 VISIT_START( node );
1198
1199 maybeAccept_impl( node->callStmt, *this );
1200
1201 VISIT_END( node );
[13932f14]1202}
1203
[2065609]1204template< typename pass_type >
1205Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
[599fbb6]1206 MUTATE_START( node );
1207
1208 maybeMutate_impl( node->callStmt, *this );
1209
1210 MUTATE_END( Statement, node );
[2065609]1211}
1212
1213//--------------------------------------------------------------------------
1214// ApplicationExpr
[13932f14]1215template< typename pass_type >
[ab904dc]1216void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
[e0886db]1217 VISIT_START( node );
1218
1219 indexerScopedAccept( node->result , *this );
[3c398b6]1220 maybeAccept_impl ( node->function, *this );
1221 maybeAccept_impl ( node->args , *this );
[e0886db]1222
1223 VISIT_END( node );
[13932f14]1224}
1225
[2065609]1226template< typename pass_type >
1227Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
[e0886db]1228 MUTATE_START( node );
1229
1230 indexerScopedMutate( node->env , *this );
1231 indexerScopedMutate( node->result , *this );
[3c398b6]1232 maybeMutate_impl ( node->function, *this );
1233 maybeMutate_impl ( node->args , *this );
[e0886db]1234
1235 MUTATE_END( Expression, node );
[2065609]1236}
1237
[9c1600c]1238//--------------------------------------------------------------------------
1239// UntypedExpr
[13932f14]1240template< typename pass_type >
[ab904dc]1241void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
[9c1600c]1242 VISIT_START( node );
1243
[3c398b6]1244 // maybeAccept_impl( node->get_env(), *this );
[e0886db]1245 indexerScopedAccept( node->result, *this );
[2a7b3ca]1246
[e0886db]1247 for ( auto expr : node->args ) {
[9c1600c]1248 visitExpression( expr );
1249 }
1250
1251 VISIT_END( node );
[13932f14]1252}
1253
[296b2be]1254template< typename pass_type >
1255Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
1256 MUTATE_START( node );
1257
[e0886db]1258 indexerScopedMutate( node->env , *this );
1259 indexerScopedMutate( node->result, *this );
[2a7b3ca]1260
[e0886db]1261 for ( auto& expr : node->args ) {
[296b2be]1262 expr = mutateExpression( expr );
1263 }
1264
1265 MUTATE_END( Expression, node );
1266}
1267
[e0886db]1268//--------------------------------------------------------------------------
1269// NameExpr
[13932f14]1270template< typename pass_type >
[ab904dc]1271void PassVisitor< pass_type >::visit( NameExpr * node ) {
[e0886db]1272 VISIT_START( node );
1273
1274 indexerScopedAccept( node->result, *this );
1275
1276 VISIT_END( node );
[13932f14]1277}
1278
1279template< typename pass_type >
[e0886db]1280Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
1281 MUTATE_START( node );
1282
1283 indexerScopedMutate( node->env , *this );
1284 indexerScopedMutate( node->result, *this );
1285
1286 MUTATE_END( Expression, node );
[13932f14]1287}
1288
[e0886db]1289//--------------------------------------------------------------------------
1290// CastExpr
[a5f0529]1291template< typename pass_type >
[e0886db]1292void PassVisitor< pass_type >::visit( CastExpr * node ) {
1293 VISIT_START( node );
1294
1295 indexerScopedAccept( node->result, *this );
[3c398b6]1296 maybeAccept_impl ( node->arg , *this );
[e0886db]1297
1298 VISIT_END( node );
[a5f0529]1299}
1300
[13932f14]1301template< typename pass_type >
[e0886db]1302Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
1303 MUTATE_START( node );
1304
1305 indexerScopedMutate( node->env , *this );
1306 indexerScopedMutate( node->result, *this );
[3c398b6]1307 maybeMutate_impl ( node->arg , *this );
[e0886db]1308
1309 MUTATE_END( Expression, node );
[13932f14]1310}
1311
[e0886db]1312//--------------------------------------------------------------------------
[9a705dc8]1313// KeywordCastExpr
1314template< typename pass_type >
1315void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
1316 VISIT_START( node );
1317
1318 indexerScopedAccept( node->result, *this );
1319 maybeAccept_impl ( node->arg , *this );
1320
1321 VISIT_END( node );
1322}
1323
1324template< typename pass_type >
1325Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
1326 MUTATE_START( node );
1327
1328 indexerScopedMutate( node->env , *this );
1329 indexerScopedMutate( node->result, *this );
1330 maybeMutate_impl ( node->arg , *this );
1331
1332 MUTATE_END( Expression, node );
1333}
1334
1335//--------------------------------------------------------------------------
[e0886db]1336// VirtualCastExpr
[13932f14]1337template< typename pass_type >
[e0886db]1338void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
1339 VISIT_START( node );
1340
1341 indexerScopedAccept( node->result, *this );
[3c398b6]1342 maybeAccept_impl( node->arg, *this );
[e0886db]1343
1344 VISIT_END( node );
[13932f14]1345}
1346
1347template< typename pass_type >
[e0886db]1348Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
1349 MUTATE_START( node );
1350
1351 indexerScopedMutate( node->env , *this );
1352 indexerScopedMutate( node->result, *this );
[3c398b6]1353 maybeMutate_impl ( node->arg , *this );
[e0886db]1354
1355 MUTATE_END( Expression, node );
[13932f14]1356}
1357
[e0886db]1358//--------------------------------------------------------------------------
1359// AddressExpr
[13932f14]1360template< typename pass_type >
[e0886db]1361void PassVisitor< pass_type >::visit( AddressExpr * node ) {
1362 VISIT_START( node );
1363
1364 indexerScopedAccept( node->result, *this );
[3c398b6]1365 maybeAccept_impl ( node->arg , *this );
[e0886db]1366
1367 VISIT_END( node );
[13932f14]1368}
1369
1370template< typename pass_type >
[e0886db]1371Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
1372 MUTATE_START( node );
1373
1374 indexerScopedMutate( node->env , *this );
1375 indexerScopedMutate( node->result, *this );
[3c398b6]1376 maybeMutate_impl ( node->arg , *this );
[e0886db]1377
1378 MUTATE_END( Expression, node );
1379}
1380
1381//--------------------------------------------------------------------------
1382// LabelAddressExpr
1383template< typename pass_type >
1384void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
1385 VISIT_START( node );
1386
1387 indexerScopedAccept( node->result, *this );
1388
1389 VISIT_END( node );
1390}
1391
1392template< typename pass_type >
1393Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
1394 MUTATE_START( node );
1395
1396 indexerScopedMutate( node->env , *this );
1397 indexerScopedMutate( node->result, *this );
1398
1399 MUTATE_END( Expression, node );
1400}
1401
1402//--------------------------------------------------------------------------
1403// UntypedMemberExpr
1404template< typename pass_type >
1405void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
1406 VISIT_START( node );
1407
1408 indexerScopedAccept( node->result , *this );
[3c398b6]1409 maybeAccept_impl ( node->aggregate, *this );
1410 maybeAccept_impl ( node->member , *this );
[e0886db]1411
1412 VISIT_END( node );
[13932f14]1413}
1414
[e0886db]1415template< typename pass_type >
1416Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
1417 MUTATE_START( node );
1418
1419 indexerScopedMutate( node->env , *this );
1420 indexerScopedMutate( node->result , *this );
[3c398b6]1421 maybeMutate_impl ( node->aggregate, *this );
1422 maybeMutate_impl ( node->member , *this );
[e0886db]1423
1424 MUTATE_END( Expression, node );
1425}
1426
1427//--------------------------------------------------------------------------
1428// MemberExpr
1429template< typename pass_type >
1430void PassVisitor< pass_type >::visit( MemberExpr * node ) {
1431 VISIT_START( node );
1432
1433 indexerScopedAccept( node->result , *this );
[3c398b6]1434 maybeAccept_impl ( node->aggregate, *this );
[e0886db]1435
1436 VISIT_END( node );
1437}
1438
1439template< typename pass_type >
1440Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
1441 MUTATE_START( node );
1442
1443 indexerScopedMutate( node->env , *this );
1444 indexerScopedMutate( node->result , *this );
[3c398b6]1445 maybeMutate_impl ( node->aggregate, *this );
[e0886db]1446
1447 MUTATE_END( Expression, node );
1448}
1449
1450//--------------------------------------------------------------------------
1451// VariableExpr
1452template< typename pass_type >
1453void PassVisitor< pass_type >::visit( VariableExpr * node ) {
1454 VISIT_START( node );
1455
1456 indexerScopedAccept( node->result, *this );
1457
1458 VISIT_END( node );
1459}
1460
1461template< typename pass_type >
1462Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
1463 MUTATE_START( node );
1464
1465 indexerScopedMutate( node->env , *this );
1466 indexerScopedMutate( node->result, *this );
1467
1468 MUTATE_END( Expression, node );
1469}
1470
1471//--------------------------------------------------------------------------
1472// ConstantExpr
[13932f14]1473template< typename pass_type >
[ab904dc]1474void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
[e0886db]1475 VISIT_START( node );
1476
1477 indexerScopedAccept( node->result , *this );
[3c398b6]1478 maybeAccept_impl ( &node->constant, *this );
[e0886db]1479
1480 VISIT_END( node );
[13932f14]1481}
1482
[e0886db]1483template< typename pass_type >
1484Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
1485 MUTATE_START( node );
1486
1487 indexerScopedMutate( node->env , *this );
1488 indexerScopedMutate( node->result, *this );
[3c398b6]1489 Constant * ptr = &node->constant;
1490 maybeMutate_impl( ptr, *this );
1491 node->constant = *ptr;
[e0886db]1492
1493 MUTATE_END( Expression, node );
1494}
1495
1496//--------------------------------------------------------------------------
1497// SizeofExpr
[13932f14]1498template< typename pass_type >
[ab904dc]1499void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
[e0886db]1500 VISIT_START( node );
1501
1502 indexerScopedAccept( node->result, *this );
1503 if ( node->get_isType() ) {
[3c398b6]1504 maybeAccept_impl( node->type, *this );
[e0886db]1505 } else {
[3c398b6]1506 maybeAccept_impl( node->expr, *this );
[e0886db]1507 }
1508
1509 VISIT_END( node );
[13932f14]1510}
1511
[e0886db]1512template< typename pass_type >
1513Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
1514 MUTATE_START( node );
1515
1516 indexerScopedMutate( node->env , *this );
1517 indexerScopedMutate( node->result, *this );
1518 if ( node->get_isType() ) {
[3c398b6]1519 maybeMutate_impl( node->type, *this );
[e0886db]1520 } else {
[3c398b6]1521 maybeMutate_impl( node->expr, *this );
[e0886db]1522 }
1523
1524 MUTATE_END( Expression, node );
1525}
1526
1527//--------------------------------------------------------------------------
1528// AlignofExpr
[13932f14]1529template< typename pass_type >
[ab904dc]1530void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
[e0886db]1531 VISIT_START( node );
1532
1533 indexerScopedAccept( node->result, *this );
1534 if ( node->get_isType() ) {
[3c398b6]1535 maybeAccept_impl( node->type, *this );
[e0886db]1536 } else {
[3c398b6]1537 maybeAccept_impl( node->expr, *this );
[e0886db]1538 }
1539
1540 VISIT_END( node );
[13932f14]1541}
1542
[e0886db]1543template< typename pass_type >
1544Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
1545 MUTATE_START( node );
1546
1547 indexerScopedMutate( node->env , *this );
1548 indexerScopedMutate( node->result, *this );
1549 if ( node->get_isType() ) {
[3c398b6]1550 maybeMutate_impl( node->type, *this );
[e0886db]1551 } else {
[3c398b6]1552 maybeMutate_impl( node->expr, *this );
[e0886db]1553 }
1554
1555 MUTATE_END( Expression, node );
1556}
1557
1558//--------------------------------------------------------------------------
1559// UntypedOffsetofExpr
[13932f14]1560template< typename pass_type >
[ab904dc]1561void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
[e0886db]1562 VISIT_START( node );
1563
1564 indexerScopedAccept( node->result, *this );
[3c398b6]1565 maybeAccept_impl ( node->type , *this );
[e0886db]1566
1567 VISIT_END( node );
[13932f14]1568}
1569
[e0886db]1570template< typename pass_type >
1571Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
1572 MUTATE_START( node );
1573
1574 indexerScopedMutate( node->env , *this );
1575 indexerScopedMutate( node->result, *this );
[3c398b6]1576 maybeMutate_impl ( node->type , *this );
[e0886db]1577
1578 MUTATE_END( Expression, node );
1579}
1580
1581//--------------------------------------------------------------------------
1582// OffsetofExpr
[13932f14]1583template< typename pass_type >
[ab904dc]1584void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
[e0886db]1585 VISIT_START( node );
1586
1587 indexerScopedAccept( node->result, *this );
[3c398b6]1588 maybeAccept_impl ( node->type , *this );
[e0886db]1589
1590 VISIT_END( node );
[13932f14]1591}
1592
[e0886db]1593template< typename pass_type >
1594Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
1595 MUTATE_START( node );
1596
1597 indexerScopedMutate( node->env , *this );
1598 indexerScopedMutate( node->result, *this );
[3c398b6]1599 maybeMutate_impl ( node->type , *this );
[e0886db]1600
1601 MUTATE_END( Expression, node );
1602}
1603
1604//--------------------------------------------------------------------------
1605// OffsetPackExpr
[13932f14]1606template< typename pass_type >
[ab904dc]1607void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
[e0886db]1608 VISIT_START( node );
1609
1610 indexerScopedAccept( node->result, *this );
[3c398b6]1611 maybeAccept_impl ( node->type , *this );
[e0886db]1612
1613 VISIT_END( node );
[13932f14]1614}
1615
[e0886db]1616template< typename pass_type >
1617Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
1618 MUTATE_START( node );
1619
1620 indexerScopedMutate( node->env , *this );
1621 indexerScopedMutate( node->result, *this );
[3c398b6]1622 maybeMutate_impl ( node->type , *this );
[e0886db]1623
1624 MUTATE_END( Expression, node );
1625}
1626
1627//--------------------------------------------------------------------------
1628// AttrExpr
[13932f14]1629template< typename pass_type >
[ab904dc]1630void PassVisitor< pass_type >::visit( AttrExpr * node ) {
[e0886db]1631 VISIT_START( node );
1632
1633 indexerScopedAccept( node->result, *this );
1634 if ( node->get_isType() ) {
[3c398b6]1635 maybeAccept_impl( node->type, *this );
[e0886db]1636 } else {
[3c398b6]1637 maybeAccept_impl( node->expr, *this );
[e0886db]1638 }
1639
1640 VISIT_END( node );
1641}
1642
1643template< typename pass_type >
1644Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
1645 MUTATE_START( node );
1646
1647 indexerScopedMutate( node->env , *this );
1648 indexerScopedMutate( node->result, *this );
1649 if ( node->get_isType() ) {
[3c398b6]1650 maybeMutate_impl( node->type, *this );
[e0886db]1651 } else {
[3c398b6]1652 maybeMutate_impl( node->expr, *this );
[e0886db]1653 }
1654
1655 MUTATE_END( Expression, node );
[13932f14]1656}
1657
[e0886db]1658//--------------------------------------------------------------------------
1659// LogicalExpr
[13932f14]1660template< typename pass_type >
[ab904dc]1661void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
[e0886db]1662 VISIT_START( node );
1663
1664 indexerScopedAccept( node->result, *this );
[3c398b6]1665 maybeAccept_impl ( node->arg1 , *this );
1666 maybeAccept_impl ( node->arg2 , *this );
[e0886db]1667
1668 VISIT_END( node );
1669}
1670
1671template< typename pass_type >
1672Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
1673 MUTATE_START( node );
1674
1675 indexerScopedMutate( node->env , *this );
1676 indexerScopedMutate( node->result, *this );
[3c398b6]1677 maybeMutate_impl ( node->arg1 , *this );
1678 maybeMutate_impl ( node->arg2 , *this );
[e0886db]1679
1680 MUTATE_END( Expression, node );
[13932f14]1681}
1682
[e0886db]1683//--------------------------------------------------------------------------
1684// ConditionalExpr
[13932f14]1685template< typename pass_type >
[ab904dc]1686void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
[e0886db]1687 VISIT_START( node );
1688
1689 indexerScopedAccept( node->result, *this );
[3c398b6]1690 maybeAccept_impl ( node->arg1 , *this );
1691 maybeAccept_impl ( node->arg2 , *this );
1692 maybeAccept_impl ( node->arg3 , *this );
[e0886db]1693
1694 VISIT_END( node );
[13932f14]1695}
1696
[e0886db]1697template< typename pass_type >
1698Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
1699 MUTATE_START( node );
1700
1701 indexerScopedMutate( node->env , *this );
1702 indexerScopedMutate( node->result, *this );
[3c398b6]1703 maybeMutate_impl ( node->arg1 , *this );
1704 maybeMutate_impl ( node->arg2 , *this );
1705 maybeMutate_impl ( node->arg3 , *this );
[e0886db]1706
1707 MUTATE_END( Expression, node );
1708}
1709
1710//--------------------------------------------------------------------------
1711// CommaExpr
[13932f14]1712template< typename pass_type >
[ab904dc]1713void PassVisitor< pass_type >::visit( CommaExpr * node ) {
[e0886db]1714 VISIT_START( node );
1715
1716 indexerScopedAccept( node->result, *this );
[3c398b6]1717 maybeAccept_impl ( node->arg1 , *this );
1718 maybeAccept_impl ( node->arg2 , *this );
[e0886db]1719
1720 VISIT_END( node );
1721}
1722
1723template< typename pass_type >
1724Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
1725 MUTATE_START( node );
1726
1727 indexerScopedMutate( node->env , *this );
1728 indexerScopedMutate( node->result, *this );
[3c398b6]1729 maybeMutate_impl ( node->arg1 , *this );
1730 maybeMutate_impl ( node->arg2 , *this );
[e0886db]1731
1732 MUTATE_END( Expression, node );
[13932f14]1733}
1734
[e0886db]1735//--------------------------------------------------------------------------
1736// TypeExpr
[13932f14]1737template< typename pass_type >
[ab904dc]1738void PassVisitor< pass_type >::visit( TypeExpr * node ) {
[e0886db]1739 VISIT_START( node );
1740
1741 indexerScopedAccept( node->result, *this );
[3c398b6]1742 maybeAccept_impl ( node->type, *this );
[e0886db]1743
1744 VISIT_END( node );
[13932f14]1745}
1746
[e0886db]1747template< typename pass_type >
1748Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
1749 MUTATE_START( node );
1750
1751 indexerScopedMutate( node->env , *this );
1752 indexerScopedMutate( node->result, *this );
[3c398b6]1753 maybeMutate_impl ( node->type , *this );
[e0886db]1754
1755 MUTATE_END( Expression, node );
1756}
1757
1758//--------------------------------------------------------------------------
1759// AsmExpr
[13932f14]1760template< typename pass_type >
[ab904dc]1761void PassVisitor< pass_type >::visit( AsmExpr * node ) {
[e0886db]1762 VISIT_START( node );
1763
1764 indexerScopedAccept( node->result , *this );
[3c398b6]1765 maybeAccept_impl ( node->inout , *this );
1766 maybeAccept_impl ( node->constraint, *this );
1767 maybeAccept_impl ( node->operand , *this );
[e0886db]1768
1769 VISIT_END( node );
[13932f14]1770}
1771
[e0886db]1772template< typename pass_type >
1773Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
1774 MUTATE_START( node );
1775
1776 indexerScopedMutate( node->env , *this );
1777 indexerScopedMutate( node->result , *this );
[3c398b6]1778 maybeMutate_impl ( node->inout , *this );
1779 maybeMutate_impl ( node->constraint, *this );
1780 maybeMutate_impl ( node->operand , *this );
[e0886db]1781
1782 MUTATE_END( Expression, node );
1783}
1784
1785//--------------------------------------------------------------------------
1786// ImplicitCopyCtorExpr
[13932f14]1787template< typename pass_type >
[ab904dc]1788void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
[e0886db]1789 VISIT_START( node );
1790
[2f86ddf]1791 indexerScopedAccept( node->result , *this );
1792 maybeAccept_impl ( node->callExpr , *this );
[e0886db]1793
1794 VISIT_END( node );
1795}
1796
1797template< typename pass_type >
1798Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
1799 MUTATE_START( node );
1800
[2f86ddf]1801 indexerScopedMutate( node->env , *this );
1802 indexerScopedMutate( node->result , *this );
1803 maybeMutate_impl ( node->callExpr , *this );
[e0886db]1804
1805 MUTATE_END( Expression, node );
[13932f14]1806}
1807
[e0886db]1808//--------------------------------------------------------------------------
1809// ConstructorExpr
[13932f14]1810template< typename pass_type >
[ab904dc]1811void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
[e0886db]1812 VISIT_START( node );
1813
1814 indexerScopedAccept( node->result , *this );
[3c398b6]1815 maybeAccept_impl ( node->callExpr, *this );
[e0886db]1816
1817 VISIT_END( node );
1818}
1819
1820template< typename pass_type >
1821Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
1822 MUTATE_START( node );
1823
1824 indexerScopedMutate( node->env , *this );
1825 indexerScopedMutate( node->result , *this );
[3c398b6]1826 maybeMutate_impl ( node->callExpr, *this );
[e0886db]1827
1828 MUTATE_END( Expression, node );
[13932f14]1829}
1830
[e0886db]1831//--------------------------------------------------------------------------
1832// CompoundLiteralExpr
[13932f14]1833template< typename pass_type >
[ab904dc]1834void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
[e0886db]1835 VISIT_START( node );
1836
1837 indexerScopedAccept( node->result , *this );
[3c398b6]1838 maybeAccept_impl ( node->initializer, *this );
[e0886db]1839
1840 VISIT_END( node );
[13932f14]1841}
1842
[e0886db]1843template< typename pass_type >
1844Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
1845 MUTATE_START( node );
1846
1847 indexerScopedMutate( node->env , *this );
1848 indexerScopedMutate( node->result , *this );
[3c398b6]1849 maybeMutate_impl ( node->initializer, *this );
[e0886db]1850
1851 MUTATE_END( Expression, node );
1852}
1853
1854//--------------------------------------------------------------------------
1855// RangeExpr
[13932f14]1856template< typename pass_type >
[ab904dc]1857void PassVisitor< pass_type >::visit( RangeExpr * node ) {
[e0886db]1858 VISIT_START( node );
1859
1860 indexerScopedAccept( node->result, *this );
[3c398b6]1861 maybeAccept_impl ( node->low , *this );
1862 maybeAccept_impl ( node->high , *this );
[e0886db]1863
1864 VISIT_END( node );
[13932f14]1865}
1866
[e0886db]1867template< typename pass_type >
1868Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
1869 MUTATE_START( node );
1870
1871 indexerScopedMutate( node->env , *this );
1872 indexerScopedMutate( node->result, *this );
[3c398b6]1873 maybeMutate_impl ( node->low , *this );
1874 maybeMutate_impl ( node->high , *this );
[e0886db]1875
1876 MUTATE_END( Expression, node );
1877}
1878
1879//--------------------------------------------------------------------------
1880// UntypedTupleExpr
[13932f14]1881template< typename pass_type >
[ab904dc]1882void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
[e0886db]1883 VISIT_START( node );
1884
1885 indexerScopedAccept( node->result, *this );
[3c398b6]1886 maybeAccept_impl ( node->exprs , *this );
[e0886db]1887
1888 VISIT_END( node );
1889}
1890
1891template< typename pass_type >
1892Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
1893 MUTATE_START( node );
1894
1895 indexerScopedMutate( node->env , *this );
1896 indexerScopedMutate( node->result, *this );
[3c398b6]1897 maybeMutate_impl ( node->exprs , *this );
[e0886db]1898
1899 MUTATE_END( Expression, node );
1900}
1901
1902//--------------------------------------------------------------------------
1903// TupleExpr
1904template< typename pass_type >
1905void PassVisitor< pass_type >::visit( TupleExpr * node ) {
1906 VISIT_START( node );
1907
1908 indexerScopedAccept( node->result, *this );
[3c398b6]1909 maybeAccept_impl ( node->exprs , *this );
[e0886db]1910
1911 VISIT_END( node );
1912}
1913
1914template< typename pass_type >
1915Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
1916 MUTATE_START( node );
1917
1918 indexerScopedMutate( node->env , *this );
1919 indexerScopedMutate( node->result, *this );
[3c398b6]1920 maybeMutate_impl ( node->exprs , *this );
[e0886db]1921
1922 MUTATE_END( Expression, node );
1923}
1924
1925//--------------------------------------------------------------------------
1926// TupleIndexExpr
1927template< typename pass_type >
1928void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
1929 VISIT_START( node );
1930
1931 indexerScopedAccept( node->result, *this );
[3c398b6]1932 maybeAccept_impl ( node->tuple , *this );
[e0886db]1933
1934 VISIT_END( node );
1935}
1936
1937template< typename pass_type >
1938Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
1939 MUTATE_START( node );
1940
1941 indexerScopedMutate( node->env , *this );
1942 indexerScopedMutate( node->result, *this );
[3c398b6]1943 maybeMutate_impl ( node->tuple , *this );
[e0886db]1944
1945 MUTATE_END( Expression, node );
1946}
1947
1948//--------------------------------------------------------------------------
1949// TupleAssignExpr
1950template< typename pass_type >
1951void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
1952 VISIT_START( node );
1953
1954 indexerScopedAccept( node->result , *this );
[3c398b6]1955 maybeAccept_impl ( node->stmtExpr, *this );
[e0886db]1956
1957 VISIT_END( node );
[13932f14]1958}
1959
1960template< typename pass_type >
[e0886db]1961Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
1962 MUTATE_START( node );
[13932f14]1963
[e0886db]1964 indexerScopedMutate( node->env , *this );
1965 indexerScopedMutate( node->result , *this );
[3c398b6]1966 maybeMutate_impl ( node->stmtExpr, *this );
[13932f14]1967
[e0886db]1968 MUTATE_END( Expression, node );
[13932f14]1969}
1970
[9c1600c]1971//--------------------------------------------------------------------------
[e0886db]1972// StmtExpr
[13932f14]1973template< typename pass_type >
[ab904dc]1974void PassVisitor< pass_type >::visit( StmtExpr * node ) {
[9c1600c]1975 VISIT_START( node );
1976
1977 // don't want statements from outer CompoundStmts to be added to this StmtExpr
[02fdb8e]1978 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
[9c1600c]1979 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1980 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
1981
[e0886db]1982 indexerScopedAccept( node->result , *this );
[3c398b6]1983 maybeAccept_impl ( node->statements , *this );
1984 maybeAccept_impl ( node->returnDecls, *this );
1985 maybeAccept_impl ( node->dtors , *this );
[9c1600c]1986
1987 VISIT_END( node );
[13932f14]1988}
1989
[296b2be]1990template< typename pass_type >
1991Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
1992 MUTATE_START( node );
[4551a6e]1993
[296b2be]1994 // don't want statements from outer CompoundStmts to be added to this StmtExpr
[02fdb8e]1995 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
[134322e]1996 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1997 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
[296b2be]1998
[e0886db]1999 indexerScopedMutate( node->result , *this );
[3c398b6]2000 maybeMutate_impl ( node->statements , *this );
2001 maybeMutate_impl ( node->returnDecls, *this );
2002 maybeMutate_impl ( node->dtors , *this );
[296b2be]2003
2004 MUTATE_END( Expression, node );
2005}
2006
[e0886db]2007//--------------------------------------------------------------------------
2008// UniqueExpr
[13932f14]2009template< typename pass_type >
[ab904dc]2010void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
[e0886db]2011 VISIT_START( node );
2012
2013 indexerScopedAccept( node->result, *this );
[3c398b6]2014 maybeAccept_impl ( node->expr , *this );
[e0886db]2015
2016 VISIT_END( node );
2017}
2018
2019template< typename pass_type >
2020Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
2021 MUTATE_START( node );
2022
2023 indexerScopedMutate( node->env , *this );
2024 indexerScopedMutate( node->result, *this );
[3c398b6]2025 maybeMutate_impl ( node->expr , *this );
[e0886db]2026
2027 MUTATE_END( Expression, node );
[13932f14]2028}
2029
[73367a8]2030//--------------------------------------------------------------------------
2031// UntypedInitExpr
2032template< typename pass_type >
2033void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
2034 VISIT_START( node );
2035
2036 indexerScopedAccept( node->result, *this );
2037 maybeAccept_impl ( node->expr , *this );
2038 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2039
2040 VISIT_END( node );
2041}
2042
2043template< typename pass_type >
2044Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
2045 MUTATE_START( node );
2046
2047 indexerScopedMutate( node->env , *this );
2048 indexerScopedMutate( node->result, *this );
2049 maybeMutate_impl ( node->expr , *this );
2050 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2051
2052 MUTATE_END( Expression, node );
2053}
2054
2055//--------------------------------------------------------------------------
2056// InitExpr
2057template< typename pass_type >
2058void PassVisitor< pass_type >::visit( InitExpr * node ) {
2059 VISIT_START( node );
2060
2061 indexerScopedAccept( node->result, *this );
2062 maybeAccept_impl ( node->expr , *this );
2063 maybeAccept_impl ( node->designation, *this );
2064
2065 VISIT_END( node );
2066}
2067
2068template< typename pass_type >
2069Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
2070 MUTATE_START( node );
2071
2072 indexerScopedMutate( node->env , *this );
2073 indexerScopedMutate( node->result, *this );
2074 maybeMutate_impl ( node->expr , *this );
2075 maybeMutate_impl ( node->designation, *this );
2076
2077 MUTATE_END( Expression, node );
2078}
2079
[44b4114]2080//--------------------------------------------------------------------------
2081// DeletedExpr
2082template< typename pass_type >
2083void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
2084 VISIT_START( node );
2085
2086 indexerScopedAccept( node->result, *this );
2087 maybeAccept_impl( node->expr, *this );
2088 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
2089
2090 VISIT_END( node );
2091}
2092
2093template< typename pass_type >
2094Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
2095 MUTATE_START( node );
2096
2097 indexerScopedMutate( node->env, *this );
2098 indexerScopedMutate( node->result, *this );
2099 maybeMutate_impl( node->expr, *this );
2100
2101 MUTATE_END( Expression, node );
2102}
2103
[0f79853]2104//--------------------------------------------------------------------------
2105// DefaultArgExpr
2106template< typename pass_type >
2107void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) {
2108 VISIT_START( node );
2109
2110 indexerScopedAccept( node->result, *this );
2111 maybeAccept_impl( node->expr, *this );
2112
2113 VISIT_END( node );
2114}
2115
2116template< typename pass_type >
2117Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) {
2118 MUTATE_START( node );
2119
2120 indexerScopedMutate( node->env, *this );
2121 indexerScopedMutate( node->result, *this );
2122 maybeMutate_impl( node->expr, *this );
2123
2124 MUTATE_END( Expression, node );
2125}
2126
[d807ca28]2127//--------------------------------------------------------------------------
2128// GenericExpr
2129template< typename pass_type >
2130void PassVisitor< pass_type >::visit( GenericExpr * node ) {
2131 VISIT_START( node );
2132
2133 indexerScopedAccept( node->result, *this );
2134 maybeAccept_impl( node->control, *this );
2135 for ( GenericExpr::Association & assoc : node->associations ) {
2136 indexerScopedAccept( assoc.type, *this );
2137 maybeAccept_impl( assoc.expr, *this );
2138 }
2139
2140 VISIT_END( node );
2141}
2142
2143template< typename pass_type >
2144Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) {
2145 MUTATE_START( node );
2146
2147 indexerScopedMutate( node->env, *this );
2148 indexerScopedMutate( node->result, *this );
2149 maybeMutate_impl( node->control, *this );
2150 for ( GenericExpr::Association & assoc : node->associations ) {
2151 indexerScopedMutate( assoc.type, *this );
2152 maybeMutate_impl( assoc.expr, *this );
2153 }
2154
2155 MUTATE_END( Expression, node );
2156}
2157
[17fc7a5]2158//--------------------------------------------------------------------------
2159// VoidType
[13932f14]2160template< typename pass_type >
[ab904dc]2161void PassVisitor< pass_type >::visit( VoidType * node ) {
[599fbb6]2162 VISIT_START( node );
2163
2164 maybeAccept_impl( node->forall, *this );
2165
2166 VISIT_END( node );
2167}
2168
2169template< typename pass_type >
2170Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
2171 MUTATE_START( node );
2172
2173 maybeMutate_impl( node->forall, *this );
2174
2175 MUTATE_END( Type, node );
[13932f14]2176}
2177
[17fc7a5]2178//--------------------------------------------------------------------------
2179// BasicType
[13932f14]2180template< typename pass_type >
[ab904dc]2181void PassVisitor< pass_type >::visit( BasicType * node ) {
[17fc7a5]2182 VISIT_START( node );
2183
2184 maybeAccept_impl( node->forall, *this );
2185
2186 VISIT_END( node );
2187}
2188
2189template< typename pass_type >
2190Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
2191 MUTATE_START( node );
2192
2193 maybeMutate_impl( node->forall, *this );
2194
2195 MUTATE_END( Type, node );
[13932f14]2196}
2197
[17fc7a5]2198//--------------------------------------------------------------------------
2199// PointerType
[13932f14]2200template< typename pass_type >
[ab904dc]2201void PassVisitor< pass_type >::visit( PointerType * node ) {
[17fc7a5]2202 VISIT_START( node );
2203
2204 maybeAccept_impl( node->forall, *this );
[cfaf9be]2205 // xxx - should PointerType visit/mutate dimension?
[17fc7a5]2206 maybeAccept_impl( node->base, *this );
2207
2208 VISIT_END( node );
[13932f14]2209}
2210
[17fc7a5]2211template< typename pass_type >
2212Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
2213 MUTATE_START( node );
2214
2215 maybeMutate_impl( node->forall, *this );
[cfaf9be]2216 // xxx - should PointerType visit/mutate dimension?
[17fc7a5]2217 maybeMutate_impl( node->base, *this );
2218
2219 MUTATE_END( Type, node );
2220}
2221
2222//--------------------------------------------------------------------------
2223// ArrayType
[13932f14]2224template< typename pass_type >
[ab904dc]2225void PassVisitor< pass_type >::visit( ArrayType * node ) {
[17fc7a5]2226 VISIT_START( node );
2227
2228 maybeAccept_impl( node->forall, *this );
2229 maybeAccept_impl( node->dimension, *this );
2230 maybeAccept_impl( node->base, *this );
2231
2232 VISIT_END( node );
[13932f14]2233}
2234
[17fc7a5]2235template< typename pass_type >
2236Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
2237 MUTATE_START( node );
2238
2239 maybeMutate_impl( node->forall, *this );
2240 maybeMutate_impl( node->dimension, *this );
2241 maybeMutate_impl( node->base, *this );
2242
2243 MUTATE_END( Type, node );
2244}
2245
2246//--------------------------------------------------------------------------
2247// ReferenceType
[6b9b047]2248template< typename pass_type >
2249void PassVisitor< pass_type >::visit( ReferenceType * node ) {
[17fc7a5]2250 VISIT_START( node );
2251
2252 maybeAccept_impl( node->forall, *this );
2253 maybeAccept_impl( node->base, *this );
2254
2255 VISIT_END( node );
2256}
2257
2258template< typename pass_type >
2259Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
2260 MUTATE_START( node );
2261
2262 maybeMutate_impl( node->forall, *this );
2263 maybeMutate_impl( node->base, *this );
2264
2265 MUTATE_END( Type, node );
[6b9b047]2266}
2267
[c5d7701]2268//--------------------------------------------------------------------------
2269// QualifiedType
2270template< typename pass_type >
2271void PassVisitor< pass_type >::visit( QualifiedType * node ) {
2272 VISIT_START( node );
2273
2274 maybeAccept_impl( node->forall, *this );
[c194661]2275 maybeAccept_impl( node->parent, *this );
2276 maybeAccept_impl( node->child, *this );
[c5d7701]2277
2278 VISIT_END( node );
2279}
2280
2281template< typename pass_type >
2282Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) {
2283 MUTATE_START( node );
2284
2285 maybeMutate_impl( node->forall, *this );
[c194661]2286 maybeMutate_impl( node->parent, *this );
2287 maybeMutate_impl( node->child, *this );
[c5d7701]2288
2289 MUTATE_END( Type, node );
2290}
2291
[17fc7a5]2292//--------------------------------------------------------------------------
2293// FunctionType
[13932f14]2294template< typename pass_type >
[ab904dc]2295void PassVisitor< pass_type >::visit( FunctionType * node ) {
[17fc7a5]2296 VISIT_START( node );
2297
2298 maybeAccept_impl( node->forall, *this );
2299 maybeAccept_impl( node->returnVals, *this );
2300 maybeAccept_impl( node->parameters, *this );
2301
2302 VISIT_END( node );
2303}
2304
2305template< typename pass_type >
2306Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
2307 MUTATE_START( node );
2308
2309 maybeMutate_impl( node->forall, *this );
2310 maybeMutate_impl( node->returnVals, *this );
2311 maybeMutate_impl( node->parameters, *this );
2312
2313 MUTATE_END( Type, node );
[13932f14]2314}
2315
[e0886db]2316//--------------------------------------------------------------------------
2317// StructInstType
[13932f14]2318template< typename pass_type >
[ab904dc]2319void PassVisitor< pass_type >::visit( StructInstType * node ) {
[e0886db]2320 VISIT_START( node );
2321
2322 indexerAddStruct( node->name );
2323
2324 {
2325 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2326 maybeAccept_impl( node->forall , *this );
2327 maybeAccept_impl( node->parameters, *this );
[e0886db]2328 }
2329
2330 VISIT_END( node );
2331}
2332
2333template< typename pass_type >
2334Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
2335 MUTATE_START( node );
2336
2337 indexerAddStruct( node->name );
2338
2339 {
2340 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2341 maybeMutate_impl( node->forall , *this );
2342 maybeMutate_impl( node->parameters, *this );
[e0886db]2343 }
2344
2345 MUTATE_END( Type, node );
[13932f14]2346}
2347
[e0886db]2348//--------------------------------------------------------------------------
2349// UnionInstType
[13932f14]2350template< typename pass_type >
[ab904dc]2351void PassVisitor< pass_type >::visit( UnionInstType * node ) {
[e0886db]2352 VISIT_START( node );
2353
2354 indexerAddStruct( node->name );
2355
2356 {
2357 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2358 maybeAccept_impl( node->forall , *this );
2359 maybeAccept_impl( node->parameters, *this );
[e0886db]2360 }
2361
2362 VISIT_END( node );
2363}
2364
2365template< typename pass_type >
2366Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
2367 MUTATE_START( node );
2368
2369 indexerAddStruct( node->name );
2370
2371 {
2372 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2373 maybeMutate_impl( node->forall , *this );
2374 maybeMutate_impl( node->parameters, *this );
[e0886db]2375 }
2376
2377 MUTATE_END( Type, node );
[13932f14]2378}
2379
[e0886db]2380//--------------------------------------------------------------------------
2381// EnumInstType
[13932f14]2382template< typename pass_type >
[ab904dc]2383void PassVisitor< pass_type >::visit( EnumInstType * node ) {
[86e84e4]2384 VISIT_START( node );
2385
2386 maybeAccept_impl( node->forall, *this );
2387 maybeAccept_impl( node->parameters, *this );
2388
2389 VISIT_END( node );
[13932f14]2390}
2391
[e0886db]2392template< typename pass_type >
2393Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
[86e84e4]2394 MUTATE_START( node );
2395
2396 maybeMutate_impl( node->forall, *this );
2397 maybeMutate_impl( node->parameters, *this );
2398
2399 MUTATE_END( Type, node );
[e0886db]2400}
2401
2402//--------------------------------------------------------------------------
2403// TraitInstType
[13932f14]2404template< typename pass_type >
[ab904dc]2405void PassVisitor< pass_type >::visit( TraitInstType * node ) {
[e0886db]2406 VISIT_START( node );
2407
[3c398b6]2408 maybeAccept_impl( node->forall , *this );
2409 maybeAccept_impl( node->parameters, *this );
[e0886db]2410
2411 VISIT_END( node );
2412}
2413
2414template< typename pass_type >
2415Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
2416 MUTATE_START( node );
2417
[3c398b6]2418 maybeMutate_impl( node->forall , *this );
2419 maybeMutate_impl( node->parameters, *this );
[e0886db]2420
2421 MUTATE_END( Type, node );
[13932f14]2422}
2423
[e0886db]2424//--------------------------------------------------------------------------
2425// TypeInstType
[13932f14]2426template< typename pass_type >
[ab904dc]2427void PassVisitor< pass_type >::visit( TypeInstType * node ) {
[86e84e4]2428 VISIT_START( node );
2429
2430 maybeAccept_impl( node->forall , *this );
2431 maybeAccept_impl( node->parameters, *this );
2432
2433 VISIT_END( node );
2434}
2435
2436template< typename pass_type >
2437Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
2438 MUTATE_START( node );
2439
2440 maybeMutate_impl( node->forall , *this );
2441 maybeMutate_impl( node->parameters, *this );
2442
2443 MUTATE_END( Type, node );
[13932f14]2444}
2445
[a8a2b0a]2446//--------------------------------------------------------------------------
2447// TupleType
[13932f14]2448template< typename pass_type >
[ab904dc]2449void PassVisitor< pass_type >::visit( TupleType * node ) {
[a8a2b0a]2450 VISIT_START( node );
2451
2452 maybeAccept_impl( node->forall, *this );
2453 maybeAccept_impl( node->types, *this );
2454 maybeAccept_impl( node->members, *this );
2455
2456 VISIT_END( node );
[13932f14]2457}
2458
[a8a2b0a]2459template< typename pass_type >
2460Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
2461 MUTATE_START( node );
2462
2463 maybeMutate_impl( node->forall, *this );
2464 maybeMutate_impl( node->types, *this );
2465 maybeMutate_impl( node->members, *this );
2466
2467 MUTATE_END( Type, node );
2468}
2469
2470//--------------------------------------------------------------------------
2471// TypeofType
[13932f14]2472template< typename pass_type >
[ab904dc]2473void PassVisitor< pass_type >::visit( TypeofType * node ) {
[a8a2b0a]2474 VISIT_START( node );
2475
2476 assert( node->expr );
2477 maybeAccept_impl( node->expr, *this );
2478
2479 VISIT_END( node );
[13932f14]2480}
2481
[a8a2b0a]2482template< typename pass_type >
2483Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
2484 MUTATE_START( node );
2485
2486 assert( node->expr );
2487 maybeMutate_impl( node->expr, *this );
2488
2489 MUTATE_END( Type, node );
2490}
2491
2492//--------------------------------------------------------------------------
2493// AttrType
[13932f14]2494template< typename pass_type >
[ab904dc]2495void PassVisitor< pass_type >::visit( AttrType * node ) {
[a8a2b0a]2496 VISIT_START( node );
2497
2498 if ( node->isType ) {
2499 assert( node->type );
2500 maybeAccept_impl( node->type, *this );
2501 } else {
2502 assert( node->expr );
2503 maybeAccept_impl( node->expr, *this );
2504 } // if
2505
2506 VISIT_END( node );
[13932f14]2507}
2508
[a8a2b0a]2509template< typename pass_type >
2510Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
2511 MUTATE_START( node );
2512
2513 if ( node->isType ) {
2514 assert( node->type );
2515 maybeMutate_impl( node->type, *this );
2516 } else {
2517 assert( node->expr );
2518 maybeMutate_impl( node->expr, *this );
2519 } // if
2520
2521 MUTATE_END( Type, node );
2522}
2523
2524//--------------------------------------------------------------------------
2525// VarArgsType
[13932f14]2526template< typename pass_type >
[ab904dc]2527void PassVisitor< pass_type >::visit( VarArgsType * node ) {
[a8a2b0a]2528 VISIT_START( node );
2529
2530 maybeAccept_impl( node->forall, *this );
2531
2532 VISIT_END( node );
[13932f14]2533}
2534
[a8a2b0a]2535template< typename pass_type >
2536Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
2537 MUTATE_START( node );
2538
2539 maybeMutate_impl( node->forall, *this );
2540
2541 MUTATE_END( Type, node );
2542}
2543
2544//--------------------------------------------------------------------------
2545// ZeroType
[13932f14]2546template< typename pass_type >
[ab904dc]2547void PassVisitor< pass_type >::visit( ZeroType * node ) {
[a8a2b0a]2548 VISIT_START( node );
2549
2550 maybeAccept_impl( node->forall, *this );
2551
2552 VISIT_END( node );
[13932f14]2553}
2554
[a8a2b0a]2555template< typename pass_type >
2556Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
2557 MUTATE_START( node );
2558
2559 maybeMutate_impl( node->forall, *this );
2560
2561 MUTATE_END( Type, node );
2562}
2563
2564//--------------------------------------------------------------------------
2565// OneType
[13932f14]2566template< typename pass_type >
[ab904dc]2567void PassVisitor< pass_type >::visit( OneType * node ) {
[a8a2b0a]2568 VISIT_START( node );
2569
2570 maybeAccept_impl( node->forall, *this );
2571
2572 VISIT_END( node );
[13932f14]2573}
2574
[a8a2b0a]2575template< typename pass_type >
2576Type * PassVisitor< pass_type >::mutate( OneType * node ) {
2577 MUTATE_START( node );
2578
2579 maybeMutate_impl( node->forall, *this );
2580
2581 MUTATE_END( Type, node );
2582}
2583
[47498bd]2584//--------------------------------------------------------------------------
2585// GlobalScopeType
2586template< typename pass_type >
2587void PassVisitor< pass_type >::visit( GlobalScopeType * node ) {
2588 VISIT_START( node );
2589
2590 maybeAccept_impl( node->forall, *this );
2591
2592 VISIT_END( node );
2593}
2594
2595template< typename pass_type >
2596Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) {
2597 MUTATE_START( node );
2598
2599 maybeMutate_impl( node->forall, *this );
2600
2601 MUTATE_END( Type, node );
2602}
2603
[a8a2b0a]2604//--------------------------------------------------------------------------
2605// Designation
[b11d8e2]2606template< typename pass_type >
2607void PassVisitor< pass_type >::visit( Designation * node ) {
2608 VISIT_START( node );
2609
[a8a2b0a]2610 maybeAccept_impl( node->designators, *this );
[b11d8e2]2611
2612 VISIT_END( node );
2613}
2614
2615template< typename pass_type >
2616Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
2617 MUTATE_START( node );
2618
[a8a2b0a]2619 maybeMutate_impl( node->designators, *this );
[b11d8e2]2620
2621 MUTATE_END( Designation, node );
2622}
2623
[9c1600c]2624//--------------------------------------------------------------------------
[e0886db]2625// SingleInit
[13932f14]2626template< typename pass_type >
[ab904dc]2627void PassVisitor< pass_type >::visit( SingleInit * node ) {
[9c1600c]2628 VISIT_START( node );
2629
[a8a2b0a]2630 visitExpression( node->value );
[9c1600c]2631
2632 VISIT_END( node );
[13932f14]2633}
2634
[296b2be]2635template< typename pass_type >
2636Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
2637 MUTATE_START( node );
2638
[a8a2b0a]2639 node->value = mutateExpression( node->value );
[296b2be]2640
2641 MUTATE_END( Initializer, node );
2642}
2643
[a8a2b0a]2644//--------------------------------------------------------------------------
2645// ListInit
[13932f14]2646template< typename pass_type >
[ab904dc]2647void PassVisitor< pass_type >::visit( ListInit * node ) {
[a8a2b0a]2648 VISIT_START( node );
[13932f14]2649
[a8a2b0a]2650 maybeAccept_impl( node->designations, *this );
2651 maybeAccept_impl( node->initializers, *this );
[13932f14]2652
[a8a2b0a]2653 VISIT_END( node );
[13932f14]2654}
2655
2656template< typename pass_type >
[a8a2b0a]2657Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
2658 MUTATE_START( node );
2659
2660 maybeMutate_impl( node->designations, *this );
2661 maybeMutate_impl( node->initializers, *this );
2662
2663 MUTATE_END( Initializer, node );
[13932f14]2664}
[ab904dc]2665
[a8a2b0a]2666//--------------------------------------------------------------------------
2667// ConstructorInit
[5ea7a22]2668template< typename pass_type >
[a8a2b0a]2669void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
2670 VISIT_START( node );
[5ea7a22]2671
[a8a2b0a]2672 maybeAccept_impl( node->ctor, *this );
2673 maybeAccept_impl( node->dtor, *this );
2674 maybeAccept_impl( node->init, *this );
[ab904dc]2675
[a8a2b0a]2676 VISIT_END( node );
[ab904dc]2677}
2678
2679template< typename pass_type >
[a8a2b0a]2680Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
2681 MUTATE_START( node );
[ab904dc]2682
[a8a2b0a]2683 maybeMutate_impl( node->ctor, *this );
2684 maybeMutate_impl( node->dtor, *this );
2685 maybeMutate_impl( node->init, *this );
[ab904dc]2686
[a8a2b0a]2687 MUTATE_END( Initializer, node );
[ab904dc]2688}
2689
[a8a2b0a]2690//--------------------------------------------------------------------------
2691// Attribute
[ab904dc]2692template< typename pass_type >
[a8a2b0a]2693void PassVisitor< pass_type >::visit( Constant * node ) {
2694 VISIT_START( node );
2695
2696 VISIT_END( node );
[ab904dc]2697}
2698
2699template< typename pass_type >
[a8a2b0a]2700Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
2701 MUTATE_START( node );
2702
2703 MUTATE_END( Constant, node );
[ab904dc]2704}
2705
[a8a2b0a]2706//--------------------------------------------------------------------------
2707// Attribute
[ab904dc]2708template< typename pass_type >
[a8a2b0a]2709void PassVisitor< pass_type >::visit( Attribute * node ) {
2710 VISIT_START( node );
2711
2712 maybeAccept_impl( node->parameters, *this );
2713
2714 VISIT_END( node );
[4551a6e]2715}
[5ea7a22]2716
2717template< typename pass_type >
2718Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
[a8a2b0a]2719 MUTATE_START( node );
2720
2721 maybeMutate_impl( node->parameters, *this );
2722
2723 MUTATE_END( Attribute, node );
[5ea7a22]2724}
[447c356]2725
[a8a2b0a]2726//--------------------------------------------------------------------------
2727// TypeSubstitution
[447c356]2728template< typename pass_type >
2729TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
2730 MUTATE_START( node );
2731
2732 for ( auto & p : node->typeEnv ) {
2733 indexerScopedMutate( p.second, *this );
2734 }
2735 for ( auto & p : node->varEnv ) {
2736 indexerScopedMutate( p.second, *this );
2737 }
2738
2739 MUTATE_END( TypeSubstitution, node );
2740}
[342146e1]2741
2742#undef VISIT_START
2743#undef VISIT_END
2744
2745#undef MUTATE_START
2746#undef MUTATE_END
Note: See TracBrowser for help on using the repository browser.