source: src/Common/PassVisitor.impl.h@ 624b722d

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 624b722d was bc6f918, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Expand VISIT/MUTATE_BODY for AsmStmt

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