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

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

Update the String Enum implementation. The declaration now can handles creating the enum decl. But the compilation fails when trying to create reference to the Enum. Need a way to resolve InstTypes

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