[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();
|
---|
[522363e] | 67 | SemanticError 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 );
|
---|
[522363e] | 78 | } catch( SemanticError &e ) {
|
---|
| 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();
|
---|
[522363e] | 94 | SemanticError 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 );
|
---|
[522363e] | 104 | } catch( SemanticError &e ) {
|
---|
| 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;
|
---|
[e0886db] | 127 | SemanticError errors;
|
---|
| 128 | for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
|
---|
| 129 | try {
|
---|
| 130 | if ( *i ) {
|
---|
| 131 | (*i)->accept( visitor );
|
---|
| 132 | }
|
---|
| 133 | } catch( SemanticError &e ) {
|
---|
| 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;
|
---|
[e0886db] | 154 | SemanticError errors;
|
---|
| 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
|
---|
| 161 | } catch( SemanticError &e ) {
|
---|
| 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;
|
---|
[296b2be] | 174 | SemanticError errors;
|
---|
| 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 |
|
---|
[296b2be] | 197 | } catch ( SemanticError &e ) {
|
---|
| 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(); } );
|
---|
[7aaec67] | 395 | indexerAddWith( node->withExprs );
|
---|
| 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(); } );
|
---|
[7aaec67] | 425 | indexerAddWith( node->withExprs );
|
---|
| 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 |
|
---|
| 686 | //--------------------------------------------------------------------------
|
---|
| 687 | // CompoundStmt
|
---|
| 688 | template< typename pass_type >
|
---|
| 689 | void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
|
---|
| 690 | VISIT_START( node );
|
---|
| 691 | {
|
---|
| 692 | auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
| 693 | auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
|
---|
| 694 | visitStatementList( node->kids );
|
---|
| 695 | }
|
---|
| 696 | VISIT_END( node );
|
---|
| 697 | }
|
---|
[296b2be] | 698 |
|
---|
[e0886db] | 699 | template< typename pass_type >
|
---|
| 700 | CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
|
---|
| 701 | MUTATE_START( node );
|
---|
| 702 | {
|
---|
| 703 | auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
| 704 | auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
|
---|
| 705 | mutateStatementList( node->kids );
|
---|
| 706 | }
|
---|
[296b2be] | 707 | MUTATE_END( CompoundStmt, node );
|
---|
| 708 | }
|
---|
| 709 |
|
---|
[9c1600c] | 710 | //--------------------------------------------------------------------------
|
---|
| 711 | // ExprStmt
|
---|
[13932f14] | 712 | template< typename pass_type >
|
---|
[ab904dc] | 713 | void PassVisitor< pass_type >::visit( ExprStmt * node ) {
|
---|
[9c1600c] | 714 | VISIT_START( node );
|
---|
| 715 |
|
---|
[e0886db] | 716 | visitExpression( node->expr );
|
---|
[9c1600c] | 717 |
|
---|
| 718 | VISIT_END( node );
|
---|
[13932f14] | 719 | }
|
---|
| 720 |
|
---|
[296b2be] | 721 | template< typename pass_type >
|
---|
| 722 | Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
|
---|
| 723 | MUTATE_START( node );
|
---|
| 724 |
|
---|
[e0886db] | 725 | node->expr = mutateExpression( node->expr );
|
---|
[296b2be] | 726 |
|
---|
| 727 | MUTATE_END( Statement, node );
|
---|
| 728 | }
|
---|
| 729 |
|
---|
[6ca154b] | 730 | //--------------------------------------------------------------------------
|
---|
| 731 | // AsmStmt
|
---|
[13932f14] | 732 | template< typename pass_type >
|
---|
[ab904dc] | 733 | void PassVisitor< pass_type >::visit( AsmStmt * node ) {
|
---|
[bc6f918] | 734 | VISIT_START( node )
|
---|
| 735 |
|
---|
| 736 | maybeAccept_impl( node->instruction, *this );
|
---|
| 737 | maybeAccept_impl( node->output, *this );
|
---|
| 738 | maybeAccept_impl( node->input, *this );
|
---|
| 739 | maybeAccept_impl( node->clobber, *this );
|
---|
| 740 |
|
---|
| 741 | VISIT_END( node );
|
---|
[13932f14] | 742 | }
|
---|
| 743 |
|
---|
[6ca154b] | 744 | template< typename pass_type >
|
---|
| 745 | Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
|
---|
[bc6f918] | 746 | MUTATE_START( node );
|
---|
| 747 |
|
---|
| 748 | maybeMutate_impl( node->instruction, *this );
|
---|
| 749 | maybeMutate_impl( node->output, *this );
|
---|
| 750 | maybeMutate_impl( node->input, *this );
|
---|
| 751 | maybeMutate_impl( node->clobber, *this );
|
---|
| 752 |
|
---|
| 753 | MUTATE_END( Statement, node );
|
---|
[6ca154b] | 754 | }
|
---|
| 755 |
|
---|
[9c1600c] | 756 | //--------------------------------------------------------------------------
|
---|
| 757 | // IfStmt
|
---|
[13932f14] | 758 | template< typename pass_type >
|
---|
[ab904dc] | 759 | void PassVisitor< pass_type >::visit( IfStmt * node ) {
|
---|
[4551a6e] | 760 | VISIT_START( node );
|
---|
[33a25f9] | 761 | {
|
---|
| 762 | // if statements introduce a level of scope (for the initialization)
|
---|
| 763 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 764 | maybeAccept_impl( node->get_initialization(), *this );
|
---|
| 765 | visitExpression ( node->condition );
|
---|
[33a25f9] | 766 | node->thenPart = visitStatement( node->thenPart );
|
---|
| 767 | node->elsePart = visitStatement( node->elsePart );
|
---|
| 768 | }
|
---|
[9c1600c] | 769 | VISIT_END( node );
|
---|
[13932f14] | 770 | }
|
---|
| 771 |
|
---|
[296b2be] | 772 | template< typename pass_type >
|
---|
| 773 | Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
|
---|
[4551a6e] | 774 | MUTATE_START( node );
|
---|
[e0886db] | 775 | {
|
---|
[33a25f9] | 776 | // if statements introduce a level of scope (for the initialization)
|
---|
[e0886db] | 777 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 778 | maybeMutate_impl( node->get_initialization(), *this );
|
---|
[e0886db] | 779 | node->condition = mutateExpression( node->condition );
|
---|
| 780 | node->thenPart = mutateStatement ( node->thenPart );
|
---|
| 781 | node->elsePart = mutateStatement ( node->elsePart );
|
---|
| 782 | }
|
---|
[296b2be] | 783 | MUTATE_END( Statement, node );
|
---|
| 784 | }
|
---|
| 785 |
|
---|
[9c1600c] | 786 | //--------------------------------------------------------------------------
|
---|
| 787 | // WhileStmt
|
---|
[13932f14] | 788 | template< typename pass_type >
|
---|
[ab904dc] | 789 | void PassVisitor< pass_type >::visit( WhileStmt * node ) {
|
---|
[4551a6e] | 790 | VISIT_START( node );
|
---|
[9c1600c] | 791 |
|
---|
[e0886db] | 792 | visitExpression( node->condition );
|
---|
| 793 | node->body = visitStatement( node->body );
|
---|
[9c1600c] | 794 |
|
---|
| 795 | VISIT_END( node );
|
---|
[13932f14] | 796 | }
|
---|
| 797 |
|
---|
[296b2be] | 798 | template< typename pass_type >
|
---|
| 799 | Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
|
---|
[4551a6e] | 800 | MUTATE_START( node );
|
---|
[296b2be] | 801 |
|
---|
[e0886db] | 802 | node->condition = mutateExpression( node->condition );
|
---|
| 803 | node->body = mutateStatement ( node->body );
|
---|
[296b2be] | 804 |
|
---|
| 805 | MUTATE_END( Statement, node );
|
---|
| 806 | }
|
---|
| 807 |
|
---|
[9c1600c] | 808 | //--------------------------------------------------------------------------
|
---|
[6ca154b] | 809 | // ForStmt
|
---|
[13932f14] | 810 | template< typename pass_type >
|
---|
[ab904dc] | 811 | void PassVisitor< pass_type >::visit( ForStmt * node ) {
|
---|
[4551a6e] | 812 | VISIT_START( node );
|
---|
[e0886db] | 813 | {
|
---|
[33a25f9] | 814 | // for statements introduce a level of scope (for the initialization)
|
---|
[e0886db] | 815 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 816 | maybeAccept_impl( node->initialization, *this );
|
---|
[e0886db] | 817 | visitExpression( node->condition );
|
---|
| 818 | visitExpression( node->increment );
|
---|
| 819 | node->body = visitStatement( node->body );
|
---|
| 820 | }
|
---|
[9c1600c] | 821 | VISIT_END( node );
|
---|
[13932f14] | 822 | }
|
---|
| 823 |
|
---|
[296b2be] | 824 | template< typename pass_type >
|
---|
| 825 | Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
|
---|
[4551a6e] | 826 | MUTATE_START( node );
|
---|
[e0886db] | 827 | {
|
---|
[33a25f9] | 828 | // for statements introduce a level of scope (for the initialization)
|
---|
[e0886db] | 829 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 830 | maybeMutate_impl( node->initialization, *this );
|
---|
[e0886db] | 831 | node->condition = mutateExpression( node->condition );
|
---|
| 832 | node->increment = mutateExpression( node->increment );
|
---|
| 833 | node->body = mutateStatement ( node->body );
|
---|
| 834 | }
|
---|
[296b2be] | 835 | MUTATE_END( Statement, node );
|
---|
| 836 | }
|
---|
| 837 |
|
---|
[9c1600c] | 838 | //--------------------------------------------------------------------------
|
---|
| 839 | // SwitchStmt
|
---|
[13932f14] | 840 | template< typename pass_type >
|
---|
[ab904dc] | 841 | void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
|
---|
[4551a6e] | 842 | VISIT_START( node );
|
---|
[9c1600c] | 843 |
|
---|
[e0886db] | 844 | visitExpression ( node->condition );
|
---|
| 845 | visitStatementList( node->statements );
|
---|
[9c1600c] | 846 |
|
---|
| 847 | VISIT_END( node );
|
---|
[13932f14] | 848 | }
|
---|
| 849 |
|
---|
[296b2be] | 850 | template< typename pass_type >
|
---|
| 851 | Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
|
---|
[4551a6e] | 852 | MUTATE_START( node );
|
---|
| 853 |
|
---|
[e0886db] | 854 | node->condition = mutateExpression( node->condition );
|
---|
| 855 | mutateStatementList( node->statements );
|
---|
[4551a6e] | 856 |
|
---|
[296b2be] | 857 | MUTATE_END( Statement, node );
|
---|
| 858 | }
|
---|
| 859 |
|
---|
[9c1600c] | 860 | //--------------------------------------------------------------------------
|
---|
[35df560] | 861 | // CaseStmt
|
---|
[13932f14] | 862 | template< typename pass_type >
|
---|
[ab904dc] | 863 | void PassVisitor< pass_type >::visit( CaseStmt * node ) {
|
---|
[4551a6e] | 864 | VISIT_START( node );
|
---|
| 865 |
|
---|
[e0886db] | 866 | visitExpression ( node->condition );
|
---|
| 867 | visitStatementList( node->stmts );
|
---|
[4551a6e] | 868 |
|
---|
[9c1600c] | 869 | VISIT_END( node );
|
---|
[13932f14] | 870 | }
|
---|
| 871 |
|
---|
[296b2be] | 872 | template< typename pass_type >
|
---|
| 873 | Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
|
---|
[4551a6e] | 874 | MUTATE_START( node );
|
---|
| 875 |
|
---|
[e0886db] | 876 | node->condition = mutateExpression( node->condition );
|
---|
| 877 | mutateStatementList( node->stmts );
|
---|
[4551a6e] | 878 |
|
---|
[296b2be] | 879 | MUTATE_END( Statement, node );
|
---|
| 880 | }
|
---|
| 881 |
|
---|
[6ca154b] | 882 | //--------------------------------------------------------------------------
|
---|
| 883 | // BranchStmt
|
---|
[13932f14] | 884 | template< typename pass_type >
|
---|
[ab904dc] | 885 | void PassVisitor< pass_type >::visit( BranchStmt * node ) {
|
---|
[33c0ce8] | 886 | VISIT_START( node );
|
---|
| 887 | VISIT_END( node );
|
---|
[13932f14] | 888 | }
|
---|
| 889 |
|
---|
[6ca154b] | 890 | template< typename pass_type >
|
---|
| 891 | Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
|
---|
[33c0ce8] | 892 | MUTATE_START( node );
|
---|
| 893 | MUTATE_END( Statement, node );
|
---|
[6ca154b] | 894 | }
|
---|
| 895 |
|
---|
[9c1600c] | 896 | //--------------------------------------------------------------------------
|
---|
| 897 | // ReturnStmt
|
---|
[13932f14] | 898 | template< typename pass_type >
|
---|
[ab904dc] | 899 | void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
|
---|
[9c1600c] | 900 | VISIT_START( node );
|
---|
| 901 |
|
---|
[e0886db] | 902 | visitExpression( node->expr );
|
---|
[9c1600c] | 903 |
|
---|
| 904 | VISIT_END( node );
|
---|
[13932f14] | 905 | }
|
---|
| 906 |
|
---|
[296b2be] | 907 | template< typename pass_type >
|
---|
| 908 | Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
|
---|
| 909 | MUTATE_START( node );
|
---|
| 910 |
|
---|
[e0886db] | 911 | node->expr = mutateExpression( node->expr );
|
---|
[296b2be] | 912 |
|
---|
| 913 | MUTATE_END( Statement, node );
|
---|
| 914 | }
|
---|
| 915 |
|
---|
[6e09f211] | 916 | //--------------------------------------------------------------------------
|
---|
| 917 | // ThrowStmt
|
---|
| 918 |
|
---|
| 919 | template< typename pass_type >
|
---|
| 920 | void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
|
---|
[33c0ce8] | 921 | VISIT_START( node );
|
---|
| 922 |
|
---|
| 923 | maybeAccept_impl( node->expr, *this );
|
---|
| 924 | maybeAccept_impl( node->target, *this );
|
---|
| 925 |
|
---|
| 926 | VISIT_END( node );
|
---|
[6e09f211] | 927 | }
|
---|
| 928 |
|
---|
| 929 | template< typename pass_type >
|
---|
| 930 | Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
|
---|
[33c0ce8] | 931 | MUTATE_START( node );
|
---|
| 932 |
|
---|
| 933 | maybeMutate_impl( node->expr, *this );
|
---|
| 934 | maybeMutate_impl( node->target, *this );
|
---|
| 935 |
|
---|
| 936 | MUTATE_END( Statement, node );
|
---|
[6e09f211] | 937 | }
|
---|
| 938 |
|
---|
[9c1600c] | 939 | //--------------------------------------------------------------------------
|
---|
| 940 | // TryStmt
|
---|
[13932f14] | 941 | template< typename pass_type >
|
---|
[ab904dc] | 942 | void PassVisitor< pass_type >::visit( TryStmt * node ) {
|
---|
[9c1600c] | 943 | VISIT_START( node );
|
---|
| 944 |
|
---|
[3c398b6] | 945 | maybeAccept_impl( node->block , *this );
|
---|
| 946 | maybeAccept_impl( node->handlers , *this );
|
---|
| 947 | maybeAccept_impl( node->finallyBlock, *this );
|
---|
[9c1600c] | 948 |
|
---|
| 949 | VISIT_END( node );
|
---|
[13932f14] | 950 | }
|
---|
| 951 |
|
---|
[296b2be] | 952 | template< typename pass_type >
|
---|
| 953 | Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
|
---|
| 954 | MUTATE_START( node );
|
---|
| 955 |
|
---|
[3c398b6] | 956 | maybeMutate_impl( node->block , *this );
|
---|
| 957 | maybeMutate_impl( node->handlers , *this );
|
---|
| 958 | maybeMutate_impl( node->finallyBlock, *this );
|
---|
[4551a6e] | 959 |
|
---|
[296b2be] | 960 | MUTATE_END( Statement, node );
|
---|
| 961 | }
|
---|
| 962 |
|
---|
[9c1600c] | 963 | //--------------------------------------------------------------------------
|
---|
| 964 | // CatchStmt
|
---|
[13932f14] | 965 | template< typename pass_type >
|
---|
[ab904dc] | 966 | void PassVisitor< pass_type >::visit( CatchStmt * node ) {
|
---|
[9c1600c] | 967 | VISIT_START( node );
|
---|
[e0886db] | 968 | {
|
---|
[33a25f9] | 969 | // catch statements introduce a level of scope (for the caught exception)
|
---|
[e0886db] | 970 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 971 | maybeAccept_impl( node->decl, *this );
|
---|
[e0886db] | 972 | node->cond = visitExpression( node->cond );
|
---|
| 973 | node->body = visitStatement ( node->body );
|
---|
| 974 | }
|
---|
[9c1600c] | 975 | VISIT_END( node );
|
---|
[13932f14] | 976 | }
|
---|
| 977 |
|
---|
[296b2be] | 978 | template< typename pass_type >
|
---|
| 979 | Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
|
---|
| 980 | MUTATE_START( node );
|
---|
[e0886db] | 981 | {
|
---|
[33a25f9] | 982 | // catch statements introduce a level of scope (for the caught exception)
|
---|
[e0886db] | 983 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 984 | maybeMutate_impl( node->decl, *this );
|
---|
[e0886db] | 985 | node->cond = mutateExpression( node->cond );
|
---|
| 986 | node->body = mutateStatement ( node->body );
|
---|
| 987 | }
|
---|
[296b2be] | 988 | MUTATE_END( Statement, node );
|
---|
| 989 | }
|
---|
| 990 |
|
---|
[2065609] | 991 | //--------------------------------------------------------------------------
|
---|
| 992 | // FinallyStmt
|
---|
[13932f14] | 993 | template< typename pass_type >
|
---|
[ab904dc] | 994 | void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
|
---|
[11b7028] | 995 | VISIT_START( node );
|
---|
| 996 |
|
---|
| 997 | maybeAccept_impl( node->block, *this );
|
---|
| 998 |
|
---|
| 999 | VISIT_END( node );
|
---|
[13932f14] | 1000 | }
|
---|
| 1001 |
|
---|
[2065609] | 1002 | template< typename pass_type >
|
---|
| 1003 | Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
|
---|
[11b7028] | 1004 | MUTATE_START( node );
|
---|
| 1005 |
|
---|
| 1006 | maybeMutate_impl( node->block, *this );
|
---|
| 1007 |
|
---|
| 1008 | MUTATE_END( Statement, node );
|
---|
[2065609] | 1009 | }
|
---|
| 1010 |
|
---|
| 1011 | //--------------------------------------------------------------------------
|
---|
| 1012 | // WaitForStmt
|
---|
| 1013 | template< typename pass_type >
|
---|
| 1014 | void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
|
---|
[834b892] | 1015 | VISIT_START( node );
|
---|
| 1016 |
|
---|
| 1017 | for( auto & clause : node->clauses ) {
|
---|
| 1018 | maybeAccept_impl( clause.target.function, *this );
|
---|
| 1019 | maybeAccept_impl( clause.target.arguments, *this );
|
---|
| 1020 |
|
---|
| 1021 | maybeAccept_impl( clause.statement, *this );
|
---|
| 1022 | maybeAccept_impl( clause.condition, *this );
|
---|
| 1023 | }
|
---|
| 1024 |
|
---|
| 1025 | maybeAccept_impl( node->timeout.time, *this );
|
---|
| 1026 | maybeAccept_impl( node->timeout.statement, *this );
|
---|
| 1027 | maybeAccept_impl( node->timeout.condition, *this );
|
---|
| 1028 | maybeAccept_impl( node->orelse.statement, *this );
|
---|
| 1029 | maybeAccept_impl( node->orelse.condition, *this );
|
---|
| 1030 |
|
---|
| 1031 | VISIT_END( node );
|
---|
[2065609] | 1032 | }
|
---|
| 1033 |
|
---|
| 1034 | template< typename pass_type >
|
---|
| 1035 | Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
|
---|
[834b892] | 1036 | MUTATE_START( node );
|
---|
| 1037 |
|
---|
| 1038 | for( auto & clause : node->clauses ) {
|
---|
| 1039 | maybeMutate_impl( clause.target.function, *this );
|
---|
| 1040 | maybeMutate_impl( clause.target.arguments, *this );
|
---|
| 1041 |
|
---|
| 1042 | maybeMutate_impl( clause.statement, *this );
|
---|
| 1043 | maybeMutate_impl( clause.condition, *this );
|
---|
| 1044 | }
|
---|
| 1045 |
|
---|
| 1046 | maybeMutate_impl( node->timeout.time, *this );
|
---|
| 1047 | maybeMutate_impl( node->timeout.statement, *this );
|
---|
| 1048 | maybeMutate_impl( node->timeout.condition, *this );
|
---|
| 1049 | maybeMutate_impl( node->orelse.statement, *this );
|
---|
| 1050 | maybeMutate_impl( node->orelse.condition, *this );
|
---|
| 1051 |
|
---|
| 1052 | MUTATE_END( Statement, node );
|
---|
[2065609] | 1053 | }
|
---|
| 1054 |
|
---|
[d8893ca] | 1055 |
|
---|
| 1056 |
|
---|
[61255ad] | 1057 | //--------------------------------------------------------------------------
|
---|
| 1058 | // NullStmt
|
---|
| 1059 | template< typename pass_type >
|
---|
| 1060 | void PassVisitor< pass_type >::visit( WithStmt * node ) {
|
---|
[d8893ca] | 1061 | VISIT_START( node );
|
---|
| 1062 | maybeAccept_impl( node->exprs, *this );
|
---|
| 1063 | {
|
---|
| 1064 | // catch statements introduce a level of scope (for the caught exception)
|
---|
| 1065 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[4670c79] | 1066 | indexerAddWith( node->exprs );
|
---|
[d8893ca] | 1067 | maybeAccept_impl( node->stmt, *this );
|
---|
| 1068 | }
|
---|
| 1069 | VISIT_END( node );
|
---|
[61255ad] | 1070 | }
|
---|
| 1071 |
|
---|
| 1072 | template< typename pass_type >
|
---|
| 1073 | Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
|
---|
[d8893ca] | 1074 | MUTATE_START( node );
|
---|
| 1075 | maybeMutate_impl( node->exprs, *this );
|
---|
| 1076 | {
|
---|
| 1077 | // catch statements introduce a level of scope (for the caught exception)
|
---|
| 1078 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[4670c79] | 1079 | indexerAddWith( node->exprs );
|
---|
[d8893ca] | 1080 | maybeMutate_impl( node->stmt, *this );
|
---|
| 1081 | }
|
---|
| 1082 | MUTATE_END( Statement, node );
|
---|
[61255ad] | 1083 | }
|
---|
| 1084 |
|
---|
[2065609] | 1085 | //--------------------------------------------------------------------------
|
---|
| 1086 | // NullStmt
|
---|
[13932f14] | 1087 | template< typename pass_type >
|
---|
[ab904dc] | 1088 | void PassVisitor< pass_type >::visit( NullStmt * node ) {
|
---|
[4551a6e] | 1089 | VISIT_BODY( node );
|
---|
[13932f14] | 1090 | }
|
---|
| 1091 |
|
---|
[2065609] | 1092 | template< typename pass_type >
|
---|
| 1093 | NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
|
---|
| 1094 | MUTATE_BODY( NullStmt, node );
|
---|
| 1095 | }
|
---|
| 1096 |
|
---|
| 1097 | //--------------------------------------------------------------------------
|
---|
| 1098 | // DeclStmt
|
---|
[13932f14] | 1099 | template< typename pass_type >
|
---|
[ab904dc] | 1100 | void PassVisitor< pass_type >::visit( DeclStmt * node ) {
|
---|
[4551a6e] | 1101 | VISIT_BODY( node );
|
---|
[13932f14] | 1102 | }
|
---|
| 1103 |
|
---|
[2065609] | 1104 | template< typename pass_type >
|
---|
| 1105 | Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
|
---|
| 1106 | MUTATE_BODY( Statement, node );
|
---|
| 1107 | }
|
---|
| 1108 |
|
---|
| 1109 | //--------------------------------------------------------------------------
|
---|
| 1110 | // ImplicitCtorDtorStmt
|
---|
[13932f14] | 1111 | template< typename pass_type >
|
---|
[ab904dc] | 1112 | void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
|
---|
[4551a6e] | 1113 | VISIT_BODY( node );
|
---|
[13932f14] | 1114 | }
|
---|
| 1115 |
|
---|
[2065609] | 1116 | template< typename pass_type >
|
---|
| 1117 | Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
|
---|
| 1118 | MUTATE_BODY( Statement, node );
|
---|
| 1119 | }
|
---|
| 1120 |
|
---|
| 1121 | //--------------------------------------------------------------------------
|
---|
| 1122 | // ApplicationExpr
|
---|
[13932f14] | 1123 | template< typename pass_type >
|
---|
[ab904dc] | 1124 | void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
|
---|
[e0886db] | 1125 | VISIT_START( node );
|
---|
| 1126 |
|
---|
| 1127 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1128 | maybeAccept_impl ( node->function, *this );
|
---|
| 1129 | maybeAccept_impl ( node->args , *this );
|
---|
[e0886db] | 1130 |
|
---|
| 1131 | VISIT_END( node );
|
---|
[13932f14] | 1132 | }
|
---|
| 1133 |
|
---|
[2065609] | 1134 | template< typename pass_type >
|
---|
| 1135 | Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
|
---|
[e0886db] | 1136 | MUTATE_START( node );
|
---|
| 1137 |
|
---|
| 1138 | indexerScopedMutate( node->env , *this );
|
---|
| 1139 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1140 | maybeMutate_impl ( node->function, *this );
|
---|
| 1141 | maybeMutate_impl ( node->args , *this );
|
---|
[e0886db] | 1142 |
|
---|
| 1143 | MUTATE_END( Expression, node );
|
---|
[2065609] | 1144 | }
|
---|
| 1145 |
|
---|
[9c1600c] | 1146 | //--------------------------------------------------------------------------
|
---|
| 1147 | // UntypedExpr
|
---|
[13932f14] | 1148 | template< typename pass_type >
|
---|
[ab904dc] | 1149 | void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
|
---|
[9c1600c] | 1150 | VISIT_START( node );
|
---|
| 1151 |
|
---|
[3c398b6] | 1152 | // maybeAccept_impl( node->get_env(), *this );
|
---|
[e0886db] | 1153 | indexerScopedAccept( node->result, *this );
|
---|
[2a7b3ca] | 1154 |
|
---|
[e0886db] | 1155 | for ( auto expr : node->args ) {
|
---|
[9c1600c] | 1156 | visitExpression( expr );
|
---|
| 1157 | }
|
---|
| 1158 |
|
---|
| 1159 | VISIT_END( node );
|
---|
[13932f14] | 1160 | }
|
---|
| 1161 |
|
---|
[296b2be] | 1162 | template< typename pass_type >
|
---|
| 1163 | Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
|
---|
| 1164 | MUTATE_START( node );
|
---|
| 1165 |
|
---|
[e0886db] | 1166 | indexerScopedMutate( node->env , *this );
|
---|
| 1167 | indexerScopedMutate( node->result, *this );
|
---|
[2a7b3ca] | 1168 |
|
---|
[e0886db] | 1169 | for ( auto& expr : node->args ) {
|
---|
[296b2be] | 1170 | expr = mutateExpression( expr );
|
---|
| 1171 | }
|
---|
| 1172 |
|
---|
| 1173 | MUTATE_END( Expression, node );
|
---|
| 1174 | }
|
---|
| 1175 |
|
---|
[e0886db] | 1176 | //--------------------------------------------------------------------------
|
---|
| 1177 | // NameExpr
|
---|
[13932f14] | 1178 | template< typename pass_type >
|
---|
[ab904dc] | 1179 | void PassVisitor< pass_type >::visit( NameExpr * node ) {
|
---|
[e0886db] | 1180 | VISIT_START( node );
|
---|
| 1181 |
|
---|
| 1182 | indexerScopedAccept( node->result, *this );
|
---|
| 1183 |
|
---|
| 1184 | VISIT_END( node );
|
---|
[13932f14] | 1185 | }
|
---|
| 1186 |
|
---|
| 1187 | template< typename pass_type >
|
---|
[e0886db] | 1188 | Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
|
---|
| 1189 | MUTATE_START( node );
|
---|
| 1190 |
|
---|
| 1191 | indexerScopedMutate( node->env , *this );
|
---|
| 1192 | indexerScopedMutate( node->result, *this );
|
---|
| 1193 |
|
---|
| 1194 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1195 | }
|
---|
| 1196 |
|
---|
[e0886db] | 1197 | //--------------------------------------------------------------------------
|
---|
| 1198 | // CastExpr
|
---|
[a5f0529] | 1199 | template< typename pass_type >
|
---|
[e0886db] | 1200 | void PassVisitor< pass_type >::visit( CastExpr * node ) {
|
---|
| 1201 | VISIT_START( node );
|
---|
| 1202 |
|
---|
| 1203 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1204 | maybeAccept_impl ( node->arg , *this );
|
---|
[e0886db] | 1205 |
|
---|
| 1206 | VISIT_END( node );
|
---|
[a5f0529] | 1207 | }
|
---|
| 1208 |
|
---|
[13932f14] | 1209 | template< typename pass_type >
|
---|
[e0886db] | 1210 | Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
|
---|
| 1211 | MUTATE_START( node );
|
---|
| 1212 |
|
---|
| 1213 | indexerScopedMutate( node->env , *this );
|
---|
| 1214 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1215 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1216 |
|
---|
| 1217 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1218 | }
|
---|
| 1219 |
|
---|
[e0886db] | 1220 | //--------------------------------------------------------------------------
|
---|
| 1221 | // VirtualCastExpr
|
---|
[13932f14] | 1222 | template< typename pass_type >
|
---|
[e0886db] | 1223 | void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
|
---|
| 1224 | VISIT_START( node );
|
---|
| 1225 |
|
---|
| 1226 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1227 | maybeAccept_impl( node->arg, *this );
|
---|
[e0886db] | 1228 |
|
---|
| 1229 | VISIT_END( node );
|
---|
[13932f14] | 1230 | }
|
---|
| 1231 |
|
---|
| 1232 | template< typename pass_type >
|
---|
[e0886db] | 1233 | Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
|
---|
| 1234 | MUTATE_START( node );
|
---|
| 1235 |
|
---|
| 1236 | indexerScopedMutate( node->env , *this );
|
---|
| 1237 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1238 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1239 |
|
---|
| 1240 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1241 | }
|
---|
| 1242 |
|
---|
[e0886db] | 1243 | //--------------------------------------------------------------------------
|
---|
| 1244 | // AddressExpr
|
---|
[13932f14] | 1245 | template< typename pass_type >
|
---|
[e0886db] | 1246 | void PassVisitor< pass_type >::visit( AddressExpr * node ) {
|
---|
| 1247 | VISIT_START( node );
|
---|
| 1248 |
|
---|
| 1249 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1250 | maybeAccept_impl ( node->arg , *this );
|
---|
[e0886db] | 1251 |
|
---|
| 1252 | VISIT_END( node );
|
---|
[13932f14] | 1253 | }
|
---|
| 1254 |
|
---|
| 1255 | template< typename pass_type >
|
---|
[e0886db] | 1256 | Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
|
---|
| 1257 | MUTATE_START( node );
|
---|
| 1258 |
|
---|
| 1259 | indexerScopedMutate( node->env , *this );
|
---|
| 1260 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1261 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1262 |
|
---|
| 1263 | MUTATE_END( Expression, node );
|
---|
| 1264 | }
|
---|
| 1265 |
|
---|
| 1266 | //--------------------------------------------------------------------------
|
---|
| 1267 | // LabelAddressExpr
|
---|
| 1268 | template< typename pass_type >
|
---|
| 1269 | void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
|
---|
| 1270 | VISIT_START( node );
|
---|
| 1271 |
|
---|
| 1272 | indexerScopedAccept( node->result, *this );
|
---|
| 1273 |
|
---|
| 1274 | VISIT_END( node );
|
---|
| 1275 | }
|
---|
| 1276 |
|
---|
| 1277 | template< typename pass_type >
|
---|
| 1278 | Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
|
---|
| 1279 | MUTATE_START( node );
|
---|
| 1280 |
|
---|
| 1281 | indexerScopedMutate( node->env , *this );
|
---|
| 1282 | indexerScopedMutate( node->result, *this );
|
---|
| 1283 |
|
---|
| 1284 | MUTATE_END( Expression, node );
|
---|
| 1285 | }
|
---|
| 1286 |
|
---|
| 1287 | //--------------------------------------------------------------------------
|
---|
| 1288 | // UntypedMemberExpr
|
---|
| 1289 | template< typename pass_type >
|
---|
| 1290 | void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
|
---|
| 1291 | VISIT_START( node );
|
---|
| 1292 |
|
---|
| 1293 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1294 | maybeAccept_impl ( node->aggregate, *this );
|
---|
| 1295 | maybeAccept_impl ( node->member , *this );
|
---|
[e0886db] | 1296 |
|
---|
| 1297 | VISIT_END( node );
|
---|
[13932f14] | 1298 | }
|
---|
| 1299 |
|
---|
[e0886db] | 1300 | template< typename pass_type >
|
---|
| 1301 | Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
|
---|
| 1302 | MUTATE_START( node );
|
---|
| 1303 |
|
---|
| 1304 | indexerScopedMutate( node->env , *this );
|
---|
| 1305 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1306 | maybeMutate_impl ( node->aggregate, *this );
|
---|
| 1307 | maybeMutate_impl ( node->member , *this );
|
---|
[e0886db] | 1308 |
|
---|
| 1309 | MUTATE_END( Expression, node );
|
---|
| 1310 | }
|
---|
| 1311 |
|
---|
| 1312 | //--------------------------------------------------------------------------
|
---|
| 1313 | // MemberExpr
|
---|
| 1314 | template< typename pass_type >
|
---|
| 1315 | void PassVisitor< pass_type >::visit( MemberExpr * node ) {
|
---|
| 1316 | VISIT_START( node );
|
---|
| 1317 |
|
---|
| 1318 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1319 | maybeAccept_impl ( node->aggregate, *this );
|
---|
[e0886db] | 1320 |
|
---|
| 1321 | VISIT_END( node );
|
---|
| 1322 | }
|
---|
| 1323 |
|
---|
| 1324 | template< typename pass_type >
|
---|
| 1325 | Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
|
---|
| 1326 | MUTATE_START( node );
|
---|
| 1327 |
|
---|
| 1328 | indexerScopedMutate( node->env , *this );
|
---|
| 1329 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1330 | maybeMutate_impl ( node->aggregate, *this );
|
---|
[e0886db] | 1331 |
|
---|
| 1332 | MUTATE_END( Expression, node );
|
---|
| 1333 | }
|
---|
| 1334 |
|
---|
| 1335 | //--------------------------------------------------------------------------
|
---|
| 1336 | // VariableExpr
|
---|
| 1337 | template< typename pass_type >
|
---|
| 1338 | void PassVisitor< pass_type >::visit( VariableExpr * node ) {
|
---|
| 1339 | VISIT_START( node );
|
---|
| 1340 |
|
---|
| 1341 | indexerScopedAccept( node->result, *this );
|
---|
| 1342 |
|
---|
| 1343 | VISIT_END( node );
|
---|
| 1344 | }
|
---|
| 1345 |
|
---|
| 1346 | template< typename pass_type >
|
---|
| 1347 | Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
|
---|
| 1348 | MUTATE_START( node );
|
---|
| 1349 |
|
---|
| 1350 | indexerScopedMutate( node->env , *this );
|
---|
| 1351 | indexerScopedMutate( node->result, *this );
|
---|
| 1352 |
|
---|
| 1353 | MUTATE_END( Expression, node );
|
---|
| 1354 | }
|
---|
| 1355 |
|
---|
| 1356 | //--------------------------------------------------------------------------
|
---|
| 1357 | // ConstantExpr
|
---|
[13932f14] | 1358 | template< typename pass_type >
|
---|
[ab904dc] | 1359 | void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
|
---|
[e0886db] | 1360 | VISIT_START( node );
|
---|
| 1361 |
|
---|
| 1362 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1363 | maybeAccept_impl ( &node->constant, *this );
|
---|
[e0886db] | 1364 |
|
---|
| 1365 | VISIT_END( node );
|
---|
[13932f14] | 1366 | }
|
---|
| 1367 |
|
---|
[e0886db] | 1368 | template< typename pass_type >
|
---|
| 1369 | Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
|
---|
| 1370 | MUTATE_START( node );
|
---|
| 1371 |
|
---|
| 1372 | indexerScopedMutate( node->env , *this );
|
---|
| 1373 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1374 | Constant * ptr = &node->constant;
|
---|
| 1375 | maybeMutate_impl( ptr, *this );
|
---|
| 1376 | node->constant = *ptr;
|
---|
[e0886db] | 1377 |
|
---|
| 1378 | MUTATE_END( Expression, node );
|
---|
| 1379 | }
|
---|
| 1380 |
|
---|
| 1381 | //--------------------------------------------------------------------------
|
---|
| 1382 | // SizeofExpr
|
---|
[13932f14] | 1383 | template< typename pass_type >
|
---|
[ab904dc] | 1384 | void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
|
---|
[e0886db] | 1385 | VISIT_START( node );
|
---|
| 1386 |
|
---|
| 1387 | indexerScopedAccept( node->result, *this );
|
---|
| 1388 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1389 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1390 | } else {
|
---|
[3c398b6] | 1391 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1392 | }
|
---|
| 1393 |
|
---|
| 1394 | VISIT_END( node );
|
---|
[13932f14] | 1395 | }
|
---|
| 1396 |
|
---|
[e0886db] | 1397 | template< typename pass_type >
|
---|
| 1398 | Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
|
---|
| 1399 | MUTATE_START( node );
|
---|
| 1400 |
|
---|
| 1401 | indexerScopedMutate( node->env , *this );
|
---|
| 1402 | indexerScopedMutate( node->result, *this );
|
---|
| 1403 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1404 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1405 | } else {
|
---|
[3c398b6] | 1406 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1407 | }
|
---|
| 1408 |
|
---|
| 1409 | MUTATE_END( Expression, node );
|
---|
| 1410 | }
|
---|
| 1411 |
|
---|
| 1412 | //--------------------------------------------------------------------------
|
---|
| 1413 | // AlignofExpr
|
---|
[13932f14] | 1414 | template< typename pass_type >
|
---|
[ab904dc] | 1415 | void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
|
---|
[e0886db] | 1416 | VISIT_START( node );
|
---|
| 1417 |
|
---|
| 1418 | indexerScopedAccept( node->result, *this );
|
---|
| 1419 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1420 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1421 | } else {
|
---|
[3c398b6] | 1422 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1423 | }
|
---|
| 1424 |
|
---|
| 1425 | VISIT_END( node );
|
---|
[13932f14] | 1426 | }
|
---|
| 1427 |
|
---|
[e0886db] | 1428 | template< typename pass_type >
|
---|
| 1429 | Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
|
---|
| 1430 | MUTATE_START( node );
|
---|
| 1431 |
|
---|
| 1432 | indexerScopedMutate( node->env , *this );
|
---|
| 1433 | indexerScopedMutate( node->result, *this );
|
---|
| 1434 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1435 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1436 | } else {
|
---|
[3c398b6] | 1437 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1438 | }
|
---|
| 1439 |
|
---|
| 1440 | MUTATE_END( Expression, node );
|
---|
| 1441 | }
|
---|
| 1442 |
|
---|
| 1443 | //--------------------------------------------------------------------------
|
---|
| 1444 | // UntypedOffsetofExpr
|
---|
[13932f14] | 1445 | template< typename pass_type >
|
---|
[ab904dc] | 1446 | void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
|
---|
[e0886db] | 1447 | VISIT_START( node );
|
---|
| 1448 |
|
---|
| 1449 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1450 | maybeAccept_impl ( node->type , *this );
|
---|
[e0886db] | 1451 |
|
---|
| 1452 | VISIT_END( node );
|
---|
[13932f14] | 1453 | }
|
---|
| 1454 |
|
---|
[e0886db] | 1455 | template< typename pass_type >
|
---|
| 1456 | Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
|
---|
| 1457 | MUTATE_START( node );
|
---|
| 1458 |
|
---|
| 1459 | indexerScopedMutate( node->env , *this );
|
---|
| 1460 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1461 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1462 |
|
---|
| 1463 | MUTATE_END( Expression, node );
|
---|
| 1464 | }
|
---|
| 1465 |
|
---|
| 1466 | //--------------------------------------------------------------------------
|
---|
| 1467 | // OffsetofExpr
|
---|
[13932f14] | 1468 | template< typename pass_type >
|
---|
[ab904dc] | 1469 | void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
|
---|
[e0886db] | 1470 | VISIT_START( node );
|
---|
| 1471 |
|
---|
| 1472 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1473 | maybeAccept_impl ( node->type , *this );
|
---|
| 1474 | maybeAccept_impl ( node->member, *this );
|
---|
[e0886db] | 1475 |
|
---|
| 1476 | VISIT_END( node );
|
---|
[13932f14] | 1477 | }
|
---|
| 1478 |
|
---|
[e0886db] | 1479 | template< typename pass_type >
|
---|
| 1480 | Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
|
---|
| 1481 | MUTATE_START( node );
|
---|
| 1482 |
|
---|
| 1483 | indexerScopedMutate( node->env , *this );
|
---|
| 1484 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1485 | maybeMutate_impl ( node->type , *this );
|
---|
| 1486 | maybeMutate_impl ( node->member, *this );
|
---|
[e0886db] | 1487 |
|
---|
| 1488 | MUTATE_END( Expression, node );
|
---|
| 1489 | }
|
---|
| 1490 |
|
---|
| 1491 | //--------------------------------------------------------------------------
|
---|
| 1492 | // OffsetPackExpr
|
---|
[13932f14] | 1493 | template< typename pass_type >
|
---|
[ab904dc] | 1494 | void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
|
---|
[e0886db] | 1495 | VISIT_START( node );
|
---|
| 1496 |
|
---|
| 1497 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1498 | maybeAccept_impl ( node->type , *this );
|
---|
[e0886db] | 1499 |
|
---|
| 1500 | VISIT_END( node );
|
---|
[13932f14] | 1501 | }
|
---|
| 1502 |
|
---|
[e0886db] | 1503 | template< typename pass_type >
|
---|
| 1504 | Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
|
---|
| 1505 | MUTATE_START( node );
|
---|
| 1506 |
|
---|
| 1507 | indexerScopedMutate( node->env , *this );
|
---|
| 1508 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1509 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1510 |
|
---|
| 1511 | MUTATE_END( Expression, node );
|
---|
| 1512 | }
|
---|
| 1513 |
|
---|
| 1514 | //--------------------------------------------------------------------------
|
---|
| 1515 | // AttrExpr
|
---|
[13932f14] | 1516 | template< typename pass_type >
|
---|
[ab904dc] | 1517 | void PassVisitor< pass_type >::visit( AttrExpr * node ) {
|
---|
[e0886db] | 1518 | VISIT_START( node );
|
---|
| 1519 |
|
---|
| 1520 | indexerScopedAccept( node->result, *this );
|
---|
| 1521 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1522 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1523 | } else {
|
---|
[3c398b6] | 1524 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1525 | }
|
---|
| 1526 |
|
---|
| 1527 | VISIT_END( node );
|
---|
| 1528 | }
|
---|
| 1529 |
|
---|
| 1530 | template< typename pass_type >
|
---|
| 1531 | Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
|
---|
| 1532 | MUTATE_START( node );
|
---|
| 1533 |
|
---|
| 1534 | indexerScopedMutate( node->env , *this );
|
---|
| 1535 | indexerScopedMutate( node->result, *this );
|
---|
| 1536 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1537 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1538 | } else {
|
---|
[3c398b6] | 1539 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1540 | }
|
---|
| 1541 |
|
---|
| 1542 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1543 | }
|
---|
| 1544 |
|
---|
[e0886db] | 1545 | //--------------------------------------------------------------------------
|
---|
| 1546 | // LogicalExpr
|
---|
[13932f14] | 1547 | template< typename pass_type >
|
---|
[ab904dc] | 1548 | void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
|
---|
[e0886db] | 1549 | VISIT_START( node );
|
---|
| 1550 |
|
---|
| 1551 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1552 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1553 | maybeAccept_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1554 |
|
---|
| 1555 | VISIT_END( node );
|
---|
| 1556 | }
|
---|
| 1557 |
|
---|
| 1558 | template< typename pass_type >
|
---|
| 1559 | Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
|
---|
| 1560 | MUTATE_START( node );
|
---|
| 1561 |
|
---|
| 1562 | indexerScopedMutate( node->env , *this );
|
---|
| 1563 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1564 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1565 | maybeMutate_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1566 |
|
---|
| 1567 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1568 | }
|
---|
| 1569 |
|
---|
[e0886db] | 1570 | //--------------------------------------------------------------------------
|
---|
| 1571 | // ConditionalExpr
|
---|
[13932f14] | 1572 | template< typename pass_type >
|
---|
[ab904dc] | 1573 | void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
|
---|
[e0886db] | 1574 | VISIT_START( node );
|
---|
| 1575 |
|
---|
| 1576 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1577 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1578 | maybeAccept_impl ( node->arg2 , *this );
|
---|
| 1579 | maybeAccept_impl ( node->arg3 , *this );
|
---|
[e0886db] | 1580 |
|
---|
| 1581 | VISIT_END( node );
|
---|
[13932f14] | 1582 | }
|
---|
| 1583 |
|
---|
[e0886db] | 1584 | template< typename pass_type >
|
---|
| 1585 | Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
|
---|
| 1586 | MUTATE_START( node );
|
---|
| 1587 |
|
---|
| 1588 | indexerScopedMutate( node->env , *this );
|
---|
| 1589 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1590 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1591 | maybeMutate_impl ( node->arg2 , *this );
|
---|
| 1592 | maybeMutate_impl ( node->arg3 , *this );
|
---|
[e0886db] | 1593 |
|
---|
| 1594 | MUTATE_END( Expression, node );
|
---|
| 1595 | }
|
---|
| 1596 |
|
---|
| 1597 | //--------------------------------------------------------------------------
|
---|
| 1598 | // CommaExpr
|
---|
[13932f14] | 1599 | template< typename pass_type >
|
---|
[ab904dc] | 1600 | void PassVisitor< pass_type >::visit( CommaExpr * node ) {
|
---|
[e0886db] | 1601 | VISIT_START( node );
|
---|
| 1602 |
|
---|
| 1603 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1604 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1605 | maybeAccept_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1606 |
|
---|
| 1607 | VISIT_END( node );
|
---|
| 1608 | }
|
---|
| 1609 |
|
---|
| 1610 | template< typename pass_type >
|
---|
| 1611 | Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
|
---|
| 1612 | MUTATE_START( node );
|
---|
| 1613 |
|
---|
| 1614 | indexerScopedMutate( node->env , *this );
|
---|
| 1615 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1616 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1617 | maybeMutate_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1618 |
|
---|
| 1619 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1620 | }
|
---|
| 1621 |
|
---|
[e0886db] | 1622 | //--------------------------------------------------------------------------
|
---|
| 1623 | // TypeExpr
|
---|
[13932f14] | 1624 | template< typename pass_type >
|
---|
[ab904dc] | 1625 | void PassVisitor< pass_type >::visit( TypeExpr * node ) {
|
---|
[e0886db] | 1626 | VISIT_START( node );
|
---|
| 1627 |
|
---|
| 1628 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1629 | maybeAccept_impl ( node->type, *this );
|
---|
[e0886db] | 1630 |
|
---|
| 1631 | VISIT_END( node );
|
---|
[13932f14] | 1632 | }
|
---|
| 1633 |
|
---|
[e0886db] | 1634 | template< typename pass_type >
|
---|
| 1635 | Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
|
---|
| 1636 | MUTATE_START( node );
|
---|
| 1637 |
|
---|
| 1638 | indexerScopedMutate( node->env , *this );
|
---|
| 1639 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1640 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1641 |
|
---|
| 1642 | MUTATE_END( Expression, node );
|
---|
| 1643 | }
|
---|
| 1644 |
|
---|
| 1645 | //--------------------------------------------------------------------------
|
---|
| 1646 | // AsmExpr
|
---|
[13932f14] | 1647 | template< typename pass_type >
|
---|
[ab904dc] | 1648 | void PassVisitor< pass_type >::visit( AsmExpr * node ) {
|
---|
[e0886db] | 1649 | VISIT_START( node );
|
---|
| 1650 |
|
---|
| 1651 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1652 | maybeAccept_impl ( node->inout , *this );
|
---|
| 1653 | maybeAccept_impl ( node->constraint, *this );
|
---|
| 1654 | maybeAccept_impl ( node->operand , *this );
|
---|
[e0886db] | 1655 |
|
---|
| 1656 | VISIT_END( node );
|
---|
[13932f14] | 1657 | }
|
---|
| 1658 |
|
---|
[e0886db] | 1659 | template< typename pass_type >
|
---|
| 1660 | Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
|
---|
| 1661 | MUTATE_START( node );
|
---|
| 1662 |
|
---|
| 1663 | indexerScopedMutate( node->env , *this );
|
---|
| 1664 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1665 | maybeMutate_impl ( node->inout , *this );
|
---|
| 1666 | maybeMutate_impl ( node->constraint, *this );
|
---|
| 1667 | maybeMutate_impl ( node->operand , *this );
|
---|
[e0886db] | 1668 |
|
---|
| 1669 | MUTATE_END( Expression, node );
|
---|
| 1670 | }
|
---|
| 1671 |
|
---|
| 1672 | //--------------------------------------------------------------------------
|
---|
| 1673 | // ImplicitCopyCtorExpr
|
---|
[13932f14] | 1674 | template< typename pass_type >
|
---|
[ab904dc] | 1675 | void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
|
---|
[e0886db] | 1676 | VISIT_START( node );
|
---|
| 1677 |
|
---|
| 1678 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1679 | maybeAccept_impl ( node->callExpr , *this );
|
---|
| 1680 | maybeAccept_impl ( node->tempDecls , *this );
|
---|
| 1681 | maybeAccept_impl ( node->returnDecls, *this );
|
---|
| 1682 | maybeAccept_impl ( node->dtors , *this );
|
---|
[e0886db] | 1683 |
|
---|
| 1684 | VISIT_END( node );
|
---|
| 1685 | }
|
---|
| 1686 |
|
---|
| 1687 | template< typename pass_type >
|
---|
| 1688 | Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
|
---|
| 1689 | MUTATE_START( node );
|
---|
| 1690 |
|
---|
| 1691 | indexerScopedMutate( node->env , *this );
|
---|
| 1692 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1693 | maybeMutate_impl ( node->callExpr , *this );
|
---|
| 1694 | maybeMutate_impl ( node->tempDecls , *this );
|
---|
| 1695 | maybeMutate_impl ( node->returnDecls, *this );
|
---|
| 1696 | maybeMutate_impl ( node->dtors , *this );
|
---|
[e0886db] | 1697 |
|
---|
| 1698 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1699 | }
|
---|
| 1700 |
|
---|
[e0886db] | 1701 | //--------------------------------------------------------------------------
|
---|
| 1702 | // ConstructorExpr
|
---|
[13932f14] | 1703 | template< typename pass_type >
|
---|
[ab904dc] | 1704 | void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
|
---|
[e0886db] | 1705 | VISIT_START( node );
|
---|
| 1706 |
|
---|
| 1707 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1708 | maybeAccept_impl ( node->callExpr, *this );
|
---|
[e0886db] | 1709 |
|
---|
| 1710 | VISIT_END( node );
|
---|
| 1711 | }
|
---|
| 1712 |
|
---|
| 1713 | template< typename pass_type >
|
---|
| 1714 | Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
|
---|
| 1715 | MUTATE_START( node );
|
---|
| 1716 |
|
---|
| 1717 | indexerScopedMutate( node->env , *this );
|
---|
| 1718 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1719 | maybeMutate_impl ( node->callExpr, *this );
|
---|
[e0886db] | 1720 |
|
---|
| 1721 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1722 | }
|
---|
| 1723 |
|
---|
[e0886db] | 1724 | //--------------------------------------------------------------------------
|
---|
| 1725 | // CompoundLiteralExpr
|
---|
[13932f14] | 1726 | template< typename pass_type >
|
---|
[ab904dc] | 1727 | void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
|
---|
[e0886db] | 1728 | VISIT_START( node );
|
---|
| 1729 |
|
---|
| 1730 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1731 | maybeAccept_impl ( node->initializer, *this );
|
---|
[e0886db] | 1732 |
|
---|
| 1733 | VISIT_END( node );
|
---|
[13932f14] | 1734 | }
|
---|
| 1735 |
|
---|
[e0886db] | 1736 | template< typename pass_type >
|
---|
| 1737 | Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
|
---|
| 1738 | MUTATE_START( node );
|
---|
| 1739 |
|
---|
| 1740 | indexerScopedMutate( node->env , *this );
|
---|
| 1741 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1742 | maybeMutate_impl ( node->initializer, *this );
|
---|
[e0886db] | 1743 |
|
---|
| 1744 | MUTATE_END( Expression, node );
|
---|
| 1745 | }
|
---|
| 1746 |
|
---|
| 1747 | //--------------------------------------------------------------------------
|
---|
| 1748 | // RangeExpr
|
---|
[13932f14] | 1749 | template< typename pass_type >
|
---|
[ab904dc] | 1750 | void PassVisitor< pass_type >::visit( RangeExpr * node ) {
|
---|
[e0886db] | 1751 | VISIT_START( node );
|
---|
| 1752 |
|
---|
| 1753 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1754 | maybeAccept_impl ( node->low , *this );
|
---|
| 1755 | maybeAccept_impl ( node->high , *this );
|
---|
[e0886db] | 1756 |
|
---|
| 1757 | VISIT_END( node );
|
---|
[13932f14] | 1758 | }
|
---|
| 1759 |
|
---|
[e0886db] | 1760 | template< typename pass_type >
|
---|
| 1761 | Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
|
---|
| 1762 | MUTATE_START( node );
|
---|
| 1763 |
|
---|
| 1764 | indexerScopedMutate( node->env , *this );
|
---|
| 1765 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1766 | maybeMutate_impl ( node->low , *this );
|
---|
| 1767 | maybeMutate_impl ( node->high , *this );
|
---|
[e0886db] | 1768 |
|
---|
| 1769 | MUTATE_END( Expression, node );
|
---|
| 1770 | }
|
---|
| 1771 |
|
---|
| 1772 | //--------------------------------------------------------------------------
|
---|
| 1773 | // UntypedTupleExpr
|
---|
[13932f14] | 1774 | template< typename pass_type >
|
---|
[ab904dc] | 1775 | void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
|
---|
[e0886db] | 1776 | VISIT_START( node );
|
---|
| 1777 |
|
---|
| 1778 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1779 | maybeAccept_impl ( node->exprs , *this );
|
---|
[e0886db] | 1780 |
|
---|
| 1781 | VISIT_END( node );
|
---|
| 1782 | }
|
---|
| 1783 |
|
---|
| 1784 | template< typename pass_type >
|
---|
| 1785 | Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
|
---|
| 1786 | MUTATE_START( node );
|
---|
| 1787 |
|
---|
| 1788 | indexerScopedMutate( node->env , *this );
|
---|
| 1789 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1790 | maybeMutate_impl ( node->exprs , *this );
|
---|
[e0886db] | 1791 |
|
---|
| 1792 | MUTATE_END( Expression, node );
|
---|
| 1793 | }
|
---|
| 1794 |
|
---|
| 1795 | //--------------------------------------------------------------------------
|
---|
| 1796 | // TupleExpr
|
---|
| 1797 | template< typename pass_type >
|
---|
| 1798 | void PassVisitor< pass_type >::visit( TupleExpr * node ) {
|
---|
| 1799 | VISIT_START( node );
|
---|
| 1800 |
|
---|
| 1801 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1802 | maybeAccept_impl ( node->exprs , *this );
|
---|
[e0886db] | 1803 |
|
---|
| 1804 | VISIT_END( node );
|
---|
| 1805 | }
|
---|
| 1806 |
|
---|
| 1807 | template< typename pass_type >
|
---|
| 1808 | Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
|
---|
| 1809 | MUTATE_START( node );
|
---|
| 1810 |
|
---|
| 1811 | indexerScopedMutate( node->env , *this );
|
---|
| 1812 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1813 | maybeMutate_impl ( node->exprs , *this );
|
---|
[e0886db] | 1814 |
|
---|
| 1815 | MUTATE_END( Expression, node );
|
---|
| 1816 | }
|
---|
| 1817 |
|
---|
| 1818 | //--------------------------------------------------------------------------
|
---|
| 1819 | // TupleIndexExpr
|
---|
| 1820 | template< typename pass_type >
|
---|
| 1821 | void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
|
---|
| 1822 | VISIT_START( node );
|
---|
| 1823 |
|
---|
| 1824 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1825 | maybeAccept_impl ( node->tuple , *this );
|
---|
[e0886db] | 1826 |
|
---|
| 1827 | VISIT_END( node );
|
---|
| 1828 | }
|
---|
| 1829 |
|
---|
| 1830 | template< typename pass_type >
|
---|
| 1831 | Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
|
---|
| 1832 | MUTATE_START( node );
|
---|
| 1833 |
|
---|
| 1834 | indexerScopedMutate( node->env , *this );
|
---|
| 1835 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1836 | maybeMutate_impl ( node->tuple , *this );
|
---|
[e0886db] | 1837 |
|
---|
| 1838 | MUTATE_END( Expression, node );
|
---|
| 1839 | }
|
---|
| 1840 |
|
---|
| 1841 | //--------------------------------------------------------------------------
|
---|
| 1842 | // TupleAssignExpr
|
---|
| 1843 | template< typename pass_type >
|
---|
| 1844 | void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
|
---|
| 1845 | VISIT_START( node );
|
---|
| 1846 |
|
---|
| 1847 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1848 | maybeAccept_impl ( node->stmtExpr, *this );
|
---|
[e0886db] | 1849 |
|
---|
| 1850 | VISIT_END( node );
|
---|
[13932f14] | 1851 | }
|
---|
| 1852 |
|
---|
| 1853 | template< typename pass_type >
|
---|
[e0886db] | 1854 | Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
|
---|
| 1855 | MUTATE_START( node );
|
---|
[13932f14] | 1856 |
|
---|
[e0886db] | 1857 | indexerScopedMutate( node->env , *this );
|
---|
| 1858 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1859 | maybeMutate_impl ( node->stmtExpr, *this );
|
---|
[13932f14] | 1860 |
|
---|
[e0886db] | 1861 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1862 | }
|
---|
| 1863 |
|
---|
[9c1600c] | 1864 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 1865 | // StmtExpr
|
---|
[13932f14] | 1866 | template< typename pass_type >
|
---|
[ab904dc] | 1867 | void PassVisitor< pass_type >::visit( StmtExpr * node ) {
|
---|
[9c1600c] | 1868 | VISIT_START( node );
|
---|
| 1869 |
|
---|
| 1870 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
---|
| 1871 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
---|
| 1872 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
---|
| 1873 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
---|
| 1874 |
|
---|
[e0886db] | 1875 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1876 | maybeAccept_impl ( node->statements , *this );
|
---|
| 1877 | maybeAccept_impl ( node->returnDecls, *this );
|
---|
| 1878 | maybeAccept_impl ( node->dtors , *this );
|
---|
[9c1600c] | 1879 |
|
---|
| 1880 | VISIT_END( node );
|
---|
[13932f14] | 1881 | }
|
---|
| 1882 |
|
---|
[296b2be] | 1883 | template< typename pass_type >
|
---|
| 1884 | Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
|
---|
| 1885 | MUTATE_START( node );
|
---|
[4551a6e] | 1886 |
|
---|
[296b2be] | 1887 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
---|
[134322e] | 1888 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
---|
| 1889 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
---|
| 1890 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
---|
[296b2be] | 1891 |
|
---|
[e0886db] | 1892 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1893 | maybeMutate_impl ( node->statements , *this );
|
---|
| 1894 | maybeMutate_impl ( node->returnDecls, *this );
|
---|
| 1895 | maybeMutate_impl ( node->dtors , *this );
|
---|
[296b2be] | 1896 |
|
---|
| 1897 | MUTATE_END( Expression, node );
|
---|
| 1898 | }
|
---|
| 1899 |
|
---|
[e0886db] | 1900 | //--------------------------------------------------------------------------
|
---|
| 1901 | // UniqueExpr
|
---|
[13932f14] | 1902 | template< typename pass_type >
|
---|
[ab904dc] | 1903 | void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
|
---|
[e0886db] | 1904 | VISIT_START( node );
|
---|
| 1905 |
|
---|
| 1906 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1907 | maybeAccept_impl ( node->expr , *this );
|
---|
[e0886db] | 1908 |
|
---|
| 1909 | VISIT_END( node );
|
---|
| 1910 | }
|
---|
| 1911 |
|
---|
| 1912 | template< typename pass_type >
|
---|
| 1913 | Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
|
---|
| 1914 | MUTATE_START( node );
|
---|
| 1915 |
|
---|
| 1916 | indexerScopedMutate( node->env , *this );
|
---|
| 1917 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1918 | maybeMutate_impl ( node->expr , *this );
|
---|
[e0886db] | 1919 |
|
---|
| 1920 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1921 | }
|
---|
| 1922 |
|
---|
[73367a8] | 1923 | //--------------------------------------------------------------------------
|
---|
| 1924 | // UntypedInitExpr
|
---|
| 1925 | template< typename pass_type >
|
---|
| 1926 | void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
|
---|
| 1927 | VISIT_START( node );
|
---|
| 1928 |
|
---|
| 1929 | indexerScopedAccept( node->result, *this );
|
---|
| 1930 | maybeAccept_impl ( node->expr , *this );
|
---|
| 1931 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
| 1932 |
|
---|
| 1933 | VISIT_END( node );
|
---|
| 1934 | }
|
---|
| 1935 |
|
---|
| 1936 | template< typename pass_type >
|
---|
| 1937 | Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
|
---|
| 1938 | MUTATE_START( node );
|
---|
| 1939 |
|
---|
| 1940 | indexerScopedMutate( node->env , *this );
|
---|
| 1941 | indexerScopedMutate( node->result, *this );
|
---|
| 1942 | maybeMutate_impl ( node->expr , *this );
|
---|
| 1943 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
| 1944 |
|
---|
| 1945 | MUTATE_END( Expression, node );
|
---|
| 1946 | }
|
---|
| 1947 |
|
---|
| 1948 | //--------------------------------------------------------------------------
|
---|
| 1949 | // InitExpr
|
---|
| 1950 | template< typename pass_type >
|
---|
| 1951 | void PassVisitor< pass_type >::visit( InitExpr * node ) {
|
---|
| 1952 | VISIT_START( node );
|
---|
| 1953 |
|
---|
| 1954 | indexerScopedAccept( node->result, *this );
|
---|
| 1955 | maybeAccept_impl ( node->expr , *this );
|
---|
| 1956 | maybeAccept_impl ( node->designation, *this );
|
---|
| 1957 |
|
---|
| 1958 | VISIT_END( node );
|
---|
| 1959 | }
|
---|
| 1960 |
|
---|
| 1961 | template< typename pass_type >
|
---|
| 1962 | Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
|
---|
| 1963 | MUTATE_START( node );
|
---|
| 1964 |
|
---|
| 1965 | indexerScopedMutate( node->env , *this );
|
---|
| 1966 | indexerScopedMutate( node->result, *this );
|
---|
| 1967 | maybeMutate_impl ( node->expr , *this );
|
---|
| 1968 | maybeMutate_impl ( node->designation, *this );
|
---|
| 1969 |
|
---|
| 1970 | MUTATE_END( Expression, node );
|
---|
| 1971 | }
|
---|
| 1972 |
|
---|
[13932f14] | 1973 | template< typename pass_type >
|
---|
[ab904dc] | 1974 | void PassVisitor< pass_type >::visit( VoidType * node ) {
|
---|
[4551a6e] | 1975 | VISIT_BODY( node );
|
---|
[13932f14] | 1976 | }
|
---|
| 1977 |
|
---|
| 1978 | template< typename pass_type >
|
---|
[ab904dc] | 1979 | void PassVisitor< pass_type >::visit( BasicType * node ) {
|
---|
[4551a6e] | 1980 | VISIT_BODY( node );
|
---|
[13932f14] | 1981 | }
|
---|
| 1982 |
|
---|
| 1983 | template< typename pass_type >
|
---|
[ab904dc] | 1984 | void PassVisitor< pass_type >::visit( PointerType * node ) {
|
---|
[4551a6e] | 1985 | VISIT_BODY( node );
|
---|
[13932f14] | 1986 | }
|
---|
| 1987 |
|
---|
| 1988 | template< typename pass_type >
|
---|
[ab904dc] | 1989 | void PassVisitor< pass_type >::visit( ArrayType * node ) {
|
---|
[4551a6e] | 1990 | VISIT_BODY( node );
|
---|
[13932f14] | 1991 | }
|
---|
| 1992 |
|
---|
[6b9b047] | 1993 | template< typename pass_type >
|
---|
| 1994 | void PassVisitor< pass_type >::visit( ReferenceType * node ) {
|
---|
| 1995 | VISIT_BODY( node );
|
---|
| 1996 | }
|
---|
| 1997 |
|
---|
[13932f14] | 1998 | template< typename pass_type >
|
---|
[ab904dc] | 1999 | void PassVisitor< pass_type >::visit( FunctionType * node ) {
|
---|
[4551a6e] | 2000 | VISIT_BODY( node );
|
---|
[13932f14] | 2001 | }
|
---|
| 2002 |
|
---|
[e0886db] | 2003 | //--------------------------------------------------------------------------
|
---|
| 2004 | // StructInstType
|
---|
[13932f14] | 2005 | template< typename pass_type >
|
---|
[ab904dc] | 2006 | void PassVisitor< pass_type >::visit( StructInstType * node ) {
|
---|
[e0886db] | 2007 | VISIT_START( node );
|
---|
| 2008 |
|
---|
| 2009 | indexerAddStruct( node->name );
|
---|
| 2010 |
|
---|
| 2011 | {
|
---|
| 2012 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2013 | maybeAccept_impl( node->forall , *this );
|
---|
| 2014 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2015 | }
|
---|
| 2016 |
|
---|
| 2017 | VISIT_END( node );
|
---|
| 2018 | }
|
---|
| 2019 |
|
---|
| 2020 | template< typename pass_type >
|
---|
| 2021 | Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
|
---|
| 2022 | MUTATE_START( node );
|
---|
| 2023 |
|
---|
| 2024 | indexerAddStruct( node->name );
|
---|
| 2025 |
|
---|
| 2026 | {
|
---|
| 2027 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2028 | maybeMutate_impl( node->forall , *this );
|
---|
| 2029 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2030 | }
|
---|
| 2031 |
|
---|
| 2032 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2033 | }
|
---|
| 2034 |
|
---|
[e0886db] | 2035 | //--------------------------------------------------------------------------
|
---|
| 2036 | // UnionInstType
|
---|
[13932f14] | 2037 | template< typename pass_type >
|
---|
[ab904dc] | 2038 | void PassVisitor< pass_type >::visit( UnionInstType * node ) {
|
---|
[e0886db] | 2039 | VISIT_START( node );
|
---|
| 2040 |
|
---|
| 2041 | indexerAddStruct( node->name );
|
---|
| 2042 |
|
---|
| 2043 | {
|
---|
| 2044 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2045 | maybeAccept_impl( node->forall , *this );
|
---|
| 2046 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2047 | }
|
---|
| 2048 |
|
---|
| 2049 | VISIT_END( node );
|
---|
| 2050 | }
|
---|
| 2051 |
|
---|
| 2052 | template< typename pass_type >
|
---|
| 2053 | Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
|
---|
| 2054 | MUTATE_START( node );
|
---|
| 2055 |
|
---|
| 2056 | indexerAddStruct( node->name );
|
---|
| 2057 |
|
---|
| 2058 | {
|
---|
| 2059 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2060 | maybeMutate_impl( node->forall , *this );
|
---|
| 2061 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2062 | }
|
---|
| 2063 |
|
---|
| 2064 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2065 | }
|
---|
| 2066 |
|
---|
[e0886db] | 2067 | //--------------------------------------------------------------------------
|
---|
| 2068 | // EnumInstType
|
---|
[13932f14] | 2069 | template< typename pass_type >
|
---|
[ab904dc] | 2070 | void PassVisitor< pass_type >::visit( EnumInstType * node ) {
|
---|
[4551a6e] | 2071 | VISIT_BODY( node );
|
---|
[13932f14] | 2072 | }
|
---|
| 2073 |
|
---|
[e0886db] | 2074 | template< typename pass_type >
|
---|
| 2075 | Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
|
---|
| 2076 | MUTATE_BODY( Type, node );
|
---|
| 2077 | }
|
---|
| 2078 |
|
---|
| 2079 | //--------------------------------------------------------------------------
|
---|
| 2080 | // TraitInstType
|
---|
[13932f14] | 2081 | template< typename pass_type >
|
---|
[ab904dc] | 2082 | void PassVisitor< pass_type >::visit( TraitInstType * node ) {
|
---|
[e0886db] | 2083 | VISIT_START( node );
|
---|
| 2084 |
|
---|
[3c398b6] | 2085 | maybeAccept_impl( node->forall , *this );
|
---|
| 2086 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2087 |
|
---|
| 2088 | VISIT_END( node );
|
---|
| 2089 | }
|
---|
| 2090 |
|
---|
| 2091 | template< typename pass_type >
|
---|
| 2092 | Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
|
---|
| 2093 | MUTATE_START( node );
|
---|
| 2094 |
|
---|
[3c398b6] | 2095 | maybeMutate_impl( node->forall , *this );
|
---|
| 2096 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2097 |
|
---|
| 2098 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2099 | }
|
---|
| 2100 |
|
---|
[e0886db] | 2101 | //--------------------------------------------------------------------------
|
---|
| 2102 | // TypeInstType
|
---|
[13932f14] | 2103 | template< typename pass_type >
|
---|
[ab904dc] | 2104 | void PassVisitor< pass_type >::visit( TypeInstType * node ) {
|
---|
[4551a6e] | 2105 | VISIT_BODY( node );
|
---|
[13932f14] | 2106 | }
|
---|
| 2107 |
|
---|
| 2108 | template< typename pass_type >
|
---|
[ab904dc] | 2109 | void PassVisitor< pass_type >::visit( TupleType * node ) {
|
---|
[4551a6e] | 2110 | VISIT_BODY( node );
|
---|
[13932f14] | 2111 | }
|
---|
| 2112 |
|
---|
| 2113 | template< typename pass_type >
|
---|
[ab904dc] | 2114 | void PassVisitor< pass_type >::visit( TypeofType * node ) {
|
---|
[4551a6e] | 2115 | VISIT_BODY( node );
|
---|
[13932f14] | 2116 | }
|
---|
| 2117 |
|
---|
| 2118 | template< typename pass_type >
|
---|
[ab904dc] | 2119 | void PassVisitor< pass_type >::visit( AttrType * node ) {
|
---|
[4551a6e] | 2120 | VISIT_BODY( node );
|
---|
[13932f14] | 2121 | }
|
---|
| 2122 |
|
---|
| 2123 | template< typename pass_type >
|
---|
[ab904dc] | 2124 | void PassVisitor< pass_type >::visit( VarArgsType * node ) {
|
---|
[4551a6e] | 2125 | VISIT_BODY( node );
|
---|
[13932f14] | 2126 | }
|
---|
| 2127 |
|
---|
| 2128 | template< typename pass_type >
|
---|
[ab904dc] | 2129 | void PassVisitor< pass_type >::visit( ZeroType * node ) {
|
---|
[4551a6e] | 2130 | VISIT_BODY( node );
|
---|
[13932f14] | 2131 | }
|
---|
| 2132 |
|
---|
| 2133 | template< typename pass_type >
|
---|
[ab904dc] | 2134 | void PassVisitor< pass_type >::visit( OneType * node ) {
|
---|
[4551a6e] | 2135 | VISIT_BODY( node );
|
---|
[13932f14] | 2136 | }
|
---|
| 2137 |
|
---|
[b11d8e2] | 2138 | template< typename pass_type >
|
---|
| 2139 | void PassVisitor< pass_type >::visit( Designation * node ) {
|
---|
| 2140 | VISIT_START( node );
|
---|
| 2141 |
|
---|
[3c398b6] | 2142 | maybeAccept_impl( node->get_designators(), *this );
|
---|
[b11d8e2] | 2143 |
|
---|
| 2144 | VISIT_END( node );
|
---|
| 2145 | }
|
---|
| 2146 |
|
---|
| 2147 | template< typename pass_type >
|
---|
| 2148 | Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
|
---|
| 2149 | MUTATE_START( node );
|
---|
| 2150 |
|
---|
[3c398b6] | 2151 | maybeMutate_impl( node->get_designators(), *this );
|
---|
[b11d8e2] | 2152 |
|
---|
| 2153 | MUTATE_END( Designation, node );
|
---|
| 2154 | }
|
---|
| 2155 |
|
---|
[9c1600c] | 2156 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 2157 | // SingleInit
|
---|
[13932f14] | 2158 | template< typename pass_type >
|
---|
[ab904dc] | 2159 | void PassVisitor< pass_type >::visit( SingleInit * node ) {
|
---|
[9c1600c] | 2160 | VISIT_START( node );
|
---|
| 2161 |
|
---|
| 2162 | visitExpression( node->get_value() );
|
---|
| 2163 |
|
---|
| 2164 | VISIT_END( node );
|
---|
[13932f14] | 2165 | }
|
---|
| 2166 |
|
---|
[296b2be] | 2167 | template< typename pass_type >
|
---|
| 2168 | Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
|
---|
| 2169 | MUTATE_START( node );
|
---|
| 2170 |
|
---|
| 2171 | node->set_value( mutateExpression( node->get_value() ) );
|
---|
| 2172 |
|
---|
| 2173 | MUTATE_END( Initializer, node );
|
---|
| 2174 | }
|
---|
| 2175 |
|
---|
[13932f14] | 2176 | template< typename pass_type >
|
---|
[ab904dc] | 2177 | void PassVisitor< pass_type >::visit( ListInit * node ) {
|
---|
[4551a6e] | 2178 | VISIT_BODY( node );
|
---|
[13932f14] | 2179 | }
|
---|
| 2180 |
|
---|
| 2181 | template< typename pass_type >
|
---|
[ab904dc] | 2182 | void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
|
---|
[4551a6e] | 2183 | VISIT_BODY( node );
|
---|
[13932f14] | 2184 | }
|
---|
| 2185 |
|
---|
| 2186 | template< typename pass_type >
|
---|
[ab904dc] | 2187 | void PassVisitor< pass_type >::visit( Subrange * node ) {
|
---|
[4551a6e] | 2188 | VISIT_BODY( node );
|
---|
[13932f14] | 2189 | }
|
---|
| 2190 |
|
---|
| 2191 | template< typename pass_type >
|
---|
[ab904dc] | 2192 | void PassVisitor< pass_type >::visit( Constant * node ) {
|
---|
[4551a6e] | 2193 | VISIT_BODY( node );
|
---|
[13932f14] | 2194 | }
|
---|
[ab904dc] | 2195 |
|
---|
[5ea7a22] | 2196 | template< typename pass_type >
|
---|
| 2197 | void PassVisitor< pass_type >::visit( Attribute * node ) {
|
---|
| 2198 | VISIT_BODY( node );
|
---|
| 2199 | }
|
---|
| 2200 |
|
---|
[ab904dc] | 2201 | //---------------------------------------------------------------------------------------------------------------
|
---|
| 2202 | template< typename pass_type >
|
---|
| 2203 | Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
|
---|
| 2204 | MUTATE_BODY( Type, node );
|
---|
| 2205 | }
|
---|
| 2206 |
|
---|
| 2207 | template< typename pass_type >
|
---|
| 2208 | Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
|
---|
| 2209 | MUTATE_BODY( Type, node );
|
---|
| 2210 | }
|
---|
| 2211 |
|
---|
| 2212 | template< typename pass_type >
|
---|
| 2213 | Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
|
---|
| 2214 | MUTATE_BODY( Type, node );
|
---|
| 2215 | }
|
---|
| 2216 |
|
---|
| 2217 | template< typename pass_type >
|
---|
| 2218 | Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
|
---|
| 2219 | MUTATE_BODY( Type, node );
|
---|
| 2220 | }
|
---|
| 2221 |
|
---|
| 2222 | template< typename pass_type >
|
---|
[6b9b047] | 2223 | Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
|
---|
| 2224 | MUTATE_BODY( Type, node );
|
---|
| 2225 | }
|
---|
| 2226 |
|
---|
| 2227 | template< typename pass_type >
|
---|
[ab904dc] | 2228 | Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
|
---|
| 2229 | MUTATE_BODY( Type, node );
|
---|
| 2230 | }
|
---|
| 2231 |
|
---|
| 2232 | template< typename pass_type >
|
---|
| 2233 | Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
|
---|
| 2234 | MUTATE_BODY( Type, node );
|
---|
| 2235 | }
|
---|
| 2236 |
|
---|
| 2237 | template< typename pass_type >
|
---|
| 2238 | Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
|
---|
| 2239 | MUTATE_BODY( Type, node );
|
---|
| 2240 | }
|
---|
| 2241 |
|
---|
| 2242 | template< typename pass_type >
|
---|
| 2243 | Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
|
---|
| 2244 | MUTATE_BODY( Type, node );
|
---|
| 2245 | }
|
---|
| 2246 |
|
---|
| 2247 | template< typename pass_type >
|
---|
| 2248 | Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
|
---|
| 2249 | MUTATE_BODY( Type, node );
|
---|
| 2250 | }
|
---|
| 2251 |
|
---|
| 2252 | template< typename pass_type >
|
---|
| 2253 | Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
|
---|
| 2254 | MUTATE_BODY( Type, node );
|
---|
| 2255 | }
|
---|
| 2256 |
|
---|
| 2257 | template< typename pass_type >
|
---|
| 2258 | Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
|
---|
| 2259 | MUTATE_BODY( Type, node );
|
---|
| 2260 | }
|
---|
| 2261 |
|
---|
| 2262 | template< typename pass_type >
|
---|
| 2263 | Type * PassVisitor< pass_type >::mutate( OneType * node ) {
|
---|
| 2264 | MUTATE_BODY( Type, node );
|
---|
| 2265 | }
|
---|
| 2266 |
|
---|
| 2267 | template< typename pass_type >
|
---|
| 2268 | Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
|
---|
| 2269 | MUTATE_BODY( Initializer, node );
|
---|
| 2270 | }
|
---|
| 2271 |
|
---|
| 2272 | template< typename pass_type >
|
---|
| 2273 | Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
|
---|
| 2274 | MUTATE_BODY( Initializer, node );
|
---|
| 2275 | }
|
---|
| 2276 |
|
---|
| 2277 | template< typename pass_type >
|
---|
| 2278 | Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) {
|
---|
| 2279 | MUTATE_BODY( Subrange, node );
|
---|
| 2280 | }
|
---|
| 2281 |
|
---|
| 2282 | template< typename pass_type >
|
---|
| 2283 | Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
|
---|
| 2284 | MUTATE_BODY( Constant, node );
|
---|
[4551a6e] | 2285 | }
|
---|
[5ea7a22] | 2286 |
|
---|
| 2287 | template< typename pass_type >
|
---|
| 2288 | Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
|
---|
| 2289 | MUTATE_BODY( Attribute, node );
|
---|
| 2290 | }
|
---|
[447c356] | 2291 |
|
---|
| 2292 | template< typename pass_type >
|
---|
| 2293 | TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
|
---|
| 2294 | MUTATE_START( node );
|
---|
| 2295 |
|
---|
| 2296 | for ( auto & p : node->typeEnv ) {
|
---|
| 2297 | indexerScopedMutate( p.second, *this );
|
---|
| 2298 | }
|
---|
| 2299 | for ( auto & p : node->varEnv ) {
|
---|
| 2300 | indexerScopedMutate( p.second, *this );
|
---|
| 2301 | }
|
---|
| 2302 |
|
---|
| 2303 | MUTATE_END( TypeSubstitution, node );
|
---|
| 2304 | }
|
---|