source: src/Common/PassVisitor.impl.h@ 7aaec67

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

Add with clause support to PassVisitor

  • Property mode set to 100644
File size: 65.2 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_BODY( node );
740}
741
742template< typename pass_type >
743Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
744 MUTATE_BODY( Statement, node );
745}
746
747//--------------------------------------------------------------------------
748// IfStmt
749template< typename pass_type >
750void PassVisitor< pass_type >::visit( IfStmt * node ) {
751 VISIT_START( node );
752 {
753 // if statements introduce a level of scope (for the initialization)
754 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
755 maybeAccept_impl( node->get_initialization(), *this );
756 visitExpression ( node->condition );
757 node->thenPart = visitStatement( node->thenPart );
758 node->elsePart = visitStatement( node->elsePart );
759 }
760 VISIT_END( node );
761}
762
763template< typename pass_type >
764Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
765 MUTATE_START( node );
766 {
767 // if statements introduce a level of scope (for the initialization)
768 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
769 maybeMutate_impl( node->get_initialization(), *this );
770 node->condition = mutateExpression( node->condition );
771 node->thenPart = mutateStatement ( node->thenPart );
772 node->elsePart = mutateStatement ( node->elsePart );
773 }
774 MUTATE_END( Statement, node );
775}
776
777//--------------------------------------------------------------------------
778// WhileStmt
779template< typename pass_type >
780void PassVisitor< pass_type >::visit( WhileStmt * node ) {
781 VISIT_START( node );
782
783 visitExpression( node->condition );
784 node->body = visitStatement( node->body );
785
786 VISIT_END( node );
787}
788
789template< typename pass_type >
790Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
791 MUTATE_START( node );
792
793 node->condition = mutateExpression( node->condition );
794 node->body = mutateStatement ( node->body );
795
796 MUTATE_END( Statement, node );
797}
798
799//--------------------------------------------------------------------------
800// ForStmt
801template< typename pass_type >
802void PassVisitor< pass_type >::visit( ForStmt * node ) {
803 VISIT_START( node );
804 {
805 // for statements introduce a level of scope (for the initialization)
806 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
807 maybeAccept_impl( node->initialization, *this );
808 visitExpression( node->condition );
809 visitExpression( node->increment );
810 node->body = visitStatement( node->body );
811 }
812 VISIT_END( node );
813}
814
815template< typename pass_type >
816Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
817 MUTATE_START( node );
818 {
819 // for statements introduce a level of scope (for the initialization)
820 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
821 maybeMutate_impl( node->initialization, *this );
822 node->condition = mutateExpression( node->condition );
823 node->increment = mutateExpression( node->increment );
824 node->body = mutateStatement ( node->body );
825 }
826 MUTATE_END( Statement, node );
827}
828
829//--------------------------------------------------------------------------
830// SwitchStmt
831template< typename pass_type >
832void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
833 VISIT_START( node );
834
835 visitExpression ( node->condition );
836 visitStatementList( node->statements );
837
838 VISIT_END( node );
839}
840
841template< typename pass_type >
842Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
843 MUTATE_START( node );
844
845 node->condition = mutateExpression( node->condition );
846 mutateStatementList( node->statements );
847
848 MUTATE_END( Statement, node );
849}
850
851//--------------------------------------------------------------------------
852// CaseStmt
853template< typename pass_type >
854void PassVisitor< pass_type >::visit( CaseStmt * node ) {
855 VISIT_START( node );
856
857 visitExpression ( node->condition );
858 visitStatementList( node->stmts );
859
860 VISIT_END( node );
861}
862
863template< typename pass_type >
864Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
865 MUTATE_START( node );
866
867 node->condition = mutateExpression( node->condition );
868 mutateStatementList( node->stmts );
869
870 MUTATE_END( Statement, node );
871}
872
873//--------------------------------------------------------------------------
874// BranchStmt
875template< typename pass_type >
876void PassVisitor< pass_type >::visit( BranchStmt * node ) {
877 VISIT_BODY( node );
878}
879
880template< typename pass_type >
881Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
882 MUTATE_BODY( Statement, node );
883}
884
885//--------------------------------------------------------------------------
886// ReturnStmt
887template< typename pass_type >
888void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
889 VISIT_START( node );
890
891 visitExpression( node->expr );
892
893 VISIT_END( node );
894}
895
896template< typename pass_type >
897Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
898 MUTATE_START( node );
899
900 node->expr = mutateExpression( node->expr );
901
902 MUTATE_END( Statement, node );
903}
904
905//--------------------------------------------------------------------------
906// ThrowStmt
907
908template< typename pass_type >
909void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
910 VISIT_BODY( node );
911}
912
913template< typename pass_type >
914Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
915 MUTATE_BODY( Statement, node );
916}
917
918//--------------------------------------------------------------------------
919// TryStmt
920template< typename pass_type >
921void PassVisitor< pass_type >::visit( TryStmt * node ) {
922 VISIT_START( node );
923
924 maybeAccept_impl( node->block , *this );
925 maybeAccept_impl( node->handlers , *this );
926 maybeAccept_impl( node->finallyBlock, *this );
927
928 VISIT_END( node );
929}
930
931template< typename pass_type >
932Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
933 MUTATE_START( node );
934
935 maybeMutate_impl( node->block , *this );
936 maybeMutate_impl( node->handlers , *this );
937 maybeMutate_impl( node->finallyBlock, *this );
938
939 MUTATE_END( Statement, node );
940}
941
942//--------------------------------------------------------------------------
943// CatchStmt
944template< typename pass_type >
945void PassVisitor< pass_type >::visit( CatchStmt * node ) {
946 VISIT_START( node );
947 {
948 // catch statements introduce a level of scope (for the caught exception)
949 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
950 maybeAccept_impl( node->decl, *this );
951 node->cond = visitExpression( node->cond );
952 node->body = visitStatement ( node->body );
953 }
954 VISIT_END( node );
955}
956
957template< typename pass_type >
958Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
959 MUTATE_START( node );
960 {
961 // catch statements introduce a level of scope (for the caught exception)
962 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
963 maybeMutate_impl( node->decl, *this );
964 node->cond = mutateExpression( node->cond );
965 node->body = mutateStatement ( node->body );
966 }
967 MUTATE_END( Statement, node );
968}
969
970//--------------------------------------------------------------------------
971// FinallyStmt
972template< typename pass_type >
973void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
974 VISIT_BODY( node );
975}
976
977template< typename pass_type >
978Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
979 MUTATE_BODY( Statement, node );
980}
981
982//--------------------------------------------------------------------------
983// WaitForStmt
984template< typename pass_type >
985void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
986 VISIT_BODY( node );
987}
988
989template< typename pass_type >
990Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
991 MUTATE_BODY( Statement, node );
992}
993
994
995
996//--------------------------------------------------------------------------
997// NullStmt
998template< typename pass_type >
999void PassVisitor< pass_type >::visit( WithStmt * node ) {
1000 VISIT_START( node );
1001 maybeAccept_impl( node->exprs, *this );
1002 {
1003 // catch statements introduce a level of scope (for the caught exception)
1004 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1005 indexerAddWith( node->exprs );
1006 maybeAccept_impl( node->stmt, *this );
1007 }
1008 VISIT_END( node );
1009}
1010
1011template< typename pass_type >
1012Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
1013 MUTATE_START( node );
1014 maybeMutate_impl( node->exprs, *this );
1015 {
1016 // catch statements introduce a level of scope (for the caught exception)
1017 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1018 indexerAddWith( node->exprs );
1019 maybeMutate_impl( node->stmt, *this );
1020 }
1021 MUTATE_END( Statement, node );
1022}
1023
1024//--------------------------------------------------------------------------
1025// NullStmt
1026template< typename pass_type >
1027void PassVisitor< pass_type >::visit( NullStmt * node ) {
1028 VISIT_BODY( node );
1029}
1030
1031template< typename pass_type >
1032NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
1033 MUTATE_BODY( NullStmt, node );
1034}
1035
1036//--------------------------------------------------------------------------
1037// DeclStmt
1038template< typename pass_type >
1039void PassVisitor< pass_type >::visit( DeclStmt * node ) {
1040 VISIT_BODY( node );
1041}
1042
1043template< typename pass_type >
1044Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
1045 MUTATE_BODY( Statement, node );
1046}
1047
1048//--------------------------------------------------------------------------
1049// ImplicitCtorDtorStmt
1050template< typename pass_type >
1051void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
1052 VISIT_BODY( node );
1053}
1054
1055template< typename pass_type >
1056Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
1057 MUTATE_BODY( Statement, node );
1058}
1059
1060//--------------------------------------------------------------------------
1061// ApplicationExpr
1062template< typename pass_type >
1063void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
1064 VISIT_START( node );
1065
1066 indexerScopedAccept( node->result , *this );
1067 maybeAccept_impl ( node->function, *this );
1068 maybeAccept_impl ( node->args , *this );
1069
1070 VISIT_END( node );
1071}
1072
1073template< typename pass_type >
1074Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
1075 MUTATE_START( node );
1076
1077 indexerScopedMutate( node->env , *this );
1078 indexerScopedMutate( node->result , *this );
1079 maybeMutate_impl ( node->function, *this );
1080 maybeMutate_impl ( node->args , *this );
1081
1082 MUTATE_END( Expression, node );
1083}
1084
1085//--------------------------------------------------------------------------
1086// UntypedExpr
1087template< typename pass_type >
1088void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
1089 VISIT_START( node );
1090
1091 // maybeAccept_impl( node->get_env(), *this );
1092 indexerScopedAccept( node->result, *this );
1093
1094 for ( auto expr : node->args ) {
1095 visitExpression( expr );
1096 }
1097
1098 VISIT_END( node );
1099}
1100
1101template< typename pass_type >
1102Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
1103 MUTATE_START( node );
1104
1105 indexerScopedMutate( node->env , *this );
1106 indexerScopedMutate( node->result, *this );
1107
1108 for ( auto& expr : node->args ) {
1109 expr = mutateExpression( expr );
1110 }
1111
1112 MUTATE_END( Expression, node );
1113}
1114
1115//--------------------------------------------------------------------------
1116// NameExpr
1117template< typename pass_type >
1118void PassVisitor< pass_type >::visit( NameExpr * node ) {
1119 VISIT_START( node );
1120
1121 indexerScopedAccept( node->result, *this );
1122
1123 VISIT_END( node );
1124}
1125
1126template< typename pass_type >
1127Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
1128 MUTATE_START( node );
1129
1130 indexerScopedMutate( node->env , *this );
1131 indexerScopedMutate( node->result, *this );
1132
1133 MUTATE_END( Expression, node );
1134}
1135
1136//--------------------------------------------------------------------------
1137// CastExpr
1138template< typename pass_type >
1139void PassVisitor< pass_type >::visit( CastExpr * node ) {
1140 VISIT_START( node );
1141
1142 indexerScopedAccept( node->result, *this );
1143 maybeAccept_impl ( node->arg , *this );
1144
1145 VISIT_END( node );
1146}
1147
1148template< typename pass_type >
1149Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
1150 MUTATE_START( node );
1151
1152 indexerScopedMutate( node->env , *this );
1153 indexerScopedMutate( node->result, *this );
1154 maybeMutate_impl ( node->arg , *this );
1155
1156 MUTATE_END( Expression, node );
1157}
1158
1159//--------------------------------------------------------------------------
1160// VirtualCastExpr
1161template< typename pass_type >
1162void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
1163 VISIT_START( node );
1164
1165 indexerScopedAccept( node->result, *this );
1166 maybeAccept_impl( node->arg, *this );
1167
1168 VISIT_END( node );
1169}
1170
1171template< typename pass_type >
1172Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
1173 MUTATE_START( node );
1174
1175 indexerScopedMutate( node->env , *this );
1176 indexerScopedMutate( node->result, *this );
1177 maybeMutate_impl ( node->arg , *this );
1178
1179 MUTATE_END( Expression, node );
1180}
1181
1182//--------------------------------------------------------------------------
1183// AddressExpr
1184template< typename pass_type >
1185void PassVisitor< pass_type >::visit( AddressExpr * node ) {
1186 VISIT_START( node );
1187
1188 indexerScopedAccept( node->result, *this );
1189 maybeAccept_impl ( node->arg , *this );
1190
1191 VISIT_END( node );
1192}
1193
1194template< typename pass_type >
1195Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
1196 MUTATE_START( node );
1197
1198 indexerScopedMutate( node->env , *this );
1199 indexerScopedMutate( node->result, *this );
1200 maybeMutate_impl ( node->arg , *this );
1201
1202 MUTATE_END( Expression, node );
1203}
1204
1205//--------------------------------------------------------------------------
1206// LabelAddressExpr
1207template< typename pass_type >
1208void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
1209 VISIT_START( node );
1210
1211 indexerScopedAccept( node->result, *this );
1212
1213 VISIT_END( node );
1214}
1215
1216template< typename pass_type >
1217Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
1218 MUTATE_START( node );
1219
1220 indexerScopedMutate( node->env , *this );
1221 indexerScopedMutate( node->result, *this );
1222
1223 MUTATE_END( Expression, node );
1224}
1225
1226//--------------------------------------------------------------------------
1227// UntypedMemberExpr
1228template< typename pass_type >
1229void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
1230 VISIT_START( node );
1231
1232 indexerScopedAccept( node->result , *this );
1233 maybeAccept_impl ( node->aggregate, *this );
1234 maybeAccept_impl ( node->member , *this );
1235
1236 VISIT_END( node );
1237}
1238
1239template< typename pass_type >
1240Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
1241 MUTATE_START( node );
1242
1243 indexerScopedMutate( node->env , *this );
1244 indexerScopedMutate( node->result , *this );
1245 maybeMutate_impl ( node->aggregate, *this );
1246 maybeMutate_impl ( node->member , *this );
1247
1248 MUTATE_END( Expression, node );
1249}
1250
1251//--------------------------------------------------------------------------
1252// MemberExpr
1253template< typename pass_type >
1254void PassVisitor< pass_type >::visit( MemberExpr * node ) {
1255 VISIT_START( node );
1256
1257 indexerScopedAccept( node->result , *this );
1258 maybeAccept_impl ( node->aggregate, *this );
1259
1260 VISIT_END( node );
1261}
1262
1263template< typename pass_type >
1264Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
1265 MUTATE_START( node );
1266
1267 indexerScopedMutate( node->env , *this );
1268 indexerScopedMutate( node->result , *this );
1269 maybeMutate_impl ( node->aggregate, *this );
1270
1271 MUTATE_END( Expression, node );
1272}
1273
1274//--------------------------------------------------------------------------
1275// VariableExpr
1276template< typename pass_type >
1277void PassVisitor< pass_type >::visit( VariableExpr * node ) {
1278 VISIT_START( node );
1279
1280 indexerScopedAccept( node->result, *this );
1281
1282 VISIT_END( node );
1283}
1284
1285template< typename pass_type >
1286Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
1287 MUTATE_START( node );
1288
1289 indexerScopedMutate( node->env , *this );
1290 indexerScopedMutate( node->result, *this );
1291
1292 MUTATE_END( Expression, node );
1293}
1294
1295//--------------------------------------------------------------------------
1296// ConstantExpr
1297template< typename pass_type >
1298void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
1299 VISIT_START( node );
1300
1301 indexerScopedAccept( node->result , *this );
1302 maybeAccept_impl ( &node->constant, *this );
1303
1304 VISIT_END( node );
1305}
1306
1307template< typename pass_type >
1308Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
1309 MUTATE_START( node );
1310
1311 indexerScopedMutate( node->env , *this );
1312 indexerScopedMutate( node->result, *this );
1313 Constant * ptr = &node->constant;
1314 maybeMutate_impl( ptr, *this );
1315 node->constant = *ptr;
1316
1317 MUTATE_END( Expression, node );
1318}
1319
1320//--------------------------------------------------------------------------
1321// SizeofExpr
1322template< typename pass_type >
1323void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
1324 VISIT_START( node );
1325
1326 indexerScopedAccept( node->result, *this );
1327 if ( node->get_isType() ) {
1328 maybeAccept_impl( node->type, *this );
1329 } else {
1330 maybeAccept_impl( node->expr, *this );
1331 }
1332
1333 VISIT_END( node );
1334}
1335
1336template< typename pass_type >
1337Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
1338 MUTATE_START( node );
1339
1340 indexerScopedMutate( node->env , *this );
1341 indexerScopedMutate( node->result, *this );
1342 if ( node->get_isType() ) {
1343 maybeMutate_impl( node->type, *this );
1344 } else {
1345 maybeMutate_impl( node->expr, *this );
1346 }
1347
1348 MUTATE_END( Expression, node );
1349}
1350
1351//--------------------------------------------------------------------------
1352// AlignofExpr
1353template< typename pass_type >
1354void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
1355 VISIT_START( node );
1356
1357 indexerScopedAccept( node->result, *this );
1358 if ( node->get_isType() ) {
1359 maybeAccept_impl( node->type, *this );
1360 } else {
1361 maybeAccept_impl( node->expr, *this );
1362 }
1363
1364 VISIT_END( node );
1365}
1366
1367template< typename pass_type >
1368Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
1369 MUTATE_START( node );
1370
1371 indexerScopedMutate( node->env , *this );
1372 indexerScopedMutate( node->result, *this );
1373 if ( node->get_isType() ) {
1374 maybeMutate_impl( node->type, *this );
1375 } else {
1376 maybeMutate_impl( node->expr, *this );
1377 }
1378
1379 MUTATE_END( Expression, node );
1380}
1381
1382//--------------------------------------------------------------------------
1383// UntypedOffsetofExpr
1384template< typename pass_type >
1385void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
1386 VISIT_START( node );
1387
1388 indexerScopedAccept( node->result, *this );
1389 maybeAccept_impl ( node->type , *this );
1390
1391 VISIT_END( node );
1392}
1393
1394template< typename pass_type >
1395Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
1396 MUTATE_START( node );
1397
1398 indexerScopedMutate( node->env , *this );
1399 indexerScopedMutate( node->result, *this );
1400 maybeMutate_impl ( node->type , *this );
1401
1402 MUTATE_END( Expression, node );
1403}
1404
1405//--------------------------------------------------------------------------
1406// OffsetofExpr
1407template< typename pass_type >
1408void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
1409 VISIT_START( node );
1410
1411 indexerScopedAccept( node->result, *this );
1412 maybeAccept_impl ( node->type , *this );
1413 maybeAccept_impl ( node->member, *this );
1414
1415 VISIT_END( node );
1416}
1417
1418template< typename pass_type >
1419Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
1420 MUTATE_START( node );
1421
1422 indexerScopedMutate( node->env , *this );
1423 indexerScopedMutate( node->result, *this );
1424 maybeMutate_impl ( node->type , *this );
1425 maybeMutate_impl ( node->member, *this );
1426
1427 MUTATE_END( Expression, node );
1428}
1429
1430//--------------------------------------------------------------------------
1431// OffsetPackExpr
1432template< typename pass_type >
1433void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
1434 VISIT_START( node );
1435
1436 indexerScopedAccept( node->result, *this );
1437 maybeAccept_impl ( node->type , *this );
1438
1439 VISIT_END( node );
1440}
1441
1442template< typename pass_type >
1443Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
1444 MUTATE_START( node );
1445
1446 indexerScopedMutate( node->env , *this );
1447 indexerScopedMutate( node->result, *this );
1448 maybeMutate_impl ( node->type , *this );
1449
1450 MUTATE_END( Expression, node );
1451}
1452
1453//--------------------------------------------------------------------------
1454// AttrExpr
1455template< typename pass_type >
1456void PassVisitor< pass_type >::visit( AttrExpr * node ) {
1457 VISIT_START( node );
1458
1459 indexerScopedAccept( node->result, *this );
1460 if ( node->get_isType() ) {
1461 maybeAccept_impl( node->type, *this );
1462 } else {
1463 maybeAccept_impl( node->expr, *this );
1464 }
1465
1466 VISIT_END( node );
1467}
1468
1469template< typename pass_type >
1470Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
1471 MUTATE_START( node );
1472
1473 indexerScopedMutate( node->env , *this );
1474 indexerScopedMutate( node->result, *this );
1475 if ( node->get_isType() ) {
1476 maybeMutate_impl( node->type, *this );
1477 } else {
1478 maybeMutate_impl( node->expr, *this );
1479 }
1480
1481 MUTATE_END( Expression, node );
1482}
1483
1484//--------------------------------------------------------------------------
1485// LogicalExpr
1486template< typename pass_type >
1487void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
1488 VISIT_START( node );
1489
1490 indexerScopedAccept( node->result, *this );
1491 maybeAccept_impl ( node->arg1 , *this );
1492 maybeAccept_impl ( node->arg2 , *this );
1493
1494 VISIT_END( node );
1495}
1496
1497template< typename pass_type >
1498Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
1499 MUTATE_START( node );
1500
1501 indexerScopedMutate( node->env , *this );
1502 indexerScopedMutate( node->result, *this );
1503 maybeMutate_impl ( node->arg1 , *this );
1504 maybeMutate_impl ( node->arg2 , *this );
1505
1506 MUTATE_END( Expression, node );
1507}
1508
1509//--------------------------------------------------------------------------
1510// ConditionalExpr
1511template< typename pass_type >
1512void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
1513 VISIT_START( node );
1514
1515 indexerScopedAccept( node->result, *this );
1516 maybeAccept_impl ( node->arg1 , *this );
1517 maybeAccept_impl ( node->arg2 , *this );
1518 maybeAccept_impl ( node->arg3 , *this );
1519
1520 VISIT_END( node );
1521}
1522
1523template< typename pass_type >
1524Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
1525 MUTATE_START( node );
1526
1527 indexerScopedMutate( node->env , *this );
1528 indexerScopedMutate( node->result, *this );
1529 maybeMutate_impl ( node->arg1 , *this );
1530 maybeMutate_impl ( node->arg2 , *this );
1531 maybeMutate_impl ( node->arg3 , *this );
1532
1533 MUTATE_END( Expression, node );
1534}
1535
1536//--------------------------------------------------------------------------
1537// CommaExpr
1538template< typename pass_type >
1539void PassVisitor< pass_type >::visit( CommaExpr * node ) {
1540 VISIT_START( node );
1541
1542 indexerScopedAccept( node->result, *this );
1543 maybeAccept_impl ( node->arg1 , *this );
1544 maybeAccept_impl ( node->arg2 , *this );
1545
1546 VISIT_END( node );
1547}
1548
1549template< typename pass_type >
1550Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
1551 MUTATE_START( node );
1552
1553 indexerScopedMutate( node->env , *this );
1554 indexerScopedMutate( node->result, *this );
1555 maybeMutate_impl ( node->arg1 , *this );
1556 maybeMutate_impl ( node->arg2 , *this );
1557
1558 MUTATE_END( Expression, node );
1559}
1560
1561//--------------------------------------------------------------------------
1562// TypeExpr
1563template< typename pass_type >
1564void PassVisitor< pass_type >::visit( TypeExpr * node ) {
1565 VISIT_START( node );
1566
1567 indexerScopedAccept( node->result, *this );
1568 maybeAccept_impl ( node->type, *this );
1569
1570 VISIT_END( node );
1571}
1572
1573template< typename pass_type >
1574Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
1575 MUTATE_START( node );
1576
1577 indexerScopedMutate( node->env , *this );
1578 indexerScopedMutate( node->result, *this );
1579 maybeMutate_impl ( node->type , *this );
1580
1581 MUTATE_END( Expression, node );
1582}
1583
1584//--------------------------------------------------------------------------
1585// AsmExpr
1586template< typename pass_type >
1587void PassVisitor< pass_type >::visit( AsmExpr * node ) {
1588 VISIT_START( node );
1589
1590 indexerScopedAccept( node->result , *this );
1591 maybeAccept_impl ( node->inout , *this );
1592 maybeAccept_impl ( node->constraint, *this );
1593 maybeAccept_impl ( node->operand , *this );
1594
1595 VISIT_END( node );
1596}
1597
1598template< typename pass_type >
1599Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
1600 MUTATE_START( node );
1601
1602 indexerScopedMutate( node->env , *this );
1603 indexerScopedMutate( node->result , *this );
1604 maybeMutate_impl ( node->inout , *this );
1605 maybeMutate_impl ( node->constraint, *this );
1606 maybeMutate_impl ( node->operand , *this );
1607
1608 MUTATE_END( Expression, node );
1609}
1610
1611//--------------------------------------------------------------------------
1612// ImplicitCopyCtorExpr
1613template< typename pass_type >
1614void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
1615 VISIT_START( node );
1616
1617 indexerScopedAccept( node->result , *this );
1618 maybeAccept_impl ( node->callExpr , *this );
1619 maybeAccept_impl ( node->tempDecls , *this );
1620 maybeAccept_impl ( node->returnDecls, *this );
1621 maybeAccept_impl ( node->dtors , *this );
1622
1623 VISIT_END( node );
1624}
1625
1626template< typename pass_type >
1627Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
1628 MUTATE_START( node );
1629
1630 indexerScopedMutate( node->env , *this );
1631 indexerScopedMutate( node->result , *this );
1632 maybeMutate_impl ( node->callExpr , *this );
1633 maybeMutate_impl ( node->tempDecls , *this );
1634 maybeMutate_impl ( node->returnDecls, *this );
1635 maybeMutate_impl ( node->dtors , *this );
1636
1637 MUTATE_END( Expression, node );
1638}
1639
1640//--------------------------------------------------------------------------
1641// ConstructorExpr
1642template< typename pass_type >
1643void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
1644 VISIT_START( node );
1645
1646 indexerScopedAccept( node->result , *this );
1647 maybeAccept_impl ( node->callExpr, *this );
1648
1649 VISIT_END( node );
1650}
1651
1652template< typename pass_type >
1653Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
1654 MUTATE_START( node );
1655
1656 indexerScopedMutate( node->env , *this );
1657 indexerScopedMutate( node->result , *this );
1658 maybeMutate_impl ( node->callExpr, *this );
1659
1660 MUTATE_END( Expression, node );
1661}
1662
1663//--------------------------------------------------------------------------
1664// CompoundLiteralExpr
1665template< typename pass_type >
1666void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
1667 VISIT_START( node );
1668
1669 indexerScopedAccept( node->result , *this );
1670 maybeAccept_impl ( node->initializer, *this );
1671
1672 VISIT_END( node );
1673}
1674
1675template< typename pass_type >
1676Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
1677 MUTATE_START( node );
1678
1679 indexerScopedMutate( node->env , *this );
1680 indexerScopedMutate( node->result , *this );
1681 maybeMutate_impl ( node->initializer, *this );
1682
1683 MUTATE_END( Expression, node );
1684}
1685
1686//--------------------------------------------------------------------------
1687// RangeExpr
1688template< typename pass_type >
1689void PassVisitor< pass_type >::visit( RangeExpr * node ) {
1690 VISIT_START( node );
1691
1692 indexerScopedAccept( node->result, *this );
1693 maybeAccept_impl ( node->low , *this );
1694 maybeAccept_impl ( node->high , *this );
1695
1696 VISIT_END( node );
1697}
1698
1699template< typename pass_type >
1700Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
1701 MUTATE_START( node );
1702
1703 indexerScopedMutate( node->env , *this );
1704 indexerScopedMutate( node->result, *this );
1705 maybeMutate_impl ( node->low , *this );
1706 maybeMutate_impl ( node->high , *this );
1707
1708 MUTATE_END( Expression, node );
1709}
1710
1711//--------------------------------------------------------------------------
1712// UntypedTupleExpr
1713template< typename pass_type >
1714void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
1715 VISIT_START( node );
1716
1717 indexerScopedAccept( node->result, *this );
1718 maybeAccept_impl ( node->exprs , *this );
1719
1720 VISIT_END( node );
1721}
1722
1723template< typename pass_type >
1724Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
1725 MUTATE_START( node );
1726
1727 indexerScopedMutate( node->env , *this );
1728 indexerScopedMutate( node->result, *this );
1729 maybeMutate_impl ( node->exprs , *this );
1730
1731 MUTATE_END( Expression, node );
1732}
1733
1734//--------------------------------------------------------------------------
1735// TupleExpr
1736template< typename pass_type >
1737void PassVisitor< pass_type >::visit( TupleExpr * node ) {
1738 VISIT_START( node );
1739
1740 indexerScopedAccept( node->result, *this );
1741 maybeAccept_impl ( node->exprs , *this );
1742
1743 VISIT_END( node );
1744}
1745
1746template< typename pass_type >
1747Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
1748 MUTATE_START( node );
1749
1750 indexerScopedMutate( node->env , *this );
1751 indexerScopedMutate( node->result, *this );
1752 maybeMutate_impl ( node->exprs , *this );
1753
1754 MUTATE_END( Expression, node );
1755}
1756
1757//--------------------------------------------------------------------------
1758// TupleIndexExpr
1759template< typename pass_type >
1760void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
1761 VISIT_START( node );
1762
1763 indexerScopedAccept( node->result, *this );
1764 maybeAccept_impl ( node->tuple , *this );
1765
1766 VISIT_END( node );
1767}
1768
1769template< typename pass_type >
1770Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
1771 MUTATE_START( node );
1772
1773 indexerScopedMutate( node->env , *this );
1774 indexerScopedMutate( node->result, *this );
1775 maybeMutate_impl ( node->tuple , *this );
1776
1777 MUTATE_END( Expression, node );
1778}
1779
1780//--------------------------------------------------------------------------
1781// TupleAssignExpr
1782template< typename pass_type >
1783void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
1784 VISIT_START( node );
1785
1786 indexerScopedAccept( node->result , *this );
1787 maybeAccept_impl ( node->stmtExpr, *this );
1788
1789 VISIT_END( node );
1790}
1791
1792template< typename pass_type >
1793Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
1794 MUTATE_START( node );
1795
1796 indexerScopedMutate( node->env , *this );
1797 indexerScopedMutate( node->result , *this );
1798 maybeMutate_impl ( node->stmtExpr, *this );
1799
1800 MUTATE_END( Expression, node );
1801}
1802
1803//--------------------------------------------------------------------------
1804// StmtExpr
1805template< typename pass_type >
1806void PassVisitor< pass_type >::visit( StmtExpr * node ) {
1807 VISIT_START( node );
1808
1809 // don't want statements from outer CompoundStmts to be added to this StmtExpr
1810 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
1811 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1812 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
1813
1814 indexerScopedAccept( node->result , *this );
1815 maybeAccept_impl ( node->statements , *this );
1816 maybeAccept_impl ( node->returnDecls, *this );
1817 maybeAccept_impl ( node->dtors , *this );
1818
1819 VISIT_END( node );
1820}
1821
1822template< typename pass_type >
1823Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
1824 MUTATE_START( node );
1825
1826 // don't want statements from outer CompoundStmts to be added to this StmtExpr
1827 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
1828 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1829 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
1830
1831 indexerScopedMutate( node->result , *this );
1832 maybeMutate_impl ( node->statements , *this );
1833 maybeMutate_impl ( node->returnDecls, *this );
1834 maybeMutate_impl ( node->dtors , *this );
1835
1836 MUTATE_END( Expression, node );
1837}
1838
1839//--------------------------------------------------------------------------
1840// UniqueExpr
1841template< typename pass_type >
1842void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
1843 VISIT_START( node );
1844
1845 indexerScopedAccept( node->result, *this );
1846 maybeAccept_impl ( node->expr , *this );
1847
1848 VISIT_END( node );
1849}
1850
1851template< typename pass_type >
1852Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
1853 MUTATE_START( node );
1854
1855 indexerScopedMutate( node->env , *this );
1856 indexerScopedMutate( node->result, *this );
1857 maybeMutate_impl ( node->expr , *this );
1858
1859 MUTATE_END( Expression, node );
1860}
1861
1862//--------------------------------------------------------------------------
1863// UntypedInitExpr
1864template< typename pass_type >
1865void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
1866 VISIT_START( node );
1867
1868 indexerScopedAccept( node->result, *this );
1869 maybeAccept_impl ( node->expr , *this );
1870 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
1871
1872 VISIT_END( node );
1873}
1874
1875template< typename pass_type >
1876Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
1877 MUTATE_START( node );
1878
1879 indexerScopedMutate( node->env , *this );
1880 indexerScopedMutate( node->result, *this );
1881 maybeMutate_impl ( node->expr , *this );
1882 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
1883
1884 MUTATE_END( Expression, node );
1885}
1886
1887//--------------------------------------------------------------------------
1888// InitExpr
1889template< typename pass_type >
1890void PassVisitor< pass_type >::visit( InitExpr * node ) {
1891 VISIT_START( node );
1892
1893 indexerScopedAccept( node->result, *this );
1894 maybeAccept_impl ( node->expr , *this );
1895 maybeAccept_impl ( node->designation, *this );
1896
1897 VISIT_END( node );
1898}
1899
1900template< typename pass_type >
1901Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
1902 MUTATE_START( node );
1903
1904 indexerScopedMutate( node->env , *this );
1905 indexerScopedMutate( node->result, *this );
1906 maybeMutate_impl ( node->expr , *this );
1907 maybeMutate_impl ( node->designation, *this );
1908
1909 MUTATE_END( Expression, node );
1910}
1911
1912template< typename pass_type >
1913void PassVisitor< pass_type >::visit( VoidType * node ) {
1914 VISIT_BODY( node );
1915}
1916
1917template< typename pass_type >
1918void PassVisitor< pass_type >::visit( BasicType * node ) {
1919 VISIT_BODY( node );
1920}
1921
1922template< typename pass_type >
1923void PassVisitor< pass_type >::visit( PointerType * node ) {
1924 VISIT_BODY( node );
1925}
1926
1927template< typename pass_type >
1928void PassVisitor< pass_type >::visit( ArrayType * node ) {
1929 VISIT_BODY( node );
1930}
1931
1932template< typename pass_type >
1933void PassVisitor< pass_type >::visit( ReferenceType * node ) {
1934 VISIT_BODY( node );
1935}
1936
1937template< typename pass_type >
1938void PassVisitor< pass_type >::visit( FunctionType * node ) {
1939 VISIT_BODY( node );
1940}
1941
1942//--------------------------------------------------------------------------
1943// StructInstType
1944template< typename pass_type >
1945void PassVisitor< pass_type >::visit( StructInstType * node ) {
1946 VISIT_START( node );
1947
1948 indexerAddStruct( node->name );
1949
1950 {
1951 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1952 maybeAccept_impl( node->forall , *this );
1953 maybeAccept_impl( node->parameters, *this );
1954 }
1955
1956 VISIT_END( node );
1957}
1958
1959template< typename pass_type >
1960Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
1961 MUTATE_START( node );
1962
1963 indexerAddStruct( node->name );
1964
1965 {
1966 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1967 maybeMutate_impl( node->forall , *this );
1968 maybeMutate_impl( node->parameters, *this );
1969 }
1970
1971 MUTATE_END( Type, node );
1972}
1973
1974//--------------------------------------------------------------------------
1975// UnionInstType
1976template< typename pass_type >
1977void PassVisitor< pass_type >::visit( UnionInstType * node ) {
1978 VISIT_START( node );
1979
1980 indexerAddStruct( node->name );
1981
1982 {
1983 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1984 maybeAccept_impl( node->forall , *this );
1985 maybeAccept_impl( node->parameters, *this );
1986 }
1987
1988 VISIT_END( node );
1989}
1990
1991template< typename pass_type >
1992Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
1993 MUTATE_START( node );
1994
1995 indexerAddStruct( node->name );
1996
1997 {
1998 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1999 maybeMutate_impl( node->forall , *this );
2000 maybeMutate_impl( node->parameters, *this );
2001 }
2002
2003 MUTATE_END( Type, node );
2004}
2005
2006//--------------------------------------------------------------------------
2007// EnumInstType
2008template< typename pass_type >
2009void PassVisitor< pass_type >::visit( EnumInstType * node ) {
2010 VISIT_BODY( node );
2011}
2012
2013template< typename pass_type >
2014Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
2015 MUTATE_BODY( Type, node );
2016}
2017
2018//--------------------------------------------------------------------------
2019// TraitInstType
2020template< typename pass_type >
2021void PassVisitor< pass_type >::visit( TraitInstType * node ) {
2022 VISIT_START( node );
2023
2024 maybeAccept_impl( node->forall , *this );
2025 maybeAccept_impl( node->parameters, *this );
2026
2027 VISIT_END( node );
2028}
2029
2030template< typename pass_type >
2031Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
2032 MUTATE_START( node );
2033
2034 maybeMutate_impl( node->forall , *this );
2035 maybeMutate_impl( node->parameters, *this );
2036
2037 MUTATE_END( Type, node );
2038}
2039
2040//--------------------------------------------------------------------------
2041// TypeInstType
2042template< typename pass_type >
2043void PassVisitor< pass_type >::visit( TypeInstType * node ) {
2044 VISIT_BODY( node );
2045}
2046
2047template< typename pass_type >
2048void PassVisitor< pass_type >::visit( TupleType * node ) {
2049 VISIT_BODY( node );
2050}
2051
2052template< typename pass_type >
2053void PassVisitor< pass_type >::visit( TypeofType * node ) {
2054 VISIT_BODY( node );
2055}
2056
2057template< typename pass_type >
2058void PassVisitor< pass_type >::visit( AttrType * node ) {
2059 VISIT_BODY( node );
2060}
2061
2062template< typename pass_type >
2063void PassVisitor< pass_type >::visit( VarArgsType * node ) {
2064 VISIT_BODY( node );
2065}
2066
2067template< typename pass_type >
2068void PassVisitor< pass_type >::visit( ZeroType * node ) {
2069 VISIT_BODY( node );
2070}
2071
2072template< typename pass_type >
2073void PassVisitor< pass_type >::visit( OneType * node ) {
2074 VISIT_BODY( node );
2075}
2076
2077template< typename pass_type >
2078void PassVisitor< pass_type >::visit( Designation * node ) {
2079 VISIT_START( node );
2080
2081 maybeAccept_impl( node->get_designators(), *this );
2082
2083 VISIT_END( node );
2084}
2085
2086template< typename pass_type >
2087Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
2088 MUTATE_START( node );
2089
2090 maybeMutate_impl( node->get_designators(), *this );
2091
2092 MUTATE_END( Designation, node );
2093}
2094
2095//--------------------------------------------------------------------------
2096// SingleInit
2097template< typename pass_type >
2098void PassVisitor< pass_type >::visit( SingleInit * node ) {
2099 VISIT_START( node );
2100
2101 visitExpression( node->get_value() );
2102
2103 VISIT_END( node );
2104}
2105
2106template< typename pass_type >
2107Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
2108 MUTATE_START( node );
2109
2110 node->set_value( mutateExpression( node->get_value() ) );
2111
2112 MUTATE_END( Initializer, node );
2113}
2114
2115template< typename pass_type >
2116void PassVisitor< pass_type >::visit( ListInit * node ) {
2117 VISIT_BODY( node );
2118}
2119
2120template< typename pass_type >
2121void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
2122 VISIT_BODY( node );
2123}
2124
2125template< typename pass_type >
2126void PassVisitor< pass_type >::visit( Subrange * node ) {
2127 VISIT_BODY( node );
2128}
2129
2130template< typename pass_type >
2131void PassVisitor< pass_type >::visit( Constant * node ) {
2132 VISIT_BODY( node );
2133}
2134
2135template< typename pass_type >
2136void PassVisitor< pass_type >::visit( Attribute * node ) {
2137 VISIT_BODY( node );
2138}
2139
2140//---------------------------------------------------------------------------------------------------------------
2141template< typename pass_type >
2142Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
2143 MUTATE_BODY( Type, node );
2144}
2145
2146template< typename pass_type >
2147Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
2148 MUTATE_BODY( Type, node );
2149}
2150
2151template< typename pass_type >
2152Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
2153 MUTATE_BODY( Type, node );
2154}
2155
2156template< typename pass_type >
2157Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
2158 MUTATE_BODY( Type, node );
2159}
2160
2161template< typename pass_type >
2162Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
2163 MUTATE_BODY( Type, node );
2164}
2165
2166template< typename pass_type >
2167Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
2168 MUTATE_BODY( Type, node );
2169}
2170
2171template< typename pass_type >
2172Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
2173 MUTATE_BODY( Type, node );
2174}
2175
2176template< typename pass_type >
2177Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
2178 MUTATE_BODY( Type, node );
2179}
2180
2181template< typename pass_type >
2182Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
2183 MUTATE_BODY( Type, node );
2184}
2185
2186template< typename pass_type >
2187Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
2188 MUTATE_BODY( Type, node );
2189}
2190
2191template< typename pass_type >
2192Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
2193 MUTATE_BODY( Type, node );
2194}
2195
2196template< typename pass_type >
2197Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
2198 MUTATE_BODY( Type, node );
2199}
2200
2201template< typename pass_type >
2202Type * PassVisitor< pass_type >::mutate( OneType * node ) {
2203 MUTATE_BODY( Type, node );
2204}
2205
2206template< typename pass_type >
2207Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
2208 MUTATE_BODY( Initializer, node );
2209}
2210
2211template< typename pass_type >
2212Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
2213 MUTATE_BODY( Initializer, node );
2214}
2215
2216template< typename pass_type >
2217Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) {
2218 MUTATE_BODY( Subrange, node );
2219}
2220
2221template< typename pass_type >
2222Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
2223 MUTATE_BODY( Constant, node );
2224}
2225
2226template< typename pass_type >
2227Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
2228 MUTATE_BODY( Attribute, node );
2229}
2230
2231template< typename pass_type >
2232TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
2233 MUTATE_START( node );
2234
2235 for ( auto & p : node->typeEnv ) {
2236 indexerScopedMutate( p.second, *this );
2237 }
2238 for ( auto & p : node->varEnv ) {
2239 indexerScopedMutate( p.second, *this );
2240 }
2241
2242 MUTATE_END( TypeSubstitution, node );
2243}
Note: See TracBrowser for help on using the repository browser.