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