Changes in / [4819cac:f9cebb5]
- Location:
- src
- Files:
-
- 2 added
- 33 edited
-
CodeGen/CodeGenerator.cc (modified) (46 diffs)
-
ControlStruct/CaseRangeMutator.cc (added)
-
ControlStruct/CaseRangeMutator.h (added)
-
ControlStruct/MLEMutator.cc (modified) (3 diffs)
-
ControlStruct/Mutate.cc (modified) (4 diffs)
-
ControlStruct/module.mk (modified) (2 diffs)
-
GenPoly/DeclMutator.cc (modified) (2 diffs)
-
GenPoly/PolyMutator.cc (modified) (2 diffs)
-
Makefile.in (modified) (6 diffs)
-
Parser/ExpressionNode.cc (modified) (4 diffs)
-
Parser/ParseNode.h (modified) (3 diffs)
-
Parser/StatementNode.cc (modified) (1 diff)
-
Parser/parser.cc (modified) (8 diffs)
-
Parser/parser.yy (modified) (4 diffs)
-
SymTab/AddVisit.h (modified) (2 diffs)
-
SynTree/AddStmtVisitor.cc (modified) (2 diffs)
-
SynTree/Expression.cc (modified) (2 diffs)
-
SynTree/Expression.h (modified) (3 diffs)
-
SynTree/Mutator.cc (modified) (3 diffs)
-
SynTree/Mutator.h (modified) (2 diffs)
-
SynTree/Statement.cc (modified) (4 diffs)
-
SynTree/Statement.h (modified) (4 diffs)
-
SynTree/SynTree.h (modified) (2 diffs)
-
SynTree/Visitor.cc (modified) (3 diffs)
-
SynTree/Visitor.h (modified) (2 diffs)
-
examples/gc_no_raii/bug-repro/return_template.c (modified) (1 diff)
-
examples/gc_no_raii/src/gc.h (modified) (1 diff)
-
examples/gc_no_raii/src/gcpointers.c (modified) (1 diff)
-
examples/gc_no_raii/src/gcpointers.h (modified) (2 diffs)
-
examples/gc_no_raii/src/internal/memory_pool.h (modified) (1 diff)
-
examples/gc_no_raii/src/internal/state.h (modified) (1 diff)
-
examples/gc_no_raii/src/tools/worklist.h (modified) (1 diff)
-
examples/gc_no_raii/test/badlll.c (modified) (2 diffs)
-
examples/gc_no_raii/test/gctest.c (modified) (1 diff)
-
tests/switch.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r4819cac rf9cebb5 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Aug 4 11:16:21201613 // Update Count : 3 5111 // Last Modified By : 12 // Last Modified On : Sun Jul 31 08:42:18 2016 13 // Update Count : 345 14 14 // 15 15 … … 48 48 } 49 49 50 void CodeGenerator::extension( Expression * expr ) {50 void CodeGenerator::extension( Expression *expr ) { 51 51 if ( expr->get_extension() ) { 52 52 output << "__extension__ "; … … 54 54 } // extension 55 55 56 void CodeGenerator::extension( Declaration * decl ) {56 void CodeGenerator::extension( Declaration *decl ) { 57 57 if ( decl->get_extension() ) { 58 58 output << "__extension__ "; … … 73 73 } 74 74 75 ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter & printLabels ) {75 ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter &printLabels ) { 76 76 std::list< Label > & labs = *printLabels.labels; 77 77 // l.unique(); // assumes a sorted list. Why not use set? Does order matter? … … 79 79 output << l.get_name() + ": "; 80 80 printLabels.cg.genAttributes( l.get_attributes() ); 81 } // for81 } 82 82 return output; 83 83 } 84 84 85 CodeGenerator::CodeGenerator( std::ostream & os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {}86 87 CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )85 CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {} 86 87 CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp ) 88 88 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) { 89 89 //output << std::string( init ); 90 90 } 91 91 92 CodeGenerator::CodeGenerator( std::ostream & os, char *init, int indentation, bool infunp )92 CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indentation, bool infunp ) 93 93 : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) { 94 94 //output << std::string( init ); 95 95 } 96 96 97 string mangleName( DeclarationWithType * decl ) {97 string mangleName( DeclarationWithType *decl ) { 98 98 if ( decl->get_mangleName() != "" ) { 99 99 // need to incorporate scope level in order to differentiate names for destructors … … 112 112 genCommaList( attr->get_parameters().begin(), attr->get_parameters().end() ); 113 113 output << ")"; 114 } // if114 } 115 115 output << ","; 116 } // for116 } 117 117 output << ")) "; 118 } // if118 } 119 119 } 120 120 121 121 122 122 //*** Declarations 123 void CodeGenerator::visit( FunctionDecl * functionDecl ) {123 void CodeGenerator::visit( FunctionDecl *functionDecl ) { 124 124 extension( functionDecl ); 125 125 genAttributes( functionDecl->get_attributes() ); … … 146 146 } 147 147 148 void CodeGenerator::visit( ObjectDecl * objectDecl ) {148 void CodeGenerator::visit( ObjectDecl *objectDecl ) { 149 149 extension( objectDecl ); 150 150 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 } // if280 } 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 } // if356 } 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() == " ..." ) { // case V1 ... V2 or case V1~V2476 if ( nameExpr->get_name() == "Range" ) { // 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 } // for666 } 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 acceptAll( switchStmt->get_statements(), *this ); 723 724 acceptAll( switchStmt->get_branches(), *this ); 725 724 726 cur_indent -= CodeGenerator::tabsize; 727 725 728 output << indent << "}"; 726 729 } 727 730 728 void CodeGenerator::visit( CaseStmt * caseStmt ) {731 void CodeGenerator::visit( CaseStmt *caseStmt ) { 729 732 output << indent; 730 733 if ( caseStmt->isDefault()) { … … 747 750 } 748 751 749 void CodeGenerator::visit( BranchStmt * branchStmt ) {752 void CodeGenerator::visit( BranchStmt *branchStmt ) { 750 753 switch ( branchStmt->get_type()) { 751 754 case BranchStmt::Goto: … … 770 773 771 774 772 void CodeGenerator::visit( ReturnStmt * returnStmt ) {775 void CodeGenerator::visit( ReturnStmt *returnStmt ) { 773 776 output << "return "; 774 777 maybeAccept( returnStmt->get_expr(), *this ); … … 776 779 } 777 780 778 void CodeGenerator::visit( WhileStmt * whileStmt ) {781 void CodeGenerator::visit( WhileStmt *whileStmt ) { 779 782 if ( whileStmt->get_isDoWhile() ) { 780 783 output << "do" ; … … 798 801 } 799 802 800 void CodeGenerator::visit( ForStmt * forStmt ) {803 void CodeGenerator::visit( ForStmt *forStmt ) { 801 804 // initialization is always hoisted, so don't bother doing anything with that 802 805 output << "for (;"; … … 820 823 } 821 824 822 void CodeGenerator::visit( NullStmt * nullStmt ) {825 void CodeGenerator::visit( NullStmt *nullStmt ) { 823 826 //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() ); 824 827 output << "/* null statement */ ;"; 825 828 } 826 829 827 void CodeGenerator::visit( DeclStmt * declStmt ) {830 void CodeGenerator::visit( DeclStmt *declStmt ) { 828 831 declStmt->get_decl()->accept( *this ); 829 832 … … 833 836 } 834 837 835 void CodeGenerator::handleStorageClass( Declaration * decl ) {838 void CodeGenerator::handleStorageClass( Declaration *decl ) { 836 839 switch ( decl->get_storageClass() ) { 837 840 case DeclarationNode::Extern: -
src/ControlStruct/MLEMutator.cc
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:21:32201613 // Update Count : 20212 // Last Modified On : Tue Jul 12 17:36:51 2016 13 // Update Count : 197 14 14 // 15 15 … … 128 128 Label brkLabel = generator->newLabel("switchBreak"); 129 129 enclosingControlStructures.push_back( Entry(switchStmt, brkLabel) ); 130 mutateAll( switchStmt->get_ statements(), *this );130 mutateAll( switchStmt->get_branches(), *this ); 131 131 132 132 Entry &e = enclosingControlStructures.back(); … … 138 138 // switch should be CastStmts), append the exit label + break to the last case statement; create a default 139 139 // case if there are no cases 140 std::list< Statement * > & statements = switchStmt->get_statements();141 if ( statements.empty() ) {142 statements.push_back( CaseStmt::makeDefault() );143 } // if 144 145 if ( CaseStmt * c = dynamic_cast< CaseStmt * >( statements.back() ) ) {140 std::list< Statement * > &branches = switchStmt->get_branches(); 141 if ( branches.empty() ) { 142 branches.push_back( CaseStmt::makeDefault() ); 143 } // if 144 145 if ( CaseStmt * c = dynamic_cast< CaseStmt * >( branches.back() ) ) { 146 146 std::list<Label> temp; temp.push_back( brkLabel ); 147 147 c->get_statements().push_back( new BranchStmt( temp, Label("brkLabel"), BranchStmt::Break ) ); 148 } else assert(0); // as of this point, all statements of a switch are still CaseStmts148 } else assert(0); // as of this point, all branches of a switch are still CaseStmts 149 149 } // if 150 150 -
src/ControlStruct/Mutate.cc
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:39:08201613 // Update Count : 912 // Last Modified On : Tue Jul 12 17:37:45 2016 13 // Update Count : 8 14 14 // 15 15 … … 22 22 #include "LabelFixer.h" 23 23 #include "MLEMutator.h" 24 #include "CaseRangeMutator.h" 24 25 #include "ForExprMutator.h" 25 26 #include "LabelTypeChecker.h" … … 40 41 LabelFixer lfix; 41 42 43 // expand case ranges and turn fallthru into a null statement 44 CaseRangeMutator ranges; 45 42 46 //ExceptMutator exc; 43 47 // LabelTypeChecker lbl; … … 45 49 mutateAll( translationUnit, formut ); 46 50 acceptAll( translationUnit, lfix ); 51 mutateAll( translationUnit, ranges ); 47 52 //mutateAll( translationUnit, exc ); 48 53 //acceptAll( translationUnit, lbl ); -
src/ControlStruct/module.mk
r4819cac rf9cebb5 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : T hu Aug 4 11:38:06201614 ## Update Count : 313 ## Last Modified On : Tue Jul 12 17:40:31 2016 14 ## Update Count : 2 15 15 ############################################################################### 16 16 … … 18 18 ControlStruct/LabelFixer.cc \ 19 19 ControlStruct/MLEMutator.cc \ 20 ControlStruct/CaseRangeMutator.cc \ 20 21 ControlStruct/Mutate.cc \ 21 22 ControlStruct/ForExprMutator.cc \ -
src/GenPoly/DeclMutator.cc
r4819cac rf9cebb5 10 10 // Created On : Fri Nov 27 14:44:00 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:16:43201613 // Update Count : 312 // Last Modified On : Tue Jul 12 17:38:46 2016 13 // Update Count : 2 14 14 // 15 15 … … 163 163 Statement* DeclMutator::mutate(SwitchStmt *switchStmt) { 164 164 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 165 mutateAll( switchStmt->get_ statements(), *this );165 mutateAll( switchStmt->get_branches(), *this ); 166 166 return switchStmt; 167 167 } -
src/GenPoly/PolyMutator.cc
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:26:22 201613 // Update Count : 1 612 // Last Modified On : Tue Jul 12 17:39:32 2016 13 // Update Count : 12 14 14 // 15 15 … … 99 99 100 100 Statement * PolyMutator::mutate(SwitchStmt *switchStmt) { 101 mutateStatementList( switchStmt->get_ statements() );101 mutateStatementList( switchStmt->get_branches() ); 102 102 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) ); 103 103 return switchStmt; -
src/Makefile.in
r4819cac rf9cebb5 108 108 ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) \ 109 109 ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) \ 110 ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT) \ 110 111 ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \ 111 112 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ … … 371 372 Common/SemanticError.cc Common/UniqueName.cc \ 372 373 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 373 ControlStruct/MLEMutator.cc ControlStruct/ Mutate.cc \374 ControlStruct/ ForExprMutator.cc \374 ControlStruct/MLEMutator.cc ControlStruct/CaseRangeMutator.cc \ 375 ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \ 375 376 ControlStruct/LabelTypeChecker.cc Designators/Processor.cc \ 376 377 GenPoly/Box.cc GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ … … 541 542 ControlStruct/$(DEPDIR)/$(am__dirstamp) 542 543 ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT): \ 544 ControlStruct/$(am__dirstamp) \ 545 ControlStruct/$(DEPDIR)/$(am__dirstamp) 546 ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT): \ 543 547 ControlStruct/$(am__dirstamp) \ 544 548 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 816 820 -rm -f Common/driver_cfa_cpp-SemanticError.$(OBJEXT) 817 821 -rm -f Common/driver_cfa_cpp-UniqueName.$(OBJEXT) 822 -rm -f ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT) 818 823 -rm -f ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) 819 824 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) … … 925 930 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@ 926 931 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-UniqueName.Po@am__quote@ 932 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po@am__quote@ 927 933 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-ForExprMutator.Po@am__quote@ 928 934 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ … … 1206 1212 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-MLEMutator.obj `if test -f 'ControlStruct/MLEMutator.cc'; then $(CYGPATH_W) 'ControlStruct/MLEMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/MLEMutator.cc'; fi` 1207 1213 1214 ControlStruct/driver_cfa_cpp-CaseRangeMutator.o: ControlStruct/CaseRangeMutator.cc 1215 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-CaseRangeMutator.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.o `test -f 'ControlStruct/CaseRangeMutator.cc' || echo '$(srcdir)/'`ControlStruct/CaseRangeMutator.cc 1216 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po 1217 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/CaseRangeMutator.cc' object='ControlStruct/driver_cfa_cpp-CaseRangeMutator.o' libtool=no @AMDEPBACKSLASH@ 1218 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1219 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.o `test -f 'ControlStruct/CaseRangeMutator.cc' || echo '$(srcdir)/'`ControlStruct/CaseRangeMutator.cc 1220 1221 ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj: ControlStruct/CaseRangeMutator.cc 1222 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj `if test -f 'ControlStruct/CaseRangeMutator.cc'; then $(CYGPATH_W) 'ControlStruct/CaseRangeMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/CaseRangeMutator.cc'; fi` 1223 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po 1224 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/CaseRangeMutator.cc' object='ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj' libtool=no @AMDEPBACKSLASH@ 1225 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1226 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj `if test -f 'ControlStruct/CaseRangeMutator.cc'; then $(CYGPATH_W) 'ControlStruct/CaseRangeMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/CaseRangeMutator.cc'; fi` 1227 1208 1228 ControlStruct/driver_cfa_cpp-Mutate.o: ControlStruct/Mutate.cc 1209 1229 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-Mutate.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Tpo -c -o ControlStruct/driver_cfa_cpp-Mutate.o `test -f 'ControlStruct/Mutate.cc' || echo '$(srcdir)/'`ControlStruct/Mutate.cc -
src/Parser/ExpressionNode.cc
r4819cac rf9cebb5 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Aug 2 15:10:23201613 // Update Count : 32 212 // Last Modified On : Tue Jul 5 13:41:55 2016 13 // Update Count : 320 14 14 // 15 15 … … 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", " ...",248 "?[?]", "FieldSel", "PFieldSel", "Range", 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
r4819cac rf9cebb5 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
r4819cac rf9cebb5 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
r4819cac rf9cebb5 1031 1031 631, 632, 638, 639, 640, 641, 642, 643, 644, 645, 1032 1032 646, 656, 663, 665, 675, 676, 681, 683, 689, 691, 1033 695, 696, 701, 706, 709, 711, 713, 72 3, 725, 736,1034 73 7, 739, 743, 744, 748, 749, 754, 755, 759, 764,1033 695, 696, 701, 706, 709, 711, 713, 722, 724, 735, 1034 736, 738, 742, 743, 748, 749, 754, 755, 759, 764, 1035 1035 765, 769, 771, 777, 778, 782, 784, 786, 788, 794, 1036 1036 795, 799, 801, 806, 808, 810, 815, 817, 822, 824, … … 6009 6009 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound 6010 6010 // statement around the switch. Statements after the initial declaration list can never be executed, and 6011 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 6012 // statement. 6011 // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement. 6013 6012 (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_link( sw )) ) : sw; 6014 6013 } … … 6018 6017 6019 6018 /* Line 1806 of yacc.c */ 6020 #line 72 4"parser.yy"6019 #line 723 "parser.yy" 6021 6020 { (yyval.sn) = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); } 6022 6021 break; … … 6025 6024 6026 6025 /* Line 1806 of yacc.c */ 6027 #line 72 6"parser.yy"6026 #line 725 "parser.yy" 6028 6027 { 6029 6028 StatementNode *sw = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ); … … 6035 6034 6036 6035 /* Line 1806 of yacc.c */ 6037 #line 73 6"parser.yy"6036 #line 735 "parser.yy" 6038 6037 { (yyval.en) = (yyvsp[(1) - (1)].en); } 6039 6038 break; … … 6042 6041 6043 6042 /* Line 1806 of yacc.c */ 6044 #line 73 8"parser.yy"6043 #line 737 "parser.yy" 6045 6044 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); } 6046 6045 break; 6047 6046 6048 case 162:6049 6050 /* Line 1806 of yacc.c */6051 #line 743 "parser.yy"6052 { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(1) - (1)].en), 0 ); }6053 break;6054 6055 6047 case 163: 6056 6048 6057 6049 /* Line 1806 of yacc.c */ 6058 6050 #line 744 "parser.yy" 6059 { (yyval. sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_link( new StatementNode( StatementNode::Case, (yyvsp[(3) - (3)].en), 0) ) ); }6051 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( (yyvsp[(1) - (3)].en) ))->set_link( (yyvsp[(3) - (3)].en) ) ); } 6060 6052 break; 6061 6053 … … 6064 6056 /* Line 1806 of yacc.c */ 6065 6057 #line 748 "parser.yy" 6066 { (yyval.sn) = (yyvsp[(2) - (3)].sn); }6058 { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(2) - (3)].en), 0 ); } 6067 6059 break; 6068 6060 … … 9425 9417 9426 9418 /* Line 1806 of yacc.c */ 9427 #line 942 8"Parser/parser.cc"9419 #line 9420 "Parser/parser.cc" 9428 9420 default: break; 9429 9421 } -
src/Parser/parser.yy
r4819cac rf9cebb5 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 11:28:18201613 // Update Count : 16 7212 // Last Modified On : Sat Jul 23 17:01:30 2016 13 // Update Count : 1668 14 14 // 15 15 … … 150 150 %type<sn> block_item_list block_item 151 151 %type<sn> case_clause 152 %type<en> case_value 153 %type<sn> case_ value_list case_label case_label_list152 %type<en> case_value case_value_list 153 %type<sn> case_label case_label_list 154 154 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 155 155 %type<pn> handler_list handler_clause finally_clause … … 717 717 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound 718 718 // statement around the switch. Statements after the initial declaration list can never be executed, and 719 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 720 // statement. 719 // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement. 721 720 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw; 722 721 } … … 741 740 742 741 case_value_list: // CFA 743 case_value { $$ = new StatementNode( StatementNode::Case, $1, 0 ); } 744 | case_value_list ',' case_value { $$ = (StatementNode *)($1->set_link( new StatementNode( StatementNode::Case, $3, 0 ) ) ); } 742 case_value 743 | case_value_list ',' case_value 744 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( $1 ))->set_link( $3 ) ); } 745 745 ; 746 746 747 747 case_label: // CFA 748 CASE case_value_list ':' { $$ = $2; }748 CASE case_value_list ':' { $$ = new StatementNode( StatementNode::Case, $2, 0 ); } 749 749 | DEFAULT ':' { $$ = new StatementNode( StatementNode::Default ); } 750 750 // A semantic check is required to ensure only one default clause per switch/choose statement. -
src/SymTab/AddVisit.h
r4819cac rf9cebb5 10 10 // Created On : Sun May 17 16:14:32 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:22:01201613 // Update Count : 912 // Last Modified On : Tue Jul 12 17:46:33 2016 13 // Update Count : 6 14 14 // 15 15 … … 33 33 template< typename Visitor > 34 34 inline void addVisit(SwitchStmt *switchStmt, Visitor &visitor) { 35 addVisitStatementList( switchStmt->get_ statements(), visitor );35 addVisitStatementList( switchStmt->get_branches(), visitor ); 36 36 maybeAccept( switchStmt->get_condition(), visitor ); 37 37 } -
src/SynTree/AddStmtVisitor.cc
r4819cac rf9cebb5 10 10 // Created On : Wed Jun 22 12:11:17 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:23:47201613 // Update Count : 1 612 // Last Modified On : Tue Jul 12 17:49:59 2016 13 // Update Count : 12 14 14 // 15 15 … … 71 71 72 72 void AddStmtVisitor::visit(SwitchStmt *switchStmt) { 73 visitStatementList( switchStmt->get_ statements() );73 visitStatementList( switchStmt->get_branches() ); 74 74 maybeAccept( switchStmt->get_condition(), *this ); 75 75 } -
src/SynTree/Expression.cc
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 17:06:51201613 // Update Count : 4 512 // Last Modified On : Mon Jun 13 16:03:39 2016 13 // Update Count : 42 14 14 // 15 15 … … 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 }539 531 540 532 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 17:08:44201613 // Update Count : 2 712 // Last Modified On : Mon Jul 4 14:45:32 2016 13 // Update Count : 23 14 14 // 15 15 … … 18 18 19 19 #include <map> 20 #include <memory>21 20 #include "SynTree.h" 22 21 #include "Visitor.h" … … 635 634 }; 636 635 637 class RangeExpr : public Expression {638 public:639 RangeExpr( ConstantExpr *low, ConstantExpr *high );640 RangeExpr( const RangeExpr &other );641 642 ConstantExpr * get_low() const { return low.get(); }643 ConstantExpr * get_high() const { return high.get(); }644 RangeExpr * set_low( ConstantExpr *low ) { RangeExpr::low.reset( low ); return this; }645 RangeExpr * set_high( ConstantExpr *high ) { RangeExpr::high.reset( high ); return this; }646 647 virtual RangeExpr *clone() const { return new RangeExpr( *this ); }648 virtual void accept( Visitor &v ) { v.visit( this ); }649 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }650 virtual void print( std::ostream &os, int indent = 0 ) const;651 private:652 std::unique_ptr<ConstantExpr> low, high;653 };654 655 636 std::ostream & operator<<( std::ostream & out, Expression * expr ); 656 637 -
src/SynTree/Mutator.cc
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:23:21201613 // Update Count : 1 912 // Last Modified On : Tue Jul 12 17:51:19 2016 13 // Update Count : 17 14 14 // 15 15 … … 126 126 Statement *Mutator::mutate( SwitchStmt *switchStmt ) { 127 127 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 128 mutateAll( switchStmt->get_ statements(), *this );128 mutateAll( switchStmt->get_branches(), *this ); 129 129 return switchStmt; 130 130 } … … 349 349 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 350 350 return compLitExpr; 351 }352 353 Expression *Mutator::mutate( RangeExpr *rangeExpr ) {354 rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );355 rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );356 return rangeExpr;357 351 } 358 352 -
src/SynTree/Mutator.h
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 16:59:45201613 // Update Count : 1 212 // Last Modified On : Tue Jul 12 17:51:43 2016 13 // Update Count : 11 14 14 // 15 15 #include <cassert> … … 78 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 80 virtual Expression* mutate( RangeExpr *rangeExpr );81 80 82 81 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/Statement.cc
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:25:20201613 // Update Count : 6112 // Last Modified On : Tue Jul 12 17:52:32 2016 13 // Update Count : 55 14 14 // 15 15 … … 143 143 } 144 144 145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_ statements ):146 Statement( _labels ), condition( _condition ), statements( _statements ) {145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ): 146 Statement( _labels ), condition( _condition ), branches( _branches ) { 147 147 } 148 148 149 149 SwitchStmt::SwitchStmt( const SwitchStmt & other ): 150 150 Statement( other ), condition( maybeClone( other.condition ) ) { 151 cloneAll( other. statements, statements );151 cloneAll( other.branches, branches ); 152 152 } 153 153 154 154 SwitchStmt::~SwitchStmt() { 155 155 delete condition; 156 // destroy statements 157 } 156 // destroy branches 157 } 158 159 void SwitchStmt::add_case( CaseStmt *c ) {} 158 160 159 161 void SwitchStmt::print( std::ostream &os, int indent ) const { … … 162 164 os << endl; 163 165 164 // statements166 // branches 165 167 std::list<Statement *>::const_iterator i; 166 for ( i = statements.begin(); i != statements.end(); i++)168 for ( i = branches.begin(); i != branches.end(); i++) 167 169 (*i)->print( os, indent + 4 ); 168 170 169 //for_each( statements.begin(), statements.end(), mem_fun( bind1st(&Statement::print ), os ));171 //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os )); 170 172 } 171 173 … … 185 187 } 186 188 187 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) {188 return new CaseStmt( labels, 0, stmts, true );189 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> branches ) { 190 return new CaseStmt( labels, 0, branches, true ); 189 191 } 190 192 -
src/SynTree/Statement.h
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:26:02201613 // Update Count : 6412 // Last Modified On : Tue Jul 12 17:53:29 2016 13 // Update Count : 47 14 14 // 15 15 … … 129 129 class SwitchStmt : public Statement { 130 130 public: 131 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> & statements );131 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches ); 132 132 SwitchStmt( const SwitchStmt &other ); 133 133 virtual ~SwitchStmt(); … … 136 136 void set_condition( Expression *newValue ) { condition = newValue; } 137 137 138 std::list<Statement *> & get_statements() { return statements; } 138 std::list<Statement *> & get_branches() { return branches; } 139 void add_case( CaseStmt * ); 139 140 140 141 virtual void accept( Visitor &v ) { v.visit( this ); } … … 145 146 private: 146 147 Expression * condition; 147 std::list<Statement *> statements;148 std::list<Statement *> branches; // should be list of CaseStmt 148 149 }; 149 150 150 151 class CaseStmt : public Statement { 151 152 public: 152 CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 153 CaseStmt( std::list<Label> labels, Expression *conditions, 154 std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 153 155 CaseStmt( const CaseStmt &other ); 154 156 virtual ~CaseStmt(); 155 157 156 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() ); 158 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), 159 std::list<Statement *> stmts = std::list<Statement *>() ); 157 160 158 161 bool isDefault() const { return _isDefault; } -
src/SynTree/SynTree.h
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 17:02:34201613 // Update Count : 712 // Last Modified On : Tue Jul 12 17:54:02 2016 13 // Update Count : 6 14 14 // 15 15 … … 83 83 class UntypedValofExpr; 84 84 class CompoundLiteralExpr; 85 class RangeExpr;86 85 87 86 class Type; -
src/SynTree/Visitor.cc
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 4 11:24:25201613 // Update Count : 2112 // Last Modified On : Tue Jul 12 17:54:39 2016 13 // Update Count : 19 14 14 // 15 15 … … 109 109 void Visitor::visit( SwitchStmt *switchStmt ) { 110 110 maybeAccept( switchStmt->get_condition(), *this ); 111 acceptAll( switchStmt->get_ statements(), *this );111 acceptAll( switchStmt->get_branches(), *this ); 112 112 } 113 113 … … 296 296 maybeAccept( compLitExpr->get_type(), *this ); 297 297 maybeAccept( compLitExpr->get_initializer(), *this ); 298 }299 300 void Visitor::visit( RangeExpr *rangeExpr ) {301 maybeAccept( rangeExpr->get_low(), *this );302 maybeAccept( rangeExpr->get_high(), *this );303 298 } 304 299 -
src/SynTree/Visitor.h
r4819cac rf9cebb5 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 3 17:01:50201613 // Update Count : 912 // Last Modified On : Tue Jul 12 17:55:09 2016 13 // Update Count : 8 14 14 // 15 15 … … 78 78 virtual void visit( UntypedValofExpr *valofExpr ); 79 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 80 virtual void visit( RangeExpr *rangeExpr );81 80 82 81 virtual void visit( VoidType *basicType ); -
src/examples/gc_no_raii/bug-repro/return_template.c
r4819cac rf9cebb5 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 12 7 forall(otype T) 13 wrap(T) test()8 static inline wrap(T) test() 14 9 { 15 10 wrap(T) tester; -
src/examples/gc_no_raii/src/gc.h
r4819cac rf9cebb5 7 7 static inline gcpointer(T) gcmalloc() 8 8 { 9 gcpointer(T) ptr; 10 void* address = gc_allocate(sizeof(T)); 11 (&ptr){ address }; 12 ctor(&ptr, address); 13 gc_conditional_collect(); 14 return ptr; 9 gcpointer(T) test; 10 // ctor(&test, gc_allocate(sizeof(T))); 11 // gc_conditional_collect(); 12 return test; 15 13 } -
src/examples/gc_no_raii/src/gcpointers.c
r4819cac rf9cebb5 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
r4819cac rf9cebb5 10 10 }; 11 11 12 void ?{}(gcpointer_t* this);13 void ?{}(gcpointer_t* this, void* address);14 void ?{}(gcpointer_t* this, gcpointer_tother);15 void ^?{}(gcpointer_t* this);16 gcpointer_t* ?=?(gcpointer_t this, gcpointer_trhs);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); 17 17 18 18 //Logical operators … … 27 27 }; 28 28 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); 29 forall(otype T) 30 static inline void ctor(gcpointer(T)* this) 31 { 32 gcpointer_ctor(&this->internal); 33 } 36 34 35 // forall(otype T) 36 // static inline void ctor(gcpointer(T)* this, int null) 37 // { 38 // gcpointer_ctor(&this->internal, NULL); 39 // } 37 40 38 forall(otype T) T *?(gcpointer(T) this); 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 } 39 71 40 72 //Logical operators 41 forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs); 42 forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs); 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; -
src/examples/gc_no_raii/src/internal/memory_pool.h
r4819cac rf9cebb5 3 3 extern "C" { 4 4 #include <stdbool.h> 5 #include <stddef.h>6 5 #include <stdint.h> 7 6 } -
src/examples/gc_no_raii/src/internal/state.h
r4819cac rf9cebb5 1 1 #pragma once 2 2 3 #ifdef __cforall4 extern "C" {5 #endif6 3 #include <stddef.h> 7 4 #include <stdint.h> 8 #ifdef __cforall9 }10 #endif11 #include <vector>12 5 13 6 #include "tools.h" 7 #include "vector.h" 14 8 15 9 typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t; -
src/examples/gc_no_raii/src/tools/worklist.h
r4819cac rf9cebb5 10 10 #endif 11 11 12 #include <vector>12 #include "vector.h" 13 13 14 14 typedef vector(intptr_t*, heap_allocator(intptr_t*)) worklist_t; -
src/examples/gc_no_raii/test/badlll.c
r4819cac rf9cebb5 7 7 }; 8 8 9 void ?{}(List_t* this);10 List_t* ?=?(List_t* this, List_t* rhs);11 12 9 typedef gcpointer(List_t) LLL; 13 10 14 11 #define MAX (1024 * 1024) 15 12 16 // LLL buildLLL(int sz) 17 void bla() 13 LLL buildLLL(int sz) 18 14 { 19 15 int i; 20 // LLL ll0;//, lll, llc;21 // 22 //ll0 = gcmalloc();23 //ll0->val = 0;24 //lll = ll0;25 // 26 //for (i = 1; i < sz; i++)27 //{28 //llc = gcmalloc();29 //llc->val = i;30 //lll->next = llc;31 //lll = llc;32 //}33 // 34 //return ll0;16 LLL ll0, lll, llc; 17 18 ll0 = gcmalloc(); 19 ll0->val = 0; 20 lll = ll0; 21 22 for (i = 1; i < sz; i++) 23 { 24 llc = gcmalloc(); 25 llc->val = i; 26 lll->next = llc; 27 lll = llc; 28 } 29 30 return ll0; 35 31 } 36 // 37 //void testLLL(LLL lll)38 //{39 //unsigned char *counted;40 // 41 //counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));42 //while (lll)43 //{44 //counted[lll->val]++;45 //if (counted[lll->val] > 1)46 //{47 //fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);48 //exit(1);49 //}50 //lll = lll->next;51 //}52 // 53 //return;54 //}32 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 } 55 51 56 52 int main(void) … … 58 54 LLL mylll; 59 55 60 //mylll = buildLLL(MAX);61 // 62 //testLLL(mylll);56 mylll = buildLLL(MAX); 57 58 testLLL(mylll); 63 59 64 60 return 0; -
src/examples/gc_no_raii/test/gctest.c
r4819cac rf9cebb5 7 7 int main() { 8 8 sout | "Bonjour au monde!\n"; 9 10 gcpointer(int) anInt = gcmalloc();11 9 } -
src/tests/switch.c
r4819cac rf9cebb5 10 10 // Created On : Tue Jul 12 06:50:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 11:44:29201613 // Update Count : 3 112 // Last Modified On : Sat Jul 30 14:41:32 2016 13 // Update Count : 30 14 14 // 15 15 … … 39 39 case 4: 40 40 j = 0; 41 }42 43 switch ( i ) {44 case 1, 2, 3:45 switch ( i ) {46 case 2, 3, 4:47 7;48 }49 41 } 50 42
Note:
See TracChangeset
for help on using the changeset viewer.