[13932f14] | 1 | #pragma once
|
---|
[3268a58] | 2 | // IWYU pragma: private, include "PassVisitor.h"
|
---|
[13932f14] | 3 |
|
---|
[3c398b6] | 4 | #define VISIT_START( node ) \
|
---|
| 5 | __attribute__((unused)) \
|
---|
| 6 | ChildrenGuard children_guard( get_visit_children_ptr() ); \
|
---|
| 7 | __attribute__((unused)) \
|
---|
[62423350] | 8 | guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
|
---|
[3c398b6] | 9 | call_previsit( node ); \
|
---|
[6e09f211] | 10 |
|
---|
| 11 | #define VISIT_END( node ) \
|
---|
| 12 | call_postvisit( node ); \
|
---|
[9c1600c] | 13 |
|
---|
[3c398b6] | 14 | #define MUTATE_START( node ) \
|
---|
| 15 | __attribute__((unused)) \
|
---|
| 16 | ChildrenGuard children_guard( get_visit_children_ptr() ); \
|
---|
| 17 | __attribute__((unused)) \
|
---|
[62423350] | 18 | guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
|
---|
[3c398b6] | 19 | call_premutate( node ); \
|
---|
[296b2be] | 20 |
|
---|
| 21 | #define MUTATE_END( type, node ) \
|
---|
| 22 | return call_postmutate< type * >( node ); \
|
---|
| 23 |
|
---|
| 24 |
|
---|
[3c398b6] | 25 | #define VISIT_BODY( node ) \
|
---|
| 26 | VISIT_START( node ); \
|
---|
| 27 | if( children_guard ) { \
|
---|
| 28 | Visitor::visit( node ); \
|
---|
| 29 | } \
|
---|
| 30 | VISIT_END( node ); \
|
---|
[13932f14] | 31 |
|
---|
[ab904dc] | 32 |
|
---|
[3c398b6] | 33 | #define MUTATE_BODY( type, node ) \
|
---|
| 34 | MUTATE_START( node ); \
|
---|
| 35 | if( children_guard ) { \
|
---|
| 36 | Mutator::mutate( node ); \
|
---|
| 37 | } \
|
---|
| 38 | MUTATE_END( type, node ); \
|
---|
[296b2be] | 39 |
|
---|
[134322e] | 40 |
|
---|
| 41 |
|
---|
| 42 | template<typename T>
|
---|
| 43 | static inline bool empty( T * ptr ) {
|
---|
| 44 | return !ptr || ptr->empty();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
[6ca154b] | 47 | typedef std::list< Statement * > StmtList_t;
|
---|
| 48 | typedef std::list< Declaration * > DeclList_t;
|
---|
| 49 |
|
---|
| 50 | template<typename iterator_t>
|
---|
| 51 | static inline void splice( iterator_t it, DeclList_t * decls ) {
|
---|
| 52 | std::transform(
|
---|
| 53 | decls->begin(),
|
---|
| 54 | decls->end(),
|
---|
| 55 | it,
|
---|
| 56 | [](Declaration * decl) -> auto {
|
---|
[ba3706f] | 57 | return new DeclStmt( decl );
|
---|
[6ca154b] | 58 | }
|
---|
| 59 | );
|
---|
| 60 | decls->clear();
|
---|
| 61 | }
|
---|
[134322e] | 62 |
|
---|
| 63 | template< typename pass_type >
|
---|
[07c178f0] | 64 | inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
|
---|
[6ca154b] | 65 | DeclList_t* beforeDecls = visitor.get_beforeDecls();
|
---|
| 66 | DeclList_t* afterDecls = visitor.get_afterDecls();
|
---|
[a16764a6] | 67 | SemanticErrorException errors;
|
---|
[134322e] | 68 |
|
---|
[6ca154b] | 69 | for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
|
---|
| 70 | // splice in new declarations after previous decl
|
---|
[d24d4e1] | 71 | if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
|
---|
[6ca154b] | 72 |
|
---|
| 73 | if ( i == decls.end() ) break;
|
---|
| 74 |
|
---|
[522363e] | 75 | try {
|
---|
| 76 | // run visitor on declaration
|
---|
[3c398b6] | 77 | maybeAccept_impl( *i, visitor );
|
---|
[a16764a6] | 78 | } catch( SemanticErrorException &e ) {
|
---|
[522363e] | 79 | errors.append( e );
|
---|
| 80 | }
|
---|
[6ca154b] | 81 |
|
---|
| 82 | // splice in new declarations before current decl
|
---|
| 83 | if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
|
---|
[134322e] | 84 | }
|
---|
[522363e] | 85 | if ( ! errors.isEmpty() ) {
|
---|
| 86 | throw errors;
|
---|
| 87 | }
|
---|
[6ca154b] | 88 | }
|
---|
[134322e] | 89 |
|
---|
[6ca154b] | 90 | template< typename pass_type >
|
---|
[07c178f0] | 91 | inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
|
---|
[6ca154b] | 92 | DeclList_t* beforeDecls = mutator.get_beforeDecls();
|
---|
| 93 | DeclList_t* afterDecls = mutator.get_afterDecls();
|
---|
[a16764a6] | 94 | SemanticErrorException errors;
|
---|
[6ca154b] | 95 |
|
---|
| 96 | for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
|
---|
| 97 | // splice in new declarations after previous decl
|
---|
[d24d4e1] | 98 | if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
|
---|
[6ca154b] | 99 |
|
---|
| 100 | if ( i == decls.end() ) break;
|
---|
[522363e] | 101 | try {
|
---|
| 102 | // run mutator on declaration
|
---|
[3c398b6] | 103 | maybeMutate_impl( *i, mutator );
|
---|
[a16764a6] | 104 | } catch( SemanticErrorException &e ) {
|
---|
[522363e] | 105 | errors.append( e );
|
---|
| 106 | }
|
---|
[6ca154b] | 107 |
|
---|
| 108 | // splice in new declarations before current decl
|
---|
| 109 | if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
|
---|
| 110 | }
|
---|
[522363e] | 111 | if ( ! errors.isEmpty() ) {
|
---|
| 112 | throw errors;
|
---|
| 113 | }
|
---|
[134322e] | 114 | }
|
---|
| 115 |
|
---|
[3c398b6] | 116 | template< typename TreeType, typename pass_type >
|
---|
| 117 | inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
|
---|
| 118 | if ( ! visitor.get_visit_children() ) return;
|
---|
| 119 | if ( tree ) {
|
---|
| 120 | tree->accept( visitor );
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | template< typename Container, typename pass_type >
|
---|
| 125 | inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
|
---|
| 126 | if ( ! visitor.get_visit_children() ) return;
|
---|
[a16764a6] | 127 | SemanticErrorException errors;
|
---|
[e0886db] | 128 | for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
|
---|
| 129 | try {
|
---|
| 130 | if ( *i ) {
|
---|
| 131 | (*i)->accept( visitor );
|
---|
| 132 | }
|
---|
[a16764a6] | 133 | } catch( SemanticErrorException &e ) {
|
---|
[e0886db] | 134 | errors.append( e );
|
---|
| 135 | }
|
---|
| 136 | }
|
---|
| 137 | if ( ! errors.isEmpty() ) {
|
---|
| 138 | throw errors;
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
[3c398b6] | 142 | template< typename TreeType, typename pass_type >
|
---|
| 143 | inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
|
---|
| 144 | if ( ! mutator.get_visit_children() ) return;
|
---|
| 145 |
|
---|
| 146 | if ( tree ) {
|
---|
| 147 | tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
|
---|
| 148 | }
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | template< typename Container, typename pass_type >
|
---|
| 152 | inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
|
---|
| 153 | if ( ! mutator.get_visit_children() ) return;
|
---|
[a16764a6] | 154 | SemanticErrorException errors;
|
---|
[e0886db] | 155 | for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
|
---|
| 156 | try {
|
---|
| 157 | if ( *i ) {
|
---|
| 158 | *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
|
---|
| 159 | assert( *i );
|
---|
| 160 | } // if
|
---|
[a16764a6] | 161 | } catch( SemanticErrorException &e ) {
|
---|
[e0886db] | 162 | errors.append( e );
|
---|
| 163 | } // try
|
---|
| 164 | } // for
|
---|
| 165 | if ( ! errors.isEmpty() ) {
|
---|
| 166 | throw errors;
|
---|
| 167 | } // if
|
---|
| 168 | }
|
---|
| 169 |
|
---|
[296b2be] | 170 | template< typename pass_type >
|
---|
[6ca154b] | 171 | template< typename func_t >
|
---|
| 172 | void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
|
---|
[3c398b6] | 173 | if ( ! get_visit_children() ) return;
|
---|
[a16764a6] | 174 | SemanticErrorException errors;
|
---|
[296b2be] | 175 |
|
---|
[2a7b3ca] | 176 | // don't want statements from outer CompoundStmts to be added to this CompoundStmt
|
---|
| 177 | ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
|
---|
| 178 | ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
|
---|
| 179 | ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
|
---|
| 180 | ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
|
---|
| 181 |
|
---|
[134322e] | 182 | StmtList_t* beforeStmts = get_beforeStmts();
|
---|
| 183 | StmtList_t* afterStmts = get_afterStmts();
|
---|
[6ca154b] | 184 | DeclList_t* beforeDecls = get_beforeDecls();
|
---|
| 185 | DeclList_t* afterDecls = get_afterDecls();
|
---|
[134322e] | 186 |
|
---|
[296b2be] | 187 | for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
|
---|
[6ca154b] | 188 |
|
---|
| 189 | if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }
|
---|
[134322e] | 190 | if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
|
---|
[6ca154b] | 191 |
|
---|
[296b2be] | 192 | try {
|
---|
[6ca154b] | 193 | func( *i );
|
---|
| 194 | assert(( empty( beforeStmts ) && empty( afterStmts ))
|
---|
| 195 | || ( empty( beforeDecls ) && empty( afterDecls )) );
|
---|
| 196 |
|
---|
[a16764a6] | 197 | } catch ( SemanticErrorException &e ) {
|
---|
[296b2be] | 198 | errors.append( e );
|
---|
[134322e] | 199 | }
|
---|
[6ca154b] | 200 |
|
---|
| 201 | if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }
|
---|
[134322e] | 202 | if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
|
---|
[296b2be] | 203 | }
|
---|
[134322e] | 204 |
|
---|
[6ca154b] | 205 | if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
|
---|
[134322e] | 206 | if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
|
---|
| 207 | if ( !errors.isEmpty() ) { throw errors; }
|
---|
[296b2be] | 208 | }
|
---|
| 209 |
|
---|
| 210 | template< typename pass_type >
|
---|
[6ca154b] | 211 | void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
|
---|
| 212 | handleStatementList( statements, [this]( Statement * stmt) {
|
---|
[3c398b6] | 213 | maybeAccept_impl( stmt, *this );
|
---|
[6ca154b] | 214 | });
|
---|
| 215 | }
|
---|
[134322e] | 216 |
|
---|
[6ca154b] | 217 | template< typename pass_type >
|
---|
| 218 | void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
|
---|
| 219 | handleStatementList( statements, [this]( Statement *& stmt) {
|
---|
[3c398b6] | 220 | maybeMutate_impl( stmt, *this );
|
---|
[6ca154b] | 221 | });
|
---|
[134322e] | 222 | }
|
---|
| 223 |
|
---|
[6ca154b] | 224 |
|
---|
[134322e] | 225 | template< typename pass_type >
|
---|
[6ca154b] | 226 | template< typename func_t >
|
---|
| 227 | Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
|
---|
[3c398b6] | 228 | if ( ! get_visit_children() ) return stmt;
|
---|
| 229 |
|
---|
[134322e] | 230 | // don't want statements from outer CompoundStmts to be added to this CompoundStmt
|
---|
[6ca154b] | 231 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () );
|
---|
| 232 | ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
|
---|
| 233 | ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
|
---|
| 234 | ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
|
---|
| 235 | ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
|
---|
[296b2be] | 236 |
|
---|
[6ca154b] | 237 | Statement *newStmt = func( stmt );
|
---|
[134322e] | 238 |
|
---|
| 239 | StmtList_t* beforeStmts = get_beforeStmts();
|
---|
| 240 | StmtList_t* afterStmts = get_afterStmts();
|
---|
[6ca154b] | 241 | DeclList_t* beforeDecls = get_beforeDecls();
|
---|
| 242 | DeclList_t* afterDecls = get_afterDecls();
|
---|
[134322e] | 243 |
|
---|
[6ca154b] | 244 | if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; }
|
---|
| 245 | assert(( empty( beforeStmts ) && empty( afterStmts ))
|
---|
| 246 | || ( empty( beforeDecls ) && empty( afterDecls )) );
|
---|
[134322e] | 247 |
|
---|
[ba3706f] | 248 | CompoundStmt *compound = new CompoundStmt();
|
---|
[6ca154b] | 249 | if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); }
|
---|
[134322e] | 250 | if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
|
---|
| 251 | compound->get_kids().push_back( newStmt );
|
---|
[6ca154b] | 252 | if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }
|
---|
[134322e] | 253 | if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
|
---|
| 254 | return compound;
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | template< typename pass_type >
|
---|
[6ca154b] | 258 | Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
|
---|
| 259 | return handleStatement( stmt, [this]( Statement * stmt ) {
|
---|
[3c398b6] | 260 | maybeAccept_impl( stmt, *this );
|
---|
[6ca154b] | 261 | return stmt;
|
---|
| 262 | });
|
---|
| 263 | }
|
---|
[134322e] | 264 |
|
---|
[6ca154b] | 265 | template< typename pass_type >
|
---|
| 266 | Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
|
---|
| 267 | return handleStatement( stmt, [this]( Statement * stmt ) {
|
---|
[3c398b6] | 268 | maybeMutate_impl( stmt, *this );
|
---|
| 269 | return stmt;
|
---|
[6ca154b] | 270 | });
|
---|
[296b2be] | 271 | }
|
---|
| 272 |
|
---|
| 273 | template< typename pass_type >
|
---|
[6ca154b] | 274 | template< typename func_t >
|
---|
| 275 | Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
|
---|
[3c398b6] | 276 | if ( ! get_visit_children() ) return expr;
|
---|
[296b2be] | 277 | if( !expr ) return nullptr;
|
---|
| 278 |
|
---|
[134322e] | 279 | auto env_ptr = get_env_ptr();
|
---|
| 280 | if ( env_ptr && expr->get_env() ) {
|
---|
| 281 | *env_ptr = expr->get_env();
|
---|
[296b2be] | 282 | }
|
---|
[6ca154b] | 283 |
|
---|
[3c398b6] | 284 | // should env be moved onto the result of the mutate?
|
---|
[6ca154b] | 285 | return func( expr );
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | template< typename pass_type >
|
---|
| 289 | Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
|
---|
| 290 | return handleExpression(expr, [this]( Expression * expr ) {
|
---|
[3c398b6] | 291 | maybeAccept_impl( expr, *this );
|
---|
[6ca154b] | 292 | return expr;
|
---|
[d24d4e1] | 293 | });
|
---|
[296b2be] | 294 | }
|
---|
[ab904dc] | 295 |
|
---|
[6ca154b] | 296 | template< typename pass_type >
|
---|
| 297 | Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
|
---|
| 298 | return handleExpression(expr, [this]( Expression * expr ) {
|
---|
[3c398b6] | 299 | maybeMutate_impl( expr, *this );
|
---|
| 300 | return expr;
|
---|
[6ca154b] | 301 | });
|
---|
| 302 | }
|
---|
[ab904dc] | 303 |
|
---|
[3c398b6] | 304 | template< typename TreeType, typename VisitorType >
|
---|
| 305 | inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
|
---|
| 306 | if ( ! visitor.get_visit_children() ) return;
|
---|
| 307 | auto guard = makeFuncGuard(
|
---|
| 308 | [&visitor]() { visitor.indexerScopeEnter(); },
|
---|
| 309 | [&visitor]() { visitor.indexerScopeLeave(); }
|
---|
| 310 | );
|
---|
| 311 | maybeAccept_impl( tree, visitor );
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | template< typename TreeType, typename MutatorType >
|
---|
| 315 | inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
|
---|
| 316 | if ( ! mutator.get_visit_children() ) return;
|
---|
| 317 | auto guard = makeFuncGuard(
|
---|
| 318 | [&mutator]() { mutator.indexerScopeEnter(); },
|
---|
| 319 | [&mutator]() { mutator.indexerScopeLeave(); }
|
---|
| 320 | );
|
---|
| 321 | maybeMutate_impl( tree, mutator );
|
---|
| 322 | }
|
---|
| 323 |
|
---|
[296b2be] | 324 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
---|
[e0886db] | 325 | //========================================================================================================================================================================
|
---|
| 326 | //========================================================================================================================================================================
|
---|
| 327 | //========================================================================================================================================================================
|
---|
| 328 | //========================================================================================================================================================================
|
---|
| 329 | //========================================================================================================================================================================
|
---|
| 330 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
---|
[13932f14] | 331 |
|
---|
[33a25f9] | 332 | // A NOTE ON THE ORDER OF TRAVERSAL
|
---|
| 333 | //
|
---|
| 334 | // Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is
|
---|
| 335 | // no such thing as a recursive type or typedef.
|
---|
| 336 | //
|
---|
| 337 | // typedef struct { T *x; } T; // never allowed
|
---|
| 338 | //
|
---|
| 339 | // for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
|
---|
| 340 | // members are traversed, and then the complete type should be added (assuming the type is completed by this particular
|
---|
| 341 | // declaration).
|
---|
| 342 | //
|
---|
| 343 | // struct T { struct T *x; }; // allowed
|
---|
| 344 | //
|
---|
| 345 | // It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
|
---|
| 346 | // traversal may modify the definition of the type and these modifications should be visible when the symbol table is
|
---|
| 347 | // queried later in this pass.
|
---|
| 348 | //
|
---|
| 349 | // TODO: figure out whether recursive contexts are sensible/possible/reasonable.
|
---|
[e0886db] | 350 |
|
---|
| 351 | //--------------------------------------------------------------------------
|
---|
| 352 | // ObjectDecl
|
---|
[13932f14] | 353 | template< typename pass_type >
|
---|
[ab904dc] | 354 | void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
|
---|
[e0886db] | 355 | VISIT_START( node );
|
---|
| 356 |
|
---|
| 357 | indexerScopedAccept( node->type , *this );
|
---|
[3c398b6] | 358 | maybeAccept_impl ( node->init , *this );
|
---|
| 359 | maybeAccept_impl ( node->bitfieldWidth, *this );
|
---|
| 360 | maybeAccept_impl ( node->attributes , *this );
|
---|
[e0886db] | 361 |
|
---|
[2cb70aa] | 362 | indexerAddId( node );
|
---|
[e0886db] | 363 |
|
---|
| 364 | VISIT_END( node );
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | template< typename pass_type >
|
---|
| 368 | DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) {
|
---|
| 369 | MUTATE_START( node );
|
---|
| 370 |
|
---|
| 371 | indexerScopedMutate( node->type , *this );
|
---|
[3c398b6] | 372 | maybeMutate_impl ( node->init , *this );
|
---|
| 373 | maybeMutate_impl ( node->bitfieldWidth, *this );
|
---|
| 374 | maybeMutate_impl ( node->attributes , *this );
|
---|
[e0886db] | 375 |
|
---|
[2cb70aa] | 376 | indexerAddId( node );
|
---|
[e0886db] | 377 |
|
---|
| 378 | MUTATE_END( DeclarationWithType, node );
|
---|
[13932f14] | 379 | }
|
---|
| 380 |
|
---|
[e0886db] | 381 | //--------------------------------------------------------------------------
|
---|
| 382 | // FunctionDecl
|
---|
[13932f14] | 383 | template< typename pass_type >
|
---|
[ab904dc] | 384 | void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
|
---|
[e0886db] | 385 | VISIT_START( node );
|
---|
| 386 |
|
---|
[2cb70aa] | 387 | indexerAddId( node );
|
---|
[e0886db] | 388 |
|
---|
[7aaec67] | 389 | maybeAccept_impl( node->withExprs, *this );
|
---|
[e0886db] | 390 | {
|
---|
[2cb70aa] | 391 | // with clause introduces a level of scope (for the with expression members).
|
---|
| 392 | // with clause exprs are added to the indexer before parameters so that parameters
|
---|
| 393 | // shadow with exprs and not the other way around.
|
---|
[e0886db] | 394 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[0ac366b] | 395 | indexerAddWith( node->withExprs, node );
|
---|
[7aaec67] | 396 | {
|
---|
| 397 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
| 398 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2
|
---|
| 399 | static ObjectDecl func(
|
---|
| 400 | "__func__", noStorageClasses, LinkageSpec::C, nullptr,
|
---|
| 401 | new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
|
---|
| 402 | nullptr
|
---|
| 403 | );
|
---|
| 404 | indexerAddId( &func );
|
---|
| 405 | maybeAccept_impl( node->type, *this );
|
---|
| 406 | maybeAccept_impl( node->statements, *this );
|
---|
| 407 | maybeAccept_impl( node->attributes, *this );
|
---|
| 408 | }
|
---|
[e0886db] | 409 | }
|
---|
| 410 |
|
---|
| 411 | VISIT_END( node );
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | template< typename pass_type >
|
---|
| 415 | DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
|
---|
| 416 | MUTATE_START( node );
|
---|
| 417 |
|
---|
[2cb70aa] | 418 | indexerAddId( node );
|
---|
[e0886db] | 419 |
|
---|
| 420 | {
|
---|
[2cb70aa] | 421 | // with clause introduces a level of scope (for the with expression members).
|
---|
| 422 | // with clause exprs are added to the indexer before parameters so that parameters
|
---|
| 423 | // shadow with exprs and not the other way around.
|
---|
[e0886db] | 424 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[0ac366b] | 425 | indexerAddWith( node->withExprs, node );
|
---|
[7aaec67] | 426 | {
|
---|
| 427 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
| 428 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2
|
---|
| 429 | static ObjectDecl func(
|
---|
| 430 | "__func__", noStorageClasses, LinkageSpec::C, nullptr,
|
---|
| 431 | new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
|
---|
| 432 | nullptr
|
---|
| 433 | );
|
---|
| 434 | indexerAddId( &func );
|
---|
| 435 | maybeMutate_impl( node->type, *this );
|
---|
| 436 | maybeMutate_impl( node->statements, *this );
|
---|
| 437 | maybeMutate_impl( node->attributes, *this );
|
---|
| 438 | }
|
---|
[e0886db] | 439 | }
|
---|
| 440 |
|
---|
| 441 | MUTATE_END( DeclarationWithType, node );
|
---|
[13932f14] | 442 | }
|
---|
| 443 |
|
---|
[e0886db] | 444 | //--------------------------------------------------------------------------
|
---|
| 445 | // StructDecl
|
---|
[13932f14] | 446 | template< typename pass_type >
|
---|
[ab904dc] | 447 | void PassVisitor< pass_type >::visit( StructDecl * node ) {
|
---|
[e0886db] | 448 | VISIT_START( node );
|
---|
| 449 |
|
---|
| 450 | // make up a forward declaration and add it before processing the members
|
---|
| 451 | // needs to be on the heap because addStruct saves the pointer
|
---|
| 452 | indexerAddStructFwd( node );
|
---|
| 453 |
|
---|
| 454 | {
|
---|
| 455 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 456 | maybeAccept_impl( node->parameters, *this );
|
---|
| 457 | maybeAccept_impl( node->members , *this );
|
---|
[e0886db] | 458 | }
|
---|
| 459 |
|
---|
| 460 | // this addition replaces the forward declaration
|
---|
| 461 | indexerAddStruct( node );
|
---|
| 462 |
|
---|
| 463 | VISIT_END( node );
|
---|
| 464 | }
|
---|
| 465 |
|
---|
| 466 | template< typename pass_type >
|
---|
| 467 | Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
|
---|
| 468 | MUTATE_START( node );
|
---|
| 469 |
|
---|
| 470 | // make up a forward declaration and add it before processing the members
|
---|
| 471 | // needs to be on the heap because addStruct saves the pointer
|
---|
| 472 | indexerAddStructFwd( node );
|
---|
| 473 |
|
---|
| 474 | {
|
---|
| 475 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 476 | maybeMutate_impl( node->parameters, *this );
|
---|
| 477 | maybeMutate_impl( node->members , *this );
|
---|
[e0886db] | 478 | }
|
---|
| 479 |
|
---|
| 480 | // this addition replaces the forward declaration
|
---|
| 481 | indexerAddStruct( node );
|
---|
| 482 |
|
---|
| 483 | MUTATE_END( Declaration, node );
|
---|
[13932f14] | 484 | }
|
---|
| 485 |
|
---|
[e0886db] | 486 | //--------------------------------------------------------------------------
|
---|
| 487 | // UnionDecl
|
---|
[13932f14] | 488 | template< typename pass_type >
|
---|
[ab904dc] | 489 | void PassVisitor< pass_type >::visit( UnionDecl * node ) {
|
---|
[e0886db] | 490 | VISIT_START( node );
|
---|
| 491 |
|
---|
| 492 | // make up a forward declaration and add it before processing the members
|
---|
| 493 | indexerAddUnionFwd( node );
|
---|
| 494 |
|
---|
| 495 | {
|
---|
| 496 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 497 | maybeAccept_impl( node->parameters, *this );
|
---|
| 498 | maybeAccept_impl( node->members , *this );
|
---|
[e0886db] | 499 | }
|
---|
| 500 |
|
---|
| 501 | indexerAddUnion( node );
|
---|
| 502 |
|
---|
| 503 | VISIT_END( node );
|
---|
| 504 | }
|
---|
| 505 |
|
---|
| 506 | template< typename pass_type >
|
---|
| 507 | Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
|
---|
| 508 | MUTATE_START( node );
|
---|
| 509 |
|
---|
| 510 | // make up a forward declaration and add it before processing the members
|
---|
| 511 | indexerAddUnionFwd( node );
|
---|
| 512 |
|
---|
| 513 | {
|
---|
| 514 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 515 | maybeMutate_impl( node->parameters, *this );
|
---|
| 516 | maybeMutate_impl( node->members , *this );
|
---|
[e0886db] | 517 | }
|
---|
| 518 |
|
---|
| 519 | indexerAddUnion( node );
|
---|
| 520 |
|
---|
| 521 | MUTATE_END( Declaration, node );
|
---|
[13932f14] | 522 | }
|
---|
| 523 |
|
---|
[e0886db] | 524 | //--------------------------------------------------------------------------
|
---|
| 525 | // EnumDecl
|
---|
[13932f14] | 526 | template< typename pass_type >
|
---|
[ab904dc] | 527 | void PassVisitor< pass_type >::visit( EnumDecl * node ) {
|
---|
[e0886db] | 528 | VISIT_START( node );
|
---|
| 529 |
|
---|
| 530 | indexerAddEnum( node );
|
---|
| 531 |
|
---|
[33a25f9] | 532 | // unlike structs, traits, and unions, enums inject their members into the global scope
|
---|
[3c398b6] | 533 | maybeAccept_impl( node->parameters, *this );
|
---|
| 534 | maybeAccept_impl( node->members , *this );
|
---|
[e0886db] | 535 |
|
---|
| 536 | VISIT_END( node );
|
---|
[13932f14] | 537 | }
|
---|
| 538 |
|
---|
[e0886db] | 539 | template< typename pass_type >
|
---|
| 540 | Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
|
---|
| 541 | MUTATE_START( node );
|
---|
| 542 |
|
---|
| 543 | indexerAddEnum( node );
|
---|
| 544 |
|
---|
[522363e] | 545 | // unlike structs, traits, and unions, enums inject their members into the global scope
|
---|
[3c398b6] | 546 | maybeMutate_impl( node->parameters, *this );
|
---|
| 547 | maybeMutate_impl( node->members , *this );
|
---|
[e0886db] | 548 |
|
---|
| 549 | MUTATE_END( Declaration, node );
|
---|
| 550 | }
|
---|
| 551 |
|
---|
| 552 | //--------------------------------------------------------------------------
|
---|
| 553 | // TraitDecl
|
---|
[13932f14] | 554 | template< typename pass_type >
|
---|
[ab904dc] | 555 | void PassVisitor< pass_type >::visit( TraitDecl * node ) {
|
---|
[e0886db] | 556 | VISIT_START( node );
|
---|
| 557 |
|
---|
| 558 | {
|
---|
| 559 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 560 | maybeAccept_impl( node->parameters, *this );
|
---|
| 561 | maybeAccept_impl( node->members , *this );
|
---|
[e0886db] | 562 | }
|
---|
| 563 |
|
---|
| 564 | indexerAddTrait( node );
|
---|
| 565 |
|
---|
| 566 | VISIT_END( node );
|
---|
[13932f14] | 567 | }
|
---|
| 568 |
|
---|
[e0886db] | 569 | template< typename pass_type >
|
---|
| 570 | Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
|
---|
| 571 | MUTATE_START( node );
|
---|
| 572 |
|
---|
| 573 | {
|
---|
| 574 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 575 | maybeMutate_impl( node->parameters, *this );
|
---|
| 576 | maybeMutate_impl( node->members , *this );
|
---|
[e0886db] | 577 | }
|
---|
| 578 |
|
---|
| 579 | indexerAddTrait( node );
|
---|
| 580 |
|
---|
| 581 | MUTATE_END( Declaration, node );
|
---|
| 582 | }
|
---|
| 583 |
|
---|
| 584 | //--------------------------------------------------------------------------
|
---|
| 585 | // TypeDecl
|
---|
[13932f14] | 586 | template< typename pass_type >
|
---|
[ab904dc] | 587 | void PassVisitor< pass_type >::visit( TypeDecl * node ) {
|
---|
[e0886db] | 588 | VISIT_START( node );
|
---|
| 589 |
|
---|
| 590 | {
|
---|
| 591 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 592 | maybeAccept_impl( node->parameters, *this );
|
---|
| 593 | maybeAccept_impl( node->base , *this );
|
---|
[e0886db] | 594 | }
|
---|
| 595 |
|
---|
[33a25f9] | 596 | // see A NOTE ON THE ORDER OF TRAVERSAL, above
|
---|
| 597 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper
|
---|
| 598 | // and may depend on the type itself
|
---|
[e0886db] | 599 | indexerAddType( node );
|
---|
| 600 |
|
---|
[3c398b6] | 601 | maybeAccept_impl( node->assertions, *this );
|
---|
[e0886db] | 602 |
|
---|
| 603 | indexerScopedAccept( node->init, *this );
|
---|
| 604 |
|
---|
| 605 | VISIT_END( node );
|
---|
| 606 | }
|
---|
| 607 |
|
---|
| 608 | template< typename pass_type >
|
---|
[982832e] | 609 | Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
|
---|
[e0886db] | 610 | MUTATE_START( node );
|
---|
| 611 |
|
---|
| 612 | {
|
---|
| 613 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 614 | maybeMutate_impl( node->parameters, *this );
|
---|
| 615 | maybeMutate_impl( node->base , *this );
|
---|
[e0886db] | 616 | }
|
---|
| 617 |
|
---|
[33a25f9] | 618 | // see A NOTE ON THE ORDER OF TRAVERSAL, above
|
---|
| 619 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper
|
---|
| 620 | // and may depend on the type itself
|
---|
[e0886db] | 621 | indexerAddType( node );
|
---|
| 622 |
|
---|
[3c398b6] | 623 | maybeMutate_impl( node->assertions, *this );
|
---|
[e0886db] | 624 |
|
---|
| 625 | indexerScopedMutate( node->init, *this );
|
---|
| 626 |
|
---|
[982832e] | 627 | MUTATE_END( Declaration, node );
|
---|
[13932f14] | 628 | }
|
---|
| 629 |
|
---|
[e0886db] | 630 | //--------------------------------------------------------------------------
|
---|
| 631 | // TypedefDecl
|
---|
[13932f14] | 632 | template< typename pass_type >
|
---|
[ab904dc] | 633 | void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
|
---|
[e0886db] | 634 | VISIT_START( node );
|
---|
| 635 |
|
---|
| 636 | {
|
---|
| 637 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 638 | maybeAccept_impl( node->parameters, *this );
|
---|
| 639 | maybeAccept_impl( node->base , *this );
|
---|
[e0886db] | 640 | }
|
---|
| 641 |
|
---|
| 642 | indexerAddType( node );
|
---|
| 643 |
|
---|
[3c398b6] | 644 | maybeAccept_impl( node->assertions, *this );
|
---|
[e0886db] | 645 |
|
---|
| 646 | VISIT_END( node );
|
---|
[13932f14] | 647 | }
|
---|
| 648 |
|
---|
| 649 | template< typename pass_type >
|
---|
[e0886db] | 650 | Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
|
---|
| 651 | MUTATE_START( node );
|
---|
| 652 |
|
---|
| 653 | {
|
---|
| 654 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 655 | maybeMutate_impl( node->parameters, *this );
|
---|
| 656 | maybeMutate_impl( node->base , *this );
|
---|
[e0886db] | 657 | }
|
---|
| 658 |
|
---|
| 659 | indexerAddType( node );
|
---|
| 660 |
|
---|
[3c398b6] | 661 | maybeMutate_impl( node->assertions, *this );
|
---|
[e0886db] | 662 |
|
---|
| 663 | MUTATE_END( Declaration, node );
|
---|
[13932f14] | 664 | }
|
---|
| 665 |
|
---|
[9c1600c] | 666 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 667 | // AsmDecl
|
---|
[13932f14] | 668 | template< typename pass_type >
|
---|
[e0886db] | 669 | void PassVisitor< pass_type >::visit( AsmDecl * node ) {
|
---|
[9c1600c] | 670 | VISIT_START( node );
|
---|
| 671 |
|
---|
[3c398b6] | 672 | maybeAccept_impl( node->stmt, *this );
|
---|
[9c1600c] | 673 |
|
---|
| 674 | VISIT_END( node );
|
---|
[13932f14] | 675 | }
|
---|
| 676 |
|
---|
[296b2be] | 677 | template< typename pass_type >
|
---|
[e0886db] | 678 | AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
|
---|
[296b2be] | 679 | MUTATE_START( node );
|
---|
| 680 |
|
---|
[3c398b6] | 681 | maybeMutate_impl( node->stmt, *this );
|
---|
[e0886db] | 682 |
|
---|
| 683 | MUTATE_END( AsmDecl, node );
|
---|
| 684 | }
|
---|
| 685 |
|
---|
| 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(); } );
|
---|
[0ac366b] | 1066 | indexerAddWith( node->exprs, node );
|
---|
[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(); } );
|
---|
[0ac366b] | 1079 | indexerAddWith( node->exprs, node );
|
---|
[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 ) {
|
---|
[5964127] | 1089 | VISIT_START( node );
|
---|
| 1090 | VISIT_END( node );
|
---|
[13932f14] | 1091 | }
|
---|
| 1092 |
|
---|
[2065609] | 1093 | template< typename pass_type >
|
---|
| 1094 | NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
|
---|
[5964127] | 1095 | MUTATE_START( node );
|
---|
| 1096 | MUTATE_END( NullStmt, node );
|
---|
[2065609] | 1097 | }
|
---|
| 1098 |
|
---|
| 1099 | //--------------------------------------------------------------------------
|
---|
| 1100 | // DeclStmt
|
---|
[13932f14] | 1101 | template< typename pass_type >
|
---|
[ab904dc] | 1102 | void PassVisitor< pass_type >::visit( DeclStmt * node ) {
|
---|
[5964127] | 1103 | VISIT_START( node );
|
---|
| 1104 |
|
---|
| 1105 | maybeAccept_impl( node->decl, *this );
|
---|
| 1106 |
|
---|
| 1107 | VISIT_END( node );
|
---|
[13932f14] | 1108 | }
|
---|
| 1109 |
|
---|
[2065609] | 1110 | template< typename pass_type >
|
---|
| 1111 | Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
|
---|
[5964127] | 1112 | MUTATE_START( node );
|
---|
| 1113 |
|
---|
| 1114 | maybeMutate_impl( node->decl, *this );
|
---|
| 1115 |
|
---|
| 1116 | MUTATE_END( Statement, node );
|
---|
[2065609] | 1117 | }
|
---|
| 1118 |
|
---|
| 1119 | //--------------------------------------------------------------------------
|
---|
| 1120 | // ImplicitCtorDtorStmt
|
---|
[13932f14] | 1121 | template< typename pass_type >
|
---|
[ab904dc] | 1122 | void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
|
---|
[599fbb6] | 1123 | VISIT_START( node );
|
---|
| 1124 |
|
---|
| 1125 | maybeAccept_impl( node->callStmt, *this );
|
---|
| 1126 |
|
---|
| 1127 | VISIT_END( node );
|
---|
[13932f14] | 1128 | }
|
---|
| 1129 |
|
---|
[2065609] | 1130 | template< typename pass_type >
|
---|
| 1131 | Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
|
---|
[599fbb6] | 1132 | MUTATE_START( node );
|
---|
| 1133 |
|
---|
| 1134 | maybeMutate_impl( node->callStmt, *this );
|
---|
| 1135 |
|
---|
| 1136 | MUTATE_END( Statement, node );
|
---|
[2065609] | 1137 | }
|
---|
| 1138 |
|
---|
| 1139 | //--------------------------------------------------------------------------
|
---|
| 1140 | // ApplicationExpr
|
---|
[13932f14] | 1141 | template< typename pass_type >
|
---|
[ab904dc] | 1142 | void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
|
---|
[e0886db] | 1143 | VISIT_START( node );
|
---|
| 1144 |
|
---|
| 1145 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1146 | maybeAccept_impl ( node->function, *this );
|
---|
| 1147 | maybeAccept_impl ( node->args , *this );
|
---|
[e0886db] | 1148 |
|
---|
| 1149 | VISIT_END( node );
|
---|
[13932f14] | 1150 | }
|
---|
| 1151 |
|
---|
[2065609] | 1152 | template< typename pass_type >
|
---|
| 1153 | Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
|
---|
[e0886db] | 1154 | MUTATE_START( node );
|
---|
| 1155 |
|
---|
| 1156 | indexerScopedMutate( node->env , *this );
|
---|
| 1157 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1158 | maybeMutate_impl ( node->function, *this );
|
---|
| 1159 | maybeMutate_impl ( node->args , *this );
|
---|
[e0886db] | 1160 |
|
---|
| 1161 | MUTATE_END( Expression, node );
|
---|
[2065609] | 1162 | }
|
---|
| 1163 |
|
---|
[9c1600c] | 1164 | //--------------------------------------------------------------------------
|
---|
| 1165 | // UntypedExpr
|
---|
[13932f14] | 1166 | template< typename pass_type >
|
---|
[ab904dc] | 1167 | void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
|
---|
[9c1600c] | 1168 | VISIT_START( node );
|
---|
| 1169 |
|
---|
[3c398b6] | 1170 | // maybeAccept_impl( node->get_env(), *this );
|
---|
[e0886db] | 1171 | indexerScopedAccept( node->result, *this );
|
---|
[2a7b3ca] | 1172 |
|
---|
[e0886db] | 1173 | for ( auto expr : node->args ) {
|
---|
[9c1600c] | 1174 | visitExpression( expr );
|
---|
| 1175 | }
|
---|
| 1176 |
|
---|
| 1177 | VISIT_END( node );
|
---|
[13932f14] | 1178 | }
|
---|
| 1179 |
|
---|
[296b2be] | 1180 | template< typename pass_type >
|
---|
| 1181 | Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
|
---|
| 1182 | MUTATE_START( node );
|
---|
| 1183 |
|
---|
[e0886db] | 1184 | indexerScopedMutate( node->env , *this );
|
---|
| 1185 | indexerScopedMutate( node->result, *this );
|
---|
[2a7b3ca] | 1186 |
|
---|
[e0886db] | 1187 | for ( auto& expr : node->args ) {
|
---|
[296b2be] | 1188 | expr = mutateExpression( expr );
|
---|
| 1189 | }
|
---|
| 1190 |
|
---|
| 1191 | MUTATE_END( Expression, node );
|
---|
| 1192 | }
|
---|
| 1193 |
|
---|
[e0886db] | 1194 | //--------------------------------------------------------------------------
|
---|
| 1195 | // NameExpr
|
---|
[13932f14] | 1196 | template< typename pass_type >
|
---|
[ab904dc] | 1197 | void PassVisitor< pass_type >::visit( NameExpr * node ) {
|
---|
[e0886db] | 1198 | VISIT_START( node );
|
---|
| 1199 |
|
---|
| 1200 | indexerScopedAccept( node->result, *this );
|
---|
| 1201 |
|
---|
| 1202 | VISIT_END( node );
|
---|
[13932f14] | 1203 | }
|
---|
| 1204 |
|
---|
| 1205 | template< typename pass_type >
|
---|
[e0886db] | 1206 | Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
|
---|
| 1207 | MUTATE_START( node );
|
---|
| 1208 |
|
---|
| 1209 | indexerScopedMutate( node->env , *this );
|
---|
| 1210 | indexerScopedMutate( node->result, *this );
|
---|
| 1211 |
|
---|
| 1212 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1213 | }
|
---|
| 1214 |
|
---|
[e0886db] | 1215 | //--------------------------------------------------------------------------
|
---|
| 1216 | // CastExpr
|
---|
[a5f0529] | 1217 | template< typename pass_type >
|
---|
[e0886db] | 1218 | void PassVisitor< pass_type >::visit( CastExpr * node ) {
|
---|
| 1219 | VISIT_START( node );
|
---|
| 1220 |
|
---|
| 1221 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1222 | maybeAccept_impl ( node->arg , *this );
|
---|
[e0886db] | 1223 |
|
---|
| 1224 | VISIT_END( node );
|
---|
[a5f0529] | 1225 | }
|
---|
| 1226 |
|
---|
[13932f14] | 1227 | template< typename pass_type >
|
---|
[e0886db] | 1228 | Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
|
---|
| 1229 | MUTATE_START( node );
|
---|
| 1230 |
|
---|
| 1231 | indexerScopedMutate( node->env , *this );
|
---|
| 1232 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1233 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1234 |
|
---|
| 1235 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1236 | }
|
---|
| 1237 |
|
---|
[e0886db] | 1238 | //--------------------------------------------------------------------------
|
---|
| 1239 | // VirtualCastExpr
|
---|
[13932f14] | 1240 | template< typename pass_type >
|
---|
[e0886db] | 1241 | void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
|
---|
| 1242 | VISIT_START( node );
|
---|
| 1243 |
|
---|
| 1244 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1245 | maybeAccept_impl( node->arg, *this );
|
---|
[e0886db] | 1246 |
|
---|
| 1247 | VISIT_END( node );
|
---|
[13932f14] | 1248 | }
|
---|
| 1249 |
|
---|
| 1250 | template< typename pass_type >
|
---|
[e0886db] | 1251 | Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
|
---|
| 1252 | MUTATE_START( node );
|
---|
| 1253 |
|
---|
| 1254 | indexerScopedMutate( node->env , *this );
|
---|
| 1255 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1256 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1257 |
|
---|
| 1258 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1259 | }
|
---|
| 1260 |
|
---|
[e0886db] | 1261 | //--------------------------------------------------------------------------
|
---|
| 1262 | // AddressExpr
|
---|
[13932f14] | 1263 | template< typename pass_type >
|
---|
[e0886db] | 1264 | void PassVisitor< pass_type >::visit( AddressExpr * node ) {
|
---|
| 1265 | VISIT_START( node );
|
---|
| 1266 |
|
---|
| 1267 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1268 | maybeAccept_impl ( node->arg , *this );
|
---|
[e0886db] | 1269 |
|
---|
| 1270 | VISIT_END( node );
|
---|
[13932f14] | 1271 | }
|
---|
| 1272 |
|
---|
| 1273 | template< typename pass_type >
|
---|
[e0886db] | 1274 | Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
|
---|
| 1275 | MUTATE_START( node );
|
---|
| 1276 |
|
---|
| 1277 | indexerScopedMutate( node->env , *this );
|
---|
| 1278 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1279 | maybeMutate_impl ( node->arg , *this );
|
---|
[e0886db] | 1280 |
|
---|
| 1281 | MUTATE_END( Expression, node );
|
---|
| 1282 | }
|
---|
| 1283 |
|
---|
| 1284 | //--------------------------------------------------------------------------
|
---|
| 1285 | // LabelAddressExpr
|
---|
| 1286 | template< typename pass_type >
|
---|
| 1287 | void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
|
---|
| 1288 | VISIT_START( node );
|
---|
| 1289 |
|
---|
| 1290 | indexerScopedAccept( node->result, *this );
|
---|
| 1291 |
|
---|
| 1292 | VISIT_END( node );
|
---|
| 1293 | }
|
---|
| 1294 |
|
---|
| 1295 | template< typename pass_type >
|
---|
| 1296 | Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
|
---|
| 1297 | MUTATE_START( node );
|
---|
| 1298 |
|
---|
| 1299 | indexerScopedMutate( node->env , *this );
|
---|
| 1300 | indexerScopedMutate( node->result, *this );
|
---|
| 1301 |
|
---|
| 1302 | MUTATE_END( Expression, node );
|
---|
| 1303 | }
|
---|
| 1304 |
|
---|
| 1305 | //--------------------------------------------------------------------------
|
---|
| 1306 | // UntypedMemberExpr
|
---|
| 1307 | template< typename pass_type >
|
---|
| 1308 | void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
|
---|
| 1309 | VISIT_START( node );
|
---|
| 1310 |
|
---|
| 1311 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1312 | maybeAccept_impl ( node->aggregate, *this );
|
---|
| 1313 | maybeAccept_impl ( node->member , *this );
|
---|
[e0886db] | 1314 |
|
---|
| 1315 | VISIT_END( node );
|
---|
[13932f14] | 1316 | }
|
---|
| 1317 |
|
---|
[e0886db] | 1318 | template< typename pass_type >
|
---|
| 1319 | Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
|
---|
| 1320 | MUTATE_START( node );
|
---|
| 1321 |
|
---|
| 1322 | indexerScopedMutate( node->env , *this );
|
---|
| 1323 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1324 | maybeMutate_impl ( node->aggregate, *this );
|
---|
| 1325 | maybeMutate_impl ( node->member , *this );
|
---|
[e0886db] | 1326 |
|
---|
| 1327 | MUTATE_END( Expression, node );
|
---|
| 1328 | }
|
---|
| 1329 |
|
---|
| 1330 | //--------------------------------------------------------------------------
|
---|
| 1331 | // MemberExpr
|
---|
| 1332 | template< typename pass_type >
|
---|
| 1333 | void PassVisitor< pass_type >::visit( MemberExpr * node ) {
|
---|
| 1334 | VISIT_START( node );
|
---|
| 1335 |
|
---|
| 1336 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1337 | maybeAccept_impl ( node->aggregate, *this );
|
---|
[e0886db] | 1338 |
|
---|
| 1339 | VISIT_END( node );
|
---|
| 1340 | }
|
---|
| 1341 |
|
---|
| 1342 | template< typename pass_type >
|
---|
| 1343 | Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
|
---|
| 1344 | MUTATE_START( node );
|
---|
| 1345 |
|
---|
| 1346 | indexerScopedMutate( node->env , *this );
|
---|
| 1347 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1348 | maybeMutate_impl ( node->aggregate, *this );
|
---|
[e0886db] | 1349 |
|
---|
| 1350 | MUTATE_END( Expression, node );
|
---|
| 1351 | }
|
---|
| 1352 |
|
---|
| 1353 | //--------------------------------------------------------------------------
|
---|
| 1354 | // VariableExpr
|
---|
| 1355 | template< typename pass_type >
|
---|
| 1356 | void PassVisitor< pass_type >::visit( VariableExpr * node ) {
|
---|
| 1357 | VISIT_START( node );
|
---|
| 1358 |
|
---|
| 1359 | indexerScopedAccept( node->result, *this );
|
---|
| 1360 |
|
---|
| 1361 | VISIT_END( node );
|
---|
| 1362 | }
|
---|
| 1363 |
|
---|
| 1364 | template< typename pass_type >
|
---|
| 1365 | Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
|
---|
| 1366 | MUTATE_START( node );
|
---|
| 1367 |
|
---|
| 1368 | indexerScopedMutate( node->env , *this );
|
---|
| 1369 | indexerScopedMutate( node->result, *this );
|
---|
| 1370 |
|
---|
| 1371 | MUTATE_END( Expression, node );
|
---|
| 1372 | }
|
---|
| 1373 |
|
---|
| 1374 | //--------------------------------------------------------------------------
|
---|
| 1375 | // ConstantExpr
|
---|
[13932f14] | 1376 | template< typename pass_type >
|
---|
[ab904dc] | 1377 | void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
|
---|
[e0886db] | 1378 | VISIT_START( node );
|
---|
| 1379 |
|
---|
| 1380 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1381 | maybeAccept_impl ( &node->constant, *this );
|
---|
[e0886db] | 1382 |
|
---|
| 1383 | VISIT_END( node );
|
---|
[13932f14] | 1384 | }
|
---|
| 1385 |
|
---|
[e0886db] | 1386 | template< typename pass_type >
|
---|
| 1387 | Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
|
---|
| 1388 | MUTATE_START( node );
|
---|
| 1389 |
|
---|
| 1390 | indexerScopedMutate( node->env , *this );
|
---|
| 1391 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1392 | Constant * ptr = &node->constant;
|
---|
| 1393 | maybeMutate_impl( ptr, *this );
|
---|
| 1394 | node->constant = *ptr;
|
---|
[e0886db] | 1395 |
|
---|
| 1396 | MUTATE_END( Expression, node );
|
---|
| 1397 | }
|
---|
| 1398 |
|
---|
| 1399 | //--------------------------------------------------------------------------
|
---|
| 1400 | // SizeofExpr
|
---|
[13932f14] | 1401 | template< typename pass_type >
|
---|
[ab904dc] | 1402 | void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
|
---|
[e0886db] | 1403 | VISIT_START( node );
|
---|
| 1404 |
|
---|
| 1405 | indexerScopedAccept( node->result, *this );
|
---|
| 1406 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1407 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1408 | } else {
|
---|
[3c398b6] | 1409 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1410 | }
|
---|
| 1411 |
|
---|
| 1412 | VISIT_END( node );
|
---|
[13932f14] | 1413 | }
|
---|
| 1414 |
|
---|
[e0886db] | 1415 | template< typename pass_type >
|
---|
| 1416 | Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
|
---|
| 1417 | MUTATE_START( node );
|
---|
| 1418 |
|
---|
| 1419 | indexerScopedMutate( node->env , *this );
|
---|
| 1420 | indexerScopedMutate( node->result, *this );
|
---|
| 1421 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1422 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1423 | } else {
|
---|
[3c398b6] | 1424 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1425 | }
|
---|
| 1426 |
|
---|
| 1427 | MUTATE_END( Expression, node );
|
---|
| 1428 | }
|
---|
| 1429 |
|
---|
| 1430 | //--------------------------------------------------------------------------
|
---|
| 1431 | // AlignofExpr
|
---|
[13932f14] | 1432 | template< typename pass_type >
|
---|
[ab904dc] | 1433 | void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
|
---|
[e0886db] | 1434 | VISIT_START( node );
|
---|
| 1435 |
|
---|
| 1436 | indexerScopedAccept( node->result, *this );
|
---|
| 1437 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1438 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1439 | } else {
|
---|
[3c398b6] | 1440 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1441 | }
|
---|
| 1442 |
|
---|
| 1443 | VISIT_END( node );
|
---|
[13932f14] | 1444 | }
|
---|
| 1445 |
|
---|
[e0886db] | 1446 | template< typename pass_type >
|
---|
| 1447 | Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
|
---|
| 1448 | MUTATE_START( node );
|
---|
| 1449 |
|
---|
| 1450 | indexerScopedMutate( node->env , *this );
|
---|
| 1451 | indexerScopedMutate( node->result, *this );
|
---|
| 1452 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1453 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1454 | } else {
|
---|
[3c398b6] | 1455 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1456 | }
|
---|
| 1457 |
|
---|
| 1458 | MUTATE_END( Expression, node );
|
---|
| 1459 | }
|
---|
| 1460 |
|
---|
| 1461 | //--------------------------------------------------------------------------
|
---|
| 1462 | // UntypedOffsetofExpr
|
---|
[13932f14] | 1463 | template< typename pass_type >
|
---|
[ab904dc] | 1464 | void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
|
---|
[e0886db] | 1465 | VISIT_START( node );
|
---|
| 1466 |
|
---|
| 1467 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1468 | maybeAccept_impl ( node->type , *this );
|
---|
[e0886db] | 1469 |
|
---|
| 1470 | VISIT_END( node );
|
---|
[13932f14] | 1471 | }
|
---|
| 1472 |
|
---|
[e0886db] | 1473 | template< typename pass_type >
|
---|
| 1474 | Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
|
---|
| 1475 | MUTATE_START( node );
|
---|
| 1476 |
|
---|
| 1477 | indexerScopedMutate( node->env , *this );
|
---|
| 1478 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1479 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1480 |
|
---|
| 1481 | MUTATE_END( Expression, node );
|
---|
| 1482 | }
|
---|
| 1483 |
|
---|
| 1484 | //--------------------------------------------------------------------------
|
---|
| 1485 | // OffsetofExpr
|
---|
[13932f14] | 1486 | template< typename pass_type >
|
---|
[ab904dc] | 1487 | void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
|
---|
[e0886db] | 1488 | VISIT_START( node );
|
---|
| 1489 |
|
---|
| 1490 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1491 | maybeAccept_impl ( node->type , *this );
|
---|
| 1492 | maybeAccept_impl ( node->member, *this );
|
---|
[e0886db] | 1493 |
|
---|
| 1494 | VISIT_END( node );
|
---|
[13932f14] | 1495 | }
|
---|
| 1496 |
|
---|
[e0886db] | 1497 | template< typename pass_type >
|
---|
| 1498 | Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
|
---|
| 1499 | MUTATE_START( node );
|
---|
| 1500 |
|
---|
| 1501 | indexerScopedMutate( node->env , *this );
|
---|
| 1502 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1503 | maybeMutate_impl ( node->type , *this );
|
---|
| 1504 | maybeMutate_impl ( node->member, *this );
|
---|
[e0886db] | 1505 |
|
---|
| 1506 | MUTATE_END( Expression, node );
|
---|
| 1507 | }
|
---|
| 1508 |
|
---|
| 1509 | //--------------------------------------------------------------------------
|
---|
| 1510 | // OffsetPackExpr
|
---|
[13932f14] | 1511 | template< typename pass_type >
|
---|
[ab904dc] | 1512 | void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
|
---|
[e0886db] | 1513 | VISIT_START( node );
|
---|
| 1514 |
|
---|
| 1515 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1516 | maybeAccept_impl ( node->type , *this );
|
---|
[e0886db] | 1517 |
|
---|
| 1518 | VISIT_END( node );
|
---|
[13932f14] | 1519 | }
|
---|
| 1520 |
|
---|
[e0886db] | 1521 | template< typename pass_type >
|
---|
| 1522 | Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
|
---|
| 1523 | MUTATE_START( node );
|
---|
| 1524 |
|
---|
| 1525 | indexerScopedMutate( node->env , *this );
|
---|
| 1526 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1527 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1528 |
|
---|
| 1529 | MUTATE_END( Expression, node );
|
---|
| 1530 | }
|
---|
| 1531 |
|
---|
| 1532 | //--------------------------------------------------------------------------
|
---|
| 1533 | // AttrExpr
|
---|
[13932f14] | 1534 | template< typename pass_type >
|
---|
[ab904dc] | 1535 | void PassVisitor< pass_type >::visit( AttrExpr * node ) {
|
---|
[e0886db] | 1536 | VISIT_START( node );
|
---|
| 1537 |
|
---|
| 1538 | indexerScopedAccept( node->result, *this );
|
---|
| 1539 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1540 | maybeAccept_impl( node->type, *this );
|
---|
[e0886db] | 1541 | } else {
|
---|
[3c398b6] | 1542 | maybeAccept_impl( node->expr, *this );
|
---|
[e0886db] | 1543 | }
|
---|
| 1544 |
|
---|
| 1545 | VISIT_END( node );
|
---|
| 1546 | }
|
---|
| 1547 |
|
---|
| 1548 | template< typename pass_type >
|
---|
| 1549 | Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
|
---|
| 1550 | MUTATE_START( node );
|
---|
| 1551 |
|
---|
| 1552 | indexerScopedMutate( node->env , *this );
|
---|
| 1553 | indexerScopedMutate( node->result, *this );
|
---|
| 1554 | if ( node->get_isType() ) {
|
---|
[3c398b6] | 1555 | maybeMutate_impl( node->type, *this );
|
---|
[e0886db] | 1556 | } else {
|
---|
[3c398b6] | 1557 | maybeMutate_impl( node->expr, *this );
|
---|
[e0886db] | 1558 | }
|
---|
| 1559 |
|
---|
| 1560 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1561 | }
|
---|
| 1562 |
|
---|
[e0886db] | 1563 | //--------------------------------------------------------------------------
|
---|
| 1564 | // LogicalExpr
|
---|
[13932f14] | 1565 | template< typename pass_type >
|
---|
[ab904dc] | 1566 | void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
|
---|
[e0886db] | 1567 | VISIT_START( node );
|
---|
| 1568 |
|
---|
| 1569 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1570 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1571 | maybeAccept_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1572 |
|
---|
| 1573 | VISIT_END( node );
|
---|
| 1574 | }
|
---|
| 1575 |
|
---|
| 1576 | template< typename pass_type >
|
---|
| 1577 | Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
|
---|
| 1578 | MUTATE_START( node );
|
---|
| 1579 |
|
---|
| 1580 | indexerScopedMutate( node->env , *this );
|
---|
| 1581 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1582 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1583 | maybeMutate_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1584 |
|
---|
| 1585 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1586 | }
|
---|
| 1587 |
|
---|
[e0886db] | 1588 | //--------------------------------------------------------------------------
|
---|
| 1589 | // ConditionalExpr
|
---|
[13932f14] | 1590 | template< typename pass_type >
|
---|
[ab904dc] | 1591 | void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
|
---|
[e0886db] | 1592 | VISIT_START( node );
|
---|
| 1593 |
|
---|
| 1594 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1595 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1596 | maybeAccept_impl ( node->arg2 , *this );
|
---|
| 1597 | maybeAccept_impl ( node->arg3 , *this );
|
---|
[e0886db] | 1598 |
|
---|
| 1599 | VISIT_END( node );
|
---|
[13932f14] | 1600 | }
|
---|
| 1601 |
|
---|
[e0886db] | 1602 | template< typename pass_type >
|
---|
| 1603 | Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
|
---|
| 1604 | MUTATE_START( node );
|
---|
| 1605 |
|
---|
| 1606 | indexerScopedMutate( node->env , *this );
|
---|
| 1607 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1608 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1609 | maybeMutate_impl ( node->arg2 , *this );
|
---|
| 1610 | maybeMutate_impl ( node->arg3 , *this );
|
---|
[e0886db] | 1611 |
|
---|
| 1612 | MUTATE_END( Expression, node );
|
---|
| 1613 | }
|
---|
| 1614 |
|
---|
| 1615 | //--------------------------------------------------------------------------
|
---|
| 1616 | // CommaExpr
|
---|
[13932f14] | 1617 | template< typename pass_type >
|
---|
[ab904dc] | 1618 | void PassVisitor< pass_type >::visit( CommaExpr * node ) {
|
---|
[e0886db] | 1619 | VISIT_START( node );
|
---|
| 1620 |
|
---|
| 1621 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1622 | maybeAccept_impl ( node->arg1 , *this );
|
---|
| 1623 | maybeAccept_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1624 |
|
---|
| 1625 | VISIT_END( node );
|
---|
| 1626 | }
|
---|
| 1627 |
|
---|
| 1628 | template< typename pass_type >
|
---|
| 1629 | Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
|
---|
| 1630 | MUTATE_START( node );
|
---|
| 1631 |
|
---|
| 1632 | indexerScopedMutate( node->env , *this );
|
---|
| 1633 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1634 | maybeMutate_impl ( node->arg1 , *this );
|
---|
| 1635 | maybeMutate_impl ( node->arg2 , *this );
|
---|
[e0886db] | 1636 |
|
---|
| 1637 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1638 | }
|
---|
| 1639 |
|
---|
[e0886db] | 1640 | //--------------------------------------------------------------------------
|
---|
| 1641 | // TypeExpr
|
---|
[13932f14] | 1642 | template< typename pass_type >
|
---|
[ab904dc] | 1643 | void PassVisitor< pass_type >::visit( TypeExpr * node ) {
|
---|
[e0886db] | 1644 | VISIT_START( node );
|
---|
| 1645 |
|
---|
| 1646 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1647 | maybeAccept_impl ( node->type, *this );
|
---|
[e0886db] | 1648 |
|
---|
| 1649 | VISIT_END( node );
|
---|
[13932f14] | 1650 | }
|
---|
| 1651 |
|
---|
[e0886db] | 1652 | template< typename pass_type >
|
---|
| 1653 | Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
|
---|
| 1654 | MUTATE_START( node );
|
---|
| 1655 |
|
---|
| 1656 | indexerScopedMutate( node->env , *this );
|
---|
| 1657 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1658 | maybeMutate_impl ( node->type , *this );
|
---|
[e0886db] | 1659 |
|
---|
| 1660 | MUTATE_END( Expression, node );
|
---|
| 1661 | }
|
---|
| 1662 |
|
---|
| 1663 | //--------------------------------------------------------------------------
|
---|
| 1664 | // AsmExpr
|
---|
[13932f14] | 1665 | template< typename pass_type >
|
---|
[ab904dc] | 1666 | void PassVisitor< pass_type >::visit( AsmExpr * node ) {
|
---|
[e0886db] | 1667 | VISIT_START( node );
|
---|
| 1668 |
|
---|
| 1669 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1670 | maybeAccept_impl ( node->inout , *this );
|
---|
| 1671 | maybeAccept_impl ( node->constraint, *this );
|
---|
| 1672 | maybeAccept_impl ( node->operand , *this );
|
---|
[e0886db] | 1673 |
|
---|
| 1674 | VISIT_END( node );
|
---|
[13932f14] | 1675 | }
|
---|
| 1676 |
|
---|
[e0886db] | 1677 | template< typename pass_type >
|
---|
| 1678 | Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
|
---|
| 1679 | MUTATE_START( node );
|
---|
| 1680 |
|
---|
| 1681 | indexerScopedMutate( node->env , *this );
|
---|
| 1682 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1683 | maybeMutate_impl ( node->inout , *this );
|
---|
| 1684 | maybeMutate_impl ( node->constraint, *this );
|
---|
| 1685 | maybeMutate_impl ( node->operand , *this );
|
---|
[e0886db] | 1686 |
|
---|
| 1687 | MUTATE_END( Expression, node );
|
---|
| 1688 | }
|
---|
| 1689 |
|
---|
| 1690 | //--------------------------------------------------------------------------
|
---|
| 1691 | // ImplicitCopyCtorExpr
|
---|
[13932f14] | 1692 | template< typename pass_type >
|
---|
[ab904dc] | 1693 | void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
|
---|
[e0886db] | 1694 | VISIT_START( node );
|
---|
| 1695 |
|
---|
| 1696 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1697 | maybeAccept_impl ( node->callExpr , *this );
|
---|
| 1698 | maybeAccept_impl ( node->tempDecls , *this );
|
---|
| 1699 | maybeAccept_impl ( node->returnDecls, *this );
|
---|
| 1700 | maybeAccept_impl ( node->dtors , *this );
|
---|
[e0886db] | 1701 |
|
---|
| 1702 | VISIT_END( node );
|
---|
| 1703 | }
|
---|
| 1704 |
|
---|
| 1705 | template< typename pass_type >
|
---|
| 1706 | Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
|
---|
| 1707 | MUTATE_START( node );
|
---|
| 1708 |
|
---|
| 1709 | indexerScopedMutate( node->env , *this );
|
---|
| 1710 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1711 | maybeMutate_impl ( node->callExpr , *this );
|
---|
| 1712 | maybeMutate_impl ( node->tempDecls , *this );
|
---|
| 1713 | maybeMutate_impl ( node->returnDecls, *this );
|
---|
| 1714 | maybeMutate_impl ( node->dtors , *this );
|
---|
[e0886db] | 1715 |
|
---|
| 1716 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1717 | }
|
---|
| 1718 |
|
---|
[e0886db] | 1719 | //--------------------------------------------------------------------------
|
---|
| 1720 | // ConstructorExpr
|
---|
[13932f14] | 1721 | template< typename pass_type >
|
---|
[ab904dc] | 1722 | void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
|
---|
[e0886db] | 1723 | VISIT_START( node );
|
---|
| 1724 |
|
---|
| 1725 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1726 | maybeAccept_impl ( node->callExpr, *this );
|
---|
[e0886db] | 1727 |
|
---|
| 1728 | VISIT_END( node );
|
---|
| 1729 | }
|
---|
| 1730 |
|
---|
| 1731 | template< typename pass_type >
|
---|
| 1732 | Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
|
---|
| 1733 | MUTATE_START( node );
|
---|
| 1734 |
|
---|
| 1735 | indexerScopedMutate( node->env , *this );
|
---|
| 1736 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1737 | maybeMutate_impl ( node->callExpr, *this );
|
---|
[e0886db] | 1738 |
|
---|
| 1739 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1740 | }
|
---|
| 1741 |
|
---|
[e0886db] | 1742 | //--------------------------------------------------------------------------
|
---|
| 1743 | // CompoundLiteralExpr
|
---|
[13932f14] | 1744 | template< typename pass_type >
|
---|
[ab904dc] | 1745 | void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
|
---|
[e0886db] | 1746 | VISIT_START( node );
|
---|
| 1747 |
|
---|
| 1748 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1749 | maybeAccept_impl ( node->initializer, *this );
|
---|
[e0886db] | 1750 |
|
---|
| 1751 | VISIT_END( node );
|
---|
[13932f14] | 1752 | }
|
---|
| 1753 |
|
---|
[e0886db] | 1754 | template< typename pass_type >
|
---|
| 1755 | Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
|
---|
| 1756 | MUTATE_START( node );
|
---|
| 1757 |
|
---|
| 1758 | indexerScopedMutate( node->env , *this );
|
---|
| 1759 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1760 | maybeMutate_impl ( node->initializer, *this );
|
---|
[e0886db] | 1761 |
|
---|
| 1762 | MUTATE_END( Expression, node );
|
---|
| 1763 | }
|
---|
| 1764 |
|
---|
| 1765 | //--------------------------------------------------------------------------
|
---|
| 1766 | // RangeExpr
|
---|
[13932f14] | 1767 | template< typename pass_type >
|
---|
[ab904dc] | 1768 | void PassVisitor< pass_type >::visit( RangeExpr * node ) {
|
---|
[e0886db] | 1769 | VISIT_START( node );
|
---|
| 1770 |
|
---|
| 1771 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1772 | maybeAccept_impl ( node->low , *this );
|
---|
| 1773 | maybeAccept_impl ( node->high , *this );
|
---|
[e0886db] | 1774 |
|
---|
| 1775 | VISIT_END( node );
|
---|
[13932f14] | 1776 | }
|
---|
| 1777 |
|
---|
[e0886db] | 1778 | template< typename pass_type >
|
---|
| 1779 | Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
|
---|
| 1780 | MUTATE_START( node );
|
---|
| 1781 |
|
---|
| 1782 | indexerScopedMutate( node->env , *this );
|
---|
| 1783 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1784 | maybeMutate_impl ( node->low , *this );
|
---|
| 1785 | maybeMutate_impl ( node->high , *this );
|
---|
[e0886db] | 1786 |
|
---|
| 1787 | MUTATE_END( Expression, node );
|
---|
| 1788 | }
|
---|
| 1789 |
|
---|
| 1790 | //--------------------------------------------------------------------------
|
---|
| 1791 | // UntypedTupleExpr
|
---|
[13932f14] | 1792 | template< typename pass_type >
|
---|
[ab904dc] | 1793 | void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
|
---|
[e0886db] | 1794 | VISIT_START( node );
|
---|
| 1795 |
|
---|
| 1796 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1797 | maybeAccept_impl ( node->exprs , *this );
|
---|
[e0886db] | 1798 |
|
---|
| 1799 | VISIT_END( node );
|
---|
| 1800 | }
|
---|
| 1801 |
|
---|
| 1802 | template< typename pass_type >
|
---|
| 1803 | Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
|
---|
| 1804 | MUTATE_START( node );
|
---|
| 1805 |
|
---|
| 1806 | indexerScopedMutate( node->env , *this );
|
---|
| 1807 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1808 | maybeMutate_impl ( node->exprs , *this );
|
---|
[e0886db] | 1809 |
|
---|
| 1810 | MUTATE_END( Expression, node );
|
---|
| 1811 | }
|
---|
| 1812 |
|
---|
| 1813 | //--------------------------------------------------------------------------
|
---|
| 1814 | // TupleExpr
|
---|
| 1815 | template< typename pass_type >
|
---|
| 1816 | void PassVisitor< pass_type >::visit( TupleExpr * node ) {
|
---|
| 1817 | VISIT_START( node );
|
---|
| 1818 |
|
---|
| 1819 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1820 | maybeAccept_impl ( node->exprs , *this );
|
---|
[e0886db] | 1821 |
|
---|
| 1822 | VISIT_END( node );
|
---|
| 1823 | }
|
---|
| 1824 |
|
---|
| 1825 | template< typename pass_type >
|
---|
| 1826 | Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
|
---|
| 1827 | MUTATE_START( node );
|
---|
| 1828 |
|
---|
| 1829 | indexerScopedMutate( node->env , *this );
|
---|
| 1830 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1831 | maybeMutate_impl ( node->exprs , *this );
|
---|
[e0886db] | 1832 |
|
---|
| 1833 | MUTATE_END( Expression, node );
|
---|
| 1834 | }
|
---|
| 1835 |
|
---|
| 1836 | //--------------------------------------------------------------------------
|
---|
| 1837 | // TupleIndexExpr
|
---|
| 1838 | template< typename pass_type >
|
---|
| 1839 | void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
|
---|
| 1840 | VISIT_START( node );
|
---|
| 1841 |
|
---|
| 1842 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1843 | maybeAccept_impl ( node->tuple , *this );
|
---|
[e0886db] | 1844 |
|
---|
| 1845 | VISIT_END( node );
|
---|
| 1846 | }
|
---|
| 1847 |
|
---|
| 1848 | template< typename pass_type >
|
---|
| 1849 | Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
|
---|
| 1850 | MUTATE_START( node );
|
---|
| 1851 |
|
---|
| 1852 | indexerScopedMutate( node->env , *this );
|
---|
| 1853 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1854 | maybeMutate_impl ( node->tuple , *this );
|
---|
[e0886db] | 1855 |
|
---|
| 1856 | MUTATE_END( Expression, node );
|
---|
| 1857 | }
|
---|
| 1858 |
|
---|
| 1859 | //--------------------------------------------------------------------------
|
---|
| 1860 | // TupleAssignExpr
|
---|
| 1861 | template< typename pass_type >
|
---|
| 1862 | void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
|
---|
| 1863 | VISIT_START( node );
|
---|
| 1864 |
|
---|
| 1865 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1866 | maybeAccept_impl ( node->stmtExpr, *this );
|
---|
[e0886db] | 1867 |
|
---|
| 1868 | VISIT_END( node );
|
---|
[13932f14] | 1869 | }
|
---|
| 1870 |
|
---|
| 1871 | template< typename pass_type >
|
---|
[e0886db] | 1872 | Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
|
---|
| 1873 | MUTATE_START( node );
|
---|
[13932f14] | 1874 |
|
---|
[e0886db] | 1875 | indexerScopedMutate( node->env , *this );
|
---|
| 1876 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1877 | maybeMutate_impl ( node->stmtExpr, *this );
|
---|
[13932f14] | 1878 |
|
---|
[e0886db] | 1879 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1880 | }
|
---|
| 1881 |
|
---|
[9c1600c] | 1882 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 1883 | // StmtExpr
|
---|
[13932f14] | 1884 | template< typename pass_type >
|
---|
[ab904dc] | 1885 | void PassVisitor< pass_type >::visit( StmtExpr * node ) {
|
---|
[9c1600c] | 1886 | VISIT_START( node );
|
---|
| 1887 |
|
---|
| 1888 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
---|
| 1889 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
---|
| 1890 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
---|
| 1891 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
---|
| 1892 |
|
---|
[e0886db] | 1893 | indexerScopedAccept( node->result , *this );
|
---|
[3c398b6] | 1894 | maybeAccept_impl ( node->statements , *this );
|
---|
| 1895 | maybeAccept_impl ( node->returnDecls, *this );
|
---|
| 1896 | maybeAccept_impl ( node->dtors , *this );
|
---|
[9c1600c] | 1897 |
|
---|
| 1898 | VISIT_END( node );
|
---|
[13932f14] | 1899 | }
|
---|
| 1900 |
|
---|
[296b2be] | 1901 | template< typename pass_type >
|
---|
| 1902 | Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
|
---|
| 1903 | MUTATE_START( node );
|
---|
[4551a6e] | 1904 |
|
---|
[296b2be] | 1905 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
---|
[134322e] | 1906 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
---|
| 1907 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
---|
| 1908 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
---|
[296b2be] | 1909 |
|
---|
[e0886db] | 1910 | indexerScopedMutate( node->result , *this );
|
---|
[3c398b6] | 1911 | maybeMutate_impl ( node->statements , *this );
|
---|
| 1912 | maybeMutate_impl ( node->returnDecls, *this );
|
---|
| 1913 | maybeMutate_impl ( node->dtors , *this );
|
---|
[296b2be] | 1914 |
|
---|
| 1915 | MUTATE_END( Expression, node );
|
---|
| 1916 | }
|
---|
| 1917 |
|
---|
[e0886db] | 1918 | //--------------------------------------------------------------------------
|
---|
| 1919 | // UniqueExpr
|
---|
[13932f14] | 1920 | template< typename pass_type >
|
---|
[ab904dc] | 1921 | void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
|
---|
[e0886db] | 1922 | VISIT_START( node );
|
---|
| 1923 |
|
---|
| 1924 | indexerScopedAccept( node->result, *this );
|
---|
[3c398b6] | 1925 | maybeAccept_impl ( node->expr , *this );
|
---|
[e0886db] | 1926 |
|
---|
| 1927 | VISIT_END( node );
|
---|
| 1928 | }
|
---|
| 1929 |
|
---|
| 1930 | template< typename pass_type >
|
---|
| 1931 | Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
|
---|
| 1932 | MUTATE_START( node );
|
---|
| 1933 |
|
---|
| 1934 | indexerScopedMutate( node->env , *this );
|
---|
| 1935 | indexerScopedMutate( node->result, *this );
|
---|
[3c398b6] | 1936 | maybeMutate_impl ( node->expr , *this );
|
---|
[e0886db] | 1937 |
|
---|
| 1938 | MUTATE_END( Expression, node );
|
---|
[13932f14] | 1939 | }
|
---|
| 1940 |
|
---|
[73367a8] | 1941 | //--------------------------------------------------------------------------
|
---|
| 1942 | // UntypedInitExpr
|
---|
| 1943 | template< typename pass_type >
|
---|
| 1944 | void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) {
|
---|
| 1945 | VISIT_START( node );
|
---|
| 1946 |
|
---|
| 1947 | indexerScopedAccept( node->result, *this );
|
---|
| 1948 | maybeAccept_impl ( node->expr , *this );
|
---|
| 1949 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
| 1950 |
|
---|
| 1951 | VISIT_END( node );
|
---|
| 1952 | }
|
---|
| 1953 |
|
---|
| 1954 | template< typename pass_type >
|
---|
| 1955 | Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
|
---|
| 1956 | MUTATE_START( node );
|
---|
| 1957 |
|
---|
| 1958 | indexerScopedMutate( node->env , *this );
|
---|
| 1959 | indexerScopedMutate( node->result, *this );
|
---|
| 1960 | maybeMutate_impl ( node->expr , *this );
|
---|
| 1961 | // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
| 1962 |
|
---|
| 1963 | MUTATE_END( Expression, node );
|
---|
| 1964 | }
|
---|
| 1965 |
|
---|
| 1966 | //--------------------------------------------------------------------------
|
---|
| 1967 | // InitExpr
|
---|
| 1968 | template< typename pass_type >
|
---|
| 1969 | void PassVisitor< pass_type >::visit( InitExpr * node ) {
|
---|
| 1970 | VISIT_START( node );
|
---|
| 1971 |
|
---|
| 1972 | indexerScopedAccept( node->result, *this );
|
---|
| 1973 | maybeAccept_impl ( node->expr , *this );
|
---|
| 1974 | maybeAccept_impl ( node->designation, *this );
|
---|
| 1975 |
|
---|
| 1976 | VISIT_END( node );
|
---|
| 1977 | }
|
---|
| 1978 |
|
---|
| 1979 | template< typename pass_type >
|
---|
| 1980 | Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
|
---|
| 1981 | MUTATE_START( node );
|
---|
| 1982 |
|
---|
| 1983 | indexerScopedMutate( node->env , *this );
|
---|
| 1984 | indexerScopedMutate( node->result, *this );
|
---|
| 1985 | maybeMutate_impl ( node->expr , *this );
|
---|
| 1986 | maybeMutate_impl ( node->designation, *this );
|
---|
| 1987 |
|
---|
| 1988 | MUTATE_END( Expression, node );
|
---|
| 1989 | }
|
---|
| 1990 |
|
---|
[44b4114] | 1991 | //--------------------------------------------------------------------------
|
---|
| 1992 | // DeletedExpr
|
---|
| 1993 | template< typename pass_type >
|
---|
| 1994 | void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
|
---|
| 1995 | VISIT_START( node );
|
---|
| 1996 |
|
---|
| 1997 | indexerScopedAccept( node->result, *this );
|
---|
| 1998 | maybeAccept_impl( node->expr, *this );
|
---|
| 1999 | // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
|
---|
| 2000 |
|
---|
| 2001 | VISIT_END( node );
|
---|
| 2002 | }
|
---|
| 2003 |
|
---|
| 2004 | template< typename pass_type >
|
---|
| 2005 | Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
|
---|
| 2006 | MUTATE_START( node );
|
---|
| 2007 |
|
---|
| 2008 | indexerScopedMutate( node->env, *this );
|
---|
| 2009 | indexerScopedMutate( node->result, *this );
|
---|
| 2010 | maybeMutate_impl( node->expr, *this );
|
---|
| 2011 |
|
---|
| 2012 | MUTATE_END( Expression, node );
|
---|
| 2013 | }
|
---|
| 2014 |
|
---|
[17fc7a5] | 2015 | //--------------------------------------------------------------------------
|
---|
| 2016 | // VoidType
|
---|
[13932f14] | 2017 | template< typename pass_type >
|
---|
[ab904dc] | 2018 | void PassVisitor< pass_type >::visit( VoidType * node ) {
|
---|
[599fbb6] | 2019 | VISIT_START( node );
|
---|
| 2020 |
|
---|
| 2021 | maybeAccept_impl( node->forall, *this );
|
---|
| 2022 |
|
---|
| 2023 | VISIT_END( node );
|
---|
| 2024 | }
|
---|
| 2025 |
|
---|
| 2026 | template< typename pass_type >
|
---|
| 2027 | Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
|
---|
| 2028 | MUTATE_START( node );
|
---|
| 2029 |
|
---|
| 2030 | maybeMutate_impl( node->forall, *this );
|
---|
| 2031 |
|
---|
| 2032 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2033 | }
|
---|
| 2034 |
|
---|
[17fc7a5] | 2035 | //--------------------------------------------------------------------------
|
---|
| 2036 | // BasicType
|
---|
[13932f14] | 2037 | template< typename pass_type >
|
---|
[ab904dc] | 2038 | void PassVisitor< pass_type >::visit( BasicType * node ) {
|
---|
[17fc7a5] | 2039 | VISIT_START( node );
|
---|
| 2040 |
|
---|
| 2041 | maybeAccept_impl( node->forall, *this );
|
---|
| 2042 |
|
---|
| 2043 | VISIT_END( node );
|
---|
| 2044 | }
|
---|
| 2045 |
|
---|
| 2046 | template< typename pass_type >
|
---|
| 2047 | Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
|
---|
| 2048 | MUTATE_START( node );
|
---|
| 2049 |
|
---|
| 2050 | maybeMutate_impl( node->forall, *this );
|
---|
| 2051 |
|
---|
| 2052 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2053 | }
|
---|
| 2054 |
|
---|
[17fc7a5] | 2055 | //--------------------------------------------------------------------------
|
---|
| 2056 | // PointerType
|
---|
[13932f14] | 2057 | template< typename pass_type >
|
---|
[ab904dc] | 2058 | void PassVisitor< pass_type >::visit( PointerType * node ) {
|
---|
[17fc7a5] | 2059 | VISIT_START( node );
|
---|
| 2060 |
|
---|
| 2061 | maybeAccept_impl( node->forall, *this );
|
---|
[cfaf9be] | 2062 | // xxx - should PointerType visit/mutate dimension?
|
---|
[17fc7a5] | 2063 | maybeAccept_impl( node->base, *this );
|
---|
| 2064 |
|
---|
| 2065 | VISIT_END( node );
|
---|
[13932f14] | 2066 | }
|
---|
| 2067 |
|
---|
[17fc7a5] | 2068 | template< typename pass_type >
|
---|
| 2069 | Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
|
---|
| 2070 | MUTATE_START( node );
|
---|
| 2071 |
|
---|
| 2072 | maybeMutate_impl( node->forall, *this );
|
---|
[cfaf9be] | 2073 | // xxx - should PointerType visit/mutate dimension?
|
---|
[17fc7a5] | 2074 | maybeMutate_impl( node->base, *this );
|
---|
| 2075 |
|
---|
| 2076 | MUTATE_END( Type, node );
|
---|
| 2077 | }
|
---|
| 2078 |
|
---|
| 2079 | //--------------------------------------------------------------------------
|
---|
| 2080 | // ArrayType
|
---|
[13932f14] | 2081 | template< typename pass_type >
|
---|
[ab904dc] | 2082 | void PassVisitor< pass_type >::visit( ArrayType * node ) {
|
---|
[17fc7a5] | 2083 | VISIT_START( node );
|
---|
| 2084 |
|
---|
| 2085 | maybeAccept_impl( node->forall, *this );
|
---|
| 2086 | maybeAccept_impl( node->dimension, *this );
|
---|
| 2087 | maybeAccept_impl( node->base, *this );
|
---|
| 2088 |
|
---|
| 2089 | VISIT_END( node );
|
---|
[13932f14] | 2090 | }
|
---|
| 2091 |
|
---|
[17fc7a5] | 2092 | template< typename pass_type >
|
---|
| 2093 | Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
|
---|
| 2094 | MUTATE_START( node );
|
---|
| 2095 |
|
---|
| 2096 | maybeMutate_impl( node->forall, *this );
|
---|
| 2097 | maybeMutate_impl( node->dimension, *this );
|
---|
| 2098 | maybeMutate_impl( node->base, *this );
|
---|
| 2099 |
|
---|
| 2100 | MUTATE_END( Type, node );
|
---|
| 2101 | }
|
---|
| 2102 |
|
---|
| 2103 | //--------------------------------------------------------------------------
|
---|
| 2104 | // ReferenceType
|
---|
[6b9b047] | 2105 | template< typename pass_type >
|
---|
| 2106 | void PassVisitor< pass_type >::visit( ReferenceType * node ) {
|
---|
[17fc7a5] | 2107 | VISIT_START( node );
|
---|
| 2108 |
|
---|
| 2109 | maybeAccept_impl( node->forall, *this );
|
---|
| 2110 | maybeAccept_impl( node->base, *this );
|
---|
| 2111 |
|
---|
| 2112 | VISIT_END( node );
|
---|
| 2113 | }
|
---|
| 2114 |
|
---|
| 2115 | template< typename pass_type >
|
---|
| 2116 | Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
|
---|
| 2117 | MUTATE_START( node );
|
---|
| 2118 |
|
---|
| 2119 | maybeMutate_impl( node->forall, *this );
|
---|
| 2120 | maybeMutate_impl( node->base, *this );
|
---|
| 2121 |
|
---|
| 2122 | MUTATE_END( Type, node );
|
---|
[6b9b047] | 2123 | }
|
---|
| 2124 |
|
---|
[17fc7a5] | 2125 | //--------------------------------------------------------------------------
|
---|
| 2126 | // FunctionType
|
---|
[13932f14] | 2127 | template< typename pass_type >
|
---|
[ab904dc] | 2128 | void PassVisitor< pass_type >::visit( FunctionType * node ) {
|
---|
[17fc7a5] | 2129 | VISIT_START( node );
|
---|
| 2130 |
|
---|
| 2131 | maybeAccept_impl( node->forall, *this );
|
---|
| 2132 | maybeAccept_impl( node->returnVals, *this );
|
---|
| 2133 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2134 |
|
---|
| 2135 | VISIT_END( node );
|
---|
| 2136 | }
|
---|
| 2137 |
|
---|
| 2138 | template< typename pass_type >
|
---|
| 2139 | Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
|
---|
| 2140 | MUTATE_START( node );
|
---|
| 2141 |
|
---|
| 2142 | maybeMutate_impl( node->forall, *this );
|
---|
| 2143 | maybeMutate_impl( node->returnVals, *this );
|
---|
| 2144 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2145 |
|
---|
| 2146 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2147 | }
|
---|
| 2148 |
|
---|
[e0886db] | 2149 | //--------------------------------------------------------------------------
|
---|
| 2150 | // StructInstType
|
---|
[13932f14] | 2151 | template< typename pass_type >
|
---|
[ab904dc] | 2152 | void PassVisitor< pass_type >::visit( StructInstType * node ) {
|
---|
[e0886db] | 2153 | VISIT_START( node );
|
---|
| 2154 |
|
---|
| 2155 | indexerAddStruct( node->name );
|
---|
| 2156 |
|
---|
| 2157 | {
|
---|
| 2158 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2159 | maybeAccept_impl( node->forall , *this );
|
---|
| 2160 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2161 | }
|
---|
| 2162 |
|
---|
| 2163 | VISIT_END( node );
|
---|
| 2164 | }
|
---|
| 2165 |
|
---|
| 2166 | template< typename pass_type >
|
---|
| 2167 | Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
|
---|
| 2168 | MUTATE_START( node );
|
---|
| 2169 |
|
---|
| 2170 | indexerAddStruct( node->name );
|
---|
| 2171 |
|
---|
| 2172 | {
|
---|
| 2173 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2174 | maybeMutate_impl( node->forall , *this );
|
---|
| 2175 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2176 | }
|
---|
| 2177 |
|
---|
| 2178 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2179 | }
|
---|
| 2180 |
|
---|
[e0886db] | 2181 | //--------------------------------------------------------------------------
|
---|
| 2182 | // UnionInstType
|
---|
[13932f14] | 2183 | template< typename pass_type >
|
---|
[ab904dc] | 2184 | void PassVisitor< pass_type >::visit( UnionInstType * node ) {
|
---|
[e0886db] | 2185 | VISIT_START( node );
|
---|
| 2186 |
|
---|
| 2187 | indexerAddStruct( node->name );
|
---|
| 2188 |
|
---|
| 2189 | {
|
---|
| 2190 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2191 | maybeAccept_impl( node->forall , *this );
|
---|
| 2192 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2193 | }
|
---|
| 2194 |
|
---|
| 2195 | VISIT_END( node );
|
---|
| 2196 | }
|
---|
| 2197 |
|
---|
| 2198 | template< typename pass_type >
|
---|
| 2199 | Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
|
---|
| 2200 | MUTATE_START( node );
|
---|
| 2201 |
|
---|
| 2202 | indexerAddStruct( node->name );
|
---|
| 2203 |
|
---|
| 2204 | {
|
---|
| 2205 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
---|
[3c398b6] | 2206 | maybeMutate_impl( node->forall , *this );
|
---|
| 2207 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2208 | }
|
---|
| 2209 |
|
---|
| 2210 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2211 | }
|
---|
| 2212 |
|
---|
[e0886db] | 2213 | //--------------------------------------------------------------------------
|
---|
| 2214 | // EnumInstType
|
---|
[13932f14] | 2215 | template< typename pass_type >
|
---|
[ab904dc] | 2216 | void PassVisitor< pass_type >::visit( EnumInstType * node ) {
|
---|
[86e84e4] | 2217 | VISIT_START( node );
|
---|
| 2218 |
|
---|
| 2219 | maybeAccept_impl( node->forall, *this );
|
---|
| 2220 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2221 |
|
---|
| 2222 | VISIT_END( node );
|
---|
[13932f14] | 2223 | }
|
---|
| 2224 |
|
---|
[e0886db] | 2225 | template< typename pass_type >
|
---|
| 2226 | Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
|
---|
[86e84e4] | 2227 | MUTATE_START( node );
|
---|
| 2228 |
|
---|
| 2229 | maybeMutate_impl( node->forall, *this );
|
---|
| 2230 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2231 |
|
---|
| 2232 | MUTATE_END( Type, node );
|
---|
[e0886db] | 2233 | }
|
---|
| 2234 |
|
---|
| 2235 | //--------------------------------------------------------------------------
|
---|
| 2236 | // TraitInstType
|
---|
[13932f14] | 2237 | template< typename pass_type >
|
---|
[ab904dc] | 2238 | void PassVisitor< pass_type >::visit( TraitInstType * node ) {
|
---|
[e0886db] | 2239 | VISIT_START( node );
|
---|
| 2240 |
|
---|
[3c398b6] | 2241 | maybeAccept_impl( node->forall , *this );
|
---|
| 2242 | maybeAccept_impl( node->parameters, *this );
|
---|
[e0886db] | 2243 |
|
---|
| 2244 | VISIT_END( node );
|
---|
| 2245 | }
|
---|
| 2246 |
|
---|
| 2247 | template< typename pass_type >
|
---|
| 2248 | Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
|
---|
| 2249 | MUTATE_START( node );
|
---|
| 2250 |
|
---|
[3c398b6] | 2251 | maybeMutate_impl( node->forall , *this );
|
---|
| 2252 | maybeMutate_impl( node->parameters, *this );
|
---|
[e0886db] | 2253 |
|
---|
| 2254 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2255 | }
|
---|
| 2256 |
|
---|
[e0886db] | 2257 | //--------------------------------------------------------------------------
|
---|
| 2258 | // TypeInstType
|
---|
[13932f14] | 2259 | template< typename pass_type >
|
---|
[ab904dc] | 2260 | void PassVisitor< pass_type >::visit( TypeInstType * node ) {
|
---|
[86e84e4] | 2261 | VISIT_START( node );
|
---|
| 2262 |
|
---|
| 2263 | maybeAccept_impl( node->forall , *this );
|
---|
| 2264 | maybeAccept_impl( node->parameters, *this );
|
---|
| 2265 |
|
---|
| 2266 | VISIT_END( node );
|
---|
| 2267 | }
|
---|
| 2268 |
|
---|
| 2269 | template< typename pass_type >
|
---|
| 2270 | Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
|
---|
| 2271 | MUTATE_START( node );
|
---|
| 2272 |
|
---|
| 2273 | maybeMutate_impl( node->forall , *this );
|
---|
| 2274 | maybeMutate_impl( node->parameters, *this );
|
---|
| 2275 |
|
---|
| 2276 | MUTATE_END( Type, node );
|
---|
[13932f14] | 2277 | }
|
---|
| 2278 |
|
---|
[86e84e4] | 2279 |
|
---|
[13932f14] | 2280 | template< typename pass_type >
|
---|
[ab904dc] | 2281 | void PassVisitor< pass_type >::visit( TupleType * node ) {
|
---|
[4551a6e] | 2282 | VISIT_BODY( node );
|
---|
[13932f14] | 2283 | }
|
---|
| 2284 |
|
---|
| 2285 | template< typename pass_type >
|
---|
[ab904dc] | 2286 | void PassVisitor< pass_type >::visit( TypeofType * node ) {
|
---|
[4551a6e] | 2287 | VISIT_BODY( node );
|
---|
[13932f14] | 2288 | }
|
---|
| 2289 |
|
---|
| 2290 | template< typename pass_type >
|
---|
[ab904dc] | 2291 | void PassVisitor< pass_type >::visit( AttrType * node ) {
|
---|
[4551a6e] | 2292 | VISIT_BODY( node );
|
---|
[13932f14] | 2293 | }
|
---|
| 2294 |
|
---|
| 2295 | template< typename pass_type >
|
---|
[ab904dc] | 2296 | void PassVisitor< pass_type >::visit( VarArgsType * node ) {
|
---|
[4551a6e] | 2297 | VISIT_BODY( node );
|
---|
[13932f14] | 2298 | }
|
---|
| 2299 |
|
---|
| 2300 | template< typename pass_type >
|
---|
[ab904dc] | 2301 | void PassVisitor< pass_type >::visit( ZeroType * node ) {
|
---|
[4551a6e] | 2302 | VISIT_BODY( node );
|
---|
[13932f14] | 2303 | }
|
---|
| 2304 |
|
---|
| 2305 | template< typename pass_type >
|
---|
[ab904dc] | 2306 | void PassVisitor< pass_type >::visit( OneType * node ) {
|
---|
[4551a6e] | 2307 | VISIT_BODY( node );
|
---|
[13932f14] | 2308 | }
|
---|
| 2309 |
|
---|
[b11d8e2] | 2310 | template< typename pass_type >
|
---|
| 2311 | void PassVisitor< pass_type >::visit( Designation * node ) {
|
---|
| 2312 | VISIT_START( node );
|
---|
| 2313 |
|
---|
[3c398b6] | 2314 | maybeAccept_impl( node->get_designators(), *this );
|
---|
[b11d8e2] | 2315 |
|
---|
| 2316 | VISIT_END( node );
|
---|
| 2317 | }
|
---|
| 2318 |
|
---|
| 2319 | template< typename pass_type >
|
---|
| 2320 | Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
|
---|
| 2321 | MUTATE_START( node );
|
---|
| 2322 |
|
---|
[3c398b6] | 2323 | maybeMutate_impl( node->get_designators(), *this );
|
---|
[b11d8e2] | 2324 |
|
---|
| 2325 | MUTATE_END( Designation, node );
|
---|
| 2326 | }
|
---|
| 2327 |
|
---|
[9c1600c] | 2328 | //--------------------------------------------------------------------------
|
---|
[e0886db] | 2329 | // SingleInit
|
---|
[13932f14] | 2330 | template< typename pass_type >
|
---|
[ab904dc] | 2331 | void PassVisitor< pass_type >::visit( SingleInit * node ) {
|
---|
[9c1600c] | 2332 | VISIT_START( node );
|
---|
| 2333 |
|
---|
| 2334 | visitExpression( node->get_value() );
|
---|
| 2335 |
|
---|
| 2336 | VISIT_END( node );
|
---|
[13932f14] | 2337 | }
|
---|
| 2338 |
|
---|
[296b2be] | 2339 | template< typename pass_type >
|
---|
| 2340 | Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
|
---|
| 2341 | MUTATE_START( node );
|
---|
| 2342 |
|
---|
| 2343 | node->set_value( mutateExpression( node->get_value() ) );
|
---|
| 2344 |
|
---|
| 2345 | MUTATE_END( Initializer, node );
|
---|
| 2346 | }
|
---|
| 2347 |
|
---|
[13932f14] | 2348 | template< typename pass_type >
|
---|
[ab904dc] | 2349 | void PassVisitor< pass_type >::visit( ListInit * node ) {
|
---|
[4551a6e] | 2350 | VISIT_BODY( node );
|
---|
[13932f14] | 2351 | }
|
---|
| 2352 |
|
---|
| 2353 | template< typename pass_type >
|
---|
[ab904dc] | 2354 | void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
|
---|
[4551a6e] | 2355 | VISIT_BODY( node );
|
---|
[13932f14] | 2356 | }
|
---|
| 2357 |
|
---|
| 2358 | template< typename pass_type >
|
---|
[ab904dc] | 2359 | void PassVisitor< pass_type >::visit( Subrange * node ) {
|
---|
[4551a6e] | 2360 | VISIT_BODY( node );
|
---|
[13932f14] | 2361 | }
|
---|
| 2362 |
|
---|
| 2363 | template< typename pass_type >
|
---|
[ab904dc] | 2364 | void PassVisitor< pass_type >::visit( Constant * node ) {
|
---|
[4551a6e] | 2365 | VISIT_BODY( node );
|
---|
[13932f14] | 2366 | }
|
---|
[ab904dc] | 2367 |
|
---|
[5ea7a22] | 2368 | template< typename pass_type >
|
---|
| 2369 | void PassVisitor< pass_type >::visit( Attribute * node ) {
|
---|
| 2370 | VISIT_BODY( node );
|
---|
| 2371 | }
|
---|
| 2372 |
|
---|
[ab904dc] | 2373 | //---------------------------------------------------------------------------------------------------------------
|
---|
| 2374 |
|
---|
| 2375 | template< typename pass_type >
|
---|
| 2376 | Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
|
---|
| 2377 | MUTATE_BODY( Type, node );
|
---|
| 2378 | }
|
---|
| 2379 |
|
---|
| 2380 | template< typename pass_type >
|
---|
| 2381 | Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
|
---|
| 2382 | MUTATE_BODY( Type, node );
|
---|
| 2383 | }
|
---|
| 2384 |
|
---|
| 2385 | template< typename pass_type >
|
---|
| 2386 | Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
|
---|
| 2387 | MUTATE_BODY( Type, node );
|
---|
| 2388 | }
|
---|
| 2389 |
|
---|
| 2390 | template< typename pass_type >
|
---|
| 2391 | Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
|
---|
| 2392 | MUTATE_BODY( Type, node );
|
---|
| 2393 | }
|
---|
| 2394 |
|
---|
| 2395 | template< typename pass_type >
|
---|
| 2396 | Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
|
---|
| 2397 | MUTATE_BODY( Type, node );
|
---|
| 2398 | }
|
---|
| 2399 |
|
---|
| 2400 | template< typename pass_type >
|
---|
| 2401 | Type * PassVisitor< pass_type >::mutate( OneType * node ) {
|
---|
| 2402 | MUTATE_BODY( Type, node );
|
---|
| 2403 | }
|
---|
| 2404 |
|
---|
| 2405 | template< typename pass_type >
|
---|
| 2406 | Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
|
---|
| 2407 | MUTATE_BODY( Initializer, node );
|
---|
| 2408 | }
|
---|
| 2409 |
|
---|
| 2410 | template< typename pass_type >
|
---|
| 2411 | Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
|
---|
| 2412 | MUTATE_BODY( Initializer, node );
|
---|
| 2413 | }
|
---|
| 2414 |
|
---|
| 2415 | template< typename pass_type >
|
---|
| 2416 | Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) {
|
---|
| 2417 | MUTATE_BODY( Subrange, node );
|
---|
| 2418 | }
|
---|
| 2419 |
|
---|
| 2420 | template< typename pass_type >
|
---|
| 2421 | Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
|
---|
| 2422 | MUTATE_BODY( Constant, node );
|
---|
[4551a6e] | 2423 | }
|
---|
[5ea7a22] | 2424 |
|
---|
| 2425 | template< typename pass_type >
|
---|
| 2426 | Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
|
---|
| 2427 | MUTATE_BODY( Attribute, node );
|
---|
| 2428 | }
|
---|
[447c356] | 2429 |
|
---|
| 2430 | template< typename pass_type >
|
---|
| 2431 | TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
|
---|
| 2432 | MUTATE_START( node );
|
---|
| 2433 |
|
---|
| 2434 | for ( auto & p : node->typeEnv ) {
|
---|
| 2435 | indexerScopedMutate( p.second, *this );
|
---|
| 2436 | }
|
---|
| 2437 | for ( auto & p : node->varEnv ) {
|
---|
| 2438 | indexerScopedMutate( p.second, *this );
|
---|
| 2439 | }
|
---|
| 2440 |
|
---|
| 2441 | MUTATE_END( TypeSubstitution, node );
|
---|
| 2442 | }
|
---|