Changeset 8688ce1
- Timestamp:
- Aug 4, 2016, 12:29:54 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 76e8c55
- Parents:
- e80ebe5
- Location:
- src
- Files:
-
- 2 deleted
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
re80ebe5 r8688ce1 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : 12 // Last Modified On : Sun Jul 31 08:42:18201613 // Update Count : 3 4511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 11:16:21 2016 13 // Update Count : 351 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 } 81 } // for 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 } 114 } // if 115 115 output << ","; 116 } 116 } // for 117 117 output << ")) "; 118 } 118 } // if 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 } 278 } // if 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 } 354 } // if 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() == " Range" ) { // case V1 ... V2 or case V1~V2474 if ( nameExpr->get_name() == "..." ) { // 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 } 664 } // for 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 722 acceptAll( switchStmt->get_branches(), *this ); 723 721 acceptAll( switchStmt->get_statements(), *this ); 724 722 cur_indent -= CodeGenerator::tabsize; 725 726 723 output << indent << "}"; 727 724 } 728 725 729 void CodeGenerator::visit( CaseStmt * caseStmt ) {726 void CodeGenerator::visit( CaseStmt * caseStmt ) { 730 727 output << indent; 731 728 if ( caseStmt->isDefault()) { … … 748 745 } 749 746 750 void CodeGenerator::visit( BranchStmt * branchStmt ) {747 void CodeGenerator::visit( BranchStmt * branchStmt ) { 751 748 switch ( branchStmt->get_type()) { 752 749 case BranchStmt::Goto: … … 771 768 772 769 773 void CodeGenerator::visit( ReturnStmt * returnStmt ) {770 void CodeGenerator::visit( ReturnStmt * returnStmt ) { 774 771 output << "return "; 775 772 maybeAccept( returnStmt->get_expr(), *this ); … … 777 774 } 778 775 779 void CodeGenerator::visit( WhileStmt * whileStmt ) {776 void CodeGenerator::visit( WhileStmt * whileStmt ) { 780 777 if ( whileStmt->get_isDoWhile() ) { 781 778 output << "do" ; … … 799 796 } 800 797 801 void CodeGenerator::visit( ForStmt * forStmt ) {798 void CodeGenerator::visit( ForStmt * forStmt ) { 802 799 // initialization is always hoisted, so don't bother doing anything with that 803 800 output << "for (;"; … … 821 818 } 822 819 823 void CodeGenerator::visit( NullStmt * nullStmt ) {820 void CodeGenerator::visit( NullStmt * nullStmt ) { 824 821 //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() ); 825 822 output << "/* null statement */ ;"; 826 823 } 827 824 828 void CodeGenerator::visit( DeclStmt * declStmt ) {825 void CodeGenerator::visit( DeclStmt * declStmt ) { 829 826 declStmt->get_decl()->accept( *this ); 830 827 … … 834 831 } 835 832 836 void CodeGenerator::handleStorageClass( Declaration * decl ) {833 void CodeGenerator::handleStorageClass( Declaration * decl ) { 837 834 switch ( decl->get_storageClass() ) { 838 835 case DeclarationNode::Extern: -
src/ControlStruct/MLEMutator.cc
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:36:51201613 // Update Count : 19712 // Last Modified On : Thu Aug 4 11:21:32 2016 13 // Update Count : 202 14 14 // 15 15 … … 128 128 Label brkLabel = generator->newLabel("switchBreak"); 129 129 enclosingControlStructures.push_back( Entry(switchStmt, brkLabel) ); 130 mutateAll( switchStmt->get_ branches(), *this );130 mutateAll( switchStmt->get_statements(), *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 * > & 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() ) ) {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() ) ) { 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 branches of a switch are still CaseStmts148 } else assert(0); // as of this point, all statements of a switch are still CaseStmts 149 149 } // if 150 150 -
src/ControlStruct/Mutate.cc
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:37:45201613 // Update Count : 812 // Last Modified On : Thu Aug 4 11:39:08 2016 13 // Update Count : 9 14 14 // 15 15 … … 22 22 #include "LabelFixer.h" 23 23 #include "MLEMutator.h" 24 #include "CaseRangeMutator.h"25 24 #include "ForExprMutator.h" 26 25 #include "LabelTypeChecker.h" … … 41 40 LabelFixer lfix; 42 41 43 // expand case ranges and turn fallthru into a null statement44 CaseRangeMutator ranges;45 46 42 //ExceptMutator exc; 47 43 // LabelTypeChecker lbl; … … 49 45 mutateAll( translationUnit, formut ); 50 46 acceptAll( translationUnit, lfix ); 51 mutateAll( translationUnit, ranges );52 47 //mutateAll( translationUnit, exc ); 53 48 //acceptAll( translationUnit, lbl ); -
src/ControlStruct/module.mk
re80ebe5 r8688ce1 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : T ue Jul 12 17:40:31201614 ## Update Count : 213 ## Last Modified On : Thu Aug 4 11:38:06 2016 14 ## Update Count : 3 15 15 ############################################################################### 16 16 … … 18 18 ControlStruct/LabelFixer.cc \ 19 19 ControlStruct/MLEMutator.cc \ 20 ControlStruct/CaseRangeMutator.cc \21 20 ControlStruct/Mutate.cc \ 22 21 ControlStruct/ForExprMutator.cc \ -
src/GenPoly/DeclMutator.cc
re80ebe5 r8688ce1 10 10 // Created On : Fri Nov 27 14:44:00 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:38:46201613 // Update Count : 212 // Last Modified On : Thu Aug 4 11:16:43 2016 13 // Update Count : 3 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_ branches(), *this );165 mutateAll( switchStmt->get_statements(), *this ); 166 166 return switchStmt; 167 167 } -
src/GenPoly/PolyMutator.cc
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:39:32 201613 // Update Count : 1 212 // Last Modified On : Thu Aug 4 11:26:22 2016 13 // Update Count : 16 14 14 // 15 15 … … 99 99 100 100 Statement * PolyMutator::mutate(SwitchStmt *switchStmt) { 101 mutateStatementList( switchStmt->get_ branches() );101 mutateStatementList( switchStmt->get_statements() ); 102 102 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) ); 103 103 return switchStmt; -
src/Makefile.in
re80ebe5 r8688ce1 108 108 ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) \ 109 109 ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) \ 110 ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT) \111 110 ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \ 112 111 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ … … 372 371 Common/SemanticError.cc Common/UniqueName.cc \ 373 372 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 374 ControlStruct/MLEMutator.cc ControlStruct/ CaseRangeMutator.cc \375 ControlStruct/ Mutate.cc ControlStruct/ForExprMutator.cc \373 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 374 ControlStruct/ForExprMutator.cc \ 376 375 ControlStruct/LabelTypeChecker.cc Designators/Processor.cc \ 377 376 GenPoly/Box.cc GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ … … 542 541 ControlStruct/$(DEPDIR)/$(am__dirstamp) 543 542 ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT): \ 544 ControlStruct/$(am__dirstamp) \545 ControlStruct/$(DEPDIR)/$(am__dirstamp)546 ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT): \547 543 ControlStruct/$(am__dirstamp) \ 548 544 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 820 816 -rm -f Common/driver_cfa_cpp-SemanticError.$(OBJEXT) 821 817 -rm -f Common/driver_cfa_cpp-UniqueName.$(OBJEXT) 822 -rm -f ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT)823 818 -rm -f ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) 824 819 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) … … 930 925 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@ 931 926 @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@933 927 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-ForExprMutator.Po@am__quote@ 934 928 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ … … 1212 1206 @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` 1213 1207 1214 ControlStruct/driver_cfa_cpp-CaseRangeMutator.o: ControlStruct/CaseRangeMutator.cc1215 @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.cc1216 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po1217 @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.cc1220 1221 ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj: ControlStruct/CaseRangeMutator.cc1222 @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.Po1224 @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 1228 1208 ControlStruct/driver_cfa_cpp-Mutate.o: ControlStruct/Mutate.cc 1229 1209 @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
re80ebe5 r8688ce1 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 5 13:41:55201613 // Update Count : 32 012 // Last Modified On : Tue Aug 2 15:10:23 2016 13 // Update Count : 322 14 14 // 15 15 … … 246 246 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 247 247 "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", 248 "?[?]", "FieldSel", "PFieldSel", " Range",248 "?[?]", "FieldSel", "PFieldSel", "...", 249 249 // monadic 250 250 "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&" -
src/Parser/parser.cc
re80ebe5 r8688ce1 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 2, 724, 735,1034 73 6, 738, 742, 743, 748, 749, 754, 755, 759, 764,1033 695, 696, 701, 706, 709, 711, 713, 723, 725, 736, 1034 737, 739, 743, 744, 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. Change also applies to choose statement. 6011 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 6012 // statement. 6012 6013 (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_link( sw )) ) : sw; 6013 6014 } … … 6017 6018 6018 6019 /* Line 1806 of yacc.c */ 6019 #line 72 3"parser.yy"6020 #line 724 "parser.yy" 6020 6021 { (yyval.sn) = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); } 6021 6022 break; … … 6024 6025 6025 6026 /* Line 1806 of yacc.c */ 6026 #line 72 5"parser.yy"6027 #line 726 "parser.yy" 6027 6028 { 6028 6029 StatementNode *sw = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ); … … 6034 6035 6035 6036 /* Line 1806 of yacc.c */ 6036 #line 73 5"parser.yy"6037 #line 736 "parser.yy" 6037 6038 { (yyval.en) = (yyvsp[(1) - (1)].en); } 6038 6039 break; … … 6041 6042 6042 6043 /* Line 1806 of yacc.c */ 6043 #line 73 7"parser.yy"6044 #line 738 "parser.yy" 6044 6045 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); } 6045 6046 break; 6046 6047 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 6047 6055 case 163: 6048 6056 6049 6057 /* Line 1806 of yacc.c */ 6050 6058 #line 744 "parser.yy" 6051 { (yyval. en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( (yyvsp[(1) - (3)].en) ))->set_link( (yyvsp[(3) - (3)].en) ) ); }6059 { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_link( new StatementNode( StatementNode::Case, (yyvsp[(3) - (3)].en), 0 ) ) ); } 6052 6060 break; 6053 6061 … … 6056 6064 /* Line 1806 of yacc.c */ 6057 6065 #line 748 "parser.yy" 6058 { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(2) - (3)].en), 0); }6066 { (yyval.sn) = (yyvsp[(2) - (3)].sn); } 6059 6067 break; 6060 6068 … … 9417 9425 9418 9426 /* Line 1806 of yacc.c */ 9419 #line 942 0"Parser/parser.cc"9427 #line 9428 "Parser/parser.cc" 9420 9428 default: break; 9421 9429 } -
src/Parser/parser.yy
re80ebe5 r8688ce1 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 23 17:01:30201613 // Update Count : 16 6812 // Last Modified On : Thu Aug 4 11:28:18 2016 13 // Update Count : 1672 14 14 // 15 15 … … 150 150 %type<sn> block_item_list block_item 151 151 %type<sn> case_clause 152 %type<en> case_value case_value_list153 %type<sn> case_ label case_label_list152 %type<en> case_value 153 %type<sn> case_value_list 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. Change also applies to choose statement. 719 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 720 // statement. 720 721 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw; 721 722 } … … 740 741 741 742 case_value_list: // CFA 742 case_value 743 | case_value_list ',' case_value 744 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( $1 ))->set_link( $3 ) ); } 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 ) ) ); } 745 745 ; 746 746 747 747 case_label: // CFA 748 CASE case_value_list ':' { $$ = new StatementNode( StatementNode::Case, $2, 0 ); }748 CASE case_value_list ':' { $$ = $2; } 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
re80ebe5 r8688ce1 10 10 // Created On : Sun May 17 16:14:32 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:46:33201613 // Update Count : 612 // Last Modified On : Thu Aug 4 11:22:01 2016 13 // Update Count : 9 14 14 // 15 15 … … 33 33 template< typename Visitor > 34 34 inline void addVisit(SwitchStmt *switchStmt, Visitor &visitor) { 35 addVisitStatementList( switchStmt->get_ branches(), visitor );35 addVisitStatementList( switchStmt->get_statements(), visitor ); 36 36 maybeAccept( switchStmt->get_condition(), visitor ); 37 37 } -
src/SynTree/AddStmtVisitor.cc
re80ebe5 r8688ce1 10 10 // Created On : Wed Jun 22 12:11:17 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:49:59201613 // Update Count : 1 212 // Last Modified On : Thu Aug 4 11:23:47 2016 13 // Update Count : 16 14 14 // 15 15 … … 71 71 72 72 void AddStmtVisitor::visit(SwitchStmt *switchStmt) { 73 visitStatementList( switchStmt->get_ branches() );73 visitStatementList( switchStmt->get_statements() ); 74 74 maybeAccept( switchStmt->get_condition(), *this ); 75 75 } -
src/SynTree/Expression.cc
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 13 16:03:39201613 // Update Count : 4 212 // Last Modified On : Wed Aug 3 17:06:51 2016 13 // Update Count : 45 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 } 530 538 531 539 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 4 14:45:32201613 // Update Count : 2 312 // Last Modified On : Wed Aug 3 17:08:44 2016 13 // Update Count : 27 14 14 // 15 15 … … 18 18 19 19 #include <map> 20 #include <memory> 20 21 #include "SynTree.h" 21 22 #include "Visitor.h" … … 634 635 }; 635 636 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 636 655 std::ostream & operator<<( std::ostream & out, Expression * expr ); 637 656 -
src/SynTree/Mutator.cc
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:51:19201613 // Update Count : 1 712 // Last Modified On : Thu Aug 4 11:23:21 2016 13 // Update Count : 19 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_ branches(), *this );128 mutateAll( switchStmt->get_statements(), *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; 351 357 } 352 358 -
src/SynTree/Mutator.h
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:51:43201613 // Update Count : 1 112 // Last Modified On : Wed Aug 3 16:59:45 2016 13 // Update Count : 12 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 ); 80 81 81 82 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/Statement.cc
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:52:32201613 // Update Count : 5512 // Last Modified On : Thu Aug 4 11:25:20 2016 13 // Update Count : 61 14 14 // 15 15 … … 143 143 } 144 144 145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_ branches ):146 Statement( _labels ), condition( _condition ), branches( _branches ) {145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_statements ): 146 Statement( _labels ), condition( _condition ), statements( _statements ) { 147 147 } 148 148 149 149 SwitchStmt::SwitchStmt( const SwitchStmt & other ): 150 150 Statement( other ), condition( maybeClone( other.condition ) ) { 151 cloneAll( other. branches, branches );151 cloneAll( other.statements, statements ); 152 152 } 153 153 154 154 SwitchStmt::~SwitchStmt() { 155 155 delete condition; 156 // destroy branches 157 } 158 159 void SwitchStmt::add_case( CaseStmt *c ) {} 156 // destroy statements 157 } 160 158 161 159 void SwitchStmt::print( std::ostream &os, int indent ) const { … … 164 162 os << endl; 165 163 166 // branches164 // statements 167 165 std::list<Statement *>::const_iterator i; 168 for ( i = branches.begin(); i != branches.end(); i++)166 for ( i = statements.begin(); i != statements.end(); i++) 169 167 (*i)->print( os, indent + 4 ); 170 168 171 //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os ));169 //for_each( statements.begin(), statements.end(), mem_fun( bind1st(&Statement::print ), os )); 172 170 } 173 171 … … 187 185 } 188 186 189 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> branches ) {190 return new CaseStmt( labels, 0, branches, true );187 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) { 188 return new CaseStmt( labels, 0, stmts, true ); 191 189 } 192 190 -
src/SynTree/Statement.h
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:53:29201613 // Update Count : 4712 // Last Modified On : Thu Aug 4 11:26:02 2016 13 // Update Count : 64 14 14 // 15 15 … … 129 129 class SwitchStmt : public Statement { 130 130 public: 131 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> & branches );131 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements ); 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_branches() { return branches; } 139 void add_case( CaseStmt * ); 138 std::list<Statement *> & get_statements() { return statements; } 140 139 141 140 virtual void accept( Visitor &v ) { v.visit( this ); } … … 146 145 private: 147 146 Expression * condition; 148 std::list<Statement *> branches; // should be list of CaseStmt147 std::list<Statement *> statements; 149 148 }; 150 149 151 150 class CaseStmt : public Statement { 152 151 public: 153 CaseStmt( std::list<Label> labels, Expression *conditions, 154 std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 152 CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 155 153 CaseStmt( const CaseStmt &other ); 156 154 virtual ~CaseStmt(); 157 155 158 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), 159 std::list<Statement *> stmts = std::list<Statement *>() ); 156 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() ); 160 157 161 158 bool isDefault() const { return _isDefault; } -
src/SynTree/SynTree.h
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:54:02201613 // Update Count : 612 // Last Modified On : Wed Aug 3 17:02:34 2016 13 // Update Count : 7 14 14 // 15 15 … … 83 83 class UntypedValofExpr; 84 84 class CompoundLiteralExpr; 85 class RangeExpr; 85 86 86 87 class Type; -
src/SynTree/Visitor.cc
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:54:39201613 // Update Count : 1912 // Last Modified On : Thu Aug 4 11:24:25 2016 13 // Update Count : 21 14 14 // 15 15 … … 109 109 void Visitor::visit( SwitchStmt *switchStmt ) { 110 110 maybeAccept( switchStmt->get_condition(), *this ); 111 acceptAll( switchStmt->get_ branches(), *this );111 acceptAll( switchStmt->get_statements(), *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 ); 298 303 } 299 304 -
src/SynTree/Visitor.h
re80ebe5 r8688ce1 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:55:09201613 // Update Count : 812 // Last Modified On : Wed Aug 3 17:01:50 2016 13 // Update Count : 9 14 14 // 15 15 … … 78 78 virtual void visit( UntypedValofExpr *valofExpr ); 79 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 80 virtual void visit( RangeExpr *rangeExpr ); 80 81 81 82 virtual void visit( VoidType *basicType ); -
src/tests/switch.c
re80ebe5 r8688ce1 10 10 // Created On : Tue Jul 12 06:50:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 30 14:41:32201613 // Update Count : 3 012 // Last Modified On : Thu Aug 4 11:44:29 2016 13 // Update Count : 31 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 } 41 49 } 42 50
Note: See TracChangeset
for help on using the changeset viewer.