source: src/Common/PassVisitor.impl.h@ 86fc350

ADT ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 86fc350 was 7ff35e0e, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Implemented old ast boiler-plate for vtabletype.

  • Property mode set to 100644
File size: 110.8 KB
Line 
1#pragma once
2// IWYU pragma: private, include "PassVisitor.h"
3
4#define VISIT_START( node ) \
5 __attribute__((unused)) \
6 ChildrenGuard children_guard( get_visit_children_ptr() ); \
7 __attribute__((unused)) \
8 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
9 call_previsit( node ); \
10
11#define VISIT_END( node ) \
12 call_postvisit( node ); \
13
14#define MUTATE_START( node ) \
15 __attribute__((unused)) \
16 ChildrenGuard children_guard( get_visit_children_ptr() ); \
17 __attribute__((unused)) \
18 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
19 call_premutate( node ); \
20
21#define MUTATE_END( type, node ) \
22 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 maybeAccept_impl( node->parameters, *this );
757 maybeAccept_impl( node->members , *this );
758 maybeAccept_impl( node->attributes, *this );
759
760 VISIT_END( node );
761}
762
763template< typename pass_type >
764void PassVisitor< pass_type >::visit( const EnumDecl * node ) {
765 VISIT_START( node );
766
767 indexerAddEnum( node );
768
769 // unlike structs, traits, and unions, enums inject their members into the global scope
770 maybeAccept_impl( node->parameters, *this );
771 maybeAccept_impl( node->members , *this );
772 maybeAccept_impl( node->attributes, *this );
773
774 VISIT_END( node );
775}
776
777template< typename pass_type >
778Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
779 MUTATE_START( node );
780
781 indexerAddEnum( node );
782
783 // unlike structs, traits, and unions, enums inject their members into the global scope
784 maybeMutate_impl( node->parameters, *this );
785 maybeMutate_impl( node->members , *this );
786 maybeMutate_impl( node->attributes, *this );
787
788 MUTATE_END( Declaration, node );
789}
790
791//--------------------------------------------------------------------------
792// TraitDecl
793template< typename pass_type >
794void PassVisitor< pass_type >::visit( TraitDecl * node ) {
795 VISIT_START( node );
796
797 {
798 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
799 maybeAccept_impl( node->parameters, *this );
800 maybeAccept_impl( node->members , *this );
801 maybeAccept_impl( node->attributes, *this );
802 }
803
804 indexerAddTrait( node );
805
806 VISIT_END( node );
807}
808
809template< typename pass_type >
810void PassVisitor< pass_type >::visit( const TraitDecl * node ) {
811 VISIT_START( node );
812
813 {
814 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
815 maybeAccept_impl( node->parameters, *this );
816 maybeAccept_impl( node->members , *this );
817 maybeAccept_impl( node->attributes, *this );
818 }
819
820 indexerAddTrait( node );
821
822 VISIT_END( node );
823}
824
825template< typename pass_type >
826Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
827 MUTATE_START( node );
828
829 {
830 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
831 maybeMutate_impl( node->parameters, *this );
832 maybeMutate_impl( node->members , *this );
833 maybeMutate_impl( node->attributes, *this );
834 }
835
836 indexerAddTrait( node );
837
838 MUTATE_END( Declaration, node );
839}
840
841//--------------------------------------------------------------------------
842// TypeDecl
843template< typename pass_type >
844void PassVisitor< pass_type >::visit( TypeDecl * node ) {
845 VISIT_START( node );
846
847 {
848 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
849 maybeAccept_impl( node->base , *this );
850 }
851
852 // see A NOTE ON THE ORDER OF TRAVERSAL, above
853 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
854 // and may depend on the type itself
855 indexerAddType( node );
856
857 maybeAccept_impl( node->assertions, *this );
858
859 indexerScopedAccept( node->init, *this );
860
861 VISIT_END( node );
862}
863
864
865template< typename pass_type >
866void PassVisitor< pass_type >::visit( const TypeDecl * node ) {
867 VISIT_START( node );
868
869 {
870 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
871 maybeAccept_impl( node->base , *this );
872 }
873
874 // see A NOTE ON THE ORDER OF TRAVERSAL, above
875 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
876 // and may depend on the type itself
877 indexerAddType( node );
878
879 maybeAccept_impl( node->assertions, *this );
880
881 indexerScopedAccept( node->init, *this );
882
883 VISIT_END( node );
884}
885
886template< typename pass_type >
887Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
888 MUTATE_START( node );
889
890 {
891 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
892 maybeMutate_impl( node->base , *this );
893 }
894
895 // see A NOTE ON THE ORDER OF TRAVERSAL, above
896 // note that assertions come after the type is added to the symtab, since they are not part of the type proper
897 // and may depend on the type itself
898 indexerAddType( node );
899
900 maybeMutate_impl( node->assertions, *this );
901
902 indexerScopedMutate( node->init, *this );
903
904 MUTATE_END( Declaration, node );
905}
906
907//--------------------------------------------------------------------------
908// TypedefDecl
909template< typename pass_type >
910void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
911 VISIT_START( node );
912
913 {
914 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
915 maybeAccept_impl( node->base , *this );
916 }
917
918 indexerAddType( node );
919
920 maybeAccept_impl( node->assertions, *this );
921
922 VISIT_END( node );
923}
924
925template< typename pass_type >
926void PassVisitor< pass_type >::visit( const TypedefDecl * node ) {
927 VISIT_START( node );
928
929 {
930 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
931 maybeAccept_impl( node->base , *this );
932 }
933
934 indexerAddType( node );
935
936 maybeAccept_impl( node->assertions, *this );
937
938 VISIT_END( node );
939}
940
941template< typename pass_type >
942Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
943 MUTATE_START( node );
944
945 {
946 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
947 maybeMutate_impl( node->base , *this );
948 }
949
950 indexerAddType( node );
951
952 maybeMutate_impl( node->assertions, *this );
953
954 MUTATE_END( Declaration, node );
955}
956
957//--------------------------------------------------------------------------
958// AsmDecl
959template< typename pass_type >
960void PassVisitor< pass_type >::visit( AsmDecl * node ) {
961 VISIT_START( node );
962
963 maybeAccept_impl( node->stmt, *this );
964
965 VISIT_END( node );
966}
967
968template< typename pass_type >
969void PassVisitor< pass_type >::visit( const AsmDecl * node ) {
970 VISIT_START( node );
971
972 maybeAccept_impl( node->stmt, *this );
973
974 VISIT_END( node );
975}
976
977template< typename pass_type >
978AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
979 MUTATE_START( node );
980
981 maybeMutate_impl( node->stmt, *this );
982
983 MUTATE_END( AsmDecl, node );
984}
985
986//--------------------------------------------------------------------------
987// DirectiveDecl
988template< typename pass_type >
989void PassVisitor< pass_type >::visit( DirectiveDecl * node ) {
990 VISIT_START( node );
991
992 maybeAccept_impl( node->stmt, *this );
993
994 VISIT_END( node );
995}
996
997template< typename pass_type >
998void PassVisitor< pass_type >::visit( const DirectiveDecl * node ) {
999 VISIT_START( node );
1000
1001 maybeAccept_impl( node->stmt, *this );
1002
1003 VISIT_END( node );
1004}
1005
1006template< typename pass_type >
1007DirectiveDecl * PassVisitor< pass_type >::mutate( DirectiveDecl * node ) {
1008 MUTATE_START( node );
1009
1010 maybeMutate_impl( node->stmt, *this );
1011
1012 MUTATE_END( DirectiveDecl, node );
1013}
1014
1015//--------------------------------------------------------------------------
1016// StaticAssertDecl
1017template< typename pass_type >
1018void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) {
1019 VISIT_START( node );
1020
1021 node->condition = visitExpression( node->condition );
1022 maybeAccept_impl( node->message, *this );
1023
1024 VISIT_END( node );
1025}
1026
1027template< typename pass_type >
1028void PassVisitor< pass_type >::visit( const StaticAssertDecl * node ) {
1029 VISIT_START( node );
1030
1031 visitExpression( node->condition );
1032 maybeAccept_impl( node->message, *this );
1033
1034 VISIT_END( node );
1035}
1036
1037template< typename pass_type >
1038StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) {
1039 MUTATE_START( node );
1040
1041 node->condition = mutateExpression( node->condition );
1042 maybeMutate_impl( node->message, *this );
1043
1044 MUTATE_END( StaticAssertDecl, node );
1045}
1046
1047//--------------------------------------------------------------------------
1048// CompoundStmt
1049template< typename pass_type >
1050void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
1051 VISIT_START( node );
1052 {
1053 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1054 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1055 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
1056 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
1057 atFunctionTop = false;
1058 visitStatementList( node->kids );
1059 }
1060 VISIT_END( node );
1061}
1062
1063template< typename pass_type >
1064void PassVisitor< pass_type >::visit( const CompoundStmt * node ) {
1065 VISIT_START( node );
1066 {
1067 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1068 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1069 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
1070 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
1071 atFunctionTop = false;
1072 visitStatementList( node->kids );
1073 }
1074 VISIT_END( node );
1075}
1076
1077template< typename pass_type >
1078CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
1079 MUTATE_START( node );
1080 {
1081 // Do not enter a new scope if atFunctionTop is true, don't leave one either.
1082 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );
1083 auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } );
1084 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
1085 atFunctionTop = false;
1086 mutateStatementList( node->kids );
1087 }
1088 MUTATE_END( CompoundStmt, node );
1089}
1090
1091//--------------------------------------------------------------------------
1092// ExprStmt
1093template< typename pass_type >
1094void PassVisitor< pass_type >::visit( ExprStmt * node ) {
1095 VISIT_START( node );
1096
1097 visitExpression( node->expr );
1098
1099 VISIT_END( node );
1100}
1101
1102template< typename pass_type >
1103void PassVisitor< pass_type >::visit( const ExprStmt * node ) {
1104 VISIT_START( node );
1105
1106 visitExpression( node->expr );
1107
1108 VISIT_END( node );
1109}
1110
1111template< typename pass_type >
1112Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
1113 MUTATE_START( node );
1114
1115 node->expr = mutateExpression( node->expr );
1116
1117 MUTATE_END( Statement, node );
1118}
1119
1120//--------------------------------------------------------------------------
1121// AsmStmt
1122template< typename pass_type >
1123void PassVisitor< pass_type >::visit( AsmStmt * node ) {
1124 VISIT_START( node )
1125
1126 maybeAccept_impl( node->instruction, *this );
1127 maybeAccept_impl( node->output, *this );
1128 maybeAccept_impl( node->input, *this );
1129 maybeAccept_impl( node->clobber, *this );
1130
1131 VISIT_END( node );
1132}
1133
1134template< typename pass_type >
1135void PassVisitor< pass_type >::visit( const AsmStmt * node ) {
1136 VISIT_START( node )
1137
1138 maybeAccept_impl( node->instruction, *this );
1139 maybeAccept_impl( node->output, *this );
1140 maybeAccept_impl( node->input, *this );
1141 maybeAccept_impl( node->clobber, *this );
1142
1143 VISIT_END( node );
1144}
1145
1146template< typename pass_type >
1147Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
1148 MUTATE_START( node );
1149
1150 maybeMutate_impl( node->instruction, *this );
1151 maybeMutate_impl( node->output, *this );
1152 maybeMutate_impl( node->input, *this );
1153 maybeMutate_impl( node->clobber, *this );
1154
1155 MUTATE_END( Statement, node );
1156}
1157
1158//--------------------------------------------------------------------------
1159// AsmStmt
1160template< typename pass_type >
1161void PassVisitor< pass_type >::visit( DirectiveStmt * node ) {
1162 VISIT_START( node )
1163
1164 VISIT_END( node );
1165}
1166
1167template< typename pass_type >
1168void PassVisitor< pass_type >::visit( const DirectiveStmt * node ) {
1169 VISIT_START( node )
1170
1171 VISIT_END( node );
1172}
1173
1174template< typename pass_type >
1175Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) {
1176 MUTATE_START( node );
1177
1178 MUTATE_END( Statement, node );
1179}
1180
1181//--------------------------------------------------------------------------
1182// IfStmt
1183template< typename pass_type >
1184void PassVisitor< pass_type >::visit( IfStmt * node ) {
1185 VISIT_START( node );
1186 {
1187 // if statements introduce a level of scope (for the initialization)
1188 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1189 maybeAccept_impl( node->initialization, *this );
1190 visitExpression ( node->condition );
1191 node->thenPart = visitStatement( node->thenPart );
1192 node->elsePart = visitStatement( node->elsePart );
1193 }
1194 VISIT_END( node );
1195}
1196
1197template< typename pass_type >
1198void PassVisitor< pass_type >::visit( const IfStmt * node ) {
1199 VISIT_START( node );
1200 {
1201 // if statements introduce a level of scope (for the initialization)
1202 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1203 maybeAccept_impl( node->initialization, *this );
1204 visitExpression ( node->condition );
1205 visitStatement ( node->thenPart );
1206 visitStatement ( node->elsePart );
1207 }
1208 VISIT_END( node );
1209}
1210
1211template< typename pass_type >
1212Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
1213 MUTATE_START( node );
1214 {
1215 // if statements introduce a level of scope (for the initialization)
1216 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1217 maybeMutate_impl( node->initialization, *this );
1218 node->condition = mutateExpression( node->condition );
1219 node->thenPart = mutateStatement ( node->thenPart );
1220 node->elsePart = mutateStatement ( node->elsePart );
1221 }
1222 MUTATE_END( Statement, node );
1223}
1224
1225//--------------------------------------------------------------------------
1226// WhileStmt
1227template< typename pass_type >
1228void PassVisitor< pass_type >::visit( WhileStmt * node ) {
1229 VISIT_START( node );
1230
1231 {
1232 // while statements introduce a level of scope (for the initialization)
1233 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1234 maybeAccept_impl( node->initialization, *this );
1235 visitExpression ( node->condition );
1236 node->body = visitStatement( node->body );
1237 }
1238
1239 VISIT_END( node );
1240}
1241
1242template< typename pass_type >
1243void PassVisitor< pass_type >::visit( const WhileStmt * node ) {
1244 VISIT_START( node );
1245
1246 {
1247 // while statements introduce a level of scope (for the initialization)
1248 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1249 maybeAccept_impl( node->initialization, *this );
1250 visitExpression ( node->condition );
1251 visitStatement ( node->body );
1252 }
1253
1254 VISIT_END( node );
1255}
1256
1257template< typename pass_type >
1258Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
1259 MUTATE_START( node );
1260
1261 {
1262 // while statements introduce a level of scope (for the initialization)
1263 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1264 maybeMutate_impl( node->initialization, *this );
1265 node->condition = mutateExpression( node->condition );
1266 node->body = mutateStatement ( node->body );
1267 }
1268
1269
1270 MUTATE_END( Statement, node );
1271}
1272
1273//--------------------------------------------------------------------------
1274// ForStmt
1275template< typename pass_type >
1276void PassVisitor< pass_type >::visit( ForStmt * node ) {
1277 VISIT_START( node );
1278 {
1279 // for statements introduce a level of scope (for the initialization)
1280 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1281 maybeAccept_impl( node->initialization, *this );
1282 visitExpression( node->condition );
1283 visitExpression( node->increment );
1284 node->body = visitStatement( node->body );
1285 }
1286 VISIT_END( node );
1287}
1288
1289template< typename pass_type >
1290void PassVisitor< pass_type >::visit( const ForStmt * node ) {
1291 VISIT_START( node );
1292 {
1293 // for statements introduce a level of scope (for the initialization)
1294 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1295 maybeAccept_impl( node->initialization, *this );
1296 visitExpression( node->condition );
1297 visitExpression( node->increment );
1298 visitStatement ( node->body );
1299 }
1300 VISIT_END( node );
1301}
1302
1303template< typename pass_type >
1304Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
1305 MUTATE_START( node );
1306 {
1307 // for statements introduce a level of scope (for the initialization)
1308 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1309 maybeMutate_impl( node->initialization, *this );
1310 node->condition = mutateExpression( node->condition );
1311 node->increment = mutateExpression( node->increment );
1312 node->body = mutateStatement ( node->body );
1313 }
1314 MUTATE_END( Statement, node );
1315}
1316
1317//--------------------------------------------------------------------------
1318// SwitchStmt
1319template< typename pass_type >
1320void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
1321 VISIT_START( node );
1322
1323 visitExpression ( node->condition );
1324 visitStatementList( node->statements );
1325
1326 VISIT_END( node );
1327}
1328
1329template< typename pass_type >
1330void PassVisitor< pass_type >::visit( const SwitchStmt * node ) {
1331 VISIT_START( node );
1332
1333 visitExpression ( node->condition );
1334 visitStatementList( node->statements );
1335
1336 VISIT_END( node );
1337}
1338
1339template< typename pass_type >
1340Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
1341 MUTATE_START( node );
1342
1343 node->condition = mutateExpression( node->condition );
1344 mutateStatementList( node->statements );
1345
1346 MUTATE_END( Statement, node );
1347}
1348
1349//--------------------------------------------------------------------------
1350// CaseStmt
1351template< typename pass_type >
1352void PassVisitor< pass_type >::visit( CaseStmt * node ) {
1353 VISIT_START( node );
1354
1355 visitExpression ( node->condition );
1356 visitStatementList( node->stmts );
1357
1358 VISIT_END( node );
1359}
1360
1361template< typename pass_type >
1362void PassVisitor< pass_type >::visit( const CaseStmt * node ) {
1363 VISIT_START( node );
1364
1365 visitExpression ( node->condition );
1366 visitStatementList( node->stmts );
1367
1368 VISIT_END( node );
1369}
1370
1371template< typename pass_type >
1372Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
1373 MUTATE_START( node );
1374
1375 node->condition = mutateExpression( node->condition );
1376 mutateStatementList( node->stmts );
1377
1378 MUTATE_END( Statement, node );
1379}
1380
1381//--------------------------------------------------------------------------
1382// BranchStmt
1383template< typename pass_type >
1384void PassVisitor< pass_type >::visit( BranchStmt * node ) {
1385 VISIT_START( node );
1386 VISIT_END( node );
1387}
1388
1389template< typename pass_type >
1390void PassVisitor< pass_type >::visit( const BranchStmt * node ) {
1391 VISIT_START( node );
1392 VISIT_END( node );
1393}
1394
1395template< typename pass_type >
1396Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
1397 MUTATE_START( node );
1398 MUTATE_END( Statement, node );
1399}
1400
1401//--------------------------------------------------------------------------
1402// ReturnStmt
1403template< typename pass_type >
1404void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
1405 VISIT_START( node );
1406
1407 visitExpression( node->expr );
1408
1409 VISIT_END( node );
1410}
1411
1412template< typename pass_type >
1413void PassVisitor< pass_type >::visit( const ReturnStmt * node ) {
1414 VISIT_START( node );
1415
1416 visitExpression( node->expr );
1417
1418 VISIT_END( node );
1419}
1420
1421template< typename pass_type >
1422Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
1423 MUTATE_START( node );
1424
1425 node->expr = mutateExpression( node->expr );
1426
1427 MUTATE_END( Statement, node );
1428}
1429
1430//--------------------------------------------------------------------------
1431// ThrowStmt
1432template< typename pass_type >
1433void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
1434 VISIT_START( node );
1435
1436 maybeAccept_impl( node->expr, *this );
1437 maybeAccept_impl( node->target, *this );
1438
1439 VISIT_END( node );
1440}
1441
1442template< typename pass_type >
1443void PassVisitor< pass_type >::visit( const ThrowStmt * node ) {
1444 VISIT_START( node );
1445
1446 maybeAccept_impl( node->expr, *this );
1447 maybeAccept_impl( node->target, *this );
1448
1449 VISIT_END( node );
1450}
1451
1452template< typename pass_type >
1453Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
1454 MUTATE_START( node );
1455
1456 maybeMutate_impl( node->expr, *this );
1457 maybeMutate_impl( node->target, *this );
1458
1459 MUTATE_END( Statement, node );
1460}
1461
1462//--------------------------------------------------------------------------
1463// TryStmt
1464template< typename pass_type >
1465void PassVisitor< pass_type >::visit( TryStmt * node ) {
1466 VISIT_START( node );
1467
1468 maybeAccept_impl( node->block , *this );
1469 maybeAccept_impl( node->handlers , *this );
1470 maybeAccept_impl( node->finallyBlock, *this );
1471
1472 VISIT_END( node );
1473}
1474
1475template< typename pass_type >
1476void PassVisitor< pass_type >::visit( const TryStmt * node ) {
1477 VISIT_START( node );
1478
1479 maybeAccept_impl( node->block , *this );
1480 maybeAccept_impl( node->handlers , *this );
1481 maybeAccept_impl( node->finallyBlock, *this );
1482
1483 VISIT_END( node );
1484}
1485
1486template< typename pass_type >
1487Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
1488 MUTATE_START( node );
1489
1490 maybeMutate_impl( node->block , *this );
1491 maybeMutate_impl( node->handlers , *this );
1492 maybeMutate_impl( node->finallyBlock, *this );
1493
1494 MUTATE_END( Statement, node );
1495}
1496
1497//--------------------------------------------------------------------------
1498// CatchStmt
1499template< typename pass_type >
1500void PassVisitor< pass_type >::visit( CatchStmt * node ) {
1501 VISIT_START( node );
1502 {
1503 // catch statements introduce a level of scope (for the caught exception)
1504 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1505 maybeAccept_impl( node->decl, *this );
1506 node->cond = visitExpression( node->cond );
1507 node->body = visitStatement ( node->body );
1508 }
1509 VISIT_END( node );
1510}
1511
1512template< typename pass_type >
1513void PassVisitor< pass_type >::visit( const CatchStmt * node ) {
1514 VISIT_START( node );
1515 {
1516 // catch statements introduce a level of scope (for the caught exception)
1517 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1518 maybeAccept_impl( node->decl, *this );
1519 visitExpression ( node->cond );
1520 visitStatement ( node->body );
1521 }
1522 VISIT_END( node );
1523}
1524
1525template< typename pass_type >
1526Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
1527 MUTATE_START( node );
1528 {
1529 // catch statements introduce a level of scope (for the caught exception)
1530 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1531 maybeMutate_impl( node->decl, *this );
1532 node->cond = mutateExpression( node->cond );
1533 node->body = mutateStatement ( node->body );
1534 }
1535 MUTATE_END( Statement, node );
1536}
1537
1538//--------------------------------------------------------------------------
1539// FinallyStmt
1540template< typename pass_type >
1541void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
1542 VISIT_START( node );
1543
1544 maybeAccept_impl( node->block, *this );
1545
1546 VISIT_END( node );
1547}
1548
1549template< typename pass_type >
1550void PassVisitor< pass_type >::visit( const FinallyStmt * node ) {
1551 VISIT_START( node );
1552
1553 maybeAccept_impl( node->block, *this );
1554
1555 VISIT_END( node );
1556}
1557
1558template< typename pass_type >
1559Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
1560 MUTATE_START( node );
1561
1562 maybeMutate_impl( node->block, *this );
1563
1564 MUTATE_END( Statement, node );
1565}
1566
1567//--------------------------------------------------------------------------
1568// SuspendStmt
1569template< typename pass_type >
1570void PassVisitor< pass_type >::visit( SuspendStmt * node ) {
1571 VISIT_START( node );
1572
1573 maybeAccept_impl( node->then , *this );
1574
1575 VISIT_END( node );
1576}
1577
1578template< typename pass_type >
1579void PassVisitor< pass_type >::visit( const SuspendStmt * node ) {
1580 VISIT_START( node );
1581
1582 maybeAccept_impl( node->then , *this );
1583
1584 VISIT_END( node );
1585}
1586
1587template< typename pass_type >
1588Statement * PassVisitor< pass_type >::mutate( SuspendStmt * node ) {
1589 MUTATE_START( node );
1590
1591 maybeMutate_impl( node->then , *this );
1592
1593 MUTATE_END( Statement, node );
1594}
1595
1596//--------------------------------------------------------------------------
1597// WaitForStmt
1598template< typename pass_type >
1599void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
1600 VISIT_START( node );
1601
1602 for( auto & clause : node->clauses ) {
1603 maybeAccept_impl( clause.target.function, *this );
1604 maybeAccept_impl( clause.target.arguments, *this );
1605
1606 maybeAccept_impl( clause.statement, *this );
1607 maybeAccept_impl( clause.condition, *this );
1608 }
1609
1610 maybeAccept_impl( node->timeout.time, *this );
1611 maybeAccept_impl( node->timeout.statement, *this );
1612 maybeAccept_impl( node->timeout.condition, *this );
1613 maybeAccept_impl( node->orelse.statement, *this );
1614 maybeAccept_impl( node->orelse.condition, *this );
1615
1616 VISIT_END( node );
1617}
1618
1619template< typename pass_type >
1620void PassVisitor< pass_type >::visit( const WaitForStmt * node ) {
1621 VISIT_START( node );
1622
1623 for( auto & clause : node->clauses ) {
1624 maybeAccept_impl( clause.target.function, *this );
1625 maybeAccept_impl( clause.target.arguments, *this );
1626
1627 maybeAccept_impl( clause.statement, *this );
1628 maybeAccept_impl( clause.condition, *this );
1629 }
1630
1631 maybeAccept_impl( node->timeout.time, *this );
1632 maybeAccept_impl( node->timeout.statement, *this );
1633 maybeAccept_impl( node->timeout.condition, *this );
1634 maybeAccept_impl( node->orelse.statement, *this );
1635 maybeAccept_impl( node->orelse.condition, *this );
1636
1637 VISIT_END( node );
1638}
1639
1640template< typename pass_type >
1641Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
1642 MUTATE_START( node );
1643
1644 for( auto & clause : node->clauses ) {
1645 maybeMutate_impl( clause.target.function, *this );
1646 maybeMutate_impl( clause.target.arguments, *this );
1647
1648 maybeMutate_impl( clause.statement, *this );
1649 maybeMutate_impl( clause.condition, *this );
1650 }
1651
1652 maybeMutate_impl( node->timeout.time, *this );
1653 maybeMutate_impl( node->timeout.statement, *this );
1654 maybeMutate_impl( node->timeout.condition, *this );
1655 maybeMutate_impl( node->orelse.statement, *this );
1656 maybeMutate_impl( node->orelse.condition, *this );
1657
1658 MUTATE_END( Statement, node );
1659}
1660
1661
1662
1663//--------------------------------------------------------------------------
1664// WithStmt
1665template< typename pass_type >
1666void PassVisitor< pass_type >::visit( WithStmt * node ) {
1667 VISIT_START( node );
1668 maybeAccept_impl( node->exprs, *this );
1669 {
1670 // catch statements introduce a level of scope (for the caught exception)
1671 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1672 indexerAddWith( node->exprs, node );
1673 maybeAccept_impl( node->stmt, *this );
1674 }
1675 VISIT_END( node );
1676}
1677
1678template< typename pass_type >
1679void PassVisitor< pass_type >::visit( const WithStmt * node ) {
1680 VISIT_START( node );
1681 maybeAccept_impl( node->exprs, *this );
1682 {
1683 // catch statements introduce a level of scope (for the caught exception)
1684 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1685 indexerAddWith( node->exprs, node );
1686 maybeAccept_impl( node->stmt, *this );
1687 }
1688 VISIT_END( node );
1689}
1690
1691template< typename pass_type >
1692Declaration * PassVisitor< pass_type >::mutate( WithStmt * node ) {
1693 MUTATE_START( node );
1694 maybeMutate_impl( node->exprs, *this );
1695 {
1696 // catch statements introduce a level of scope (for the caught exception)
1697 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1698 indexerAddWith( node->exprs, node );
1699 maybeMutate_impl( node->stmt, *this );
1700 }
1701 MUTATE_END( Declaration, node );
1702}
1703
1704//--------------------------------------------------------------------------
1705// NullStmt
1706template< typename pass_type >
1707void PassVisitor< pass_type >::visit( NullStmt * node ) {
1708 VISIT_START( node );
1709 VISIT_END( node );
1710}
1711
1712template< typename pass_type >
1713void PassVisitor< pass_type >::visit( const NullStmt * node ) {
1714 VISIT_START( node );
1715 VISIT_END( node );
1716}
1717
1718template< typename pass_type >
1719NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
1720 MUTATE_START( node );
1721 MUTATE_END( NullStmt, node );
1722}
1723
1724//--------------------------------------------------------------------------
1725// DeclStmt
1726template< typename pass_type >
1727void PassVisitor< pass_type >::visit( DeclStmt * node ) {
1728 VISIT_START( node );
1729
1730 maybeAccept_impl( node->decl, *this );
1731
1732 VISIT_END( node );
1733}
1734
1735template< typename pass_type >
1736void PassVisitor< pass_type >::visit( const DeclStmt * node ) {
1737 VISIT_START( node );
1738
1739 maybeAccept_impl( node->decl, *this );
1740
1741 VISIT_END( node );
1742}
1743
1744template< typename pass_type >
1745Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
1746 MUTATE_START( node );
1747
1748 maybeMutate_impl( node->decl, *this );
1749
1750 MUTATE_END( Statement, node );
1751}
1752
1753//--------------------------------------------------------------------------
1754// ImplicitCtorDtorStmt
1755template< typename pass_type >
1756void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
1757 VISIT_START( node );
1758
1759 maybeAccept_impl( node->callStmt, *this );
1760
1761 VISIT_END( node );
1762}
1763
1764template< typename pass_type >
1765void PassVisitor< pass_type >::visit( const ImplicitCtorDtorStmt * node ) {
1766 VISIT_START( node );
1767
1768 maybeAccept_impl( node->callStmt, *this );
1769
1770 VISIT_END( node );
1771}
1772
1773template< typename pass_type >
1774Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
1775 MUTATE_START( node );
1776
1777 maybeMutate_impl( node->callStmt, *this );
1778
1779 MUTATE_END( Statement, node );
1780}
1781
1782//--------------------------------------------------------------------------
1783// ApplicationExpr
1784template< typename pass_type >
1785void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
1786 VISIT_START( node );
1787
1788 indexerScopedAccept( node->result , *this );
1789 maybeAccept_impl ( node->function, *this );
1790 maybeAccept_impl ( node->args , *this );
1791
1792 VISIT_END( node );
1793}
1794
1795template< typename pass_type >
1796void PassVisitor< pass_type >::visit( const ApplicationExpr * node ) {
1797 VISIT_START( node );
1798
1799 indexerScopedAccept( node->result , *this );
1800 maybeAccept_impl ( node->function, *this );
1801 maybeAccept_impl ( node->args , *this );
1802
1803 VISIT_END( node );
1804}
1805
1806template< typename pass_type >
1807Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
1808 MUTATE_START( node );
1809
1810 indexerScopedMutate( node->env , *this );
1811 indexerScopedMutate( node->result , *this );
1812 maybeMutate_impl ( node->function, *this );
1813 maybeMutate_impl ( node->args , *this );
1814
1815 MUTATE_END( Expression, node );
1816}
1817
1818//--------------------------------------------------------------------------
1819// UntypedExpr
1820template< typename pass_type >
1821void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
1822 VISIT_START( node );
1823
1824 // maybeAccept_impl( node->get_env(), *this );
1825 indexerScopedAccept( node->result, *this );
1826
1827 for ( auto expr : node->args ) {
1828 visitExpression( expr );
1829 }
1830
1831 VISIT_END( node );
1832}
1833
1834template< typename pass_type >
1835void PassVisitor< pass_type >::visit( const UntypedExpr * node ) {
1836 VISIT_START( node );
1837
1838 indexerScopedAccept( node->result, *this );
1839
1840 for ( auto expr : node->args ) {
1841 visitExpression( expr );
1842 }
1843
1844 VISIT_END( node );
1845}
1846
1847template< typename pass_type >
1848Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
1849 MUTATE_START( node );
1850
1851 indexerScopedMutate( node->env , *this );
1852 indexerScopedMutate( node->result, *this );
1853
1854 for ( auto& expr : node->args ) {
1855 expr = mutateExpression( expr );
1856 }
1857
1858 MUTATE_END( Expression, node );
1859}
1860
1861//--------------------------------------------------------------------------
1862// NameExpr
1863template< typename pass_type >
1864void PassVisitor< pass_type >::visit( NameExpr * node ) {
1865 VISIT_START( node );
1866
1867 indexerScopedAccept( node->result, *this );
1868
1869 VISIT_END( node );
1870}
1871
1872template< typename pass_type >
1873void PassVisitor< pass_type >::visit( const NameExpr * node ) {
1874 VISIT_START( node );
1875
1876 indexerScopedAccept( node->result, *this );
1877
1878 VISIT_END( node );
1879}
1880
1881template< typename pass_type >
1882Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
1883 MUTATE_START( node );
1884
1885 indexerScopedMutate( node->env , *this );
1886 indexerScopedMutate( node->result, *this );
1887
1888 MUTATE_END( Expression, node );
1889}
1890
1891//--------------------------------------------------------------------------
1892// CastExpr
1893template< typename pass_type >
1894void PassVisitor< pass_type >::visit( CastExpr * node ) {
1895 VISIT_START( node );
1896
1897 indexerScopedAccept( node->result, *this );
1898 maybeAccept_impl ( node->arg , *this );
1899
1900 VISIT_END( node );
1901}
1902
1903template< typename pass_type >
1904void PassVisitor< pass_type >::visit( const CastExpr * node ) {
1905 VISIT_START( node );
1906
1907 indexerScopedAccept( node->result, *this );
1908 maybeAccept_impl ( node->arg , *this );
1909
1910 VISIT_END( node );
1911}
1912
1913template< typename pass_type >
1914Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
1915 MUTATE_START( node );
1916
1917 indexerScopedMutate( node->env , *this );
1918 indexerScopedMutate( node->result, *this );
1919 maybeMutate_impl ( node->arg , *this );
1920
1921 MUTATE_END( Expression, node );
1922}
1923
1924//--------------------------------------------------------------------------
1925// KeywordCastExpr
1926template< typename pass_type >
1927void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
1928 VISIT_START( node );
1929
1930 indexerScopedAccept( node->result, *this );
1931 maybeAccept_impl ( node->arg , *this );
1932
1933 VISIT_END( node );
1934}
1935
1936template< typename pass_type >
1937void PassVisitor< pass_type >::visit( const KeywordCastExpr * node ) {
1938 VISIT_START( node );
1939
1940 indexerScopedAccept( node->result, *this );
1941 maybeAccept_impl ( node->arg , *this );
1942
1943 VISIT_END( node );
1944}
1945
1946template< typename pass_type >
1947Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
1948 MUTATE_START( node );
1949
1950 indexerScopedMutate( node->env , *this );
1951 indexerScopedMutate( node->result, *this );
1952 maybeMutate_impl ( node->arg , *this );
1953
1954 MUTATE_END( Expression, node );
1955}
1956
1957//--------------------------------------------------------------------------
1958// VirtualCastExpr
1959template< typename pass_type >
1960void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
1961 VISIT_START( node );
1962
1963 indexerScopedAccept( node->result, *this );
1964 maybeAccept_impl ( node->arg, *this );
1965
1966 VISIT_END( node );
1967}
1968
1969template< typename pass_type >
1970void PassVisitor< pass_type >::visit( const VirtualCastExpr * node ) {
1971 VISIT_START( node );
1972
1973 indexerScopedAccept( node->result, *this );
1974 maybeAccept_impl ( node->arg, *this );
1975
1976 VISIT_END( node );
1977}
1978
1979template< typename pass_type >
1980Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
1981 MUTATE_START( node );
1982
1983 indexerScopedMutate( node->env , *this );
1984 indexerScopedMutate( node->result, *this );
1985 maybeMutate_impl ( node->arg , *this );
1986
1987 MUTATE_END( Expression, node );
1988}
1989
1990//--------------------------------------------------------------------------
1991// AddressExpr
1992template< typename pass_type >
1993void PassVisitor< pass_type >::visit( AddressExpr * node ) {
1994 VISIT_START( node );
1995
1996 indexerScopedAccept( node->result, *this );
1997 maybeAccept_impl ( node->arg , *this );
1998
1999 VISIT_END( node );
2000}
2001
2002template< typename pass_type >
2003void PassVisitor< pass_type >::visit( const AddressExpr * node ) {
2004 VISIT_START( node );
2005
2006 indexerScopedAccept( node->result, *this );
2007 maybeAccept_impl ( node->arg , *this );
2008
2009 VISIT_END( node );
2010}
2011
2012template< typename pass_type >
2013Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
2014 MUTATE_START( node );
2015
2016 indexerScopedMutate( node->env , *this );
2017 indexerScopedMutate( node->result, *this );
2018 maybeMutate_impl ( node->arg , *this );
2019
2020 MUTATE_END( Expression, node );
2021}
2022
2023//--------------------------------------------------------------------------
2024// LabelAddressExpr
2025template< typename pass_type >
2026void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
2027 VISIT_START( node );
2028
2029 indexerScopedAccept( node->result, *this );
2030
2031 VISIT_END( node );
2032}
2033
2034template< typename pass_type >
2035void PassVisitor< pass_type >::visit( const LabelAddressExpr * node ) {
2036 VISIT_START( node );
2037
2038 indexerScopedAccept( node->result, *this );
2039
2040 VISIT_END( node );
2041}
2042
2043template< typename pass_type >
2044Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
2045 MUTATE_START( node );
2046
2047 indexerScopedMutate( node->env , *this );
2048 indexerScopedMutate( node->result, *this );
2049
2050 MUTATE_END( Expression, node );
2051}
2052
2053//--------------------------------------------------------------------------
2054// UntypedMemberExpr
2055template< typename pass_type >
2056void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
2057 VISIT_START( node );
2058
2059 indexerScopedAccept( node->result , *this );
2060 maybeAccept_impl ( node->aggregate, *this );
2061 maybeAccept_impl ( node->member , *this );
2062
2063 VISIT_END( node );
2064}
2065
2066template< typename pass_type >
2067void PassVisitor< pass_type >::visit( const UntypedMemberExpr * node ) {
2068 VISIT_START( node );
2069
2070 indexerScopedAccept( node->result , *this );
2071 maybeAccept_impl ( node->aggregate, *this );
2072 maybeAccept_impl ( node->member , *this );
2073
2074 VISIT_END( node );
2075}
2076
2077template< typename pass_type >
2078Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
2079 MUTATE_START( node );
2080
2081 indexerScopedMutate( node->env , *this );
2082 indexerScopedMutate( node->result , *this );
2083 maybeMutate_impl ( node->aggregate, *this );
2084 maybeMutate_impl ( node->member , *this );
2085
2086 MUTATE_END( Expression, node );
2087}
2088
2089//--------------------------------------------------------------------------
2090// MemberExpr
2091template< typename pass_type >
2092void PassVisitor< pass_type >::visit( MemberExpr * node ) {
2093 VISIT_START( node );
2094
2095 indexerScopedAccept( node->result , *this );
2096 maybeAccept_impl ( node->aggregate, *this );
2097
2098 VISIT_END( node );
2099}
2100
2101template< typename pass_type >
2102void PassVisitor< pass_type >::visit( const MemberExpr * node ) {
2103 VISIT_START( node );
2104
2105 indexerScopedAccept( node->result , *this );
2106 maybeAccept_impl ( node->aggregate, *this );
2107
2108 VISIT_END( node );
2109}
2110
2111template< typename pass_type >
2112Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
2113 MUTATE_START( node );
2114
2115 indexerScopedMutate( node->env , *this );
2116 indexerScopedMutate( node->result , *this );
2117 maybeMutate_impl ( node->aggregate, *this );
2118
2119 MUTATE_END( Expression, node );
2120}
2121
2122//--------------------------------------------------------------------------
2123// VariableExpr
2124template< typename pass_type >
2125void PassVisitor< pass_type >::visit( VariableExpr * node ) {
2126 VISIT_START( node );
2127
2128 indexerScopedAccept( node->result, *this );
2129
2130 VISIT_END( node );
2131}
2132
2133template< typename pass_type >
2134void PassVisitor< pass_type >::visit( const VariableExpr * node ) {
2135 VISIT_START( node );
2136
2137 indexerScopedAccept( node->result, *this );
2138
2139 VISIT_END( node );
2140}
2141
2142template< typename pass_type >
2143Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
2144 MUTATE_START( node );
2145
2146 indexerScopedMutate( node->env , *this );
2147 indexerScopedMutate( node->result, *this );
2148
2149 MUTATE_END( Expression, node );
2150}
2151
2152//--------------------------------------------------------------------------
2153// ConstantExpr
2154template< typename pass_type >
2155void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
2156 VISIT_START( node );
2157
2158 indexerScopedAccept( node->result , *this );
2159 maybeAccept_impl ( &node->constant, *this );
2160
2161 VISIT_END( node );
2162}
2163
2164template< typename pass_type >
2165void PassVisitor< pass_type >::visit( const ConstantExpr * node ) {
2166 VISIT_START( node );
2167
2168 indexerScopedAccept( node->result , *this );
2169 maybeAccept_impl ( &node->constant, *this );
2170
2171 VISIT_END( node );
2172}
2173
2174template< typename pass_type >
2175Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
2176 MUTATE_START( node );
2177
2178 indexerScopedMutate( node->env , *this );
2179 indexerScopedMutate( node->result, *this );
2180 Constant * ptr = &node->constant;
2181 maybeMutate_impl( ptr, *this );
2182 node->constant = *ptr;
2183
2184 MUTATE_END( Expression, node );
2185}
2186
2187//--------------------------------------------------------------------------
2188// SizeofExpr
2189template< typename pass_type >
2190void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
2191 VISIT_START( node );
2192
2193 indexerScopedAccept( node->result, *this );
2194 if ( node->get_isType() ) {
2195 maybeAccept_impl( node->type, *this );
2196 } else {
2197 maybeAccept_impl( node->expr, *this );
2198 }
2199
2200 VISIT_END( node );
2201}
2202
2203template< typename pass_type >
2204void PassVisitor< pass_type >::visit( const SizeofExpr * node ) {
2205 VISIT_START( node );
2206
2207 indexerScopedAccept( node->result, *this );
2208 if ( node->get_isType() ) {
2209 maybeAccept_impl( node->type, *this );
2210 } else {
2211 maybeAccept_impl( node->expr, *this );
2212 }
2213
2214 VISIT_END( node );
2215}
2216
2217template< typename pass_type >
2218Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
2219 MUTATE_START( node );
2220
2221 indexerScopedMutate( node->env , *this );
2222 indexerScopedMutate( node->result, *this );
2223 if ( node->get_isType() ) {
2224 maybeMutate_impl( node->type, *this );
2225 } else {
2226 maybeMutate_impl( node->expr, *this );
2227 }
2228
2229 MUTATE_END( Expression, node );
2230}
2231
2232//--------------------------------------------------------------------------
2233// AlignofExpr
2234template< typename pass_type >
2235void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
2236 VISIT_START( node );
2237
2238 indexerScopedAccept( node->result, *this );
2239 if ( node->get_isType() ) {
2240 maybeAccept_impl( node->type, *this );
2241 } else {
2242 maybeAccept_impl( node->expr, *this );
2243 }
2244
2245 VISIT_END( node );
2246}
2247
2248template< typename pass_type >
2249void PassVisitor< pass_type >::visit( const AlignofExpr * node ) {
2250 VISIT_START( node );
2251
2252 indexerScopedAccept( node->result, *this );
2253 if ( node->get_isType() ) {
2254 maybeAccept_impl( node->type, *this );
2255 } else {
2256 maybeAccept_impl( node->expr, *this );
2257 }
2258
2259 VISIT_END( node );
2260}
2261
2262template< typename pass_type >
2263Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
2264 MUTATE_START( node );
2265
2266 indexerScopedMutate( node->env , *this );
2267 indexerScopedMutate( node->result, *this );
2268 if ( node->get_isType() ) {
2269 maybeMutate_impl( node->type, *this );
2270 } else {
2271 maybeMutate_impl( node->expr, *this );
2272 }
2273
2274 MUTATE_END( Expression, node );
2275}
2276
2277//--------------------------------------------------------------------------
2278// UntypedOffsetofExpr
2279template< typename pass_type >
2280void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
2281 VISIT_START( node );
2282
2283 indexerScopedAccept( node->result, *this );
2284 maybeAccept_impl ( node->type , *this );
2285
2286 VISIT_END( node );
2287}
2288
2289template< typename pass_type >
2290void PassVisitor< pass_type >::visit( const UntypedOffsetofExpr * node ) {
2291 VISIT_START( node );
2292
2293 indexerScopedAccept( node->result, *this );
2294 maybeAccept_impl ( node->type , *this );
2295
2296 VISIT_END( node );
2297}
2298
2299template< typename pass_type >
2300Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
2301 MUTATE_START( node );
2302
2303 indexerScopedMutate( node->env , *this );
2304 indexerScopedMutate( node->result, *this );
2305 maybeMutate_impl ( node->type , *this );
2306
2307 MUTATE_END( Expression, node );
2308}
2309
2310//--------------------------------------------------------------------------
2311// OffsetofExpr
2312template< typename pass_type >
2313void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
2314 VISIT_START( node );
2315
2316 indexerScopedAccept( node->result, *this );
2317 maybeAccept_impl ( node->type , *this );
2318
2319 VISIT_END( node );
2320}
2321
2322template< typename pass_type >
2323void PassVisitor< pass_type >::visit( const OffsetofExpr * node ) {
2324 VISIT_START( node );
2325
2326 indexerScopedAccept( node->result, *this );
2327 maybeAccept_impl ( node->type , *this );
2328
2329 VISIT_END( node );
2330}
2331
2332template< typename pass_type >
2333Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
2334 MUTATE_START( node );
2335
2336 indexerScopedMutate( node->env , *this );
2337 indexerScopedMutate( node->result, *this );
2338 maybeMutate_impl ( node->type , *this );
2339
2340 MUTATE_END( Expression, node );
2341}
2342
2343//--------------------------------------------------------------------------
2344// OffsetPackExpr
2345template< typename pass_type >
2346void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
2347 VISIT_START( node );
2348
2349 indexerScopedAccept( node->result, *this );
2350 maybeAccept_impl ( node->type , *this );
2351
2352 VISIT_END( node );
2353}
2354
2355template< typename pass_type >
2356void PassVisitor< pass_type >::visit( const OffsetPackExpr * node ) {
2357 VISIT_START( node );
2358
2359 indexerScopedAccept( node->result, *this );
2360 maybeAccept_impl ( node->type , *this );
2361
2362 VISIT_END( node );
2363}
2364
2365template< typename pass_type >
2366Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
2367 MUTATE_START( node );
2368
2369 indexerScopedMutate( node->env , *this );
2370 indexerScopedMutate( node->result, *this );
2371 maybeMutate_impl ( node->type , *this );
2372
2373 MUTATE_END( Expression, node );
2374}
2375
2376//--------------------------------------------------------------------------
2377// LogicalExpr
2378template< typename pass_type >
2379void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
2380 VISIT_START( node );
2381
2382 indexerScopedAccept( node->result, *this );
2383 maybeAccept_impl ( node->arg1 , *this );
2384 maybeAccept_impl ( node->arg2 , *this );
2385
2386 VISIT_END( node );
2387}
2388
2389template< typename pass_type >
2390void PassVisitor< pass_type >::visit( const LogicalExpr * node ) {
2391 VISIT_START( node );
2392
2393 indexerScopedAccept( node->result, *this );
2394 maybeAccept_impl ( node->arg1 , *this );
2395 maybeAccept_impl ( node->arg2 , *this );
2396
2397 VISIT_END( node );
2398}
2399
2400template< typename pass_type >
2401Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
2402 MUTATE_START( node );
2403
2404 indexerScopedMutate( node->env , *this );
2405 indexerScopedMutate( node->result, *this );
2406 maybeMutate_impl ( node->arg1 , *this );
2407 maybeMutate_impl ( node->arg2 , *this );
2408
2409 MUTATE_END( Expression, node );
2410}
2411
2412//--------------------------------------------------------------------------
2413// ConditionalExpr
2414template< typename pass_type >
2415void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
2416 VISIT_START( node );
2417
2418 indexerScopedAccept( node->result, *this );
2419 maybeAccept_impl ( node->arg1 , *this );
2420 maybeAccept_impl ( node->arg2 , *this );
2421 maybeAccept_impl ( node->arg3 , *this );
2422
2423 VISIT_END( node );
2424}
2425
2426template< typename pass_type >
2427void PassVisitor< pass_type >::visit( const ConditionalExpr * node ) {
2428 VISIT_START( node );
2429
2430 indexerScopedAccept( node->result, *this );
2431 maybeAccept_impl ( node->arg1 , *this );
2432 maybeAccept_impl ( node->arg2 , *this );
2433 maybeAccept_impl ( node->arg3 , *this );
2434
2435 VISIT_END( node );
2436}
2437
2438template< typename pass_type >
2439Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
2440 MUTATE_START( node );
2441
2442 indexerScopedMutate( node->env , *this );
2443 indexerScopedMutate( node->result, *this );
2444 maybeMutate_impl ( node->arg1 , *this );
2445 maybeMutate_impl ( node->arg2 , *this );
2446 maybeMutate_impl ( node->arg3 , *this );
2447
2448 MUTATE_END( Expression, node );
2449}
2450
2451//--------------------------------------------------------------------------
2452// CommaExpr
2453template< typename pass_type >
2454void PassVisitor< pass_type >::visit( CommaExpr * node ) {
2455 VISIT_START( node );
2456
2457 indexerScopedAccept( node->result, *this );
2458 maybeAccept_impl ( node->arg1 , *this );
2459 maybeAccept_impl ( node->arg2 , *this );
2460
2461 VISIT_END( node );
2462}
2463
2464template< typename pass_type >
2465void PassVisitor< pass_type >::visit( const CommaExpr * node ) {
2466 VISIT_START( node );
2467
2468 indexerScopedAccept( node->result, *this );
2469 maybeAccept_impl ( node->arg1 , *this );
2470 maybeAccept_impl ( node->arg2 , *this );
2471
2472 VISIT_END( node );
2473}
2474
2475template< typename pass_type >
2476Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
2477 MUTATE_START( node );
2478
2479 indexerScopedMutate( node->env , *this );
2480 indexerScopedMutate( node->result, *this );
2481 maybeMutate_impl ( node->arg1 , *this );
2482 maybeMutate_impl ( node->arg2 , *this );
2483
2484 MUTATE_END( Expression, node );
2485}
2486
2487//--------------------------------------------------------------------------
2488// TypeExpr
2489template< typename pass_type >
2490void PassVisitor< pass_type >::visit( TypeExpr * node ) {
2491 VISIT_START( node );
2492
2493 indexerScopedAccept( node->result, *this );
2494 maybeAccept_impl ( node->type, *this );
2495
2496 VISIT_END( node );
2497}
2498
2499template< typename pass_type >
2500void PassVisitor< pass_type >::visit( const TypeExpr * node ) {
2501 VISIT_START( node );
2502
2503 indexerScopedAccept( node->result, *this );
2504 maybeAccept_impl ( node->type, *this );
2505
2506 VISIT_END( node );
2507}
2508
2509template< typename pass_type >
2510Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
2511 MUTATE_START( node );
2512
2513 indexerScopedMutate( node->env , *this );
2514 indexerScopedMutate( node->result, *this );
2515 maybeMutate_impl ( node->type , *this );
2516
2517 MUTATE_END( Expression, node );
2518}
2519
2520//--------------------------------------------------------------------------
2521// DimensionExpr
2522template< typename pass_type >
2523void PassVisitor< pass_type >::visit( DimensionExpr * node ) {
2524 VISIT_START( node );
2525
2526 indexerScopedAccept( node->result, *this );
2527
2528 VISIT_END( node );
2529}
2530
2531template< typename pass_type >
2532void PassVisitor< pass_type >::visit( const DimensionExpr * node ) {
2533 VISIT_START( node );
2534
2535 indexerScopedAccept( node->result, *this );
2536
2537 VISIT_END( node );
2538}
2539
2540template< typename pass_type >
2541Expression * PassVisitor< pass_type >::mutate( DimensionExpr * node ) {
2542 MUTATE_START( node );
2543
2544 indexerScopedMutate( node->env , *this );
2545 indexerScopedMutate( node->result, *this );
2546
2547 MUTATE_END( Expression, node );
2548}
2549
2550//--------------------------------------------------------------------------
2551// AsmExpr
2552template< typename pass_type >
2553void PassVisitor< pass_type >::visit( AsmExpr * node ) {
2554 VISIT_START( node );
2555
2556 indexerScopedAccept( node->result , *this );
2557 maybeAccept_impl ( node->constraint, *this );
2558 maybeAccept_impl ( node->operand , *this );
2559
2560 VISIT_END( node );
2561}
2562
2563template< typename pass_type >
2564void PassVisitor< pass_type >::visit( const AsmExpr * node ) {
2565 VISIT_START( node );
2566
2567 indexerScopedAccept( node->result , *this );
2568 maybeAccept_impl ( node->constraint, *this );
2569 maybeAccept_impl ( node->operand , *this );
2570
2571 VISIT_END( node );
2572}
2573
2574template< typename pass_type >
2575Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
2576 MUTATE_START( node );
2577
2578 indexerScopedMutate( node->env , *this );
2579 indexerScopedMutate( node->result , *this );
2580 maybeMutate_impl ( node->constraint, *this );
2581 maybeMutate_impl ( node->operand , *this );
2582
2583 MUTATE_END( Expression, node );
2584}
2585
2586//--------------------------------------------------------------------------
2587// ImplicitCopyCtorExpr
2588template< typename pass_type >
2589void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
2590 VISIT_START( node );
2591
2592 indexerScopedAccept( node->result , *this );
2593 maybeAccept_impl ( node->callExpr , *this );
2594
2595 VISIT_END( node );
2596}
2597
2598template< typename pass_type >
2599void PassVisitor< pass_type >::visit( const ImplicitCopyCtorExpr * node ) {
2600 VISIT_START( node );
2601
2602 indexerScopedAccept( node->result , *this );
2603 maybeAccept_impl ( node->callExpr , *this );
2604
2605 VISIT_END( node );
2606}
2607
2608template< typename pass_type >
2609Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
2610 MUTATE_START( node );
2611
2612 indexerScopedMutate( node->env , *this );
2613 indexerScopedMutate( node->result , *this );
2614 maybeMutate_impl ( node->callExpr , *this );
2615
2616 MUTATE_END( Expression, node );
2617}
2618
2619//--------------------------------------------------------------------------
2620// ConstructorExpr
2621template< typename pass_type >
2622void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
2623 VISIT_START( node );
2624
2625 indexerScopedAccept( node->result , *this );
2626 maybeAccept_impl ( node->callExpr, *this );
2627
2628 VISIT_END( node );
2629}
2630
2631template< typename pass_type >
2632void PassVisitor< pass_type >::visit( const ConstructorExpr * node ) {
2633 VISIT_START( node );
2634
2635 indexerScopedAccept( node->result , *this );
2636 maybeAccept_impl ( node->callExpr, *this );
2637
2638 VISIT_END( node );
2639}
2640
2641template< typename pass_type >
2642Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
2643 MUTATE_START( node );
2644
2645 indexerScopedMutate( node->env , *this );
2646 indexerScopedMutate( node->result , *this );
2647 maybeMutate_impl ( node->callExpr, *this );
2648
2649 MUTATE_END( Expression, node );
2650}
2651
2652//--------------------------------------------------------------------------
2653// CompoundLiteralExpr
2654template< typename pass_type >
2655void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
2656 VISIT_START( node );
2657
2658 indexerScopedAccept( node->result , *this );
2659 maybeAccept_impl ( node->initializer, *this );
2660
2661 VISIT_END( node );
2662}
2663
2664template< typename pass_type >
2665void PassVisitor< pass_type >::visit( const CompoundLiteralExpr * node ) {
2666 VISIT_START( node );
2667
2668 indexerScopedAccept( node->result , *this );
2669 maybeAccept_impl ( node->initializer, *this );
2670
2671 VISIT_END( node );
2672}
2673
2674template< typename pass_type >
2675Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
2676 MUTATE_START( node );
2677
2678 indexerScopedMutate( node->env , *this );
2679 indexerScopedMutate( node->result , *this );
2680 maybeMutate_impl ( node->initializer, *this );
2681
2682 MUTATE_END( Expression, node );
2683}
2684
2685//--------------------------------------------------------------------------
2686// RangeExpr
2687template< typename pass_type >
2688void PassVisitor< pass_type >::visit( RangeExpr * node ) {
2689 VISIT_START( node );
2690
2691 indexerScopedAccept( node->result, *this );
2692 maybeAccept_impl ( node->low , *this );
2693 maybeAccept_impl ( node->high , *this );
2694
2695 VISIT_END( node );
2696}
2697
2698template< typename pass_type >
2699void PassVisitor< pass_type >::visit( const RangeExpr * node ) {
2700 VISIT_START( node );
2701
2702 indexerScopedAccept( node->result, *this );
2703 maybeAccept_impl ( node->low , *this );
2704 maybeAccept_impl ( node->high , *this );
2705
2706 VISIT_END( node );
2707}
2708
2709template< typename pass_type >
2710Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
2711 MUTATE_START( node );
2712
2713 indexerScopedMutate( node->env , *this );
2714 indexerScopedMutate( node->result, *this );
2715 maybeMutate_impl ( node->low , *this );
2716 maybeMutate_impl ( node->high , *this );
2717
2718 MUTATE_END( Expression, node );
2719}
2720
2721//--------------------------------------------------------------------------
2722// UntypedTupleExpr
2723template< typename pass_type >
2724void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
2725 VISIT_START( node );
2726
2727 indexerScopedAccept( node->result, *this );
2728 maybeAccept_impl ( node->exprs , *this );
2729
2730 VISIT_END( node );
2731}
2732
2733template< typename pass_type >
2734void PassVisitor< pass_type >::visit( const UntypedTupleExpr * node ) {
2735 VISIT_START( node );
2736
2737 indexerScopedAccept( node->result, *this );
2738 maybeAccept_impl ( node->exprs , *this );
2739
2740 VISIT_END( node );
2741}
2742
2743template< typename pass_type >
2744Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
2745 MUTATE_START( node );
2746
2747 indexerScopedMutate( node->env , *this );
2748 indexerScopedMutate( node->result, *this );
2749 maybeMutate_impl ( node->exprs , *this );
2750
2751 MUTATE_END( Expression, node );
2752}
2753
2754//--------------------------------------------------------------------------
2755// TupleExpr
2756template< typename pass_type >
2757void PassVisitor< pass_type >::visit( TupleExpr * node ) {
2758 VISIT_START( node );
2759
2760 indexerScopedAccept( node->result, *this );
2761 maybeAccept_impl ( node->exprs , *this );
2762
2763 VISIT_END( node );
2764}
2765
2766template< typename pass_type >
2767void PassVisitor< pass_type >::visit( const TupleExpr * node ) {
2768 VISIT_START( node );
2769
2770 indexerScopedAccept( node->result, *this );
2771 maybeAccept_impl ( node->exprs , *this );
2772
2773 VISIT_END( node );
2774}
2775
2776template< typename pass_type >
2777Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
2778 MUTATE_START( node );
2779
2780 indexerScopedMutate( node->env , *this );
2781 indexerScopedMutate( node->result, *this );
2782 maybeMutate_impl ( node->exprs , *this );
2783
2784 MUTATE_END( Expression, node );
2785}
2786
2787//--------------------------------------------------------------------------
2788// TupleIndexExpr
2789template< typename pass_type >
2790void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
2791 VISIT_START( node );
2792
2793 indexerScopedAccept( node->result, *this );
2794 maybeAccept_impl ( node->tuple , *this );
2795
2796 VISIT_END( node );
2797}
2798
2799template< typename pass_type >
2800void PassVisitor< pass_type >::visit( const TupleIndexExpr * node ) {
2801 VISIT_START( node );
2802
2803 indexerScopedAccept( node->result, *this );
2804 maybeAccept_impl ( node->tuple , *this );
2805
2806 VISIT_END( node );
2807}
2808
2809template< typename pass_type >
2810Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
2811 MUTATE_START( node );
2812
2813 indexerScopedMutate( node->env , *this );
2814 indexerScopedMutate( node->result, *this );
2815 maybeMutate_impl ( node->tuple , *this );
2816
2817 MUTATE_END( Expression, node );
2818}
2819
2820//--------------------------------------------------------------------------
2821// TupleAssignExpr
2822template< typename pass_type >
2823void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
2824 VISIT_START( node );
2825
2826 indexerScopedAccept( node->result , *this );
2827 maybeAccept_impl ( node->stmtExpr, *this );
2828
2829 VISIT_END( node );
2830}
2831
2832template< typename pass_type >
2833void PassVisitor< pass_type >::visit( const TupleAssignExpr * node ) {
2834 VISIT_START( node );
2835
2836 indexerScopedAccept( node->result , *this );
2837 maybeAccept_impl( node->stmtExpr, *this );
2838
2839 VISIT_END( node );
2840}
2841
2842template< typename pass_type >
2843Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
2844 MUTATE_START( node );
2845
2846 indexerScopedMutate( node->env , *this );
2847 indexerScopedMutate( node->result , *this );
2848 maybeMutate_impl ( node->stmtExpr, *this );
2849
2850 MUTATE_END( Expression, node );
2851}
2852
2853//--------------------------------------------------------------------------
2854// StmtExpr
2855template< typename pass_type >
2856void PassVisitor< pass_type >::visit( StmtExpr * node ) {
2857 VISIT_START( node );
2858
2859 // don't want statements from outer CompoundStmts to be added to this StmtExpr
2860 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
2861 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2862 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
2863
2864 indexerScopedAccept( node->result , *this );
2865 maybeAccept_impl ( node->statements , *this );
2866 maybeAccept_impl ( node->returnDecls, *this );
2867 maybeAccept_impl ( node->dtors , *this );
2868
2869 VISIT_END( node );
2870}
2871
2872template< typename pass_type >
2873void PassVisitor< pass_type >::visit( const StmtExpr * node ) {
2874 VISIT_START( node );
2875
2876 // don't want statements from outer CompoundStmts to be added to this StmtExpr
2877 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
2878 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2879 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
2880
2881 indexerScopedAccept( node->result , *this );
2882 maybeAccept_impl ( node->statements , *this );
2883 maybeAccept_impl ( node->returnDecls, *this );
2884 maybeAccept_impl ( node->dtors , *this );
2885
2886 VISIT_END( node );
2887}
2888
2889template< typename pass_type >
2890Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
2891 MUTATE_START( node );
2892
2893 // don't want statements from outer CompoundStmts to be added to this StmtExpr
2894 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );
2895 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
2896 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
2897
2898 indexerScopedMutate( node->result , *this );
2899 maybeMutate_impl ( node->statements , *this );
2900 maybeMutate_impl ( node->returnDecls, *this );
2901 maybeMutate_impl ( node->dtors , *this );
2902
2903 MUTATE_END( Expression, node );
2904}
2905
2906//--------------------------------------------------------------------------
2907// UniqueExpr
2908template< typename pass_type >
2909void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
2910 VISIT_START( node );
2911
2912 indexerScopedAccept( node->result, *this );
2913 maybeAccept_impl ( node->expr , *this );
2914
2915 VISIT_END( node );
2916}
2917
2918template< typename pass_type >
2919void PassVisitor< pass_type >::visit( const UniqueExpr * node ) {
2920 VISIT_START( node );
2921
2922 indexerScopedAccept( node->result, *this );
2923 maybeAccept_impl ( node->expr , *this );
2924
2925 VISIT_END( node );
2926}
2927
2928template< typename pass_type >
2929Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
2930 MUTATE_START( node );
2931
2932 indexerScopedMutate( node->env , *this );
2933 indexerScopedMutate( node->result, *this );
2934 maybeMutate_impl ( node->expr , *this );
2935
2936 MUTATE_END( Expression, node );
2937}
2938
2939//--------------------------------------------------------------------------
2940// UntypedInitExpr
2941template< typename pass_type >
2942void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
2943 VISIT_START( node );
2944
2945 indexerScopedAccept( node->result, *this );
2946 maybeAccept_impl ( node->expr , *this );
2947 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2948
2949 VISIT_END( node );
2950}
2951
2952template< typename pass_type >
2953void PassVisitor< pass_type >::visit( const UntypedInitExpr * node ) {
2954 VISIT_START( node );
2955
2956 indexerScopedAccept( node->result, *this );
2957 maybeAccept_impl ( node->expr , *this );
2958 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2959
2960 VISIT_END( node );
2961}
2962
2963template< typename pass_type >
2964Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
2965 MUTATE_START( node );
2966
2967 indexerScopedMutate( node->env , *this );
2968 indexerScopedMutate( node->result, *this );
2969 maybeMutate_impl ( node->expr , *this );
2970 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
2971
2972 MUTATE_END( Expression, node );
2973}
2974
2975//--------------------------------------------------------------------------
2976// InitExpr
2977template< typename pass_type >
2978void PassVisitor< pass_type >::visit( InitExpr * node ) {
2979 VISIT_START( node );
2980
2981 indexerScopedAccept( node->result, *this );
2982 maybeAccept_impl ( node->expr , *this );
2983 maybeAccept_impl ( node->designation, *this );
2984
2985 VISIT_END( node );
2986}
2987
2988template< typename pass_type >
2989void PassVisitor< pass_type >::visit( const InitExpr * node ) {
2990 VISIT_START( node );
2991
2992 indexerScopedAccept( node->result, *this );
2993 maybeAccept_impl ( node->expr , *this );
2994 maybeAccept_impl ( node->designation, *this );
2995
2996 VISIT_END( node );
2997}
2998
2999template< typename pass_type >
3000Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
3001 MUTATE_START( node );
3002
3003 indexerScopedMutate( node->env , *this );
3004 indexerScopedMutate( node->result, *this );
3005 maybeMutate_impl ( node->expr , *this );
3006 maybeMutate_impl ( node->designation, *this );
3007
3008 MUTATE_END( Expression, node );
3009}
3010
3011//--------------------------------------------------------------------------
3012// DeletedExpr
3013template< typename pass_type >
3014void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
3015 VISIT_START( node );
3016
3017 indexerScopedAccept( node->result, *this );
3018 maybeAccept_impl ( node->expr, *this );
3019 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
3020
3021 VISIT_END( node );
3022}
3023
3024template< typename pass_type >
3025void PassVisitor< pass_type >::visit( const DeletedExpr * node ) {
3026 VISIT_START( node );
3027
3028 indexerScopedAccept( node->result, *this );
3029 maybeAccept_impl ( node->expr, *this );
3030 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
3031
3032 VISIT_END( node );
3033}
3034
3035template< typename pass_type >
3036Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
3037 MUTATE_START( node );
3038
3039 indexerScopedMutate( node->env, *this );
3040 indexerScopedMutate( node->result, *this );
3041 maybeMutate_impl( node->expr, *this );
3042
3043 MUTATE_END( Expression, node );
3044}
3045
3046//--------------------------------------------------------------------------
3047// DefaultArgExpr
3048template< typename pass_type >
3049void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) {
3050 VISIT_START( node );
3051
3052 indexerScopedAccept( node->result, *this );
3053 maybeAccept_impl ( node->expr, *this );
3054
3055 VISIT_END( node );
3056}
3057
3058template< typename pass_type >
3059void PassVisitor< pass_type >::visit( const DefaultArgExpr * node ) {
3060 VISIT_START( node );
3061
3062 indexerScopedAccept( node->result, *this );
3063 maybeAccept_impl ( node->expr, *this );
3064
3065 VISIT_END( node );
3066}
3067
3068template< typename pass_type >
3069Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) {
3070 MUTATE_START( node );
3071
3072 indexerScopedMutate( node->env, *this );
3073 indexerScopedMutate( node->result, *this );
3074 maybeMutate_impl( node->expr, *this );
3075
3076 MUTATE_END( Expression, node );
3077}
3078
3079//--------------------------------------------------------------------------
3080// GenericExpr
3081template< typename pass_type >
3082void PassVisitor< pass_type >::visit( GenericExpr * node ) {
3083 VISIT_START( node );
3084
3085 indexerScopedAccept( node->result, *this );
3086 maybeAccept_impl( node->control, *this );
3087 for ( GenericExpr::Association & assoc : node->associations ) {
3088 indexerScopedAccept( assoc.type, *this );
3089 maybeAccept_impl( assoc.expr, *this );
3090 }
3091
3092 VISIT_END( node );
3093}
3094
3095template< typename pass_type >
3096void PassVisitor< pass_type >::visit( const GenericExpr * node ) {
3097 VISIT_START( node );
3098
3099 indexerScopedAccept( node->result, *this );
3100 maybeAccept_impl( node->control, *this );
3101 for ( const GenericExpr::Association & assoc : node->associations ) {
3102 indexerScopedAccept( assoc.type, *this );
3103 maybeAccept_impl( assoc.expr, *this );
3104 }
3105
3106 VISIT_END( node );
3107}
3108
3109template< typename pass_type >
3110Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) {
3111 MUTATE_START( node );
3112
3113 indexerScopedMutate( node->env, *this );
3114 indexerScopedMutate( node->result, *this );
3115 maybeMutate_impl( node->control, *this );
3116 for ( GenericExpr::Association & assoc : node->associations ) {
3117 indexerScopedMutate( assoc.type, *this );
3118 maybeMutate_impl( assoc.expr, *this );
3119 }
3120
3121 MUTATE_END( Expression, node );
3122}
3123
3124//--------------------------------------------------------------------------
3125// VoidType
3126template< typename pass_type >
3127void PassVisitor< pass_type >::visit( VoidType * node ) {
3128 VISIT_START( node );
3129
3130 maybeAccept_impl( node->forall, *this );
3131
3132 VISIT_END( node );
3133}
3134
3135template< typename pass_type >
3136void PassVisitor< pass_type >::visit( const VoidType * node ) {
3137 VISIT_START( node );
3138
3139 maybeAccept_impl( node->forall, *this );
3140
3141 VISIT_END( node );
3142}
3143
3144template< typename pass_type >
3145Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
3146 MUTATE_START( node );
3147
3148 maybeMutate_impl( node->forall, *this );
3149
3150 MUTATE_END( Type, node );
3151}
3152
3153//--------------------------------------------------------------------------
3154// BasicType
3155template< typename pass_type >
3156void PassVisitor< pass_type >::visit( BasicType * node ) {
3157 VISIT_START( node );
3158
3159 maybeAccept_impl( node->forall, *this );
3160
3161 VISIT_END( node );
3162}
3163
3164template< typename pass_type >
3165void PassVisitor< pass_type >::visit( const BasicType * node ) {
3166 VISIT_START( node );
3167
3168 maybeAccept_impl( node->forall, *this );
3169
3170 VISIT_END( node );
3171}
3172
3173template< typename pass_type >
3174Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
3175 MUTATE_START( node );
3176
3177 maybeMutate_impl( node->forall, *this );
3178
3179 MUTATE_END( Type, node );
3180}
3181
3182//--------------------------------------------------------------------------
3183// PointerType
3184template< typename pass_type >
3185void PassVisitor< pass_type >::visit( PointerType * node ) {
3186 VISIT_START( node );
3187
3188 maybeAccept_impl( node->forall, *this );
3189 maybeAccept_impl( node->dimension, *this );
3190 maybeAccept_impl( node->base, *this );
3191
3192 VISIT_END( node );
3193}
3194
3195template< typename pass_type >
3196void PassVisitor< pass_type >::visit( const PointerType * node ) {
3197 VISIT_START( node );
3198
3199 maybeAccept_impl( node->forall, *this );
3200 maybeAccept_impl( node->dimension, *this );
3201 maybeAccept_impl( node->base, *this );
3202
3203 VISIT_END( node );
3204}
3205
3206template< typename pass_type >
3207Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
3208 MUTATE_START( node );
3209
3210 maybeMutate_impl( node->forall, *this );
3211 maybeMutate_impl( node->dimension, *this );
3212 maybeMutate_impl( node->base, *this );
3213
3214 MUTATE_END( Type, node );
3215}
3216
3217//--------------------------------------------------------------------------
3218// ArrayType
3219template< typename pass_type >
3220void PassVisitor< pass_type >::visit( ArrayType * node ) {
3221 VISIT_START( node );
3222
3223 maybeAccept_impl( node->forall, *this );
3224 maybeAccept_impl( node->dimension, *this );
3225 maybeAccept_impl( node->base, *this );
3226
3227 VISIT_END( node );
3228}
3229
3230template< typename pass_type >
3231void PassVisitor< pass_type >::visit( const ArrayType * node ) {
3232 VISIT_START( node );
3233
3234 maybeAccept_impl( node->forall, *this );
3235 maybeAccept_impl( node->dimension, *this );
3236 maybeAccept_impl( node->base, *this );
3237
3238 VISIT_END( node );
3239}
3240
3241template< typename pass_type >
3242Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
3243 MUTATE_START( node );
3244
3245 maybeMutate_impl( node->forall, *this );
3246 maybeMutate_impl( node->dimension, *this );
3247 maybeMutate_impl( node->base, *this );
3248
3249 MUTATE_END( Type, node );
3250}
3251
3252//--------------------------------------------------------------------------
3253// ReferenceType
3254template< typename pass_type >
3255void PassVisitor< pass_type >::visit( ReferenceType * node ) {
3256 VISIT_START( node );
3257
3258 maybeAccept_impl( node->forall, *this );
3259 maybeAccept_impl( node->base, *this );
3260
3261 VISIT_END( node );
3262}
3263
3264template< typename pass_type >
3265void PassVisitor< pass_type >::visit( const ReferenceType * node ) {
3266 VISIT_START( node );
3267
3268 maybeAccept_impl( node->forall, *this );
3269 maybeAccept_impl( node->base, *this );
3270
3271 VISIT_END( node );
3272}
3273
3274template< typename pass_type >
3275Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
3276 MUTATE_START( node );
3277
3278 maybeMutate_impl( node->forall, *this );
3279 maybeMutate_impl( node->base, *this );
3280
3281 MUTATE_END( Type, node );
3282}
3283
3284//--------------------------------------------------------------------------
3285// QualifiedType
3286template< typename pass_type >
3287void PassVisitor< pass_type >::visit( QualifiedType * node ) {
3288 VISIT_START( node );
3289
3290 maybeAccept_impl( node->forall, *this );
3291 maybeAccept_impl( node->parent, *this );
3292 maybeAccept_impl( node->child, *this );
3293
3294 VISIT_END( node );
3295}
3296
3297template< typename pass_type >
3298void PassVisitor< pass_type >::visit( const QualifiedType * node ) {
3299 VISIT_START( node );
3300
3301 maybeAccept_impl( node->forall, *this );
3302 maybeAccept_impl( node->parent, *this );
3303 maybeAccept_impl( node->child, *this );
3304
3305 VISIT_END( node );
3306}
3307
3308template< typename pass_type >
3309Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) {
3310 MUTATE_START( node );
3311
3312 maybeMutate_impl( node->forall, *this );
3313 maybeMutate_impl( node->parent, *this );
3314 maybeMutate_impl( node->child, *this );
3315
3316 MUTATE_END( Type, node );
3317}
3318
3319//--------------------------------------------------------------------------
3320// FunctionType
3321template< typename pass_type >
3322void PassVisitor< pass_type >::visit( FunctionType * node ) {
3323 VISIT_START( node );
3324
3325 maybeAccept_impl( node->forall, *this );
3326 maybeAccept_impl( node->returnVals, *this );
3327 maybeAccept_impl( node->parameters, *this );
3328
3329 VISIT_END( node );
3330}
3331
3332template< typename pass_type >
3333void PassVisitor< pass_type >::visit( const FunctionType * node ) {
3334 VISIT_START( node );
3335
3336 maybeAccept_impl( node->forall, *this );
3337 maybeAccept_impl( node->returnVals, *this );
3338 maybeAccept_impl( node->parameters, *this );
3339
3340 VISIT_END( node );
3341}
3342
3343template< typename pass_type >
3344Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
3345 MUTATE_START( node );
3346
3347 maybeMutate_impl( node->forall, *this );
3348 maybeMutate_impl( node->returnVals, *this );
3349 maybeMutate_impl( node->parameters, *this );
3350
3351 MUTATE_END( Type, node );
3352}
3353
3354//--------------------------------------------------------------------------
3355// StructInstType
3356template< typename pass_type >
3357void PassVisitor< pass_type >::visit( StructInstType * node ) {
3358 VISIT_START( node );
3359
3360 indexerAddStruct( node->name );
3361
3362 {
3363 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3364 maybeAccept_impl( node->forall , *this );
3365 maybeAccept_impl( node->parameters, *this );
3366 }
3367
3368 VISIT_END( node );
3369}
3370
3371template< typename pass_type >
3372void PassVisitor< pass_type >::visit( const StructInstType * node ) {
3373 VISIT_START( node );
3374
3375 indexerAddStruct( node->name );
3376
3377 {
3378 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3379 maybeAccept_impl( node->forall , *this );
3380 maybeAccept_impl( node->parameters, *this );
3381 }
3382
3383 VISIT_END( node );
3384}
3385
3386template< typename pass_type >
3387Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
3388 MUTATE_START( node );
3389
3390 indexerAddStruct( node->name );
3391
3392 {
3393 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3394 maybeMutate_impl( node->forall , *this );
3395 maybeMutate_impl( node->parameters, *this );
3396 }
3397
3398 MUTATE_END( Type, node );
3399}
3400
3401//--------------------------------------------------------------------------
3402// UnionInstType
3403template< typename pass_type >
3404void PassVisitor< pass_type >::visit( UnionInstType * node ) {
3405 VISIT_START( node );
3406
3407 indexerAddUnion( node->name );
3408
3409 {
3410 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3411 maybeAccept_impl( node->forall , *this );
3412 maybeAccept_impl( node->parameters, *this );
3413 }
3414
3415 VISIT_END( node );
3416}
3417
3418template< typename pass_type >
3419void PassVisitor< pass_type >::visit( const UnionInstType * node ) {
3420 VISIT_START( node );
3421
3422 indexerAddUnion( node->name );
3423
3424 {
3425 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3426 maybeAccept_impl( node->forall , *this );
3427 maybeAccept_impl( node->parameters, *this );
3428 }
3429
3430 VISIT_END( node );
3431}
3432
3433template< typename pass_type >
3434Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
3435 MUTATE_START( node );
3436
3437 indexerAddUnion( node->name );
3438
3439 {
3440 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
3441 maybeMutate_impl( node->forall , *this );
3442 maybeMutate_impl( node->parameters, *this );
3443 }
3444
3445 MUTATE_END( Type, node );
3446}
3447
3448//--------------------------------------------------------------------------
3449// EnumInstType
3450template< typename pass_type >
3451void PassVisitor< pass_type >::visit( EnumInstType * node ) {
3452 VISIT_START( node );
3453
3454 maybeAccept_impl( node->forall, *this );
3455 maybeAccept_impl( node->parameters, *this );
3456
3457 VISIT_END( node );
3458}
3459
3460template< typename pass_type >
3461void PassVisitor< pass_type >::visit( const EnumInstType * node ) {
3462 VISIT_START( node );
3463
3464 maybeAccept_impl( node->forall, *this );
3465 maybeAccept_impl( node->parameters, *this );
3466
3467 VISIT_END( node );
3468}
3469
3470template< typename pass_type >
3471Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
3472 MUTATE_START( node );
3473
3474 maybeMutate_impl( node->forall, *this );
3475 maybeMutate_impl( node->parameters, *this );
3476
3477 MUTATE_END( Type, node );
3478}
3479
3480//--------------------------------------------------------------------------
3481// TraitInstType
3482template< typename pass_type >
3483void PassVisitor< pass_type >::visit( TraitInstType * node ) {
3484 VISIT_START( node );
3485
3486 maybeAccept_impl( node->forall , *this );
3487 maybeAccept_impl( node->parameters, *this );
3488
3489 VISIT_END( node );
3490}
3491
3492template< typename pass_type >
3493void PassVisitor< pass_type >::visit( const TraitInstType * node ) {
3494 VISIT_START( node );
3495
3496 maybeAccept_impl( node->forall , *this );
3497 maybeAccept_impl( node->parameters, *this );
3498
3499 VISIT_END( node );
3500}
3501
3502template< typename pass_type >
3503Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
3504 MUTATE_START( node );
3505
3506 maybeMutate_impl( node->forall , *this );
3507 maybeMutate_impl( node->parameters, *this );
3508
3509 MUTATE_END( Type, node );
3510}
3511
3512//--------------------------------------------------------------------------
3513// TypeInstType
3514template< typename pass_type >
3515void PassVisitor< pass_type >::visit( TypeInstType * node ) {
3516 VISIT_START( node );
3517
3518 maybeAccept_impl( node->forall , *this );
3519 maybeAccept_impl( node->parameters, *this );
3520
3521 VISIT_END( node );
3522}
3523
3524template< typename pass_type >
3525void PassVisitor< pass_type >::visit( const TypeInstType * node ) {
3526 VISIT_START( node );
3527
3528 maybeAccept_impl( node->forall , *this );
3529 maybeAccept_impl( node->parameters, *this );
3530
3531 VISIT_END( node );
3532}
3533
3534template< typename pass_type >
3535Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
3536 MUTATE_START( node );
3537
3538 maybeMutate_impl( node->forall , *this );
3539 maybeMutate_impl( node->parameters, *this );
3540
3541 MUTATE_END( Type, node );
3542}
3543
3544//--------------------------------------------------------------------------
3545// TupleType
3546template< typename pass_type >
3547void PassVisitor< pass_type >::visit( TupleType * node ) {
3548 VISIT_START( node );
3549
3550 maybeAccept_impl( node->forall, *this );
3551 maybeAccept_impl( node->types, *this );
3552 maybeAccept_impl( node->members, *this );
3553
3554 VISIT_END( node );
3555}
3556
3557template< typename pass_type >
3558void PassVisitor< pass_type >::visit( const TupleType * node ) {
3559 VISIT_START( node );
3560
3561 maybeAccept_impl( node->forall, *this );
3562 maybeAccept_impl( node->types, *this );
3563 maybeAccept_impl( node->members, *this );
3564
3565 VISIT_END( node );
3566}
3567
3568template< typename pass_type >
3569Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
3570 MUTATE_START( node );
3571
3572 maybeMutate_impl( node->forall, *this );
3573 maybeMutate_impl( node->types, *this );
3574 maybeMutate_impl( node->members, *this );
3575
3576 MUTATE_END( Type, node );
3577}
3578
3579//--------------------------------------------------------------------------
3580// TypeofType
3581template< typename pass_type >
3582void PassVisitor< pass_type >::visit( TypeofType * node ) {
3583 VISIT_START( node );
3584
3585 assert( node->expr );
3586 maybeAccept_impl( node->expr, *this );
3587
3588 VISIT_END( node );
3589}
3590
3591template< typename pass_type >
3592void PassVisitor< pass_type >::visit( const TypeofType * node ) {
3593 VISIT_START( node );
3594
3595 assert( node->expr );
3596 maybeAccept_impl( node->expr, *this );
3597
3598 VISIT_END( node );
3599}
3600
3601template< typename pass_type >
3602Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
3603 MUTATE_START( node );
3604
3605 assert( node->expr );
3606 maybeMutate_impl( node->expr, *this );
3607
3608 MUTATE_END( Type, node );
3609}
3610
3611//--------------------------------------------------------------------------
3612// VTableType
3613template< typename pass_type >
3614void PassVisitor< pass_type >::visit( VTableType * node ) {
3615 VISIT_START( node );
3616
3617 // Forall qualifiers should be on base type, not here
3618 // maybeAccept_impl( node->forall, *this );
3619 maybeAccept_impl( node->base, *this );
3620
3621 VISIT_END( node );
3622}
3623
3624template< typename pass_type >
3625void PassVisitor< pass_type >::visit( const VTableType * node ) {
3626 VISIT_START( node );
3627
3628 // Forall qualifiers should be on base type, not here
3629 // maybeAccept_impl( node->forall, *this );
3630 maybeAccept_impl( node->base, *this );
3631
3632 VISIT_END( node );
3633}
3634
3635template< typename pass_type >
3636Type * PassVisitor< pass_type >::mutate( VTableType * node ) {
3637 MUTATE_START( node );
3638
3639 // Forall qualifiers should be on base type, not here
3640 // maybeMutate_impl( node->forall, *this );
3641 maybeMutate_impl( node->base, *this );
3642
3643 MUTATE_END( Type, node );
3644}
3645
3646//--------------------------------------------------------------------------
3647// AttrType
3648template< typename pass_type >
3649void PassVisitor< pass_type >::visit( AttrType * node ) {
3650 VISIT_START( node );
3651
3652 if ( node->isType ) {
3653 assert( node->type );
3654 maybeAccept_impl( node->type, *this );
3655 } else {
3656 assert( node->expr );
3657 maybeAccept_impl( node->expr, *this );
3658 } // if
3659
3660 VISIT_END( node );
3661}
3662
3663template< typename pass_type >
3664void PassVisitor< pass_type >::visit( const AttrType * node ) {
3665 VISIT_START( node );
3666
3667 if ( node->isType ) {
3668 assert( node->type );
3669 maybeAccept_impl( node->type, *this );
3670 } else {
3671 assert( node->expr );
3672 maybeAccept_impl( node->expr, *this );
3673 } // if
3674
3675 VISIT_END( node );
3676}
3677
3678template< typename pass_type >
3679Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
3680 MUTATE_START( node );
3681
3682 if ( node->isType ) {
3683 assert( node->type );
3684 maybeMutate_impl( node->type, *this );
3685 } else {
3686 assert( node->expr );
3687 maybeMutate_impl( node->expr, *this );
3688 } // if
3689
3690 MUTATE_END( Type, node );
3691}
3692
3693//--------------------------------------------------------------------------
3694// VarArgsType
3695template< typename pass_type >
3696void PassVisitor< pass_type >::visit( VarArgsType * node ) {
3697 VISIT_START( node );
3698
3699 maybeAccept_impl( node->forall, *this );
3700
3701 VISIT_END( node );
3702}
3703
3704template< typename pass_type >
3705void PassVisitor< pass_type >::visit( const VarArgsType * node ) {
3706 VISIT_START( node );
3707
3708 maybeAccept_impl( node->forall, *this );
3709
3710 VISIT_END( node );
3711}
3712
3713template< typename pass_type >
3714Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
3715 MUTATE_START( node );
3716
3717 maybeMutate_impl( node->forall, *this );
3718
3719 MUTATE_END( Type, node );
3720}
3721
3722//--------------------------------------------------------------------------
3723// ZeroType
3724template< typename pass_type >
3725void PassVisitor< pass_type >::visit( ZeroType * node ) {
3726 VISIT_START( node );
3727
3728 maybeAccept_impl( node->forall, *this );
3729
3730 VISIT_END( node );
3731}
3732
3733template< typename pass_type >
3734void PassVisitor< pass_type >::visit( const ZeroType * node ) {
3735 VISIT_START( node );
3736
3737 maybeAccept_impl( node->forall, *this );
3738
3739 VISIT_END( node );
3740}
3741
3742template< typename pass_type >
3743Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
3744 MUTATE_START( node );
3745
3746 maybeMutate_impl( node->forall, *this );
3747
3748 MUTATE_END( Type, node );
3749}
3750
3751//--------------------------------------------------------------------------
3752// OneType
3753template< typename pass_type >
3754void PassVisitor< pass_type >::visit( OneType * node ) {
3755 VISIT_START( node );
3756
3757 maybeAccept_impl( node->forall, *this );
3758
3759 VISIT_END( node );
3760}
3761
3762template< typename pass_type >
3763void PassVisitor< pass_type >::visit( const OneType * node ) {
3764 VISIT_START( node );
3765
3766 maybeAccept_impl( node->forall, *this );
3767
3768 VISIT_END( node );
3769}
3770
3771template< typename pass_type >
3772Type * PassVisitor< pass_type >::mutate( OneType * node ) {
3773 MUTATE_START( node );
3774
3775 maybeMutate_impl( node->forall, *this );
3776
3777 MUTATE_END( Type, node );
3778}
3779
3780//--------------------------------------------------------------------------
3781// GlobalScopeType
3782template< typename pass_type >
3783void PassVisitor< pass_type >::visit( GlobalScopeType * node ) {
3784 VISIT_START( node );
3785
3786 maybeAccept_impl( node->forall, *this );
3787
3788 VISIT_END( node );
3789}
3790
3791template< typename pass_type >
3792void PassVisitor< pass_type >::visit( const GlobalScopeType * node ) {
3793 VISIT_START( node );
3794
3795 maybeAccept_impl( node->forall, *this );
3796
3797 VISIT_END( node );
3798}
3799
3800template< typename pass_type >
3801Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) {
3802 MUTATE_START( node );
3803
3804 maybeMutate_impl( node->forall, *this );
3805
3806 MUTATE_END( Type, node );
3807}
3808
3809//--------------------------------------------------------------------------
3810// Designation
3811template< typename pass_type >
3812void PassVisitor< pass_type >::visit( Designation * node ) {
3813 VISIT_START( node );
3814
3815 maybeAccept_impl( node->designators, *this );
3816
3817 VISIT_END( node );
3818}
3819
3820template< typename pass_type >
3821void PassVisitor< pass_type >::visit( const Designation * node ) {
3822 VISIT_START( node );
3823
3824 maybeAccept_impl( node->designators, *this );
3825
3826 VISIT_END( node );
3827}
3828
3829template< typename pass_type >
3830Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
3831 MUTATE_START( node );
3832
3833 maybeMutate_impl( node->designators, *this );
3834
3835 MUTATE_END( Designation, node );
3836}
3837
3838//--------------------------------------------------------------------------
3839// SingleInit
3840template< typename pass_type >
3841void PassVisitor< pass_type >::visit( SingleInit * node ) {
3842 VISIT_START( node );
3843
3844 visitExpression( node->value );
3845
3846 VISIT_END( node );
3847}
3848
3849template< typename pass_type >
3850void PassVisitor< pass_type >::visit( const SingleInit * node ) {
3851 VISIT_START( node );
3852
3853 visitExpression( node->value );
3854
3855 VISIT_END( node );
3856}
3857
3858template< typename pass_type >
3859Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
3860 MUTATE_START( node );
3861
3862 node->value = mutateExpression( node->value );
3863
3864 MUTATE_END( Initializer, node );
3865}
3866
3867//--------------------------------------------------------------------------
3868// ListInit
3869template< typename pass_type >
3870void PassVisitor< pass_type >::visit( ListInit * node ) {
3871 VISIT_START( node );
3872
3873 maybeAccept_impl( node->designations, *this );
3874 maybeAccept_impl( node->initializers, *this );
3875
3876 VISIT_END( node );
3877}
3878
3879template< typename pass_type >
3880void PassVisitor< pass_type >::visit( const ListInit * node ) {
3881 VISIT_START( node );
3882
3883 maybeAccept_impl( node->designations, *this );
3884 maybeAccept_impl( node->initializers, *this );
3885
3886 VISIT_END( node );
3887}
3888
3889template< typename pass_type >
3890Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
3891 MUTATE_START( node );
3892
3893 maybeMutate_impl( node->designations, *this );
3894 maybeMutate_impl( node->initializers, *this );
3895
3896 MUTATE_END( Initializer, node );
3897}
3898
3899//--------------------------------------------------------------------------
3900// ConstructorInit
3901template< typename pass_type >
3902void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
3903 VISIT_START( node );
3904
3905 maybeAccept_impl( node->ctor, *this );
3906 maybeAccept_impl( node->dtor, *this );
3907 maybeAccept_impl( node->init, *this );
3908
3909 VISIT_END( node );
3910}
3911
3912template< typename pass_type >
3913void PassVisitor< pass_type >::visit( const ConstructorInit * node ) {
3914 VISIT_START( node );
3915
3916 maybeAccept_impl( node->ctor, *this );
3917 maybeAccept_impl( node->dtor, *this );
3918 maybeAccept_impl( node->init, *this );
3919
3920 VISIT_END( node );
3921}
3922
3923template< typename pass_type >
3924Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
3925 MUTATE_START( node );
3926
3927 maybeMutate_impl( node->ctor, *this );
3928 maybeMutate_impl( node->dtor, *this );
3929 maybeMutate_impl( node->init, *this );
3930
3931 MUTATE_END( Initializer, node );
3932}
3933
3934//--------------------------------------------------------------------------
3935// Constant
3936template< typename pass_type >
3937void PassVisitor< pass_type >::visit( Constant * node ) {
3938 VISIT_START( node );
3939
3940 VISIT_END( node );
3941}
3942
3943template< typename pass_type >
3944void PassVisitor< pass_type >::visit( const Constant * node ) {
3945 VISIT_START( node );
3946
3947 VISIT_END( node );
3948}
3949
3950template< typename pass_type >
3951Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
3952 MUTATE_START( node );
3953
3954 MUTATE_END( Constant, node );
3955}
3956
3957//--------------------------------------------------------------------------
3958// Attribute
3959template< typename pass_type >
3960void PassVisitor< pass_type >::visit( Attribute * node ) {
3961 VISIT_START( node );
3962
3963 maybeAccept_impl( node->parameters, *this );
3964
3965 VISIT_END( node );
3966}
3967
3968template< typename pass_type >
3969void PassVisitor< pass_type >::visit( const Attribute * node ) {
3970 VISIT_START( node );
3971
3972 maybeAccept_impl( node->parameters, *this );
3973
3974 VISIT_END( node );
3975}
3976
3977template< typename pass_type >
3978Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
3979 MUTATE_START( node );
3980
3981 maybeMutate_impl( node->parameters, *this );
3982
3983 MUTATE_END( Attribute, node );
3984}
3985
3986//--------------------------------------------------------------------------
3987// TypeSubstitution
3988template< typename pass_type >
3989TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
3990 MUTATE_START( node );
3991
3992 for ( auto & p : node->typeEnv ) {
3993 indexerScopedMutate( p.second, *this );
3994 }
3995 for ( auto & p : node->varEnv ) {
3996 indexerScopedMutate( p.second, *this );
3997 }
3998
3999 MUTATE_END( TypeSubstitution, node );
4000}
4001
4002#undef VISIT_START
4003#undef VISIT_END
4004
4005#undef MUTATE_START
4006#undef MUTATE_END
Note: See TracBrowser for help on using the repository browser.