Changes in src/ControlStruct/MLEMutator.cc [5cdeecd:d62806c]
- File:
-
- 1 edited
-
src/ControlStruct/MLEMutator.cc (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/MLEMutator.cc
r5cdeecd rd62806c 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T ue Jan 21 10:33:00 202013 // Update Count : 22 212 // Last Modified On : Thr Jan 16 15:33:00 2020 13 // Update Count : 221 14 14 // 15 15 … … 33 33 34 34 namespace ControlStruct { 35 M ultiLevelExitMutator::~MultiLevelExitMutator() {35 MLEMutator::~MLEMutator() { 36 36 delete targetTable; 37 37 targetTable = 0; 38 38 } 39 39 namespace { 40 bool isLoop( const MultiLevelExitMutator::Entry & e ) { 41 return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) 42 || dynamic_cast< ForStmt * >( e.get_controlStructure() ); 43 } 44 bool isSwitch( const MultiLevelExitMutator::Entry & e ) { 45 return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); 46 } 47 48 bool isBreakTarget( const MultiLevelExitMutator::Entry & e ) { 49 return isLoop( e ) || isSwitch( e ) 50 || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); 51 } 52 bool isContinueTarget( const MultiLevelExitMutator::Entry & e ) { 53 return isLoop( e ); 54 } 55 bool isFallthroughTarget( const MultiLevelExitMutator::Entry & e ) { 56 return dynamic_cast< CaseStmt *>( e.get_controlStructure() ); 57 } 58 bool isFallthroughDefaultTarget( const MultiLevelExitMutator::Entry & e ) { 59 return isSwitch( e ); 60 } 40 bool isLoop( const MLEMutator::Entry & e ) { return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) || dynamic_cast< ForStmt * >( e.get_controlStructure() ); } 41 bool isSwitch( const MLEMutator::Entry & e ) { return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); } 42 43 bool isBreakTarget( const MLEMutator::Entry & e ) { return isLoop( e ) || isSwitch( e ) || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); } 44 bool isContinueTarget( const MLEMutator::Entry & e ) { return isLoop( e ); } 45 bool isFallthroughTarget( const MLEMutator::Entry & e ) { return dynamic_cast< CaseStmt *>( e.get_controlStructure() );; } 46 bool isFallthroughDefaultTarget( const MLEMutator::Entry & e ) { return isSwitch( e ); } 61 47 } // namespace 62 48 … … 64 50 // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the 65 51 // body of statements 66 void M ultiLevelExitMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {52 void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) { 67 53 SemanticErrorException errors; 68 54 … … 95 81 } 96 82 97 void M ultiLevelExitMutator::premutate( CompoundStmt *cmpndStmt ) {83 void MLEMutator::premutate( CompoundStmt *cmpndStmt ) { 98 84 visit_children = false; 99 85 bool labeledBlock = !(cmpndStmt->labels.empty()); … … 132 118 } 133 119 } 134 assertf( false, "Could not find label '%s' on statement %s", 135 originalTarget.get_name().c_str(), toString( stmt ).c_str() ); 136 } 137 138 139 Statement *MultiLevelExitMutator::postmutate( BranchStmt *branchStmt ) 140 throw ( SemanticErrorException ) { 120 assertf( false, "Could not find label '%s' on statement %s", originalTarget.get_name().c_str(), toString( stmt ).c_str() ); 121 } 122 123 124 Statement *MLEMutator::postmutate( BranchStmt *branchStmt ) throw ( SemanticErrorException ) { 141 125 std::string originalTarget = branchStmt->originalTarget; 142 126 … … 246 230 } 247 231 248 Statement *M ultiLevelExitMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {232 Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) { 249 233 // only generate these when needed 250 234 if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop; … … 269 253 270 254 template< typename LoopClass > 271 void M ultiLevelExitMutator::prehandleLoopStmt( LoopClass * loopStmt ) {255 void MLEMutator::prehandleLoopStmt( LoopClass * loopStmt ) { 272 256 // remember this as the most recent enclosing loop, then mutate the body of the loop -- this will determine 273 257 // whether brkLabel and contLabel are used with branch statements and will recursively do the same to nested … … 280 264 281 265 template< typename LoopClass > 282 Statement * M ultiLevelExitMutator::posthandleLoopStmt( LoopClass * loopStmt ) {266 Statement * MLEMutator::posthandleLoopStmt( LoopClass * loopStmt ) { 283 267 assert( ! enclosingControlStructures.empty() ); 284 268 Entry &e = enclosingControlStructures.back(); … … 291 275 } 292 276 293 void M ultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {277 void MLEMutator::premutate( WhileStmt * whileStmt ) { 294 278 return prehandleLoopStmt( whileStmt ); 295 279 } 296 280 297 void M ultiLevelExitMutator::premutate( ForStmt * forStmt ) {281 void MLEMutator::premutate( ForStmt * forStmt ) { 298 282 return prehandleLoopStmt( forStmt ); 299 283 } 300 284 301 Statement * M ultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {285 Statement * MLEMutator::postmutate( WhileStmt * whileStmt ) { 302 286 return posthandleLoopStmt( whileStmt ); 303 287 } 304 288 305 Statement * M ultiLevelExitMutator::postmutate( ForStmt * forStmt ) {289 Statement * MLEMutator::postmutate( ForStmt * forStmt ) { 306 290 return posthandleLoopStmt( forStmt ); 307 291 } 308 292 309 void M ultiLevelExitMutator::premutate( IfStmt * ifStmt ) {293 void MLEMutator::premutate( IfStmt * ifStmt ) { 310 294 // generate a label for breaking out of a labeled if 311 295 bool labeledBlock = !(ifStmt->get_labels().empty()); … … 317 301 } 318 302 319 Statement * M ultiLevelExitMutator::postmutate( IfStmt * ifStmt ) {303 Statement * MLEMutator::postmutate( IfStmt * ifStmt ) { 320 304 bool labeledBlock = !(ifStmt->get_labels().empty()); 321 305 if ( labeledBlock ) { … … 327 311 } 328 312 329 void M ultiLevelExitMutator::premutate( TryStmt * tryStmt ) {313 void MLEMutator::premutate( TryStmt * tryStmt ) { 330 314 // generate a label for breaking out of a labeled if 331 315 bool labeledBlock = !(tryStmt->get_labels().empty()); … … 337 321 } 338 322 339 Statement * M ultiLevelExitMutator::postmutate( TryStmt * tryStmt ) {323 Statement * MLEMutator::postmutate( TryStmt * tryStmt ) { 340 324 bool labeledBlock = !(tryStmt->get_labels().empty()); 341 325 if ( labeledBlock ) { … … 347 331 } 348 332 349 void M ultiLevelExitMutator::premutate( FinallyStmt * ) {333 void MLEMutator::premutate( FinallyStmt * ) { 350 334 GuardAction([this, old = std::move(enclosingControlStructures)]() { 351 335 enclosingControlStructures = std::move(old); … … 354 338 } 355 339 356 void M ultiLevelExitMutator::premutate( CaseStmt *caseStmt ) {340 void MLEMutator::premutate( CaseStmt *caseStmt ) { 357 341 visit_children = false; 358 342 … … 393 377 } 394 378 395 void M ultiLevelExitMutator::premutate( SwitchStmt *switchStmt ) {379 void MLEMutator::premutate( SwitchStmt *switchStmt ) { 396 380 // generate a label for breaking out of a labeled switch 397 381 Label brkLabel = generator->newLabel("switchBreak", switchStmt); … … 419 403 } 420 404 421 Statement * M ultiLevelExitMutator::postmutate( SwitchStmt * switchStmt ) {405 Statement * MLEMutator::postmutate( SwitchStmt * switchStmt ) { 422 406 Entry &e = enclosingControlStructures.back(); 423 407 assert ( e == switchStmt );
Note:
See TracChangeset
for help on using the changeset viewer.