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

ADT ast-experimental pthread-emulation
Last change on this file since e9e9f56 was b0d9ff7, checked in by JiadaL <j82liang@…>, 3 years ago

Fix up the QualifiedNameExpr. It should now work on both old AST and new AST. There are some known bugs to fix so make all-tests will fail.

  • Property mode set to 100644
File size: 113.0 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 auto __return = call_postmutate< type * >( node ); \
23 assert( __return ); \
24 return __return;
25
26
27template<typename T>
28static inline bool empty( T * ptr ) {
29 return !ptr || ptr->empty();
30}
31
32typedef std::list< Statement * > StmtList_t;
33typedef std::list< Declaration * > DeclList_t;
34
35template<typename iterator_t>
36static inline void splice( iterator_t it, DeclList_t * decls ) {
37 std::transform(
38 decls->begin(),
39 decls->end(),
40 it,
41 [](Declaration * decl) -> auto {
42 return new DeclStmt( decl );
43 }
44 );
45 decls->clear();
46}
47
48template< typename pass_type >
49inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
50 DeclList_t* beforeDecls = visitor.get_beforeDecls();
51 DeclList_t* afterDecls = visitor.get_afterDecls();
52 SemanticErrorException errors;
53
54 pass_visitor_stats.depth++;
55 pass_visitor_stats.max->push(pass_visitor_stats.depth);
56 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
57 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
58
59
60 // splice in new declarations after previous decl
61 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
62
63 if ( i == decls.end() ) break;
64
65 try {
66 // run visitor on declaration
67 maybeAccept_impl( *i, visitor );
68 } catch( SemanticErrorException &e ) {
69 errors.append( e );
70 }
71
72 // splice in new declarations before current decl
73 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
74 }
75 pass_visitor_stats.depth--;
76 if ( ! errors.isEmpty() ) {
77 throw errors;
78 }
79}
80
81template< typename pass_type >
82inline void acceptAll( const std::list< const Declaration * > & decls, PassVisitor< pass_type >& visitor ) {
83 SemanticErrorException errors;
84
85 pass_visitor_stats.depth++;
86 pass_visitor_stats.max->push(pass_visitor_stats.depth);
87 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
88 for ( const Declaration * decl : decls ) {
89 try {
90 // run visitor on declaration
91 maybeAccept_impl( decl, visitor );
92 }
93 catch( SemanticErrorException &e ) {
94 errors.append( e );
95 }
96 }
97 pass_visitor_stats.depth--;
98 if ( ! errors.isEmpty() ) {
99 throw errors;
100 }
101}
102
103template< typename pass_type >
104inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
105 DeclList_t* beforeDecls = mutator.get_beforeDecls();
106 DeclList_t* afterDecls = mutator.get_afterDecls();
107 SemanticErrorException errors;
108
109 pass_visitor_stats.depth++;
110 pass_visitor_stats.max->push(pass_visitor_stats.depth);
111 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
112 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
113 // splice in new declarations after previous decl
114 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
115
116 if ( i == decls.end() ) break;
117 try {
118 // run mutator on declaration
119 maybeMutate_impl( *i, mutator );
120 } catch( SemanticErrorException &e ) {
121 errors.append( e );
122 }
123
124 // splice in new declarations before current decl
125 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
126 }
127 pass_visitor_stats.depth--;
128 if ( ! errors.isEmpty() ) {
129 throw errors;
130 }
131}
132
133template< typename TreeType, typename pass_type >
134inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
135 if ( ! visitor.get_visit_children() ) return;
136 if ( tree ) {
137 tree->accept( visitor );
138 }
139}
140
141template< typename TreeType, typename pass_type >
142inline void maybeAccept_impl( const TreeType * tree, PassVisitor< pass_type > & visitor ) {
143 if ( ! visitor.get_visit_children() ) return;
144 if ( tree ) {
145 tree->accept( visitor );
146 }
147}
148
149template< typename Container, typename pass_type >
150inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
151 if ( ! visitor.get_visit_children() ) return;
152 SemanticErrorException errors;
153
154 pass_visitor_stats.depth++;
155 pass_visitor_stats.max->push(pass_visitor_stats.depth);
156 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
157 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
158 try {
159 if ( *i ) {
160 (*i)->accept( visitor );
161 }
162 } catch( SemanticErrorException &e ) {
163 errors.append( e );
164 }
165 }
166 pass_visitor_stats.depth--;
167 if ( ! errors.isEmpty() ) {
168 throw errors;
169 }
170}
171
172template< typename Container, typename pass_type >
173inline void maybeAccept_impl( const Container & container, PassVisitor< pass_type > & visitor ) {
174 if ( ! visitor.get_visit_children() ) return;
175 SemanticErrorException errors;
176
177 pass_visitor_stats.depth++;
178 pass_visitor_stats.max->push(pass_visitor_stats.depth);
179 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
180 for ( const auto & i : container ) {
181 try {
182 if ( i ) {
183 i->accept( visitor );
184 }
185 } catch( SemanticErrorException &e ) {
186 errors.append( e );
187 }
188 }
189 pass_visitor_stats.depth--;
190 if ( ! errors.isEmpty() ) {
191 throw errors;
192 }
193}
194
195template< typename TreeType, typename pass_type >
196inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
197 if ( ! mutator.get_visit_children() ) return;
198
199 if ( tree ) {
200 tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
201 }
202}
203
204template< typename Container, typename pass_type >
205inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
206
207 if ( ! mutator.get_visit_children() ) return;
208 SemanticErrorException errors;
209
210 pass_visitor_stats.depth++;
211 pass_visitor_stats.max->push(pass_visitor_stats.depth);
212 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
213 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
214 try {
215 if ( *i ) {
216 *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
217 assert( *i );
218 } // if
219 } catch( SemanticErrorException &e ) {
220 errors.append( e );
221 } // try
222 } // for
223 pass_visitor_stats.depth--;
224 if ( ! errors.isEmpty() ) {
225 throw errors;
226 } // if
227}
228
229template< typename pass_type >
230template< typename func_t >
231void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
232 if ( ! get_visit_children() ) return;
233 SemanticErrorException errors;
234
235 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
236 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
237 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
238 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
239 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
240
241 StmtList_t* beforeStmts = get_beforeStmts();
242 StmtList_t* afterStmts = get_afterStmts();
243 DeclList_t* beforeDecls = get_beforeDecls();
244 DeclList_t* afterDecls = get_afterDecls();
245
246 pass_visitor_stats.depth++;
247 pass_visitor_stats.max->push(pass_visitor_stats.depth);
248 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
249 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
250
251 if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }
252 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
253
254 try {
255 func( *i );
256 assert( *i );
257 assert(( empty( beforeStmts ) && empty( afterStmts ))
258 || ( empty( beforeDecls ) && empty( afterDecls )) );
259
260 } catch ( SemanticErrorException &e ) {
261 errors.append( e );
262 }
263
264 if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }
265 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
266 }
267 pass_visitor_stats.depth--;
268
269 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
270 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
271 if ( !errors.isEmpty() ) { throw errors; }
272}
273
274template< typename pass_type >
275void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
276 handleStatementList( statements, [this]( Statement * stmt) {
277 maybeAccept_impl( stmt, *this );
278 });
279}
280
281template< typename pass_type >
282void PassVisitor< pass_type >::visitStatementList( const std::list< Statement * > & statements ) {
283 if ( ! get_visit_children() ) return;
284 SemanticErrorException errors;
285
286 pass_visitor_stats.depth++;
287 pass_visitor_stats.max->push(pass_visitor_stats.depth);
288 pass_visitor_stats.avg->push(pass_visitor_stats.depth);
289 for ( const Statement * i : statements ) {
290 try {
291 maybeAccept_impl( i, *this );
292 } catch ( SemanticErrorException &e ) {
293 errors.append( e );
294 }
295 }
296 pass_visitor_stats.depth--;
297 if ( !errors.isEmpty() ) { throw errors; }
298}
299
300template< typename pass_type >
301void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
302 handleStatementList( statements, [this]( Statement *& stmt) {
303 maybeMutate_impl( stmt, *this );
304 });
305}
306
307
308template< typename pass_type >
309template< typename func_t >
310Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
311 if ( ! get_visit_children() ) return stmt;
312
313 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
314 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
315 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
316 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
317 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
318 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
319
320 Statement *newStmt = func( stmt );
321
322 StmtList_t* beforeStmts = get_beforeStmts();
323 StmtList_t* afterStmts = get_afterStmts();
324 DeclList_t* beforeDecls = get_beforeDecls();
325 DeclList_t* afterDecls = get_afterDecls();
326
327 if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; }
328 assert(( empty( beforeStmts ) && empty( afterStmts ))
329 || ( empty( beforeDecls ) && empty( afterDecls )) );
330
331 CompoundStmt *compound = new CompoundStmt();
332 if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); }
333 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
334 compound->get_kids().push_back( newStmt );
335 if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }
336 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
337 return compound;
338}
339
340template< typename pass_type >
341Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
342 return handleStatement( stmt, [this]( Statement * stmt ) {
343 maybeAccept_impl( stmt, *this );
344 return stmt;
345 });
346}
347
348template< typename pass_type >
349void PassVisitor< pass_type >::visitStatement( const Statement * stmt ) {
350 if ( ! get_visit_children() ) return;
351
352 // don't want statements from outer CompoundStmts to be added to this CompoundStmt
353 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
354
355 maybeAccept_impl( stmt, *this );
356}
357
358template< typename pass_type >
359Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
360 return handleStatement( stmt, [this]( Statement * stmt ) {
361 maybeMutate_impl( stmt, *this );
362 return stmt;
363 });
364}
365
366template< typename pass_type >
367template< typename func_t >
368Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
369 if ( ! get_visit_children() ) return expr;
370 if( !expr ) return nullptr;
371
372 auto env_ptr = get_env_ptr();
373 if ( env_ptr && expr->get_env() ) {
374 *env_ptr = expr->get_env();
375 }
376
377 // should env be moved onto the result of the mutate?
378 return func( expr );
379}
380
381template< typename pass_type >
382Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
383 return handleExpression(expr, [this]( Expression * expr ) {
384 maybeAccept_impl( expr, *this );
385 return expr;
386 });
387}
388
389template< typename pass_type >
390void PassVisitor< pass_type >::visitExpression( const Expression * expr ) {
391 if ( ! get_visit_children() ) return;
392 if( !expr ) return;
393
394 auto env_ptr = get_env_ptr();
395 if ( env_ptr && expr->get_env() ) {
396 *env_ptr = expr->get_env();
397 }
398
399 maybeAccept_impl( expr, *this );
400}
401
402template< typename pass_type >
403Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
404 return handleExpression(expr, [this]( Expression * expr ) {
405 maybeMutate_impl( expr, *this );
406 return expr;
407 });
408}
409
410template< typename TreeType, typename VisitorType >
411inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
412 if ( ! visitor.get_visit_children() ) return;
413 auto guard = makeFuncGuard(
414 [&visitor]() { visitor.indexerScopeEnter(); },
415 [&visitor]() { visitor.indexerScopeLeave(); }
416 );
417 maybeAccept_impl( tree, visitor );
418}
419
420template< typename TreeType, typename VisitorType >
421inline void indexerScopedAccept( const TreeType * tree, VisitorType & visitor ) {
422 if ( ! visitor.get_visit_children() ) return;
423 auto guard = makeFuncGuard(
424 [&visitor]() { visitor.indexerScopeEnter(); },
425 [&visitor]() { visitor.indexerScopeLeave(); }
426 );
427 maybeAccept_impl( tree, visitor );
428}
429
430template< typename TreeType, typename MutatorType >
431inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
432 if ( ! mutator.get_visit_children() ) return;
433 auto guard = makeFuncGuard(
434 [&mutator]() { mutator.indexerScopeEnter(); },
435 [&mutator]() { mutator.indexerScopeLeave(); }
436 );
437 maybeMutate_impl( tree, mutator );
438}
439
440//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
441//========================================================================================================================================================================
442//========================================================================================================================================================================
443//========================================================================================================================================================================
444//========================================================================================================================================================================
445//========================================================================================================================================================================
446//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
447
448// A NOTE ON THE ORDER OF TRAVERSAL
449//
450// Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is
451// no such thing as a recursive type or typedef.
452//
453// typedef struct { T *x; } T; // never allowed
454//
455// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
456// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
457// declaration).
458//
459// struct T { struct T *x; }; // allowed
460//
461// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
462// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
463// queried later in this pass.
464//
465// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
466
467//--------------------------------------------------------------------------
468// ObjectDecl
469template< typename pass_type >
470void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
471 VISIT_START( node );
472
473 indexerScopedAccept( node->type , *this );
474 maybeAccept_impl ( node->init , *this );
475 maybeAccept_impl ( node->bitfieldWidth, *this );
476 maybeAccept_impl ( node->attributes , *this );
477
478 indexerAddId( node );
479
480 VISIT_END( node );
481}
482
483template< typename pass_type >
484void PassVisitor< pass_type >::visit( const ObjectDecl * node ) {
485 VISIT_START( node );
486
487 maybeAccept_impl( node->type , *this );
488 maybeAccept_impl( node->init , *this );
489 maybeAccept_impl( node->bitfieldWidth, *this );
490 maybeAccept_impl( node->attributes , *this );
491
492 VISIT_END( node );
493}
494
495template< typename pass_type >
496DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) {
497 MUTATE_START( node );
498
499 indexerScopedMutate( node->type , *this );
500 maybeMutate_impl ( node->init , *this );
501 maybeMutate_impl ( node->bitfieldWidth, *this );
502 maybeMutate_impl ( node->attributes , *this );
503
504 indexerAddId( node );
505
506 MUTATE_END( DeclarationWithType, node );
507}
508
509//--------------------------------------------------------------------------
510// FunctionDecl
511template< typename pass_type >
512void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
513 VISIT_START( node );
514
515 indexerAddId( node );
516
517 maybeAccept_impl( node->withExprs, *this );
518 {
519 // with clause introduces a level of scope (for the with expression members).
520 // with clause exprs are added to the indexer before parameters so that parameters
521 // shadow with exprs and not the other way around.
522 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
523 indexerAddWith( node->withExprs, node );
524 {
525 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
526 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
527 static ObjectDecl func(
528 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
529 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
530 nullptr
531 );
532 indexerAddId( &func );
533 maybeAccept_impl( node->type, *this );
534 // First remember that we are now within a function.
535 ValueGuard< bool > oldInFunction( inFunction );
536 inFunction = true;
537 // The function body needs to have the same scope as parameters.
538 // A CompoundStmt will not enter a new scope if atFunctionTop is true.
539 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
540 atFunctionTop = true;
541 maybeAccept_impl( node->statements, *this );
542 maybeAccept_impl( node->attributes, *this );
543 }
544 }
545
546 VISIT_END( node );
547}
548
549template< typename pass_type >
550void PassVisitor< pass_type >::visit( const FunctionDecl * node ) {
551 VISIT_START( node );
552
553 indexerAddId( node );
554
555 maybeAccept_impl( node->withExprs, *this );
556 {
557 // with clause introduces a level of scope (for the with expression members).
558 // with clause exprs are added to the indexer before parameters so that parameters
559 // shadow with exprs and not the other way around.
560 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
561 indexerAddWith( node->withExprs, node );
562 {
563 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
564 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
565 static ObjectDecl func(
566 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
567 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
568 nullptr
569 );
570 indexerAddId( &func );
571 maybeAccept_impl( node->type, *this );
572 // First remember that we are now within a function.
573 ValueGuard< bool > oldInFunction( inFunction );
574 inFunction = true;
575 // The function body needs to have the same scope as parameters.
576 // A CompoundStmt will not enter a new scope if atFunctionTop is true.
577 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
578 atFunctionTop = true;
579 maybeAccept_impl( node->statements, *this );
580 maybeAccept_impl( node->attributes, *this );
581 }
582 }
583
584 VISIT_END( node );
585}
586
587template< typename pass_type >
588DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
589 MUTATE_START( node );
590
591 indexerAddId( node );
592
593 {
594 // with clause introduces a level of scope (for the with expression members).
595 // with clause exprs are added to the indexer before parameters so that parameters
596 // shadow with exprs and not the other way around.
597 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
598 indexerAddWith( node->withExprs, node );
599 {
600 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
601 // implicit add __func__ identifier as specified in the C manual 6.4.2.2
602 static ObjectDecl func(
603 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
604 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
605 nullptr
606 );
607 indexerAddId( &func );
608 maybeMutate_impl( node->type, *this );
609 // First remember that we are now within a function.
610 ValueGuard< bool > oldInFunction( inFunction );
611 inFunction = true;
612 // The function body needs to have the same scope as parameters.
613 // A CompoundStmt will not enter a new scope if atFunctionTop is true.
614 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
615 atFunctionTop = true;
616 maybeMutate_impl( node->statements, *this );
617 maybeMutate_impl( node->attributes, *this );
618 }
619 }
620
621 MUTATE_END( DeclarationWithType, node );
622}
623
624//--------------------------------------------------------------------------
625// StructDecl
626template< typename pass_type >
627void PassVisitor< pass_type >::visit( StructDecl * node ) {
628 VISIT_START( node );
629
630 // make up a forward declaration and add it before processing the members
631 // needs to be on the heap because addStruct saves the pointer
632 indexerAddStructFwd( node );
633
634 {
635 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
636 maybeAccept_impl( node->parameters, *this );
637 maybeAccept_impl( node->members , *this );
638 maybeAccept_impl( node->attributes, *this );
639 }
640
641 // this addition replaces the forward declaration
642 indexerAddStruct( node );
643
644 VISIT_END( node );
645}
646
647template< typename pass_type >
648void PassVisitor< pass_type >::visit( const StructDecl * node ) {
649 VISIT_START( node );
650
651 // make up a forward declaration and add it before processing the members
652 // needs to be on the heap because addStruct saves the pointer
653 indexerAddStructFwd( node );
654
655 {
656 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
657 maybeAccept_impl( node->parameters, *this );
658 maybeAccept_impl( node->members , *this );
659 maybeAccept_impl( node->attributes, *this );
660 }
661
662 // this addition replaces the forward declaration
663 indexerAddStruct( node );
664
665 VISIT_END( node );
666}
667
668template< typename pass_type >
669Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
670 MUTATE_START( node );
671
672 // make up a forward declaration and add it before processing the members
673 // needs to be on the heap because addStruct saves the pointer
674 indexerAddStructFwd( node );
675
676 {
677 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
678 maybeMutate_impl( node->parameters, *this );
679 maybeMutate_impl( node->members , *this );
680 maybeMutate_impl( node->attributes, *this );
681 }
682
683 // this addition replaces the forward declaration
684 indexerAddStruct( node );
685
686 MUTATE_END( Declaration, node );
687}
688
689//--------------------------------------------------------------------------
690// UnionDecl
691template< typename pass_type >
692void PassVisitor< pass_type >::visit( UnionDecl * node ) {
693 VISIT_START( node );
694
695 // make up a forward declaration and add it before processing the members
696 indexerAddUnionFwd( node );
697
698 {
699 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
700 maybeAccept_impl( node->parameters, *this );
701 maybeAccept_impl( node->members , *this );
702 maybeAccept_impl( node->attributes, *this );
703 }
704
705 indexerAddUnion( node );
706
707 VISIT_END( node );
708}
709template< typename pass_type >
710void PassVisitor< pass_type >::visit( const UnionDecl * node ) {
711 VISIT_START( node );
712
713 // make up a forward declaration and add it before processing the members
714 indexerAddUnionFwd( node );
715
716 {
717 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
718 maybeAccept_impl( node->parameters, *this );
719 maybeAccept_impl( node->members , *this );
720 maybeAccept_impl( node->attributes, *this );
721 }
722
723 indexerAddUnion( node );
724
725 VISIT_END( node );
726}
727
728template< typename pass_type >
729Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
730 MUTATE_START( node );
731
732 // make up a forward declaration and add it before processing the members
733 indexerAddUnionFwd( node );
734
735 {
736 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
737 maybeMutate_impl( node->parameters, *this );
738 maybeMutate_impl( node->members , *this );
739 maybeMutate_impl( node->attributes, *this );
740 }
741
742 indexerAddUnion( node );
743
744 MUTATE_END( Declaration, node );
745}
746
747//--------------------------------------------------------------------------
748// EnumDecl
749template< typename pass_type >
750void PassVisitor< pass_type >::visit( EnumDecl * node ) {
751 VISIT_START( node );
752
753 indexerAddEnum( node );
754
755 // unlike structs, traits, and unions, enums inject their members into the global scope
756 // if ( node->base ) maybeAccept_impl( node->base, *this ); // Need this? Maybe not?
757 maybeAccept_impl( node->parameters, *this );
758 maybeAccept_impl( node->members , *this );
759 maybeAccept_impl( node->attributes, *this );
760
761 VISIT_END( node );
762}
763
764template< typename pass_type >
765void PassVisitor< pass_type >::visit( const EnumDecl * node ) {
766 VISIT_START( node );
767
768 indexerAddEnum( node );
769
770 // unlike structs, traits, and unions, enums inject their members into the global scope
771 maybeAccept_impl( node->parameters, *this );
772 maybeAccept_impl( node->members , *this );
773 maybeAccept_impl( node->attributes, *this );
774
775 VISIT_END( node );
776}
777
778template< typename pass_type >
779Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
780 MUTATE_START( node );
781
782 indexerAddEnum( node );
783
784 // unlike structs, traits, and unions, enums inject their members into the global scope
785 maybeMutate_impl( node->parameters, *this );
786 maybeMutate_impl( node->members , *this );
787 maybeMutate_impl( node->attributes, *this );
788
789 MUTATE_END( Declaration, node );
790}
791
792//--------------------------------------------------------------------------
793// TraitDecl
794template< typename pass_type >
795void PassVisitor< pass_type >::visit( TraitDecl * node ) {
796 VISIT_START( node );
797
798 {
799 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
800 maybeAccept_impl( node->parameters, *this );
801 maybeAccept_impl( node->members , *this );
802 maybeAccept_impl( node->attributes, *this );
803 }
804
805 indexerAddTrait( node );
806
807 VISIT_END( node );
808}
809
810template< typename pass_type >
811void PassVisitor< pass_type >::visit( const TraitDecl * node ) {
812 VISIT_START( node );
813
814 {
815 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
816 maybeAccept_impl( node->parameters, *this );
817 maybeAccept_impl( node->members , *this );
818 maybeAccept_impl( node->attributes, *this );
819 }
820
821 indexerAddTrait( node );
822
823 VISIT_END( node );
824}
825
826template< typename pass_type >
827Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
828 MUTATE_START( node );
829
830 {
831 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
832 maybeMutate_impl( node->parameters, *this );
833 maybeMutate_impl( node->members , *this );
834 maybeMutate_impl( node->attributes, *this );
835 }
836
837 indexerAddTrait( node );
838
839 MUTATE_END( Declaration, node );
840}
841
842//--------------------------------------------------------------------------
843// TypeDecl
844template< typename pass_type >
845void PassVisitor< pass_type >::visit( TypeDecl * node ) {
846 VISIT_START( node );
847
848 {
849 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
850 maybeAccept_impl( node->base , *this );
851 }
852
853 // see A NOTE ON THE ORDER OF TRAVERSAL, above
854 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
855 // and may depend on the type itself
856 indexerAddType( node );
857
858 maybeAccept_impl( node->assertions, *this );
859
860 indexerScopedAccept( node->init, *this );
861
862 VISIT_END( node );
863}
864
865
866template< typename pass_type >
867void PassVisitor< pass_type >::visit( const TypeDecl * node ) {
868 VISIT_START( node );
869
870 {
871 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
872 maybeAccept_impl( node->base , *this );
873 }
874
875 // see A NOTE ON THE ORDER OF TRAVERSAL, above
876 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
877 // and may depend on the type itself
878 indexerAddType( node );
879
880 maybeAccept_impl( node->assertions, *this );
881
882 indexerScopedAccept( node->init, *this );
883
884 VISIT_END( node );
885}
886
887template< typename pass_type >
888Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
889 MUTATE_START( node );
890
891 {
892 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
893 maybeMutate_impl( node->base , *this );
894 }
895
896 // see A NOTE ON THE ORDER OF TRAVERSAL, above
897 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
898 // and may depend on the type itself
899 indexerAddType( node );
900
901 maybeMutate_impl( node->assertions, *this );
902
903 indexerScopedMutate( node->init, *this );
904
905 MUTATE_END( Declaration, node );
906}
907
908//--------------------------------------------------------------------------
909// TypedefDecl
910template< typename pass_type >
911void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
912 VISIT_START( node );
913
914 {
915 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
916 maybeAccept_impl( node->base , *this );
917 }
918
919 indexerAddType( node );
920
921 maybeAccept_impl( node->assertions, *this );
922
923 VISIT_END( node );
924}
925
926template< typename pass_type >
927void PassVisitor< pass_type >::visit( const TypedefDecl * node ) {
928 VISIT_START( node );
929
930 {
931 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
932 maybeAccept_impl( node->base , *this );
933 }
934
935 indexerAddType( node );
936
937 maybeAccept_impl( node->assertions, *this );
938
939 VISIT_END( node );
940}
941
942template< typename pass_type >
943Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
944 MUTATE_START( node );
945
946 {
947 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
948 maybeMutate_impl( node->base , *this );
949 }
950
951 indexerAddType( node );
952
953 maybeMutate_impl( node->assertions, *this );
954
955 MUTATE_END( Declaration, node );
956}
957
958//--------------------------------------------------------------------------
959// AsmDecl
960template< typename pass_type >
961void PassVisitor< pass_type >::visit( AsmDecl * node ) {
962 VISIT_START( node );
963
964 maybeAccept_impl( node->stmt, *this );
965
966 VISIT_END( node );
967}
968
969template< typename pass_type >
970void PassVisitor< pass_type >::visit( const AsmDecl * node ) {
971 VISIT_START( node );
972
973 maybeAccept_impl( node->stmt, *this );
974
975 VISIT_END( node );
976}
977
978template< typename pass_type >
979AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
980 MUTATE_START( node );
981
982 maybeMutate_impl( node->stmt, *this );
983
984 MUTATE_END( AsmDecl, node );
985}
986
987//--------------------------------------------------------------------------
988// DirectiveDecl
989template< typename pass_type >
990void PassVisitor< pass_type >::visit( DirectiveDecl * node ) {
991 VISIT_START( node );
992
993 maybeAccept_impl( node->stmt, *this );
994
995 VISIT_END( node );
996}
997
998template< typename pass_type >
999void PassVisitor< pass_type >::visit( const DirectiveDecl * node ) {
1000 VISIT_START( node );
1001
1002 maybeAccept_impl( node->stmt, *this );
1003
1004 VISIT_END( node );
1005}
1006
1007template< typename pass_type >
1008DirectiveDecl * PassVisitor< pass_type >::mutate( DirectiveDecl * node ) {
1009 MUTATE_START( node );
1010
1011 maybeMutate_impl( node->stmt, *this );
1012
1013 MUTATE_END( DirectiveDecl, node );
1014}
1015
1016//--------------------------------------------------------------------------
1017// StaticAssertDecl
1018template< typename pass_type >
1019void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) {
1020 VISIT_START( node );
1021
1022 node->condition = visitExpression( node->condition );
1023 maybeAccept_impl( node->message, *this );
1024
1025 VISIT_END( node );
1026}
1027
1028template< typename pass_type >
1029void PassVisitor< pass_type >::visit( const StaticAssertDecl * node ) {
1030 VISIT_START( node );
1031
1032 visitExpression( node->condition );
1033 maybeAccept_impl( node->message, *this );
1034
1035 VISIT_END( node );
1036}
1037
1038template< typename pass_type >
1039StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) {
1040 MUTATE_START( node );
1041
1042 node->condition = mutateExpression( node->condition );
1043 maybeMutate_impl( node->message, *this );
1044
1045 MUTATE_END( StaticAssertDecl, node );
1046}
1047
1048//--------------------------------------------------------------------------
1049// CompoundStmt
1050template< typename pass_type >
1051void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
1052 VISIT_START( node );
1053 {
1054 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1055 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1056 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
1057 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
1058 atFunctionTop = false;
1059 visitStatementList( node->kids );
1060 }
1061 VISIT_END( node );
1062}
1063
1064template< typename pass_type >
1065void PassVisitor< pass_type >::visit( const CompoundStmt * node ) {
1066 VISIT_START( node );
1067 {
1068 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1069 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1070 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
1071 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
1072 atFunctionTop = false;
1073 visitStatementList( node->kids );
1074 }
1075 VISIT_END( node );
1076}
1077
1078template< typename pass_type >
1079CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
1080 MUTATE_START( node );
1081 {
1082 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1083 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1084 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
1085 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
1086 atFunctionTop = false;
1087 mutateStatementList( node->kids );
1088 }
1089 MUTATE_END( CompoundStmt, node );
1090}
1091
1092//--------------------------------------------------------------------------
1093// ExprStmt
1094template< typename pass_type >
1095void PassVisitor< pass_type >::visit( ExprStmt * node ) {
1096 VISIT_START( node );
1097
1098 visitExpression( node->expr );
1099
1100 VISIT_END( node );
1101}
1102
1103template< typename pass_type >
1104void PassVisitor< pass_type >::visit( const ExprStmt * node ) {
1105 VISIT_START( node );
1106
1107 visitExpression( node->expr );
1108
1109 VISIT_END( node );
1110}
1111
1112template< typename pass_type >
1113Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
1114 MUTATE_START( node );
1115
1116 node->expr = mutateExpression( node->expr );
1117
1118 MUTATE_END( Statement, node );
1119}
1120
1121//--------------------------------------------------------------------------
1122// AsmStmt
1123template< typename pass_type >
1124void PassVisitor< pass_type >::visit( AsmStmt * node ) {
1125 VISIT_START( node )
1126
1127 maybeAccept_impl( node->instruction, *this );
1128 maybeAccept_impl( node->output, *this );
1129 maybeAccept_impl( node->input, *this );
1130 maybeAccept_impl( node->clobber, *this );
1131
1132 VISIT_END( node );
1133}
1134
1135template< typename pass_type >
1136void PassVisitor< pass_type >::visit( const AsmStmt * node ) {
1137 VISIT_START( node )
1138
1139 maybeAccept_impl( node->instruction, *this );
1140 maybeAccept_impl( node->output, *this );
1141 maybeAccept_impl( node->input, *this );
1142 maybeAccept_impl( node->clobber, *this );
1143
1144 VISIT_END( node );
1145}
1146
1147template< typename pass_type >
1148Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
1149 MUTATE_START( node );
1150
1151 maybeMutate_impl( node->instruction, *this );
1152 maybeMutate_impl( node->output, *this );
1153 maybeMutate_impl( node->input, *this );
1154 maybeMutate_impl( node->clobber, *this );
1155
1156 MUTATE_END( Statement, node );
1157}
1158
1159//--------------------------------------------------------------------------
1160// AsmStmt
1161template< typename pass_type >
1162void PassVisitor< pass_type >::visit( DirectiveStmt * node ) {
1163 VISIT_START( node )
1164
1165 VISIT_END( node );
1166}
1167
1168template< typename pass_type >
1169void PassVisitor< pass_type >::visit( const DirectiveStmt * node ) {
1170 VISIT_START( node )
1171
1172 VISIT_END( node );
1173}
1174
1175template< typename pass_type >
1176Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) {
1177 MUTATE_START( node );
1178
1179 MUTATE_END( Statement, node );
1180}
1181
1182//--------------------------------------------------------------------------
1183// IfStmt
1184template< typename pass_type >
1185void PassVisitor< pass_type >::visit( IfStmt * node ) {
1186 VISIT_START( node );
1187 {
1188 // if statements introduce a level of scope (for the initialization)
1189 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1190 maybeAccept_impl( node->initialization, *this );
1191 visitExpression ( node->condition );
1192 node->then = visitStatement( node->then );
1193 node->else_ = visitStatement( node->else_ );
1194 }
1195 VISIT_END( node );
1196}
1197
1198template< typename pass_type >
1199void PassVisitor< pass_type >::visit( const IfStmt * node ) {
1200 VISIT_START( node );
1201 {
1202 // if statements introduce a level of scope (for the initialization)
1203 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1204 maybeAccept_impl( node->initialization, *this );
1205 visitExpression ( node->condition );
1206 visitStatement ( node->then );
1207 visitStatement ( node->else_ );
1208 }
1209 VISIT_END( node );
1210}
1211
1212template< typename pass_type >
1213Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
1214 MUTATE_START( node );
1215 {
1216 // if statements introduce a level of scope (for the initialization)
1217 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1218 maybeMutate_impl( node->initialization, *this );
1219 node->condition = mutateExpression( node->condition );
1220 node->then = mutateStatement ( node->then );
1221 node->else_ = mutateStatement ( node->else_ );
1222 }
1223 MUTATE_END( Statement, node );
1224}
1225
1226//--------------------------------------------------------------------------
1227// WhileDoStmt
1228template< typename pass_type >
1229void PassVisitor< pass_type >::visit( WhileDoStmt * node ) {
1230 VISIT_START( node );
1231
1232 {
1233 // while statements introduce a level of scope (for the initialization)
1234 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1235 maybeAccept_impl( node->initialization, *this );
1236 visitExpression ( node->condition );
1237 node->body = visitStatement( node->body );
1238 }
1239
1240 VISIT_END( node );
1241}
1242
1243template< typename pass_type >
1244void PassVisitor< pass_type >::visit( const WhileDoStmt * node ) {
1245 VISIT_START( node );
1246
1247 {
1248 // while statements introduce a level of scope (for the initialization)
1249 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1250 maybeAccept_impl( node->initialization, *this );
1251 visitExpression ( node->condition );
1252 visitStatement ( node->body );
1253 }
1254
1255 VISIT_END( node );
1256}
1257
1258template< typename pass_type >
1259Statement * PassVisitor< pass_type >::mutate( WhileDoStmt * node ) {
1260 MUTATE_START( node );
1261
1262 {
1263 // while statements introduce a level of scope (for the initialization)
1264 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1265 maybeMutate_impl( node->initialization, *this );
1266 node->condition = mutateExpression( node->condition );
1267 node->body = mutateStatement ( node->body );
1268 }
1269
1270
1271 MUTATE_END( Statement, node );
1272}
1273
1274//--------------------------------------------------------------------------
1275// ForStmt
1276template< typename pass_type >
1277void PassVisitor< pass_type >::visit( ForStmt * node ) {
1278 VISIT_START( node );
1279 {
1280 // for statements introduce a level of scope (for the initialization)
1281 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1282 maybeAccept_impl( node->initialization, *this );
1283 visitExpression( node->condition );
1284 visitExpression( node->increment );
1285 node->body = visitStatement( node->body );
1286 }
1287 VISIT_END( node );
1288}
1289
1290template< typename pass_type >
1291void PassVisitor< pass_type >::visit( const ForStmt * node ) {
1292 VISIT_START( node );
1293 {
1294 // for statements introduce a level of scope (for the initialization)
1295 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1296 maybeAccept_impl( node->initialization, *this );
1297 visitExpression( node->condition );
1298 visitExpression( node->increment );
1299 visitStatement ( node->body );
1300 }
1301 VISIT_END( node );
1302}
1303
1304template< typename pass_type >
1305Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
1306 MUTATE_START( node );
1307 {
1308 // for statements introduce a level of scope (for the initialization)
1309 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1310 maybeMutate_impl( node->initialization, *this );
1311 node->condition = mutateExpression( node->condition );
1312 node->increment = mutateExpression( node->increment );
1313 node->body = mutateStatement ( node->body );
1314 }
1315 MUTATE_END( Statement, node );
1316}
1317
1318//--------------------------------------------------------------------------
1319// SwitchStmt
1320template< typename pass_type >
1321void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
1322 VISIT_START( node );
1323
1324 visitExpression ( node->condition );
1325 visitStatementList( node->statements );
1326
1327 VISIT_END( node );
1328}
1329
1330template< typename pass_type >
1331void PassVisitor< pass_type >::visit( const SwitchStmt * node ) {
1332 VISIT_START( node );
1333
1334 visitExpression ( node->condition );
1335 visitStatementList( node->statements );
1336
1337 VISIT_END( node );
1338}
1339
1340template< typename pass_type >
1341Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
1342 MUTATE_START( node );
1343
1344 node->condition = mutateExpression( node->condition );
1345 mutateStatementList( node->statements );
1346
1347 MUTATE_END( Statement, node );
1348}
1349
1350//--------------------------------------------------------------------------
1351// CaseStmt
1352template< typename pass_type >
1353void PassVisitor< pass_type >::visit( CaseStmt * node ) {
1354 VISIT_START( node );
1355
1356 visitExpression ( node->condition );
1357 visitStatementList( node->stmts );
1358
1359 VISIT_END( node );
1360}
1361
1362template< typename pass_type >
1363void PassVisitor< pass_type >::visit( const CaseStmt * node ) {
1364 VISIT_START( node );
1365
1366 visitExpression ( node->condition );
1367 visitStatementList( node->stmts );
1368
1369 VISIT_END( node );
1370}
1371
1372template< typename pass_type >
1373Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
1374 MUTATE_START( node );
1375
1376 node->condition = mutateExpression( node->condition );
1377 mutateStatementList( node->stmts );
1378
1379 MUTATE_END( Statement, node );
1380}
1381
1382//--------------------------------------------------------------------------
1383// BranchStmt
1384template< typename pass_type >
1385void PassVisitor< pass_type >::visit( BranchStmt * node ) {
1386 VISIT_START( node );
1387 VISIT_END( node );
1388}
1389
1390template< typename pass_type >
1391void PassVisitor< pass_type >::visit( const BranchStmt * node ) {
1392 VISIT_START( node );
1393 VISIT_END( node );
1394}
1395
1396template< typename pass_type >
1397Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
1398 MUTATE_START( node );
1399 MUTATE_END( Statement, node );
1400}
1401
1402//--------------------------------------------------------------------------
1403// ReturnStmt
1404template< typename pass_type >
1405void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
1406 VISIT_START( node );
1407
1408 visitExpression( node->expr );
1409
1410 VISIT_END( node );
1411}
1412
1413template< typename pass_type >
1414void PassVisitor< pass_type >::visit( const ReturnStmt * node ) {
1415 VISIT_START( node );
1416
1417 visitExpression( node->expr );
1418
1419 VISIT_END( node );
1420}
1421
1422template< typename pass_type >
1423Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
1424 MUTATE_START( node );
1425
1426 node->expr = mutateExpression( node->expr );
1427
1428 MUTATE_END( Statement, node );
1429}
1430
1431//--------------------------------------------------------------------------
1432// ThrowStmt
1433template< typename pass_type >
1434void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
1435 VISIT_START( node );
1436
1437 maybeAccept_impl( node->expr, *this );
1438 maybeAccept_impl( node->target, *this );
1439
1440 VISIT_END( node );
1441}
1442
1443template< typename pass_type >
1444void PassVisitor< pass_type >::visit( const ThrowStmt * node ) {
1445 VISIT_START( node );
1446
1447 maybeAccept_impl( node->expr, *this );
1448 maybeAccept_impl( node->target, *this );
1449
1450 VISIT_END( node );
1451}
1452
1453template< typename pass_type >
1454Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
1455 MUTATE_START( node );
1456
1457 maybeMutate_impl( node->expr, *this );
1458 maybeMutate_impl( node->target, *this );
1459
1460 MUTATE_END( Statement, node );
1461}
1462
1463//--------------------------------------------------------------------------
1464// TryStmt
1465template< typename pass_type >
1466void PassVisitor< pass_type >::visit( TryStmt * node ) {
1467 VISIT_START( node );
1468
1469 maybeAccept_impl( node->block , *this );
1470 maybeAccept_impl( node->handlers , *this );
1471 maybeAccept_impl( node->finallyBlock, *this );
1472
1473 VISIT_END( node );
1474}
1475
1476template< typename pass_type >
1477void PassVisitor< pass_type >::visit( const TryStmt * node ) {
1478 VISIT_START( node );
1479
1480 maybeAccept_impl( node->block , *this );
1481 maybeAccept_impl( node->handlers , *this );
1482 maybeAccept_impl( node->finallyBlock, *this );
1483
1484 VISIT_END( node );
1485}
1486
1487template< typename pass_type >
1488Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
1489 MUTATE_START( node );
1490
1491 maybeMutate_impl( node->block , *this );
1492 maybeMutate_impl( node->handlers , *this );
1493 maybeMutate_impl( node->finallyBlock, *this );
1494
1495 MUTATE_END( Statement, node );
1496}
1497
1498//--------------------------------------------------------------------------
1499// CatchStmt
1500template< typename pass_type >
1501void PassVisitor< pass_type >::visit( CatchStmt * node ) {
1502 VISIT_START( node );
1503 {
1504 // catch statements introduce a level of scope (for the caught exception)
1505 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1506 maybeAccept_impl( node->decl, *this );
1507 node->cond = visitExpression( node->cond );
1508 node->body = visitStatement ( node->body );
1509 }
1510 VISIT_END( node );
1511}
1512
1513template< typename pass_type >
1514void PassVisitor< pass_type >::visit( const CatchStmt * node ) {
1515 VISIT_START( node );
1516 {
1517 // catch statements introduce a level of scope (for the caught exception)
1518 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1519 maybeAccept_impl( node->decl, *this );
1520 visitExpression ( node->cond );
1521 visitStatement ( node->body );
1522 }
1523 VISIT_END( node );
1524}
1525
1526template< typename pass_type >
1527Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
1528 MUTATE_START( node );
1529 {
1530 // catch statements introduce a level of scope (for the caught exception)
1531 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1532 maybeMutate_impl( node->decl, *this );
1533 node->cond = mutateExpression( node->cond );
1534 node->body = mutateStatement ( node->body );
1535 }
1536 MUTATE_END( Statement, node );
1537}
1538
1539//--------------------------------------------------------------------------
1540// FinallyStmt
1541template< typename pass_type >
1542void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
1543 VISIT_START( node );
1544
1545 maybeAccept_impl( node->block, *this );
1546
1547 VISIT_END( node );
1548}
1549
1550template< typename pass_type >
1551void PassVisitor< pass_type >::visit( const FinallyStmt * node ) {
1552 VISIT_START( node );
1553
1554 maybeAccept_impl( node->block, *this );
1555
1556 VISIT_END( node );
1557}
1558
1559template< typename pass_type >
1560Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
1561 MUTATE_START( node );
1562
1563 maybeMutate_impl( node->block, *this );
1564
1565 MUTATE_END( Statement, node );
1566}
1567
1568//--------------------------------------------------------------------------
1569// SuspendStmt
1570template< typename pass_type >
1571void PassVisitor< pass_type >::visit( SuspendStmt * node ) {
1572 VISIT_START( node );
1573
1574 maybeAccept_impl( node->then , *this );
1575
1576 VISIT_END( node );
1577}
1578
1579template< typename pass_type >
1580void PassVisitor< pass_type >::visit( const SuspendStmt * node ) {
1581 VISIT_START( node );
1582
1583 maybeAccept_impl( node->then , *this );
1584
1585 VISIT_END( node );
1586}
1587
1588template< typename pass_type >
1589Statement * PassVisitor< pass_type >::mutate( SuspendStmt * node ) {
1590 MUTATE_START( node );
1591
1592 maybeMutate_impl( node->then , *this );
1593
1594 MUTATE_END( Statement, node );
1595}
1596
1597//--------------------------------------------------------------------------
1598// WaitForStmt
1599template< typename pass_type >
1600void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
1601 VISIT_START( node );
1602
1603 for( auto & clause : node->clauses ) {
1604 maybeAccept_impl( clause.target.function, *this );
1605 maybeAccept_impl( clause.target.arguments, *this );
1606
1607 maybeAccept_impl( clause.statement, *this );
1608 maybeAccept_impl( clause.condition, *this );
1609 }
1610
1611 maybeAccept_impl( node->timeout.time, *this );
1612 maybeAccept_impl( node->timeout.statement, *this );
1613 maybeAccept_impl( node->timeout.condition, *this );
1614 maybeAccept_impl( node->orelse.statement, *this );
1615 maybeAccept_impl( node->orelse.condition, *this );
1616
1617 VISIT_END( node );
1618}
1619
1620template< typename pass_type >
1621void PassVisitor< pass_type >::visit( const WaitForStmt * node ) {
1622 VISIT_START( node );
1623
1624 for( auto & clause : node->clauses ) {
1625 maybeAccept_impl( clause.target.function, *this );
1626 maybeAccept_impl( clause.target.arguments, *this );
1627
1628 maybeAccept_impl( clause.statement, *this );
1629 maybeAccept_impl( clause.condition, *this );
1630 }
1631
1632 maybeAccept_impl( node->timeout.time, *this );
1633 maybeAccept_impl( node->timeout.statement, *this );
1634 maybeAccept_impl( node->timeout.condition, *this );
1635 maybeAccept_impl( node->orelse.statement, *this );
1636 maybeAccept_impl( node->orelse.condition, *this );
1637
1638 VISIT_END( node );
1639}
1640
1641template< typename pass_type >
1642Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
1643 MUTATE_START( node );
1644
1645 for( auto & clause : node->clauses ) {
1646 maybeMutate_impl( clause.target.function, *this );
1647 maybeMutate_impl( clause.target.arguments, *this );
1648
1649 maybeMutate_impl( clause.statement, *this );
1650 maybeMutate_impl( clause.condition, *this );
1651 }
1652
1653 maybeMutate_impl( node->timeout.time, *this );
1654 maybeMutate_impl( node->timeout.statement, *this );
1655 maybeMutate_impl( node->timeout.condition, *this );
1656 maybeMutate_impl( node->orelse.statement, *this );
1657 maybeMutate_impl( node->orelse.condition, *this );
1658
1659 MUTATE_END( Statement, node );
1660}
1661
1662
1663
1664//--------------------------------------------------------------------------
1665// WithStmt
1666template< typename pass_type >
1667void PassVisitor< pass_type >::visit( WithStmt * node ) {
1668 VISIT_START( node );
1669 maybeAccept_impl( node->exprs, *this );
1670 {
1671 // catch statements introduce a level of scope (for the caught exception)
1672 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1673 indexerAddWith( node->exprs, node );
1674 maybeAccept_impl( node->stmt, *this );
1675 }
1676 VISIT_END( node );
1677}
1678
1679template< typename pass_type >
1680void PassVisitor< pass_type >::visit( const WithStmt * node ) {
1681 VISIT_START( node );
1682 maybeAccept_impl( node->exprs, *this );
1683 {
1684 // catch statements introduce a level of scope (for the caught exception)
1685 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1686 indexerAddWith( node->exprs, node );
1687 maybeAccept_impl( node->stmt, *this );
1688 }
1689 VISIT_END( node );
1690}
1691
1692template< typename pass_type >
1693Declaration * PassVisitor< pass_type >::mutate( WithStmt * node ) {
1694 MUTATE_START( node );
1695 maybeMutate_impl( node->exprs, *this );
1696 {
1697 // catch statements introduce a level of scope (for the caught exception)
1698 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1699 indexerAddWith( node->exprs, node );
1700 maybeMutate_impl( node->stmt, *this );
1701 }
1702 MUTATE_END( Declaration, node );
1703}
1704
1705//--------------------------------------------------------------------------
1706// NullStmt
1707template< typename pass_type >
1708void PassVisitor< pass_type >::visit( NullStmt * node ) {
1709 VISIT_START( node );
1710 VISIT_END( node );
1711}
1712
1713template< typename pass_type >
1714void PassVisitor< pass_type >::visit( const NullStmt * node ) {
1715 VISIT_START( node );
1716 VISIT_END( node );
1717}
1718
1719template< typename pass_type >
1720NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
1721 MUTATE_START( node );
1722 MUTATE_END( NullStmt, node );
1723}
1724
1725//--------------------------------------------------------------------------
1726// DeclStmt
1727template< typename pass_type >
1728void PassVisitor< pass_type >::visit( DeclStmt * node ) {
1729 VISIT_START( node );
1730
1731 maybeAccept_impl( node->decl, *this );
1732
1733 VISIT_END( node );
1734}
1735
1736template< typename pass_type >
1737void PassVisitor< pass_type >::visit( const DeclStmt * node ) {
1738 VISIT_START( node );
1739
1740 maybeAccept_impl( node->decl, *this );
1741
1742 VISIT_END( node );
1743}
1744
1745template< typename pass_type >
1746Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
1747 MUTATE_START( node );
1748
1749 maybeMutate_impl( node->decl, *this );
1750
1751 MUTATE_END( Statement, node );
1752}
1753
1754//--------------------------------------------------------------------------
1755// ImplicitCtorDtorStmt
1756template< typename pass_type >
1757void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
1758 VISIT_START( node );
1759
1760 maybeAccept_impl( node->callStmt, *this );
1761
1762 VISIT_END( node );
1763}
1764
1765template< typename pass_type >
1766void PassVisitor< pass_type >::visit( const ImplicitCtorDtorStmt * node ) {
1767 VISIT_START( node );
1768
1769 maybeAccept_impl( node->callStmt, *this );
1770
1771 VISIT_END( node );
1772}
1773
1774template< typename pass_type >
1775Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
1776 MUTATE_START( node );
1777
1778 maybeMutate_impl( node->callStmt, *this );
1779
1780 MUTATE_END( Statement, node );
1781}
1782
1783//--------------------------------------------------------------------------
1784// MutexStmt
1785template< typename pass_type >
1786void PassVisitor< pass_type >::visit( MutexStmt * node ) {
1787 VISIT_START( node );
1788 // mutex statements introduce a level of scope (for the initialization)
1789 maybeAccept_impl( node->mutexObjs, *this );
1790 {
1791 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1792 node->stmt = visitStatement( node->stmt );
1793 }
1794 VISIT_END( node );
1795}
1796
1797template< typename pass_type >
1798void PassVisitor< pass_type >::visit( const MutexStmt * node ) {
1799 VISIT_START( node );
1800 maybeAccept_impl( node->mutexObjs, *this );
1801 {
1802 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1803 visitStatement( node->stmt );
1804 }
1805 VISIT_END( node );
1806}
1807
1808template< typename pass_type >
1809Statement * PassVisitor< pass_type >::mutate( MutexStmt * node ) {
1810 MUTATE_START( node );
1811 maybeMutate_impl( node->mutexObjs, *this );
1812 {
1813 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1814 node->stmt = mutateStatement( node->stmt );
1815 }
1816 MUTATE_END( Statement, node );
1817}
1818
1819//--------------------------------------------------------------------------
1820// ApplicationExpr
1821template< typename pass_type >
1822void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
1823 VISIT_START( node );
1824
1825 indexerScopedAccept( node->result , *this );
1826 maybeAccept_impl ( node->function, *this );
1827 maybeAccept_impl ( node->args , *this );
1828
1829 VISIT_END( node );
1830}
1831
1832template< typename pass_type >
1833void PassVisitor< pass_type >::visit( const ApplicationExpr * node ) {
1834 VISIT_START( node );
1835
1836 indexerScopedAccept( node->result , *this );
1837 maybeAccept_impl ( node->function, *this );
1838 maybeAccept_impl ( node->args , *this );
1839
1840 VISIT_END( node );
1841}
1842
1843template< typename pass_type >
1844Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
1845 MUTATE_START( node );
1846
1847 indexerScopedMutate( node->env , *this );
1848 indexerScopedMutate( node->result , *this );
1849 maybeMutate_impl ( node->function, *this );
1850 maybeMutate_impl ( node->args , *this );
1851
1852 MUTATE_END( Expression, node );
1853}
1854
1855//--------------------------------------------------------------------------
1856// UntypedExpr
1857template< typename pass_type >
1858void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
1859 VISIT_START( node );
1860
1861 // maybeAccept_impl( node->get_env(), *this );
1862 indexerScopedAccept( node->result, *this );
1863
1864 for ( auto expr : node->args ) {
1865 visitExpression( expr );
1866 }
1867
1868 VISIT_END( node );
1869}
1870
1871template< typename pass_type >
1872void PassVisitor< pass_type >::visit( const UntypedExpr * node ) {
1873 VISIT_START( node );
1874
1875 indexerScopedAccept( node->result, *this );
1876
1877 for ( auto expr : node->args ) {
1878 visitExpression( expr );
1879 }
1880
1881 VISIT_END( node );
1882}
1883
1884template< typename pass_type >
1885Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
1886 MUTATE_START( node );
1887
1888 indexerScopedMutate( node->env , *this );
1889 indexerScopedMutate( node->result, *this );
1890
1891 for ( auto& expr : node->args ) {
1892 expr = mutateExpression( expr );
1893 }
1894
1895 MUTATE_END( Expression, node );
1896}
1897
1898//--------------------------------------------------------------------------
1899// NameExpr
1900template< typename pass_type >
1901void PassVisitor< pass_type >::visit( NameExpr * node ) {
1902 VISIT_START( node );
1903
1904 indexerScopedAccept( node->result, *this );
1905
1906 VISIT_END( node );
1907}
1908
1909template< typename pass_type >
1910void PassVisitor< pass_type >::visit( const NameExpr * node ) {
1911 VISIT_START( node );
1912
1913 indexerScopedAccept( node->result, *this );
1914
1915 VISIT_END( node );
1916}
1917
1918template< typename pass_type >
1919Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
1920 MUTATE_START( node );
1921
1922 indexerScopedMutate( node->env , *this );
1923 indexerScopedMutate( node->result, *this );
1924
1925 MUTATE_END( Expression, node );
1926}
1927
1928//--------------------------------------------------------------------------
1929// QualifiedNameExpr
1930template< typename pass_type >
1931void PassVisitor< pass_type >::visit( QualifiedNameExpr * node ) {
1932 VISIT_START( node );
1933
1934 indexerScopedAccept( node->result, *this );
1935 maybeAccept_impl( node->type_decl, *this );
1936 maybeAccept_impl( node->var, *this );
1937
1938 VISIT_END( node );
1939}
1940
1941template< typename pass_type >
1942void PassVisitor< pass_type >::visit( const QualifiedNameExpr * node ) {
1943 VISIT_START( node );
1944
1945 indexerScopedAccept( node->result, *this );
1946 maybeAccept_impl( node->type_decl, *this );
1947 maybeAccept_impl( node->var, *this );
1948
1949 VISIT_END( node );
1950}
1951
1952template< typename pass_type >
1953Expression * PassVisitor< pass_type >::mutate( QualifiedNameExpr * node ) {
1954 MUTATE_START( node );
1955
1956 indexerScopedMutate( node->env , *this );
1957 indexerScopedMutate( node->result, *this );
1958 maybeMutate_impl( node->type_decl, *this );
1959 maybeAccept_impl( node->var, *this );
1960
1961 MUTATE_END( Expression, node );
1962}
1963
1964//--------------------------------------------------------------------------
1965// CastExpr
1966template< typename pass_type >
1967void PassVisitor< pass_type >::visit( CastExpr * node ) {
1968 VISIT_START( node );
1969
1970 indexerScopedAccept( node->result, *this );
1971 maybeAccept_impl ( node->arg , *this );
1972
1973 VISIT_END( node );
1974}
1975
1976template< typename pass_type >
1977void PassVisitor< pass_type >::visit( const CastExpr * node ) {
1978 VISIT_START( node );
1979
1980 indexerScopedAccept( node->result, *this );
1981 maybeAccept_impl ( node->arg , *this );
1982
1983 VISIT_END( node );
1984}
1985
1986template< typename pass_type >
1987Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
1988 MUTATE_START( node );
1989
1990 indexerScopedMutate( node->env , *this );
1991 indexerScopedMutate( node->result, *this );
1992 maybeMutate_impl ( node->arg , *this );
1993
1994 MUTATE_END( Expression, node );
1995}
1996
1997//--------------------------------------------------------------------------
1998// KeywordCastExpr
1999template< typename pass_type >
2000void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
2001 VISIT_START( node );
2002
2003 indexerScopedAccept( node->result, *this );
2004 maybeAccept_impl ( node->arg , *this );
2005
2006 VISIT_END( node );
2007}
2008
2009template< typename pass_type >
2010void PassVisitor< pass_type >::visit( const KeywordCastExpr * node ) {
2011 VISIT_START( node );
2012
2013 indexerScopedAccept( node->result, *this );
2014 maybeAccept_impl ( node->arg , *this );
2015
2016 VISIT_END( node );
2017}
2018
2019template< typename pass_type >
2020Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
2021 MUTATE_START( node );
2022
2023 indexerScopedMutate( node->env , *this );
2024 indexerScopedMutate( node->result, *this );
2025 maybeMutate_impl ( node->arg , *this );
2026
2027 MUTATE_END( Expression, node );
2028}
2029
2030//--------------------------------------------------------------------------
2031// VirtualCastExpr
2032template< typename pass_type >
2033void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
2034 VISIT_START( node );
2035
2036 indexerScopedAccept( node->result, *this );
2037 maybeAccept_impl ( node->arg, *this );
2038
2039 VISIT_END( node );
2040}
2041
2042template< typename pass_type >
2043void PassVisitor< pass_type >::visit( const VirtualCastExpr * node ) {
2044 VISIT_START( node );
2045
2046 indexerScopedAccept( node->result, *this );
2047 maybeAccept_impl ( node->arg, *this );
2048
2049 VISIT_END( node );
2050}
2051
2052template< typename pass_type >
2053Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
2054 MUTATE_START( node );
2055
2056 indexerScopedMutate( node->env , *this );
2057 indexerScopedMutate( node->result, *this );
2058 maybeMutate_impl ( node->arg , *this );
2059
2060 MUTATE_END( Expression, node );
2061}
2062
2063//--------------------------------------------------------------------------
2064// AddressExpr
2065template< typename pass_type >
2066void PassVisitor< pass_type >::visit( AddressExpr * node ) {
2067 VISIT_START( node );
2068
2069 indexerScopedAccept( node->result, *this );
2070 maybeAccept_impl ( node->arg , *this );
2071
2072 VISIT_END( node );
2073}
2074
2075template< typename pass_type >
2076void PassVisitor< pass_type >::visit( const AddressExpr * node ) {
2077 VISIT_START( node );
2078
2079 indexerScopedAccept( node->result, *this );
2080 maybeAccept_impl ( node->arg , *this );
2081
2082 VISIT_END( node );
2083}
2084
2085template< typename pass_type >
2086Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
2087 MUTATE_START( node );
2088
2089 indexerScopedMutate( node->env , *this );
2090 indexerScopedMutate( node->result, *this );
2091 maybeMutate_impl ( node->arg , *this );
2092
2093 MUTATE_END( Expression, node );
2094}
2095
2096//--------------------------------------------------------------------------
2097// LabelAddressExpr
2098template< typename pass_type >
2099void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
2100 VISIT_START( node );
2101
2102 indexerScopedAccept( node->result, *this );
2103
2104 VISIT_END( node );
2105}
2106
2107template< typename pass_type >
2108void PassVisitor< pass_type >::visit( const LabelAddressExpr * node ) {
2109 VISIT_START( node );
2110
2111 indexerScopedAccept( node->result, *this );
2112
2113 VISIT_END( node );
2114}
2115
2116template< typename pass_type >
2117Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
2118 MUTATE_START( node );
2119
2120 indexerScopedMutate( node->env , *this );
2121 indexerScopedMutate( node->result, *this );
2122
2123 MUTATE_END( Expression, node );
2124}
2125
2126//--------------------------------------------------------------------------
2127// UntypedMemberExpr
2128template< typename pass_type >
2129void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
2130 VISIT_START( node );
2131
2132 indexerScopedAccept( node->result , *this );
2133 maybeAccept_impl ( node->aggregate, *this );
2134 maybeAccept_impl ( node->member , *this );
2135
2136 VISIT_END( node );
2137}
2138
2139template< typename pass_type >
2140void PassVisitor< pass_type >::visit( const UntypedMemberExpr * node ) {
2141 VISIT_START( node );
2142
2143 indexerScopedAccept( node->result , *this );
2144 maybeAccept_impl ( node->aggregate, *this );
2145 maybeAccept_impl ( node->member , *this );
2146
2147 VISIT_END( node );
2148}
2149
2150template< typename pass_type >
2151Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
2152 MUTATE_START( node );
2153
2154 indexerScopedMutate( node->env , *this );
2155 indexerScopedMutate( node->result , *this );
2156 maybeMutate_impl ( node->aggregate, *this );
2157 maybeMutate_impl ( node->member , *this );
2158
2159 MUTATE_END( Expression, node );
2160}
2161
2162//--------------------------------------------------------------------------
2163// MemberExpr
2164template< typename pass_type >
2165void PassVisitor< pass_type >::visit( MemberExpr * node ) {
2166 VISIT_START( node );
2167
2168 indexerScopedAccept( node->result , *this );
2169 maybeAccept_impl ( node->aggregate, *this );
2170
2171 VISIT_END( node );
2172}
2173
2174template< typename pass_type >
2175void PassVisitor< pass_type >::visit( const MemberExpr * node ) {
2176 VISIT_START( node );
2177
2178 indexerScopedAccept( node->result , *this );
2179 maybeAccept_impl ( node->aggregate, *this );
2180
2181 VISIT_END( node );
2182}
2183
2184template< typename pass_type >
2185Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
2186 MUTATE_START( node );
2187
2188 indexerScopedMutate( node->env , *this );
2189 indexerScopedMutate( node->result , *this );
2190 maybeMutate_impl ( node->aggregate, *this );
2191
2192 MUTATE_END( Expression, node );
2193}
2194
2195//--------------------------------------------------------------------------
2196// VariableExpr
2197template< typename pass_type >
2198void PassVisitor< pass_type >::visit( VariableExpr * node ) {
2199 VISIT_START( node );
2200
2201 indexerScopedAccept( node->result, *this );
2202
2203 VISIT_END( node );
2204}
2205
2206template< typename pass_type >
2207void PassVisitor< pass_type >::visit( const VariableExpr * node ) {
2208 VISIT_START( node );
2209
2210 indexerScopedAccept( node->result, *this );
2211
2212 VISIT_END( node );
2213}
2214
2215template< typename pass_type >
2216Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
2217 MUTATE_START( node );
2218
2219 indexerScopedMutate( node->env , *this );
2220 indexerScopedMutate( node->result, *this );
2221
2222 MUTATE_END( Expression, node );
2223}
2224
2225//--------------------------------------------------------------------------
2226// ConstantExpr
2227template< typename pass_type >
2228void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
2229 VISIT_START( node );
2230
2231 indexerScopedAccept( node->result , *this );
2232 maybeAccept_impl ( &node->constant, *this );
2233
2234 VISIT_END( node );
2235}
2236
2237template< typename pass_type >
2238void PassVisitor< pass_type >::visit( const ConstantExpr * node ) {
2239 VISIT_START( node );
2240
2241 indexerScopedAccept( node->result , *this );
2242 maybeAccept_impl ( &node->constant, *this );
2243
2244 VISIT_END( node );
2245}
2246
2247template< typename pass_type >
2248Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
2249 MUTATE_START( node );
2250
2251 indexerScopedMutate( node->env , *this );
2252 indexerScopedMutate( node->result, *this );
2253 Constant * ptr = &node->constant;
2254 maybeMutate_impl( ptr, *this );
2255 node->constant = *ptr;
2256
2257 MUTATE_END( Expression, node );
2258}
2259
2260//--------------------------------------------------------------------------
2261// SizeofExpr
2262template< typename pass_type >
2263void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
2264 VISIT_START( node );
2265
2266 indexerScopedAccept( node->result, *this );
2267 if ( node->get_isType() ) {
2268 maybeAccept_impl( node->type, *this );
2269 } else {
2270 maybeAccept_impl( node->expr, *this );
2271 }
2272
2273 VISIT_END( node );
2274}
2275
2276template< typename pass_type >
2277void PassVisitor< pass_type >::visit( const SizeofExpr * node ) {
2278 VISIT_START( node );
2279
2280 indexerScopedAccept( node->result, *this );
2281 if ( node->get_isType() ) {
2282 maybeAccept_impl( node->type, *this );
2283 } else {
2284 maybeAccept_impl( node->expr, *this );
2285 }
2286
2287 VISIT_END( node );
2288}
2289
2290template< typename pass_type >
2291Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
2292 MUTATE_START( node );
2293
2294 indexerScopedMutate( node->env , *this );
2295 indexerScopedMutate( node->result, *this );
2296 if ( node->get_isType() ) {
2297 maybeMutate_impl( node->type, *this );
2298 } else {
2299 maybeMutate_impl( node->expr, *this );
2300 }
2301
2302 MUTATE_END( Expression, node );
2303}
2304
2305//--------------------------------------------------------------------------
2306// AlignofExpr
2307template< typename pass_type >
2308void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
2309 VISIT_START( node );
2310
2311 indexerScopedAccept( node->result, *this );
2312 if ( node->get_isType() ) {
2313 maybeAccept_impl( node->type, *this );
2314 } else {
2315 maybeAccept_impl( node->expr, *this );
2316 }
2317
2318 VISIT_END( node );
2319}
2320
2321template< typename pass_type >
2322void PassVisitor< pass_type >::visit( const AlignofExpr * node ) {
2323 VISIT_START( node );
2324
2325 indexerScopedAccept( node->result, *this );
2326 if ( node->get_isType() ) {
2327 maybeAccept_impl( node->type, *this );
2328 } else {
2329 maybeAccept_impl( node->expr, *this );
2330 }
2331
2332 VISIT_END( node );
2333}
2334
2335template< typename pass_type >
2336Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
2337 MUTATE_START( node );
2338
2339 indexerScopedMutate( node->env , *this );
2340 indexerScopedMutate( node->result, *this );
2341 if ( node->get_isType() ) {
2342 maybeMutate_impl( node->type, *this );
2343 } else {
2344 maybeMutate_impl( node->expr, *this );
2345 }
2346
2347 MUTATE_END( Expression, node );
2348}
2349
2350//--------------------------------------------------------------------------
2351// UntypedOffsetofExpr
2352template< typename pass_type >
2353void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
2354 VISIT_START( node );
2355
2356 indexerScopedAccept( node->result, *this );
2357 maybeAccept_impl ( node->type , *this );
2358
2359 VISIT_END( node );
2360}
2361
2362template< typename pass_type >
2363void PassVisitor< pass_type >::visit( const UntypedOffsetofExpr * node ) {
2364 VISIT_START( node );
2365
2366 indexerScopedAccept( node->result, *this );
2367 maybeAccept_impl ( node->type , *this );
2368
2369 VISIT_END( node );
2370}
2371
2372template< typename pass_type >
2373Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
2374 MUTATE_START( node );
2375
2376 indexerScopedMutate( node->env , *this );
2377 indexerScopedMutate( node->result, *this );
2378 maybeMutate_impl ( node->type , *this );
2379
2380 MUTATE_END( Expression, node );
2381}
2382
2383//--------------------------------------------------------------------------
2384// OffsetofExpr
2385template< typename pass_type >
2386void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
2387 VISIT_START( node );
2388
2389 indexerScopedAccept( node->result, *this );
2390 maybeAccept_impl ( node->type , *this );
2391
2392 VISIT_END( node );
2393}
2394
2395template< typename pass_type >
2396void PassVisitor< pass_type >::visit( const OffsetofExpr * node ) {
2397 VISIT_START( node );
2398
2399 indexerScopedAccept( node->result, *this );
2400 maybeAccept_impl ( node->type , *this );
2401
2402 VISIT_END( node );
2403}
2404
2405template< typename pass_type >
2406Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
2407 MUTATE_START( node );
2408
2409 indexerScopedMutate( node->env , *this );
2410 indexerScopedMutate( node->result, *this );
2411 maybeMutate_impl ( node->type , *this );
2412
2413 MUTATE_END( Expression, node );
2414}
2415
2416//--------------------------------------------------------------------------
2417// OffsetPackExpr
2418template< typename pass_type >
2419void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
2420 VISIT_START( node );
2421
2422 indexerScopedAccept( node->result, *this );
2423 maybeAccept_impl ( node->type , *this );
2424
2425 VISIT_END( node );
2426}
2427
2428template< typename pass_type >
2429void PassVisitor< pass_type >::visit( const OffsetPackExpr * node ) {
2430 VISIT_START( node );
2431
2432 indexerScopedAccept( node->result, *this );
2433 maybeAccept_impl ( node->type , *this );
2434
2435 VISIT_END( node );
2436}
2437
2438template< typename pass_type >
2439Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
2440 MUTATE_START( node );
2441
2442 indexerScopedMutate( node->env , *this );
2443 indexerScopedMutate( node->result, *this );
2444 maybeMutate_impl ( node->type , *this );
2445
2446 MUTATE_END( Expression, node );
2447}
2448
2449//--------------------------------------------------------------------------
2450// LogicalExpr
2451template< typename pass_type >
2452void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
2453 VISIT_START( node );
2454
2455 indexerScopedAccept( node->result, *this );
2456 maybeAccept_impl ( node->arg1 , *this );
2457 maybeAccept_impl ( node->arg2 , *this );
2458
2459 VISIT_END( node );
2460}
2461
2462template< typename pass_type >
2463void PassVisitor< pass_type >::visit( const LogicalExpr * node ) {
2464 VISIT_START( node );
2465
2466 indexerScopedAccept( node->result, *this );
2467 maybeAccept_impl ( node->arg1 , *this );
2468 maybeAccept_impl ( node->arg2 , *this );
2469
2470 VISIT_END( node );
2471}
2472
2473template< typename pass_type >
2474Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
2475 MUTATE_START( node );
2476
2477 indexerScopedMutate( node->env , *this );
2478 indexerScopedMutate( node->result, *this );
2479 maybeMutate_impl ( node->arg1 , *this );
2480 maybeMutate_impl ( node->arg2 , *this );
2481
2482 MUTATE_END( Expression, node );
2483}
2484
2485//--------------------------------------------------------------------------
2486// ConditionalExpr
2487template< typename pass_type >
2488void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
2489 VISIT_START( node );
2490
2491 indexerScopedAccept( node->result, *this );
2492 maybeAccept_impl ( node->arg1 , *this );
2493 maybeAccept_impl ( node->arg2 , *this );
2494 maybeAccept_impl ( node->arg3 , *this );
2495
2496 VISIT_END( node );
2497}
2498
2499template< typename pass_type >
2500void PassVisitor< pass_type >::visit( const ConditionalExpr * node ) {
2501 VISIT_START( node );
2502
2503 indexerScopedAccept( node->result, *this );
2504 maybeAccept_impl ( node->arg1 , *this );
2505 maybeAccept_impl ( node->arg2 , *this );
2506 maybeAccept_impl ( node->arg3 , *this );
2507
2508 VISIT_END( node );
2509}
2510
2511template< typename pass_type >
2512Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
2513 MUTATE_START( node );
2514
2515 indexerScopedMutate( node->env , *this );
2516 indexerScopedMutate( node->result, *this );
2517 maybeMutate_impl ( node->arg1 , *this );
2518 maybeMutate_impl ( node->arg2 , *this );
2519 maybeMutate_impl ( node->arg3 , *this );
2520
2521 MUTATE_END( Expression, node );
2522}
2523
2524//--------------------------------------------------------------------------
2525// CommaExpr
2526template< typename pass_type >
2527void PassVisitor< pass_type >::visit( CommaExpr * node ) {
2528 VISIT_START( node );
2529
2530 indexerScopedAccept( node->result, *this );
2531 maybeAccept_impl ( node->arg1 , *this );
2532 maybeAccept_impl ( node->arg2 , *this );
2533
2534 VISIT_END( node );
2535}
2536
2537template< typename pass_type >
2538void PassVisitor< pass_type >::visit( const CommaExpr * node ) {
2539 VISIT_START( node );
2540
2541 indexerScopedAccept( node->result, *this );
2542 maybeAccept_impl ( node->arg1 , *this );
2543 maybeAccept_impl ( node->arg2 , *this );
2544
2545 VISIT_END( node );
2546}
2547
2548template< typename pass_type >
2549Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
2550 MUTATE_START( node );
2551
2552 indexerScopedMutate( node->env , *this );
2553 indexerScopedMutate( node->result, *this );
2554 maybeMutate_impl ( node->arg1 , *this );
2555 maybeMutate_impl ( node->arg2 , *this );
2556
2557 MUTATE_END( Expression, node );
2558}
2559
2560//--------------------------------------------------------------------------
2561// TypeExpr
2562template< typename pass_type >
2563void PassVisitor< pass_type >::visit( TypeExpr * node ) {
2564 VISIT_START( node );
2565
2566 indexerScopedAccept( node->result, *this );
2567 maybeAccept_impl ( node->type, *this );
2568
2569 VISIT_END( node );
2570}
2571
2572template< typename pass_type >
2573void PassVisitor< pass_type >::visit( const TypeExpr * node ) {
2574 VISIT_START( node );
2575
2576 indexerScopedAccept( node->result, *this );
2577 maybeAccept_impl ( node->type, *this );
2578
2579 VISIT_END( node );
2580}
2581
2582template< typename pass_type >
2583Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
2584 MUTATE_START( node );
2585
2586 indexerScopedMutate( node->env , *this );
2587 indexerScopedMutate( node->result, *this );
2588 maybeMutate_impl ( node->type , *this );
2589
2590 MUTATE_END( Expression, node );
2591}
2592
2593//--------------------------------------------------------------------------
2594// DimensionExpr
2595template< typename pass_type >
2596void PassVisitor< pass_type >::visit( DimensionExpr * node ) {
2597 VISIT_START( node );
2598
2599 indexerScopedAccept( node->result, *this );
2600
2601 VISIT_END( node );
2602}
2603
2604template< typename pass_type >
2605void PassVisitor< pass_type >::visit( const DimensionExpr * node ) {
2606 VISIT_START( node );
2607
2608 indexerScopedAccept( node->result, *this );
2609
2610 VISIT_END( node );
2611}
2612
2613template< typename pass_type >
2614Expression * PassVisitor< pass_type >::mutate( DimensionExpr * node ) {
2615 MUTATE_START( node );
2616
2617 indexerScopedMutate( node->env , *this );
2618 indexerScopedMutate( node->result, *this );
2619
2620 MUTATE_END( Expression, node );
2621}
2622
2623//--------------------------------------------------------------------------
2624// AsmExpr
2625template< typename pass_type >
2626void PassVisitor< pass_type >::visit( AsmExpr * node ) {
2627 VISIT_START( node );
2628
2629 indexerScopedAccept( node->result , *this );
2630 maybeAccept_impl ( node->constraint, *this );
2631 maybeAccept_impl ( node->operand , *this );
2632
2633 VISIT_END( node );
2634}
2635
2636template< typename pass_type >
2637void PassVisitor< pass_type >::visit( const AsmExpr * node ) {
2638 VISIT_START( node );
2639
2640 indexerScopedAccept( node->result , *this );
2641 maybeAccept_impl ( node->constraint, *this );
2642 maybeAccept_impl ( node->operand , *this );
2643
2644 VISIT_END( node );
2645}
2646
2647template< typename pass_type >
2648Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
2649 MUTATE_START( node );
2650
2651 indexerScopedMutate( node->env , *this );
2652 indexerScopedMutate( node->result , *this );
2653 maybeMutate_impl ( node->constraint, *this );
2654 maybeMutate_impl ( node->operand , *this );
2655
2656 MUTATE_END( Expression, node );
2657}
2658
2659//--------------------------------------------------------------------------
2660// ImplicitCopyCtorExpr
2661template< typename pass_type >
2662void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
2663 VISIT_START( node );
2664
2665 indexerScopedAccept( node->result , *this );
2666 maybeAccept_impl ( node->callExpr , *this );
2667
2668 VISIT_END( node );
2669}
2670
2671template< typename pass_type >
2672void PassVisitor< pass_type >::visit( const ImplicitCopyCtorExpr * node ) {
2673 VISIT_START( node );
2674
2675 indexerScopedAccept( node->result , *this );
2676 maybeAccept_impl ( node->callExpr , *this );
2677
2678 VISIT_END( node );
2679}
2680
2681template< typename pass_type >
2682Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
2683 MUTATE_START( node );
2684
2685 indexerScopedMutate( node->env , *this );
2686 indexerScopedMutate( node->result , *this );
2687 maybeMutate_impl ( node->callExpr , *this );
2688
2689 MUTATE_END( Expression, node );
2690}
2691
2692//--------------------------------------------------------------------------
2693// ConstructorExpr
2694template< typename pass_type >
2695void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
2696 VISIT_START( node );
2697
2698 indexerScopedAccept( node->result , *this );
2699 maybeAccept_impl ( node->callExpr, *this );
2700
2701 VISIT_END( node );
2702}
2703
2704template< typename pass_type >
2705void PassVisitor< pass_type >::visit( const ConstructorExpr * node ) {
2706 VISIT_START( node );
2707
2708 indexerScopedAccept( node->result , *this );
2709 maybeAccept_impl ( node->callExpr, *this );
2710
2711 VISIT_END( node );
2712}
2713
2714template< typename pass_type >
2715Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
2716 MUTATE_START( node );
2717
2718 indexerScopedMutate( node->env , *this );
2719 indexerScopedMutate( node->result , *this );
2720 maybeMutate_impl ( node->callExpr, *this );
2721
2722 MUTATE_END( Expression, node );
2723}
2724
2725//--------------------------------------------------------------------------
2726// CompoundLiteralExpr
2727template< typename pass_type >
2728void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
2729 VISIT_START( node );
2730
2731 indexerScopedAccept( node->result , *this );
2732 maybeAccept_impl ( node->initializer, *this );
2733
2734 VISIT_END( node );
2735}
2736
2737template< typename pass_type >
2738void PassVisitor< pass_type >::visit( const CompoundLiteralExpr * node ) {
2739 VISIT_START( node );
2740
2741 indexerScopedAccept( node->result , *this );
2742 maybeAccept_impl ( node->initializer, *this );
2743
2744 VISIT_END( node );
2745}
2746
2747template< typename pass_type >
2748Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
2749 MUTATE_START( node );
2750
2751 indexerScopedMutate( node->env , *this );
2752 indexerScopedMutate( node->result , *this );
2753 maybeMutate_impl ( node->initializer, *this );
2754
2755 MUTATE_END( Expression, node );
2756}
2757
2758//--------------------------------------------------------------------------
2759// RangeExpr
2760template< typename pass_type >
2761void PassVisitor< pass_type >::visit( RangeExpr * node ) {
2762 VISIT_START( node );
2763
2764 indexerScopedAccept( node->result, *this );
2765 maybeAccept_impl ( node->low , *this );
2766 maybeAccept_impl ( node->high , *this );
2767
2768 VISIT_END( node );
2769}
2770
2771template< typename pass_type >
2772void PassVisitor< pass_type >::visit( const RangeExpr * node ) {
2773 VISIT_START( node );
2774
2775 indexerScopedAccept( node->result, *this );
2776 maybeAccept_impl ( node->low , *this );
2777 maybeAccept_impl ( node->high , *this );
2778
2779 VISIT_END( node );
2780}
2781
2782template< typename pass_type >
2783Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
2784 MUTATE_START( node );
2785
2786 indexerScopedMutate( node->env , *this );
2787 indexerScopedMutate( node->result, *this );
2788 maybeMutate_impl ( node->low , *this );
2789 maybeMutate_impl ( node->high , *this );
2790
2791 MUTATE_END( Expression, node );
2792}
2793
2794//--------------------------------------------------------------------------
2795// UntypedTupleExpr
2796template< typename pass_type >
2797void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
2798 VISIT_START( node );
2799
2800 indexerScopedAccept( node->result, *this );
2801 maybeAccept_impl ( node->exprs , *this );
2802
2803 VISIT_END( node );
2804}
2805
2806template< typename pass_type >
2807void PassVisitor< pass_type >::visit( const UntypedTupleExpr * node ) {
2808 VISIT_START( node );
2809
2810 indexerScopedAccept( node->result, *this );
2811 maybeAccept_impl ( node->exprs , *this );
2812
2813 VISIT_END( node );
2814}
2815
2816template< typename pass_type >
2817Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
2818 MUTATE_START( node );
2819
2820 indexerScopedMutate( node->env , *this );
2821 indexerScopedMutate( node->result, *this );
2822 maybeMutate_impl ( node->exprs , *this );
2823
2824 MUTATE_END( Expression, node );
2825}
2826
2827//--------------------------------------------------------------------------
2828// TupleExpr
2829template< typename pass_type >
2830void PassVisitor< pass_type >::visit( TupleExpr * node ) {
2831 VISIT_START( node );
2832
2833 indexerScopedAccept( node->result, *this );
2834 maybeAccept_impl ( node->exprs , *this );
2835
2836 VISIT_END( node );
2837}
2838
2839template< typename pass_type >
2840void PassVisitor< pass_type >::visit( const TupleExpr * node ) {
2841 VISIT_START( node );
2842
2843 indexerScopedAccept( node->result, *this );
2844 maybeAccept_impl ( node->exprs , *this );
2845
2846 VISIT_END( node );
2847}
2848
2849template< typename pass_type >
2850Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
2851 MUTATE_START( node );
2852
2853 indexerScopedMutate( node->env , *this );
2854 indexerScopedMutate( node->result, *this );
2855 maybeMutate_impl ( node->exprs , *this );
2856
2857 MUTATE_END( Expression, node );
2858}
2859
2860//--------------------------------------------------------------------------
2861// TupleIndexExpr
2862template< typename pass_type >
2863void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
2864 VISIT_START( node );
2865
2866 indexerScopedAccept( node->result, *this );
2867 maybeAccept_impl ( node->tuple , *this );
2868
2869 VISIT_END( node );
2870}
2871
2872template< typename pass_type >
2873void PassVisitor< pass_type >::visit( const TupleIndexExpr * node ) {
2874 VISIT_START( node );
2875
2876 indexerScopedAccept( node->result, *this );
2877 maybeAccept_impl ( node->tuple , *this );
2878
2879 VISIT_END( node );
2880}
2881
2882template< typename pass_type >
2883Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
2884 MUTATE_START( node );
2885
2886 indexerScopedMutate( node->env , *this );
2887 indexerScopedMutate( node->result, *this );
2888 maybeMutate_impl ( node->tuple , *this );
2889
2890 MUTATE_END( Expression, node );
2891}
2892
2893//--------------------------------------------------------------------------
2894// TupleAssignExpr
2895template< typename pass_type >
2896void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
2897 VISIT_START( node );
2898
2899 indexerScopedAccept( node->result , *this );
2900 maybeAccept_impl ( node->stmtExpr, *this );
2901
2902 VISIT_END( node );
2903}
2904
2905template< typename pass_type >
2906void PassVisitor< pass_type >::visit( const TupleAssignExpr * node ) {
2907 VISIT_START( node );
2908
2909 indexerScopedAccept( node->result , *this );
2910 maybeAccept_impl( node->stmtExpr, *this );
2911
2912 VISIT_END( node );
2913}
2914
2915template< typename pass_type >
2916Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
2917 MUTATE_START( node );
2918
2919 indexerScopedMutate( node->env , *this );
2920 indexerScopedMutate( node->result , *this );
2921 maybeMutate_impl ( node->stmtExpr, *this );
2922
2923 MUTATE_END( Expression, node );
2924}
2925
2926//--------------------------------------------------------------------------
2927// StmtExpr
2928template< typename pass_type >
2929void PassVisitor< pass_type >::visit( StmtExpr * node ) {
2930 VISIT_START( node );
2931
2932 // don't want statements from outer CompoundStmts to be added to this StmtExpr
2933 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
2934 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2935 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
2936
2937 indexerScopedAccept( node->result , *this );
2938 maybeAccept_impl ( node->statements , *this );
2939 maybeAccept_impl ( node->returnDecls, *this );
2940 maybeAccept_impl ( node->dtors , *this );
2941
2942 VISIT_END( node );
2943}
2944
2945template< typename pass_type >
2946void PassVisitor< pass_type >::visit( const StmtExpr * node ) {
2947 VISIT_START( node );
2948
2949 // don't want statements from outer CompoundStmts to be added to this StmtExpr
2950 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
2951 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2952 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
2953
2954 indexerScopedAccept( node->result , *this );
2955 maybeAccept_impl ( node->statements , *this );
2956 maybeAccept_impl ( node->returnDecls, *this );
2957 maybeAccept_impl ( node->dtors , *this );
2958
2959 VISIT_END( node );
2960}
2961
2962template< typename pass_type >
2963Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
2964 MUTATE_START( node );
2965
2966 // don't want statements from outer CompoundStmts to be added to this StmtExpr
2967 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
2968 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2969 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
2970
2971 indexerScopedMutate( node->result , *this );
2972 maybeMutate_impl ( node->statements , *this );
2973 maybeMutate_impl ( node->returnDecls, *this );
2974 maybeMutate_impl ( node->dtors , *this );
2975
2976 MUTATE_END( Expression, node );
2977}
2978
2979//--------------------------------------------------------------------------
2980// UniqueExpr
2981template< typename pass_type >
2982void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
2983 VISIT_START( node );
2984
2985 indexerScopedAccept( node->result, *this );
2986 maybeAccept_impl ( node->expr , *this );
2987
2988 VISIT_END( node );
2989}
2990
2991template< typename pass_type >
2992void PassVisitor< pass_type >::visit( const UniqueExpr * node ) {
2993 VISIT_START( node );
2994
2995 indexerScopedAccept( node->result, *this );
2996 maybeAccept_impl ( node->expr , *this );
2997
2998 VISIT_END( node );
2999}
3000
3001template< typename pass_type >
3002Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
3003 MUTATE_START( node );
3004
3005 indexerScopedMutate( node->env , *this );
3006 indexerScopedMutate( node->result, *this );
3007 maybeMutate_impl ( node->expr , *this );
3008
3009 MUTATE_END( Expression, node );
3010}
3011
3012//--------------------------------------------------------------------------
3013// UntypedInitExpr
3014template< typename pass_type >
3015void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
3016 VISIT_START( node );
3017
3018 indexerScopedAccept( node->result, *this );
3019 maybeAccept_impl ( node->expr , *this );
3020 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
3021
3022 VISIT_END( node );
3023}
3024
3025template< typename pass_type >
3026void PassVisitor< pass_type >::visit( const UntypedInitExpr * node ) {
3027 VISIT_START( node );
3028
3029 indexerScopedAccept( node->result, *this );
3030 maybeAccept_impl ( node->expr , *this );
3031 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
3032
3033 VISIT_END( node );
3034}
3035
3036template< typename pass_type >
3037Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
3038 MUTATE_START( node );
3039
3040 indexerScopedMutate( node->env , *this );
3041 indexerScopedMutate( node->result, *this );
3042 maybeMutate_impl ( node->expr , *this );
3043 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
3044
3045 MUTATE_END( Expression, node );
3046}
3047
3048//--------------------------------------------------------------------------
3049// InitExpr
3050template< typename pass_type >
3051void PassVisitor< pass_type >::visit( InitExpr * node ) {
3052 VISIT_START( node );
3053
3054 indexerScopedAccept( node->result, *this );
3055 maybeAccept_impl ( node->expr , *this );
3056 maybeAccept_impl ( node->designation, *this );
3057
3058 VISIT_END( node );
3059}
3060
3061template< typename pass_type >
3062void PassVisitor< pass_type >::visit( const InitExpr * node ) {
3063 VISIT_START( node );
3064
3065 indexerScopedAccept( node->result, *this );
3066 maybeAccept_impl ( node->expr , *this );
3067 maybeAccept_impl ( node->designation, *this );
3068
3069 VISIT_END( node );
3070}
3071
3072template< typename pass_type >
3073Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
3074 MUTATE_START( node );
3075
3076 indexerScopedMutate( node->env , *this );
3077 indexerScopedMutate( node->result, *this );
3078 maybeMutate_impl ( node->expr , *this );
3079 maybeMutate_impl ( node->designation, *this );
3080
3081 MUTATE_END( Expression, node );
3082}
3083
3084//--------------------------------------------------------------------------
3085// DeletedExpr
3086template< typename pass_type >
3087void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
3088 VISIT_START( node );
3089
3090 indexerScopedAccept( node->result, *this );
3091 maybeAccept_impl ( node->expr, *this );
3092 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
3093
3094 VISIT_END( node );
3095}
3096
3097template< typename pass_type >
3098void PassVisitor< pass_type >::visit( const DeletedExpr * node ) {
3099 VISIT_START( node );
3100
3101 indexerScopedAccept( node->result, *this );
3102 maybeAccept_impl ( node->expr, *this );
3103 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
3104
3105 VISIT_END( node );
3106}
3107
3108template< typename pass_type >
3109Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
3110 MUTATE_START( node );
3111
3112 indexerScopedMutate( node->env, *this );
3113 indexerScopedMutate( node->result, *this );
3114 maybeMutate_impl( node->expr, *this );
3115
3116 MUTATE_END( Expression, node );
3117}
3118
3119//--------------------------------------------------------------------------
3120// DefaultArgExpr
3121template< typename pass_type >
3122void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) {
3123 VISIT_START( node );
3124
3125 indexerScopedAccept( node->result, *this );
3126 maybeAccept_impl ( node->expr, *this );
3127
3128 VISIT_END( node );
3129}
3130
3131template< typename pass_type >
3132void PassVisitor< pass_type >::visit( const DefaultArgExpr * node ) {
3133 VISIT_START( node );
3134
3135 indexerScopedAccept( node->result, *this );
3136 maybeAccept_impl ( node->expr, *this );
3137
3138 VISIT_END( node );
3139}
3140
3141template< typename pass_type >
3142Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) {
3143 MUTATE_START( node );
3144
3145 indexerScopedMutate( node->env, *this );
3146 indexerScopedMutate( node->result, *this );
3147 maybeMutate_impl( node->expr, *this );
3148
3149 MUTATE_END( Expression, node );
3150}
3151
3152//--------------------------------------------------------------------------
3153// GenericExpr
3154template< typename pass_type >
3155void PassVisitor< pass_type >::visit( GenericExpr * node ) {
3156 VISIT_START( node );
3157
3158 indexerScopedAccept( node->result, *this );
3159 maybeAccept_impl( node->control, *this );
3160 for ( GenericExpr::Association & assoc : node->associations ) {
3161 indexerScopedAccept( assoc.type, *this );
3162 maybeAccept_impl( assoc.expr, *this );
3163 }
3164
3165 VISIT_END( node );
3166}
3167
3168template< typename pass_type >
3169void PassVisitor< pass_type >::visit( const GenericExpr * node ) {
3170 VISIT_START( node );
3171
3172 indexerScopedAccept( node->result, *this );
3173 maybeAccept_impl( node->control, *this );
3174 for ( const GenericExpr::Association & assoc : node->associations ) {
3175 indexerScopedAccept( assoc.type, *this );
3176 maybeAccept_impl( assoc.expr, *this );
3177 }
3178
3179 VISIT_END( node );
3180}
3181
3182template< typename pass_type >
3183Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) {
3184 MUTATE_START( node );
3185
3186 indexerScopedMutate( node->env, *this );
3187 indexerScopedMutate( node->result, *this );
3188 maybeMutate_impl( node->control, *this );
3189 for ( GenericExpr::Association & assoc : node->associations ) {
3190 indexerScopedMutate( assoc.type, *this );
3191 maybeMutate_impl( assoc.expr, *this );
3192 }
3193
3194 MUTATE_END( Expression, node );
3195}
3196
3197//--------------------------------------------------------------------------
3198// VoidType
3199template< typename pass_type >
3200void PassVisitor< pass_type >::visit( VoidType * node ) {
3201 VISIT_START( node );
3202
3203 maybeAccept_impl( node->forall, *this );
3204
3205 VISIT_END( node );
3206}
3207
3208template< typename pass_type >
3209void PassVisitor< pass_type >::visit( const VoidType * node ) {
3210 VISIT_START( node );
3211
3212 maybeAccept_impl( node->forall, *this );
3213
3214 VISIT_END( node );
3215}
3216
3217template< typename pass_type >
3218Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
3219 MUTATE_START( node );
3220
3221 maybeMutate_impl( node->forall, *this );
3222
3223 MUTATE_END( Type, node );
3224}
3225
3226//--------------------------------------------------------------------------
3227// BasicType
3228template< typename pass_type >
3229void PassVisitor< pass_type >::visit( BasicType * node ) {
3230 VISIT_START( node );
3231
3232 maybeAccept_impl( node->forall, *this );
3233
3234 VISIT_END( node );
3235}
3236
3237template< typename pass_type >
3238void PassVisitor< pass_type >::visit( const BasicType * node ) {
3239 VISIT_START( node );
3240
3241 maybeAccept_impl( node->forall, *this );
3242
3243 VISIT_END( node );
3244}
3245
3246template< typename pass_type >
3247Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
3248 MUTATE_START( node );
3249
3250 maybeMutate_impl( node->forall, *this );
3251
3252 MUTATE_END( Type, node );
3253}
3254
3255//--------------------------------------------------------------------------
3256// PointerType
3257template< typename pass_type >
3258void PassVisitor< pass_type >::visit( PointerType * node ) {
3259 VISIT_START( node );
3260
3261 maybeAccept_impl( node->forall, *this );
3262 maybeAccept_impl( node->dimension, *this );
3263 maybeAccept_impl( node->base, *this );
3264
3265 VISIT_END( node );
3266}
3267
3268template< typename pass_type >
3269void PassVisitor< pass_type >::visit( const PointerType * node ) {
3270 VISIT_START( node );
3271
3272 maybeAccept_impl( node->forall, *this );
3273 maybeAccept_impl( node->dimension, *this );
3274 maybeAccept_impl( node->base, *this );
3275
3276 VISIT_END( node );
3277}
3278
3279template< typename pass_type >
3280Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
3281 MUTATE_START( node );
3282
3283 maybeMutate_impl( node->forall, *this );
3284 maybeMutate_impl( node->dimension, *this );
3285 maybeMutate_impl( node->base, *this );
3286
3287 MUTATE_END( Type, node );
3288}
3289
3290//--------------------------------------------------------------------------
3291// ArrayType
3292template< typename pass_type >
3293void PassVisitor< pass_type >::visit( ArrayType * node ) {
3294 VISIT_START( node );
3295
3296 maybeAccept_impl( node->forall, *this );
3297 maybeAccept_impl( node->dimension, *this );
3298 maybeAccept_impl( node->base, *this );
3299
3300 VISIT_END( node );
3301}
3302
3303template< typename pass_type >
3304void PassVisitor< pass_type >::visit( const ArrayType * node ) {
3305 VISIT_START( node );
3306
3307 maybeAccept_impl( node->forall, *this );
3308 maybeAccept_impl( node->dimension, *this );
3309 maybeAccept_impl( node->base, *this );
3310
3311 VISIT_END( node );
3312}
3313
3314template< typename pass_type >
3315Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
3316 MUTATE_START( node );
3317
3318 maybeMutate_impl( node->forall, *this );
3319 maybeMutate_impl( node->dimension, *this );
3320 maybeMutate_impl( node->base, *this );
3321
3322 MUTATE_END( Type, node );
3323}
3324
3325//--------------------------------------------------------------------------
3326// ReferenceType
3327template< typename pass_type >
3328void PassVisitor< pass_type >::visit( ReferenceType * node ) {
3329 VISIT_START( node );
3330
3331 maybeAccept_impl( node->forall, *this );
3332 maybeAccept_impl( node->base, *this );
3333
3334 VISIT_END( node );
3335}
3336
3337template< typename pass_type >
3338void PassVisitor< pass_type >::visit( const ReferenceType * node ) {
3339 VISIT_START( node );
3340
3341 maybeAccept_impl( node->forall, *this );
3342 maybeAccept_impl( node->base, *this );
3343
3344 VISIT_END( node );
3345}
3346
3347template< typename pass_type >
3348Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
3349 MUTATE_START( node );
3350
3351 maybeMutate_impl( node->forall, *this );
3352 maybeMutate_impl( node->base, *this );
3353
3354 MUTATE_END( Type, node );
3355}
3356
3357//--------------------------------------------------------------------------
3358// QualifiedType
3359template< typename pass_type >
3360void PassVisitor< pass_type >::visit( QualifiedType * node ) {
3361 VISIT_START( node );
3362
3363 maybeAccept_impl( node->forall, *this );
3364 maybeAccept_impl( node->parent, *this );
3365 maybeAccept_impl( node->child, *this );
3366
3367 VISIT_END( node );
3368}
3369
3370template< typename pass_type >
3371void PassVisitor< pass_type >::visit( const QualifiedType * node ) {
3372 VISIT_START( node );
3373
3374 maybeAccept_impl( node->forall, *this );
3375 maybeAccept_impl( node->parent, *this );
3376 maybeAccept_impl( node->child, *this );
3377
3378 VISIT_END( node );
3379}
3380
3381template< typename pass_type >
3382Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) {
3383 MUTATE_START( node );
3384
3385 maybeMutate_impl( node->forall, *this );
3386 maybeMutate_impl( node->parent, *this );
3387 maybeMutate_impl( node->child, *this );
3388
3389 MUTATE_END( Type, node );
3390}
3391
3392//--------------------------------------------------------------------------
3393// FunctionType
3394template< typename pass_type >
3395void PassVisitor< pass_type >::visit( FunctionType * node ) {
3396 VISIT_START( node );
3397
3398 maybeAccept_impl( node->forall, *this );
3399 maybeAccept_impl( node->returnVals, *this );
3400 maybeAccept_impl( node->parameters, *this );
3401
3402 VISIT_END( node );
3403}
3404
3405template< typename pass_type >
3406void PassVisitor< pass_type >::visit( const FunctionType * node ) {
3407 VISIT_START( node );
3408
3409 maybeAccept_impl( node->forall, *this );
3410 maybeAccept_impl( node->returnVals, *this );
3411 maybeAccept_impl( node->parameters, *this );
3412
3413 VISIT_END( node );
3414}
3415
3416template< typename pass_type >
3417Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
3418 MUTATE_START( node );
3419
3420 maybeMutate_impl( node->forall, *this );
3421 maybeMutate_impl( node->returnVals, *this );
3422 maybeMutate_impl( node->parameters, *this );
3423
3424 MUTATE_END( Type, node );
3425}
3426
3427//--------------------------------------------------------------------------
3428// StructInstType
3429template< typename pass_type >
3430void PassVisitor< pass_type >::visit( StructInstType * node ) {
3431 VISIT_START( node );
3432
3433 indexerAddStruct( node->name );
3434
3435 {
3436 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3437 maybeAccept_impl( node->forall , *this );
3438 maybeAccept_impl( node->parameters, *this );
3439 }
3440
3441 VISIT_END( node );
3442}
3443
3444template< typename pass_type >
3445void PassVisitor< pass_type >::visit( const StructInstType * node ) {
3446 VISIT_START( node );
3447
3448 indexerAddStruct( node->name );
3449
3450 {
3451 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3452 maybeAccept_impl( node->forall , *this );
3453 maybeAccept_impl( node->parameters, *this );
3454 }
3455
3456 VISIT_END( node );
3457}
3458
3459template< typename pass_type >
3460Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
3461 MUTATE_START( node );
3462
3463 indexerAddStruct( node->name );
3464
3465 {
3466 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3467 maybeMutate_impl( node->forall , *this );
3468 maybeMutate_impl( node->parameters, *this );
3469 }
3470
3471 MUTATE_END( Type, node );
3472}
3473
3474//--------------------------------------------------------------------------
3475// UnionInstType
3476template< typename pass_type >
3477void PassVisitor< pass_type >::visit( UnionInstType * node ) {
3478 VISIT_START( node );
3479
3480 indexerAddUnion( node->name );
3481
3482 {
3483 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3484 maybeAccept_impl( node->forall , *this );
3485 maybeAccept_impl( node->parameters, *this );
3486 }
3487
3488 VISIT_END( node );
3489}
3490
3491template< typename pass_type >
3492void PassVisitor< pass_type >::visit( const UnionInstType * node ) {
3493 VISIT_START( node );
3494
3495 indexerAddUnion( node->name );
3496
3497 {
3498 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3499 maybeAccept_impl( node->forall , *this );
3500 maybeAccept_impl( node->parameters, *this );
3501 }
3502
3503 VISIT_END( node );
3504}
3505
3506template< typename pass_type >
3507Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
3508 MUTATE_START( node );
3509
3510 indexerAddUnion( node->name );
3511
3512 {
3513 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3514 maybeMutate_impl( node->forall , *this );
3515 maybeMutate_impl( node->parameters, *this );
3516 }
3517
3518 MUTATE_END( Type, node );
3519}
3520
3521//--------------------------------------------------------------------------
3522// EnumInstType
3523template< typename pass_type >
3524void PassVisitor< pass_type >::visit( EnumInstType * node ) {
3525 VISIT_START( node );
3526
3527 maybeAccept_impl( node->forall, *this );
3528 maybeAccept_impl( node->parameters, *this );
3529
3530 VISIT_END( node );
3531}
3532
3533template< typename pass_type >
3534void PassVisitor< pass_type >::visit( const EnumInstType * node ) {
3535 VISIT_START( node );
3536
3537 maybeAccept_impl( node->forall, *this );
3538 maybeAccept_impl( node->parameters, *this );
3539
3540 VISIT_END( node );
3541}
3542
3543template< typename pass_type >
3544Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
3545 MUTATE_START( node );
3546
3547 maybeMutate_impl( node->forall, *this );
3548 maybeMutate_impl( node->parameters, *this );
3549
3550 MUTATE_END( Type, node );
3551}
3552
3553//--------------------------------------------------------------------------
3554// TraitInstType
3555template< typename pass_type >
3556void PassVisitor< pass_type >::visit( TraitInstType * node ) {
3557 VISIT_START( node );
3558
3559 maybeAccept_impl( node->forall , *this );
3560 maybeAccept_impl( node->parameters, *this );
3561
3562 VISIT_END( node );
3563}
3564
3565template< typename pass_type >
3566void PassVisitor< pass_type >::visit( const TraitInstType * node ) {
3567 VISIT_START( node );
3568
3569 maybeAccept_impl( node->forall , *this );
3570 maybeAccept_impl( node->parameters, *this );
3571
3572 VISIT_END( node );
3573}
3574
3575template< typename pass_type >
3576Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
3577 MUTATE_START( node );
3578
3579 maybeMutate_impl( node->forall , *this );
3580 maybeMutate_impl( node->parameters, *this );
3581
3582 MUTATE_END( Type, node );
3583}
3584
3585//--------------------------------------------------------------------------
3586// TypeInstType
3587template< typename pass_type >
3588void PassVisitor< pass_type >::visit( TypeInstType * node ) {
3589 VISIT_START( node );
3590
3591 maybeAccept_impl( node->forall , *this );
3592 maybeAccept_impl( node->parameters, *this );
3593
3594 VISIT_END( node );
3595}
3596
3597template< typename pass_type >
3598void PassVisitor< pass_type >::visit( const TypeInstType * node ) {
3599 VISIT_START( node );
3600
3601 maybeAccept_impl( node->forall , *this );
3602 maybeAccept_impl( node->parameters, *this );
3603
3604 VISIT_END( node );
3605}
3606
3607template< typename pass_type >
3608Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
3609 MUTATE_START( node );
3610
3611 maybeMutate_impl( node->forall , *this );
3612 maybeMutate_impl( node->parameters, *this );
3613
3614 MUTATE_END( Type, node );
3615}
3616
3617//--------------------------------------------------------------------------
3618// TupleType
3619template< typename pass_type >
3620void PassVisitor< pass_type >::visit( TupleType * node ) {
3621 VISIT_START( node );
3622
3623 maybeAccept_impl( node->forall, *this );
3624 maybeAccept_impl( node->types, *this );
3625 maybeAccept_impl( node->members, *this );
3626
3627 VISIT_END( node );
3628}
3629
3630template< typename pass_type >
3631void PassVisitor< pass_type >::visit( const TupleType * node ) {
3632 VISIT_START( node );
3633
3634 maybeAccept_impl( node->forall, *this );
3635 maybeAccept_impl( node->types, *this );
3636 maybeAccept_impl( node->members, *this );
3637
3638 VISIT_END( node );
3639}
3640
3641template< typename pass_type >
3642Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
3643 MUTATE_START( node );
3644
3645 maybeMutate_impl( node->forall, *this );
3646 maybeMutate_impl( node->types, *this );
3647 maybeMutate_impl( node->members, *this );
3648
3649 MUTATE_END( Type, node );
3650}
3651
3652//--------------------------------------------------------------------------
3653// TypeofType
3654template< typename pass_type >
3655void PassVisitor< pass_type >::visit( TypeofType * node ) {
3656 VISIT_START( node );
3657
3658 assert( node->expr );
3659 maybeAccept_impl( node->expr, *this );
3660
3661 VISIT_END( node );
3662}
3663
3664template< typename pass_type >
3665void PassVisitor< pass_type >::visit( const TypeofType * node ) {
3666 VISIT_START( node );
3667
3668 assert( node->expr );
3669 maybeAccept_impl( node->expr, *this );
3670
3671 VISIT_END( node );
3672}
3673
3674template< typename pass_type >
3675Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
3676 MUTATE_START( node );
3677
3678 assert( node->expr );
3679 maybeMutate_impl( node->expr, *this );
3680
3681 MUTATE_END( Type, node );
3682}
3683
3684//--------------------------------------------------------------------------
3685// VTableType
3686template< typename pass_type >
3687void PassVisitor< pass_type >::visit( VTableType * node ) {
3688 VISIT_START( node );
3689
3690 // Forall qualifiers should be on base type, not here
3691 // maybeAccept_impl( node->forall, *this );
3692 maybeAccept_impl( node->base, *this );
3693
3694 VISIT_END( node );
3695}
3696
3697template< typename pass_type >
3698void PassVisitor< pass_type >::visit( const VTableType * node ) {
3699 VISIT_START( node );
3700
3701 // Forall qualifiers should be on base type, not here
3702 // maybeAccept_impl( node->forall, *this );
3703 maybeAccept_impl( node->base, *this );
3704
3705 VISIT_END( node );
3706}
3707
3708template< typename pass_type >
3709Type * PassVisitor< pass_type >::mutate( VTableType * node ) {
3710 MUTATE_START( node );
3711
3712 // Forall qualifiers should be on base type, not here
3713 // maybeMutate_impl( node->forall, *this );
3714 maybeMutate_impl( node->base, *this );
3715
3716 MUTATE_END( Type, node );
3717}
3718
3719//--------------------------------------------------------------------------
3720// AttrType
3721template< typename pass_type >
3722void PassVisitor< pass_type >::visit( AttrType * node ) {
3723 VISIT_START( node );
3724
3725 if ( node->isType ) {
3726 assert( node->type );
3727 maybeAccept_impl( node->type, *this );
3728 } else {
3729 assert( node->expr );
3730 maybeAccept_impl( node->expr, *this );
3731 } // if
3732
3733 VISIT_END( node );
3734}
3735
3736template< typename pass_type >
3737void PassVisitor< pass_type >::visit( const AttrType * node ) {
3738 VISIT_START( node );
3739
3740 if ( node->isType ) {
3741 assert( node->type );
3742 maybeAccept_impl( node->type, *this );
3743 } else {
3744 assert( node->expr );
3745 maybeAccept_impl( node->expr, *this );
3746 } // if
3747
3748 VISIT_END( node );
3749}
3750
3751template< typename pass_type >
3752Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
3753 MUTATE_START( node );
3754
3755 if ( node->isType ) {
3756 assert( node->type );
3757 maybeMutate_impl( node->type, *this );
3758 } else {
3759 assert( node->expr );
3760 maybeMutate_impl( node->expr, *this );
3761 } // if
3762
3763 MUTATE_END( Type, node );
3764}
3765
3766//--------------------------------------------------------------------------
3767// VarArgsType
3768template< typename pass_type >
3769void PassVisitor< pass_type >::visit( VarArgsType * node ) {
3770 VISIT_START( node );
3771
3772 maybeAccept_impl( node->forall, *this );
3773
3774 VISIT_END( node );
3775}
3776
3777template< typename pass_type >
3778void PassVisitor< pass_type >::visit( const VarArgsType * node ) {
3779 VISIT_START( node );
3780
3781 maybeAccept_impl( node->forall, *this );
3782
3783 VISIT_END( node );
3784}
3785
3786template< typename pass_type >
3787Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
3788 MUTATE_START( node );
3789
3790 maybeMutate_impl( node->forall, *this );
3791
3792 MUTATE_END( Type, node );
3793}
3794
3795//--------------------------------------------------------------------------
3796// ZeroType
3797template< typename pass_type >
3798void PassVisitor< pass_type >::visit( ZeroType * node ) {
3799 VISIT_START( node );
3800
3801 maybeAccept_impl( node->forall, *this );
3802
3803 VISIT_END( node );
3804}
3805
3806template< typename pass_type >
3807void PassVisitor< pass_type >::visit( const ZeroType * node ) {
3808 VISIT_START( node );
3809
3810 maybeAccept_impl( node->forall, *this );
3811
3812 VISIT_END( node );
3813}
3814
3815template< typename pass_type >
3816Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
3817 MUTATE_START( node );
3818
3819 maybeMutate_impl( node->forall, *this );
3820
3821 MUTATE_END( Type, node );
3822}
3823
3824//--------------------------------------------------------------------------
3825// OneType
3826template< typename pass_type >
3827void PassVisitor< pass_type >::visit( OneType * node ) {
3828 VISIT_START( node );
3829
3830 maybeAccept_impl( node->forall, *this );
3831
3832 VISIT_END( node );
3833}
3834
3835template< typename pass_type >
3836void PassVisitor< pass_type >::visit( const OneType * node ) {
3837 VISIT_START( node );
3838
3839 maybeAccept_impl( node->forall, *this );
3840
3841 VISIT_END( node );
3842}
3843
3844template< typename pass_type >
3845Type * PassVisitor< pass_type >::mutate( OneType * node ) {
3846 MUTATE_START( node );
3847
3848 maybeMutate_impl( node->forall, *this );
3849
3850 MUTATE_END( Type, node );
3851}
3852
3853//--------------------------------------------------------------------------
3854// GlobalScopeType
3855template< typename pass_type >
3856void PassVisitor< pass_type >::visit( GlobalScopeType * node ) {
3857 VISIT_START( node );
3858
3859 maybeAccept_impl( node->forall, *this );
3860
3861 VISIT_END( node );
3862}
3863
3864template< typename pass_type >
3865void PassVisitor< pass_type >::visit( const GlobalScopeType * node ) {
3866 VISIT_START( node );
3867
3868 maybeAccept_impl( node->forall, *this );
3869
3870 VISIT_END( node );
3871}
3872
3873template< typename pass_type >
3874Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) {
3875 MUTATE_START( node );
3876
3877 maybeMutate_impl( node->forall, *this );
3878
3879 MUTATE_END( Type, node );
3880}
3881
3882//--------------------------------------------------------------------------
3883// Designation
3884template< typename pass_type >
3885void PassVisitor< pass_type >::visit( Designation * node ) {
3886 VISIT_START( node );
3887
3888 maybeAccept_impl( node->designators, *this );
3889
3890 VISIT_END( node );
3891}
3892
3893template< typename pass_type >
3894void PassVisitor< pass_type >::visit( const Designation * node ) {
3895 VISIT_START( node );
3896
3897 maybeAccept_impl( node->designators, *this );
3898
3899 VISIT_END( node );
3900}
3901
3902template< typename pass_type >
3903Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
3904 MUTATE_START( node );
3905
3906 maybeMutate_impl( node->designators, *this );
3907
3908 MUTATE_END( Designation, node );
3909}
3910
3911//--------------------------------------------------------------------------
3912// SingleInit
3913template< typename pass_type >
3914void PassVisitor< pass_type >::visit( SingleInit * node ) {
3915 VISIT_START( node );
3916
3917 visitExpression( node->value );
3918
3919 VISIT_END( node );
3920}
3921
3922template< typename pass_type >
3923void PassVisitor< pass_type >::visit( const SingleInit * node ) {
3924 VISIT_START( node );
3925
3926 visitExpression( node->value );
3927
3928 VISIT_END( node );
3929}
3930
3931template< typename pass_type >
3932Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
3933 MUTATE_START( node );
3934
3935 node->value = mutateExpression( node->value );
3936
3937 MUTATE_END( Initializer, node );
3938}
3939
3940//--------------------------------------------------------------------------
3941// ListInit
3942template< typename pass_type >
3943void PassVisitor< pass_type >::visit( ListInit * node ) {
3944 VISIT_START( node );
3945
3946 maybeAccept_impl( node->designations, *this );
3947 maybeAccept_impl( node->initializers, *this );
3948
3949 VISIT_END( node );
3950}
3951
3952template< typename pass_type >
3953void PassVisitor< pass_type >::visit( const ListInit * node ) {
3954 VISIT_START( node );
3955
3956 maybeAccept_impl( node->designations, *this );
3957 maybeAccept_impl( node->initializers, *this );
3958
3959 VISIT_END( node );
3960}
3961
3962template< typename pass_type >
3963Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
3964 MUTATE_START( node );
3965
3966 maybeMutate_impl( node->designations, *this );
3967 maybeMutate_impl( node->initializers, *this );
3968
3969 MUTATE_END( Initializer, node );
3970}
3971
3972//--------------------------------------------------------------------------
3973// ConstructorInit
3974template< typename pass_type >
3975void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
3976 VISIT_START( node );
3977
3978 maybeAccept_impl( node->ctor, *this );
3979 maybeAccept_impl( node->dtor, *this );
3980 maybeAccept_impl( node->init, *this );
3981
3982 VISIT_END( node );
3983}
3984
3985template< typename pass_type >
3986void PassVisitor< pass_type >::visit( const ConstructorInit * node ) {
3987 VISIT_START( node );
3988
3989 maybeAccept_impl( node->ctor, *this );
3990 maybeAccept_impl( node->dtor, *this );
3991 maybeAccept_impl( node->init, *this );
3992
3993 VISIT_END( node );
3994}
3995
3996template< typename pass_type >
3997Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
3998 MUTATE_START( node );
3999
4000 maybeMutate_impl( node->ctor, *this );
4001 maybeMutate_impl( node->dtor, *this );
4002 maybeMutate_impl( node->init, *this );
4003
4004 MUTATE_END( Initializer, node );
4005}
4006
4007//--------------------------------------------------------------------------
4008// Constant
4009template< typename pass_type >
4010void PassVisitor< pass_type >::visit( Constant * node ) {
4011 VISIT_START( node );
4012
4013 VISIT_END( node );
4014}
4015
4016template< typename pass_type >
4017void PassVisitor< pass_type >::visit( const Constant * node ) {
4018 VISIT_START( node );
4019
4020 VISIT_END( node );
4021}
4022
4023template< typename pass_type >
4024Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
4025 MUTATE_START( node );
4026
4027 MUTATE_END( Constant, node );
4028}
4029
4030//--------------------------------------------------------------------------
4031// Attribute
4032template< typename pass_type >
4033void PassVisitor< pass_type >::visit( Attribute * node ) {
4034 VISIT_START( node );
4035
4036 maybeAccept_impl( node->parameters, *this );
4037
4038 VISIT_END( node );
4039}
4040
4041template< typename pass_type >
4042void PassVisitor< pass_type >::visit( const Attribute * node ) {
4043 VISIT_START( node );
4044
4045 maybeAccept_impl( node->parameters, *this );
4046
4047 VISIT_END( node );
4048}
4049
4050template< typename pass_type >
4051Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
4052 MUTATE_START( node );
4053
4054 maybeMutate_impl( node->parameters, *this );
4055
4056 MUTATE_END( Attribute, node );
4057}
4058
4059//--------------------------------------------------------------------------
4060// TypeSubstitution
4061template< typename pass_type >
4062TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
4063 MUTATE_START( node );
4064
4065 for ( auto & p : node->typeEnv ) {
4066 indexerScopedMutate( p.second, *this );
4067 }
4068 for ( auto & p : node->varEnv ) {
4069 indexerScopedMutate( p.second, *this );
4070 }
4071
4072 MUTATE_END( TypeSubstitution, node );
4073}
4074
4075#undef VISIT_START
4076#undef VISIT_END
4077
4078#undef MUTATE_START
4079#undef MUTATE_END
Note: See TracBrowser for help on using the repository browser.