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