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