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