source: src/Common/PassVisitor.impl.h @ 1830a86

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 1830a86 was 6a45bd78, checked in by Fangren Yu <f37yu@…>, 4 years ago

cleanup: remove params in TypeDecl? (never used)

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