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