source: src/Common/PassVisitor.impl.h @ 1f7dc61

ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change on this file since 1f7dc61 was 3b0bc16, checked in by Peter A. Buhr <pabuhr@…>, 2 years ago

change class name WhileStmt? to WhileDoStmt?, add else clause to WhileDoStmt? and ForStmt?, change names thenPart/ElsePart to then/else_

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