source: src/Common/PassVisitor.impl.h@ 0b0f1dd

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 0b0f1dd was d55d7a6, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Massive change to errors to enable warnings

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