Changes in / [4819cac:f9cebb5]


Ignore:
Location:
src
Files:
2 added
33 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r4819cac rf9cebb5  
    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                genAttributes( objectDecl->get_attributes() );
     
    164164        }
    165165
    166         void CodeGenerator::handleAggregate( AggregateDecl * aggDecl ) {
     166        void CodeGenerator::handleAggregate( AggregateDecl *aggDecl ) {
    167167                if ( aggDecl->get_name() != "" )
    168168                        output << aggDecl->get_name();
    169169
    170                 std::list< Declaration * > & memb = aggDecl->get_members();
     170                std::list< Declaration * > &memb = aggDecl->get_members();
    171171                if ( ! memb.empty() ) {
    172172//              if ( aggDecl->has_body() ) {
    173 //                      std::list< Declaration * > & memb = aggDecl->get_members();
     173//                      std::list< Declaration * > &memb = aggDecl->get_members();
    174174                        output << " {" << endl;
    175175
     
    187187        }
    188188
    189         void CodeGenerator::visit( StructDecl * structDecl ) {
     189        void CodeGenerator::visit( StructDecl *structDecl ) {
    190190                extension( structDecl );
    191191                output << "struct ";
     
    193193        }
    194194
    195         void CodeGenerator::visit( UnionDecl * unionDecl ) {
     195        void CodeGenerator::visit( UnionDecl *unionDecl ) {
    196196                extension( unionDecl );
    197197                output << "union ";
     
    199199        }
    200200
    201         void CodeGenerator::visit( EnumDecl * enumDecl ) {
     201        void CodeGenerator::visit( EnumDecl *enumDecl ) {
    202202                extension( enumDecl );
    203203                output << "enum ";
     
    213213                        cur_indent += CodeGenerator::tabsize;
    214214                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    215                                 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i );
     215                                ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i );
    216216                                assert( obj );
    217217                                output << indent << mangleName( obj );
     
    229229        }
    230230
    231         void CodeGenerator::visit( TraitDecl * traitDecl ) {}
    232 
    233         void CodeGenerator::visit( TypedefDecl * typeDecl ) {
     231        void CodeGenerator::visit( TraitDecl *traitDecl ) {}
     232
     233        void CodeGenerator::visit( TypedefDecl *typeDecl ) {
    234234                assert( false && "Typedefs are removed and substituted in earlier passes." );
    235235                //output << "typedef ";
     
    237237        }
    238238
    239         void CodeGenerator::visit( TypeDecl * typeDecl ) {
     239        void CodeGenerator::visit( TypeDecl *typeDecl ) {
    240240                // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
    241241                // still to be done
     
    265265        }
    266266
    267         void CodeGenerator::visit( SingleInit * init ) {
     267        void CodeGenerator::visit( SingleInit *init ) {
    268268                printDesignators( init->get_designators() );
    269269                init->get_value()->accept( *this );
    270270        }
    271271
    272         void CodeGenerator::visit( ListInit * init ) {
     272        void CodeGenerator::visit( ListInit *init ) {
    273273                printDesignators( init->get_designators() );
    274274                output << "{ ";
     
    278278                } else {
    279279                        genCommaList( init->begin(), init->end() );
    280                 } // if
     280                }
    281281                output << " }";
    282282        }
    283283
    284         void CodeGenerator::visit( Constant * constant ) {
     284        void CodeGenerator::visit( Constant *constant ) {
    285285                output << constant->get_value() ;
    286286        }
    287287
    288288        //*** Expressions
    289         void CodeGenerator::visit( ApplicationExpr * applicationExpr ) {
     289        void CodeGenerator::visit( ApplicationExpr *applicationExpr ) {
    290290                extension( applicationExpr );
    291                 if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {
     291                if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {
    292292                        OperatorInfo opInfo;
    293293                        if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( varExpr->get_var()->get_name(), opInfo ) ) {
     
    301301                                        {
    302302                                                assert( arg != applicationExpr->get_args().end() );
    303                                                 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
     303                                                if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {
    304304                                                        // remove & from first assignment/ctor argument
    305305                                                        *arg = addrExpr->get_arg();
    306306                                                } else {
    307307                                                        // no address-of operator, so must be a pointer - add dereference
    308                                                         UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );
     308                                                        UntypedExpr *newExpr = new UntypedExpr( new NameExpr( "*?" ) );
    309309                                                        newExpr->get_args().push_back( *arg );
    310310                                                        assert( (*arg)->get_results().size() == 1 );
     
    354354                                                // no constructors with 0 or more than 2 parameters
    355355                                                assert( false );
    356                                         } // if
     356                                        }
    357357                                        break;
    358358
     
    403403        }
    404404
    405         void CodeGenerator::visit( UntypedExpr * untypedExpr ) {
     405        void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
    406406                extension( untypedExpr );
    407                 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
     407                if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
    408408                        OperatorInfo opInfo;
    409409                        if ( operatorLookup( nameExpr->get_name(), opInfo ) ) {
     
    474474                                } // switch
    475475                        } else {
    476                                 if ( nameExpr->get_name() == "..." ) { // case V1 ... V2 or case V1~V2
     476                                if ( nameExpr->get_name() == "Range" ) { // case V1 ... V2 or case V1~V2
    477477                                        assert( untypedExpr->get_args().size() == 2 );
    478478                                        (*untypedExpr->get_args().begin())->accept( *this );
     
    494494        }
    495495
    496         void CodeGenerator::visit( NameExpr * nameExpr ) {
     496        void CodeGenerator::visit( NameExpr *nameExpr ) {
    497497                extension( nameExpr );
    498498                OperatorInfo opInfo;
     
    505505        }
    506506
    507         void CodeGenerator::visit( AddressExpr * addressExpr ) {
     507        void CodeGenerator::visit( AddressExpr *addressExpr ) {
    508508                extension( addressExpr );
    509509                output << "(&";
    510510                // this hack makes sure that we don't convert "constant_zero" to "0" if we're taking its address
    511                 if ( VariableExpr * variableExpr = dynamic_cast< VariableExpr* >( addressExpr->get_arg() ) ) {
     511                if ( VariableExpr *variableExpr = dynamic_cast< VariableExpr* >( addressExpr->get_arg() ) ) {
    512512                        output << mangleName( variableExpr->get_var() );
    513513                } else {
     
    517517        }
    518518
    519         void CodeGenerator::visit( CastExpr * castExpr ) {
     519        void CodeGenerator::visit( CastExpr *castExpr ) {
    520520                extension( castExpr );
    521521                output << "(";
     
    535535        }
    536536
    537         void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) {
     537        void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) {
    538538                assert( false );
    539539        }
    540540
    541         void CodeGenerator::visit( MemberExpr * memberExpr ) {
     541        void CodeGenerator::visit( MemberExpr *memberExpr ) {
    542542                extension( memberExpr );
    543543                memberExpr->get_aggregate()->accept( *this );
     
    545545        }
    546546
    547         void CodeGenerator::visit( VariableExpr * variableExpr ) {
     547        void CodeGenerator::visit( VariableExpr *variableExpr ) {
    548548                extension( variableExpr );
    549549                OperatorInfo opInfo;
     
    555555        }
    556556
    557         void CodeGenerator::visit( ConstantExpr * constantExpr ) {
     557        void CodeGenerator::visit( ConstantExpr *constantExpr ) {
    558558                assert( constantExpr->get_constant() );
    559559                extension( constantExpr );
     
    561561        }
    562562
    563         void CodeGenerator::visit( SizeofExpr * sizeofExpr ) {
     563        void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
    564564                extension( sizeofExpr );
    565565                output << "sizeof(";
     
    572572        }
    573573
    574         void CodeGenerator::visit( AlignofExpr * alignofExpr ) {
     574        void CodeGenerator::visit( AlignofExpr *alignofExpr ) {
    575575                // use GCC extension to avoid bumping std to C11
    576576                extension( alignofExpr );
     
    584584        }
    585585
    586         void CodeGenerator::visit( UntypedOffsetofExpr * offsetofExpr ) {
     586        void CodeGenerator::visit( UntypedOffsetofExpr *offsetofExpr ) {
    587587                assert( false && "UntypedOffsetofExpr should not reach code generation." );
    588588        }
    589589
    590         void CodeGenerator::visit( OffsetofExpr * offsetofExpr ) {
     590        void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) {
    591591                // use GCC builtin
    592592                output << "__builtin_offsetof(";
     
    596596        }
    597597
    598         void CodeGenerator::visit( OffsetPackExpr * offsetPackExpr ) {
     598        void CodeGenerator::visit( OffsetPackExpr *offsetPackExpr ) {
    599599                assert( false && "OffsetPackExpr should not reach code generation." );
    600600        }
    601601
    602         void CodeGenerator::visit( LogicalExpr * logicalExpr ) {
     602        void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
    603603                extension( logicalExpr );
    604604                output << "(";
     
    613613        }
    614614
    615         void CodeGenerator::visit( ConditionalExpr * conditionalExpr ) {
     615        void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
    616616                extension( conditionalExpr );
    617617                output << "(";
     
    624624        }
    625625
    626         void CodeGenerator::visit( CommaExpr * commaExpr ) {
     626        void CodeGenerator::visit( CommaExpr *commaExpr ) {
    627627                extension( commaExpr );
    628628                output << "(";
     
    633633        }
    634634
    635         void CodeGenerator::visit( TupleExpr * tupleExpr ) {}
    636 
    637         void CodeGenerator::visit( TypeExpr * typeExpr ) {}
    638 
    639         void CodeGenerator::visit( AsmExpr * asmExpr ) {
     635        void CodeGenerator::visit( TupleExpr *tupleExpr ) {}
     636
     637        void CodeGenerator::visit( TypeExpr *typeExpr ) {}
     638
     639        void CodeGenerator::visit( AsmExpr *asmExpr ) {
    640640                if ( asmExpr->get_inout() ) {
    641641                        output << "[ ";
     
    650650
    651651        //*** Statements
    652         void CodeGenerator::visit( CompoundStmt * compoundStmt ) {
     652        void CodeGenerator::visit( CompoundStmt *compoundStmt ) {
    653653                std::list<Statement*> ks = compoundStmt->get_kids();
    654654                output << "{" << endl;
     
    664664                                output << endl;
    665665                        } // if
    666                 } // for
     666                }
    667667                cur_indent -= CodeGenerator::tabsize;
    668668
     
    670670        }
    671671
    672         void CodeGenerator::visit( ExprStmt * exprStmt ) {
     672        void CodeGenerator::visit( ExprStmt *exprStmt ) {
    673673                assert( exprStmt );
    674674                // cast the top-level expression to void to reduce gcc warnings.
     
    678678        }
    679679
    680         void CodeGenerator::visit( AsmStmt * asmStmt ) {
     680        void CodeGenerator::visit( AsmStmt *asmStmt ) {
    681681                output << "asm ";
    682682                if ( asmStmt->get_voltile() ) output << "volatile ";
     
    701701        }
    702702
    703         void CodeGenerator::visit( IfStmt * ifStmt ) {
     703        void CodeGenerator::visit( IfStmt *ifStmt ) {
    704704                output << "if ( ";
    705705                ifStmt->get_condition()->accept( *this );
     
    714714        }
    715715
    716         void CodeGenerator::visit( SwitchStmt * switchStmt ) {
     716        void CodeGenerator::visit( SwitchStmt *switchStmt ) {
    717717                output << "switch ( " ;
    718718                switchStmt->get_condition()->accept( *this );
     
    721721                output << "{" << std::endl;
    722722                cur_indent += CodeGenerator::tabsize;
    723                 acceptAll( switchStmt->get_statements(), *this );
     723
     724                acceptAll( switchStmt->get_branches(), *this );
     725
    724726                cur_indent -= CodeGenerator::tabsize;
     727
    725728                output << indent << "}";
    726729        }
    727730
    728         void CodeGenerator::visit( CaseStmt * caseStmt ) {
     731        void CodeGenerator::visit( CaseStmt *caseStmt ) {
    729732                output << indent;
    730733                if ( caseStmt->isDefault()) {
     
    747750        }
    748751
    749         void CodeGenerator::visit( BranchStmt * branchStmt ) {
     752        void CodeGenerator::visit( BranchStmt *branchStmt ) {
    750753                switch ( branchStmt->get_type()) {
    751754                  case BranchStmt::Goto:
     
    770773
    771774
    772         void CodeGenerator::visit( ReturnStmt * returnStmt ) {
     775        void CodeGenerator::visit( ReturnStmt *returnStmt ) {
    773776                output << "return ";
    774777                maybeAccept( returnStmt->get_expr(), *this );
     
    776779        }
    777780
    778         void CodeGenerator::visit( WhileStmt * whileStmt ) {
     781        void CodeGenerator::visit( WhileStmt *whileStmt ) {
    779782                if ( whileStmt->get_isDoWhile() ) {
    780783                        output << "do" ;
     
    798801        }
    799802
    800         void CodeGenerator::visit( ForStmt * forStmt ) {
     803        void CodeGenerator::visit( ForStmt *forStmt ) {
    801804                // initialization is always hoisted, so don't bother doing anything with that
    802805                output << "for (;";
     
    820823        }
    821824
    822         void CodeGenerator::visit( NullStmt * nullStmt ) {
     825        void CodeGenerator::visit( NullStmt *nullStmt ) {
    823826                //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() );
    824827                output << "/* null statement */ ;";
    825828        }
    826829
    827         void CodeGenerator::visit( DeclStmt * declStmt ) {
     830        void CodeGenerator::visit( DeclStmt *declStmt ) {
    828831                declStmt->get_decl()->accept( *this );
    829832
     
    833836        }
    834837
    835         void CodeGenerator::handleStorageClass( Declaration * decl ) {
     838        void CodeGenerator::handleStorageClass( Declaration *decl ) {
    836839                switch ( decl->get_storageClass() ) {
    837840                  case DeclarationNode::Extern:
  • src/ControlStruct/MLEMutator.cc

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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
     
    8383}
    8484
    85 // CommaExprNode *ExpressionNode::add_to_list( ExpressionNode *exp ) {
    86 //      return new CommaExprNode( this, exp );
    87 // }
     85CommaExprNode *ExpressionNode::add_to_list( ExpressionNode *exp ) {
     86        return new CommaExprNode( this, exp );
     87}
    8888
    8989//##############################################################################
     
    246246        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    247247        "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
    248         "?[?]", "FieldSel", "PFieldSel", "...",
     248        "?[?]", "FieldSel", "PFieldSel", "Range",
    249249        // monadic
    250250        "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&"
     
    616616}
    617617
    618 // CommaExprNode *CommaExprNode::add_to_list( ExpressionNode *exp ) {
    619 //      add_arg( exp );
    620 //
    621 //      return this;
    622 // }
     618CommaExprNode *CommaExprNode::add_to_list( ExpressionNode *exp ) {
     619        add_arg( exp );
     620
     621        return this;
     622}
    623623
    624624CommaExprNode::CommaExprNode( const CommaExprNode &other ) : CompositeExprNode( other ) {
  • src/Parser/ParseNode.h

    r4819cac rf9cebb5  
    7777        virtual ExpressionNode *clone() const = 0;
    7878
    79         // virtual CommaExprNode *add_to_list( ExpressionNode * );
     79        virtual CommaExprNode *add_to_list( ExpressionNode * );
    8080
    8181        ExpressionNode *get_argName() const { return argName; }
     
    299299        CommaExprNode( const CommaExprNode &other );
    300300
    301         // virtual CommaExprNode *add_to_list( ExpressionNode * );
     301        virtual CommaExprNode *add_to_list( ExpressionNode * );
    302302        virtual CommaExprNode *clone() const { return new CommaExprNode( *this ); }
    303303};
     
    485485        std::string get_target() const;
    486486
    487         // StatementNode *add_controlexp( ExpressionNode * );
     487        StatementNode *add_controlexp( ExpressionNode * );
    488488        StatementNode *append_block( StatementNode * );
    489489        StatementNode *append_last_case( StatementNode * );
  • src/Parser/StatementNode.cc

    r4819cac rf9cebb5  
    107107}
    108108
    109 // StatementNode *StatementNode::add_controlexp( ExpressionNode *e ) {
    110 //      if ( control && e )
    111 //              control->add_to_list( e ); // xxx - check this
    112 //      return this;
    113 // }
     109StatementNode *StatementNode::add_controlexp( ExpressionNode *e ) {
     110        if ( control && e )
     111                control->add_to_list( e ); // xxx - check this
     112        return this;
     113}
    114114
    115115StatementNode *StatementNode::append_block( StatementNode *stmt ) {
  • src/Parser/parser.cc

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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
     
    529529}
    530530
    531 RangeExpr::RangeExpr( ConstantExpr *low, ConstantExpr *high ) : low( low ), high( high ) {}
    532 RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {}
    533 void RangeExpr::print( std::ostream &os, int indent ) const {
    534         os << std::string( indent, ' ' ) << "Range Expression: ";
    535         low->print( os, indent );
    536         os << " ... ";
    537         high->print( os, indent );
    538 }
    539531
    540532std::ostream & operator<<( std::ostream & out, Expression * expr ) {
  • src/SynTree/Expression.h

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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

    r4819cac rf9cebb5  
    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/examples/gc_no_raii/bug-repro/return_template.c

    r4819cac rf9cebb5  
    55};
    66
    7 forall(otype T) void ?{}(wrap(T)* this);
    8 forall(otype T) void ?{}(wrap(T)* this, wrap(T)* rhs);
    9 forall(otype T) void ^?{}(wrap(T)* this);
    10 forall(otype T) void ?=?(wrap(T)* this, wrap(T)* rhs);
    11 
    127forall(otype T)
    13 wrap(T) test()
     8static inline wrap(T) test()
    149{
    1510        wrap(T) tester;
  • src/examples/gc_no_raii/src/gc.h

    r4819cac rf9cebb5  
    77static inline gcpointer(T) gcmalloc()
    88{
    9     gcpointer(T) ptr;
    10     void* address = gc_allocate(sizeof(T));
    11     (&ptr){ address };
    12     ctor(&ptr, address);
    13     gc_conditional_collect();
    14     return ptr;
     9    gcpointer(T) test;
     10    // ctor(&test, gc_allocate(sizeof(T)));
     11    // gc_conditional_collect();
     12    return test;
    1513}
  • src/examples/gc_no_raii/src/gcpointers.c

    r4819cac rf9cebb5  
    11#include "gcpointers.h"
    22
    3 // #include "gc.h"
     3#include "gc.h"
    44#include "internal/collector.h"
    55#include "internal/object_header.h"
  • src/examples/gc_no_raii/src/gcpointers.h

    r4819cac rf9cebb5  
    1010};
    1111
    12 void ?{}(gcpointer_t* this);
    13 void ?{}(gcpointer_t* this, void* address);
    14 void ?{}(gcpointer_t* this, gcpointer_t other);
    15 void ^?{}(gcpointer_t* this);
    16 gcpointer_t* ?=?(gcpointer_t this, gcpointer_t rhs);
     12void gcpointer_ctor(gcpointer_t* this);
     13void gcpointer_ctor(gcpointer_t* this, void* address);
     14void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other);
     15void gcpointer_dtor(gcpointer_t* this);
     16gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t* rhs);
    1717
    1818//Logical operators
     
    2727};
    2828
    29 //
    30 forall(otype T) void ?{}(gcpointer(T)* this);
    31 forall(otype T) void ?{}(gcpointer(T)* this, void* address);
    32 forall(otype T) void ctor(gcpointer(T)* this, void* address);
    33 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other);
    34 forall(otype T) void ^?{}(gcpointer(T)* this);
    35 forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs);
     29forall(otype T)
     30static inline void ctor(gcpointer(T)* this)
     31{
     32        gcpointer_ctor(&this->internal);
     33}
    3634
     35// forall(otype T)
     36// static inline void ctor(gcpointer(T)* this, int null)
     37// {
     38//      gcpointer_ctor(&this->internal, NULL);
     39// }
    3740
    38 forall(otype T) T *?(gcpointer(T) this);
     41forall(otype T)
     42static inline void ctor(gcpointer(T)* this, void* address)
     43{
     44        gcpointer_ctor(&this->internal, address);
     45}
     46
     47forall(otype T)
     48static inline void ctor(gcpointer(T)* this, gcpointer(T)* other)
     49{
     50        gcpointer_ctor(&this->internal, other);
     51}
     52
     53forall(otype T)
     54static inline void dtor(gcpointer(T)* this)
     55{
     56        gcpointer_dtor(&this->internal);
     57}
     58
     59forall(otype T)
     60static inline gcpointer(T)* ?=?(gcpointer(T)* this, gcpointer(T)* rhs)
     61{
     62        gcpointer_assign(&this->internal, &rhs->internal);
     63        return this;
     64}
     65
     66forall(otype T)
     67static inline T *?(gcpointer(T) this)
     68{
     69        return *(T*)this.internal.ptr;
     70}
    3971
    4072//Logical operators
    41 forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs);
    42 forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs);
     73forall(otype T)
     74static inline int ?!=?(gcpointer(T) this, gcpointer(T) rhs)
     75{
     76        return this.internal.ptr != rhs.internal.ptr;
     77}
     78
     79forall(otype T)
     80static inline int ?==?(gcpointer(T) this, gcpointer(T) rhs)
     81{
     82        return !(this == rhs);
     83}
     84
     85forall(otype T)
     86extern struct gcpointer(T) 0;
  • src/examples/gc_no_raii/src/internal/memory_pool.h

    r4819cac rf9cebb5  
    33extern "C" {
    44#include <stdbool.h>
    5 #include <stddef.h>
    65#include <stdint.h>
    76}
  • src/examples/gc_no_raii/src/internal/state.h

    r4819cac rf9cebb5  
    11#pragma once
    22
    3 #ifdef __cforall
    4 extern "C" {
    5 #endif
    63#include <stddef.h>
    74#include <stdint.h>
    8 #ifdef __cforall
    9 }
    10 #endif
    11 #include <vector>
    125
    136#include "tools.h"
     7#include "vector.h"
    148
    159typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t;
  • src/examples/gc_no_raii/src/tools/worklist.h

    r4819cac rf9cebb5  
    1010#endif
    1111
    12 #include <vector>
     12#include "vector.h"
    1313
    1414typedef vector(intptr_t*, heap_allocator(intptr_t*)) worklist_t;
  • src/examples/gc_no_raii/test/badlll.c

    r4819cac rf9cebb5  
    77};
    88
    9 void ?{}(List_t* this);
    10 List_t* ?=?(List_t* this, List_t* rhs);
    11 
    129typedef gcpointer(List_t) LLL;
    1310
    1411#define MAX (1024 * 1024)
    1512
    16 // LLL buildLLL(int sz)
    17 void bla()
     13LLL buildLLL(int sz)
    1814{
    1915        int i;
    20         // LLL ll0;//, lll, llc;
    21 //
    22 //      ll0 = gcmalloc();
    23 //      ll0->val = 0;
    24 //      lll = ll0;
    25 //
    26 //      for (i = 1; i < sz; i++)
    27 //      {
    28 //              llc = gcmalloc();
    29 //              llc->val = i;
    30 //              lll->next = llc;
    31 //              lll = llc;
    32 //      }
    33 //
    34         // return ll0;
     16        LLL ll0, lll, llc;
     17
     18        ll0 = gcmalloc();
     19        ll0->val = 0;
     20        lll = ll0;
     21
     22        for (i = 1; i < sz; i++)
     23        {
     24                llc = gcmalloc();
     25                llc->val = i;
     26                lll->next = llc;
     27                lll = llc;
     28        }
     29
     30        return ll0;
    3531}
    36 //
    37 // void testLLL(LLL lll)
    38 // {
    39 //      unsigned char *counted;
    40 //
    41 //      counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));
    42 //      while (lll)
    43 //      {
    44 //              counted[lll->val]++;
    45 //              if (counted[lll->val] > 1)
    46 //              {
    47 //                      fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);
    48 //                      exit(1);
    49 //              }
    50 //              lll = lll->next;
    51 //      }
    52 //
    53 //      return;
    54 // }
     32
     33void testLLL(LLL lll)
     34{
     35        unsigned char *counted;
     36
     37        counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));
     38        while (lll)
     39        {
     40                counted[lll->val]++;
     41                if (counted[lll->val] > 1)
     42                {
     43                        fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);
     44                        exit(1);
     45                }
     46                lll = lll->next;
     47        }
     48
     49        return;
     50}
    5551
    5652int main(void)
     
    5854        LLL mylll;
    5955
    60         // mylll = buildLLL(MAX);
    61         //
    62         // testLLL(mylll);
     56        mylll = buildLLL(MAX);
     57
     58        testLLL(mylll);
    6359
    6460        return 0;
  • src/examples/gc_no_raii/test/gctest.c

    r4819cac rf9cebb5  
    77int main() {
    88        sout | "Bonjour au monde!\n";
    9 
    10         gcpointer(int) anInt = gcmalloc();
    119}
  • src/tests/switch.c

    r4819cac rf9cebb5  
    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.