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

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

Fixed visit children to properly work with the indexer

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