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