- Timestamp:
- Jun 14, 2016, 1:23:18 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 545ef59, c738ca4, ee51534
- Parents:
- 6cbc25a (diff), c8c03683 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 32 edited
-
CodeGen/CodeGenerator.cc (modified) (15 diffs)
-
CodeGen/CodeGenerator.h (modified) (2 diffs)
-
Common/utility.h (modified) (2 diffs)
-
Parser/ExpressionNode.cc (modified) (10 diffs)
-
Parser/ParseNode.h (modified) (6 diffs)
-
Parser/StatementNode.cc (modified) (4 diffs)
-
Parser/parser.cc (modified) (5 diffs)
-
Parser/parser.yy (modified) (5 diffs)
-
ResolvExpr/AlternativeFinder.cc (modified) (2 diffs)
-
SynTree/Expression.cc (modified) (3 diffs)
-
SynTree/Expression.h (modified) (3 diffs)
-
Tests/Abstype.c (modified) (2 diffs)
-
Tests/Attributes.c (modified) (4 diffs)
-
Tests/InferParam.c (modified) (3 diffs)
-
Tests/Makefile (modified) (2 diffs)
-
Tests/Members.c (modified) (1 diff)
-
Tests/OccursError.c (modified) (1 diff)
-
Tests/Quad.c (modified) (1 diff)
-
Tests/Rank2.c (modified) (2 diffs)
-
driver/cc1.cc (modified) (2 diffs)
-
driver/cfa.cc (modified) (3 diffs)
-
libcfa/Makefile.am (modified) (2 diffs)
-
tests/Array.c (modified) (2 diffs)
-
tests/Forall.c (modified) (6 diffs)
-
tests/Functions.c (modified) (1 diff)
-
tests/GccExtensions.c (modified) (1 diff)
-
tests/Scope.c (modified) (2 diffs)
-
tests/Subrange.c (modified) (5 diffs)
-
tests/TypeGenerator.c (modified) (2 diffs)
-
tests/Typedef.c (modified) (2 diffs)
-
tests/Typeof.c (modified) (1 diff)
-
tests/io.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r6cbc25a r7ff30d07 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri May 06 16:01:00 201613 // Update Count : 25 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 9 13:21:00 2016 13 // Update Count : 256 14 14 // 15 15 … … 251 251 //*** Expressions 252 252 void CodeGenerator::visit( ApplicationExpr *applicationExpr ) { 253 extension( applicationExpr ); 253 254 if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) { 254 255 OperatorInfo opInfo; … … 366 367 367 368 void CodeGenerator::visit( UntypedExpr *untypedExpr ) { 369 extension( untypedExpr ); 368 370 if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) { 369 371 OperatorInfo opInfo; … … 450 452 451 453 void CodeGenerator::visit( NameExpr *nameExpr ) { 454 extension( nameExpr ); 452 455 OperatorInfo opInfo; 453 456 if ( operatorLookup( nameExpr->get_name(), opInfo ) ) { … … 460 463 461 464 void CodeGenerator::visit( AddressExpr *addressExpr ) { 465 extension( addressExpr ); 462 466 output << "(&"; 463 467 // this hack makes sure that we don't convert "constant_zero" to "0" if we're taking its address … … 471 475 472 476 void CodeGenerator::visit( CastExpr *castExpr ) { 477 extension( castExpr ); 473 478 output << "("; 474 479 if ( castExpr->get_results().empty() ) { … … 493 498 494 499 void CodeGenerator::visit( MemberExpr *memberExpr ) { 500 extension( memberExpr ); 495 501 memberExpr->get_aggregate()->accept( *this ); 496 502 output << "." << mangleName( memberExpr->get_member() ); … … 498 504 499 505 void CodeGenerator::visit( VariableExpr *variableExpr ) { 506 extension( variableExpr ); 500 507 OperatorInfo opInfo; 501 508 if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( variableExpr->get_var()->get_name(), opInfo ) && opInfo.type == OT_CONSTANT ) { … … 508 515 void CodeGenerator::visit( ConstantExpr *constantExpr ) { 509 516 assert( constantExpr->get_constant() ); 517 extension( constantExpr ); 510 518 constantExpr->get_constant()->accept( *this ); 511 519 } 512 520 513 521 void CodeGenerator::visit( SizeofExpr *sizeofExpr ) { 522 extension( sizeofExpr ); 514 523 output << "sizeof("; 515 524 if ( sizeofExpr->get_isType() ) { … … 522 531 523 532 void CodeGenerator::visit( AlignofExpr *alignofExpr ) { 533 extension( alignofExpr ); 524 534 // use GCC extension to avoid bumping std to C11 525 535 output << "__alignof__("; … … 537 547 538 548 void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) { 549 extension( offsetofExpr ); 539 550 // use GCC builtin 540 551 output << "__builtin_offsetof("; … … 549 560 550 561 void CodeGenerator::visit( LogicalExpr *logicalExpr ) { 562 extension( logicalExpr ); 551 563 output << "("; 552 564 logicalExpr->get_arg1()->accept( *this ); … … 561 573 562 574 void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) { 575 extension( conditionalExpr ); 563 576 output << "("; 564 577 conditionalExpr->get_arg1()->accept( *this ); … … 571 584 572 585 void CodeGenerator::visit( CommaExpr *commaExpr ) { 586 extension( commaExpr ); 573 587 output << "("; 574 588 commaExpr->get_arg1()->accept( *this ); … … 583 597 584 598 void CodeGenerator::visit( AsmExpr *asmExpr ) { 599 extension( asmExpr ); 585 600 if ( asmExpr->get_inout() ) { 586 601 output << "[ "; -
src/CodeGen/CodeGenerator.h
r6cbc25a r7ff30d07 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:32:24201613 // Update Count : 2 812 // Last Modified On : Thu Jun 9 13:15:58 2016 13 // Update Count : 29 14 14 // 15 15 … … 96 96 std::ostream& operator()(std::ostream & os); 97 97 }; 98 99 void extension( Expression *expr ) { 100 if ( expr->get_extension() ) { 101 output << "__extension__ "; 102 } // if 103 } // extension 98 104 private: 99 105 -
src/Common/utility.h
r6cbc25a r7ff30d07 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Thu Apr 28 13:18:24201613 // Update Count : 1611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 8 17:33:59 2016 13 // Update Count : 22 14 14 // 15 15 … … 33 33 } 34 34 35 template<typename T, typename U> 36 struct maybeBuild_t { 37 static T * doit( const U *orig ) { 38 if ( orig ) { 39 return orig->build(); 40 } else { 41 return 0; 42 } // if 43 } 44 }; 45 35 46 template< typename T, typename U > 36 47 static inline T * maybeBuild( const U *orig ) { 37 if ( orig ) { 38 return orig->build(); 39 } else { 40 return 0; 41 } // if 48 return maybeBuild_t<T,U>::doit(orig); 42 49 } 43 50 -
src/Parser/ExpressionNode.cc
r6cbc25a r7ff30d07 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 15:43:05201613 // Update Count : 29612 // Last Modified On : Mon Jun 13 14:46:17 2016 13 // Update Count : 307 14 14 // 15 15 … … 32 32 using namespace std; 33 33 34 ExpressionNode::ExpressionNode() : ParseNode() , argName( 0 ){}35 36 ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name ) , argName( 0 ){}37 38 ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ) {34 ExpressionNode::ExpressionNode() : ParseNode() {} 35 36 ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name ) {} 37 38 ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ), extension( other.extension ) { 39 39 if ( other.argName ) { 40 40 argName = other.argName->clone(); … … 344 344 345 345 Expression *DesignatorNode::build() const { 346 Expression * ret = get_argName()->build();346 Expression * ret = maybeBuild<Expression>(get_argName()); 347 347 348 348 if ( isArrayIndex ) { … … 389 389 "Cond", "NCond", 390 390 // diadic 391 "SizeOf", "AlignOf", "OffsetOf", "Attr", " CompLit", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",391 "SizeOf", "AlignOf", "OffsetOf", "Attr", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&", 392 392 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 393 393 "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", … … 466 466 467 467 if ( ! ( op = dynamic_cast<OperatorNode *>( function ) ) ) { // function as opposed to operator 468 return new UntypedExpr( function->build(), args, maybeBuild< Expression >( get_argName() ));468 return new UntypedExpr( maybeBuild<Expression>(function), args, maybeBuild< Expression >( get_argName() )); 469 469 } // if 470 470 … … 550 550 if ( dynamic_cast< VoidType* >( targetType ) ) { 551 551 delete targetType; 552 return new CastExpr( expr_node->build(), maybeBuild< Expression >( get_argName() ) );552 return new CastExpr( maybeBuild<Expression>(expr_node), maybeBuild< Expression >( get_argName() ) ); 553 553 } else { 554 return new CastExpr( expr_node->build(),targetType, maybeBuild< Expression >( get_argName() ) );554 return new CastExpr( maybeBuild<Expression>(expr_node),targetType, maybeBuild< Expression >( get_argName() ) ); 555 555 } // if 556 556 } … … 621 621 assert( var ); 622 622 if ( ! get_args()->get_link() ) { 623 return new AttrExpr( var->build(), ( Expression*)0);623 return new AttrExpr( maybeBuild<Expression>(var), ( Expression*)0); 624 624 } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link()) ) { 625 return new AttrExpr( var->build(), arg->get_decl()->buildType());625 return new AttrExpr( maybeBuild<Expression>(var), arg->get_decl()->buildType()); 626 626 } else { 627 return new AttrExpr( var->build(), args.back()); 628 } // if 629 } 630 case OperatorNode::CompLit: 631 throw UnimplementedError( "C99 compound literals" ); 632 // the short-circuited operators 627 return new AttrExpr( maybeBuild<Expression>(var), args.back()); 628 } // if 629 } 633 630 case OperatorNode::Or: 634 631 case OperatorNode::And: … … 719 716 720 717 Expression *AsmExprNode::build() const { 721 return new AsmExpr( maybeBuild< Expression >( inout ), (ConstantExpr *) constraint->build(), operand->build() );718 return new AsmExpr( maybeBuild< Expression >( inout ), (ConstantExpr *)maybeBuild<Expression>(constraint), maybeBuild<Expression>(operand) ); 722 719 } 723 720 … … 796 793 797 794 Expression *ValofExprNode::build() const { 798 return new UntypedValofExpr ( get_body()->build(), maybeBuild< Expression >( get_argName() ) );795 return new UntypedValofExpr ( maybeBuild<Statement>(get_body()), maybeBuild< Expression >( get_argName() ) ); 799 796 } 800 797 … … 908 905 909 906 Expression *CompoundLiteralNode::build() const { 910 Declaration * newDecl = type->build();// compound literal type907 Declaration * newDecl = maybeBuild<Declaration>(type); // compound literal type 911 908 if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type 912 return new CompoundLiteralExpr( newDeclWithType->get_type(), kids->build() );909 return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeBuild<Initializer>(kids) ); 913 910 // these types do not have associated type information 914 911 } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl ) ) { 915 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), kids->build() );912 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeBuild<Initializer>(kids) ); 916 913 } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl ) ) { 917 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), kids->build() );914 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeBuild<Initializer>(kids) ); 918 915 } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl ) ) { 919 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), kids->build() );916 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeBuild<Initializer>(kids) ); 920 917 } else { 921 918 assert( false ); -
src/Parser/ParseNode.h
r6cbc25a r7ff30d07 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:28:16 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Thu Apr 14 15:37:52201613 // Update Count : 2 0511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 13 16:04:47 2016 13 // Update Count : 240 14 14 // 15 15 … … 20 20 #include <list> 21 21 #include <iterator> 22 #include <memory> 22 23 23 24 #include "Common/utility.h" 24 25 #include "Parser/LinkageSpec.h" 25 26 #include "SynTree/Type.h" 27 #include "SynTree/Expression.h" 26 28 //#include "SynTree/Declaration.h" 27 29 #include "Common/UniqueName.h" … … 79 81 ExpressionNode *set_argName( const std::string *aName ); 80 82 ExpressionNode *set_argName( ExpressionNode *aDesignator ); 83 bool get_extension() const { return extension; } 84 ExpressionNode *set_extension( bool exten ) { extension = exten; return this; } 81 85 82 86 virtual void print( std::ostream &, int indent = 0) const = 0; … … 87 91 void printDesignation ( std::ostream &, int indent = 0) const; 88 92 private: 89 ExpressionNode *argName; 93 ExpressionNode *argName = 0; 94 bool extension = false; 95 }; 96 97 template< typename T > 98 struct maybeBuild_t<Expression, T> { 99 static inline Expression * doit( const T *orig ) { 100 if ( orig ) { 101 Expression *p = orig->build(); 102 p->set_extension( orig->get_extension() ); 103 return p; 104 } else { 105 return 0; 106 } // if 107 } 90 108 }; 91 109 … … 179 197 Cond, NCond, 180 198 // diadic 181 SizeOf, AlignOf, OffsetOf, Attr, CompLit,Plus, Minus, Mul, Div, Mod, Or, And,199 SizeOf, AlignOf, OffsetOf, Attr, Plus, Minus, Mul, Div, Mod, Or, And, 182 200 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq, 183 201 Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn, … … 574 592 while ( cur ) { 575 593 try { 576 SynTreeType *result = dynamic_cast< SynTreeType *>( cur->build() ); 594 // SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::result_of<decltype(&NodeType::build)(NodeType)>::type>( cur ) ); 595 SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::pointer_traits<decltype(cur->build())>::element_type>( cur ) ); 577 596 if ( result ) { 578 597 *out++ = result; -
src/Parser/StatementNode.cc
r6cbc25a r7ff30d07 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Ju l 30 14:39:39 201513 // Update Count : 13 012 // Last Modified On : Thu Jun 9 14:18:46 2016 13 // Update Count : 132 14 14 // 15 15 … … 222 222 branches.pop_front(); 223 223 } // if 224 return new IfStmt( labs, notZeroExpr( get_control()->build() ), thenb, elseb );224 return new IfStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), thenb, elseb ); 225 225 } 226 226 case While: 227 227 assert( branches.size() == 1 ); 228 return new WhileStmt( labs, notZeroExpr( get_control()->build() ), branches.front() );228 return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front() ); 229 229 case Do: 230 230 assert( branches.size() == 1 ); 231 return new WhileStmt( labs, notZeroExpr( get_control()->build() ), branches.front(), true );231 return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front(), true ); 232 232 case For: 233 233 { … … 244 244 Expression *cond = 0; 245 245 if ( ctl->get_condition() != 0 ) 246 cond = notZeroExpr( ctl->get_condition()->build() );246 cond = notZeroExpr( maybeBuild<Expression>(ctl->get_condition()) ); 247 247 248 248 Expression *incr = 0; 249 249 if ( ctl->get_change() != 0 ) 250 incr = ctl->get_change()->build();250 incr = maybeBuild<Expression>(ctl->get_change()); 251 251 252 252 return new ForStmt( labs, init, cond, incr, branches.front() ); 253 253 } 254 254 case Switch: 255 return new SwitchStmt( labs, get_control()->build(), branches );255 return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches ); 256 256 case Choose: 257 return new ChooseStmt( labs, get_control()->build(), branches );257 return new ChooseStmt( labs, maybeBuild<Expression>(get_control()), branches ); 258 258 case Fallthru: 259 259 return new FallthruStmt( labs ); 260 260 case Case: 261 return new CaseStmt( labs, get_control()->build(), branches );261 return new CaseStmt( labs, maybeBuild<Expression>(get_control()), branches ); 262 262 case Default: 263 263 return new CaseStmt( labs, 0, branches, true ); … … 266 266 if ( get_target() == "" ) { // computed goto 267 267 assert( get_control() != 0 ); 268 return new BranchStmt( labs, get_control()->build(), BranchStmt::Goto );268 return new BranchStmt( labs, maybeBuild<Expression>(get_control()), BranchStmt::Goto ); 269 269 } // if 270 270 -
src/Parser/parser.cc
r6cbc25a r7ff30d07 5299 5299 /* Line 1806 of yacc.c */ 5300 5300 #line 432 "parser.yy" 5301 { (yyval.en) = (yyvsp[(2) - (2)].en) ; }5301 { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); } 5302 5302 break; 5303 5303 … … 5809 5809 /* Line 1806 of yacc.c */ 5810 5810 #line 685 "parser.yy" 5811 { (yyval.sn) = new StatementNode( (yyvsp[(2) - (2)].decl) ) ; }5811 { (yyval.sn) = new StatementNode( (yyvsp[(2) - (2)].decl) )/*->set_extension( true )*/; } 5812 5812 break; 5813 5813 … … 7122 7122 /* Line 1806 of yacc.c */ 7123 7123 #line 1475 "parser.yy" 7124 { (yyval.decl) = (yyvsp[(2) - (3)].decl) ; }7124 { (yyval.decl) = (yyvsp[(2) - (3)].decl)/*->set_extension( true )*/; } 7125 7125 break; 7126 7126 … … 7129 7129 /* Line 1806 of yacc.c */ 7130 7130 #line 1478 "parser.yy" 7131 { (yyval.decl) = (yyvsp[(2) - (3)].decl) ; }7131 { (yyval.decl) = (yyvsp[(2) - (3)].decl)/*->set_extension( true )*/; } 7132 7132 break; 7133 7133 … … 7913 7913 /* Line 1806 of yacc.c */ 7914 7914 #line 1994 "parser.yy" 7915 { (yyval.decl) = (yyvsp[(2) - (2)].decl) ; }7915 { (yyval.decl) = (yyvsp[(2) - (2)].decl)/*->set_extension( true )*/; } 7916 7916 break; 7917 7917 -
src/Parser/parser.yy
r6cbc25a r7ff30d07 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 7 08:08:31201613 // Update Count : 15 6012 // Last Modified On : Mon Jun 13 15:00:23 2016 13 // Update Count : 1578 14 14 // 15 15 … … 430 430 { $$ = $1; } 431 431 | EXTENSION cast_expression // GCC 432 { $$ = $2 ; }432 { $$ = $2->set_extension( true ); } 433 433 | ptrref_operator cast_expression // CFA 434 434 { $$ = new CompositeExprNode( $1, $2 ); } … … 683 683 { $$ = new StatementNode( $1 ); } 684 684 | EXTENSION declaration // GCC 685 { $$ = new StatementNode( $2 ) ; }685 { $$ = new StatementNode( $2 )/*->set_extension( true )*/; } 686 686 | function_definition 687 687 { $$ = new StatementNode( $1 ); } … … 1473 1473 new_field_declaring_list ';' // CFA, new style field declaration 1474 1474 | EXTENSION new_field_declaring_list ';' // GCC 1475 { $$ = $2 ; }1475 { $$ = $2/*->set_extension( true )*/; } 1476 1476 | field_declaring_list ';' 1477 1477 | EXTENSION field_declaring_list ';' // GCC 1478 { $$ = $2 ; }1478 { $$ = $2/*->set_extension( true )*/; } 1479 1479 ; 1480 1480 … … 1992 1992 } 1993 1993 | EXTENSION external_definition 1994 { $$ = $2 ; }1994 { $$ = $2/*->set_extension( true )*/; } 1995 1995 ; 1996 1996 -
src/ResolvExpr/AlternativeFinder.cc
r6cbc25a r7ff30d07 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 23:52:08 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 20 14:24:03201613 // Update Count : 2 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 13 16:13:54 2016 13 // Update Count : 25 14 14 // 15 15 … … 757 757 for ( std::list< DeclarationWithType* >::iterator i = declList.begin(); i != declList.end(); ++i ) { 758 758 VariableExpr newExpr( *i, nameExpr->get_argName() ); 759 newExpr.set_extension( nameExpr->get_extension() ); 759 760 alternatives.push_back( Alternative( newExpr.clone(), env, Cost() ) ); 760 761 PRINT( -
src/SynTree/Expression.cc
r6cbc25a r7ff30d07 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri May 13 13:23:11201613 // Update Count : 4 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 13 16:03:39 2016 13 // Update Count : 42 14 14 // 15 15 … … 32 32 Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {} 33 33 34 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ) {34 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) { 35 35 cloneAll( other.results, results ); 36 36 } … … 59 59 os << std::string( indent, ' ' ) << "with designator:"; 60 60 argName->print( os, indent+2 ); 61 } // if 62 63 if ( extension ) { 64 os << std::string( indent, ' ' ) << "with extension:"; 61 65 } // if 62 66 } -
src/SynTree/Expression.h
r6cbc25a r7ff30d07 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:06:49201613 // Update Count : 2 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 8 17:05:30 2016 13 // Update Count : 22 14 14 // 15 15 … … 38 38 Expression *get_argName() const { return argName; } 39 39 void set_argName( Expression *name ) { argName = name; } 40 bool get_extension() const { return extension; } 41 void set_extension( bool exten ) { extension = exten; } 40 42 41 43 virtual Expression *clone() const = 0; … … 47 49 TypeSubstitution *env; 48 50 Expression* argName; // if expression is used as an argument, it can be "designated" by this name 51 bool extension = false; 49 52 }; 50 53 -
src/Tests/Abstype.c
r6cbc25a r7ff30d07 1 type T | { T x( T ); };1 otype T | { T x( T ); }; 2 2 3 3 T y( T t ) { … … 6 6 } 7 7 8 forall( type T ) lvalue T *?( T * );8 forall( otype T ) lvalue T *?( T * ); 9 9 int ?++( int * ); 10 10 int ?=?( int *, int ); 11 11 forall( dtype DT ) DT * ?=?( DT **, DT * ); 12 12 13 type U = int *;13 otype U = int *; 14 14 15 15 U x( U u ) { -
src/Tests/Attributes.c
r6cbc25a r7ff30d07 6 6 // @max 7 7 // 8 // 2. a direct application to a manifest type8 // 2. a direct application to a manifest otype 9 9 // 10 10 // @max( int ) 11 11 // 12 // 3. constraining a type variable; the application is implicitly performed at the call site as in (2)12 // 3. constraining a otype variable; the application is implicitly performed at the call site as in (2) 13 13 // 14 // forall( type T | { T @max( T ); } ) T x( T t );14 // forall( otype T | { T @max( T ); } ) T x( T t ); 15 15 // 16 16 // … … 23 23 // x = (*attr_var); 24 24 // 25 // 2. an indirect application to a manifest type25 // 2. an indirect application to a manifest otype 26 26 // 27 27 // (*attr_var)( int ) 28 28 // 29 // 3. a direct application to a type variable29 // 3. a direct application to a otype variable 30 30 // 31 31 // @max( T ) … … 47 47 // 3. polymorphic 48 48 // 49 // forall( type T | constraint( T ) ) int @attr( T );49 // forall( otype T | constraint( T ) ) int @attr( T ); 50 50 51 51 int @max = 3; … … 53 53 int main() { 54 54 int x; 55 type @type(type t); // compiler intrinsic56 type @widest(type t);57 @ type(x) *y; // gcc:typeof(x) *y;58 const @widest(double) *w; // gcc: const typeof(x) *w;59 * @ type(3 + 4) z; // cfa declaration syntax55 otype @otype(otype t); // compiler intrinsic 56 otype @widest(otype t); 57 @otype(x) *y; // gcc: otypeof(x) *y; 58 const @widest(double) *w; // gcc: const otypeof(x) *w; 59 * @otype(3 + 4) z; // cfa declaration syntax 60 60 y = @max; 61 61 z = @max(x) + @size(int); -
src/Tests/InferParam.c
r6cbc25a r7ff30d07 3 3 double ?=?( double*, double ); 4 4 5 forall( type T,type U | { U f(T); } ) U g(T);5 forall( otype T, otype U | { U f(T); } ) U g(T); 6 6 float f( int ); 7 7 double f( int ); … … 13 13 } 14 14 15 context has_f_and_j( type T,type U ) {15 context has_f_and_j( otype T, otype U ) { 16 16 U f( T ); 17 17 U j( T, U ); … … 19 19 20 20 float j( int, float ); 21 forall( type T,type U | has_f_and_j( T, U ) ) U k( T );21 forall( otype T, otype U | has_f_and_j( T, U ) ) U k( T ); 22 22 23 23 void l() { -
src/Tests/Makefile
r6cbc25a r7ff30d07 1 CFA ?= ../ cfa-cpp1 CFA ?= ../driver/cfa-cpp 2 2 CFAOPT ?= -a 3 3 OUTPUT ?= Output … … 32 32 33 33 ${OUTPUTDIR} : 34 mkdir $@34 mkdir -p $@ 35 35 36 36 # remove the expected results directories to generate new ones from the current output -
src/Tests/Members.c
r6cbc25a r7ff30d07 3 3 float ?=?( float*, float ); 4 4 forall( dtype DT ) DT * ?=?( DT**, DT* ); 5 forall( type T) lvalue T *?( T* );5 forall(otype T) lvalue T *?( T* ); 6 6 char *__builtin_memcpy(); 7 7 -
src/Tests/OccursError.c
r6cbc25a r7ff30d07 1 forall( type T ) void f( void (*)( T, T* ) );2 forall( type U ) void g( U*, U );1 forall( otype T ) void f( void (*)( T, T* ) ); 2 forall( otype U ) void g( U*, U ); 3 3 4 4 void test() { -
src/Tests/Quad.c
r6cbc25a r7ff30d07 2 2 int ?*?( int, int ); 3 3 4 forall( type T | { T ?*?( T, T ); } )4 forall( otype T | { T ?*?( T, T ); } ) 5 5 T square( T t ) { 6 6 return t * t; 7 7 } 8 8 9 forall( type U | { U square( U ); } )9 forall( otype U | { U square( U ); } ) 10 10 U quad( U u ) { 11 11 return square( square( u ) ); -
src/Tests/Rank2.c
r6cbc25a r7ff30d07 3 3 4 4 void a() { 5 forall( type T ) void f( T );6 void g( forall( type U ) void p( U ) );5 forall( otype T ) void f( T ); 6 void g( forall( otype U ) void p( U ) ); 7 7 g( f ); 8 8 } … … 10 10 void g() { 11 11 void h( int *null ); 12 forall( type T ) T id( T );12 forall( otype T ) T id( T ); 13 13 forall( dtype T ) T *0; 14 14 int 0; -
src/driver/cc1.cc
r6cbc25a r7ff30d07 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 2 17:24:26201613 // Update Count : 7912 // Last Modified On : Fri Jun 10 09:27:37 2016 13 // Update Count : 80 14 14 // 15 15 … … 151 151 i += 1; // and the argument 152 152 cpp_flag = true; 153 } else if ( arg == "-D__CFA_ _" ) {153 } else if ( arg == "-D__CFA_PREPROCESS__" ) { 154 154 CFA_flag = true; 155 } else if ( arg == "-D" && string( argv[i + 1] ) == "__CFA_ _" ) {155 } else if ( arg == "-D" && string( argv[i + 1] ) == "__CFA_PREPROCESS__" ) { 156 156 i += 1; // and the argument 157 157 CFA_flag = true; -
src/driver/cfa.cc
r6cbc25a r7ff30d07 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 2 17:24:25201613 // Update Count : 13 712 // Last Modified On : Fri Jun 10 09:26:19 2016 13 // Update Count : 138 14 14 // 15 15 … … 263 263 args[nargs] = ( *new string( string("-D__CFA_PATCHLEVEL__=") + Patch ) ).c_str(); 264 264 nargs += 1; 265 args[nargs] = "-D__CFORALL__=1"; 265 args[nargs] = "-D__CFA__"; 266 nargs += 1; 267 args[nargs] = "-D__CFORALL__"; 266 268 nargs += 1; 267 269 … … 272 274 273 275 if ( CFA_flag ) { 274 args[nargs] = "-D__CFA_ _";276 args[nargs] = "-D__CFA_PREPROCESS_"; 275 277 nargs += 1; 276 278 } // if -
src/libcfa/Makefile.am
r6cbc25a r7ff30d07 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Wed Jun 8 14:20:34201614 ## Update Count : 16 513 ## Last Modified On : Mon Jun 13 14:27:22 2016 14 ## Update Count : 166 15 15 ############################################################################### 16 16 … … 50 50 @BACKEND_CC@ -c -o $@ $< 51 51 52 CFLAGS = - g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O252 CFLAGS = -quiet -g -Wall -Wno-unused-function -B${abs_top_srcdir}/src/driver -XCFA -t # TEMPORARY: does not build with -O2 53 53 CC = ${abs_top_srcdir}/src/driver/cfa 54 54 -
src/tests/Array.c
r6cbc25a r7ff30d07 1 1 //Testing array declarations 2 2 int a1[]; 3 int a2[*];4 double a4[3.0];3 //int a2[*]; 4 //double a4[3.0]; 5 5 6 6 int m1[][3]; 7 int m2[*][*];7 //int m2[*][*]; 8 8 int m4[3][3]; 9 9 … … 11 11 12 12 int fred() { 13 int a1[];14 int a2[*];13 // int a1[]; 14 // int a2[*]; 15 15 int a4[3]; 16 16 int T[3]; -
src/tests/Forall.c
r6cbc25a r7ff30d07 7 7 8 8 void g1() { 9 forall( type T ) T f( T );9 forall( otype T ) T f( T ); 10 10 void f( int ); 11 11 void h( void (*p)(void) ); … … 24 24 25 25 void g2() { 26 forall( type T ) void f( T, T );27 forall( type T,type U ) void f( T, U );26 forall( otype T ) void f( T, T ); 27 forall( otype T, otype U ) void f( T, U ); 28 28 29 29 int x; … … 37 37 } 38 38 39 typedef forall ( type T ) int (*f)( int );39 typedef forall ( otype T ) int (*f)( int ); 40 40 41 forall( type T )41 forall( otype T ) 42 42 void swap( T left, T right ) { 43 43 T temp = left; … … 46 46 } 47 47 48 context sumable( type T ) {48 context sumable( otype T ) { 49 49 const T 0; 50 50 T ?+?(T, T); … … 53 53 }; 54 54 55 type T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); },56 T2( type P1,type P2 ),55 otype T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); }, 56 T2(otype P1, otype P2 ), 57 57 T3 | sumable(T3); 58 58 59 type T2(type P1,type P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; };59 otype T2(otype P1, otype P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; }; 60 60 61 61 T2(int, int) w1; 62 62 typedef T2(int, int) w2; 63 63 w2 g2; 64 type w3 = T2(int, int);64 otype w3 = T2(int, int); 65 65 w3 g3; 66 66 67 forall( type T | sumable( T ) )67 forall( otype T | sumable( T ) ) 68 68 T sum( int n, T a[] ) { 69 69 T total = 0; … … 74 74 } 75 75 76 forall( type T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } )76 forall( otype T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } ) 77 77 T twice( T t ) { 78 78 return t + t; 79 79 } 80 80 81 forall( type T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } )81 forall( otype T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } ) 82 82 T min( T t1, T t2 ) { 83 83 return t1 < t2 ? t1 : t2; -
src/tests/Functions.c
r6cbc25a r7ff30d07 28 28 int ((*f12())[])[3] {} 29 29 30 // "implicit int" type specifier (not ANSI)30 // "implicit int" otype specifier (not ANSI) 31 31 32 32 fII1( int i ) {} -
src/tests/GccExtensions.c
r6cbc25a r7ff30d07 19 19 __signed s2; 20 20 21 __ typeof(s1) t1;22 __ typeof__(s1) t2;21 __otypeof(s1) t1; 22 __otypeof__(s1) t2; 23 23 24 24 __volatile int v1; -
src/tests/Scope.c
r6cbc25a r7ff30d07 3 3 typedef float t; 4 4 y z; 5 type u = struct { int a; double b; };5 otype u = struct { int a; double b; }; 6 6 int f( int y ); 7 7 y q; 8 8 9 9 y w( y y, u v ) { 10 type x | { x t(u); };10 otype x | { x t(u); }; 11 11 u u = y; 12 12 x z = t(u); … … 15 15 y p; 16 16 17 context has_u( type z ) {17 context has_u( otype z ) { 18 18 z u(z); 19 19 }; 20 20 21 forall( type t | has_u( t ) )21 forall( otype t | has_u( t ) ) 22 22 y q( t the_t ) { 23 23 t y = u( the_t ); -
src/tests/Subrange.c
r6cbc25a r7ff30d07 1 // A small context defining the notion of an ordered type. (The standard1 // A small context defining the notion of an ordered otype. (The standard 2 2 // library should probably contain a context for this purpose.) 3 context ordered( type T) {3 context ordered(otype T) { 4 4 int ?<?(T, T), ?<=?(T, T); 5 5 }; 6 6 7 // A subrange type resembling an Ada subtype with a basetype and a range7 // A subrange otype resembling an Ada subotype with a base otype and a range 8 8 // constraint. 9 type subrange(type base_t | ordered(base_t), base_t low = 0, base_t high = 8) = base_t;9 otype subrange(otype base_t | ordered(base_t), base_t low = 0, base_t high = 8) = base_t; 10 10 11 // Note that subrange() can be applied to floating-point and pointer types, not12 // just integral types.13 // This requires a " type generator" extension to Cforall. Type generators14 // must accept type and non-type parameters, which is beyond what we discussed11 // Note that subrange() can be applied to floating-point and pointer otypes, not 12 // just integral otypes. 13 // This requires a "otype generator" extension to Cforall. Type generators 14 // must accept otype and non-otype parameters, which is beyond what we discussed 15 15 // previously. Type parameters must be usable in the declaration of 16 16 // subsequent parameters: parameter T is used to declare parameters "low" … … 22 22 subrange(int, 0, (rand() & 0xF) ) foo; 23 23 24 // What sorts of expressions can be used as arguments of type generators? Is24 // What sorts of expressions can be used as arguments of otype generators? Is 25 25 // "subrange(int, 0, rand() & 0xF)" legal? Probably. The nearest C equivalent 26 26 // to the "low" and "high" arguments is the array size in a variable-length … … 28 28 29 29 // Convenient access to subrange bounds, for instance for iteration: 30 forall ( type T, T low, T high)30 forall (otype T, T low, T high) 31 31 T lbound( subrange(T, low, high) v) { 32 32 return low; 33 33 } 34 34 35 forall ( type T, T low, T high)35 forall (otype T, T low, T high) 36 36 T hbound( subrange(T, low, high) v) { 37 37 return high; … … 41 41 unsigned lday = lbound(day_of_month); 42 42 43 // Assignment from the base type, with bounds checking. I'll ignore the issue43 // Assignment from the base otype, with bounds checking. I'll ignore the issue 44 44 // of exception handling here. Inlining allows the compiler to eliminate 45 45 // bounds checks. 46 forall ( type T | ordered(T), T low, T high)46 forall (otype T | ordered(T), T low, T high) 47 47 inline subrange(T, low, high) ?=?(subrange(T, low, high)* target, T source) { 48 48 if (low <= source && source <= high) *((T*)target) = source; … … 51 51 } 52 52 53 // Assignment between subranges with a common base type. The bounds check53 // Assignment between subranges with a common base otype. The bounds check 54 54 // compares range bounds so that the compiler can optimize checks away when the 55 55 // ranges are known to overlap. 56 forall ( type T | ordered(T), T t_low, T t_high, T s_low, T s_high)56 forall (otype T | ordered(T), T t_low, T t_high, T s_low, T s_high) 57 57 inline subrange(T, t_low, t_high) ?=?(subrange(T, t_low, t_high)* target, 58 58 subrange(T, s_low, s_high) source) { -
src/tests/TypeGenerator.c
r6cbc25a r7ff30d07 1 context addable( type T ) {1 context addable( otype T ) { 2 2 T ?+?( T,T ); 3 3 T ?=?( T*, T); 4 4 }; 5 5 6 type List1(type T | addable( T ) ) = struct { T data; List1( T ) *next; } *;6 otype List1( otype T | addable( T ) ) = struct { T data; List1( T ) *next; } *; 7 7 typedef List1( int ) ListOfIntegers; 8 8 //List1( int ) li; … … 11 11 [int] h( * List1( int ) p ); // new declaration syntax 12 12 13 struct( type T ) S2 { T i; }; // actual definition13 struct( otype T ) S2 { T i; }; // actual definition 14 14 struct( int ) S3 v1, *p; // expansion and instantiation 15 struct( type T )( int ) S24 { T i; } v2; // actual definition, expansion and instantiation16 struct( type T )( int ) { T i; } v2; // anonymous actual definition, expansion and instantiation15 struct( otype T )( int ) S24 { T i; } v2; // actual definition, expansion and instantiation 16 struct( otype T )( int ) { T i; } v2; // anonymous actual definition, expansion and instantiation 17 17 18 struct( type T | addable( T ) ) node { T data; struct( T ) node *next; };19 type List(type T ) = struct( T ) node *;18 struct( otype T | addable( T ) ) node { T data; struct( T ) node *next; }; 19 otype List( otype T ) = struct( T ) node *; 20 20 List( int ) my_list; 21 21 22 type Complex | addable( Complex );22 otype Complex | addable( Complex ); 23 23 24 24 int main() { -
src/tests/Typedef.c
r6cbc25a r7ff30d07 18 18 a c; 19 19 20 typedef typeof(3) x, y; // GCC20 typedef otypeof(3) x, y; // GCC 21 21 22 22 x p; … … 24 24 25 25 int main() { 26 typedef typeof(3) z, p;26 typedef otypeof(3) z, p; 27 27 z w; 28 28 p x; -
src/tests/Typeof.c
r6cbc25a r7ff30d07 1 1 int main() { 2 2 int *v1; 3 typeof(v1) v2;4 typeof(*v1) v3[4];3 otypeof(v1) v2; 4 otypeof(*v1) v3[4]; 5 5 char *v4[4]; 6 typeof(typeof(char *)[4]) v5;7 typeof (int *) v6;8 typeof( int ( int, int p ) ) *v7;9 typeof( [int] ( int, int p ) ) *v8;6 otypeof(otypeof(char *)[4]) v5; 7 otypeof (int *) v6; 8 otypeof( int ( int, int p ) ) *v7; 9 otypeof( [int] ( int, int p ) ) *v8; 10 10 } -
src/tests/io.c
r6cbc25a r7ff30d07 11 11 // Created On : Wed Mar 2 16:56:02 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu May 26 10:06:00201614 // Update Count : 2813 // Last Modified On : Wed Jun 8 22:52:04 2016 14 // Update Count : 30 15 15 // 16 16 … … 34 34 long double _Complex ldc; 35 35 char s1[10], s2[10]; 36 37 int x = 3, y = 5, z = 7; 38 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl; 39 sout | 1 | 2 | 3 | endl; 40 sout | '1' | '2' | '3' | endl; 41 sout | 1 | "" | 2 | "" | 3 | endl; 42 sout | endl; 36 43 37 44 ifstream in; // create / open file
Note:
See TracChangeset
for help on using the changeset viewer.