source: src/Common/PassVisitor.impl.h@ 5f08961d

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 with_gc
Last change on this file since 5f08961d was f6e3e34, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Add StaticAssertDecl node

  • Property mode set to 100644
File size: 73.7 KB
RevLine 
[13932f14]1#pragma once
[3268a58]2// IWYU pragma: private, include "PassVisitor.h"
[13932f14]3
[3c398b6]4#define VISIT_START( node ) \
5 __attribute__((unused)) \
6 ChildrenGuard children_guard( get_visit_children_ptr() ); \
7 __attribute__((unused)) \
[62423350]8 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
[3c398b6]9 call_previsit( node ); \
[6e09f211]10
11#define VISIT_END( node ) \
12 call_postvisit( node ); \
[9c1600c]13
[3c398b6]14#define MUTATE_START( node ) \
15 __attribute__((unused)) \
16 ChildrenGuard children_guard( get_visit_children_ptr() ); \
17 __attribute__((unused)) \
[62423350]18 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
[3c398b6]19 call_premutate( node ); \
[296b2be]20
21#define MUTATE_END( type, node ) \
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();
[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
399 static ObjectDecl func(
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 );
404 indexerAddId( &func );
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
429 static ObjectDecl func(
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 );
434 indexerAddId( &func );
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
[f6e3e34]686//--------------------------------------------------------------------------
687// StaticAssertDecl
688template< typename pass_type >
689void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) {
690 VISIT_START( node );
691
692 maybeAccept_impl( node->condition, *this );
693 maybeAccept_impl( node->message , *this );
694
695 VISIT_END( node );
696}
697
698template< typename pass_type >
699StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) {
700 MUTATE_START( node );
701
702 maybeMutate_impl( node->condition, *this );
703 maybeMutate_impl( node->message , *this );
704
705 MUTATE_END( StaticAssertDecl, node );
706}
707
[e0886db]708//--------------------------------------------------------------------------
709// CompoundStmt
710template< typename pass_type >
711void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
712 VISIT_START( node );
713 {
714 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
715 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
716 visitStatementList( node->kids );
717 }
718 VISIT_END( node );
719}
[296b2be]720
[e0886db]721template< typename pass_type >
722CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
723 MUTATE_START( node );
724 {
725 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
726 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
727 mutateStatementList( node->kids );
728 }
[296b2be]729 MUTATE_END( CompoundStmt, node );
730}
731
[9c1600c]732//--------------------------------------------------------------------------
733// ExprStmt
[13932f14]734template< typename pass_type >
[ab904dc]735void PassVisitor< pass_type >::visit( ExprStmt * node ) {
[9c1600c]736 VISIT_START( node );
737
[e0886db]738 visitExpression( node->expr );
[9c1600c]739
740 VISIT_END( node );
[13932f14]741}
742
[296b2be]743template< typename pass_type >
744Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
745 MUTATE_START( node );
746
[e0886db]747 node->expr = mutateExpression( node->expr );
[296b2be]748
749 MUTATE_END( Statement, node );
750}
751
[6ca154b]752//--------------------------------------------------------------------------
753// AsmStmt
[13932f14]754template< typename pass_type >
[ab904dc]755void PassVisitor< pass_type >::visit( AsmStmt * node ) {
[bc6f918]756 VISIT_START( node )
757
758 maybeAccept_impl( node->instruction, *this );
759 maybeAccept_impl( node->output, *this );
760 maybeAccept_impl( node->input, *this );
761 maybeAccept_impl( node->clobber, *this );
762
763 VISIT_END( node );
[13932f14]764}
765
[6ca154b]766template< typename pass_type >
767Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
[bc6f918]768 MUTATE_START( node );
769
770 maybeMutate_impl( node->instruction, *this );
771 maybeMutate_impl( node->output, *this );
772 maybeMutate_impl( node->input, *this );
773 maybeMutate_impl( node->clobber, *this );
774
775 MUTATE_END( Statement, node );
[6ca154b]776}
777
[9c1600c]778//--------------------------------------------------------------------------
779// IfStmt
[13932f14]780template< typename pass_type >
[ab904dc]781void PassVisitor< pass_type >::visit( IfStmt * node ) {
[4551a6e]782 VISIT_START( node );
[33a25f9]783 {
784 // if statements introduce a level of scope (for the initialization)
785 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]786 maybeAccept_impl( node->get_initialization(), *this );
787 visitExpression ( node->condition );
[33a25f9]788 node->thenPart = visitStatement( node->thenPart );
789 node->elsePart = visitStatement( node->elsePart );
790 }
[9c1600c]791 VISIT_END( node );
[13932f14]792}
793
[296b2be]794template< typename pass_type >
795Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
[4551a6e]796 MUTATE_START( node );
[e0886db]797 {
[33a25f9]798 // if statements introduce a level of scope (for the initialization)
[e0886db]799 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]800 maybeMutate_impl( node->get_initialization(), *this );
[e0886db]801 node->condition = mutateExpression( node->condition );
802 node->thenPart = mutateStatement ( node->thenPart );
803 node->elsePart = mutateStatement ( node->elsePart );
804 }
[296b2be]805 MUTATE_END( Statement, node );
806}
807
[9c1600c]808//--------------------------------------------------------------------------
809// WhileStmt
[13932f14]810template< typename pass_type >
[ab904dc]811void PassVisitor< pass_type >::visit( WhileStmt * node ) {
[4551a6e]812 VISIT_START( node );
[9c1600c]813
[e0886db]814 visitExpression( node->condition );
815 node->body = visitStatement( node->body );
[9c1600c]816
817 VISIT_END( node );
[13932f14]818}
819
[296b2be]820template< typename pass_type >
821Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
[4551a6e]822 MUTATE_START( node );
[296b2be]823
[e0886db]824 node->condition = mutateExpression( node->condition );
825 node->body = mutateStatement ( node->body );
[296b2be]826
827 MUTATE_END( Statement, node );
828}
829
[9c1600c]830//--------------------------------------------------------------------------
[6ca154b]831// ForStmt
[13932f14]832template< typename pass_type >
[ab904dc]833void PassVisitor< pass_type >::visit( ForStmt * node ) {
[4551a6e]834 VISIT_START( node );
[e0886db]835 {
[33a25f9]836 // for statements introduce a level of scope (for the initialization)
[e0886db]837 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]838 maybeAccept_impl( node->initialization, *this );
[e0886db]839 visitExpression( node->condition );
840 visitExpression( node->increment );
841 node->body = visitStatement( node->body );
842 }
[9c1600c]843 VISIT_END( node );
[13932f14]844}
845
[296b2be]846template< typename pass_type >
847Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
[4551a6e]848 MUTATE_START( node );
[e0886db]849 {
[33a25f9]850 // for statements introduce a level of scope (for the initialization)
[e0886db]851 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]852 maybeMutate_impl( node->initialization, *this );
[e0886db]853 node->condition = mutateExpression( node->condition );
854 node->increment = mutateExpression( node->increment );
855 node->body = mutateStatement ( node->body );
856 }
[296b2be]857 MUTATE_END( Statement, node );
858}
859
[9c1600c]860//--------------------------------------------------------------------------
861// SwitchStmt
[13932f14]862template< typename pass_type >
[ab904dc]863void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
[4551a6e]864 VISIT_START( node );
[9c1600c]865
[e0886db]866 visitExpression ( node->condition );
867 visitStatementList( node->statements );
[9c1600c]868
869 VISIT_END( node );
[13932f14]870}
871
[296b2be]872template< typename pass_type >
873Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
[4551a6e]874 MUTATE_START( node );
875
[e0886db]876 node->condition = mutateExpression( node->condition );
877 mutateStatementList( node->statements );
[4551a6e]878
[296b2be]879 MUTATE_END( Statement, node );
880}
881
[9c1600c]882//--------------------------------------------------------------------------
[35df560]883// CaseStmt
[13932f14]884template< typename pass_type >
[ab904dc]885void PassVisitor< pass_type >::visit( CaseStmt * node ) {
[4551a6e]886 VISIT_START( node );
887
[e0886db]888 visitExpression ( node->condition );
889 visitStatementList( node->stmts );
[4551a6e]890
[9c1600c]891 VISIT_END( node );
[13932f14]892}
893
[296b2be]894template< typename pass_type >
895Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
[4551a6e]896 MUTATE_START( node );
897
[e0886db]898 node->condition = mutateExpression( node->condition );
899 mutateStatementList( node->stmts );
[4551a6e]900
[296b2be]901 MUTATE_END( Statement, node );
902}
903
[6ca154b]904//--------------------------------------------------------------------------
905// BranchStmt
[13932f14]906template< typename pass_type >
[ab904dc]907void PassVisitor< pass_type >::visit( BranchStmt * node ) {
[33c0ce8]908 VISIT_START( node );
909 VISIT_END( node );
[13932f14]910}
911
[6ca154b]912template< typename pass_type >
913Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
[33c0ce8]914 MUTATE_START( node );
915 MUTATE_END( Statement, node );
[6ca154b]916}
917
[9c1600c]918//--------------------------------------------------------------------------
919// ReturnStmt
[13932f14]920template< typename pass_type >
[ab904dc]921void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
[9c1600c]922 VISIT_START( node );
923
[e0886db]924 visitExpression( node->expr );
[9c1600c]925
926 VISIT_END( node );
[13932f14]927}
928
[296b2be]929template< typename pass_type >
930Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
931 MUTATE_START( node );
932
[e0886db]933 node->expr = mutateExpression( node->expr );
[296b2be]934
935 MUTATE_END( Statement, node );
936}
937
[6e09f211]938//--------------------------------------------------------------------------
939// ThrowStmt
940
941template< typename pass_type >
942void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
[33c0ce8]943 VISIT_START( node );
944
945 maybeAccept_impl( node->expr, *this );
946 maybeAccept_impl( node->target, *this );
947
948 VISIT_END( node );
[6e09f211]949}
950
951template< typename pass_type >
952Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
[33c0ce8]953 MUTATE_START( node );
954
955 maybeMutate_impl( node->expr, *this );
956 maybeMutate_impl( node->target, *this );
957
958 MUTATE_END( Statement, node );
[6e09f211]959}
960
[9c1600c]961//--------------------------------------------------------------------------
962// TryStmt
[13932f14]963template< typename pass_type >
[ab904dc]964void PassVisitor< pass_type >::visit( TryStmt * node ) {
[9c1600c]965 VISIT_START( node );
966
[3c398b6]967 maybeAccept_impl( node->block , *this );
968 maybeAccept_impl( node->handlers , *this );
969 maybeAccept_impl( node->finallyBlock, *this );
[9c1600c]970
971 VISIT_END( node );
[13932f14]972}
973
[296b2be]974template< typename pass_type >
975Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
976 MUTATE_START( node );
977
[3c398b6]978 maybeMutate_impl( node->block , *this );
979 maybeMutate_impl( node->handlers , *this );
980 maybeMutate_impl( node->finallyBlock, *this );
[4551a6e]981
[296b2be]982 MUTATE_END( Statement, node );
983}
984
[9c1600c]985//--------------------------------------------------------------------------
986// CatchStmt
[13932f14]987template< typename pass_type >
[ab904dc]988void PassVisitor< pass_type >::visit( CatchStmt * node ) {
[9c1600c]989 VISIT_START( node );
[e0886db]990 {
[33a25f9]991 // catch statements introduce a level of scope (for the caught exception)
[e0886db]992 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]993 maybeAccept_impl( node->decl, *this );
[e0886db]994 node->cond = visitExpression( node->cond );
995 node->body = visitStatement ( node->body );
996 }
[9c1600c]997 VISIT_END( node );
[13932f14]998}
999
[296b2be]1000template< typename pass_type >
1001Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
1002 MUTATE_START( node );
[e0886db]1003 {
[33a25f9]1004 // catch statements introduce a level of scope (for the caught exception)
[e0886db]1005 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]1006 maybeMutate_impl( node->decl, *this );
[e0886db]1007 node->cond = mutateExpression( node->cond );
1008 node->body = mutateStatement ( node->body );
1009 }
[296b2be]1010 MUTATE_END( Statement, node );
1011}
1012
[2065609]1013//--------------------------------------------------------------------------
1014// FinallyStmt
[13932f14]1015template< typename pass_type >
[ab904dc]1016void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
[11b7028]1017 VISIT_START( node );
1018
1019 maybeAccept_impl( node->block, *this );
1020
1021 VISIT_END( node );
[13932f14]1022}
1023
[2065609]1024template< typename pass_type >
1025Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
[11b7028]1026 MUTATE_START( node );
1027
1028 maybeMutate_impl( node->block, *this );
1029
1030 MUTATE_END( Statement, node );
[2065609]1031}
1032
1033//--------------------------------------------------------------------------
1034// WaitForStmt
1035template< typename pass_type >
1036void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
[834b892]1037 VISIT_START( node );
1038
1039 for( auto & clause : node->clauses ) {
1040 maybeAccept_impl( clause.target.function, *this );
1041 maybeAccept_impl( clause.target.arguments, *this );
1042
1043 maybeAccept_impl( clause.statement, *this );
1044 maybeAccept_impl( clause.condition, *this );
1045 }
1046
1047 maybeAccept_impl( node->timeout.time, *this );
1048 maybeAccept_impl( node->timeout.statement, *this );
1049 maybeAccept_impl( node->timeout.condition, *this );
1050 maybeAccept_impl( node->orelse.statement, *this );
1051 maybeAccept_impl( node->orelse.condition, *this );
1052
1053 VISIT_END( node );
[2065609]1054}
1055
1056template< typename pass_type >
1057Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
[834b892]1058 MUTATE_START( node );
1059
1060 for( auto & clause : node->clauses ) {
1061 maybeMutate_impl( clause.target.function, *this );
1062 maybeMutate_impl( clause.target.arguments, *this );
1063
1064 maybeMutate_impl( clause.statement, *this );
1065 maybeMutate_impl( clause.condition, *this );
1066 }
1067
1068 maybeMutate_impl( node->timeout.time, *this );
1069 maybeMutate_impl( node->timeout.statement, *this );
1070 maybeMutate_impl( node->timeout.condition, *this );
1071 maybeMutate_impl( node->orelse.statement, *this );
1072 maybeMutate_impl( node->orelse.condition, *this );
1073
1074 MUTATE_END( Statement, node );
[2065609]1075}
1076
[d8893ca]1077
1078
[61255ad]1079//--------------------------------------------------------------------------
1080// NullStmt
1081template< typename pass_type >
1082void PassVisitor< pass_type >::visit( WithStmt * node ) {
[d8893ca]1083 VISIT_START( node );
1084 maybeAccept_impl( node->exprs, *this );
1085 {
1086 // catch statements introduce a level of scope (for the caught exception)
1087 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]1088 indexerAddWith( node->exprs, node );
[d8893ca]1089 maybeAccept_impl( node->stmt, *this );
1090 }
1091 VISIT_END( node );
[61255ad]1092}
1093
1094template< typename pass_type >
1095Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
[d8893ca]1096 MUTATE_START( node );
1097 maybeMutate_impl( node->exprs, *this );
1098 {
1099 // catch statements introduce a level of scope (for the caught exception)
1100 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[0ac366b]1101 indexerAddWith( node->exprs, node );
[d8893ca]1102 maybeMutate_impl( node->stmt, *this );
1103 }
1104 MUTATE_END( Statement, node );
[61255ad]1105}
1106
[2065609]1107//--------------------------------------------------------------------------
1108// NullStmt
[13932f14]1109template< typename pass_type >
[ab904dc]1110void PassVisitor< pass_type >::visit( NullStmt * node ) {
[5964127]1111 VISIT_START( node );
1112 VISIT_END( node );
[13932f14]1113}
1114
[2065609]1115template< typename pass_type >
1116NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
[5964127]1117 MUTATE_START( node );
1118 MUTATE_END( NullStmt, node );
[2065609]1119}
1120
1121//--------------------------------------------------------------------------
1122// DeclStmt
[13932f14]1123template< typename pass_type >
[ab904dc]1124void PassVisitor< pass_type >::visit( DeclStmt * node ) {
[5964127]1125 VISIT_START( node );
1126
1127 maybeAccept_impl( node->decl, *this );
1128
1129 VISIT_END( node );
[13932f14]1130}
1131
[2065609]1132template< typename pass_type >
1133Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
[5964127]1134 MUTATE_START( node );
1135
1136 maybeMutate_impl( node->decl, *this );
1137
1138 MUTATE_END( Statement, node );
[2065609]1139}
1140
1141//--------------------------------------------------------------------------
1142// ImplicitCtorDtorStmt
[13932f14]1143template< typename pass_type >
[ab904dc]1144void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
[599fbb6]1145 VISIT_START( node );
1146
1147 maybeAccept_impl( node->callStmt, *this );
1148
1149 VISIT_END( node );
[13932f14]1150}
1151
[2065609]1152template< typename pass_type >
1153Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
[599fbb6]1154 MUTATE_START( node );
1155
1156 maybeMutate_impl( node->callStmt, *this );
1157
1158 MUTATE_END( Statement, node );
[2065609]1159}
1160
1161//--------------------------------------------------------------------------
1162// ApplicationExpr
[13932f14]1163template< typename pass_type >
[ab904dc]1164void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
[e0886db]1165 VISIT_START( node );
1166
1167 indexerScopedAccept( node->result , *this );
[3c398b6]1168 maybeAccept_impl ( node->function, *this );
1169 maybeAccept_impl ( node->args , *this );
[e0886db]1170
1171 VISIT_END( node );
[13932f14]1172}
1173
[2065609]1174template< typename pass_type >
1175Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
[e0886db]1176 MUTATE_START( node );
1177
1178 indexerScopedMutate( node->env , *this );
1179 indexerScopedMutate( node->result , *this );
[3c398b6]1180 maybeMutate_impl ( node->function, *this );
1181 maybeMutate_impl ( node->args , *this );
[e0886db]1182
1183 MUTATE_END( Expression, node );
[2065609]1184}
1185
[9c1600c]1186//--------------------------------------------------------------------------
1187// UntypedExpr
[13932f14]1188template< typename pass_type >
[ab904dc]1189void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
[9c1600c]1190 VISIT_START( node );
1191
[3c398b6]1192 // maybeAccept_impl( node->get_env(), *this );
[e0886db]1193 indexerScopedAccept( node->result, *this );
[2a7b3ca]1194
[e0886db]1195 for ( auto expr : node->args ) {
[9c1600c]1196 visitExpression( expr );
1197 }
1198
1199 VISIT_END( node );
[13932f14]1200}
1201
[296b2be]1202template< typename pass_type >
1203Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
1204 MUTATE_START( node );
1205
[e0886db]1206 indexerScopedMutate( node->env , *this );
1207 indexerScopedMutate( node->result, *this );
[2a7b3ca]1208
[e0886db]1209 for ( auto& expr : node->args ) {
[296b2be]1210 expr = mutateExpression( expr );
1211 }
1212
1213 MUTATE_END( Expression, node );
1214}
1215
[e0886db]1216//--------------------------------------------------------------------------
1217// NameExpr
[13932f14]1218template< typename pass_type >
[ab904dc]1219void PassVisitor< pass_type >::visit( NameExpr * node ) {
[e0886db]1220 VISIT_START( node );
1221
1222 indexerScopedAccept( node->result, *this );
1223
1224 VISIT_END( node );
[13932f14]1225}
1226
1227template< typename pass_type >
[e0886db]1228Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
1229 MUTATE_START( node );
1230
1231 indexerScopedMutate( node->env , *this );
1232 indexerScopedMutate( node->result, *this );
1233
1234 MUTATE_END( Expression, node );
[13932f14]1235}
1236
[e0886db]1237//--------------------------------------------------------------------------
1238// CastExpr
[a5f0529]1239template< typename pass_type >
[e0886db]1240void PassVisitor< pass_type >::visit( CastExpr * node ) {
1241 VISIT_START( node );
1242
1243 indexerScopedAccept( node->result, *this );
[3c398b6]1244 maybeAccept_impl ( node->arg , *this );
[e0886db]1245
1246 VISIT_END( node );
[a5f0529]1247}
1248
[13932f14]1249template< typename pass_type >
[e0886db]1250Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
1251 MUTATE_START( node );
1252
1253 indexerScopedMutate( node->env , *this );
1254 indexerScopedMutate( node->result, *this );
[3c398b6]1255 maybeMutate_impl ( node->arg , *this );
[e0886db]1256
1257 MUTATE_END( Expression, node );
[13932f14]1258}
1259
[e0886db]1260//--------------------------------------------------------------------------
1261// VirtualCastExpr
[13932f14]1262template< typename pass_type >
[e0886db]1263void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
1264 VISIT_START( node );
1265
1266 indexerScopedAccept( node->result, *this );
[3c398b6]1267 maybeAccept_impl( node->arg, *this );
[e0886db]1268
1269 VISIT_END( node );
[13932f14]1270}
1271
1272template< typename pass_type >
[e0886db]1273Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
1274 MUTATE_START( node );
1275
1276 indexerScopedMutate( node->env , *this );
1277 indexerScopedMutate( node->result, *this );
[3c398b6]1278 maybeMutate_impl ( node->arg , *this );
[e0886db]1279
1280 MUTATE_END( Expression, node );
[13932f14]1281}
1282
[e0886db]1283//--------------------------------------------------------------------------
1284// AddressExpr
[13932f14]1285template< typename pass_type >
[e0886db]1286void PassVisitor< pass_type >::visit( AddressExpr * node ) {
1287 VISIT_START( node );
1288
1289 indexerScopedAccept( node->result, *this );
[3c398b6]1290 maybeAccept_impl ( node->arg , *this );
[e0886db]1291
1292 VISIT_END( node );
[13932f14]1293}
1294
1295template< typename pass_type >
[e0886db]1296Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
1297 MUTATE_START( node );
1298
1299 indexerScopedMutate( node->env , *this );
1300 indexerScopedMutate( node->result, *this );
[3c398b6]1301 maybeMutate_impl ( node->arg , *this );
[e0886db]1302
1303 MUTATE_END( Expression, node );
1304}
1305
1306//--------------------------------------------------------------------------
1307// LabelAddressExpr
1308template< typename pass_type >
1309void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
1310 VISIT_START( node );
1311
1312 indexerScopedAccept( node->result, *this );
1313
1314 VISIT_END( node );
1315}
1316
1317template< typename pass_type >
1318Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
1319 MUTATE_START( node );
1320
1321 indexerScopedMutate( node->env , *this );
1322 indexerScopedMutate( node->result, *this );
1323
1324 MUTATE_END( Expression, node );
1325}
1326
1327//--------------------------------------------------------------------------
1328// UntypedMemberExpr
1329template< typename pass_type >
1330void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
1331 VISIT_START( node );
1332
1333 indexerScopedAccept( node->result , *this );
[3c398b6]1334 maybeAccept_impl ( node->aggregate, *this );
1335 maybeAccept_impl ( node->member , *this );
[e0886db]1336
1337 VISIT_END( node );
[13932f14]1338}
1339
[e0886db]1340template< typename pass_type >
1341Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
1342 MUTATE_START( node );
1343
1344 indexerScopedMutate( node->env , *this );
1345 indexerScopedMutate( node->result , *this );
[3c398b6]1346 maybeMutate_impl ( node->aggregate, *this );
1347 maybeMutate_impl ( node->member , *this );
[e0886db]1348
1349 MUTATE_END( Expression, node );
1350}
1351
1352//--------------------------------------------------------------------------
1353// MemberExpr
1354template< typename pass_type >
1355void PassVisitor< pass_type >::visit( MemberExpr * node ) {
1356 VISIT_START( node );
1357
1358 indexerScopedAccept( node->result , *this );
[3c398b6]1359 maybeAccept_impl ( node->aggregate, *this );
[e0886db]1360
1361 VISIT_END( node );
1362}
1363
1364template< typename pass_type >
1365Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
1366 MUTATE_START( node );
1367
1368 indexerScopedMutate( node->env , *this );
1369 indexerScopedMutate( node->result , *this );
[3c398b6]1370 maybeMutate_impl ( node->aggregate, *this );
[e0886db]1371
1372 MUTATE_END( Expression, node );
1373}
1374
1375//--------------------------------------------------------------------------
1376// VariableExpr
1377template< typename pass_type >
1378void PassVisitor< pass_type >::visit( VariableExpr * node ) {
1379 VISIT_START( node );
1380
1381 indexerScopedAccept( node->result, *this );
1382
1383 VISIT_END( node );
1384}
1385
1386template< typename pass_type >
1387Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
1388 MUTATE_START( node );
1389
1390 indexerScopedMutate( node->env , *this );
1391 indexerScopedMutate( node->result, *this );
1392
1393 MUTATE_END( Expression, node );
1394}
1395
1396//--------------------------------------------------------------------------
1397// ConstantExpr
[13932f14]1398template< typename pass_type >
[ab904dc]1399void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
[e0886db]1400 VISIT_START( node );
1401
1402 indexerScopedAccept( node->result , *this );
[3c398b6]1403 maybeAccept_impl ( &node->constant, *this );
[e0886db]1404
1405 VISIT_END( node );
[13932f14]1406}
1407
[e0886db]1408template< typename pass_type >
1409Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
1410 MUTATE_START( node );
1411
1412 indexerScopedMutate( node->env , *this );
1413 indexerScopedMutate( node->result, *this );
[3c398b6]1414 Constant * ptr = &node->constant;
1415 maybeMutate_impl( ptr, *this );
1416 node->constant = *ptr;
[e0886db]1417
1418 MUTATE_END( Expression, node );
1419}
1420
1421//--------------------------------------------------------------------------
1422// SizeofExpr
[13932f14]1423template< typename pass_type >
[ab904dc]1424void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
[e0886db]1425 VISIT_START( node );
1426
1427 indexerScopedAccept( node->result, *this );
1428 if ( node->get_isType() ) {
[3c398b6]1429 maybeAccept_impl( node->type, *this );
[e0886db]1430 } else {
[3c398b6]1431 maybeAccept_impl( node->expr, *this );
[e0886db]1432 }
1433
1434 VISIT_END( node );
[13932f14]1435}
1436
[e0886db]1437template< typename pass_type >
1438Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
1439 MUTATE_START( node );
1440
1441 indexerScopedMutate( node->env , *this );
1442 indexerScopedMutate( node->result, *this );
1443 if ( node->get_isType() ) {
[3c398b6]1444 maybeMutate_impl( node->type, *this );
[e0886db]1445 } else {
[3c398b6]1446 maybeMutate_impl( node->expr, *this );
[e0886db]1447 }
1448
1449 MUTATE_END( Expression, node );
1450}
1451
1452//--------------------------------------------------------------------------
1453// AlignofExpr
[13932f14]1454template< typename pass_type >
[ab904dc]1455void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
[e0886db]1456 VISIT_START( node );
1457
1458 indexerScopedAccept( node->result, *this );
1459 if ( node->get_isType() ) {
[3c398b6]1460 maybeAccept_impl( node->type, *this );
[e0886db]1461 } else {
[3c398b6]1462 maybeAccept_impl( node->expr, *this );
[e0886db]1463 }
1464
1465 VISIT_END( node );
[13932f14]1466}
1467
[e0886db]1468template< typename pass_type >
1469Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
1470 MUTATE_START( node );
1471
1472 indexerScopedMutate( node->env , *this );
1473 indexerScopedMutate( node->result, *this );
1474 if ( node->get_isType() ) {
[3c398b6]1475 maybeMutate_impl( node->type, *this );
[e0886db]1476 } else {
[3c398b6]1477 maybeMutate_impl( node->expr, *this );
[e0886db]1478 }
1479
1480 MUTATE_END( Expression, node );
1481}
1482
1483//--------------------------------------------------------------------------
1484// UntypedOffsetofExpr
[13932f14]1485template< typename pass_type >
[ab904dc]1486void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
[e0886db]1487 VISIT_START( node );
1488
1489 indexerScopedAccept( node->result, *this );
[3c398b6]1490 maybeAccept_impl ( node->type , *this );
[e0886db]1491
1492 VISIT_END( node );
[13932f14]1493}
1494
[e0886db]1495template< typename pass_type >
1496Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
1497 MUTATE_START( node );
1498
1499 indexerScopedMutate( node->env , *this );
1500 indexerScopedMutate( node->result, *this );
[3c398b6]1501 maybeMutate_impl ( node->type , *this );
[e0886db]1502
1503 MUTATE_END( Expression, node );
1504}
1505
1506//--------------------------------------------------------------------------
1507// OffsetofExpr
[13932f14]1508template< typename pass_type >
[ab904dc]1509void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
[e0886db]1510 VISIT_START( node );
1511
1512 indexerScopedAccept( node->result, *this );
[3c398b6]1513 maybeAccept_impl ( node->type , *this );
[e0886db]1514
1515 VISIT_END( node );
[13932f14]1516}
1517
[e0886db]1518template< typename pass_type >
1519Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
1520 MUTATE_START( node );
1521
1522 indexerScopedMutate( node->env , *this );
1523 indexerScopedMutate( node->result, *this );
[3c398b6]1524 maybeMutate_impl ( node->type , *this );
[e0886db]1525
1526 MUTATE_END( Expression, node );
1527}
1528
1529//--------------------------------------------------------------------------
1530// OffsetPackExpr
[13932f14]1531template< typename pass_type >
[ab904dc]1532void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
[e0886db]1533 VISIT_START( node );
1534
1535 indexerScopedAccept( node->result, *this );
[3c398b6]1536 maybeAccept_impl ( node->type , *this );
[e0886db]1537
1538 VISIT_END( node );
[13932f14]1539}
1540
[e0886db]1541template< typename pass_type >
1542Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
1543 MUTATE_START( node );
1544
1545 indexerScopedMutate( node->env , *this );
1546 indexerScopedMutate( node->result, *this );
[3c398b6]1547 maybeMutate_impl ( node->type , *this );
[e0886db]1548
1549 MUTATE_END( Expression, node );
1550}
1551
1552//--------------------------------------------------------------------------
1553// AttrExpr
[13932f14]1554template< typename pass_type >
[ab904dc]1555void PassVisitor< pass_type >::visit( AttrExpr * node ) {
[e0886db]1556 VISIT_START( node );
1557
1558 indexerScopedAccept( node->result, *this );
1559 if ( node->get_isType() ) {
[3c398b6]1560 maybeAccept_impl( node->type, *this );
[e0886db]1561 } else {
[3c398b6]1562 maybeAccept_impl( node->expr, *this );
[e0886db]1563 }
1564
1565 VISIT_END( node );
1566}
1567
1568template< typename pass_type >
1569Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
1570 MUTATE_START( node );
1571
1572 indexerScopedMutate( node->env , *this );
1573 indexerScopedMutate( node->result, *this );
1574 if ( node->get_isType() ) {
[3c398b6]1575 maybeMutate_impl( node->type, *this );
[e0886db]1576 } else {
[3c398b6]1577 maybeMutate_impl( node->expr, *this );
[e0886db]1578 }
1579
1580 MUTATE_END( Expression, node );
[13932f14]1581}
1582
[e0886db]1583//--------------------------------------------------------------------------
1584// LogicalExpr
[13932f14]1585template< typename pass_type >
[ab904dc]1586void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
[e0886db]1587 VISIT_START( node );
1588
1589 indexerScopedAccept( node->result, *this );
[3c398b6]1590 maybeAccept_impl ( node->arg1 , *this );
1591 maybeAccept_impl ( node->arg2 , *this );
[e0886db]1592
1593 VISIT_END( node );
1594}
1595
1596template< typename pass_type >
1597Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
1598 MUTATE_START( node );
1599
1600 indexerScopedMutate( node->env , *this );
1601 indexerScopedMutate( node->result, *this );
[3c398b6]1602 maybeMutate_impl ( node->arg1 , *this );
1603 maybeMutate_impl ( node->arg2 , *this );
[e0886db]1604
1605 MUTATE_END( Expression, node );
[13932f14]1606}
1607
[e0886db]1608//--------------------------------------------------------------------------
1609// ConditionalExpr
[13932f14]1610template< typename pass_type >
[ab904dc]1611void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
[e0886db]1612 VISIT_START( node );
1613
1614 indexerScopedAccept( node->result, *this );
[3c398b6]1615 maybeAccept_impl ( node->arg1 , *this );
1616 maybeAccept_impl ( node->arg2 , *this );
1617 maybeAccept_impl ( node->arg3 , *this );
[e0886db]1618
1619 VISIT_END( node );
[13932f14]1620}
1621
[e0886db]1622template< typename pass_type >
1623Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
1624 MUTATE_START( node );
1625
1626 indexerScopedMutate( node->env , *this );
1627 indexerScopedMutate( node->result, *this );
[3c398b6]1628 maybeMutate_impl ( node->arg1 , *this );
1629 maybeMutate_impl ( node->arg2 , *this );
1630 maybeMutate_impl ( node->arg3 , *this );
[e0886db]1631
1632 MUTATE_END( Expression, node );
1633}
1634
1635//--------------------------------------------------------------------------
1636// CommaExpr
[13932f14]1637template< typename pass_type >
[ab904dc]1638void PassVisitor< pass_type >::visit( CommaExpr * node ) {
[e0886db]1639 VISIT_START( node );
1640
1641 indexerScopedAccept( node->result, *this );
[3c398b6]1642 maybeAccept_impl ( node->arg1 , *this );
1643 maybeAccept_impl ( node->arg2 , *this );
[e0886db]1644
1645 VISIT_END( node );
1646}
1647
1648template< typename pass_type >
1649Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
1650 MUTATE_START( node );
1651
1652 indexerScopedMutate( node->env , *this );
1653 indexerScopedMutate( node->result, *this );
[3c398b6]1654 maybeMutate_impl ( node->arg1 , *this );
1655 maybeMutate_impl ( node->arg2 , *this );
[e0886db]1656
1657 MUTATE_END( Expression, node );
[13932f14]1658}
1659
[e0886db]1660//--------------------------------------------------------------------------
1661// TypeExpr
[13932f14]1662template< typename pass_type >
[ab904dc]1663void PassVisitor< pass_type >::visit( TypeExpr * node ) {
[e0886db]1664 VISIT_START( node );
1665
1666 indexerScopedAccept( node->result, *this );
[3c398b6]1667 maybeAccept_impl ( node->type, *this );
[e0886db]1668
1669 VISIT_END( node );
[13932f14]1670}
1671
[e0886db]1672template< typename pass_type >
1673Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
1674 MUTATE_START( node );
1675
1676 indexerScopedMutate( node->env , *this );
1677 indexerScopedMutate( node->result, *this );
[3c398b6]1678 maybeMutate_impl ( node->type , *this );
[e0886db]1679
1680 MUTATE_END( Expression, node );
1681}
1682
1683//--------------------------------------------------------------------------
1684// AsmExpr
[13932f14]1685template< typename pass_type >
[ab904dc]1686void PassVisitor< pass_type >::visit( AsmExpr * node ) {
[e0886db]1687 VISIT_START( node );
1688
1689 indexerScopedAccept( node->result , *this );
[3c398b6]1690 maybeAccept_impl ( node->inout , *this );
1691 maybeAccept_impl ( node->constraint, *this );
1692 maybeAccept_impl ( node->operand , *this );
[e0886db]1693
1694 VISIT_END( node );
[13932f14]1695}
1696
[e0886db]1697template< typename pass_type >
1698Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
1699 MUTATE_START( node );
1700
1701 indexerScopedMutate( node->env , *this );
1702 indexerScopedMutate( node->result , *this );
[3c398b6]1703 maybeMutate_impl ( node->inout , *this );
1704 maybeMutate_impl ( node->constraint, *this );
1705 maybeMutate_impl ( node->operand , *this );
[e0886db]1706
1707 MUTATE_END( Expression, node );
1708}
1709
1710//--------------------------------------------------------------------------
1711// ImplicitCopyCtorExpr
[13932f14]1712template< typename pass_type >
[ab904dc]1713void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
[e0886db]1714 VISIT_START( node );
1715
1716 indexerScopedAccept( node->result , *this );
[3c398b6]1717 maybeAccept_impl ( node->callExpr , *this );
1718 maybeAccept_impl ( node->tempDecls , *this );
1719 maybeAccept_impl ( node->returnDecls, *this );
1720 maybeAccept_impl ( node->dtors , *this );
[e0886db]1721
1722 VISIT_END( node );
1723}
1724
1725template< typename pass_type >
1726Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
1727 MUTATE_START( node );
1728
1729 indexerScopedMutate( node->env , *this );
1730 indexerScopedMutate( node->result , *this );
[3c398b6]1731 maybeMutate_impl ( node->callExpr , *this );
1732 maybeMutate_impl ( node->tempDecls , *this );
1733 maybeMutate_impl ( node->returnDecls, *this );
1734 maybeMutate_impl ( node->dtors , *this );
[e0886db]1735
1736 MUTATE_END( Expression, node );
[13932f14]1737}
1738
[e0886db]1739//--------------------------------------------------------------------------
1740// ConstructorExpr
[13932f14]1741template< typename pass_type >
[ab904dc]1742void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
[e0886db]1743 VISIT_START( node );
1744
1745 indexerScopedAccept( node->result , *this );
[3c398b6]1746 maybeAccept_impl ( node->callExpr, *this );
[e0886db]1747
1748 VISIT_END( node );
1749}
1750
1751template< typename pass_type >
1752Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
1753 MUTATE_START( node );
1754
1755 indexerScopedMutate( node->env , *this );
1756 indexerScopedMutate( node->result , *this );
[3c398b6]1757 maybeMutate_impl ( node->callExpr, *this );
[e0886db]1758
1759 MUTATE_END( Expression, node );
[13932f14]1760}
1761
[e0886db]1762//--------------------------------------------------------------------------
1763// CompoundLiteralExpr
[13932f14]1764template< typename pass_type >
[ab904dc]1765void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
[e0886db]1766 VISIT_START( node );
1767
1768 indexerScopedAccept( node->result , *this );
[3c398b6]1769 maybeAccept_impl ( node->initializer, *this );
[e0886db]1770
1771 VISIT_END( node );
[13932f14]1772}
1773
[e0886db]1774template< typename pass_type >
1775Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
1776 MUTATE_START( node );
1777
1778 indexerScopedMutate( node->env , *this );
1779 indexerScopedMutate( node->result , *this );
[3c398b6]1780 maybeMutate_impl ( node->initializer, *this );
[e0886db]1781
1782 MUTATE_END( Expression, node );
1783}
1784
1785//--------------------------------------------------------------------------
1786// RangeExpr
[13932f14]1787template< typename pass_type >
[ab904dc]1788void PassVisitor< pass_type >::visit( RangeExpr * node ) {
[e0886db]1789 VISIT_START( node );
1790
1791 indexerScopedAccept( node->result, *this );
[3c398b6]1792 maybeAccept_impl ( node->low , *this );
1793 maybeAccept_impl ( node->high , *this );
[e0886db]1794
1795 VISIT_END( node );
[13932f14]1796}
1797
[e0886db]1798template< typename pass_type >
1799Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
1800 MUTATE_START( node );
1801
1802 indexerScopedMutate( node->env , *this );
1803 indexerScopedMutate( node->result, *this );
[3c398b6]1804 maybeMutate_impl ( node->low , *this );
1805 maybeMutate_impl ( node->high , *this );
[e0886db]1806
1807 MUTATE_END( Expression, node );
1808}
1809
1810//--------------------------------------------------------------------------
1811// UntypedTupleExpr
[13932f14]1812template< typename pass_type >
[ab904dc]1813void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
[e0886db]1814 VISIT_START( node );
1815
1816 indexerScopedAccept( node->result, *this );
[3c398b6]1817 maybeAccept_impl ( node->exprs , *this );
[e0886db]1818
1819 VISIT_END( node );
1820}
1821
1822template< typename pass_type >
1823Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
1824 MUTATE_START( node );
1825
1826 indexerScopedMutate( node->env , *this );
1827 indexerScopedMutate( node->result, *this );
[3c398b6]1828 maybeMutate_impl ( node->exprs , *this );
[e0886db]1829
1830 MUTATE_END( Expression, node );
1831}
1832
1833//--------------------------------------------------------------------------
1834// TupleExpr
1835template< typename pass_type >
1836void PassVisitor< pass_type >::visit( TupleExpr * node ) {
1837 VISIT_START( node );
1838
1839 indexerScopedAccept( node->result, *this );
[3c398b6]1840 maybeAccept_impl ( node->exprs , *this );
[e0886db]1841
1842 VISIT_END( node );
1843}
1844
1845template< typename pass_type >
1846Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
1847 MUTATE_START( node );
1848
1849 indexerScopedMutate( node->env , *this );
1850 indexerScopedMutate( node->result, *this );
[3c398b6]1851 maybeMutate_impl ( node->exprs , *this );
[e0886db]1852
1853 MUTATE_END( Expression, node );
1854}
1855
1856//--------------------------------------------------------------------------
1857// TupleIndexExpr
1858template< typename pass_type >
1859void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
1860 VISIT_START( node );
1861
1862 indexerScopedAccept( node->result, *this );
[3c398b6]1863 maybeAccept_impl ( node->tuple , *this );
[e0886db]1864
1865 VISIT_END( node );
1866}
1867
1868template< typename pass_type >
1869Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
1870 MUTATE_START( node );
1871
1872 indexerScopedMutate( node->env , *this );
1873 indexerScopedMutate( node->result, *this );
[3c398b6]1874 maybeMutate_impl ( node->tuple , *this );
[e0886db]1875
1876 MUTATE_END( Expression, node );
1877}
1878
1879//--------------------------------------------------------------------------
1880// TupleAssignExpr
1881template< typename pass_type >
1882void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
1883 VISIT_START( node );
1884
1885 indexerScopedAccept( node->result , *this );
[3c398b6]1886 maybeAccept_impl ( node->stmtExpr, *this );
[e0886db]1887
1888 VISIT_END( node );
[13932f14]1889}
1890
1891template< typename pass_type >
[e0886db]1892Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
1893 MUTATE_START( node );
[13932f14]1894
[e0886db]1895 indexerScopedMutate( node->env , *this );
1896 indexerScopedMutate( node->result , *this );
[3c398b6]1897 maybeMutate_impl ( node->stmtExpr, *this );
[13932f14]1898
[e0886db]1899 MUTATE_END( Expression, node );
[13932f14]1900}
1901
[9c1600c]1902//--------------------------------------------------------------------------
[e0886db]1903// StmtExpr
[13932f14]1904template< typename pass_type >
[ab904dc]1905void PassVisitor< pass_type >::visit( StmtExpr * node ) {
[9c1600c]1906 VISIT_START( node );
1907
1908 // don't want statements from outer CompoundStmts to be added to this StmtExpr
1909 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
1910 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1911 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
1912
[e0886db]1913 indexerScopedAccept( node->result , *this );
[3c398b6]1914 maybeAccept_impl ( node->statements , *this );
1915 maybeAccept_impl ( node->returnDecls, *this );
1916 maybeAccept_impl ( node->dtors , *this );
[9c1600c]1917
1918 VISIT_END( node );
[13932f14]1919}
1920
[296b2be]1921template< typename pass_type >
1922Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
1923 MUTATE_START( node );
[4551a6e]1924
[296b2be]1925 // don't want statements from outer CompoundStmts to be added to this StmtExpr
[134322e]1926 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
1927 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1928 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
[296b2be]1929
[e0886db]1930 indexerScopedMutate( node->result , *this );
[3c398b6]1931 maybeMutate_impl ( node->statements , *this );
1932 maybeMutate_impl ( node->returnDecls, *this );
1933 maybeMutate_impl ( node->dtors , *this );
[296b2be]1934
1935 MUTATE_END( Expression, node );
1936}
1937
[e0886db]1938//--------------------------------------------------------------------------
1939// UniqueExpr
[13932f14]1940template< typename pass_type >
[ab904dc]1941void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
[e0886db]1942 VISIT_START( node );
1943
1944 indexerScopedAccept( node->result, *this );
[3c398b6]1945 maybeAccept_impl ( node->expr , *this );
[e0886db]1946
1947 VISIT_END( node );
1948}
1949
1950template< typename pass_type >
1951Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
1952 MUTATE_START( node );
1953
1954 indexerScopedMutate( node->env , *this );
1955 indexerScopedMutate( node->result, *this );
[3c398b6]1956 maybeMutate_impl ( node->expr , *this );
[e0886db]1957
1958 MUTATE_END( Expression, node );
[13932f14]1959}
1960
[73367a8]1961//--------------------------------------------------------------------------
1962// UntypedInitExpr
1963template< typename pass_type >
1964void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
1965 VISIT_START( node );
1966
1967 indexerScopedAccept( node->result, *this );
1968 maybeAccept_impl ( node->expr , *this );
1969 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
1970
1971 VISIT_END( node );
1972}
1973
1974template< typename pass_type >
1975Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
1976 MUTATE_START( node );
1977
1978 indexerScopedMutate( node->env , *this );
1979 indexerScopedMutate( node->result, *this );
1980 maybeMutate_impl ( node->expr , *this );
1981 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
1982
1983 MUTATE_END( Expression, node );
1984}
1985
1986//--------------------------------------------------------------------------
1987// InitExpr
1988template< typename pass_type >
1989void PassVisitor< pass_type >::visit( InitExpr * node ) {
1990 VISIT_START( node );
1991
1992 indexerScopedAccept( node->result, *this );
1993 maybeAccept_impl ( node->expr , *this );
1994 maybeAccept_impl ( node->designation, *this );
1995
1996 VISIT_END( node );
1997}
1998
1999template< typename pass_type >
2000Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
2001 MUTATE_START( node );
2002
2003 indexerScopedMutate( node->env , *this );
2004 indexerScopedMutate( node->result, *this );
2005 maybeMutate_impl ( node->expr , *this );
2006 maybeMutate_impl ( node->designation, *this );
2007
2008 MUTATE_END( Expression, node );
2009}
2010
[44b4114]2011//--------------------------------------------------------------------------
2012// DeletedExpr
2013template< typename pass_type >
2014void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
2015 VISIT_START( node );
2016
2017 indexerScopedAccept( node->result, *this );
2018 maybeAccept_impl( node->expr, *this );
2019 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
2020
2021 VISIT_END( node );
2022}
2023
2024template< typename pass_type >
2025Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
2026 MUTATE_START( node );
2027
2028 indexerScopedMutate( node->env, *this );
2029 indexerScopedMutate( node->result, *this );
2030 maybeMutate_impl( node->expr, *this );
2031
2032 MUTATE_END( Expression, node );
2033}
2034
[17fc7a5]2035//--------------------------------------------------------------------------
2036// VoidType
[13932f14]2037template< typename pass_type >
[ab904dc]2038void PassVisitor< pass_type >::visit( VoidType * node ) {
[599fbb6]2039 VISIT_START( node );
2040
2041 maybeAccept_impl( node->forall, *this );
2042
2043 VISIT_END( node );
2044}
2045
2046template< typename pass_type >
2047Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
2048 MUTATE_START( node );
2049
2050 maybeMutate_impl( node->forall, *this );
2051
2052 MUTATE_END( Type, node );
[13932f14]2053}
2054
[17fc7a5]2055//--------------------------------------------------------------------------
2056// BasicType
[13932f14]2057template< typename pass_type >
[ab904dc]2058void PassVisitor< pass_type >::visit( BasicType * node ) {
[17fc7a5]2059 VISIT_START( node );
2060
2061 maybeAccept_impl( node->forall, *this );
2062
2063 VISIT_END( node );
2064}
2065
2066template< typename pass_type >
2067Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
2068 MUTATE_START( node );
2069
2070 maybeMutate_impl( node->forall, *this );
2071
2072 MUTATE_END( Type, node );
[13932f14]2073}
2074
[17fc7a5]2075//--------------------------------------------------------------------------
2076// PointerType
[13932f14]2077template< typename pass_type >
[ab904dc]2078void PassVisitor< pass_type >::visit( PointerType * node ) {
[17fc7a5]2079 VISIT_START( node );
2080
2081 maybeAccept_impl( node->forall, *this );
[cfaf9be]2082 // xxx - should PointerType visit/mutate dimension?
[17fc7a5]2083 maybeAccept_impl( node->base, *this );
2084
2085 VISIT_END( node );
[13932f14]2086}
2087
[17fc7a5]2088template< typename pass_type >
2089Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
2090 MUTATE_START( node );
2091
2092 maybeMutate_impl( node->forall, *this );
[cfaf9be]2093 // xxx - should PointerType visit/mutate dimension?
[17fc7a5]2094 maybeMutate_impl( node->base, *this );
2095
2096 MUTATE_END( Type, node );
2097}
2098
2099//--------------------------------------------------------------------------
2100// ArrayType
[13932f14]2101template< typename pass_type >
[ab904dc]2102void PassVisitor< pass_type >::visit( ArrayType * node ) {
[17fc7a5]2103 VISIT_START( node );
2104
2105 maybeAccept_impl( node->forall, *this );
2106 maybeAccept_impl( node->dimension, *this );
2107 maybeAccept_impl( node->base, *this );
2108
2109 VISIT_END( node );
[13932f14]2110}
2111
[17fc7a5]2112template< typename pass_type >
2113Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
2114 MUTATE_START( node );
2115
2116 maybeMutate_impl( node->forall, *this );
2117 maybeMutate_impl( node->dimension, *this );
2118 maybeMutate_impl( node->base, *this );
2119
2120 MUTATE_END( Type, node );
2121}
2122
2123//--------------------------------------------------------------------------
2124// ReferenceType
[6b9b047]2125template< typename pass_type >
2126void PassVisitor< pass_type >::visit( ReferenceType * node ) {
[17fc7a5]2127 VISIT_START( node );
2128
2129 maybeAccept_impl( node->forall, *this );
2130 maybeAccept_impl( node->base, *this );
2131
2132 VISIT_END( node );
2133}
2134
2135template< typename pass_type >
2136Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
2137 MUTATE_START( node );
2138
2139 maybeMutate_impl( node->forall, *this );
2140 maybeMutate_impl( node->base, *this );
2141
2142 MUTATE_END( Type, node );
[6b9b047]2143}
2144
[17fc7a5]2145//--------------------------------------------------------------------------
2146// FunctionType
[13932f14]2147template< typename pass_type >
[ab904dc]2148void PassVisitor< pass_type >::visit( FunctionType * node ) {
[17fc7a5]2149 VISIT_START( node );
2150
2151 maybeAccept_impl( node->forall, *this );
2152 maybeAccept_impl( node->returnVals, *this );
2153 maybeAccept_impl( node->parameters, *this );
2154
2155 VISIT_END( node );
2156}
2157
2158template< typename pass_type >
2159Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
2160 MUTATE_START( node );
2161
2162 maybeMutate_impl( node->forall, *this );
2163 maybeMutate_impl( node->returnVals, *this );
2164 maybeMutate_impl( node->parameters, *this );
2165
2166 MUTATE_END( Type, node );
[13932f14]2167}
2168
[e0886db]2169//--------------------------------------------------------------------------
2170// StructInstType
[13932f14]2171template< typename pass_type >
[ab904dc]2172void PassVisitor< pass_type >::visit( StructInstType * node ) {
[e0886db]2173 VISIT_START( node );
2174
2175 indexerAddStruct( node->name );
2176
2177 {
2178 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2179 maybeAccept_impl( node->forall , *this );
2180 maybeAccept_impl( node->parameters, *this );
[e0886db]2181 }
2182
2183 VISIT_END( node );
2184}
2185
2186template< typename pass_type >
2187Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
2188 MUTATE_START( node );
2189
2190 indexerAddStruct( node->name );
2191
2192 {
2193 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2194 maybeMutate_impl( node->forall , *this );
2195 maybeMutate_impl( node->parameters, *this );
[e0886db]2196 }
2197
2198 MUTATE_END( Type, node );
[13932f14]2199}
2200
[e0886db]2201//--------------------------------------------------------------------------
2202// UnionInstType
[13932f14]2203template< typename pass_type >
[ab904dc]2204void PassVisitor< pass_type >::visit( UnionInstType * node ) {
[e0886db]2205 VISIT_START( node );
2206
2207 indexerAddStruct( node->name );
2208
2209 {
2210 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2211 maybeAccept_impl( node->forall , *this );
2212 maybeAccept_impl( node->parameters, *this );
[e0886db]2213 }
2214
2215 VISIT_END( node );
2216}
2217
2218template< typename pass_type >
2219Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
2220 MUTATE_START( node );
2221
2222 indexerAddStruct( node->name );
2223
2224 {
2225 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
[3c398b6]2226 maybeMutate_impl( node->forall , *this );
2227 maybeMutate_impl( node->parameters, *this );
[e0886db]2228 }
2229
2230 MUTATE_END( Type, node );
[13932f14]2231}
2232
[e0886db]2233//--------------------------------------------------------------------------
2234// EnumInstType
[13932f14]2235template< typename pass_type >
[ab904dc]2236void PassVisitor< pass_type >::visit( EnumInstType * node ) {
[86e84e4]2237 VISIT_START( node );
2238
2239 maybeAccept_impl( node->forall, *this );
2240 maybeAccept_impl( node->parameters, *this );
2241
2242 VISIT_END( node );
[13932f14]2243}
2244
[e0886db]2245template< typename pass_type >
2246Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
[86e84e4]2247 MUTATE_START( node );
2248
2249 maybeMutate_impl( node->forall, *this );
2250 maybeMutate_impl( node->parameters, *this );
2251
2252 MUTATE_END( Type, node );
[e0886db]2253}
2254
2255//--------------------------------------------------------------------------
2256// TraitInstType
[13932f14]2257template< typename pass_type >
[ab904dc]2258void PassVisitor< pass_type >::visit( TraitInstType * node ) {
[e0886db]2259 VISIT_START( node );
2260
[3c398b6]2261 maybeAccept_impl( node->forall , *this );
2262 maybeAccept_impl( node->parameters, *this );
[e0886db]2263
2264 VISIT_END( node );
2265}
2266
2267template< typename pass_type >
2268Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
2269 MUTATE_START( node );
2270
[3c398b6]2271 maybeMutate_impl( node->forall , *this );
2272 maybeMutate_impl( node->parameters, *this );
[e0886db]2273
2274 MUTATE_END( Type, node );
[13932f14]2275}
2276
[e0886db]2277//--------------------------------------------------------------------------
2278// TypeInstType
[13932f14]2279template< typename pass_type >
[ab904dc]2280void PassVisitor< pass_type >::visit( TypeInstType * node ) {
[86e84e4]2281 VISIT_START( node );
2282
2283 maybeAccept_impl( node->forall , *this );
2284 maybeAccept_impl( node->parameters, *this );
2285
2286 VISIT_END( node );
2287}
2288
2289template< typename pass_type >
2290Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
2291 MUTATE_START( node );
2292
2293 maybeMutate_impl( node->forall , *this );
2294 maybeMutate_impl( node->parameters, *this );
2295
2296 MUTATE_END( Type, node );
[13932f14]2297}
2298
[a8a2b0a]2299//--------------------------------------------------------------------------
2300// TupleType
[13932f14]2301template< typename pass_type >
[ab904dc]2302void PassVisitor< pass_type >::visit( TupleType * node ) {
[a8a2b0a]2303 VISIT_START( node );
2304
2305 maybeAccept_impl( node->forall, *this );
2306 maybeAccept_impl( node->types, *this );
2307 maybeAccept_impl( node->members, *this );
2308
2309 VISIT_END( node );
[13932f14]2310}
2311
[a8a2b0a]2312template< typename pass_type >
2313Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
2314 MUTATE_START( node );
2315
2316 maybeMutate_impl( node->forall, *this );
2317 maybeMutate_impl( node->types, *this );
2318 maybeMutate_impl( node->members, *this );
2319
2320 MUTATE_END( Type, node );
2321}
2322
2323//--------------------------------------------------------------------------
2324// TypeofType
[13932f14]2325template< typename pass_type >
[ab904dc]2326void PassVisitor< pass_type >::visit( TypeofType * node ) {
[a8a2b0a]2327 VISIT_START( node );
2328
2329 assert( node->expr );
2330 maybeAccept_impl( node->expr, *this );
2331
2332 VISIT_END( node );
[13932f14]2333}
2334
[a8a2b0a]2335template< typename pass_type >
2336Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
2337 MUTATE_START( node );
2338
2339 assert( node->expr );
2340 maybeMutate_impl( node->expr, *this );
2341
2342 MUTATE_END( Type, node );
2343}
2344
2345//--------------------------------------------------------------------------
2346// AttrType
[13932f14]2347template< typename pass_type >
[ab904dc]2348void PassVisitor< pass_type >::visit( AttrType * node ) {
[a8a2b0a]2349 VISIT_START( node );
2350
2351 if ( node->isType ) {
2352 assert( node->type );
2353 maybeAccept_impl( node->type, *this );
2354 } else {
2355 assert( node->expr );
2356 maybeAccept_impl( node->expr, *this );
2357 } // if
2358
2359 VISIT_END( node );
[13932f14]2360}
2361
[a8a2b0a]2362template< typename pass_type >
2363Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
2364 MUTATE_START( node );
2365
2366 if ( node->isType ) {
2367 assert( node->type );
2368 maybeMutate_impl( node->type, *this );
2369 } else {
2370 assert( node->expr );
2371 maybeMutate_impl( node->expr, *this );
2372 } // if
2373
2374 MUTATE_END( Type, node );
2375}
2376
2377//--------------------------------------------------------------------------
2378// VarArgsType
[13932f14]2379template< typename pass_type >
[ab904dc]2380void PassVisitor< pass_type >::visit( VarArgsType * node ) {
[a8a2b0a]2381 VISIT_START( node );
2382
2383 maybeAccept_impl( node->forall, *this );
2384
2385 VISIT_END( node );
[13932f14]2386}
2387
[a8a2b0a]2388template< typename pass_type >
2389Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
2390 MUTATE_START( node );
2391
2392 maybeMutate_impl( node->forall, *this );
2393
2394 MUTATE_END( Type, node );
2395}
2396
2397//--------------------------------------------------------------------------
2398// ZeroType
[13932f14]2399template< typename pass_type >
[ab904dc]2400void PassVisitor< pass_type >::visit( ZeroType * node ) {
[a8a2b0a]2401 VISIT_START( node );
2402
2403 maybeAccept_impl( node->forall, *this );
2404
2405 VISIT_END( node );
[13932f14]2406}
2407
[a8a2b0a]2408template< typename pass_type >
2409Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
2410 MUTATE_START( node );
2411
2412 maybeMutate_impl( node->forall, *this );
2413
2414 MUTATE_END( Type, node );
2415}
2416
2417//--------------------------------------------------------------------------
2418// OneType
[13932f14]2419template< typename pass_type >
[ab904dc]2420void PassVisitor< pass_type >::visit( OneType * node ) {
[a8a2b0a]2421 VISIT_START( node );
2422
2423 maybeAccept_impl( node->forall, *this );
2424
2425 VISIT_END( node );
[13932f14]2426}
2427
[a8a2b0a]2428template< typename pass_type >
2429Type * PassVisitor< pass_type >::mutate( OneType * node ) {
2430 MUTATE_START( node );
2431
2432 maybeMutate_impl( node->forall, *this );
2433
2434 MUTATE_END( Type, node );
2435}
2436
2437//--------------------------------------------------------------------------
2438// Designation
[b11d8e2]2439template< typename pass_type >
2440void PassVisitor< pass_type >::visit( Designation * node ) {
2441 VISIT_START( node );
2442
[a8a2b0a]2443 maybeAccept_impl( node->designators, *this );
[b11d8e2]2444
2445 VISIT_END( node );
2446}
2447
2448template< typename pass_type >
2449Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
2450 MUTATE_START( node );
2451
[a8a2b0a]2452 maybeMutate_impl( node->designators, *this );
[b11d8e2]2453
2454 MUTATE_END( Designation, node );
2455}
2456
[9c1600c]2457//--------------------------------------------------------------------------
[e0886db]2458// SingleInit
[13932f14]2459template< typename pass_type >
[ab904dc]2460void PassVisitor< pass_type >::visit( SingleInit * node ) {
[9c1600c]2461 VISIT_START( node );
2462
[a8a2b0a]2463 visitExpression( node->value );
[9c1600c]2464
2465 VISIT_END( node );
[13932f14]2466}
2467
[296b2be]2468template< typename pass_type >
2469Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
2470 MUTATE_START( node );
2471
[a8a2b0a]2472 node->value = mutateExpression( node->value );
[296b2be]2473
2474 MUTATE_END( Initializer, node );
2475}
2476
[a8a2b0a]2477//--------------------------------------------------------------------------
2478// ListInit
[13932f14]2479template< typename pass_type >
[ab904dc]2480void PassVisitor< pass_type >::visit( ListInit * node ) {
[a8a2b0a]2481 VISIT_START( node );
[13932f14]2482
[a8a2b0a]2483 maybeAccept_impl( node->designations, *this );
2484 maybeAccept_impl( node->initializers, *this );
[13932f14]2485
[a8a2b0a]2486 VISIT_END( node );
[13932f14]2487}
2488
2489template< typename pass_type >
[a8a2b0a]2490Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
2491 MUTATE_START( node );
2492
2493 maybeMutate_impl( node->designations, *this );
2494 maybeMutate_impl( node->initializers, *this );
2495
2496 MUTATE_END( Initializer, node );
[13932f14]2497}
[ab904dc]2498
[a8a2b0a]2499//--------------------------------------------------------------------------
2500// ConstructorInit
[5ea7a22]2501template< typename pass_type >
[a8a2b0a]2502void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
2503 VISIT_START( node );
[5ea7a22]2504
[a8a2b0a]2505 maybeAccept_impl( node->ctor, *this );
2506 maybeAccept_impl( node->dtor, *this );
2507 maybeAccept_impl( node->init, *this );
[ab904dc]2508
[a8a2b0a]2509 VISIT_END( node );
[ab904dc]2510}
2511
2512template< typename pass_type >
[a8a2b0a]2513Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
2514 MUTATE_START( node );
[ab904dc]2515
[a8a2b0a]2516 maybeMutate_impl( node->ctor, *this );
2517 maybeMutate_impl( node->dtor, *this );
2518 maybeMutate_impl( node->init, *this );
[ab904dc]2519
[a8a2b0a]2520 MUTATE_END( Initializer, node );
[ab904dc]2521}
2522
[a8a2b0a]2523//--------------------------------------------------------------------------
2524// Subrange
[ab904dc]2525template< typename pass_type >
[a8a2b0a]2526void PassVisitor< pass_type >::visit( Subrange * node ) {
2527 VISIT_START( node );
[ab904dc]2528
[a8a2b0a]2529 VISIT_END( node );
[ab904dc]2530}
2531
2532template< typename pass_type >
[a8a2b0a]2533Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) {
2534 MUTATE_START( node );
2535
2536 MUTATE_END( Subrange, node );
[ab904dc]2537}
2538
[a8a2b0a]2539//--------------------------------------------------------------------------
2540// Attribute
[ab904dc]2541template< typename pass_type >
[a8a2b0a]2542void PassVisitor< pass_type >::visit( Constant * node ) {
2543 VISIT_START( node );
2544
2545 VISIT_END( node );
[ab904dc]2546}
2547
2548template< typename pass_type >
[a8a2b0a]2549Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
2550 MUTATE_START( node );
2551
2552 MUTATE_END( Constant, node );
[ab904dc]2553}
2554
[a8a2b0a]2555//--------------------------------------------------------------------------
2556// Attribute
[ab904dc]2557template< typename pass_type >
[a8a2b0a]2558void PassVisitor< pass_type >::visit( Attribute * node ) {
2559 VISIT_START( node );
2560
2561 maybeAccept_impl( node->parameters, *this );
2562
2563 VISIT_END( node );
[4551a6e]2564}
[5ea7a22]2565
2566template< typename pass_type >
2567Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
[a8a2b0a]2568 MUTATE_START( node );
2569
2570 maybeMutate_impl( node->parameters, *this );
2571
2572 MUTATE_END( Attribute, node );
[5ea7a22]2573}
[447c356]2574
[a8a2b0a]2575//--------------------------------------------------------------------------
2576// TypeSubstitution
[447c356]2577template< typename pass_type >
2578TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
2579 MUTATE_START( node );
2580
2581 for ( auto & p : node->typeEnv ) {
2582 indexerScopedMutate( p.second, *this );
2583 }
2584 for ( auto & p : node->varEnv ) {
2585 indexerScopedMutate( p.second, *this );
2586 }
2587
2588 MUTATE_END( TypeSubstitution, node );
2589}
Note: See TracBrowser for help on using the repository browser.