[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 | //--------------------------------------------------------------------------
|
---|
| 1261 | // VirtualCastExpr
|
---|
[13932f14] | 1262 | template< typename pass_type >
|
---|
[e0886db] | 1263 | void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
|
---|
| 1264 | VISIT_START( node );
|
---|
| 1265 |
|
---|
| 1266 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1267 | maybeAccept_impl( node->arg, *this );
|
---|
[e0886db] | 1268 |
|
---|
| 1269 | VISIT_END( node );
|
---|
[13932f14] | 1270 | }
|
---|
| 1271 |
|
---|
| 1272 | template< typename pass_type >
|
---|
[e0886db] | 1273 | Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
|
---|
| 1274 | MUTATE_START( node );
|
---|
| 1275 |
|
---|
| 1276 | indexerScopedMutate( node->env , *this );
|
---|
| 1277 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1278 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1279 |
|
---|
| 1280 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1281 | }
|
---|
| 1282 |
|
---|
[e0886db] | 1283 | //--------------------------------------------------------------------------
|
---|
| 1284 | // AddressExpr
|
---|
[13932f14] | 1285 | template< typename pass_type >
|
---|
[e0886db] | 1286 | void PassVisitor< pass_type >::visit( AddressExpr * 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( AddressExpr * 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 );
|
---|
| 1304 | }
|
---|
| 1305 |
|
---|
| 1306 | //--------------------------------------------------------------------------
|
---|
| 1307 | // LabelAddressExpr
|
---|
| 1308 | template< typename pass_type >
|
---|
| 1309 | void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
|
---|
| 1310 | VISIT_START( node );
|
---|
| 1311 |
|
---|
| 1312 | indexerScopedAccept( node->result, *this );
|
---|
| 1313 |
|
---|
| 1314 | VISIT_END( node );
|
---|
| 1315 | }
|
---|
| 1316 |
|
---|
| 1317 | template< typename pass_type >
|
---|
| 1318 | Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
|
---|
| 1319 | MUTATE_START( node );
|
---|
| 1320 |
|
---|
| 1321 | indexerScopedMutate( node->env , *this );
|
---|
| 1322 | indexerScopedMutate( node->result, *this );
|
---|
| 1323 |
|
---|
| 1324 | MUTATE_END( Expression, node );
|
---|
| 1325 | }
|
---|
| 1326 |
|
---|
| 1327 | //--------------------------------------------------------------------------
|
---|
| 1328 | // UntypedMemberExpr
|
---|
| 1329 | template< typename pass_type >
|
---|
| 1330 | void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
|
---|
| 1331 | VISIT_START( node );
|
---|
| 1332 |
|
---|
| 1333 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1334 | maybeAccept_impl ( node->aggregate, *this );
|
---|
| 1335 | maybeAccept_impl ( node->member , *this );
|
---|
[e0886db] | 1336 |
|
---|
| 1337 | VISIT_END( node );
|
---|
[13932f14] | 1338 | }
|
---|
| 1339 |
|
---|
[e0886db] | 1340 | template< typename pass_type >
|
---|
| 1341 | Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
|
---|
| 1342 | MUTATE_START( node );
|
---|
| 1343 |
|
---|
| 1344 | indexerScopedMutate( node->env , *this );
|
---|
| 1345 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1346 | maybeMutate_impl ( node->aggregate, *this );
|
---|
| 1347 | maybeMutate_impl ( node->member , *this );
|
---|
[e0886db] | 1348 |
|
---|
| 1349 | MUTATE_END( Expression, node );
|
---|
| 1350 | }
|
---|
| 1351 |
|
---|
| 1352 | //--------------------------------------------------------------------------
|
---|
| 1353 | // MemberExpr
|
---|
| 1354 | template< typename pass_type >
|
---|
| 1355 | void PassVisitor< pass_type >::visit( MemberExpr * node ) {
|
---|
| 1356 | VISIT_START( node );
|
---|
| 1357 |
|
---|
| 1358 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1359 | maybeAccept_impl ( node->aggregate, *this );
|
---|
[e0886db] | 1360 |
|
---|
| 1361 | VISIT_END( node );
|
---|
| 1362 | }
|
---|
| 1363 |
|
---|
| 1364 | template< typename pass_type >
|
---|
| 1365 | Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
|
---|
| 1366 | MUTATE_START( node );
|
---|
| 1367 |
|
---|
| 1368 | indexerScopedMutate( node->env , *this );
|
---|
| 1369 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1370 | maybeMutate_impl ( node->aggregate, *this );
|
---|
[e0886db] | 1371 |
|
---|
| 1372 | MUTATE_END( Expression, node );
|
---|
| 1373 | }
|
---|
| 1374 |
|
---|
| 1375 | //--------------------------------------------------------------------------
|
---|
| 1376 | // VariableExpr
|
---|
| 1377 | template< typename pass_type >
|
---|
| 1378 | void PassVisitor< pass_type >::visit( VariableExpr * node ) {
|
---|
| 1379 | VISIT_START( node );
|
---|
| 1380 |
|
---|
| 1381 | indexerScopedAccept( node->result, *this );
|
---|
| 1382 |
|
---|
| 1383 | VISIT_END( node );
|
---|
| 1384 | }
|
---|
| 1385 |
|
---|
| 1386 | template< typename pass_type >
|
---|
| 1387 | Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
|
---|
| 1388 | MUTATE_START( node );
|
---|
| 1389 |
|
---|
| 1390 | indexerScopedMutate( node->env , *this );
|
---|
| 1391 | indexerScopedMutate( node->result, *this );
|
---|
| 1392 |
|
---|
| 1393 | MUTATE_END( Expression, node );
|
---|
| 1394 | }
|
---|
| 1395 |
|
---|
| 1396 | //--------------------------------------------------------------------------
|
---|
| 1397 | // ConstantExpr
|
---|
[13932f14] | 1398 | template< typename pass_type >
|
---|
[ab904dc] | 1399 | void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
|
---|
[e0886db] | 1400 | VISIT_START( node );
|
---|
| 1401 |
|
---|
| 1402 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1403 | maybeAccept_impl ( &node->constant, *this );
|
---|
[e0886db] | 1404 |
|
---|
| 1405 | VISIT_END( node );
|
---|
[13932f14] | 1406 | }
|
---|
| 1407 |
|
---|
[e0886db] | 1408 | template< typename pass_type >
|
---|
| 1409 | Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
|
---|
| 1410 | MUTATE_START( node );
|
---|
| 1411 |
|
---|
| 1412 | indexerScopedMutate( node->env , *this );
|
---|
| 1413 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1414 | Constant * ptr = &node->constant;
|
---|
| 1415 | maybeMutate_impl( ptr, *this );
|
---|
| 1416 | node->constant = *ptr;
|
---|
[e0886db] | 1417 |
|
---|
| 1418 | MUTATE_END( Expression, node );
|
---|
| 1419 | }
|
---|
| 1420 |
|
---|
| 1421 | //--------------------------------------------------------------------------
|
---|
| 1422 | // SizeofExpr
|
---|
[13932f14] | 1423 | template< typename pass_type >
|
---|
[ab904dc] | 1424 | void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
|
---|
[e0886db] | 1425 | VISIT_START( node );
|
---|
| 1426 |
|
---|
| 1427 | indexerScopedAccept( node->result, *this );
|
---|
| 1428 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1429 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1430 | } else {
|
---|
[3c398b6] | 1431 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1432 | }
|
---|
| 1433 |
|
---|
| 1434 | VISIT_END( node );
|
---|
[13932f14] | 1435 | }
|
---|
| 1436 |
|
---|
[e0886db] | 1437 | template< typename pass_type >
|
---|
| 1438 | Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
|
---|
| 1439 | MUTATE_START( node );
|
---|
| 1440 |
|
---|
| 1441 | indexerScopedMutate( node->env , *this );
|
---|
| 1442 | indexerScopedMutate( node->result, *this );
|
---|
| 1443 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1444 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1445 | } else {
|
---|
[3c398b6] | 1446 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1447 | }
|
---|
| 1448 |
|
---|
| 1449 | MUTATE_END( Expression, node );
|
---|
| 1450 | }
|
---|
| 1451 |
|
---|
| 1452 | //--------------------------------------------------------------------------
|
---|
| 1453 | // AlignofExpr
|
---|
[13932f14] | 1454 | template< typename pass_type >
|
---|
[ab904dc] | 1455 | void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
|
---|
[e0886db] | 1456 | VISIT_START( node );
|
---|
| 1457 |
|
---|
| 1458 | indexerScopedAccept( node->result, *this );
|
---|
| 1459 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1460 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1461 | } else {
|
---|
[3c398b6] | 1462 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1463 | }
|
---|
| 1464 |
|
---|
| 1465 | VISIT_END( node );
|
---|
[13932f14] | 1466 | }
|
---|
| 1467 |
|
---|
[e0886db] | 1468 | template< typename pass_type >
|
---|
| 1469 | Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
|
---|
| 1470 | MUTATE_START( node );
|
---|
| 1471 |
|
---|
| 1472 | indexerScopedMutate( node->env , *this );
|
---|
| 1473 | indexerScopedMutate( node->result, *this );
|
---|
| 1474 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1475 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1476 | } else {
|
---|
[3c398b6] | 1477 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1478 | }
|
---|
| 1479 |
|
---|
| 1480 | MUTATE_END( Expression, node );
|
---|
| 1481 | }
|
---|
| 1482 |
|
---|
| 1483 | //--------------------------------------------------------------------------
|
---|
| 1484 | // UntypedOffsetofExpr
|
---|
[13932f14] | 1485 | template< typename pass_type >
|
---|
[ab904dc] | 1486 | void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
|
---|
[e0886db] | 1487 | VISIT_START( node );
|
---|
| 1488 |
|
---|
| 1489 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1490 | maybeAccept_impl ( node->type , *this );
|
---|
[e0886db] | 1491 |
|
---|
| 1492 | VISIT_END( node );
|
---|
[13932f14] | 1493 | }
|
---|
| 1494 |
|
---|
[e0886db] | 1495 | template< typename pass_type >
|
---|
| 1496 | Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
|
---|
| 1497 | MUTATE_START( node );
|
---|
| 1498 |
|
---|
| 1499 | indexerScopedMutate( node->env , *this );
|
---|
| 1500 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1501 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1502 |
|
---|
| 1503 | MUTATE_END( Expression, node );
|
---|
| 1504 | }
|
---|
| 1505 |
|
---|
| 1506 | //--------------------------------------------------------------------------
|
---|
| 1507 | // OffsetofExpr
|
---|
[13932f14] | 1508 | template< typename pass_type >
|
---|
[ab904dc] | 1509 | void PassVisitor< pass_type >::visit( OffsetofExpr * 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( OffsetofExpr * 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 | // OffsetPackExpr
|
---|
[13932f14] | 1531 | template< typename pass_type >
|
---|
[ab904dc] | 1532 | void PassVisitor< pass_type >::visit( OffsetPackExpr * 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( OffsetPackExpr * 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 | // AttrExpr
|
---|
[13932f14] | 1554 | template< typename pass_type >
|
---|
[ab904dc] | 1555 | void PassVisitor< pass_type >::visit( AttrExpr * node ) {
|
---|
[e0886db] | 1556 | VISIT_START( node );
|
---|
| 1557 |
|
---|
| 1558 | indexerScopedAccept( node->result, *this );
|
---|
| 1559 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1560 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1561 | } else {
|
---|
[3c398b6] | 1562 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1563 | }
|
---|
| 1564 |
|
---|
| 1565 | VISIT_END( node );
|
---|
| 1566 | }
|
---|
| 1567 |
|
---|
| 1568 | template< typename pass_type >
|
---|
| 1569 | Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
|
---|
| 1570 | MUTATE_START( node );
|
---|
| 1571 |
|
---|
| 1572 | indexerScopedMutate( node->env , *this );
|
---|
| 1573 | indexerScopedMutate( node->result, *this );
|
---|
| 1574 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1575 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1576 | } else {
|
---|
[3c398b6] | 1577 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1578 | }
|
---|
| 1579 |
|
---|
| 1580 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1581 | }
|
---|
| 1582 |
|
---|
[e0886db] | 1583 | //--------------------------------------------------------------------------
|
---|
| 1584 | // LogicalExpr
|
---|
[13932f14] | 1585 | template< typename pass_type >
|
---|
[ab904dc] | 1586 | void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
|
---|
[e0886db] | 1587 | VISIT_START( node );
|
---|
| 1588 |
|
---|
| 1589 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1590 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1591 | maybeAccept_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1592 |
|
---|
| 1593 | VISIT_END( node );
|
---|
| 1594 | }
|
---|
| 1595 |
|
---|
| 1596 | template< typename pass_type >
|
---|
| 1597 | Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
|
---|
| 1598 | MUTATE_START( node );
|
---|
| 1599 |
|
---|
| 1600 | indexerScopedMutate( node->env , *this );
|
---|
| 1601 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1602 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1603 | maybeMutate_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1604 |
|
---|
| 1605 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1606 | }
|
---|
| 1607 |
|
---|
[e0886db] | 1608 | //--------------------------------------------------------------------------
|
---|
| 1609 | // ConditionalExpr
|
---|
[13932f14] | 1610 | template< typename pass_type >
|
---|
[ab904dc] | 1611 | void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
|
---|
[e0886db] | 1612 | VISIT_START( node );
|
---|
| 1613 |
|
---|
| 1614 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1615 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1616 | maybeAccept_impl ( node->arg2 , *this );
|
---|
| 1617 | maybeAccept_impl ( node->arg3 , *this );
|
---|
[e0886db] | 1618 |
|
---|
| 1619 | VISIT_END( node );
|
---|
[13932f14] | 1620 | }
|
---|
| 1621 |
|
---|
[e0886db] | 1622 | template< typename pass_type >
|
---|
| 1623 | Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
|
---|
| 1624 | MUTATE_START( node );
|
---|
| 1625 |
|
---|
| 1626 | indexerScopedMutate( node->env , *this );
|
---|
| 1627 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1628 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1629 | maybeMutate_impl ( node->arg2 , *this );
|
---|
| 1630 | maybeMutate_impl ( node->arg3 , *this );
|
---|
[e0886db] | 1631 |
|
---|
| 1632 | MUTATE_END( Expression, node );
|
---|
| 1633 | }
|
---|
| 1634 |
|
---|
| 1635 | //--------------------------------------------------------------------------
|
---|
| 1636 | // CommaExpr
|
---|
[13932f14] | 1637 | template< typename pass_type >
|
---|
[ab904dc] | 1638 | void PassVisitor< pass_type >::visit( CommaExpr * node ) {
|
---|
[e0886db] | 1639 | VISIT_START( node );
|
---|
| 1640 |
|
---|
| 1641 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1642 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1643 | maybeAccept_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1644 |
|
---|
| 1645 | VISIT_END( node );
|
---|
| 1646 | }
|
---|
| 1647 |
|
---|
| 1648 | template< typename pass_type >
|
---|
| 1649 | Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
|
---|
| 1650 | MUTATE_START( node );
|
---|
| 1651 |
|
---|
| 1652 | indexerScopedMutate( node->env , *this );
|
---|
| 1653 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1654 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1655 | maybeMutate_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1656 |
|
---|
| 1657 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1658 | }
|
---|
| 1659 |
|
---|
[e0886db] | 1660 | //--------------------------------------------------------------------------
|
---|
| 1661 | // TypeExpr
|
---|
[13932f14] | 1662 | template< typename pass_type >
|
---|
[ab904dc] | 1663 | void PassVisitor< pass_type >::visit( TypeExpr * node ) {
|
---|
[e0886db] | 1664 | VISIT_START( node );
|
---|
| 1665 |
|
---|
| 1666 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1667 | maybeAccept_impl ( node->type, *this );
|
---|
[e0886db] | 1668 |
|
---|
| 1669 | VISIT_END( node );
|
---|
[13932f14] | 1670 | }
|
---|
| 1671 |
|
---|
[e0886db] | 1672 | template< typename pass_type >
|
---|
| 1673 | Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
|
---|
| 1674 | MUTATE_START( node );
|
---|
| 1675 |
|
---|
| 1676 | indexerScopedMutate( node->env , *this );
|
---|
| 1677 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1678 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1679 |
|
---|
| 1680 | MUTATE_END( Expression, node );
|
---|
| 1681 | }
|
---|
| 1682 |
|
---|
| 1683 | //--------------------------------------------------------------------------
|
---|
| 1684 | // AsmExpr
|
---|
[13932f14] | 1685 | template< typename pass_type >
|
---|
[ab904dc] | 1686 | void PassVisitor< pass_type >::visit( AsmExpr * node ) {
|
---|
[e0886db] | 1687 | VISIT_START( node );
|
---|
| 1688 |
|
---|
| 1689 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1690 | maybeAccept_impl ( node->inout , *this );
|
---|
| 1691 | maybeAccept_impl ( node->constraint, *this );
|
---|
| 1692 | maybeAccept_impl ( node->operand , *this );
|
---|
[e0886db] | 1693 |
|
---|
| 1694 | VISIT_END( node );
|
---|
[13932f14] | 1695 | }
|
---|
| 1696 |
|
---|
[e0886db] | 1697 | template< typename pass_type >
|
---|
| 1698 | Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
|
---|
| 1699 | MUTATE_START( node );
|
---|
| 1700 |
|
---|
| 1701 | indexerScopedMutate( node->env , *this );
|
---|
| 1702 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1703 | maybeMutate_impl ( node->inout , *this );
|
---|
| 1704 | maybeMutate_impl ( node->constraint, *this );
|
---|
| 1705 | maybeMutate_impl ( node->operand , *this );
|
---|
[e0886db] | 1706 |
|
---|
| 1707 | MUTATE_END( Expression, node );
|
---|
| 1708 | }
|
---|
| 1709 |
|
---|
| 1710 | //--------------------------------------------------------------------------
|
---|
| 1711 | // ImplicitCopyCtorExpr
|
---|
[13932f14] | 1712 | template< typename pass_type >
|
---|
[ab904dc] | 1713 | void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
|
---|
[e0886db] | 1714 | VISIT_START( node );
|
---|
| 1715 |
|
---|
| 1716 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1717 | maybeAccept_impl ( node->callExpr , *this );
|
---|
| 1718 | maybeAccept_impl ( node->tempDecls , *this );
|
---|
| 1719 | maybeAccept_impl ( node->returnDecls, *this );
|
---|
| 1720 | maybeAccept_impl ( node->dtors , *this );
|
---|
[e0886db] | 1721 |
|
---|
| 1722 | VISIT_END( node );
|
---|
| 1723 | }
|
---|
| 1724 |
|
---|
| 1725 | template< typename pass_type >
|
---|
| 1726 | Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
|
---|
| 1727 | MUTATE_START( node );
|
---|
| 1728 |
|
---|
| 1729 | indexerScopedMutate( node->env , *this );
|
---|
| 1730 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1731 | maybeMutate_impl ( node->callExpr , *this );
|
---|
| 1732 | maybeMutate_impl ( node->tempDecls , *this );
|
---|
| 1733 | maybeMutate_impl ( node->returnDecls, *this );
|
---|
| 1734 | maybeMutate_impl ( node->dtors , *this );
|
---|
[e0886db] | 1735 |
|
---|
| 1736 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1737 | }
|
---|
| 1738 |
|
---|
[e0886db] | 1739 | //--------------------------------------------------------------------------
|
---|
| 1740 | // ConstructorExpr
|
---|
[13932f14] | 1741 | template< typename pass_type >
|
---|
[ab904dc] | 1742 | void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
|
---|
[e0886db] | 1743 | VISIT_START( node );
|
---|
| 1744 |
|
---|
| 1745 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1746 | maybeAccept_impl ( node->callExpr, *this );
|
---|
[e0886db] | 1747 |
|
---|
| 1748 | VISIT_END( node );
|
---|
| 1749 | }
|
---|
| 1750 |
|
---|
| 1751 | template< typename pass_type >
|
---|
| 1752 | Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
|
---|
| 1753 | MUTATE_START( node );
|
---|
| 1754 |
|
---|
| 1755 | indexerScopedMutate( node->env , *this );
|
---|
| 1756 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1757 | maybeMutate_impl ( node->callExpr, *this );
|
---|
[e0886db] | 1758 |
|
---|
| 1759 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1760 | }
|
---|
| 1761 |
|
---|
[e0886db] | 1762 | //--------------------------------------------------------------------------
|
---|
| 1763 | // CompoundLiteralExpr
|
---|
[13932f14] | 1764 | template< typename pass_type >
|
---|
[ab904dc] | 1765 | void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
|
---|
[e0886db] | 1766 | VISIT_START( node );
|
---|
| 1767 |
|
---|
| 1768 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1769 | maybeAccept_impl ( node->initializer, *this );
|
---|
[e0886db] | 1770 |
|
---|
| 1771 | VISIT_END( node );
|
---|
[13932f14] | 1772 | }
|
---|
| 1773 |
|
---|
[e0886db] | 1774 | template< typename pass_type >
|
---|
| 1775 | Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
|
---|
| 1776 | MUTATE_START( node );
|
---|
| 1777 |
|
---|
| 1778 | indexerScopedMutate( node->env , *this );
|
---|
| 1779 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1780 | maybeMutate_impl ( node->initializer, *this );
|
---|
[e0886db] | 1781 |
|
---|
| 1782 | MUTATE_END( Expression, node );
|
---|
| 1783 | }
|
---|
| 1784 |
|
---|
| 1785 | //--------------------------------------------------------------------------
|
---|
| 1786 | // RangeExpr
|
---|
[13932f14] | 1787 | template< typename pass_type >
|
---|
[ab904dc] | 1788 | void PassVisitor< pass_type >::visit( RangeExpr * node ) {
|
---|
[e0886db] | 1789 | VISIT_START( node );
|
---|
| 1790 |
|
---|
| 1791 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1792 | maybeAccept_impl ( node->low , *this );
|
---|
| 1793 | maybeAccept_impl ( node->high , *this );
|
---|
[e0886db] | 1794 |
|
---|
| 1795 | VISIT_END( node );
|
---|
[13932f14] | 1796 | }
|
---|
| 1797 |
|
---|
[e0886db] | 1798 | template< typename pass_type >
|
---|
| 1799 | Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
|
---|
| 1800 | MUTATE_START( node );
|
---|
| 1801 |
|
---|
| 1802 | indexerScopedMutate( node->env , *this );
|
---|
| 1803 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1804 | maybeMutate_impl ( node->low , *this );
|
---|
| 1805 | maybeMutate_impl ( node->high , *this );
|
---|
[e0886db] | 1806 |
|
---|
| 1807 | MUTATE_END( Expression, node );
|
---|
| 1808 | }
|
---|
| 1809 |
|
---|
| 1810 | //--------------------------------------------------------------------------
|
---|
| 1811 | // UntypedTupleExpr
|
---|
[13932f14] | 1812 | template< typename pass_type >
|
---|
[ab904dc] | 1813 | void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
|
---|
[e0886db] | 1814 | VISIT_START( node );
|
---|
| 1815 |
|
---|
| 1816 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1817 | maybeAccept_impl ( node->exprs , *this );
|
---|
[e0886db] | 1818 |
|
---|
| 1819 | VISIT_END( node );
|
---|
| 1820 | }
|
---|
| 1821 |
|
---|
| 1822 | template< typename pass_type >
|
---|
| 1823 | Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
|
---|
| 1824 | MUTATE_START( node );
|
---|
| 1825 |
|
---|
| 1826 | indexerScopedMutate( node->env , *this );
|
---|
| 1827 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1828 | maybeMutate_impl ( node->exprs , *this );
|
---|
[e0886db] | 1829 |
|
---|
| 1830 | MUTATE_END( Expression, node );
|
---|
| 1831 | }
|
---|
| 1832 |
|
---|
| 1833 | //--------------------------------------------------------------------------
|
---|
| 1834 | // TupleExpr
|
---|
| 1835 | template< typename pass_type >
|
---|
| 1836 | void PassVisitor< pass_type >::visit( TupleExpr * node ) {
|
---|
| 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( TupleExpr * 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 | // TupleIndexExpr
|
---|
| 1858 | template< typename pass_type >
|
---|
| 1859 | void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
|
---|
| 1860 | VISIT_START( node );
|
---|
| 1861 |
|
---|
| 1862 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1863 | maybeAccept_impl ( node->tuple , *this );
|
---|
[e0886db] | 1864 |
|
---|
| 1865 | VISIT_END( node );
|
---|
| 1866 | }
|
---|
| 1867 |
|
---|
| 1868 | template< typename pass_type >
|
---|
| 1869 | Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
|
---|
| 1870 | MUTATE_START( node );
|
---|
| 1871 |
|
---|
| 1872 | indexerScopedMutate( node->env , *this );
|
---|
| 1873 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1874 | maybeMutate_impl ( node->tuple , *this );
|
---|
[e0886db] | 1875 |
|
---|
| 1876 | MUTATE_END( Expression, node );
|
---|
| 1877 | }
|
---|
| 1878 |
|
---|
| 1879 | //--------------------------------------------------------------------------
|
---|
| 1880 | // TupleAssignExpr
|
---|
| 1881 | template< typename pass_type >
|
---|
| 1882 | void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
|
---|
| 1883 | VISIT_START( node );
|
---|
| 1884 |
|
---|
| 1885 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1886 | maybeAccept_impl ( node->stmtExpr, *this );
|
---|
[e0886db] | 1887 |
|
---|
| 1888 | VISIT_END( node );
|
---|
[13932f14] | 1889 | }
|
---|
| 1890 |
|
---|
| 1891 | template< typename pass_type >
|
---|
[e0886db] | 1892 | Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
|
---|
| 1893 | MUTATE_START( node );
|
---|
[13932f14] | 1894 |
|
---|
[e0886db] | 1895 | indexerScopedMutate( node->env , *this );
|
---|
| 1896 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1897 | maybeMutate_impl ( node->stmtExpr, *this );
|
---|
[13932f14] | 1898 |
|
---|
[e0886db] | 1899 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1900 | }
|
---|
| 1901 |
|
---|
[9c1600c] | 1902 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 1903 | // StmtExpr
|
---|
[13932f14] | 1904 | template< typename pass_type >
|
---|
[ab904dc] | 1905 | void PassVisitor< pass_type >::visit( StmtExpr * node ) {
|
---|
[9c1600c] | 1906 | VISIT_START( node );
|
---|
| 1907 |
|
---|
| 1908 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
---|
| 1909 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
---|
| 1910 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
---|
| 1911 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
---|
| 1912 |
|
---|
[e0886db] | 1913 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1914 | maybeAccept_impl ( node->statements , *this );
|
---|
| 1915 | maybeAccept_impl ( node->returnDecls, *this );
|
---|
| 1916 | maybeAccept_impl ( node->dtors , *this );
|
---|
[9c1600c] | 1917 |
|
---|
| 1918 | VISIT_END( node );
|
---|
[13932f14] | 1919 | }
|
---|
| 1920 |
|
---|
[296b2be] | 1921 | template< typename pass_type >
|
---|
| 1922 | Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
|
---|
| 1923 | MUTATE_START( node );
|
---|
[4551a6e] | 1924 |
|
---|
[296b2be] | 1925 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
---|
[134322e] | 1926 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
---|
| 1927 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
---|
| 1928 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
---|
[296b2be] | 1929 |
|
---|
[e0886db] | 1930 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1931 | maybeMutate_impl ( node->statements , *this );
|
---|
| 1932 | maybeMutate_impl ( node->returnDecls, *this );
|
---|
| 1933 | maybeMutate_impl ( node->dtors , *this );
|
---|
[296b2be] | 1934 |
|
---|
| 1935 | MUTATE_END( Expression, node );
|
---|
| 1936 | }
|
---|
| 1937 |
|
---|
[e0886db] | 1938 | //--------------------------------------------------------------------------
|
---|
| 1939 | // UniqueExpr
|
---|
[13932f14] | 1940 | template< typename pass_type >
|
---|
[ab904dc] | 1941 | void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
|
---|
[e0886db] | 1942 | VISIT_START( node );
|
---|
| 1943 |
|
---|
| 1944 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1945 | maybeAccept_impl ( node->expr , *this );
|
---|
[e0886db] | 1946 |
|
---|
| 1947 | VISIT_END( node );
|
---|
| 1948 | }
|
---|
| 1949 |
|
---|
| 1950 | template< typename pass_type >
|
---|
| 1951 | Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
|
---|
| 1952 | MUTATE_START( node );
|
---|
| 1953 |
|
---|
| 1954 | indexerScopedMutate( node->env , *this );
|
---|
| 1955 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1956 | maybeMutate_impl ( node->expr , *this );
|
---|
[e0886db] | 1957 |
|
---|
| 1958 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1959 | }
|
---|
| 1960 |
|
---|
[73367a8] | 1961 | //--------------------------------------------------------------------------
|
---|
| 1962 | // UntypedInitExpr
|
---|
| 1963 | template< typename pass_type >
|
---|
| 1964 | void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
|
---|
| 1965 | VISIT_START( node );
|
---|
| 1966 |
|
---|
| 1967 | indexerScopedAccept( node->result, *this );
|
---|
| 1968 | maybeAccept_impl ( node->expr , *this );
|
---|
| 1969 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
| 1970 |
|
---|
| 1971 | VISIT_END( node );
|
---|
| 1972 | }
|
---|
| 1973 |
|
---|
| 1974 | template< typename pass_type >
|
---|
| 1975 | Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
|
---|
| 1976 | MUTATE_START( node );
|
---|
| 1977 |
|
---|
| 1978 | indexerScopedMutate( node->env , *this );
|
---|
| 1979 | indexerScopedMutate( node->result, *this );
|
---|
| 1980 | maybeMutate_impl ( node->expr , *this );
|
---|
| 1981 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
| 1982 |
|
---|
| 1983 | MUTATE_END( Expression, node );
|
---|
| 1984 | }
|
---|
| 1985 |
|
---|
| 1986 | //--------------------------------------------------------------------------
|
---|
| 1987 | // InitExpr
|
---|
| 1988 | template< typename pass_type >
|
---|
| 1989 | void PassVisitor< pass_type >::visit( InitExpr * node ) {
|
---|
| 1990 | VISIT_START( node );
|
---|
| 1991 |
|
---|
| 1992 | indexerScopedAccept( node->result, *this );
|
---|
| 1993 | maybeAccept_impl ( node->expr , *this );
|
---|
| 1994 | maybeAccept_impl ( node->designation, *this );
|
---|
| 1995 |
|
---|
| 1996 | VISIT_END( node );
|
---|
| 1997 | }
|
---|
| 1998 |
|
---|
| 1999 | template< typename pass_type >
|
---|
| 2000 | Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
|
---|
| 2001 | MUTATE_START( node );
|
---|
| 2002 |
|
---|
| 2003 | indexerScopedMutate( node->env , *this );
|
---|
| 2004 | indexerScopedMutate( node->result, *this );
|
---|
| 2005 | maybeMutate_impl ( node->expr , *this );
|
---|
| 2006 | maybeMutate_impl ( node->designation, *this );
|
---|
| 2007 |
|
---|
| 2008 | MUTATE_END( Expression, node );
|
---|
| 2009 | }
|
---|
| 2010 |
|
---|
[44b4114] | 2011 | //--------------------------------------------------------------------------
|
---|
| 2012 | // DeletedExpr
|
---|
| 2013 | template< typename pass_type >
|
---|
| 2014 | void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
|
---|
| 2015 | VISIT_START( node );
|
---|
| 2016 |
|
---|
| 2017 | indexerScopedAccept( node->result, *this );
|
---|
| 2018 | maybeAccept_impl( node->expr, *this );
|
---|
| 2019 | // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
|
---|
| 2020 |
|
---|
| 2021 | VISIT_END( node );
|
---|
| 2022 | }
|
---|
| 2023 |
|
---|
| 2024 | template< typename pass_type >
|
---|
| 2025 | Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
|
---|
| 2026 | MUTATE_START( node );
|
---|
| 2027 |
|
---|
| 2028 | indexerScopedMutate( node->env, *this );
|
---|
| 2029 | indexerScopedMutate( node->result, *this );
|
---|
| 2030 | maybeMutate_impl( node->expr, *this );
|
---|
| 2031 |
|
---|
| 2032 | MUTATE_END( Expression, node );
|
---|
| 2033 | }
|
---|
| 2034 |
|
---|
[17fc7a5] | 2035 | //--------------------------------------------------------------------------
|
---|
| 2036 | // VoidType
|
---|
[13932f14] | 2037 | template< typename pass_type >
|
---|
[ab904dc] | 2038 | void PassVisitor< pass_type >::visit( VoidType * node ) {
|
---|
[599fbb6] | 2039 | VISIT_START( node );
|
---|
| 2040 |
|
---|
| 2041 | maybeAccept_impl( node->forall, *this );
|
---|
| 2042 |
|
---|
| 2043 | VISIT_END( node );
|
---|
| 2044 | }
|
---|
| 2045 |
|
---|
| 2046 | template< typename pass_type >
|
---|
| 2047 | Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
|
---|
| 2048 | MUTATE_START( node );
|
---|
| 2049 |
|
---|
| 2050 | maybeMutate_impl( node->forall, *this );
|
---|
| 2051 |
|
---|
| 2052 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2053 | }
|
---|
| 2054 |
|
---|
[17fc7a5] | 2055 | //--------------------------------------------------------------------------
|
---|
| 2056 | // BasicType
|
---|
[13932f14] | 2057 | template< typename pass_type >
|
---|
[ab904dc] | 2058 | void PassVisitor< pass_type >::visit( BasicType * node ) {
|
---|
[17fc7a5] | 2059 | VISIT_START( node );
|
---|
| 2060 |
|
---|
| 2061 | maybeAccept_impl( node->forall, *this );
|
---|
| 2062 |
|
---|
| 2063 | VISIT_END( node );
|
---|
| 2064 | }
|
---|
| 2065 |
|
---|
| 2066 | template< typename pass_type >
|
---|
| 2067 | Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
|
---|
| 2068 | MUTATE_START( node );
|
---|
| 2069 |
|
---|
| 2070 | maybeMutate_impl( node->forall, *this );
|
---|
| 2071 |
|
---|
| 2072 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2073 | }
|
---|
| 2074 |
|
---|
[17fc7a5] | 2075 | //--------------------------------------------------------------------------
|
---|
| 2076 | // PointerType
|
---|
[13932f14] | 2077 | template< typename pass_type >
|
---|
[ab904dc] | 2078 | void PassVisitor< pass_type >::visit( PointerType * node ) {
|
---|
[17fc7a5] | 2079 | VISIT_START( node );
|
---|
| 2080 |
|
---|
| 2081 | maybeAccept_impl( node->forall, *this );
|
---|
[cfaf9be] | 2082 | // xxx - should PointerType visit/mutate dimension?
|
---|
[17fc7a5] | 2083 | maybeAccept_impl( node->base, *this );
|
---|
| 2084 |
|
---|
| 2085 | VISIT_END( node );
|
---|
[13932f14] | 2086 | }
|
---|
| 2087 |
|
---|
[17fc7a5] | 2088 | template< typename pass_type >
|
---|
| 2089 | Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
|
---|
| 2090 | MUTATE_START( node );
|
---|
| 2091 |
|
---|
| 2092 | maybeMutate_impl( node->forall, *this );
|
---|
[cfaf9be] | 2093 | // xxx - should PointerType visit/mutate dimension?
|
---|
[17fc7a5] | 2094 | maybeMutate_impl( node->base, *this );
|
---|
| 2095 |
|
---|
| 2096 | MUTATE_END( Type, node );
|
---|
| 2097 | }
|
---|
| 2098 |
|
---|
| 2099 | //--------------------------------------------------------------------------
|
---|
| 2100 | // ArrayType
|
---|
[13932f14] | 2101 | template< typename pass_type >
|
---|
[ab904dc] | 2102 | void PassVisitor< pass_type >::visit( ArrayType * node ) {
|
---|
[17fc7a5] | 2103 | VISIT_START( node );
|
---|
| 2104 |
|
---|
| 2105 | maybeAccept_impl( node->forall, *this );
|
---|
| 2106 | maybeAccept_impl( node->dimension, *this );
|
---|
| 2107 | maybeAccept_impl( node->base, *this );
|
---|
| 2108 |
|
---|
| 2109 | VISIT_END( node );
|
---|
[13932f14] | 2110 | }
|
---|
| 2111 |
|
---|
[17fc7a5] | 2112 | template< typename pass_type >
|
---|
| 2113 | Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
|
---|
| 2114 | MUTATE_START( node );
|
---|
| 2115 |
|
---|
| 2116 | maybeMutate_impl( node->forall, *this );
|
---|
| 2117 | maybeMutate_impl( node->dimension, *this );
|
---|
| 2118 | maybeMutate_impl( node->base, *this );
|
---|
| 2119 |
|
---|
| 2120 | MUTATE_END( Type, node );
|
---|
| 2121 | }
|
---|
| 2122 |
|
---|
| 2123 | //--------------------------------------------------------------------------
|
---|
| 2124 | // ReferenceType
|
---|
[6b9b047] | 2125 | template< typename pass_type >
|
---|
| 2126 | void PassVisitor< pass_type >::visit( ReferenceType * node ) {
|
---|
[17fc7a5] | 2127 | VISIT_START( node );
|
---|
| 2128 |
|
---|
| 2129 | maybeAccept_impl( node->forall, *this );
|
---|
| 2130 | maybeAccept_impl( node->base, *this );
|
---|
| 2131 |
|
---|
| 2132 | VISIT_END( node );
|
---|
| 2133 | }
|
---|
| 2134 |
|
---|
| 2135 | template< typename pass_type >
|
---|
| 2136 | Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
|
---|
| 2137 | MUTATE_START( node );
|
---|
| 2138 |
|
---|
| 2139 | maybeMutate_impl( node->forall, *this );
|
---|
| 2140 | maybeMutate_impl( node->base, *this );
|
---|
| 2141 |
|
---|
| 2142 | MUTATE_END( Type, node );
|
---|
[6b9b047] | 2143 | }
|
---|
| 2144 |
|
---|
[17fc7a5] | 2145 | //--------------------------------------------------------------------------
|
---|
| 2146 | // FunctionType
|
---|
[13932f14] | 2147 | template< typename pass_type >
|
---|
[ab904dc] | 2148 | void PassVisitor< pass_type >::visit( FunctionType * node ) {
|
---|
[17fc7a5] | 2149 | VISIT_START( node );
|
---|
| 2150 |
|
---|
| 2151 | maybeAccept_impl( node->forall, *this );
|
---|
| 2152 | maybeAccept_impl( node->returnVals, *this );
|
---|
| 2153 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2154 |
|
---|
| 2155 | VISIT_END( node );
|
---|
| 2156 | }
|
---|
| 2157 |
|
---|
| 2158 | template< typename pass_type >
|
---|
| 2159 | Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
|
---|
| 2160 | MUTATE_START( node );
|
---|
| 2161 |
|
---|
| 2162 | maybeMutate_impl( node->forall, *this );
|
---|
| 2163 | maybeMutate_impl( node->returnVals, *this );
|
---|
| 2164 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2165 |
|
---|
| 2166 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2167 | }
|
---|
| 2168 |
|
---|
[e0886db] | 2169 | //--------------------------------------------------------------------------
|
---|
| 2170 | // StructInstType
|
---|
[13932f14] | 2171 | template< typename pass_type >
|
---|
[ab904dc] | 2172 | void PassVisitor< pass_type >::visit( StructInstType * node ) {
|
---|
[e0886db] | 2173 | VISIT_START( node );
|
---|
| 2174 |
|
---|
| 2175 | indexerAddStruct( node->name );
|
---|
| 2176 |
|
---|
| 2177 | {
|
---|
| 2178 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2179 | maybeAccept_impl( node->forall , *this );
|
---|
| 2180 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2181 | }
|
---|
| 2182 |
|
---|
| 2183 | VISIT_END( node );
|
---|
| 2184 | }
|
---|
| 2185 |
|
---|
| 2186 | template< typename pass_type >
|
---|
| 2187 | Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
|
---|
| 2188 | MUTATE_START( node );
|
---|
| 2189 |
|
---|
| 2190 | indexerAddStruct( node->name );
|
---|
| 2191 |
|
---|
| 2192 | {
|
---|
| 2193 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2194 | maybeMutate_impl( node->forall , *this );
|
---|
| 2195 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2196 | }
|
---|
| 2197 |
|
---|
| 2198 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2199 | }
|
---|
| 2200 |
|
---|
[e0886db] | 2201 | //--------------------------------------------------------------------------
|
---|
| 2202 | // UnionInstType
|
---|
[13932f14] | 2203 | template< typename pass_type >
|
---|
[ab904dc] | 2204 | void PassVisitor< pass_type >::visit( UnionInstType * node ) {
|
---|
[e0886db] | 2205 | VISIT_START( node );
|
---|
| 2206 |
|
---|
| 2207 | indexerAddStruct( node->name );
|
---|
| 2208 |
|
---|
| 2209 | {
|
---|
| 2210 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2211 | maybeAccept_impl( node->forall , *this );
|
---|
| 2212 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2213 | }
|
---|
| 2214 |
|
---|
| 2215 | VISIT_END( node );
|
---|
| 2216 | }
|
---|
| 2217 |
|
---|
| 2218 | template< typename pass_type >
|
---|
| 2219 | Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
|
---|
| 2220 | MUTATE_START( node );
|
---|
| 2221 |
|
---|
| 2222 | indexerAddStruct( node->name );
|
---|
| 2223 |
|
---|
| 2224 | {
|
---|
| 2225 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2226 | maybeMutate_impl( node->forall , *this );
|
---|
| 2227 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2228 | }
|
---|
| 2229 |
|
---|
| 2230 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2231 | }
|
---|
| 2232 |
|
---|
[e0886db] | 2233 | //--------------------------------------------------------------------------
|
---|
| 2234 | // EnumInstType
|
---|
[13932f14] | 2235 | template< typename pass_type >
|
---|
[ab904dc] | 2236 | void PassVisitor< pass_type >::visit( EnumInstType * node ) {
|
---|
[86e84e4] | 2237 | VISIT_START( node );
|
---|
| 2238 |
|
---|
| 2239 | maybeAccept_impl( node->forall, *this );
|
---|
| 2240 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2241 |
|
---|
| 2242 | VISIT_END( node );
|
---|
[13932f14] | 2243 | }
|
---|
| 2244 |
|
---|
[e0886db] | 2245 | template< typename pass_type >
|
---|
| 2246 | Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
|
---|
[86e84e4] | 2247 | MUTATE_START( node );
|
---|
| 2248 |
|
---|
| 2249 | maybeMutate_impl( node->forall, *this );
|
---|
| 2250 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2251 |
|
---|
| 2252 | MUTATE_END( Type, node );
|
---|
[e0886db] | 2253 | }
|
---|
| 2254 |
|
---|
| 2255 | //--------------------------------------------------------------------------
|
---|
| 2256 | // TraitInstType
|
---|
[13932f14] | 2257 | template< typename pass_type >
|
---|
[ab904dc] | 2258 | void PassVisitor< pass_type >::visit( TraitInstType * node ) {
|
---|
[e0886db] | 2259 | VISIT_START( node );
|
---|
| 2260 |
|
---|
[3c398b6] | 2261 | maybeAccept_impl( node->forall , *this );
|
---|
| 2262 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2263 |
|
---|
| 2264 | VISIT_END( node );
|
---|
| 2265 | }
|
---|
| 2266 |
|
---|
| 2267 | template< typename pass_type >
|
---|
| 2268 | Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
|
---|
| 2269 | MUTATE_START( node );
|
---|
| 2270 |
|
---|
[3c398b6] | 2271 | maybeMutate_impl( node->forall , *this );
|
---|
| 2272 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2273 |
|
---|
| 2274 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2275 | }
|
---|
| 2276 |
|
---|
[e0886db] | 2277 | //--------------------------------------------------------------------------
|
---|
| 2278 | // TypeInstType
|
---|
[13932f14] | 2279 | template< typename pass_type >
|
---|
[ab904dc] | 2280 | void PassVisitor< pass_type >::visit( TypeInstType * node ) {
|
---|
[86e84e4] | 2281 | VISIT_START( node );
|
---|
| 2282 |
|
---|
| 2283 | maybeAccept_impl( node->forall , *this );
|
---|
| 2284 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2285 |
|
---|
| 2286 | VISIT_END( node );
|
---|
| 2287 | }
|
---|
| 2288 |
|
---|
| 2289 | template< typename pass_type >
|
---|
| 2290 | Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
|
---|
| 2291 | MUTATE_START( node );
|
---|
| 2292 |
|
---|
| 2293 | maybeMutate_impl( node->forall , *this );
|
---|
| 2294 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2295 |
|
---|
| 2296 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2297 | }
|
---|
| 2298 |
|
---|
[a8a2b0a] | 2299 | //--------------------------------------------------------------------------
|
---|
| 2300 | // TupleType
|
---|
[13932f14] | 2301 | template< typename pass_type >
|
---|
[ab904dc] | 2302 | void PassVisitor< pass_type >::visit( TupleType * node ) {
|
---|
[a8a2b0a] | 2303 | VISIT_START( node );
|
---|
| 2304 |
|
---|
| 2305 | maybeAccept_impl( node->forall, *this );
|
---|
| 2306 | maybeAccept_impl( node->types, *this );
|
---|
| 2307 | maybeAccept_impl( node->members, *this );
|
---|
| 2308 |
|
---|
| 2309 | VISIT_END( node );
|
---|
[13932f14] | 2310 | }
|
---|
| 2311 |
|
---|
[a8a2b0a] | 2312 | template< typename pass_type >
|
---|
| 2313 | Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
|
---|
| 2314 | MUTATE_START( node );
|
---|
| 2315 |
|
---|
| 2316 | maybeMutate_impl( node->forall, *this );
|
---|
| 2317 | maybeMutate_impl( node->types, *this );
|
---|
| 2318 | maybeMutate_impl( node->members, *this );
|
---|
| 2319 |
|
---|
| 2320 | MUTATE_END( Type, node );
|
---|
| 2321 | }
|
---|
| 2322 |
|
---|
| 2323 | //--------------------------------------------------------------------------
|
---|
| 2324 | // TypeofType
|
---|
[13932f14] | 2325 | template< typename pass_type >
|
---|
[ab904dc] | 2326 | void PassVisitor< pass_type >::visit( TypeofType * node ) {
|
---|
[a8a2b0a] | 2327 | VISIT_START( node );
|
---|
| 2328 |
|
---|
| 2329 | assert( node->expr );
|
---|
| 2330 | maybeAccept_impl( node->expr, *this );
|
---|
| 2331 |
|
---|
| 2332 | VISIT_END( node );
|
---|
[13932f14] | 2333 | }
|
---|
| 2334 |
|
---|
[a8a2b0a] | 2335 | template< typename pass_type >
|
---|
| 2336 | Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
|
---|
| 2337 | MUTATE_START( node );
|
---|
| 2338 |
|
---|
| 2339 | assert( node->expr );
|
---|
| 2340 | maybeMutate_impl( node->expr, *this );
|
---|
| 2341 |
|
---|
| 2342 | MUTATE_END( Type, node );
|
---|
| 2343 | }
|
---|
| 2344 |
|
---|
| 2345 | //--------------------------------------------------------------------------
|
---|
| 2346 | // AttrType
|
---|
[13932f14] | 2347 | template< typename pass_type >
|
---|
[ab904dc] | 2348 | void PassVisitor< pass_type >::visit( AttrType * node ) {
|
---|
[a8a2b0a] | 2349 | VISIT_START( node );
|
---|
| 2350 |
|
---|
| 2351 | if ( node->isType ) {
|
---|
| 2352 | assert( node->type );
|
---|
| 2353 | maybeAccept_impl( node->type, *this );
|
---|
| 2354 | } else {
|
---|
| 2355 | assert( node->expr );
|
---|
| 2356 | maybeAccept_impl( node->expr, *this );
|
---|
| 2357 | } // if
|
---|
| 2358 |
|
---|
| 2359 | VISIT_END( node );
|
---|
[13932f14] | 2360 | }
|
---|
| 2361 |
|
---|
[a8a2b0a] | 2362 | template< typename pass_type >
|
---|
| 2363 | Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
|
---|
| 2364 | MUTATE_START( node );
|
---|
| 2365 |
|
---|
| 2366 | if ( node->isType ) {
|
---|
| 2367 | assert( node->type );
|
---|
| 2368 | maybeMutate_impl( node->type, *this );
|
---|
| 2369 | } else {
|
---|
| 2370 | assert( node->expr );
|
---|
| 2371 | maybeMutate_impl( node->expr, *this );
|
---|
| 2372 | } // if
|
---|
| 2373 |
|
---|
| 2374 | MUTATE_END( Type, node );
|
---|
| 2375 | }
|
---|
| 2376 |
|
---|
| 2377 | //--------------------------------------------------------------------------
|
---|
| 2378 | // VarArgsType
|
---|
[13932f14] | 2379 | template< typename pass_type >
|
---|
[ab904dc] | 2380 | void PassVisitor< pass_type >::visit( VarArgsType * node ) {
|
---|
[a8a2b0a] | 2381 | VISIT_START( node );
|
---|
| 2382 |
|
---|
| 2383 | maybeAccept_impl( node->forall, *this );
|
---|
| 2384 |
|
---|
| 2385 | VISIT_END( node );
|
---|
[13932f14] | 2386 | }
|
---|
| 2387 |
|
---|
[a8a2b0a] | 2388 | template< typename pass_type >
|
---|
| 2389 | Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
|
---|
| 2390 | MUTATE_START( node );
|
---|
| 2391 |
|
---|
| 2392 | maybeMutate_impl( node->forall, *this );
|
---|
| 2393 |
|
---|
| 2394 | MUTATE_END( Type, node );
|
---|
| 2395 | }
|
---|
| 2396 |
|
---|
| 2397 | //--------------------------------------------------------------------------
|
---|
| 2398 | // ZeroType
|
---|
[13932f14] | 2399 | template< typename pass_type >
|
---|
[ab904dc] | 2400 | void PassVisitor< pass_type >::visit( ZeroType * node ) {
|
---|
[a8a2b0a] | 2401 | VISIT_START( node );
|
---|
| 2402 |
|
---|
| 2403 | maybeAccept_impl( node->forall, *this );
|
---|
| 2404 |
|
---|
| 2405 | VISIT_END( node );
|
---|
[13932f14] | 2406 | }
|
---|
| 2407 |
|
---|
[a8a2b0a] | 2408 | template< typename pass_type >
|
---|
| 2409 | Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
|
---|
| 2410 | MUTATE_START( node );
|
---|
| 2411 |
|
---|
| 2412 | maybeMutate_impl( node->forall, *this );
|
---|
| 2413 |
|
---|
| 2414 | MUTATE_END( Type, node );
|
---|
| 2415 | }
|
---|
| 2416 |
|
---|
| 2417 | //--------------------------------------------------------------------------
|
---|
| 2418 | // OneType
|
---|
[13932f14] | 2419 | template< typename pass_type >
|
---|
[ab904dc] | 2420 | void PassVisitor< pass_type >::visit( OneType * node ) {
|
---|
[a8a2b0a] | 2421 | VISIT_START( node );
|
---|
| 2422 |
|
---|
| 2423 | maybeAccept_impl( node->forall, *this );
|
---|
| 2424 |
|
---|
| 2425 | VISIT_END( node );
|
---|
[13932f14] | 2426 | }
|
---|
| 2427 |
|
---|
[a8a2b0a] | 2428 | template< typename pass_type >
|
---|
| 2429 | Type * PassVisitor< pass_type >::mutate( OneType * node ) {
|
---|
| 2430 | MUTATE_START( node );
|
---|
| 2431 |
|
---|
| 2432 | maybeMutate_impl( node->forall, *this );
|
---|
| 2433 |
|
---|
| 2434 | MUTATE_END( Type, node );
|
---|
| 2435 | }
|
---|
| 2436 |
|
---|
| 2437 | //--------------------------------------------------------------------------
|
---|
| 2438 | // Designation
|
---|
[b11d8e2] | 2439 | template< typename pass_type >
|
---|
| 2440 | void PassVisitor< pass_type >::visit( Designation * node ) {
|
---|
| 2441 | VISIT_START( node );
|
---|
| 2442 |
|
---|
[a8a2b0a] | 2443 | maybeAccept_impl( node->designators, *this );
|
---|
[b11d8e2] | 2444 |
|
---|
| 2445 | VISIT_END( node );
|
---|
| 2446 | }
|
---|
| 2447 |
|
---|
| 2448 | template< typename pass_type >
|
---|
| 2449 | Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
|
---|
| 2450 | MUTATE_START( node );
|
---|
| 2451 |
|
---|
[a8a2b0a] | 2452 | maybeMutate_impl( node->designators, *this );
|
---|
[b11d8e2] | 2453 |
|
---|
| 2454 | MUTATE_END( Designation, node );
|
---|
| 2455 | }
|
---|
| 2456 |
|
---|
[9c1600c] | 2457 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 2458 | // SingleInit
|
---|
[13932f14] | 2459 | template< typename pass_type >
|
---|
[ab904dc] | 2460 | void PassVisitor< pass_type >::visit( SingleInit * node ) {
|
---|
[9c1600c] | 2461 | VISIT_START( node );
|
---|
| 2462 |
|
---|
[a8a2b0a] | 2463 | visitExpression( node->value );
|
---|
[9c1600c] | 2464 |
|
---|
| 2465 | VISIT_END( node );
|
---|
[13932f14] | 2466 | }
|
---|
| 2467 |
|
---|
[296b2be] | 2468 | template< typename pass_type >
|
---|
| 2469 | Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
|
---|
| 2470 | MUTATE_START( node );
|
---|
| 2471 |
|
---|
[a8a2b0a] | 2472 | node->value = mutateExpression( node->value );
|
---|
[296b2be] | 2473 |
|
---|
| 2474 | MUTATE_END( Initializer, node );
|
---|
| 2475 | }
|
---|
| 2476 |
|
---|
[a8a2b0a] | 2477 | //--------------------------------------------------------------------------
|
---|
| 2478 | // ListInit
|
---|
[13932f14] | 2479 | template< typename pass_type >
|
---|
[ab904dc] | 2480 | void PassVisitor< pass_type >::visit( ListInit * node ) {
|
---|
[a8a2b0a] | 2481 | VISIT_START( node );
|
---|
[13932f14] | 2482 |
|
---|
[a8a2b0a] | 2483 | maybeAccept_impl( node->designations, *this );
|
---|
| 2484 | maybeAccept_impl( node->initializers, *this );
|
---|
[13932f14] | 2485 |
|
---|
[a8a2b0a] | 2486 | VISIT_END( node );
|
---|
[13932f14] | 2487 | }
|
---|
| 2488 |
|
---|
| 2489 | template< typename pass_type >
|
---|
[a8a2b0a] | 2490 | Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
|
---|
| 2491 | MUTATE_START( node );
|
---|
| 2492 |
|
---|
| 2493 | maybeMutate_impl( node->designations, *this );
|
---|
| 2494 | maybeMutate_impl( node->initializers, *this );
|
---|
| 2495 |
|
---|
| 2496 | MUTATE_END( Initializer, node );
|
---|
[13932f14] | 2497 | }
|
---|
[ab904dc] | 2498 |
|
---|
[a8a2b0a] | 2499 | //--------------------------------------------------------------------------
|
---|
| 2500 | // ConstructorInit
|
---|
[5ea7a22] | 2501 | template< typename pass_type >
|
---|
[a8a2b0a] | 2502 | void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
|
---|
| 2503 | VISIT_START( node );
|
---|
[5ea7a22] | 2504 |
|
---|
[a8a2b0a] | 2505 | maybeAccept_impl( node->ctor, *this );
|
---|
| 2506 | maybeAccept_impl( node->dtor, *this );
|
---|
| 2507 | maybeAccept_impl( node->init, *this );
|
---|
[ab904dc] | 2508 |
|
---|
[a8a2b0a] | 2509 | VISIT_END( node );
|
---|
[ab904dc] | 2510 | }
|
---|
| 2511 |
|
---|
| 2512 | template< typename pass_type >
|
---|
[a8a2b0a] | 2513 | Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
|
---|
| 2514 | MUTATE_START( node );
|
---|
[ab904dc] | 2515 |
|
---|
[a8a2b0a] | 2516 | maybeMutate_impl( node->ctor, *this );
|
---|
| 2517 | maybeMutate_impl( node->dtor, *this );
|
---|
| 2518 | maybeMutate_impl( node->init, *this );
|
---|
[ab904dc] | 2519 |
|
---|
[a8a2b0a] | 2520 | MUTATE_END( Initializer, node );
|
---|
[ab904dc] | 2521 | }
|
---|
| 2522 |
|
---|
[a8a2b0a] | 2523 | //--------------------------------------------------------------------------
|
---|
| 2524 | // Subrange
|
---|
[ab904dc] | 2525 | template< typename pass_type >
|
---|
[a8a2b0a] | 2526 | void PassVisitor< pass_type >::visit( Subrange * node ) {
|
---|
| 2527 | VISIT_START( node );
|
---|
[ab904dc] | 2528 |
|
---|
[a8a2b0a] | 2529 | VISIT_END( node );
|
---|
[ab904dc] | 2530 | }
|
---|
| 2531 |
|
---|
| 2532 | template< typename pass_type >
|
---|
[a8a2b0a] | 2533 | Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) {
|
---|
| 2534 | MUTATE_START( node );
|
---|
| 2535 |
|
---|
| 2536 | MUTATE_END( Subrange, node );
|
---|
[ab904dc] | 2537 | }
|
---|
| 2538 |
|
---|
[a8a2b0a] | 2539 | //--------------------------------------------------------------------------
|
---|
| 2540 | // Attribute
|
---|
[ab904dc] | 2541 | template< typename pass_type >
|
---|
[a8a2b0a] | 2542 | void PassVisitor< pass_type >::visit( Constant * node ) {
|
---|
| 2543 | VISIT_START( node );
|
---|
| 2544 |
|
---|
| 2545 | VISIT_END( node );
|
---|
[ab904dc] | 2546 | }
|
---|
| 2547 |
|
---|
| 2548 | template< typename pass_type >
|
---|
[a8a2b0a] | 2549 | Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
|
---|
| 2550 | MUTATE_START( node );
|
---|
| 2551 |
|
---|
| 2552 | MUTATE_END( Constant, node );
|
---|
[ab904dc] | 2553 | }
|
---|
| 2554 |
|
---|
[a8a2b0a] | 2555 | //--------------------------------------------------------------------------
|
---|
| 2556 | // Attribute
|
---|
[ab904dc] | 2557 | template< typename pass_type >
|
---|
[a8a2b0a] | 2558 | void PassVisitor< pass_type >::visit( Attribute * node ) {
|
---|
| 2559 | VISIT_START( node );
|
---|
| 2560 |
|
---|
| 2561 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2562 |
|
---|
| 2563 | VISIT_END( node );
|
---|
[4551a6e] | 2564 | }
|
---|
[5ea7a22] | 2565 |
|
---|
| 2566 | template< typename pass_type >
|
---|
| 2567 | Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
|
---|
[a8a2b0a] | 2568 | MUTATE_START( node );
|
---|
| 2569 |
|
---|
| 2570 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2571 |
|
---|
| 2572 | MUTATE_END( Attribute, node );
|
---|
[5ea7a22] | 2573 | }
|
---|
[447c356] | 2574 |
|
---|
[a8a2b0a] | 2575 | //--------------------------------------------------------------------------
|
---|
| 2576 | // TypeSubstitution
|
---|
[447c356] | 2577 | template< typename pass_type >
|
---|
| 2578 | TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
|
---|
| 2579 | MUTATE_START( node );
|
---|
| 2580 |
|
---|
| 2581 | for ( auto & p : node->typeEnv ) {
|
---|
| 2582 | indexerScopedMutate( p.second, *this );
|
---|
| 2583 | }
|
---|
| 2584 | for ( auto & p : node->varEnv ) {
|
---|
| 2585 | indexerScopedMutate( p.second, *this );
|
---|
| 2586 | }
|
---|
| 2587 |
|
---|
| 2588 | MUTATE_END( TypeSubstitution, node );
|
---|
| 2589 | }
|
---|