source: src/Common/PassVisitor.impl.h@ 4670c79

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 4670c79 was 4670c79, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Change Indexer::addWith to take a list of expressions instead of a WithStmt

  • Property mode set to 100644
File size: 64.8 KB
RevLine 
[13932f14]1#pragma once
[3268a58]2// IWYU pragma: private, include "PassVisitor.h"
[13932f14]3
[3c398b6]4#define VISIT_START( node ) \
5 __attribute__((unused)) \
6 ChildrenGuard children_guard( get_visit_children_ptr() ); \
7 __attribute__((unused)) \
[62423350]8 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
[3c398b6]9 call_previsit( node ); \
[6e09f211]10
11#define VISIT_END( node ) \
12 call_postvisit( node ); \
[9c1600c]13
[3c398b6]14#define MUTATE_START( node ) \
15 __attribute__((unused)) \
16 ChildrenGuard children_guard( get_visit_children_ptr() ); \
17 __attribute__((unused)) \
[62423350]18 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
[3c398b6]19 call_premutate( node ); \
[296b2be]20
21#define MUTATE_END( type, node ) \
22 return call_postmutate< type * >( node ); \
23
24
[3c398b6]25#define VISIT_BODY( node ) \
26 VISIT_START( node ); \
27 if( children_guard ) { \
28 Visitor::visit( node ); \
29 } \
30 VISIT_END( node ); \
[13932f14]31
[ab904dc]32
[3c398b6]33#define MUTATE_BODY( type, node ) \
34 MUTATE_START( node ); \
35 if( children_guard ) { \
36 Mutator::mutate( node ); \
37 } \
38 MUTATE_END( type, node ); \
[296b2be]39
[134322e]40
41
42template<typename T>
43static inline bool empty( T * ptr ) {
44 return !ptr || ptr->empty();
45}
46
[6ca154b]47typedef std::list< Statement * > StmtList_t;
48typedef std::list< Declaration * > DeclList_t;
49
50template<typename iterator_t>
51static inline void splice( iterator_t it, DeclList_t * decls ) {
52 std::transform(
53 decls->begin(),
54 decls->end(),
55 it,
56 [](Declaration * decl) -> auto {
[ba3706f]57 return new DeclStmt( decl );
[6ca154b]58 }
59 );
60 decls->clear();
61}
[134322e]62
63template< typename pass_type >
[07c178f0]64inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
[6ca154b]65 DeclList_t* beforeDecls = visitor.get_beforeDecls();
66 DeclList_t* afterDecls = visitor.get_afterDecls();
[522363e]67 SemanticError errors;
[134322e]68
[6ca154b]69 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
70 // splice in new declarations after previous decl
[d24d4e1]71 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
[6ca154b]72
73 if ( i == decls.end() ) break;
74
[522363e]75 try {
76 // run visitor on declaration
[3c398b6]77 maybeAccept_impl( *i, visitor );
[522363e]78 } catch( SemanticError &e ) {
79 e.set_location( (*i)->location );
80 errors.append( e );
81 }
[6ca154b]82
83 // splice in new declarations before current decl
84 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
[134322e]85 }
[522363e]86 if ( ! errors.isEmpty() ) {
87 throw errors;
88 }
[6ca154b]89}
[134322e]90
[6ca154b]91template< typename pass_type >
[07c178f0]92inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
[6ca154b]93 DeclList_t* beforeDecls = mutator.get_beforeDecls();
94 DeclList_t* afterDecls = mutator.get_afterDecls();
[522363e]95 SemanticError errors;
[6ca154b]96
97 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
98 // splice in new declarations after previous decl
[d24d4e1]99 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
[6ca154b]100
101 if ( i == decls.end() ) break;
[522363e]102 try {
103 // run mutator on declaration
[3c398b6]104 maybeMutate_impl( *i, mutator );
[522363e]105 } catch( SemanticError &e ) {
106 e.set_location( (*i)->location );
107 errors.append( e );
108 }
[6ca154b]109
110 // splice in new declarations before current decl
111 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
112 }
[522363e]113 if ( ! errors.isEmpty() ) {
114 throw errors;
115 }
[134322e]116}
117
[3c398b6]118template< typename TreeType, typename pass_type >
119inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
120 if ( ! visitor.get_visit_children() ) return;
121 if ( tree ) {
122 tree->accept( visitor );
123 }
124}
125
126template< typename Container, typename pass_type >
127inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
128 if ( ! visitor.get_visit_children() ) return;
[e0886db]129 SemanticError errors;
130 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
131 try {
132 if ( *i ) {
133 (*i)->accept( visitor );
134 }
135 } catch( SemanticError &e ) {
136 e.set_location( (*i)->location );
137 errors.append( e );
138 }
139 }
140 if ( ! errors.isEmpty() ) {
141 throw errors;
142 }
143}
144
[3c398b6]145template< typename TreeType, typename pass_type >
146inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
147 if ( ! mutator.get_visit_children() ) return;
148
149 if ( tree ) {
150 tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
151 }
152}
153
154template< typename Container, typename pass_type >
155inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
156 if ( ! mutator.get_visit_children() ) return;
[e0886db]157 SemanticError errors;
158 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
159 try {
160 if ( *i ) {
161 *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
162 assert( *i );
163 } // if
164 } catch( SemanticError &e ) {
165 e.set_location( (*i)->location );
166 errors.append( e );
167 } // try
168 } // for
169 if ( ! errors.isEmpty() ) {
170 throw errors;
171 } // if
172}
173
[296b2be]174template< typename pass_type >
[6ca154b]175template< typename func_t >
176void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
[3c398b6]177 if ( ! get_visit_children() ) return;
[296b2be]178 SemanticError errors;
179
[2a7b3ca]180 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
181 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
182 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
183 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
184 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
185
[134322e]186 StmtList_t* beforeStmts = get_beforeStmts();
187 StmtList_t* afterStmts = get_afterStmts();
[6ca154b]188 DeclList_t* beforeDecls = get_beforeDecls();
189 DeclList_t* afterDecls = get_afterDecls();
[134322e]190
[296b2be]191 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
[6ca154b]192
193 if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }
[134322e]194 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
[6ca154b]195
[296b2be]196 try {
[6ca154b]197 func( *i );
198 assert(( empty( beforeStmts ) && empty( afterStmts ))
199 || ( empty( beforeDecls ) && empty( afterDecls )) );
200
[296b2be]201 } catch ( SemanticError &e ) {
[aa685db]202 e.set_location( (*i)->location );
[296b2be]203 errors.append( e );
[134322e]204 }
[6ca154b]205
206 if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }
[134322e]207 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
[296b2be]208 }
[134322e]209
[6ca154b]210 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
[134322e]211 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
212 if ( !errors.isEmpty() ) { throw errors; }
[296b2be]213}
214
215template< typename pass_type >
[6ca154b]216void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
217 handleStatementList( statements, [this]( Statement * stmt) {
[3c398b6]218 maybeAccept_impl( stmt, *this );
[6ca154b]219 });
220}
[134322e]221
[6ca154b]222template< typename pass_type >
223void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
224 handleStatementList( statements, [this]( Statement *& stmt) {
[3c398b6]225 maybeMutate_impl( stmt, *this );
[6ca154b]226 });
[134322e]227}
228
[6ca154b]229
[134322e]230template< typename pass_type >
[6ca154b]231template< typename func_t >
232Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
[3c398b6]233 if ( ! get_visit_children() ) return stmt;
234
[134322e]235 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
[6ca154b]236 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () );
237 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
238 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
239 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
240 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
[296b2be]241
[6ca154b]242 Statement *newStmt = func( stmt );
[134322e]243
244 StmtList_t* beforeStmts = get_beforeStmts();
245 StmtList_t* afterStmts = get_afterStmts();
[6ca154b]246 DeclList_t* beforeDecls = get_beforeDecls();
247 DeclList_t* afterDecls = get_afterDecls();
[134322e]248
[6ca154b]249 if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; }
250 assert(( empty( beforeStmts ) && empty( afterStmts ))
251 || ( empty( beforeDecls ) && empty( afterDecls )) );
[134322e]252
[ba3706f]253 CompoundStmt *compound = new CompoundStmt();
[6ca154b]254 if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); }
[134322e]255 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
256 compound->get_kids().push_back( newStmt );
[6ca154b]257 if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }
[134322e]258 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
259 return compound;
260}
261
262template< typename pass_type >
[6ca154b]263Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
264 return handleStatement( stmt, [this]( Statement * stmt ) {
[3c398b6]265 maybeAccept_impl( stmt, *this );
[6ca154b]266 return stmt;
267 });
268}
[134322e]269
[6ca154b]270template< typename pass_type >
271Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
272 return handleStatement( stmt, [this]( Statement * stmt ) {
[3c398b6]273 maybeMutate_impl( stmt, *this );
274 return stmt;
[6ca154b]275 });
[296b2be]276}
277
278template< typename pass_type >
[6ca154b]279template< typename func_t >
280Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
[3c398b6]281 if ( ! get_visit_children() ) return expr;
[296b2be]282 if( !expr ) return nullptr;
283
[134322e]284 auto env_ptr = get_env_ptr();
285 if ( env_ptr && expr->get_env() ) {
286 *env_ptr = expr->get_env();
[296b2be]287 }
[6ca154b]288
[3c398b6]289 // should env be moved onto the result of the mutate?
[6ca154b]290 return func( expr );
291}
292
293template< typename pass_type >
294Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
295 return handleExpression(expr, [this]( Expression * expr ) {
[3c398b6]296 maybeAccept_impl( expr, *this );
[6ca154b]297 return expr;
[d24d4e1]298 });
[296b2be]299}
[ab904dc]300
[6ca154b]301template< typename pass_type >
302Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
303 return handleExpression(expr, [this]( Expression * expr ) {
[3c398b6]304 maybeMutate_impl( expr, *this );
305 return expr;
[6ca154b]306 });
307}
[ab904dc]308
[3c398b6]309template< typename TreeType, typename VisitorType >
310inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
311 if ( ! visitor.get_visit_children() ) return;
312 auto guard = makeFuncGuard(
313 [&visitor]() { visitor.indexerScopeEnter(); },
314 [&visitor]() { visitor.indexerScopeLeave(); }
315 );
316 maybeAccept_impl( tree, visitor );
317}
318
319template< typename TreeType, typename MutatorType >
320inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
321 if ( ! mutator.get_visit_children() ) return;
322 auto guard = makeFuncGuard(
323 [&mutator]() { mutator.indexerScopeEnter(); },
324 [&mutator]() { mutator.indexerScopeLeave(); }
325 );
326 maybeMutate_impl( tree, mutator );
327}
328
[296b2be]329//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[e0886db]330//========================================================================================================================================================================
331//========================================================================================================================================================================
332//========================================================================================================================================================================
333//========================================================================================================================================================================
334//========================================================================================================================================================================
335//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[13932f14]336
[33a25f9]337// A NOTE ON THE ORDER OF TRAVERSAL
338//
339// Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is
340// no such thing as a recursive type or typedef.
341//
342// typedef struct { T *x; } T; // never allowed
343//
344// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
345// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
346// declaration).
347//
348// struct T { struct T *x; }; // allowed
349//
350// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
351// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
352// queried later in this pass.
353//
354// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
[e0886db]355
356//--------------------------------------------------------------------------
357// ObjectDecl
[13932f14]358template< typename pass_type >
[ab904dc]359void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
[e0886db]360 VISIT_START( node );
361
362 indexerScopedAccept( node->type , *this );
[3c398b6]363 maybeAccept_impl ( node->init , *this );
364 maybeAccept_impl ( node->bitfieldWidth, *this );
365 maybeAccept_impl ( node->attributes , *this );
[e0886db]366
[2cb70aa]367 indexerAddId( node );
[e0886db]368
369 VISIT_END( node );
370}
371
372template< typename pass_type >
373DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) {
374 MUTATE_START( node );
375
376 indexerScopedMutate( node->type , *this );
[3c398b6]377 maybeMutate_impl ( node->init , *this );
378 maybeMutate_impl ( node->bitfieldWidth, *this );
379 maybeMutate_impl ( node->attributes , *this );
[e0886db]380
[2cb70aa]381 indexerAddId( node );
[e0886db]382
383 MUTATE_END( DeclarationWithType, node );
[13932f14]384}
385
[e0886db]386//--------------------------------------------------------------------------
387// FunctionDecl
[13932f14]388template< typename pass_type >
[ab904dc]389void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
[e0886db]390 VISIT_START( node );
391
[2cb70aa]392 indexerAddId( node );
[e0886db]393
394 {
[2cb70aa]395 // with clause introduces a level of scope (for the with expression members).
396 // with clause exprs are added to the indexer before parameters so that parameters
397 // shadow with exprs and not the other way around.
[e0886db]398 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[4429b04]399 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
400 static ObjectDecl func(
401 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
402 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
403 nullptr
404 );
405 indexerAddId( &func );
[3c398b6]406 maybeAccept_impl( node->type, *this );
407 maybeAccept_impl( node->statements, *this );
408 maybeAccept_impl( node->attributes, *this );
[e0886db]409 }
410
411 VISIT_END( node );
412}
413
414template< typename pass_type >
415DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
416 MUTATE_START( node );
417
[2cb70aa]418 indexerAddId( node );
[e0886db]419
420 {
[2cb70aa]421 // with clause introduces a level of scope (for the with expression members).
422 // with clause exprs are added to the indexer before parameters so that parameters
423 // shadow with exprs and not the other way around.
[e0886db]424 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[4429b04]425 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
426 static ObjectDecl func(
427 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
428 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
429 nullptr
430 );
431 indexerAddId( &func );
[3c398b6]432 maybeMutate_impl( node->type, *this );
433 maybeMutate_impl( node->statements, *this );
434 maybeMutate_impl( node->attributes, *this );
[e0886db]435 }
436
437 MUTATE_END( DeclarationWithType, node );
[13932f14]438}
439
[e0886db]440//--------------------------------------------------------------------------
441// StructDecl
[13932f14]442template< typename pass_type >
[ab904dc]443void PassVisitor< pass_type >::visit( StructDecl * node ) {
[e0886db]444 VISIT_START( node );
445
446 // make up a forward declaration and add it before processing the members
447 // needs to be on the heap because addStruct saves the pointer
448 indexerAddStructFwd( node );
449
450 {
451 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]452 maybeAccept_impl( node->parameters, *this );
453 maybeAccept_impl( node->members , *this );
[e0886db]454 }
455
456 // this addition replaces the forward declaration
457 indexerAddStruct( node );
458
459 VISIT_END( node );
460}
461
462template< typename pass_type >
463Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
464 MUTATE_START( node );
465
466 // make up a forward declaration and add it before processing the members
467 // needs to be on the heap because addStruct saves the pointer
468 indexerAddStructFwd( node );
469
470 {
471 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]472 maybeMutate_impl( node->parameters, *this );
473 maybeMutate_impl( node->members , *this );
[e0886db]474 }
475
476 // this addition replaces the forward declaration
477 indexerAddStruct( node );
478
479 MUTATE_END( Declaration, node );
[13932f14]480}
481
[e0886db]482//--------------------------------------------------------------------------
483// UnionDecl
[13932f14]484template< typename pass_type >
[ab904dc]485void PassVisitor< pass_type >::visit( UnionDecl * node ) {
[e0886db]486 VISIT_START( node );
487
488 // make up a forward declaration and add it before processing the members
489 indexerAddUnionFwd( node );
490
491 {
492 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]493 maybeAccept_impl( node->parameters, *this );
494 maybeAccept_impl( node->members , *this );
[e0886db]495 }
496
497 indexerAddUnion( node );
498
499 VISIT_END( node );
500}
501
502template< typename pass_type >
503Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
504 MUTATE_START( node );
505
506 // make up a forward declaration and add it before processing the members
507 indexerAddUnionFwd( node );
508
509 {
510 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]511 maybeMutate_impl( node->parameters, *this );
512 maybeMutate_impl( node->members , *this );
[e0886db]513 }
514
515 indexerAddUnion( node );
516
517 MUTATE_END( Declaration, node );
[13932f14]518}
519
[e0886db]520//--------------------------------------------------------------------------
521// EnumDecl
[13932f14]522template< typename pass_type >
[ab904dc]523void PassVisitor< pass_type >::visit( EnumDecl * node ) {
[e0886db]524 VISIT_START( node );
525
526 indexerAddEnum( node );
527
[33a25f9]528 // unlike structs, traits, and unions, enums inject their members into the global scope
[3c398b6]529 maybeAccept_impl( node->parameters, *this );
530 maybeAccept_impl( node->members , *this );
[e0886db]531
532 VISIT_END( node );
[13932f14]533}
534
[e0886db]535template< typename pass_type >
536Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
537 MUTATE_START( node );
538
539 indexerAddEnum( node );
540
[522363e]541 // unlike structs, traits, and unions, enums inject their members into the global scope
[3c398b6]542 maybeMutate_impl( node->parameters, *this );
543 maybeMutate_impl( node->members , *this );
[e0886db]544
545 MUTATE_END( Declaration, node );
546}
547
548//--------------------------------------------------------------------------
549// TraitDecl
[13932f14]550template< typename pass_type >
[ab904dc]551void PassVisitor< pass_type >::visit( TraitDecl * node ) {
[e0886db]552 VISIT_START( node );
553
554 {
555 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]556 maybeAccept_impl( node->parameters, *this );
557 maybeAccept_impl( node->members , *this );
[e0886db]558 }
559
560 indexerAddTrait( node );
561
562 VISIT_END( node );
[13932f14]563}
564
[e0886db]565template< typename pass_type >
566Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
567 MUTATE_START( node );
568
569 {
570 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]571 maybeMutate_impl( node->parameters, *this );
572 maybeMutate_impl( node->members , *this );
[e0886db]573 }
574
575 indexerAddTrait( node );
576
577 MUTATE_END( Declaration, node );
578}
579
580//--------------------------------------------------------------------------
581// TypeDecl
[13932f14]582template< typename pass_type >
[ab904dc]583void PassVisitor< pass_type >::visit( TypeDecl * node ) {
[e0886db]584 VISIT_START( node );
585
586 {
587 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]588 maybeAccept_impl( node->parameters, *this );
589 maybeAccept_impl( node->base , *this );
[e0886db]590 }
591
[33a25f9]592 // see A NOTE ON THE ORDER OF TRAVERSAL, above
593 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
594 // and may depend on the type itself
[e0886db]595 indexerAddType( node );
596
[3c398b6]597 maybeAccept_impl( node->assertions, *this );
[e0886db]598
599 indexerScopedAccept( node->init, *this );
600
601 VISIT_END( node );
602}
603
604template< typename pass_type >
[982832e]605Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
[e0886db]606 MUTATE_START( node );
607
608 {
609 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]610 maybeMutate_impl( node->parameters, *this );
611 maybeMutate_impl( node->base , *this );
[e0886db]612 }
613
[33a25f9]614 // see A NOTE ON THE ORDER OF TRAVERSAL, above
615 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
616 // and may depend on the type itself
[e0886db]617 indexerAddType( node );
618
[3c398b6]619 maybeMutate_impl( node->assertions, *this );
[e0886db]620
621 indexerScopedMutate( node->init, *this );
622
[982832e]623 MUTATE_END( Declaration, node );
[13932f14]624}
625
[e0886db]626//--------------------------------------------------------------------------
627// TypedefDecl
[13932f14]628template< typename pass_type >
[ab904dc]629void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
[e0886db]630 VISIT_START( node );
631
632 {
633 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]634 maybeAccept_impl( node->parameters, *this );
635 maybeAccept_impl( node->base , *this );
[e0886db]636 }
637
638 indexerAddType( node );
639
[3c398b6]640 maybeAccept_impl( node->assertions, *this );
[e0886db]641
642 VISIT_END( node );
[13932f14]643}
644
645template< typename pass_type >
[e0886db]646Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
647 MUTATE_START( node );
648
649 {
650 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]651 maybeMutate_impl( node->parameters, *this );
652 maybeMutate_impl( node->base , *this );
[e0886db]653 }
654
655 indexerAddType( node );
656
[3c398b6]657 maybeMutate_impl( node->assertions, *this );
[e0886db]658
659 MUTATE_END( Declaration, node );
[13932f14]660}
661
[9c1600c]662//--------------------------------------------------------------------------
[e0886db]663// AsmDecl
[13932f14]664template< typename pass_type >
[e0886db]665void PassVisitor< pass_type >::visit( AsmDecl * node ) {
[9c1600c]666 VISIT_START( node );
667
[3c398b6]668 maybeAccept_impl( node->stmt, *this );
[9c1600c]669
670 VISIT_END( node );
[13932f14]671}
672
[296b2be]673template< typename pass_type >
[e0886db]674AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
[296b2be]675 MUTATE_START( node );
676
[3c398b6]677 maybeMutate_impl( node->stmt, *this );
[e0886db]678
679 MUTATE_END( AsmDecl, node );
680}
681
682//--------------------------------------------------------------------------
683// CompoundStmt
684template< typename pass_type >
685void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
686 VISIT_START( node );
687 {
688 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
689 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
690 visitStatementList( node->kids );
691 }
692 VISIT_END( node );
693}
[296b2be]694
[e0886db]695template< typename pass_type >
696CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
697 MUTATE_START( node );
698 {
699 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
700 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
701 mutateStatementList( node->kids );
702 }
[296b2be]703 MUTATE_END( CompoundStmt, node );
704}
705
[9c1600c]706//--------------------------------------------------------------------------
707// ExprStmt
[13932f14]708template< typename pass_type >
[ab904dc]709void PassVisitor< pass_type >::visit( ExprStmt * node ) {
[9c1600c]710 VISIT_START( node );
711
[e0886db]712 visitExpression( node->expr );
[9c1600c]713
714 VISIT_END( node );
[13932f14]715}
716
[296b2be]717template< typename pass_type >
718Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
719 MUTATE_START( node );
720
[e0886db]721 node->expr = mutateExpression( node->expr );
[296b2be]722
723 MUTATE_END( Statement, node );
724}
725
[6ca154b]726//--------------------------------------------------------------------------
727// AsmStmt
[13932f14]728template< typename pass_type >
[ab904dc]729void PassVisitor< pass_type >::visit( AsmStmt * node ) {
[4551a6e]730 VISIT_BODY( node );
[13932f14]731}
732
[6ca154b]733template< typename pass_type >
734Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
735 MUTATE_BODY( Statement, node );
736}
737
[9c1600c]738//--------------------------------------------------------------------------
739// IfStmt
[13932f14]740template< typename pass_type >
[ab904dc]741void PassVisitor< pass_type >::visit( IfStmt * node ) {
[4551a6e]742 VISIT_START( node );
[33a25f9]743 {
744 // if statements introduce a level of scope (for the initialization)
745 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]746 maybeAccept_impl( node->get_initialization(), *this );
747 visitExpression ( node->condition );
[33a25f9]748 node->thenPart = visitStatement( node->thenPart );
749 node->elsePart = visitStatement( node->elsePart );
750 }
[9c1600c]751 VISIT_END( node );
[13932f14]752}
753
[296b2be]754template< typename pass_type >
755Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
[4551a6e]756 MUTATE_START( node );
[e0886db]757 {
[33a25f9]758 // if statements introduce a level of scope (for the initialization)
[e0886db]759 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]760 maybeMutate_impl( node->get_initialization(), *this );
[e0886db]761 node->condition = mutateExpression( node->condition );
762 node->thenPart = mutateStatement ( node->thenPart );
763 node->elsePart = mutateStatement ( node->elsePart );
764 }
[296b2be]765 MUTATE_END( Statement, node );
766}
767
[9c1600c]768//--------------------------------------------------------------------------
769// WhileStmt
[13932f14]770template< typename pass_type >
[ab904dc]771void PassVisitor< pass_type >::visit( WhileStmt * node ) {
[4551a6e]772 VISIT_START( node );
[9c1600c]773
[e0886db]774 visitExpression( node->condition );
775 node->body = visitStatement( node->body );
[9c1600c]776
777 VISIT_END( node );
[13932f14]778}
779
[296b2be]780template< typename pass_type >
781Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
[4551a6e]782 MUTATE_START( node );
[296b2be]783
[e0886db]784 node->condition = mutateExpression( node->condition );
785 node->body = mutateStatement ( node->body );
[296b2be]786
787 MUTATE_END( Statement, node );
788}
789
[9c1600c]790//--------------------------------------------------------------------------
[6ca154b]791// ForStmt
[13932f14]792template< typename pass_type >
[ab904dc]793void PassVisitor< pass_type >::visit( ForStmt * node ) {
[4551a6e]794 VISIT_START( node );
[e0886db]795 {
[33a25f9]796 // for statements introduce a level of scope (for the initialization)
[e0886db]797 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]798 maybeAccept_impl( node->initialization, *this );
[e0886db]799 visitExpression( node->condition );
800 visitExpression( node->increment );
801 node->body = visitStatement( node->body );
802 }
[9c1600c]803 VISIT_END( node );
[13932f14]804}
805
[296b2be]806template< typename pass_type >
807Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
[4551a6e]808 MUTATE_START( node );
[e0886db]809 {
[33a25f9]810 // for statements introduce a level of scope (for the initialization)
[e0886db]811 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]812 maybeMutate_impl( node->initialization, *this );
[e0886db]813 node->condition = mutateExpression( node->condition );
814 node->increment = mutateExpression( node->increment );
815 node->body = mutateStatement ( node->body );
816 }
[296b2be]817 MUTATE_END( Statement, node );
818}
819
[9c1600c]820//--------------------------------------------------------------------------
821// SwitchStmt
[13932f14]822template< typename pass_type >
[ab904dc]823void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
[4551a6e]824 VISIT_START( node );
[9c1600c]825
[e0886db]826 visitExpression ( node->condition );
827 visitStatementList( node->statements );
[9c1600c]828
829 VISIT_END( node );
[13932f14]830}
831
[296b2be]832template< typename pass_type >
833Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
[4551a6e]834 MUTATE_START( node );
835
[e0886db]836 node->condition = mutateExpression( node->condition );
837 mutateStatementList( node->statements );
[4551a6e]838
[296b2be]839 MUTATE_END( Statement, node );
840}
841
[9c1600c]842//--------------------------------------------------------------------------
[35df560]843// CaseStmt
[13932f14]844template< typename pass_type >
[ab904dc]845void PassVisitor< pass_type >::visit( CaseStmt * node ) {
[4551a6e]846 VISIT_START( node );
847
[e0886db]848 visitExpression ( node->condition );
849 visitStatementList( node->stmts );
[4551a6e]850
[9c1600c]851 VISIT_END( node );
[13932f14]852}
853
[296b2be]854template< typename pass_type >
855Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
[4551a6e]856 MUTATE_START( node );
857
[e0886db]858 node->condition = mutateExpression( node->condition );
859 mutateStatementList( node->stmts );
[4551a6e]860
[296b2be]861 MUTATE_END( Statement, node );
862}
863
[6ca154b]864//--------------------------------------------------------------------------
865// BranchStmt
[13932f14]866template< typename pass_type >
[ab904dc]867void PassVisitor< pass_type >::visit( BranchStmt * node ) {
[4551a6e]868 VISIT_BODY( node );
[13932f14]869}
870
[6ca154b]871template< typename pass_type >
872Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
873 MUTATE_BODY( Statement, node );
874}
875
[9c1600c]876//--------------------------------------------------------------------------
877// ReturnStmt
[13932f14]878template< typename pass_type >
[ab904dc]879void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
[9c1600c]880 VISIT_START( node );
881
[e0886db]882 visitExpression( node->expr );
[9c1600c]883
884 VISIT_END( node );
[13932f14]885}
886
[296b2be]887template< typename pass_type >
888Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
889 MUTATE_START( node );
890
[e0886db]891 node->expr = mutateExpression( node->expr );
[296b2be]892
893 MUTATE_END( Statement, node );
894}
895
[6e09f211]896//--------------------------------------------------------------------------
897// ThrowStmt
898
899template< typename pass_type >
900void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
901 VISIT_BODY( node );
902}
903
904template< typename pass_type >
905Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
906 MUTATE_BODY( Statement, node );
907}
908
[9c1600c]909//--------------------------------------------------------------------------
910// TryStmt
[13932f14]911template< typename pass_type >
[ab904dc]912void PassVisitor< pass_type >::visit( TryStmt * node ) {
[9c1600c]913 VISIT_START( node );
914
[3c398b6]915 maybeAccept_impl( node->block , *this );
916 maybeAccept_impl( node->handlers , *this );
917 maybeAccept_impl( node->finallyBlock, *this );
[9c1600c]918
919 VISIT_END( node );
[13932f14]920}
921
[296b2be]922template< typename pass_type >
923Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
924 MUTATE_START( node );
925
[3c398b6]926 maybeMutate_impl( node->block , *this );
927 maybeMutate_impl( node->handlers , *this );
928 maybeMutate_impl( node->finallyBlock, *this );
[4551a6e]929
[296b2be]930 MUTATE_END( Statement, node );
931}
932
[9c1600c]933//--------------------------------------------------------------------------
934// CatchStmt
[13932f14]935template< typename pass_type >
[ab904dc]936void PassVisitor< pass_type >::visit( CatchStmt * node ) {
[9c1600c]937 VISIT_START( node );
[e0886db]938 {
[33a25f9]939 // catch statements introduce a level of scope (for the caught exception)
[e0886db]940 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]941 maybeAccept_impl( node->decl, *this );
[e0886db]942 node->cond = visitExpression( node->cond );
943 node->body = visitStatement ( node->body );
944 }
[9c1600c]945 VISIT_END( node );
[13932f14]946}
947
[296b2be]948template< typename pass_type >
949Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
950 MUTATE_START( node );
[e0886db]951 {
[33a25f9]952 // catch statements introduce a level of scope (for the caught exception)
[e0886db]953 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]954 maybeMutate_impl( node->decl, *this );
[e0886db]955 node->cond = mutateExpression( node->cond );
956 node->body = mutateStatement ( node->body );
957 }
[296b2be]958 MUTATE_END( Statement, node );
959}
960
[2065609]961//--------------------------------------------------------------------------
962// FinallyStmt
[13932f14]963template< typename pass_type >
[ab904dc]964void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
[4551a6e]965 VISIT_BODY( node );
[13932f14]966}
967
[2065609]968template< typename pass_type >
969Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
970 MUTATE_BODY( Statement, node );
971}
972
973//--------------------------------------------------------------------------
974// WaitForStmt
975template< typename pass_type >
976void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
977 VISIT_BODY( node );
978}
979
980template< typename pass_type >
981Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
982 MUTATE_BODY( Statement, node );
983}
984
[d8893ca]985
986
[61255ad]987//--------------------------------------------------------------------------
988// NullStmt
989template< typename pass_type >
990void PassVisitor< pass_type >::visit( WithStmt * node ) {
[d8893ca]991 VISIT_START( node );
992 maybeAccept_impl( node->exprs, *this );
993 {
994 // catch statements introduce a level of scope (for the caught exception)
995 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[4670c79]996 indexerAddWith( node->exprs );
[d8893ca]997 maybeAccept_impl( node->stmt, *this );
998 }
999 VISIT_END( node );
[61255ad]1000}
1001
1002template< typename pass_type >
1003Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
[d8893ca]1004 MUTATE_START( node );
1005 maybeMutate_impl( node->exprs, *this );
1006 {
1007 // catch statements introduce a level of scope (for the caught exception)
1008 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[4670c79]1009 indexerAddWith( node->exprs );
[d8893ca]1010 maybeMutate_impl( node->stmt, *this );
1011 }
1012 MUTATE_END( Statement, node );
[61255ad]1013}
1014
[2065609]1015//--------------------------------------------------------------------------
1016// NullStmt
[13932f14]1017template< typename pass_type >
[ab904dc]1018void PassVisitor< pass_type >::visit( NullStmt * node ) {
[4551a6e]1019 VISIT_BODY( node );
[13932f14]1020}
1021
[2065609]1022template< typename pass_type >
1023NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
1024 MUTATE_BODY( NullStmt, node );
1025}
1026
1027//--------------------------------------------------------------------------
1028// DeclStmt
[13932f14]1029template< typename pass_type >
[ab904dc]1030void PassVisitor< pass_type >::visit( DeclStmt * node ) {
[4551a6e]1031 VISIT_BODY( node );
[13932f14]1032}
1033
[2065609]1034template< typename pass_type >
1035Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
1036 MUTATE_BODY( Statement, node );
1037}
1038
1039//--------------------------------------------------------------------------
1040// ImplicitCtorDtorStmt
[13932f14]1041template< typename pass_type >
[ab904dc]1042void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
[4551a6e]1043 VISIT_BODY( node );
[13932f14]1044}
1045
[2065609]1046template< typename pass_type >
1047Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
1048 MUTATE_BODY( Statement, node );
1049}
1050
1051//--------------------------------------------------------------------------
1052// ApplicationExpr
[13932f14]1053template< typename pass_type >
[ab904dc]1054void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
[e0886db]1055 VISIT_START( node );
1056
1057 indexerScopedAccept( node->result , *this );
[3c398b6]1058 maybeAccept_impl ( node->function, *this );
1059 maybeAccept_impl ( node->args , *this );
[e0886db]1060
1061 VISIT_END( node );
[13932f14]1062}
1063
[2065609]1064template< typename pass_type >
1065Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
[e0886db]1066 MUTATE_START( node );
1067
1068 indexerScopedMutate( node->env , *this );
1069 indexerScopedMutate( node->result , *this );
[3c398b6]1070 maybeMutate_impl ( node->function, *this );
1071 maybeMutate_impl ( node->args , *this );
[e0886db]1072
1073 MUTATE_END( Expression, node );
[2065609]1074}
1075
[9c1600c]1076//--------------------------------------------------------------------------
1077// UntypedExpr
[13932f14]1078template< typename pass_type >
[ab904dc]1079void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
[9c1600c]1080 VISIT_START( node );
1081
[3c398b6]1082 // maybeAccept_impl( node->get_env(), *this );
[e0886db]1083 indexerScopedAccept( node->result, *this );
[2a7b3ca]1084
[e0886db]1085 for ( auto expr : node->args ) {
[9c1600c]1086 visitExpression( expr );
1087 }
1088
1089 VISIT_END( node );
[13932f14]1090}
1091
[296b2be]1092template< typename pass_type >
1093Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
1094 MUTATE_START( node );
1095
[e0886db]1096 indexerScopedMutate( node->env , *this );
1097 indexerScopedMutate( node->result, *this );
[2a7b3ca]1098
[e0886db]1099 for ( auto& expr : node->args ) {
[296b2be]1100 expr = mutateExpression( expr );
1101 }
1102
1103 MUTATE_END( Expression, node );
1104}
1105
[e0886db]1106//--------------------------------------------------------------------------
1107// NameExpr
[13932f14]1108template< typename pass_type >
[ab904dc]1109void PassVisitor< pass_type >::visit( NameExpr * node ) {
[e0886db]1110 VISIT_START( node );
1111
1112 indexerScopedAccept( node->result, *this );
1113
1114 VISIT_END( node );
[13932f14]1115}
1116
1117template< typename pass_type >
[e0886db]1118Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
1119 MUTATE_START( node );
1120
1121 indexerScopedMutate( node->env , *this );
1122 indexerScopedMutate( node->result, *this );
1123
1124 MUTATE_END( Expression, node );
[13932f14]1125}
1126
[e0886db]1127//--------------------------------------------------------------------------
1128// CastExpr
[a5f0529]1129template< typename pass_type >
[e0886db]1130void PassVisitor< pass_type >::visit( CastExpr * node ) {
1131 VISIT_START( node );
1132
1133 indexerScopedAccept( node->result, *this );
[3c398b6]1134 maybeAccept_impl ( node->arg , *this );
[e0886db]1135
1136 VISIT_END( node );
[a5f0529]1137}
1138
[13932f14]1139template< typename pass_type >
[e0886db]1140Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
1141 MUTATE_START( node );
1142
1143 indexerScopedMutate( node->env , *this );
1144 indexerScopedMutate( node->result, *this );
[3c398b6]1145 maybeMutate_impl ( node->arg , *this );
[e0886db]1146
1147 MUTATE_END( Expression, node );
[13932f14]1148}
1149
[e0886db]1150//--------------------------------------------------------------------------
1151// VirtualCastExpr
[13932f14]1152template< typename pass_type >
[e0886db]1153void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
1154 VISIT_START( node );
1155
1156 indexerScopedAccept( node->result, *this );
[3c398b6]1157 maybeAccept_impl( node->arg, *this );
[e0886db]1158
1159 VISIT_END( node );
[13932f14]1160}
1161
1162template< typename pass_type >
[e0886db]1163Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
1164 MUTATE_START( node );
1165
1166 indexerScopedMutate( node->env , *this );
1167 indexerScopedMutate( node->result, *this );
[3c398b6]1168 maybeMutate_impl ( node->arg , *this );
[e0886db]1169
1170 MUTATE_END( Expression, node );
[13932f14]1171}
1172
[e0886db]1173//--------------------------------------------------------------------------
1174// AddressExpr
[13932f14]1175template< typename pass_type >
[e0886db]1176void PassVisitor< pass_type >::visit( AddressExpr * node ) {
1177 VISIT_START( node );
1178
1179 indexerScopedAccept( node->result, *this );
[3c398b6]1180 maybeAccept_impl ( node->arg , *this );
[e0886db]1181
1182 VISIT_END( node );
[13932f14]1183}
1184
1185template< typename pass_type >
[e0886db]1186Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
1187 MUTATE_START( node );
1188
1189 indexerScopedMutate( node->env , *this );
1190 indexerScopedMutate( node->result, *this );
[3c398b6]1191 maybeMutate_impl ( node->arg , *this );
[e0886db]1192
1193 MUTATE_END( Expression, node );
1194}
1195
1196//--------------------------------------------------------------------------
1197// LabelAddressExpr
1198template< typename pass_type >
1199void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
1200 VISIT_START( node );
1201
1202 indexerScopedAccept( node->result, *this );
1203
1204 VISIT_END( node );
1205}
1206
1207template< typename pass_type >
1208Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
1209 MUTATE_START( node );
1210
1211 indexerScopedMutate( node->env , *this );
1212 indexerScopedMutate( node->result, *this );
1213
1214 MUTATE_END( Expression, node );
1215}
1216
1217//--------------------------------------------------------------------------
1218// UntypedMemberExpr
1219template< typename pass_type >
1220void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
1221 VISIT_START( node );
1222
1223 indexerScopedAccept( node->result , *this );
[3c398b6]1224 maybeAccept_impl ( node->aggregate, *this );
1225 maybeAccept_impl ( node->member , *this );
[e0886db]1226
1227 VISIT_END( node );
[13932f14]1228}
1229
[e0886db]1230template< typename pass_type >
1231Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
1232 MUTATE_START( node );
1233
1234 indexerScopedMutate( node->env , *this );
1235 indexerScopedMutate( node->result , *this );
[3c398b6]1236 maybeMutate_impl ( node->aggregate, *this );
1237 maybeMutate_impl ( node->member , *this );
[e0886db]1238
1239 MUTATE_END( Expression, node );
1240}
1241
1242//--------------------------------------------------------------------------
1243// MemberExpr
1244template< typename pass_type >
1245void PassVisitor< pass_type >::visit( MemberExpr * node ) {
1246 VISIT_START( node );
1247
1248 indexerScopedAccept( node->result , *this );
[3c398b6]1249 maybeAccept_impl ( node->aggregate, *this );
[e0886db]1250
1251 VISIT_END( node );
1252}
1253
1254template< typename pass_type >
1255Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
1256 MUTATE_START( node );
1257
1258 indexerScopedMutate( node->env , *this );
1259 indexerScopedMutate( node->result , *this );
[3c398b6]1260 maybeMutate_impl ( node->aggregate, *this );
[e0886db]1261
1262 MUTATE_END( Expression, node );
1263}
1264
1265//--------------------------------------------------------------------------
1266// VariableExpr
1267template< typename pass_type >
1268void PassVisitor< pass_type >::visit( VariableExpr * node ) {
1269 VISIT_START( node );
1270
1271 indexerScopedAccept( node->result, *this );
1272
1273 VISIT_END( node );
1274}
1275
1276template< typename pass_type >
1277Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
1278 MUTATE_START( node );
1279
1280 indexerScopedMutate( node->env , *this );
1281 indexerScopedMutate( node->result, *this );
1282
1283 MUTATE_END( Expression, node );
1284}
1285
1286//--------------------------------------------------------------------------
1287// ConstantExpr
[13932f14]1288template< typename pass_type >
[ab904dc]1289void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
[e0886db]1290 VISIT_START( node );
1291
1292 indexerScopedAccept( node->result , *this );
[3c398b6]1293 maybeAccept_impl ( &node->constant, *this );
[e0886db]1294
1295 VISIT_END( node );
[13932f14]1296}
1297
[e0886db]1298template< typename pass_type >
1299Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
1300 MUTATE_START( node );
1301
1302 indexerScopedMutate( node->env , *this );
1303 indexerScopedMutate( node->result, *this );
[3c398b6]1304 Constant * ptr = &node->constant;
1305 maybeMutate_impl( ptr, *this );
1306 node->constant = *ptr;
[e0886db]1307
1308 MUTATE_END( Expression, node );
1309}
1310
1311//--------------------------------------------------------------------------
1312// SizeofExpr
[13932f14]1313template< typename pass_type >
[ab904dc]1314void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
[e0886db]1315 VISIT_START( node );
1316
1317 indexerScopedAccept( node->result, *this );
1318 if ( node->get_isType() ) {
[3c398b6]1319 maybeAccept_impl( node->type, *this );
[e0886db]1320 } else {
[3c398b6]1321 maybeAccept_impl( node->expr, *this );
[e0886db]1322 }
1323
1324 VISIT_END( node );
[13932f14]1325}
1326
[e0886db]1327template< typename pass_type >
1328Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
1329 MUTATE_START( node );
1330
1331 indexerScopedMutate( node->env , *this );
1332 indexerScopedMutate( node->result, *this );
1333 if ( node->get_isType() ) {
[3c398b6]1334 maybeMutate_impl( node->type, *this );
[e0886db]1335 } else {
[3c398b6]1336 maybeMutate_impl( node->expr, *this );
[e0886db]1337 }
1338
1339 MUTATE_END( Expression, node );
1340}
1341
1342//--------------------------------------------------------------------------
1343// AlignofExpr
[13932f14]1344template< typename pass_type >
[ab904dc]1345void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
[e0886db]1346 VISIT_START( node );
1347
1348 indexerScopedAccept( node->result, *this );
1349 if ( node->get_isType() ) {
[3c398b6]1350 maybeAccept_impl( node->type, *this );
[e0886db]1351 } else {
[3c398b6]1352 maybeAccept_impl( node->expr, *this );
[e0886db]1353 }
1354
1355 VISIT_END( node );
[13932f14]1356}
1357
[e0886db]1358template< typename pass_type >
1359Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
1360 MUTATE_START( node );
1361
1362 indexerScopedMutate( node->env , *this );
1363 indexerScopedMutate( node->result, *this );
1364 if ( node->get_isType() ) {
[3c398b6]1365 maybeMutate_impl( node->type, *this );
[e0886db]1366 } else {
[3c398b6]1367 maybeMutate_impl( node->expr, *this );
[e0886db]1368 }
1369
1370 MUTATE_END( Expression, node );
1371}
1372
1373//--------------------------------------------------------------------------
1374// UntypedOffsetofExpr
[13932f14]1375template< typename pass_type >
[ab904dc]1376void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
[e0886db]1377 VISIT_START( node );
1378
1379 indexerScopedAccept( node->result, *this );
[3c398b6]1380 maybeAccept_impl ( node->type , *this );
[e0886db]1381
1382 VISIT_END( node );
[13932f14]1383}
1384
[e0886db]1385template< typename pass_type >
1386Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
1387 MUTATE_START( node );
1388
1389 indexerScopedMutate( node->env , *this );
1390 indexerScopedMutate( node->result, *this );
[3c398b6]1391 maybeMutate_impl ( node->type , *this );
[e0886db]1392
1393 MUTATE_END( Expression, node );
1394}
1395
1396//--------------------------------------------------------------------------
1397// OffsetofExpr
[13932f14]1398template< typename pass_type >
[ab904dc]1399void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
[e0886db]1400 VISIT_START( node );
1401
1402 indexerScopedAccept( node->result, *this );
[3c398b6]1403 maybeAccept_impl ( node->type , *this );
1404 maybeAccept_impl ( node->member, *this );
[e0886db]1405
1406 VISIT_END( node );
[13932f14]1407}
1408
[e0886db]1409template< typename pass_type >
1410Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
1411 MUTATE_START( node );
1412
1413 indexerScopedMutate( node->env , *this );
1414 indexerScopedMutate( node->result, *this );
[3c398b6]1415 maybeMutate_impl ( node->type , *this );
1416 maybeMutate_impl ( node->member, *this );
[e0886db]1417
1418 MUTATE_END( Expression, node );
1419}
1420
1421//--------------------------------------------------------------------------
1422// OffsetPackExpr
[13932f14]1423template< typename pass_type >
[ab904dc]1424void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
[e0886db]1425 VISIT_START( node );
1426
1427 indexerScopedAccept( node->result, *this );
[3c398b6]1428 maybeAccept_impl ( node->type , *this );
[e0886db]1429
1430 VISIT_END( node );
[13932f14]1431}
1432
[e0886db]1433template< typename pass_type >
1434Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
1435 MUTATE_START( node );
1436
1437 indexerScopedMutate( node->env , *this );
1438 indexerScopedMutate( node->result, *this );
[3c398b6]1439 maybeMutate_impl ( node->type , *this );
[e0886db]1440
1441 MUTATE_END( Expression, node );
1442}
1443
1444//--------------------------------------------------------------------------
1445// AttrExpr
[13932f14]1446template< typename pass_type >
[ab904dc]1447void PassVisitor< pass_type >::visit( AttrExpr * node ) {
[e0886db]1448 VISIT_START( node );
1449
1450 indexerScopedAccept( node->result, *this );
1451 if ( node->get_isType() ) {
[3c398b6]1452 maybeAccept_impl( node->type, *this );
[e0886db]1453 } else {
[3c398b6]1454 maybeAccept_impl( node->expr, *this );
[e0886db]1455 }
1456
1457 VISIT_END( node );
1458}
1459
1460template< typename pass_type >
1461Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
1462 MUTATE_START( node );
1463
1464 indexerScopedMutate( node->env , *this );
1465 indexerScopedMutate( node->result, *this );
1466 if ( node->get_isType() ) {
[3c398b6]1467 maybeMutate_impl( node->type, *this );
[e0886db]1468 } else {
[3c398b6]1469 maybeMutate_impl( node->expr, *this );
[e0886db]1470 }
1471
1472 MUTATE_END( Expression, node );
[13932f14]1473}
1474
[e0886db]1475//--------------------------------------------------------------------------
1476// LogicalExpr
[13932f14]1477template< typename pass_type >
[ab904dc]1478void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
[e0886db]1479 VISIT_START( node );
1480
1481 indexerScopedAccept( node->result, *this );
[3c398b6]1482 maybeAccept_impl ( node->arg1 , *this );
1483 maybeAccept_impl ( node->arg2 , *this );
[e0886db]1484
1485 VISIT_END( node );
1486}
1487
1488template< typename pass_type >
1489Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
1490 MUTATE_START( node );
1491
1492 indexerScopedMutate( node->env , *this );
1493 indexerScopedMutate( node->result, *this );
[3c398b6]1494 maybeMutate_impl ( node->arg1 , *this );
1495 maybeMutate_impl ( node->arg2 , *this );
[e0886db]1496
1497 MUTATE_END( Expression, node );
[13932f14]1498}
1499
[e0886db]1500//--------------------------------------------------------------------------
1501// ConditionalExpr
[13932f14]1502template< typename pass_type >
[ab904dc]1503void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
[e0886db]1504 VISIT_START( node );
1505
1506 indexerScopedAccept( node->result, *this );
[3c398b6]1507 maybeAccept_impl ( node->arg1 , *this );
1508 maybeAccept_impl ( node->arg2 , *this );
1509 maybeAccept_impl ( node->arg3 , *this );
[e0886db]1510
1511 VISIT_END( node );
[13932f14]1512}
1513
[e0886db]1514template< typename pass_type >
1515Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
1516 MUTATE_START( node );
1517
1518 indexerScopedMutate( node->env , *this );
1519 indexerScopedMutate( node->result, *this );
[3c398b6]1520 maybeMutate_impl ( node->arg1 , *this );
1521 maybeMutate_impl ( node->arg2 , *this );
1522 maybeMutate_impl ( node->arg3 , *this );
[e0886db]1523
1524 MUTATE_END( Expression, node );
1525}
1526
1527//--------------------------------------------------------------------------
1528// CommaExpr
[13932f14]1529template< typename pass_type >
[ab904dc]1530void PassVisitor< pass_type >::visit( CommaExpr * node ) {
[e0886db]1531 VISIT_START( node );
1532
1533 indexerScopedAccept( node->result, *this );
[3c398b6]1534 maybeAccept_impl ( node->arg1 , *this );
1535 maybeAccept_impl ( node->arg2 , *this );
[e0886db]1536
1537 VISIT_END( node );
1538}
1539
1540template< typename pass_type >
1541Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
1542 MUTATE_START( node );
1543
1544 indexerScopedMutate( node->env , *this );
1545 indexerScopedMutate( node->result, *this );
[3c398b6]1546 maybeMutate_impl ( node->arg1 , *this );
1547 maybeMutate_impl ( node->arg2 , *this );
[e0886db]1548
1549 MUTATE_END( Expression, node );
[13932f14]1550}
1551
[e0886db]1552//--------------------------------------------------------------------------
1553// TypeExpr
[13932f14]1554template< typename pass_type >
[ab904dc]1555void PassVisitor< pass_type >::visit( TypeExpr * node ) {
[e0886db]1556 VISIT_START( node );
1557
1558 indexerScopedAccept( node->result, *this );
[3c398b6]1559 maybeAccept_impl ( node->type, *this );
[e0886db]1560
1561 VISIT_END( node );
[13932f14]1562}
1563
[e0886db]1564template< typename pass_type >
1565Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
1566 MUTATE_START( node );
1567
1568 indexerScopedMutate( node->env , *this );
1569 indexerScopedMutate( node->result, *this );
[3c398b6]1570 maybeMutate_impl ( node->type , *this );
[e0886db]1571
1572 MUTATE_END( Expression, node );
1573}
1574
1575//--------------------------------------------------------------------------
1576// AsmExpr
[13932f14]1577template< typename pass_type >
[ab904dc]1578void PassVisitor< pass_type >::visit( AsmExpr * node ) {
[e0886db]1579 VISIT_START( node );
1580
1581 indexerScopedAccept( node->result , *this );
[3c398b6]1582 maybeAccept_impl ( node->inout , *this );
1583 maybeAccept_impl ( node->constraint, *this );
1584 maybeAccept_impl ( node->operand , *this );
[e0886db]1585
1586 VISIT_END( node );
[13932f14]1587}
1588
[e0886db]1589template< typename pass_type >
1590Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
1591 MUTATE_START( node );
1592
1593 indexerScopedMutate( node->env , *this );
1594 indexerScopedMutate( node->result , *this );
[3c398b6]1595 maybeMutate_impl ( node->inout , *this );
1596 maybeMutate_impl ( node->constraint, *this );
1597 maybeMutate_impl ( node->operand , *this );
[e0886db]1598
1599 MUTATE_END( Expression, node );
1600}
1601
1602//--------------------------------------------------------------------------
1603// ImplicitCopyCtorExpr
[13932f14]1604template< typename pass_type >
[ab904dc]1605void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
[e0886db]1606 VISIT_START( node );
1607
1608 indexerScopedAccept( node->result , *this );
[3c398b6]1609 maybeAccept_impl ( node->callExpr , *this );
1610 maybeAccept_impl ( node->tempDecls , *this );
1611 maybeAccept_impl ( node->returnDecls, *this );
1612 maybeAccept_impl ( node->dtors , *this );
[e0886db]1613
1614 VISIT_END( node );
1615}
1616
1617template< typename pass_type >
1618Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
1619 MUTATE_START( node );
1620
1621 indexerScopedMutate( node->env , *this );
1622 indexerScopedMutate( node->result , *this );
[3c398b6]1623 maybeMutate_impl ( node->callExpr , *this );
1624 maybeMutate_impl ( node->tempDecls , *this );
1625 maybeMutate_impl ( node->returnDecls, *this );
1626 maybeMutate_impl ( node->dtors , *this );
[e0886db]1627
1628 MUTATE_END( Expression, node );
[13932f14]1629}
1630
[e0886db]1631//--------------------------------------------------------------------------
1632// ConstructorExpr
[13932f14]1633template< typename pass_type >
[ab904dc]1634void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
[e0886db]1635 VISIT_START( node );
1636
1637 indexerScopedAccept( node->result , *this );
[3c398b6]1638 maybeAccept_impl ( node->callExpr, *this );
[e0886db]1639
1640 VISIT_END( node );
1641}
1642
1643template< typename pass_type >
1644Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
1645 MUTATE_START( node );
1646
1647 indexerScopedMutate( node->env , *this );
1648 indexerScopedMutate( node->result , *this );
[3c398b6]1649 maybeMutate_impl ( node->callExpr, *this );
[e0886db]1650
1651 MUTATE_END( Expression, node );
[13932f14]1652}
1653
[e0886db]1654//--------------------------------------------------------------------------
1655// CompoundLiteralExpr
[13932f14]1656template< typename pass_type >
[ab904dc]1657void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
[e0886db]1658 VISIT_START( node );
1659
1660 indexerScopedAccept( node->result , *this );
[3c398b6]1661 maybeAccept_impl ( node->initializer, *this );
[e0886db]1662
1663 VISIT_END( node );
[13932f14]1664}
1665
[e0886db]1666template< typename pass_type >
1667Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
1668 MUTATE_START( node );
1669
1670 indexerScopedMutate( node->env , *this );
1671 indexerScopedMutate( node->result , *this );
[3c398b6]1672 maybeMutate_impl ( node->initializer, *this );
[e0886db]1673
1674 MUTATE_END( Expression, node );
1675}
1676
1677//--------------------------------------------------------------------------
1678// RangeExpr
[13932f14]1679template< typename pass_type >
[ab904dc]1680void PassVisitor< pass_type >::visit( RangeExpr * node ) {
[e0886db]1681 VISIT_START( node );
1682
1683 indexerScopedAccept( node->result, *this );
[3c398b6]1684 maybeAccept_impl ( node->low , *this );
1685 maybeAccept_impl ( node->high , *this );
[e0886db]1686
1687 VISIT_END( node );
[13932f14]1688}
1689
[e0886db]1690template< typename pass_type >
1691Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
1692 MUTATE_START( node );
1693
1694 indexerScopedMutate( node->env , *this );
1695 indexerScopedMutate( node->result, *this );
[3c398b6]1696 maybeMutate_impl ( node->low , *this );
1697 maybeMutate_impl ( node->high , *this );
[e0886db]1698
1699 MUTATE_END( Expression, node );
1700}
1701
1702//--------------------------------------------------------------------------
1703// UntypedTupleExpr
[13932f14]1704template< typename pass_type >
[ab904dc]1705void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
[e0886db]1706 VISIT_START( node );
1707
1708 indexerScopedAccept( node->result, *this );
[3c398b6]1709 maybeAccept_impl ( node->exprs , *this );
[e0886db]1710
1711 VISIT_END( node );
1712}
1713
1714template< typename pass_type >
1715Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
1716 MUTATE_START( node );
1717
1718 indexerScopedMutate( node->env , *this );
1719 indexerScopedMutate( node->result, *this );
[3c398b6]1720 maybeMutate_impl ( node->exprs , *this );
[e0886db]1721
1722 MUTATE_END( Expression, node );
1723}
1724
1725//--------------------------------------------------------------------------
1726// TupleExpr
1727template< typename pass_type >
1728void PassVisitor< pass_type >::visit( TupleExpr * node ) {
1729 VISIT_START( node );
1730
1731 indexerScopedAccept( node->result, *this );
[3c398b6]1732 maybeAccept_impl ( node->exprs , *this );
[e0886db]1733
1734 VISIT_END( node );
1735}
1736
1737template< typename pass_type >
1738Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
1739 MUTATE_START( node );
1740
1741 indexerScopedMutate( node->env , *this );
1742 indexerScopedMutate( node->result, *this );
[3c398b6]1743 maybeMutate_impl ( node->exprs , *this );
[e0886db]1744
1745 MUTATE_END( Expression, node );
1746}
1747
1748//--------------------------------------------------------------------------
1749// TupleIndexExpr
1750template< typename pass_type >
1751void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
1752 VISIT_START( node );
1753
1754 indexerScopedAccept( node->result, *this );
[3c398b6]1755 maybeAccept_impl ( node->tuple , *this );
[e0886db]1756
1757 VISIT_END( node );
1758}
1759
1760template< typename pass_type >
1761Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
1762 MUTATE_START( node );
1763
1764 indexerScopedMutate( node->env , *this );
1765 indexerScopedMutate( node->result, *this );
[3c398b6]1766 maybeMutate_impl ( node->tuple , *this );
[e0886db]1767
1768 MUTATE_END( Expression, node );
1769}
1770
1771//--------------------------------------------------------------------------
1772// TupleAssignExpr
1773template< typename pass_type >
1774void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
1775 VISIT_START( node );
1776
1777 indexerScopedAccept( node->result , *this );
[3c398b6]1778 maybeAccept_impl ( node->stmtExpr, *this );
[e0886db]1779
1780 VISIT_END( node );
[13932f14]1781}
1782
1783template< typename pass_type >
[e0886db]1784Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
1785 MUTATE_START( node );
[13932f14]1786
[e0886db]1787 indexerScopedMutate( node->env , *this );
1788 indexerScopedMutate( node->result , *this );
[3c398b6]1789 maybeMutate_impl ( node->stmtExpr, *this );
[13932f14]1790
[e0886db]1791 MUTATE_END( Expression, node );
[13932f14]1792}
1793
[9c1600c]1794//--------------------------------------------------------------------------
[e0886db]1795// StmtExpr
[13932f14]1796template< typename pass_type >
[ab904dc]1797void PassVisitor< pass_type >::visit( StmtExpr * node ) {
[9c1600c]1798 VISIT_START( node );
1799
1800 // don't want statements from outer CompoundStmts to be added to this StmtExpr
1801 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
1802 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1803 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
1804
[e0886db]1805 indexerScopedAccept( node->result , *this );
[3c398b6]1806 maybeAccept_impl ( node->statements , *this );
1807 maybeAccept_impl ( node->returnDecls, *this );
1808 maybeAccept_impl ( node->dtors , *this );
[9c1600c]1809
1810 VISIT_END( node );
[13932f14]1811}
1812
[296b2be]1813template< typename pass_type >
1814Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
1815 MUTATE_START( node );
[4551a6e]1816
[296b2be]1817 // don't want statements from outer CompoundStmts to be added to this StmtExpr
[134322e]1818 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
1819 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1820 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
[296b2be]1821
[e0886db]1822 indexerScopedMutate( node->result , *this );
[3c398b6]1823 maybeMutate_impl ( node->statements , *this );
1824 maybeMutate_impl ( node->returnDecls, *this );
1825 maybeMutate_impl ( node->dtors , *this );
[296b2be]1826
1827 MUTATE_END( Expression, node );
1828}
1829
[e0886db]1830//--------------------------------------------------------------------------
1831// UniqueExpr
[13932f14]1832template< typename pass_type >
[ab904dc]1833void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
[e0886db]1834 VISIT_START( node );
1835
1836 indexerScopedAccept( node->result, *this );
[3c398b6]1837 maybeAccept_impl ( node->expr , *this );
[e0886db]1838
1839 VISIT_END( node );
1840}
1841
1842template< typename pass_type >
1843Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
1844 MUTATE_START( node );
1845
1846 indexerScopedMutate( node->env , *this );
1847 indexerScopedMutate( node->result, *this );
[3c398b6]1848 maybeMutate_impl ( node->expr , *this );
[e0886db]1849
1850 MUTATE_END( Expression, node );
[13932f14]1851}
1852
[73367a8]1853//--------------------------------------------------------------------------
1854// UntypedInitExpr
1855template< typename pass_type >
1856void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
1857 VISIT_START( node );
1858
1859 indexerScopedAccept( node->result, *this );
1860 maybeAccept_impl ( node->expr , *this );
1861 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
1862
1863 VISIT_END( node );
1864}
1865
1866template< typename pass_type >
1867Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
1868 MUTATE_START( node );
1869
1870 indexerScopedMutate( node->env , *this );
1871 indexerScopedMutate( node->result, *this );
1872 maybeMutate_impl ( node->expr , *this );
1873 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
1874
1875 MUTATE_END( Expression, node );
1876}
1877
1878//--------------------------------------------------------------------------
1879// InitExpr
1880template< typename pass_type >
1881void PassVisitor< pass_type >::visit( InitExpr * node ) {
1882 VISIT_START( node );
1883
1884 indexerScopedAccept( node->result, *this );
1885 maybeAccept_impl ( node->expr , *this );
1886 maybeAccept_impl ( node->designation, *this );
1887
1888 VISIT_END( node );
1889}
1890
1891template< typename pass_type >
1892Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
1893 MUTATE_START( node );
1894
1895 indexerScopedMutate( node->env , *this );
1896 indexerScopedMutate( node->result, *this );
1897 maybeMutate_impl ( node->expr , *this );
1898 maybeMutate_impl ( node->designation, *this );
1899
1900 MUTATE_END( Expression, node );
1901}
1902
[13932f14]1903template< typename pass_type >
[ab904dc]1904void PassVisitor< pass_type >::visit( VoidType * node ) {
[4551a6e]1905 VISIT_BODY( node );
[13932f14]1906}
1907
1908template< typename pass_type >
[ab904dc]1909void PassVisitor< pass_type >::visit( BasicType * node ) {
[4551a6e]1910 VISIT_BODY( node );
[13932f14]1911}
1912
1913template< typename pass_type >
[ab904dc]1914void PassVisitor< pass_type >::visit( PointerType * node ) {
[4551a6e]1915 VISIT_BODY( node );
[13932f14]1916}
1917
1918template< typename pass_type >
[ab904dc]1919void PassVisitor< pass_type >::visit( ArrayType * node ) {
[4551a6e]1920 VISIT_BODY( node );
[13932f14]1921}
1922
[6b9b047]1923template< typename pass_type >
1924void PassVisitor< pass_type >::visit( ReferenceType * node ) {
1925 VISIT_BODY( node );
1926}
1927
[13932f14]1928template< typename pass_type >
[ab904dc]1929void PassVisitor< pass_type >::visit( FunctionType * node ) {
[4551a6e]1930 VISIT_BODY( node );
[13932f14]1931}
1932
[e0886db]1933//--------------------------------------------------------------------------
1934// StructInstType
[13932f14]1935template< typename pass_type >
[ab904dc]1936void PassVisitor< pass_type >::visit( StructInstType * node ) {
[e0886db]1937 VISIT_START( node );
1938
1939 indexerAddStruct( node->name );
1940
1941 {
1942 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1943 maybeAccept_impl( node->forall , *this );
1944 maybeAccept_impl( node->parameters, *this );
[e0886db]1945 }
1946
1947 VISIT_END( node );
1948}
1949
1950template< typename pass_type >
1951Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
1952 MUTATE_START( node );
1953
1954 indexerAddStruct( node->name );
1955
1956 {
1957 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1958 maybeMutate_impl( node->forall , *this );
1959 maybeMutate_impl( node->parameters, *this );
[e0886db]1960 }
1961
1962 MUTATE_END( Type, node );
[13932f14]1963}
1964
[e0886db]1965//--------------------------------------------------------------------------
1966// UnionInstType
[13932f14]1967template< typename pass_type >
[ab904dc]1968void PassVisitor< pass_type >::visit( UnionInstType * node ) {
[e0886db]1969 VISIT_START( node );
1970
1971 indexerAddStruct( node->name );
1972
1973 {
1974 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1975 maybeAccept_impl( node->forall , *this );
1976 maybeAccept_impl( node->parameters, *this );
[e0886db]1977 }
1978
1979 VISIT_END( node );
1980}
1981
1982template< typename pass_type >
1983Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
1984 MUTATE_START( node );
1985
1986 indexerAddStruct( node->name );
1987
1988 {
1989 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1990 maybeMutate_impl( node->forall , *this );
1991 maybeMutate_impl( node->parameters, *this );
[e0886db]1992 }
1993
1994 MUTATE_END( Type, node );
[13932f14]1995}
1996
[e0886db]1997//--------------------------------------------------------------------------
1998// EnumInstType
[13932f14]1999template< typename pass_type >
[ab904dc]2000void PassVisitor< pass_type >::visit( EnumInstType * node ) {
[4551a6e]2001 VISIT_BODY( node );
[13932f14]2002}
2003
[e0886db]2004template< typename pass_type >
2005Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
2006 MUTATE_BODY( Type, node );
2007}
2008
2009//--------------------------------------------------------------------------
2010// TraitInstType
[13932f14]2011template< typename pass_type >
[ab904dc]2012void PassVisitor< pass_type >::visit( TraitInstType * node ) {
[e0886db]2013 VISIT_START( node );
2014
[3c398b6]2015 maybeAccept_impl( node->forall , *this );
2016 maybeAccept_impl( node->parameters, *this );
[e0886db]2017
2018 VISIT_END( node );
2019}
2020
2021template< typename pass_type >
2022Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
2023 MUTATE_START( node );
2024
[3c398b6]2025 maybeMutate_impl( node->forall , *this );
2026 maybeMutate_impl( node->parameters, *this );
[e0886db]2027
2028 MUTATE_END( Type, node );
[13932f14]2029}
2030
[e0886db]2031//--------------------------------------------------------------------------
2032// TypeInstType
[13932f14]2033template< typename pass_type >
[ab904dc]2034void PassVisitor< pass_type >::visit( TypeInstType * node ) {
[4551a6e]2035 VISIT_BODY( node );
[13932f14]2036}
2037
2038template< typename pass_type >
[ab904dc]2039void PassVisitor< pass_type >::visit( TupleType * node ) {
[4551a6e]2040 VISIT_BODY( node );
[13932f14]2041}
2042
2043template< typename pass_type >
[ab904dc]2044void PassVisitor< pass_type >::visit( TypeofType * node ) {
[4551a6e]2045 VISIT_BODY( node );
[13932f14]2046}
2047
2048template< typename pass_type >
[ab904dc]2049void PassVisitor< pass_type >::visit( AttrType * node ) {
[4551a6e]2050 VISIT_BODY( node );
[13932f14]2051}
2052
2053template< typename pass_type >
[ab904dc]2054void PassVisitor< pass_type >::visit( VarArgsType * node ) {
[4551a6e]2055 VISIT_BODY( node );
[13932f14]2056}
2057
2058template< typename pass_type >
[ab904dc]2059void PassVisitor< pass_type >::visit( ZeroType * node ) {
[4551a6e]2060 VISIT_BODY( node );
[13932f14]2061}
2062
2063template< typename pass_type >
[ab904dc]2064void PassVisitor< pass_type >::visit( OneType * node ) {
[4551a6e]2065 VISIT_BODY( node );
[13932f14]2066}
2067
[b11d8e2]2068template< typename pass_type >
2069void PassVisitor< pass_type >::visit( Designation * node ) {
2070 VISIT_START( node );
2071
[3c398b6]2072 maybeAccept_impl( node->get_designators(), *this );
[b11d8e2]2073
2074 VISIT_END( node );
2075}
2076
2077template< typename pass_type >
2078Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
2079 MUTATE_START( node );
2080
[3c398b6]2081 maybeMutate_impl( node->get_designators(), *this );
[b11d8e2]2082
2083 MUTATE_END( Designation, node );
2084}
2085
[9c1600c]2086//--------------------------------------------------------------------------
[e0886db]2087// SingleInit
[13932f14]2088template< typename pass_type >
[ab904dc]2089void PassVisitor< pass_type >::visit( SingleInit * node ) {
[9c1600c]2090 VISIT_START( node );
2091
2092 visitExpression( node->get_value() );
2093
2094 VISIT_END( node );
[13932f14]2095}
2096
[296b2be]2097template< typename pass_type >
2098Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
2099 MUTATE_START( node );
2100
2101 node->set_value( mutateExpression( node->get_value() ) );
2102
2103 MUTATE_END( Initializer, node );
2104}
2105
[13932f14]2106template< typename pass_type >
[ab904dc]2107void PassVisitor< pass_type >::visit( ListInit * node ) {
[4551a6e]2108 VISIT_BODY( node );
[13932f14]2109}
2110
2111template< typename pass_type >
[ab904dc]2112void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
[4551a6e]2113 VISIT_BODY( node );
[13932f14]2114}
2115
2116template< typename pass_type >
[ab904dc]2117void PassVisitor< pass_type >::visit( Subrange * node ) {
[4551a6e]2118 VISIT_BODY( node );
[13932f14]2119}
2120
2121template< typename pass_type >
[ab904dc]2122void PassVisitor< pass_type >::visit( Constant * node ) {
[4551a6e]2123 VISIT_BODY( node );
[13932f14]2124}
[ab904dc]2125
[5ea7a22]2126template< typename pass_type >
2127void PassVisitor< pass_type >::visit( Attribute * node ) {
2128 VISIT_BODY( node );
2129}
2130
[ab904dc]2131//---------------------------------------------------------------------------------------------------------------
2132template< typename pass_type >
2133Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
2134 MUTATE_BODY( Type, node );
2135}
2136
2137template< typename pass_type >
2138Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
2139 MUTATE_BODY( Type, node );
2140}
2141
2142template< typename pass_type >
2143Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
2144 MUTATE_BODY( Type, node );
2145}
2146
2147template< typename pass_type >
2148Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
2149 MUTATE_BODY( Type, node );
2150}
2151
2152template< typename pass_type >
[6b9b047]2153Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
2154 MUTATE_BODY( Type, node );
2155}
2156
2157template< typename pass_type >
[ab904dc]2158Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
2159 MUTATE_BODY( Type, node );
2160}
2161
2162template< typename pass_type >
2163Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
2164 MUTATE_BODY( Type, node );
2165}
2166
2167template< typename pass_type >
2168Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
2169 MUTATE_BODY( Type, node );
2170}
2171
2172template< typename pass_type >
2173Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
2174 MUTATE_BODY( Type, node );
2175}
2176
2177template< typename pass_type >
2178Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
2179 MUTATE_BODY( Type, node );
2180}
2181
2182template< typename pass_type >
2183Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
2184 MUTATE_BODY( Type, node );
2185}
2186
2187template< typename pass_type >
2188Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
2189 MUTATE_BODY( Type, node );
2190}
2191
2192template< typename pass_type >
2193Type * PassVisitor< pass_type >::mutate( OneType * node ) {
2194 MUTATE_BODY( Type, node );
2195}
2196
2197template< typename pass_type >
2198Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
2199 MUTATE_BODY( Initializer, node );
2200}
2201
2202template< typename pass_type >
2203Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
2204 MUTATE_BODY( Initializer, node );
2205}
2206
2207template< typename pass_type >
2208Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) {
2209 MUTATE_BODY( Subrange, node );
2210}
2211
2212template< typename pass_type >
2213Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
2214 MUTATE_BODY( Constant, node );
[4551a6e]2215}
[5ea7a22]2216
2217template< typename pass_type >
2218Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
2219 MUTATE_BODY( Attribute, node );
2220}
[447c356]2221
2222template< typename pass_type >
2223TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
2224 MUTATE_START( node );
2225
2226 for ( auto & p : node->typeEnv ) {
2227 indexerScopedMutate( p.second, *this );
2228 }
2229 for ( auto & p : node->varEnv ) {
2230 indexerScopedMutate( p.second, *this );
2231 }
2232
2233 MUTATE_END( TypeSubstitution, node );
2234}
Note: See TracBrowser for help on using the repository browser.