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

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

Old pass visitor no longer leaks macros

  • Property mode set to 100644
File size: 79.0 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
1791 indexerScopedAccept( node->result , *this );
[3c398b6]1792 maybeAccept_impl ( node->callExpr , *this );
1793 maybeAccept_impl ( node->tempDecls , *this );
1794 maybeAccept_impl ( node->returnDecls, *this );
1795 maybeAccept_impl ( node->dtors , *this );
[e0886db]1796
1797 VISIT_END( node );
1798}
1799
1800template< typename pass_type >
1801Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
1802 MUTATE_START( node );
1803
1804 indexerScopedMutate( node->env , *this );
1805 indexerScopedMutate( node->result , *this );
[3c398b6]1806 maybeMutate_impl ( node->callExpr , *this );
1807 maybeMutate_impl ( node->tempDecls , *this );
1808 maybeMutate_impl ( node->returnDecls, *this );
1809 maybeMutate_impl ( node->dtors , *this );
[e0886db]1810
1811 MUTATE_END( Expression, node );
[13932f14]1812}
1813
[e0886db]1814//--------------------------------------------------------------------------
1815// ConstructorExpr
[13932f14]1816template< typename pass_type >
[ab904dc]1817void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
[e0886db]1818 VISIT_START( node );
1819
1820 indexerScopedAccept( node->result , *this );
[3c398b6]1821 maybeAccept_impl ( node->callExpr, *this );
[e0886db]1822
1823 VISIT_END( node );
1824}
1825
1826template< typename pass_type >
1827Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
1828 MUTATE_START( node );
1829
1830 indexerScopedMutate( node->env , *this );
1831 indexerScopedMutate( node->result , *this );
[3c398b6]1832 maybeMutate_impl ( node->callExpr, *this );
[e0886db]1833
1834 MUTATE_END( Expression, node );
[13932f14]1835}
1836
[e0886db]1837//--------------------------------------------------------------------------
1838// CompoundLiteralExpr
[13932f14]1839template< typename pass_type >
[ab904dc]1840void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
[e0886db]1841 VISIT_START( node );
1842
1843 indexerScopedAccept( node->result , *this );
[3c398b6]1844 maybeAccept_impl ( node->initializer, *this );
[e0886db]1845
1846 VISIT_END( node );
[13932f14]1847}
1848
[e0886db]1849template< typename pass_type >
1850Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
1851 MUTATE_START( node );
1852
1853 indexerScopedMutate( node->env , *this );
1854 indexerScopedMutate( node->result , *this );
[3c398b6]1855 maybeMutate_impl ( node->initializer, *this );
[e0886db]1856
1857 MUTATE_END( Expression, node );
1858}
1859
1860//--------------------------------------------------------------------------
1861// RangeExpr
[13932f14]1862template< typename pass_type >
[ab904dc]1863void PassVisitor< pass_type >::visit( RangeExpr * node ) {
[e0886db]1864 VISIT_START( node );
1865
1866 indexerScopedAccept( node->result, *this );
[3c398b6]1867 maybeAccept_impl ( node->low , *this );
1868 maybeAccept_impl ( node->high , *this );
[e0886db]1869
1870 VISIT_END( node );
[13932f14]1871}
1872
[e0886db]1873template< typename pass_type >
1874Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
1875 MUTATE_START( node );
1876
1877 indexerScopedMutate( node->env , *this );
1878 indexerScopedMutate( node->result, *this );
[3c398b6]1879 maybeMutate_impl ( node->low , *this );
1880 maybeMutate_impl ( node->high , *this );
[e0886db]1881
1882 MUTATE_END( Expression, node );
1883}
1884
1885//--------------------------------------------------------------------------
1886// UntypedTupleExpr
[13932f14]1887template< typename pass_type >
[ab904dc]1888void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
[e0886db]1889 VISIT_START( node );
1890
1891 indexerScopedAccept( node->result, *this );
[3c398b6]1892 maybeAccept_impl ( node->exprs , *this );
[e0886db]1893
1894 VISIT_END( node );
1895}
1896
1897template< typename pass_type >
1898Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
1899 MUTATE_START( node );
1900
1901 indexerScopedMutate( node->env , *this );
1902 indexerScopedMutate( node->result, *this );
[3c398b6]1903 maybeMutate_impl ( node->exprs , *this );
[e0886db]1904
1905 MUTATE_END( Expression, node );
1906}
1907
1908//--------------------------------------------------------------------------
1909// TupleExpr
1910template< typename pass_type >
1911void PassVisitor< pass_type >::visit( TupleExpr * node ) {
1912 VISIT_START( node );
1913
1914 indexerScopedAccept( node->result, *this );
[3c398b6]1915 maybeAccept_impl ( node->exprs , *this );
[e0886db]1916
1917 VISIT_END( node );
1918}
1919
1920template< typename pass_type >
1921Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
1922 MUTATE_START( node );
1923
1924 indexerScopedMutate( node->env , *this );
1925 indexerScopedMutate( node->result, *this );
[3c398b6]1926 maybeMutate_impl ( node->exprs , *this );
[e0886db]1927
1928 MUTATE_END( Expression, node );
1929}
1930
1931//--------------------------------------------------------------------------
1932// TupleIndexExpr
1933template< typename pass_type >
1934void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
1935 VISIT_START( node );
1936
1937 indexerScopedAccept( node->result, *this );
[3c398b6]1938 maybeAccept_impl ( node->tuple , *this );
[e0886db]1939
1940 VISIT_END( node );
1941}
1942
1943template< typename pass_type >
1944Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
1945 MUTATE_START( node );
1946
1947 indexerScopedMutate( node->env , *this );
1948 indexerScopedMutate( node->result, *this );
[3c398b6]1949 maybeMutate_impl ( node->tuple , *this );
[e0886db]1950
1951 MUTATE_END( Expression, node );
1952}
1953
1954//--------------------------------------------------------------------------
1955// TupleAssignExpr
1956template< typename pass_type >
1957void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
1958 VISIT_START( node );
1959
1960 indexerScopedAccept( node->result , *this );
[3c398b6]1961 maybeAccept_impl ( node->stmtExpr, *this );
[e0886db]1962
1963 VISIT_END( node );
[13932f14]1964}
1965
1966template< typename pass_type >
[e0886db]1967Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
1968 MUTATE_START( node );
[13932f14]1969
[e0886db]1970 indexerScopedMutate( node->env , *this );
1971 indexerScopedMutate( node->result , *this );
[3c398b6]1972 maybeMutate_impl ( node->stmtExpr, *this );
[13932f14]1973
[e0886db]1974 MUTATE_END( Expression, node );
[13932f14]1975}
1976
[9c1600c]1977//--------------------------------------------------------------------------
[e0886db]1978// StmtExpr
[13932f14]1979template< typename pass_type >
[ab904dc]1980void PassVisitor< pass_type >::visit( StmtExpr * node ) {
[9c1600c]1981 VISIT_START( node );
1982
1983 // don't want statements from outer CompoundStmts to be added to this StmtExpr
[02fdb8e]1984 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
[9c1600c]1985 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1986 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
1987
[e0886db]1988 indexerScopedAccept( node->result , *this );
[3c398b6]1989 maybeAccept_impl ( node->statements , *this );
1990 maybeAccept_impl ( node->returnDecls, *this );
1991 maybeAccept_impl ( node->dtors , *this );
[9c1600c]1992
1993 VISIT_END( node );
[13932f14]1994}
1995
[296b2be]1996template< typename pass_type >
1997Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
1998 MUTATE_START( node );
[4551a6e]1999
[296b2be]2000 // don't want statements from outer CompoundStmts to be added to this StmtExpr
[02fdb8e]2001 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
[134322e]2002 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2003 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
[296b2be]2004
[e0886db]2005 indexerScopedMutate( node->result , *this );
[3c398b6]2006 maybeMutate_impl ( node->statements , *this );
2007 maybeMutate_impl ( node->returnDecls, *this );
2008 maybeMutate_impl ( node->dtors , *this );
[296b2be]2009
2010 MUTATE_END( Expression, node );
2011}
2012
[e0886db]2013//--------------------------------------------------------------------------
2014// UniqueExpr
[13932f14]2015template< typename pass_type >
[ab904dc]2016void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
[e0886db]2017 VISIT_START( node );
2018
2019 indexerScopedAccept( node->result, *this );
[3c398b6]2020 maybeAccept_impl ( node->expr , *this );
[e0886db]2021
2022 VISIT_END( node );
2023}
2024
2025template< typename pass_type >
2026Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
2027 MUTATE_START( node );
2028
2029 indexerScopedMutate( node->env , *this );
2030 indexerScopedMutate( node->result, *this );
[3c398b6]2031 maybeMutate_impl ( node->expr , *this );
[e0886db]2032
2033 MUTATE_END( Expression, node );
[13932f14]2034}
2035
[73367a8]2036//--------------------------------------------------------------------------
2037// UntypedInitExpr
2038template< typename pass_type >
2039void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
2040 VISIT_START( node );
2041
2042 indexerScopedAccept( node->result, *this );
2043 maybeAccept_impl ( node->expr , *this );
2044 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2045
2046 VISIT_END( node );
2047}
2048
2049template< typename pass_type >
2050Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
2051 MUTATE_START( node );
2052
2053 indexerScopedMutate( node->env , *this );
2054 indexerScopedMutate( node->result, *this );
2055 maybeMutate_impl ( node->expr , *this );
2056 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2057
2058 MUTATE_END( Expression, node );
2059}
2060
2061//--------------------------------------------------------------------------
2062// InitExpr
2063template< typename pass_type >
2064void PassVisitor< pass_type >::visit( InitExpr * node ) {
2065 VISIT_START( node );
2066
2067 indexerScopedAccept( node->result, *this );
2068 maybeAccept_impl ( node->expr , *this );
2069 maybeAccept_impl ( node->designation, *this );
2070
2071 VISIT_END( node );
2072}
2073
2074template< typename pass_type >
2075Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
2076 MUTATE_START( node );
2077
2078 indexerScopedMutate( node->env , *this );
2079 indexerScopedMutate( node->result, *this );
2080 maybeMutate_impl ( node->expr , *this );
2081 maybeMutate_impl ( node->designation, *this );
2082
2083 MUTATE_END( Expression, node );
2084}
2085
[44b4114]2086//--------------------------------------------------------------------------
2087// DeletedExpr
2088template< typename pass_type >
2089void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
2090 VISIT_START( node );
2091
2092 indexerScopedAccept( node->result, *this );
2093 maybeAccept_impl( node->expr, *this );
2094 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
2095
2096 VISIT_END( node );
2097}
2098
2099template< typename pass_type >
2100Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
2101 MUTATE_START( node );
2102
2103 indexerScopedMutate( node->env, *this );
2104 indexerScopedMutate( node->result, *this );
2105 maybeMutate_impl( node->expr, *this );
2106
2107 MUTATE_END( Expression, node );
2108}
2109
[0f79853]2110//--------------------------------------------------------------------------
2111// DefaultArgExpr
2112template< typename pass_type >
2113void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) {
2114 VISIT_START( node );
2115
2116 indexerScopedAccept( node->result, *this );
2117 maybeAccept_impl( node->expr, *this );
2118
2119 VISIT_END( node );
2120}
2121
2122template< typename pass_type >
2123Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) {
2124 MUTATE_START( node );
2125
2126 indexerScopedMutate( node->env, *this );
2127 indexerScopedMutate( node->result, *this );
2128 maybeMutate_impl( node->expr, *this );
2129
2130 MUTATE_END( Expression, node );
2131}
2132
[d807ca28]2133//--------------------------------------------------------------------------
2134// GenericExpr
2135template< typename pass_type >
2136void PassVisitor< pass_type >::visit( GenericExpr * node ) {
2137 VISIT_START( node );
2138
2139 indexerScopedAccept( node->result, *this );
2140 maybeAccept_impl( node->control, *this );
2141 for ( GenericExpr::Association & assoc : node->associations ) {
2142 indexerScopedAccept( assoc.type, *this );
2143 maybeAccept_impl( assoc.expr, *this );
2144 }
2145
2146 VISIT_END( node );
2147}
2148
2149template< typename pass_type >
2150Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) {
2151 MUTATE_START( node );
2152
2153 indexerScopedMutate( node->env, *this );
2154 indexerScopedMutate( node->result, *this );
2155 maybeMutate_impl( node->control, *this );
2156 for ( GenericExpr::Association & assoc : node->associations ) {
2157 indexerScopedMutate( assoc.type, *this );
2158 maybeMutate_impl( assoc.expr, *this );
2159 }
2160
2161 MUTATE_END( Expression, node );
2162}
2163
[17fc7a5]2164//--------------------------------------------------------------------------
2165// VoidType
[13932f14]2166template< typename pass_type >
[ab904dc]2167void PassVisitor< pass_type >::visit( VoidType * node ) {
[599fbb6]2168 VISIT_START( node );
2169
2170 maybeAccept_impl( node->forall, *this );
2171
2172 VISIT_END( node );
2173}
2174
2175template< typename pass_type >
2176Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
2177 MUTATE_START( node );
2178
2179 maybeMutate_impl( node->forall, *this );
2180
2181 MUTATE_END( Type, node );
[13932f14]2182}
2183
[17fc7a5]2184//--------------------------------------------------------------------------
2185// BasicType
[13932f14]2186template< typename pass_type >
[ab904dc]2187void PassVisitor< pass_type >::visit( BasicType * node ) {
[17fc7a5]2188 VISIT_START( node );
2189
2190 maybeAccept_impl( node->forall, *this );
2191
2192 VISIT_END( node );
2193}
2194
2195template< typename pass_type >
2196Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
2197 MUTATE_START( node );
2198
2199 maybeMutate_impl( node->forall, *this );
2200
2201 MUTATE_END( Type, node );
[13932f14]2202}
2203
[17fc7a5]2204//--------------------------------------------------------------------------
2205// PointerType
[13932f14]2206template< typename pass_type >
[ab904dc]2207void PassVisitor< pass_type >::visit( PointerType * node ) {
[17fc7a5]2208 VISIT_START( node );
2209
2210 maybeAccept_impl( node->forall, *this );
[cfaf9be]2211 // xxx - should PointerType visit/mutate dimension?
[17fc7a5]2212 maybeAccept_impl( node->base, *this );
2213
2214 VISIT_END( node );
[13932f14]2215}
2216
[17fc7a5]2217template< typename pass_type >
2218Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
2219 MUTATE_START( node );
2220
2221 maybeMutate_impl( node->forall, *this );
[cfaf9be]2222 // xxx - should PointerType visit/mutate dimension?
[17fc7a5]2223 maybeMutate_impl( node->base, *this );
2224
2225 MUTATE_END( Type, node );
2226}
2227
2228//--------------------------------------------------------------------------
2229// ArrayType
[13932f14]2230template< typename pass_type >
[ab904dc]2231void PassVisitor< pass_type >::visit( ArrayType * node ) {
[17fc7a5]2232 VISIT_START( node );
2233
2234 maybeAccept_impl( node->forall, *this );
2235 maybeAccept_impl( node->dimension, *this );
2236 maybeAccept_impl( node->base, *this );
2237
2238 VISIT_END( node );
[13932f14]2239}
2240
[17fc7a5]2241template< typename pass_type >
2242Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
2243 MUTATE_START( node );
2244
2245 maybeMutate_impl( node->forall, *this );
2246 maybeMutate_impl( node->dimension, *this );
2247 maybeMutate_impl( node->base, *this );
2248
2249 MUTATE_END( Type, node );
2250}
2251
2252//--------------------------------------------------------------------------
2253// ReferenceType
[6b9b047]2254template< typename pass_type >
2255void PassVisitor< pass_type >::visit( ReferenceType * node ) {
[17fc7a5]2256 VISIT_START( node );
2257
2258 maybeAccept_impl( node->forall, *this );
2259 maybeAccept_impl( node->base, *this );
2260
2261 VISIT_END( node );
2262}
2263
2264template< typename pass_type >
2265Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
2266 MUTATE_START( node );
2267
2268 maybeMutate_impl( node->forall, *this );
2269 maybeMutate_impl( node->base, *this );
2270
2271 MUTATE_END( Type, node );
[6b9b047]2272}
2273
[c5d7701]2274//--------------------------------------------------------------------------
2275// QualifiedType
2276template< typename pass_type >
2277void PassVisitor< pass_type >::visit( QualifiedType * node ) {
2278 VISIT_START( node );
2279
2280 maybeAccept_impl( node->forall, *this );
[c194661]2281 maybeAccept_impl( node->parent, *this );
2282 maybeAccept_impl( node->child, *this );
[c5d7701]2283
2284 VISIT_END( node );
2285}
2286
2287template< typename pass_type >
2288Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) {
2289 MUTATE_START( node );
2290
2291 maybeMutate_impl( node->forall, *this );
[c194661]2292 maybeMutate_impl( node->parent, *this );
2293 maybeMutate_impl( node->child, *this );
[c5d7701]2294
2295 MUTATE_END( Type, node );
2296}
2297
[17fc7a5]2298//--------------------------------------------------------------------------
2299// FunctionType
[13932f14]2300template< typename pass_type >
[ab904dc]2301void PassVisitor< pass_type >::visit( FunctionType * node ) {
[17fc7a5]2302 VISIT_START( node );
2303
2304 maybeAccept_impl( node->forall, *this );
2305 maybeAccept_impl( node->returnVals, *this );
2306 maybeAccept_impl( node->parameters, *this );
2307
2308 VISIT_END( node );
2309}
2310
2311template< typename pass_type >
2312Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
2313 MUTATE_START( node );
2314
2315 maybeMutate_impl( node->forall, *this );
2316 maybeMutate_impl( node->returnVals, *this );
2317 maybeMutate_impl( node->parameters, *this );
2318
2319 MUTATE_END( Type, node );
[13932f14]2320}
2321
[e0886db]2322//--------------------------------------------------------------------------
2323// StructInstType
[13932f14]2324template< typename pass_type >
[ab904dc]2325void PassVisitor< pass_type >::visit( StructInstType * node ) {
[e0886db]2326 VISIT_START( node );
2327
2328 indexerAddStruct( node->name );
2329
2330 {
2331 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2332 maybeAccept_impl( node->forall , *this );
2333 maybeAccept_impl( node->parameters, *this );
[e0886db]2334 }
2335
2336 VISIT_END( node );
2337}
2338
2339template< typename pass_type >
2340Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
2341 MUTATE_START( node );
2342
2343 indexerAddStruct( node->name );
2344
2345 {
2346 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2347 maybeMutate_impl( node->forall , *this );
2348 maybeMutate_impl( node->parameters, *this );
[e0886db]2349 }
2350
2351 MUTATE_END( Type, node );
[13932f14]2352}
2353
[e0886db]2354//--------------------------------------------------------------------------
2355// UnionInstType
[13932f14]2356template< typename pass_type >
[ab904dc]2357void PassVisitor< pass_type >::visit( UnionInstType * node ) {
[e0886db]2358 VISIT_START( node );
2359
2360 indexerAddStruct( node->name );
2361
2362 {
2363 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2364 maybeAccept_impl( node->forall , *this );
2365 maybeAccept_impl( node->parameters, *this );
[e0886db]2366 }
2367
2368 VISIT_END( node );
2369}
2370
2371template< typename pass_type >
2372Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
2373 MUTATE_START( node );
2374
2375 indexerAddStruct( node->name );
2376
2377 {
2378 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2379 maybeMutate_impl( node->forall , *this );
2380 maybeMutate_impl( node->parameters, *this );
[e0886db]2381 }
2382
2383 MUTATE_END( Type, node );
[13932f14]2384}
2385
[e0886db]2386//--------------------------------------------------------------------------
2387// EnumInstType
[13932f14]2388template< typename pass_type >
[ab904dc]2389void PassVisitor< pass_type >::visit( EnumInstType * node ) {
[86e84e4]2390 VISIT_START( node );
2391
2392 maybeAccept_impl( node->forall, *this );
2393 maybeAccept_impl( node->parameters, *this );
2394
2395 VISIT_END( node );
[13932f14]2396}
2397
[e0886db]2398template< typename pass_type >
2399Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
[86e84e4]2400 MUTATE_START( node );
2401
2402 maybeMutate_impl( node->forall, *this );
2403 maybeMutate_impl( node->parameters, *this );
2404
2405 MUTATE_END( Type, node );
[e0886db]2406}
2407
2408//--------------------------------------------------------------------------
2409// TraitInstType
[13932f14]2410template< typename pass_type >
[ab904dc]2411void PassVisitor< pass_type >::visit( TraitInstType * node ) {
[e0886db]2412 VISIT_START( node );
2413
[3c398b6]2414 maybeAccept_impl( node->forall , *this );
2415 maybeAccept_impl( node->parameters, *this );
[e0886db]2416
2417 VISIT_END( node );
2418}
2419
2420template< typename pass_type >
2421Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
2422 MUTATE_START( node );
2423
[3c398b6]2424 maybeMutate_impl( node->forall , *this );
2425 maybeMutate_impl( node->parameters, *this );
[e0886db]2426
2427 MUTATE_END( Type, node );
[13932f14]2428}
2429
[e0886db]2430//--------------------------------------------------------------------------
2431// TypeInstType
[13932f14]2432template< typename pass_type >
[ab904dc]2433void PassVisitor< pass_type >::visit( TypeInstType * node ) {
[86e84e4]2434 VISIT_START( node );
2435
2436 maybeAccept_impl( node->forall , *this );
2437 maybeAccept_impl( node->parameters, *this );
2438
2439 VISIT_END( node );
2440}
2441
2442template< typename pass_type >
2443Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
2444 MUTATE_START( node );
2445
2446 maybeMutate_impl( node->forall , *this );
2447 maybeMutate_impl( node->parameters, *this );
2448
2449 MUTATE_END( Type, node );
[13932f14]2450}
2451
[a8a2b0a]2452//--------------------------------------------------------------------------
2453// TupleType
[13932f14]2454template< typename pass_type >
[ab904dc]2455void PassVisitor< pass_type >::visit( TupleType * node ) {
[a8a2b0a]2456 VISIT_START( node );
2457
2458 maybeAccept_impl( node->forall, *this );
2459 maybeAccept_impl( node->types, *this );
2460 maybeAccept_impl( node->members, *this );
2461
2462 VISIT_END( node );
[13932f14]2463}
2464
[a8a2b0a]2465template< typename pass_type >
2466Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
2467 MUTATE_START( node );
2468
2469 maybeMutate_impl( node->forall, *this );
2470 maybeMutate_impl( node->types, *this );
2471 maybeMutate_impl( node->members, *this );
2472
2473 MUTATE_END( Type, node );
2474}
2475
2476//--------------------------------------------------------------------------
2477// TypeofType
[13932f14]2478template< typename pass_type >
[ab904dc]2479void PassVisitor< pass_type >::visit( TypeofType * node ) {
[a8a2b0a]2480 VISIT_START( node );
2481
2482 assert( node->expr );
2483 maybeAccept_impl( node->expr, *this );
2484
2485 VISIT_END( node );
[13932f14]2486}
2487
[a8a2b0a]2488template< typename pass_type >
2489Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
2490 MUTATE_START( node );
2491
2492 assert( node->expr );
2493 maybeMutate_impl( node->expr, *this );
2494
2495 MUTATE_END( Type, node );
2496}
2497
2498//--------------------------------------------------------------------------
2499// AttrType
[13932f14]2500template< typename pass_type >
[ab904dc]2501void PassVisitor< pass_type >::visit( AttrType * node ) {
[a8a2b0a]2502 VISIT_START( node );
2503
2504 if ( node->isType ) {
2505 assert( node->type );
2506 maybeAccept_impl( node->type, *this );
2507 } else {
2508 assert( node->expr );
2509 maybeAccept_impl( node->expr, *this );
2510 } // if
2511
2512 VISIT_END( node );
[13932f14]2513}
2514
[a8a2b0a]2515template< typename pass_type >
2516Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
2517 MUTATE_START( node );
2518
2519 if ( node->isType ) {
2520 assert( node->type );
2521 maybeMutate_impl( node->type, *this );
2522 } else {
2523 assert( node->expr );
2524 maybeMutate_impl( node->expr, *this );
2525 } // if
2526
2527 MUTATE_END( Type, node );
2528}
2529
2530//--------------------------------------------------------------------------
2531// VarArgsType
[13932f14]2532template< typename pass_type >
[ab904dc]2533void PassVisitor< pass_type >::visit( VarArgsType * node ) {
[a8a2b0a]2534 VISIT_START( node );
2535
2536 maybeAccept_impl( node->forall, *this );
2537
2538 VISIT_END( node );
[13932f14]2539}
2540
[a8a2b0a]2541template< typename pass_type >
2542Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
2543 MUTATE_START( node );
2544
2545 maybeMutate_impl( node->forall, *this );
2546
2547 MUTATE_END( Type, node );
2548}
2549
2550//--------------------------------------------------------------------------
2551// ZeroType
[13932f14]2552template< typename pass_type >
[ab904dc]2553void PassVisitor< pass_type >::visit( ZeroType * node ) {
[a8a2b0a]2554 VISIT_START( node );
2555
2556 maybeAccept_impl( node->forall, *this );
2557
2558 VISIT_END( node );
[13932f14]2559}
2560
[a8a2b0a]2561template< typename pass_type >
2562Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
2563 MUTATE_START( node );
2564
2565 maybeMutate_impl( node->forall, *this );
2566
2567 MUTATE_END( Type, node );
2568}
2569
2570//--------------------------------------------------------------------------
2571// OneType
[13932f14]2572template< typename pass_type >
[ab904dc]2573void PassVisitor< pass_type >::visit( OneType * node ) {
[a8a2b0a]2574 VISIT_START( node );
2575
2576 maybeAccept_impl( node->forall, *this );
2577
2578 VISIT_END( node );
[13932f14]2579}
2580
[a8a2b0a]2581template< typename pass_type >
2582Type * PassVisitor< pass_type >::mutate( OneType * node ) {
2583 MUTATE_START( node );
2584
2585 maybeMutate_impl( node->forall, *this );
2586
2587 MUTATE_END( Type, node );
2588}
2589
[47498bd]2590//--------------------------------------------------------------------------
2591// GlobalScopeType
2592template< typename pass_type >
2593void PassVisitor< pass_type >::visit( GlobalScopeType * node ) {
2594 VISIT_START( node );
2595
2596 maybeAccept_impl( node->forall, *this );
2597
2598 VISIT_END( node );
2599}
2600
2601template< typename pass_type >
2602Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) {
2603 MUTATE_START( node );
2604
2605 maybeMutate_impl( node->forall, *this );
2606
2607 MUTATE_END( Type, node );
2608}
2609
[a8a2b0a]2610//--------------------------------------------------------------------------
2611// Designation
[b11d8e2]2612template< typename pass_type >
2613void PassVisitor< pass_type >::visit( Designation * node ) {
2614 VISIT_START( node );
2615
[a8a2b0a]2616 maybeAccept_impl( node->designators, *this );
[b11d8e2]2617
2618 VISIT_END( node );
2619}
2620
2621template< typename pass_type >
2622Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
2623 MUTATE_START( node );
2624
[a8a2b0a]2625 maybeMutate_impl( node->designators, *this );
[b11d8e2]2626
2627 MUTATE_END( Designation, node );
2628}
2629
[9c1600c]2630//--------------------------------------------------------------------------
[e0886db]2631// SingleInit
[13932f14]2632template< typename pass_type >
[ab904dc]2633void PassVisitor< pass_type >::visit( SingleInit * node ) {
[9c1600c]2634 VISIT_START( node );
2635
[a8a2b0a]2636 visitExpression( node->value );
[9c1600c]2637
2638 VISIT_END( node );
[13932f14]2639}
2640
[296b2be]2641template< typename pass_type >
2642Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
2643 MUTATE_START( node );
2644
[a8a2b0a]2645 node->value = mutateExpression( node->value );
[296b2be]2646
2647 MUTATE_END( Initializer, node );
2648}
2649
[a8a2b0a]2650//--------------------------------------------------------------------------
2651// ListInit
[13932f14]2652template< typename pass_type >
[ab904dc]2653void PassVisitor< pass_type >::visit( ListInit * node ) {
[a8a2b0a]2654 VISIT_START( node );
[13932f14]2655
[a8a2b0a]2656 maybeAccept_impl( node->designations, *this );
2657 maybeAccept_impl( node->initializers, *this );
[13932f14]2658
[a8a2b0a]2659 VISIT_END( node );
[13932f14]2660}
2661
2662template< typename pass_type >
[a8a2b0a]2663Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
2664 MUTATE_START( node );
2665
2666 maybeMutate_impl( node->designations, *this );
2667 maybeMutate_impl( node->initializers, *this );
2668
2669 MUTATE_END( Initializer, node );
[13932f14]2670}
[ab904dc]2671
[a8a2b0a]2672//--------------------------------------------------------------------------
2673// ConstructorInit
[5ea7a22]2674template< typename pass_type >
[a8a2b0a]2675void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
2676 VISIT_START( node );
[5ea7a22]2677
[a8a2b0a]2678 maybeAccept_impl( node->ctor, *this );
2679 maybeAccept_impl( node->dtor, *this );
2680 maybeAccept_impl( node->init, *this );
[ab904dc]2681
[a8a2b0a]2682 VISIT_END( node );
[ab904dc]2683}
2684
2685template< typename pass_type >
[a8a2b0a]2686Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
2687 MUTATE_START( node );
[ab904dc]2688
[a8a2b0a]2689 maybeMutate_impl( node->ctor, *this );
2690 maybeMutate_impl( node->dtor, *this );
2691 maybeMutate_impl( node->init, *this );
[ab904dc]2692
[a8a2b0a]2693 MUTATE_END( Initializer, node );
[ab904dc]2694}
2695
[a8a2b0a]2696//--------------------------------------------------------------------------
2697// Attribute
[ab904dc]2698template< typename pass_type >
[a8a2b0a]2699void PassVisitor< pass_type >::visit( Constant * node ) {
2700 VISIT_START( node );
2701
2702 VISIT_END( node );
[ab904dc]2703}
2704
2705template< typename pass_type >
[a8a2b0a]2706Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
2707 MUTATE_START( node );
2708
2709 MUTATE_END( Constant, node );
[ab904dc]2710}
2711
[a8a2b0a]2712//--------------------------------------------------------------------------
2713// Attribute
[ab904dc]2714template< typename pass_type >
[a8a2b0a]2715void PassVisitor< pass_type >::visit( Attribute * node ) {
2716 VISIT_START( node );
2717
2718 maybeAccept_impl( node->parameters, *this );
2719
2720 VISIT_END( node );
[4551a6e]2721}
[5ea7a22]2722
2723template< typename pass_type >
2724Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
[a8a2b0a]2725 MUTATE_START( node );
2726
2727 maybeMutate_impl( node->parameters, *this );
2728
2729 MUTATE_END( Attribute, node );
[5ea7a22]2730}
[447c356]2731
[a8a2b0a]2732//--------------------------------------------------------------------------
2733// TypeSubstitution
[447c356]2734template< typename pass_type >
2735TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
2736 MUTATE_START( node );
2737
2738 for ( auto & p : node->typeEnv ) {
2739 indexerScopedMutate( p.second, *this );
2740 }
2741 for ( auto & p : node->varEnv ) {
2742 indexerScopedMutate( p.second, *this );
2743 }
2744
2745 MUTATE_END( TypeSubstitution, node );
2746}
[342146e1]2747
2748#undef VISIT_START
2749#undef VISIT_END
2750
2751#undef MUTATE_START
2752#undef MUTATE_END
Note: See TracBrowser for help on using the repository browser.