source: src/Common/PassVisitor.impl.h@ 539cdfe

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 539cdfe was 11b7028, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Expand VISIT/MUTATE_BODY for FinallyStmt

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