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

ADT
Last change on this file since d6c464d was 561354f, checked in by JiadaL <j82liang@…>, 2 years ago

Save progress

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