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