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