source: src/Common/PassVisitor.impl.h @ 28f8f15

ADT
Last change on this file since 28f8f15 was 28f8f15, checked in by JiadaL <j82liang@…>, 13 months ago

Save progress

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