Changes in / [5518719:26fd986]


Ignore:
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/LabelFixer.cc

    r5518719 r26fd986  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Jan 21 10:32:00 2020
    13 // Update Count     : 160
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Mar 11 22:26:02 2019
     13// Update Count     : 159
    1414//
    1515
     
    2121#include "ControlStruct/LabelGenerator.h"  // for LabelGenerator
    2222#include "LabelFixer.h"
    23 #include "MLEMutator.h"                    // for MultiLevelExitMutator
     23#include "MLEMutator.h"                    // for MLEMutator
    2424#include "SynTree/Declaration.h"           // for FunctionDecl
    2525#include "SynTree/Expression.h"            // for NameExpr, Expression, Unty...
     
    4444
    4545        void LabelFixer::postvisit( FunctionDecl * functionDecl ) {
    46                 PassVisitor<MultiLevelExitMutator> mlem( resolveJumps(), generator );
    47                 functionDecl->acceptMutator( mlem );
     46                PassVisitor<MLEMutator> mlemut( resolveJumps(), generator );
     47                functionDecl->acceptMutator( mlemut );
    4848        }
    4949
  • src/ControlStruct/MLEMutator.cc

    r5518719 r26fd986  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Jan 21 10:33:00 2020
    13 // Update Count     : 222
     12// Last Modified On : Thr Jan 16 15:33:00 2020
     13// Update Count     : 221
    1414//
    1515
     
    3333
    3434namespace ControlStruct {
    35         MultiLevelExitMutator::~MultiLevelExitMutator() {
     35        MLEMutator::~MLEMutator() {
    3636                delete targetTable;
    3737                targetTable = 0;
    3838        }
    3939        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 ); }
    6147        } // namespace
    6248
     
    6450        // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the
    6551        // body of statements
    66         void MultiLevelExitMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
     52        void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
    6753                SemanticErrorException errors;
    6854
     
    9581        }
    9682
    97         void MultiLevelExitMutator::premutate( CompoundStmt *cmpndStmt ) {
     83        void MLEMutator::premutate( CompoundStmt *cmpndStmt ) {
    9884                visit_children = false;
    9985                bool labeledBlock = !(cmpndStmt->labels.empty());
     
    132118                        }
    133119                }
    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 ) {
    141125                std::string originalTarget = branchStmt->originalTarget;
    142126
     
    246230        }
    247231
    248         Statement *MultiLevelExitMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
     232        Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
    249233                // only generate these when needed
    250234                if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop;
     
    269253
    270254        template< typename LoopClass >
    271         void MultiLevelExitMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
     255        void MLEMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
    272256                // remember this as the most recent enclosing loop, then mutate the body of the loop -- this will determine
    273257                // whether brkLabel and contLabel are used with branch statements and will recursively do the same to nested
     
    280264
    281265        template< typename LoopClass >
    282         Statement * MultiLevelExitMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
     266        Statement * MLEMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
    283267                assert( ! enclosingControlStructures.empty() );
    284268                Entry &e = enclosingControlStructures.back();
     
    291275        }
    292276
    293         void MultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {
     277        void MLEMutator::premutate( WhileStmt * whileStmt ) {
    294278                return prehandleLoopStmt( whileStmt );
    295279        }
    296280
    297         void MultiLevelExitMutator::premutate( ForStmt * forStmt ) {
     281        void MLEMutator::premutate( ForStmt * forStmt ) {
    298282                return prehandleLoopStmt( forStmt );
    299283        }
    300284
    301         Statement * MultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {
     285        Statement * MLEMutator::postmutate( WhileStmt * whileStmt ) {
    302286                return posthandleLoopStmt( whileStmt );
    303287        }
    304288
    305         Statement * MultiLevelExitMutator::postmutate( ForStmt * forStmt ) {
     289        Statement * MLEMutator::postmutate( ForStmt * forStmt ) {
    306290                return posthandleLoopStmt( forStmt );
    307291        }
    308292
    309         void MultiLevelExitMutator::premutate( IfStmt * ifStmt ) {
     293        void MLEMutator::premutate( IfStmt * ifStmt ) {
    310294                // generate a label for breaking out of a labeled if
    311295                bool labeledBlock = !(ifStmt->get_labels().empty());
     
    317301        }
    318302
    319         Statement * MultiLevelExitMutator::postmutate( IfStmt * ifStmt ) {
     303        Statement * MLEMutator::postmutate( IfStmt * ifStmt ) {
    320304                bool labeledBlock = !(ifStmt->get_labels().empty());
    321305                if ( labeledBlock ) {
     
    327311        }
    328312
    329         void MultiLevelExitMutator::premutate( TryStmt * tryStmt ) {
     313        void MLEMutator::premutate( TryStmt * tryStmt ) {
    330314                // generate a label for breaking out of a labeled if
    331315                bool labeledBlock = !(tryStmt->get_labels().empty());
     
    337321        }
    338322
    339         Statement * MultiLevelExitMutator::postmutate( TryStmt * tryStmt ) {
     323        Statement * MLEMutator::postmutate( TryStmt * tryStmt ) {
    340324                bool labeledBlock = !(tryStmt->get_labels().empty());
    341325                if ( labeledBlock ) {
     
    347331        }
    348332
    349         void MultiLevelExitMutator::premutate( FinallyStmt * ) {
     333        void MLEMutator::premutate( FinallyStmt * ) {
    350334                GuardAction([this, old = std::move(enclosingControlStructures)]() {
    351335                        enclosingControlStructures = std::move(old);
     
    354338        }
    355339
    356         void MultiLevelExitMutator::premutate( CaseStmt *caseStmt ) {
     340        void MLEMutator::premutate( CaseStmt *caseStmt ) {
    357341                visit_children = false;
    358342
     
    393377        }
    394378
    395         void MultiLevelExitMutator::premutate( SwitchStmt *switchStmt ) {
     379        void MLEMutator::premutate( SwitchStmt *switchStmt ) {
    396380                // generate a label for breaking out of a labeled switch
    397381                Label brkLabel = generator->newLabel("switchBreak", switchStmt);
     
    419403        }
    420404
    421         Statement * MultiLevelExitMutator::postmutate( SwitchStmt * switchStmt ) {
     405        Statement * MLEMutator::postmutate( SwitchStmt * switchStmt ) {
    422406                Entry &e = enclosingControlStructures.back();
    423407                assert ( e == switchStmt );
  • src/ControlStruct/MLEMutator.h

    r5518719 r26fd986  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Jan 21 10:33:00 2020
    13 // Update Count     : 47
     12// Last Modified On : Thr Jan 16 12:46:00 2020
     13// Update Count     : 46
    1414//
     15
     16// Can anyone figure out what MLE stands for?
    1517
    1618#pragma once
     
    3032        class LabelGenerator;
    3133
    32         class MultiLevelExitMutator : public WithVisitorRef<MultiLevelExitMutator>,
    33                         public WithShortCircuiting, public WithGuards {
     34        class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards {
    3435          public:
    3536                class Entry;
    36                 MultiLevelExitMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) :
    37                         targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
    38                 ~MultiLevelExitMutator();
     37                MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
     38                ~MLEMutator();
    3939
    4040                void premutate( CompoundStmt *cmpndStmt );
  • src/SynTree/Statement.cc

    r5518719 r26fd986  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jan 20 16:03:00 2020
    13 // Update Count     : 71
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Jan 10 14:20:47 2020
     13// Update Count     : 70
    1414//
    1515
     
    101101
    102102
    103 const char * BranchStmt::brType[] = {
    104         "Goto", "Break", "Continue", "Fall Through", "Fall Through Default",
    105 };
     103const char * BranchStmt::brType[] = { "Goto", "Break", "Continue" };
    106104
    107105BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) :
     
    121119
    122120void BranchStmt::print( std::ostream & os, Indenter indent ) const {
    123         assert(type < 5);
    124121        os << "Branch (" << brType[type] << ")" << endl ;
    125122        if ( target != "" ) os << indent+1 << "with target: " << target << endl;
Note: See TracChangeset for help on using the changeset viewer.