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