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