Changes in / [cf37a8e:00c32e9]
- Location:
- src
- Files:
-
- 2 added
- 22 edited
-
CodeGen/CodeGenerator.cc (modified) (46 diffs)
-
ControlStruct/CaseRangeMutator.cc (added)
-
ControlStruct/CaseRangeMutator.h (added)
-
ControlStruct/MLEMutator.cc (modified) (3 diffs)
-
ControlStruct/Mutate.cc (modified) (4 diffs)
-
ControlStruct/module.mk (modified) (2 diffs)
-
GenPoly/DeclMutator.cc (modified) (2 diffs)
-
GenPoly/PolyMutator.cc (modified) (2 diffs)
-
Makefile.in (modified) (6 diffs)
-
Parser/ExpressionNode.cc (modified) (2 diffs)
-
Parser/parser.cc (modified) (8 diffs)
-
Parser/parser.yy (modified) (4 diffs)
-
SymTab/AddVisit.h (modified) (2 diffs)
-
SynTree/AddStmtVisitor.cc (modified) (2 diffs)
-
SynTree/Expression.cc (modified) (2 diffs)
-
SynTree/Expression.h (modified) (3 diffs)
-
SynTree/Mutator.cc (modified) (3 diffs)
-
SynTree/Mutator.h (modified) (2 diffs)
-
SynTree/Statement.cc (modified) (4 diffs)
-
SynTree/Statement.h (modified) (4 diffs)
-
SynTree/SynTree.h (modified) (2 diffs)
-
SynTree/Visitor.cc (modified) (3 diffs)
-
SynTree/Visitor.h (modified) (2 diffs)
-
tests/switch.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rcf37a8e r00c32e9 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Aug 4 11:16:21201613 // Update Count : 3 5111 // Last Modified By : 12 // Last Modified On : Sun Jul 31 08:42:18 2016 13 // Update Count : 345 14 14 // 15 15 … … 48 48 } 49 49 50 void CodeGenerator::extension( Expression * expr ) {50 void CodeGenerator::extension( Expression *expr ) { 51 51 if ( expr->get_extension() ) { 52 52 output << "__extension__ "; … … 54 54 } // extension 55 55 56 void CodeGenerator::extension( Declaration * decl ) {56 void CodeGenerator::extension( Declaration *decl ) { 57 57 if ( decl->get_extension() ) { 58 58 output << "__extension__ "; … … 73 73 } 74 74 75 ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter & printLabels ) {75 ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter &printLabels ) { 76 76 std::list< Label > & labs = *printLabels.labels; 77 77 // l.unique(); // assumes a sorted list. Why not use set? Does order matter? … … 79 79 output << l.get_name() + ": "; 80 80 printLabels.cg.genAttributes( l.get_attributes() ); 81 } // for81 } 82 82 return output; 83 83 } 84 84 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 ) 88 88 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) { 89 89 //output << std::string( init ); 90 90 } 91 91 92 CodeGenerator::CodeGenerator( std::ostream & os, char *init, int indentation, bool infunp )92 CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indentation, bool infunp ) 93 93 : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) { 94 94 //output << std::string( init ); 95 95 } 96 96 97 string mangleName( DeclarationWithType * decl ) {97 string mangleName( DeclarationWithType *decl ) { 98 98 if ( decl->get_mangleName() != "" ) { 99 99 // need to incorporate scope level in order to differentiate names for destructors … … 112 112 genCommaList( attr->get_parameters().begin(), attr->get_parameters().end() ); 113 113 output << ")"; 114 } // if114 } 115 115 output << ","; 116 } // for116 } 117 117 output << ")) "; 118 } // if118 } 119 119 } 120 120 121 121 122 122 //*** Declarations 123 void CodeGenerator::visit( FunctionDecl * functionDecl ) {123 void CodeGenerator::visit( FunctionDecl *functionDecl ) { 124 124 extension( functionDecl ); 125 125 genAttributes( functionDecl->get_attributes() ); … … 146 146 } 147 147 148 void CodeGenerator::visit( ObjectDecl * objectDecl ) {148 void CodeGenerator::visit( ObjectDecl *objectDecl ) { 149 149 extension( objectDecl ); 150 150 handleStorageClass( objectDecl ); … … 162 162 } 163 163 164 void CodeGenerator::handleAggregate( AggregateDecl * aggDecl ) {164 void CodeGenerator::handleAggregate( AggregateDecl *aggDecl ) { 165 165 if ( aggDecl->get_name() != "" ) 166 166 output << aggDecl->get_name(); 167 167 168 std::list< Declaration * > & memb = aggDecl->get_members();168 std::list< Declaration * > &memb = aggDecl->get_members(); 169 169 if ( ! memb.empty() ) { 170 170 // if ( aggDecl->has_body() ) { 171 // std::list< Declaration * > & memb = aggDecl->get_members();171 // std::list< Declaration * > &memb = aggDecl->get_members(); 172 172 output << " {" << endl; 173 173 … … 185 185 } 186 186 187 void CodeGenerator::visit( StructDecl * structDecl ) {187 void CodeGenerator::visit( StructDecl *structDecl ) { 188 188 extension( structDecl ); 189 189 output << "struct "; … … 191 191 } 192 192 193 void CodeGenerator::visit( UnionDecl * unionDecl ) {193 void CodeGenerator::visit( UnionDecl *unionDecl ) { 194 194 extension( unionDecl ); 195 195 output << "union "; … … 197 197 } 198 198 199 void CodeGenerator::visit( EnumDecl * enumDecl ) {199 void CodeGenerator::visit( EnumDecl *enumDecl ) { 200 200 extension( enumDecl ); 201 201 output << "enum "; … … 211 211 cur_indent += CodeGenerator::tabsize; 212 212 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 ); 214 214 assert( obj ); 215 215 output << indent << mangleName( obj ); … … 227 227 } 228 228 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 ) { 232 232 assert( false && "Typedefs are removed and substituted in earlier passes." ); 233 233 //output << "typedef "; … … 235 235 } 236 236 237 void CodeGenerator::visit( TypeDecl * typeDecl ) {237 void CodeGenerator::visit( TypeDecl *typeDecl ) { 238 238 // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes, 239 239 // still to be done … … 263 263 } 264 264 265 void CodeGenerator::visit( SingleInit * init ) {265 void CodeGenerator::visit( SingleInit *init ) { 266 266 printDesignators( init->get_designators() ); 267 267 init->get_value()->accept( *this ); 268 268 } 269 269 270 void CodeGenerator::visit( ListInit * init ) {270 void CodeGenerator::visit( ListInit *init ) { 271 271 printDesignators( init->get_designators() ); 272 272 output << "{ "; … … 276 276 } else { 277 277 genCommaList( init->begin_initializers(), init->end_initializers() ); 278 } // if278 } 279 279 output << " }"; 280 280 } 281 281 282 void CodeGenerator::visit( Constant * constant ) {282 void CodeGenerator::visit( Constant *constant ) { 283 283 output << constant->get_value() ; 284 284 } 285 285 286 286 //*** Expressions 287 void CodeGenerator::visit( ApplicationExpr * applicationExpr ) {287 void CodeGenerator::visit( ApplicationExpr *applicationExpr ) { 288 288 extension( applicationExpr ); 289 if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {289 if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) { 290 290 OperatorInfo opInfo; 291 291 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( varExpr->get_var()->get_name(), opInfo ) ) { … … 299 299 { 300 300 assert( arg != applicationExpr->get_args().end() ); 301 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {301 if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) { 302 302 // remove & from first assignment/ctor argument 303 303 *arg = addrExpr->get_arg(); 304 304 } else { 305 305 // 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( "*?" ) ); 307 307 newExpr->get_args().push_back( *arg ); 308 308 assert( (*arg)->get_results().size() == 1 ); … … 352 352 // no constructors with 0 or more than 2 parameters 353 353 assert( false ); 354 } // if354 } 355 355 break; 356 356 … … 401 401 } 402 402 403 void CodeGenerator::visit( UntypedExpr * untypedExpr ) {403 void CodeGenerator::visit( UntypedExpr *untypedExpr ) { 404 404 extension( untypedExpr ); 405 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {405 if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) { 406 406 OperatorInfo opInfo; 407 407 if ( operatorLookup( nameExpr->get_name(), opInfo ) ) { … … 472 472 } // switch 473 473 } else { 474 if ( nameExpr->get_name() == " ..." ) { // case V1 ... V2 or case V1~V2474 if ( nameExpr->get_name() == "Range" ) { // case V1 ... V2 or case V1~V2 475 475 assert( untypedExpr->get_args().size() == 2 ); 476 476 (*untypedExpr->get_args().begin())->accept( *this ); … … 492 492 } 493 493 494 void CodeGenerator::visit( NameExpr * nameExpr ) {494 void CodeGenerator::visit( NameExpr *nameExpr ) { 495 495 extension( nameExpr ); 496 496 OperatorInfo opInfo; … … 503 503 } 504 504 505 void CodeGenerator::visit( AddressExpr * addressExpr ) {505 void CodeGenerator::visit( AddressExpr *addressExpr ) { 506 506 extension( addressExpr ); 507 507 output << "(&"; 508 508 // 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() ) ) { 510 510 output << mangleName( variableExpr->get_var() ); 511 511 } else { … … 515 515 } 516 516 517 void CodeGenerator::visit( CastExpr * castExpr ) {517 void CodeGenerator::visit( CastExpr *castExpr ) { 518 518 extension( castExpr ); 519 519 output << "("; … … 533 533 } 534 534 535 void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) {535 void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) { 536 536 assert( false ); 537 537 } 538 538 539 void CodeGenerator::visit( MemberExpr * memberExpr ) {539 void CodeGenerator::visit( MemberExpr *memberExpr ) { 540 540 extension( memberExpr ); 541 541 memberExpr->get_aggregate()->accept( *this ); … … 543 543 } 544 544 545 void CodeGenerator::visit( VariableExpr * variableExpr ) {545 void CodeGenerator::visit( VariableExpr *variableExpr ) { 546 546 extension( variableExpr ); 547 547 OperatorInfo opInfo; … … 553 553 } 554 554 555 void CodeGenerator::visit( ConstantExpr * constantExpr ) {555 void CodeGenerator::visit( ConstantExpr *constantExpr ) { 556 556 assert( constantExpr->get_constant() ); 557 557 extension( constantExpr ); … … 559 559 } 560 560 561 void CodeGenerator::visit( SizeofExpr * sizeofExpr ) {561 void CodeGenerator::visit( SizeofExpr *sizeofExpr ) { 562 562 extension( sizeofExpr ); 563 563 output << "sizeof("; … … 570 570 } 571 571 572 void CodeGenerator::visit( AlignofExpr * alignofExpr ) {572 void CodeGenerator::visit( AlignofExpr *alignofExpr ) { 573 573 // use GCC extension to avoid bumping std to C11 574 574 extension( alignofExpr ); … … 582 582 } 583 583 584 void CodeGenerator::visit( UntypedOffsetofExpr * offsetofExpr ) {584 void CodeGenerator::visit( UntypedOffsetofExpr *offsetofExpr ) { 585 585 assert( false && "UntypedOffsetofExpr should not reach code generation." ); 586 586 } 587 587 588 void CodeGenerator::visit( OffsetofExpr * offsetofExpr ) {588 void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) { 589 589 // use GCC builtin 590 590 output << "__builtin_offsetof("; … … 594 594 } 595 595 596 void CodeGenerator::visit( OffsetPackExpr * offsetPackExpr ) {596 void CodeGenerator::visit( OffsetPackExpr *offsetPackExpr ) { 597 597 assert( false && "OffsetPackExpr should not reach code generation." ); 598 598 } 599 599 600 void CodeGenerator::visit( LogicalExpr * logicalExpr ) {600 void CodeGenerator::visit( LogicalExpr *logicalExpr ) { 601 601 extension( logicalExpr ); 602 602 output << "("; … … 611 611 } 612 612 613 void CodeGenerator::visit( ConditionalExpr * conditionalExpr ) {613 void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) { 614 614 extension( conditionalExpr ); 615 615 output << "("; … … 622 622 } 623 623 624 void CodeGenerator::visit( CommaExpr * commaExpr ) {624 void CodeGenerator::visit( CommaExpr *commaExpr ) { 625 625 extension( commaExpr ); 626 626 output << "("; … … 631 631 } 632 632 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 ) { 638 638 if ( asmExpr->get_inout() ) { 639 639 output << "[ "; … … 648 648 649 649 //*** Statements 650 void CodeGenerator::visit( CompoundStmt * compoundStmt ) {650 void CodeGenerator::visit( CompoundStmt *compoundStmt ) { 651 651 std::list<Statement*> ks = compoundStmt->get_kids(); 652 652 output << "{" << endl; … … 662 662 output << endl; 663 663 } // if 664 } // for664 } 665 665 cur_indent -= CodeGenerator::tabsize; 666 666 … … 668 668 } 669 669 670 void CodeGenerator::visit( ExprStmt * exprStmt ) {670 void CodeGenerator::visit( ExprStmt *exprStmt ) { 671 671 assert( exprStmt ); 672 672 // cast the top-level expression to void to reduce gcc warnings. … … 676 676 } 677 677 678 void CodeGenerator::visit( AsmStmt * asmStmt ) {678 void CodeGenerator::visit( AsmStmt *asmStmt ) { 679 679 output << "asm "; 680 680 if ( asmStmt->get_voltile() ) output << "volatile "; … … 699 699 } 700 700 701 void CodeGenerator::visit( IfStmt * ifStmt ) {701 void CodeGenerator::visit( IfStmt *ifStmt ) { 702 702 output << "if ( "; 703 703 ifStmt->get_condition()->accept( *this ); … … 712 712 } 713 713 714 void CodeGenerator::visit( SwitchStmt * switchStmt ) {714 void CodeGenerator::visit( SwitchStmt *switchStmt ) { 715 715 output << "switch ( " ; 716 716 switchStmt->get_condition()->accept( *this ); … … 719 719 output << "{" << std::endl; 720 720 cur_indent += CodeGenerator::tabsize; 721 acceptAll( switchStmt->get_statements(), *this ); 721 722 acceptAll( switchStmt->get_branches(), *this ); 723 722 724 cur_indent -= CodeGenerator::tabsize; 725 723 726 output << indent << "}"; 724 727 } 725 728 726 void CodeGenerator::visit( CaseStmt * caseStmt ) {729 void CodeGenerator::visit( CaseStmt *caseStmt ) { 727 730 output << indent; 728 731 if ( caseStmt->isDefault()) { … … 745 748 } 746 749 747 void CodeGenerator::visit( BranchStmt * branchStmt ) {750 void CodeGenerator::visit( BranchStmt *branchStmt ) { 748 751 switch ( branchStmt->get_type()) { 749 752 case BranchStmt::Goto: … … 768 771 769 772 770 void CodeGenerator::visit( ReturnStmt * returnStmt ) {773 void CodeGenerator::visit( ReturnStmt *returnStmt ) { 771 774 output << "return "; 772 775 maybeAccept( returnStmt->get_expr(), *this ); … … 774 777 } 775 778 776 void CodeGenerator::visit( WhileStmt * whileStmt ) {779 void CodeGenerator::visit( WhileStmt *whileStmt ) { 777 780 if ( whileStmt->get_isDoWhile() ) { 778 781 output << "do" ; … … 796 799 } 797 800 798 void CodeGenerator::visit( ForStmt * forStmt ) {801 void CodeGenerator::visit( ForStmt *forStmt ) { 799 802 // initialization is always hoisted, so don't bother doing anything with that 800 803 output << "for (;"; … … 818 821 } 819 822 820 void CodeGenerator::visit( NullStmt * nullStmt ) {823 void CodeGenerator::visit( NullStmt *nullStmt ) { 821 824 //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() ); 822 825 output << "/* null statement */ ;"; 823 826 } 824 827 825 void CodeGenerator::visit( DeclStmt * declStmt ) {828 void CodeGenerator::visit( DeclStmt *declStmt ) { 826 829 declStmt->get_decl()->accept( *this ); 827 830 … … 831 834 } 832 835 833 void CodeGenerator::handleStorageClass( Declaration * decl ) {836 void CodeGenerator::handleStorageClass( Declaration *decl ) { 834 837 switch ( decl->get_storageClass() ) { 835 838 case DeclarationNode::Extern: -
src/ControlStruct/MLEMutator.cc
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:21:32201613 // Update Count : 20212 // Last Modified On : Tue Jul 12 17:36:51 2016 13 // Update Count : 197 14 14 // 15 15 … … 128 128 Label brkLabel = generator->newLabel("switchBreak"); 129 129 enclosingControlStructures.push_back( Entry(switchStmt, brkLabel) ); 130 mutateAll( switchStmt->get_ statements(), *this );130 mutateAll( switchStmt->get_branches(), *this ); 131 131 132 132 Entry &e = enclosingControlStructures.back(); … … 138 138 // switch should be CastStmts), append the exit label + break to the last case statement; create a default 139 139 // 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() ) ) { 146 146 std::list<Label> temp; temp.push_back( brkLabel ); 147 147 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 CaseStmts148 } else assert(0); // as of this point, all branches of a switch are still CaseStmts 149 149 } // if 150 150 -
src/ControlStruct/Mutate.cc
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:39:08201613 // Update Count : 912 // Last Modified On : Tue Jul 12 17:37:45 2016 13 // Update Count : 8 14 14 // 15 15 … … 22 22 #include "LabelFixer.h" 23 23 #include "MLEMutator.h" 24 #include "CaseRangeMutator.h" 24 25 #include "ForExprMutator.h" 25 26 #include "LabelTypeChecker.h" … … 40 41 LabelFixer lfix; 41 42 43 // expand case ranges and turn fallthru into a null statement 44 CaseRangeMutator ranges; 45 42 46 //ExceptMutator exc; 43 47 // LabelTypeChecker lbl; … … 45 49 mutateAll( translationUnit, formut ); 46 50 acceptAll( translationUnit, lfix ); 51 mutateAll( translationUnit, ranges ); 47 52 //mutateAll( translationUnit, exc ); 48 53 //acceptAll( translationUnit, lbl ); -
src/ControlStruct/module.mk
rcf37a8e r00c32e9 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : T hu Aug 4 11:38:06201614 ## Update Count : 313 ## Last Modified On : Tue Jul 12 17:40:31 2016 14 ## Update Count : 2 15 15 ############################################################################### 16 16 … … 18 18 ControlStruct/LabelFixer.cc \ 19 19 ControlStruct/MLEMutator.cc \ 20 ControlStruct/CaseRangeMutator.cc \ 20 21 ControlStruct/Mutate.cc \ 21 22 ControlStruct/ForExprMutator.cc \ -
src/GenPoly/DeclMutator.cc
rcf37a8e r00c32e9 10 10 // Created On : Fri Nov 27 14:44:00 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:16:43201613 // Update Count : 312 // Last Modified On : Tue Jul 12 17:38:46 2016 13 // Update Count : 2 14 14 // 15 15 … … 163 163 Statement* DeclMutator::mutate(SwitchStmt *switchStmt) { 164 164 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 165 mutateAll( switchStmt->get_ statements(), *this );165 mutateAll( switchStmt->get_branches(), *this ); 166 166 return switchStmt; 167 167 } -
src/GenPoly/PolyMutator.cc
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:26:22 201613 // Update Count : 1 612 // Last Modified On : Tue Jul 12 17:39:32 2016 13 // Update Count : 12 14 14 // 15 15 … … 99 99 100 100 Statement * PolyMutator::mutate(SwitchStmt *switchStmt) { 101 mutateStatementList( switchStmt->get_ statements() );101 mutateStatementList( switchStmt->get_branches() ); 102 102 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) ); 103 103 return switchStmt; -
src/Makefile.in
rcf37a8e r00c32e9 108 108 ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) \ 109 109 ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) \ 110 ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT) \ 110 111 ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \ 111 112 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ … … 371 372 Common/SemanticError.cc Common/UniqueName.cc \ 372 373 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 \ 375 376 ControlStruct/LabelTypeChecker.cc Designators/Processor.cc \ 376 377 GenPoly/Box.cc GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ … … 541 542 ControlStruct/$(DEPDIR)/$(am__dirstamp) 542 543 ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT): \ 544 ControlStruct/$(am__dirstamp) \ 545 ControlStruct/$(DEPDIR)/$(am__dirstamp) 546 ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT): \ 543 547 ControlStruct/$(am__dirstamp) \ 544 548 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 816 820 -rm -f Common/driver_cfa_cpp-SemanticError.$(OBJEXT) 817 821 -rm -f Common/driver_cfa_cpp-UniqueName.$(OBJEXT) 822 -rm -f ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT) 818 823 -rm -f ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) 819 824 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) … … 925 930 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@ 926 931 @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@ 927 933 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-ForExprMutator.Po@am__quote@ 928 934 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ … … 1206 1212 @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` 1207 1213 1214 ControlStruct/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 1221 ControlStruct/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 1208 1228 ControlStruct/driver_cfa_cpp-Mutate.o: ControlStruct/Mutate.cc 1209 1229 @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 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 2 15:10:23201613 // Update Count : 32 212 // Last Modified On : Tue Jul 5 13:41:55 2016 13 // Update Count : 320 14 14 // 15 15 … … 246 246 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 247 247 "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", 248 "?[?]", "FieldSel", "PFieldSel", " ...",248 "?[?]", "FieldSel", "PFieldSel", "Range", 249 249 // monadic 250 250 "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&" -
src/Parser/parser.cc
rcf37a8e r00c32e9 1031 1031 631, 632, 638, 639, 640, 641, 642, 643, 644, 645, 1032 1032 646, 656, 663, 665, 675, 676, 681, 683, 689, 691, 1033 695, 696, 701, 706, 709, 711, 713, 72 3, 725, 736,1034 73 7, 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, 1035 1035 765, 769, 771, 777, 778, 782, 784, 786, 788, 794, 1036 1036 795, 799, 801, 806, 808, 810, 815, 817, 822, 824, … … 6009 6009 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound 6010 6010 // 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. 6013 6012 (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_link( sw )) ) : sw; 6014 6013 } … … 6018 6017 6019 6018 /* Line 1806 of yacc.c */ 6020 #line 72 4"parser.yy"6019 #line 723 "parser.yy" 6021 6020 { (yyval.sn) = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); } 6022 6021 break; … … 6025 6024 6026 6025 /* Line 1806 of yacc.c */ 6027 #line 72 6"parser.yy"6026 #line 725 "parser.yy" 6028 6027 { 6029 6028 StatementNode *sw = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ); … … 6035 6034 6036 6035 /* Line 1806 of yacc.c */ 6037 #line 73 6"parser.yy"6036 #line 735 "parser.yy" 6038 6037 { (yyval.en) = (yyvsp[(1) - (1)].en); } 6039 6038 break; … … 6042 6041 6043 6042 /* Line 1806 of yacc.c */ 6044 #line 73 8"parser.yy"6043 #line 737 "parser.yy" 6045 6044 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); } 6046 6045 break; 6047 6046 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 6055 6047 case 163: 6056 6048 6057 6049 /* Line 1806 of yacc.c */ 6058 6050 #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) ) ); } 6060 6052 break; 6061 6053 … … 6064 6056 /* Line 1806 of yacc.c */ 6065 6057 #line 748 "parser.yy" 6066 { (yyval.sn) = (yyvsp[(2) - (3)].sn); }6058 { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(2) - (3)].en), 0 ); } 6067 6059 break; 6068 6060 … … 9425 9417 9426 9418 /* Line 1806 of yacc.c */ 9427 #line 942 8"Parser/parser.cc"9419 #line 9420 "Parser/parser.cc" 9428 9420 default: break; 9429 9421 } -
src/Parser/parser.yy
rcf37a8e r00c32e9 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 11:28:18201613 // Update Count : 16 7212 // Last Modified On : Sat Jul 23 17:01:30 2016 13 // Update Count : 1668 14 14 // 15 15 … … 150 150 %type<sn> block_item_list block_item 151 151 %type<sn> case_clause 152 %type<en> case_value 153 %type<sn> case_ value_list case_label case_label_list152 %type<en> case_value case_value_list 153 %type<sn> case_label case_label_list 154 154 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 155 155 %type<pn> handler_list handler_clause finally_clause … … 717 717 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound 718 718 // 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. 721 720 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw; 722 721 } … … 741 740 742 741 case_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 ) ); } 745 745 ; 746 746 747 747 case_label: // CFA 748 CASE case_value_list ':' { $$ = $2; }748 CASE case_value_list ':' { $$ = new StatementNode( StatementNode::Case, $2, 0 ); } 749 749 | DEFAULT ':' { $$ = new StatementNode( StatementNode::Default ); } 750 750 // A semantic check is required to ensure only one default clause per switch/choose statement. -
src/SymTab/AddVisit.h
rcf37a8e r00c32e9 10 10 // Created On : Sun May 17 16:14:32 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:22:01201613 // Update Count : 912 // Last Modified On : Tue Jul 12 17:46:33 2016 13 // Update Count : 6 14 14 // 15 15 … … 33 33 template< typename Visitor > 34 34 inline void addVisit(SwitchStmt *switchStmt, Visitor &visitor) { 35 addVisitStatementList( switchStmt->get_ statements(), visitor );35 addVisitStatementList( switchStmt->get_branches(), visitor ); 36 36 maybeAccept( switchStmt->get_condition(), visitor ); 37 37 } -
src/SynTree/AddStmtVisitor.cc
rcf37a8e r00c32e9 10 10 // Created On : Wed Jun 22 12:11:17 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:23:47201613 // Update Count : 1 612 // Last Modified On : Tue Jul 12 17:49:59 2016 13 // Update Count : 12 14 14 // 15 15 … … 71 71 72 72 void AddStmtVisitor::visit(SwitchStmt *switchStmt) { 73 visitStatementList( switchStmt->get_ statements() );73 visitStatementList( switchStmt->get_branches() ); 74 74 maybeAccept( switchStmt->get_condition(), *this ); 75 75 } -
src/SynTree/Expression.cc
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 17:06:51201613 // Update Count : 4 512 // Last Modified On : Mon Jun 13 16:03:39 2016 13 // Update Count : 42 14 14 // 15 15 … … 528 528 } 529 529 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 }538 530 539 531 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 17:08:44201613 // Update Count : 2 712 // Last Modified On : Mon Jul 4 14:45:32 2016 13 // Update Count : 23 14 14 // 15 15 … … 18 18 19 19 #include <map> 20 #include <memory>21 20 #include "SynTree.h" 22 21 #include "Visitor.h" … … 635 634 }; 636 635 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 655 636 std::ostream & operator<<( std::ostream & out, Expression * expr ); 656 637 -
src/SynTree/Mutator.cc
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:23:21201613 // Update Count : 1 912 // Last Modified On : Tue Jul 12 17:51:19 2016 13 // Update Count : 17 14 14 // 15 15 … … 126 126 Statement *Mutator::mutate( SwitchStmt *switchStmt ) { 127 127 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 128 mutateAll( switchStmt->get_ statements(), *this );128 mutateAll( switchStmt->get_branches(), *this ); 129 129 return switchStmt; 130 130 } … … 349 349 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 350 350 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;357 351 } 358 352 -
src/SynTree/Mutator.h
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 16:59:45201613 // Update Count : 1 212 // Last Modified On : Tue Jul 12 17:51:43 2016 13 // Update Count : 11 14 14 // 15 15 #include <cassert> … … 78 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 80 virtual Expression* mutate( RangeExpr *rangeExpr );81 80 82 81 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/Statement.cc
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:25:20201613 // Update Count : 6112 // Last Modified On : Tue Jul 12 17:52:32 2016 13 // Update Count : 55 14 14 // 15 15 … … 143 143 } 144 144 145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_ statements ):146 Statement( _labels ), condition( _condition ), statements( _statements ) {145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ): 146 Statement( _labels ), condition( _condition ), branches( _branches ) { 147 147 } 148 148 149 149 SwitchStmt::SwitchStmt( const SwitchStmt & other ): 150 150 Statement( other ), condition( maybeClone( other.condition ) ) { 151 cloneAll( other. statements, statements );151 cloneAll( other.branches, branches ); 152 152 } 153 153 154 154 SwitchStmt::~SwitchStmt() { 155 155 delete condition; 156 // destroy statements 157 } 156 // destroy branches 157 } 158 159 void SwitchStmt::add_case( CaseStmt *c ) {} 158 160 159 161 void SwitchStmt::print( std::ostream &os, int indent ) const { … … 162 164 os << endl; 163 165 164 // statements166 // branches 165 167 std::list<Statement *>::const_iterator i; 166 for ( i = statements.begin(); i != statements.end(); i++)168 for ( i = branches.begin(); i != branches.end(); i++) 167 169 (*i)->print( os, indent + 4 ); 168 170 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 )); 170 172 } 171 173 … … 185 187 } 186 188 187 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) {188 return new CaseStmt( labels, 0, stmts, true );189 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> branches ) { 190 return new CaseStmt( labels, 0, branches, true ); 189 191 } 190 192 -
src/SynTree/Statement.h
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:26:02201613 // Update Count : 6412 // Last Modified On : Tue Jul 12 17:53:29 2016 13 // Update Count : 47 14 14 // 15 15 … … 129 129 class SwitchStmt : public Statement { 130 130 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 ); 132 132 SwitchStmt( const SwitchStmt &other ); 133 133 virtual ~SwitchStmt(); … … 136 136 void set_condition( Expression *newValue ) { condition = newValue; } 137 137 138 std::list<Statement *> & get_statements() { return statements; } 138 std::list<Statement *> & get_branches() { return branches; } 139 void add_case( CaseStmt * ); 139 140 140 141 virtual void accept( Visitor &v ) { v.visit( this ); } … … 145 146 private: 146 147 Expression * condition; 147 std::list<Statement *> statements;148 std::list<Statement *> branches; // should be list of CaseStmt 148 149 }; 149 150 150 151 class CaseStmt : public Statement { 151 152 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); 153 155 CaseStmt( const CaseStmt &other ); 154 156 virtual ~CaseStmt(); 155 157 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 *>() ); 157 160 158 161 bool isDefault() const { return _isDefault; } -
src/SynTree/SynTree.h
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 17:02:34201613 // Update Count : 712 // Last Modified On : Tue Jul 12 17:54:02 2016 13 // Update Count : 6 14 14 // 15 15 … … 83 83 class UntypedValofExpr; 84 84 class CompoundLiteralExpr; 85 class RangeExpr;86 85 87 86 class Type; -
src/SynTree/Visitor.cc
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:24:25201613 // Update Count : 2112 // Last Modified On : Tue Jul 12 17:54:39 2016 13 // Update Count : 19 14 14 // 15 15 … … 109 109 void Visitor::visit( SwitchStmt *switchStmt ) { 110 110 maybeAccept( switchStmt->get_condition(), *this ); 111 acceptAll( switchStmt->get_ statements(), *this );111 acceptAll( switchStmt->get_branches(), *this ); 112 112 } 113 113 … … 296 296 maybeAccept( compLitExpr->get_type(), *this ); 297 297 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 );303 298 } 304 299 -
src/SynTree/Visitor.h
rcf37a8e r00c32e9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 17:01:50201613 // Update Count : 912 // Last Modified On : Tue Jul 12 17:55:09 2016 13 // Update Count : 8 14 14 // 15 15 … … 78 78 virtual void visit( UntypedValofExpr *valofExpr ); 79 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 80 virtual void visit( RangeExpr *rangeExpr );81 80 82 81 virtual void visit( VoidType *basicType ); -
src/tests/switch.c
rcf37a8e r00c32e9 10 10 // Created On : Tue Jul 12 06:50:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 11:44:29201613 // Update Count : 3 112 // Last Modified On : Sat Jul 30 14:41:32 2016 13 // Update Count : 30 14 14 // 15 15 … … 39 39 case 4: 40 40 j = 0; 41 }42 43 switch ( i ) {44 case 1, 2, 3:45 switch ( i ) {46 case 2, 3, 4:47 7;48 }49 41 } 50 42
Note:
See TracChangeset
for help on using the changeset viewer.