Changes in / [d43cd01:1c273d0]
- Files:
-
- 2 deleted
- 13 edited
-
doc/working/exception/translate.c (modified) (7 diffs)
-
src/Common/PassVisitor.h (modified) (8 diffs)
-
src/Common/PassVisitor.impl.h (modified) (15 diffs)
-
src/Common/PassVisitor.proto.h (modified) (3 diffs)
-
src/ControlStruct/ExceptTranslate.cc (deleted)
-
src/ControlStruct/ExceptTranslate.h (deleted)
-
src/GenPoly/DeclMutator.cc (modified) (2 diffs)
-
src/GenPoly/PolyMutator.cc (modified) (2 diffs)
-
src/GenPoly/Specialize.cc (modified) (1 diff)
-
src/InitTweak/InitTweak.cc (modified) (1 diff)
-
src/Parser/StatementNode.cc (modified) (1 diff)
-
src/SynTree/Constant.cc (modified) (2 diffs)
-
src/SynTree/Constant.h (modified) (2 diffs)
-
src/SynTree/Mutator.cc (modified) (3 diffs)
-
src/SynTree/Visitor.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/working/exception/translate.c
rd43cd01 r1c273d0 1 1 /* Translation rules for exception handling code, from Cforall to C. 2 2 * 3 * Reminder: This is not final. Besides names and things it is also going very 4 * much for correctness and simplisity over efficiency. 5 * 6 * The first section is the shared definitions, not generated by the local 7 * translations but used by the translated code. 3 * Note that these are not final. Names, syntax and the exact translation 4 * will be updated. The first section is the shared definitions, not generated 5 * by the local translations but used by the translated code. 8 6 * 9 7 * Most of these exist only after translation (in C code). The first (the … … 17 15 // Currently it is a typedef for int, but later it will be a new type. 18 16 typedef int exception; 19 20 // Will have to be availibe to user. Consider new name. Requires tagged types.21 forall(dtype parent | tagged(parent), dtype child | tagged(child))22 parent *dynamic_cast(child *);23 17 24 18 void __throw_terminate(exception except) __attribute__((noreturn)); … … 122 116 } 123 117 int match1(exception except) { 124 { 125 if (dynamic_cast__SomeException(except)) { 126 return 1; 127 } 128 } 129 { 130 OtherException err; 131 if ( (err = dynamic_cast__OtherException(except)) && 132 err.priority > 3) { 133 return 2; 134 } 135 } 136 return 0; 118 OtherException inner_except; 119 if (dynamic_cast__SomeException(except)) { 120 return 1; 121 } 122 else if ( (inner_except = dynamic_cast__OtherException(except)) && 123 inner_except.priority > 3) { 124 return 2; 125 } 126 else return 0; 137 127 } 138 128 __try_terminate(try1, catch1, match1); … … 161 151 { 162 152 bool handle1(exception except) { 163 { 164 if (dynamic_cast__SomeException(except)) { 165 fiddleThing(); 166 return true; 167 } 168 } 169 { 170 OtherException err; 171 if ( ( err = dynamic_cast__OtherException(except) ) && 172 err.priority > 3) { 173 twiddleWidget(); 174 return true; 175 } 176 } 177 return false; 153 OtherException inner_except; 154 if (dynamic_cast__SomeException(except)) { 155 fiddleThing(); 156 return true; 157 } else if (dynamic_cast__OtherException(except) && 158 inner_except.priority > 3) { 159 twiddleWidget(); 160 return true; 161 } else { 162 return false; 163 } 178 164 } 179 165 struct __try_resume_node data = … … 244 230 } 245 231 bool handle1(exception except) { 246 { 247 if (dynamic_cast__SomeException(except)) { 248 fiddleThing(); 249 return true; 250 } 251 } 252 return false; 232 if (dynamic_cast__SomeException(except)) { 233 fiddleThing(); 234 return true; 235 } else { 236 return false; 237 } 253 238 } 254 239 struct __cleanup_hook generated_name … … 288 273 { 289 274 bool handle1() { 290 { 291 if (dynamic_cast__OtherException(except)) { 292 twiddleWidget(); 293 return true; 294 } 275 if (dynamic_cast__OtherException(except)) { 276 twiddleWidget(); 277 return true; 295 278 } 296 279 return false; … … 314 297 } 315 298 int match1(exception except) { 316 { 317 if (dynamic_cast__SomeException(except)) { 318 return 1; 319 } 299 if (dynamic_cast__SomeException(except)) { 300 return 1; 320 301 } 321 302 return 0; -
src/Common/PassVisitor.h
rd43cd01 r1c273d0 25 25 // | WithStmtsToAdd - provides the ability to insert statements before or after the current statement by adding new statements into 26 26 // stmtsToAddBefore or stmtsToAddAfter respectively. 27 // | WithShortCircuiting - provides the ability to skip visiting child nodes; set visit_children to false inpre{visit,mutate} to skip visiting children27 // | WithShortCircuiting - provides the ability to skip visiting child nodes; set skip_children to true if pre{visit,mutate} to skip visiting children 28 28 // | WithScopes - provides the ability to save/restore data like a LIFO stack; to save, call GuardValue with the variable to save, the variable 29 29 // will automatically be restored to its previous value after the corresponding postvisit/postmutate teminates. … … 37 37 PassVisitor(Args &&... args) 38 38 : pass( std::forward<Args>( args )... ) 39 { 40 typedef PassVisitor<pass_type> this_t; 41 this_t * const * visitor = visitor_impl(pass, 0); 42 if(visitor) { 43 *const_cast<this_t **>( visitor ) = this; 44 } 45 } 39 {} 46 40 47 41 virtual ~PassVisitor() = default; … … 220 214 221 215 private: 222 template<typename pass_t> friend void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );223 template<typename pass_t> friend void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );224 225 216 template<typename node_type> void call_previsit ( node_type * node ) { previsit_impl ( pass, node, 0 ); } 226 217 template<typename node_type> void call_postvisit( node_type * node ) { postvisit_impl( pass, node, 0 ); } … … 234 225 void set_env( TypeSubstitution * env ) { set_env_impl( pass, env, 0); } 235 226 236 template< typename func_t > 237 void handleStatementList( std::list< Statement * > & statements, func_t func ); 238 void visitStatementList ( std::list< Statement* > &statements ); 227 void visitStatementList( std::list< Statement* > &statements ); 239 228 void mutateStatementList( std::list< Statement* > &statements ); 240 229 241 template< typename func_t > 242 Statement * handleStatement( Statement * stmt, func_t func ); 243 Statement * visitStatement ( Statement * stmt ); 230 Statement * visitStatement( Statement * stmt ); 244 231 Statement * mutateStatement( Statement * stmt ); 245 232 246 template< typename func_t > 247 Expression * handleExpression( Expression * expr, func_t func ); 248 Expression * visitExpression ( Expression * expr ); 233 void visitExpression( Expression * expr ); 249 234 Expression * mutateExpression( Expression * expr ); 250 235 … … 253 238 std::list< Statement* > * get_beforeStmts() { return stmtsToAddBefore_impl( pass, 0); } 254 239 std::list< Statement* > * get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); } 255 std::list< Declaration* > * get_beforeDecls() { return declsToAddBefore_impl( pass, 0); } 256 std::list< Declaration* > * get_afterDecls () { return declsToAddAfter_impl ( pass, 0); } 257 258 void set_visit_children( bool& ref ) { bool_ref * ptr = visit_children_impl(pass, 0); if(ptr) ptr->set( ref ); } 240 bool visit_children() { bool* skip = skip_children_impl(pass, 0); return ! (skip && *skip); } 241 void reset_visit() { bool* skip = skip_children_impl(pass, 0); if(skip) *skip = false; } 259 242 260 243 guard_value_impl init_guard() { … … 295 278 std::list< Statement* > stmtsToAddAfter; 296 279 }; 280 297 281 class WithShortCircuiting { 298 282 protected: … … 301 285 302 286 public: 303 bool _ref visit_children;287 bool skip_children; 304 288 }; 305 289 … … 320 304 }; 321 305 322 template<typename pass_type>323 class WithVisitorRef {324 protected:325 WithVisitorRef() = default;326 ~WithVisitorRef() = default;327 328 public:329 PassVisitor<pass_type> * const visitor;330 };331 306 332 307 #include "PassVisitor.impl.h" -
src/Common/PassVisitor.impl.h
rd43cd01 r1c273d0 4 4 __attribute__((unused)) \ 5 5 const auto & guard = init_guard(); \ 6 bool visit_children = true; \7 set_visit_children( visit_children ); \8 6 call_previsit( node ); \ 9 if( visit_children ) {\7 if( visit_children() ) { \ 10 8 11 9 #define VISIT_END( node ) \ 12 10 } \ 11 reset_visit(); \ 13 12 call_postvisit( node ); \ 14 13 … … 16 15 __attribute__((unused)) \ 17 16 const auto & guard = init_guard(); \ 18 bool visit_children = true; \19 set_visit_children( visit_children ); \20 17 call_premutate( node ); \ 21 if( visit_children ) {\18 if( visit_children() ) { \ 22 19 23 20 #define MUTATE_END( type, node ) \ 24 21 } \ 22 reset_visit(); \ 25 23 return call_postmutate< type * >( node ); \ 26 24 … … 44 42 } 45 43 46 typedef std::list< Statement * > StmtList_t; 47 typedef std::list< Declaration * > DeclList_t; 48 49 template<typename iterator_t> 50 static inline void splice( iterator_t it, DeclList_t * decls ) { 51 std::transform( 52 decls->begin(), 53 decls->end(), 54 it, 55 [](Declaration * decl) -> auto { 56 return new DeclStmt( noLabels, decl ); 57 } 58 ); 59 decls->clear(); 60 } 61 62 template< typename pass_type > 63 static inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) { 64 65 DeclList_t* beforeDecls = visitor.get_beforeDecls(); 66 DeclList_t* afterDecls = visitor.get_afterDecls(); 67 68 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 69 // splice in new declarations after previous decl 70 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } 71 72 if ( i == decls.end() ) break; 73 74 // run mutator on declaration 75 maybeAccept( *i, visitor ); 76 77 // splice in new declarations before current decl 78 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 79 } 80 } 81 82 template< typename pass_type > 83 static inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) { 84 85 DeclList_t* beforeDecls = mutator.get_beforeDecls(); 86 DeclList_t* afterDecls = mutator.get_afterDecls(); 87 88 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 89 // splice in new declarations after previous decl 90 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } 91 92 if ( i == decls.end() ) break; 93 94 // run mutator on declaration 95 *i = maybeMutate( *i, mutator ); 96 97 // splice in new declarations before current decl 98 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 99 } 100 } 101 102 template< typename pass_type > 103 template< typename func_t > 104 void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) { 44 typedef std::list< Statement * > StmtList_t; 45 46 template< typename pass_type > 47 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) { 105 48 SemanticError errors; 106 49 107 50 StmtList_t* beforeStmts = get_beforeStmts(); 108 51 StmtList_t* afterStmts = get_afterStmts(); 109 DeclList_t* beforeDecls = get_beforeDecls();110 DeclList_t* afterDecls = get_afterDecls();111 52 112 53 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 113 114 if ( !empty( afterDecls ) ) { splice( std::inserter( statements, i ), afterDecls ); }115 54 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } 116 117 55 try { 118 func( *i ); 119 assert(( empty( beforeStmts ) && empty( afterStmts )) 120 || ( empty( beforeDecls ) && empty( afterDecls )) ); 121 56 (*i)->accept( *this ); 122 57 } catch ( SemanticError &e ) { 123 58 errors.append( e ); 124 59 } 125 126 if ( !empty( beforeDecls ) ) { splice( std::inserter( statements, i ), beforeDecls ); }127 60 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 128 61 } 129 62 130 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }131 63 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } 132 64 if ( !errors.isEmpty() ) { throw errors; } … … 134 66 135 67 template< typename pass_type > 136 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {137 handleStatementList( statements, [this]( Statement * stmt) {138 stmt->accept( *this );139 });140 }141 142 template< typename pass_type >143 68 void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) { 144 handleStatementList( statements, [this]( Statement *& stmt) { 145 stmt = stmt->acceptMutator( *this ); 146 }); 147 } 148 149 150 template< typename pass_type > 151 template< typename func_t > 152 Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) { 153 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 154 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () ); 155 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 156 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); 157 ValueGuardPtr< StmtList_t > oldBeforeStmts( get_beforeStmts() ); 158 ValueGuardPtr< StmtList_t > oldAfterStmts ( get_afterStmts () ); 159 160 Statement *newStmt = func( stmt ); 69 SemanticError errors; 161 70 162 71 StmtList_t* beforeStmts = get_beforeStmts(); 163 72 StmtList_t* afterStmts = get_afterStmts(); 164 DeclList_t* beforeDecls = get_beforeDecls(); 165 DeclList_t* afterDecls = get_afterDecls(); 166 167 if( empty(beforeStmts) && empty(afterStmts) && empty(beforeDecls) && empty(afterDecls) ) { return newStmt; } 168 assert(( empty( beforeStmts ) && empty( afterStmts )) 169 || ( empty( beforeDecls ) && empty( afterDecls )) ); 73 74 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 75 if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); } 76 try { 77 *i = (*i)->acceptMutator( *this ); 78 } catch ( SemanticError &e ) { 79 errors.append( e ); 80 } 81 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 82 } 83 84 if ( !empty( afterStmts ) ) { statements.splice( statements.end(), *afterStmts ); } 85 if ( !errors.isEmpty() ) { throw errors; } 86 } 87 88 template< typename pass_type > 89 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { 90 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 91 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 92 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 93 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 94 95 maybeAccept( stmt, *this ); 96 97 StmtList_t* beforeStmts = get_beforeStmts(); 98 StmtList_t* afterStmts = get_afterStmts(); 99 100 if( empty(beforeStmts) && empty(afterStmts) ) { return stmt; } 170 101 171 102 CompoundStmt *compound = new CompoundStmt( noLabels ); 172 if( !empty(beforeDecls) ) { splice( std::back_inserter( compound->get_kids() ), beforeDecls ); } 103 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } 104 compound->get_kids().push_back( stmt ); 105 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } 106 return compound; 107 } 108 109 template< typename pass_type > 110 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { 111 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 112 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 113 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 114 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 115 116 Statement *newStmt = maybeMutate( stmt, *this ); 117 118 StmtList_t* beforeStmts = get_beforeStmts(); 119 StmtList_t* afterStmts = get_afterStmts(); 120 121 if( empty(beforeStmts) && empty(afterStmts) ) { return newStmt; } 122 123 CompoundStmt *compound = new CompoundStmt( noLabels ); 173 124 if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); } 174 125 compound->get_kids().push_back( newStmt ); 175 if( !empty(afterDecls) ) { splice( std::back_inserter( compound->get_kids() ), afterDecls ); }176 126 if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); } 177 127 return compound; 178 128 } 179 129 180 template< typename pass_type > 181 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { 182 return handleStatement( stmt, [this]( Statement * stmt ) { 183 maybeAccept( stmt, *this ); 184 return stmt; 185 }); 186 } 187 188 template< typename pass_type > 189 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { 190 return handleStatement( stmt, [this]( Statement * stmt ) { 191 return maybeMutate( stmt, *this ); 192 }); 193 } 194 195 template< typename pass_type > 196 template< typename func_t > 197 Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) { 198 if( !expr ) return nullptr; 130 131 132 template< typename pass_type > 133 void PassVisitor< pass_type >::visitExpression( Expression * expr ) { 134 if( !expr ) return; 199 135 200 136 auto env_ptr = get_env_ptr(); … … 202 138 *env_ptr = expr->get_env(); 203 139 } 204 205 // should env be cloned (or moved) onto the result of the mutate? 206 return func( expr ); 207 } 208 209 template< typename pass_type > 210 Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) { 211 return handleExpression(expr, [this]( Expression * expr ) { 212 expr->accept( *this ); 213 return expr; 214 }); 140 // xxx - should env be cloned (or moved) onto the result of the mutate? 141 expr->accept( *this ); 215 142 } 216 143 217 144 template< typename pass_type > 218 145 Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) { 219 return handleExpression(expr, [this]( Expression * expr ) { 220 return expr->acceptMutator( *this ); 221 }); 222 } 146 if( !expr ) return nullptr; 147 148 auto env_ptr = get_env_ptr(); 149 if ( env_ptr && expr->get_env() ) { 150 *env_ptr = expr->get_env(); 151 } 152 // xxx - should env be cloned (or moved) onto the result of the mutate? 153 return expr->acceptMutator( *this ); 154 } 155 223 156 224 157 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ … … 298 231 void PassVisitor< pass_type >::visit( ExprStmt * node ) { 299 232 VISIT_START( node ); 233 call_beginScope(); 300 234 301 235 visitExpression( node->get_expr() ); 302 236 237 call_endScope(); 303 238 VISIT_END( node ); 304 239 } … … 313 248 } 314 249 315 //--------------------------------------------------------------------------316 // AsmStmt317 250 template< typename pass_type > 318 251 void PassVisitor< pass_type >::visit( AsmStmt * node ) { 319 252 VISIT_BODY( node ); 320 }321 322 template< typename pass_type >323 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {324 MUTATE_BODY( Statement, node );325 253 } 326 254 … … 372 300 373 301 //-------------------------------------------------------------------------- 374 // ForStmt302 // WhileStmt 375 303 template< typename pass_type > 376 304 void PassVisitor< pass_type >::visit( ForStmt * node ) { … … 420 348 421 349 //-------------------------------------------------------------------------- 422 // CaseStmt350 // SwitchStmt 423 351 template< typename pass_type > 424 352 void PassVisitor< pass_type >::visit( CaseStmt * node ) { … … 441 369 } 442 370 443 //--------------------------------------------------------------------------444 // BranchStmt445 371 template< typename pass_type > 446 372 void PassVisitor< pass_type >::visit( BranchStmt * node ) { 447 373 VISIT_BODY( node ); 448 }449 450 template< typename pass_type >451 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {452 MUTATE_BODY( Statement, node );453 374 } 454 375 … … 494 415 maybeAccept( node->get_block(), *this ); 495 416 acceptAll( node->get_catchers(), *this ); 496 maybeAccept( node->get_finally(), *this );497 417 498 418 VISIT_END( node ); … … 505 425 node->set_block( maybeMutate( node->get_block(), *this ) ); 506 426 mutateAll( node->get_catchers(), *this ); 507 node->set_finally( maybeMutate( node->get_finally(), *this ) );508 427 509 428 MUTATE_END( Statement, node ); … … 516 435 VISIT_START( node ); 517 436 437 node->set_body( visitStatement( node->get_body() ) ); 518 438 maybeAccept( node->get_decl(), *this ); 519 node->set_cond( visitExpression( node->get_cond() ) );520 node->set_body( visitStatement( node->get_body() ) );521 439 522 440 VISIT_END( node ); … … 527 445 MUTATE_START( node ); 528 446 529 node->set_decl( maybeMutate( node->get_decl(), *this ) ); 530 node->set_cond( mutateExpression( node->get_cond() ) ); 531 node->set_body( mutateStatement( node->get_body() ) ); 447 node->set_body( mutateStatement( node->get_body() ) ); 448 node->set_decl( maybeMutate( node->get_decl(), *this ) ); 532 449 533 450 MUTATE_END( Statement, node ); … … 921 838 922 839 template< typename pass_type > 840 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { 841 MUTATE_BODY( Statement, node ); 842 } 843 844 template< typename pass_type > 845 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { 846 MUTATE_BODY( Statement, node ); 847 } 848 849 template< typename pass_type > 923 850 Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) { 924 851 MUTATE_BODY( Statement, node ); -
src/Common/PassVisitor.proto.h
rd43cd01 r1c273d0 1 1 #pragma once 2 3 template<typename pass_type>4 class PassVisitor;5 2 6 3 typedef std::function<void( void * )> cleanup_func_t; … … 34 31 35 32 typedef std::function< void( cleanup_func_t, void * ) > at_cleanup_t; 36 37 class bool_ref {38 public:39 bool_ref() = default;40 ~bool_ref() = default;41 42 operator bool() { return *m_ref; }43 bool operator=( bool val ) { return *m_ref = val; }44 45 private:46 47 template<typename pass>48 friend class PassVisitor;49 50 void set( bool & val ) { m_ref = &val; };51 52 bool * m_ref;53 };54 33 55 34 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- … … 133 112 FIELD_PTR( std::list< Statement* >, stmtsToAddBefore ) 134 113 FIELD_PTR( std::list< Statement* >, stmtsToAddAfter ) 135 FIELD_PTR( std::list< Declaration* >, declsToAddBefore ) 136 FIELD_PTR( std::list< Declaration* >, declsToAddAfter ) 137 FIELD_PTR( bool_ref, visit_children ) 114 FIELD_PTR( bool, skip_children ) 138 115 FIELD_PTR( at_cleanup_t, at_cleanup ) 139 FIELD_PTR( PassVisitor<pass_type> * const, visitor ) -
src/GenPoly/DeclMutator.cc
rd43cd01 r1c273d0 9 9 // Author : Aaron B. Moss 10 10 // Created On : Fri Nov 27 14:44:00 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thu Jun 22 13:49:00 201713 // Update Count : 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 11:16:43 2016 13 // Update Count : 3 14 14 // 15 15 … … 178 178 Statement* DeclMutator::mutate(CatchStmt *catchStmt) { 179 179 catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) ); 180 catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );181 180 catchStmt->set_body( mutateStatement( catchStmt->get_body() ) ); 182 181 return catchStmt; -
src/GenPoly/PolyMutator.cc
rd43cd01 r1c273d0 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thu Jun 22 13:47:00 201713 // Update Count : 1 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 11:26:22 2016 13 // Update Count : 16 14 14 // 15 15 … … 123 123 124 124 Statement * PolyMutator::mutate(TryStmt *tryStmt) { 125 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );125 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) ); 126 126 mutateAll( tryStmt->get_catchers(), *this ); 127 tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );128 127 return tryStmt; 129 128 } 130 129 131 130 Statement * PolyMutator::mutate(CatchStmt *cathStmt) { 132 cathStmt->set_body( mutateStatement( cathStmt->get_body() ) ); 133 cathStmt->set_cond( maybeMutate( cathStmt->get_cond(), *this ) ); 134 cathStmt->set_decl( maybeMutate( cathStmt->get_decl(), *this ) ); 131 cathStmt->set_body( mutateStatement( cathStmt->get_body() ) ); 132 cathStmt->set_decl( maybeMutate( cathStmt->get_decl(), *this ) ); 135 133 return cathStmt; 136 134 } -
src/GenPoly/Specialize.cc
rd43cd01 r1c273d0 99 99 if ( FunctionType * fftype = getFunctionType( formalType ) ) { 100 100 if ( fftype->isTtype() ) return true; 101 // conversion of 0 (null) to function type does not require tuple specialization102 if ( dynamic_cast< ZeroType * >( actualType ) ) return false;103 101 FunctionType * aftype = getFunctionType( actualType ); 104 102 assertf( aftype, "formal type is a function type, but actual type is not." ); -
src/InitTweak/InitTweak.cc
rd43cd01 r1c273d0 474 474 public: 475 475 ConstExprChecker() : isConstExpr( true ) {} 476 477 using Visitor::visit;478 476 479 477 virtual void visit( __attribute((unused)) ApplicationExpr *applicationExpr ) { isConstExpr = false; } -
src/Parser/StatementNode.cc
rd43cd01 r1c273d0 168 168 169 169 Statement *build_resume_at( ExpressionNode *ctl, ExpressionNode *target ) { 170 (void)ctl; 171 (void)target; 172 assertf( false, "resume at (non-local throw) is not yet supported," ); 170 std::list< Expression * > exps; 171 buildMoveList( ctl, exps ); 172 assertf( exps.size() < 2, "This means we are leaking memory"); 173 return new ThrowStmt( noLabels, ThrowStmt::Resume, !exps.empty() ? exps.back() : nullptr ); 173 174 } 174 175 -
src/SynTree/Constant.cc
rd43cd01 r1c273d0 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Jun 22 10:11:00201713 // Update Count : 2 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 21 16:44:48 2017 13 // Update Count : 27 14 14 // 15 15 … … 29 29 30 30 Constant::~Constant() { delete type; } 31 32 Constant Constant::from_bool( bool b ) {33 return Constant( new BasicType( Type::Qualifiers(), BasicType::Bool ), b ? "1" : "0" , (unsigned long long int)b );34 }35 31 36 32 Constant Constant::from_int( int i ) { -
src/SynTree/Constant.h
rd43cd01 r1c273d0 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Jun 22 10:13:00201713 // Update Count : 1 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 21 16:44:48 2017 13 // Update Count : 14 14 14 // 15 15 … … 33 33 void set_value( std::string newValue ) { rep = newValue; } 34 34 35 /// generates a boolean constant of the given bool36 static Constant from_bool( bool b );37 35 /// generates an integer constant of the given int 38 36 static Constant from_int( int i ); -
src/SynTree/Mutator.cc
rd43cd01 r1c273d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 22 13:43:00 201713 // Update Count : 2 412 // Last Modified On : Thu Mar 8 16:36:00 2017 13 // Update Count : 23 14 14 // 15 15 … … 162 162 tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) ); 163 163 mutateAll( tryStmt->get_catchers(), *this ); 164 tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );165 164 return tryStmt; 166 165 } … … 168 167 Statement *Mutator::mutate( CatchStmt *catchStmt ) { 169 168 catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) ); 170 catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );171 169 catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) ); 172 170 return catchStmt; -
src/SynTree/Visitor.cc
rd43cd01 r1c273d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jun 22 13:41:00 201713 // Update Count : 2 612 // Last Modified On : Thu Jun 8 16:31:00 2017 13 // Update Count : 25 14 14 // 15 15 … … 137 137 maybeAccept( tryStmt->get_block(), *this ); 138 138 acceptAll( tryStmt->get_catchers(), *this ); 139 maybeAccept( tryStmt->get_finally(), *this );140 139 } 141 140 142 141 void Visitor::visit( CatchStmt *catchStmt ) { 143 142 maybeAccept( catchStmt->get_decl(), *this ); 144 maybeAccept( catchStmt->get_cond(), *this );145 143 maybeAccept( catchStmt->get_body(), *this ); 146 144 }
Note:
See TracChangeset
for help on using the changeset viewer.