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