source: src/Common/PassVisitor.impl.h @ 2cb70aa

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 2cb70aa was 2cb70aa, checked in by Rob Schluntz <rschlunt@…>, 5 years ago

Move Indexer unnamed object check into addId

  • Property mode set to 100644
File size: 64.8 KB
Line 
1#pragma once
2// IWYU pragma: private, include "PassVisitor.h"
3
4#define VISIT_START( node )                                     \
5        __attribute__((unused))                                   \
6        ChildrenGuard children_guard( get_visit_children_ptr() ); \
7        __attribute__((unused))                                   \
8        guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
9        call_previsit( node );                                    \
10
11#define VISIT_END( node )                       \
12        call_postvisit( node );                   \
13
14#define MUTATE_START( node )                                    \
15        __attribute__((unused))                                   \
16        ChildrenGuard children_guard( get_visit_children_ptr() ); \
17        __attribute__((unused))                                   \
18        guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
19        call_premutate( node );                                   \
20
21#define MUTATE_END( type, node )                \
22        return call_postmutate< type * >( node ); \
23
24
25#define VISIT_BODY( node )          \
26        VISIT_START( node );          \
27        if( children_guard ) {        \
28                Visitor::visit( node ); \
29        }                             \
30        VISIT_END( node );            \
31
32
33#define MUTATE_BODY( type, node )    \
34        MUTATE_START( node );          \
35        if( children_guard ) {         \
36                Mutator::mutate( node ); \
37        }                              \
38        MUTATE_END( type, node );      \
39
40
41
42template<typename T>
43static inline bool empty( T * ptr ) {
44        return !ptr || ptr->empty();
45}
46
47typedef std::list< Statement   * > StmtList_t;
48typedef std::list< Declaration * > DeclList_t;
49
50template<typename iterator_t>
51static inline void splice( iterator_t it, DeclList_t * decls ) {
52        std::transform(
53                decls->begin(),
54                decls->end(),
55                it,
56                [](Declaration * decl) -> auto {
57                        return new DeclStmt( decl );
58                }
59        );
60        decls->clear();
61}
62
63template< typename pass_type >
64inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
65        DeclList_t* beforeDecls = visitor.get_beforeDecls();
66        DeclList_t* afterDecls  = visitor.get_afterDecls();
67        SemanticError errors;
68
69        for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
70                // splice in new declarations after previous decl
71                if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
72
73                if ( i == decls.end() ) break;
74
75                try {
76                        // run visitor on declaration
77                        maybeAccept_impl( *i, visitor );
78                } catch( SemanticError &e ) {
79                        e.set_location( (*i)->location );
80                        errors.append( e );
81                }
82
83                // splice in new declarations before current decl
84                if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
85        }
86        if ( ! errors.isEmpty() ) {
87                throw errors;
88        }
89}
90
91template< typename pass_type >
92inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
93        DeclList_t* beforeDecls = mutator.get_beforeDecls();
94        DeclList_t* afterDecls  = mutator.get_afterDecls();
95        SemanticError errors;
96
97        for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
98                // splice in new declarations after previous decl
99                if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
100
101                if ( i == decls.end() ) break;
102                try {
103                        // run mutator on declaration
104                        maybeMutate_impl( *i, mutator );
105                } catch( SemanticError &e ) {
106                        e.set_location( (*i)->location );
107                        errors.append( e );
108                }
109
110                // splice in new declarations before current decl
111                if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
112        }
113        if ( ! errors.isEmpty() ) {
114                throw errors;
115        }
116}
117
118template< typename TreeType, typename pass_type >
119inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
120        if ( ! visitor.get_visit_children() ) return;
121        if ( tree ) {
122                tree->accept( visitor );
123        }
124}
125
126template< typename Container, typename pass_type >
127inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
128        if ( ! visitor.get_visit_children() ) return;
129        SemanticError errors;
130        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
131                try {
132                        if ( *i ) {
133                                (*i)->accept( visitor );
134                        }
135                } catch( SemanticError &e ) {
136                        e.set_location( (*i)->location );
137                        errors.append( e );
138                }
139        }
140        if ( ! errors.isEmpty() ) {
141                throw errors;
142        }
143}
144
145template< typename TreeType, typename pass_type >
146inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
147        if ( ! mutator.get_visit_children() ) return;
148
149        if ( tree ) {
150                tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
151        }
152}
153
154template< typename Container, typename pass_type >
155inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
156        if ( ! mutator.get_visit_children() ) return;
157        SemanticError errors;
158        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
159                try {
160                        if ( *i ) {
161                                *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
162                                assert( *i );
163                        } // if
164                } catch( SemanticError &e ) {
165                        e.set_location( (*i)->location );
166                        errors.append( e );
167                } // try
168        } // for
169        if ( ! errors.isEmpty() ) {
170                throw errors;
171        } // if
172}
173
174template< typename pass_type >
175template< typename func_t >
176void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
177        if ( ! get_visit_children() ) return;
178        SemanticError errors;
179
180        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
181        ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
182        ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
183        ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
184        ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
185
186        StmtList_t* beforeStmts = get_beforeStmts();
187        StmtList_t* afterStmts  = get_afterStmts();
188        DeclList_t* beforeDecls = get_beforeDecls();
189        DeclList_t* afterDecls  = get_afterDecls();
190
191        for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
192
193                if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }
194                if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
195
196                try {
197                        func( *i );
198                        assert(( empty( beforeStmts ) && empty( afterStmts ))
199                            || ( empty( beforeDecls ) && empty( afterDecls )) );
200
201                } catch ( SemanticError &e ) {
202                        e.set_location( (*i)->location );
203                        errors.append( e );
204                }
205
206                if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }
207                if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
208        }
209
210        if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
211        if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
212        if ( !errors.isEmpty() ) { throw errors; }
213}
214
215template< typename pass_type >
216void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
217        handleStatementList( statements, [this]( Statement * stmt) {
218                maybeAccept_impl( stmt, *this );
219        });
220}
221
222template< typename pass_type >
223void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
224        handleStatementList( statements, [this]( Statement *& stmt) {
225                maybeMutate_impl( stmt, *this );
226        });
227}
228
229
230template< typename pass_type >
231template< typename func_t >
232Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
233        if ( ! get_visit_children() ) return stmt;
234
235        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
236        ValueGuardPtr< TypeSubstitution * >  oldEnv        ( get_env_ptr    () );
237        ValueGuardPtr< DeclList_t >          oldBeforeDecls( get_beforeDecls() );
238        ValueGuardPtr< DeclList_t >          oldAfterDecls ( get_afterDecls () );
239        ValueGuardPtr< StmtList_t >          oldBeforeStmts( get_beforeStmts() );
240        ValueGuardPtr< StmtList_t >          oldAfterStmts ( get_afterStmts () );
241
242        Statement *newStmt = func( stmt );
243
244        StmtList_t* beforeStmts = get_beforeStmts();
245        StmtList_t* afterStmts  = get_afterStmts();
246        DeclList_t* beforeDecls = get_beforeDecls();
247        DeclList_t* afterDecls  = get_afterDecls();
248
249        if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; }
250        assert(( empty( beforeStmts ) && empty( afterStmts ))
251            || ( empty( beforeDecls ) && empty( afterDecls )) );
252
253        CompoundStmt *compound = new CompoundStmt();
254        if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); }
255        if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
256        compound->get_kids().push_back( newStmt );
257        if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }
258        if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
259        return compound;
260}
261
262template< typename pass_type >
263Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
264        return handleStatement( stmt, [this]( Statement * stmt ) {
265                maybeAccept_impl( stmt, *this );
266                return stmt;
267        });
268}
269
270template< typename pass_type >
271Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
272        return handleStatement( stmt, [this]( Statement * stmt ) {
273                maybeMutate_impl( stmt, *this );
274                return stmt;
275        });
276}
277
278template< typename pass_type >
279template< typename func_t >
280Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
281        if ( ! get_visit_children() ) return expr;
282        if( !expr ) return nullptr;
283
284        auto env_ptr = get_env_ptr();
285        if ( env_ptr && expr->get_env() ) {
286                *env_ptr = expr->get_env();
287        }
288
289        // should env be moved onto the result of the mutate?
290        return func( expr );
291}
292
293template< typename pass_type >
294Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
295        return handleExpression(expr, [this]( Expression * expr ) {
296                maybeAccept_impl( expr, *this );
297                return expr;
298        });
299}
300
301template< typename pass_type >
302Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
303        return handleExpression(expr, [this]( Expression * expr ) {
304                maybeMutate_impl( expr, *this );
305                return expr;
306        });
307}
308
309template< typename TreeType, typename VisitorType >
310inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
311        if ( ! visitor.get_visit_children() ) return;
312        auto guard = makeFuncGuard(
313                [&visitor]() { visitor.indexerScopeEnter(); },
314                [&visitor]() { visitor.indexerScopeLeave(); }
315        );
316        maybeAccept_impl( tree, visitor );
317}
318
319template< typename TreeType, typename MutatorType >
320inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
321        if ( ! mutator.get_visit_children() ) return;
322        auto guard = makeFuncGuard(
323                [&mutator]() { mutator.indexerScopeEnter(); },
324                [&mutator]() { mutator.indexerScopeLeave(); }
325        );
326        maybeMutate_impl( tree, mutator );
327}
328
329//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
330//========================================================================================================================================================================
331//========================================================================================================================================================================
332//========================================================================================================================================================================
333//========================================================================================================================================================================
334//========================================================================================================================================================================
335//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
336
337// A NOTE ON THE ORDER OF TRAVERSAL
338//
339// Types and typedefs have their base types visited before they are added to the type table.  This is ok, since there is
340// no such thing as a recursive type or typedef.
341//
342//             typedef struct { T *x; } T; // never allowed
343//
344// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
345// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
346// declaration).
347//
348//             struct T { struct T *x; }; // allowed
349//
350// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
351// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
352// queried later in this pass.
353//
354// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
355
356//--------------------------------------------------------------------------
357// ObjectDecl
358template< typename pass_type >
359void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
360        VISIT_START( node );
361
362        indexerScopedAccept( node->type         , *this );
363        maybeAccept_impl   ( node->init         , *this );
364        maybeAccept_impl   ( node->bitfieldWidth, *this );
365        maybeAccept_impl   ( node->attributes   , *this );
366
367        indexerAddId( node );
368
369        VISIT_END( node );
370}
371
372template< typename pass_type >
373DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) {
374        MUTATE_START( node );
375
376        indexerScopedMutate( node->type         , *this );
377        maybeMutate_impl   ( node->init         , *this );
378        maybeMutate_impl   ( node->bitfieldWidth, *this );
379        maybeMutate_impl   ( node->attributes   , *this );
380
381        indexerAddId( node );
382
383        MUTATE_END( DeclarationWithType, node );
384}
385
386//--------------------------------------------------------------------------
387// FunctionDecl
388template< typename pass_type >
389void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
390        VISIT_START( node );
391
392        indexerAddId( node );
393
394        {
395                // with clause introduces a level of scope (for the with expression members).
396                // with clause exprs are added to the indexer before parameters so that parameters
397                // shadow with exprs and not the other way around.
398                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
399                // implicit add __func__ identifier as specified in the C manual 6.4.2.2
400                static ObjectDecl func(
401                        "__func__", noStorageClasses, LinkageSpec::C, nullptr,
402                        new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
403                        nullptr
404                );
405                indexerAddId( &func );
406                maybeAccept_impl( node->type, *this );
407                maybeAccept_impl( node->statements, *this );
408                maybeAccept_impl( node->attributes, *this );
409        }
410
411        VISIT_END( node );
412}
413
414template< typename pass_type >
415DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
416        MUTATE_START( node );
417
418        indexerAddId( node );
419
420        {
421                // with clause introduces a level of scope (for the with expression members).
422                // with clause exprs are added to the indexer before parameters so that parameters
423                // shadow with exprs and not the other way around.
424                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
425                // implicit add __func__ identifier as specified in the C manual 6.4.2.2
426                static ObjectDecl func(
427                        "__func__", noStorageClasses, LinkageSpec::C, nullptr,
428                        new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
429                        nullptr
430                );
431                indexerAddId( &func );
432                maybeMutate_impl( node->type, *this );
433                maybeMutate_impl( node->statements, *this );
434                maybeMutate_impl( node->attributes, *this );
435        }
436
437        MUTATE_END( DeclarationWithType, node );
438}
439
440//--------------------------------------------------------------------------
441// StructDecl
442template< typename pass_type >
443void PassVisitor< pass_type >::visit( StructDecl * node ) {
444        VISIT_START( node );
445
446        // make up a forward declaration and add it before processing the members
447        // needs to be on the heap because addStruct saves the pointer
448        indexerAddStructFwd( node );
449
450        {
451                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
452                maybeAccept_impl( node->parameters, *this );
453                maybeAccept_impl( node->members   , *this );
454        }
455
456        // this addition replaces the forward declaration
457        indexerAddStruct( node );
458
459        VISIT_END( node );
460}
461
462template< typename pass_type >
463Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
464        MUTATE_START( node );
465
466        // make up a forward declaration and add it before processing the members
467        // needs to be on the heap because addStruct saves the pointer
468        indexerAddStructFwd( node );
469
470        {
471                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
472                maybeMutate_impl( node->parameters, *this );
473                maybeMutate_impl( node->members   , *this );
474        }
475
476        // this addition replaces the forward declaration
477        indexerAddStruct( node );
478
479        MUTATE_END( Declaration, node );
480}
481
482//--------------------------------------------------------------------------
483// UnionDecl
484template< typename pass_type >
485void PassVisitor< pass_type >::visit( UnionDecl * node ) {
486        VISIT_START( node );
487
488        // make up a forward declaration and add it before processing the members
489        indexerAddUnionFwd( node );
490
491        {
492                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
493                maybeAccept_impl( node->parameters, *this );
494                maybeAccept_impl( node->members   , *this );
495        }
496
497        indexerAddUnion( node );
498
499        VISIT_END( node );
500}
501
502template< typename pass_type >
503Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
504        MUTATE_START( node );
505
506        // make up a forward declaration and add it before processing the members
507        indexerAddUnionFwd( node );
508
509        {
510                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
511                maybeMutate_impl( node->parameters, *this );
512                maybeMutate_impl( node->members   , *this );
513        }
514
515        indexerAddUnion( node );
516
517        MUTATE_END( Declaration, node );
518}
519
520//--------------------------------------------------------------------------
521// EnumDecl
522template< typename pass_type >
523void PassVisitor< pass_type >::visit( EnumDecl * node ) {
524        VISIT_START( node );
525
526        indexerAddEnum( node );
527
528        // unlike structs, traits, and unions, enums inject their members into the global scope
529        maybeAccept_impl( node->parameters, *this );
530        maybeAccept_impl( node->members   , *this );
531
532        VISIT_END( node );
533}
534
535template< typename pass_type >
536Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
537        MUTATE_START( node );
538
539        indexerAddEnum( node );
540
541        // unlike structs, traits, and unions, enums inject their members into the global scope
542        maybeMutate_impl( node->parameters, *this );
543        maybeMutate_impl( node->members   , *this );
544
545        MUTATE_END( Declaration, node );
546}
547
548//--------------------------------------------------------------------------
549// TraitDecl
550template< typename pass_type >
551void PassVisitor< pass_type >::visit( TraitDecl * node ) {
552        VISIT_START( node );
553
554        {
555                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
556                maybeAccept_impl( node->parameters, *this );
557                maybeAccept_impl( node->members   , *this );
558        }
559
560        indexerAddTrait( node );
561
562        VISIT_END( node );
563}
564
565template< typename pass_type >
566Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
567        MUTATE_START( node );
568
569        {
570                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
571                maybeMutate_impl( node->parameters, *this );
572                maybeMutate_impl( node->members   , *this );
573        }
574
575        indexerAddTrait( node );
576
577        MUTATE_END( Declaration, node );
578}
579
580//--------------------------------------------------------------------------
581// TypeDecl
582template< typename pass_type >
583void PassVisitor< pass_type >::visit( TypeDecl * node ) {
584        VISIT_START( node );
585
586        {
587                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
588                maybeAccept_impl( node->parameters, *this );
589                maybeAccept_impl( node->base      , *this );
590        }
591
592        // see A NOTE ON THE ORDER OF TRAVERSAL, above
593        // note that assertions come after the type is added to the symtab, since they are not part of the type proper
594        // and may depend on the type itself
595        indexerAddType( node );
596
597        maybeAccept_impl( node->assertions, *this );
598
599        indexerScopedAccept( node->init, *this );
600
601        VISIT_END( node );
602}
603
604template< typename pass_type >
605Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
606        MUTATE_START( node );
607
608        {
609                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
610                maybeMutate_impl( node->parameters, *this );
611                maybeMutate_impl( node->base      , *this );
612        }
613
614        // see A NOTE ON THE ORDER OF TRAVERSAL, above
615        // note that assertions come after the type is added to the symtab, since they are not part of the type proper
616        // and may depend on the type itself
617        indexerAddType( node );
618
619        maybeMutate_impl( node->assertions, *this );
620
621        indexerScopedMutate( node->init, *this );
622
623        MUTATE_END( Declaration, node );
624}
625
626//--------------------------------------------------------------------------
627// TypedefDecl
628template< typename pass_type >
629void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
630        VISIT_START( node );
631
632        {
633                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
634                maybeAccept_impl( node->parameters, *this );
635                maybeAccept_impl( node->base      , *this );
636        }
637
638        indexerAddType( node );
639
640        maybeAccept_impl( node->assertions, *this );
641
642        VISIT_END( node );
643}
644
645template< typename pass_type >
646Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
647        MUTATE_START( node );
648
649        {
650                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
651                maybeMutate_impl( node->parameters, *this );
652                maybeMutate_impl( node->base      , *this );
653        }
654
655        indexerAddType( node );
656
657        maybeMutate_impl( node->assertions, *this );
658
659        MUTATE_END( Declaration, node );
660}
661
662//--------------------------------------------------------------------------
663// AsmDecl
664template< typename pass_type >
665void PassVisitor< pass_type >::visit( AsmDecl * node ) {
666        VISIT_START( node );
667
668        maybeAccept_impl( node->stmt, *this );
669
670        VISIT_END( node );
671}
672
673template< typename pass_type >
674AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
675        MUTATE_START( node );
676
677        maybeMutate_impl( node->stmt, *this );
678
679        MUTATE_END( AsmDecl, node );
680}
681
682//--------------------------------------------------------------------------
683// CompoundStmt
684template< typename pass_type >
685void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
686        VISIT_START( node );
687        {
688                auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
689                auto guard2 = makeFuncGuard( [this]() { call_beginScope();   }, [this]() { call_endScope();     } );
690                visitStatementList( node->kids );
691        }
692        VISIT_END( node );
693}
694
695template< typename pass_type >
696CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
697        MUTATE_START( node );
698        {
699                auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
700                auto guard2 = makeFuncGuard( [this]() { call_beginScope();   }, [this]() { call_endScope();     } );
701                mutateStatementList( node->kids );
702        }
703        MUTATE_END( CompoundStmt, node );
704}
705
706//--------------------------------------------------------------------------
707// ExprStmt
708template< typename pass_type >
709void PassVisitor< pass_type >::visit( ExprStmt * node ) {
710        VISIT_START( node );
711
712        visitExpression( node->expr );
713
714        VISIT_END( node );
715}
716
717template< typename pass_type >
718Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
719        MUTATE_START( node );
720
721        node->expr = mutateExpression( node->expr );
722
723        MUTATE_END( Statement, node );
724}
725
726//--------------------------------------------------------------------------
727// AsmStmt
728template< typename pass_type >
729void PassVisitor< pass_type >::visit( AsmStmt * node ) {
730        VISIT_BODY( node );
731}
732
733template< typename pass_type >
734Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
735        MUTATE_BODY( Statement, node );
736}
737
738//--------------------------------------------------------------------------
739// IfStmt
740template< typename pass_type >
741void PassVisitor< pass_type >::visit( IfStmt * node ) {
742        VISIT_START( node );
743        {
744                // if statements introduce a level of scope (for the initialization)
745                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
746                maybeAccept_impl( node->get_initialization(), *this );
747                visitExpression ( node->condition );
748                node->thenPart = visitStatement( node->thenPart );
749                node->elsePart = visitStatement( node->elsePart );
750        }
751        VISIT_END( node );
752}
753
754template< typename pass_type >
755Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
756        MUTATE_START( node );
757        {
758                // if statements introduce a level of scope (for the initialization)
759                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
760                maybeMutate_impl( node->get_initialization(), *this );
761                node->condition = mutateExpression( node->condition );
762                node->thenPart  = mutateStatement ( node->thenPart  );
763                node->elsePart  = mutateStatement ( node->elsePart  );
764        }
765        MUTATE_END( Statement, node );
766}
767
768//--------------------------------------------------------------------------
769// WhileStmt
770template< typename pass_type >
771void PassVisitor< pass_type >::visit( WhileStmt * node ) {
772        VISIT_START( node );
773
774        visitExpression( node->condition );
775        node->body = visitStatement( node->body );
776
777        VISIT_END( node );
778}
779
780template< typename pass_type >
781Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
782        MUTATE_START( node );
783
784        node->condition = mutateExpression( node->condition );
785        node->body      = mutateStatement ( node->body      );
786
787        MUTATE_END( Statement, node );
788}
789
790//--------------------------------------------------------------------------
791// ForStmt
792template< typename pass_type >
793void PassVisitor< pass_type >::visit( ForStmt * node ) {
794        VISIT_START( node );
795        {
796                // for statements introduce a level of scope (for the initialization)
797                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
798                maybeAccept_impl( node->initialization, *this );
799                visitExpression( node->condition );
800                visitExpression( node->increment );
801                node->body = visitStatement( node->body );
802        }
803        VISIT_END( node );
804}
805
806template< typename pass_type >
807Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
808        MUTATE_START( node );
809        {
810                // for statements introduce a level of scope (for the initialization)
811                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
812                maybeMutate_impl( node->initialization, *this );
813                node->condition = mutateExpression( node->condition );
814                node->increment = mutateExpression( node->increment );
815                node->body      = mutateStatement ( node->body      );
816        }
817        MUTATE_END( Statement, node );
818}
819
820//--------------------------------------------------------------------------
821// SwitchStmt
822template< typename pass_type >
823void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
824        VISIT_START( node );
825
826        visitExpression   ( node->condition  );
827        visitStatementList( node->statements );
828
829        VISIT_END( node );
830}
831
832template< typename pass_type >
833Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
834        MUTATE_START( node );
835
836        node->condition = mutateExpression( node->condition );
837        mutateStatementList( node->statements );
838
839        MUTATE_END( Statement, node );
840}
841
842//--------------------------------------------------------------------------
843// CaseStmt
844template< typename pass_type >
845void PassVisitor< pass_type >::visit( CaseStmt * node ) {
846        VISIT_START( node );
847
848        visitExpression   ( node->condition );
849        visitStatementList( node->stmts     );
850
851        VISIT_END( node );
852}
853
854template< typename pass_type >
855Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
856        MUTATE_START( node );
857
858        node->condition = mutateExpression( node->condition );
859        mutateStatementList( node->stmts );
860
861        MUTATE_END( Statement, node );
862}
863
864//--------------------------------------------------------------------------
865// BranchStmt
866template< typename pass_type >
867void PassVisitor< pass_type >::visit( BranchStmt * node ) {
868        VISIT_BODY( node );
869}
870
871template< typename pass_type >
872Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
873        MUTATE_BODY( Statement, node );
874}
875
876//--------------------------------------------------------------------------
877// ReturnStmt
878template< typename pass_type >
879void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
880        VISIT_START( node );
881
882        visitExpression( node->expr );
883
884        VISIT_END( node );
885}
886
887template< typename pass_type >
888Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
889        MUTATE_START( node );
890
891        node->expr = mutateExpression( node->expr );
892
893        MUTATE_END( Statement, node );
894}
895
896//--------------------------------------------------------------------------
897// ThrowStmt
898
899template< typename pass_type >
900void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
901        VISIT_BODY( node );
902}
903
904template< typename pass_type >
905Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
906        MUTATE_BODY( Statement, node );
907}
908
909//--------------------------------------------------------------------------
910// TryStmt
911template< typename pass_type >
912void PassVisitor< pass_type >::visit( TryStmt * node ) {
913        VISIT_START( node );
914
915        maybeAccept_impl( node->block       , *this );
916        maybeAccept_impl( node->handlers    , *this );
917        maybeAccept_impl( node->finallyBlock, *this );
918
919        VISIT_END( node );
920}
921
922template< typename pass_type >
923Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
924        MUTATE_START( node );
925
926        maybeMutate_impl( node->block       , *this );
927        maybeMutate_impl( node->handlers    , *this );
928        maybeMutate_impl( node->finallyBlock, *this );
929
930        MUTATE_END( Statement, node );
931}
932
933//--------------------------------------------------------------------------
934// CatchStmt
935template< typename pass_type >
936void PassVisitor< pass_type >::visit( CatchStmt * node ) {
937        VISIT_START( node );
938        {
939                // catch statements introduce a level of scope (for the caught exception)
940                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
941                maybeAccept_impl( node->decl, *this );
942                node->cond = visitExpression( node->cond );
943                node->body = visitStatement ( node->body );
944        }
945        VISIT_END( node );
946}
947
948template< typename pass_type >
949Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
950        MUTATE_START( node );
951        {
952                // catch statements introduce a level of scope (for the caught exception)
953                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
954                maybeMutate_impl( node->decl, *this );
955                node->cond = mutateExpression( node->cond );
956                node->body = mutateStatement ( node->body );
957        }
958        MUTATE_END( Statement, node );
959}
960
961//--------------------------------------------------------------------------
962// FinallyStmt
963template< typename pass_type >
964void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
965        VISIT_BODY( node );
966}
967
968template< typename pass_type >
969Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
970        MUTATE_BODY( Statement, node );
971}
972
973//--------------------------------------------------------------------------
974// WaitForStmt
975template< typename pass_type >
976void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
977        VISIT_BODY( node );
978}
979
980template< typename pass_type >
981Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
982        MUTATE_BODY( Statement, node );
983}
984
985
986
987//--------------------------------------------------------------------------
988// NullStmt
989template< typename pass_type >
990void PassVisitor< pass_type >::visit( WithStmt * node ) {
991        VISIT_START( node );
992        maybeAccept_impl( node->exprs, *this );
993        {
994                // catch statements introduce a level of scope (for the caught exception)
995                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
996                indexerAddWith( node );
997                maybeAccept_impl( node->stmt, *this );
998        }
999        VISIT_END( node );
1000}
1001
1002template< typename pass_type >
1003Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
1004        MUTATE_START( node );
1005        maybeMutate_impl( node->exprs, *this );
1006        {
1007                // catch statements introduce a level of scope (for the caught exception)
1008                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1009                indexerAddWith( node );
1010                maybeMutate_impl( node->stmt, *this );
1011        }
1012        MUTATE_END( Statement, node );
1013}
1014
1015//--------------------------------------------------------------------------
1016// NullStmt
1017template< typename pass_type >
1018void PassVisitor< pass_type >::visit( NullStmt * node ) {
1019        VISIT_BODY( node );
1020}
1021
1022template< typename pass_type >
1023NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
1024        MUTATE_BODY( NullStmt, node );
1025}
1026
1027//--------------------------------------------------------------------------
1028// DeclStmt
1029template< typename pass_type >
1030void PassVisitor< pass_type >::visit( DeclStmt * node ) {
1031        VISIT_BODY( node );
1032}
1033
1034template< typename pass_type >
1035Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
1036        MUTATE_BODY( Statement, node );
1037}
1038
1039//--------------------------------------------------------------------------
1040// ImplicitCtorDtorStmt
1041template< typename pass_type >
1042void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
1043        VISIT_BODY( node );
1044}
1045
1046template< typename pass_type >
1047Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
1048        MUTATE_BODY( Statement, node );
1049}
1050
1051//--------------------------------------------------------------------------
1052// ApplicationExpr
1053template< typename pass_type >
1054void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
1055        VISIT_START( node );
1056
1057        indexerScopedAccept( node->result  , *this );
1058        maybeAccept_impl        ( node->function, *this );
1059        maybeAccept_impl        ( node->args    , *this );
1060
1061        VISIT_END( node );
1062}
1063
1064template< typename pass_type >
1065Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
1066        MUTATE_START( node );
1067
1068        indexerScopedMutate( node->env     , *this );
1069        indexerScopedMutate( node->result  , *this );
1070        maybeMutate_impl   ( node->function, *this );
1071        maybeMutate_impl   ( node->args    , *this );
1072
1073        MUTATE_END( Expression, node );
1074}
1075
1076//--------------------------------------------------------------------------
1077// UntypedExpr
1078template< typename pass_type >
1079void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
1080        VISIT_START( node );
1081
1082        // maybeAccept_impl( node->get_env(), *this );
1083        indexerScopedAccept( node->result, *this );
1084
1085        for ( auto expr : node->args ) {
1086                visitExpression( expr );
1087        }
1088
1089        VISIT_END( node );
1090}
1091
1092template< typename pass_type >
1093Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
1094        MUTATE_START( node );
1095
1096        indexerScopedMutate( node->env   , *this );
1097        indexerScopedMutate( node->result, *this );
1098
1099        for ( auto& expr : node->args ) {
1100                expr = mutateExpression( expr );
1101        }
1102
1103        MUTATE_END( Expression, node );
1104}
1105
1106//--------------------------------------------------------------------------
1107// NameExpr
1108template< typename pass_type >
1109void PassVisitor< pass_type >::visit( NameExpr * node ) {
1110        VISIT_START( node );
1111
1112        indexerScopedAccept( node->result, *this );
1113
1114        VISIT_END( node );
1115}
1116
1117template< typename pass_type >
1118Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
1119        MUTATE_START( node );
1120
1121        indexerScopedMutate( node->env   , *this );
1122        indexerScopedMutate( node->result, *this );
1123
1124        MUTATE_END( Expression, node );
1125}
1126
1127//--------------------------------------------------------------------------
1128// CastExpr
1129template< typename pass_type >
1130void PassVisitor< pass_type >::visit( CastExpr * node ) {
1131        VISIT_START( node );
1132
1133        indexerScopedAccept( node->result, *this );
1134        maybeAccept_impl        ( node->arg   , *this );
1135
1136        VISIT_END( node );
1137}
1138
1139template< typename pass_type >
1140Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
1141        MUTATE_START( node );
1142
1143        indexerScopedMutate( node->env   , *this );
1144        indexerScopedMutate( node->result, *this );
1145        maybeMutate_impl   ( node->arg   , *this );
1146
1147        MUTATE_END( Expression, node );
1148}
1149
1150//--------------------------------------------------------------------------
1151// VirtualCastExpr
1152template< typename pass_type >
1153void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
1154        VISIT_START( node );
1155
1156        indexerScopedAccept( node->result, *this );
1157        maybeAccept_impl( node->arg, *this );
1158
1159        VISIT_END( node );
1160}
1161
1162template< typename pass_type >
1163Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
1164        MUTATE_START( node );
1165
1166        indexerScopedMutate( node->env   , *this );
1167        indexerScopedMutate( node->result, *this );
1168        maybeMutate_impl   ( node->arg   , *this );
1169
1170        MUTATE_END( Expression, node );
1171}
1172
1173//--------------------------------------------------------------------------
1174// AddressExpr
1175template< typename pass_type >
1176void PassVisitor< pass_type >::visit( AddressExpr * node ) {
1177        VISIT_START( node );
1178
1179        indexerScopedAccept( node->result, *this );
1180        maybeAccept_impl   ( node->arg   , *this );
1181
1182        VISIT_END( node );
1183}
1184
1185template< typename pass_type >
1186Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
1187        MUTATE_START( node );
1188
1189        indexerScopedMutate( node->env   , *this );
1190        indexerScopedMutate( node->result, *this );
1191        maybeMutate_impl   ( node->arg   , *this );
1192
1193        MUTATE_END( Expression, node );
1194}
1195
1196//--------------------------------------------------------------------------
1197// LabelAddressExpr
1198template< typename pass_type >
1199void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
1200        VISIT_START( node );
1201
1202        indexerScopedAccept( node->result, *this );
1203
1204        VISIT_END( node );
1205}
1206
1207template< typename pass_type >
1208Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
1209        MUTATE_START( node );
1210
1211        indexerScopedMutate( node->env   , *this );
1212        indexerScopedMutate( node->result, *this );
1213
1214        MUTATE_END( Expression, node );
1215}
1216
1217//--------------------------------------------------------------------------
1218// UntypedMemberExpr
1219template< typename pass_type >
1220void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
1221        VISIT_START( node );
1222
1223        indexerScopedAccept( node->result   , *this );
1224        maybeAccept_impl   ( node->aggregate, *this );
1225        maybeAccept_impl   ( node->member   , *this );
1226
1227        VISIT_END( node );
1228}
1229
1230template< typename pass_type >
1231Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
1232        MUTATE_START( node );
1233
1234        indexerScopedMutate( node->env      , *this );
1235        indexerScopedMutate( node->result   , *this );
1236        maybeMutate_impl   ( node->aggregate, *this );
1237        maybeMutate_impl   ( node->member   , *this );
1238
1239        MUTATE_END( Expression, node );
1240}
1241
1242//--------------------------------------------------------------------------
1243// MemberExpr
1244template< typename pass_type >
1245void PassVisitor< pass_type >::visit( MemberExpr * node ) {
1246        VISIT_START( node );
1247
1248        indexerScopedAccept( node->result   , *this );
1249        maybeAccept_impl   ( node->aggregate, *this );
1250
1251        VISIT_END( node );
1252}
1253
1254template< typename pass_type >
1255Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
1256        MUTATE_START( node );
1257
1258        indexerScopedMutate( node->env      , *this );
1259        indexerScopedMutate( node->result   , *this );
1260        maybeMutate_impl   ( node->aggregate, *this );
1261
1262        MUTATE_END( Expression, node );
1263}
1264
1265//--------------------------------------------------------------------------
1266// VariableExpr
1267template< typename pass_type >
1268void PassVisitor< pass_type >::visit( VariableExpr * node ) {
1269        VISIT_START( node );
1270
1271        indexerScopedAccept( node->result, *this );
1272
1273        VISIT_END( node );
1274}
1275
1276template< typename pass_type >
1277Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
1278        MUTATE_START( node );
1279
1280        indexerScopedMutate( node->env   , *this );
1281        indexerScopedMutate( node->result, *this );
1282
1283        MUTATE_END( Expression, node );
1284}
1285
1286//--------------------------------------------------------------------------
1287// ConstantExpr
1288template< typename pass_type >
1289void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
1290        VISIT_START( node );
1291
1292        indexerScopedAccept( node->result   , *this );
1293        maybeAccept_impl   ( &node->constant, *this );
1294
1295        VISIT_END( node );
1296}
1297
1298template< typename pass_type >
1299Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
1300        MUTATE_START( node );
1301
1302        indexerScopedMutate( node->env   , *this );
1303        indexerScopedMutate( node->result, *this );
1304        Constant * ptr = &node->constant;
1305        maybeMutate_impl( ptr, *this );
1306        node->constant = *ptr;
1307
1308        MUTATE_END( Expression, node );
1309}
1310
1311//--------------------------------------------------------------------------
1312// SizeofExpr
1313template< typename pass_type >
1314void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
1315        VISIT_START( node );
1316
1317        indexerScopedAccept( node->result, *this );
1318        if ( node->get_isType() ) {
1319                maybeAccept_impl( node->type, *this );
1320        } else {
1321                maybeAccept_impl( node->expr, *this );
1322        }
1323
1324        VISIT_END( node );
1325}
1326
1327template< typename pass_type >
1328Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
1329        MUTATE_START( node );
1330
1331        indexerScopedMutate( node->env   , *this );
1332        indexerScopedMutate( node->result, *this );
1333        if ( node->get_isType() ) {
1334                maybeMutate_impl( node->type, *this );
1335        } else {
1336                maybeMutate_impl( node->expr, *this );
1337        }
1338
1339        MUTATE_END( Expression, node );
1340}
1341
1342//--------------------------------------------------------------------------
1343// AlignofExpr
1344template< typename pass_type >
1345void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
1346        VISIT_START( node );
1347
1348        indexerScopedAccept( node->result, *this );
1349        if ( node->get_isType() ) {
1350                maybeAccept_impl( node->type, *this );
1351        } else {
1352                maybeAccept_impl( node->expr, *this );
1353        }
1354
1355        VISIT_END( node );
1356}
1357
1358template< typename pass_type >
1359Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
1360        MUTATE_START( node );
1361
1362        indexerScopedMutate( node->env   , *this );
1363        indexerScopedMutate( node->result, *this );
1364        if ( node->get_isType() ) {
1365                maybeMutate_impl( node->type, *this );
1366        } else {
1367                maybeMutate_impl( node->expr, *this );
1368        }
1369
1370        MUTATE_END( Expression, node );
1371}
1372
1373//--------------------------------------------------------------------------
1374// UntypedOffsetofExpr
1375template< typename pass_type >
1376void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
1377        VISIT_START( node );
1378
1379        indexerScopedAccept( node->result, *this );
1380        maybeAccept_impl   ( node->type  , *this );
1381
1382        VISIT_END( node );
1383}
1384
1385template< typename pass_type >
1386Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
1387        MUTATE_START( node );
1388
1389        indexerScopedMutate( node->env   , *this );
1390        indexerScopedMutate( node->result, *this );
1391        maybeMutate_impl   ( node->type  , *this );
1392
1393        MUTATE_END( Expression, node );
1394}
1395
1396//--------------------------------------------------------------------------
1397// OffsetofExpr
1398template< typename pass_type >
1399void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
1400        VISIT_START( node );
1401
1402        indexerScopedAccept( node->result, *this );
1403        maybeAccept_impl   ( node->type  , *this );
1404        maybeAccept_impl   ( node->member, *this );
1405
1406        VISIT_END( node );
1407}
1408
1409template< typename pass_type >
1410Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
1411        MUTATE_START( node );
1412
1413        indexerScopedMutate( node->env   , *this );
1414        indexerScopedMutate( node->result, *this );
1415        maybeMutate_impl   ( node->type  , *this );
1416        maybeMutate_impl   ( node->member, *this );
1417
1418        MUTATE_END( Expression, node );
1419}
1420
1421//--------------------------------------------------------------------------
1422// OffsetPackExpr
1423template< typename pass_type >
1424void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
1425        VISIT_START( node );
1426
1427        indexerScopedAccept( node->result, *this );
1428        maybeAccept_impl   ( node->type  , *this );
1429
1430        VISIT_END( node );
1431}
1432
1433template< typename pass_type >
1434Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
1435        MUTATE_START( node );
1436
1437        indexerScopedMutate( node->env   , *this );
1438        indexerScopedMutate( node->result, *this );
1439        maybeMutate_impl   ( node->type  , *this );
1440
1441        MUTATE_END( Expression, node );
1442}
1443
1444//--------------------------------------------------------------------------
1445// AttrExpr
1446template< typename pass_type >
1447void PassVisitor< pass_type >::visit( AttrExpr * node ) {
1448        VISIT_START( node );
1449
1450        indexerScopedAccept( node->result, *this );
1451        if ( node->get_isType() ) {
1452                maybeAccept_impl( node->type, *this );
1453        } else {
1454                maybeAccept_impl( node->expr, *this );
1455        }
1456
1457        VISIT_END( node );
1458}
1459
1460template< typename pass_type >
1461Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
1462        MUTATE_START( node );
1463
1464        indexerScopedMutate( node->env   , *this );
1465        indexerScopedMutate( node->result, *this );
1466        if ( node->get_isType() ) {
1467                maybeMutate_impl( node->type, *this );
1468        } else {
1469                maybeMutate_impl( node->expr, *this );
1470        }
1471
1472        MUTATE_END( Expression, node );
1473}
1474
1475//--------------------------------------------------------------------------
1476// LogicalExpr
1477template< typename pass_type >
1478void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
1479        VISIT_START( node );
1480
1481        indexerScopedAccept( node->result, *this );
1482        maybeAccept_impl   ( node->arg1  , *this );
1483        maybeAccept_impl   ( node->arg2  , *this );
1484
1485        VISIT_END( node );
1486}
1487
1488template< typename pass_type >
1489Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
1490        MUTATE_START( node );
1491
1492        indexerScopedMutate( node->env   , *this );
1493        indexerScopedMutate( node->result, *this );
1494        maybeMutate_impl   ( node->arg1  , *this );
1495        maybeMutate_impl   ( node->arg2  , *this );
1496
1497        MUTATE_END( Expression, node );
1498}
1499
1500//--------------------------------------------------------------------------
1501// ConditionalExpr
1502template< typename pass_type >
1503void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
1504        VISIT_START( node );
1505
1506        indexerScopedAccept( node->result, *this );
1507        maybeAccept_impl        ( node->arg1  , *this );
1508        maybeAccept_impl        ( node->arg2  , *this );
1509        maybeAccept_impl        ( node->arg3  , *this );
1510
1511        VISIT_END( node );
1512}
1513
1514template< typename pass_type >
1515Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
1516        MUTATE_START( node );
1517
1518        indexerScopedMutate( node->env   , *this );
1519        indexerScopedMutate( node->result, *this );
1520        maybeMutate_impl   ( node->arg1  , *this );
1521        maybeMutate_impl   ( node->arg2  , *this );
1522        maybeMutate_impl   ( node->arg3  , *this );
1523
1524        MUTATE_END( Expression, node );
1525}
1526
1527//--------------------------------------------------------------------------
1528// CommaExpr
1529template< typename pass_type >
1530void PassVisitor< pass_type >::visit( CommaExpr * node ) {
1531        VISIT_START( node );
1532
1533        indexerScopedAccept( node->result, *this );
1534        maybeAccept_impl   ( node->arg1  , *this );
1535        maybeAccept_impl   ( node->arg2  , *this );
1536
1537        VISIT_END( node );
1538}
1539
1540template< typename pass_type >
1541Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
1542        MUTATE_START( node );
1543
1544        indexerScopedMutate( node->env   , *this );
1545        indexerScopedMutate( node->result, *this );
1546        maybeMutate_impl   ( node->arg1  , *this );
1547        maybeMutate_impl   ( node->arg2  , *this );
1548
1549        MUTATE_END( Expression, node );
1550}
1551
1552//--------------------------------------------------------------------------
1553// TypeExpr
1554template< typename pass_type >
1555void PassVisitor< pass_type >::visit( TypeExpr * node ) {
1556        VISIT_START( node );
1557
1558        indexerScopedAccept( node->result, *this );
1559        maybeAccept_impl   ( node->type, *this );
1560
1561        VISIT_END( node );
1562}
1563
1564template< typename pass_type >
1565Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
1566        MUTATE_START( node );
1567
1568        indexerScopedMutate( node->env   , *this );
1569        indexerScopedMutate( node->result, *this );
1570        maybeMutate_impl   ( node->type  , *this );
1571
1572        MUTATE_END( Expression, node );
1573}
1574
1575//--------------------------------------------------------------------------
1576// AsmExpr
1577template< typename pass_type >
1578void PassVisitor< pass_type >::visit( AsmExpr * node ) {
1579        VISIT_START( node );
1580
1581        indexerScopedAccept( node->result    , *this );
1582        maybeAccept_impl   ( node->inout     , *this );
1583        maybeAccept_impl   ( node->constraint, *this );
1584        maybeAccept_impl   ( node->operand   , *this );
1585
1586        VISIT_END( node );
1587}
1588
1589template< typename pass_type >
1590Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
1591        MUTATE_START( node );
1592
1593        indexerScopedMutate( node->env       , *this );
1594        indexerScopedMutate( node->result    , *this );
1595        maybeMutate_impl   ( node->inout     , *this );
1596        maybeMutate_impl   ( node->constraint, *this );
1597        maybeMutate_impl   ( node->operand   , *this );
1598
1599        MUTATE_END( Expression, node );
1600}
1601
1602//--------------------------------------------------------------------------
1603// ImplicitCopyCtorExpr
1604template< typename pass_type >
1605void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
1606        VISIT_START( node );
1607
1608        indexerScopedAccept( node->result     , *this );
1609        maybeAccept_impl   ( node->callExpr   , *this );
1610        maybeAccept_impl   ( node->tempDecls  , *this );
1611        maybeAccept_impl   ( node->returnDecls, *this );
1612        maybeAccept_impl   ( node->dtors      , *this );
1613
1614        VISIT_END( node );
1615}
1616
1617template< typename pass_type >
1618Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
1619        MUTATE_START( node );
1620
1621        indexerScopedMutate( node->env        , *this );
1622        indexerScopedMutate( node->result     , *this );
1623        maybeMutate_impl   ( node->callExpr   , *this );
1624        maybeMutate_impl   ( node->tempDecls  , *this );
1625        maybeMutate_impl   ( node->returnDecls, *this );
1626        maybeMutate_impl   ( node->dtors      , *this );
1627
1628        MUTATE_END( Expression, node );
1629}
1630
1631//--------------------------------------------------------------------------
1632// ConstructorExpr
1633template< typename pass_type >
1634void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
1635        VISIT_START( node );
1636
1637        indexerScopedAccept( node->result  , *this );
1638        maybeAccept_impl   ( node->callExpr, *this );
1639
1640        VISIT_END( node );
1641}
1642
1643template< typename pass_type >
1644Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
1645        MUTATE_START( node );
1646
1647        indexerScopedMutate( node->env     , *this );
1648        indexerScopedMutate( node->result  , *this );
1649        maybeMutate_impl   ( node->callExpr, *this );
1650
1651        MUTATE_END( Expression, node );
1652}
1653
1654//--------------------------------------------------------------------------
1655// CompoundLiteralExpr
1656template< typename pass_type >
1657void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
1658        VISIT_START( node );
1659
1660        indexerScopedAccept( node->result     , *this );
1661        maybeAccept_impl   ( node->initializer, *this );
1662
1663        VISIT_END( node );
1664}
1665
1666template< typename pass_type >
1667Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
1668        MUTATE_START( node );
1669
1670        indexerScopedMutate( node->env        , *this );
1671        indexerScopedMutate( node->result     , *this );
1672        maybeMutate_impl     ( node->initializer, *this );
1673
1674        MUTATE_END( Expression, node );
1675}
1676
1677//--------------------------------------------------------------------------
1678// RangeExpr
1679template< typename pass_type >
1680void PassVisitor< pass_type >::visit( RangeExpr * node ) {
1681        VISIT_START( node );
1682
1683        indexerScopedAccept( node->result, *this );
1684        maybeAccept_impl   ( node->low   , *this );
1685        maybeAccept_impl   ( node->high  , *this );
1686
1687        VISIT_END( node );
1688}
1689
1690template< typename pass_type >
1691Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
1692        MUTATE_START( node );
1693
1694        indexerScopedMutate( node->env   , *this );
1695        indexerScopedMutate( node->result, *this );
1696        maybeMutate_impl   ( node->low   , *this );
1697        maybeMutate_impl   ( node->high  , *this );
1698
1699        MUTATE_END( Expression, node );
1700}
1701
1702//--------------------------------------------------------------------------
1703// UntypedTupleExpr
1704template< typename pass_type >
1705void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
1706        VISIT_START( node );
1707
1708        indexerScopedAccept( node->result, *this );
1709        maybeAccept_impl   ( node->exprs , *this );
1710
1711        VISIT_END( node );
1712}
1713
1714template< typename pass_type >
1715Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
1716        MUTATE_START( node );
1717
1718        indexerScopedMutate( node->env   , *this );
1719        indexerScopedMutate( node->result, *this );
1720        maybeMutate_impl   ( node->exprs , *this );
1721
1722        MUTATE_END( Expression, node );
1723}
1724
1725//--------------------------------------------------------------------------
1726// TupleExpr
1727template< typename pass_type >
1728void PassVisitor< pass_type >::visit( TupleExpr * node ) {
1729        VISIT_START( node );
1730
1731        indexerScopedAccept( node->result, *this );
1732        maybeAccept_impl   ( node->exprs , *this );
1733
1734        VISIT_END( node );
1735}
1736
1737template< typename pass_type >
1738Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
1739        MUTATE_START( node );
1740
1741        indexerScopedMutate( node->env   , *this );
1742        indexerScopedMutate( node->result, *this );
1743        maybeMutate_impl   ( node->exprs , *this );
1744
1745        MUTATE_END( Expression, node );
1746}
1747
1748//--------------------------------------------------------------------------
1749// TupleIndexExpr
1750template< typename pass_type >
1751void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
1752        VISIT_START( node );
1753
1754        indexerScopedAccept( node->result, *this );
1755        maybeAccept_impl   ( node->tuple , *this );
1756
1757        VISIT_END( node );
1758}
1759
1760template< typename pass_type >
1761Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
1762        MUTATE_START( node );
1763
1764        indexerScopedMutate( node->env   , *this );
1765        indexerScopedMutate( node->result, *this );
1766        maybeMutate_impl   ( node->tuple , *this );
1767
1768        MUTATE_END( Expression, node );
1769}
1770
1771//--------------------------------------------------------------------------
1772// TupleAssignExpr
1773template< typename pass_type >
1774void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
1775        VISIT_START( node );
1776
1777        indexerScopedAccept( node->result  , *this );
1778        maybeAccept_impl   ( node->stmtExpr, *this );
1779
1780        VISIT_END( node );
1781}
1782
1783template< typename pass_type >
1784Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
1785        MUTATE_START( node );
1786
1787        indexerScopedMutate( node->env     , *this );
1788        indexerScopedMutate( node->result  , *this );
1789        maybeMutate_impl   ( node->stmtExpr, *this );
1790
1791        MUTATE_END( Expression, node );
1792}
1793
1794//--------------------------------------------------------------------------
1795// StmtExpr
1796template< typename pass_type >
1797void PassVisitor< pass_type >::visit( StmtExpr * node ) {
1798        VISIT_START( node );
1799
1800        // don't want statements from outer CompoundStmts to be added to this StmtExpr
1801        ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
1802        ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1803        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
1804
1805        indexerScopedAccept( node->result     , *this );
1806        maybeAccept_impl   ( node->statements , *this );
1807        maybeAccept_impl   ( node->returnDecls, *this );
1808        maybeAccept_impl   ( node->dtors      , *this );
1809
1810        VISIT_END( node );
1811}
1812
1813template< typename pass_type >
1814Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
1815        MUTATE_START( node );
1816
1817        // don't want statements from outer CompoundStmts to be added to this StmtExpr
1818        ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
1819        ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
1820        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
1821
1822        indexerScopedMutate( node->result     , *this );
1823        maybeMutate_impl   ( node->statements , *this );
1824        maybeMutate_impl   ( node->returnDecls, *this );
1825        maybeMutate_impl   ( node->dtors      , *this );
1826
1827        MUTATE_END( Expression, node );
1828}
1829
1830//--------------------------------------------------------------------------
1831// UniqueExpr
1832template< typename pass_type >
1833void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
1834        VISIT_START( node );
1835
1836        indexerScopedAccept( node->result, *this );
1837        maybeAccept_impl   ( node->expr  , *this );
1838
1839        VISIT_END( node );
1840}
1841
1842template< typename pass_type >
1843Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
1844        MUTATE_START( node );
1845
1846        indexerScopedMutate( node->env   , *this );
1847        indexerScopedMutate( node->result, *this );
1848        maybeMutate_impl   ( node->expr  , *this );
1849
1850        MUTATE_END( Expression, node );
1851}
1852
1853//--------------------------------------------------------------------------
1854// UntypedInitExpr
1855template< typename pass_type >
1856void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
1857        VISIT_START( node );
1858
1859        indexerScopedAccept( node->result, *this );
1860        maybeAccept_impl   ( node->expr  , *this );
1861        // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
1862
1863        VISIT_END( node );
1864}
1865
1866template< typename pass_type >
1867Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
1868        MUTATE_START( node );
1869
1870        indexerScopedMutate( node->env   , *this );
1871        indexerScopedMutate( node->result, *this );
1872        maybeMutate_impl   ( node->expr  , *this );
1873        // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
1874
1875        MUTATE_END( Expression, node );
1876}
1877
1878//--------------------------------------------------------------------------
1879// InitExpr
1880template< typename pass_type >
1881void PassVisitor< pass_type >::visit( InitExpr * node ) {
1882        VISIT_START( node );
1883
1884        indexerScopedAccept( node->result, *this );
1885        maybeAccept_impl   ( node->expr  , *this );
1886        maybeAccept_impl   ( node->designation, *this );
1887
1888        VISIT_END( node );
1889}
1890
1891template< typename pass_type >
1892Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
1893        MUTATE_START( node );
1894
1895        indexerScopedMutate( node->env   , *this );
1896        indexerScopedMutate( node->result, *this );
1897        maybeMutate_impl   ( node->expr  , *this );
1898        maybeMutate_impl   ( node->designation, *this );
1899
1900        MUTATE_END( Expression, node );
1901}
1902
1903template< typename pass_type >
1904void PassVisitor< pass_type >::visit( VoidType * node ) {
1905        VISIT_BODY( node );
1906}
1907
1908template< typename pass_type >
1909void PassVisitor< pass_type >::visit( BasicType * node ) {
1910        VISIT_BODY( node );
1911}
1912
1913template< typename pass_type >
1914void PassVisitor< pass_type >::visit( PointerType * node ) {
1915        VISIT_BODY( node );
1916}
1917
1918template< typename pass_type >
1919void PassVisitor< pass_type >::visit( ArrayType * node ) {
1920        VISIT_BODY( node );
1921}
1922
1923template< typename pass_type >
1924void PassVisitor< pass_type >::visit( ReferenceType * node ) {
1925        VISIT_BODY( node );
1926}
1927
1928template< typename pass_type >
1929void PassVisitor< pass_type >::visit( FunctionType * node ) {
1930        VISIT_BODY( node );
1931}
1932
1933//--------------------------------------------------------------------------
1934// StructInstType
1935template< typename pass_type >
1936void PassVisitor< pass_type >::visit( StructInstType * node ) {
1937        VISIT_START( node );
1938
1939        indexerAddStruct( node->name );
1940
1941        {
1942                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1943                maybeAccept_impl( node->forall    , *this );
1944                maybeAccept_impl( node->parameters, *this );
1945        }
1946
1947        VISIT_END( node );
1948}
1949
1950template< typename pass_type >
1951Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
1952        MUTATE_START( node );
1953
1954        indexerAddStruct( node->name );
1955
1956        {
1957                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1958                maybeMutate_impl( node->forall    , *this );
1959                maybeMutate_impl( node->parameters, *this );
1960        }
1961
1962        MUTATE_END( Type, node );
1963}
1964
1965//--------------------------------------------------------------------------
1966// UnionInstType
1967template< typename pass_type >
1968void PassVisitor< pass_type >::visit( UnionInstType * node ) {
1969        VISIT_START( node );
1970
1971        indexerAddStruct( node->name );
1972
1973        {
1974                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1975                maybeAccept_impl( node->forall    , *this );
1976                maybeAccept_impl( node->parameters, *this );
1977        }
1978
1979        VISIT_END( node );
1980}
1981
1982template< typename pass_type >
1983Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
1984        MUTATE_START( node );
1985
1986        indexerAddStruct( node->name );
1987
1988        {
1989                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
1990                maybeMutate_impl( node->forall    , *this );
1991                maybeMutate_impl( node->parameters, *this );
1992        }
1993
1994        MUTATE_END( Type, node );
1995}
1996
1997//--------------------------------------------------------------------------
1998// EnumInstType
1999template< typename pass_type >
2000void PassVisitor< pass_type >::visit( EnumInstType * node ) {
2001        VISIT_BODY( node );
2002}
2003
2004template< typename pass_type >
2005Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
2006        MUTATE_BODY( Type, node );
2007}
2008
2009//--------------------------------------------------------------------------
2010// TraitInstType
2011template< typename pass_type >
2012void PassVisitor< pass_type >::visit( TraitInstType * node ) {
2013        VISIT_START( node );
2014
2015        maybeAccept_impl( node->forall    , *this );
2016        maybeAccept_impl( node->parameters, *this );
2017
2018        VISIT_END( node );
2019}
2020
2021template< typename pass_type >
2022Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
2023        MUTATE_START( node );
2024
2025        maybeMutate_impl( node->forall    , *this );
2026        maybeMutate_impl( node->parameters, *this );
2027
2028        MUTATE_END( Type, node );
2029}
2030
2031//--------------------------------------------------------------------------
2032// TypeInstType
2033template< typename pass_type >
2034void PassVisitor< pass_type >::visit( TypeInstType * node ) {
2035        VISIT_BODY( node );
2036}
2037
2038template< typename pass_type >
2039void PassVisitor< pass_type >::visit( TupleType * node ) {
2040        VISIT_BODY( node );
2041}
2042
2043template< typename pass_type >
2044void PassVisitor< pass_type >::visit( TypeofType * node ) {
2045        VISIT_BODY( node );
2046}
2047
2048template< typename pass_type >
2049void PassVisitor< pass_type >::visit( AttrType * node ) {
2050        VISIT_BODY( node );
2051}
2052
2053template< typename pass_type >
2054void PassVisitor< pass_type >::visit( VarArgsType * node ) {
2055        VISIT_BODY( node );
2056}
2057
2058template< typename pass_type >
2059void PassVisitor< pass_type >::visit( ZeroType * node ) {
2060        VISIT_BODY( node );
2061}
2062
2063template< typename pass_type >
2064void PassVisitor< pass_type >::visit( OneType * node ) {
2065        VISIT_BODY( node );
2066}
2067
2068template< typename pass_type >
2069void PassVisitor< pass_type >::visit( Designation * node ) {
2070        VISIT_START( node );
2071
2072        maybeAccept_impl( node->get_designators(), *this );
2073
2074        VISIT_END( node );
2075}
2076
2077template< typename pass_type >
2078Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
2079        MUTATE_START( node );
2080
2081        maybeMutate_impl( node->get_designators(), *this );
2082
2083        MUTATE_END( Designation, node );
2084}
2085
2086//--------------------------------------------------------------------------
2087// SingleInit
2088template< typename pass_type >
2089void PassVisitor< pass_type >::visit( SingleInit * node ) {
2090        VISIT_START( node );
2091
2092        visitExpression( node->get_value() );
2093
2094        VISIT_END( node );
2095}
2096
2097template< typename pass_type >
2098Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
2099        MUTATE_START( node );
2100
2101        node->set_value( mutateExpression( node->get_value() ) );
2102
2103        MUTATE_END( Initializer, node );
2104}
2105
2106template< typename pass_type >
2107void PassVisitor< pass_type >::visit( ListInit * node ) {
2108        VISIT_BODY( node );
2109}
2110
2111template< typename pass_type >
2112void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
2113        VISIT_BODY( node );
2114}
2115
2116template< typename pass_type >
2117void PassVisitor< pass_type >::visit( Subrange * node ) {
2118        VISIT_BODY( node );
2119}
2120
2121template< typename pass_type >
2122void PassVisitor< pass_type >::visit( Constant * node ) {
2123        VISIT_BODY( node );
2124}
2125
2126template< typename pass_type >
2127void PassVisitor< pass_type >::visit( Attribute * node ) {
2128        VISIT_BODY( node );
2129}
2130
2131//---------------------------------------------------------------------------------------------------------------
2132template< typename pass_type >
2133Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
2134        MUTATE_BODY( Type, node );
2135}
2136
2137template< typename pass_type >
2138Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
2139        MUTATE_BODY( Type, node );
2140}
2141
2142template< typename pass_type >
2143Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
2144        MUTATE_BODY( Type, node );
2145}
2146
2147template< typename pass_type >
2148Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
2149        MUTATE_BODY( Type, node );
2150}
2151
2152template< typename pass_type >
2153Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
2154        MUTATE_BODY( Type, node );
2155}
2156
2157template< typename pass_type >
2158Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
2159        MUTATE_BODY( Type, node );
2160}
2161
2162template< typename pass_type >
2163Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
2164        MUTATE_BODY( Type, node );
2165}
2166
2167template< typename pass_type >
2168Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
2169        MUTATE_BODY( Type, node );
2170}
2171
2172template< typename pass_type >
2173Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
2174        MUTATE_BODY( Type, node );
2175}
2176
2177template< typename pass_type >
2178Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
2179        MUTATE_BODY( Type, node );
2180}
2181
2182template< typename pass_type >
2183Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
2184        MUTATE_BODY( Type, node );
2185}
2186
2187template< typename pass_type >
2188Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
2189        MUTATE_BODY( Type, node );
2190}
2191
2192template< typename pass_type >
2193Type * PassVisitor< pass_type >::mutate( OneType * node ) {
2194        MUTATE_BODY( Type, node );
2195}
2196
2197template< typename pass_type >
2198Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
2199        MUTATE_BODY( Initializer, node );
2200}
2201
2202template< typename pass_type >
2203Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
2204        MUTATE_BODY( Initializer, node );
2205}
2206
2207template< typename pass_type >
2208Subrange * PassVisitor< pass_type >::mutate( Subrange * node  )  {
2209        MUTATE_BODY( Subrange, node );
2210}
2211
2212template< typename pass_type >
2213Constant * PassVisitor< pass_type >::mutate( Constant * node  )  {
2214        MUTATE_BODY( Constant, node );
2215}
2216
2217template< typename pass_type >
2218Attribute * PassVisitor< pass_type >::mutate( Attribute * node  )  {
2219        MUTATE_BODY( Attribute, node );
2220}
2221
2222template< typename pass_type >
2223TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
2224        MUTATE_START( node );
2225
2226        for ( auto & p : node->typeEnv ) {
2227                indexerScopedMutate( p.second, *this );
2228        }
2229        for ( auto & p : node->varEnv ) {
2230                indexerScopedMutate( p.second, *this );
2231        }
2232
2233        MUTATE_END( TypeSubstitution, node );
2234}
Note: See TracBrowser for help on using the repository browser.