Changeset 9bdb8b7 for src/ControlStruct


Ignore:
Timestamp:
Oct 25, 2019, 5:44:25 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c3a2007
Parents:
89124ff
Message:

allow labelled break from within the body of a try statement

Location:
src/ControlStruct
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/MLEMutator.cc

    r89124ff r9bdb8b7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 17:08:25 2018
    13 // Update Count     : 219
     12// Last Modified On : Tue Oct 22 17:22:44 2019
     13// Update Count     : 220
    1414//
    1515
     
    313313        }
    314314
     315        void MLEMutator::premutate( TryStmt * tryStmt ) {
     316                // generate a label for breaking out of a labeled if
     317                bool labeledBlock = !(tryStmt->get_labels().empty());
     318                if ( labeledBlock ) {
     319                        Label brkLabel = generator->newLabel("blockBreak", tryStmt);
     320                        enclosingControlStructures.push_back( Entry( tryStmt, brkLabel ) );
     321                        GuardAction( [this]() { enclosingControlStructures.pop_back(); } );
     322                } // if
     323        }
     324
     325        Statement * MLEMutator::postmutate( TryStmt * tryStmt ) {
     326                bool labeledBlock = !(tryStmt->get_labels().empty());
     327                if ( labeledBlock ) {
     328                        if ( ! enclosingControlStructures.back().useBreakExit().empty() ) {
     329                                set_breakLabel( enclosingControlStructures.back().useBreakExit() );
     330                        } // if
     331                } // if
     332                return tryStmt;
     333        }
     334
    315335        void MLEMutator::premutate( CaseStmt *caseStmt ) {
    316336                visit_children = false;
  • src/ControlStruct/MLEMutator.h

    r89124ff r9bdb8b7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  8 16:42:32 2018
    13 // Update Count     : 41
     12// Last Modified On : Tue Oct 22 17:22:47 2019
     13// Update Count     : 45
    1414//
    1515
     
    4747                void premutate( SwitchStmt *switchStmt );
    4848                Statement * postmutate( SwitchStmt *switchStmt );
     49                void premutate( TryStmt *tryStmt );
     50                Statement * postmutate( TryStmt *tryStmt );
    4951
    5052                Statement *mutateLoop( Statement *bodyLoop, Entry &e );
     
    7375                        explicit Entry( SwitchStmt *stmt, Label breakExit, Label fallDefaultExit ) :
    7476                                stmt( stmt ), breakExit( breakExit ), fallDefaultExit( fallDefaultExit ) {}
     77
     78                        explicit Entry( TryStmt *stmt, Label breakExit ) :
     79                                stmt( stmt ), breakExit( breakExit ) {}
    7580
    7681                        bool operator==( const Statement *other ) { return stmt == other; }
Note: See TracChangeset for help on using the changeset viewer.