| 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 acceptAll( const std::list< const Declaration * > & decls, PassVisitor< pass_type >& visitor ) { | 
|---|
| 83 | SemanticErrorException errors; | 
|---|
| 84 |  | 
|---|
| 85 | pass_visitor_stats.depth++; | 
|---|
| 86 | pass_visitor_stats.max->push(pass_visitor_stats.depth); | 
|---|
| 87 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); | 
|---|
| 88 | for ( const Declaration * decl : decls ) { | 
|---|
| 89 | try { | 
|---|
| 90 | // run visitor on declaration | 
|---|
| 91 | maybeAccept_impl( decl, visitor ); | 
|---|
| 92 | } | 
|---|
| 93 | catch( SemanticErrorException &e ) { | 
|---|
| 94 | errors.append( e ); | 
|---|
| 95 | } | 
|---|
| 96 | } | 
|---|
| 97 | pass_visitor_stats.depth--; | 
|---|
| 98 | if ( ! errors.isEmpty() ) { | 
|---|
| 99 | throw errors; | 
|---|
| 100 | } | 
|---|
| 101 | } | 
|---|
| 102 |  | 
|---|
| 103 | template< typename pass_type > | 
|---|
| 104 | inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) { | 
|---|
| 105 | DeclList_t* beforeDecls = mutator.get_beforeDecls(); | 
|---|
| 106 | DeclList_t* afterDecls  = mutator.get_afterDecls(); | 
|---|
| 107 | SemanticErrorException errors; | 
|---|
| 108 |  | 
|---|
| 109 | pass_visitor_stats.depth++; | 
|---|
| 110 | pass_visitor_stats.max->push(pass_visitor_stats.depth); | 
|---|
| 111 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); | 
|---|
| 112 | for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { | 
|---|
| 113 | // splice in new declarations after previous decl | 
|---|
| 114 | if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } | 
|---|
| 115 |  | 
|---|
| 116 | if ( i == decls.end() ) break; | 
|---|
| 117 | try { | 
|---|
| 118 | // run mutator on declaration | 
|---|
| 119 | maybeMutate_impl( *i, mutator ); | 
|---|
| 120 | } catch( SemanticErrorException &e ) { | 
|---|
| 121 | errors.append( e ); | 
|---|
| 122 | } | 
|---|
| 123 |  | 
|---|
| 124 | // splice in new declarations before current decl | 
|---|
| 125 | if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } | 
|---|
| 126 | } | 
|---|
| 127 | pass_visitor_stats.depth--; | 
|---|
| 128 | if ( ! errors.isEmpty() ) { | 
|---|
| 129 | throw errors; | 
|---|
| 130 | } | 
|---|
| 131 | } | 
|---|
| 132 |  | 
|---|
| 133 | template< typename TreeType, typename pass_type > | 
|---|
| 134 | inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) { | 
|---|
| 135 | if ( ! visitor.get_visit_children() ) return; | 
|---|
| 136 | if ( tree ) { | 
|---|
| 137 | tree->accept( visitor ); | 
|---|
| 138 | } | 
|---|
| 139 | } | 
|---|
| 140 |  | 
|---|
| 141 | template< typename TreeType, typename pass_type > | 
|---|
| 142 | inline void maybeAccept_impl( const TreeType * tree, PassVisitor< pass_type > & visitor ) { | 
|---|
| 143 | if ( ! visitor.get_visit_children() ) return; | 
|---|
| 144 | if ( tree ) { | 
|---|
| 145 | tree->accept( visitor ); | 
|---|
| 146 | } | 
|---|
| 147 | } | 
|---|
| 148 |  | 
|---|
| 149 | template< typename Container, typename pass_type > | 
|---|
| 150 | inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) { | 
|---|
| 151 | if ( ! visitor.get_visit_children() ) return; | 
|---|
| 152 | SemanticErrorException errors; | 
|---|
| 153 |  | 
|---|
| 154 | pass_visitor_stats.depth++; | 
|---|
| 155 | pass_visitor_stats.max->push(pass_visitor_stats.depth); | 
|---|
| 156 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); | 
|---|
| 157 | for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { | 
|---|
| 158 | try { | 
|---|
| 159 | if ( *i ) { | 
|---|
| 160 | (*i)->accept( visitor ); | 
|---|
| 161 | } | 
|---|
| 162 | } catch( SemanticErrorException &e ) { | 
|---|
| 163 | errors.append( e ); | 
|---|
| 164 | } | 
|---|
| 165 | } | 
|---|
| 166 | pass_visitor_stats.depth--; | 
|---|
| 167 | if ( ! errors.isEmpty() ) { | 
|---|
| 168 | throw errors; | 
|---|
| 169 | } | 
|---|
| 170 | } | 
|---|
| 171 |  | 
|---|
| 172 | template< typename Container, typename pass_type > | 
|---|
| 173 | inline void maybeAccept_impl( const Container & container, PassVisitor< pass_type > & visitor ) { | 
|---|
| 174 | if ( ! visitor.get_visit_children() ) return; | 
|---|
| 175 | SemanticErrorException errors; | 
|---|
| 176 |  | 
|---|
| 177 | pass_visitor_stats.depth++; | 
|---|
| 178 | pass_visitor_stats.max->push(pass_visitor_stats.depth); | 
|---|
| 179 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); | 
|---|
| 180 | for ( const auto & i : container ) { | 
|---|
| 181 | try { | 
|---|
| 182 | if ( i ) { | 
|---|
| 183 | i->accept( visitor ); | 
|---|
| 184 | } | 
|---|
| 185 | } catch( SemanticErrorException &e ) { | 
|---|
| 186 | errors.append( e ); | 
|---|
| 187 | } | 
|---|
| 188 | } | 
|---|
| 189 | pass_visitor_stats.depth--; | 
|---|
| 190 | if ( ! errors.isEmpty() ) { | 
|---|
| 191 | throw errors; | 
|---|
| 192 | } | 
|---|
| 193 | } | 
|---|
| 194 |  | 
|---|
| 195 | template< typename TreeType, typename pass_type > | 
|---|
| 196 | inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) { | 
|---|
| 197 | if ( ! mutator.get_visit_children() ) return; | 
|---|
| 198 |  | 
|---|
| 199 | if ( tree ) { | 
|---|
| 200 | tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) ); | 
|---|
| 201 | } | 
|---|
| 202 | } | 
|---|
| 203 |  | 
|---|
| 204 | template< typename Container, typename pass_type > | 
|---|
| 205 | inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) { | 
|---|
| 206 |  | 
|---|
| 207 | if ( ! mutator.get_visit_children() ) return; | 
|---|
| 208 | SemanticErrorException errors; | 
|---|
| 209 |  | 
|---|
| 210 | pass_visitor_stats.depth++; | 
|---|
| 211 | pass_visitor_stats.max->push(pass_visitor_stats.depth); | 
|---|
| 212 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); | 
|---|
| 213 | for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { | 
|---|
| 214 | try { | 
|---|
| 215 | if ( *i ) { | 
|---|
| 216 | *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) ); | 
|---|
| 217 | assert( *i ); | 
|---|
| 218 | } // if | 
|---|
| 219 | } catch( SemanticErrorException &e ) { | 
|---|
| 220 | errors.append( e ); | 
|---|
| 221 | } // try | 
|---|
| 222 | } // for | 
|---|
| 223 | pass_visitor_stats.depth--; | 
|---|
| 224 | if ( ! errors.isEmpty() ) { | 
|---|
| 225 | throw errors; | 
|---|
| 226 | } // if | 
|---|
| 227 | } | 
|---|
| 228 |  | 
|---|
| 229 | template< typename pass_type > | 
|---|
| 230 | template< typename func_t > | 
|---|
| 231 | void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) { | 
|---|
| 232 | if ( ! get_visit_children() ) return; | 
|---|
| 233 | SemanticErrorException errors; | 
|---|
| 234 |  | 
|---|
| 235 | // don't want statements from outer CompoundStmts to be added to this CompoundStmt | 
|---|
| 236 | ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() ); | 
|---|
| 237 | ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () ); | 
|---|
| 238 | ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); | 
|---|
| 239 | ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); | 
|---|
| 240 |  | 
|---|
| 241 | StmtList_t* beforeStmts = get_beforeStmts(); | 
|---|
| 242 | StmtList_t* afterStmts  = get_afterStmts(); | 
|---|
| 243 | DeclList_t* beforeDecls = get_beforeDecls(); | 
|---|
| 244 | DeclList_t* afterDecls  = get_afterDecls(); | 
|---|
| 245 |  | 
|---|
| 246 | pass_visitor_stats.depth++; | 
|---|
| 247 | pass_visitor_stats.max->push(pass_visitor_stats.depth); | 
|---|
| 248 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); | 
|---|
| 249 | for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { | 
|---|
| 250 |  | 
|---|
| 251 | if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); } | 
|---|
| 252 | if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } | 
|---|
| 253 |  | 
|---|
| 254 | try { | 
|---|
| 255 | func( *i ); | 
|---|
| 256 | assert( *i ); | 
|---|
| 257 | assert(( empty( beforeStmts ) && empty( afterStmts )) | 
|---|
| 258 | || ( empty( beforeDecls ) && empty( afterDecls )) ); | 
|---|
| 259 |  | 
|---|
| 260 | } catch ( SemanticErrorException &e ) { | 
|---|
| 261 | errors.append( e ); | 
|---|
| 262 | } | 
|---|
| 263 |  | 
|---|
| 264 | if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); } | 
|---|
| 265 | if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } | 
|---|
| 266 | } | 
|---|
| 267 | pass_visitor_stats.depth--; | 
|---|
| 268 |  | 
|---|
| 269 | if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); } | 
|---|
| 270 | if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } | 
|---|
| 271 | if ( !errors.isEmpty() ) { throw errors; } | 
|---|
| 272 | } | 
|---|
| 273 |  | 
|---|
| 274 | template< typename pass_type > | 
|---|
| 275 | void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) { | 
|---|
| 276 | handleStatementList( statements, [this]( Statement * stmt) { | 
|---|
| 277 | maybeAccept_impl( stmt, *this ); | 
|---|
| 278 | }); | 
|---|
| 279 | } | 
|---|
| 280 |  | 
|---|
| 281 | template< typename pass_type > | 
|---|
| 282 | void PassVisitor< pass_type >::visitStatementList( const std::list< Statement * > & statements ) { | 
|---|
| 283 | if ( ! get_visit_children() ) return; | 
|---|
| 284 | SemanticErrorException errors; | 
|---|
| 285 |  | 
|---|
| 286 | pass_visitor_stats.depth++; | 
|---|
| 287 | pass_visitor_stats.max->push(pass_visitor_stats.depth); | 
|---|
| 288 | pass_visitor_stats.avg->push(pass_visitor_stats.depth); | 
|---|
| 289 | for ( const Statement * i : statements ) { | 
|---|
| 290 | try { | 
|---|
| 291 | maybeAccept_impl( i, *this ); | 
|---|
| 292 | } catch ( SemanticErrorException &e ) { | 
|---|
| 293 | errors.append( e ); | 
|---|
| 294 | } | 
|---|
| 295 | } | 
|---|
| 296 | pass_visitor_stats.depth--; | 
|---|
| 297 | if ( !errors.isEmpty() ) { throw errors; } | 
|---|
| 298 | } | 
|---|
| 299 |  | 
|---|
| 300 | template< typename pass_type > | 
|---|
| 301 | void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) { | 
|---|
| 302 | handleStatementList( statements, [this]( Statement *& stmt) { | 
|---|
| 303 | maybeMutate_impl( stmt, *this ); | 
|---|
| 304 | }); | 
|---|
| 305 | } | 
|---|
| 306 |  | 
|---|
| 307 |  | 
|---|
| 308 | template< typename pass_type > | 
|---|
| 309 | template< typename func_t > | 
|---|
| 310 | Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) { | 
|---|
| 311 | if ( ! get_visit_children() ) return stmt; | 
|---|
| 312 |  | 
|---|
| 313 | // don't want statements from outer CompoundStmts to be added to this CompoundStmt | 
|---|
| 314 | ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() ); | 
|---|
| 315 | ValueGuardPtr< DeclList_t >          oldBeforeDecls( get_beforeDecls() ); | 
|---|
| 316 | ValueGuardPtr< DeclList_t >          oldAfterDecls ( get_afterDecls () ); | 
|---|
| 317 | ValueGuardPtr< StmtList_t >          oldBeforeStmts( get_beforeStmts() ); | 
|---|
| 318 | ValueGuardPtr< StmtList_t >          oldAfterStmts ( get_afterStmts () ); | 
|---|
| 319 |  | 
|---|
| 320 | Statement *newStmt = func( stmt ); | 
|---|
| 321 |  | 
|---|
| 322 | StmtList_t* beforeStmts = get_beforeStmts(); | 
|---|
| 323 | StmtList_t* afterStmts  = get_afterStmts(); | 
|---|
| 324 | DeclList_t* beforeDecls = get_beforeDecls(); | 
|---|
| 325 | DeclList_t* afterDecls  = get_afterDecls(); | 
|---|
| 326 |  | 
|---|
| 327 | if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; } | 
|---|
| 328 | assert(( empty( beforeStmts ) && empty( afterStmts )) | 
|---|
| 329 | || ( empty( beforeDecls ) && empty( afterDecls )) ); | 
|---|
| 330 |  | 
|---|
| 331 | CompoundStmt *compound = new CompoundStmt(); | 
|---|
| 332 | if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); } | 
|---|
| 333 | if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } | 
|---|
| 334 | compound->get_kids().push_back( newStmt ); | 
|---|
| 335 | if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); } | 
|---|
| 336 | if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } | 
|---|
| 337 | return compound; | 
|---|
| 338 | } | 
|---|
| 339 |  | 
|---|
| 340 | template< typename pass_type > | 
|---|
| 341 | Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { | 
|---|
| 342 | return handleStatement( stmt, [this]( Statement * stmt ) { | 
|---|
| 343 | maybeAccept_impl( stmt, *this ); | 
|---|
| 344 | return stmt; | 
|---|
| 345 | }); | 
|---|
| 346 | } | 
|---|
| 347 |  | 
|---|
| 348 | template< typename pass_type > | 
|---|
| 349 | void PassVisitor< pass_type >::visitStatement( const Statement * stmt ) { | 
|---|
| 350 | if ( ! get_visit_children() ) return; | 
|---|
| 351 |  | 
|---|
| 352 | // don't want statements from outer CompoundStmts to be added to this CompoundStmt | 
|---|
| 353 | ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() ); | 
|---|
| 354 |  | 
|---|
| 355 | maybeAccept_impl( stmt, *this ); | 
|---|
| 356 | } | 
|---|
| 357 |  | 
|---|
| 358 | template< typename pass_type > | 
|---|
| 359 | Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { | 
|---|
| 360 | return handleStatement( stmt, [this]( Statement * stmt ) { | 
|---|
| 361 | maybeMutate_impl( stmt, *this ); | 
|---|
| 362 | return stmt; | 
|---|
| 363 | }); | 
|---|
| 364 | } | 
|---|
| 365 |  | 
|---|
| 366 | template< typename pass_type > | 
|---|
| 367 | template< typename func_t > | 
|---|
| 368 | Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) { | 
|---|
| 369 | if ( ! get_visit_children() ) return expr; | 
|---|
| 370 | if( !expr ) return nullptr; | 
|---|
| 371 |  | 
|---|
| 372 | auto env_ptr = get_env_ptr(); | 
|---|
| 373 | if ( env_ptr && expr->get_env() ) { | 
|---|
| 374 | *env_ptr = expr->get_env(); | 
|---|
| 375 | } | 
|---|
| 376 |  | 
|---|
| 377 | // should env be moved onto the result of the mutate? | 
|---|
| 378 | return func( expr ); | 
|---|
| 379 | } | 
|---|
| 380 |  | 
|---|
| 381 | template< typename pass_type > | 
|---|
| 382 | Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) { | 
|---|
| 383 | return handleExpression(expr, [this]( Expression * expr ) { | 
|---|
| 384 | maybeAccept_impl( expr, *this ); | 
|---|
| 385 | return expr; | 
|---|
| 386 | }); | 
|---|
| 387 | } | 
|---|
| 388 |  | 
|---|
| 389 | template< typename pass_type > | 
|---|
| 390 | void PassVisitor< pass_type >::visitExpression( const Expression * expr ) { | 
|---|
| 391 | if ( ! get_visit_children() ) return; | 
|---|
| 392 | if( !expr ) return; | 
|---|
| 393 |  | 
|---|
| 394 | auto env_ptr = get_env_ptr(); | 
|---|
| 395 | if ( env_ptr && expr->get_env() ) { | 
|---|
| 396 | *env_ptr = expr->get_env(); | 
|---|
| 397 | } | 
|---|
| 398 |  | 
|---|
| 399 | maybeAccept_impl( expr, *this ); | 
|---|
| 400 | } | 
|---|
| 401 |  | 
|---|
| 402 | template< typename pass_type > | 
|---|
| 403 | Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) { | 
|---|
| 404 | return handleExpression(expr, [this]( Expression * expr ) { | 
|---|
| 405 | maybeMutate_impl( expr, *this ); | 
|---|
| 406 | return expr; | 
|---|
| 407 | }); | 
|---|
| 408 | } | 
|---|
| 409 |  | 
|---|
| 410 | template< typename TreeType, typename VisitorType > | 
|---|
| 411 | inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) { | 
|---|
| 412 | if ( ! visitor.get_visit_children() ) return; | 
|---|
| 413 | auto guard = makeFuncGuard( | 
|---|
| 414 | [&visitor]() { visitor.indexerScopeEnter(); }, | 
|---|
| 415 | [&visitor]() { visitor.indexerScopeLeave(); } | 
|---|
| 416 | ); | 
|---|
| 417 | maybeAccept_impl( tree, visitor ); | 
|---|
| 418 | } | 
|---|
| 419 |  | 
|---|
| 420 | template< typename TreeType, typename VisitorType > | 
|---|
| 421 | inline void indexerScopedAccept( const TreeType * tree, VisitorType & visitor ) { | 
|---|
| 422 | if ( ! visitor.get_visit_children() ) return; | 
|---|
| 423 | auto guard = makeFuncGuard( | 
|---|
| 424 | [&visitor]() { visitor.indexerScopeEnter(); }, | 
|---|
| 425 | [&visitor]() { visitor.indexerScopeLeave(); } | 
|---|
| 426 | ); | 
|---|
| 427 | maybeAccept_impl( tree, visitor ); | 
|---|
| 428 | } | 
|---|
| 429 |  | 
|---|
| 430 | template< typename TreeType, typename MutatorType > | 
|---|
| 431 | inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) { | 
|---|
| 432 | if ( ! mutator.get_visit_children() ) return; | 
|---|
| 433 | auto guard = makeFuncGuard( | 
|---|
| 434 | [&mutator]() { mutator.indexerScopeEnter(); }, | 
|---|
| 435 | [&mutator]() { mutator.indexerScopeLeave(); } | 
|---|
| 436 | ); | 
|---|
| 437 | maybeMutate_impl( tree, mutator ); | 
|---|
| 438 | } | 
|---|
| 439 |  | 
|---|
| 440 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | 
|---|
| 441 | //======================================================================================================================================================================== | 
|---|
| 442 | //======================================================================================================================================================================== | 
|---|
| 443 | //======================================================================================================================================================================== | 
|---|
| 444 | //======================================================================================================================================================================== | 
|---|
| 445 | //======================================================================================================================================================================== | 
|---|
| 446 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | 
|---|
| 447 |  | 
|---|
| 448 | // A NOTE ON THE ORDER OF TRAVERSAL | 
|---|
| 449 | // | 
|---|
| 450 | // Types and typedefs have their base types visited before they are added to the type table.  This is ok, since there is | 
|---|
| 451 | // no such thing as a recursive type or typedef. | 
|---|
| 452 | // | 
|---|
| 453 | //             typedef struct { T *x; } T; // never allowed | 
|---|
| 454 | // | 
|---|
| 455 | // for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the | 
|---|
| 456 | // members are traversed, and then the complete type should be added (assuming the type is completed by this particular | 
|---|
| 457 | // declaration). | 
|---|
| 458 | // | 
|---|
| 459 | //             struct T { struct T *x; }; // allowed | 
|---|
| 460 | // | 
|---|
| 461 | // It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that | 
|---|
| 462 | // traversal may modify the definition of the type and these modifications should be visible when the symbol table is | 
|---|
| 463 | // queried later in this pass. | 
|---|
| 464 | // | 
|---|
| 465 | // TODO: figure out whether recursive contexts are sensible/possible/reasonable. | 
|---|
| 466 |  | 
|---|
| 467 | //-------------------------------------------------------------------------- | 
|---|
| 468 | // ObjectDecl | 
|---|
| 469 | template< typename pass_type > | 
|---|
| 470 | void PassVisitor< pass_type >::visit( ObjectDecl * node ) { | 
|---|
| 471 | VISIT_START( node ); | 
|---|
| 472 |  | 
|---|
| 473 | indexerScopedAccept( node->type         , *this ); | 
|---|
| 474 | maybeAccept_impl   ( node->init         , *this ); | 
|---|
| 475 | maybeAccept_impl   ( node->bitfieldWidth, *this ); | 
|---|
| 476 | maybeAccept_impl   ( node->attributes   , *this ); | 
|---|
| 477 |  | 
|---|
| 478 | indexerAddId( node ); | 
|---|
| 479 |  | 
|---|
| 480 | VISIT_END( node ); | 
|---|
| 481 | } | 
|---|
| 482 |  | 
|---|
| 483 | template< typename pass_type > | 
|---|
| 484 | void PassVisitor< pass_type >::visit( const ObjectDecl * node ) { | 
|---|
| 485 | VISIT_START( node ); | 
|---|
| 486 |  | 
|---|
| 487 | maybeAccept_impl( node->type         , *this ); | 
|---|
| 488 | maybeAccept_impl( node->init         , *this ); | 
|---|
| 489 | maybeAccept_impl( node->bitfieldWidth, *this ); | 
|---|
| 490 | maybeAccept_impl( node->attributes   , *this ); | 
|---|
| 491 |  | 
|---|
| 492 | VISIT_END( node ); | 
|---|
| 493 | } | 
|---|
| 494 |  | 
|---|
| 495 | template< typename pass_type > | 
|---|
| 496 | DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) { | 
|---|
| 497 | MUTATE_START( node ); | 
|---|
| 498 |  | 
|---|
| 499 | indexerScopedMutate( node->type         , *this ); | 
|---|
| 500 | maybeMutate_impl   ( node->init         , *this ); | 
|---|
| 501 | maybeMutate_impl   ( node->bitfieldWidth, *this ); | 
|---|
| 502 | maybeMutate_impl   ( node->attributes   , *this ); | 
|---|
| 503 |  | 
|---|
| 504 | indexerAddId( node ); | 
|---|
| 505 |  | 
|---|
| 506 | MUTATE_END( DeclarationWithType, node ); | 
|---|
| 507 | } | 
|---|
| 508 |  | 
|---|
| 509 | //-------------------------------------------------------------------------- | 
|---|
| 510 | // FunctionDecl | 
|---|
| 511 | template< typename pass_type > | 
|---|
| 512 | void PassVisitor< pass_type >::visit( FunctionDecl * node ) { | 
|---|
| 513 | VISIT_START( node ); | 
|---|
| 514 |  | 
|---|
| 515 | indexerAddId( node ); | 
|---|
| 516 |  | 
|---|
| 517 | maybeAccept_impl( node->withExprs, *this ); | 
|---|
| 518 | { | 
|---|
| 519 | // with clause introduces a level of scope (for the with expression members). | 
|---|
| 520 | // with clause exprs are added to the indexer before parameters so that parameters | 
|---|
| 521 | // shadow with exprs and not the other way around. | 
|---|
| 522 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 523 | indexerAddWith( node->withExprs, node ); | 
|---|
| 524 | { | 
|---|
| 525 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 526 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2 | 
|---|
| 527 | static ObjectDecl func( | 
|---|
| 528 | "__func__", noStorageClasses, LinkageSpec::C, nullptr, | 
|---|
| 529 | new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), | 
|---|
| 530 | nullptr | 
|---|
| 531 | ); | 
|---|
| 532 | indexerAddId( &func ); | 
|---|
| 533 | maybeAccept_impl( node->type, *this ); | 
|---|
| 534 | // First remember that we are now within a function. | 
|---|
| 535 | ValueGuard< bool > oldInFunction( inFunction ); | 
|---|
| 536 | inFunction = true; | 
|---|
| 537 | // The function body needs to have the same scope as parameters. | 
|---|
| 538 | // A CompoundStmt will not enter a new scope if atFunctionTop is true. | 
|---|
| 539 | ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); | 
|---|
| 540 | atFunctionTop = true; | 
|---|
| 541 | maybeAccept_impl( node->statements, *this ); | 
|---|
| 542 | maybeAccept_impl( node->attributes, *this ); | 
|---|
| 543 | } | 
|---|
| 544 | } | 
|---|
| 545 |  | 
|---|
| 546 | VISIT_END( node ); | 
|---|
| 547 | } | 
|---|
| 548 |  | 
|---|
| 549 | template< typename pass_type > | 
|---|
| 550 | void PassVisitor< pass_type >::visit( const FunctionDecl * node ) { | 
|---|
| 551 | VISIT_START( node ); | 
|---|
| 552 |  | 
|---|
| 553 | indexerAddId( node ); | 
|---|
| 554 |  | 
|---|
| 555 | maybeAccept_impl( node->withExprs, *this ); | 
|---|
| 556 | { | 
|---|
| 557 | // with clause introduces a level of scope (for the with expression members). | 
|---|
| 558 | // with clause exprs are added to the indexer before parameters so that parameters | 
|---|
| 559 | // shadow with exprs and not the other way around. | 
|---|
| 560 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 561 | indexerAddWith( node->withExprs, node ); | 
|---|
| 562 | { | 
|---|
| 563 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 564 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2 | 
|---|
| 565 | static ObjectDecl func( | 
|---|
| 566 | "__func__", noStorageClasses, LinkageSpec::C, nullptr, | 
|---|
| 567 | new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), | 
|---|
| 568 | nullptr | 
|---|
| 569 | ); | 
|---|
| 570 | indexerAddId( &func ); | 
|---|
| 571 | maybeAccept_impl( node->type, *this ); | 
|---|
| 572 | // First remember that we are now within a function. | 
|---|
| 573 | ValueGuard< bool > oldInFunction( inFunction ); | 
|---|
| 574 | inFunction = true; | 
|---|
| 575 | // The function body needs to have the same scope as parameters. | 
|---|
| 576 | // A CompoundStmt will not enter a new scope if atFunctionTop is true. | 
|---|
| 577 | ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); | 
|---|
| 578 | atFunctionTop = true; | 
|---|
| 579 | maybeAccept_impl( node->statements, *this ); | 
|---|
| 580 | maybeAccept_impl( node->attributes, *this ); | 
|---|
| 581 | } | 
|---|
| 582 | } | 
|---|
| 583 |  | 
|---|
| 584 | VISIT_END( node ); | 
|---|
| 585 | } | 
|---|
| 586 |  | 
|---|
| 587 | template< typename pass_type > | 
|---|
| 588 | DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) { | 
|---|
| 589 | MUTATE_START( node ); | 
|---|
| 590 |  | 
|---|
| 591 | indexerAddId( node ); | 
|---|
| 592 |  | 
|---|
| 593 | { | 
|---|
| 594 | // with clause introduces a level of scope (for the with expression members). | 
|---|
| 595 | // with clause exprs are added to the indexer before parameters so that parameters | 
|---|
| 596 | // shadow with exprs and not the other way around. | 
|---|
| 597 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 598 | indexerAddWith( node->withExprs, node ); | 
|---|
| 599 | { | 
|---|
| 600 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 601 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2 | 
|---|
| 602 | static ObjectDecl func( | 
|---|
| 603 | "__func__", noStorageClasses, LinkageSpec::C, nullptr, | 
|---|
| 604 | new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ), | 
|---|
| 605 | nullptr | 
|---|
| 606 | ); | 
|---|
| 607 | indexerAddId( &func ); | 
|---|
| 608 | maybeMutate_impl( node->type, *this ); | 
|---|
| 609 | // First remember that we are now within a function. | 
|---|
| 610 | ValueGuard< bool > oldInFunction( inFunction ); | 
|---|
| 611 | inFunction = true; | 
|---|
| 612 | // The function body needs to have the same scope as parameters. | 
|---|
| 613 | // A CompoundStmt will not enter a new scope if atFunctionTop is true. | 
|---|
| 614 | ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); | 
|---|
| 615 | atFunctionTop = true; | 
|---|
| 616 | maybeMutate_impl( node->statements, *this ); | 
|---|
| 617 | maybeMutate_impl( node->attributes, *this ); | 
|---|
| 618 | } | 
|---|
| 619 | } | 
|---|
| 620 |  | 
|---|
| 621 | MUTATE_END( DeclarationWithType, node ); | 
|---|
| 622 | } | 
|---|
| 623 |  | 
|---|
| 624 | //-------------------------------------------------------------------------- | 
|---|
| 625 | // StructDecl | 
|---|
| 626 | template< typename pass_type > | 
|---|
| 627 | void PassVisitor< pass_type >::visit( StructDecl * node ) { | 
|---|
| 628 | VISIT_START( node ); | 
|---|
| 629 |  | 
|---|
| 630 | // make up a forward declaration and add it before processing the members | 
|---|
| 631 | // needs to be on the heap because addStruct saves the pointer | 
|---|
| 632 | indexerAddStructFwd( node ); | 
|---|
| 633 |  | 
|---|
| 634 | { | 
|---|
| 635 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 636 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 637 | maybeAccept_impl( node->members   , *this ); | 
|---|
| 638 | } | 
|---|
| 639 |  | 
|---|
| 640 | // this addition replaces the forward declaration | 
|---|
| 641 | indexerAddStruct( node ); | 
|---|
| 642 |  | 
|---|
| 643 | VISIT_END( node ); | 
|---|
| 644 | } | 
|---|
| 645 |  | 
|---|
| 646 | template< typename pass_type > | 
|---|
| 647 | void PassVisitor< pass_type >::visit( const StructDecl * node ) { | 
|---|
| 648 | VISIT_START( node ); | 
|---|
| 649 |  | 
|---|
| 650 | // make up a forward declaration and add it before processing the members | 
|---|
| 651 | // needs to be on the heap because addStruct saves the pointer | 
|---|
| 652 | indexerAddStructFwd( node ); | 
|---|
| 653 |  | 
|---|
| 654 | { | 
|---|
| 655 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 656 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 657 | maybeAccept_impl( node->members   , *this ); | 
|---|
| 658 | } | 
|---|
| 659 |  | 
|---|
| 660 | // this addition replaces the forward declaration | 
|---|
| 661 | indexerAddStruct( node ); | 
|---|
| 662 |  | 
|---|
| 663 | VISIT_END( node ); | 
|---|
| 664 | } | 
|---|
| 665 |  | 
|---|
| 666 | template< typename pass_type > | 
|---|
| 667 | Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) { | 
|---|
| 668 | MUTATE_START( node ); | 
|---|
| 669 |  | 
|---|
| 670 | // make up a forward declaration and add it before processing the members | 
|---|
| 671 | // needs to be on the heap because addStruct saves the pointer | 
|---|
| 672 | indexerAddStructFwd( node ); | 
|---|
| 673 |  | 
|---|
| 674 | { | 
|---|
| 675 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 676 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 677 | maybeMutate_impl( node->members   , *this ); | 
|---|
| 678 | } | 
|---|
| 679 |  | 
|---|
| 680 | // this addition replaces the forward declaration | 
|---|
| 681 | indexerAddStruct( node ); | 
|---|
| 682 |  | 
|---|
| 683 | MUTATE_END( Declaration, node ); | 
|---|
| 684 | } | 
|---|
| 685 |  | 
|---|
| 686 | //-------------------------------------------------------------------------- | 
|---|
| 687 | // UnionDecl | 
|---|
| 688 | template< typename pass_type > | 
|---|
| 689 | void PassVisitor< pass_type >::visit( UnionDecl * node ) { | 
|---|
| 690 | VISIT_START( node ); | 
|---|
| 691 |  | 
|---|
| 692 | // make up a forward declaration and add it before processing the members | 
|---|
| 693 | indexerAddUnionFwd( node ); | 
|---|
| 694 |  | 
|---|
| 695 | { | 
|---|
| 696 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 697 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 698 | maybeAccept_impl( node->members   , *this ); | 
|---|
| 699 | } | 
|---|
| 700 |  | 
|---|
| 701 | indexerAddUnion( node ); | 
|---|
| 702 |  | 
|---|
| 703 | VISIT_END( node ); | 
|---|
| 704 | } | 
|---|
| 705 | template< typename pass_type > | 
|---|
| 706 | void PassVisitor< pass_type >::visit( const UnionDecl * node ) { | 
|---|
| 707 | VISIT_START( node ); | 
|---|
| 708 |  | 
|---|
| 709 | // make up a forward declaration and add it before processing the members | 
|---|
| 710 | indexerAddUnionFwd( node ); | 
|---|
| 711 |  | 
|---|
| 712 | { | 
|---|
| 713 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 714 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 715 | maybeAccept_impl( node->members   , *this ); | 
|---|
| 716 | } | 
|---|
| 717 |  | 
|---|
| 718 | indexerAddUnion( node ); | 
|---|
| 719 |  | 
|---|
| 720 | VISIT_END( node ); | 
|---|
| 721 | } | 
|---|
| 722 |  | 
|---|
| 723 | template< typename pass_type > | 
|---|
| 724 | Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) { | 
|---|
| 725 | MUTATE_START( node ); | 
|---|
| 726 |  | 
|---|
| 727 | // make up a forward declaration and add it before processing the members | 
|---|
| 728 | indexerAddUnionFwd( node ); | 
|---|
| 729 |  | 
|---|
| 730 | { | 
|---|
| 731 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 732 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 733 | maybeMutate_impl( node->members   , *this ); | 
|---|
| 734 | } | 
|---|
| 735 |  | 
|---|
| 736 | indexerAddUnion( node ); | 
|---|
| 737 |  | 
|---|
| 738 | MUTATE_END( Declaration, node ); | 
|---|
| 739 | } | 
|---|
| 740 |  | 
|---|
| 741 | //-------------------------------------------------------------------------- | 
|---|
| 742 | // EnumDecl | 
|---|
| 743 | template< typename pass_type > | 
|---|
| 744 | void PassVisitor< pass_type >::visit( EnumDecl * node ) { | 
|---|
| 745 | VISIT_START( node ); | 
|---|
| 746 |  | 
|---|
| 747 | indexerAddEnum( node ); | 
|---|
| 748 |  | 
|---|
| 749 | // unlike structs, traits, and unions, enums inject their members into the global scope | 
|---|
| 750 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 751 | maybeAccept_impl( node->members   , *this ); | 
|---|
| 752 |  | 
|---|
| 753 | VISIT_END( node ); | 
|---|
| 754 | } | 
|---|
| 755 |  | 
|---|
| 756 | template< typename pass_type > | 
|---|
| 757 | void PassVisitor< pass_type >::visit( const EnumDecl * node ) { | 
|---|
| 758 | VISIT_START( node ); | 
|---|
| 759 |  | 
|---|
| 760 | indexerAddEnum( node ); | 
|---|
| 761 |  | 
|---|
| 762 | // unlike structs, traits, and unions, enums inject their members into the global scope | 
|---|
| 763 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 764 | maybeAccept_impl( node->members   , *this ); | 
|---|
| 765 |  | 
|---|
| 766 | VISIT_END( node ); | 
|---|
| 767 | } | 
|---|
| 768 |  | 
|---|
| 769 | template< typename pass_type > | 
|---|
| 770 | Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) { | 
|---|
| 771 | MUTATE_START( node ); | 
|---|
| 772 |  | 
|---|
| 773 | indexerAddEnum( node ); | 
|---|
| 774 |  | 
|---|
| 775 | // unlike structs, traits, and unions, enums inject their members into the global scope | 
|---|
| 776 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 777 | maybeMutate_impl( node->members   , *this ); | 
|---|
| 778 |  | 
|---|
| 779 | MUTATE_END( Declaration, node ); | 
|---|
| 780 | } | 
|---|
| 781 |  | 
|---|
| 782 | //-------------------------------------------------------------------------- | 
|---|
| 783 | // TraitDecl | 
|---|
| 784 | template< typename pass_type > | 
|---|
| 785 | void PassVisitor< pass_type >::visit( TraitDecl * node ) { | 
|---|
| 786 | VISIT_START( node ); | 
|---|
| 787 |  | 
|---|
| 788 | { | 
|---|
| 789 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 790 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 791 | maybeAccept_impl( node->members   , *this ); | 
|---|
| 792 | } | 
|---|
| 793 |  | 
|---|
| 794 | indexerAddTrait( node ); | 
|---|
| 795 |  | 
|---|
| 796 | VISIT_END( node ); | 
|---|
| 797 | } | 
|---|
| 798 |  | 
|---|
| 799 | template< typename pass_type > | 
|---|
| 800 | void PassVisitor< pass_type >::visit( const TraitDecl * node ) { | 
|---|
| 801 | VISIT_START( node ); | 
|---|
| 802 |  | 
|---|
| 803 | { | 
|---|
| 804 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 805 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 806 | maybeAccept_impl( node->members   , *this ); | 
|---|
| 807 | } | 
|---|
| 808 |  | 
|---|
| 809 | indexerAddTrait( node ); | 
|---|
| 810 |  | 
|---|
| 811 | VISIT_END( node ); | 
|---|
| 812 | } | 
|---|
| 813 |  | 
|---|
| 814 | template< typename pass_type > | 
|---|
| 815 | Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) { | 
|---|
| 816 | MUTATE_START( node ); | 
|---|
| 817 |  | 
|---|
| 818 | { | 
|---|
| 819 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 820 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 821 | maybeMutate_impl( node->members   , *this ); | 
|---|
| 822 | } | 
|---|
| 823 |  | 
|---|
| 824 | indexerAddTrait( node ); | 
|---|
| 825 |  | 
|---|
| 826 | MUTATE_END( Declaration, node ); | 
|---|
| 827 | } | 
|---|
| 828 |  | 
|---|
| 829 | //-------------------------------------------------------------------------- | 
|---|
| 830 | // TypeDecl | 
|---|
| 831 | template< typename pass_type > | 
|---|
| 832 | void PassVisitor< pass_type >::visit( TypeDecl * node ) { | 
|---|
| 833 | VISIT_START( node ); | 
|---|
| 834 |  | 
|---|
| 835 | { | 
|---|
| 836 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 837 | maybeAccept_impl( node->base      , *this ); | 
|---|
| 838 | } | 
|---|
| 839 |  | 
|---|
| 840 | // see A NOTE ON THE ORDER OF TRAVERSAL, above | 
|---|
| 841 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper | 
|---|
| 842 | // and may depend on the type itself | 
|---|
| 843 | indexerAddType( node ); | 
|---|
| 844 |  | 
|---|
| 845 | maybeAccept_impl( node->assertions, *this ); | 
|---|
| 846 |  | 
|---|
| 847 | indexerScopedAccept( node->init, *this ); | 
|---|
| 848 |  | 
|---|
| 849 | VISIT_END( node ); | 
|---|
| 850 | } | 
|---|
| 851 |  | 
|---|
| 852 |  | 
|---|
| 853 | template< typename pass_type > | 
|---|
| 854 | void PassVisitor< pass_type >::visit( const TypeDecl * node ) { | 
|---|
| 855 | VISIT_START( node ); | 
|---|
| 856 |  | 
|---|
| 857 | { | 
|---|
| 858 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 859 | maybeAccept_impl( node->base      , *this ); | 
|---|
| 860 | } | 
|---|
| 861 |  | 
|---|
| 862 | // see A NOTE ON THE ORDER OF TRAVERSAL, above | 
|---|
| 863 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper | 
|---|
| 864 | // and may depend on the type itself | 
|---|
| 865 | indexerAddType( node ); | 
|---|
| 866 |  | 
|---|
| 867 | maybeAccept_impl( node->assertions, *this ); | 
|---|
| 868 |  | 
|---|
| 869 | indexerScopedAccept( node->init, *this ); | 
|---|
| 870 |  | 
|---|
| 871 | VISIT_END( node ); | 
|---|
| 872 | } | 
|---|
| 873 |  | 
|---|
| 874 | template< typename pass_type > | 
|---|
| 875 | Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) { | 
|---|
| 876 | MUTATE_START( node ); | 
|---|
| 877 |  | 
|---|
| 878 | { | 
|---|
| 879 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 880 | maybeMutate_impl( node->base      , *this ); | 
|---|
| 881 | } | 
|---|
| 882 |  | 
|---|
| 883 | // see A NOTE ON THE ORDER OF TRAVERSAL, above | 
|---|
| 884 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper | 
|---|
| 885 | // and may depend on the type itself | 
|---|
| 886 | indexerAddType( node ); | 
|---|
| 887 |  | 
|---|
| 888 | maybeMutate_impl( node->assertions, *this ); | 
|---|
| 889 |  | 
|---|
| 890 | indexerScopedMutate( node->init, *this ); | 
|---|
| 891 |  | 
|---|
| 892 | MUTATE_END( Declaration, node ); | 
|---|
| 893 | } | 
|---|
| 894 |  | 
|---|
| 895 | //-------------------------------------------------------------------------- | 
|---|
| 896 | // TypedefDecl | 
|---|
| 897 | template< typename pass_type > | 
|---|
| 898 | void PassVisitor< pass_type >::visit( TypedefDecl * node ) { | 
|---|
| 899 | VISIT_START( node ); | 
|---|
| 900 |  | 
|---|
| 901 | { | 
|---|
| 902 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 903 | maybeAccept_impl( node->base      , *this ); | 
|---|
| 904 | } | 
|---|
| 905 |  | 
|---|
| 906 | indexerAddType( node ); | 
|---|
| 907 |  | 
|---|
| 908 | maybeAccept_impl( node->assertions, *this ); | 
|---|
| 909 |  | 
|---|
| 910 | VISIT_END( node ); | 
|---|
| 911 | } | 
|---|
| 912 |  | 
|---|
| 913 | template< typename pass_type > | 
|---|
| 914 | void PassVisitor< pass_type >::visit( const TypedefDecl * node ) { | 
|---|
| 915 | VISIT_START( node ); | 
|---|
| 916 |  | 
|---|
| 917 | { | 
|---|
| 918 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 919 | maybeAccept_impl( node->base      , *this ); | 
|---|
| 920 | } | 
|---|
| 921 |  | 
|---|
| 922 | indexerAddType( node ); | 
|---|
| 923 |  | 
|---|
| 924 | maybeAccept_impl( node->assertions, *this ); | 
|---|
| 925 |  | 
|---|
| 926 | VISIT_END( node ); | 
|---|
| 927 | } | 
|---|
| 928 |  | 
|---|
| 929 | template< typename pass_type > | 
|---|
| 930 | Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) { | 
|---|
| 931 | MUTATE_START( node ); | 
|---|
| 932 |  | 
|---|
| 933 | { | 
|---|
| 934 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 935 | maybeMutate_impl( node->base      , *this ); | 
|---|
| 936 | } | 
|---|
| 937 |  | 
|---|
| 938 | indexerAddType( node ); | 
|---|
| 939 |  | 
|---|
| 940 | maybeMutate_impl( node->assertions, *this ); | 
|---|
| 941 |  | 
|---|
| 942 | MUTATE_END( Declaration, node ); | 
|---|
| 943 | } | 
|---|
| 944 |  | 
|---|
| 945 | //-------------------------------------------------------------------------- | 
|---|
| 946 | // AsmDecl | 
|---|
| 947 | template< typename pass_type > | 
|---|
| 948 | void PassVisitor< pass_type >::visit( AsmDecl * node ) { | 
|---|
| 949 | VISIT_START( node ); | 
|---|
| 950 |  | 
|---|
| 951 | maybeAccept_impl( node->stmt, *this ); | 
|---|
| 952 |  | 
|---|
| 953 | VISIT_END( node ); | 
|---|
| 954 | } | 
|---|
| 955 |  | 
|---|
| 956 | template< typename pass_type > | 
|---|
| 957 | void PassVisitor< pass_type >::visit( const AsmDecl * node ) { | 
|---|
| 958 | VISIT_START( node ); | 
|---|
| 959 |  | 
|---|
| 960 | maybeAccept_impl( node->stmt, *this ); | 
|---|
| 961 |  | 
|---|
| 962 | VISIT_END( node ); | 
|---|
| 963 | } | 
|---|
| 964 |  | 
|---|
| 965 | template< typename pass_type > | 
|---|
| 966 | AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) { | 
|---|
| 967 | MUTATE_START( node ); | 
|---|
| 968 |  | 
|---|
| 969 | maybeMutate_impl( node->stmt, *this ); | 
|---|
| 970 |  | 
|---|
| 971 | MUTATE_END( AsmDecl, node ); | 
|---|
| 972 | } | 
|---|
| 973 |  | 
|---|
| 974 | //-------------------------------------------------------------------------- | 
|---|
| 975 | // DirectiveDecl | 
|---|
| 976 | template< typename pass_type > | 
|---|
| 977 | void PassVisitor< pass_type >::visit( DirectiveDecl * node ) { | 
|---|
| 978 | VISIT_START( node ); | 
|---|
| 979 |  | 
|---|
| 980 | maybeAccept_impl( node->stmt, *this ); | 
|---|
| 981 |  | 
|---|
| 982 | VISIT_END( node ); | 
|---|
| 983 | } | 
|---|
| 984 |  | 
|---|
| 985 | template< typename pass_type > | 
|---|
| 986 | void PassVisitor< pass_type >::visit( const DirectiveDecl * node ) { | 
|---|
| 987 | VISIT_START( node ); | 
|---|
| 988 |  | 
|---|
| 989 | maybeAccept_impl( node->stmt, *this ); | 
|---|
| 990 |  | 
|---|
| 991 | VISIT_END( node ); | 
|---|
| 992 | } | 
|---|
| 993 |  | 
|---|
| 994 | template< typename pass_type > | 
|---|
| 995 | DirectiveDecl * PassVisitor< pass_type >::mutate( DirectiveDecl * node ) { | 
|---|
| 996 | MUTATE_START( node ); | 
|---|
| 997 |  | 
|---|
| 998 | maybeMutate_impl( node->stmt, *this ); | 
|---|
| 999 |  | 
|---|
| 1000 | MUTATE_END( DirectiveDecl, node ); | 
|---|
| 1001 | } | 
|---|
| 1002 |  | 
|---|
| 1003 | //-------------------------------------------------------------------------- | 
|---|
| 1004 | // StaticAssertDecl | 
|---|
| 1005 | template< typename pass_type > | 
|---|
| 1006 | void PassVisitor< pass_type >::visit( StaticAssertDecl * node ) { | 
|---|
| 1007 | VISIT_START( node ); | 
|---|
| 1008 |  | 
|---|
| 1009 | node->condition = visitExpression( node->condition ); | 
|---|
| 1010 | maybeAccept_impl( node->message, *this ); | 
|---|
| 1011 |  | 
|---|
| 1012 | VISIT_END( node ); | 
|---|
| 1013 | } | 
|---|
| 1014 |  | 
|---|
| 1015 | template< typename pass_type > | 
|---|
| 1016 | void PassVisitor< pass_type >::visit( const StaticAssertDecl * node ) { | 
|---|
| 1017 | VISIT_START( node ); | 
|---|
| 1018 |  | 
|---|
| 1019 | visitExpression( node->condition ); | 
|---|
| 1020 | maybeAccept_impl( node->message, *this ); | 
|---|
| 1021 |  | 
|---|
| 1022 | VISIT_END( node ); | 
|---|
| 1023 | } | 
|---|
| 1024 |  | 
|---|
| 1025 | template< typename pass_type > | 
|---|
| 1026 | StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) { | 
|---|
| 1027 | MUTATE_START( node ); | 
|---|
| 1028 |  | 
|---|
| 1029 | node->condition = mutateExpression( node->condition ); | 
|---|
| 1030 | maybeMutate_impl( node->message, *this ); | 
|---|
| 1031 |  | 
|---|
| 1032 | MUTATE_END( StaticAssertDecl, node ); | 
|---|
| 1033 | } | 
|---|
| 1034 |  | 
|---|
| 1035 | //-------------------------------------------------------------------------- | 
|---|
| 1036 | // CompoundStmt | 
|---|
| 1037 | template< typename pass_type > | 
|---|
| 1038 | void PassVisitor< pass_type >::visit( CompoundStmt * node ) { | 
|---|
| 1039 | VISIT_START( node ); | 
|---|
| 1040 | { | 
|---|
| 1041 | // Do not enter a new scope if atFunctionTop is true, don't leave one either. | 
|---|
| 1042 | ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); | 
|---|
| 1043 | auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); | 
|---|
| 1044 | auto guard2 = makeFuncGuard( [this]() { call_beginScope();   }, [this]() { call_endScope();     } ); | 
|---|
| 1045 | atFunctionTop = false; | 
|---|
| 1046 | visitStatementList( node->kids ); | 
|---|
| 1047 | } | 
|---|
| 1048 | VISIT_END( node ); | 
|---|
| 1049 | } | 
|---|
| 1050 |  | 
|---|
| 1051 | template< typename pass_type > | 
|---|
| 1052 | void PassVisitor< pass_type >::visit( const CompoundStmt * node ) { | 
|---|
| 1053 | VISIT_START( node ); | 
|---|
| 1054 | { | 
|---|
| 1055 | // Do not enter a new scope if atFunctionTop is true, don't leave one either. | 
|---|
| 1056 | ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); | 
|---|
| 1057 | auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); | 
|---|
| 1058 | auto guard2 = makeFuncGuard( [this]() { call_beginScope();   }, [this]() { call_endScope();     } ); | 
|---|
| 1059 | atFunctionTop = false; | 
|---|
| 1060 | visitStatementList( node->kids ); | 
|---|
| 1061 | } | 
|---|
| 1062 | VISIT_END( node ); | 
|---|
| 1063 | } | 
|---|
| 1064 |  | 
|---|
| 1065 | template< typename pass_type > | 
|---|
| 1066 | CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) { | 
|---|
| 1067 | MUTATE_START( node ); | 
|---|
| 1068 | { | 
|---|
| 1069 | // Do not enter a new scope if atFunctionTop is true, don't leave one either. | 
|---|
| 1070 | ValueGuard< bool > oldAtFunctionTop( atFunctionTop ); | 
|---|
| 1071 | auto guard1 = makeFuncGuard( [this, go = !atFunctionTop]() { if ( go ) indexerScopeEnter(); }, [this, go = !atFunctionTop]() { if ( go ) indexerScopeLeave(); } ); | 
|---|
| 1072 | auto guard2 = makeFuncGuard( [this]() { call_beginScope();   }, [this]() { call_endScope();     } ); | 
|---|
| 1073 | atFunctionTop = false; | 
|---|
| 1074 | mutateStatementList( node->kids ); | 
|---|
| 1075 | } | 
|---|
| 1076 | MUTATE_END( CompoundStmt, node ); | 
|---|
| 1077 | } | 
|---|
| 1078 |  | 
|---|
| 1079 | //-------------------------------------------------------------------------- | 
|---|
| 1080 | // ExprStmt | 
|---|
| 1081 | template< typename pass_type > | 
|---|
| 1082 | void PassVisitor< pass_type >::visit( ExprStmt * node ) { | 
|---|
| 1083 | VISIT_START( node ); | 
|---|
| 1084 |  | 
|---|
| 1085 | visitExpression( node->expr ); | 
|---|
| 1086 |  | 
|---|
| 1087 | VISIT_END( node ); | 
|---|
| 1088 | } | 
|---|
| 1089 |  | 
|---|
| 1090 | template< typename pass_type > | 
|---|
| 1091 | void PassVisitor< pass_type >::visit( const ExprStmt * node ) { | 
|---|
| 1092 | VISIT_START( node ); | 
|---|
| 1093 |  | 
|---|
| 1094 | visitExpression( node->expr ); | 
|---|
| 1095 |  | 
|---|
| 1096 | VISIT_END( node ); | 
|---|
| 1097 | } | 
|---|
| 1098 |  | 
|---|
| 1099 | template< typename pass_type > | 
|---|
| 1100 | Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) { | 
|---|
| 1101 | MUTATE_START( node ); | 
|---|
| 1102 |  | 
|---|
| 1103 | node->expr = mutateExpression( node->expr ); | 
|---|
| 1104 |  | 
|---|
| 1105 | MUTATE_END( Statement, node ); | 
|---|
| 1106 | } | 
|---|
| 1107 |  | 
|---|
| 1108 | //-------------------------------------------------------------------------- | 
|---|
| 1109 | // AsmStmt | 
|---|
| 1110 | template< typename pass_type > | 
|---|
| 1111 | void PassVisitor< pass_type >::visit( AsmStmt * node ) { | 
|---|
| 1112 | VISIT_START( node ) | 
|---|
| 1113 |  | 
|---|
| 1114 | maybeAccept_impl( node->instruction, *this ); | 
|---|
| 1115 | maybeAccept_impl( node->output, *this ); | 
|---|
| 1116 | maybeAccept_impl( node->input, *this ); | 
|---|
| 1117 | maybeAccept_impl( node->clobber, *this ); | 
|---|
| 1118 |  | 
|---|
| 1119 | VISIT_END( node ); | 
|---|
| 1120 | } | 
|---|
| 1121 |  | 
|---|
| 1122 | template< typename pass_type > | 
|---|
| 1123 | void PassVisitor< pass_type >::visit( const AsmStmt * node ) { | 
|---|
| 1124 | VISIT_START( node ) | 
|---|
| 1125 |  | 
|---|
| 1126 | maybeAccept_impl( node->instruction, *this ); | 
|---|
| 1127 | maybeAccept_impl( node->output, *this ); | 
|---|
| 1128 | maybeAccept_impl( node->input, *this ); | 
|---|
| 1129 | maybeAccept_impl( node->clobber, *this ); | 
|---|
| 1130 |  | 
|---|
| 1131 | VISIT_END( node ); | 
|---|
| 1132 | } | 
|---|
| 1133 |  | 
|---|
| 1134 | template< typename pass_type > | 
|---|
| 1135 | Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { | 
|---|
| 1136 | MUTATE_START( node ); | 
|---|
| 1137 |  | 
|---|
| 1138 | maybeMutate_impl( node->instruction, *this ); | 
|---|
| 1139 | maybeMutate_impl( node->output, *this ); | 
|---|
| 1140 | maybeMutate_impl( node->input, *this ); | 
|---|
| 1141 | maybeMutate_impl( node->clobber, *this ); | 
|---|
| 1142 |  | 
|---|
| 1143 | MUTATE_END( Statement, node ); | 
|---|
| 1144 | } | 
|---|
| 1145 |  | 
|---|
| 1146 | //-------------------------------------------------------------------------- | 
|---|
| 1147 | // AsmStmt | 
|---|
| 1148 | template< typename pass_type > | 
|---|
| 1149 | void PassVisitor< pass_type >::visit( DirectiveStmt * node ) { | 
|---|
| 1150 | VISIT_START( node ) | 
|---|
| 1151 |  | 
|---|
| 1152 | VISIT_END( node ); | 
|---|
| 1153 | } | 
|---|
| 1154 |  | 
|---|
| 1155 | template< typename pass_type > | 
|---|
| 1156 | void PassVisitor< pass_type >::visit( const DirectiveStmt * node ) { | 
|---|
| 1157 | VISIT_START( node ) | 
|---|
| 1158 |  | 
|---|
| 1159 | VISIT_END( node ); | 
|---|
| 1160 | } | 
|---|
| 1161 |  | 
|---|
| 1162 | template< typename pass_type > | 
|---|
| 1163 | Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) { | 
|---|
| 1164 | MUTATE_START( node ); | 
|---|
| 1165 |  | 
|---|
| 1166 | MUTATE_END( Statement, node ); | 
|---|
| 1167 | } | 
|---|
| 1168 |  | 
|---|
| 1169 | //-------------------------------------------------------------------------- | 
|---|
| 1170 | // IfStmt | 
|---|
| 1171 | template< typename pass_type > | 
|---|
| 1172 | void PassVisitor< pass_type >::visit( IfStmt * node ) { | 
|---|
| 1173 | VISIT_START( node ); | 
|---|
| 1174 | { | 
|---|
| 1175 | // if statements introduce a level of scope (for the initialization) | 
|---|
| 1176 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1177 | maybeAccept_impl( node->initialization, *this ); | 
|---|
| 1178 | visitExpression ( node->condition ); | 
|---|
| 1179 | node->thenPart = visitStatement( node->thenPart ); | 
|---|
| 1180 | node->elsePart = visitStatement( node->elsePart ); | 
|---|
| 1181 | } | 
|---|
| 1182 | VISIT_END( node ); | 
|---|
| 1183 | } | 
|---|
| 1184 |  | 
|---|
| 1185 | template< typename pass_type > | 
|---|
| 1186 | void PassVisitor< pass_type >::visit( const IfStmt * node ) { | 
|---|
| 1187 | VISIT_START( node ); | 
|---|
| 1188 | { | 
|---|
| 1189 | // if statements introduce a level of scope (for the initialization) | 
|---|
| 1190 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1191 | maybeAccept_impl( node->initialization, *this ); | 
|---|
| 1192 | visitExpression ( node->condition ); | 
|---|
| 1193 | visitStatement  ( node->thenPart ); | 
|---|
| 1194 | visitStatement  ( node->elsePart ); | 
|---|
| 1195 | } | 
|---|
| 1196 | VISIT_END( node ); | 
|---|
| 1197 | } | 
|---|
| 1198 |  | 
|---|
| 1199 | template< typename pass_type > | 
|---|
| 1200 | Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) { | 
|---|
| 1201 | MUTATE_START( node ); | 
|---|
| 1202 | { | 
|---|
| 1203 | // if statements introduce a level of scope (for the initialization) | 
|---|
| 1204 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1205 | maybeMutate_impl( node->initialization, *this ); | 
|---|
| 1206 | node->condition = mutateExpression( node->condition ); | 
|---|
| 1207 | node->thenPart  = mutateStatement ( node->thenPart  ); | 
|---|
| 1208 | node->elsePart  = mutateStatement ( node->elsePart  ); | 
|---|
| 1209 | } | 
|---|
| 1210 | MUTATE_END( Statement, node ); | 
|---|
| 1211 | } | 
|---|
| 1212 |  | 
|---|
| 1213 | //-------------------------------------------------------------------------- | 
|---|
| 1214 | // WhileStmt | 
|---|
| 1215 | template< typename pass_type > | 
|---|
| 1216 | void PassVisitor< pass_type >::visit( WhileStmt * node ) { | 
|---|
| 1217 | VISIT_START( node ); | 
|---|
| 1218 |  | 
|---|
| 1219 | { | 
|---|
| 1220 | // while statements introduce a level of scope (for the initialization) | 
|---|
| 1221 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1222 | maybeAccept_impl( node->initialization, *this ); | 
|---|
| 1223 | visitExpression ( node->condition ); | 
|---|
| 1224 | node->body = visitStatement( node->body ); | 
|---|
| 1225 | } | 
|---|
| 1226 |  | 
|---|
| 1227 | VISIT_END( node ); | 
|---|
| 1228 | } | 
|---|
| 1229 |  | 
|---|
| 1230 | template< typename pass_type > | 
|---|
| 1231 | void PassVisitor< pass_type >::visit( const WhileStmt * node ) { | 
|---|
| 1232 | VISIT_START( node ); | 
|---|
| 1233 |  | 
|---|
| 1234 | { | 
|---|
| 1235 | // while statements introduce a level of scope (for the initialization) | 
|---|
| 1236 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1237 | maybeAccept_impl( node->initialization, *this ); | 
|---|
| 1238 | visitExpression ( node->condition ); | 
|---|
| 1239 | visitStatement  ( node->body ); | 
|---|
| 1240 | } | 
|---|
| 1241 |  | 
|---|
| 1242 | VISIT_END( node ); | 
|---|
| 1243 | } | 
|---|
| 1244 |  | 
|---|
| 1245 | template< typename pass_type > | 
|---|
| 1246 | Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) { | 
|---|
| 1247 | MUTATE_START( node ); | 
|---|
| 1248 |  | 
|---|
| 1249 | { | 
|---|
| 1250 | // while statements introduce a level of scope (for the initialization) | 
|---|
| 1251 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1252 | maybeMutate_impl( node->initialization, *this ); | 
|---|
| 1253 | node->condition = mutateExpression( node->condition ); | 
|---|
| 1254 | node->body      = mutateStatement ( node->body      ); | 
|---|
| 1255 | } | 
|---|
| 1256 |  | 
|---|
| 1257 |  | 
|---|
| 1258 | MUTATE_END( Statement, node ); | 
|---|
| 1259 | } | 
|---|
| 1260 |  | 
|---|
| 1261 | //-------------------------------------------------------------------------- | 
|---|
| 1262 | // ForStmt | 
|---|
| 1263 | template< typename pass_type > | 
|---|
| 1264 | void PassVisitor< pass_type >::visit( ForStmt * node ) { | 
|---|
| 1265 | VISIT_START( node ); | 
|---|
| 1266 | { | 
|---|
| 1267 | // for statements introduce a level of scope (for the initialization) | 
|---|
| 1268 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1269 | maybeAccept_impl( node->initialization, *this ); | 
|---|
| 1270 | visitExpression( node->condition ); | 
|---|
| 1271 | visitExpression( node->increment ); | 
|---|
| 1272 | node->body = visitStatement( node->body ); | 
|---|
| 1273 | } | 
|---|
| 1274 | VISIT_END( node ); | 
|---|
| 1275 | } | 
|---|
| 1276 |  | 
|---|
| 1277 | template< typename pass_type > | 
|---|
| 1278 | void PassVisitor< pass_type >::visit( const ForStmt * node ) { | 
|---|
| 1279 | VISIT_START( node ); | 
|---|
| 1280 | { | 
|---|
| 1281 | // for statements introduce a level of scope (for the initialization) | 
|---|
| 1282 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1283 | maybeAccept_impl( node->initialization, *this ); | 
|---|
| 1284 | visitExpression( node->condition ); | 
|---|
| 1285 | visitExpression( node->increment ); | 
|---|
| 1286 | visitStatement ( node->body ); | 
|---|
| 1287 | } | 
|---|
| 1288 | VISIT_END( node ); | 
|---|
| 1289 | } | 
|---|
| 1290 |  | 
|---|
| 1291 | template< typename pass_type > | 
|---|
| 1292 | Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) { | 
|---|
| 1293 | MUTATE_START( node ); | 
|---|
| 1294 | { | 
|---|
| 1295 | // for statements introduce a level of scope (for the initialization) | 
|---|
| 1296 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1297 | maybeMutate_impl( node->initialization, *this ); | 
|---|
| 1298 | node->condition = mutateExpression( node->condition ); | 
|---|
| 1299 | node->increment = mutateExpression( node->increment ); | 
|---|
| 1300 | node->body      = mutateStatement ( node->body      ); | 
|---|
| 1301 | } | 
|---|
| 1302 | MUTATE_END( Statement, node ); | 
|---|
| 1303 | } | 
|---|
| 1304 |  | 
|---|
| 1305 | //-------------------------------------------------------------------------- | 
|---|
| 1306 | // SwitchStmt | 
|---|
| 1307 | template< typename pass_type > | 
|---|
| 1308 | void PassVisitor< pass_type >::visit( SwitchStmt * node ) { | 
|---|
| 1309 | VISIT_START( node ); | 
|---|
| 1310 |  | 
|---|
| 1311 | visitExpression   ( node->condition  ); | 
|---|
| 1312 | visitStatementList( node->statements ); | 
|---|
| 1313 |  | 
|---|
| 1314 | VISIT_END( node ); | 
|---|
| 1315 | } | 
|---|
| 1316 |  | 
|---|
| 1317 | template< typename pass_type > | 
|---|
| 1318 | void PassVisitor< pass_type >::visit( const SwitchStmt * node ) { | 
|---|
| 1319 | VISIT_START( node ); | 
|---|
| 1320 |  | 
|---|
| 1321 | visitExpression   ( node->condition  ); | 
|---|
| 1322 | visitStatementList( node->statements ); | 
|---|
| 1323 |  | 
|---|
| 1324 | VISIT_END( node ); | 
|---|
| 1325 | } | 
|---|
| 1326 |  | 
|---|
| 1327 | template< typename pass_type > | 
|---|
| 1328 | Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) { | 
|---|
| 1329 | MUTATE_START( node ); | 
|---|
| 1330 |  | 
|---|
| 1331 | node->condition = mutateExpression( node->condition ); | 
|---|
| 1332 | mutateStatementList( node->statements ); | 
|---|
| 1333 |  | 
|---|
| 1334 | MUTATE_END( Statement, node ); | 
|---|
| 1335 | } | 
|---|
| 1336 |  | 
|---|
| 1337 | //-------------------------------------------------------------------------- | 
|---|
| 1338 | // CaseStmt | 
|---|
| 1339 | template< typename pass_type > | 
|---|
| 1340 | void PassVisitor< pass_type >::visit( CaseStmt * node ) { | 
|---|
| 1341 | VISIT_START( node ); | 
|---|
| 1342 |  | 
|---|
| 1343 | visitExpression   ( node->condition ); | 
|---|
| 1344 | visitStatementList( node->stmts     ); | 
|---|
| 1345 |  | 
|---|
| 1346 | VISIT_END( node ); | 
|---|
| 1347 | } | 
|---|
| 1348 |  | 
|---|
| 1349 | template< typename pass_type > | 
|---|
| 1350 | void PassVisitor< pass_type >::visit( const CaseStmt * node ) { | 
|---|
| 1351 | VISIT_START( node ); | 
|---|
| 1352 |  | 
|---|
| 1353 | visitExpression   ( node->condition ); | 
|---|
| 1354 | visitStatementList( node->stmts     ); | 
|---|
| 1355 |  | 
|---|
| 1356 | VISIT_END( node ); | 
|---|
| 1357 | } | 
|---|
| 1358 |  | 
|---|
| 1359 | template< typename pass_type > | 
|---|
| 1360 | Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) { | 
|---|
| 1361 | MUTATE_START( node ); | 
|---|
| 1362 |  | 
|---|
| 1363 | node->condition = mutateExpression( node->condition ); | 
|---|
| 1364 | mutateStatementList( node->stmts ); | 
|---|
| 1365 |  | 
|---|
| 1366 | MUTATE_END( Statement, node ); | 
|---|
| 1367 | } | 
|---|
| 1368 |  | 
|---|
| 1369 | //-------------------------------------------------------------------------- | 
|---|
| 1370 | // BranchStmt | 
|---|
| 1371 | template< typename pass_type > | 
|---|
| 1372 | void PassVisitor< pass_type >::visit( BranchStmt * node ) { | 
|---|
| 1373 | VISIT_START( node ); | 
|---|
| 1374 | VISIT_END( node ); | 
|---|
| 1375 | } | 
|---|
| 1376 |  | 
|---|
| 1377 | template< typename pass_type > | 
|---|
| 1378 | void PassVisitor< pass_type >::visit( const BranchStmt * node ) { | 
|---|
| 1379 | VISIT_START( node ); | 
|---|
| 1380 | VISIT_END( node ); | 
|---|
| 1381 | } | 
|---|
| 1382 |  | 
|---|
| 1383 | template< typename pass_type > | 
|---|
| 1384 | Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { | 
|---|
| 1385 | MUTATE_START( node ); | 
|---|
| 1386 | MUTATE_END( Statement, node ); | 
|---|
| 1387 | } | 
|---|
| 1388 |  | 
|---|
| 1389 | //-------------------------------------------------------------------------- | 
|---|
| 1390 | // ReturnStmt | 
|---|
| 1391 | template< typename pass_type > | 
|---|
| 1392 | void PassVisitor< pass_type >::visit( ReturnStmt * node ) { | 
|---|
| 1393 | VISIT_START( node ); | 
|---|
| 1394 |  | 
|---|
| 1395 | visitExpression( node->expr ); | 
|---|
| 1396 |  | 
|---|
| 1397 | VISIT_END( node ); | 
|---|
| 1398 | } | 
|---|
| 1399 |  | 
|---|
| 1400 | template< typename pass_type > | 
|---|
| 1401 | void PassVisitor< pass_type >::visit( const ReturnStmt * node ) { | 
|---|
| 1402 | VISIT_START( node ); | 
|---|
| 1403 |  | 
|---|
| 1404 | visitExpression( node->expr ); | 
|---|
| 1405 |  | 
|---|
| 1406 | VISIT_END( node ); | 
|---|
| 1407 | } | 
|---|
| 1408 |  | 
|---|
| 1409 | template< typename pass_type > | 
|---|
| 1410 | Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) { | 
|---|
| 1411 | MUTATE_START( node ); | 
|---|
| 1412 |  | 
|---|
| 1413 | node->expr = mutateExpression( node->expr ); | 
|---|
| 1414 |  | 
|---|
| 1415 | MUTATE_END( Statement, node ); | 
|---|
| 1416 | } | 
|---|
| 1417 |  | 
|---|
| 1418 | //-------------------------------------------------------------------------- | 
|---|
| 1419 | // ThrowStmt | 
|---|
| 1420 | template< typename pass_type > | 
|---|
| 1421 | void PassVisitor< pass_type >::visit( ThrowStmt * node ) { | 
|---|
| 1422 | VISIT_START( node ); | 
|---|
| 1423 |  | 
|---|
| 1424 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 1425 | maybeAccept_impl( node->target, *this ); | 
|---|
| 1426 |  | 
|---|
| 1427 | VISIT_END( node ); | 
|---|
| 1428 | } | 
|---|
| 1429 |  | 
|---|
| 1430 | template< typename pass_type > | 
|---|
| 1431 | void PassVisitor< pass_type >::visit( const ThrowStmt * node ) { | 
|---|
| 1432 | VISIT_START( node ); | 
|---|
| 1433 |  | 
|---|
| 1434 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 1435 | maybeAccept_impl( node->target, *this ); | 
|---|
| 1436 |  | 
|---|
| 1437 | VISIT_END( node ); | 
|---|
| 1438 | } | 
|---|
| 1439 |  | 
|---|
| 1440 | template< typename pass_type > | 
|---|
| 1441 | Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) { | 
|---|
| 1442 | MUTATE_START( node ); | 
|---|
| 1443 |  | 
|---|
| 1444 | maybeMutate_impl( node->expr, *this ); | 
|---|
| 1445 | maybeMutate_impl( node->target, *this ); | 
|---|
| 1446 |  | 
|---|
| 1447 | MUTATE_END( Statement, node ); | 
|---|
| 1448 | } | 
|---|
| 1449 |  | 
|---|
| 1450 | //-------------------------------------------------------------------------- | 
|---|
| 1451 | // TryStmt | 
|---|
| 1452 | template< typename pass_type > | 
|---|
| 1453 | void PassVisitor< pass_type >::visit( TryStmt * node ) { | 
|---|
| 1454 | VISIT_START( node ); | 
|---|
| 1455 |  | 
|---|
| 1456 | maybeAccept_impl( node->block       , *this ); | 
|---|
| 1457 | maybeAccept_impl( node->handlers    , *this ); | 
|---|
| 1458 | maybeAccept_impl( node->finallyBlock, *this ); | 
|---|
| 1459 |  | 
|---|
| 1460 | VISIT_END( node ); | 
|---|
| 1461 | } | 
|---|
| 1462 |  | 
|---|
| 1463 | template< typename pass_type > | 
|---|
| 1464 | void PassVisitor< pass_type >::visit( const TryStmt * node ) { | 
|---|
| 1465 | VISIT_START( node ); | 
|---|
| 1466 |  | 
|---|
| 1467 | maybeAccept_impl( node->block       , *this ); | 
|---|
| 1468 | maybeAccept_impl( node->handlers    , *this ); | 
|---|
| 1469 | maybeAccept_impl( node->finallyBlock, *this ); | 
|---|
| 1470 |  | 
|---|
| 1471 | VISIT_END( node ); | 
|---|
| 1472 | } | 
|---|
| 1473 |  | 
|---|
| 1474 | template< typename pass_type > | 
|---|
| 1475 | Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) { | 
|---|
| 1476 | MUTATE_START( node ); | 
|---|
| 1477 |  | 
|---|
| 1478 | maybeMutate_impl( node->block       , *this ); | 
|---|
| 1479 | maybeMutate_impl( node->handlers    , *this ); | 
|---|
| 1480 | maybeMutate_impl( node->finallyBlock, *this ); | 
|---|
| 1481 |  | 
|---|
| 1482 | MUTATE_END( Statement, node ); | 
|---|
| 1483 | } | 
|---|
| 1484 |  | 
|---|
| 1485 | //-------------------------------------------------------------------------- | 
|---|
| 1486 | // CatchStmt | 
|---|
| 1487 | template< typename pass_type > | 
|---|
| 1488 | void PassVisitor< pass_type >::visit( CatchStmt * node ) { | 
|---|
| 1489 | VISIT_START( node ); | 
|---|
| 1490 | { | 
|---|
| 1491 | // catch statements introduce a level of scope (for the caught exception) | 
|---|
| 1492 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1493 | maybeAccept_impl( node->decl, *this ); | 
|---|
| 1494 | node->cond = visitExpression( node->cond ); | 
|---|
| 1495 | node->body = visitStatement ( node->body ); | 
|---|
| 1496 | } | 
|---|
| 1497 | VISIT_END( node ); | 
|---|
| 1498 | } | 
|---|
| 1499 |  | 
|---|
| 1500 | template< typename pass_type > | 
|---|
| 1501 | void PassVisitor< pass_type >::visit( const CatchStmt * node ) { | 
|---|
| 1502 | VISIT_START( node ); | 
|---|
| 1503 | { | 
|---|
| 1504 | // catch statements introduce a level of scope (for the caught exception) | 
|---|
| 1505 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1506 | maybeAccept_impl( node->decl, *this ); | 
|---|
| 1507 | visitExpression ( node->cond ); | 
|---|
| 1508 | visitStatement  ( node->body ); | 
|---|
| 1509 | } | 
|---|
| 1510 | VISIT_END( node ); | 
|---|
| 1511 | } | 
|---|
| 1512 |  | 
|---|
| 1513 | template< typename pass_type > | 
|---|
| 1514 | Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) { | 
|---|
| 1515 | MUTATE_START( node ); | 
|---|
| 1516 | { | 
|---|
| 1517 | // catch statements introduce a level of scope (for the caught exception) | 
|---|
| 1518 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1519 | maybeMutate_impl( node->decl, *this ); | 
|---|
| 1520 | node->cond = mutateExpression( node->cond ); | 
|---|
| 1521 | node->body = mutateStatement ( node->body ); | 
|---|
| 1522 | } | 
|---|
| 1523 | MUTATE_END( Statement, node ); | 
|---|
| 1524 | } | 
|---|
| 1525 |  | 
|---|
| 1526 | //-------------------------------------------------------------------------- | 
|---|
| 1527 | // FinallyStmt | 
|---|
| 1528 | template< typename pass_type > | 
|---|
| 1529 | void PassVisitor< pass_type >::visit( FinallyStmt * node ) { | 
|---|
| 1530 | VISIT_START( node ); | 
|---|
| 1531 |  | 
|---|
| 1532 | maybeAccept_impl( node->block, *this ); | 
|---|
| 1533 |  | 
|---|
| 1534 | VISIT_END( node ); | 
|---|
| 1535 | } | 
|---|
| 1536 |  | 
|---|
| 1537 | template< typename pass_type > | 
|---|
| 1538 | void PassVisitor< pass_type >::visit( const FinallyStmt * node ) { | 
|---|
| 1539 | VISIT_START( node ); | 
|---|
| 1540 |  | 
|---|
| 1541 | maybeAccept_impl( node->block, *this ); | 
|---|
| 1542 |  | 
|---|
| 1543 | VISIT_END( node ); | 
|---|
| 1544 | } | 
|---|
| 1545 |  | 
|---|
| 1546 | template< typename pass_type > | 
|---|
| 1547 | Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) { | 
|---|
| 1548 | MUTATE_START( node ); | 
|---|
| 1549 |  | 
|---|
| 1550 | maybeMutate_impl( node->block, *this ); | 
|---|
| 1551 |  | 
|---|
| 1552 | MUTATE_END( Statement, node ); | 
|---|
| 1553 | } | 
|---|
| 1554 |  | 
|---|
| 1555 | //-------------------------------------------------------------------------- | 
|---|
| 1556 | // SuspendStmt | 
|---|
| 1557 | template< typename pass_type > | 
|---|
| 1558 | void PassVisitor< pass_type >::visit( SuspendStmt * node ) { | 
|---|
| 1559 | VISIT_START( node ); | 
|---|
| 1560 |  | 
|---|
| 1561 | maybeAccept_impl( node->then  , *this ); | 
|---|
| 1562 |  | 
|---|
| 1563 | VISIT_END( node ); | 
|---|
| 1564 | } | 
|---|
| 1565 |  | 
|---|
| 1566 | template< typename pass_type > | 
|---|
| 1567 | void PassVisitor< pass_type >::visit( const SuspendStmt * node ) { | 
|---|
| 1568 | VISIT_START( node ); | 
|---|
| 1569 |  | 
|---|
| 1570 | maybeAccept_impl( node->then  , *this ); | 
|---|
| 1571 |  | 
|---|
| 1572 | VISIT_END( node ); | 
|---|
| 1573 | } | 
|---|
| 1574 |  | 
|---|
| 1575 | template< typename pass_type > | 
|---|
| 1576 | Statement * PassVisitor< pass_type >::mutate( SuspendStmt * node ) { | 
|---|
| 1577 | MUTATE_START( node ); | 
|---|
| 1578 |  | 
|---|
| 1579 | maybeMutate_impl( node->then  , *this ); | 
|---|
| 1580 |  | 
|---|
| 1581 | MUTATE_END( Statement, node ); | 
|---|
| 1582 | } | 
|---|
| 1583 |  | 
|---|
| 1584 | //-------------------------------------------------------------------------- | 
|---|
| 1585 | // WaitForStmt | 
|---|
| 1586 | template< typename pass_type > | 
|---|
| 1587 | void PassVisitor< pass_type >::visit( WaitForStmt * node ) { | 
|---|
| 1588 | VISIT_START( node ); | 
|---|
| 1589 |  | 
|---|
| 1590 | for( auto & clause : node->clauses ) { | 
|---|
| 1591 | maybeAccept_impl( clause.target.function, *this ); | 
|---|
| 1592 | maybeAccept_impl( clause.target.arguments, *this ); | 
|---|
| 1593 |  | 
|---|
| 1594 | maybeAccept_impl( clause.statement, *this ); | 
|---|
| 1595 | maybeAccept_impl( clause.condition, *this ); | 
|---|
| 1596 | } | 
|---|
| 1597 |  | 
|---|
| 1598 | maybeAccept_impl( node->timeout.time, *this ); | 
|---|
| 1599 | maybeAccept_impl( node->timeout.statement, *this ); | 
|---|
| 1600 | maybeAccept_impl( node->timeout.condition, *this ); | 
|---|
| 1601 | maybeAccept_impl( node->orelse.statement, *this ); | 
|---|
| 1602 | maybeAccept_impl( node->orelse.condition, *this ); | 
|---|
| 1603 |  | 
|---|
| 1604 | VISIT_END( node ); | 
|---|
| 1605 | } | 
|---|
| 1606 |  | 
|---|
| 1607 | template< typename pass_type > | 
|---|
| 1608 | void PassVisitor< pass_type >::visit( const WaitForStmt * node ) { | 
|---|
| 1609 | VISIT_START( node ); | 
|---|
| 1610 |  | 
|---|
| 1611 | for( auto & clause : node->clauses ) { | 
|---|
| 1612 | maybeAccept_impl( clause.target.function, *this ); | 
|---|
| 1613 | maybeAccept_impl( clause.target.arguments, *this ); | 
|---|
| 1614 |  | 
|---|
| 1615 | maybeAccept_impl( clause.statement, *this ); | 
|---|
| 1616 | maybeAccept_impl( clause.condition, *this ); | 
|---|
| 1617 | } | 
|---|
| 1618 |  | 
|---|
| 1619 | maybeAccept_impl( node->timeout.time, *this ); | 
|---|
| 1620 | maybeAccept_impl( node->timeout.statement, *this ); | 
|---|
| 1621 | maybeAccept_impl( node->timeout.condition, *this ); | 
|---|
| 1622 | maybeAccept_impl( node->orelse.statement, *this ); | 
|---|
| 1623 | maybeAccept_impl( node->orelse.condition, *this ); | 
|---|
| 1624 |  | 
|---|
| 1625 | VISIT_END( node ); | 
|---|
| 1626 | } | 
|---|
| 1627 |  | 
|---|
| 1628 | template< typename pass_type > | 
|---|
| 1629 | Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) { | 
|---|
| 1630 | MUTATE_START( node ); | 
|---|
| 1631 |  | 
|---|
| 1632 | for( auto & clause : node->clauses ) { | 
|---|
| 1633 | maybeMutate_impl( clause.target.function, *this ); | 
|---|
| 1634 | maybeMutate_impl( clause.target.arguments, *this ); | 
|---|
| 1635 |  | 
|---|
| 1636 | maybeMutate_impl( clause.statement, *this ); | 
|---|
| 1637 | maybeMutate_impl( clause.condition, *this ); | 
|---|
| 1638 | } | 
|---|
| 1639 |  | 
|---|
| 1640 | maybeMutate_impl( node->timeout.time, *this ); | 
|---|
| 1641 | maybeMutate_impl( node->timeout.statement, *this ); | 
|---|
| 1642 | maybeMutate_impl( node->timeout.condition, *this ); | 
|---|
| 1643 | maybeMutate_impl( node->orelse.statement, *this ); | 
|---|
| 1644 | maybeMutate_impl( node->orelse.condition, *this ); | 
|---|
| 1645 |  | 
|---|
| 1646 | MUTATE_END( Statement, node ); | 
|---|
| 1647 | } | 
|---|
| 1648 |  | 
|---|
| 1649 |  | 
|---|
| 1650 |  | 
|---|
| 1651 | //-------------------------------------------------------------------------- | 
|---|
| 1652 | // WithStmt | 
|---|
| 1653 | template< typename pass_type > | 
|---|
| 1654 | void PassVisitor< pass_type >::visit( WithStmt * node ) { | 
|---|
| 1655 | VISIT_START( node ); | 
|---|
| 1656 | maybeAccept_impl( node->exprs, *this ); | 
|---|
| 1657 | { | 
|---|
| 1658 | // catch statements introduce a level of scope (for the caught exception) | 
|---|
| 1659 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1660 | indexerAddWith( node->exprs, node ); | 
|---|
| 1661 | maybeAccept_impl( node->stmt, *this ); | 
|---|
| 1662 | } | 
|---|
| 1663 | VISIT_END( node ); | 
|---|
| 1664 | } | 
|---|
| 1665 |  | 
|---|
| 1666 | template< typename pass_type > | 
|---|
| 1667 | void PassVisitor< pass_type >::visit( const WithStmt * node ) { | 
|---|
| 1668 | VISIT_START( node ); | 
|---|
| 1669 | maybeAccept_impl( node->exprs, *this ); | 
|---|
| 1670 | { | 
|---|
| 1671 | // catch statements introduce a level of scope (for the caught exception) | 
|---|
| 1672 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1673 | indexerAddWith( node->exprs, node ); | 
|---|
| 1674 | maybeAccept_impl( node->stmt, *this ); | 
|---|
| 1675 | } | 
|---|
| 1676 | VISIT_END( node ); | 
|---|
| 1677 | } | 
|---|
| 1678 |  | 
|---|
| 1679 | template< typename pass_type > | 
|---|
| 1680 | Declaration * PassVisitor< pass_type >::mutate( WithStmt * node ) { | 
|---|
| 1681 | MUTATE_START( node ); | 
|---|
| 1682 | maybeMutate_impl( node->exprs, *this ); | 
|---|
| 1683 | { | 
|---|
| 1684 | // catch statements introduce a level of scope (for the caught exception) | 
|---|
| 1685 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 1686 | indexerAddWith( node->exprs, node ); | 
|---|
| 1687 | maybeMutate_impl( node->stmt, *this ); | 
|---|
| 1688 | } | 
|---|
| 1689 | MUTATE_END( Declaration, node ); | 
|---|
| 1690 | } | 
|---|
| 1691 |  | 
|---|
| 1692 | //-------------------------------------------------------------------------- | 
|---|
| 1693 | // NullStmt | 
|---|
| 1694 | template< typename pass_type > | 
|---|
| 1695 | void PassVisitor< pass_type >::visit( NullStmt * node ) { | 
|---|
| 1696 | VISIT_START( node ); | 
|---|
| 1697 | VISIT_END( node ); | 
|---|
| 1698 | } | 
|---|
| 1699 |  | 
|---|
| 1700 | template< typename pass_type > | 
|---|
| 1701 | void PassVisitor< pass_type >::visit( const NullStmt * node ) { | 
|---|
| 1702 | VISIT_START( node ); | 
|---|
| 1703 | VISIT_END( node ); | 
|---|
| 1704 | } | 
|---|
| 1705 |  | 
|---|
| 1706 | template< typename pass_type > | 
|---|
| 1707 | NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) { | 
|---|
| 1708 | MUTATE_START( node ); | 
|---|
| 1709 | MUTATE_END( NullStmt, node ); | 
|---|
| 1710 | } | 
|---|
| 1711 |  | 
|---|
| 1712 | //-------------------------------------------------------------------------- | 
|---|
| 1713 | // DeclStmt | 
|---|
| 1714 | template< typename pass_type > | 
|---|
| 1715 | void PassVisitor< pass_type >::visit( DeclStmt * node ) { | 
|---|
| 1716 | VISIT_START( node ); | 
|---|
| 1717 |  | 
|---|
| 1718 | maybeAccept_impl( node->decl, *this ); | 
|---|
| 1719 |  | 
|---|
| 1720 | VISIT_END( node ); | 
|---|
| 1721 | } | 
|---|
| 1722 |  | 
|---|
| 1723 | template< typename pass_type > | 
|---|
| 1724 | void PassVisitor< pass_type >::visit( const DeclStmt * node ) { | 
|---|
| 1725 | VISIT_START( node ); | 
|---|
| 1726 |  | 
|---|
| 1727 | maybeAccept_impl( node->decl, *this ); | 
|---|
| 1728 |  | 
|---|
| 1729 | VISIT_END( node ); | 
|---|
| 1730 | } | 
|---|
| 1731 |  | 
|---|
| 1732 | template< typename pass_type > | 
|---|
| 1733 | Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) { | 
|---|
| 1734 | MUTATE_START( node ); | 
|---|
| 1735 |  | 
|---|
| 1736 | maybeMutate_impl( node->decl, *this ); | 
|---|
| 1737 |  | 
|---|
| 1738 | MUTATE_END( Statement, node ); | 
|---|
| 1739 | } | 
|---|
| 1740 |  | 
|---|
| 1741 | //-------------------------------------------------------------------------- | 
|---|
| 1742 | // ImplicitCtorDtorStmt | 
|---|
| 1743 | template< typename pass_type > | 
|---|
| 1744 | void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) { | 
|---|
| 1745 | VISIT_START( node ); | 
|---|
| 1746 |  | 
|---|
| 1747 | maybeAccept_impl( node->callStmt, *this ); | 
|---|
| 1748 |  | 
|---|
| 1749 | VISIT_END( node ); | 
|---|
| 1750 | } | 
|---|
| 1751 |  | 
|---|
| 1752 | template< typename pass_type > | 
|---|
| 1753 | void PassVisitor< pass_type >::visit( const ImplicitCtorDtorStmt * node ) { | 
|---|
| 1754 | VISIT_START( node ); | 
|---|
| 1755 |  | 
|---|
| 1756 | maybeAccept_impl( node->callStmt, *this ); | 
|---|
| 1757 |  | 
|---|
| 1758 | VISIT_END( node ); | 
|---|
| 1759 | } | 
|---|
| 1760 |  | 
|---|
| 1761 | template< typename pass_type > | 
|---|
| 1762 | Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) { | 
|---|
| 1763 | MUTATE_START( node ); | 
|---|
| 1764 |  | 
|---|
| 1765 | maybeMutate_impl( node->callStmt, *this ); | 
|---|
| 1766 |  | 
|---|
| 1767 | MUTATE_END( Statement, node ); | 
|---|
| 1768 | } | 
|---|
| 1769 |  | 
|---|
| 1770 | //-------------------------------------------------------------------------- | 
|---|
| 1771 | // ApplicationExpr | 
|---|
| 1772 | template< typename pass_type > | 
|---|
| 1773 | void PassVisitor< pass_type >::visit( ApplicationExpr * node ) { | 
|---|
| 1774 | VISIT_START( node ); | 
|---|
| 1775 |  | 
|---|
| 1776 | indexerScopedAccept( node->result  , *this ); | 
|---|
| 1777 | maybeAccept_impl   ( node->function, *this ); | 
|---|
| 1778 | maybeAccept_impl   ( node->args    , *this ); | 
|---|
| 1779 |  | 
|---|
| 1780 | VISIT_END( node ); | 
|---|
| 1781 | } | 
|---|
| 1782 |  | 
|---|
| 1783 | template< typename pass_type > | 
|---|
| 1784 | void PassVisitor< pass_type >::visit( const ApplicationExpr * node ) { | 
|---|
| 1785 | VISIT_START( node ); | 
|---|
| 1786 |  | 
|---|
| 1787 | indexerScopedAccept( node->result  , *this ); | 
|---|
| 1788 | maybeAccept_impl   ( node->function, *this ); | 
|---|
| 1789 | maybeAccept_impl   ( node->args    , *this ); | 
|---|
| 1790 |  | 
|---|
| 1791 | VISIT_END( node ); | 
|---|
| 1792 | } | 
|---|
| 1793 |  | 
|---|
| 1794 | template< typename pass_type > | 
|---|
| 1795 | Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) { | 
|---|
| 1796 | MUTATE_START( node ); | 
|---|
| 1797 |  | 
|---|
| 1798 | indexerScopedMutate( node->env     , *this ); | 
|---|
| 1799 | indexerScopedMutate( node->result  , *this ); | 
|---|
| 1800 | maybeMutate_impl   ( node->function, *this ); | 
|---|
| 1801 | maybeMutate_impl   ( node->args    , *this ); | 
|---|
| 1802 |  | 
|---|
| 1803 | MUTATE_END( Expression, node ); | 
|---|
| 1804 | } | 
|---|
| 1805 |  | 
|---|
| 1806 | //-------------------------------------------------------------------------- | 
|---|
| 1807 | // UntypedExpr | 
|---|
| 1808 | template< typename pass_type > | 
|---|
| 1809 | void PassVisitor< pass_type >::visit( UntypedExpr * node ) { | 
|---|
| 1810 | VISIT_START( node ); | 
|---|
| 1811 |  | 
|---|
| 1812 | // maybeAccept_impl( node->get_env(), *this ); | 
|---|
| 1813 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1814 |  | 
|---|
| 1815 | for ( auto expr : node->args ) { | 
|---|
| 1816 | visitExpression( expr ); | 
|---|
| 1817 | } | 
|---|
| 1818 |  | 
|---|
| 1819 | VISIT_END( node ); | 
|---|
| 1820 | } | 
|---|
| 1821 |  | 
|---|
| 1822 | template< typename pass_type > | 
|---|
| 1823 | void PassVisitor< pass_type >::visit( const UntypedExpr * node ) { | 
|---|
| 1824 | VISIT_START( node ); | 
|---|
| 1825 |  | 
|---|
| 1826 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1827 |  | 
|---|
| 1828 | for ( auto expr : node->args ) { | 
|---|
| 1829 | visitExpression( expr ); | 
|---|
| 1830 | } | 
|---|
| 1831 |  | 
|---|
| 1832 | VISIT_END( node ); | 
|---|
| 1833 | } | 
|---|
| 1834 |  | 
|---|
| 1835 | template< typename pass_type > | 
|---|
| 1836 | Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) { | 
|---|
| 1837 | MUTATE_START( node ); | 
|---|
| 1838 |  | 
|---|
| 1839 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 1840 | indexerScopedMutate( node->result, *this ); | 
|---|
| 1841 |  | 
|---|
| 1842 | for ( auto& expr : node->args ) { | 
|---|
| 1843 | expr = mutateExpression( expr ); | 
|---|
| 1844 | } | 
|---|
| 1845 |  | 
|---|
| 1846 | MUTATE_END( Expression, node ); | 
|---|
| 1847 | } | 
|---|
| 1848 |  | 
|---|
| 1849 | //-------------------------------------------------------------------------- | 
|---|
| 1850 | // NameExpr | 
|---|
| 1851 | template< typename pass_type > | 
|---|
| 1852 | void PassVisitor< pass_type >::visit( NameExpr * node ) { | 
|---|
| 1853 | VISIT_START( node ); | 
|---|
| 1854 |  | 
|---|
| 1855 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1856 |  | 
|---|
| 1857 | VISIT_END( node ); | 
|---|
| 1858 | } | 
|---|
| 1859 |  | 
|---|
| 1860 | template< typename pass_type > | 
|---|
| 1861 | void PassVisitor< pass_type >::visit( const NameExpr * node ) { | 
|---|
| 1862 | VISIT_START( node ); | 
|---|
| 1863 |  | 
|---|
| 1864 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1865 |  | 
|---|
| 1866 | VISIT_END( node ); | 
|---|
| 1867 | } | 
|---|
| 1868 |  | 
|---|
| 1869 | template< typename pass_type > | 
|---|
| 1870 | Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) { | 
|---|
| 1871 | MUTATE_START( node ); | 
|---|
| 1872 |  | 
|---|
| 1873 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 1874 | indexerScopedMutate( node->result, *this ); | 
|---|
| 1875 |  | 
|---|
| 1876 | MUTATE_END( Expression, node ); | 
|---|
| 1877 | } | 
|---|
| 1878 |  | 
|---|
| 1879 | //-------------------------------------------------------------------------- | 
|---|
| 1880 | // CastExpr | 
|---|
| 1881 | template< typename pass_type > | 
|---|
| 1882 | void PassVisitor< pass_type >::visit( CastExpr * node ) { | 
|---|
| 1883 | VISIT_START( node ); | 
|---|
| 1884 |  | 
|---|
| 1885 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1886 | maybeAccept_impl   ( node->arg   , *this ); | 
|---|
| 1887 |  | 
|---|
| 1888 | VISIT_END( node ); | 
|---|
| 1889 | } | 
|---|
| 1890 |  | 
|---|
| 1891 | template< typename pass_type > | 
|---|
| 1892 | void PassVisitor< pass_type >::visit( const CastExpr * node ) { | 
|---|
| 1893 | VISIT_START( node ); | 
|---|
| 1894 |  | 
|---|
| 1895 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1896 | maybeAccept_impl   ( node->arg   , *this ); | 
|---|
| 1897 |  | 
|---|
| 1898 | VISIT_END( node ); | 
|---|
| 1899 | } | 
|---|
| 1900 |  | 
|---|
| 1901 | template< typename pass_type > | 
|---|
| 1902 | Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) { | 
|---|
| 1903 | MUTATE_START( node ); | 
|---|
| 1904 |  | 
|---|
| 1905 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 1906 | indexerScopedMutate( node->result, *this ); | 
|---|
| 1907 | maybeMutate_impl   ( node->arg   , *this ); | 
|---|
| 1908 |  | 
|---|
| 1909 | MUTATE_END( Expression, node ); | 
|---|
| 1910 | } | 
|---|
| 1911 |  | 
|---|
| 1912 | //-------------------------------------------------------------------------- | 
|---|
| 1913 | // KeywordCastExpr | 
|---|
| 1914 | template< typename pass_type > | 
|---|
| 1915 | void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) { | 
|---|
| 1916 | VISIT_START( node ); | 
|---|
| 1917 |  | 
|---|
| 1918 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1919 | maybeAccept_impl        ( node->arg   , *this ); | 
|---|
| 1920 |  | 
|---|
| 1921 | VISIT_END( node ); | 
|---|
| 1922 | } | 
|---|
| 1923 |  | 
|---|
| 1924 | template< typename pass_type > | 
|---|
| 1925 | void PassVisitor< pass_type >::visit( const KeywordCastExpr * node ) { | 
|---|
| 1926 | VISIT_START( node ); | 
|---|
| 1927 |  | 
|---|
| 1928 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1929 | maybeAccept_impl   ( node->arg   , *this ); | 
|---|
| 1930 |  | 
|---|
| 1931 | VISIT_END( node ); | 
|---|
| 1932 | } | 
|---|
| 1933 |  | 
|---|
| 1934 | template< typename pass_type > | 
|---|
| 1935 | Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) { | 
|---|
| 1936 | MUTATE_START( node ); | 
|---|
| 1937 |  | 
|---|
| 1938 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 1939 | indexerScopedMutate( node->result, *this ); | 
|---|
| 1940 | maybeMutate_impl   ( node->arg   , *this ); | 
|---|
| 1941 |  | 
|---|
| 1942 | MUTATE_END( Expression, node ); | 
|---|
| 1943 | } | 
|---|
| 1944 |  | 
|---|
| 1945 | //-------------------------------------------------------------------------- | 
|---|
| 1946 | // VirtualCastExpr | 
|---|
| 1947 | template< typename pass_type > | 
|---|
| 1948 | void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) { | 
|---|
| 1949 | VISIT_START( node ); | 
|---|
| 1950 |  | 
|---|
| 1951 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1952 | maybeAccept_impl   ( node->arg, *this ); | 
|---|
| 1953 |  | 
|---|
| 1954 | VISIT_END( node ); | 
|---|
| 1955 | } | 
|---|
| 1956 |  | 
|---|
| 1957 | template< typename pass_type > | 
|---|
| 1958 | void PassVisitor< pass_type >::visit( const VirtualCastExpr * node ) { | 
|---|
| 1959 | VISIT_START( node ); | 
|---|
| 1960 |  | 
|---|
| 1961 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1962 | maybeAccept_impl   ( node->arg, *this ); | 
|---|
| 1963 |  | 
|---|
| 1964 | VISIT_END( node ); | 
|---|
| 1965 | } | 
|---|
| 1966 |  | 
|---|
| 1967 | template< typename pass_type > | 
|---|
| 1968 | Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) { | 
|---|
| 1969 | MUTATE_START( node ); | 
|---|
| 1970 |  | 
|---|
| 1971 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 1972 | indexerScopedMutate( node->result, *this ); | 
|---|
| 1973 | maybeMutate_impl   ( node->arg   , *this ); | 
|---|
| 1974 |  | 
|---|
| 1975 | MUTATE_END( Expression, node ); | 
|---|
| 1976 | } | 
|---|
| 1977 |  | 
|---|
| 1978 | //-------------------------------------------------------------------------- | 
|---|
| 1979 | // AddressExpr | 
|---|
| 1980 | template< typename pass_type > | 
|---|
| 1981 | void PassVisitor< pass_type >::visit( AddressExpr * node ) { | 
|---|
| 1982 | VISIT_START( node ); | 
|---|
| 1983 |  | 
|---|
| 1984 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1985 | maybeAccept_impl   ( node->arg   , *this ); | 
|---|
| 1986 |  | 
|---|
| 1987 | VISIT_END( node ); | 
|---|
| 1988 | } | 
|---|
| 1989 |  | 
|---|
| 1990 | template< typename pass_type > | 
|---|
| 1991 | void PassVisitor< pass_type >::visit( const AddressExpr * node ) { | 
|---|
| 1992 | VISIT_START( node ); | 
|---|
| 1993 |  | 
|---|
| 1994 | indexerScopedAccept( node->result, *this ); | 
|---|
| 1995 | maybeAccept_impl   ( node->arg   , *this ); | 
|---|
| 1996 |  | 
|---|
| 1997 | VISIT_END( node ); | 
|---|
| 1998 | } | 
|---|
| 1999 |  | 
|---|
| 2000 | template< typename pass_type > | 
|---|
| 2001 | Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) { | 
|---|
| 2002 | MUTATE_START( node ); | 
|---|
| 2003 |  | 
|---|
| 2004 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2005 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2006 | maybeMutate_impl   ( node->arg   , *this ); | 
|---|
| 2007 |  | 
|---|
| 2008 | MUTATE_END( Expression, node ); | 
|---|
| 2009 | } | 
|---|
| 2010 |  | 
|---|
| 2011 | //-------------------------------------------------------------------------- | 
|---|
| 2012 | // LabelAddressExpr | 
|---|
| 2013 | template< typename pass_type > | 
|---|
| 2014 | void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) { | 
|---|
| 2015 | VISIT_START( node ); | 
|---|
| 2016 |  | 
|---|
| 2017 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2018 |  | 
|---|
| 2019 | VISIT_END( node ); | 
|---|
| 2020 | } | 
|---|
| 2021 |  | 
|---|
| 2022 | template< typename pass_type > | 
|---|
| 2023 | void PassVisitor< pass_type >::visit( const LabelAddressExpr * node ) { | 
|---|
| 2024 | VISIT_START( node ); | 
|---|
| 2025 |  | 
|---|
| 2026 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2027 |  | 
|---|
| 2028 | VISIT_END( node ); | 
|---|
| 2029 | } | 
|---|
| 2030 |  | 
|---|
| 2031 | template< typename pass_type > | 
|---|
| 2032 | Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) { | 
|---|
| 2033 | MUTATE_START( node ); | 
|---|
| 2034 |  | 
|---|
| 2035 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2036 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2037 |  | 
|---|
| 2038 | MUTATE_END( Expression, node ); | 
|---|
| 2039 | } | 
|---|
| 2040 |  | 
|---|
| 2041 | //-------------------------------------------------------------------------- | 
|---|
| 2042 | // UntypedMemberExpr | 
|---|
| 2043 | template< typename pass_type > | 
|---|
| 2044 | void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) { | 
|---|
| 2045 | VISIT_START( node ); | 
|---|
| 2046 |  | 
|---|
| 2047 | indexerScopedAccept( node->result   , *this ); | 
|---|
| 2048 | maybeAccept_impl   ( node->aggregate, *this ); | 
|---|
| 2049 | maybeAccept_impl   ( node->member   , *this ); | 
|---|
| 2050 |  | 
|---|
| 2051 | VISIT_END( node ); | 
|---|
| 2052 | } | 
|---|
| 2053 |  | 
|---|
| 2054 | template< typename pass_type > | 
|---|
| 2055 | void PassVisitor< pass_type >::visit( const UntypedMemberExpr * node ) { | 
|---|
| 2056 | VISIT_START( node ); | 
|---|
| 2057 |  | 
|---|
| 2058 | indexerScopedAccept( node->result   , *this ); | 
|---|
| 2059 | maybeAccept_impl   ( node->aggregate, *this ); | 
|---|
| 2060 | maybeAccept_impl   ( node->member   , *this ); | 
|---|
| 2061 |  | 
|---|
| 2062 | VISIT_END( node ); | 
|---|
| 2063 | } | 
|---|
| 2064 |  | 
|---|
| 2065 | template< typename pass_type > | 
|---|
| 2066 | Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) { | 
|---|
| 2067 | MUTATE_START( node ); | 
|---|
| 2068 |  | 
|---|
| 2069 | indexerScopedMutate( node->env      , *this ); | 
|---|
| 2070 | indexerScopedMutate( node->result   , *this ); | 
|---|
| 2071 | maybeMutate_impl   ( node->aggregate, *this ); | 
|---|
| 2072 | maybeMutate_impl   ( node->member   , *this ); | 
|---|
| 2073 |  | 
|---|
| 2074 | MUTATE_END( Expression, node ); | 
|---|
| 2075 | } | 
|---|
| 2076 |  | 
|---|
| 2077 | //-------------------------------------------------------------------------- | 
|---|
| 2078 | // MemberExpr | 
|---|
| 2079 | template< typename pass_type > | 
|---|
| 2080 | void PassVisitor< pass_type >::visit( MemberExpr * node ) { | 
|---|
| 2081 | VISIT_START( node ); | 
|---|
| 2082 |  | 
|---|
| 2083 | indexerScopedAccept( node->result   , *this ); | 
|---|
| 2084 | maybeAccept_impl   ( node->aggregate, *this ); | 
|---|
| 2085 |  | 
|---|
| 2086 | VISIT_END( node ); | 
|---|
| 2087 | } | 
|---|
| 2088 |  | 
|---|
| 2089 | template< typename pass_type > | 
|---|
| 2090 | void PassVisitor< pass_type >::visit( const MemberExpr * node ) { | 
|---|
| 2091 | VISIT_START( node ); | 
|---|
| 2092 |  | 
|---|
| 2093 | indexerScopedAccept( node->result   , *this ); | 
|---|
| 2094 | maybeAccept_impl   ( node->aggregate, *this ); | 
|---|
| 2095 |  | 
|---|
| 2096 | VISIT_END( node ); | 
|---|
| 2097 | } | 
|---|
| 2098 |  | 
|---|
| 2099 | template< typename pass_type > | 
|---|
| 2100 | Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) { | 
|---|
| 2101 | MUTATE_START( node ); | 
|---|
| 2102 |  | 
|---|
| 2103 | indexerScopedMutate( node->env      , *this ); | 
|---|
| 2104 | indexerScopedMutate( node->result   , *this ); | 
|---|
| 2105 | maybeMutate_impl   ( node->aggregate, *this ); | 
|---|
| 2106 |  | 
|---|
| 2107 | MUTATE_END( Expression, node ); | 
|---|
| 2108 | } | 
|---|
| 2109 |  | 
|---|
| 2110 | //-------------------------------------------------------------------------- | 
|---|
| 2111 | // VariableExpr | 
|---|
| 2112 | template< typename pass_type > | 
|---|
| 2113 | void PassVisitor< pass_type >::visit( VariableExpr * node ) { | 
|---|
| 2114 | VISIT_START( node ); | 
|---|
| 2115 |  | 
|---|
| 2116 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2117 |  | 
|---|
| 2118 | VISIT_END( node ); | 
|---|
| 2119 | } | 
|---|
| 2120 |  | 
|---|
| 2121 | template< typename pass_type > | 
|---|
| 2122 | void PassVisitor< pass_type >::visit( const VariableExpr * node ) { | 
|---|
| 2123 | VISIT_START( node ); | 
|---|
| 2124 |  | 
|---|
| 2125 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2126 |  | 
|---|
| 2127 | VISIT_END( node ); | 
|---|
| 2128 | } | 
|---|
| 2129 |  | 
|---|
| 2130 | template< typename pass_type > | 
|---|
| 2131 | Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) { | 
|---|
| 2132 | MUTATE_START( node ); | 
|---|
| 2133 |  | 
|---|
| 2134 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2135 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2136 |  | 
|---|
| 2137 | MUTATE_END( Expression, node ); | 
|---|
| 2138 | } | 
|---|
| 2139 |  | 
|---|
| 2140 | //-------------------------------------------------------------------------- | 
|---|
| 2141 | // ConstantExpr | 
|---|
| 2142 | template< typename pass_type > | 
|---|
| 2143 | void PassVisitor< pass_type >::visit( ConstantExpr * node ) { | 
|---|
| 2144 | VISIT_START( node ); | 
|---|
| 2145 |  | 
|---|
| 2146 | indexerScopedAccept( node->result   , *this ); | 
|---|
| 2147 | maybeAccept_impl   ( &node->constant, *this ); | 
|---|
| 2148 |  | 
|---|
| 2149 | VISIT_END( node ); | 
|---|
| 2150 | } | 
|---|
| 2151 |  | 
|---|
| 2152 | template< typename pass_type > | 
|---|
| 2153 | void PassVisitor< pass_type >::visit( const ConstantExpr * node ) { | 
|---|
| 2154 | VISIT_START( node ); | 
|---|
| 2155 |  | 
|---|
| 2156 | indexerScopedAccept( node->result   , *this ); | 
|---|
| 2157 | maybeAccept_impl   ( &node->constant, *this ); | 
|---|
| 2158 |  | 
|---|
| 2159 | VISIT_END( node ); | 
|---|
| 2160 | } | 
|---|
| 2161 |  | 
|---|
| 2162 | template< typename pass_type > | 
|---|
| 2163 | Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) { | 
|---|
| 2164 | MUTATE_START( node ); | 
|---|
| 2165 |  | 
|---|
| 2166 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2167 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2168 | Constant * ptr = &node->constant; | 
|---|
| 2169 | maybeMutate_impl( ptr, *this ); | 
|---|
| 2170 | node->constant = *ptr; | 
|---|
| 2171 |  | 
|---|
| 2172 | MUTATE_END( Expression, node ); | 
|---|
| 2173 | } | 
|---|
| 2174 |  | 
|---|
| 2175 | //-------------------------------------------------------------------------- | 
|---|
| 2176 | // SizeofExpr | 
|---|
| 2177 | template< typename pass_type > | 
|---|
| 2178 | void PassVisitor< pass_type >::visit( SizeofExpr * node ) { | 
|---|
| 2179 | VISIT_START( node ); | 
|---|
| 2180 |  | 
|---|
| 2181 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2182 | if ( node->get_isType() ) { | 
|---|
| 2183 | maybeAccept_impl( node->type, *this ); | 
|---|
| 2184 | } else { | 
|---|
| 2185 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 2186 | } | 
|---|
| 2187 |  | 
|---|
| 2188 | VISIT_END( node ); | 
|---|
| 2189 | } | 
|---|
| 2190 |  | 
|---|
| 2191 | template< typename pass_type > | 
|---|
| 2192 | void PassVisitor< pass_type >::visit( const SizeofExpr * node ) { | 
|---|
| 2193 | VISIT_START( node ); | 
|---|
| 2194 |  | 
|---|
| 2195 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2196 | if ( node->get_isType() ) { | 
|---|
| 2197 | maybeAccept_impl( node->type, *this ); | 
|---|
| 2198 | } else { | 
|---|
| 2199 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 2200 | } | 
|---|
| 2201 |  | 
|---|
| 2202 | VISIT_END( node ); | 
|---|
| 2203 | } | 
|---|
| 2204 |  | 
|---|
| 2205 | template< typename pass_type > | 
|---|
| 2206 | Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) { | 
|---|
| 2207 | MUTATE_START( node ); | 
|---|
| 2208 |  | 
|---|
| 2209 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2210 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2211 | if ( node->get_isType() ) { | 
|---|
| 2212 | maybeMutate_impl( node->type, *this ); | 
|---|
| 2213 | } else { | 
|---|
| 2214 | maybeMutate_impl( node->expr, *this ); | 
|---|
| 2215 | } | 
|---|
| 2216 |  | 
|---|
| 2217 | MUTATE_END( Expression, node ); | 
|---|
| 2218 | } | 
|---|
| 2219 |  | 
|---|
| 2220 | //-------------------------------------------------------------------------- | 
|---|
| 2221 | // AlignofExpr | 
|---|
| 2222 | template< typename pass_type > | 
|---|
| 2223 | void PassVisitor< pass_type >::visit( AlignofExpr * node ) { | 
|---|
| 2224 | VISIT_START( node ); | 
|---|
| 2225 |  | 
|---|
| 2226 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2227 | if ( node->get_isType() ) { | 
|---|
| 2228 | maybeAccept_impl( node->type, *this ); | 
|---|
| 2229 | } else { | 
|---|
| 2230 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 2231 | } | 
|---|
| 2232 |  | 
|---|
| 2233 | VISIT_END( node ); | 
|---|
| 2234 | } | 
|---|
| 2235 |  | 
|---|
| 2236 | template< typename pass_type > | 
|---|
| 2237 | void PassVisitor< pass_type >::visit( const AlignofExpr * node ) { | 
|---|
| 2238 | VISIT_START( node ); | 
|---|
| 2239 |  | 
|---|
| 2240 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2241 | if ( node->get_isType() ) { | 
|---|
| 2242 | maybeAccept_impl( node->type, *this ); | 
|---|
| 2243 | } else { | 
|---|
| 2244 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 2245 | } | 
|---|
| 2246 |  | 
|---|
| 2247 | VISIT_END( node ); | 
|---|
| 2248 | } | 
|---|
| 2249 |  | 
|---|
| 2250 | template< typename pass_type > | 
|---|
| 2251 | Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) { | 
|---|
| 2252 | MUTATE_START( node ); | 
|---|
| 2253 |  | 
|---|
| 2254 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2255 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2256 | if ( node->get_isType() ) { | 
|---|
| 2257 | maybeMutate_impl( node->type, *this ); | 
|---|
| 2258 | } else { | 
|---|
| 2259 | maybeMutate_impl( node->expr, *this ); | 
|---|
| 2260 | } | 
|---|
| 2261 |  | 
|---|
| 2262 | MUTATE_END( Expression, node ); | 
|---|
| 2263 | } | 
|---|
| 2264 |  | 
|---|
| 2265 | //-------------------------------------------------------------------------- | 
|---|
| 2266 | // UntypedOffsetofExpr | 
|---|
| 2267 | template< typename pass_type > | 
|---|
| 2268 | void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) { | 
|---|
| 2269 | VISIT_START( node ); | 
|---|
| 2270 |  | 
|---|
| 2271 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2272 | maybeAccept_impl   ( node->type  , *this ); | 
|---|
| 2273 |  | 
|---|
| 2274 | VISIT_END( node ); | 
|---|
| 2275 | } | 
|---|
| 2276 |  | 
|---|
| 2277 | template< typename pass_type > | 
|---|
| 2278 | void PassVisitor< pass_type >::visit( const UntypedOffsetofExpr * node ) { | 
|---|
| 2279 | VISIT_START( node ); | 
|---|
| 2280 |  | 
|---|
| 2281 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2282 | maybeAccept_impl   ( node->type  , *this ); | 
|---|
| 2283 |  | 
|---|
| 2284 | VISIT_END( node ); | 
|---|
| 2285 | } | 
|---|
| 2286 |  | 
|---|
| 2287 | template< typename pass_type > | 
|---|
| 2288 | Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) { | 
|---|
| 2289 | MUTATE_START( node ); | 
|---|
| 2290 |  | 
|---|
| 2291 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2292 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2293 | maybeMutate_impl   ( node->type  , *this ); | 
|---|
| 2294 |  | 
|---|
| 2295 | MUTATE_END( Expression, node ); | 
|---|
| 2296 | } | 
|---|
| 2297 |  | 
|---|
| 2298 | //-------------------------------------------------------------------------- | 
|---|
| 2299 | // OffsetofExpr | 
|---|
| 2300 | template< typename pass_type > | 
|---|
| 2301 | void PassVisitor< pass_type >::visit( OffsetofExpr * node ) { | 
|---|
| 2302 | VISIT_START( node ); | 
|---|
| 2303 |  | 
|---|
| 2304 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2305 | maybeAccept_impl   ( node->type  , *this ); | 
|---|
| 2306 |  | 
|---|
| 2307 | VISIT_END( node ); | 
|---|
| 2308 | } | 
|---|
| 2309 |  | 
|---|
| 2310 | template< typename pass_type > | 
|---|
| 2311 | void PassVisitor< pass_type >::visit( const OffsetofExpr * node ) { | 
|---|
| 2312 | VISIT_START( node ); | 
|---|
| 2313 |  | 
|---|
| 2314 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2315 | maybeAccept_impl   ( node->type  , *this ); | 
|---|
| 2316 |  | 
|---|
| 2317 | VISIT_END( node ); | 
|---|
| 2318 | } | 
|---|
| 2319 |  | 
|---|
| 2320 | template< typename pass_type > | 
|---|
| 2321 | Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) { | 
|---|
| 2322 | MUTATE_START( node ); | 
|---|
| 2323 |  | 
|---|
| 2324 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2325 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2326 | maybeMutate_impl   ( node->type  , *this ); | 
|---|
| 2327 |  | 
|---|
| 2328 | MUTATE_END( Expression, node ); | 
|---|
| 2329 | } | 
|---|
| 2330 |  | 
|---|
| 2331 | //-------------------------------------------------------------------------- | 
|---|
| 2332 | // OffsetPackExpr | 
|---|
| 2333 | template< typename pass_type > | 
|---|
| 2334 | void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) { | 
|---|
| 2335 | VISIT_START( node ); | 
|---|
| 2336 |  | 
|---|
| 2337 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2338 | maybeAccept_impl   ( node->type  , *this ); | 
|---|
| 2339 |  | 
|---|
| 2340 | VISIT_END( node ); | 
|---|
| 2341 | } | 
|---|
| 2342 |  | 
|---|
| 2343 | template< typename pass_type > | 
|---|
| 2344 | void PassVisitor< pass_type >::visit( const OffsetPackExpr * node ) { | 
|---|
| 2345 | VISIT_START( node ); | 
|---|
| 2346 |  | 
|---|
| 2347 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2348 | maybeAccept_impl   ( node->type  , *this ); | 
|---|
| 2349 |  | 
|---|
| 2350 | VISIT_END( node ); | 
|---|
| 2351 | } | 
|---|
| 2352 |  | 
|---|
| 2353 | template< typename pass_type > | 
|---|
| 2354 | Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) { | 
|---|
| 2355 | MUTATE_START( node ); | 
|---|
| 2356 |  | 
|---|
| 2357 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2358 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2359 | maybeMutate_impl   ( node->type  , *this ); | 
|---|
| 2360 |  | 
|---|
| 2361 | MUTATE_END( Expression, node ); | 
|---|
| 2362 | } | 
|---|
| 2363 |  | 
|---|
| 2364 | //-------------------------------------------------------------------------- | 
|---|
| 2365 | // LogicalExpr | 
|---|
| 2366 | template< typename pass_type > | 
|---|
| 2367 | void PassVisitor< pass_type >::visit( LogicalExpr * node ) { | 
|---|
| 2368 | VISIT_START( node ); | 
|---|
| 2369 |  | 
|---|
| 2370 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2371 | maybeAccept_impl   ( node->arg1  , *this ); | 
|---|
| 2372 | maybeAccept_impl   ( node->arg2  , *this ); | 
|---|
| 2373 |  | 
|---|
| 2374 | VISIT_END( node ); | 
|---|
| 2375 | } | 
|---|
| 2376 |  | 
|---|
| 2377 | template< typename pass_type > | 
|---|
| 2378 | void PassVisitor< pass_type >::visit( const LogicalExpr * node ) { | 
|---|
| 2379 | VISIT_START( node ); | 
|---|
| 2380 |  | 
|---|
| 2381 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2382 | maybeAccept_impl   ( node->arg1  , *this ); | 
|---|
| 2383 | maybeAccept_impl   ( node->arg2  , *this ); | 
|---|
| 2384 |  | 
|---|
| 2385 | VISIT_END( node ); | 
|---|
| 2386 | } | 
|---|
| 2387 |  | 
|---|
| 2388 | template< typename pass_type > | 
|---|
| 2389 | Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) { | 
|---|
| 2390 | MUTATE_START( node ); | 
|---|
| 2391 |  | 
|---|
| 2392 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2393 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2394 | maybeMutate_impl   ( node->arg1  , *this ); | 
|---|
| 2395 | maybeMutate_impl   ( node->arg2  , *this ); | 
|---|
| 2396 |  | 
|---|
| 2397 | MUTATE_END( Expression, node ); | 
|---|
| 2398 | } | 
|---|
| 2399 |  | 
|---|
| 2400 | //-------------------------------------------------------------------------- | 
|---|
| 2401 | // ConditionalExpr | 
|---|
| 2402 | template< typename pass_type > | 
|---|
| 2403 | void PassVisitor< pass_type >::visit( ConditionalExpr * node ) { | 
|---|
| 2404 | VISIT_START( node ); | 
|---|
| 2405 |  | 
|---|
| 2406 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2407 | maybeAccept_impl        ( node->arg1  , *this ); | 
|---|
| 2408 | maybeAccept_impl        ( node->arg2  , *this ); | 
|---|
| 2409 | maybeAccept_impl        ( node->arg3  , *this ); | 
|---|
| 2410 |  | 
|---|
| 2411 | VISIT_END( node ); | 
|---|
| 2412 | } | 
|---|
| 2413 |  | 
|---|
| 2414 | template< typename pass_type > | 
|---|
| 2415 | void PassVisitor< pass_type >::visit( const ConditionalExpr * node ) { | 
|---|
| 2416 | VISIT_START( node ); | 
|---|
| 2417 |  | 
|---|
| 2418 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2419 | maybeAccept_impl   ( node->arg1  , *this ); | 
|---|
| 2420 | maybeAccept_impl   ( node->arg2  , *this ); | 
|---|
| 2421 | maybeAccept_impl   ( node->arg3  , *this ); | 
|---|
| 2422 |  | 
|---|
| 2423 | VISIT_END( node ); | 
|---|
| 2424 | } | 
|---|
| 2425 |  | 
|---|
| 2426 | template< typename pass_type > | 
|---|
| 2427 | Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) { | 
|---|
| 2428 | MUTATE_START( node ); | 
|---|
| 2429 |  | 
|---|
| 2430 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2431 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2432 | maybeMutate_impl   ( node->arg1  , *this ); | 
|---|
| 2433 | maybeMutate_impl   ( node->arg2  , *this ); | 
|---|
| 2434 | maybeMutate_impl   ( node->arg3  , *this ); | 
|---|
| 2435 |  | 
|---|
| 2436 | MUTATE_END( Expression, node ); | 
|---|
| 2437 | } | 
|---|
| 2438 |  | 
|---|
| 2439 | //-------------------------------------------------------------------------- | 
|---|
| 2440 | // CommaExpr | 
|---|
| 2441 | template< typename pass_type > | 
|---|
| 2442 | void PassVisitor< pass_type >::visit( CommaExpr * node ) { | 
|---|
| 2443 | VISIT_START( node ); | 
|---|
| 2444 |  | 
|---|
| 2445 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2446 | maybeAccept_impl   ( node->arg1  , *this ); | 
|---|
| 2447 | maybeAccept_impl   ( node->arg2  , *this ); | 
|---|
| 2448 |  | 
|---|
| 2449 | VISIT_END( node ); | 
|---|
| 2450 | } | 
|---|
| 2451 |  | 
|---|
| 2452 | template< typename pass_type > | 
|---|
| 2453 | void PassVisitor< pass_type >::visit( const CommaExpr * node ) { | 
|---|
| 2454 | VISIT_START( node ); | 
|---|
| 2455 |  | 
|---|
| 2456 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2457 | maybeAccept_impl   ( node->arg1  , *this ); | 
|---|
| 2458 | maybeAccept_impl   ( node->arg2  , *this ); | 
|---|
| 2459 |  | 
|---|
| 2460 | VISIT_END( node ); | 
|---|
| 2461 | } | 
|---|
| 2462 |  | 
|---|
| 2463 | template< typename pass_type > | 
|---|
| 2464 | Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) { | 
|---|
| 2465 | MUTATE_START( node ); | 
|---|
| 2466 |  | 
|---|
| 2467 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2468 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2469 | maybeMutate_impl   ( node->arg1  , *this ); | 
|---|
| 2470 | maybeMutate_impl   ( node->arg2  , *this ); | 
|---|
| 2471 |  | 
|---|
| 2472 | MUTATE_END( Expression, node ); | 
|---|
| 2473 | } | 
|---|
| 2474 |  | 
|---|
| 2475 | //-------------------------------------------------------------------------- | 
|---|
| 2476 | // TypeExpr | 
|---|
| 2477 | template< typename pass_type > | 
|---|
| 2478 | void PassVisitor< pass_type >::visit( TypeExpr * node ) { | 
|---|
| 2479 | VISIT_START( node ); | 
|---|
| 2480 |  | 
|---|
| 2481 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2482 | maybeAccept_impl   ( node->type, *this ); | 
|---|
| 2483 |  | 
|---|
| 2484 | VISIT_END( node ); | 
|---|
| 2485 | } | 
|---|
| 2486 |  | 
|---|
| 2487 | template< typename pass_type > | 
|---|
| 2488 | void PassVisitor< pass_type >::visit( const TypeExpr * node ) { | 
|---|
| 2489 | VISIT_START( node ); | 
|---|
| 2490 |  | 
|---|
| 2491 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2492 | maybeAccept_impl   ( node->type, *this ); | 
|---|
| 2493 |  | 
|---|
| 2494 | VISIT_END( node ); | 
|---|
| 2495 | } | 
|---|
| 2496 |  | 
|---|
| 2497 | template< typename pass_type > | 
|---|
| 2498 | Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) { | 
|---|
| 2499 | MUTATE_START( node ); | 
|---|
| 2500 |  | 
|---|
| 2501 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2502 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2503 | maybeMutate_impl   ( node->type  , *this ); | 
|---|
| 2504 |  | 
|---|
| 2505 | MUTATE_END( Expression, node ); | 
|---|
| 2506 | } | 
|---|
| 2507 |  | 
|---|
| 2508 | //-------------------------------------------------------------------------- | 
|---|
| 2509 | // AsmExpr | 
|---|
| 2510 | template< typename pass_type > | 
|---|
| 2511 | void PassVisitor< pass_type >::visit( AsmExpr * node ) { | 
|---|
| 2512 | VISIT_START( node ); | 
|---|
| 2513 |  | 
|---|
| 2514 | indexerScopedAccept( node->result    , *this ); | 
|---|
| 2515 | maybeAccept_impl   ( node->constraint, *this ); | 
|---|
| 2516 | maybeAccept_impl   ( node->operand   , *this ); | 
|---|
| 2517 |  | 
|---|
| 2518 | VISIT_END( node ); | 
|---|
| 2519 | } | 
|---|
| 2520 |  | 
|---|
| 2521 | template< typename pass_type > | 
|---|
| 2522 | void PassVisitor< pass_type >::visit( const AsmExpr * node ) { | 
|---|
| 2523 | VISIT_START( node ); | 
|---|
| 2524 |  | 
|---|
| 2525 | indexerScopedAccept( node->result    , *this ); | 
|---|
| 2526 | maybeAccept_impl   ( node->constraint, *this ); | 
|---|
| 2527 | maybeAccept_impl   ( node->operand   , *this ); | 
|---|
| 2528 |  | 
|---|
| 2529 | VISIT_END( node ); | 
|---|
| 2530 | } | 
|---|
| 2531 |  | 
|---|
| 2532 | template< typename pass_type > | 
|---|
| 2533 | Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) { | 
|---|
| 2534 | MUTATE_START( node ); | 
|---|
| 2535 |  | 
|---|
| 2536 | indexerScopedMutate( node->env       , *this ); | 
|---|
| 2537 | indexerScopedMutate( node->result    , *this ); | 
|---|
| 2538 | maybeMutate_impl   ( node->constraint, *this ); | 
|---|
| 2539 | maybeMutate_impl   ( node->operand   , *this ); | 
|---|
| 2540 |  | 
|---|
| 2541 | MUTATE_END( Expression, node ); | 
|---|
| 2542 | } | 
|---|
| 2543 |  | 
|---|
| 2544 | //-------------------------------------------------------------------------- | 
|---|
| 2545 | // ImplicitCopyCtorExpr | 
|---|
| 2546 | template< typename pass_type > | 
|---|
| 2547 | void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) { | 
|---|
| 2548 | VISIT_START( node ); | 
|---|
| 2549 |  | 
|---|
| 2550 | indexerScopedAccept( node->result    , *this ); | 
|---|
| 2551 | maybeAccept_impl   ( node->callExpr  , *this ); | 
|---|
| 2552 |  | 
|---|
| 2553 | VISIT_END( node ); | 
|---|
| 2554 | } | 
|---|
| 2555 |  | 
|---|
| 2556 | template< typename pass_type > | 
|---|
| 2557 | void PassVisitor< pass_type >::visit( const ImplicitCopyCtorExpr * node ) { | 
|---|
| 2558 | VISIT_START( node ); | 
|---|
| 2559 |  | 
|---|
| 2560 | indexerScopedAccept( node->result    , *this ); | 
|---|
| 2561 | maybeAccept_impl   ( node->callExpr  , *this ); | 
|---|
| 2562 |  | 
|---|
| 2563 | VISIT_END( node ); | 
|---|
| 2564 | } | 
|---|
| 2565 |  | 
|---|
| 2566 | template< typename pass_type > | 
|---|
| 2567 | Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) { | 
|---|
| 2568 | MUTATE_START( node ); | 
|---|
| 2569 |  | 
|---|
| 2570 | indexerScopedMutate( node->env       , *this ); | 
|---|
| 2571 | indexerScopedMutate( node->result    , *this ); | 
|---|
| 2572 | maybeMutate_impl   ( node->callExpr  , *this ); | 
|---|
| 2573 |  | 
|---|
| 2574 | MUTATE_END( Expression, node ); | 
|---|
| 2575 | } | 
|---|
| 2576 |  | 
|---|
| 2577 | //-------------------------------------------------------------------------- | 
|---|
| 2578 | // ConstructorExpr | 
|---|
| 2579 | template< typename pass_type > | 
|---|
| 2580 | void PassVisitor< pass_type >::visit( ConstructorExpr * node ) { | 
|---|
| 2581 | VISIT_START( node ); | 
|---|
| 2582 |  | 
|---|
| 2583 | indexerScopedAccept( node->result  , *this ); | 
|---|
| 2584 | maybeAccept_impl   ( node->callExpr, *this ); | 
|---|
| 2585 |  | 
|---|
| 2586 | VISIT_END( node ); | 
|---|
| 2587 | } | 
|---|
| 2588 |  | 
|---|
| 2589 | template< typename pass_type > | 
|---|
| 2590 | void PassVisitor< pass_type >::visit( const ConstructorExpr * node ) { | 
|---|
| 2591 | VISIT_START( node ); | 
|---|
| 2592 |  | 
|---|
| 2593 | indexerScopedAccept( node->result  , *this ); | 
|---|
| 2594 | maybeAccept_impl   ( node->callExpr, *this ); | 
|---|
| 2595 |  | 
|---|
| 2596 | VISIT_END( node ); | 
|---|
| 2597 | } | 
|---|
| 2598 |  | 
|---|
| 2599 | template< typename pass_type > | 
|---|
| 2600 | Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) { | 
|---|
| 2601 | MUTATE_START( node ); | 
|---|
| 2602 |  | 
|---|
| 2603 | indexerScopedMutate( node->env     , *this ); | 
|---|
| 2604 | indexerScopedMutate( node->result  , *this ); | 
|---|
| 2605 | maybeMutate_impl   ( node->callExpr, *this ); | 
|---|
| 2606 |  | 
|---|
| 2607 | MUTATE_END( Expression, node ); | 
|---|
| 2608 | } | 
|---|
| 2609 |  | 
|---|
| 2610 | //-------------------------------------------------------------------------- | 
|---|
| 2611 | // CompoundLiteralExpr | 
|---|
| 2612 | template< typename pass_type > | 
|---|
| 2613 | void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) { | 
|---|
| 2614 | VISIT_START( node ); | 
|---|
| 2615 |  | 
|---|
| 2616 | indexerScopedAccept( node->result     , *this ); | 
|---|
| 2617 | maybeAccept_impl   ( node->initializer, *this ); | 
|---|
| 2618 |  | 
|---|
| 2619 | VISIT_END( node ); | 
|---|
| 2620 | } | 
|---|
| 2621 |  | 
|---|
| 2622 | template< typename pass_type > | 
|---|
| 2623 | void PassVisitor< pass_type >::visit( const CompoundLiteralExpr * node ) { | 
|---|
| 2624 | VISIT_START( node ); | 
|---|
| 2625 |  | 
|---|
| 2626 | indexerScopedAccept( node->result     , *this ); | 
|---|
| 2627 | maybeAccept_impl   ( node->initializer, *this ); | 
|---|
| 2628 |  | 
|---|
| 2629 | VISIT_END( node ); | 
|---|
| 2630 | } | 
|---|
| 2631 |  | 
|---|
| 2632 | template< typename pass_type > | 
|---|
| 2633 | Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) { | 
|---|
| 2634 | MUTATE_START( node ); | 
|---|
| 2635 |  | 
|---|
| 2636 | indexerScopedMutate( node->env        , *this ); | 
|---|
| 2637 | indexerScopedMutate( node->result     , *this ); | 
|---|
| 2638 | maybeMutate_impl     ( node->initializer, *this ); | 
|---|
| 2639 |  | 
|---|
| 2640 | MUTATE_END( Expression, node ); | 
|---|
| 2641 | } | 
|---|
| 2642 |  | 
|---|
| 2643 | //-------------------------------------------------------------------------- | 
|---|
| 2644 | // RangeExpr | 
|---|
| 2645 | template< typename pass_type > | 
|---|
| 2646 | void PassVisitor< pass_type >::visit( RangeExpr * node ) { | 
|---|
| 2647 | VISIT_START( node ); | 
|---|
| 2648 |  | 
|---|
| 2649 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2650 | maybeAccept_impl   ( node->low   , *this ); | 
|---|
| 2651 | maybeAccept_impl   ( node->high  , *this ); | 
|---|
| 2652 |  | 
|---|
| 2653 | VISIT_END( node ); | 
|---|
| 2654 | } | 
|---|
| 2655 |  | 
|---|
| 2656 | template< typename pass_type > | 
|---|
| 2657 | void PassVisitor< pass_type >::visit( const RangeExpr * node ) { | 
|---|
| 2658 | VISIT_START( node ); | 
|---|
| 2659 |  | 
|---|
| 2660 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2661 | maybeAccept_impl   ( node->low   , *this ); | 
|---|
| 2662 | maybeAccept_impl   ( node->high  , *this ); | 
|---|
| 2663 |  | 
|---|
| 2664 | VISIT_END( node ); | 
|---|
| 2665 | } | 
|---|
| 2666 |  | 
|---|
| 2667 | template< typename pass_type > | 
|---|
| 2668 | Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) { | 
|---|
| 2669 | MUTATE_START( node ); | 
|---|
| 2670 |  | 
|---|
| 2671 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2672 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2673 | maybeMutate_impl   ( node->low   , *this ); | 
|---|
| 2674 | maybeMutate_impl   ( node->high  , *this ); | 
|---|
| 2675 |  | 
|---|
| 2676 | MUTATE_END( Expression, node ); | 
|---|
| 2677 | } | 
|---|
| 2678 |  | 
|---|
| 2679 | //-------------------------------------------------------------------------- | 
|---|
| 2680 | // UntypedTupleExpr | 
|---|
| 2681 | template< typename pass_type > | 
|---|
| 2682 | void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) { | 
|---|
| 2683 | VISIT_START( node ); | 
|---|
| 2684 |  | 
|---|
| 2685 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2686 | maybeAccept_impl   ( node->exprs , *this ); | 
|---|
| 2687 |  | 
|---|
| 2688 | VISIT_END( node ); | 
|---|
| 2689 | } | 
|---|
| 2690 |  | 
|---|
| 2691 | template< typename pass_type > | 
|---|
| 2692 | void PassVisitor< pass_type >::visit( const UntypedTupleExpr * node ) { | 
|---|
| 2693 | VISIT_START( node ); | 
|---|
| 2694 |  | 
|---|
| 2695 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2696 | maybeAccept_impl   ( node->exprs , *this ); | 
|---|
| 2697 |  | 
|---|
| 2698 | VISIT_END( node ); | 
|---|
| 2699 | } | 
|---|
| 2700 |  | 
|---|
| 2701 | template< typename pass_type > | 
|---|
| 2702 | Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) { | 
|---|
| 2703 | MUTATE_START( node ); | 
|---|
| 2704 |  | 
|---|
| 2705 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2706 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2707 | maybeMutate_impl   ( node->exprs , *this ); | 
|---|
| 2708 |  | 
|---|
| 2709 | MUTATE_END( Expression, node ); | 
|---|
| 2710 | } | 
|---|
| 2711 |  | 
|---|
| 2712 | //-------------------------------------------------------------------------- | 
|---|
| 2713 | // TupleExpr | 
|---|
| 2714 | template< typename pass_type > | 
|---|
| 2715 | void PassVisitor< pass_type >::visit( TupleExpr * node ) { | 
|---|
| 2716 | VISIT_START( node ); | 
|---|
| 2717 |  | 
|---|
| 2718 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2719 | maybeAccept_impl   ( node->exprs , *this ); | 
|---|
| 2720 |  | 
|---|
| 2721 | VISIT_END( node ); | 
|---|
| 2722 | } | 
|---|
| 2723 |  | 
|---|
| 2724 | template< typename pass_type > | 
|---|
| 2725 | void PassVisitor< pass_type >::visit( const TupleExpr * node ) { | 
|---|
| 2726 | VISIT_START( node ); | 
|---|
| 2727 |  | 
|---|
| 2728 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2729 | maybeAccept_impl   ( node->exprs , *this ); | 
|---|
| 2730 |  | 
|---|
| 2731 | VISIT_END( node ); | 
|---|
| 2732 | } | 
|---|
| 2733 |  | 
|---|
| 2734 | template< typename pass_type > | 
|---|
| 2735 | Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) { | 
|---|
| 2736 | MUTATE_START( node ); | 
|---|
| 2737 |  | 
|---|
| 2738 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2739 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2740 | maybeMutate_impl   ( node->exprs , *this ); | 
|---|
| 2741 |  | 
|---|
| 2742 | MUTATE_END( Expression, node ); | 
|---|
| 2743 | } | 
|---|
| 2744 |  | 
|---|
| 2745 | //-------------------------------------------------------------------------- | 
|---|
| 2746 | // TupleIndexExpr | 
|---|
| 2747 | template< typename pass_type > | 
|---|
| 2748 | void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) { | 
|---|
| 2749 | VISIT_START( node ); | 
|---|
| 2750 |  | 
|---|
| 2751 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2752 | maybeAccept_impl   ( node->tuple , *this ); | 
|---|
| 2753 |  | 
|---|
| 2754 | VISIT_END( node ); | 
|---|
| 2755 | } | 
|---|
| 2756 |  | 
|---|
| 2757 | template< typename pass_type > | 
|---|
| 2758 | void PassVisitor< pass_type >::visit( const TupleIndexExpr * node ) { | 
|---|
| 2759 | VISIT_START( node ); | 
|---|
| 2760 |  | 
|---|
| 2761 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2762 | maybeAccept_impl   ( node->tuple , *this ); | 
|---|
| 2763 |  | 
|---|
| 2764 | VISIT_END( node ); | 
|---|
| 2765 | } | 
|---|
| 2766 |  | 
|---|
| 2767 | template< typename pass_type > | 
|---|
| 2768 | Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) { | 
|---|
| 2769 | MUTATE_START( node ); | 
|---|
| 2770 |  | 
|---|
| 2771 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2772 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2773 | maybeMutate_impl   ( node->tuple , *this ); | 
|---|
| 2774 |  | 
|---|
| 2775 | MUTATE_END( Expression, node ); | 
|---|
| 2776 | } | 
|---|
| 2777 |  | 
|---|
| 2778 | //-------------------------------------------------------------------------- | 
|---|
| 2779 | // TupleAssignExpr | 
|---|
| 2780 | template< typename pass_type > | 
|---|
| 2781 | void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) { | 
|---|
| 2782 | VISIT_START( node ); | 
|---|
| 2783 |  | 
|---|
| 2784 | indexerScopedAccept( node->result  , *this ); | 
|---|
| 2785 | maybeAccept_impl   ( node->stmtExpr, *this ); | 
|---|
| 2786 |  | 
|---|
| 2787 | VISIT_END( node ); | 
|---|
| 2788 | } | 
|---|
| 2789 |  | 
|---|
| 2790 | template< typename pass_type > | 
|---|
| 2791 | void PassVisitor< pass_type >::visit( const TupleAssignExpr * node ) { | 
|---|
| 2792 | VISIT_START( node ); | 
|---|
| 2793 |  | 
|---|
| 2794 | indexerScopedAccept( node->result  , *this ); | 
|---|
| 2795 | maybeAccept_impl( node->stmtExpr, *this ); | 
|---|
| 2796 |  | 
|---|
| 2797 | VISIT_END( node ); | 
|---|
| 2798 | } | 
|---|
| 2799 |  | 
|---|
| 2800 | template< typename pass_type > | 
|---|
| 2801 | Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) { | 
|---|
| 2802 | MUTATE_START( node ); | 
|---|
| 2803 |  | 
|---|
| 2804 | indexerScopedMutate( node->env     , *this ); | 
|---|
| 2805 | indexerScopedMutate( node->result  , *this ); | 
|---|
| 2806 | maybeMutate_impl   ( node->stmtExpr, *this ); | 
|---|
| 2807 |  | 
|---|
| 2808 | MUTATE_END( Expression, node ); | 
|---|
| 2809 | } | 
|---|
| 2810 |  | 
|---|
| 2811 | //-------------------------------------------------------------------------- | 
|---|
| 2812 | // StmtExpr | 
|---|
| 2813 | template< typename pass_type > | 
|---|
| 2814 | void PassVisitor< pass_type >::visit( StmtExpr * node ) { | 
|---|
| 2815 | VISIT_START( node ); | 
|---|
| 2816 |  | 
|---|
| 2817 | // don't want statements from outer CompoundStmts to be added to this StmtExpr | 
|---|
| 2818 | ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() ); | 
|---|
| 2819 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); | 
|---|
| 2820 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); | 
|---|
| 2821 |  | 
|---|
| 2822 | indexerScopedAccept( node->result     , *this ); | 
|---|
| 2823 | maybeAccept_impl   ( node->statements , *this ); | 
|---|
| 2824 | maybeAccept_impl   ( node->returnDecls, *this ); | 
|---|
| 2825 | maybeAccept_impl   ( node->dtors      , *this ); | 
|---|
| 2826 |  | 
|---|
| 2827 | VISIT_END( node ); | 
|---|
| 2828 | } | 
|---|
| 2829 |  | 
|---|
| 2830 | template< typename pass_type > | 
|---|
| 2831 | void PassVisitor< pass_type >::visit( const StmtExpr * node ) { | 
|---|
| 2832 | VISIT_START( node ); | 
|---|
| 2833 |  | 
|---|
| 2834 | // don't want statements from outer CompoundStmts to be added to this StmtExpr | 
|---|
| 2835 | ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() ); | 
|---|
| 2836 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); | 
|---|
| 2837 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); | 
|---|
| 2838 |  | 
|---|
| 2839 | indexerScopedAccept( node->result     , *this ); | 
|---|
| 2840 | maybeAccept_impl   ( node->statements , *this ); | 
|---|
| 2841 | maybeAccept_impl   ( node->returnDecls, *this ); | 
|---|
| 2842 | maybeAccept_impl   ( node->dtors      , *this ); | 
|---|
| 2843 |  | 
|---|
| 2844 | VISIT_END( node ); | 
|---|
| 2845 | } | 
|---|
| 2846 |  | 
|---|
| 2847 | template< typename pass_type > | 
|---|
| 2848 | Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { | 
|---|
| 2849 | MUTATE_START( node ); | 
|---|
| 2850 |  | 
|---|
| 2851 | // don't want statements from outer CompoundStmts to be added to this StmtExpr | 
|---|
| 2852 | ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() ); | 
|---|
| 2853 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); | 
|---|
| 2854 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); | 
|---|
| 2855 |  | 
|---|
| 2856 | indexerScopedMutate( node->result     , *this ); | 
|---|
| 2857 | maybeMutate_impl   ( node->statements , *this ); | 
|---|
| 2858 | maybeMutate_impl   ( node->returnDecls, *this ); | 
|---|
| 2859 | maybeMutate_impl   ( node->dtors      , *this ); | 
|---|
| 2860 |  | 
|---|
| 2861 | MUTATE_END( Expression, node ); | 
|---|
| 2862 | } | 
|---|
| 2863 |  | 
|---|
| 2864 | //-------------------------------------------------------------------------- | 
|---|
| 2865 | // UniqueExpr | 
|---|
| 2866 | template< typename pass_type > | 
|---|
| 2867 | void PassVisitor< pass_type >::visit( UniqueExpr * node ) { | 
|---|
| 2868 | VISIT_START( node ); | 
|---|
| 2869 |  | 
|---|
| 2870 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2871 | maybeAccept_impl   ( node->expr  , *this ); | 
|---|
| 2872 |  | 
|---|
| 2873 | VISIT_END( node ); | 
|---|
| 2874 | } | 
|---|
| 2875 |  | 
|---|
| 2876 | template< typename pass_type > | 
|---|
| 2877 | void PassVisitor< pass_type >::visit( const UniqueExpr * node ) { | 
|---|
| 2878 | VISIT_START( node ); | 
|---|
| 2879 |  | 
|---|
| 2880 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2881 | maybeAccept_impl   ( node->expr  , *this ); | 
|---|
| 2882 |  | 
|---|
| 2883 | VISIT_END( node ); | 
|---|
| 2884 | } | 
|---|
| 2885 |  | 
|---|
| 2886 | template< typename pass_type > | 
|---|
| 2887 | Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) { | 
|---|
| 2888 | MUTATE_START( node ); | 
|---|
| 2889 |  | 
|---|
| 2890 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2891 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2892 | maybeMutate_impl   ( node->expr  , *this ); | 
|---|
| 2893 |  | 
|---|
| 2894 | MUTATE_END( Expression, node ); | 
|---|
| 2895 | } | 
|---|
| 2896 |  | 
|---|
| 2897 | //-------------------------------------------------------------------------- | 
|---|
| 2898 | // UntypedInitExpr | 
|---|
| 2899 | template< typename pass_type > | 
|---|
| 2900 | void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) { | 
|---|
| 2901 | VISIT_START( node ); | 
|---|
| 2902 |  | 
|---|
| 2903 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2904 | maybeAccept_impl   ( node->expr  , *this ); | 
|---|
| 2905 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. | 
|---|
| 2906 |  | 
|---|
| 2907 | VISIT_END( node ); | 
|---|
| 2908 | } | 
|---|
| 2909 |  | 
|---|
| 2910 | template< typename pass_type > | 
|---|
| 2911 | void PassVisitor< pass_type >::visit( const UntypedInitExpr * node ) { | 
|---|
| 2912 | VISIT_START( node ); | 
|---|
| 2913 |  | 
|---|
| 2914 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2915 | maybeAccept_impl   ( node->expr  , *this ); | 
|---|
| 2916 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. | 
|---|
| 2917 |  | 
|---|
| 2918 | VISIT_END( node ); | 
|---|
| 2919 | } | 
|---|
| 2920 |  | 
|---|
| 2921 | template< typename pass_type > | 
|---|
| 2922 | Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) { | 
|---|
| 2923 | MUTATE_START( node ); | 
|---|
| 2924 |  | 
|---|
| 2925 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2926 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2927 | maybeMutate_impl   ( node->expr  , *this ); | 
|---|
| 2928 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. | 
|---|
| 2929 |  | 
|---|
| 2930 | MUTATE_END( Expression, node ); | 
|---|
| 2931 | } | 
|---|
| 2932 |  | 
|---|
| 2933 | //-------------------------------------------------------------------------- | 
|---|
| 2934 | // InitExpr | 
|---|
| 2935 | template< typename pass_type > | 
|---|
| 2936 | void PassVisitor< pass_type >::visit( InitExpr * node ) { | 
|---|
| 2937 | VISIT_START( node ); | 
|---|
| 2938 |  | 
|---|
| 2939 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2940 | maybeAccept_impl   ( node->expr  , *this ); | 
|---|
| 2941 | maybeAccept_impl   ( node->designation, *this ); | 
|---|
| 2942 |  | 
|---|
| 2943 | VISIT_END( node ); | 
|---|
| 2944 | } | 
|---|
| 2945 |  | 
|---|
| 2946 | template< typename pass_type > | 
|---|
| 2947 | void PassVisitor< pass_type >::visit( const InitExpr * node ) { | 
|---|
| 2948 | VISIT_START( node ); | 
|---|
| 2949 |  | 
|---|
| 2950 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2951 | maybeAccept_impl   ( node->expr  , *this ); | 
|---|
| 2952 | maybeAccept_impl   ( node->designation, *this ); | 
|---|
| 2953 |  | 
|---|
| 2954 | VISIT_END( node ); | 
|---|
| 2955 | } | 
|---|
| 2956 |  | 
|---|
| 2957 | template< typename pass_type > | 
|---|
| 2958 | Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) { | 
|---|
| 2959 | MUTATE_START( node ); | 
|---|
| 2960 |  | 
|---|
| 2961 | indexerScopedMutate( node->env   , *this ); | 
|---|
| 2962 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2963 | maybeMutate_impl   ( node->expr  , *this ); | 
|---|
| 2964 | maybeMutate_impl   ( node->designation, *this ); | 
|---|
| 2965 |  | 
|---|
| 2966 | MUTATE_END( Expression, node ); | 
|---|
| 2967 | } | 
|---|
| 2968 |  | 
|---|
| 2969 | //-------------------------------------------------------------------------- | 
|---|
| 2970 | // DeletedExpr | 
|---|
| 2971 | template< typename pass_type > | 
|---|
| 2972 | void PassVisitor< pass_type >::visit( DeletedExpr * node ) { | 
|---|
| 2973 | VISIT_START( node ); | 
|---|
| 2974 |  | 
|---|
| 2975 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2976 | maybeAccept_impl   ( node->expr, *this ); | 
|---|
| 2977 | // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. | 
|---|
| 2978 |  | 
|---|
| 2979 | VISIT_END( node ); | 
|---|
| 2980 | } | 
|---|
| 2981 |  | 
|---|
| 2982 | template< typename pass_type > | 
|---|
| 2983 | void PassVisitor< pass_type >::visit( const DeletedExpr * node ) { | 
|---|
| 2984 | VISIT_START( node ); | 
|---|
| 2985 |  | 
|---|
| 2986 | indexerScopedAccept( node->result, *this ); | 
|---|
| 2987 | maybeAccept_impl   ( node->expr, *this ); | 
|---|
| 2988 | // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. | 
|---|
| 2989 |  | 
|---|
| 2990 | VISIT_END( node ); | 
|---|
| 2991 | } | 
|---|
| 2992 |  | 
|---|
| 2993 | template< typename pass_type > | 
|---|
| 2994 | Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) { | 
|---|
| 2995 | MUTATE_START( node ); | 
|---|
| 2996 |  | 
|---|
| 2997 | indexerScopedMutate( node->env, *this ); | 
|---|
| 2998 | indexerScopedMutate( node->result, *this ); | 
|---|
| 2999 | maybeMutate_impl( node->expr, *this ); | 
|---|
| 3000 |  | 
|---|
| 3001 | MUTATE_END( Expression, node ); | 
|---|
| 3002 | } | 
|---|
| 3003 |  | 
|---|
| 3004 | //-------------------------------------------------------------------------- | 
|---|
| 3005 | // DefaultArgExpr | 
|---|
| 3006 | template< typename pass_type > | 
|---|
| 3007 | void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) { | 
|---|
| 3008 | VISIT_START( node ); | 
|---|
| 3009 |  | 
|---|
| 3010 | indexerScopedAccept( node->result, *this ); | 
|---|
| 3011 | maybeAccept_impl   ( node->expr, *this ); | 
|---|
| 3012 |  | 
|---|
| 3013 | VISIT_END( node ); | 
|---|
| 3014 | } | 
|---|
| 3015 |  | 
|---|
| 3016 | template< typename pass_type > | 
|---|
| 3017 | void PassVisitor< pass_type >::visit( const DefaultArgExpr * node ) { | 
|---|
| 3018 | VISIT_START( node ); | 
|---|
| 3019 |  | 
|---|
| 3020 | indexerScopedAccept( node->result, *this ); | 
|---|
| 3021 | maybeAccept_impl   ( node->expr, *this ); | 
|---|
| 3022 |  | 
|---|
| 3023 | VISIT_END( node ); | 
|---|
| 3024 | } | 
|---|
| 3025 |  | 
|---|
| 3026 | template< typename pass_type > | 
|---|
| 3027 | Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) { | 
|---|
| 3028 | MUTATE_START( node ); | 
|---|
| 3029 |  | 
|---|
| 3030 | indexerScopedMutate( node->env, *this ); | 
|---|
| 3031 | indexerScopedMutate( node->result, *this ); | 
|---|
| 3032 | maybeMutate_impl( node->expr, *this ); | 
|---|
| 3033 |  | 
|---|
| 3034 | MUTATE_END( Expression, node ); | 
|---|
| 3035 | } | 
|---|
| 3036 |  | 
|---|
| 3037 | //-------------------------------------------------------------------------- | 
|---|
| 3038 | // GenericExpr | 
|---|
| 3039 | template< typename pass_type > | 
|---|
| 3040 | void PassVisitor< pass_type >::visit( GenericExpr * node ) { | 
|---|
| 3041 | VISIT_START( node ); | 
|---|
| 3042 |  | 
|---|
| 3043 | indexerScopedAccept( node->result, *this ); | 
|---|
| 3044 | maybeAccept_impl( node->control, *this ); | 
|---|
| 3045 | for ( GenericExpr::Association & assoc : node->associations ) { | 
|---|
| 3046 | indexerScopedAccept( assoc.type, *this ); | 
|---|
| 3047 | maybeAccept_impl( assoc.expr, *this ); | 
|---|
| 3048 | } | 
|---|
| 3049 |  | 
|---|
| 3050 | VISIT_END( node ); | 
|---|
| 3051 | } | 
|---|
| 3052 |  | 
|---|
| 3053 | template< typename pass_type > | 
|---|
| 3054 | void PassVisitor< pass_type >::visit( const GenericExpr * node ) { | 
|---|
| 3055 | VISIT_START( node ); | 
|---|
| 3056 |  | 
|---|
| 3057 | indexerScopedAccept( node->result, *this ); | 
|---|
| 3058 | maybeAccept_impl( node->control, *this ); | 
|---|
| 3059 | for ( const GenericExpr::Association & assoc : node->associations ) { | 
|---|
| 3060 | indexerScopedAccept( assoc.type, *this ); | 
|---|
| 3061 | maybeAccept_impl( assoc.expr, *this ); | 
|---|
| 3062 | } | 
|---|
| 3063 |  | 
|---|
| 3064 | VISIT_END( node ); | 
|---|
| 3065 | } | 
|---|
| 3066 |  | 
|---|
| 3067 | template< typename pass_type > | 
|---|
| 3068 | Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) { | 
|---|
| 3069 | MUTATE_START( node ); | 
|---|
| 3070 |  | 
|---|
| 3071 | indexerScopedMutate( node->env, *this ); | 
|---|
| 3072 | indexerScopedMutate( node->result, *this ); | 
|---|
| 3073 | maybeMutate_impl( node->control, *this ); | 
|---|
| 3074 | for ( GenericExpr::Association & assoc : node->associations ) { | 
|---|
| 3075 | indexerScopedMutate( assoc.type, *this ); | 
|---|
| 3076 | maybeMutate_impl( assoc.expr, *this ); | 
|---|
| 3077 | } | 
|---|
| 3078 |  | 
|---|
| 3079 | MUTATE_END( Expression, node ); | 
|---|
| 3080 | } | 
|---|
| 3081 |  | 
|---|
| 3082 | //-------------------------------------------------------------------------- | 
|---|
| 3083 | // VoidType | 
|---|
| 3084 | template< typename pass_type > | 
|---|
| 3085 | void PassVisitor< pass_type >::visit( VoidType * node ) { | 
|---|
| 3086 | VISIT_START( node ); | 
|---|
| 3087 |  | 
|---|
| 3088 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3089 |  | 
|---|
| 3090 | VISIT_END( node ); | 
|---|
| 3091 | } | 
|---|
| 3092 |  | 
|---|
| 3093 | template< typename pass_type > | 
|---|
| 3094 | void PassVisitor< pass_type >::visit( const VoidType * node ) { | 
|---|
| 3095 | VISIT_START( node ); | 
|---|
| 3096 |  | 
|---|
| 3097 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3098 |  | 
|---|
| 3099 | VISIT_END( node ); | 
|---|
| 3100 | } | 
|---|
| 3101 |  | 
|---|
| 3102 | template< typename pass_type > | 
|---|
| 3103 | Type * PassVisitor< pass_type >::mutate( VoidType * node ) { | 
|---|
| 3104 | MUTATE_START( node ); | 
|---|
| 3105 |  | 
|---|
| 3106 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3107 |  | 
|---|
| 3108 | MUTATE_END( Type, node ); | 
|---|
| 3109 | } | 
|---|
| 3110 |  | 
|---|
| 3111 | //-------------------------------------------------------------------------- | 
|---|
| 3112 | // BasicType | 
|---|
| 3113 | template< typename pass_type > | 
|---|
| 3114 | void PassVisitor< pass_type >::visit( BasicType * node ) { | 
|---|
| 3115 | VISIT_START( node ); | 
|---|
| 3116 |  | 
|---|
| 3117 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3118 |  | 
|---|
| 3119 | VISIT_END( node ); | 
|---|
| 3120 | } | 
|---|
| 3121 |  | 
|---|
| 3122 | template< typename pass_type > | 
|---|
| 3123 | void PassVisitor< pass_type >::visit( const BasicType * node ) { | 
|---|
| 3124 | VISIT_START( node ); | 
|---|
| 3125 |  | 
|---|
| 3126 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3127 |  | 
|---|
| 3128 | VISIT_END( node ); | 
|---|
| 3129 | } | 
|---|
| 3130 |  | 
|---|
| 3131 | template< typename pass_type > | 
|---|
| 3132 | Type * PassVisitor< pass_type >::mutate( BasicType * node ) { | 
|---|
| 3133 | MUTATE_START( node ); | 
|---|
| 3134 |  | 
|---|
| 3135 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3136 |  | 
|---|
| 3137 | MUTATE_END( Type, node ); | 
|---|
| 3138 | } | 
|---|
| 3139 |  | 
|---|
| 3140 | //-------------------------------------------------------------------------- | 
|---|
| 3141 | // PointerType | 
|---|
| 3142 | template< typename pass_type > | 
|---|
| 3143 | void PassVisitor< pass_type >::visit( PointerType * node ) { | 
|---|
| 3144 | VISIT_START( node ); | 
|---|
| 3145 |  | 
|---|
| 3146 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3147 | // xxx - should PointerType visit/mutate dimension? | 
|---|
| 3148 | maybeAccept_impl( node->base, *this ); | 
|---|
| 3149 |  | 
|---|
| 3150 | VISIT_END( node ); | 
|---|
| 3151 | } | 
|---|
| 3152 |  | 
|---|
| 3153 | template< typename pass_type > | 
|---|
| 3154 | void PassVisitor< pass_type >::visit( const PointerType * node ) { | 
|---|
| 3155 | VISIT_START( node ); | 
|---|
| 3156 |  | 
|---|
| 3157 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3158 | // xxx - should PointerType visit/mutate dimension? | 
|---|
| 3159 | maybeAccept_impl( node->base, *this ); | 
|---|
| 3160 |  | 
|---|
| 3161 | VISIT_END( node ); | 
|---|
| 3162 | } | 
|---|
| 3163 |  | 
|---|
| 3164 | template< typename pass_type > | 
|---|
| 3165 | Type * PassVisitor< pass_type >::mutate( PointerType * node ) { | 
|---|
| 3166 | MUTATE_START( node ); | 
|---|
| 3167 |  | 
|---|
| 3168 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3169 | // xxx - should PointerType visit/mutate dimension? | 
|---|
| 3170 | maybeMutate_impl( node->base, *this ); | 
|---|
| 3171 |  | 
|---|
| 3172 | MUTATE_END( Type, node ); | 
|---|
| 3173 | } | 
|---|
| 3174 |  | 
|---|
| 3175 | //-------------------------------------------------------------------------- | 
|---|
| 3176 | // ArrayType | 
|---|
| 3177 | template< typename pass_type > | 
|---|
| 3178 | void PassVisitor< pass_type >::visit( ArrayType * node ) { | 
|---|
| 3179 | VISIT_START( node ); | 
|---|
| 3180 |  | 
|---|
| 3181 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3182 | maybeAccept_impl( node->dimension, *this ); | 
|---|
| 3183 | maybeAccept_impl( node->base, *this ); | 
|---|
| 3184 |  | 
|---|
| 3185 | VISIT_END( node ); | 
|---|
| 3186 | } | 
|---|
| 3187 |  | 
|---|
| 3188 | template< typename pass_type > | 
|---|
| 3189 | void PassVisitor< pass_type >::visit( const ArrayType * node ) { | 
|---|
| 3190 | VISIT_START( node ); | 
|---|
| 3191 |  | 
|---|
| 3192 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3193 | maybeAccept_impl( node->dimension, *this ); | 
|---|
| 3194 | maybeAccept_impl( node->base, *this ); | 
|---|
| 3195 |  | 
|---|
| 3196 | VISIT_END( node ); | 
|---|
| 3197 | } | 
|---|
| 3198 |  | 
|---|
| 3199 | template< typename pass_type > | 
|---|
| 3200 | Type * PassVisitor< pass_type >::mutate( ArrayType * node ) { | 
|---|
| 3201 | MUTATE_START( node ); | 
|---|
| 3202 |  | 
|---|
| 3203 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3204 | maybeMutate_impl( node->dimension, *this ); | 
|---|
| 3205 | maybeMutate_impl( node->base, *this ); | 
|---|
| 3206 |  | 
|---|
| 3207 | MUTATE_END( Type, node ); | 
|---|
| 3208 | } | 
|---|
| 3209 |  | 
|---|
| 3210 | //-------------------------------------------------------------------------- | 
|---|
| 3211 | // ReferenceType | 
|---|
| 3212 | template< typename pass_type > | 
|---|
| 3213 | void PassVisitor< pass_type >::visit( ReferenceType * node ) { | 
|---|
| 3214 | VISIT_START( node ); | 
|---|
| 3215 |  | 
|---|
| 3216 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3217 | maybeAccept_impl( node->base, *this ); | 
|---|
| 3218 |  | 
|---|
| 3219 | VISIT_END( node ); | 
|---|
| 3220 | } | 
|---|
| 3221 |  | 
|---|
| 3222 | template< typename pass_type > | 
|---|
| 3223 | void PassVisitor< pass_type >::visit( const ReferenceType * node ) { | 
|---|
| 3224 | VISIT_START( node ); | 
|---|
| 3225 |  | 
|---|
| 3226 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3227 | maybeAccept_impl( node->base, *this ); | 
|---|
| 3228 |  | 
|---|
| 3229 | VISIT_END( node ); | 
|---|
| 3230 | } | 
|---|
| 3231 |  | 
|---|
| 3232 | template< typename pass_type > | 
|---|
| 3233 | Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) { | 
|---|
| 3234 | MUTATE_START( node ); | 
|---|
| 3235 |  | 
|---|
| 3236 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3237 | maybeMutate_impl( node->base, *this ); | 
|---|
| 3238 |  | 
|---|
| 3239 | MUTATE_END( Type, node ); | 
|---|
| 3240 | } | 
|---|
| 3241 |  | 
|---|
| 3242 | //-------------------------------------------------------------------------- | 
|---|
| 3243 | // QualifiedType | 
|---|
| 3244 | template< typename pass_type > | 
|---|
| 3245 | void PassVisitor< pass_type >::visit( QualifiedType * node ) { | 
|---|
| 3246 | VISIT_START( node ); | 
|---|
| 3247 |  | 
|---|
| 3248 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3249 | maybeAccept_impl( node->parent, *this ); | 
|---|
| 3250 | maybeAccept_impl( node->child, *this ); | 
|---|
| 3251 |  | 
|---|
| 3252 | VISIT_END( node ); | 
|---|
| 3253 | } | 
|---|
| 3254 |  | 
|---|
| 3255 | template< typename pass_type > | 
|---|
| 3256 | void PassVisitor< pass_type >::visit( const QualifiedType * node ) { | 
|---|
| 3257 | VISIT_START( node ); | 
|---|
| 3258 |  | 
|---|
| 3259 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3260 | maybeAccept_impl( node->parent, *this ); | 
|---|
| 3261 | maybeAccept_impl( node->child, *this ); | 
|---|
| 3262 |  | 
|---|
| 3263 | VISIT_END( node ); | 
|---|
| 3264 | } | 
|---|
| 3265 |  | 
|---|
| 3266 | template< typename pass_type > | 
|---|
| 3267 | Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) { | 
|---|
| 3268 | MUTATE_START( node ); | 
|---|
| 3269 |  | 
|---|
| 3270 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3271 | maybeMutate_impl( node->parent, *this ); | 
|---|
| 3272 | maybeMutate_impl( node->child, *this ); | 
|---|
| 3273 |  | 
|---|
| 3274 | MUTATE_END( Type, node ); | 
|---|
| 3275 | } | 
|---|
| 3276 |  | 
|---|
| 3277 | //-------------------------------------------------------------------------- | 
|---|
| 3278 | // FunctionType | 
|---|
| 3279 | template< typename pass_type > | 
|---|
| 3280 | void PassVisitor< pass_type >::visit( FunctionType * node ) { | 
|---|
| 3281 | VISIT_START( node ); | 
|---|
| 3282 |  | 
|---|
| 3283 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3284 | maybeAccept_impl( node->returnVals, *this ); | 
|---|
| 3285 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3286 |  | 
|---|
| 3287 | VISIT_END( node ); | 
|---|
| 3288 | } | 
|---|
| 3289 |  | 
|---|
| 3290 | template< typename pass_type > | 
|---|
| 3291 | void PassVisitor< pass_type >::visit( const FunctionType * node ) { | 
|---|
| 3292 | VISIT_START( node ); | 
|---|
| 3293 |  | 
|---|
| 3294 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3295 | maybeAccept_impl( node->returnVals, *this ); | 
|---|
| 3296 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3297 |  | 
|---|
| 3298 | VISIT_END( node ); | 
|---|
| 3299 | } | 
|---|
| 3300 |  | 
|---|
| 3301 | template< typename pass_type > | 
|---|
| 3302 | Type * PassVisitor< pass_type >::mutate( FunctionType * node ) { | 
|---|
| 3303 | MUTATE_START( node ); | 
|---|
| 3304 |  | 
|---|
| 3305 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3306 | maybeMutate_impl( node->returnVals, *this ); | 
|---|
| 3307 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 3308 |  | 
|---|
| 3309 | MUTATE_END( Type, node ); | 
|---|
| 3310 | } | 
|---|
| 3311 |  | 
|---|
| 3312 | //-------------------------------------------------------------------------- | 
|---|
| 3313 | // StructInstType | 
|---|
| 3314 | template< typename pass_type > | 
|---|
| 3315 | void PassVisitor< pass_type >::visit( StructInstType * node ) { | 
|---|
| 3316 | VISIT_START( node ); | 
|---|
| 3317 |  | 
|---|
| 3318 | indexerAddStruct( node->name ); | 
|---|
| 3319 |  | 
|---|
| 3320 | { | 
|---|
| 3321 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 3322 | maybeAccept_impl( node->forall    , *this ); | 
|---|
| 3323 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3324 | } | 
|---|
| 3325 |  | 
|---|
| 3326 | VISIT_END( node ); | 
|---|
| 3327 | } | 
|---|
| 3328 |  | 
|---|
| 3329 | template< typename pass_type > | 
|---|
| 3330 | void PassVisitor< pass_type >::visit( const StructInstType * node ) { | 
|---|
| 3331 | VISIT_START( node ); | 
|---|
| 3332 |  | 
|---|
| 3333 | indexerAddStruct( node->name ); | 
|---|
| 3334 |  | 
|---|
| 3335 | { | 
|---|
| 3336 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 3337 | maybeAccept_impl( node->forall    , *this ); | 
|---|
| 3338 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3339 | } | 
|---|
| 3340 |  | 
|---|
| 3341 | VISIT_END( node ); | 
|---|
| 3342 | } | 
|---|
| 3343 |  | 
|---|
| 3344 | template< typename pass_type > | 
|---|
| 3345 | Type * PassVisitor< pass_type >::mutate( StructInstType * node ) { | 
|---|
| 3346 | MUTATE_START( node ); | 
|---|
| 3347 |  | 
|---|
| 3348 | indexerAddStruct( node->name ); | 
|---|
| 3349 |  | 
|---|
| 3350 | { | 
|---|
| 3351 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 3352 | maybeMutate_impl( node->forall    , *this ); | 
|---|
| 3353 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 3354 | } | 
|---|
| 3355 |  | 
|---|
| 3356 | MUTATE_END( Type, node ); | 
|---|
| 3357 | } | 
|---|
| 3358 |  | 
|---|
| 3359 | //-------------------------------------------------------------------------- | 
|---|
| 3360 | // UnionInstType | 
|---|
| 3361 | template< typename pass_type > | 
|---|
| 3362 | void PassVisitor< pass_type >::visit( UnionInstType * node ) { | 
|---|
| 3363 | VISIT_START( node ); | 
|---|
| 3364 |  | 
|---|
| 3365 | indexerAddUnion( node->name ); | 
|---|
| 3366 |  | 
|---|
| 3367 | { | 
|---|
| 3368 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 3369 | maybeAccept_impl( node->forall    , *this ); | 
|---|
| 3370 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3371 | } | 
|---|
| 3372 |  | 
|---|
| 3373 | VISIT_END( node ); | 
|---|
| 3374 | } | 
|---|
| 3375 |  | 
|---|
| 3376 | template< typename pass_type > | 
|---|
| 3377 | void PassVisitor< pass_type >::visit( const UnionInstType * node ) { | 
|---|
| 3378 | VISIT_START( node ); | 
|---|
| 3379 |  | 
|---|
| 3380 | indexerAddUnion( node->name ); | 
|---|
| 3381 |  | 
|---|
| 3382 | { | 
|---|
| 3383 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 3384 | maybeAccept_impl( node->forall    , *this ); | 
|---|
| 3385 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3386 | } | 
|---|
| 3387 |  | 
|---|
| 3388 | VISIT_END( node ); | 
|---|
| 3389 | } | 
|---|
| 3390 |  | 
|---|
| 3391 | template< typename pass_type > | 
|---|
| 3392 | Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) { | 
|---|
| 3393 | MUTATE_START( node ); | 
|---|
| 3394 |  | 
|---|
| 3395 | indexerAddUnion( node->name ); | 
|---|
| 3396 |  | 
|---|
| 3397 | { | 
|---|
| 3398 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); | 
|---|
| 3399 | maybeMutate_impl( node->forall    , *this ); | 
|---|
| 3400 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 3401 | } | 
|---|
| 3402 |  | 
|---|
| 3403 | MUTATE_END( Type, node ); | 
|---|
| 3404 | } | 
|---|
| 3405 |  | 
|---|
| 3406 | //-------------------------------------------------------------------------- | 
|---|
| 3407 | // EnumInstType | 
|---|
| 3408 | template< typename pass_type > | 
|---|
| 3409 | void PassVisitor< pass_type >::visit( EnumInstType * node ) { | 
|---|
| 3410 | VISIT_START( node ); | 
|---|
| 3411 |  | 
|---|
| 3412 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3413 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3414 |  | 
|---|
| 3415 | VISIT_END( node ); | 
|---|
| 3416 | } | 
|---|
| 3417 |  | 
|---|
| 3418 | template< typename pass_type > | 
|---|
| 3419 | void PassVisitor< pass_type >::visit( const EnumInstType * node ) { | 
|---|
| 3420 | VISIT_START( node ); | 
|---|
| 3421 |  | 
|---|
| 3422 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3423 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3424 |  | 
|---|
| 3425 | VISIT_END( node ); | 
|---|
| 3426 | } | 
|---|
| 3427 |  | 
|---|
| 3428 | template< typename pass_type > | 
|---|
| 3429 | Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) { | 
|---|
| 3430 | MUTATE_START( node ); | 
|---|
| 3431 |  | 
|---|
| 3432 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3433 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 3434 |  | 
|---|
| 3435 | MUTATE_END( Type, node ); | 
|---|
| 3436 | } | 
|---|
| 3437 |  | 
|---|
| 3438 | //-------------------------------------------------------------------------- | 
|---|
| 3439 | // TraitInstType | 
|---|
| 3440 | template< typename pass_type > | 
|---|
| 3441 | void PassVisitor< pass_type >::visit( TraitInstType * node ) { | 
|---|
| 3442 | VISIT_START( node ); | 
|---|
| 3443 |  | 
|---|
| 3444 | maybeAccept_impl( node->forall    , *this ); | 
|---|
| 3445 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3446 |  | 
|---|
| 3447 | VISIT_END( node ); | 
|---|
| 3448 | } | 
|---|
| 3449 |  | 
|---|
| 3450 | template< typename pass_type > | 
|---|
| 3451 | void PassVisitor< pass_type >::visit( const TraitInstType * node ) { | 
|---|
| 3452 | VISIT_START( node ); | 
|---|
| 3453 |  | 
|---|
| 3454 | maybeAccept_impl( node->forall    , *this ); | 
|---|
| 3455 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3456 |  | 
|---|
| 3457 | VISIT_END( node ); | 
|---|
| 3458 | } | 
|---|
| 3459 |  | 
|---|
| 3460 | template< typename pass_type > | 
|---|
| 3461 | Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) { | 
|---|
| 3462 | MUTATE_START( node ); | 
|---|
| 3463 |  | 
|---|
| 3464 | maybeMutate_impl( node->forall    , *this ); | 
|---|
| 3465 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 3466 |  | 
|---|
| 3467 | MUTATE_END( Type, node ); | 
|---|
| 3468 | } | 
|---|
| 3469 |  | 
|---|
| 3470 | //-------------------------------------------------------------------------- | 
|---|
| 3471 | // TypeInstType | 
|---|
| 3472 | template< typename pass_type > | 
|---|
| 3473 | void PassVisitor< pass_type >::visit( TypeInstType * node ) { | 
|---|
| 3474 | VISIT_START( node ); | 
|---|
| 3475 |  | 
|---|
| 3476 | maybeAccept_impl( node->forall    , *this ); | 
|---|
| 3477 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3478 |  | 
|---|
| 3479 | VISIT_END( node ); | 
|---|
| 3480 | } | 
|---|
| 3481 |  | 
|---|
| 3482 | template< typename pass_type > | 
|---|
| 3483 | void PassVisitor< pass_type >::visit( const TypeInstType * node ) { | 
|---|
| 3484 | VISIT_START( node ); | 
|---|
| 3485 |  | 
|---|
| 3486 | maybeAccept_impl( node->forall    , *this ); | 
|---|
| 3487 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3488 |  | 
|---|
| 3489 | VISIT_END( node ); | 
|---|
| 3490 | } | 
|---|
| 3491 |  | 
|---|
| 3492 | template< typename pass_type > | 
|---|
| 3493 | Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) { | 
|---|
| 3494 | MUTATE_START( node ); | 
|---|
| 3495 |  | 
|---|
| 3496 | maybeMutate_impl( node->forall    , *this ); | 
|---|
| 3497 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 3498 |  | 
|---|
| 3499 | MUTATE_END( Type, node ); | 
|---|
| 3500 | } | 
|---|
| 3501 |  | 
|---|
| 3502 | //-------------------------------------------------------------------------- | 
|---|
| 3503 | // TupleType | 
|---|
| 3504 | template< typename pass_type > | 
|---|
| 3505 | void PassVisitor< pass_type >::visit( TupleType * node ) { | 
|---|
| 3506 | VISIT_START( node ); | 
|---|
| 3507 |  | 
|---|
| 3508 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3509 | maybeAccept_impl( node->types, *this ); | 
|---|
| 3510 | maybeAccept_impl( node->members, *this ); | 
|---|
| 3511 |  | 
|---|
| 3512 | VISIT_END( node ); | 
|---|
| 3513 | } | 
|---|
| 3514 |  | 
|---|
| 3515 | template< typename pass_type > | 
|---|
| 3516 | void PassVisitor< pass_type >::visit( const TupleType * node ) { | 
|---|
| 3517 | VISIT_START( node ); | 
|---|
| 3518 |  | 
|---|
| 3519 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3520 | maybeAccept_impl( node->types, *this ); | 
|---|
| 3521 | maybeAccept_impl( node->members, *this ); | 
|---|
| 3522 |  | 
|---|
| 3523 | VISIT_END( node ); | 
|---|
| 3524 | } | 
|---|
| 3525 |  | 
|---|
| 3526 | template< typename pass_type > | 
|---|
| 3527 | Type * PassVisitor< pass_type >::mutate( TupleType * node ) { | 
|---|
| 3528 | MUTATE_START( node ); | 
|---|
| 3529 |  | 
|---|
| 3530 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3531 | maybeMutate_impl( node->types, *this ); | 
|---|
| 3532 | maybeMutate_impl( node->members, *this ); | 
|---|
| 3533 |  | 
|---|
| 3534 | MUTATE_END( Type, node ); | 
|---|
| 3535 | } | 
|---|
| 3536 |  | 
|---|
| 3537 | //-------------------------------------------------------------------------- | 
|---|
| 3538 | // TypeofType | 
|---|
| 3539 | template< typename pass_type > | 
|---|
| 3540 | void PassVisitor< pass_type >::visit( TypeofType * node ) { | 
|---|
| 3541 | VISIT_START( node ); | 
|---|
| 3542 |  | 
|---|
| 3543 | assert( node->expr ); | 
|---|
| 3544 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 3545 |  | 
|---|
| 3546 | VISIT_END( node ); | 
|---|
| 3547 | } | 
|---|
| 3548 |  | 
|---|
| 3549 | template< typename pass_type > | 
|---|
| 3550 | void PassVisitor< pass_type >::visit( const TypeofType * node ) { | 
|---|
| 3551 | VISIT_START( node ); | 
|---|
| 3552 |  | 
|---|
| 3553 | assert( node->expr ); | 
|---|
| 3554 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 3555 |  | 
|---|
| 3556 | VISIT_END( node ); | 
|---|
| 3557 | } | 
|---|
| 3558 |  | 
|---|
| 3559 | template< typename pass_type > | 
|---|
| 3560 | Type * PassVisitor< pass_type >::mutate( TypeofType * node ) { | 
|---|
| 3561 | MUTATE_START( node ); | 
|---|
| 3562 |  | 
|---|
| 3563 | assert( node->expr ); | 
|---|
| 3564 | maybeMutate_impl( node->expr, *this ); | 
|---|
| 3565 |  | 
|---|
| 3566 | MUTATE_END( Type, node ); | 
|---|
| 3567 | } | 
|---|
| 3568 |  | 
|---|
| 3569 | //-------------------------------------------------------------------------- | 
|---|
| 3570 | // AttrType | 
|---|
| 3571 | template< typename pass_type > | 
|---|
| 3572 | void PassVisitor< pass_type >::visit( AttrType * node ) { | 
|---|
| 3573 | VISIT_START( node ); | 
|---|
| 3574 |  | 
|---|
| 3575 | if ( node->isType ) { | 
|---|
| 3576 | assert( node->type ); | 
|---|
| 3577 | maybeAccept_impl( node->type, *this ); | 
|---|
| 3578 | } else { | 
|---|
| 3579 | assert( node->expr ); | 
|---|
| 3580 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 3581 | } // if | 
|---|
| 3582 |  | 
|---|
| 3583 | VISIT_END( node ); | 
|---|
| 3584 | } | 
|---|
| 3585 |  | 
|---|
| 3586 | template< typename pass_type > | 
|---|
| 3587 | void PassVisitor< pass_type >::visit( const AttrType * node ) { | 
|---|
| 3588 | VISIT_START( node ); | 
|---|
| 3589 |  | 
|---|
| 3590 | if ( node->isType ) { | 
|---|
| 3591 | assert( node->type ); | 
|---|
| 3592 | maybeAccept_impl( node->type, *this ); | 
|---|
| 3593 | } else { | 
|---|
| 3594 | assert( node->expr ); | 
|---|
| 3595 | maybeAccept_impl( node->expr, *this ); | 
|---|
| 3596 | } // if | 
|---|
| 3597 |  | 
|---|
| 3598 | VISIT_END( node ); | 
|---|
| 3599 | } | 
|---|
| 3600 |  | 
|---|
| 3601 | template< typename pass_type > | 
|---|
| 3602 | Type * PassVisitor< pass_type >::mutate( AttrType * node ) { | 
|---|
| 3603 | MUTATE_START( node ); | 
|---|
| 3604 |  | 
|---|
| 3605 | if ( node->isType ) { | 
|---|
| 3606 | assert( node->type ); | 
|---|
| 3607 | maybeMutate_impl( node->type, *this ); | 
|---|
| 3608 | } else { | 
|---|
| 3609 | assert( node->expr ); | 
|---|
| 3610 | maybeMutate_impl( node->expr, *this ); | 
|---|
| 3611 | } // if | 
|---|
| 3612 |  | 
|---|
| 3613 | MUTATE_END( Type, node ); | 
|---|
| 3614 | } | 
|---|
| 3615 |  | 
|---|
| 3616 | //-------------------------------------------------------------------------- | 
|---|
| 3617 | // VarArgsType | 
|---|
| 3618 | template< typename pass_type > | 
|---|
| 3619 | void PassVisitor< pass_type >::visit( VarArgsType * node ) { | 
|---|
| 3620 | VISIT_START( node ); | 
|---|
| 3621 |  | 
|---|
| 3622 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3623 |  | 
|---|
| 3624 | VISIT_END( node ); | 
|---|
| 3625 | } | 
|---|
| 3626 |  | 
|---|
| 3627 | template< typename pass_type > | 
|---|
| 3628 | void PassVisitor< pass_type >::visit( const VarArgsType * node ) { | 
|---|
| 3629 | VISIT_START( node ); | 
|---|
| 3630 |  | 
|---|
| 3631 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3632 |  | 
|---|
| 3633 | VISIT_END( node ); | 
|---|
| 3634 | } | 
|---|
| 3635 |  | 
|---|
| 3636 | template< typename pass_type > | 
|---|
| 3637 | Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) { | 
|---|
| 3638 | MUTATE_START( node ); | 
|---|
| 3639 |  | 
|---|
| 3640 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3641 |  | 
|---|
| 3642 | MUTATE_END( Type, node ); | 
|---|
| 3643 | } | 
|---|
| 3644 |  | 
|---|
| 3645 | //-------------------------------------------------------------------------- | 
|---|
| 3646 | // ZeroType | 
|---|
| 3647 | template< typename pass_type > | 
|---|
| 3648 | void PassVisitor< pass_type >::visit( ZeroType * node ) { | 
|---|
| 3649 | VISIT_START( node ); | 
|---|
| 3650 |  | 
|---|
| 3651 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3652 |  | 
|---|
| 3653 | VISIT_END( node ); | 
|---|
| 3654 | } | 
|---|
| 3655 |  | 
|---|
| 3656 | template< typename pass_type > | 
|---|
| 3657 | void PassVisitor< pass_type >::visit( const ZeroType * node ) { | 
|---|
| 3658 | VISIT_START( node ); | 
|---|
| 3659 |  | 
|---|
| 3660 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3661 |  | 
|---|
| 3662 | VISIT_END( node ); | 
|---|
| 3663 | } | 
|---|
| 3664 |  | 
|---|
| 3665 | template< typename pass_type > | 
|---|
| 3666 | Type * PassVisitor< pass_type >::mutate( ZeroType * node ) { | 
|---|
| 3667 | MUTATE_START( node ); | 
|---|
| 3668 |  | 
|---|
| 3669 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3670 |  | 
|---|
| 3671 | MUTATE_END( Type, node ); | 
|---|
| 3672 | } | 
|---|
| 3673 |  | 
|---|
| 3674 | //-------------------------------------------------------------------------- | 
|---|
| 3675 | // OneType | 
|---|
| 3676 | template< typename pass_type > | 
|---|
| 3677 | void PassVisitor< pass_type >::visit( OneType * node ) { | 
|---|
| 3678 | VISIT_START( node ); | 
|---|
| 3679 |  | 
|---|
| 3680 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3681 |  | 
|---|
| 3682 | VISIT_END( node ); | 
|---|
| 3683 | } | 
|---|
| 3684 |  | 
|---|
| 3685 | template< typename pass_type > | 
|---|
| 3686 | void PassVisitor< pass_type >::visit( const OneType * node ) { | 
|---|
| 3687 | VISIT_START( node ); | 
|---|
| 3688 |  | 
|---|
| 3689 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3690 |  | 
|---|
| 3691 | VISIT_END( node ); | 
|---|
| 3692 | } | 
|---|
| 3693 |  | 
|---|
| 3694 | template< typename pass_type > | 
|---|
| 3695 | Type * PassVisitor< pass_type >::mutate( OneType * node ) { | 
|---|
| 3696 | MUTATE_START( node ); | 
|---|
| 3697 |  | 
|---|
| 3698 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3699 |  | 
|---|
| 3700 | MUTATE_END( Type, node ); | 
|---|
| 3701 | } | 
|---|
| 3702 |  | 
|---|
| 3703 | //-------------------------------------------------------------------------- | 
|---|
| 3704 | // GlobalScopeType | 
|---|
| 3705 | template< typename pass_type > | 
|---|
| 3706 | void PassVisitor< pass_type >::visit( GlobalScopeType * node ) { | 
|---|
| 3707 | VISIT_START( node ); | 
|---|
| 3708 |  | 
|---|
| 3709 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3710 |  | 
|---|
| 3711 | VISIT_END( node ); | 
|---|
| 3712 | } | 
|---|
| 3713 |  | 
|---|
| 3714 | template< typename pass_type > | 
|---|
| 3715 | void PassVisitor< pass_type >::visit( const GlobalScopeType * node ) { | 
|---|
| 3716 | VISIT_START( node ); | 
|---|
| 3717 |  | 
|---|
| 3718 | maybeAccept_impl( node->forall, *this ); | 
|---|
| 3719 |  | 
|---|
| 3720 | VISIT_END( node ); | 
|---|
| 3721 | } | 
|---|
| 3722 |  | 
|---|
| 3723 | template< typename pass_type > | 
|---|
| 3724 | Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) { | 
|---|
| 3725 | MUTATE_START( node ); | 
|---|
| 3726 |  | 
|---|
| 3727 | maybeMutate_impl( node->forall, *this ); | 
|---|
| 3728 |  | 
|---|
| 3729 | MUTATE_END( Type, node ); | 
|---|
| 3730 | } | 
|---|
| 3731 |  | 
|---|
| 3732 | //-------------------------------------------------------------------------- | 
|---|
| 3733 | // Designation | 
|---|
| 3734 | template< typename pass_type > | 
|---|
| 3735 | void PassVisitor< pass_type >::visit( Designation * node ) { | 
|---|
| 3736 | VISIT_START( node ); | 
|---|
| 3737 |  | 
|---|
| 3738 | maybeAccept_impl( node->designators, *this ); | 
|---|
| 3739 |  | 
|---|
| 3740 | VISIT_END( node ); | 
|---|
| 3741 | } | 
|---|
| 3742 |  | 
|---|
| 3743 | template< typename pass_type > | 
|---|
| 3744 | void PassVisitor< pass_type >::visit( const Designation * node ) { | 
|---|
| 3745 | VISIT_START( node ); | 
|---|
| 3746 |  | 
|---|
| 3747 | maybeAccept_impl( node->designators, *this ); | 
|---|
| 3748 |  | 
|---|
| 3749 | VISIT_END( node ); | 
|---|
| 3750 | } | 
|---|
| 3751 |  | 
|---|
| 3752 | template< typename pass_type > | 
|---|
| 3753 | Designation * PassVisitor< pass_type >::mutate( Designation * node ) { | 
|---|
| 3754 | MUTATE_START( node ); | 
|---|
| 3755 |  | 
|---|
| 3756 | maybeMutate_impl( node->designators, *this ); | 
|---|
| 3757 |  | 
|---|
| 3758 | MUTATE_END( Designation, node ); | 
|---|
| 3759 | } | 
|---|
| 3760 |  | 
|---|
| 3761 | //-------------------------------------------------------------------------- | 
|---|
| 3762 | // SingleInit | 
|---|
| 3763 | template< typename pass_type > | 
|---|
| 3764 | void PassVisitor< pass_type >::visit( SingleInit * node ) { | 
|---|
| 3765 | VISIT_START( node ); | 
|---|
| 3766 |  | 
|---|
| 3767 | visitExpression( node->value ); | 
|---|
| 3768 |  | 
|---|
| 3769 | VISIT_END( node ); | 
|---|
| 3770 | } | 
|---|
| 3771 |  | 
|---|
| 3772 | template< typename pass_type > | 
|---|
| 3773 | void PassVisitor< pass_type >::visit( const SingleInit * node ) { | 
|---|
| 3774 | VISIT_START( node ); | 
|---|
| 3775 |  | 
|---|
| 3776 | visitExpression( node->value ); | 
|---|
| 3777 |  | 
|---|
| 3778 | VISIT_END( node ); | 
|---|
| 3779 | } | 
|---|
| 3780 |  | 
|---|
| 3781 | template< typename pass_type > | 
|---|
| 3782 | Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) { | 
|---|
| 3783 | MUTATE_START( node ); | 
|---|
| 3784 |  | 
|---|
| 3785 | node->value = mutateExpression( node->value ); | 
|---|
| 3786 |  | 
|---|
| 3787 | MUTATE_END( Initializer, node ); | 
|---|
| 3788 | } | 
|---|
| 3789 |  | 
|---|
| 3790 | //-------------------------------------------------------------------------- | 
|---|
| 3791 | // ListInit | 
|---|
| 3792 | template< typename pass_type > | 
|---|
| 3793 | void PassVisitor< pass_type >::visit( ListInit * node ) { | 
|---|
| 3794 | VISIT_START( node ); | 
|---|
| 3795 |  | 
|---|
| 3796 | maybeAccept_impl( node->designations, *this ); | 
|---|
| 3797 | maybeAccept_impl( node->initializers, *this ); | 
|---|
| 3798 |  | 
|---|
| 3799 | VISIT_END( node ); | 
|---|
| 3800 | } | 
|---|
| 3801 |  | 
|---|
| 3802 | template< typename pass_type > | 
|---|
| 3803 | void PassVisitor< pass_type >::visit( const ListInit * node ) { | 
|---|
| 3804 | VISIT_START( node ); | 
|---|
| 3805 |  | 
|---|
| 3806 | maybeAccept_impl( node->designations, *this ); | 
|---|
| 3807 | maybeAccept_impl( node->initializers, *this ); | 
|---|
| 3808 |  | 
|---|
| 3809 | VISIT_END( node ); | 
|---|
| 3810 | } | 
|---|
| 3811 |  | 
|---|
| 3812 | template< typename pass_type > | 
|---|
| 3813 | Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) { | 
|---|
| 3814 | MUTATE_START( node ); | 
|---|
| 3815 |  | 
|---|
| 3816 | maybeMutate_impl( node->designations, *this ); | 
|---|
| 3817 | maybeMutate_impl( node->initializers, *this ); | 
|---|
| 3818 |  | 
|---|
| 3819 | MUTATE_END( Initializer, node ); | 
|---|
| 3820 | } | 
|---|
| 3821 |  | 
|---|
| 3822 | //-------------------------------------------------------------------------- | 
|---|
| 3823 | // ConstructorInit | 
|---|
| 3824 | template< typename pass_type > | 
|---|
| 3825 | void PassVisitor< pass_type >::visit( ConstructorInit * node ) { | 
|---|
| 3826 | VISIT_START( node ); | 
|---|
| 3827 |  | 
|---|
| 3828 | maybeAccept_impl( node->ctor, *this ); | 
|---|
| 3829 | maybeAccept_impl( node->dtor, *this ); | 
|---|
| 3830 | maybeAccept_impl( node->init, *this ); | 
|---|
| 3831 |  | 
|---|
| 3832 | VISIT_END( node ); | 
|---|
| 3833 | } | 
|---|
| 3834 |  | 
|---|
| 3835 | template< typename pass_type > | 
|---|
| 3836 | void PassVisitor< pass_type >::visit( const ConstructorInit * node ) { | 
|---|
| 3837 | VISIT_START( node ); | 
|---|
| 3838 |  | 
|---|
| 3839 | maybeAccept_impl( node->ctor, *this ); | 
|---|
| 3840 | maybeAccept_impl( node->dtor, *this ); | 
|---|
| 3841 | maybeAccept_impl( node->init, *this ); | 
|---|
| 3842 |  | 
|---|
| 3843 | VISIT_END( node ); | 
|---|
| 3844 | } | 
|---|
| 3845 |  | 
|---|
| 3846 | template< typename pass_type > | 
|---|
| 3847 | Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) { | 
|---|
| 3848 | MUTATE_START( node ); | 
|---|
| 3849 |  | 
|---|
| 3850 | maybeMutate_impl( node->ctor, *this ); | 
|---|
| 3851 | maybeMutate_impl( node->dtor, *this ); | 
|---|
| 3852 | maybeMutate_impl( node->init, *this ); | 
|---|
| 3853 |  | 
|---|
| 3854 | MUTATE_END( Initializer, node ); | 
|---|
| 3855 | } | 
|---|
| 3856 |  | 
|---|
| 3857 | //-------------------------------------------------------------------------- | 
|---|
| 3858 | // Attribute | 
|---|
| 3859 | template< typename pass_type > | 
|---|
| 3860 | void PassVisitor< pass_type >::visit( Constant * node ) { | 
|---|
| 3861 | VISIT_START( node ); | 
|---|
| 3862 |  | 
|---|
| 3863 | VISIT_END( node ); | 
|---|
| 3864 | } | 
|---|
| 3865 |  | 
|---|
| 3866 | template< typename pass_type > | 
|---|
| 3867 | void PassVisitor< pass_type >::visit( const Constant * node ) { | 
|---|
| 3868 | VISIT_START( node ); | 
|---|
| 3869 |  | 
|---|
| 3870 | VISIT_END( node ); | 
|---|
| 3871 | } | 
|---|
| 3872 |  | 
|---|
| 3873 | template< typename pass_type > | 
|---|
| 3874 | Constant * PassVisitor< pass_type >::mutate( Constant * node  )  { | 
|---|
| 3875 | MUTATE_START( node ); | 
|---|
| 3876 |  | 
|---|
| 3877 | MUTATE_END( Constant, node ); | 
|---|
| 3878 | } | 
|---|
| 3879 |  | 
|---|
| 3880 | //-------------------------------------------------------------------------- | 
|---|
| 3881 | // Attribute | 
|---|
| 3882 | template< typename pass_type > | 
|---|
| 3883 | void PassVisitor< pass_type >::visit( Attribute * node ) { | 
|---|
| 3884 | VISIT_START( node ); | 
|---|
| 3885 |  | 
|---|
| 3886 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3887 |  | 
|---|
| 3888 | VISIT_END( node ); | 
|---|
| 3889 | } | 
|---|
| 3890 |  | 
|---|
| 3891 | template< typename pass_type > | 
|---|
| 3892 | void PassVisitor< pass_type >::visit( const Attribute * node ) { | 
|---|
| 3893 | VISIT_START( node ); | 
|---|
| 3894 |  | 
|---|
| 3895 | maybeAccept_impl( node->parameters, *this ); | 
|---|
| 3896 |  | 
|---|
| 3897 | VISIT_END( node ); | 
|---|
| 3898 | } | 
|---|
| 3899 |  | 
|---|
| 3900 | template< typename pass_type > | 
|---|
| 3901 | Attribute * PassVisitor< pass_type >::mutate( Attribute * node  )  { | 
|---|
| 3902 | MUTATE_START( node ); | 
|---|
| 3903 |  | 
|---|
| 3904 | maybeMutate_impl( node->parameters, *this ); | 
|---|
| 3905 |  | 
|---|
| 3906 | MUTATE_END( Attribute, node ); | 
|---|
| 3907 | } | 
|---|
| 3908 |  | 
|---|
| 3909 | //-------------------------------------------------------------------------- | 
|---|
| 3910 | // TypeSubstitution | 
|---|
| 3911 | template< typename pass_type > | 
|---|
| 3912 | TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) { | 
|---|
| 3913 | MUTATE_START( node ); | 
|---|
| 3914 |  | 
|---|
| 3915 | for ( auto & p : node->typeEnv ) { | 
|---|
| 3916 | indexerScopedMutate( p.second, *this ); | 
|---|
| 3917 | } | 
|---|
| 3918 | for ( auto & p : node->varEnv ) { | 
|---|
| 3919 | indexerScopedMutate( p.second, *this ); | 
|---|
| 3920 | } | 
|---|
| 3921 |  | 
|---|
| 3922 | MUTATE_END( TypeSubstitution, node ); | 
|---|
| 3923 | } | 
|---|
| 3924 |  | 
|---|
| 3925 | #undef VISIT_START | 
|---|
| 3926 | #undef VISIT_END | 
|---|
| 3927 |  | 
|---|
| 3928 | #undef MUTATE_START | 
|---|
| 3929 | #undef MUTATE_END | 
|---|