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