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