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