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