| [13932f14] | 1 | #pragma once
|
|---|
| [3268a58] | 2 | // IWYU pragma: private, include "PassVisitor.h"
|
|---|
| [13932f14] | 3 |
|
|---|
| [3c398b6] | 4 | #define VISIT_START( node ) \
|
|---|
| 5 | __attribute__((unused)) \
|
|---|
| 6 | ChildrenGuard children_guard( get_visit_children_ptr() ); \
|
|---|
| 7 | __attribute__((unused)) \
|
|---|
| [62423350] | 8 | guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
|
|---|
| [3c398b6] | 9 | call_previsit( node ); \
|
|---|
| [6e09f211] | 10 |
|
|---|
| 11 | #define VISIT_END( node ) \
|
|---|
| 12 | call_postvisit( node ); \
|
|---|
| [9c1600c] | 13 |
|
|---|
| [3c398b6] | 14 | #define MUTATE_START( node ) \
|
|---|
| 15 | __attribute__((unused)) \
|
|---|
| 16 | ChildrenGuard children_guard( get_visit_children_ptr() ); \
|
|---|
| 17 | __attribute__((unused)) \
|
|---|
| [62423350] | 18 | guard_value_impl guard( at_cleanup_impl(pass, 0) ); \
|
|---|
| [3c398b6] | 19 | call_premutate( node ); \
|
|---|
| [296b2be] | 20 |
|
|---|
| 21 | #define MUTATE_END( type, node ) \
|
|---|
| 22 | return call_postmutate< type * >( node ); \
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| [3c398b6] | 25 | #define VISIT_BODY( node ) \
|
|---|
| 26 | VISIT_START( node ); \
|
|---|
| 27 | if( children_guard ) { \
|
|---|
| 28 | Visitor::visit( node ); \
|
|---|
| 29 | } \
|
|---|
| 30 | VISIT_END( node ); \
|
|---|
| [13932f14] | 31 |
|
|---|
| [ab904dc] | 32 |
|
|---|
| [3c398b6] | 33 | #define MUTATE_BODY( type, node ) \
|
|---|
| 34 | MUTATE_START( node ); \
|
|---|
| 35 | if( children_guard ) { \
|
|---|
| 36 | Mutator::mutate( node ); \
|
|---|
| 37 | } \
|
|---|
| 38 | MUTATE_END( type, node ); \
|
|---|
| [296b2be] | 39 |
|
|---|
| [134322e] | 40 |
|
|---|
| 41 |
|
|---|
| 42 | template<typename T>
|
|---|
| 43 | static inline bool empty( T * ptr ) {
|
|---|
| 44 | return !ptr || ptr->empty();
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| [6ca154b] | 47 | typedef std::list< Statement * > StmtList_t;
|
|---|
| 48 | typedef std::list< Declaration * > DeclList_t;
|
|---|
| 49 |
|
|---|
| 50 | template<typename iterator_t>
|
|---|
| 51 | static inline void splice( iterator_t it, DeclList_t * decls ) {
|
|---|
| 52 | std::transform(
|
|---|
| 53 | decls->begin(),
|
|---|
| 54 | decls->end(),
|
|---|
| 55 | it,
|
|---|
| 56 | [](Declaration * decl) -> auto {
|
|---|
| 57 | return new DeclStmt( noLabels, decl );
|
|---|
| 58 | }
|
|---|
| 59 | );
|
|---|
| 60 | decls->clear();
|
|---|
| 61 | }
|
|---|
| [134322e] | 62 |
|
|---|
| 63 | template< typename pass_type >
|
|---|
| [6ca154b] | 64 | static inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
|
|---|
| 65 | DeclList_t* beforeDecls = visitor.get_beforeDecls();
|
|---|
| 66 | DeclList_t* afterDecls = visitor.get_afterDecls();
|
|---|
| [522363e] | 67 | SemanticError errors;
|
|---|
| [134322e] | 68 |
|
|---|
| [6ca154b] | 69 | for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
|
|---|
| 70 | // splice in new declarations after previous decl
|
|---|
| [d24d4e1] | 71 | if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
|
|---|
| [6ca154b] | 72 |
|
|---|
| 73 | if ( i == decls.end() ) break;
|
|---|
| 74 |
|
|---|
| [522363e] | 75 | try {
|
|---|
| 76 | // run visitor on declaration
|
|---|
| [3c398b6] | 77 | maybeAccept_impl( *i, visitor );
|
|---|
| [522363e] | 78 | } catch( SemanticError &e ) {
|
|---|
| 79 | e.set_location( (*i)->location );
|
|---|
| 80 | errors.append( e );
|
|---|
| 81 | }
|
|---|
| [6ca154b] | 82 |
|
|---|
| 83 | // splice in new declarations before current decl
|
|---|
| 84 | if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
|
|---|
| [134322e] | 85 | }
|
|---|
| [522363e] | 86 | if ( ! errors.isEmpty() ) {
|
|---|
| 87 | throw errors;
|
|---|
| 88 | }
|
|---|
| [6ca154b] | 89 | }
|
|---|
| [134322e] | 90 |
|
|---|
| [6ca154b] | 91 | template< typename pass_type >
|
|---|
| 92 | static inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
|
|---|
| 93 | DeclList_t* beforeDecls = mutator.get_beforeDecls();
|
|---|
| 94 | DeclList_t* afterDecls = mutator.get_afterDecls();
|
|---|
| [522363e] | 95 | SemanticError errors;
|
|---|
| [6ca154b] | 96 |
|
|---|
| 97 | for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
|
|---|
| 98 | // splice in new declarations after previous decl
|
|---|
| [d24d4e1] | 99 | if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
|
|---|
| [6ca154b] | 100 |
|
|---|
| 101 | if ( i == decls.end() ) break;
|
|---|
| [522363e] | 102 | try {
|
|---|
| 103 | // run mutator on declaration
|
|---|
| [3c398b6] | 104 | maybeMutate_impl( *i, mutator );
|
|---|
| [522363e] | 105 | } catch( SemanticError &e ) {
|
|---|
| 106 | e.set_location( (*i)->location );
|
|---|
| 107 | errors.append( e );
|
|---|
| 108 | }
|
|---|
| [6ca154b] | 109 |
|
|---|
| 110 | // splice in new declarations before current decl
|
|---|
| 111 | if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
|
|---|
| 112 | }
|
|---|
| [522363e] | 113 | if ( ! errors.isEmpty() ) {
|
|---|
| 114 | throw errors;
|
|---|
| 115 | }
|
|---|
| [134322e] | 116 | }
|
|---|
| 117 |
|
|---|
| [3c398b6] | 118 | template< typename TreeType, typename pass_type >
|
|---|
| 119 | inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
|
|---|
| 120 | if ( ! visitor.get_visit_children() ) return;
|
|---|
| 121 | if ( tree ) {
|
|---|
| 122 | tree->accept( visitor );
|
|---|
| 123 | }
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | template< typename Container, typename pass_type >
|
|---|
| 127 | inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
|
|---|
| 128 | if ( ! visitor.get_visit_children() ) return;
|
|---|
| [e0886db] | 129 | SemanticError errors;
|
|---|
| 130 | for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
|
|---|
| 131 | try {
|
|---|
| 132 | if ( *i ) {
|
|---|
| 133 | (*i)->accept( visitor );
|
|---|
| 134 | }
|
|---|
| 135 | } catch( SemanticError &e ) {
|
|---|
| 136 | e.set_location( (*i)->location );
|
|---|
| 137 | errors.append( e );
|
|---|
| 138 | }
|
|---|
| 139 | }
|
|---|
| 140 | if ( ! errors.isEmpty() ) {
|
|---|
| 141 | throw errors;
|
|---|
| 142 | }
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| [3c398b6] | 145 | template< typename TreeType, typename pass_type >
|
|---|
| 146 | inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
|
|---|
| 147 | if ( ! mutator.get_visit_children() ) return;
|
|---|
| 148 |
|
|---|
| 149 | if ( tree ) {
|
|---|
| 150 | tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
|
|---|
| 151 | }
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | template< typename Container, typename pass_type >
|
|---|
| 155 | inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
|
|---|
| 156 | if ( ! mutator.get_visit_children() ) return;
|
|---|
| [e0886db] | 157 | SemanticError errors;
|
|---|
| 158 | for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
|
|---|
| 159 | try {
|
|---|
| 160 | if ( *i ) {
|
|---|
| 161 | *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
|
|---|
| 162 | assert( *i );
|
|---|
| 163 | } // if
|
|---|
| 164 | } catch( SemanticError &e ) {
|
|---|
| 165 | e.set_location( (*i)->location );
|
|---|
| 166 | errors.append( e );
|
|---|
| 167 | } // try
|
|---|
| 168 | } // for
|
|---|
| 169 | if ( ! errors.isEmpty() ) {
|
|---|
| 170 | throw errors;
|
|---|
| 171 | } // if
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| [296b2be] | 174 | template< typename pass_type >
|
|---|
| [6ca154b] | 175 | template< typename func_t >
|
|---|
| 176 | void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
|
|---|
| [3c398b6] | 177 | if ( ! get_visit_children() ) return;
|
|---|
| [296b2be] | 178 | SemanticError errors;
|
|---|
| 179 |
|
|---|
| [2a7b3ca] | 180 | // don't want statements from outer CompoundStmts to be added to this CompoundStmt
|
|---|
| 181 | ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
|
|---|
| 182 | ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
|
|---|
| 183 | ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
|
|---|
| 184 | ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
|
|---|
| 185 |
|
|---|
| [134322e] | 186 | StmtList_t* beforeStmts = get_beforeStmts();
|
|---|
| 187 | StmtList_t* afterStmts = get_afterStmts();
|
|---|
| [6ca154b] | 188 | DeclList_t* beforeDecls = get_beforeDecls();
|
|---|
| 189 | DeclList_t* afterDecls = get_afterDecls();
|
|---|
| [134322e] | 190 |
|
|---|
| [296b2be] | 191 | for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
|
|---|
| [6ca154b] | 192 |
|
|---|
| 193 | if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }
|
|---|
| [134322e] | 194 | if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
|
|---|
| [6ca154b] | 195 |
|
|---|
| [296b2be] | 196 | try {
|
|---|
| [6ca154b] | 197 | func( *i );
|
|---|
| 198 | assert(( empty( beforeStmts ) && empty( afterStmts ))
|
|---|
| 199 | || ( empty( beforeDecls ) && empty( afterDecls )) );
|
|---|
| 200 |
|
|---|
| [296b2be] | 201 | } catch ( SemanticError &e ) {
|
|---|
| [aa685db] | 202 | e.set_location( (*i)->location );
|
|---|
| [296b2be] | 203 | errors.append( e );
|
|---|
| [134322e] | 204 | }
|
|---|
| [6ca154b] | 205 |
|
|---|
| 206 | if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }
|
|---|
| [134322e] | 207 | if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
|
|---|
| [296b2be] | 208 | }
|
|---|
| [134322e] | 209 |
|
|---|
| [6ca154b] | 210 | if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
|
|---|
| [134322e] | 211 | if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); }
|
|---|
| 212 | if ( !errors.isEmpty() ) { throw errors; }
|
|---|
| [296b2be] | 213 | }
|
|---|
| 214 |
|
|---|
| 215 | template< typename pass_type >
|
|---|
| [6ca154b] | 216 | void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
|
|---|
| 217 | handleStatementList( statements, [this]( Statement * stmt) {
|
|---|
| [3c398b6] | 218 | maybeAccept_impl( stmt, *this );
|
|---|
| [6ca154b] | 219 | });
|
|---|
| 220 | }
|
|---|
| [134322e] | 221 |
|
|---|
| [6ca154b] | 222 | template< typename pass_type >
|
|---|
| 223 | void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
|
|---|
| 224 | handleStatementList( statements, [this]( Statement *& stmt) {
|
|---|
| [3c398b6] | 225 | maybeMutate_impl( stmt, *this );
|
|---|
| [6ca154b] | 226 | });
|
|---|
| [134322e] | 227 | }
|
|---|
| 228 |
|
|---|
| [6ca154b] | 229 |
|
|---|
| [134322e] | 230 | template< typename pass_type >
|
|---|
| [6ca154b] | 231 | template< typename func_t >
|
|---|
| 232 | Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
|
|---|
| [3c398b6] | 233 | if ( ! get_visit_children() ) return stmt;
|
|---|
| 234 |
|
|---|
| [134322e] | 235 | // don't want statements from outer CompoundStmts to be added to this CompoundStmt
|
|---|
| [6ca154b] | 236 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () );
|
|---|
| 237 | ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() );
|
|---|
| 238 | ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () );
|
|---|
| 239 | ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() );
|
|---|
| 240 | ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () );
|
|---|
| [296b2be] | 241 |
|
|---|
| [6ca154b] | 242 | Statement *newStmt = func( stmt );
|
|---|
| [134322e] | 243 |
|
|---|
| 244 | StmtList_t* beforeStmts = get_beforeStmts();
|
|---|
| 245 | StmtList_t* afterStmts = get_afterStmts();
|
|---|
| [6ca154b] | 246 | DeclList_t* beforeDecls = get_beforeDecls();
|
|---|
| 247 | DeclList_t* afterDecls = get_afterDecls();
|
|---|
| [134322e] | 248 |
|
|---|
| [6ca154b] | 249 | if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; }
|
|---|
| 250 | assert(( empty( beforeStmts ) && empty( afterStmts ))
|
|---|
| 251 | || ( empty( beforeDecls ) && empty( afterDecls )) );
|
|---|
| [134322e] | 252 |
|
|---|
| 253 | CompoundStmt *compound = new CompoundStmt( noLabels );
|
|---|
| [6ca154b] | 254 | if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); }
|
|---|
| [134322e] | 255 | if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
|
|---|
| 256 | compound->get_kids().push_back( newStmt );
|
|---|
| [6ca154b] | 257 | if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }
|
|---|
| [134322e] | 258 | if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
|
|---|
| 259 | return compound;
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | template< typename pass_type >
|
|---|
| [6ca154b] | 263 | Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
|
|---|
| 264 | return handleStatement( stmt, [this]( Statement * stmt ) {
|
|---|
| [3c398b6] | 265 | maybeAccept_impl( stmt, *this );
|
|---|
| [6ca154b] | 266 | return stmt;
|
|---|
| 267 | });
|
|---|
| 268 | }
|
|---|
| [134322e] | 269 |
|
|---|
| [6ca154b] | 270 | template< typename pass_type >
|
|---|
| 271 | Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
|
|---|
| 272 | return handleStatement( stmt, [this]( Statement * stmt ) {
|
|---|
| [3c398b6] | 273 | maybeMutate_impl( stmt, *this );
|
|---|
| 274 | return stmt;
|
|---|
| [6ca154b] | 275 | });
|
|---|
| [296b2be] | 276 | }
|
|---|
| 277 |
|
|---|
| 278 | template< typename pass_type >
|
|---|
| [6ca154b] | 279 | template< typename func_t >
|
|---|
| 280 | Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
|
|---|
| [3c398b6] | 281 | if ( ! get_visit_children() ) return expr;
|
|---|
| [296b2be] | 282 | if( !expr ) return nullptr;
|
|---|
| 283 |
|
|---|
| [134322e] | 284 | auto env_ptr = get_env_ptr();
|
|---|
| 285 | if ( env_ptr && expr->get_env() ) {
|
|---|
| 286 | *env_ptr = expr->get_env();
|
|---|
| [296b2be] | 287 | }
|
|---|
| [6ca154b] | 288 |
|
|---|
| [3c398b6] | 289 | // should env be moved onto the result of the mutate?
|
|---|
| [6ca154b] | 290 | return func( expr );
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | template< typename pass_type >
|
|---|
| 294 | Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
|
|---|
| 295 | return handleExpression(expr, [this]( Expression * expr ) {
|
|---|
| [3c398b6] | 296 | maybeAccept_impl( expr, *this );
|
|---|
| [6ca154b] | 297 | return expr;
|
|---|
| [d24d4e1] | 298 | });
|
|---|
| [296b2be] | 299 | }
|
|---|
| [ab904dc] | 300 |
|
|---|
| [6ca154b] | 301 | template< typename pass_type >
|
|---|
| 302 | Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
|
|---|
| 303 | return handleExpression(expr, [this]( Expression * expr ) {
|
|---|
| [3c398b6] | 304 | maybeMutate_impl( expr, *this );
|
|---|
| 305 | return expr;
|
|---|
| [6ca154b] | 306 | });
|
|---|
| 307 | }
|
|---|
| [ab904dc] | 308 |
|
|---|
| [3c398b6] | 309 | template< typename TreeType, typename VisitorType >
|
|---|
| 310 | inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
|
|---|
| 311 | if ( ! visitor.get_visit_children() ) return;
|
|---|
| 312 | auto guard = makeFuncGuard(
|
|---|
| 313 | [&visitor]() { visitor.indexerScopeEnter(); },
|
|---|
| 314 | [&visitor]() { visitor.indexerScopeLeave(); }
|
|---|
| 315 | );
|
|---|
| 316 | maybeAccept_impl( tree, visitor );
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | template< typename TreeType, typename MutatorType >
|
|---|
| 320 | inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
|
|---|
| 321 | if ( ! mutator.get_visit_children() ) return;
|
|---|
| 322 | auto guard = makeFuncGuard(
|
|---|
| 323 | [&mutator]() { mutator.indexerScopeEnter(); },
|
|---|
| 324 | [&mutator]() { mutator.indexerScopeLeave(); }
|
|---|
| 325 | );
|
|---|
| 326 | maybeMutate_impl( tree, mutator );
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| [296b2be] | 329 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|---|
| [e0886db] | 330 | //========================================================================================================================================================================
|
|---|
| 331 | //========================================================================================================================================================================
|
|---|
| 332 | //========================================================================================================================================================================
|
|---|
| 333 | //========================================================================================================================================================================
|
|---|
| 334 | //========================================================================================================================================================================
|
|---|
| 335 | //------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|---|
| [13932f14] | 336 |
|
|---|
| [33a25f9] | 337 | // A NOTE ON THE ORDER OF TRAVERSAL
|
|---|
| 338 | //
|
|---|
| 339 | // Types and typedefs have their base types visited before they are added to the type table. This is ok, since there is
|
|---|
| 340 | // no such thing as a recursive type or typedef.
|
|---|
| 341 | //
|
|---|
| 342 | // typedef struct { T *x; } T; // never allowed
|
|---|
| 343 | //
|
|---|
| 344 | // for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
|
|---|
| 345 | // members are traversed, and then the complete type should be added (assuming the type is completed by this particular
|
|---|
| 346 | // declaration).
|
|---|
| 347 | //
|
|---|
| 348 | // struct T { struct T *x; }; // allowed
|
|---|
| 349 | //
|
|---|
| 350 | // It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
|
|---|
| 351 | // traversal may modify the definition of the type and these modifications should be visible when the symbol table is
|
|---|
| 352 | // queried later in this pass.
|
|---|
| 353 | //
|
|---|
| 354 | // TODO: figure out whether recursive contexts are sensible/possible/reasonable.
|
|---|
| [e0886db] | 355 |
|
|---|
| 356 | //--------------------------------------------------------------------------
|
|---|
| 357 | // ObjectDecl
|
|---|
| [13932f14] | 358 | template< typename pass_type >
|
|---|
| [ab904dc] | 359 | void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
|
|---|
| [e0886db] | 360 | VISIT_START( node );
|
|---|
| 361 |
|
|---|
| 362 | indexerScopedAccept( node->type , *this );
|
|---|
| [3c398b6] | 363 | maybeAccept_impl ( node->init , *this );
|
|---|
| 364 | maybeAccept_impl ( node->bitfieldWidth, *this );
|
|---|
| 365 | maybeAccept_impl ( node->attributes , *this );
|
|---|
| [e0886db] | 366 |
|
|---|
| 367 | if ( node->name != "" ) {
|
|---|
| 368 | indexerAddId( node );
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | VISIT_END( node );
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 | template< typename pass_type >
|
|---|
| 375 | DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) {
|
|---|
| 376 | MUTATE_START( node );
|
|---|
| 377 |
|
|---|
| 378 | indexerScopedMutate( node->type , *this );
|
|---|
| [3c398b6] | 379 | maybeMutate_impl ( node->init , *this );
|
|---|
| 380 | maybeMutate_impl ( node->bitfieldWidth, *this );
|
|---|
| 381 | maybeMutate_impl ( node->attributes , *this );
|
|---|
| [e0886db] | 382 |
|
|---|
| 383 | if ( node->name != "" ) {
|
|---|
| 384 | indexerAddId( node );
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | MUTATE_END( DeclarationWithType, node );
|
|---|
| [13932f14] | 388 | }
|
|---|
| 389 |
|
|---|
| [e0886db] | 390 | //--------------------------------------------------------------------------
|
|---|
| 391 | // FunctionDecl
|
|---|
| [13932f14] | 392 | template< typename pass_type >
|
|---|
| [ab904dc] | 393 | void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
|
|---|
| [e0886db] | 394 | VISIT_START( node );
|
|---|
| 395 |
|
|---|
| 396 | if ( node->name != "" ) {
|
|---|
| 397 | indexerAddId( node );
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | {
|
|---|
| 401 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [4429b04] | 402 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2
|
|---|
| 403 | static ObjectDecl func(
|
|---|
| 404 | "__func__", noStorageClasses, LinkageSpec::C, nullptr,
|
|---|
| 405 | new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
|
|---|
| 406 | nullptr
|
|---|
| 407 | );
|
|---|
| 408 | indexerAddId( &func );
|
|---|
| [3c398b6] | 409 | maybeAccept_impl( node->type, *this );
|
|---|
| 410 | maybeAccept_impl( node->statements, *this );
|
|---|
| 411 | maybeAccept_impl( node->attributes, *this );
|
|---|
| [e0886db] | 412 | }
|
|---|
| 413 |
|
|---|
| 414 | VISIT_END( node );
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | template< typename pass_type >
|
|---|
| 418 | DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
|
|---|
| 419 | MUTATE_START( node );
|
|---|
| 420 |
|
|---|
| 421 | if ( node->name != "" ) {
|
|---|
| 422 | indexerAddId( node );
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| 425 | {
|
|---|
| 426 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [4429b04] | 427 | // implicit add __func__ identifier as specified in the C manual 6.4.2.2
|
|---|
| 428 | static ObjectDecl func(
|
|---|
| 429 | "__func__", noStorageClasses, LinkageSpec::C, nullptr,
|
|---|
| 430 | new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
|
|---|
| 431 | nullptr
|
|---|
| 432 | );
|
|---|
| 433 | indexerAddId( &func );
|
|---|
| [3c398b6] | 434 | maybeMutate_impl( node->type, *this );
|
|---|
| 435 | maybeMutate_impl( node->statements, *this );
|
|---|
| 436 | maybeMutate_impl( node->attributes, *this );
|
|---|
| [e0886db] | 437 | }
|
|---|
| 438 |
|
|---|
| 439 | MUTATE_END( DeclarationWithType, node );
|
|---|
| [13932f14] | 440 | }
|
|---|
| 441 |
|
|---|
| [e0886db] | 442 | //--------------------------------------------------------------------------
|
|---|
| 443 | // StructDecl
|
|---|
| [13932f14] | 444 | template< typename pass_type >
|
|---|
| [ab904dc] | 445 | void PassVisitor< pass_type >::visit( StructDecl * node ) {
|
|---|
| [e0886db] | 446 | VISIT_START( node );
|
|---|
| 447 |
|
|---|
| 448 | // make up a forward declaration and add it before processing the members
|
|---|
| 449 | // needs to be on the heap because addStruct saves the pointer
|
|---|
| 450 | indexerAddStructFwd( node );
|
|---|
| 451 |
|
|---|
| 452 | {
|
|---|
| 453 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 454 | maybeAccept_impl( node->parameters, *this );
|
|---|
| 455 | maybeAccept_impl( node->members , *this );
|
|---|
| [e0886db] | 456 | }
|
|---|
| 457 |
|
|---|
| 458 | // this addition replaces the forward declaration
|
|---|
| 459 | indexerAddStruct( node );
|
|---|
| 460 |
|
|---|
| 461 | VISIT_END( node );
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | template< typename pass_type >
|
|---|
| 465 | Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
|
|---|
| 466 | MUTATE_START( node );
|
|---|
| 467 |
|
|---|
| 468 | // make up a forward declaration and add it before processing the members
|
|---|
| 469 | // needs to be on the heap because addStruct saves the pointer
|
|---|
| 470 | indexerAddStructFwd( node );
|
|---|
| 471 |
|
|---|
| 472 | {
|
|---|
| 473 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 474 | maybeMutate_impl( node->parameters, *this );
|
|---|
| 475 | maybeMutate_impl( node->members , *this );
|
|---|
| [e0886db] | 476 | }
|
|---|
| 477 |
|
|---|
| 478 | // this addition replaces the forward declaration
|
|---|
| 479 | indexerAddStruct( node );
|
|---|
| 480 |
|
|---|
| 481 | MUTATE_END( Declaration, node );
|
|---|
| [13932f14] | 482 | }
|
|---|
| 483 |
|
|---|
| [e0886db] | 484 | //--------------------------------------------------------------------------
|
|---|
| 485 | // UnionDecl
|
|---|
| [13932f14] | 486 | template< typename pass_type >
|
|---|
| [ab904dc] | 487 | void PassVisitor< pass_type >::visit( UnionDecl * node ) {
|
|---|
| [e0886db] | 488 | VISIT_START( node );
|
|---|
| 489 |
|
|---|
| 490 | // make up a forward declaration and add it before processing the members
|
|---|
| 491 | indexerAddUnionFwd( node );
|
|---|
| 492 |
|
|---|
| 493 | {
|
|---|
| 494 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 495 | maybeAccept_impl( node->parameters, *this );
|
|---|
| 496 | maybeAccept_impl( node->members , *this );
|
|---|
| [e0886db] | 497 | }
|
|---|
| 498 |
|
|---|
| 499 | indexerAddUnion( node );
|
|---|
| 500 |
|
|---|
| 501 | VISIT_END( node );
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | template< typename pass_type >
|
|---|
| 505 | Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
|
|---|
| 506 | MUTATE_START( node );
|
|---|
| 507 |
|
|---|
| 508 | // make up a forward declaration and add it before processing the members
|
|---|
| 509 | indexerAddUnionFwd( node );
|
|---|
| 510 |
|
|---|
| 511 | {
|
|---|
| 512 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 513 | maybeMutate_impl( node->parameters, *this );
|
|---|
| 514 | maybeMutate_impl( node->members , *this );
|
|---|
| [e0886db] | 515 | }
|
|---|
| 516 |
|
|---|
| 517 | indexerAddUnion( node );
|
|---|
| 518 |
|
|---|
| 519 | MUTATE_END( Declaration, node );
|
|---|
| [13932f14] | 520 | }
|
|---|
| 521 |
|
|---|
| [e0886db] | 522 | //--------------------------------------------------------------------------
|
|---|
| 523 | // EnumDecl
|
|---|
| [13932f14] | 524 | template< typename pass_type >
|
|---|
| [ab904dc] | 525 | void PassVisitor< pass_type >::visit( EnumDecl * node ) {
|
|---|
| [e0886db] | 526 | VISIT_START( node );
|
|---|
| 527 |
|
|---|
| 528 | indexerAddEnum( node );
|
|---|
| 529 |
|
|---|
| [33a25f9] | 530 | // unlike structs, traits, and unions, enums inject their members into the global scope
|
|---|
| [3c398b6] | 531 | maybeAccept_impl( node->parameters, *this );
|
|---|
| 532 | maybeAccept_impl( node->members , *this );
|
|---|
| [e0886db] | 533 |
|
|---|
| 534 | VISIT_END( node );
|
|---|
| [13932f14] | 535 | }
|
|---|
| 536 |
|
|---|
| [e0886db] | 537 | template< typename pass_type >
|
|---|
| 538 | Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
|
|---|
| 539 | MUTATE_START( node );
|
|---|
| 540 |
|
|---|
| 541 | indexerAddEnum( node );
|
|---|
| 542 |
|
|---|
| [522363e] | 543 | // unlike structs, traits, and unions, enums inject their members into the global scope
|
|---|
| [3c398b6] | 544 | maybeMutate_impl( node->parameters, *this );
|
|---|
| 545 | maybeMutate_impl( node->members , *this );
|
|---|
| [e0886db] | 546 |
|
|---|
| 547 | MUTATE_END( Declaration, node );
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | //--------------------------------------------------------------------------
|
|---|
| 551 | // TraitDecl
|
|---|
| [13932f14] | 552 | template< typename pass_type >
|
|---|
| [ab904dc] | 553 | void PassVisitor< pass_type >::visit( TraitDecl * node ) {
|
|---|
| [e0886db] | 554 | VISIT_START( node );
|
|---|
| 555 |
|
|---|
| 556 | {
|
|---|
| 557 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 558 | maybeAccept_impl( node->parameters, *this );
|
|---|
| 559 | maybeAccept_impl( node->members , *this );
|
|---|
| [e0886db] | 560 | }
|
|---|
| 561 |
|
|---|
| 562 | indexerAddTrait( node );
|
|---|
| 563 |
|
|---|
| 564 | VISIT_END( node );
|
|---|
| [13932f14] | 565 | }
|
|---|
| 566 |
|
|---|
| [e0886db] | 567 | template< typename pass_type >
|
|---|
| 568 | Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
|
|---|
| 569 | MUTATE_START( node );
|
|---|
| 570 |
|
|---|
| 571 | {
|
|---|
| 572 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 573 | maybeMutate_impl( node->parameters, *this );
|
|---|
| 574 | maybeMutate_impl( node->members , *this );
|
|---|
| [e0886db] | 575 | }
|
|---|
| 576 |
|
|---|
| 577 | indexerAddTrait( node );
|
|---|
| 578 |
|
|---|
| 579 | MUTATE_END( Declaration, node );
|
|---|
| 580 | }
|
|---|
| 581 |
|
|---|
| 582 | //--------------------------------------------------------------------------
|
|---|
| 583 | // TypeDecl
|
|---|
| [13932f14] | 584 | template< typename pass_type >
|
|---|
| [ab904dc] | 585 | void PassVisitor< pass_type >::visit( TypeDecl * node ) {
|
|---|
| [e0886db] | 586 | VISIT_START( node );
|
|---|
| 587 |
|
|---|
| 588 | {
|
|---|
| 589 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 590 | maybeAccept_impl( node->parameters, *this );
|
|---|
| 591 | maybeAccept_impl( node->base , *this );
|
|---|
| [e0886db] | 592 | }
|
|---|
| 593 |
|
|---|
| [33a25f9] | 594 | // see A NOTE ON THE ORDER OF TRAVERSAL, above
|
|---|
| 595 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper
|
|---|
| 596 | // and may depend on the type itself
|
|---|
| [e0886db] | 597 | indexerAddType( node );
|
|---|
| 598 |
|
|---|
| [3c398b6] | 599 | maybeAccept_impl( node->assertions, *this );
|
|---|
| [e0886db] | 600 |
|
|---|
| 601 | indexerScopedAccept( node->init, *this );
|
|---|
| 602 |
|
|---|
| 603 | VISIT_END( node );
|
|---|
| 604 | }
|
|---|
| 605 |
|
|---|
| 606 | template< typename pass_type >
|
|---|
| [982832e] | 607 | Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
|
|---|
| [e0886db] | 608 | MUTATE_START( node );
|
|---|
| 609 |
|
|---|
| 610 | {
|
|---|
| 611 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 612 | maybeMutate_impl( node->parameters, *this );
|
|---|
| 613 | maybeMutate_impl( node->base , *this );
|
|---|
| [e0886db] | 614 | }
|
|---|
| 615 |
|
|---|
| [33a25f9] | 616 | // see A NOTE ON THE ORDER OF TRAVERSAL, above
|
|---|
| 617 | // note that assertions come after the type is added to the symtab, since they are not part of the type proper
|
|---|
| 618 | // and may depend on the type itself
|
|---|
| [e0886db] | 619 | indexerAddType( node );
|
|---|
| 620 |
|
|---|
| [3c398b6] | 621 | maybeMutate_impl( node->assertions, *this );
|
|---|
| [e0886db] | 622 |
|
|---|
| 623 | indexerScopedMutate( node->init, *this );
|
|---|
| 624 |
|
|---|
| [982832e] | 625 | MUTATE_END( Declaration, node );
|
|---|
| [13932f14] | 626 | }
|
|---|
| 627 |
|
|---|
| [e0886db] | 628 | //--------------------------------------------------------------------------
|
|---|
| 629 | // TypedefDecl
|
|---|
| [13932f14] | 630 | template< typename pass_type >
|
|---|
| [ab904dc] | 631 | void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
|
|---|
| [e0886db] | 632 | VISIT_START( node );
|
|---|
| 633 |
|
|---|
| 634 | {
|
|---|
| 635 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 636 | maybeAccept_impl( node->parameters, *this );
|
|---|
| 637 | maybeAccept_impl( node->base , *this );
|
|---|
| [e0886db] | 638 | }
|
|---|
| 639 |
|
|---|
| 640 | indexerAddType( node );
|
|---|
| 641 |
|
|---|
| [3c398b6] | 642 | maybeAccept_impl( node->assertions, *this );
|
|---|
| [e0886db] | 643 |
|
|---|
| 644 | VISIT_END( node );
|
|---|
| [13932f14] | 645 | }
|
|---|
| 646 |
|
|---|
| 647 | template< typename pass_type >
|
|---|
| [e0886db] | 648 | Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
|
|---|
| 649 | MUTATE_START( node );
|
|---|
| 650 |
|
|---|
| 651 | {
|
|---|
| 652 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 653 | maybeMutate_impl( node->parameters, *this );
|
|---|
| 654 | maybeMutate_impl( node->base , *this );
|
|---|
| [e0886db] | 655 | }
|
|---|
| 656 |
|
|---|
| 657 | indexerAddType( node );
|
|---|
| 658 |
|
|---|
| [3c398b6] | 659 | maybeMutate_impl( node->assertions, *this );
|
|---|
| [e0886db] | 660 |
|
|---|
| 661 | MUTATE_END( Declaration, node );
|
|---|
| [13932f14] | 662 | }
|
|---|
| 663 |
|
|---|
| [9c1600c] | 664 | //--------------------------------------------------------------------------
|
|---|
| [e0886db] | 665 | // AsmDecl
|
|---|
| [13932f14] | 666 | template< typename pass_type >
|
|---|
| [e0886db] | 667 | void PassVisitor< pass_type >::visit( AsmDecl * node ) {
|
|---|
| [9c1600c] | 668 | VISIT_START( node );
|
|---|
| 669 |
|
|---|
| [3c398b6] | 670 | maybeAccept_impl( node->stmt, *this );
|
|---|
| [9c1600c] | 671 |
|
|---|
| 672 | VISIT_END( node );
|
|---|
| [13932f14] | 673 | }
|
|---|
| 674 |
|
|---|
| [296b2be] | 675 | template< typename pass_type >
|
|---|
| [e0886db] | 676 | AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
|
|---|
| [296b2be] | 677 | MUTATE_START( node );
|
|---|
| 678 |
|
|---|
| [3c398b6] | 679 | maybeMutate_impl( node->stmt, *this );
|
|---|
| [e0886db] | 680 |
|
|---|
| 681 | MUTATE_END( AsmDecl, node );
|
|---|
| 682 | }
|
|---|
| 683 |
|
|---|
| 684 | //--------------------------------------------------------------------------
|
|---|
| 685 | // CompoundStmt
|
|---|
| 686 | template< typename pass_type >
|
|---|
| 687 | void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
|
|---|
| 688 | VISIT_START( node );
|
|---|
| 689 | {
|
|---|
| 690 | auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| 691 | auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
|
|---|
| 692 | visitStatementList( node->kids );
|
|---|
| 693 | }
|
|---|
| 694 | VISIT_END( node );
|
|---|
| 695 | }
|
|---|
| [296b2be] | 696 |
|
|---|
| [e0886db] | 697 | template< typename pass_type >
|
|---|
| 698 | CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
|
|---|
| 699 | MUTATE_START( node );
|
|---|
| 700 | {
|
|---|
| 701 | auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| 702 | auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );
|
|---|
| 703 | mutateStatementList( node->kids );
|
|---|
| 704 | }
|
|---|
| [296b2be] | 705 | MUTATE_END( CompoundStmt, node );
|
|---|
| 706 | }
|
|---|
| 707 |
|
|---|
| [9c1600c] | 708 | //--------------------------------------------------------------------------
|
|---|
| 709 | // ExprStmt
|
|---|
| [13932f14] | 710 | template< typename pass_type >
|
|---|
| [ab904dc] | 711 | void PassVisitor< pass_type >::visit( ExprStmt * node ) {
|
|---|
| [9c1600c] | 712 | VISIT_START( node );
|
|---|
| 713 |
|
|---|
| [e0886db] | 714 | visitExpression( node->expr );
|
|---|
| [9c1600c] | 715 |
|
|---|
| 716 | VISIT_END( node );
|
|---|
| [13932f14] | 717 | }
|
|---|
| 718 |
|
|---|
| [296b2be] | 719 | template< typename pass_type >
|
|---|
| 720 | Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
|
|---|
| 721 | MUTATE_START( node );
|
|---|
| 722 |
|
|---|
| [e0886db] | 723 | node->expr = mutateExpression( node->expr );
|
|---|
| [296b2be] | 724 |
|
|---|
| 725 | MUTATE_END( Statement, node );
|
|---|
| 726 | }
|
|---|
| 727 |
|
|---|
| [6ca154b] | 728 | //--------------------------------------------------------------------------
|
|---|
| 729 | // AsmStmt
|
|---|
| [13932f14] | 730 | template< typename pass_type >
|
|---|
| [ab904dc] | 731 | void PassVisitor< pass_type >::visit( AsmStmt * node ) {
|
|---|
| [4551a6e] | 732 | VISIT_BODY( node );
|
|---|
| [13932f14] | 733 | }
|
|---|
| 734 |
|
|---|
| [6ca154b] | 735 | template< typename pass_type >
|
|---|
| 736 | Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
|
|---|
| 737 | MUTATE_BODY( Statement, node );
|
|---|
| 738 | }
|
|---|
| 739 |
|
|---|
| [9c1600c] | 740 | //--------------------------------------------------------------------------
|
|---|
| 741 | // IfStmt
|
|---|
| [13932f14] | 742 | template< typename pass_type >
|
|---|
| [ab904dc] | 743 | void PassVisitor< pass_type >::visit( IfStmt * node ) {
|
|---|
| [4551a6e] | 744 | VISIT_START( node );
|
|---|
| [33a25f9] | 745 | {
|
|---|
| 746 | // if statements introduce a level of scope (for the initialization)
|
|---|
| 747 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 748 | maybeAccept_impl( node->get_initialization(), *this );
|
|---|
| 749 | visitExpression ( node->condition );
|
|---|
| [33a25f9] | 750 | node->thenPart = visitStatement( node->thenPart );
|
|---|
| 751 | node->elsePart = visitStatement( node->elsePart );
|
|---|
| 752 | }
|
|---|
| [9c1600c] | 753 | VISIT_END( node );
|
|---|
| [13932f14] | 754 | }
|
|---|
| 755 |
|
|---|
| [296b2be] | 756 | template< typename pass_type >
|
|---|
| 757 | Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
|
|---|
| [4551a6e] | 758 | MUTATE_START( node );
|
|---|
| [e0886db] | 759 | {
|
|---|
| [33a25f9] | 760 | // if statements introduce a level of scope (for the initialization)
|
|---|
| [e0886db] | 761 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 762 | maybeMutate_impl( node->get_initialization(), *this );
|
|---|
| [e0886db] | 763 | node->condition = mutateExpression( node->condition );
|
|---|
| 764 | node->thenPart = mutateStatement ( node->thenPart );
|
|---|
| 765 | node->elsePart = mutateStatement ( node->elsePart );
|
|---|
| 766 | }
|
|---|
| [296b2be] | 767 | MUTATE_END( Statement, node );
|
|---|
| 768 | }
|
|---|
| 769 |
|
|---|
| [9c1600c] | 770 | //--------------------------------------------------------------------------
|
|---|
| 771 | // WhileStmt
|
|---|
| [13932f14] | 772 | template< typename pass_type >
|
|---|
| [ab904dc] | 773 | void PassVisitor< pass_type >::visit( WhileStmt * node ) {
|
|---|
| [4551a6e] | 774 | VISIT_START( node );
|
|---|
| [9c1600c] | 775 |
|
|---|
| [e0886db] | 776 | visitExpression( node->condition );
|
|---|
| 777 | node->body = visitStatement( node->body );
|
|---|
| [9c1600c] | 778 |
|
|---|
| 779 | VISIT_END( node );
|
|---|
| [13932f14] | 780 | }
|
|---|
| 781 |
|
|---|
| [296b2be] | 782 | template< typename pass_type >
|
|---|
| 783 | Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
|
|---|
| [4551a6e] | 784 | MUTATE_START( node );
|
|---|
| [296b2be] | 785 |
|
|---|
| [e0886db] | 786 | node->condition = mutateExpression( node->condition );
|
|---|
| 787 | node->body = mutateStatement ( node->body );
|
|---|
| [296b2be] | 788 |
|
|---|
| 789 | MUTATE_END( Statement, node );
|
|---|
| 790 | }
|
|---|
| 791 |
|
|---|
| [9c1600c] | 792 | //--------------------------------------------------------------------------
|
|---|
| [6ca154b] | 793 | // ForStmt
|
|---|
| [13932f14] | 794 | template< typename pass_type >
|
|---|
| [ab904dc] | 795 | void PassVisitor< pass_type >::visit( ForStmt * node ) {
|
|---|
| [4551a6e] | 796 | VISIT_START( node );
|
|---|
| [e0886db] | 797 | {
|
|---|
| [33a25f9] | 798 | // for statements introduce a level of scope (for the initialization)
|
|---|
| [e0886db] | 799 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 800 | maybeAccept_impl( node->initialization, *this );
|
|---|
| [e0886db] | 801 | visitExpression( node->condition );
|
|---|
| 802 | visitExpression( node->increment );
|
|---|
| 803 | node->body = visitStatement( node->body );
|
|---|
| 804 | }
|
|---|
| [9c1600c] | 805 | VISIT_END( node );
|
|---|
| [13932f14] | 806 | }
|
|---|
| 807 |
|
|---|
| [296b2be] | 808 | template< typename pass_type >
|
|---|
| 809 | Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
|
|---|
| [4551a6e] | 810 | MUTATE_START( node );
|
|---|
| [e0886db] | 811 | {
|
|---|
| [33a25f9] | 812 | // for statements introduce a level of scope (for the initialization)
|
|---|
| [e0886db] | 813 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 814 | maybeMutate_impl( node->initialization, *this );
|
|---|
| [e0886db] | 815 | node->condition = mutateExpression( node->condition );
|
|---|
| 816 | node->increment = mutateExpression( node->increment );
|
|---|
| 817 | node->body = mutateStatement ( node->body );
|
|---|
| 818 | }
|
|---|
| [296b2be] | 819 | MUTATE_END( Statement, node );
|
|---|
| 820 | }
|
|---|
| 821 |
|
|---|
| [9c1600c] | 822 | //--------------------------------------------------------------------------
|
|---|
| 823 | // SwitchStmt
|
|---|
| [13932f14] | 824 | template< typename pass_type >
|
|---|
| [ab904dc] | 825 | void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
|
|---|
| [4551a6e] | 826 | VISIT_START( node );
|
|---|
| [9c1600c] | 827 |
|
|---|
| [e0886db] | 828 | visitExpression ( node->condition );
|
|---|
| 829 | visitStatementList( node->statements );
|
|---|
| [9c1600c] | 830 |
|
|---|
| 831 | VISIT_END( node );
|
|---|
| [13932f14] | 832 | }
|
|---|
| 833 |
|
|---|
| [296b2be] | 834 | template< typename pass_type >
|
|---|
| 835 | Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
|
|---|
| [4551a6e] | 836 | MUTATE_START( node );
|
|---|
| 837 |
|
|---|
| [e0886db] | 838 | node->condition = mutateExpression( node->condition );
|
|---|
| 839 | mutateStatementList( node->statements );
|
|---|
| [4551a6e] | 840 |
|
|---|
| [296b2be] | 841 | MUTATE_END( Statement, node );
|
|---|
| 842 | }
|
|---|
| 843 |
|
|---|
| [9c1600c] | 844 | //--------------------------------------------------------------------------
|
|---|
| [35df560] | 845 | // CaseStmt
|
|---|
| [13932f14] | 846 | template< typename pass_type >
|
|---|
| [ab904dc] | 847 | void PassVisitor< pass_type >::visit( CaseStmt * node ) {
|
|---|
| [4551a6e] | 848 | VISIT_START( node );
|
|---|
| 849 |
|
|---|
| [e0886db] | 850 | visitExpression ( node->condition );
|
|---|
| 851 | visitStatementList( node->stmts );
|
|---|
| [4551a6e] | 852 |
|
|---|
| [9c1600c] | 853 | VISIT_END( node );
|
|---|
| [13932f14] | 854 | }
|
|---|
| 855 |
|
|---|
| [296b2be] | 856 | template< typename pass_type >
|
|---|
| 857 | Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
|
|---|
| [4551a6e] | 858 | MUTATE_START( node );
|
|---|
| 859 |
|
|---|
| [e0886db] | 860 | node->condition = mutateExpression( node->condition );
|
|---|
| 861 | mutateStatementList( node->stmts );
|
|---|
| [4551a6e] | 862 |
|
|---|
| [296b2be] | 863 | MUTATE_END( Statement, node );
|
|---|
| 864 | }
|
|---|
| 865 |
|
|---|
| [6ca154b] | 866 | //--------------------------------------------------------------------------
|
|---|
| 867 | // BranchStmt
|
|---|
| [13932f14] | 868 | template< typename pass_type >
|
|---|
| [ab904dc] | 869 | void PassVisitor< pass_type >::visit( BranchStmt * node ) {
|
|---|
| [4551a6e] | 870 | VISIT_BODY( node );
|
|---|
| [13932f14] | 871 | }
|
|---|
| 872 |
|
|---|
| [6ca154b] | 873 | template< typename pass_type >
|
|---|
| 874 | Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
|
|---|
| 875 | MUTATE_BODY( Statement, node );
|
|---|
| 876 | }
|
|---|
| 877 |
|
|---|
| [9c1600c] | 878 | //--------------------------------------------------------------------------
|
|---|
| 879 | // ReturnStmt
|
|---|
| [13932f14] | 880 | template< typename pass_type >
|
|---|
| [ab904dc] | 881 | void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
|
|---|
| [9c1600c] | 882 | VISIT_START( node );
|
|---|
| 883 |
|
|---|
| [e0886db] | 884 | visitExpression( node->expr );
|
|---|
| [9c1600c] | 885 |
|
|---|
| 886 | VISIT_END( node );
|
|---|
| [13932f14] | 887 | }
|
|---|
| 888 |
|
|---|
| [296b2be] | 889 | template< typename pass_type >
|
|---|
| 890 | Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
|
|---|
| 891 | MUTATE_START( node );
|
|---|
| 892 |
|
|---|
| [e0886db] | 893 | node->expr = mutateExpression( node->expr );
|
|---|
| [296b2be] | 894 |
|
|---|
| 895 | MUTATE_END( Statement, node );
|
|---|
| 896 | }
|
|---|
| 897 |
|
|---|
| [6e09f211] | 898 | //--------------------------------------------------------------------------
|
|---|
| 899 | // ThrowStmt
|
|---|
| 900 |
|
|---|
| 901 | template< typename pass_type >
|
|---|
| 902 | void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
|
|---|
| 903 | VISIT_BODY( node );
|
|---|
| 904 | }
|
|---|
| 905 |
|
|---|
| 906 | template< typename pass_type >
|
|---|
| 907 | Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
|
|---|
| 908 | MUTATE_BODY( Statement, node );
|
|---|
| 909 | }
|
|---|
| 910 |
|
|---|
| [9c1600c] | 911 | //--------------------------------------------------------------------------
|
|---|
| 912 | // TryStmt
|
|---|
| [13932f14] | 913 | template< typename pass_type >
|
|---|
| [ab904dc] | 914 | void PassVisitor< pass_type >::visit( TryStmt * node ) {
|
|---|
| [9c1600c] | 915 | VISIT_START( node );
|
|---|
| 916 |
|
|---|
| [3c398b6] | 917 | maybeAccept_impl( node->block , *this );
|
|---|
| 918 | maybeAccept_impl( node->handlers , *this );
|
|---|
| 919 | maybeAccept_impl( node->finallyBlock, *this );
|
|---|
| [9c1600c] | 920 |
|
|---|
| 921 | VISIT_END( node );
|
|---|
| [13932f14] | 922 | }
|
|---|
| 923 |
|
|---|
| [296b2be] | 924 | template< typename pass_type >
|
|---|
| 925 | Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
|
|---|
| 926 | MUTATE_START( node );
|
|---|
| 927 |
|
|---|
| [3c398b6] | 928 | maybeMutate_impl( node->block , *this );
|
|---|
| 929 | maybeMutate_impl( node->handlers , *this );
|
|---|
| 930 | maybeMutate_impl( node->finallyBlock, *this );
|
|---|
| [4551a6e] | 931 |
|
|---|
| [296b2be] | 932 | MUTATE_END( Statement, node );
|
|---|
| 933 | }
|
|---|
| 934 |
|
|---|
| [9c1600c] | 935 | //--------------------------------------------------------------------------
|
|---|
| 936 | // CatchStmt
|
|---|
| [13932f14] | 937 | template< typename pass_type >
|
|---|
| [ab904dc] | 938 | void PassVisitor< pass_type >::visit( CatchStmt * node ) {
|
|---|
| [9c1600c] | 939 | VISIT_START( node );
|
|---|
| [e0886db] | 940 | {
|
|---|
| [33a25f9] | 941 | // catch statements introduce a level of scope (for the caught exception)
|
|---|
| [e0886db] | 942 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 943 | maybeAccept_impl( node->decl, *this );
|
|---|
| [e0886db] | 944 | node->cond = visitExpression( node->cond );
|
|---|
| 945 | node->body = visitStatement ( node->body );
|
|---|
| 946 | }
|
|---|
| [9c1600c] | 947 | VISIT_END( node );
|
|---|
| [13932f14] | 948 | }
|
|---|
| 949 |
|
|---|
| [296b2be] | 950 | template< typename pass_type >
|
|---|
| 951 | Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
|
|---|
| 952 | MUTATE_START( node );
|
|---|
| [e0886db] | 953 | {
|
|---|
| [33a25f9] | 954 | // catch statements introduce a level of scope (for the caught exception)
|
|---|
| [e0886db] | 955 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 956 | maybeMutate_impl( node->decl, *this );
|
|---|
| [e0886db] | 957 | node->cond = mutateExpression( node->cond );
|
|---|
| 958 | node->body = mutateStatement ( node->body );
|
|---|
| 959 | }
|
|---|
| [296b2be] | 960 | MUTATE_END( Statement, node );
|
|---|
| 961 | }
|
|---|
| 962 |
|
|---|
| [2065609] | 963 | //--------------------------------------------------------------------------
|
|---|
| 964 | // FinallyStmt
|
|---|
| [13932f14] | 965 | template< typename pass_type >
|
|---|
| [ab904dc] | 966 | void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
|
|---|
| [4551a6e] | 967 | VISIT_BODY( node );
|
|---|
| [13932f14] | 968 | }
|
|---|
| 969 |
|
|---|
| [2065609] | 970 | template< typename pass_type >
|
|---|
| 971 | Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
|
|---|
| 972 | MUTATE_BODY( Statement, node );
|
|---|
| 973 | }
|
|---|
| 974 |
|
|---|
| 975 | //--------------------------------------------------------------------------
|
|---|
| 976 | // WaitForStmt
|
|---|
| 977 | template< typename pass_type >
|
|---|
| 978 | void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
|
|---|
| 979 | VISIT_BODY( node );
|
|---|
| 980 | }
|
|---|
| 981 |
|
|---|
| 982 | template< typename pass_type >
|
|---|
| 983 | Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
|
|---|
| 984 | MUTATE_BODY( Statement, node );
|
|---|
| 985 | }
|
|---|
| 986 |
|
|---|
| [61255ad] | 987 | //--------------------------------------------------------------------------
|
|---|
| 988 | // NullStmt
|
|---|
| 989 | template< typename pass_type >
|
|---|
| 990 | void PassVisitor< pass_type >::visit( WithStmt * node ) {
|
|---|
| 991 | VISIT_BODY( node );
|
|---|
| 992 | }
|
|---|
| 993 |
|
|---|
| 994 | template< typename pass_type >
|
|---|
| 995 | Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
|
|---|
| 996 | MUTATE_BODY( Statement, node );
|
|---|
| 997 | }
|
|---|
| 998 |
|
|---|
| [2065609] | 999 | //--------------------------------------------------------------------------
|
|---|
| 1000 | // NullStmt
|
|---|
| [13932f14] | 1001 | template< typename pass_type >
|
|---|
| [ab904dc] | 1002 | void PassVisitor< pass_type >::visit( NullStmt * node ) {
|
|---|
| [4551a6e] | 1003 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1004 | }
|
|---|
| 1005 |
|
|---|
| [2065609] | 1006 | template< typename pass_type >
|
|---|
| 1007 | NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
|
|---|
| 1008 | MUTATE_BODY( NullStmt, node );
|
|---|
| 1009 | }
|
|---|
| 1010 |
|
|---|
| 1011 | //--------------------------------------------------------------------------
|
|---|
| 1012 | // DeclStmt
|
|---|
| [13932f14] | 1013 | template< typename pass_type >
|
|---|
| [ab904dc] | 1014 | void PassVisitor< pass_type >::visit( DeclStmt * node ) {
|
|---|
| [4551a6e] | 1015 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1016 | }
|
|---|
| 1017 |
|
|---|
| [2065609] | 1018 | template< typename pass_type >
|
|---|
| 1019 | Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
|
|---|
| 1020 | MUTATE_BODY( Statement, node );
|
|---|
| 1021 | }
|
|---|
| 1022 |
|
|---|
| 1023 | //--------------------------------------------------------------------------
|
|---|
| 1024 | // ImplicitCtorDtorStmt
|
|---|
| [13932f14] | 1025 | template< typename pass_type >
|
|---|
| [ab904dc] | 1026 | void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
|
|---|
| [4551a6e] | 1027 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1028 | }
|
|---|
| 1029 |
|
|---|
| [2065609] | 1030 | template< typename pass_type >
|
|---|
| 1031 | Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
|
|---|
| 1032 | MUTATE_BODY( Statement, node );
|
|---|
| 1033 | }
|
|---|
| 1034 |
|
|---|
| 1035 | //--------------------------------------------------------------------------
|
|---|
| 1036 | // ApplicationExpr
|
|---|
| [13932f14] | 1037 | template< typename pass_type >
|
|---|
| [ab904dc] | 1038 | void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
|
|---|
| [e0886db] | 1039 | VISIT_START( node );
|
|---|
| 1040 |
|
|---|
| 1041 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1042 | maybeAccept_impl ( node->function, *this );
|
|---|
| 1043 | maybeAccept_impl ( node->args , *this );
|
|---|
| [e0886db] | 1044 |
|
|---|
| 1045 | VISIT_END( node );
|
|---|
| [13932f14] | 1046 | }
|
|---|
| 1047 |
|
|---|
| [2065609] | 1048 | template< typename pass_type >
|
|---|
| 1049 | Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
|
|---|
| [e0886db] | 1050 | MUTATE_START( node );
|
|---|
| 1051 |
|
|---|
| 1052 | indexerScopedMutate( node->env , *this );
|
|---|
| 1053 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1054 | maybeMutate_impl ( node->function, *this );
|
|---|
| 1055 | maybeMutate_impl ( node->args , *this );
|
|---|
| [e0886db] | 1056 |
|
|---|
| 1057 | MUTATE_END( Expression, node );
|
|---|
| [2065609] | 1058 | }
|
|---|
| 1059 |
|
|---|
| [9c1600c] | 1060 | //--------------------------------------------------------------------------
|
|---|
| 1061 | // UntypedExpr
|
|---|
| [13932f14] | 1062 | template< typename pass_type >
|
|---|
| [ab904dc] | 1063 | void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
|
|---|
| [9c1600c] | 1064 | VISIT_START( node );
|
|---|
| 1065 |
|
|---|
| [3c398b6] | 1066 | // maybeAccept_impl( node->get_env(), *this );
|
|---|
| [e0886db] | 1067 | indexerScopedAccept( node->result, *this );
|
|---|
| [2a7b3ca] | 1068 |
|
|---|
| [e0886db] | 1069 | for ( auto expr : node->args ) {
|
|---|
| [9c1600c] | 1070 | visitExpression( expr );
|
|---|
| 1071 | }
|
|---|
| 1072 |
|
|---|
| 1073 | VISIT_END( node );
|
|---|
| [13932f14] | 1074 | }
|
|---|
| 1075 |
|
|---|
| [296b2be] | 1076 | template< typename pass_type >
|
|---|
| 1077 | Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
|
|---|
| 1078 | MUTATE_START( node );
|
|---|
| 1079 |
|
|---|
| [e0886db] | 1080 | indexerScopedMutate( node->env , *this );
|
|---|
| 1081 | indexerScopedMutate( node->result, *this );
|
|---|
| [2a7b3ca] | 1082 |
|
|---|
| [e0886db] | 1083 | for ( auto& expr : node->args ) {
|
|---|
| [296b2be] | 1084 | expr = mutateExpression( expr );
|
|---|
| 1085 | }
|
|---|
| 1086 |
|
|---|
| 1087 | MUTATE_END( Expression, node );
|
|---|
| 1088 | }
|
|---|
| 1089 |
|
|---|
| [e0886db] | 1090 | //--------------------------------------------------------------------------
|
|---|
| 1091 | // NameExpr
|
|---|
| [13932f14] | 1092 | template< typename pass_type >
|
|---|
| [ab904dc] | 1093 | void PassVisitor< pass_type >::visit( NameExpr * node ) {
|
|---|
| [e0886db] | 1094 | VISIT_START( node );
|
|---|
| 1095 |
|
|---|
| 1096 | indexerScopedAccept( node->result, *this );
|
|---|
| 1097 |
|
|---|
| 1098 | VISIT_END( node );
|
|---|
| [13932f14] | 1099 | }
|
|---|
| 1100 |
|
|---|
| 1101 | template< typename pass_type >
|
|---|
| [e0886db] | 1102 | Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
|
|---|
| 1103 | MUTATE_START( node );
|
|---|
| 1104 |
|
|---|
| 1105 | indexerScopedMutate( node->env , *this );
|
|---|
| 1106 | indexerScopedMutate( node->result, *this );
|
|---|
| 1107 |
|
|---|
| 1108 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1109 | }
|
|---|
| 1110 |
|
|---|
| [e0886db] | 1111 | //--------------------------------------------------------------------------
|
|---|
| 1112 | // CastExpr
|
|---|
| [a5f0529] | 1113 | template< typename pass_type >
|
|---|
| [e0886db] | 1114 | void PassVisitor< pass_type >::visit( CastExpr * node ) {
|
|---|
| 1115 | VISIT_START( node );
|
|---|
| 1116 |
|
|---|
| 1117 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1118 | maybeAccept_impl ( node->arg , *this );
|
|---|
| [e0886db] | 1119 |
|
|---|
| 1120 | VISIT_END( node );
|
|---|
| [a5f0529] | 1121 | }
|
|---|
| 1122 |
|
|---|
| [13932f14] | 1123 | template< typename pass_type >
|
|---|
| [e0886db] | 1124 | Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
|
|---|
| 1125 | MUTATE_START( node );
|
|---|
| 1126 |
|
|---|
| 1127 | indexerScopedMutate( node->env , *this );
|
|---|
| 1128 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1129 | maybeMutate_impl ( node->arg , *this );
|
|---|
| [e0886db] | 1130 |
|
|---|
| 1131 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1132 | }
|
|---|
| 1133 |
|
|---|
| [e0886db] | 1134 | //--------------------------------------------------------------------------
|
|---|
| 1135 | // VirtualCastExpr
|
|---|
| [13932f14] | 1136 | template< typename pass_type >
|
|---|
| [e0886db] | 1137 | void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
|
|---|
| 1138 | VISIT_START( node );
|
|---|
| 1139 |
|
|---|
| 1140 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1141 | maybeAccept_impl( node->arg, *this );
|
|---|
| [e0886db] | 1142 |
|
|---|
| 1143 | VISIT_END( node );
|
|---|
| [13932f14] | 1144 | }
|
|---|
| 1145 |
|
|---|
| 1146 | template< typename pass_type >
|
|---|
| [e0886db] | 1147 | Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
|
|---|
| 1148 | MUTATE_START( node );
|
|---|
| 1149 |
|
|---|
| 1150 | indexerScopedMutate( node->env , *this );
|
|---|
| 1151 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1152 | maybeMutate_impl ( node->arg , *this );
|
|---|
| [e0886db] | 1153 |
|
|---|
| 1154 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1155 | }
|
|---|
| 1156 |
|
|---|
| [e0886db] | 1157 | //--------------------------------------------------------------------------
|
|---|
| 1158 | // AddressExpr
|
|---|
| [13932f14] | 1159 | template< typename pass_type >
|
|---|
| [e0886db] | 1160 | void PassVisitor< pass_type >::visit( AddressExpr * node ) {
|
|---|
| 1161 | VISIT_START( node );
|
|---|
| 1162 |
|
|---|
| 1163 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1164 | maybeAccept_impl ( node->arg , *this );
|
|---|
| [e0886db] | 1165 |
|
|---|
| 1166 | VISIT_END( node );
|
|---|
| [13932f14] | 1167 | }
|
|---|
| 1168 |
|
|---|
| 1169 | template< typename pass_type >
|
|---|
| [e0886db] | 1170 | Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
|
|---|
| 1171 | MUTATE_START( node );
|
|---|
| 1172 |
|
|---|
| 1173 | indexerScopedMutate( node->env , *this );
|
|---|
| 1174 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1175 | maybeMutate_impl ( node->arg , *this );
|
|---|
| [e0886db] | 1176 |
|
|---|
| 1177 | MUTATE_END( Expression, node );
|
|---|
| 1178 | }
|
|---|
| 1179 |
|
|---|
| 1180 | //--------------------------------------------------------------------------
|
|---|
| 1181 | // LabelAddressExpr
|
|---|
| 1182 | template< typename pass_type >
|
|---|
| 1183 | void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
|
|---|
| 1184 | VISIT_START( node );
|
|---|
| 1185 |
|
|---|
| 1186 | indexerScopedAccept( node->result, *this );
|
|---|
| 1187 |
|
|---|
| 1188 | VISIT_END( node );
|
|---|
| 1189 | }
|
|---|
| 1190 |
|
|---|
| 1191 | template< typename pass_type >
|
|---|
| 1192 | Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
|
|---|
| 1193 | MUTATE_START( node );
|
|---|
| 1194 |
|
|---|
| 1195 | indexerScopedMutate( node->env , *this );
|
|---|
| 1196 | indexerScopedMutate( node->result, *this );
|
|---|
| 1197 |
|
|---|
| 1198 | MUTATE_END( Expression, node );
|
|---|
| 1199 | }
|
|---|
| 1200 |
|
|---|
| 1201 | //--------------------------------------------------------------------------
|
|---|
| 1202 | // UntypedMemberExpr
|
|---|
| 1203 | template< typename pass_type >
|
|---|
| 1204 | void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
|
|---|
| 1205 | VISIT_START( node );
|
|---|
| 1206 |
|
|---|
| 1207 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1208 | maybeAccept_impl ( node->aggregate, *this );
|
|---|
| 1209 | maybeAccept_impl ( node->member , *this );
|
|---|
| [e0886db] | 1210 |
|
|---|
| 1211 | VISIT_END( node );
|
|---|
| [13932f14] | 1212 | }
|
|---|
| 1213 |
|
|---|
| [e0886db] | 1214 | template< typename pass_type >
|
|---|
| 1215 | Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
|
|---|
| 1216 | MUTATE_START( node );
|
|---|
| 1217 |
|
|---|
| 1218 | indexerScopedMutate( node->env , *this );
|
|---|
| 1219 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1220 | maybeMutate_impl ( node->aggregate, *this );
|
|---|
| 1221 | maybeMutate_impl ( node->member , *this );
|
|---|
| [e0886db] | 1222 |
|
|---|
| 1223 | MUTATE_END( Expression, node );
|
|---|
| 1224 | }
|
|---|
| 1225 |
|
|---|
| 1226 | //--------------------------------------------------------------------------
|
|---|
| 1227 | // MemberExpr
|
|---|
| 1228 | template< typename pass_type >
|
|---|
| 1229 | void PassVisitor< pass_type >::visit( MemberExpr * node ) {
|
|---|
| 1230 | VISIT_START( node );
|
|---|
| 1231 |
|
|---|
| 1232 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1233 | maybeAccept_impl ( node->aggregate, *this );
|
|---|
| [e0886db] | 1234 |
|
|---|
| 1235 | VISIT_END( node );
|
|---|
| 1236 | }
|
|---|
| 1237 |
|
|---|
| 1238 | template< typename pass_type >
|
|---|
| 1239 | Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
|
|---|
| 1240 | MUTATE_START( node );
|
|---|
| 1241 |
|
|---|
| 1242 | indexerScopedMutate( node->env , *this );
|
|---|
| 1243 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1244 | maybeMutate_impl ( node->aggregate, *this );
|
|---|
| [e0886db] | 1245 |
|
|---|
| 1246 | MUTATE_END( Expression, node );
|
|---|
| 1247 | }
|
|---|
| 1248 |
|
|---|
| 1249 | //--------------------------------------------------------------------------
|
|---|
| 1250 | // VariableExpr
|
|---|
| 1251 | template< typename pass_type >
|
|---|
| 1252 | void PassVisitor< pass_type >::visit( VariableExpr * node ) {
|
|---|
| 1253 | VISIT_START( node );
|
|---|
| 1254 |
|
|---|
| 1255 | indexerScopedAccept( node->result, *this );
|
|---|
| 1256 |
|
|---|
| 1257 | VISIT_END( node );
|
|---|
| 1258 | }
|
|---|
| 1259 |
|
|---|
| 1260 | template< typename pass_type >
|
|---|
| 1261 | Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
|
|---|
| 1262 | MUTATE_START( node );
|
|---|
| 1263 |
|
|---|
| 1264 | indexerScopedMutate( node->env , *this );
|
|---|
| 1265 | indexerScopedMutate( node->result, *this );
|
|---|
| 1266 |
|
|---|
| 1267 | MUTATE_END( Expression, node );
|
|---|
| 1268 | }
|
|---|
| 1269 |
|
|---|
| 1270 | //--------------------------------------------------------------------------
|
|---|
| 1271 | // ConstantExpr
|
|---|
| [13932f14] | 1272 | template< typename pass_type >
|
|---|
| [ab904dc] | 1273 | void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
|
|---|
| [e0886db] | 1274 | VISIT_START( node );
|
|---|
| 1275 |
|
|---|
| 1276 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1277 | maybeAccept_impl ( &node->constant, *this );
|
|---|
| [e0886db] | 1278 |
|
|---|
| 1279 | VISIT_END( node );
|
|---|
| [13932f14] | 1280 | }
|
|---|
| 1281 |
|
|---|
| [e0886db] | 1282 | template< typename pass_type >
|
|---|
| 1283 | Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
|
|---|
| 1284 | MUTATE_START( node );
|
|---|
| 1285 |
|
|---|
| 1286 | indexerScopedMutate( node->env , *this );
|
|---|
| 1287 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1288 | Constant * ptr = &node->constant;
|
|---|
| 1289 | maybeMutate_impl( ptr, *this );
|
|---|
| 1290 | node->constant = *ptr;
|
|---|
| [e0886db] | 1291 |
|
|---|
| 1292 | MUTATE_END( Expression, node );
|
|---|
| 1293 | }
|
|---|
| 1294 |
|
|---|
| 1295 | //--------------------------------------------------------------------------
|
|---|
| 1296 | // SizeofExpr
|
|---|
| [13932f14] | 1297 | template< typename pass_type >
|
|---|
| [ab904dc] | 1298 | void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
|
|---|
| [e0886db] | 1299 | VISIT_START( node );
|
|---|
| 1300 |
|
|---|
| 1301 | indexerScopedAccept( node->result, *this );
|
|---|
| 1302 | if ( node->get_isType() ) {
|
|---|
| [3c398b6] | 1303 | maybeAccept_impl( node->type, *this );
|
|---|
| [e0886db] | 1304 | } else {
|
|---|
| [3c398b6] | 1305 | maybeAccept_impl( node->expr, *this );
|
|---|
| [e0886db] | 1306 | }
|
|---|
| 1307 |
|
|---|
| 1308 | VISIT_END( node );
|
|---|
| [13932f14] | 1309 | }
|
|---|
| 1310 |
|
|---|
| [e0886db] | 1311 | template< typename pass_type >
|
|---|
| 1312 | Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
|
|---|
| 1313 | MUTATE_START( node );
|
|---|
| 1314 |
|
|---|
| 1315 | indexerScopedMutate( node->env , *this );
|
|---|
| 1316 | indexerScopedMutate( node->result, *this );
|
|---|
| 1317 | if ( node->get_isType() ) {
|
|---|
| [3c398b6] | 1318 | maybeMutate_impl( node->type, *this );
|
|---|
| [e0886db] | 1319 | } else {
|
|---|
| [3c398b6] | 1320 | maybeMutate_impl( node->expr, *this );
|
|---|
| [e0886db] | 1321 | }
|
|---|
| 1322 |
|
|---|
| 1323 | MUTATE_END( Expression, node );
|
|---|
| 1324 | }
|
|---|
| 1325 |
|
|---|
| 1326 | //--------------------------------------------------------------------------
|
|---|
| 1327 | // AlignofExpr
|
|---|
| [13932f14] | 1328 | template< typename pass_type >
|
|---|
| [ab904dc] | 1329 | void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
|
|---|
| [e0886db] | 1330 | VISIT_START( node );
|
|---|
| 1331 |
|
|---|
| 1332 | indexerScopedAccept( node->result, *this );
|
|---|
| 1333 | if ( node->get_isType() ) {
|
|---|
| [3c398b6] | 1334 | maybeAccept_impl( node->type, *this );
|
|---|
| [e0886db] | 1335 | } else {
|
|---|
| [3c398b6] | 1336 | maybeAccept_impl( node->expr, *this );
|
|---|
| [e0886db] | 1337 | }
|
|---|
| 1338 |
|
|---|
| 1339 | VISIT_END( node );
|
|---|
| [13932f14] | 1340 | }
|
|---|
| 1341 |
|
|---|
| [e0886db] | 1342 | template< typename pass_type >
|
|---|
| 1343 | Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
|
|---|
| 1344 | MUTATE_START( node );
|
|---|
| 1345 |
|
|---|
| 1346 | indexerScopedMutate( node->env , *this );
|
|---|
| 1347 | indexerScopedMutate( node->result, *this );
|
|---|
| 1348 | if ( node->get_isType() ) {
|
|---|
| [3c398b6] | 1349 | maybeMutate_impl( node->type, *this );
|
|---|
| [e0886db] | 1350 | } else {
|
|---|
| [3c398b6] | 1351 | maybeMutate_impl( node->expr, *this );
|
|---|
| [e0886db] | 1352 | }
|
|---|
| 1353 |
|
|---|
| 1354 | MUTATE_END( Expression, node );
|
|---|
| 1355 | }
|
|---|
| 1356 |
|
|---|
| 1357 | //--------------------------------------------------------------------------
|
|---|
| 1358 | // UntypedOffsetofExpr
|
|---|
| [13932f14] | 1359 | template< typename pass_type >
|
|---|
| [ab904dc] | 1360 | void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
|
|---|
| [e0886db] | 1361 | VISIT_START( node );
|
|---|
| 1362 |
|
|---|
| 1363 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1364 | maybeAccept_impl ( node->type , *this );
|
|---|
| [e0886db] | 1365 |
|
|---|
| 1366 | VISIT_END( node );
|
|---|
| [13932f14] | 1367 | }
|
|---|
| 1368 |
|
|---|
| [e0886db] | 1369 | template< typename pass_type >
|
|---|
| 1370 | Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
|
|---|
| 1371 | MUTATE_START( node );
|
|---|
| 1372 |
|
|---|
| 1373 | indexerScopedMutate( node->env , *this );
|
|---|
| 1374 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1375 | maybeMutate_impl ( node->type , *this );
|
|---|
| [e0886db] | 1376 |
|
|---|
| 1377 | MUTATE_END( Expression, node );
|
|---|
| 1378 | }
|
|---|
| 1379 |
|
|---|
| 1380 | //--------------------------------------------------------------------------
|
|---|
| 1381 | // OffsetofExpr
|
|---|
| [13932f14] | 1382 | template< typename pass_type >
|
|---|
| [ab904dc] | 1383 | void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
|
|---|
| [e0886db] | 1384 | VISIT_START( node );
|
|---|
| 1385 |
|
|---|
| 1386 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1387 | maybeAccept_impl ( node->type , *this );
|
|---|
| 1388 | maybeAccept_impl ( node->member, *this );
|
|---|
| [e0886db] | 1389 |
|
|---|
| 1390 | VISIT_END( node );
|
|---|
| [13932f14] | 1391 | }
|
|---|
| 1392 |
|
|---|
| [e0886db] | 1393 | template< typename pass_type >
|
|---|
| 1394 | Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
|
|---|
| 1395 | MUTATE_START( node );
|
|---|
| 1396 |
|
|---|
| 1397 | indexerScopedMutate( node->env , *this );
|
|---|
| 1398 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1399 | maybeMutate_impl ( node->type , *this );
|
|---|
| 1400 | maybeMutate_impl ( node->member, *this );
|
|---|
| [e0886db] | 1401 |
|
|---|
| 1402 | MUTATE_END( Expression, node );
|
|---|
| 1403 | }
|
|---|
| 1404 |
|
|---|
| 1405 | //--------------------------------------------------------------------------
|
|---|
| 1406 | // OffsetPackExpr
|
|---|
| [13932f14] | 1407 | template< typename pass_type >
|
|---|
| [ab904dc] | 1408 | void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
|
|---|
| [e0886db] | 1409 | VISIT_START( node );
|
|---|
| 1410 |
|
|---|
| 1411 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1412 | maybeAccept_impl ( node->type , *this );
|
|---|
| [e0886db] | 1413 |
|
|---|
| 1414 | VISIT_END( node );
|
|---|
| [13932f14] | 1415 | }
|
|---|
| 1416 |
|
|---|
| [e0886db] | 1417 | template< typename pass_type >
|
|---|
| 1418 | Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
|
|---|
| 1419 | MUTATE_START( node );
|
|---|
| 1420 |
|
|---|
| 1421 | indexerScopedMutate( node->env , *this );
|
|---|
| 1422 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1423 | maybeMutate_impl ( node->type , *this );
|
|---|
| [e0886db] | 1424 |
|
|---|
| 1425 | MUTATE_END( Expression, node );
|
|---|
| 1426 | }
|
|---|
| 1427 |
|
|---|
| 1428 | //--------------------------------------------------------------------------
|
|---|
| 1429 | // AttrExpr
|
|---|
| [13932f14] | 1430 | template< typename pass_type >
|
|---|
| [ab904dc] | 1431 | void PassVisitor< pass_type >::visit( AttrExpr * node ) {
|
|---|
| [e0886db] | 1432 | VISIT_START( node );
|
|---|
| 1433 |
|
|---|
| 1434 | indexerScopedAccept( node->result, *this );
|
|---|
| 1435 | if ( node->get_isType() ) {
|
|---|
| [3c398b6] | 1436 | maybeAccept_impl( node->type, *this );
|
|---|
| [e0886db] | 1437 | } else {
|
|---|
| [3c398b6] | 1438 | maybeAccept_impl( node->expr, *this );
|
|---|
| [e0886db] | 1439 | }
|
|---|
| 1440 |
|
|---|
| 1441 | VISIT_END( node );
|
|---|
| 1442 | }
|
|---|
| 1443 |
|
|---|
| 1444 | template< typename pass_type >
|
|---|
| 1445 | Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
|
|---|
| 1446 | MUTATE_START( node );
|
|---|
| 1447 |
|
|---|
| 1448 | indexerScopedMutate( node->env , *this );
|
|---|
| 1449 | indexerScopedMutate( node->result, *this );
|
|---|
| 1450 | if ( node->get_isType() ) {
|
|---|
| [3c398b6] | 1451 | maybeMutate_impl( node->type, *this );
|
|---|
| [e0886db] | 1452 | } else {
|
|---|
| [3c398b6] | 1453 | maybeMutate_impl( node->expr, *this );
|
|---|
| [e0886db] | 1454 | }
|
|---|
| 1455 |
|
|---|
| 1456 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1457 | }
|
|---|
| 1458 |
|
|---|
| [e0886db] | 1459 | //--------------------------------------------------------------------------
|
|---|
| 1460 | // LogicalExpr
|
|---|
| [13932f14] | 1461 | template< typename pass_type >
|
|---|
| [ab904dc] | 1462 | void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
|
|---|
| [e0886db] | 1463 | VISIT_START( node );
|
|---|
| 1464 |
|
|---|
| 1465 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1466 | maybeAccept_impl ( node->arg1 , *this );
|
|---|
| 1467 | maybeAccept_impl ( node->arg2 , *this );
|
|---|
| [e0886db] | 1468 |
|
|---|
| 1469 | VISIT_END( node );
|
|---|
| 1470 | }
|
|---|
| 1471 |
|
|---|
| 1472 | template< typename pass_type >
|
|---|
| 1473 | Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
|
|---|
| 1474 | MUTATE_START( node );
|
|---|
| 1475 |
|
|---|
| 1476 | indexerScopedMutate( node->env , *this );
|
|---|
| 1477 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1478 | maybeMutate_impl ( node->arg1 , *this );
|
|---|
| 1479 | maybeMutate_impl ( node->arg2 , *this );
|
|---|
| [e0886db] | 1480 |
|
|---|
| 1481 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1482 | }
|
|---|
| 1483 |
|
|---|
| [e0886db] | 1484 | //--------------------------------------------------------------------------
|
|---|
| 1485 | // ConditionalExpr
|
|---|
| [13932f14] | 1486 | template< typename pass_type >
|
|---|
| [ab904dc] | 1487 | void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
|
|---|
| [e0886db] | 1488 | VISIT_START( node );
|
|---|
| 1489 |
|
|---|
| 1490 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1491 | maybeAccept_impl ( node->arg1 , *this );
|
|---|
| 1492 | maybeAccept_impl ( node->arg2 , *this );
|
|---|
| 1493 | maybeAccept_impl ( node->arg3 , *this );
|
|---|
| [e0886db] | 1494 |
|
|---|
| 1495 | VISIT_END( node );
|
|---|
| [13932f14] | 1496 | }
|
|---|
| 1497 |
|
|---|
| [e0886db] | 1498 | template< typename pass_type >
|
|---|
| 1499 | Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
|
|---|
| 1500 | MUTATE_START( node );
|
|---|
| 1501 |
|
|---|
| 1502 | indexerScopedMutate( node->env , *this );
|
|---|
| 1503 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1504 | maybeMutate_impl ( node->arg1 , *this );
|
|---|
| 1505 | maybeMutate_impl ( node->arg2 , *this );
|
|---|
| 1506 | maybeMutate_impl ( node->arg3 , *this );
|
|---|
| [e0886db] | 1507 |
|
|---|
| 1508 | MUTATE_END( Expression, node );
|
|---|
| 1509 | }
|
|---|
| 1510 |
|
|---|
| 1511 | //--------------------------------------------------------------------------
|
|---|
| 1512 | // CommaExpr
|
|---|
| [13932f14] | 1513 | template< typename pass_type >
|
|---|
| [ab904dc] | 1514 | void PassVisitor< pass_type >::visit( CommaExpr * node ) {
|
|---|
| [e0886db] | 1515 | VISIT_START( node );
|
|---|
| 1516 |
|
|---|
| 1517 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1518 | maybeAccept_impl ( node->arg1 , *this );
|
|---|
| 1519 | maybeAccept_impl ( node->arg2 , *this );
|
|---|
| [e0886db] | 1520 |
|
|---|
| 1521 | VISIT_END( node );
|
|---|
| 1522 | }
|
|---|
| 1523 |
|
|---|
| 1524 | template< typename pass_type >
|
|---|
| 1525 | Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
|
|---|
| 1526 | MUTATE_START( node );
|
|---|
| 1527 |
|
|---|
| 1528 | indexerScopedMutate( node->env , *this );
|
|---|
| 1529 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1530 | maybeMutate_impl ( node->arg1 , *this );
|
|---|
| 1531 | maybeMutate_impl ( node->arg2 , *this );
|
|---|
| [e0886db] | 1532 |
|
|---|
| 1533 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1534 | }
|
|---|
| 1535 |
|
|---|
| [e0886db] | 1536 | //--------------------------------------------------------------------------
|
|---|
| 1537 | // TypeExpr
|
|---|
| [13932f14] | 1538 | template< typename pass_type >
|
|---|
| [ab904dc] | 1539 | void PassVisitor< pass_type >::visit( TypeExpr * node ) {
|
|---|
| [e0886db] | 1540 | VISIT_START( node );
|
|---|
| 1541 |
|
|---|
| 1542 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1543 | maybeAccept_impl ( node->type, *this );
|
|---|
| [e0886db] | 1544 |
|
|---|
| 1545 | VISIT_END( node );
|
|---|
| [13932f14] | 1546 | }
|
|---|
| 1547 |
|
|---|
| [e0886db] | 1548 | template< typename pass_type >
|
|---|
| 1549 | Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
|
|---|
| 1550 | MUTATE_START( node );
|
|---|
| 1551 |
|
|---|
| 1552 | indexerScopedMutate( node->env , *this );
|
|---|
| 1553 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1554 | maybeMutate_impl ( node->type , *this );
|
|---|
| [e0886db] | 1555 |
|
|---|
| 1556 | MUTATE_END( Expression, node );
|
|---|
| 1557 | }
|
|---|
| 1558 |
|
|---|
| 1559 | //--------------------------------------------------------------------------
|
|---|
| 1560 | // AsmExpr
|
|---|
| [13932f14] | 1561 | template< typename pass_type >
|
|---|
| [ab904dc] | 1562 | void PassVisitor< pass_type >::visit( AsmExpr * node ) {
|
|---|
| [e0886db] | 1563 | VISIT_START( node );
|
|---|
| 1564 |
|
|---|
| 1565 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1566 | maybeAccept_impl ( node->inout , *this );
|
|---|
| 1567 | maybeAccept_impl ( node->constraint, *this );
|
|---|
| 1568 | maybeAccept_impl ( node->operand , *this );
|
|---|
| [e0886db] | 1569 |
|
|---|
| 1570 | VISIT_END( node );
|
|---|
| [13932f14] | 1571 | }
|
|---|
| 1572 |
|
|---|
| [e0886db] | 1573 | template< typename pass_type >
|
|---|
| 1574 | Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
|
|---|
| 1575 | MUTATE_START( node );
|
|---|
| 1576 |
|
|---|
| 1577 | indexerScopedMutate( node->env , *this );
|
|---|
| 1578 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1579 | maybeMutate_impl ( node->inout , *this );
|
|---|
| 1580 | maybeMutate_impl ( node->constraint, *this );
|
|---|
| 1581 | maybeMutate_impl ( node->operand , *this );
|
|---|
| [e0886db] | 1582 |
|
|---|
| 1583 | MUTATE_END( Expression, node );
|
|---|
| 1584 | }
|
|---|
| 1585 |
|
|---|
| 1586 | //--------------------------------------------------------------------------
|
|---|
| 1587 | // ImplicitCopyCtorExpr
|
|---|
| [13932f14] | 1588 | template< typename pass_type >
|
|---|
| [ab904dc] | 1589 | void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
|
|---|
| [e0886db] | 1590 | VISIT_START( node );
|
|---|
| 1591 |
|
|---|
| 1592 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1593 | maybeAccept_impl ( node->callExpr , *this );
|
|---|
| 1594 | maybeAccept_impl ( node->tempDecls , *this );
|
|---|
| 1595 | maybeAccept_impl ( node->returnDecls, *this );
|
|---|
| 1596 | maybeAccept_impl ( node->dtors , *this );
|
|---|
| [e0886db] | 1597 |
|
|---|
| 1598 | VISIT_END( node );
|
|---|
| 1599 | }
|
|---|
| 1600 |
|
|---|
| 1601 | template< typename pass_type >
|
|---|
| 1602 | Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
|
|---|
| 1603 | MUTATE_START( node );
|
|---|
| 1604 |
|
|---|
| 1605 | indexerScopedMutate( node->env , *this );
|
|---|
| 1606 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1607 | maybeMutate_impl ( node->callExpr , *this );
|
|---|
| 1608 | maybeMutate_impl ( node->tempDecls , *this );
|
|---|
| 1609 | maybeMutate_impl ( node->returnDecls, *this );
|
|---|
| 1610 | maybeMutate_impl ( node->dtors , *this );
|
|---|
| [e0886db] | 1611 |
|
|---|
| 1612 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1613 | }
|
|---|
| 1614 |
|
|---|
| [e0886db] | 1615 | //--------------------------------------------------------------------------
|
|---|
| 1616 | // ConstructorExpr
|
|---|
| [13932f14] | 1617 | template< typename pass_type >
|
|---|
| [ab904dc] | 1618 | void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
|
|---|
| [e0886db] | 1619 | VISIT_START( node );
|
|---|
| 1620 |
|
|---|
| 1621 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1622 | maybeAccept_impl ( node->callExpr, *this );
|
|---|
| [e0886db] | 1623 |
|
|---|
| 1624 | VISIT_END( node );
|
|---|
| 1625 | }
|
|---|
| 1626 |
|
|---|
| 1627 | template< typename pass_type >
|
|---|
| 1628 | Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
|
|---|
| 1629 | MUTATE_START( node );
|
|---|
| 1630 |
|
|---|
| 1631 | indexerScopedMutate( node->env , *this );
|
|---|
| 1632 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1633 | maybeMutate_impl ( node->callExpr, *this );
|
|---|
| [e0886db] | 1634 |
|
|---|
| 1635 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1636 | }
|
|---|
| 1637 |
|
|---|
| [e0886db] | 1638 | //--------------------------------------------------------------------------
|
|---|
| 1639 | // CompoundLiteralExpr
|
|---|
| [13932f14] | 1640 | template< typename pass_type >
|
|---|
| [ab904dc] | 1641 | void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
|
|---|
| [e0886db] | 1642 | VISIT_START( node );
|
|---|
| 1643 |
|
|---|
| 1644 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1645 | maybeAccept_impl ( node->initializer, *this );
|
|---|
| [e0886db] | 1646 |
|
|---|
| 1647 | VISIT_END( node );
|
|---|
| [13932f14] | 1648 | }
|
|---|
| 1649 |
|
|---|
| [e0886db] | 1650 | template< typename pass_type >
|
|---|
| 1651 | Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
|
|---|
| 1652 | MUTATE_START( node );
|
|---|
| 1653 |
|
|---|
| 1654 | indexerScopedMutate( node->env , *this );
|
|---|
| 1655 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1656 | maybeMutate_impl ( node->initializer, *this );
|
|---|
| [e0886db] | 1657 |
|
|---|
| 1658 | MUTATE_END( Expression, node );
|
|---|
| 1659 | }
|
|---|
| 1660 |
|
|---|
| 1661 | //--------------------------------------------------------------------------
|
|---|
| 1662 | // RangeExpr
|
|---|
| [13932f14] | 1663 | template< typename pass_type >
|
|---|
| [ab904dc] | 1664 | void PassVisitor< pass_type >::visit( RangeExpr * node ) {
|
|---|
| [e0886db] | 1665 | VISIT_START( node );
|
|---|
| 1666 |
|
|---|
| 1667 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1668 | maybeAccept_impl ( node->low , *this );
|
|---|
| 1669 | maybeAccept_impl ( node->high , *this );
|
|---|
| [e0886db] | 1670 |
|
|---|
| 1671 | VISIT_END( node );
|
|---|
| [13932f14] | 1672 | }
|
|---|
| 1673 |
|
|---|
| [e0886db] | 1674 | template< typename pass_type >
|
|---|
| 1675 | Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
|
|---|
| 1676 | MUTATE_START( node );
|
|---|
| 1677 |
|
|---|
| 1678 | indexerScopedMutate( node->env , *this );
|
|---|
| 1679 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1680 | maybeMutate_impl ( node->low , *this );
|
|---|
| 1681 | maybeMutate_impl ( node->high , *this );
|
|---|
| [e0886db] | 1682 |
|
|---|
| 1683 | MUTATE_END( Expression, node );
|
|---|
| 1684 | }
|
|---|
| 1685 |
|
|---|
| 1686 | //--------------------------------------------------------------------------
|
|---|
| 1687 | // UntypedTupleExpr
|
|---|
| [13932f14] | 1688 | template< typename pass_type >
|
|---|
| [ab904dc] | 1689 | void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
|
|---|
| [e0886db] | 1690 | VISIT_START( node );
|
|---|
| 1691 |
|
|---|
| 1692 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1693 | maybeAccept_impl ( node->exprs , *this );
|
|---|
| [e0886db] | 1694 |
|
|---|
| 1695 | VISIT_END( node );
|
|---|
| 1696 | }
|
|---|
| 1697 |
|
|---|
| 1698 | template< typename pass_type >
|
|---|
| 1699 | Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
|
|---|
| 1700 | MUTATE_START( node );
|
|---|
| 1701 |
|
|---|
| 1702 | indexerScopedMutate( node->env , *this );
|
|---|
| 1703 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1704 | maybeMutate_impl ( node->exprs , *this );
|
|---|
| [e0886db] | 1705 |
|
|---|
| 1706 | MUTATE_END( Expression, node );
|
|---|
| 1707 | }
|
|---|
| 1708 |
|
|---|
| 1709 | //--------------------------------------------------------------------------
|
|---|
| 1710 | // TupleExpr
|
|---|
| 1711 | template< typename pass_type >
|
|---|
| 1712 | void PassVisitor< pass_type >::visit( TupleExpr * node ) {
|
|---|
| 1713 | VISIT_START( node );
|
|---|
| 1714 |
|
|---|
| 1715 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1716 | maybeAccept_impl ( node->exprs , *this );
|
|---|
| [e0886db] | 1717 |
|
|---|
| 1718 | VISIT_END( node );
|
|---|
| 1719 | }
|
|---|
| 1720 |
|
|---|
| 1721 | template< typename pass_type >
|
|---|
| 1722 | Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
|
|---|
| 1723 | MUTATE_START( node );
|
|---|
| 1724 |
|
|---|
| 1725 | indexerScopedMutate( node->env , *this );
|
|---|
| 1726 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1727 | maybeMutate_impl ( node->exprs , *this );
|
|---|
| [e0886db] | 1728 |
|
|---|
| 1729 | MUTATE_END( Expression, node );
|
|---|
| 1730 | }
|
|---|
| 1731 |
|
|---|
| 1732 | //--------------------------------------------------------------------------
|
|---|
| 1733 | // TupleIndexExpr
|
|---|
| 1734 | template< typename pass_type >
|
|---|
| 1735 | void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
|
|---|
| 1736 | VISIT_START( node );
|
|---|
| 1737 |
|
|---|
| 1738 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1739 | maybeAccept_impl ( node->tuple , *this );
|
|---|
| [e0886db] | 1740 |
|
|---|
| 1741 | VISIT_END( node );
|
|---|
| 1742 | }
|
|---|
| 1743 |
|
|---|
| 1744 | template< typename pass_type >
|
|---|
| 1745 | Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
|
|---|
| 1746 | MUTATE_START( node );
|
|---|
| 1747 |
|
|---|
| 1748 | indexerScopedMutate( node->env , *this );
|
|---|
| 1749 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1750 | maybeMutate_impl ( node->tuple , *this );
|
|---|
| [e0886db] | 1751 |
|
|---|
| 1752 | MUTATE_END( Expression, node );
|
|---|
| 1753 | }
|
|---|
| 1754 |
|
|---|
| 1755 | //--------------------------------------------------------------------------
|
|---|
| 1756 | // TupleAssignExpr
|
|---|
| 1757 | template< typename pass_type >
|
|---|
| 1758 | void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
|
|---|
| 1759 | VISIT_START( node );
|
|---|
| 1760 |
|
|---|
| 1761 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1762 | maybeAccept_impl ( node->stmtExpr, *this );
|
|---|
| [e0886db] | 1763 |
|
|---|
| 1764 | VISIT_END( node );
|
|---|
| [13932f14] | 1765 | }
|
|---|
| 1766 |
|
|---|
| 1767 | template< typename pass_type >
|
|---|
| [e0886db] | 1768 | Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
|
|---|
| 1769 | MUTATE_START( node );
|
|---|
| [13932f14] | 1770 |
|
|---|
| [e0886db] | 1771 | indexerScopedMutate( node->env , *this );
|
|---|
| 1772 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1773 | maybeMutate_impl ( node->stmtExpr, *this );
|
|---|
| [13932f14] | 1774 |
|
|---|
| [e0886db] | 1775 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1776 | }
|
|---|
| 1777 |
|
|---|
| [9c1600c] | 1778 | //--------------------------------------------------------------------------
|
|---|
| [e0886db] | 1779 | // StmtExpr
|
|---|
| [13932f14] | 1780 | template< typename pass_type >
|
|---|
| [ab904dc] | 1781 | void PassVisitor< pass_type >::visit( StmtExpr * node ) {
|
|---|
| [9c1600c] | 1782 | VISIT_START( node );
|
|---|
| 1783 |
|
|---|
| 1784 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
|---|
| 1785 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
|---|
| 1786 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
|---|
| 1787 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
|---|
| 1788 |
|
|---|
| [e0886db] | 1789 | indexerScopedAccept( node->result , *this );
|
|---|
| [3c398b6] | 1790 | maybeAccept_impl ( node->statements , *this );
|
|---|
| 1791 | maybeAccept_impl ( node->returnDecls, *this );
|
|---|
| 1792 | maybeAccept_impl ( node->dtors , *this );
|
|---|
| [9c1600c] | 1793 |
|
|---|
| 1794 | VISIT_END( node );
|
|---|
| [13932f14] | 1795 | }
|
|---|
| 1796 |
|
|---|
| [296b2be] | 1797 | template< typename pass_type >
|
|---|
| 1798 | Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
|
|---|
| 1799 | MUTATE_START( node );
|
|---|
| [4551a6e] | 1800 |
|
|---|
| [296b2be] | 1801 | // don't want statements from outer CompoundStmts to be added to this StmtExpr
|
|---|
| [134322e] | 1802 | ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );
|
|---|
| 1803 | ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
|
|---|
| 1804 | ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
|
|---|
| [296b2be] | 1805 |
|
|---|
| [e0886db] | 1806 | indexerScopedMutate( node->result , *this );
|
|---|
| [3c398b6] | 1807 | maybeMutate_impl ( node->statements , *this );
|
|---|
| 1808 | maybeMutate_impl ( node->returnDecls, *this );
|
|---|
| 1809 | maybeMutate_impl ( node->dtors , *this );
|
|---|
| [296b2be] | 1810 |
|
|---|
| 1811 | MUTATE_END( Expression, node );
|
|---|
| 1812 | }
|
|---|
| 1813 |
|
|---|
| [e0886db] | 1814 | //--------------------------------------------------------------------------
|
|---|
| 1815 | // UniqueExpr
|
|---|
| [13932f14] | 1816 | template< typename pass_type >
|
|---|
| [ab904dc] | 1817 | void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
|
|---|
| [e0886db] | 1818 | VISIT_START( node );
|
|---|
| 1819 |
|
|---|
| 1820 | indexerScopedAccept( node->result, *this );
|
|---|
| [3c398b6] | 1821 | maybeAccept_impl ( node->expr , *this );
|
|---|
| [e0886db] | 1822 |
|
|---|
| 1823 | VISIT_END( node );
|
|---|
| 1824 | }
|
|---|
| 1825 |
|
|---|
| 1826 | template< typename pass_type >
|
|---|
| 1827 | Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
|
|---|
| 1828 | MUTATE_START( node );
|
|---|
| 1829 |
|
|---|
| 1830 | indexerScopedMutate( node->env , *this );
|
|---|
| 1831 | indexerScopedMutate( node->result, *this );
|
|---|
| [3c398b6] | 1832 | maybeMutate_impl ( node->expr , *this );
|
|---|
| [e0886db] | 1833 |
|
|---|
| 1834 | MUTATE_END( Expression, node );
|
|---|
| [13932f14] | 1835 | }
|
|---|
| 1836 |
|
|---|
| 1837 | template< typename pass_type >
|
|---|
| [ab904dc] | 1838 | void PassVisitor< pass_type >::visit( VoidType * node ) {
|
|---|
| [4551a6e] | 1839 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1840 | }
|
|---|
| 1841 |
|
|---|
| 1842 | template< typename pass_type >
|
|---|
| [ab904dc] | 1843 | void PassVisitor< pass_type >::visit( BasicType * node ) {
|
|---|
| [4551a6e] | 1844 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1845 | }
|
|---|
| 1846 |
|
|---|
| 1847 | template< typename pass_type >
|
|---|
| [ab904dc] | 1848 | void PassVisitor< pass_type >::visit( PointerType * node ) {
|
|---|
| [4551a6e] | 1849 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1850 | }
|
|---|
| 1851 |
|
|---|
| 1852 | template< typename pass_type >
|
|---|
| [ab904dc] | 1853 | void PassVisitor< pass_type >::visit( ArrayType * node ) {
|
|---|
| [4551a6e] | 1854 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1855 | }
|
|---|
| 1856 |
|
|---|
| [6b9b047] | 1857 | template< typename pass_type >
|
|---|
| 1858 | void PassVisitor< pass_type >::visit( ReferenceType * node ) {
|
|---|
| 1859 | VISIT_BODY( node );
|
|---|
| 1860 | }
|
|---|
| 1861 |
|
|---|
| [13932f14] | 1862 | template< typename pass_type >
|
|---|
| [ab904dc] | 1863 | void PassVisitor< pass_type >::visit( FunctionType * node ) {
|
|---|
| [4551a6e] | 1864 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1865 | }
|
|---|
| 1866 |
|
|---|
| [e0886db] | 1867 | //--------------------------------------------------------------------------
|
|---|
| 1868 | // StructInstType
|
|---|
| [13932f14] | 1869 | template< typename pass_type >
|
|---|
| [ab904dc] | 1870 | void PassVisitor< pass_type >::visit( StructInstType * node ) {
|
|---|
| [e0886db] | 1871 | VISIT_START( node );
|
|---|
| 1872 |
|
|---|
| 1873 | indexerAddStruct( node->name );
|
|---|
| 1874 |
|
|---|
| 1875 | {
|
|---|
| 1876 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 1877 | maybeAccept_impl( node->forall , *this );
|
|---|
| 1878 | maybeAccept_impl( node->parameters, *this );
|
|---|
| [e0886db] | 1879 | }
|
|---|
| 1880 |
|
|---|
| 1881 | VISIT_END( node );
|
|---|
| 1882 | }
|
|---|
| 1883 |
|
|---|
| 1884 | template< typename pass_type >
|
|---|
| 1885 | Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
|
|---|
| 1886 | MUTATE_START( node );
|
|---|
| 1887 |
|
|---|
| 1888 | indexerAddStruct( node->name );
|
|---|
| 1889 |
|
|---|
| 1890 | {
|
|---|
| 1891 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 1892 | maybeMutate_impl( node->forall , *this );
|
|---|
| 1893 | maybeMutate_impl( node->parameters, *this );
|
|---|
| [e0886db] | 1894 | }
|
|---|
| 1895 |
|
|---|
| 1896 | MUTATE_END( Type, node );
|
|---|
| [13932f14] | 1897 | }
|
|---|
| 1898 |
|
|---|
| [e0886db] | 1899 | //--------------------------------------------------------------------------
|
|---|
| 1900 | // UnionInstType
|
|---|
| [13932f14] | 1901 | template< typename pass_type >
|
|---|
| [ab904dc] | 1902 | void PassVisitor< pass_type >::visit( UnionInstType * node ) {
|
|---|
| [e0886db] | 1903 | VISIT_START( node );
|
|---|
| 1904 |
|
|---|
| 1905 | indexerAddStruct( node->name );
|
|---|
| 1906 |
|
|---|
| 1907 | {
|
|---|
| 1908 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 1909 | maybeAccept_impl( node->forall , *this );
|
|---|
| 1910 | maybeAccept_impl( node->parameters, *this );
|
|---|
| [e0886db] | 1911 | }
|
|---|
| 1912 |
|
|---|
| 1913 | VISIT_END( node );
|
|---|
| 1914 | }
|
|---|
| 1915 |
|
|---|
| 1916 | template< typename pass_type >
|
|---|
| 1917 | Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
|
|---|
| 1918 | MUTATE_START( node );
|
|---|
| 1919 |
|
|---|
| 1920 | indexerAddStruct( node->name );
|
|---|
| 1921 |
|
|---|
| 1922 | {
|
|---|
| 1923 | auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
|
|---|
| [3c398b6] | 1924 | maybeMutate_impl( node->forall , *this );
|
|---|
| 1925 | maybeMutate_impl( node->parameters, *this );
|
|---|
| [e0886db] | 1926 | }
|
|---|
| 1927 |
|
|---|
| 1928 | MUTATE_END( Type, node );
|
|---|
| [13932f14] | 1929 | }
|
|---|
| 1930 |
|
|---|
| [e0886db] | 1931 | //--------------------------------------------------------------------------
|
|---|
| 1932 | // EnumInstType
|
|---|
| [13932f14] | 1933 | template< typename pass_type >
|
|---|
| [ab904dc] | 1934 | void PassVisitor< pass_type >::visit( EnumInstType * node ) {
|
|---|
| [4551a6e] | 1935 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1936 | }
|
|---|
| 1937 |
|
|---|
| [e0886db] | 1938 | template< typename pass_type >
|
|---|
| 1939 | Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
|
|---|
| 1940 | MUTATE_BODY( Type, node );
|
|---|
| 1941 | }
|
|---|
| 1942 |
|
|---|
| 1943 | //--------------------------------------------------------------------------
|
|---|
| 1944 | // TraitInstType
|
|---|
| [13932f14] | 1945 | template< typename pass_type >
|
|---|
| [ab904dc] | 1946 | void PassVisitor< pass_type >::visit( TraitInstType * node ) {
|
|---|
| [e0886db] | 1947 | VISIT_START( node );
|
|---|
| 1948 |
|
|---|
| [3c398b6] | 1949 | maybeAccept_impl( node->forall , *this );
|
|---|
| 1950 | maybeAccept_impl( node->parameters, *this );
|
|---|
| [e0886db] | 1951 |
|
|---|
| 1952 | VISIT_END( node );
|
|---|
| 1953 | }
|
|---|
| 1954 |
|
|---|
| 1955 | template< typename pass_type >
|
|---|
| 1956 | Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
|
|---|
| 1957 | MUTATE_START( node );
|
|---|
| 1958 |
|
|---|
| [3c398b6] | 1959 | maybeMutate_impl( node->forall , *this );
|
|---|
| 1960 | maybeMutate_impl( node->parameters, *this );
|
|---|
| [e0886db] | 1961 |
|
|---|
| 1962 | MUTATE_END( Type, node );
|
|---|
| [13932f14] | 1963 | }
|
|---|
| 1964 |
|
|---|
| [e0886db] | 1965 | //--------------------------------------------------------------------------
|
|---|
| 1966 | // TypeInstType
|
|---|
| [13932f14] | 1967 | template< typename pass_type >
|
|---|
| [ab904dc] | 1968 | void PassVisitor< pass_type >::visit( TypeInstType * node ) {
|
|---|
| [4551a6e] | 1969 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1970 | }
|
|---|
| 1971 |
|
|---|
| 1972 | template< typename pass_type >
|
|---|
| [ab904dc] | 1973 | void PassVisitor< pass_type >::visit( TupleType * node ) {
|
|---|
| [4551a6e] | 1974 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1975 | }
|
|---|
| 1976 |
|
|---|
| 1977 | template< typename pass_type >
|
|---|
| [ab904dc] | 1978 | void PassVisitor< pass_type >::visit( TypeofType * node ) {
|
|---|
| [4551a6e] | 1979 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1980 | }
|
|---|
| 1981 |
|
|---|
| 1982 | template< typename pass_type >
|
|---|
| [ab904dc] | 1983 | void PassVisitor< pass_type >::visit( AttrType * node ) {
|
|---|
| [4551a6e] | 1984 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1985 | }
|
|---|
| 1986 |
|
|---|
| 1987 | template< typename pass_type >
|
|---|
| [ab904dc] | 1988 | void PassVisitor< pass_type >::visit( VarArgsType * node ) {
|
|---|
| [4551a6e] | 1989 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1990 | }
|
|---|
| 1991 |
|
|---|
| 1992 | template< typename pass_type >
|
|---|
| [ab904dc] | 1993 | void PassVisitor< pass_type >::visit( ZeroType * node ) {
|
|---|
| [4551a6e] | 1994 | VISIT_BODY( node );
|
|---|
| [13932f14] | 1995 | }
|
|---|
| 1996 |
|
|---|
| 1997 | template< typename pass_type >
|
|---|
| [ab904dc] | 1998 | void PassVisitor< pass_type >::visit( OneType * node ) {
|
|---|
| [4551a6e] | 1999 | VISIT_BODY( node );
|
|---|
| [13932f14] | 2000 | }
|
|---|
| 2001 |
|
|---|
| [b11d8e2] | 2002 | template< typename pass_type >
|
|---|
| 2003 | void PassVisitor< pass_type >::visit( Designation * node ) {
|
|---|
| 2004 | VISIT_START( node );
|
|---|
| 2005 |
|
|---|
| [3c398b6] | 2006 | maybeAccept_impl( node->get_designators(), *this );
|
|---|
| [b11d8e2] | 2007 |
|
|---|
| 2008 | VISIT_END( node );
|
|---|
| 2009 | }
|
|---|
| 2010 |
|
|---|
| 2011 | template< typename pass_type >
|
|---|
| 2012 | Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
|
|---|
| 2013 | MUTATE_START( node );
|
|---|
| 2014 |
|
|---|
| [3c398b6] | 2015 | maybeMutate_impl( node->get_designators(), *this );
|
|---|
| [b11d8e2] | 2016 |
|
|---|
| 2017 | MUTATE_END( Designation, node );
|
|---|
| 2018 | }
|
|---|
| 2019 |
|
|---|
| [9c1600c] | 2020 | //--------------------------------------------------------------------------
|
|---|
| [e0886db] | 2021 | // SingleInit
|
|---|
| [13932f14] | 2022 | template< typename pass_type >
|
|---|
| [ab904dc] | 2023 | void PassVisitor< pass_type >::visit( SingleInit * node ) {
|
|---|
| [9c1600c] | 2024 | VISIT_START( node );
|
|---|
| 2025 |
|
|---|
| 2026 | visitExpression( node->get_value() );
|
|---|
| 2027 |
|
|---|
| 2028 | VISIT_END( node );
|
|---|
| [13932f14] | 2029 | }
|
|---|
| 2030 |
|
|---|
| [296b2be] | 2031 | template< typename pass_type >
|
|---|
| 2032 | Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
|
|---|
| 2033 | MUTATE_START( node );
|
|---|
| 2034 |
|
|---|
| 2035 | node->set_value( mutateExpression( node->get_value() ) );
|
|---|
| 2036 |
|
|---|
| 2037 | MUTATE_END( Initializer, node );
|
|---|
| 2038 | }
|
|---|
| 2039 |
|
|---|
| [13932f14] | 2040 | template< typename pass_type >
|
|---|
| [ab904dc] | 2041 | void PassVisitor< pass_type >::visit( ListInit * node ) {
|
|---|
| [4551a6e] | 2042 | VISIT_BODY( node );
|
|---|
| [13932f14] | 2043 | }
|
|---|
| 2044 |
|
|---|
| 2045 | template< typename pass_type >
|
|---|
| [ab904dc] | 2046 | void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
|
|---|
| [4551a6e] | 2047 | VISIT_BODY( node );
|
|---|
| [13932f14] | 2048 | }
|
|---|
| 2049 |
|
|---|
| 2050 | template< typename pass_type >
|
|---|
| [ab904dc] | 2051 | void PassVisitor< pass_type >::visit( Subrange * node ) {
|
|---|
| [4551a6e] | 2052 | VISIT_BODY( node );
|
|---|
| [13932f14] | 2053 | }
|
|---|
| 2054 |
|
|---|
| 2055 | template< typename pass_type >
|
|---|
| [ab904dc] | 2056 | void PassVisitor< pass_type >::visit( Constant * node ) {
|
|---|
| [4551a6e] | 2057 | VISIT_BODY( node );
|
|---|
| [13932f14] | 2058 | }
|
|---|
| [ab904dc] | 2059 |
|
|---|
| [5ea7a22] | 2060 | template< typename pass_type >
|
|---|
| 2061 | void PassVisitor< pass_type >::visit( Attribute * node ) {
|
|---|
| 2062 | VISIT_BODY( node );
|
|---|
| 2063 | }
|
|---|
| 2064 |
|
|---|
| [ab904dc] | 2065 | //---------------------------------------------------------------------------------------------------------------
|
|---|
| 2066 | template< typename pass_type >
|
|---|
| 2067 | Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
|
|---|
| 2068 | MUTATE_BODY( Type, node );
|
|---|
| 2069 | }
|
|---|
| 2070 |
|
|---|
| 2071 | template< typename pass_type >
|
|---|
| 2072 | Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
|
|---|
| 2073 | MUTATE_BODY( Type, node );
|
|---|
| 2074 | }
|
|---|
| 2075 |
|
|---|
| 2076 | template< typename pass_type >
|
|---|
| 2077 | Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
|
|---|
| 2078 | MUTATE_BODY( Type, node );
|
|---|
| 2079 | }
|
|---|
| 2080 |
|
|---|
| 2081 | template< typename pass_type >
|
|---|
| 2082 | Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
|
|---|
| 2083 | MUTATE_BODY( Type, node );
|
|---|
| 2084 | }
|
|---|
| 2085 |
|
|---|
| 2086 | template< typename pass_type >
|
|---|
| [6b9b047] | 2087 | Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
|
|---|
| 2088 | MUTATE_BODY( Type, node );
|
|---|
| 2089 | }
|
|---|
| 2090 |
|
|---|
| 2091 | template< typename pass_type >
|
|---|
| [ab904dc] | 2092 | Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
|
|---|
| 2093 | MUTATE_BODY( Type, node );
|
|---|
| 2094 | }
|
|---|
| 2095 |
|
|---|
| 2096 | template< typename pass_type >
|
|---|
| 2097 | Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
|
|---|
| 2098 | MUTATE_BODY( Type, node );
|
|---|
| 2099 | }
|
|---|
| 2100 |
|
|---|
| 2101 | template< typename pass_type >
|
|---|
| 2102 | Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
|
|---|
| 2103 | MUTATE_BODY( Type, node );
|
|---|
| 2104 | }
|
|---|
| 2105 |
|
|---|
| 2106 | template< typename pass_type >
|
|---|
| 2107 | Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
|
|---|
| 2108 | MUTATE_BODY( Type, node );
|
|---|
| 2109 | }
|
|---|
| 2110 |
|
|---|
| 2111 | template< typename pass_type >
|
|---|
| 2112 | Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
|
|---|
| 2113 | MUTATE_BODY( Type, node );
|
|---|
| 2114 | }
|
|---|
| 2115 |
|
|---|
| 2116 | template< typename pass_type >
|
|---|
| 2117 | Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
|
|---|
| 2118 | MUTATE_BODY( Type, node );
|
|---|
| 2119 | }
|
|---|
| 2120 |
|
|---|
| 2121 | template< typename pass_type >
|
|---|
| 2122 | Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
|
|---|
| 2123 | MUTATE_BODY( Type, node );
|
|---|
| 2124 | }
|
|---|
| 2125 |
|
|---|
| 2126 | template< typename pass_type >
|
|---|
| 2127 | Type * PassVisitor< pass_type >::mutate( OneType * node ) {
|
|---|
| 2128 | MUTATE_BODY( Type, node );
|
|---|
| 2129 | }
|
|---|
| 2130 |
|
|---|
| 2131 | template< typename pass_type >
|
|---|
| 2132 | Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
|
|---|
| 2133 | MUTATE_BODY( Initializer, node );
|
|---|
| 2134 | }
|
|---|
| 2135 |
|
|---|
| 2136 | template< typename pass_type >
|
|---|
| 2137 | Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
|
|---|
| 2138 | MUTATE_BODY( Initializer, node );
|
|---|
| 2139 | }
|
|---|
| 2140 |
|
|---|
| 2141 | template< typename pass_type >
|
|---|
| 2142 | Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) {
|
|---|
| 2143 | MUTATE_BODY( Subrange, node );
|
|---|
| 2144 | }
|
|---|
| 2145 |
|
|---|
| 2146 | template< typename pass_type >
|
|---|
| 2147 | Constant * PassVisitor< pass_type >::mutate( Constant * node ) {
|
|---|
| 2148 | MUTATE_BODY( Constant, node );
|
|---|
| [4551a6e] | 2149 | }
|
|---|
| [5ea7a22] | 2150 |
|
|---|
| 2151 | template< typename pass_type >
|
|---|
| 2152 | Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) {
|
|---|
| 2153 | MUTATE_BODY( Attribute, node );
|
|---|
| 2154 | }
|
|---|
| [447c356] | 2155 |
|
|---|
| 2156 | template< typename pass_type >
|
|---|
| 2157 | TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
|
|---|
| 2158 | MUTATE_START( node );
|
|---|
| 2159 |
|
|---|
| 2160 | for ( auto & p : node->typeEnv ) {
|
|---|
| 2161 | indexerScopedMutate( p.second, *this );
|
|---|
| 2162 | }
|
|---|
| 2163 | for ( auto & p : node->varEnv ) {
|
|---|
| 2164 | indexerScopedMutate( p.second, *this );
|
|---|
| 2165 | }
|
|---|
| 2166 |
|
|---|
| 2167 | MUTATE_END( TypeSubstitution, node );
|
|---|
| 2168 | }
|
|---|