[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 |
|
---|
| 692 | maybeAccept_impl( node->condition, *this );
|
---|
| 693 | maybeAccept_impl( node->message , *this );
|
---|
| 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 |
|
---|
| 702 | maybeMutate_impl( node->condition, *this );
|
---|
| 703 | maybeMutate_impl( node->message , *this );
|
---|
| 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 |
|
---|
[9c1600c] | 778 | //--------------------------------------------------------------------------
|
---|
| 779 | // IfStmt
|
---|
[13932f14] | 780 | template< typename pass_type >
|
---|
[ab904dc] | 781 | void PassVisitor< pass_type >::visit( IfStmt * node ) {
|
---|
[4551a6e] | 782 | VISIT_START( node );
|
---|
[33a25f9] | 783 | {
|
---|
| 784 | // if statements introduce a level of scope (for the initialization)
|
---|
| 785 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 786 | maybeAccept_impl( node->get_initialization(), *this );
|
---|
| 787 | visitExpression ( node->condition );
|
---|
[33a25f9] | 788 | node->thenPart = visitStatement( node->thenPart );
|
---|
| 789 | node->elsePart = visitStatement( node->elsePart );
|
---|
| 790 | }
|
---|
[9c1600c] | 791 | VISIT_END( node );
|
---|
[13932f14] | 792 | }
|
---|
| 793 |
|
---|
[296b2be] | 794 | template< typename pass_type >
|
---|
| 795 | Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
|
---|
[4551a6e] | 796 | MUTATE_START( node );
|
---|
[e0886db] | 797 | {
|
---|
[33a25f9] | 798 | // if statements introduce a level of scope (for the initialization)
|
---|
[e0886db] | 799 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 800 | maybeMutate_impl( node->get_initialization(), *this );
|
---|
[e0886db] | 801 | node->condition = mutateExpression( node->condition );
|
---|
| 802 | node->thenPart = mutateStatement ( node->thenPart );
|
---|
| 803 | node->elsePart = mutateStatement ( node->elsePart );
|
---|
| 804 | }
|
---|
[296b2be] | 805 | MUTATE_END( Statement, node );
|
---|
| 806 | }
|
---|
| 807 |
|
---|
[9c1600c] | 808 | //--------------------------------------------------------------------------
|
---|
| 809 | // WhileStmt
|
---|
[13932f14] | 810 | template< typename pass_type >
|
---|
[ab904dc] | 811 | void PassVisitor< pass_type >::visit( WhileStmt * node ) {
|
---|
[4551a6e] | 812 | VISIT_START( node );
|
---|
[9c1600c] | 813 |
|
---|
[e0886db] | 814 | visitExpression( node->condition );
|
---|
| 815 | node->body = visitStatement( node->body );
|
---|
[9c1600c] | 816 |
|
---|
| 817 | VISIT_END( node );
|
---|
[13932f14] | 818 | }
|
---|
| 819 |
|
---|
[296b2be] | 820 | template< typename pass_type >
|
---|
| 821 | Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
|
---|
[4551a6e] | 822 | MUTATE_START( node );
|
---|
[296b2be] | 823 |
|
---|
[e0886db] | 824 | node->condition = mutateExpression( node->condition );
|
---|
| 825 | node->body = mutateStatement ( node->body );
|
---|
[296b2be] | 826 |
|
---|
| 827 | MUTATE_END( Statement, node );
|
---|
| 828 | }
|
---|
| 829 |
|
---|
[9c1600c] | 830 | //--------------------------------------------------------------------------
|
---|
[6ca154b] | 831 | // ForStmt
|
---|
[13932f14] | 832 | template< typename pass_type >
|
---|
[ab904dc] | 833 | void PassVisitor< pass_type >::visit( ForStmt * node ) {
|
---|
[4551a6e] | 834 | VISIT_START( node );
|
---|
[e0886db] | 835 | {
|
---|
[33a25f9] | 836 | // for statements introduce a level of scope (for the initialization)
|
---|
[e0886db] | 837 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 838 | maybeAccept_impl( node->initialization, *this );
|
---|
[e0886db] | 839 | visitExpression( node->condition );
|
---|
| 840 | visitExpression( node->increment );
|
---|
| 841 | node->body = visitStatement( node->body );
|
---|
| 842 | }
|
---|
[9c1600c] | 843 | VISIT_END( node );
|
---|
[13932f14] | 844 | }
|
---|
| 845 |
|
---|
[296b2be] | 846 | template< typename pass_type >
|
---|
| 847 | Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
|
---|
[4551a6e] | 848 | MUTATE_START( node );
|
---|
[e0886db] | 849 | {
|
---|
[33a25f9] | 850 | // for statements introduce a level of scope (for the initialization)
|
---|
[e0886db] | 851 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 852 | maybeMutate_impl( node->initialization, *this );
|
---|
[e0886db] | 853 | node->condition = mutateExpression( node->condition );
|
---|
| 854 | node->increment = mutateExpression( node->increment );
|
---|
| 855 | node->body = mutateStatement ( node->body );
|
---|
| 856 | }
|
---|
[296b2be] | 857 | MUTATE_END( Statement, node );
|
---|
| 858 | }
|
---|
| 859 |
|
---|
[9c1600c] | 860 | //--------------------------------------------------------------------------
|
---|
| 861 | // SwitchStmt
|
---|
[13932f14] | 862 | template< typename pass_type >
|
---|
[ab904dc] | 863 | void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
|
---|
[4551a6e] | 864 | VISIT_START( node );
|
---|
[9c1600c] | 865 |
|
---|
[e0886db] | 866 | visitExpression ( node->condition );
|
---|
| 867 | visitStatementList( node->statements );
|
---|
[9c1600c] | 868 |
|
---|
| 869 | VISIT_END( node );
|
---|
[13932f14] | 870 | }
|
---|
| 871 |
|
---|
[296b2be] | 872 | template< typename pass_type >
|
---|
| 873 | Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
|
---|
[4551a6e] | 874 | MUTATE_START( node );
|
---|
| 875 |
|
---|
[e0886db] | 876 | node->condition = mutateExpression( node->condition );
|
---|
| 877 | mutateStatementList( node->statements );
|
---|
[4551a6e] | 878 |
|
---|
[296b2be] | 879 | MUTATE_END( Statement, node );
|
---|
| 880 | }
|
---|
| 881 |
|
---|
[9c1600c] | 882 | //--------------------------------------------------------------------------
|
---|
[35df560] | 883 | // CaseStmt
|
---|
[13932f14] | 884 | template< typename pass_type >
|
---|
[ab904dc] | 885 | void PassVisitor< pass_type >::visit( CaseStmt * node ) {
|
---|
[4551a6e] | 886 | VISIT_START( node );
|
---|
| 887 |
|
---|
[e0886db] | 888 | visitExpression ( node->condition );
|
---|
| 889 | visitStatementList( node->stmts );
|
---|
[4551a6e] | 890 |
|
---|
[9c1600c] | 891 | VISIT_END( node );
|
---|
[13932f14] | 892 | }
|
---|
| 893 |
|
---|
[296b2be] | 894 | template< typename pass_type >
|
---|
| 895 | Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
|
---|
[4551a6e] | 896 | MUTATE_START( node );
|
---|
| 897 |
|
---|
[e0886db] | 898 | node->condition = mutateExpression( node->condition );
|
---|
| 899 | mutateStatementList( node->stmts );
|
---|
[4551a6e] | 900 |
|
---|
[296b2be] | 901 | MUTATE_END( Statement, node );
|
---|
| 902 | }
|
---|
| 903 |
|
---|
[6ca154b] | 904 | //--------------------------------------------------------------------------
|
---|
| 905 | // BranchStmt
|
---|
[13932f14] | 906 | template< typename pass_type >
|
---|
[ab904dc] | 907 | void PassVisitor< pass_type >::visit( BranchStmt * node ) {
|
---|
[33c0ce8] | 908 | VISIT_START( node );
|
---|
| 909 | VISIT_END( node );
|
---|
[13932f14] | 910 | }
|
---|
| 911 |
|
---|
[6ca154b] | 912 | template< typename pass_type >
|
---|
| 913 | Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
|
---|
[33c0ce8] | 914 | MUTATE_START( node );
|
---|
| 915 | MUTATE_END( Statement, node );
|
---|
[6ca154b] | 916 | }
|
---|
| 917 |
|
---|
[9c1600c] | 918 | //--------------------------------------------------------------------------
|
---|
| 919 | // ReturnStmt
|
---|
[13932f14] | 920 | template< typename pass_type >
|
---|
[ab904dc] | 921 | void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
|
---|
[9c1600c] | 922 | VISIT_START( node );
|
---|
| 923 |
|
---|
[e0886db] | 924 | visitExpression( node->expr );
|
---|
[9c1600c] | 925 |
|
---|
| 926 | VISIT_END( node );
|
---|
[13932f14] | 927 | }
|
---|
| 928 |
|
---|
[296b2be] | 929 | template< typename pass_type >
|
---|
| 930 | Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
|
---|
| 931 | MUTATE_START( node );
|
---|
| 932 |
|
---|
[e0886db] | 933 | node->expr = mutateExpression( node->expr );
|
---|
[296b2be] | 934 |
|
---|
| 935 | MUTATE_END( Statement, node );
|
---|
| 936 | }
|
---|
| 937 |
|
---|
[6e09f211] | 938 | //--------------------------------------------------------------------------
|
---|
| 939 | // ThrowStmt
|
---|
| 940 |
|
---|
| 941 | template< typename pass_type >
|
---|
| 942 | void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
|
---|
[33c0ce8] | 943 | VISIT_START( node );
|
---|
| 944 |
|
---|
| 945 | maybeAccept_impl( node->expr, *this );
|
---|
| 946 | maybeAccept_impl( node->target, *this );
|
---|
| 947 |
|
---|
| 948 | VISIT_END( node );
|
---|
[6e09f211] | 949 | }
|
---|
| 950 |
|
---|
| 951 | template< typename pass_type >
|
---|
| 952 | Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
|
---|
[33c0ce8] | 953 | MUTATE_START( node );
|
---|
| 954 |
|
---|
| 955 | maybeMutate_impl( node->expr, *this );
|
---|
| 956 | maybeMutate_impl( node->target, *this );
|
---|
| 957 |
|
---|
| 958 | MUTATE_END( Statement, node );
|
---|
[6e09f211] | 959 | }
|
---|
| 960 |
|
---|
[9c1600c] | 961 | //--------------------------------------------------------------------------
|
---|
| 962 | // TryStmt
|
---|
[13932f14] | 963 | template< typename pass_type >
|
---|
[ab904dc] | 964 | void PassVisitor< pass_type >::visit( TryStmt * node ) {
|
---|
[9c1600c] | 965 | VISIT_START( node );
|
---|
| 966 |
|
---|
[3c398b6] | 967 | maybeAccept_impl( node->block , *this );
|
---|
| 968 | maybeAccept_impl( node->handlers , *this );
|
---|
| 969 | maybeAccept_impl( node->finallyBlock, *this );
|
---|
[9c1600c] | 970 |
|
---|
| 971 | VISIT_END( node );
|
---|
[13932f14] | 972 | }
|
---|
| 973 |
|
---|
[296b2be] | 974 | template< typename pass_type >
|
---|
| 975 | Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
|
---|
| 976 | MUTATE_START( node );
|
---|
| 977 |
|
---|
[3c398b6] | 978 | maybeMutate_impl( node->block , *this );
|
---|
| 979 | maybeMutate_impl( node->handlers , *this );
|
---|
| 980 | maybeMutate_impl( node->finallyBlock, *this );
|
---|
[4551a6e] | 981 |
|
---|
[296b2be] | 982 | MUTATE_END( Statement, node );
|
---|
| 983 | }
|
---|
| 984 |
|
---|
[9c1600c] | 985 | //--------------------------------------------------------------------------
|
---|
| 986 | // CatchStmt
|
---|
[13932f14] | 987 | template< typename pass_type >
|
---|
[ab904dc] | 988 | void PassVisitor< pass_type >::visit( CatchStmt * node ) {
|
---|
[9c1600c] | 989 | VISIT_START( node );
|
---|
[e0886db] | 990 | {
|
---|
[33a25f9] | 991 | // catch statements introduce a level of scope (for the caught exception)
|
---|
[e0886db] | 992 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 993 | maybeAccept_impl( node->decl, *this );
|
---|
[e0886db] | 994 | node->cond = visitExpression( node->cond );
|
---|
| 995 | node->body = visitStatement ( node->body );
|
---|
| 996 | }
|
---|
[9c1600c] | 997 | VISIT_END( node );
|
---|
[13932f14] | 998 | }
|
---|
| 999 |
|
---|
[296b2be] | 1000 | template< typename pass_type >
|
---|
| 1001 | Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
|
---|
| 1002 | MUTATE_START( node );
|
---|
[e0886db] | 1003 | {
|
---|
[33a25f9] | 1004 | // catch statements introduce a level of scope (for the caught exception)
|
---|
[e0886db] | 1005 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 1006 | maybeMutate_impl( node->decl, *this );
|
---|
[e0886db] | 1007 | node->cond = mutateExpression( node->cond );
|
---|
| 1008 | node->body = mutateStatement ( node->body );
|
---|
| 1009 | }
|
---|
[296b2be] | 1010 | MUTATE_END( Statement, node );
|
---|
| 1011 | }
|
---|
| 1012 |
|
---|
[2065609] | 1013 | //--------------------------------------------------------------------------
|
---|
| 1014 | // FinallyStmt
|
---|
[13932f14] | 1015 | template< typename pass_type >
|
---|
[ab904dc] | 1016 | void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
|
---|
[11b7028] | 1017 | VISIT_START( node );
|
---|
| 1018 |
|
---|
| 1019 | maybeAccept_impl( node->block, *this );
|
---|
| 1020 |
|
---|
| 1021 | VISIT_END( node );
|
---|
[13932f14] | 1022 | }
|
---|
| 1023 |
|
---|
[2065609] | 1024 | template< typename pass_type >
|
---|
| 1025 | Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
|
---|
[11b7028] | 1026 | MUTATE_START( node );
|
---|
| 1027 |
|
---|
| 1028 | maybeMutate_impl( node->block, *this );
|
---|
| 1029 |
|
---|
| 1030 | MUTATE_END( Statement, node );
|
---|
[2065609] | 1031 | }
|
---|
| 1032 |
|
---|
| 1033 | //--------------------------------------------------------------------------
|
---|
| 1034 | // WaitForStmt
|
---|
| 1035 | template< typename pass_type >
|
---|
| 1036 | void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
|
---|
[834b892] | 1037 | VISIT_START( node );
|
---|
| 1038 |
|
---|
| 1039 | for( auto & clause : node->clauses ) {
|
---|
| 1040 | maybeAccept_impl( clause.target.function, *this );
|
---|
| 1041 | maybeAccept_impl( clause.target.arguments, *this );
|
---|
| 1042 |
|
---|
| 1043 | maybeAccept_impl( clause.statement, *this );
|
---|
| 1044 | maybeAccept_impl( clause.condition, *this );
|
---|
| 1045 | }
|
---|
| 1046 |
|
---|
| 1047 | maybeAccept_impl( node->timeout.time, *this );
|
---|
| 1048 | maybeAccept_impl( node->timeout.statement, *this );
|
---|
| 1049 | maybeAccept_impl( node->timeout.condition, *this );
|
---|
| 1050 | maybeAccept_impl( node->orelse.statement, *this );
|
---|
| 1051 | maybeAccept_impl( node->orelse.condition, *this );
|
---|
| 1052 |
|
---|
| 1053 | VISIT_END( node );
|
---|
[2065609] | 1054 | }
|
---|
| 1055 |
|
---|
| 1056 | template< typename pass_type >
|
---|
| 1057 | Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
|
---|
[834b892] | 1058 | MUTATE_START( node );
|
---|
| 1059 |
|
---|
| 1060 | for( auto & clause : node->clauses ) {
|
---|
| 1061 | maybeMutate_impl( clause.target.function, *this );
|
---|
| 1062 | maybeMutate_impl( clause.target.arguments, *this );
|
---|
| 1063 |
|
---|
| 1064 | maybeMutate_impl( clause.statement, *this );
|
---|
| 1065 | maybeMutate_impl( clause.condition, *this );
|
---|
| 1066 | }
|
---|
| 1067 |
|
---|
| 1068 | maybeMutate_impl( node->timeout.time, *this );
|
---|
| 1069 | maybeMutate_impl( node->timeout.statement, *this );
|
---|
| 1070 | maybeMutate_impl( node->timeout.condition, *this );
|
---|
| 1071 | maybeMutate_impl( node->orelse.statement, *this );
|
---|
| 1072 | maybeMutate_impl( node->orelse.condition, *this );
|
---|
| 1073 |
|
---|
| 1074 | MUTATE_END( Statement, node );
|
---|
[2065609] | 1075 | }
|
---|
| 1076 |
|
---|
[d8893ca] | 1077 |
|
---|
| 1078 |
|
---|
[61255ad] | 1079 | //--------------------------------------------------------------------------
|
---|
| 1080 | // NullStmt
|
---|
| 1081 | template< typename pass_type >
|
---|
| 1082 | void PassVisitor< pass_type >::visit( WithStmt * node ) {
|
---|
[d8893ca] | 1083 | VISIT_START( node );
|
---|
| 1084 | maybeAccept_impl( node->exprs, *this );
|
---|
| 1085 | {
|
---|
| 1086 | // catch statements introduce a level of scope (for the caught exception)
|
---|
| 1087 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[0ac366b] | 1088 | indexerAddWith( node->exprs, node );
|
---|
[d8893ca] | 1089 | maybeAccept_impl( node->stmt, *this );
|
---|
| 1090 | }
|
---|
| 1091 | VISIT_END( node );
|
---|
[61255ad] | 1092 | }
|
---|
| 1093 |
|
---|
| 1094 | template< typename pass_type >
|
---|
| 1095 | Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
|
---|
[d8893ca] | 1096 | MUTATE_START( node );
|
---|
| 1097 | maybeMutate_impl( node->exprs, *this );
|
---|
| 1098 | {
|
---|
| 1099 | // catch statements introduce a level of scope (for the caught exception)
|
---|
| 1100 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[0ac366b] | 1101 | indexerAddWith( node->exprs, node );
|
---|
[d8893ca] | 1102 | maybeMutate_impl( node->stmt, *this );
|
---|
| 1103 | }
|
---|
| 1104 | MUTATE_END( Statement, node );
|
---|
[61255ad] | 1105 | }
|
---|
| 1106 |
|
---|
[2065609] | 1107 | //--------------------------------------------------------------------------
|
---|
| 1108 | // NullStmt
|
---|
[13932f14] | 1109 | template< typename pass_type >
|
---|
[ab904dc] | 1110 | void PassVisitor< pass_type >::visit( NullStmt * node ) {
|
---|
[5964127] | 1111 | VISIT_START( node );
|
---|
| 1112 | VISIT_END( node );
|
---|
[13932f14] | 1113 | }
|
---|
| 1114 |
|
---|
[2065609] | 1115 | template< typename pass_type >
|
---|
| 1116 | NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
|
---|
[5964127] | 1117 | MUTATE_START( node );
|
---|
| 1118 | MUTATE_END( NullStmt, node );
|
---|
[2065609] | 1119 | }
|
---|
| 1120 |
|
---|
| 1121 | //--------------------------------------------------------------------------
|
---|
| 1122 | // DeclStmt
|
---|
[13932f14] | 1123 | template< typename pass_type >
|
---|
[ab904dc] | 1124 | void PassVisitor< pass_type >::visit( DeclStmt * node ) {
|
---|
[5964127] | 1125 | VISIT_START( node );
|
---|
| 1126 |
|
---|
| 1127 | maybeAccept_impl( node->decl, *this );
|
---|
| 1128 |
|
---|
| 1129 | VISIT_END( node );
|
---|
[13932f14] | 1130 | }
|
---|
| 1131 |
|
---|
[2065609] | 1132 | template< typename pass_type >
|
---|
| 1133 | Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
|
---|
[5964127] | 1134 | MUTATE_START( node );
|
---|
| 1135 |
|
---|
| 1136 | maybeMutate_impl( node->decl, *this );
|
---|
| 1137 |
|
---|
| 1138 | MUTATE_END( Statement, node );
|
---|
[2065609] | 1139 | }
|
---|
| 1140 |
|
---|
| 1141 | //--------------------------------------------------------------------------
|
---|
| 1142 | // ImplicitCtorDtorStmt
|
---|
[13932f14] | 1143 | template< typename pass_type >
|
---|
[ab904dc] | 1144 | void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
|
---|
[599fbb6] | 1145 | VISIT_START( node );
|
---|
| 1146 |
|
---|
| 1147 | maybeAccept_impl( node->callStmt, *this );
|
---|
| 1148 |
|
---|
| 1149 | VISIT_END( node );
|
---|
[13932f14] | 1150 | }
|
---|
| 1151 |
|
---|
[2065609] | 1152 | template< typename pass_type >
|
---|
| 1153 | Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
|
---|
[599fbb6] | 1154 | MUTATE_START( node );
|
---|
| 1155 |
|
---|
| 1156 | maybeMutate_impl( node->callStmt, *this );
|
---|
| 1157 |
|
---|
| 1158 | MUTATE_END( Statement, node );
|
---|
[2065609] | 1159 | }
|
---|
| 1160 |
|
---|
| 1161 | //--------------------------------------------------------------------------
|
---|
| 1162 | // ApplicationExpr
|
---|
[13932f14] | 1163 | template< typename pass_type >
|
---|
[ab904dc] | 1164 | void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
|
---|
[e0886db] | 1165 | VISIT_START( node );
|
---|
| 1166 |
|
---|
| 1167 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1168 | maybeAccept_impl ( node->function, *this );
|
---|
| 1169 | maybeAccept_impl ( node->args , *this );
|
---|
[e0886db] | 1170 |
|
---|
| 1171 | VISIT_END( node );
|
---|
[13932f14] | 1172 | }
|
---|
| 1173 |
|
---|
[2065609] | 1174 | template< typename pass_type >
|
---|
| 1175 | Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
|
---|
[e0886db] | 1176 | MUTATE_START( node );
|
---|
| 1177 |
|
---|
| 1178 | indexerScopedMutate( node->env , *this );
|
---|
| 1179 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1180 | maybeMutate_impl ( node->function, *this );
|
---|
| 1181 | maybeMutate_impl ( node->args , *this );
|
---|
[e0886db] | 1182 |
|
---|
| 1183 | MUTATE_END( Expression, node );
|
---|
[2065609] | 1184 | }
|
---|
| 1185 |
|
---|
[9c1600c] | 1186 | //--------------------------------------------------------------------------
|
---|
| 1187 | // UntypedExpr
|
---|
[13932f14] | 1188 | template< typename pass_type >
|
---|
[ab904dc] | 1189 | void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
|
---|
[9c1600c] | 1190 | VISIT_START( node );
|
---|
| 1191 |
|
---|
[3c398b6] | 1192 | // maybeAccept_impl( node->get_env(), *this );
|
---|
[e0886db] | 1193 | indexerScopedAccept( node->result, *this );
|
---|
[2a7b3ca] | 1194 |
|
---|
[e0886db] | 1195 | for ( auto expr : node->args ) {
|
---|
[9c1600c] | 1196 | visitExpression( expr );
|
---|
| 1197 | }
|
---|
| 1198 |
|
---|
| 1199 | VISIT_END( node );
|
---|
[13932f14] | 1200 | }
|
---|
| 1201 |
|
---|
[296b2be] | 1202 | template< typename pass_type >
|
---|
| 1203 | Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
|
---|
| 1204 | MUTATE_START( node );
|
---|
| 1205 |
|
---|
[e0886db] | 1206 | indexerScopedMutate( node->env , *this );
|
---|
| 1207 | indexerScopedMutate( node->result, *this );
|
---|
[2a7b3ca] | 1208 |
|
---|
[e0886db] | 1209 | for ( auto& expr : node->args ) {
|
---|
[296b2be] | 1210 | expr = mutateExpression( expr );
|
---|
| 1211 | }
|
---|
| 1212 |
|
---|
| 1213 | MUTATE_END( Expression, node );
|
---|
| 1214 | }
|
---|
| 1215 |
|
---|
[e0886db] | 1216 | //--------------------------------------------------------------------------
|
---|
| 1217 | // NameExpr
|
---|
[13932f14] | 1218 | template< typename pass_type >
|
---|
[ab904dc] | 1219 | void PassVisitor< pass_type >::visit( NameExpr * node ) {
|
---|
[e0886db] | 1220 | VISIT_START( node );
|
---|
| 1221 |
|
---|
| 1222 | indexerScopedAccept( node->result, *this );
|
---|
| 1223 |
|
---|
| 1224 | VISIT_END( node );
|
---|
[13932f14] | 1225 | }
|
---|
| 1226 |
|
---|
| 1227 | template< typename pass_type >
|
---|
[e0886db] | 1228 | Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
|
---|
| 1229 | MUTATE_START( node );
|
---|
| 1230 |
|
---|
| 1231 | indexerScopedMutate( node->env , *this );
|
---|
| 1232 | indexerScopedMutate( node->result, *this );
|
---|
| 1233 |
|
---|
| 1234 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1235 | }
|
---|
| 1236 |
|
---|
[e0886db] | 1237 | //--------------------------------------------------------------------------
|
---|
| 1238 | // CastExpr
|
---|
[a5f0529] | 1239 | template< typename pass_type >
|
---|
[e0886db] | 1240 | void PassVisitor< pass_type >::visit( CastExpr * node ) {
|
---|
| 1241 | VISIT_START( node );
|
---|
| 1242 |
|
---|
| 1243 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1244 | maybeAccept_impl ( node->arg , *this );
|
---|
[e0886db] | 1245 |
|
---|
| 1246 | VISIT_END( node );
|
---|
[a5f0529] | 1247 | }
|
---|
| 1248 |
|
---|
[13932f14] | 1249 | template< typename pass_type >
|
---|
[e0886db] | 1250 | Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
|
---|
| 1251 | MUTATE_START( node );
|
---|
| 1252 |
|
---|
| 1253 | indexerScopedMutate( node->env , *this );
|
---|
| 1254 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1255 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1256 |
|
---|
| 1257 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1258 | }
|
---|
| 1259 |
|
---|
[e0886db] | 1260 | //--------------------------------------------------------------------------
|
---|
[9a705dc8] | 1261 | // KeywordCastExpr
|
---|
| 1262 | template< typename pass_type >
|
---|
| 1263 | void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
|
---|
| 1264 | VISIT_START( node );
|
---|
| 1265 |
|
---|
| 1266 | indexerScopedAccept( node->result, *this );
|
---|
| 1267 | maybeAccept_impl ( node->arg , *this );
|
---|
| 1268 |
|
---|
| 1269 | VISIT_END( node );
|
---|
| 1270 | }
|
---|
| 1271 |
|
---|
| 1272 | template< typename pass_type >
|
---|
| 1273 | Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
|
---|
| 1274 | MUTATE_START( node );
|
---|
| 1275 |
|
---|
| 1276 | indexerScopedMutate( node->env , *this );
|
---|
| 1277 | indexerScopedMutate( node->result, *this );
|
---|
| 1278 | maybeMutate_impl ( node->arg , *this );
|
---|
| 1279 |
|
---|
| 1280 | MUTATE_END( Expression, node );
|
---|
| 1281 | }
|
---|
| 1282 |
|
---|
| 1283 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 1284 | // VirtualCastExpr
|
---|
[13932f14] | 1285 | template< typename pass_type >
|
---|
[e0886db] | 1286 | void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
|
---|
| 1287 | VISIT_START( node );
|
---|
| 1288 |
|
---|
| 1289 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1290 | maybeAccept_impl( node->arg, *this );
|
---|
[e0886db] | 1291 |
|
---|
| 1292 | VISIT_END( node );
|
---|
[13932f14] | 1293 | }
|
---|
| 1294 |
|
---|
| 1295 | template< typename pass_type >
|
---|
[e0886db] | 1296 | Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
|
---|
| 1297 | MUTATE_START( node );
|
---|
| 1298 |
|
---|
| 1299 | indexerScopedMutate( node->env , *this );
|
---|
| 1300 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1301 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1302 |
|
---|
| 1303 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1304 | }
|
---|
| 1305 |
|
---|
[e0886db] | 1306 | //--------------------------------------------------------------------------
|
---|
| 1307 | // AddressExpr
|
---|
[13932f14] | 1308 | template< typename pass_type >
|
---|
[e0886db] | 1309 | void PassVisitor< pass_type >::visit( AddressExpr * node ) {
|
---|
| 1310 | VISIT_START( node );
|
---|
| 1311 |
|
---|
| 1312 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1313 | maybeAccept_impl ( node->arg , *this );
|
---|
[e0886db] | 1314 |
|
---|
| 1315 | VISIT_END( node );
|
---|
[13932f14] | 1316 | }
|
---|
| 1317 |
|
---|
| 1318 | template< typename pass_type >
|
---|
[e0886db] | 1319 | Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
|
---|
| 1320 | MUTATE_START( node );
|
---|
| 1321 |
|
---|
| 1322 | indexerScopedMutate( node->env , *this );
|
---|
| 1323 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1324 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1325 |
|
---|
| 1326 | MUTATE_END( Expression, node );
|
---|
| 1327 | }
|
---|
| 1328 |
|
---|
| 1329 | //--------------------------------------------------------------------------
|
---|
| 1330 | // LabelAddressExpr
|
---|
| 1331 | template< typename pass_type >
|
---|
| 1332 | void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
|
---|
| 1333 | VISIT_START( node );
|
---|
| 1334 |
|
---|
| 1335 | indexerScopedAccept( node->result, *this );
|
---|
| 1336 |
|
---|
| 1337 | VISIT_END( node );
|
---|
| 1338 | }
|
---|
| 1339 |
|
---|
| 1340 | template< typename pass_type >
|
---|
| 1341 | Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
|
---|
| 1342 | MUTATE_START( node );
|
---|
| 1343 |
|
---|
| 1344 | indexerScopedMutate( node->env , *this );
|
---|
| 1345 | indexerScopedMutate( node->result, *this );
|
---|
| 1346 |
|
---|
| 1347 | MUTATE_END( Expression, node );
|
---|
| 1348 | }
|
---|
| 1349 |
|
---|
| 1350 | //--------------------------------------------------------------------------
|
---|
| 1351 | // UntypedMemberExpr
|
---|
| 1352 | template< typename pass_type >
|
---|
| 1353 | void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
|
---|
| 1354 | VISIT_START( node );
|
---|
| 1355 |
|
---|
| 1356 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1357 | maybeAccept_impl ( node->aggregate, *this );
|
---|
| 1358 | maybeAccept_impl ( node->member , *this );
|
---|
[e0886db] | 1359 |
|
---|
| 1360 | VISIT_END( node );
|
---|
[13932f14] | 1361 | }
|
---|
| 1362 |
|
---|
[e0886db] | 1363 | template< typename pass_type >
|
---|
| 1364 | Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
|
---|
| 1365 | MUTATE_START( node );
|
---|
| 1366 |
|
---|
| 1367 | indexerScopedMutate( node->env , *this );
|
---|
| 1368 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1369 | maybeMutate_impl ( node->aggregate, *this );
|
---|
| 1370 | maybeMutate_impl ( node->member , *this );
|
---|
[e0886db] | 1371 |
|
---|
| 1372 | MUTATE_END( Expression, node );
|
---|
| 1373 | }
|
---|
| 1374 |
|
---|
| 1375 | //--------------------------------------------------------------------------
|
---|
| 1376 | // MemberExpr
|
---|
| 1377 | template< typename pass_type >
|
---|
| 1378 | void PassVisitor< pass_type >::visit( MemberExpr * node ) {
|
---|
| 1379 | VISIT_START( node );
|
---|
| 1380 |
|
---|
| 1381 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1382 | maybeAccept_impl ( node->aggregate, *this );
|
---|
[e0886db] | 1383 |
|
---|
| 1384 | VISIT_END( node );
|
---|
| 1385 | }
|
---|
| 1386 |
|
---|
| 1387 | template< typename pass_type >
|
---|
| 1388 | Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
|
---|
| 1389 | MUTATE_START( node );
|
---|
| 1390 |
|
---|
| 1391 | indexerScopedMutate( node->env , *this );
|
---|
| 1392 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1393 | maybeMutate_impl ( node->aggregate, *this );
|
---|
[e0886db] | 1394 |
|
---|
| 1395 | MUTATE_END( Expression, node );
|
---|
| 1396 | }
|
---|
| 1397 |
|
---|
| 1398 | //--------------------------------------------------------------------------
|
---|
| 1399 | // VariableExpr
|
---|
| 1400 | template< typename pass_type >
|
---|
| 1401 | void PassVisitor< pass_type >::visit( VariableExpr * node ) {
|
---|
| 1402 | VISIT_START( node );
|
---|
| 1403 |
|
---|
| 1404 | indexerScopedAccept( node->result, *this );
|
---|
| 1405 |
|
---|
| 1406 | VISIT_END( node );
|
---|
| 1407 | }
|
---|
| 1408 |
|
---|
| 1409 | template< typename pass_type >
|
---|
| 1410 | Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
|
---|
| 1411 | MUTATE_START( node );
|
---|
| 1412 |
|
---|
| 1413 | indexerScopedMutate( node->env , *this );
|
---|
| 1414 | indexerScopedMutate( node->result, *this );
|
---|
| 1415 |
|
---|
| 1416 | MUTATE_END( Expression, node );
|
---|
| 1417 | }
|
---|
| 1418 |
|
---|
| 1419 | //--------------------------------------------------------------------------
|
---|
| 1420 | // ConstantExpr
|
---|
[13932f14] | 1421 | template< typename pass_type >
|
---|
[ab904dc] | 1422 | void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
|
---|
[e0886db] | 1423 | VISIT_START( node );
|
---|
| 1424 |
|
---|
| 1425 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1426 | maybeAccept_impl ( &node->constant, *this );
|
---|
[e0886db] | 1427 |
|
---|
| 1428 | VISIT_END( node );
|
---|
[13932f14] | 1429 | }
|
---|
| 1430 |
|
---|
[e0886db] | 1431 | template< typename pass_type >
|
---|
| 1432 | Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
|
---|
| 1433 | MUTATE_START( node );
|
---|
| 1434 |
|
---|
| 1435 | indexerScopedMutate( node->env , *this );
|
---|
| 1436 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1437 | Constant * ptr = &node->constant;
|
---|
| 1438 | maybeMutate_impl( ptr, *this );
|
---|
| 1439 | node->constant = *ptr;
|
---|
[e0886db] | 1440 |
|
---|
| 1441 | MUTATE_END( Expression, node );
|
---|
| 1442 | }
|
---|
| 1443 |
|
---|
| 1444 | //--------------------------------------------------------------------------
|
---|
| 1445 | // SizeofExpr
|
---|
[13932f14] | 1446 | template< typename pass_type >
|
---|
[ab904dc] | 1447 | void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
|
---|
[e0886db] | 1448 | VISIT_START( node );
|
---|
| 1449 |
|
---|
| 1450 | indexerScopedAccept( node->result, *this );
|
---|
| 1451 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1452 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1453 | } else {
|
---|
[3c398b6] | 1454 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1455 | }
|
---|
| 1456 |
|
---|
| 1457 | VISIT_END( node );
|
---|
[13932f14] | 1458 | }
|
---|
| 1459 |
|
---|
[e0886db] | 1460 | template< typename pass_type >
|
---|
| 1461 | Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
|
---|
| 1462 | MUTATE_START( node );
|
---|
| 1463 |
|
---|
| 1464 | indexerScopedMutate( node->env , *this );
|
---|
| 1465 | indexerScopedMutate( node->result, *this );
|
---|
| 1466 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1467 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1468 | } else {
|
---|
[3c398b6] | 1469 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1470 | }
|
---|
| 1471 |
|
---|
| 1472 | MUTATE_END( Expression, node );
|
---|
| 1473 | }
|
---|
| 1474 |
|
---|
| 1475 | //--------------------------------------------------------------------------
|
---|
| 1476 | // AlignofExpr
|
---|
[13932f14] | 1477 | template< typename pass_type >
|
---|
[ab904dc] | 1478 | void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
|
---|
[e0886db] | 1479 | VISIT_START( node );
|
---|
| 1480 |
|
---|
| 1481 | indexerScopedAccept( node->result, *this );
|
---|
| 1482 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1483 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1484 | } else {
|
---|
[3c398b6] | 1485 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1486 | }
|
---|
| 1487 |
|
---|
| 1488 | VISIT_END( node );
|
---|
[13932f14] | 1489 | }
|
---|
| 1490 |
|
---|
[e0886db] | 1491 | template< typename pass_type >
|
---|
| 1492 | Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
|
---|
| 1493 | MUTATE_START( node );
|
---|
| 1494 |
|
---|
| 1495 | indexerScopedMutate( node->env , *this );
|
---|
| 1496 | indexerScopedMutate( node->result, *this );
|
---|
| 1497 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1498 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1499 | } else {
|
---|
[3c398b6] | 1500 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1501 | }
|
---|
| 1502 |
|
---|
| 1503 | MUTATE_END( Expression, node );
|
---|
| 1504 | }
|
---|
| 1505 |
|
---|
| 1506 | //--------------------------------------------------------------------------
|
---|
| 1507 | // UntypedOffsetofExpr
|
---|
[13932f14] | 1508 | template< typename pass_type >
|
---|
[ab904dc] | 1509 | void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
|
---|
[e0886db] | 1510 | VISIT_START( node );
|
---|
| 1511 |
|
---|
| 1512 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1513 | maybeAccept_impl ( node->type , *this );
|
---|
[e0886db] | 1514 |
|
---|
| 1515 | VISIT_END( node );
|
---|
[13932f14] | 1516 | }
|
---|
| 1517 |
|
---|
[e0886db] | 1518 | template< typename pass_type >
|
---|
| 1519 | Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
|
---|
| 1520 | MUTATE_START( node );
|
---|
| 1521 |
|
---|
| 1522 | indexerScopedMutate( node->env , *this );
|
---|
| 1523 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1524 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1525 |
|
---|
| 1526 | MUTATE_END( Expression, node );
|
---|
| 1527 | }
|
---|
| 1528 |
|
---|
| 1529 | //--------------------------------------------------------------------------
|
---|
| 1530 | // OffsetofExpr
|
---|
[13932f14] | 1531 | template< typename pass_type >
|
---|
[ab904dc] | 1532 | void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
|
---|
[e0886db] | 1533 | VISIT_START( node );
|
---|
| 1534 |
|
---|
| 1535 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1536 | maybeAccept_impl ( node->type , *this );
|
---|
[e0886db] | 1537 |
|
---|
| 1538 | VISIT_END( node );
|
---|
[13932f14] | 1539 | }
|
---|
| 1540 |
|
---|
[e0886db] | 1541 | template< typename pass_type >
|
---|
| 1542 | Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
|
---|
| 1543 | MUTATE_START( node );
|
---|
| 1544 |
|
---|
| 1545 | indexerScopedMutate( node->env , *this );
|
---|
| 1546 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1547 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1548 |
|
---|
| 1549 | MUTATE_END( Expression, node );
|
---|
| 1550 | }
|
---|
| 1551 |
|
---|
| 1552 | //--------------------------------------------------------------------------
|
---|
| 1553 | // OffsetPackExpr
|
---|
[13932f14] | 1554 | template< typename pass_type >
|
---|
[ab904dc] | 1555 | void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
|
---|
[e0886db] | 1556 | VISIT_START( node );
|
---|
| 1557 |
|
---|
| 1558 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1559 | maybeAccept_impl ( node->type , *this );
|
---|
[e0886db] | 1560 |
|
---|
| 1561 | VISIT_END( node );
|
---|
[13932f14] | 1562 | }
|
---|
| 1563 |
|
---|
[e0886db] | 1564 | template< typename pass_type >
|
---|
| 1565 | Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
|
---|
| 1566 | MUTATE_START( node );
|
---|
| 1567 |
|
---|
| 1568 | indexerScopedMutate( node->env , *this );
|
---|
| 1569 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1570 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1571 |
|
---|
| 1572 | MUTATE_END( Expression, node );
|
---|
| 1573 | }
|
---|
| 1574 |
|
---|
| 1575 | //--------------------------------------------------------------------------
|
---|
| 1576 | // AttrExpr
|
---|
[13932f14] | 1577 | template< typename pass_type >
|
---|
[ab904dc] | 1578 | void PassVisitor< pass_type >::visit( AttrExpr * node ) {
|
---|
[e0886db] | 1579 | VISIT_START( node );
|
---|
| 1580 |
|
---|
| 1581 | indexerScopedAccept( node->result, *this );
|
---|
| 1582 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1583 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1584 | } else {
|
---|
[3c398b6] | 1585 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1586 | }
|
---|
| 1587 |
|
---|
| 1588 | VISIT_END( node );
|
---|
| 1589 | }
|
---|
| 1590 |
|
---|
| 1591 | template< typename pass_type >
|
---|
| 1592 | Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
|
---|
| 1593 | MUTATE_START( node );
|
---|
| 1594 |
|
---|
| 1595 | indexerScopedMutate( node->env , *this );
|
---|
| 1596 | indexerScopedMutate( node->result, *this );
|
---|
| 1597 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1598 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1599 | } else {
|
---|
[3c398b6] | 1600 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1601 | }
|
---|
| 1602 |
|
---|
| 1603 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1604 | }
|
---|
| 1605 |
|
---|
[e0886db] | 1606 | //--------------------------------------------------------------------------
|
---|
| 1607 | // LogicalExpr
|
---|
[13932f14] | 1608 | template< typename pass_type >
|
---|
[ab904dc] | 1609 | void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
|
---|
[e0886db] | 1610 | VISIT_START( node );
|
---|
| 1611 |
|
---|
| 1612 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1613 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1614 | maybeAccept_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1615 |
|
---|
| 1616 | VISIT_END( node );
|
---|
| 1617 | }
|
---|
| 1618 |
|
---|
| 1619 | template< typename pass_type >
|
---|
| 1620 | Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
|
---|
| 1621 | MUTATE_START( node );
|
---|
| 1622 |
|
---|
| 1623 | indexerScopedMutate( node->env , *this );
|
---|
| 1624 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1625 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1626 | maybeMutate_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1627 |
|
---|
| 1628 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1629 | }
|
---|
| 1630 |
|
---|
[e0886db] | 1631 | //--------------------------------------------------------------------------
|
---|
| 1632 | // ConditionalExpr
|
---|
[13932f14] | 1633 | template< typename pass_type >
|
---|
[ab904dc] | 1634 | void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
|
---|
[e0886db] | 1635 | VISIT_START( node );
|
---|
| 1636 |
|
---|
| 1637 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1638 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1639 | maybeAccept_impl ( node->arg2 , *this );
|
---|
| 1640 | maybeAccept_impl ( node->arg3 , *this );
|
---|
[e0886db] | 1641 |
|
---|
| 1642 | VISIT_END( node );
|
---|
[13932f14] | 1643 | }
|
---|
| 1644 |
|
---|
[e0886db] | 1645 | template< typename pass_type >
|
---|
| 1646 | Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
|
---|
| 1647 | MUTATE_START( node );
|
---|
| 1648 |
|
---|
| 1649 | indexerScopedMutate( node->env , *this );
|
---|
| 1650 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1651 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1652 | maybeMutate_impl ( node->arg2 , *this );
|
---|
| 1653 | maybeMutate_impl ( node->arg3 , *this );
|
---|
[e0886db] | 1654 |
|
---|
| 1655 | MUTATE_END( Expression, node );
|
---|
| 1656 | }
|
---|
| 1657 |
|
---|
| 1658 | //--------------------------------------------------------------------------
|
---|
| 1659 | // CommaExpr
|
---|
[13932f14] | 1660 | template< typename pass_type >
|
---|
[ab904dc] | 1661 | void PassVisitor< pass_type >::visit( CommaExpr * 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 );
|
---|
[e0886db] | 1667 |
|
---|
| 1668 | VISIT_END( node );
|
---|
| 1669 | }
|
---|
| 1670 |
|
---|
| 1671 | template< typename pass_type >
|
---|
| 1672 | Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
|
---|
| 1673 | MUTATE_START( node );
|
---|
| 1674 |
|
---|
| 1675 | indexerScopedMutate( node->env , *this );
|
---|
| 1676 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1677 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1678 | maybeMutate_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1679 |
|
---|
| 1680 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1681 | }
|
---|
| 1682 |
|
---|
[e0886db] | 1683 | //--------------------------------------------------------------------------
|
---|
| 1684 | // TypeExpr
|
---|
[13932f14] | 1685 | template< typename pass_type >
|
---|
[ab904dc] | 1686 | void PassVisitor< pass_type >::visit( TypeExpr * node ) {
|
---|
[e0886db] | 1687 | VISIT_START( node );
|
---|
| 1688 |
|
---|
| 1689 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1690 | maybeAccept_impl ( node->type, *this );
|
---|
[e0886db] | 1691 |
|
---|
| 1692 | VISIT_END( node );
|
---|
[13932f14] | 1693 | }
|
---|
| 1694 |
|
---|
[e0886db] | 1695 | template< typename pass_type >
|
---|
| 1696 | Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
|
---|
| 1697 | MUTATE_START( node );
|
---|
| 1698 |
|
---|
| 1699 | indexerScopedMutate( node->env , *this );
|
---|
| 1700 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1701 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1702 |
|
---|
| 1703 | MUTATE_END( Expression, node );
|
---|
| 1704 | }
|
---|
| 1705 |
|
---|
| 1706 | //--------------------------------------------------------------------------
|
---|
| 1707 | // AsmExpr
|
---|
[13932f14] | 1708 | template< typename pass_type >
|
---|
[ab904dc] | 1709 | void PassVisitor< pass_type >::visit( AsmExpr * node ) {
|
---|
[e0886db] | 1710 | VISIT_START( node );
|
---|
| 1711 |
|
---|
| 1712 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1713 | maybeAccept_impl ( node->inout , *this );
|
---|
| 1714 | maybeAccept_impl ( node->constraint, *this );
|
---|
| 1715 | maybeAccept_impl ( node->operand , *this );
|
---|
[e0886db] | 1716 |
|
---|
| 1717 | VISIT_END( node );
|
---|
[13932f14] | 1718 | }
|
---|
| 1719 |
|
---|
[e0886db] | 1720 | template< typename pass_type >
|
---|
| 1721 | Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
|
---|
| 1722 | MUTATE_START( node );
|
---|
| 1723 |
|
---|
| 1724 | indexerScopedMutate( node->env , *this );
|
---|
| 1725 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1726 | maybeMutate_impl ( node->inout , *this );
|
---|
| 1727 | maybeMutate_impl ( node->constraint, *this );
|
---|
| 1728 | maybeMutate_impl ( node->operand , *this );
|
---|
[e0886db] | 1729 |
|
---|
| 1730 | MUTATE_END( Expression, node );
|
---|
| 1731 | }
|
---|
| 1732 |
|
---|
| 1733 | //--------------------------------------------------------------------------
|
---|
| 1734 | // ImplicitCopyCtorExpr
|
---|
[13932f14] | 1735 | template< typename pass_type >
|
---|
[ab904dc] | 1736 | void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
|
---|
[e0886db] | 1737 | VISIT_START( node );
|
---|
| 1738 |
|
---|
| 1739 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1740 | maybeAccept_impl ( node->callExpr , *this );
|
---|
| 1741 | maybeAccept_impl ( node->tempDecls , *this );
|
---|
| 1742 | maybeAccept_impl ( node->returnDecls, *this );
|
---|
| 1743 | maybeAccept_impl ( node->dtors , *this );
|
---|
[e0886db] | 1744 |
|
---|
| 1745 | VISIT_END( node );
|
---|
| 1746 | }
|
---|
| 1747 |
|
---|
| 1748 | template< typename pass_type >
|
---|
| 1749 | Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
|
---|
| 1750 | MUTATE_START( node );
|
---|
| 1751 |
|
---|
| 1752 | indexerScopedMutate( node->env , *this );
|
---|
| 1753 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1754 | maybeMutate_impl ( node->callExpr , *this );
|
---|
| 1755 | maybeMutate_impl ( node->tempDecls , *this );
|
---|
| 1756 | maybeMutate_impl ( node->returnDecls, *this );
|
---|
| 1757 | maybeMutate_impl ( node->dtors , *this );
|
---|
[e0886db] | 1758 |
|
---|
| 1759 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1760 | }
|
---|
| 1761 |
|
---|
[e0886db] | 1762 | //--------------------------------------------------------------------------
|
---|
| 1763 | // ConstructorExpr
|
---|
[13932f14] | 1764 | template< typename pass_type >
|
---|
[ab904dc] | 1765 | void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
|
---|
[e0886db] | 1766 | VISIT_START( node );
|
---|
| 1767 |
|
---|
| 1768 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1769 | maybeAccept_impl ( node->callExpr, *this );
|
---|
[e0886db] | 1770 |
|
---|
| 1771 | VISIT_END( node );
|
---|
| 1772 | }
|
---|
| 1773 |
|
---|
| 1774 | template< typename pass_type >
|
---|
| 1775 | Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
|
---|
| 1776 | MUTATE_START( node );
|
---|
| 1777 |
|
---|
| 1778 | indexerScopedMutate( node->env , *this );
|
---|
| 1779 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1780 | maybeMutate_impl ( node->callExpr, *this );
|
---|
[e0886db] | 1781 |
|
---|
| 1782 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1783 | }
|
---|
| 1784 |
|
---|
[e0886db] | 1785 | //--------------------------------------------------------------------------
|
---|
| 1786 | // CompoundLiteralExpr
|
---|
[13932f14] | 1787 | template< typename pass_type >
|
---|
[ab904dc] | 1788 | void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
|
---|
[e0886db] | 1789 | VISIT_START( node );
|
---|
| 1790 |
|
---|
| 1791 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1792 | maybeAccept_impl ( node->initializer, *this );
|
---|
[e0886db] | 1793 |
|
---|
| 1794 | VISIT_END( node );
|
---|
[13932f14] | 1795 | }
|
---|
| 1796 |
|
---|
[e0886db] | 1797 | template< typename pass_type >
|
---|
| 1798 | Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
|
---|
| 1799 | MUTATE_START( node );
|
---|
| 1800 |
|
---|
| 1801 | indexerScopedMutate( node->env , *this );
|
---|
| 1802 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1803 | maybeMutate_impl ( node->initializer, *this );
|
---|
[e0886db] | 1804 |
|
---|
| 1805 | MUTATE_END( Expression, node );
|
---|
| 1806 | }
|
---|
| 1807 |
|
---|
| 1808 | //--------------------------------------------------------------------------
|
---|
| 1809 | // RangeExpr
|
---|
[13932f14] | 1810 | template< typename pass_type >
|
---|
[ab904dc] | 1811 | void PassVisitor< pass_type >::visit( RangeExpr * node ) {
|
---|
[e0886db] | 1812 | VISIT_START( node );
|
---|
| 1813 |
|
---|
| 1814 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1815 | maybeAccept_impl ( node->low , *this );
|
---|
| 1816 | maybeAccept_impl ( node->high , *this );
|
---|
[e0886db] | 1817 |
|
---|
| 1818 | VISIT_END( node );
|
---|
[13932f14] | 1819 | }
|
---|
| 1820 |
|
---|
[e0886db] | 1821 | template< typename pass_type >
|
---|
| 1822 | Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
|
---|
| 1823 | MUTATE_START( node );
|
---|
| 1824 |
|
---|
| 1825 | indexerScopedMutate( node->env , *this );
|
---|
| 1826 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1827 | maybeMutate_impl ( node->low , *this );
|
---|
| 1828 | maybeMutate_impl ( node->high , *this );
|
---|
[e0886db] | 1829 |
|
---|
| 1830 | MUTATE_END( Expression, node );
|
---|
| 1831 | }
|
---|
| 1832 |
|
---|
| 1833 | //--------------------------------------------------------------------------
|
---|
| 1834 | // UntypedTupleExpr
|
---|
[13932f14] | 1835 | template< typename pass_type >
|
---|
[ab904dc] | 1836 | void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
|
---|
[e0886db] | 1837 | VISIT_START( node );
|
---|
| 1838 |
|
---|
| 1839 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1840 | maybeAccept_impl ( node->exprs , *this );
|
---|
[e0886db] | 1841 |
|
---|
| 1842 | VISIT_END( node );
|
---|
| 1843 | }
|
---|
| 1844 |
|
---|
| 1845 | template< typename pass_type >
|
---|
| 1846 | Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
|
---|
| 1847 | MUTATE_START( node );
|
---|
| 1848 |
|
---|
| 1849 | indexerScopedMutate( node->env , *this );
|
---|
| 1850 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1851 | maybeMutate_impl ( node->exprs , *this );
|
---|
[e0886db] | 1852 |
|
---|
| 1853 | MUTATE_END( Expression, node );
|
---|
| 1854 | }
|
---|
| 1855 |
|
---|
| 1856 | //--------------------------------------------------------------------------
|
---|
| 1857 | // TupleExpr
|
---|
| 1858 | template< typename pass_type >
|
---|
| 1859 | void PassVisitor< pass_type >::visit( TupleExpr * node ) {
|
---|
| 1860 | VISIT_START( node );
|
---|
| 1861 |
|
---|
| 1862 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1863 | maybeAccept_impl ( node->exprs , *this );
|
---|
[e0886db] | 1864 |
|
---|
| 1865 | VISIT_END( node );
|
---|
| 1866 | }
|
---|
| 1867 |
|
---|
| 1868 | template< typename pass_type >
|
---|
| 1869 | Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
|
---|
| 1870 | MUTATE_START( node );
|
---|
| 1871 |
|
---|
| 1872 | indexerScopedMutate( node->env , *this );
|
---|
| 1873 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1874 | maybeMutate_impl ( node->exprs , *this );
|
---|
[e0886db] | 1875 |
|
---|
| 1876 | MUTATE_END( Expression, node );
|
---|
| 1877 | }
|
---|
| 1878 |
|
---|
| 1879 | //--------------------------------------------------------------------------
|
---|
| 1880 | // TupleIndexExpr
|
---|
| 1881 | template< typename pass_type >
|
---|
| 1882 | void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
|
---|
| 1883 | VISIT_START( node );
|
---|
| 1884 |
|
---|
| 1885 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1886 | maybeAccept_impl ( node->tuple , *this );
|
---|
[e0886db] | 1887 |
|
---|
| 1888 | VISIT_END( node );
|
---|
| 1889 | }
|
---|
| 1890 |
|
---|
| 1891 | template< typename pass_type >
|
---|
| 1892 | Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
|
---|
| 1893 | MUTATE_START( node );
|
---|
| 1894 |
|
---|
| 1895 | indexerScopedMutate( node->env , *this );
|
---|
| 1896 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1897 | maybeMutate_impl ( node->tuple , *this );
|
---|
[e0886db] | 1898 |
|
---|
| 1899 | MUTATE_END( Expression, node );
|
---|
| 1900 | }
|
---|
| 1901 |
|
---|
| 1902 | //--------------------------------------------------------------------------
|
---|
| 1903 | // TupleAssignExpr
|
---|
| 1904 | template< typename pass_type >
|
---|
| 1905 | void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
|
---|
| 1906 | VISIT_START( node );
|
---|
| 1907 |
|
---|
| 1908 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1909 | maybeAccept_impl ( node->stmtExpr, *this );
|
---|
[e0886db] | 1910 |
|
---|
| 1911 | VISIT_END( node );
|
---|
[13932f14] | 1912 | }
|
---|
| 1913 |
|
---|
| 1914 | template< typename pass_type >
|
---|
[e0886db] | 1915 | Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
|
---|
| 1916 | MUTATE_START( node );
|
---|
[13932f14] | 1917 |
|
---|
[e0886db] | 1918 | indexerScopedMutate( node->env , *this );
|
---|
| 1919 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1920 | maybeMutate_impl ( node->stmtExpr, *this );
|
---|
[13932f14] | 1921 |
|
---|
[e0886db] | 1922 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1923 | }
|
---|
| 1924 |
|
---|
[9c1600c] | 1925 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 1926 | // StmtExpr
|
---|
[13932f14] | 1927 | template< typename pass_type >
|
---|
[ab904dc] | 1928 | void PassVisitor< pass_type >::visit( StmtExpr * node ) {
|
---|
[9c1600c] | 1929 | VISIT_START( node );
|
---|
| 1930 |
|
---|
| 1931 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
---|
| 1932 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
---|
| 1933 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
---|
| 1934 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
---|
| 1935 |
|
---|
[e0886db] | 1936 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1937 | maybeAccept_impl ( node->statements , *this );
|
---|
| 1938 | maybeAccept_impl ( node->returnDecls, *this );
|
---|
| 1939 | maybeAccept_impl ( node->dtors , *this );
|
---|
[9c1600c] | 1940 |
|
---|
| 1941 | VISIT_END( node );
|
---|
[13932f14] | 1942 | }
|
---|
| 1943 |
|
---|
[296b2be] | 1944 | template< typename pass_type >
|
---|
| 1945 | Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
|
---|
| 1946 | MUTATE_START( node );
|
---|
[4551a6e] | 1947 |
|
---|
[296b2be] | 1948 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
---|
[134322e] | 1949 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
---|
| 1950 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
---|
| 1951 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
---|
[296b2be] | 1952 |
|
---|
[e0886db] | 1953 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1954 | maybeMutate_impl ( node->statements , *this );
|
---|
| 1955 | maybeMutate_impl ( node->returnDecls, *this );
|
---|
| 1956 | maybeMutate_impl ( node->dtors , *this );
|
---|
[296b2be] | 1957 |
|
---|
| 1958 | MUTATE_END( Expression, node );
|
---|
| 1959 | }
|
---|
| 1960 |
|
---|
[e0886db] | 1961 | //--------------------------------------------------------------------------
|
---|
| 1962 | // UniqueExpr
|
---|
[13932f14] | 1963 | template< typename pass_type >
|
---|
[ab904dc] | 1964 | void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
|
---|
[e0886db] | 1965 | VISIT_START( node );
|
---|
| 1966 |
|
---|
| 1967 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1968 | maybeAccept_impl ( node->expr , *this );
|
---|
[e0886db] | 1969 |
|
---|
| 1970 | VISIT_END( node );
|
---|
| 1971 | }
|
---|
| 1972 |
|
---|
| 1973 | template< typename pass_type >
|
---|
| 1974 | Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
|
---|
| 1975 | MUTATE_START( node );
|
---|
| 1976 |
|
---|
| 1977 | indexerScopedMutate( node->env , *this );
|
---|
| 1978 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1979 | maybeMutate_impl ( node->expr , *this );
|
---|
[e0886db] | 1980 |
|
---|
| 1981 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1982 | }
|
---|
| 1983 |
|
---|
[73367a8] | 1984 | //--------------------------------------------------------------------------
|
---|
| 1985 | // UntypedInitExpr
|
---|
| 1986 | template< typename pass_type >
|
---|
| 1987 | void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
|
---|
| 1988 | VISIT_START( node );
|
---|
| 1989 |
|
---|
| 1990 | indexerScopedAccept( node->result, *this );
|
---|
| 1991 | maybeAccept_impl ( node->expr , *this );
|
---|
| 1992 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
| 1993 |
|
---|
| 1994 | VISIT_END( node );
|
---|
| 1995 | }
|
---|
| 1996 |
|
---|
| 1997 | template< typename pass_type >
|
---|
| 1998 | Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
|
---|
| 1999 | MUTATE_START( node );
|
---|
| 2000 |
|
---|
| 2001 | indexerScopedMutate( node->env , *this );
|
---|
| 2002 | indexerScopedMutate( node->result, *this );
|
---|
| 2003 | maybeMutate_impl ( node->expr , *this );
|
---|
| 2004 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
| 2005 |
|
---|
| 2006 | MUTATE_END( Expression, node );
|
---|
| 2007 | }
|
---|
| 2008 |
|
---|
| 2009 | //--------------------------------------------------------------------------
|
---|
| 2010 | // InitExpr
|
---|
| 2011 | template< typename pass_type >
|
---|
| 2012 | void PassVisitor< pass_type >::visit( InitExpr * node ) {
|
---|
| 2013 | VISIT_START( node );
|
---|
| 2014 |
|
---|
| 2015 | indexerScopedAccept( node->result, *this );
|
---|
| 2016 | maybeAccept_impl ( node->expr , *this );
|
---|
| 2017 | maybeAccept_impl ( node->designation, *this );
|
---|
| 2018 |
|
---|
| 2019 | VISIT_END( node );
|
---|
| 2020 | }
|
---|
| 2021 |
|
---|
| 2022 | template< typename pass_type >
|
---|
| 2023 | Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
|
---|
| 2024 | MUTATE_START( node );
|
---|
| 2025 |
|
---|
| 2026 | indexerScopedMutate( node->env , *this );
|
---|
| 2027 | indexerScopedMutate( node->result, *this );
|
---|
| 2028 | maybeMutate_impl ( node->expr , *this );
|
---|
| 2029 | maybeMutate_impl ( node->designation, *this );
|
---|
| 2030 |
|
---|
| 2031 | MUTATE_END( Expression, node );
|
---|
| 2032 | }
|
---|
| 2033 |
|
---|
[44b4114] | 2034 | //--------------------------------------------------------------------------
|
---|
| 2035 | // DeletedExpr
|
---|
| 2036 | template< typename pass_type >
|
---|
| 2037 | void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
|
---|
| 2038 | VISIT_START( node );
|
---|
| 2039 |
|
---|
| 2040 | indexerScopedAccept( node->result, *this );
|
---|
| 2041 | maybeAccept_impl( node->expr, *this );
|
---|
| 2042 | // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
|
---|
| 2043 |
|
---|
| 2044 | VISIT_END( node );
|
---|
| 2045 | }
|
---|
| 2046 |
|
---|
| 2047 | template< typename pass_type >
|
---|
| 2048 | Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
|
---|
| 2049 | MUTATE_START( node );
|
---|
| 2050 |
|
---|
| 2051 | indexerScopedMutate( node->env, *this );
|
---|
| 2052 | indexerScopedMutate( node->result, *this );
|
---|
| 2053 | maybeMutate_impl( node->expr, *this );
|
---|
| 2054 |
|
---|
| 2055 | MUTATE_END( Expression, node );
|
---|
| 2056 | }
|
---|
| 2057 |
|
---|
[17fc7a5] | 2058 | //--------------------------------------------------------------------------
|
---|
| 2059 | // VoidType
|
---|
[13932f14] | 2060 | template< typename pass_type >
|
---|
[ab904dc] | 2061 | void PassVisitor< pass_type >::visit( VoidType * node ) {
|
---|
[599fbb6] | 2062 | VISIT_START( node );
|
---|
| 2063 |
|
---|
| 2064 | maybeAccept_impl( node->forall, *this );
|
---|
| 2065 |
|
---|
| 2066 | VISIT_END( node );
|
---|
| 2067 | }
|
---|
| 2068 |
|
---|
| 2069 | template< typename pass_type >
|
---|
| 2070 | Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
|
---|
| 2071 | MUTATE_START( node );
|
---|
| 2072 |
|
---|
| 2073 | maybeMutate_impl( node->forall, *this );
|
---|
| 2074 |
|
---|
| 2075 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2076 | }
|
---|
| 2077 |
|
---|
[17fc7a5] | 2078 | //--------------------------------------------------------------------------
|
---|
| 2079 | // BasicType
|
---|
[13932f14] | 2080 | template< typename pass_type >
|
---|
[ab904dc] | 2081 | void PassVisitor< pass_type >::visit( BasicType * node ) {
|
---|
[17fc7a5] | 2082 | VISIT_START( node );
|
---|
| 2083 |
|
---|
| 2084 | maybeAccept_impl( node->forall, *this );
|
---|
| 2085 |
|
---|
| 2086 | VISIT_END( node );
|
---|
| 2087 | }
|
---|
| 2088 |
|
---|
| 2089 | template< typename pass_type >
|
---|
| 2090 | Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
|
---|
| 2091 | MUTATE_START( node );
|
---|
| 2092 |
|
---|
| 2093 | maybeMutate_impl( node->forall, *this );
|
---|
| 2094 |
|
---|
| 2095 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2096 | }
|
---|
| 2097 |
|
---|
[17fc7a5] | 2098 | //--------------------------------------------------------------------------
|
---|
| 2099 | // PointerType
|
---|
[13932f14] | 2100 | template< typename pass_type >
|
---|
[ab904dc] | 2101 | void PassVisitor< pass_type >::visit( PointerType * node ) {
|
---|
[17fc7a5] | 2102 | VISIT_START( node );
|
---|
| 2103 |
|
---|
| 2104 | maybeAccept_impl( node->forall, *this );
|
---|
[cfaf9be] | 2105 | // xxx - should PointerType visit/mutate dimension?
|
---|
[17fc7a5] | 2106 | maybeAccept_impl( node->base, *this );
|
---|
| 2107 |
|
---|
| 2108 | VISIT_END( node );
|
---|
[13932f14] | 2109 | }
|
---|
| 2110 |
|
---|
[17fc7a5] | 2111 | template< typename pass_type >
|
---|
| 2112 | Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
|
---|
| 2113 | MUTATE_START( node );
|
---|
| 2114 |
|
---|
| 2115 | maybeMutate_impl( node->forall, *this );
|
---|
[cfaf9be] | 2116 | // xxx - should PointerType visit/mutate dimension?
|
---|
[17fc7a5] | 2117 | maybeMutate_impl( node->base, *this );
|
---|
| 2118 |
|
---|
| 2119 | MUTATE_END( Type, node );
|
---|
| 2120 | }
|
---|
| 2121 |
|
---|
| 2122 | //--------------------------------------------------------------------------
|
---|
| 2123 | // ArrayType
|
---|
[13932f14] | 2124 | template< typename pass_type >
|
---|
[ab904dc] | 2125 | void PassVisitor< pass_type >::visit( ArrayType * node ) {
|
---|
[17fc7a5] | 2126 | VISIT_START( node );
|
---|
| 2127 |
|
---|
| 2128 | maybeAccept_impl( node->forall, *this );
|
---|
| 2129 | maybeAccept_impl( node->dimension, *this );
|
---|
| 2130 | maybeAccept_impl( node->base, *this );
|
---|
| 2131 |
|
---|
| 2132 | VISIT_END( node );
|
---|
[13932f14] | 2133 | }
|
---|
| 2134 |
|
---|
[17fc7a5] | 2135 | template< typename pass_type >
|
---|
| 2136 | Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
|
---|
| 2137 | MUTATE_START( node );
|
---|
| 2138 |
|
---|
| 2139 | maybeMutate_impl( node->forall, *this );
|
---|
| 2140 | maybeMutate_impl( node->dimension, *this );
|
---|
| 2141 | maybeMutate_impl( node->base, *this );
|
---|
| 2142 |
|
---|
| 2143 | MUTATE_END( Type, node );
|
---|
| 2144 | }
|
---|
| 2145 |
|
---|
| 2146 | //--------------------------------------------------------------------------
|
---|
| 2147 | // ReferenceType
|
---|
[6b9b047] | 2148 | template< typename pass_type >
|
---|
| 2149 | void PassVisitor< pass_type >::visit( ReferenceType * node ) {
|
---|
[17fc7a5] | 2150 | VISIT_START( node );
|
---|
| 2151 |
|
---|
| 2152 | maybeAccept_impl( node->forall, *this );
|
---|
| 2153 | maybeAccept_impl( node->base, *this );
|
---|
| 2154 |
|
---|
| 2155 | VISIT_END( node );
|
---|
| 2156 | }
|
---|
| 2157 |
|
---|
| 2158 | template< typename pass_type >
|
---|
| 2159 | Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
|
---|
| 2160 | MUTATE_START( node );
|
---|
| 2161 |
|
---|
| 2162 | maybeMutate_impl( node->forall, *this );
|
---|
| 2163 | maybeMutate_impl( node->base, *this );
|
---|
| 2164 |
|
---|
| 2165 | MUTATE_END( Type, node );
|
---|
[6b9b047] | 2166 | }
|
---|
| 2167 |
|
---|
[17fc7a5] | 2168 | //--------------------------------------------------------------------------
|
---|
| 2169 | // FunctionType
|
---|
[13932f14] | 2170 | template< typename pass_type >
|
---|
[ab904dc] | 2171 | void PassVisitor< pass_type >::visit( FunctionType * node ) {
|
---|
[17fc7a5] | 2172 | VISIT_START( node );
|
---|
| 2173 |
|
---|
| 2174 | maybeAccept_impl( node->forall, *this );
|
---|
| 2175 | maybeAccept_impl( node->returnVals, *this );
|
---|
| 2176 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2177 |
|
---|
| 2178 | VISIT_END( node );
|
---|
| 2179 | }
|
---|
| 2180 |
|
---|
| 2181 | template< typename pass_type >
|
---|
| 2182 | Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
|
---|
| 2183 | MUTATE_START( node );
|
---|
| 2184 |
|
---|
| 2185 | maybeMutate_impl( node->forall, *this );
|
---|
| 2186 | maybeMutate_impl( node->returnVals, *this );
|
---|
| 2187 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2188 |
|
---|
| 2189 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2190 | }
|
---|
| 2191 |
|
---|
[e0886db] | 2192 | //--------------------------------------------------------------------------
|
---|
| 2193 | // StructInstType
|
---|
[13932f14] | 2194 | template< typename pass_type >
|
---|
[ab904dc] | 2195 | void PassVisitor< pass_type >::visit( StructInstType * node ) {
|
---|
[e0886db] | 2196 | VISIT_START( node );
|
---|
| 2197 |
|
---|
| 2198 | indexerAddStruct( node->name );
|
---|
| 2199 |
|
---|
| 2200 | {
|
---|
| 2201 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2202 | maybeAccept_impl( node->forall , *this );
|
---|
| 2203 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2204 | }
|
---|
| 2205 |
|
---|
| 2206 | VISIT_END( node );
|
---|
| 2207 | }
|
---|
| 2208 |
|
---|
| 2209 | template< typename pass_type >
|
---|
| 2210 | Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
|
---|
| 2211 | MUTATE_START( node );
|
---|
| 2212 |
|
---|
| 2213 | indexerAddStruct( node->name );
|
---|
| 2214 |
|
---|
| 2215 | {
|
---|
| 2216 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2217 | maybeMutate_impl( node->forall , *this );
|
---|
| 2218 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2219 | }
|
---|
| 2220 |
|
---|
| 2221 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2222 | }
|
---|
| 2223 |
|
---|
[e0886db] | 2224 | //--------------------------------------------------------------------------
|
---|
| 2225 | // UnionInstType
|
---|
[13932f14] | 2226 | template< typename pass_type >
|
---|
[ab904dc] | 2227 | void PassVisitor< pass_type >::visit( UnionInstType * node ) {
|
---|
[e0886db] | 2228 | VISIT_START( node );
|
---|
| 2229 |
|
---|
| 2230 | indexerAddStruct( node->name );
|
---|
| 2231 |
|
---|
| 2232 | {
|
---|
| 2233 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2234 | maybeAccept_impl( node->forall , *this );
|
---|
| 2235 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2236 | }
|
---|
| 2237 |
|
---|
| 2238 | VISIT_END( node );
|
---|
| 2239 | }
|
---|
| 2240 |
|
---|
| 2241 | template< typename pass_type >
|
---|
| 2242 | Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
|
---|
| 2243 | MUTATE_START( node );
|
---|
| 2244 |
|
---|
| 2245 | indexerAddStruct( node->name );
|
---|
| 2246 |
|
---|
| 2247 | {
|
---|
| 2248 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2249 | maybeMutate_impl( node->forall , *this );
|
---|
| 2250 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2251 | }
|
---|
| 2252 |
|
---|
| 2253 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2254 | }
|
---|
| 2255 |
|
---|
[e0886db] | 2256 | //--------------------------------------------------------------------------
|
---|
| 2257 | // EnumInstType
|
---|
[13932f14] | 2258 | template< typename pass_type >
|
---|
[ab904dc] | 2259 | void PassVisitor< pass_type >::visit( EnumInstType * node ) {
|
---|
[86e84e4] | 2260 | VISIT_START( node );
|
---|
| 2261 |
|
---|
| 2262 | maybeAccept_impl( node->forall, *this );
|
---|
| 2263 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2264 |
|
---|
| 2265 | VISIT_END( node );
|
---|
[13932f14] | 2266 | }
|
---|
| 2267 |
|
---|
[e0886db] | 2268 | template< typename pass_type >
|
---|
| 2269 | Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
|
---|
[86e84e4] | 2270 | MUTATE_START( node );
|
---|
| 2271 |
|
---|
| 2272 | maybeMutate_impl( node->forall, *this );
|
---|
| 2273 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2274 |
|
---|
| 2275 | MUTATE_END( Type, node );
|
---|
[e0886db] | 2276 | }
|
---|
| 2277 |
|
---|
| 2278 | //--------------------------------------------------------------------------
|
---|
| 2279 | // TraitInstType
|
---|
[13932f14] | 2280 | template< typename pass_type >
|
---|
[ab904dc] | 2281 | void PassVisitor< pass_type >::visit( TraitInstType * node ) {
|
---|
[e0886db] | 2282 | VISIT_START( node );
|
---|
| 2283 |
|
---|
[3c398b6] | 2284 | maybeAccept_impl( node->forall , *this );
|
---|
| 2285 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2286 |
|
---|
| 2287 | VISIT_END( node );
|
---|
| 2288 | }
|
---|
| 2289 |
|
---|
| 2290 | template< typename pass_type >
|
---|
| 2291 | Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
|
---|
| 2292 | MUTATE_START( node );
|
---|
| 2293 |
|
---|
[3c398b6] | 2294 | maybeMutate_impl( node->forall , *this );
|
---|
| 2295 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2296 |
|
---|
| 2297 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2298 | }
|
---|
| 2299 |
|
---|
[e0886db] | 2300 | //--------------------------------------------------------------------------
|
---|
| 2301 | // TypeInstType
|
---|
[13932f14] | 2302 | template< typename pass_type >
|
---|
[ab904dc] | 2303 | void PassVisitor< pass_type >::visit( TypeInstType * node ) {
|
---|
[86e84e4] | 2304 | VISIT_START( node );
|
---|
| 2305 |
|
---|
| 2306 | maybeAccept_impl( node->forall , *this );
|
---|
| 2307 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2308 |
|
---|
| 2309 | VISIT_END( node );
|
---|
| 2310 | }
|
---|
| 2311 |
|
---|
| 2312 | template< typename pass_type >
|
---|
| 2313 | Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
|
---|
| 2314 | MUTATE_START( node );
|
---|
| 2315 |
|
---|
| 2316 | maybeMutate_impl( node->forall , *this );
|
---|
| 2317 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2318 |
|
---|
| 2319 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2320 | }
|
---|
| 2321 |
|
---|
[a8a2b0a] | 2322 | //--------------------------------------------------------------------------
|
---|
| 2323 | // TupleType
|
---|
[13932f14] | 2324 | template< typename pass_type >
|
---|
[ab904dc] | 2325 | void PassVisitor< pass_type >::visit( TupleType * node ) {
|
---|
[a8a2b0a] | 2326 | VISIT_START( node );
|
---|
| 2327 |
|
---|
| 2328 | maybeAccept_impl( node->forall, *this );
|
---|
| 2329 | maybeAccept_impl( node->types, *this );
|
---|
| 2330 | maybeAccept_impl( node->members, *this );
|
---|
| 2331 |
|
---|
| 2332 | VISIT_END( node );
|
---|
[13932f14] | 2333 | }
|
---|
| 2334 |
|
---|
[a8a2b0a] | 2335 | template< typename pass_type >
|
---|
| 2336 | Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
|
---|
| 2337 | MUTATE_START( node );
|
---|
| 2338 |
|
---|
| 2339 | maybeMutate_impl( node->forall, *this );
|
---|
| 2340 | maybeMutate_impl( node->types, *this );
|
---|
| 2341 | maybeMutate_impl( node->members, *this );
|
---|
| 2342 |
|
---|
| 2343 | MUTATE_END( Type, node );
|
---|
| 2344 | }
|
---|
| 2345 |
|
---|
| 2346 | //--------------------------------------------------------------------------
|
---|
| 2347 | // TypeofType
|
---|
[13932f14] | 2348 | template< typename pass_type >
|
---|
[ab904dc] | 2349 | void PassVisitor< pass_type >::visit( TypeofType * node ) {
|
---|
[a8a2b0a] | 2350 | VISIT_START( node );
|
---|
| 2351 |
|
---|
| 2352 | assert( node->expr );
|
---|
| 2353 | maybeAccept_impl( node->expr, *this );
|
---|
| 2354 |
|
---|
| 2355 | VISIT_END( node );
|
---|
[13932f14] | 2356 | }
|
---|
| 2357 |
|
---|
[a8a2b0a] | 2358 | template< typename pass_type >
|
---|
| 2359 | Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
|
---|
| 2360 | MUTATE_START( node );
|
---|
| 2361 |
|
---|
| 2362 | assert( node->expr );
|
---|
| 2363 | maybeMutate_impl( node->expr, *this );
|
---|
| 2364 |
|
---|
| 2365 | MUTATE_END( Type, node );
|
---|
| 2366 | }
|
---|
| 2367 |
|
---|
| 2368 | //--------------------------------------------------------------------------
|
---|
| 2369 | // AttrType
|
---|
[13932f14] | 2370 | template< typename pass_type >
|
---|
[ab904dc] | 2371 | void PassVisitor< pass_type >::visit( AttrType * node ) {
|
---|
[a8a2b0a] | 2372 | VISIT_START( node );
|
---|
| 2373 |
|
---|
| 2374 | if ( node->isType ) {
|
---|
| 2375 | assert( node->type );
|
---|
| 2376 | maybeAccept_impl( node->type, *this );
|
---|
| 2377 | } else {
|
---|
| 2378 | assert( node->expr );
|
---|
| 2379 | maybeAccept_impl( node->expr, *this );
|
---|
| 2380 | } // if
|
---|
| 2381 |
|
---|
| 2382 | VISIT_END( node );
|
---|
[13932f14] | 2383 | }
|
---|
| 2384 |
|
---|
[a8a2b0a] | 2385 | template< typename pass_type >
|
---|
| 2386 | Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
|
---|
| 2387 | MUTATE_START( node );
|
---|
| 2388 |
|
---|
| 2389 | if ( node->isType ) {
|
---|
| 2390 | assert( node->type );
|
---|
| 2391 | maybeMutate_impl( node->type, *this );
|
---|
| 2392 | } else {
|
---|
| 2393 | assert( node->expr );
|
---|
| 2394 | maybeMutate_impl( node->expr, *this );
|
---|
| 2395 | } // if
|
---|
| 2396 |
|
---|
| 2397 | MUTATE_END( Type, node );
|
---|
| 2398 | }
|
---|
| 2399 |
|
---|
| 2400 | //--------------------------------------------------------------------------
|
---|
| 2401 | // VarArgsType
|
---|
[13932f14] | 2402 | template< typename pass_type >
|
---|
[ab904dc] | 2403 | void PassVisitor< pass_type >::visit( VarArgsType * node ) {
|
---|
[a8a2b0a] | 2404 | VISIT_START( node );
|
---|
| 2405 |
|
---|
| 2406 | maybeAccept_impl( node->forall, *this );
|
---|
| 2407 |
|
---|
| 2408 | VISIT_END( node );
|
---|
[13932f14] | 2409 | }
|
---|
| 2410 |
|
---|
[a8a2b0a] | 2411 | template< typename pass_type >
|
---|
| 2412 | Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
|
---|
| 2413 | MUTATE_START( node );
|
---|
| 2414 |
|
---|
| 2415 | maybeMutate_impl( node->forall, *this );
|
---|
| 2416 |
|
---|
| 2417 | MUTATE_END( Type, node );
|
---|
| 2418 | }
|
---|
| 2419 |
|
---|
| 2420 | //--------------------------------------------------------------------------
|
---|
| 2421 | // ZeroType
|
---|
[13932f14] | 2422 | template< typename pass_type >
|
---|
[ab904dc] | 2423 | void PassVisitor< pass_type >::visit( ZeroType * node ) {
|
---|
[a8a2b0a] | 2424 | VISIT_START( node );
|
---|
| 2425 |
|
---|
| 2426 | maybeAccept_impl( node->forall, *this );
|
---|
| 2427 |
|
---|
| 2428 | VISIT_END( node );
|
---|
[13932f14] | 2429 | }
|
---|
| 2430 |
|
---|
[a8a2b0a] | 2431 | template< typename pass_type >
|
---|
| 2432 | Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
|
---|
| 2433 | MUTATE_START( node );
|
---|
| 2434 |
|
---|
| 2435 | maybeMutate_impl( node->forall, *this );
|
---|
| 2436 |
|
---|
| 2437 | MUTATE_END( Type, node );
|
---|
| 2438 | }
|
---|
| 2439 |
|
---|
| 2440 | //--------------------------------------------------------------------------
|
---|
| 2441 | // OneType
|
---|
[13932f14] | 2442 | template< typename pass_type >
|
---|
[ab904dc] | 2443 | void PassVisitor< pass_type >::visit( OneType * node ) {
|
---|
[a8a2b0a] | 2444 | VISIT_START( node );
|
---|
| 2445 |
|
---|
| 2446 | maybeAccept_impl( node->forall, *this );
|
---|
| 2447 |
|
---|
| 2448 | VISIT_END( node );
|
---|
[13932f14] | 2449 | }
|
---|
| 2450 |
|
---|
[a8a2b0a] | 2451 | template< typename pass_type >
|
---|
| 2452 | Type * PassVisitor< pass_type >::mutate( OneType * node ) {
|
---|
| 2453 | MUTATE_START( node );
|
---|
| 2454 |
|
---|
| 2455 | maybeMutate_impl( node->forall, *this );
|
---|
| 2456 |
|
---|
| 2457 | MUTATE_END( Type, node );
|
---|
| 2458 | }
|
---|
| 2459 |
|
---|
| 2460 | //--------------------------------------------------------------------------
|
---|
| 2461 | // Designation
|
---|
[b11d8e2] | 2462 | template< typename pass_type >
|
---|
| 2463 | void PassVisitor< pass_type >::visit( Designation * node ) {
|
---|
| 2464 | VISIT_START( node );
|
---|
| 2465 |
|
---|
[a8a2b0a] | 2466 | maybeAccept_impl( node->designators, *this );
|
---|
[b11d8e2] | 2467 |
|
---|
| 2468 | VISIT_END( node );
|
---|
| 2469 | }
|
---|
| 2470 |
|
---|
| 2471 | template< typename pass_type >
|
---|
| 2472 | Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
|
---|
| 2473 | MUTATE_START( node );
|
---|
| 2474 |
|
---|
[a8a2b0a] | 2475 | maybeMutate_impl( node->designators, *this );
|
---|
[b11d8e2] | 2476 |
|
---|
| 2477 | MUTATE_END( Designation, node );
|
---|
| 2478 | }
|
---|
| 2479 |
|
---|
[9c1600c] | 2480 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 2481 | // SingleInit
|
---|
[13932f14] | 2482 | template< typename pass_type >
|
---|
[ab904dc] | 2483 | void PassVisitor< pass_type >::visit( SingleInit * node ) {
|
---|
[9c1600c] | 2484 | VISIT_START( node );
|
---|
| 2485 |
|
---|
[a8a2b0a] | 2486 | visitExpression( node->value );
|
---|
[9c1600c] | 2487 |
|
---|
| 2488 | VISIT_END( node );
|
---|
[13932f14] | 2489 | }
|
---|
| 2490 |
|
---|
[296b2be] | 2491 | template< typename pass_type >
|
---|
| 2492 | Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
|
---|
| 2493 | MUTATE_START( node );
|
---|
| 2494 |
|
---|
[a8a2b0a] | 2495 | node->value = mutateExpression( node->value );
|
---|
[296b2be] | 2496 |
|
---|
| 2497 | MUTATE_END( Initializer, node );
|
---|
| 2498 | }
|
---|
| 2499 |
|
---|
[a8a2b0a] | 2500 | //--------------------------------------------------------------------------
|
---|
| 2501 | // ListInit
|
---|
[13932f14] | 2502 | template< typename pass_type >
|
---|
[ab904dc] | 2503 | void PassVisitor< pass_type >::visit( ListInit * node ) {
|
---|
[a8a2b0a] | 2504 | VISIT_START( node );
|
---|
[13932f14] | 2505 |
|
---|
[a8a2b0a] | 2506 | maybeAccept_impl( node->designations, *this );
|
---|
| 2507 | maybeAccept_impl( node->initializers, *this );
|
---|
[13932f14] | 2508 |
|
---|
[a8a2b0a] | 2509 | VISIT_END( node );
|
---|
[13932f14] | 2510 | }
|
---|
| 2511 |
|
---|
| 2512 | template< typename pass_type >
|
---|
[a8a2b0a] | 2513 | Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
|
---|
| 2514 | MUTATE_START( node );
|
---|
| 2515 |
|
---|
| 2516 | maybeMutate_impl( node->designations, *this );
|
---|
| 2517 | maybeMutate_impl( node->initializers, *this );
|
---|
| 2518 |
|
---|
| 2519 | MUTATE_END( Initializer, node );
|
---|
[13932f14] | 2520 | }
|
---|
[ab904dc] | 2521 |
|
---|
[a8a2b0a] | 2522 | //--------------------------------------------------------------------------
|
---|
| 2523 | // ConstructorInit
|
---|
[5ea7a22] | 2524 | template< typename pass_type >
|
---|
[a8a2b0a] | 2525 | void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
|
---|
| 2526 | VISIT_START( node );
|
---|
[5ea7a22] | 2527 |
|
---|
[a8a2b0a] | 2528 | maybeAccept_impl( node->ctor, *this );
|
---|
| 2529 | maybeAccept_impl( node->dtor, *this );
|
---|
| 2530 | maybeAccept_impl( node->init, *this );
|
---|
[ab904dc] | 2531 |
|
---|
[a8a2b0a] | 2532 | VISIT_END( node );
|
---|
[ab904dc] | 2533 | }
|
---|
| 2534 |
|
---|
| 2535 | template< typename pass_type >
|
---|
[a8a2b0a] | 2536 | Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
|
---|
| 2537 | MUTATE_START( node );
|
---|
[ab904dc] | 2538 |
|
---|
[a8a2b0a] | 2539 | maybeMutate_impl( node->ctor, *this );
|
---|
| 2540 | maybeMutate_impl( node->dtor, *this );
|
---|
| 2541 | maybeMutate_impl( node->init, *this );
|
---|
[ab904dc] | 2542 |
|
---|
[a8a2b0a] | 2543 | MUTATE_END( Initializer, node );
|
---|
[ab904dc] | 2544 | }
|
---|
| 2545 |
|
---|
[a8a2b0a] | 2546 | //--------------------------------------------------------------------------
|
---|
| 2547 | // Subrange
|
---|
[ab904dc] | 2548 | template< typename pass_type >
|
---|
[a8a2b0a] | 2549 | void PassVisitor< pass_type >::visit( Subrange * node ) {
|
---|
| 2550 | VISIT_START( node );
|
---|
[ab904dc] | 2551 |
|
---|
[a8a2b0a] | 2552 | VISIT_END( node );
|
---|
[ab904dc] | 2553 | }
|
---|
| 2554 |
|
---|
| 2555 | template< typename pass_type >
|
---|
[a8a2b0a] | 2556 | Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) {
|
---|
| 2557 | MUTATE_START( node );
|
---|
| 2558 |
|
---|
| 2559 | MUTATE_END( Subrange, node );
|
---|
[ab904dc] | 2560 | }
|
---|
| 2561 |
|
---|
[a8a2b0a] | 2562 | //--------------------------------------------------------------------------
|
---|
| 2563 | // Attribute
|
---|
[ab904dc] | 2564 | template< typename pass_type >
|
---|
[a8a2b0a] | 2565 | void PassVisitor< pass_type >::visit( Constant * node ) {
|
---|
| 2566 | VISIT_START( node );
|
---|
| 2567 |
|
---|
| 2568 | VISIT_END( node );
|
---|
[ab904dc] | 2569 | }
|
---|
| 2570 |
|
---|
| 2571 | template< typename pass_type >
|
---|
[a8a2b0a] | 2572 | Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
|
---|
| 2573 | MUTATE_START( node );
|
---|
| 2574 |
|
---|
| 2575 | MUTATE_END( Constant, node );
|
---|
[ab904dc] | 2576 | }
|
---|
| 2577 |
|
---|
[a8a2b0a] | 2578 | //--------------------------------------------------------------------------
|
---|
| 2579 | // Attribute
|
---|
[ab904dc] | 2580 | template< typename pass_type >
|
---|
[a8a2b0a] | 2581 | void PassVisitor< pass_type >::visit( Attribute * node ) {
|
---|
| 2582 | VISIT_START( node );
|
---|
| 2583 |
|
---|
| 2584 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2585 |
|
---|
| 2586 | VISIT_END( node );
|
---|
[4551a6e] | 2587 | }
|
---|
[5ea7a22] | 2588 |
|
---|
| 2589 | template< typename pass_type >
|
---|
| 2590 | Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
|
---|
[a8a2b0a] | 2591 | MUTATE_START( node );
|
---|
| 2592 |
|
---|
| 2593 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2594 |
|
---|
| 2595 | MUTATE_END( Attribute, node );
|
---|
[5ea7a22] | 2596 | }
|
---|
[447c356] | 2597 |
|
---|
[a8a2b0a] | 2598 | //--------------------------------------------------------------------------
|
---|
| 2599 | // TypeSubstitution
|
---|
[447c356] | 2600 | template< typename pass_type >
|
---|
| 2601 | TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
|
---|
| 2602 | MUTATE_START( node );
|
---|
| 2603 |
|
---|
| 2604 | for ( auto & p : node->typeEnv ) {
|
---|
| 2605 | indexerScopedMutate( p.second, *this );
|
---|
| 2606 | }
|
---|
| 2607 | for ( auto & p : node->varEnv ) {
|
---|
| 2608 | indexerScopedMutate( p.second, *this );
|
---|
| 2609 | }
|
---|
| 2610 |
|
---|
| 2611 | MUTATE_END( TypeSubstitution, node );
|
---|
| 2612 | }
|
---|