source: src/Common/PassVisitor.impl.h @ 1784e9e

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since 1784e9e was 4559b34, checked in by JiadaL <j82liang@…>, 2 years ago

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

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