Changes in / [f9cebb5:4819cac]
- Location:
- src
- Files:
-
- 2 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rf9cebb5 r4819cac 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 genAttributes( objectDecl->get_attributes() ); … … 164 164 } 165 165 166 void CodeGenerator::handleAggregate( AggregateDecl * aggDecl ) {166 void CodeGenerator::handleAggregate( AggregateDecl * aggDecl ) { 167 167 if ( aggDecl->get_name() != "" ) 168 168 output << aggDecl->get_name(); 169 169 170 std::list< Declaration * > & memb = aggDecl->get_members();170 std::list< Declaration * > & memb = aggDecl->get_members(); 171 171 if ( ! memb.empty() ) { 172 172 // if ( aggDecl->has_body() ) { 173 // std::list< Declaration * > & memb = aggDecl->get_members();173 // std::list< Declaration * > & memb = aggDecl->get_members(); 174 174 output << " {" << endl; 175 175 … … 187 187 } 188 188 189 void CodeGenerator::visit( StructDecl * structDecl ) {189 void CodeGenerator::visit( StructDecl * structDecl ) { 190 190 extension( structDecl ); 191 191 output << "struct "; … … 193 193 } 194 194 195 void CodeGenerator::visit( UnionDecl * unionDecl ) {195 void CodeGenerator::visit( UnionDecl * unionDecl ) { 196 196 extension( unionDecl ); 197 197 output << "union "; … … 199 199 } 200 200 201 void CodeGenerator::visit( EnumDecl * enumDecl ) {201 void CodeGenerator::visit( EnumDecl * enumDecl ) { 202 202 extension( enumDecl ); 203 203 output << "enum "; … … 213 213 cur_indent += CodeGenerator::tabsize; 214 214 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 ); 216 216 assert( obj ); 217 217 output << indent << mangleName( obj ); … … 229 229 } 230 230 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 ) { 234 234 assert( false && "Typedefs are removed and substituted in earlier passes." ); 235 235 //output << "typedef "; … … 237 237 } 238 238 239 void CodeGenerator::visit( TypeDecl * typeDecl ) {239 void CodeGenerator::visit( TypeDecl * typeDecl ) { 240 240 // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes, 241 241 // still to be done … … 265 265 } 266 266 267 void CodeGenerator::visit( SingleInit * init ) {267 void CodeGenerator::visit( SingleInit * init ) { 268 268 printDesignators( init->get_designators() ); 269 269 init->get_value()->accept( *this ); 270 270 } 271 271 272 void CodeGenerator::visit( ListInit * init ) {272 void CodeGenerator::visit( ListInit * init ) { 273 273 printDesignators( init->get_designators() ); 274 274 output << "{ "; … … 278 278 } else { 279 279 genCommaList( init->begin(), init->end() ); 280 } 280 } // if 281 281 output << " }"; 282 282 } 283 283 284 void CodeGenerator::visit( Constant * constant ) {284 void CodeGenerator::visit( Constant * constant ) { 285 285 output << constant->get_value() ; 286 286 } 287 287 288 288 //*** Expressions 289 void CodeGenerator::visit( ApplicationExpr * applicationExpr ) {289 void CodeGenerator::visit( ApplicationExpr * applicationExpr ) { 290 290 extension( applicationExpr ); 291 if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {291 if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) { 292 292 OperatorInfo opInfo; 293 293 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( varExpr->get_var()->get_name(), opInfo ) ) { … … 301 301 { 302 302 assert( arg != applicationExpr->get_args().end() ); 303 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {303 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) { 304 304 // remove & from first assignment/ctor argument 305 305 *arg = addrExpr->get_arg(); 306 306 } else { 307 307 // 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( "*?" ) ); 309 309 newExpr->get_args().push_back( *arg ); 310 310 assert( (*arg)->get_results().size() == 1 ); … … 354 354 // no constructors with 0 or more than 2 parameters 355 355 assert( false ); 356 } 356 } // if 357 357 break; 358 358 … … 403 403 } 404 404 405 void CodeGenerator::visit( UntypedExpr * untypedExpr ) {405 void CodeGenerator::visit( UntypedExpr * untypedExpr ) { 406 406 extension( untypedExpr ); 407 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {407 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) { 408 408 OperatorInfo opInfo; 409 409 if ( operatorLookup( nameExpr->get_name(), opInfo ) ) { … … 474 474 } // switch 475 475 } else { 476 if ( nameExpr->get_name() == " Range" ) { // case V1 ... V2 or case V1~V2476 if ( nameExpr->get_name() == "..." ) { // case V1 ... V2 or case V1~V2 477 477 assert( untypedExpr->get_args().size() == 2 ); 478 478 (*untypedExpr->get_args().begin())->accept( *this ); … … 494 494 } 495 495 496 void CodeGenerator::visit( NameExpr * nameExpr ) {496 void CodeGenerator::visit( NameExpr * nameExpr ) { 497 497 extension( nameExpr ); 498 498 OperatorInfo opInfo; … … 505 505 } 506 506 507 void CodeGenerator::visit( AddressExpr * addressExpr ) {507 void CodeGenerator::visit( AddressExpr * addressExpr ) { 508 508 extension( addressExpr ); 509 509 output << "(&"; 510 510 // 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() ) ) { 512 512 output << mangleName( variableExpr->get_var() ); 513 513 } else { … … 517 517 } 518 518 519 void CodeGenerator::visit( CastExpr * castExpr ) {519 void CodeGenerator::visit( CastExpr * castExpr ) { 520 520 extension( castExpr ); 521 521 output << "("; … … 535 535 } 536 536 537 void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) {537 void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) { 538 538 assert( false ); 539 539 } 540 540 541 void CodeGenerator::visit( MemberExpr * memberExpr ) {541 void CodeGenerator::visit( MemberExpr * memberExpr ) { 542 542 extension( memberExpr ); 543 543 memberExpr->get_aggregate()->accept( *this ); … … 545 545 } 546 546 547 void CodeGenerator::visit( VariableExpr * variableExpr ) {547 void CodeGenerator::visit( VariableExpr * variableExpr ) { 548 548 extension( variableExpr ); 549 549 OperatorInfo opInfo; … … 555 555 } 556 556 557 void CodeGenerator::visit( ConstantExpr * constantExpr ) {557 void CodeGenerator::visit( ConstantExpr * constantExpr ) { 558 558 assert( constantExpr->get_constant() ); 559 559 extension( constantExpr ); … … 561 561 } 562 562 563 void CodeGenerator::visit( SizeofExpr * sizeofExpr ) {563 void CodeGenerator::visit( SizeofExpr * sizeofExpr ) { 564 564 extension( sizeofExpr ); 565 565 output << "sizeof("; … … 572 572 } 573 573 574 void CodeGenerator::visit( AlignofExpr * alignofExpr ) {574 void CodeGenerator::visit( AlignofExpr * alignofExpr ) { 575 575 // use GCC extension to avoid bumping std to C11 576 576 extension( alignofExpr ); … … 584 584 } 585 585 586 void CodeGenerator::visit( UntypedOffsetofExpr * offsetofExpr ) {586 void CodeGenerator::visit( UntypedOffsetofExpr * offsetofExpr ) { 587 587 assert( false && "UntypedOffsetofExpr should not reach code generation." ); 588 588 } 589 589 590 void CodeGenerator::visit( OffsetofExpr * offsetofExpr ) {590 void CodeGenerator::visit( OffsetofExpr * offsetofExpr ) { 591 591 // use GCC builtin 592 592 output << "__builtin_offsetof("; … … 596 596 } 597 597 598 void CodeGenerator::visit( OffsetPackExpr * offsetPackExpr ) {598 void CodeGenerator::visit( OffsetPackExpr * offsetPackExpr ) { 599 599 assert( false && "OffsetPackExpr should not reach code generation." ); 600 600 } 601 601 602 void CodeGenerator::visit( LogicalExpr * logicalExpr ) {602 void CodeGenerator::visit( LogicalExpr * logicalExpr ) { 603 603 extension( logicalExpr ); 604 604 output << "("; … … 613 613 } 614 614 615 void CodeGenerator::visit( ConditionalExpr * conditionalExpr ) {615 void CodeGenerator::visit( ConditionalExpr * conditionalExpr ) { 616 616 extension( conditionalExpr ); 617 617 output << "("; … … 624 624 } 625 625 626 void CodeGenerator::visit( CommaExpr * commaExpr ) {626 void CodeGenerator::visit( CommaExpr * commaExpr ) { 627 627 extension( commaExpr ); 628 628 output << "("; … … 633 633 } 634 634 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 ) { 640 640 if ( asmExpr->get_inout() ) { 641 641 output << "[ "; … … 650 650 651 651 //*** Statements 652 void CodeGenerator::visit( CompoundStmt * compoundStmt ) {652 void CodeGenerator::visit( CompoundStmt * compoundStmt ) { 653 653 std::list<Statement*> ks = compoundStmt->get_kids(); 654 654 output << "{" << endl; … … 664 664 output << endl; 665 665 } // if 666 } 666 } // for 667 667 cur_indent -= CodeGenerator::tabsize; 668 668 … … 670 670 } 671 671 672 void CodeGenerator::visit( ExprStmt * exprStmt ) {672 void CodeGenerator::visit( ExprStmt * exprStmt ) { 673 673 assert( exprStmt ); 674 674 // cast the top-level expression to void to reduce gcc warnings. … … 678 678 } 679 679 680 void CodeGenerator::visit( AsmStmt * asmStmt ) {680 void CodeGenerator::visit( AsmStmt * asmStmt ) { 681 681 output << "asm "; 682 682 if ( asmStmt->get_voltile() ) output << "volatile "; … … 701 701 } 702 702 703 void CodeGenerator::visit( IfStmt * ifStmt ) {703 void CodeGenerator::visit( IfStmt * ifStmt ) { 704 704 output << "if ( "; 705 705 ifStmt->get_condition()->accept( *this ); … … 714 714 } 715 715 716 void CodeGenerator::visit( SwitchStmt * switchStmt ) {716 void CodeGenerator::visit( SwitchStmt * switchStmt ) { 717 717 output << "switch ( " ; 718 718 switchStmt->get_condition()->accept( *this ); … … 721 721 output << "{" << std::endl; 722 722 cur_indent += CodeGenerator::tabsize; 723 724 acceptAll( switchStmt->get_branches(), *this ); 725 723 acceptAll( switchStmt->get_statements(), *this ); 726 724 cur_indent -= CodeGenerator::tabsize; 727 728 725 output << indent << "}"; 729 726 } 730 727 731 void CodeGenerator::visit( CaseStmt * caseStmt ) {728 void CodeGenerator::visit( CaseStmt * caseStmt ) { 732 729 output << indent; 733 730 if ( caseStmt->isDefault()) { … … 750 747 } 751 748 752 void CodeGenerator::visit( BranchStmt * branchStmt ) {749 void CodeGenerator::visit( BranchStmt * branchStmt ) { 753 750 switch ( branchStmt->get_type()) { 754 751 case BranchStmt::Goto: … … 773 770 774 771 775 void CodeGenerator::visit( ReturnStmt * returnStmt ) {772 void CodeGenerator::visit( ReturnStmt * returnStmt ) { 776 773 output << "return "; 777 774 maybeAccept( returnStmt->get_expr(), *this ); … … 779 776 } 780 777 781 void CodeGenerator::visit( WhileStmt * whileStmt ) {778 void CodeGenerator::visit( WhileStmt * whileStmt ) { 782 779 if ( whileStmt->get_isDoWhile() ) { 783 780 output << "do" ; … … 801 798 } 802 799 803 void CodeGenerator::visit( ForStmt * forStmt ) {800 void CodeGenerator::visit( ForStmt * forStmt ) { 804 801 // initialization is always hoisted, so don't bother doing anything with that 805 802 output << "for (;"; … … 823 820 } 824 821 825 void CodeGenerator::visit( NullStmt * nullStmt ) {822 void CodeGenerator::visit( NullStmt * nullStmt ) { 826 823 //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() ); 827 824 output << "/* null statement */ ;"; 828 825 } 829 826 830 void CodeGenerator::visit( DeclStmt * declStmt ) {827 void CodeGenerator::visit( DeclStmt * declStmt ) { 831 828 declStmt->get_decl()->accept( *this ); 832 829 … … 836 833 } 837 834 838 void CodeGenerator::handleStorageClass( Declaration * decl ) {835 void CodeGenerator::handleStorageClass( Declaration * decl ) { 839 836 switch ( decl->get_storageClass() ) { 840 837 case DeclarationNode::Extern: -
src/ControlStruct/MLEMutator.cc
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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 … … 83 83 } 84 84 85 CommaExprNode *ExpressionNode::add_to_list( ExpressionNode *exp ) {86 return new CommaExprNode( this, exp );87 }85 // CommaExprNode *ExpressionNode::add_to_list( ExpressionNode *exp ) { 86 // return new CommaExprNode( this, exp ); 87 // } 88 88 89 89 //############################################################################## … … 246 246 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 247 247 "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", 248 "?[?]", "FieldSel", "PFieldSel", " Range",248 "?[?]", "FieldSel", "PFieldSel", "...", 249 249 // monadic 250 250 "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&" … … 616 616 } 617 617 618 CommaExprNode *CommaExprNode::add_to_list( ExpressionNode *exp ) {619 add_arg( exp );620 621 return this;622 }618 // CommaExprNode *CommaExprNode::add_to_list( ExpressionNode *exp ) { 619 // add_arg( exp ); 620 // 621 // return this; 622 // } 623 623 624 624 CommaExprNode::CommaExprNode( const CommaExprNode &other ) : CompositeExprNode( other ) { -
src/Parser/ParseNode.h
rf9cebb5 r4819cac 77 77 virtual ExpressionNode *clone() const = 0; 78 78 79 virtual CommaExprNode *add_to_list( ExpressionNode * );79 // virtual CommaExprNode *add_to_list( ExpressionNode * ); 80 80 81 81 ExpressionNode *get_argName() const { return argName; } … … 299 299 CommaExprNode( const CommaExprNode &other ); 300 300 301 virtual CommaExprNode *add_to_list( ExpressionNode * );301 // virtual CommaExprNode *add_to_list( ExpressionNode * ); 302 302 virtual CommaExprNode *clone() const { return new CommaExprNode( *this ); } 303 303 }; … … 485 485 std::string get_target() const; 486 486 487 StatementNode *add_controlexp( ExpressionNode * );487 // StatementNode *add_controlexp( ExpressionNode * ); 488 488 StatementNode *append_block( StatementNode * ); 489 489 StatementNode *append_last_case( StatementNode * ); -
src/Parser/StatementNode.cc
rf9cebb5 r4819cac 107 107 } 108 108 109 StatementNode *StatementNode::add_controlexp( ExpressionNode *e ) {110 if ( control && e )111 control->add_to_list( e ); // xxx - check this112 return this;113 }109 // StatementNode *StatementNode::add_controlexp( ExpressionNode *e ) { 110 // if ( control && e ) 111 // control->add_to_list( e ); // xxx - check this 112 // return this; 113 // } 114 114 115 115 StatementNode *StatementNode::append_block( StatementNode *stmt ) { -
src/Parser/parser.cc
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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 … … 529 529 } 530 530 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 } 531 539 532 540 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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
rf9cebb5 r4819cac 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/examples/gc_no_raii/bug-repro/return_template.c
rf9cebb5 r4819cac 5 5 }; 6 6 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 7 12 forall(otype T) 8 static inlinewrap(T) test()13 wrap(T) test() 9 14 { 10 15 wrap(T) tester; -
src/examples/gc_no_raii/src/gc.h
rf9cebb5 r4819cac 7 7 static inline gcpointer(T) gcmalloc() 8 8 { 9 gcpointer(T) test; 10 // ctor(&test, gc_allocate(sizeof(T))); 11 // gc_conditional_collect(); 12 return test; 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; 13 15 } -
src/examples/gc_no_raii/src/gcpointers.c
rf9cebb5 r4819cac 1 1 #include "gcpointers.h" 2 2 3 #include "gc.h"3 // #include "gc.h" 4 4 #include "internal/collector.h" 5 5 #include "internal/object_header.h" -
src/examples/gc_no_raii/src/gcpointers.h
rf9cebb5 r4819cac 10 10 }; 11 11 12 void gcpointer_ctor(gcpointer_t* this);13 void gcpointer_ctor(gcpointer_t* this, void* address);14 void gcpointer_ctor(gcpointer_t* this, gcpointer_t*other);15 void gcpointer_dtor(gcpointer_t* this);16 gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t*rhs);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); 17 17 18 18 //Logical operators … … 27 27 }; 28 28 29 forall(otype T) 30 static inline void ctor(gcpointer(T)* this) 31 { 32 gcpointer_ctor(&this->internal); 33 } 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); 34 36 35 // forall(otype T)36 // static inline void ctor(gcpointer(T)* this, int null)37 // {38 // gcpointer_ctor(&this->internal, NULL);39 // }40 37 41 forall(otype T) 42 static inline void ctor(gcpointer(T)* this, void* address) 43 { 44 gcpointer_ctor(&this->internal, address); 45 } 46 47 forall(otype T) 48 static inline void ctor(gcpointer(T)* this, gcpointer(T)* other) 49 { 50 gcpointer_ctor(&this->internal, other); 51 } 52 53 forall(otype T) 54 static inline void dtor(gcpointer(T)* this) 55 { 56 gcpointer_dtor(&this->internal); 57 } 58 59 forall(otype T) 60 static inline gcpointer(T)* ?=?(gcpointer(T)* this, gcpointer(T)* rhs) 61 { 62 gcpointer_assign(&this->internal, &rhs->internal); 63 return this; 64 } 65 66 forall(otype T) 67 static inline T *?(gcpointer(T) this) 68 { 69 return *(T*)this.internal.ptr; 70 } 38 forall(otype T) T *?(gcpointer(T) this); 71 39 72 40 //Logical operators 73 forall(otype T) 74 static inline int ?!=?(gcpointer(T) this, gcpointer(T) rhs) 75 { 76 return this.internal.ptr != rhs.internal.ptr; 77 } 78 79 forall(otype T) 80 static inline int ?==?(gcpointer(T) this, gcpointer(T) rhs) 81 { 82 return !(this == rhs); 83 } 84 85 forall(otype T) 86 extern struct gcpointer(T) 0; 41 forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs); 42 forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs); -
src/examples/gc_no_raii/src/internal/memory_pool.h
rf9cebb5 r4819cac 3 3 extern "C" { 4 4 #include <stdbool.h> 5 #include <stddef.h> 5 6 #include <stdint.h> 6 7 } -
src/examples/gc_no_raii/src/internal/state.h
rf9cebb5 r4819cac 1 1 #pragma once 2 2 3 #ifdef __cforall 4 extern "C" { 5 #endif 3 6 #include <stddef.h> 4 7 #include <stdint.h> 8 #ifdef __cforall 9 } 10 #endif 11 #include <vector> 5 12 6 13 #include "tools.h" 7 #include "vector.h"8 14 9 15 typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t; -
src/examples/gc_no_raii/src/tools/worklist.h
rf9cebb5 r4819cac 10 10 #endif 11 11 12 #include "vector.h"12 #include <vector> 13 13 14 14 typedef vector(intptr_t*, heap_allocator(intptr_t*)) worklist_t; -
src/examples/gc_no_raii/test/badlll.c
rf9cebb5 r4819cac 7 7 }; 8 8 9 void ?{}(List_t* this); 10 List_t* ?=?(List_t* this, List_t* rhs); 11 9 12 typedef gcpointer(List_t) LLL; 10 13 11 14 #define MAX (1024 * 1024) 12 15 13 LLL buildLLL(int sz) 16 // LLL buildLLL(int sz) 17 void bla() 14 18 { 15 19 int i; 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;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; 31 35 } 32 33 void 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 }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 // } 51 55 52 56 int main(void) … … 54 58 LLL mylll; 55 59 56 mylll = buildLLL(MAX);57 58 testLLL(mylll);60 // mylll = buildLLL(MAX); 61 // 62 // testLLL(mylll); 59 63 60 64 return 0; -
src/examples/gc_no_raii/test/gctest.c
rf9cebb5 r4819cac 7 7 int main() { 8 8 sout | "Bonjour au monde!\n"; 9 10 gcpointer(int) anInt = gcmalloc(); 9 11 } -
src/tests/switch.c
rf9cebb5 r4819cac 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.