source: src/Common/PassVisitor.impl.h@ 24de7b1

new-env with_gc
Last change on this file since 24de7b1 was 09a1ae6, checked in by Aaron Moss <a3moss@…>, 8 years ago

Fix some missing static roots -- GC'd CFA-CC now builds prelude

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