Changes in / [cf37a8e:00c32e9]


Ignore:
Location:
src
Files:
2 added
22 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rcf37a8e r00c32e9  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:16:21 2016
    13 // Update Count     : 351
     11// Last Modified By :
     12// Last Modified On : Sun Jul 31 08:42:18 2016
     13// Update Count     : 345
    1414//
    1515
     
    4848        }
    4949
    50         void CodeGenerator::extension( Expression * expr ) {
     50        void CodeGenerator::extension( Expression *expr ) {
    5151                if ( expr->get_extension() ) {
    5252                        output << "__extension__ ";
     
    5454        } // extension
    5555
    56         void CodeGenerator::extension( Declaration * decl ) {
     56        void CodeGenerator::extension( Declaration *decl ) {
    5757                if ( decl->get_extension() ) {
    5858                        output << "__extension__ ";
     
    7373        }
    7474
    75         ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter & printLabels ) {
     75        ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter &printLabels ) {
    7676                std::list< Label > & labs = *printLabels.labels;
    7777                // l.unique(); // assumes a sorted list. Why not use set? Does order matter?
     
    7979                        output << l.get_name() + ": ";
    8080                        printLabels.cg.genAttributes( l.get_attributes() );
    81                 } // for
     81                }
    8282                return output;
    8383        }
    8484
    85         CodeGenerator::CodeGenerator( std::ostream & os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {}
    86 
    87         CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )
     85        CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {}
     86
     87        CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp )
    8888                        : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) {
    8989                //output << std::string( init );
    9090        }
    9191
    92         CodeGenerator::CodeGenerator( std::ostream & os, char * init, int indentation, bool infunp )
     92        CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indentation, bool infunp )
    9393                        : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) {
    9494                //output << std::string( init );
    9595        }
    9696
    97         string mangleName( DeclarationWithType * decl ) {
     97        string mangleName( DeclarationWithType *decl ) {
    9898                if ( decl->get_mangleName() != "" ) {
    9999                        // need to incorporate scope level in order to differentiate names for destructors
     
    112112                                        genCommaList( attr->get_parameters().begin(), attr->get_parameters().end() );
    113113                                        output << ")";
    114                                 } // if
     114                                }
    115115                                output << ",";
    116                         } // for
     116                        }
    117117                        output << ")) ";
    118                 } // if
     118                }
    119119        }
    120120
    121121
    122122        //*** Declarations
    123         void CodeGenerator::visit( FunctionDecl * functionDecl ) {
     123        void CodeGenerator::visit( FunctionDecl *functionDecl ) {
    124124                extension( functionDecl );
    125125                genAttributes( functionDecl->get_attributes() );
     
    146146        }
    147147
    148         void CodeGenerator::visit( ObjectDecl * objectDecl ) {
     148        void CodeGenerator::visit( ObjectDecl *objectDecl ) {
    149149                extension( objectDecl );
    150150                handleStorageClass( objectDecl );
     
    162162        }
    163163
    164         void CodeGenerator::handleAggregate( AggregateDecl * aggDecl ) {
     164        void CodeGenerator::handleAggregate( AggregateDecl *aggDecl ) {
    165165                if ( aggDecl->get_name() != "" )
    166166                        output << aggDecl->get_name();
    167167
    168                 std::list< Declaration * > & memb = aggDecl->get_members();
     168                std::list< Declaration * > &memb = aggDecl->get_members();
    169169                if ( ! memb.empty() ) {
    170170//              if ( aggDecl->has_body() ) {
    171 //                      std::list< Declaration * > & memb = aggDecl->get_members();
     171//                      std::list< Declaration * > &memb = aggDecl->get_members();
    172172                        output << " {" << endl;
    173173
     
    185185        }
    186186
    187         void CodeGenerator::visit( StructDecl * structDecl ) {
     187        void CodeGenerator::visit( StructDecl *structDecl ) {
    188188                extension( structDecl );
    189189                output << "struct ";
     
    191191        }
    192192
    193         void CodeGenerator::visit( UnionDecl * unionDecl ) {
     193        void CodeGenerator::visit( UnionDecl *unionDecl ) {
    194194                extension( unionDecl );
    195195                output << "union ";
     
    197197        }
    198198
    199         void CodeGenerator::visit( EnumDecl * enumDecl ) {
     199        void CodeGenerator::visit( EnumDecl *enumDecl ) {
    200200                extension( enumDecl );
    201201                output << "enum ";
     
    211211                        cur_indent += CodeGenerator::tabsize;
    212212                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    213                                 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i );
     213                                ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i );
    214214                                assert( obj );
    215215                                output << indent << mangleName( obj );
     
    227227        }
    228228
    229         void CodeGenerator::visit( TraitDecl * traitDecl ) {}
    230 
    231         void CodeGenerator::visit( TypedefDecl * typeDecl ) {
     229        void CodeGenerator::visit( TraitDecl *traitDecl ) {}
     230
     231        void CodeGenerator::visit( TypedefDecl *typeDecl ) {
    232232                assert( false && "Typedefs are removed and substituted in earlier passes." );
    233233                //output << "typedef ";
     
    235235        }
    236236
    237         void CodeGenerator::visit( TypeDecl * typeDecl ) {
     237        void CodeGenerator::visit( TypeDecl *typeDecl ) {
    238238                // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
    239239                // still to be done
     
    263263        }
    264264
    265         void CodeGenerator::visit( SingleInit * init ) {
     265        void CodeGenerator::visit( SingleInit *init ) {
    266266                printDesignators( init->get_designators() );
    267267                init->get_value()->accept( *this );
    268268        }
    269269
    270         void CodeGenerator::visit( ListInit * init ) {
     270        void CodeGenerator::visit( ListInit *init ) {
    271271                printDesignators( init->get_designators() );
    272272                output << "{ ";
     
    276276                } else {
    277277                        genCommaList( init->begin_initializers(), init->end_initializers() );
    278                 } // if
     278                }
    279279                output << " }";
    280280        }
    281281
    282         void CodeGenerator::visit( Constant * constant ) {
     282        void CodeGenerator::visit( Constant *constant ) {
    283283                output << constant->get_value() ;
    284284        }
    285285
    286286        //*** Expressions
    287         void CodeGenerator::visit( ApplicationExpr * applicationExpr ) {
     287        void CodeGenerator::visit( ApplicationExpr *applicationExpr ) {
    288288                extension( applicationExpr );
    289                 if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {
     289                if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {
    290290                        OperatorInfo opInfo;
    291291                        if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( varExpr->get_var()->get_name(), opInfo ) ) {
     
    299299                                        {
    300300                                                assert( arg != applicationExpr->get_args().end() );
    301                                                 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
     301                                                if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
    302302                                                        // remove & from first assignment/ctor argument
    303303                                                        *arg = addrExpr->get_arg();
    304304                                                } else {
    305305                                                        // no address-of operator, so must be a pointer - add dereference
    306                                                         UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );
     306                                                        UntypedExpr *newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    307307                                                        newExpr->get_args().push_back( *arg );
    308308                                                        assert( (*arg)->get_results().size() == 1 );
     
    352352                                                // no constructors with 0 or more than 2 parameters
    353353                                                assert( false );
    354                                         } // if
     354                                        }
    355355                                        break;
    356356
     
    401401        }
    402402
    403         void CodeGenerator::visit( UntypedExpr * untypedExpr ) {
     403        void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
    404404                extension( untypedExpr );
    405                 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
     405                if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
    406406                        OperatorInfo opInfo;
    407407                        if ( operatorLookup( nameExpr->get_name(), opInfo ) ) {
     
    472472                                } // switch
    473473                        } else {
    474                                 if ( nameExpr->get_name() == "..." ) { // case V1 ... V2 or case V1~V2
     474                                if ( nameExpr->get_name() == "Range" ) { // case V1 ... V2 or case V1~V2
    475475                                        assert( untypedExpr->get_args().size() == 2 );
    476476                                        (*untypedExpr->get_args().begin())->accept( *this );
     
    492492        }
    493493
    494         void CodeGenerator::visit( NameExpr * nameExpr ) {
     494        void CodeGenerator::visit( NameExpr *nameExpr ) {
    495495                extension( nameExpr );
    496496                OperatorInfo opInfo;
     
    503503        }
    504504
    505         void CodeGenerator::visit( AddressExpr * addressExpr ) {
     505        void CodeGenerator::visit( AddressExpr *addressExpr ) {
    506506                extension( addressExpr );
    507507                output << "(&";
    508508                // this hack makes sure that we don't convert "constant_zero" to "0" if we're taking its address
    509                 if ( VariableExpr * variableExpr = dynamic_cast< VariableExpr* >( addressExpr->get_arg() ) ) {
     509                if ( VariableExpr *variableExpr = dynamic_cast< VariableExpr* >( addressExpr->get_arg() ) ) {
    510510                        output << mangleName( variableExpr->get_var() );
    511511                } else {
     
    515515        }
    516516
    517         void CodeGenerator::visit( CastExpr * castExpr ) {
     517        void CodeGenerator::visit( CastExpr *castExpr ) {
    518518                extension( castExpr );
    519519                output << "(";
     
    533533        }
    534534
    535         void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) {
     535        void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) {
    536536                assert( false );
    537537        }
    538538
    539         void CodeGenerator::visit( MemberExpr * memberExpr ) {
     539        void CodeGenerator::visit( MemberExpr *memberExpr ) {
    540540                extension( memberExpr );
    541541                memberExpr->get_aggregate()->accept( *this );
     
    543543        }
    544544
    545         void CodeGenerator::visit( VariableExpr * variableExpr ) {
     545        void CodeGenerator::visit( VariableExpr *variableExpr ) {
    546546                extension( variableExpr );
    547547                OperatorInfo opInfo;
     
    553553        }
    554554
    555         void CodeGenerator::visit( ConstantExpr * constantExpr ) {
     555        void CodeGenerator::visit( ConstantExpr *constantExpr ) {
    556556                assert( constantExpr->get_constant() );
    557557                extension( constantExpr );
     
    559559        }
    560560
    561         void CodeGenerator::visit( SizeofExpr * sizeofExpr ) {
     561        void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
    562562                extension( sizeofExpr );
    563563                output << "sizeof(";
     
    570570        }
    571571
    572         void CodeGenerator::visit( AlignofExpr * alignofExpr ) {
     572        void CodeGenerator::visit( AlignofExpr *alignofExpr ) {
    573573                // use GCC extension to avoid bumping std to C11
    574574                extension( alignofExpr );
     
    582582        }
    583583
    584         void CodeGenerator::visit( UntypedOffsetofExpr * offsetofExpr ) {
     584        void CodeGenerator::visit( UntypedOffsetofExpr *offsetofExpr ) {
    585585                assert( false && "UntypedOffsetofExpr should not reach code generation." );
    586586        }
    587587
    588         void CodeGenerator::visit( OffsetofExpr * offsetofExpr ) {
     588        void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) {
    589589                // use GCC builtin
    590590                output << "__builtin_offsetof(";
     
    594594        }
    595595
    596         void CodeGenerator::visit( OffsetPackExpr * offsetPackExpr ) {
     596        void CodeGenerator::visit( OffsetPackExpr *offsetPackExpr ) {
    597597                assert( false && "OffsetPackExpr should not reach code generation." );
    598598        }
    599599
    600         void CodeGenerator::visit( LogicalExpr * logicalExpr ) {
     600        void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
    601601                extension( logicalExpr );
    602602                output << "(";
     
    611611        }
    612612
    613         void CodeGenerator::visit( ConditionalExpr * conditionalExpr ) {
     613        void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
    614614                extension( conditionalExpr );
    615615                output << "(";
     
    622622        }
    623623
    624         void CodeGenerator::visit( CommaExpr * commaExpr ) {
     624        void CodeGenerator::visit( CommaExpr *commaExpr ) {
    625625                extension( commaExpr );
    626626                output << "(";
     
    631631        }
    632632
    633         void CodeGenerator::visit( TupleExpr * tupleExpr ) {}
    634 
    635         void CodeGenerator::visit( TypeExpr * typeExpr ) {}
    636 
    637         void CodeGenerator::visit( AsmExpr * asmExpr ) {
     633        void CodeGenerator::visit( TupleExpr *tupleExpr ) {}
     634
     635        void CodeGenerator::visit( TypeExpr *typeExpr ) {}
     636
     637        void CodeGenerator::visit( AsmExpr *asmExpr ) {
    638638                if ( asmExpr->get_inout() ) {
    639639                        output << "[ ";
     
    648648
    649649        //*** Statements
    650         void CodeGenerator::visit( CompoundStmt * compoundStmt ) {
     650        void CodeGenerator::visit( CompoundStmt *compoundStmt ) {
    651651                std::list<Statement*> ks = compoundStmt->get_kids();
    652652                output << "{" << endl;
     
    662662                                output << endl;
    663663                        } // if
    664                 } // for
     664                }
    665665                cur_indent -= CodeGenerator::tabsize;
    666666
     
    668668        }
    669669
    670         void CodeGenerator::visit( ExprStmt * exprStmt ) {
     670        void CodeGenerator::visit( ExprStmt *exprStmt ) {
    671671                assert( exprStmt );
    672672                // cast the top-level expression to void to reduce gcc warnings.
     
    676676        }
    677677
    678         void CodeGenerator::visit( AsmStmt * asmStmt ) {
     678        void CodeGenerator::visit( AsmStmt *asmStmt ) {
    679679                output << "asm ";
    680680                if ( asmStmt->get_voltile() ) output << "volatile ";
     
    699699        }
    700700
    701         void CodeGenerator::visit( IfStmt * ifStmt ) {
     701        void CodeGenerator::visit( IfStmt *ifStmt ) {
    702702                output << "if ( ";
    703703                ifStmt->get_condition()->accept( *this );
     
    712712        }
    713713
    714         void CodeGenerator::visit( SwitchStmt * switchStmt ) {
     714        void CodeGenerator::visit( SwitchStmt *switchStmt ) {
    715715                output << "switch ( " ;
    716716                switchStmt->get_condition()->accept( *this );
     
    719719                output << "{" << std::endl;
    720720                cur_indent += CodeGenerator::tabsize;
    721                 acceptAll( switchStmt->get_statements(), *this );
     721
     722                acceptAll( switchStmt->get_branches(), *this );
     723
    722724                cur_indent -= CodeGenerator::tabsize;
     725
    723726                output << indent << "}";
    724727        }
    725728
    726         void CodeGenerator::visit( CaseStmt * caseStmt ) {
     729        void CodeGenerator::visit( CaseStmt *caseStmt ) {
    727730                output << indent;
    728731                if ( caseStmt->isDefault()) {
     
    745748        }
    746749
    747         void CodeGenerator::visit( BranchStmt * branchStmt ) {
     750        void CodeGenerator::visit( BranchStmt *branchStmt ) {
    748751                switch ( branchStmt->get_type()) {
    749752                  case BranchStmt::Goto:
     
    768771
    769772
    770         void CodeGenerator::visit( ReturnStmt * returnStmt ) {
     773        void CodeGenerator::visit( ReturnStmt *returnStmt ) {
    771774                output << "return ";
    772775                maybeAccept( returnStmt->get_expr(), *this );
     
    774777        }
    775778
    776         void CodeGenerator::visit( WhileStmt * whileStmt ) {
     779        void CodeGenerator::visit( WhileStmt *whileStmt ) {
    777780                if ( whileStmt->get_isDoWhile() ) {
    778781                        output << "do" ;
     
    796799        }
    797800
    798         void CodeGenerator::visit( ForStmt * forStmt ) {
     801        void CodeGenerator::visit( ForStmt *forStmt ) {
    799802                // initialization is always hoisted, so don't bother doing anything with that
    800803                output << "for (;";
     
    818821        }
    819822
    820         void CodeGenerator::visit( NullStmt * nullStmt ) {
     823        void CodeGenerator::visit( NullStmt *nullStmt ) {
    821824                //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() );
    822825                output << "/* null statement */ ;";
    823826        }
    824827
    825         void CodeGenerator::visit( DeclStmt * declStmt ) {
     828        void CodeGenerator::visit( DeclStmt *declStmt ) {
    826829                declStmt->get_decl()->accept( *this );
    827830
     
    831834        }
    832835
    833         void CodeGenerator::handleStorageClass( Declaration * decl ) {
     836        void CodeGenerator::handleStorageClass( Declaration *decl ) {
    834837                switch ( decl->get_storageClass() ) {
    835838                  case DeclarationNode::Extern:
  • src/ControlStruct/MLEMutator.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:21:32 2016
    13 // Update Count     : 202
     12// Last Modified On : Tue Jul 12 17:36:51 2016
     13// Update Count     : 197
    1414//
    1515
     
    128128                Label brkLabel = generator->newLabel("switchBreak");
    129129                enclosingControlStructures.push_back( Entry(switchStmt, brkLabel) );
    130                 mutateAll( switchStmt->get_statements(), *this );
     130                mutateAll( switchStmt->get_branches(), *this );
    131131
    132132                Entry &e = enclosingControlStructures.back();
     
    138138                        // switch should be CastStmts), append the exit label + break to the last case statement; create a default
    139139                        // case if there are no cases
    140                         std::list< Statement * > &statements = switchStmt->get_statements();
    141                         if ( statements.empty() ) {
    142                                 statements.push_back( CaseStmt::makeDefault() );
    143                         } // if
    144 
    145                         if ( CaseStmt * c = dynamic_cast< CaseStmt * >( statements.back() ) ) {
     140                        std::list< Statement * > &branches = switchStmt->get_branches();
     141                        if ( branches.empty() ) {
     142                                branches.push_back( CaseStmt::makeDefault() );
     143                        } // if
     144
     145                        if ( CaseStmt * c = dynamic_cast< CaseStmt * >( branches.back() ) ) {
    146146                                std::list<Label> temp; temp.push_back( brkLabel );
    147147                                c->get_statements().push_back( new BranchStmt( temp, Label("brkLabel"), BranchStmt::Break ) );
    148                         } else assert(0); // as of this point, all statements of a switch are still CaseStmts
     148                        } else assert(0); // as of this point, all branches of a switch are still CaseStmts
    149149                } // if
    150150
  • src/ControlStruct/Mutate.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:39:08 2016
    13 // Update Count     : 9
     12// Last Modified On : Tue Jul 12 17:37:45 2016
     13// Update Count     : 8
    1414//
    1515
     
    2222#include "LabelFixer.h"
    2323#include "MLEMutator.h"
     24#include "CaseRangeMutator.h"
    2425#include "ForExprMutator.h"
    2526#include "LabelTypeChecker.h"
     
    4041                LabelFixer lfix;
    4142
     43                // expand case ranges and turn fallthru into a null statement
     44                CaseRangeMutator ranges;
     45
    4246                //ExceptMutator exc;
    4347                // LabelTypeChecker lbl;
     
    4549                mutateAll( translationUnit, formut );
    4650                acceptAll( translationUnit, lfix );
     51                mutateAll( translationUnit, ranges );
    4752                //mutateAll( translationUnit, exc );
    4853                //acceptAll( translationUnit, lbl );
  • src/ControlStruct/module.mk

    rcf37a8e r00c32e9  
    1111## Created On       : Mon Jun  1 17:49:17 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Thu Aug  4 11:38:06 2016
    14 ## Update Count     : 3
     13## Last Modified On : Tue Jul 12 17:40:31 2016
     14## Update Count     : 2
    1515###############################################################################
    1616
     
    1818        ControlStruct/LabelFixer.cc \
    1919        ControlStruct/MLEMutator.cc \
     20        ControlStruct/CaseRangeMutator.cc \
    2021        ControlStruct/Mutate.cc \
    2122        ControlStruct/ForExprMutator.cc \
  • src/GenPoly/DeclMutator.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Fri Nov 27 14:44:00 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:16:43 2016
    13 // Update Count     : 3
     12// Last Modified On : Tue Jul 12 17:38:46 2016
     13// Update Count     : 2
    1414//
    1515
     
    163163        Statement* DeclMutator::mutate(SwitchStmt *switchStmt) {
    164164                switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
    165                 mutateAll( switchStmt->get_statements(), *this );
     165                mutateAll( switchStmt->get_branches(), *this );
    166166                return switchStmt;
    167167        }
  • src/GenPoly/PolyMutator.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:26:22 2016
    13 // Update Count     : 16
     12// Last Modified On : Tue Jul 12 17:39:32 2016
     13// Update Count     : 12
    1414//
    1515
     
    9999
    100100        Statement * PolyMutator::mutate(SwitchStmt *switchStmt) {
    101                 mutateStatementList( switchStmt->get_statements() );
     101                mutateStatementList( switchStmt->get_branches() );
    102102                switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );
    103103                return switchStmt;
  • src/Makefile.in

    rcf37a8e r00c32e9  
    108108        ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) \
    109109        ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) \
     110        ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT) \
    110111        ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \
    111112        ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \
     
    371372        Common/SemanticError.cc Common/UniqueName.cc \
    372373        ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
    373         ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
    374         ControlStruct/ForExprMutator.cc \
     374        ControlStruct/MLEMutator.cc ControlStruct/CaseRangeMutator.cc \
     375        ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \
    375376        ControlStruct/LabelTypeChecker.cc Designators/Processor.cc \
    376377        GenPoly/Box.cc GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \
     
    541542        ControlStruct/$(DEPDIR)/$(am__dirstamp)
    542543ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT):  \
     544        ControlStruct/$(am__dirstamp) \
     545        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     546ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT):  \
    543547        ControlStruct/$(am__dirstamp) \
    544548        ControlStruct/$(DEPDIR)/$(am__dirstamp)
     
    816820        -rm -f Common/driver_cfa_cpp-SemanticError.$(OBJEXT)
    817821        -rm -f Common/driver_cfa_cpp-UniqueName.$(OBJEXT)
     822        -rm -f ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT)
    818823        -rm -f ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT)
    819824        -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT)
     
    925930@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@
    926931@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-UniqueName.Po@am__quote@
     932@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po@am__quote@
    927933@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-ForExprMutator.Po@am__quote@
    928934@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@
     
    12061212@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-MLEMutator.obj `if test -f 'ControlStruct/MLEMutator.cc'; then $(CYGPATH_W) 'ControlStruct/MLEMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/MLEMutator.cc'; fi`
    12071213
     1214ControlStruct/driver_cfa_cpp-CaseRangeMutator.o: ControlStruct/CaseRangeMutator.cc
     1215@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-CaseRangeMutator.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.o `test -f 'ControlStruct/CaseRangeMutator.cc' || echo '$(srcdir)/'`ControlStruct/CaseRangeMutator.cc
     1216@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po
     1217@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/CaseRangeMutator.cc' object='ControlStruct/driver_cfa_cpp-CaseRangeMutator.o' libtool=no @AMDEPBACKSLASH@
     1218@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1219@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.o `test -f 'ControlStruct/CaseRangeMutator.cc' || echo '$(srcdir)/'`ControlStruct/CaseRangeMutator.cc
     1220
     1221ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj: ControlStruct/CaseRangeMutator.cc
     1222@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj `if test -f 'ControlStruct/CaseRangeMutator.cc'; then $(CYGPATH_W) 'ControlStruct/CaseRangeMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/CaseRangeMutator.cc'; fi`
     1223@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po
     1224@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='ControlStruct/CaseRangeMutator.cc' object='ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj' libtool=no @AMDEPBACKSLASH@
     1225@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1226@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj `if test -f 'ControlStruct/CaseRangeMutator.cc'; then $(CYGPATH_W) 'ControlStruct/CaseRangeMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/CaseRangeMutator.cc'; fi`
     1227
    12081228ControlStruct/driver_cfa_cpp-Mutate.o: ControlStruct/Mutate.cc
    12091229@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-Mutate.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Tpo -c -o ControlStruct/driver_cfa_cpp-Mutate.o `test -f 'ControlStruct/Mutate.cc' || echo '$(srcdir)/'`ControlStruct/Mutate.cc
  • src/Parser/ExpressionNode.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug  2 15:10:23 2016
    13 // Update Count     : 322
     12// Last Modified On : Tue Jul  5 13:41:55 2016
     13// Update Count     : 320
    1414//
    1515
     
    246246        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    247247        "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
    248         "?[?]", "FieldSel", "PFieldSel", "...",
     248        "?[?]", "FieldSel", "PFieldSel", "Range",
    249249        // monadic
    250250        "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&"
  • src/Parser/parser.cc

    rcf37a8e r00c32e9  
    10311031     631,   632,   638,   639,   640,   641,   642,   643,   644,   645,
    10321032     646,   656,   663,   665,   675,   676,   681,   683,   689,   691,
    1033      695,   696,   701,   706,   709,   711,   713,   723,   725,   736,
    1034      737,   739,   743,   744,   748,   749,   754,   755,   759,   764,
     1033     695,   696,   701,   706,   709,   711,   713,   722,   724,   735,
     1034     736,   738,   742,   743,   748,   749,   754,   755,   759,   764,
    10351035     765,   769,   771,   777,   778,   782,   784,   786,   788,   794,
    10361036     795,   799,   801,   806,   808,   810,   815,   817,   822,   824,
     
    60096009                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
    60106010                        // statement around the switch.  Statements after the initial declaration list can never be executed, and
    6011                         // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    6012                         // statement.
     6011                        // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement.
    60136012                        (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_link( sw )) ) : sw;
    60146013                }
     
    60186017
    60196018/* Line 1806 of yacc.c  */
    6020 #line 724 "parser.yy"
     6019#line 723 "parser.yy"
    60216020    { (yyval.sn) = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); }
    60226021    break;
     
    60256024
    60266025/* Line 1806 of yacc.c  */
    6027 #line 726 "parser.yy"
     6026#line 725 "parser.yy"
    60286027    {
    60296028                        StatementNode *sw = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) );
     
    60356034
    60366035/* Line 1806 of yacc.c  */
    6037 #line 736 "parser.yy"
     6036#line 735 "parser.yy"
    60386037    { (yyval.en) = (yyvsp[(1) - (1)].en); }
    60396038    break;
     
    60426041
    60436042/* Line 1806 of yacc.c  */
    6044 #line 738 "parser.yy"
     6043#line 737 "parser.yy"
    60456044    { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }
    60466045    break;
    60476046
    6048   case 162:
    6049 
    6050 /* Line 1806 of yacc.c  */
    6051 #line 743 "parser.yy"
    6052     { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(1) - (1)].en), 0 ); }
    6053     break;
    6054 
    60556047  case 163:
    60566048
    60576049/* Line 1806 of yacc.c  */
    60586050#line 744 "parser.yy"
    6059     { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_link( new StatementNode( StatementNode::Case, (yyvsp[(3) - (3)].en), 0 ) ) ); }
     6051    { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( (yyvsp[(1) - (3)].en) ))->set_link( (yyvsp[(3) - (3)].en) ) ); }
    60606052    break;
    60616053
     
    60646056/* Line 1806 of yacc.c  */
    60656057#line 748 "parser.yy"
    6066     { (yyval.sn) = (yyvsp[(2) - (3)].sn); }
     6058    { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(2) - (3)].en), 0 ); }
    60676059    break;
    60686060
     
    94259417
    94269418/* Line 1806 of yacc.c  */
    9427 #line 9428 "Parser/parser.cc"
     9419#line 9420 "Parser/parser.cc"
    94289420      default: break;
    94299421    }
  • src/Parser/parser.yy

    rcf37a8e r00c32e9  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:28:18 2016
    13 // Update Count     : 1672
     12// Last Modified On : Sat Jul 23 17:01:30 2016
     13// Update Count     : 1668
    1414//
    1515
     
    150150%type<sn> block_item_list                               block_item
    151151%type<sn> case_clause
    152 %type<en> case_value
    153 %type<sn> case_value_list                               case_label                                      case_label_list
     152%type<en> case_value                                    case_value_list
     153%type<sn> case_label                                    case_label_list
    154154%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    155155%type<pn> handler_list                                  handler_clause                          finally_clause
     
    717717                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
    718718                        // statement around the switch.  Statements after the initial declaration list can never be executed, and
    719                         // therefore, are removed from the grammar even though C allows it. The change also applies to choose
    720                         // statement.
     719                        // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement.
    721720                        $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;
    722721                }
     
    741740
    742741case_value_list:                                                                                // CFA
    743         case_value                                                                      { $$ = new StatementNode( StatementNode::Case, $1, 0 ); }
    744         | case_value_list ',' case_value                        { $$ = (StatementNode *)($1->set_link( new StatementNode( StatementNode::Case, $3, 0 ) ) ); }
     742        case_value
     743        | case_value_list ',' case_value
     744                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( $1 ))->set_link( $3 ) ); }
    745745        ;
    746746
    747747case_label:                                                                                             // CFA
    748         CASE case_value_list ':'                                        { $$ = $2; }
     748        CASE case_value_list ':'                                        { $$ = new StatementNode( StatementNode::Case, $2, 0 ); }
    749749        | DEFAULT ':'                                                           { $$ = new StatementNode( StatementNode::Default ); }
    750750                // A semantic check is required to ensure only one default clause per switch/choose statement.
  • src/SymTab/AddVisit.h

    rcf37a8e r00c32e9  
    1010// Created On       : Sun May 17 16:14:32 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:22:01 2016
    13 // Update Count     : 9
     12// Last Modified On : Tue Jul 12 17:46:33 2016
     13// Update Count     : 6
    1414//
    1515
     
    3333        template< typename Visitor >
    3434        inline void addVisit(SwitchStmt *switchStmt, Visitor &visitor) {
    35                 addVisitStatementList( switchStmt->get_statements(), visitor );
     35                addVisitStatementList( switchStmt->get_branches(), visitor );
    3636                maybeAccept( switchStmt->get_condition(), visitor );
    3737        }
  • src/SynTree/AddStmtVisitor.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Wed Jun 22 12:11:17 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:23:47 2016
    13 // Update Count     : 16
     12// Last Modified On : Tue Jul 12 17:49:59 2016
     13// Update Count     : 12
    1414//
    1515
     
    7171
    7272void AddStmtVisitor::visit(SwitchStmt *switchStmt) {
    73         visitStatementList( switchStmt->get_statements() );
     73        visitStatementList( switchStmt->get_branches() );
    7474        maybeAccept( switchStmt->get_condition(), *this );
    7575}
  • src/SynTree/Expression.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  3 17:06:51 2016
    13 // Update Count     : 45
     12// Last Modified On : Mon Jun 13 16:03:39 2016
     13// Update Count     : 42
    1414//
    1515
     
    528528}
    529529
    530 RangeExpr::RangeExpr( ConstantExpr *low, ConstantExpr *high ) : low( low ), high( high ) {}
    531 RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {}
    532 void RangeExpr::print( std::ostream &os, int indent ) const {
    533         os << std::string( indent, ' ' ) << "Range Expression: ";
    534         low->print( os, indent );
    535         os << " ... ";
    536         high->print( os, indent );
    537 }
    538530
    539531std::ostream & operator<<( std::ostream & out, Expression * expr ) {
  • src/SynTree/Expression.h

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  3 17:08:44 2016
    13 // Update Count     : 27
     12// Last Modified On : Mon Jul  4 14:45:32 2016
     13// Update Count     : 23
    1414//
    1515
     
    1818
    1919#include <map>
    20 #include <memory>
    2120#include "SynTree.h"
    2221#include "Visitor.h"
     
    635634};
    636635
    637 class RangeExpr : public Expression {
    638   public:
    639         RangeExpr( ConstantExpr *low, ConstantExpr *high );
    640         RangeExpr( const RangeExpr &other );
    641 
    642         ConstantExpr * get_low() const { return low.get(); }
    643         ConstantExpr * get_high() const { return high.get(); }
    644         RangeExpr * set_low( ConstantExpr *low ) { RangeExpr::low.reset( low ); return this; }
    645         RangeExpr * set_high( ConstantExpr *high ) { RangeExpr::high.reset( high ); return this; }
    646 
    647         virtual RangeExpr *clone() const { return new RangeExpr( *this ); }
    648         virtual void accept( Visitor &v ) { v.visit( this ); }
    649         virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    650         virtual void print( std::ostream &os, int indent = 0 ) const;
    651   private:
    652         std::unique_ptr<ConstantExpr> low, high;
    653 };
    654 
    655636std::ostream & operator<<( std::ostream & out, Expression * expr );
    656637
  • src/SynTree/Mutator.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:23:21 2016
    13 // Update Count     : 19
     12// Last Modified On : Tue Jul 12 17:51:19 2016
     13// Update Count     : 17
    1414//
    1515
     
    126126Statement *Mutator::mutate( SwitchStmt *switchStmt ) {
    127127        switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
    128         mutateAll( switchStmt->get_statements(), *this );
     128        mutateAll( switchStmt->get_branches(), *this );
    129129        return switchStmt;
    130130}
     
    349349        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
    350350        return compLitExpr;
    351 }
    352 
    353 Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
    354         rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
    355         rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
    356         return rangeExpr;
    357351}
    358352
  • src/SynTree/Mutator.h

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  3 16:59:45 2016
    13 // Update Count     : 12
     12// Last Modified On : Tue Jul 12 17:51:43 2016
     13// Update Count     : 11
    1414//
    1515#include <cassert>
     
    7878        virtual Expression* mutate( UntypedValofExpr *valofExpr );
    7979        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );
    80         virtual Expression* mutate( RangeExpr *rangeExpr );
    8180
    8281        virtual Type* mutate( VoidType *basicType );
  • src/SynTree/Statement.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:25:20 2016
    13 // Update Count     : 61
     12// Last Modified On : Tue Jul 12 17:52:32 2016
     13// Update Count     : 55
    1414//
    1515
     
    143143}
    144144
    145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_statements ):
    146         Statement( _labels ), condition( _condition ), statements( _statements ) {
     145SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ):
     146        Statement( _labels ), condition( _condition ), branches( _branches ) {
    147147}
    148148
    149149SwitchStmt::SwitchStmt( const SwitchStmt & other ):
    150150        Statement( other ), condition( maybeClone( other.condition ) ) {
    151         cloneAll( other.statements, statements );
     151        cloneAll( other.branches, branches );
    152152}
    153153
    154154SwitchStmt::~SwitchStmt() {
    155155        delete condition;
    156         // destroy statements
    157 }
     156        // destroy branches
     157}
     158
     159void SwitchStmt::add_case( CaseStmt *c ) {}
    158160
    159161void SwitchStmt::print( std::ostream &os, int indent ) const {
     
    162164        os << endl;
    163165
    164         // statements
     166        // branches
    165167        std::list<Statement *>::const_iterator i;
    166         for ( i = statements.begin(); i != statements.end(); i++)
     168        for ( i = branches.begin(); i != branches.end(); i++)
    167169                (*i)->print( os, indent + 4 );
    168170
    169         //for_each( statements.begin(), statements.end(), mem_fun( bind1st(&Statement::print ), os ));
     171        //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os ));
    170172}
    171173
     
    185187}
    186188
    187 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) {
    188         return new CaseStmt( labels, 0, stmts, true );
     189CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> branches ) {
     190        return new CaseStmt( labels, 0, branches, true );
    189191}
    190192
  • src/SynTree/Statement.h

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:26:02 2016
    13 // Update Count     : 64
     12// Last Modified On : Tue Jul 12 17:53:29 2016
     13// Update Count     : 47
    1414//
    1515
     
    129129class SwitchStmt : public Statement {
    130130  public:
    131         SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements );
     131        SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );
    132132        SwitchStmt( const SwitchStmt &other );
    133133        virtual ~SwitchStmt();
     
    136136        void set_condition( Expression *newValue ) { condition = newValue; }
    137137
    138         std::list<Statement *> & get_statements() { return statements; }
     138        std::list<Statement *> & get_branches() { return branches; }
     139        void add_case( CaseStmt * );
    139140
    140141        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    145146  private:
    146147        Expression * condition;
    147         std::list<Statement *> statements;
     148        std::list<Statement *> branches; // should be list of CaseStmt
    148149};
    149150
    150151class CaseStmt : public Statement {
    151152  public:
    152         CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
     153        CaseStmt( std::list<Label> labels, Expression *conditions,
     154              std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);
    153155        CaseStmt( const CaseStmt &other );
    154156        virtual ~CaseStmt();
    155157
    156         static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() );
     158        static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(),
     159                std::list<Statement *> stmts = std::list<Statement *>() );
    157160
    158161        bool isDefault() const { return _isDefault; }
  • src/SynTree/SynTree.h

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  3 17:02:34 2016
    13 // Update Count     : 7
     12// Last Modified On : Tue Jul 12 17:54:02 2016
     13// Update Count     : 6
    1414//
    1515
     
    8383class UntypedValofExpr;
    8484class CompoundLiteralExpr;
    85 class RangeExpr;
    8685
    8786class Type;
  • src/SynTree/Visitor.cc

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:24:25 2016
    13 // Update Count     : 21
     12// Last Modified On : Tue Jul 12 17:54:39 2016
     13// Update Count     : 19
    1414//
    1515
     
    109109void Visitor::visit( SwitchStmt *switchStmt ) {
    110110        maybeAccept( switchStmt->get_condition(), *this );
    111         acceptAll( switchStmt->get_statements(), *this );
     111        acceptAll( switchStmt->get_branches(), *this );
    112112}
    113113
     
    296296        maybeAccept( compLitExpr->get_type(), *this );
    297297        maybeAccept( compLitExpr->get_initializer(), *this );
    298 }
    299 
    300 void Visitor::visit( RangeExpr *rangeExpr ) {
    301         maybeAccept( rangeExpr->get_low(), *this );
    302         maybeAccept( rangeExpr->get_high(), *this );
    303298}
    304299
  • src/SynTree/Visitor.h

    rcf37a8e r00c32e9  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug  3 17:01:50 2016
    13 // Update Count     : 9
     12// Last Modified On : Tue Jul 12 17:55:09 2016
     13// Update Count     : 8
    1414//
    1515
     
    7878        virtual void visit( UntypedValofExpr *valofExpr );
    7979        virtual void visit( CompoundLiteralExpr *compLitExpr );
    80         virtual void visit( RangeExpr *rangeExpr );
    8180
    8281        virtual void visit( VoidType *basicType );
  • src/tests/switch.c

    rcf37a8e r00c32e9  
    1010// Created On       : Tue Jul 12 06:50:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug  4 11:44:29 2016
    13 // Update Count     : 31
     12// Last Modified On : Sat Jul 30 14:41:32 2016
     13// Update Count     : 30
    1414//
    1515
     
    3939          case 4:
    4040                j = 0;
    41         }
    42 
    43         switch ( i ) {
    44           case 1, 2, 3:
    45                 switch ( i ) {
    46                   case 2, 3, 4:
    47                         7;
    48                 }
    4941        }
    5042
Note: See TracChangeset for help on using the changeset viewer.