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 | // function body needs to have the same scope as parameters - CompoundStmt will not enter |
---|
407 | // a new scope if inFunction is true |
---|
408 | ValueGuard< bool > oldInFunction( inFunction ); |
---|
409 | inFunction = true; |
---|
410 | maybeAccept_impl( node->statements, *this ); |
---|
411 | maybeAccept_impl( node->attributes, *this ); |
---|
412 | } |
---|
413 | } |
---|
414 | |
---|
415 | VISIT_END( node ); |
---|
416 | } |
---|
417 | |
---|
418 | template< typename pass_type > |
---|
419 | DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) { |
---|
420 | MUTATE_START( node ); |
---|
421 | |
---|
422 | indexerAddId( node ); |
---|
423 | |
---|
424 | { |
---|
425 | // with clause introduces a level of scope (for the with expression members). |
---|
426 | // with clause exprs are added to the indexer before parameters so that parameters |
---|
427 | // shadow with exprs and not the other way around. |
---|
428 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
429 | indexerAddWith( node->withExprs, node ); |
---|
430 | { |
---|
431 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
432 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2 |
---|
433 | static ObjectDecl func( |
---|
434 | "__func__", noStorageClasses, LinkageSpec::C, nullptr, |
---|
435 | new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), |
---|
436 | nullptr |
---|
437 | ); |
---|
438 | indexerAddId( &func ); |
---|
439 | maybeMutate_impl( node->type, *this ); |
---|
440 | // function body needs to have the same scope as parameters - CompoundStmt will not enter |
---|
441 | // a new scope if inFunction is true |
---|
442 | ValueGuard< bool > oldInFunction( inFunction ); |
---|
443 | inFunction = true; |
---|
444 | maybeMutate_impl( node->statements, *this ); |
---|
445 | maybeMutate_impl( node->attributes, *this ); |
---|
446 | } |
---|
447 | } |
---|
448 | |
---|
449 | MUTATE_END( DeclarationWithType, node ); |
---|
450 | } |
---|
451 | |
---|
452 | //-------------------------------------------------------------------------- |
---|
453 | // StructDecl |
---|
454 | template< typename pass_type > |
---|
455 | void PassVisitor< pass_type >::visit( StructDecl * node ) { |
---|
456 | VISIT_START( node ); |
---|
457 | |
---|
458 | // make up a forward declaration and add it before processing the members |
---|
459 | // needs to be on the heap because addStruct saves the pointer |
---|
460 | indexerAddStructFwd( node ); |
---|
461 | |
---|
462 | { |
---|
463 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
464 | maybeAccept_impl( node->parameters, *this ); |
---|
465 | maybeAccept_impl( node->members , *this ); |
---|
466 | } |
---|
467 | |
---|
468 | // this addition replaces the forward declaration |
---|
469 | indexerAddStruct( node ); |
---|
470 | |
---|
471 | VISIT_END( node ); |
---|
472 | } |
---|
473 | |
---|
474 | template< typename pass_type > |
---|
475 | Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) { |
---|
476 | MUTATE_START( node ); |
---|
477 | |
---|
478 | // make up a forward declaration and add it before processing the members |
---|
479 | // needs to be on the heap because addStruct saves the pointer |
---|
480 | indexerAddStructFwd( node ); |
---|
481 | |
---|
482 | { |
---|
483 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
484 | maybeMutate_impl( node->parameters, *this ); |
---|
485 | maybeMutate_impl( node->members , *this ); |
---|
486 | } |
---|
487 | |
---|
488 | // this addition replaces the forward declaration |
---|
489 | indexerAddStruct( node ); |
---|
490 | |
---|
491 | MUTATE_END( Declaration, node ); |
---|
492 | } |
---|
493 | |
---|
494 | //-------------------------------------------------------------------------- |
---|
495 | // UnionDecl |
---|
496 | template< typename pass_type > |
---|
497 | void PassVisitor< pass_type >::visit( UnionDecl * node ) { |
---|
498 | VISIT_START( node ); |
---|
499 | |
---|
500 | // make up a forward declaration and add it before processing the members |
---|
501 | indexerAddUnionFwd( node ); |
---|
502 | |
---|
503 | { |
---|
504 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
505 | maybeAccept_impl( node->parameters, *this ); |
---|
506 | maybeAccept_impl( node->members , *this ); |
---|
507 | } |
---|
508 | |
---|
509 | indexerAddUnion( node ); |
---|
510 | |
---|
511 | VISIT_END( node ); |
---|
512 | } |
---|
513 | |
---|
514 | template< typename pass_type > |
---|
515 | Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) { |
---|
516 | MUTATE_START( node ); |
---|
517 | |
---|
518 | // make up a forward declaration and add it before processing the members |
---|
519 | indexerAddUnionFwd( node ); |
---|
520 | |
---|
521 | { |
---|
522 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
523 | maybeMutate_impl( node->parameters, *this ); |
---|
524 | maybeMutate_impl( node->members , *this ); |
---|
525 | } |
---|
526 | |
---|
527 | indexerAddUnion( node ); |
---|
528 | |
---|
529 | MUTATE_END( Declaration, node ); |
---|
530 | } |
---|
531 | |
---|
532 | //-------------------------------------------------------------------------- |
---|
533 | // EnumDecl |
---|
534 | template< typename pass_type > |
---|
535 | void PassVisitor< pass_type >::visit( EnumDecl * node ) { |
---|
536 | VISIT_START( node ); |
---|
537 | |
---|
538 | indexerAddEnum( node ); |
---|
539 | |
---|
540 | // unlike structs, traits, and unions, enums inject their members into the global scope |
---|
541 | maybeAccept_impl( node->parameters, *this ); |
---|
542 | maybeAccept_impl( node->members , *this ); |
---|
543 | |
---|
544 | VISIT_END( node ); |
---|
545 | } |
---|
546 | |
---|
547 | template< typename pass_type > |
---|
548 | Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) { |
---|
549 | MUTATE_START( node ); |
---|
550 | |
---|
551 | indexerAddEnum( node ); |
---|
552 | |
---|
553 | // unlike structs, traits, and unions, enums inject their members into the global scope |
---|
554 | maybeMutate_impl( node->parameters, *this ); |
---|
555 | maybeMutate_impl( node->members , *this ); |
---|
556 | |
---|
557 | MUTATE_END( Declaration, node ); |
---|
558 | } |
---|
559 | |
---|
560 | //-------------------------------------------------------------------------- |
---|
561 | // TraitDecl |
---|
562 | template< typename pass_type > |
---|
563 | void PassVisitor< pass_type >::visit( TraitDecl * node ) { |
---|
564 | VISIT_START( node ); |
---|
565 | |
---|
566 | { |
---|
567 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
568 | maybeAccept_impl( node->parameters, *this ); |
---|
569 | maybeAccept_impl( node->members , *this ); |
---|
570 | } |
---|
571 | |
---|
572 | indexerAddTrait( node ); |
---|
573 | |
---|
574 | VISIT_END( node ); |
---|
575 | } |
---|
576 | |
---|
577 | template< typename pass_type > |
---|
578 | Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) { |
---|
579 | MUTATE_START( node ); |
---|
580 | |
---|
581 | { |
---|
582 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
583 | maybeMutate_impl( node->parameters, *this ); |
---|
584 | maybeMutate_impl( node->members , *this ); |
---|
585 | } |
---|
586 | |
---|
587 | indexerAddTrait( node ); |
---|
588 | |
---|
589 | MUTATE_END( Declaration, node ); |
---|
590 | } |
---|
591 | |
---|
592 | //-------------------------------------------------------------------------- |
---|
593 | // TypeDecl |
---|
594 | template< typename pass_type > |
---|
595 | void PassVisitor< pass_type >::visit( TypeDecl * node ) { |
---|
596 | VISIT_START( node ); |
---|
597 | |
---|
598 | { |
---|
599 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
600 | maybeAccept_impl( node->parameters, *this ); |
---|
601 | maybeAccept_impl( node->base , *this ); |
---|
602 | } |
---|
603 | |
---|
604 | // see A NOTE ON THE ORDER OF TRAVERSAL, above |
---|
605 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper |
---|
606 | // and may depend on the type itself |
---|
607 | indexerAddType( node ); |
---|
608 | |
---|
609 | maybeAccept_impl( node->assertions, *this ); |
---|
610 | |
---|
611 | indexerScopedAccept( node->init, *this ); |
---|
612 | |
---|
613 | VISIT_END( node ); |
---|
614 | } |
---|
615 | |
---|
616 | template< typename pass_type > |
---|
617 | Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) { |
---|
618 | MUTATE_START( node ); |
---|
619 | |
---|
620 | { |
---|
621 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
622 | maybeMutate_impl( node->parameters, *this ); |
---|
623 | maybeMutate_impl( node->base , *this ); |
---|
624 | } |
---|
625 | |
---|
626 | // see A NOTE ON THE ORDER OF TRAVERSAL, above |
---|
627 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper |
---|
628 | // and may depend on the type itself |
---|
629 | indexerAddType( node ); |
---|
630 | |
---|
631 | maybeMutate_impl( node->assertions, *this ); |
---|
632 | |
---|
633 | indexerScopedMutate( node->init, *this ); |
---|
634 | |
---|
635 | MUTATE_END( Declaration, node ); |
---|
636 | } |
---|
637 | |
---|
638 | //-------------------------------------------------------------------------- |
---|
639 | // TypedefDecl |
---|
640 | template< typename pass_type > |
---|
641 | void PassVisitor< pass_type >::visit( TypedefDecl * node ) { |
---|
642 | VISIT_START( node ); |
---|
643 | |
---|
644 | { |
---|
645 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
646 | maybeAccept_impl( node->parameters, *this ); |
---|
647 | maybeAccept_impl( node->base , *this ); |
---|
648 | } |
---|
649 | |
---|
650 | indexerAddType( node ); |
---|
651 | |
---|
652 | maybeAccept_impl( node->assertions, *this ); |
---|
653 | |
---|
654 | VISIT_END( node ); |
---|
655 | } |
---|
656 | |
---|
657 | template< typename pass_type > |
---|
658 | Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) { |
---|
659 | MUTATE_START( node ); |
---|
660 | |
---|
661 | { |
---|
662 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
663 | maybeMutate_impl( node->parameters, *this ); |
---|
664 | maybeMutate_impl( node->base , *this ); |
---|
665 | } |
---|
666 | |
---|
667 | indexerAddType( node ); |
---|
668 | |
---|
669 | maybeMutate_impl( node->assertions, *this ); |
---|
670 | |
---|
671 | MUTATE_END( Declaration, node ); |
---|
672 | } |
---|
673 | |
---|
674 | //-------------------------------------------------------------------------- |
---|
675 | // AsmDecl |
---|
676 | template< typename pass_type > |
---|
677 | void PassVisitor< pass_type >::visit( AsmDecl * node ) { |
---|
678 | VISIT_START( node ); |
---|
679 | |
---|
680 | maybeAccept_impl( node->stmt, *this ); |
---|
681 | |
---|
682 | VISIT_END( node ); |
---|
683 | } |
---|
684 | |
---|
685 | template< typename pass_type > |
---|
686 | AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) { |
---|
687 | MUTATE_START( node ); |
---|
688 | |
---|
689 | maybeMutate_impl( node->stmt, *this ); |
---|
690 | |
---|
691 | MUTATE_END( AsmDecl, node ); |
---|
692 | } |
---|
693 | |
---|
694 | //-------------------------------------------------------------------------- |
---|
695 | // StaticAssertDecl |
---|
696 | template< typename pass_type > |
---|
697 | void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) { |
---|
698 | VISIT_START( node ); |
---|
699 | |
---|
700 | node->condition = visitExpression( node->condition ); |
---|
701 | maybeAccept_impl( node->message, *this ); |
---|
702 | |
---|
703 | VISIT_END( node ); |
---|
704 | } |
---|
705 | |
---|
706 | template< typename pass_type > |
---|
707 | StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) { |
---|
708 | MUTATE_START( node ); |
---|
709 | |
---|
710 | node->condition = mutateExpression( node->condition ); |
---|
711 | maybeMutate_impl( node->message, *this ); |
---|
712 | |
---|
713 | MUTATE_END( StaticAssertDecl, node ); |
---|
714 | } |
---|
715 | |
---|
716 | //-------------------------------------------------------------------------- |
---|
717 | // CompoundStmt |
---|
718 | template< typename pass_type > |
---|
719 | void PassVisitor< pass_type >::visit( CompoundStmt * node ) { |
---|
720 | VISIT_START( node ); |
---|
721 | { |
---|
722 | // do not enter a new scope if inFunction is true - needs to check old state before the assignment |
---|
723 | ValueGuard< bool > oldInFunction( inFunction ); |
---|
724 | auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } ); |
---|
725 | auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); |
---|
726 | inFunction = false; |
---|
727 | visitStatementList( node->kids ); |
---|
728 | } |
---|
729 | VISIT_END( node ); |
---|
730 | } |
---|
731 | |
---|
732 | template< typename pass_type > |
---|
733 | CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) { |
---|
734 | MUTATE_START( node ); |
---|
735 | { |
---|
736 | // do not enter a new scope if inFunction is true - needs to check old state before the assignment |
---|
737 | ValueGuard< bool > oldInFunction( inFunction ); |
---|
738 | auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } ); |
---|
739 | auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); |
---|
740 | inFunction = false; |
---|
741 | mutateStatementList( node->kids ); |
---|
742 | } |
---|
743 | MUTATE_END( CompoundStmt, node ); |
---|
744 | } |
---|
745 | |
---|
746 | //-------------------------------------------------------------------------- |
---|
747 | // ExprStmt |
---|
748 | template< typename pass_type > |
---|
749 | void PassVisitor< pass_type >::visit( ExprStmt * node ) { |
---|
750 | VISIT_START( node ); |
---|
751 | |
---|
752 | visitExpression( node->expr ); |
---|
753 | |
---|
754 | VISIT_END( node ); |
---|
755 | } |
---|
756 | |
---|
757 | template< typename pass_type > |
---|
758 | Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) { |
---|
759 | MUTATE_START( node ); |
---|
760 | |
---|
761 | node->expr = mutateExpression( node->expr ); |
---|
762 | |
---|
763 | MUTATE_END( Statement, node ); |
---|
764 | } |
---|
765 | |
---|
766 | //-------------------------------------------------------------------------- |
---|
767 | // AsmStmt |
---|
768 | template< typename pass_type > |
---|
769 | void PassVisitor< pass_type >::visit( AsmStmt * node ) { |
---|
770 | VISIT_START( node ) |
---|
771 | |
---|
772 | maybeAccept_impl( node->instruction, *this ); |
---|
773 | maybeAccept_impl( node->output, *this ); |
---|
774 | maybeAccept_impl( node->input, *this ); |
---|
775 | maybeAccept_impl( node->clobber, *this ); |
---|
776 | |
---|
777 | VISIT_END( node ); |
---|
778 | } |
---|
779 | |
---|
780 | template< typename pass_type > |
---|
781 | Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { |
---|
782 | MUTATE_START( node ); |
---|
783 | |
---|
784 | maybeMutate_impl( node->instruction, *this ); |
---|
785 | maybeMutate_impl( node->output, *this ); |
---|
786 | maybeMutate_impl( node->input, *this ); |
---|
787 | maybeMutate_impl( node->clobber, *this ); |
---|
788 | |
---|
789 | MUTATE_END( Statement, node ); |
---|
790 | } |
---|
791 | |
---|
792 | //-------------------------------------------------------------------------- |
---|
793 | // AsmStmt |
---|
794 | template< typename pass_type > |
---|
795 | void PassVisitor< pass_type >::visit( DirectiveStmt * node ) { |
---|
796 | VISIT_START( node ) |
---|
797 | |
---|
798 | VISIT_END( node ); |
---|
799 | } |
---|
800 | |
---|
801 | template< typename pass_type > |
---|
802 | Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) { |
---|
803 | MUTATE_START( node ); |
---|
804 | |
---|
805 | MUTATE_END( Statement, node ); |
---|
806 | } |
---|
807 | |
---|
808 | //-------------------------------------------------------------------------- |
---|
809 | // IfStmt |
---|
810 | template< typename pass_type > |
---|
811 | void PassVisitor< pass_type >::visit( IfStmt * node ) { |
---|
812 | VISIT_START( node ); |
---|
813 | { |
---|
814 | // if statements introduce a level of scope (for the initialization) |
---|
815 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
816 | maybeAccept_impl( node->get_initialization(), *this ); |
---|
817 | visitExpression ( node->condition ); |
---|
818 | node->thenPart = visitStatement( node->thenPart ); |
---|
819 | node->elsePart = visitStatement( node->elsePart ); |
---|
820 | } |
---|
821 | VISIT_END( node ); |
---|
822 | } |
---|
823 | |
---|
824 | template< typename pass_type > |
---|
825 | Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) { |
---|
826 | MUTATE_START( node ); |
---|
827 | { |
---|
828 | // if statements introduce a level of scope (for the initialization) |
---|
829 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
830 | maybeMutate_impl( node->get_initialization(), *this ); |
---|
831 | node->condition = mutateExpression( node->condition ); |
---|
832 | node->thenPart = mutateStatement ( node->thenPart ); |
---|
833 | node->elsePart = mutateStatement ( node->elsePart ); |
---|
834 | } |
---|
835 | MUTATE_END( Statement, node ); |
---|
836 | } |
---|
837 | |
---|
838 | //-------------------------------------------------------------------------- |
---|
839 | // WhileStmt |
---|
840 | template< typename pass_type > |
---|
841 | void PassVisitor< pass_type >::visit( WhileStmt * node ) { |
---|
842 | VISIT_START( node ); |
---|
843 | |
---|
844 | { |
---|
845 | // while statements introduce a level of scope (for the initialization) |
---|
846 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
847 | maybeAccept_impl( node->initialization, *this ); |
---|
848 | visitExpression ( node->condition ); |
---|
849 | node->body = visitStatement( node->body ); |
---|
850 | } |
---|
851 | |
---|
852 | VISIT_END( node ); |
---|
853 | } |
---|
854 | |
---|
855 | template< typename pass_type > |
---|
856 | Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) { |
---|
857 | MUTATE_START( node ); |
---|
858 | |
---|
859 | { |
---|
860 | // while statements introduce a level of scope (for the initialization) |
---|
861 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
862 | maybeMutate_impl( node->initialization, *this ); |
---|
863 | node->condition = mutateExpression( node->condition ); |
---|
864 | node->body = mutateStatement ( node->body ); |
---|
865 | } |
---|
866 | |
---|
867 | |
---|
868 | MUTATE_END( Statement, node ); |
---|
869 | } |
---|
870 | |
---|
871 | //-------------------------------------------------------------------------- |
---|
872 | // ForStmt |
---|
873 | template< typename pass_type > |
---|
874 | void PassVisitor< pass_type >::visit( ForStmt * node ) { |
---|
875 | VISIT_START( node ); |
---|
876 | { |
---|
877 | // for statements introduce a level of scope (for the initialization) |
---|
878 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
879 | maybeAccept_impl( node->initialization, *this ); |
---|
880 | visitExpression( node->condition ); |
---|
881 | visitExpression( node->increment ); |
---|
882 | node->body = visitStatement( node->body ); |
---|
883 | } |
---|
884 | VISIT_END( node ); |
---|
885 | } |
---|
886 | |
---|
887 | template< typename pass_type > |
---|
888 | Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) { |
---|
889 | MUTATE_START( node ); |
---|
890 | { |
---|
891 | // for statements introduce a level of scope (for the initialization) |
---|
892 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
893 | maybeMutate_impl( node->initialization, *this ); |
---|
894 | node->condition = mutateExpression( node->condition ); |
---|
895 | node->increment = mutateExpression( node->increment ); |
---|
896 | node->body = mutateStatement ( node->body ); |
---|
897 | } |
---|
898 | MUTATE_END( Statement, node ); |
---|
899 | } |
---|
900 | |
---|
901 | //-------------------------------------------------------------------------- |
---|
902 | // SwitchStmt |
---|
903 | template< typename pass_type > |
---|
904 | void PassVisitor< pass_type >::visit( SwitchStmt * node ) { |
---|
905 | VISIT_START( node ); |
---|
906 | |
---|
907 | visitExpression ( node->condition ); |
---|
908 | visitStatementList( node->statements ); |
---|
909 | |
---|
910 | VISIT_END( node ); |
---|
911 | } |
---|
912 | |
---|
913 | template< typename pass_type > |
---|
914 | Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) { |
---|
915 | MUTATE_START( node ); |
---|
916 | |
---|
917 | node->condition = mutateExpression( node->condition ); |
---|
918 | mutateStatementList( node->statements ); |
---|
919 | |
---|
920 | MUTATE_END( Statement, node ); |
---|
921 | } |
---|
922 | |
---|
923 | //-------------------------------------------------------------------------- |
---|
924 | // CaseStmt |
---|
925 | template< typename pass_type > |
---|
926 | void PassVisitor< pass_type >::visit( CaseStmt * node ) { |
---|
927 | VISIT_START( node ); |
---|
928 | |
---|
929 | visitExpression ( node->condition ); |
---|
930 | visitStatementList( node->stmts ); |
---|
931 | |
---|
932 | VISIT_END( node ); |
---|
933 | } |
---|
934 | |
---|
935 | template< typename pass_type > |
---|
936 | Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) { |
---|
937 | MUTATE_START( node ); |
---|
938 | |
---|
939 | node->condition = mutateExpression( node->condition ); |
---|
940 | mutateStatementList( node->stmts ); |
---|
941 | |
---|
942 | MUTATE_END( Statement, node ); |
---|
943 | } |
---|
944 | |
---|
945 | //-------------------------------------------------------------------------- |
---|
946 | // BranchStmt |
---|
947 | template< typename pass_type > |
---|
948 | void PassVisitor< pass_type >::visit( BranchStmt * node ) { |
---|
949 | VISIT_START( node ); |
---|
950 | VISIT_END( node ); |
---|
951 | } |
---|
952 | |
---|
953 | template< typename pass_type > |
---|
954 | Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { |
---|
955 | MUTATE_START( node ); |
---|
956 | MUTATE_END( Statement, node ); |
---|
957 | } |
---|
958 | |
---|
959 | //-------------------------------------------------------------------------- |
---|
960 | // ReturnStmt |
---|
961 | template< typename pass_type > |
---|
962 | void PassVisitor< pass_type >::visit( ReturnStmt * node ) { |
---|
963 | VISIT_START( node ); |
---|
964 | |
---|
965 | visitExpression( node->expr ); |
---|
966 | |
---|
967 | VISIT_END( node ); |
---|
968 | } |
---|
969 | |
---|
970 | template< typename pass_type > |
---|
971 | Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) { |
---|
972 | MUTATE_START( node ); |
---|
973 | |
---|
974 | node->expr = mutateExpression( node->expr ); |
---|
975 | |
---|
976 | MUTATE_END( Statement, node ); |
---|
977 | } |
---|
978 | |
---|
979 | //-------------------------------------------------------------------------- |
---|
980 | // ThrowStmt |
---|
981 | |
---|
982 | template< typename pass_type > |
---|
983 | void PassVisitor< pass_type >::visit( ThrowStmt * node ) { |
---|
984 | VISIT_START( node ); |
---|
985 | |
---|
986 | maybeAccept_impl( node->expr, *this ); |
---|
987 | maybeAccept_impl( node->target, *this ); |
---|
988 | |
---|
989 | VISIT_END( node ); |
---|
990 | } |
---|
991 | |
---|
992 | template< typename pass_type > |
---|
993 | Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) { |
---|
994 | MUTATE_START( node ); |
---|
995 | |
---|
996 | maybeMutate_impl( node->expr, *this ); |
---|
997 | maybeMutate_impl( node->target, *this ); |
---|
998 | |
---|
999 | MUTATE_END( Statement, node ); |
---|
1000 | } |
---|
1001 | |
---|
1002 | //-------------------------------------------------------------------------- |
---|
1003 | // TryStmt |
---|
1004 | template< typename pass_type > |
---|
1005 | void PassVisitor< pass_type >::visit( TryStmt * node ) { |
---|
1006 | VISIT_START( node ); |
---|
1007 | |
---|
1008 | maybeAccept_impl( node->block , *this ); |
---|
1009 | maybeAccept_impl( node->handlers , *this ); |
---|
1010 | maybeAccept_impl( node->finallyBlock, *this ); |
---|
1011 | |
---|
1012 | VISIT_END( node ); |
---|
1013 | } |
---|
1014 | |
---|
1015 | template< typename pass_type > |
---|
1016 | Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) { |
---|
1017 | MUTATE_START( node ); |
---|
1018 | |
---|
1019 | maybeMutate_impl( node->block , *this ); |
---|
1020 | maybeMutate_impl( node->handlers , *this ); |
---|
1021 | maybeMutate_impl( node->finallyBlock, *this ); |
---|
1022 | |
---|
1023 | MUTATE_END( Statement, node ); |
---|
1024 | } |
---|
1025 | |
---|
1026 | //-------------------------------------------------------------------------- |
---|
1027 | // CatchStmt |
---|
1028 | template< typename pass_type > |
---|
1029 | void PassVisitor< pass_type >::visit( CatchStmt * node ) { |
---|
1030 | VISIT_START( node ); |
---|
1031 | { |
---|
1032 | // catch statements introduce a level of scope (for the caught exception) |
---|
1033 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
1034 | maybeAccept_impl( node->decl, *this ); |
---|
1035 | node->cond = visitExpression( node->cond ); |
---|
1036 | node->body = visitStatement ( node->body ); |
---|
1037 | } |
---|
1038 | VISIT_END( node ); |
---|
1039 | } |
---|
1040 | |
---|
1041 | template< typename pass_type > |
---|
1042 | Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) { |
---|
1043 | MUTATE_START( node ); |
---|
1044 | { |
---|
1045 | // catch statements introduce a level of scope (for the caught exception) |
---|
1046 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
1047 | maybeMutate_impl( node->decl, *this ); |
---|
1048 | node->cond = mutateExpression( node->cond ); |
---|
1049 | node->body = mutateStatement ( node->body ); |
---|
1050 | } |
---|
1051 | MUTATE_END( Statement, node ); |
---|
1052 | } |
---|
1053 | |
---|
1054 | //-------------------------------------------------------------------------- |
---|
1055 | // FinallyStmt |
---|
1056 | template< typename pass_type > |
---|
1057 | void PassVisitor< pass_type >::visit( FinallyStmt * node ) { |
---|
1058 | VISIT_START( node ); |
---|
1059 | |
---|
1060 | maybeAccept_impl( node->block, *this ); |
---|
1061 | |
---|
1062 | VISIT_END( node ); |
---|
1063 | } |
---|
1064 | |
---|
1065 | template< typename pass_type > |
---|
1066 | Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) { |
---|
1067 | MUTATE_START( node ); |
---|
1068 | |
---|
1069 | maybeMutate_impl( node->block, *this ); |
---|
1070 | |
---|
1071 | MUTATE_END( Statement, node ); |
---|
1072 | } |
---|
1073 | |
---|
1074 | //-------------------------------------------------------------------------- |
---|
1075 | // WaitForStmt |
---|
1076 | template< typename pass_type > |
---|
1077 | void PassVisitor< pass_type >::visit( WaitForStmt * node ) { |
---|
1078 | VISIT_START( node ); |
---|
1079 | |
---|
1080 | for( auto & clause : node->clauses ) { |
---|
1081 | maybeAccept_impl( clause.target.function, *this ); |
---|
1082 | maybeAccept_impl( clause.target.arguments, *this ); |
---|
1083 | |
---|
1084 | maybeAccept_impl( clause.statement, *this ); |
---|
1085 | maybeAccept_impl( clause.condition, *this ); |
---|
1086 | } |
---|
1087 | |
---|
1088 | maybeAccept_impl( node->timeout.time, *this ); |
---|
1089 | maybeAccept_impl( node->timeout.statement, *this ); |
---|
1090 | maybeAccept_impl( node->timeout.condition, *this ); |
---|
1091 | maybeAccept_impl( node->orelse.statement, *this ); |
---|
1092 | maybeAccept_impl( node->orelse.condition, *this ); |
---|
1093 | |
---|
1094 | VISIT_END( node ); |
---|
1095 | } |
---|
1096 | |
---|
1097 | template< typename pass_type > |
---|
1098 | Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) { |
---|
1099 | MUTATE_START( node ); |
---|
1100 | |
---|
1101 | for( auto & clause : node->clauses ) { |
---|
1102 | maybeMutate_impl( clause.target.function, *this ); |
---|
1103 | maybeMutate_impl( clause.target.arguments, *this ); |
---|
1104 | |
---|
1105 | maybeMutate_impl( clause.statement, *this ); |
---|
1106 | maybeMutate_impl( clause.condition, *this ); |
---|
1107 | } |
---|
1108 | |
---|
1109 | maybeMutate_impl( node->timeout.time, *this ); |
---|
1110 | maybeMutate_impl( node->timeout.statement, *this ); |
---|
1111 | maybeMutate_impl( node->timeout.condition, *this ); |
---|
1112 | maybeMutate_impl( node->orelse.statement, *this ); |
---|
1113 | maybeMutate_impl( node->orelse.condition, *this ); |
---|
1114 | |
---|
1115 | MUTATE_END( Statement, node ); |
---|
1116 | } |
---|
1117 | |
---|
1118 | |
---|
1119 | |
---|
1120 | //-------------------------------------------------------------------------- |
---|
1121 | // NullStmt |
---|
1122 | template< typename pass_type > |
---|
1123 | void PassVisitor< pass_type >::visit( WithStmt * node ) { |
---|
1124 | VISIT_START( node ); |
---|
1125 | maybeAccept_impl( node->exprs, *this ); |
---|
1126 | { |
---|
1127 | // catch statements introduce a level of scope (for the caught exception) |
---|
1128 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
1129 | indexerAddWith( node->exprs, node ); |
---|
1130 | maybeAccept_impl( node->stmt, *this ); |
---|
1131 | } |
---|
1132 | VISIT_END( node ); |
---|
1133 | } |
---|
1134 | |
---|
1135 | template< typename pass_type > |
---|
1136 | Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) { |
---|
1137 | MUTATE_START( node ); |
---|
1138 | maybeMutate_impl( node->exprs, *this ); |
---|
1139 | { |
---|
1140 | // catch statements introduce a level of scope (for the caught exception) |
---|
1141 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
1142 | indexerAddWith( node->exprs, node ); |
---|
1143 | maybeMutate_impl( node->stmt, *this ); |
---|
1144 | } |
---|
1145 | MUTATE_END( Statement, node ); |
---|
1146 | } |
---|
1147 | |
---|
1148 | //-------------------------------------------------------------------------- |
---|
1149 | // NullStmt |
---|
1150 | template< typename pass_type > |
---|
1151 | void PassVisitor< pass_type >::visit( NullStmt * node ) { |
---|
1152 | VISIT_START( node ); |
---|
1153 | VISIT_END( node ); |
---|
1154 | } |
---|
1155 | |
---|
1156 | template< typename pass_type > |
---|
1157 | NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) { |
---|
1158 | MUTATE_START( node ); |
---|
1159 | MUTATE_END( NullStmt, node ); |
---|
1160 | } |
---|
1161 | |
---|
1162 | //-------------------------------------------------------------------------- |
---|
1163 | // DeclStmt |
---|
1164 | template< typename pass_type > |
---|
1165 | void PassVisitor< pass_type >::visit( DeclStmt * node ) { |
---|
1166 | VISIT_START( node ); |
---|
1167 | |
---|
1168 | maybeAccept_impl( node->decl, *this ); |
---|
1169 | |
---|
1170 | VISIT_END( node ); |
---|
1171 | } |
---|
1172 | |
---|
1173 | template< typename pass_type > |
---|
1174 | Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) { |
---|
1175 | MUTATE_START( node ); |
---|
1176 | |
---|
1177 | maybeMutate_impl( node->decl, *this ); |
---|
1178 | |
---|
1179 | MUTATE_END( Statement, node ); |
---|
1180 | } |
---|
1181 | |
---|
1182 | //-------------------------------------------------------------------------- |
---|
1183 | // ImplicitCtorDtorStmt |
---|
1184 | template< typename pass_type > |
---|
1185 | void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) { |
---|
1186 | VISIT_START( node ); |
---|
1187 | |
---|
1188 | maybeAccept_impl( node->callStmt, *this ); |
---|
1189 | |
---|
1190 | VISIT_END( node ); |
---|
1191 | } |
---|
1192 | |
---|
1193 | template< typename pass_type > |
---|
1194 | Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) { |
---|
1195 | MUTATE_START( node ); |
---|
1196 | |
---|
1197 | maybeMutate_impl( node->callStmt, *this ); |
---|
1198 | |
---|
1199 | MUTATE_END( Statement, node ); |
---|
1200 | } |
---|
1201 | |
---|
1202 | //-------------------------------------------------------------------------- |
---|
1203 | // ApplicationExpr |
---|
1204 | template< typename pass_type > |
---|
1205 | void PassVisitor< pass_type >::visit( ApplicationExpr * node ) { |
---|
1206 | VISIT_START( node ); |
---|
1207 | |
---|
1208 | indexerScopedAccept( node->result , *this ); |
---|
1209 | maybeAccept_impl ( node->function, *this ); |
---|
1210 | maybeAccept_impl ( node->args , *this ); |
---|
1211 | |
---|
1212 | VISIT_END( node ); |
---|
1213 | } |
---|
1214 | |
---|
1215 | template< typename pass_type > |
---|
1216 | Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) { |
---|
1217 | MUTATE_START( node ); |
---|
1218 | |
---|
1219 | indexerScopedMutate( node->env , *this ); |
---|
1220 | indexerScopedMutate( node->result , *this ); |
---|
1221 | maybeMutate_impl ( node->function, *this ); |
---|
1222 | maybeMutate_impl ( node->args , *this ); |
---|
1223 | |
---|
1224 | MUTATE_END( Expression, node ); |
---|
1225 | } |
---|
1226 | |
---|
1227 | //-------------------------------------------------------------------------- |
---|
1228 | // UntypedExpr |
---|
1229 | template< typename pass_type > |
---|
1230 | void PassVisitor< pass_type >::visit( UntypedExpr * node ) { |
---|
1231 | VISIT_START( node ); |
---|
1232 | |
---|
1233 | // maybeAccept_impl( node->get_env(), *this ); |
---|
1234 | indexerScopedAccept( node->result, *this ); |
---|
1235 | |
---|
1236 | for ( auto expr : node->args ) { |
---|
1237 | visitExpression( expr ); |
---|
1238 | } |
---|
1239 | |
---|
1240 | VISIT_END( node ); |
---|
1241 | } |
---|
1242 | |
---|
1243 | template< typename pass_type > |
---|
1244 | Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) { |
---|
1245 | MUTATE_START( node ); |
---|
1246 | |
---|
1247 | indexerScopedMutate( node->env , *this ); |
---|
1248 | indexerScopedMutate( node->result, *this ); |
---|
1249 | |
---|
1250 | for ( auto& expr : node->args ) { |
---|
1251 | expr = mutateExpression( expr ); |
---|
1252 | } |
---|
1253 | |
---|
1254 | MUTATE_END( Expression, node ); |
---|
1255 | } |
---|
1256 | |
---|
1257 | //-------------------------------------------------------------------------- |
---|
1258 | // NameExpr |
---|
1259 | template< typename pass_type > |
---|
1260 | void PassVisitor< pass_type >::visit( NameExpr * node ) { |
---|
1261 | VISIT_START( node ); |
---|
1262 | |
---|
1263 | indexerScopedAccept( node->result, *this ); |
---|
1264 | |
---|
1265 | VISIT_END( node ); |
---|
1266 | } |
---|
1267 | |
---|
1268 | template< typename pass_type > |
---|
1269 | Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) { |
---|
1270 | MUTATE_START( node ); |
---|
1271 | |
---|
1272 | indexerScopedMutate( node->env , *this ); |
---|
1273 | indexerScopedMutate( node->result, *this ); |
---|
1274 | |
---|
1275 | MUTATE_END( Expression, node ); |
---|
1276 | } |
---|
1277 | |
---|
1278 | //-------------------------------------------------------------------------- |
---|
1279 | // CastExpr |
---|
1280 | template< typename pass_type > |
---|
1281 | void PassVisitor< pass_type >::visit( CastExpr * node ) { |
---|
1282 | VISIT_START( node ); |
---|
1283 | |
---|
1284 | indexerScopedAccept( node->result, *this ); |
---|
1285 | maybeAccept_impl ( node->arg , *this ); |
---|
1286 | |
---|
1287 | VISIT_END( node ); |
---|
1288 | } |
---|
1289 | |
---|
1290 | template< typename pass_type > |
---|
1291 | Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) { |
---|
1292 | MUTATE_START( node ); |
---|
1293 | |
---|
1294 | indexerScopedMutate( node->env , *this ); |
---|
1295 | indexerScopedMutate( node->result, *this ); |
---|
1296 | maybeMutate_impl ( node->arg , *this ); |
---|
1297 | |
---|
1298 | MUTATE_END( Expression, node ); |
---|
1299 | } |
---|
1300 | |
---|
1301 | //-------------------------------------------------------------------------- |
---|
1302 | // KeywordCastExpr |
---|
1303 | template< typename pass_type > |
---|
1304 | void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) { |
---|
1305 | VISIT_START( node ); |
---|
1306 | |
---|
1307 | indexerScopedAccept( node->result, *this ); |
---|
1308 | maybeAccept_impl ( node->arg , *this ); |
---|
1309 | |
---|
1310 | VISIT_END( node ); |
---|
1311 | } |
---|
1312 | |
---|
1313 | template< typename pass_type > |
---|
1314 | Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) { |
---|
1315 | MUTATE_START( node ); |
---|
1316 | |
---|
1317 | indexerScopedMutate( node->env , *this ); |
---|
1318 | indexerScopedMutate( node->result, *this ); |
---|
1319 | maybeMutate_impl ( node->arg , *this ); |
---|
1320 | |
---|
1321 | MUTATE_END( Expression, node ); |
---|
1322 | } |
---|
1323 | |
---|
1324 | //-------------------------------------------------------------------------- |
---|
1325 | // VirtualCastExpr |
---|
1326 | template< typename pass_type > |
---|
1327 | void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) { |
---|
1328 | VISIT_START( node ); |
---|
1329 | |
---|
1330 | indexerScopedAccept( node->result, *this ); |
---|
1331 | maybeAccept_impl( node->arg, *this ); |
---|
1332 | |
---|
1333 | VISIT_END( node ); |
---|
1334 | } |
---|
1335 | |
---|
1336 | template< typename pass_type > |
---|
1337 | Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) { |
---|
1338 | MUTATE_START( node ); |
---|
1339 | |
---|
1340 | indexerScopedMutate( node->env , *this ); |
---|
1341 | indexerScopedMutate( node->result, *this ); |
---|
1342 | maybeMutate_impl ( node->arg , *this ); |
---|
1343 | |
---|
1344 | MUTATE_END( Expression, node ); |
---|
1345 | } |
---|
1346 | |
---|
1347 | //-------------------------------------------------------------------------- |
---|
1348 | // AddressExpr |
---|
1349 | template< typename pass_type > |
---|
1350 | void PassVisitor< pass_type >::visit( AddressExpr * node ) { |
---|
1351 | VISIT_START( node ); |
---|
1352 | |
---|
1353 | indexerScopedAccept( node->result, *this ); |
---|
1354 | maybeAccept_impl ( node->arg , *this ); |
---|
1355 | |
---|
1356 | VISIT_END( node ); |
---|
1357 | } |
---|
1358 | |
---|
1359 | template< typename pass_type > |
---|
1360 | Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) { |
---|
1361 | MUTATE_START( node ); |
---|
1362 | |
---|
1363 | indexerScopedMutate( node->env , *this ); |
---|
1364 | indexerScopedMutate( node->result, *this ); |
---|
1365 | maybeMutate_impl ( node->arg , *this ); |
---|
1366 | |
---|
1367 | MUTATE_END( Expression, node ); |
---|
1368 | } |
---|
1369 | |
---|
1370 | //-------------------------------------------------------------------------- |
---|
1371 | // LabelAddressExpr |
---|
1372 | template< typename pass_type > |
---|
1373 | void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) { |
---|
1374 | VISIT_START( node ); |
---|
1375 | |
---|
1376 | indexerScopedAccept( node->result, *this ); |
---|
1377 | |
---|
1378 | VISIT_END( node ); |
---|
1379 | } |
---|
1380 | |
---|
1381 | template< typename pass_type > |
---|
1382 | Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) { |
---|
1383 | MUTATE_START( node ); |
---|
1384 | |
---|
1385 | indexerScopedMutate( node->env , *this ); |
---|
1386 | indexerScopedMutate( node->result, *this ); |
---|
1387 | |
---|
1388 | MUTATE_END( Expression, node ); |
---|
1389 | } |
---|
1390 | |
---|
1391 | //-------------------------------------------------------------------------- |
---|
1392 | // UntypedMemberExpr |
---|
1393 | template< typename pass_type > |
---|
1394 | void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) { |
---|
1395 | VISIT_START( node ); |
---|
1396 | |
---|
1397 | indexerScopedAccept( node->result , *this ); |
---|
1398 | maybeAccept_impl ( node->aggregate, *this ); |
---|
1399 | maybeAccept_impl ( node->member , *this ); |
---|
1400 | |
---|
1401 | VISIT_END( node ); |
---|
1402 | } |
---|
1403 | |
---|
1404 | template< typename pass_type > |
---|
1405 | Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) { |
---|
1406 | MUTATE_START( node ); |
---|
1407 | |
---|
1408 | indexerScopedMutate( node->env , *this ); |
---|
1409 | indexerScopedMutate( node->result , *this ); |
---|
1410 | maybeMutate_impl ( node->aggregate, *this ); |
---|
1411 | maybeMutate_impl ( node->member , *this ); |
---|
1412 | |
---|
1413 | MUTATE_END( Expression, node ); |
---|
1414 | } |
---|
1415 | |
---|
1416 | //-------------------------------------------------------------------------- |
---|
1417 | // MemberExpr |
---|
1418 | template< typename pass_type > |
---|
1419 | void PassVisitor< pass_type >::visit( MemberExpr * node ) { |
---|
1420 | VISIT_START( node ); |
---|
1421 | |
---|
1422 | indexerScopedAccept( node->result , *this ); |
---|
1423 | maybeAccept_impl ( node->aggregate, *this ); |
---|
1424 | |
---|
1425 | VISIT_END( node ); |
---|
1426 | } |
---|
1427 | |
---|
1428 | template< typename pass_type > |
---|
1429 | Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) { |
---|
1430 | MUTATE_START( node ); |
---|
1431 | |
---|
1432 | indexerScopedMutate( node->env , *this ); |
---|
1433 | indexerScopedMutate( node->result , *this ); |
---|
1434 | maybeMutate_impl ( node->aggregate, *this ); |
---|
1435 | |
---|
1436 | MUTATE_END( Expression, node ); |
---|
1437 | } |
---|
1438 | |
---|
1439 | //-------------------------------------------------------------------------- |
---|
1440 | // VariableExpr |
---|
1441 | template< typename pass_type > |
---|
1442 | void PassVisitor< pass_type >::visit( VariableExpr * node ) { |
---|
1443 | VISIT_START( node ); |
---|
1444 | |
---|
1445 | indexerScopedAccept( node->result, *this ); |
---|
1446 | |
---|
1447 | VISIT_END( node ); |
---|
1448 | } |
---|
1449 | |
---|
1450 | template< typename pass_type > |
---|
1451 | Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) { |
---|
1452 | MUTATE_START( node ); |
---|
1453 | |
---|
1454 | indexerScopedMutate( node->env , *this ); |
---|
1455 | indexerScopedMutate( node->result, *this ); |
---|
1456 | |
---|
1457 | MUTATE_END( Expression, node ); |
---|
1458 | } |
---|
1459 | |
---|
1460 | //-------------------------------------------------------------------------- |
---|
1461 | // ConstantExpr |
---|
1462 | template< typename pass_type > |
---|
1463 | void PassVisitor< pass_type >::visit( ConstantExpr * node ) { |
---|
1464 | VISIT_START( node ); |
---|
1465 | |
---|
1466 | indexerScopedAccept( node->result , *this ); |
---|
1467 | maybeAccept_impl ( &node->constant, *this ); |
---|
1468 | |
---|
1469 | VISIT_END( node ); |
---|
1470 | } |
---|
1471 | |
---|
1472 | template< typename pass_type > |
---|
1473 | Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) { |
---|
1474 | MUTATE_START( node ); |
---|
1475 | |
---|
1476 | indexerScopedMutate( node->env , *this ); |
---|
1477 | indexerScopedMutate( node->result, *this ); |
---|
1478 | Constant * ptr = &node->constant; |
---|
1479 | maybeMutate_impl( ptr, *this ); |
---|
1480 | node->constant = *ptr; |
---|
1481 | |
---|
1482 | MUTATE_END( Expression, node ); |
---|
1483 | } |
---|
1484 | |
---|
1485 | //-------------------------------------------------------------------------- |
---|
1486 | // SizeofExpr |
---|
1487 | template< typename pass_type > |
---|
1488 | void PassVisitor< pass_type >::visit( SizeofExpr * node ) { |
---|
1489 | VISIT_START( node ); |
---|
1490 | |
---|
1491 | indexerScopedAccept( node->result, *this ); |
---|
1492 | if ( node->get_isType() ) { |
---|
1493 | maybeAccept_impl( node->type, *this ); |
---|
1494 | } else { |
---|
1495 | maybeAccept_impl( node->expr, *this ); |
---|
1496 | } |
---|
1497 | |
---|
1498 | VISIT_END( node ); |
---|
1499 | } |
---|
1500 | |
---|
1501 | template< typename pass_type > |
---|
1502 | Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) { |
---|
1503 | MUTATE_START( node ); |
---|
1504 | |
---|
1505 | indexerScopedMutate( node->env , *this ); |
---|
1506 | indexerScopedMutate( node->result, *this ); |
---|
1507 | if ( node->get_isType() ) { |
---|
1508 | maybeMutate_impl( node->type, *this ); |
---|
1509 | } else { |
---|
1510 | maybeMutate_impl( node->expr, *this ); |
---|
1511 | } |
---|
1512 | |
---|
1513 | MUTATE_END( Expression, node ); |
---|
1514 | } |
---|
1515 | |
---|
1516 | //-------------------------------------------------------------------------- |
---|
1517 | // AlignofExpr |
---|
1518 | template< typename pass_type > |
---|
1519 | void PassVisitor< pass_type >::visit( AlignofExpr * node ) { |
---|
1520 | VISIT_START( node ); |
---|
1521 | |
---|
1522 | indexerScopedAccept( node->result, *this ); |
---|
1523 | if ( node->get_isType() ) { |
---|
1524 | maybeAccept_impl( node->type, *this ); |
---|
1525 | } else { |
---|
1526 | maybeAccept_impl( node->expr, *this ); |
---|
1527 | } |
---|
1528 | |
---|
1529 | VISIT_END( node ); |
---|
1530 | } |
---|
1531 | |
---|
1532 | template< typename pass_type > |
---|
1533 | Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) { |
---|
1534 | MUTATE_START( node ); |
---|
1535 | |
---|
1536 | indexerScopedMutate( node->env , *this ); |
---|
1537 | indexerScopedMutate( node->result, *this ); |
---|
1538 | if ( node->get_isType() ) { |
---|
1539 | maybeMutate_impl( node->type, *this ); |
---|
1540 | } else { |
---|
1541 | maybeMutate_impl( node->expr, *this ); |
---|
1542 | } |
---|
1543 | |
---|
1544 | MUTATE_END( Expression, node ); |
---|
1545 | } |
---|
1546 | |
---|
1547 | //-------------------------------------------------------------------------- |
---|
1548 | // UntypedOffsetofExpr |
---|
1549 | template< typename pass_type > |
---|
1550 | void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) { |
---|
1551 | VISIT_START( node ); |
---|
1552 | |
---|
1553 | indexerScopedAccept( node->result, *this ); |
---|
1554 | maybeAccept_impl ( node->type , *this ); |
---|
1555 | |
---|
1556 | VISIT_END( node ); |
---|
1557 | } |
---|
1558 | |
---|
1559 | template< typename pass_type > |
---|
1560 | Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) { |
---|
1561 | MUTATE_START( node ); |
---|
1562 | |
---|
1563 | indexerScopedMutate( node->env , *this ); |
---|
1564 | indexerScopedMutate( node->result, *this ); |
---|
1565 | maybeMutate_impl ( node->type , *this ); |
---|
1566 | |
---|
1567 | MUTATE_END( Expression, node ); |
---|
1568 | } |
---|
1569 | |
---|
1570 | //-------------------------------------------------------------------------- |
---|
1571 | // OffsetofExpr |
---|
1572 | template< typename pass_type > |
---|
1573 | void PassVisitor< pass_type >::visit( OffsetofExpr * node ) { |
---|
1574 | VISIT_START( node ); |
---|
1575 | |
---|
1576 | indexerScopedAccept( node->result, *this ); |
---|
1577 | maybeAccept_impl ( node->type , *this ); |
---|
1578 | |
---|
1579 | VISIT_END( node ); |
---|
1580 | } |
---|
1581 | |
---|
1582 | template< typename pass_type > |
---|
1583 | Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) { |
---|
1584 | MUTATE_START( node ); |
---|
1585 | |
---|
1586 | indexerScopedMutate( node->env , *this ); |
---|
1587 | indexerScopedMutate( node->result, *this ); |
---|
1588 | maybeMutate_impl ( node->type , *this ); |
---|
1589 | |
---|
1590 | MUTATE_END( Expression, node ); |
---|
1591 | } |
---|
1592 | |
---|
1593 | //-------------------------------------------------------------------------- |
---|
1594 | // OffsetPackExpr |
---|
1595 | template< typename pass_type > |
---|
1596 | void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) { |
---|
1597 | VISIT_START( node ); |
---|
1598 | |
---|
1599 | indexerScopedAccept( node->result, *this ); |
---|
1600 | maybeAccept_impl ( node->type , *this ); |
---|
1601 | |
---|
1602 | VISIT_END( node ); |
---|
1603 | } |
---|
1604 | |
---|
1605 | template< typename pass_type > |
---|
1606 | Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) { |
---|
1607 | MUTATE_START( node ); |
---|
1608 | |
---|
1609 | indexerScopedMutate( node->env , *this ); |
---|
1610 | indexerScopedMutate( node->result, *this ); |
---|
1611 | maybeMutate_impl ( node->type , *this ); |
---|
1612 | |
---|
1613 | MUTATE_END( Expression, node ); |
---|
1614 | } |
---|
1615 | |
---|
1616 | //-------------------------------------------------------------------------- |
---|
1617 | // AttrExpr |
---|
1618 | template< typename pass_type > |
---|
1619 | void PassVisitor< pass_type >::visit( AttrExpr * node ) { |
---|
1620 | VISIT_START( node ); |
---|
1621 | |
---|
1622 | indexerScopedAccept( node->result, *this ); |
---|
1623 | if ( node->get_isType() ) { |
---|
1624 | maybeAccept_impl( node->type, *this ); |
---|
1625 | } else { |
---|
1626 | maybeAccept_impl( node->expr, *this ); |
---|
1627 | } |
---|
1628 | |
---|
1629 | VISIT_END( node ); |
---|
1630 | } |
---|
1631 | |
---|
1632 | template< typename pass_type > |
---|
1633 | Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) { |
---|
1634 | MUTATE_START( node ); |
---|
1635 | |
---|
1636 | indexerScopedMutate( node->env , *this ); |
---|
1637 | indexerScopedMutate( node->result, *this ); |
---|
1638 | if ( node->get_isType() ) { |
---|
1639 | maybeMutate_impl( node->type, *this ); |
---|
1640 | } else { |
---|
1641 | maybeMutate_impl( node->expr, *this ); |
---|
1642 | } |
---|
1643 | |
---|
1644 | MUTATE_END( Expression, node ); |
---|
1645 | } |
---|
1646 | |
---|
1647 | //-------------------------------------------------------------------------- |
---|
1648 | // LogicalExpr |
---|
1649 | template< typename pass_type > |
---|
1650 | void PassVisitor< pass_type >::visit( LogicalExpr * node ) { |
---|
1651 | VISIT_START( node ); |
---|
1652 | |
---|
1653 | indexerScopedAccept( node->result, *this ); |
---|
1654 | maybeAccept_impl ( node->arg1 , *this ); |
---|
1655 | maybeAccept_impl ( node->arg2 , *this ); |
---|
1656 | |
---|
1657 | VISIT_END( node ); |
---|
1658 | } |
---|
1659 | |
---|
1660 | template< typename pass_type > |
---|
1661 | Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) { |
---|
1662 | MUTATE_START( node ); |
---|
1663 | |
---|
1664 | indexerScopedMutate( node->env , *this ); |
---|
1665 | indexerScopedMutate( node->result, *this ); |
---|
1666 | maybeMutate_impl ( node->arg1 , *this ); |
---|
1667 | maybeMutate_impl ( node->arg2 , *this ); |
---|
1668 | |
---|
1669 | MUTATE_END( Expression, node ); |
---|
1670 | } |
---|
1671 | |
---|
1672 | //-------------------------------------------------------------------------- |
---|
1673 | // ConditionalExpr |
---|
1674 | template< typename pass_type > |
---|
1675 | void PassVisitor< pass_type >::visit( ConditionalExpr * node ) { |
---|
1676 | VISIT_START( node ); |
---|
1677 | |
---|
1678 | indexerScopedAccept( node->result, *this ); |
---|
1679 | maybeAccept_impl ( node->arg1 , *this ); |
---|
1680 | maybeAccept_impl ( node->arg2 , *this ); |
---|
1681 | maybeAccept_impl ( node->arg3 , *this ); |
---|
1682 | |
---|
1683 | VISIT_END( node ); |
---|
1684 | } |
---|
1685 | |
---|
1686 | template< typename pass_type > |
---|
1687 | Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) { |
---|
1688 | MUTATE_START( node ); |
---|
1689 | |
---|
1690 | indexerScopedMutate( node->env , *this ); |
---|
1691 | indexerScopedMutate( node->result, *this ); |
---|
1692 | maybeMutate_impl ( node->arg1 , *this ); |
---|
1693 | maybeMutate_impl ( node->arg2 , *this ); |
---|
1694 | maybeMutate_impl ( node->arg3 , *this ); |
---|
1695 | |
---|
1696 | MUTATE_END( Expression, node ); |
---|
1697 | } |
---|
1698 | |
---|
1699 | //-------------------------------------------------------------------------- |
---|
1700 | // CommaExpr |
---|
1701 | template< typename pass_type > |
---|
1702 | void PassVisitor< pass_type >::visit( CommaExpr * node ) { |
---|
1703 | VISIT_START( node ); |
---|
1704 | |
---|
1705 | indexerScopedAccept( node->result, *this ); |
---|
1706 | maybeAccept_impl ( node->arg1 , *this ); |
---|
1707 | maybeAccept_impl ( node->arg2 , *this ); |
---|
1708 | |
---|
1709 | VISIT_END( node ); |
---|
1710 | } |
---|
1711 | |
---|
1712 | template< typename pass_type > |
---|
1713 | Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) { |
---|
1714 | MUTATE_START( node ); |
---|
1715 | |
---|
1716 | indexerScopedMutate( node->env , *this ); |
---|
1717 | indexerScopedMutate( node->result, *this ); |
---|
1718 | maybeMutate_impl ( node->arg1 , *this ); |
---|
1719 | maybeMutate_impl ( node->arg2 , *this ); |
---|
1720 | |
---|
1721 | MUTATE_END( Expression, node ); |
---|
1722 | } |
---|
1723 | |
---|
1724 | //-------------------------------------------------------------------------- |
---|
1725 | // TypeExpr |
---|
1726 | template< typename pass_type > |
---|
1727 | void PassVisitor< pass_type >::visit( TypeExpr * node ) { |
---|
1728 | VISIT_START( node ); |
---|
1729 | |
---|
1730 | indexerScopedAccept( node->result, *this ); |
---|
1731 | maybeAccept_impl ( node->type, *this ); |
---|
1732 | |
---|
1733 | VISIT_END( node ); |
---|
1734 | } |
---|
1735 | |
---|
1736 | template< typename pass_type > |
---|
1737 | Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) { |
---|
1738 | MUTATE_START( node ); |
---|
1739 | |
---|
1740 | indexerScopedMutate( node->env , *this ); |
---|
1741 | indexerScopedMutate( node->result, *this ); |
---|
1742 | maybeMutate_impl ( node->type , *this ); |
---|
1743 | |
---|
1744 | MUTATE_END( Expression, node ); |
---|
1745 | } |
---|
1746 | |
---|
1747 | //-------------------------------------------------------------------------- |
---|
1748 | // AsmExpr |
---|
1749 | template< typename pass_type > |
---|
1750 | void PassVisitor< pass_type >::visit( AsmExpr * node ) { |
---|
1751 | VISIT_START( node ); |
---|
1752 | |
---|
1753 | indexerScopedAccept( node->result , *this ); |
---|
1754 | maybeAccept_impl ( node->inout , *this ); |
---|
1755 | maybeAccept_impl ( node->constraint, *this ); |
---|
1756 | maybeAccept_impl ( node->operand , *this ); |
---|
1757 | |
---|
1758 | VISIT_END( node ); |
---|
1759 | } |
---|
1760 | |
---|
1761 | template< typename pass_type > |
---|
1762 | Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) { |
---|
1763 | MUTATE_START( node ); |
---|
1764 | |
---|
1765 | indexerScopedMutate( node->env , *this ); |
---|
1766 | indexerScopedMutate( node->result , *this ); |
---|
1767 | maybeMutate_impl ( node->inout , *this ); |
---|
1768 | maybeMutate_impl ( node->constraint, *this ); |
---|
1769 | maybeMutate_impl ( node->operand , *this ); |
---|
1770 | |
---|
1771 | MUTATE_END( Expression, node ); |
---|
1772 | } |
---|
1773 | |
---|
1774 | //-------------------------------------------------------------------------- |
---|
1775 | // ImplicitCopyCtorExpr |
---|
1776 | template< typename pass_type > |
---|
1777 | void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) { |
---|
1778 | VISIT_START( node ); |
---|
1779 | |
---|
1780 | indexerScopedAccept( node->result , *this ); |
---|
1781 | maybeAccept_impl ( node->callExpr , *this ); |
---|
1782 | |
---|
1783 | VISIT_END( node ); |
---|
1784 | } |
---|
1785 | |
---|
1786 | template< typename pass_type > |
---|
1787 | Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) { |
---|
1788 | MUTATE_START( node ); |
---|
1789 | |
---|
1790 | indexerScopedMutate( node->env , *this ); |
---|
1791 | indexerScopedMutate( node->result , *this ); |
---|
1792 | maybeMutate_impl ( node->callExpr , *this ); |
---|
1793 | |
---|
1794 | MUTATE_END( Expression, node ); |
---|
1795 | } |
---|
1796 | |
---|
1797 | //-------------------------------------------------------------------------- |
---|
1798 | // ConstructorExpr |
---|
1799 | template< typename pass_type > |
---|
1800 | void PassVisitor< pass_type >::visit( ConstructorExpr * node ) { |
---|
1801 | VISIT_START( node ); |
---|
1802 | |
---|
1803 | indexerScopedAccept( node->result , *this ); |
---|
1804 | maybeAccept_impl ( node->callExpr, *this ); |
---|
1805 | |
---|
1806 | VISIT_END( node ); |
---|
1807 | } |
---|
1808 | |
---|
1809 | template< typename pass_type > |
---|
1810 | Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) { |
---|
1811 | MUTATE_START( node ); |
---|
1812 | |
---|
1813 | indexerScopedMutate( node->env , *this ); |
---|
1814 | indexerScopedMutate( node->result , *this ); |
---|
1815 | maybeMutate_impl ( node->callExpr, *this ); |
---|
1816 | |
---|
1817 | MUTATE_END( Expression, node ); |
---|
1818 | } |
---|
1819 | |
---|
1820 | //-------------------------------------------------------------------------- |
---|
1821 | // CompoundLiteralExpr |
---|
1822 | template< typename pass_type > |
---|
1823 | void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) { |
---|
1824 | VISIT_START( node ); |
---|
1825 | |
---|
1826 | indexerScopedAccept( node->result , *this ); |
---|
1827 | maybeAccept_impl ( node->initializer, *this ); |
---|
1828 | |
---|
1829 | VISIT_END( node ); |
---|
1830 | } |
---|
1831 | |
---|
1832 | template< typename pass_type > |
---|
1833 | Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) { |
---|
1834 | MUTATE_START( node ); |
---|
1835 | |
---|
1836 | indexerScopedMutate( node->env , *this ); |
---|
1837 | indexerScopedMutate( node->result , *this ); |
---|
1838 | maybeMutate_impl ( node->initializer, *this ); |
---|
1839 | |
---|
1840 | MUTATE_END( Expression, node ); |
---|
1841 | } |
---|
1842 | |
---|
1843 | //-------------------------------------------------------------------------- |
---|
1844 | // RangeExpr |
---|
1845 | template< typename pass_type > |
---|
1846 | void PassVisitor< pass_type >::visit( RangeExpr * node ) { |
---|
1847 | VISIT_START( node ); |
---|
1848 | |
---|
1849 | indexerScopedAccept( node->result, *this ); |
---|
1850 | maybeAccept_impl ( node->low , *this ); |
---|
1851 | maybeAccept_impl ( node->high , *this ); |
---|
1852 | |
---|
1853 | VISIT_END( node ); |
---|
1854 | } |
---|
1855 | |
---|
1856 | template< typename pass_type > |
---|
1857 | Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) { |
---|
1858 | MUTATE_START( node ); |
---|
1859 | |
---|
1860 | indexerScopedMutate( node->env , *this ); |
---|
1861 | indexerScopedMutate( node->result, *this ); |
---|
1862 | maybeMutate_impl ( node->low , *this ); |
---|
1863 | maybeMutate_impl ( node->high , *this ); |
---|
1864 | |
---|
1865 | MUTATE_END( Expression, node ); |
---|
1866 | } |
---|
1867 | |
---|
1868 | //-------------------------------------------------------------------------- |
---|
1869 | // UntypedTupleExpr |
---|
1870 | template< typename pass_type > |
---|
1871 | void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) { |
---|
1872 | VISIT_START( node ); |
---|
1873 | |
---|
1874 | indexerScopedAccept( node->result, *this ); |
---|
1875 | maybeAccept_impl ( node->exprs , *this ); |
---|
1876 | |
---|
1877 | VISIT_END( node ); |
---|
1878 | } |
---|
1879 | |
---|
1880 | template< typename pass_type > |
---|
1881 | Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) { |
---|
1882 | MUTATE_START( node ); |
---|
1883 | |
---|
1884 | indexerScopedMutate( node->env , *this ); |
---|
1885 | indexerScopedMutate( node->result, *this ); |
---|
1886 | maybeMutate_impl ( node->exprs , *this ); |
---|
1887 | |
---|
1888 | MUTATE_END( Expression, node ); |
---|
1889 | } |
---|
1890 | |
---|
1891 | //-------------------------------------------------------------------------- |
---|
1892 | // TupleExpr |
---|
1893 | template< typename pass_type > |
---|
1894 | void PassVisitor< pass_type >::visit( TupleExpr * node ) { |
---|
1895 | VISIT_START( node ); |
---|
1896 | |
---|
1897 | indexerScopedAccept( node->result, *this ); |
---|
1898 | maybeAccept_impl ( node->exprs , *this ); |
---|
1899 | |
---|
1900 | VISIT_END( node ); |
---|
1901 | } |
---|
1902 | |
---|
1903 | template< typename pass_type > |
---|
1904 | Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) { |
---|
1905 | MUTATE_START( node ); |
---|
1906 | |
---|
1907 | indexerScopedMutate( node->env , *this ); |
---|
1908 | indexerScopedMutate( node->result, *this ); |
---|
1909 | maybeMutate_impl ( node->exprs , *this ); |
---|
1910 | |
---|
1911 | MUTATE_END( Expression, node ); |
---|
1912 | } |
---|
1913 | |
---|
1914 | //-------------------------------------------------------------------------- |
---|
1915 | // TupleIndexExpr |
---|
1916 | template< typename pass_type > |
---|
1917 | void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) { |
---|
1918 | VISIT_START( node ); |
---|
1919 | |
---|
1920 | indexerScopedAccept( node->result, *this ); |
---|
1921 | maybeAccept_impl ( node->tuple , *this ); |
---|
1922 | |
---|
1923 | VISIT_END( node ); |
---|
1924 | } |
---|
1925 | |
---|
1926 | template< typename pass_type > |
---|
1927 | Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) { |
---|
1928 | MUTATE_START( node ); |
---|
1929 | |
---|
1930 | indexerScopedMutate( node->env , *this ); |
---|
1931 | indexerScopedMutate( node->result, *this ); |
---|
1932 | maybeMutate_impl ( node->tuple , *this ); |
---|
1933 | |
---|
1934 | MUTATE_END( Expression, node ); |
---|
1935 | } |
---|
1936 | |
---|
1937 | //-------------------------------------------------------------------------- |
---|
1938 | // TupleAssignExpr |
---|
1939 | template< typename pass_type > |
---|
1940 | void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) { |
---|
1941 | VISIT_START( node ); |
---|
1942 | |
---|
1943 | indexerScopedAccept( node->result , *this ); |
---|
1944 | maybeAccept_impl ( node->stmtExpr, *this ); |
---|
1945 | |
---|
1946 | VISIT_END( node ); |
---|
1947 | } |
---|
1948 | |
---|
1949 | template< typename pass_type > |
---|
1950 | Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) { |
---|
1951 | MUTATE_START( node ); |
---|
1952 | |
---|
1953 | indexerScopedMutate( node->env , *this ); |
---|
1954 | indexerScopedMutate( node->result , *this ); |
---|
1955 | maybeMutate_impl ( node->stmtExpr, *this ); |
---|
1956 | |
---|
1957 | MUTATE_END( Expression, node ); |
---|
1958 | } |
---|
1959 | |
---|
1960 | //-------------------------------------------------------------------------- |
---|
1961 | // StmtExpr |
---|
1962 | template< typename pass_type > |
---|
1963 | void PassVisitor< pass_type >::visit( StmtExpr * node ) { |
---|
1964 | VISIT_START( node ); |
---|
1965 | |
---|
1966 | // don't want statements from outer CompoundStmts to be added to this StmtExpr |
---|
1967 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); |
---|
1968 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); |
---|
1969 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); |
---|
1970 | |
---|
1971 | indexerScopedAccept( node->result , *this ); |
---|
1972 | maybeAccept_impl ( node->statements , *this ); |
---|
1973 | maybeAccept_impl ( node->returnDecls, *this ); |
---|
1974 | maybeAccept_impl ( node->dtors , *this ); |
---|
1975 | |
---|
1976 | VISIT_END( node ); |
---|
1977 | } |
---|
1978 | |
---|
1979 | template< typename pass_type > |
---|
1980 | Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { |
---|
1981 | MUTATE_START( node ); |
---|
1982 | |
---|
1983 | // don't want statements from outer CompoundStmts to be added to this StmtExpr |
---|
1984 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); |
---|
1985 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); |
---|
1986 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); |
---|
1987 | |
---|
1988 | indexerScopedMutate( node->result , *this ); |
---|
1989 | maybeMutate_impl ( node->statements , *this ); |
---|
1990 | maybeMutate_impl ( node->returnDecls, *this ); |
---|
1991 | maybeMutate_impl ( node->dtors , *this ); |
---|
1992 | |
---|
1993 | MUTATE_END( Expression, node ); |
---|
1994 | } |
---|
1995 | |
---|
1996 | //-------------------------------------------------------------------------- |
---|
1997 | // UniqueExpr |
---|
1998 | template< typename pass_type > |
---|
1999 | void PassVisitor< pass_type >::visit( UniqueExpr * node ) { |
---|
2000 | VISIT_START( node ); |
---|
2001 | |
---|
2002 | indexerScopedAccept( node->result, *this ); |
---|
2003 | maybeAccept_impl ( node->expr , *this ); |
---|
2004 | |
---|
2005 | VISIT_END( node ); |
---|
2006 | } |
---|
2007 | |
---|
2008 | template< typename pass_type > |
---|
2009 | Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) { |
---|
2010 | MUTATE_START( node ); |
---|
2011 | |
---|
2012 | indexerScopedMutate( node->env , *this ); |
---|
2013 | indexerScopedMutate( node->result, *this ); |
---|
2014 | maybeMutate_impl ( node->expr , *this ); |
---|
2015 | |
---|
2016 | MUTATE_END( Expression, node ); |
---|
2017 | } |
---|
2018 | |
---|
2019 | //-------------------------------------------------------------------------- |
---|
2020 | // UntypedInitExpr |
---|
2021 | template< typename pass_type > |
---|
2022 | void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) { |
---|
2023 | VISIT_START( node ); |
---|
2024 | |
---|
2025 | indexerScopedAccept( node->result, *this ); |
---|
2026 | maybeAccept_impl ( node->expr , *this ); |
---|
2027 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. |
---|
2028 | |
---|
2029 | VISIT_END( node ); |
---|
2030 | } |
---|
2031 | |
---|
2032 | template< typename pass_type > |
---|
2033 | Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) { |
---|
2034 | MUTATE_START( node ); |
---|
2035 | |
---|
2036 | indexerScopedMutate( node->env , *this ); |
---|
2037 | indexerScopedMutate( node->result, *this ); |
---|
2038 | maybeMutate_impl ( node->expr , *this ); |
---|
2039 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. |
---|
2040 | |
---|
2041 | MUTATE_END( Expression, node ); |
---|
2042 | } |
---|
2043 | |
---|
2044 | //-------------------------------------------------------------------------- |
---|
2045 | // InitExpr |
---|
2046 | template< typename pass_type > |
---|
2047 | void PassVisitor< pass_type >::visit( InitExpr * node ) { |
---|
2048 | VISIT_START( node ); |
---|
2049 | |
---|
2050 | indexerScopedAccept( node->result, *this ); |
---|
2051 | maybeAccept_impl ( node->expr , *this ); |
---|
2052 | maybeAccept_impl ( node->designation, *this ); |
---|
2053 | |
---|
2054 | VISIT_END( node ); |
---|
2055 | } |
---|
2056 | |
---|
2057 | template< typename pass_type > |
---|
2058 | Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) { |
---|
2059 | MUTATE_START( node ); |
---|
2060 | |
---|
2061 | indexerScopedMutate( node->env , *this ); |
---|
2062 | indexerScopedMutate( node->result, *this ); |
---|
2063 | maybeMutate_impl ( node->expr , *this ); |
---|
2064 | maybeMutate_impl ( node->designation, *this ); |
---|
2065 | |
---|
2066 | MUTATE_END( Expression, node ); |
---|
2067 | } |
---|
2068 | |
---|
2069 | //-------------------------------------------------------------------------- |
---|
2070 | // DeletedExpr |
---|
2071 | template< typename pass_type > |
---|
2072 | void PassVisitor< pass_type >::visit( DeletedExpr * node ) { |
---|
2073 | VISIT_START( node ); |
---|
2074 | |
---|
2075 | indexerScopedAccept( node->result, *this ); |
---|
2076 | maybeAccept_impl( node->expr, *this ); |
---|
2077 | // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. |
---|
2078 | |
---|
2079 | VISIT_END( node ); |
---|
2080 | } |
---|
2081 | |
---|
2082 | template< typename pass_type > |
---|
2083 | Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) { |
---|
2084 | MUTATE_START( node ); |
---|
2085 | |
---|
2086 | indexerScopedMutate( node->env, *this ); |
---|
2087 | indexerScopedMutate( node->result, *this ); |
---|
2088 | maybeMutate_impl( node->expr, *this ); |
---|
2089 | |
---|
2090 | MUTATE_END( Expression, node ); |
---|
2091 | } |
---|
2092 | |
---|
2093 | //-------------------------------------------------------------------------- |
---|
2094 | // DefaultArgExpr |
---|
2095 | template< typename pass_type > |
---|
2096 | void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) { |
---|
2097 | VISIT_START( node ); |
---|
2098 | |
---|
2099 | indexerScopedAccept( node->result, *this ); |
---|
2100 | maybeAccept_impl( node->expr, *this ); |
---|
2101 | |
---|
2102 | VISIT_END( node ); |
---|
2103 | } |
---|
2104 | |
---|
2105 | template< typename pass_type > |
---|
2106 | Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) { |
---|
2107 | MUTATE_START( node ); |
---|
2108 | |
---|
2109 | indexerScopedMutate( node->env, *this ); |
---|
2110 | indexerScopedMutate( node->result, *this ); |
---|
2111 | maybeMutate_impl( node->expr, *this ); |
---|
2112 | |
---|
2113 | MUTATE_END( Expression, node ); |
---|
2114 | } |
---|
2115 | |
---|
2116 | //-------------------------------------------------------------------------- |
---|
2117 | // GenericExpr |
---|
2118 | template< typename pass_type > |
---|
2119 | void PassVisitor< pass_type >::visit( GenericExpr * node ) { |
---|
2120 | VISIT_START( node ); |
---|
2121 | |
---|
2122 | indexerScopedAccept( node->result, *this ); |
---|
2123 | maybeAccept_impl( node->control, *this ); |
---|
2124 | for ( GenericExpr::Association & assoc : node->associations ) { |
---|
2125 | indexerScopedAccept( assoc.type, *this ); |
---|
2126 | maybeAccept_impl( assoc.expr, *this ); |
---|
2127 | } |
---|
2128 | |
---|
2129 | VISIT_END( node ); |
---|
2130 | } |
---|
2131 | |
---|
2132 | template< typename pass_type > |
---|
2133 | Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) { |
---|
2134 | MUTATE_START( node ); |
---|
2135 | |
---|
2136 | indexerScopedMutate( node->env, *this ); |
---|
2137 | indexerScopedMutate( node->result, *this ); |
---|
2138 | maybeMutate_impl( node->control, *this ); |
---|
2139 | for ( GenericExpr::Association & assoc : node->associations ) { |
---|
2140 | indexerScopedMutate( assoc.type, *this ); |
---|
2141 | maybeMutate_impl( assoc.expr, *this ); |
---|
2142 | } |
---|
2143 | |
---|
2144 | MUTATE_END( Expression, node ); |
---|
2145 | } |
---|
2146 | |
---|
2147 | //-------------------------------------------------------------------------- |
---|
2148 | // VoidType |
---|
2149 | template< typename pass_type > |
---|
2150 | void PassVisitor< pass_type >::visit( VoidType * node ) { |
---|
2151 | VISIT_START( node ); |
---|
2152 | |
---|
2153 | maybeAccept_impl( node->forall, *this ); |
---|
2154 | |
---|
2155 | VISIT_END( node ); |
---|
2156 | } |
---|
2157 | |
---|
2158 | template< typename pass_type > |
---|
2159 | Type * PassVisitor< pass_type >::mutate( VoidType * node ) { |
---|
2160 | MUTATE_START( node ); |
---|
2161 | |
---|
2162 | maybeMutate_impl( node->forall, *this ); |
---|
2163 | |
---|
2164 | MUTATE_END( Type, node ); |
---|
2165 | } |
---|
2166 | |
---|
2167 | //-------------------------------------------------------------------------- |
---|
2168 | // BasicType |
---|
2169 | template< typename pass_type > |
---|
2170 | void PassVisitor< pass_type >::visit( BasicType * node ) { |
---|
2171 | VISIT_START( node ); |
---|
2172 | |
---|
2173 | maybeAccept_impl( node->forall, *this ); |
---|
2174 | |
---|
2175 | VISIT_END( node ); |
---|
2176 | } |
---|
2177 | |
---|
2178 | template< typename pass_type > |
---|
2179 | Type * PassVisitor< pass_type >::mutate( BasicType * node ) { |
---|
2180 | MUTATE_START( node ); |
---|
2181 | |
---|
2182 | maybeMutate_impl( node->forall, *this ); |
---|
2183 | |
---|
2184 | MUTATE_END( Type, node ); |
---|
2185 | } |
---|
2186 | |
---|
2187 | //-------------------------------------------------------------------------- |
---|
2188 | // PointerType |
---|
2189 | template< typename pass_type > |
---|
2190 | void PassVisitor< pass_type >::visit( PointerType * node ) { |
---|
2191 | VISIT_START( node ); |
---|
2192 | |
---|
2193 | maybeAccept_impl( node->forall, *this ); |
---|
2194 | // xxx - should PointerType visit/mutate dimension? |
---|
2195 | maybeAccept_impl( node->base, *this ); |
---|
2196 | |
---|
2197 | VISIT_END( node ); |
---|
2198 | } |
---|
2199 | |
---|
2200 | template< typename pass_type > |
---|
2201 | Type * PassVisitor< pass_type >::mutate( PointerType * node ) { |
---|
2202 | MUTATE_START( node ); |
---|
2203 | |
---|
2204 | maybeMutate_impl( node->forall, *this ); |
---|
2205 | // xxx - should PointerType visit/mutate dimension? |
---|
2206 | maybeMutate_impl( node->base, *this ); |
---|
2207 | |
---|
2208 | MUTATE_END( Type, node ); |
---|
2209 | } |
---|
2210 | |
---|
2211 | //-------------------------------------------------------------------------- |
---|
2212 | // ArrayType |
---|
2213 | template< typename pass_type > |
---|
2214 | void PassVisitor< pass_type >::visit( ArrayType * node ) { |
---|
2215 | VISIT_START( node ); |
---|
2216 | |
---|
2217 | maybeAccept_impl( node->forall, *this ); |
---|
2218 | maybeAccept_impl( node->dimension, *this ); |
---|
2219 | maybeAccept_impl( node->base, *this ); |
---|
2220 | |
---|
2221 | VISIT_END( node ); |
---|
2222 | } |
---|
2223 | |
---|
2224 | template< typename pass_type > |
---|
2225 | Type * PassVisitor< pass_type >::mutate( ArrayType * node ) { |
---|
2226 | MUTATE_START( node ); |
---|
2227 | |
---|
2228 | maybeMutate_impl( node->forall, *this ); |
---|
2229 | maybeMutate_impl( node->dimension, *this ); |
---|
2230 | maybeMutate_impl( node->base, *this ); |
---|
2231 | |
---|
2232 | MUTATE_END( Type, node ); |
---|
2233 | } |
---|
2234 | |
---|
2235 | //-------------------------------------------------------------------------- |
---|
2236 | // ReferenceType |
---|
2237 | template< typename pass_type > |
---|
2238 | void PassVisitor< pass_type >::visit( ReferenceType * node ) { |
---|
2239 | VISIT_START( node ); |
---|
2240 | |
---|
2241 | maybeAccept_impl( node->forall, *this ); |
---|
2242 | maybeAccept_impl( node->base, *this ); |
---|
2243 | |
---|
2244 | VISIT_END( node ); |
---|
2245 | } |
---|
2246 | |
---|
2247 | template< typename pass_type > |
---|
2248 | Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) { |
---|
2249 | MUTATE_START( node ); |
---|
2250 | |
---|
2251 | maybeMutate_impl( node->forall, *this ); |
---|
2252 | maybeMutate_impl( node->base, *this ); |
---|
2253 | |
---|
2254 | MUTATE_END( Type, node ); |
---|
2255 | } |
---|
2256 | |
---|
2257 | //-------------------------------------------------------------------------- |
---|
2258 | // QualifiedType |
---|
2259 | template< typename pass_type > |
---|
2260 | void PassVisitor< pass_type >::visit( QualifiedType * node ) { |
---|
2261 | VISIT_START( node ); |
---|
2262 | |
---|
2263 | maybeAccept_impl( node->forall, *this ); |
---|
2264 | maybeAccept_impl( node->parent, *this ); |
---|
2265 | maybeAccept_impl( node->child, *this ); |
---|
2266 | |
---|
2267 | VISIT_END( node ); |
---|
2268 | } |
---|
2269 | |
---|
2270 | template< typename pass_type > |
---|
2271 | Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) { |
---|
2272 | MUTATE_START( node ); |
---|
2273 | |
---|
2274 | maybeMutate_impl( node->forall, *this ); |
---|
2275 | maybeMutate_impl( node->parent, *this ); |
---|
2276 | maybeMutate_impl( node->child, *this ); |
---|
2277 | |
---|
2278 | MUTATE_END( Type, node ); |
---|
2279 | } |
---|
2280 | |
---|
2281 | //-------------------------------------------------------------------------- |
---|
2282 | // FunctionType |
---|
2283 | template< typename pass_type > |
---|
2284 | void PassVisitor< pass_type >::visit( FunctionType * node ) { |
---|
2285 | VISIT_START( node ); |
---|
2286 | |
---|
2287 | maybeAccept_impl( node->forall, *this ); |
---|
2288 | maybeAccept_impl( node->returnVals, *this ); |
---|
2289 | maybeAccept_impl( node->parameters, *this ); |
---|
2290 | |
---|
2291 | VISIT_END( node ); |
---|
2292 | } |
---|
2293 | |
---|
2294 | template< typename pass_type > |
---|
2295 | Type * PassVisitor< pass_type >::mutate( FunctionType * node ) { |
---|
2296 | MUTATE_START( node ); |
---|
2297 | |
---|
2298 | maybeMutate_impl( node->forall, *this ); |
---|
2299 | maybeMutate_impl( node->returnVals, *this ); |
---|
2300 | maybeMutate_impl( node->parameters, *this ); |
---|
2301 | |
---|
2302 | MUTATE_END( Type, node ); |
---|
2303 | } |
---|
2304 | |
---|
2305 | //-------------------------------------------------------------------------- |
---|
2306 | // StructInstType |
---|
2307 | template< typename pass_type > |
---|
2308 | void PassVisitor< pass_type >::visit( StructInstType * node ) { |
---|
2309 | VISIT_START( node ); |
---|
2310 | |
---|
2311 | indexerAddStruct( node->name ); |
---|
2312 | |
---|
2313 | { |
---|
2314 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
2315 | maybeAccept_impl( node->forall , *this ); |
---|
2316 | maybeAccept_impl( node->parameters, *this ); |
---|
2317 | } |
---|
2318 | |
---|
2319 | VISIT_END( node ); |
---|
2320 | } |
---|
2321 | |
---|
2322 | template< typename pass_type > |
---|
2323 | Type * PassVisitor< pass_type >::mutate( StructInstType * node ) { |
---|
2324 | MUTATE_START( node ); |
---|
2325 | |
---|
2326 | indexerAddStruct( node->name ); |
---|
2327 | |
---|
2328 | { |
---|
2329 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
2330 | maybeMutate_impl( node->forall , *this ); |
---|
2331 | maybeMutate_impl( node->parameters, *this ); |
---|
2332 | } |
---|
2333 | |
---|
2334 | MUTATE_END( Type, node ); |
---|
2335 | } |
---|
2336 | |
---|
2337 | //-------------------------------------------------------------------------- |
---|
2338 | // UnionInstType |
---|
2339 | template< typename pass_type > |
---|
2340 | void PassVisitor< pass_type >::visit( UnionInstType * node ) { |
---|
2341 | VISIT_START( node ); |
---|
2342 | |
---|
2343 | indexerAddStruct( node->name ); |
---|
2344 | |
---|
2345 | { |
---|
2346 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
2347 | maybeAccept_impl( node->forall , *this ); |
---|
2348 | maybeAccept_impl( node->parameters, *this ); |
---|
2349 | } |
---|
2350 | |
---|
2351 | VISIT_END( node ); |
---|
2352 | } |
---|
2353 | |
---|
2354 | template< typename pass_type > |
---|
2355 | Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) { |
---|
2356 | MUTATE_START( node ); |
---|
2357 | |
---|
2358 | indexerAddStruct( node->name ); |
---|
2359 | |
---|
2360 | { |
---|
2361 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); |
---|
2362 | maybeMutate_impl( node->forall , *this ); |
---|
2363 | maybeMutate_impl( node->parameters, *this ); |
---|
2364 | } |
---|
2365 | |
---|
2366 | MUTATE_END( Type, node ); |
---|
2367 | } |
---|
2368 | |
---|
2369 | //-------------------------------------------------------------------------- |
---|
2370 | // EnumInstType |
---|
2371 | template< typename pass_type > |
---|
2372 | void PassVisitor< pass_type >::visit( EnumInstType * node ) { |
---|
2373 | VISIT_START( node ); |
---|
2374 | |
---|
2375 | maybeAccept_impl( node->forall, *this ); |
---|
2376 | maybeAccept_impl( node->parameters, *this ); |
---|
2377 | |
---|
2378 | VISIT_END( node ); |
---|
2379 | } |
---|
2380 | |
---|
2381 | template< typename pass_type > |
---|
2382 | Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) { |
---|
2383 | MUTATE_START( node ); |
---|
2384 | |
---|
2385 | maybeMutate_impl( node->forall, *this ); |
---|
2386 | maybeMutate_impl( node->parameters, *this ); |
---|
2387 | |
---|
2388 | MUTATE_END( Type, node ); |
---|
2389 | } |
---|
2390 | |
---|
2391 | //-------------------------------------------------------------------------- |
---|
2392 | // TraitInstType |
---|
2393 | template< typename pass_type > |
---|
2394 | void PassVisitor< pass_type >::visit( TraitInstType * node ) { |
---|
2395 | VISIT_START( node ); |
---|
2396 | |
---|
2397 | maybeAccept_impl( node->forall , *this ); |
---|
2398 | maybeAccept_impl( node->parameters, *this ); |
---|
2399 | |
---|
2400 | VISIT_END( node ); |
---|
2401 | } |
---|
2402 | |
---|
2403 | template< typename pass_type > |
---|
2404 | Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) { |
---|
2405 | MUTATE_START( node ); |
---|
2406 | |
---|
2407 | maybeMutate_impl( node->forall , *this ); |
---|
2408 | maybeMutate_impl( node->parameters, *this ); |
---|
2409 | |
---|
2410 | MUTATE_END( Type, node ); |
---|
2411 | } |
---|
2412 | |
---|
2413 | //-------------------------------------------------------------------------- |
---|
2414 | // TypeInstType |
---|
2415 | template< typename pass_type > |
---|
2416 | void PassVisitor< pass_type >::visit( TypeInstType * node ) { |
---|
2417 | VISIT_START( node ); |
---|
2418 | |
---|
2419 | maybeAccept_impl( node->forall , *this ); |
---|
2420 | maybeAccept_impl( node->parameters, *this ); |
---|
2421 | |
---|
2422 | VISIT_END( node ); |
---|
2423 | } |
---|
2424 | |
---|
2425 | template< typename pass_type > |
---|
2426 | Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) { |
---|
2427 | MUTATE_START( node ); |
---|
2428 | |
---|
2429 | maybeMutate_impl( node->forall , *this ); |
---|
2430 | maybeMutate_impl( node->parameters, *this ); |
---|
2431 | |
---|
2432 | MUTATE_END( Type, node ); |
---|
2433 | } |
---|
2434 | |
---|
2435 | //-------------------------------------------------------------------------- |
---|
2436 | // TupleType |
---|
2437 | template< typename pass_type > |
---|
2438 | void PassVisitor< pass_type >::visit( TupleType * node ) { |
---|
2439 | VISIT_START( node ); |
---|
2440 | |
---|
2441 | maybeAccept_impl( node->forall, *this ); |
---|
2442 | maybeAccept_impl( node->types, *this ); |
---|
2443 | maybeAccept_impl( node->members, *this ); |
---|
2444 | |
---|
2445 | VISIT_END( node ); |
---|
2446 | } |
---|
2447 | |
---|
2448 | template< typename pass_type > |
---|
2449 | Type * PassVisitor< pass_type >::mutate( TupleType * node ) { |
---|
2450 | MUTATE_START( node ); |
---|
2451 | |
---|
2452 | maybeMutate_impl( node->forall, *this ); |
---|
2453 | maybeMutate_impl( node->types, *this ); |
---|
2454 | maybeMutate_impl( node->members, *this ); |
---|
2455 | |
---|
2456 | MUTATE_END( Type, node ); |
---|
2457 | } |
---|
2458 | |
---|
2459 | //-------------------------------------------------------------------------- |
---|
2460 | // TypeofType |
---|
2461 | template< typename pass_type > |
---|
2462 | void PassVisitor< pass_type >::visit( TypeofType * node ) { |
---|
2463 | VISIT_START( node ); |
---|
2464 | |
---|
2465 | assert( node->expr ); |
---|
2466 | maybeAccept_impl( node->expr, *this ); |
---|
2467 | |
---|
2468 | VISIT_END( node ); |
---|
2469 | } |
---|
2470 | |
---|
2471 | template< typename pass_type > |
---|
2472 | Type * PassVisitor< pass_type >::mutate( TypeofType * node ) { |
---|
2473 | MUTATE_START( node ); |
---|
2474 | |
---|
2475 | assert( node->expr ); |
---|
2476 | maybeMutate_impl( node->expr, *this ); |
---|
2477 | |
---|
2478 | MUTATE_END( Type, node ); |
---|
2479 | } |
---|
2480 | |
---|
2481 | //-------------------------------------------------------------------------- |
---|
2482 | // AttrType |
---|
2483 | template< typename pass_type > |
---|
2484 | void PassVisitor< pass_type >::visit( AttrType * node ) { |
---|
2485 | VISIT_START( node ); |
---|
2486 | |
---|
2487 | if ( node->isType ) { |
---|
2488 | assert( node->type ); |
---|
2489 | maybeAccept_impl( node->type, *this ); |
---|
2490 | } else { |
---|
2491 | assert( node->expr ); |
---|
2492 | maybeAccept_impl( node->expr, *this ); |
---|
2493 | } // if |
---|
2494 | |
---|
2495 | VISIT_END( node ); |
---|
2496 | } |
---|
2497 | |
---|
2498 | template< typename pass_type > |
---|
2499 | Type * PassVisitor< pass_type >::mutate( AttrType * node ) { |
---|
2500 | MUTATE_START( node ); |
---|
2501 | |
---|
2502 | if ( node->isType ) { |
---|
2503 | assert( node->type ); |
---|
2504 | maybeMutate_impl( node->type, *this ); |
---|
2505 | } else { |
---|
2506 | assert( node->expr ); |
---|
2507 | maybeMutate_impl( node->expr, *this ); |
---|
2508 | } // if |
---|
2509 | |
---|
2510 | MUTATE_END( Type, node ); |
---|
2511 | } |
---|
2512 | |
---|
2513 | //-------------------------------------------------------------------------- |
---|
2514 | // VarArgsType |
---|
2515 | template< typename pass_type > |
---|
2516 | void PassVisitor< pass_type >::visit( VarArgsType * node ) { |
---|
2517 | VISIT_START( node ); |
---|
2518 | |
---|
2519 | maybeAccept_impl( node->forall, *this ); |
---|
2520 | |
---|
2521 | VISIT_END( node ); |
---|
2522 | } |
---|
2523 | |
---|
2524 | template< typename pass_type > |
---|
2525 | Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) { |
---|
2526 | MUTATE_START( node ); |
---|
2527 | |
---|
2528 | maybeMutate_impl( node->forall, *this ); |
---|
2529 | |
---|
2530 | MUTATE_END( Type, node ); |
---|
2531 | } |
---|
2532 | |
---|
2533 | //-------------------------------------------------------------------------- |
---|
2534 | // ZeroType |
---|
2535 | template< typename pass_type > |
---|
2536 | void PassVisitor< pass_type >::visit( ZeroType * node ) { |
---|
2537 | VISIT_START( node ); |
---|
2538 | |
---|
2539 | maybeAccept_impl( node->forall, *this ); |
---|
2540 | |
---|
2541 | VISIT_END( node ); |
---|
2542 | } |
---|
2543 | |
---|
2544 | template< typename pass_type > |
---|
2545 | Type * PassVisitor< pass_type >::mutate( ZeroType * node ) { |
---|
2546 | MUTATE_START( node ); |
---|
2547 | |
---|
2548 | maybeMutate_impl( node->forall, *this ); |
---|
2549 | |
---|
2550 | MUTATE_END( Type, node ); |
---|
2551 | } |
---|
2552 | |
---|
2553 | //-------------------------------------------------------------------------- |
---|
2554 | // OneType |
---|
2555 | template< typename pass_type > |
---|
2556 | void PassVisitor< pass_type >::visit( OneType * node ) { |
---|
2557 | VISIT_START( node ); |
---|
2558 | |
---|
2559 | maybeAccept_impl( node->forall, *this ); |
---|
2560 | |
---|
2561 | VISIT_END( node ); |
---|
2562 | } |
---|
2563 | |
---|
2564 | template< typename pass_type > |
---|
2565 | Type * PassVisitor< pass_type >::mutate( OneType * node ) { |
---|
2566 | MUTATE_START( node ); |
---|
2567 | |
---|
2568 | maybeMutate_impl( node->forall, *this ); |
---|
2569 | |
---|
2570 | MUTATE_END( Type, node ); |
---|
2571 | } |
---|
2572 | |
---|
2573 | //-------------------------------------------------------------------------- |
---|
2574 | // GlobalScopeType |
---|
2575 | template< typename pass_type > |
---|
2576 | void PassVisitor< pass_type >::visit( GlobalScopeType * node ) { |
---|
2577 | VISIT_START( node ); |
---|
2578 | |
---|
2579 | maybeAccept_impl( node->forall, *this ); |
---|
2580 | |
---|
2581 | VISIT_END( node ); |
---|
2582 | } |
---|
2583 | |
---|
2584 | template< typename pass_type > |
---|
2585 | Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) { |
---|
2586 | MUTATE_START( node ); |
---|
2587 | |
---|
2588 | maybeMutate_impl( node->forall, *this ); |
---|
2589 | |
---|
2590 | MUTATE_END( Type, node ); |
---|
2591 | } |
---|
2592 | |
---|
2593 | //-------------------------------------------------------------------------- |
---|
2594 | // Designation |
---|
2595 | template< typename pass_type > |
---|
2596 | void PassVisitor< pass_type >::visit( Designation * node ) { |
---|
2597 | VISIT_START( node ); |
---|
2598 | |
---|
2599 | maybeAccept_impl( node->designators, *this ); |
---|
2600 | |
---|
2601 | VISIT_END( node ); |
---|
2602 | } |
---|
2603 | |
---|
2604 | template< typename pass_type > |
---|
2605 | Designation * PassVisitor< pass_type >::mutate( Designation * node ) { |
---|
2606 | MUTATE_START( node ); |
---|
2607 | |
---|
2608 | maybeMutate_impl( node->designators, *this ); |
---|
2609 | |
---|
2610 | MUTATE_END( Designation, node ); |
---|
2611 | } |
---|
2612 | |
---|
2613 | //-------------------------------------------------------------------------- |
---|
2614 | // SingleInit |
---|
2615 | template< typename pass_type > |
---|
2616 | void PassVisitor< pass_type >::visit( SingleInit * node ) { |
---|
2617 | VISIT_START( node ); |
---|
2618 | |
---|
2619 | visitExpression( node->value ); |
---|
2620 | |
---|
2621 | VISIT_END( node ); |
---|
2622 | } |
---|
2623 | |
---|
2624 | template< typename pass_type > |
---|
2625 | Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) { |
---|
2626 | MUTATE_START( node ); |
---|
2627 | |
---|
2628 | node->value = mutateExpression( node->value ); |
---|
2629 | |
---|
2630 | MUTATE_END( Initializer, node ); |
---|
2631 | } |
---|
2632 | |
---|
2633 | //-------------------------------------------------------------------------- |
---|
2634 | // ListInit |
---|
2635 | template< typename pass_type > |
---|
2636 | void PassVisitor< pass_type >::visit( ListInit * node ) { |
---|
2637 | VISIT_START( node ); |
---|
2638 | |
---|
2639 | maybeAccept_impl( node->designations, *this ); |
---|
2640 | maybeAccept_impl( node->initializers, *this ); |
---|
2641 | |
---|
2642 | VISIT_END( node ); |
---|
2643 | } |
---|
2644 | |
---|
2645 | template< typename pass_type > |
---|
2646 | Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) { |
---|
2647 | MUTATE_START( node ); |
---|
2648 | |
---|
2649 | maybeMutate_impl( node->designations, *this ); |
---|
2650 | maybeMutate_impl( node->initializers, *this ); |
---|
2651 | |
---|
2652 | MUTATE_END( Initializer, node ); |
---|
2653 | } |
---|
2654 | |
---|
2655 | //-------------------------------------------------------------------------- |
---|
2656 | // ConstructorInit |
---|
2657 | template< typename pass_type > |
---|
2658 | void PassVisitor< pass_type >::visit( ConstructorInit * node ) { |
---|
2659 | VISIT_START( node ); |
---|
2660 | |
---|
2661 | maybeAccept_impl( node->ctor, *this ); |
---|
2662 | maybeAccept_impl( node->dtor, *this ); |
---|
2663 | maybeAccept_impl( node->init, *this ); |
---|
2664 | |
---|
2665 | VISIT_END( node ); |
---|
2666 | } |
---|
2667 | |
---|
2668 | template< typename pass_type > |
---|
2669 | Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) { |
---|
2670 | MUTATE_START( node ); |
---|
2671 | |
---|
2672 | maybeMutate_impl( node->ctor, *this ); |
---|
2673 | maybeMutate_impl( node->dtor, *this ); |
---|
2674 | maybeMutate_impl( node->init, *this ); |
---|
2675 | |
---|
2676 | MUTATE_END( Initializer, node ); |
---|
2677 | } |
---|
2678 | |
---|
2679 | //-------------------------------------------------------------------------- |
---|
2680 | // Subrange |
---|
2681 | template< typename pass_type > |
---|
2682 | void PassVisitor< pass_type >::visit( Subrange * node ) { |
---|
2683 | VISIT_START( node ); |
---|
2684 | |
---|
2685 | VISIT_END( node ); |
---|
2686 | } |
---|
2687 | |
---|
2688 | template< typename pass_type > |
---|
2689 | Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) { |
---|
2690 | MUTATE_START( node ); |
---|
2691 | |
---|
2692 | MUTATE_END( Subrange, node ); |
---|
2693 | } |
---|
2694 | |
---|
2695 | //-------------------------------------------------------------------------- |
---|
2696 | // Attribute |
---|
2697 | template< typename pass_type > |
---|
2698 | void PassVisitor< pass_type >::visit( Constant * node ) { |
---|
2699 | VISIT_START( node ); |
---|
2700 | |
---|
2701 | VISIT_END( node ); |
---|
2702 | } |
---|
2703 | |
---|
2704 | template< typename pass_type > |
---|
2705 | Constant * PassVisitor< pass_type >::mutate( Constant * node ) { |
---|
2706 | MUTATE_START( node ); |
---|
2707 | |
---|
2708 | MUTATE_END( Constant, node ); |
---|
2709 | } |
---|
2710 | |
---|
2711 | //-------------------------------------------------------------------------- |
---|
2712 | // Attribute |
---|
2713 | template< typename pass_type > |
---|
2714 | void PassVisitor< pass_type >::visit( Attribute * node ) { |
---|
2715 | VISIT_START( node ); |
---|
2716 | |
---|
2717 | maybeAccept_impl( node->parameters, *this ); |
---|
2718 | |
---|
2719 | VISIT_END( node ); |
---|
2720 | } |
---|
2721 | |
---|
2722 | template< typename pass_type > |
---|
2723 | Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) { |
---|
2724 | MUTATE_START( node ); |
---|
2725 | |
---|
2726 | maybeMutate_impl( node->parameters, *this ); |
---|
2727 | |
---|
2728 | MUTATE_END( Attribute, node ); |
---|
2729 | } |
---|
2730 | |
---|
2731 | //-------------------------------------------------------------------------- |
---|
2732 | // TypeSubstitution |
---|
2733 | template< typename pass_type > |
---|
2734 | TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) { |
---|
2735 | MUTATE_START( node ); |
---|
2736 | |
---|
2737 | for ( auto & p : node->typeEnv ) { |
---|
2738 | indexerScopedMutate( p.second, *this ); |
---|
2739 | } |
---|
2740 | for ( auto & p : node->varEnv ) { |
---|
2741 | indexerScopedMutate( p.second, *this ); |
---|
2742 | } |
---|
2743 | |
---|
2744 | MUTATE_END( TypeSubstitution, node ); |
---|
2745 | } |
---|