source: src/Common/PassVisitor.impl.h@ ff2a33e

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since ff2a33e was 7870799, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Cast cost and conversion cost now take constant parameters.
This required supporting visiting const node.
The PassVisitor can now visit const nodes but not when using the Indexer

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