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