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