Changes in / [5e644d3e:1e8b02f5]
- Files:
-
- 11 edited
-
doc/aaron_comp_II/conversion_dag.eps (modified) ( previous)
-
doc/aaron_comp_II/conversion_dag.odg (modified) ( previous)
-
doc/aaron_comp_II/resolution_dag.eps (modified) ( previous)
-
doc/aaron_comp_II/resolution_dag.odg (modified) ( previous)
-
src/Parser/DeclarationNode.cc (modified) (6 diffs)
-
src/Parser/ParseNode.h (modified) (3 diffs)
-
src/Parser/TypeData.cc (modified) (25 diffs)
-
src/Parser/TypeData.h (modified) (4 diffs)
-
src/Parser/parser.yy (modified) (2 diffs)
-
src/libcfa/Makefile.am (modified) (2 diffs)
-
src/libcfa/Makefile.in (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r5e644d3e r1e8b02f5 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 28 22:12:44201613 // Update Count : 2 7812 // Last Modified On : Thu Aug 25 20:42:25 2016 13 // Update Count : 232 14 14 // 15 15 … … 375 375 } 376 376 377 void DeclarationNode::checkQualifiers( const TypeData *src, constTypeData *dst ) {377 void DeclarationNode::checkQualifiers( TypeData *src, TypeData *dst ) { 378 378 TypeData::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; 379 379 … … 801 801 DeclarationNode *DeclarationNode::extractAggregate() const { 802 802 if ( type ) { 803 TypeData *ret = type extractAggregate( type);803 TypeData *ret = type->extractAggregate(); 804 804 if ( ret ) { 805 805 DeclarationNode *newnode = new DeclarationNode; … … 896 896 if ( ! error.empty() ) throw SemanticError( error, this ); 897 897 if ( type ) { 898 return buildDecl( type,name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension );898 return type->buildDecl( name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension ); 899 899 } // if 900 900 if ( ! isInline && ! isNoreturn ) { … … 909 909 switch ( type->kind ) { 910 910 case TypeData::Enum: 911 return new EnumInstType( buildQualifiers( type), type->enumeration->name );911 return new EnumInstType( type->buildQualifiers(), type->enumeration->name ); 912 912 case TypeData::Aggregate: { 913 913 ReferenceToType *ret; 914 914 switch ( type->aggregate->kind ) { 915 915 case DeclarationNode::Struct: 916 ret = new StructInstType( buildQualifiers( type), type->aggregate->name );916 ret = new StructInstType( type->buildQualifiers(), type->aggregate->name ); 917 917 break; 918 918 case DeclarationNode::Union: 919 ret = new UnionInstType( buildQualifiers( type), type->aggregate->name );919 ret = new UnionInstType( type->buildQualifiers(), type->aggregate->name ); 920 920 break; 921 921 case DeclarationNode::Trait: 922 ret = new TraitInstType( buildQualifiers( type), type->aggregate->name );922 ret = new TraitInstType( type->buildQualifiers(), type->aggregate->name ); 923 923 break; 924 924 default: … … 929 929 } 930 930 case TypeData::Symbolic: { 931 TypeInstType *ret = new TypeInstType( buildQualifiers( type), type->symbolic->name, false );931 TypeInstType *ret = new TypeInstType( type->buildQualifiers(), type->symbolic->name, false ); 932 932 buildList( type->symbolic->actuals, ret->get_parameters() ); 933 933 return ret; 934 934 } 935 935 default: 936 return type build( type);936 return type->build(); 937 937 } // switch 938 938 } -
src/Parser/ParseNode.h
r5e644d3e r1e8b02f5 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 28 21:14:51201613 // Update Count : 5 7512 // Last Modified On : Thu Aug 25 22:46:24 2016 13 // Update Count : 564 14 14 // 15 15 … … 243 243 244 244 DeclarationNode *addQualifiers( DeclarationNode *); 245 void checkQualifiers( const TypeData *, constTypeData * );245 void checkQualifiers( TypeData *, TypeData * ); 246 246 DeclarationNode *copyStorageClasses( DeclarationNode *); 247 247 DeclarationNode *addType( DeclarationNode *); … … 308 308 309 309 Type *buildType( TypeData *type ); 310 //Type::Qualifiers buildQualifiers( const TypeData::Qualifiers & qualifiers );311 310 312 311 static inline Type * maybeMoveBuildType( const DeclarationNode *orig ) { -
src/Parser/TypeData.cc
r5e644d3e r1e8b02f5 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 28 18:28:58201613 // Update Count : 22312 // Last Modified On : Wed Aug 24 13:46:55 2016 13 // Update Count : 69 14 14 // 15 15 … … 94 94 break; 95 95 } // switch 96 } // TypeData::TypeData96 } 97 97 98 98 TypeData::~TypeData() { … … 163 163 break; 164 164 } // switch 165 } // TypeData::~TypeData166 167 TypeData * TypeData::clone() const {168 TypeData * newtype = new TypeData( kind );165 } 166 167 TypeData *TypeData::clone() const { 168 TypeData *newtype = new TypeData( kind ); 169 169 newtype->qualifiers = qualifiers; 170 170 newtype->base = maybeClone( base ); … … 238 238 } // switch 239 239 return newtype; 240 } // TypeData::clone240 } 241 241 242 242 void TypeData::print( std::ostream &os, int indent ) const { … … 418 418 assert( false ); 419 419 } // switch 420 } // TypeData::print 421 422 void buildForall( const DeclarationNode * firstNode, std::list< TypeDecl* > &outputList ) { 420 } 421 422 TypeData *TypeData::extractAggregate( bool toplevel ) const { 423 TypeData *ret = 0; 424 425 switch ( kind ) { 426 case Aggregate: 427 if ( ! toplevel && aggregate->fields ) { 428 ret = clone(); 429 // ret->qualifiers.reset(); 430 } // if 431 break; 432 case Enum: 433 if ( ! toplevel && enumeration->constants ) { 434 ret = clone(); 435 // ret->qualifiers.reset(); 436 } // if 437 break; 438 case AggregateInst: 439 if ( aggInst->aggregate ) { 440 ret = aggInst->aggregate->extractAggregate( false ); 441 } // if 442 break; 443 default: 444 if ( base ) { 445 ret = base->extractAggregate( false ); 446 } // if 447 } // switch 448 return ret; 449 } 450 451 void buildForall( const DeclarationNode *firstNode, std::list< TypeDecl* > &outputList ) { 423 452 buildList( firstNode, outputList ); 424 453 for ( std::list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) { … … 426 455 // add assertion parameters to `type' tyvars in reverse order 427 456 // add dtor: void ^?{}(T *) 428 FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false );457 FunctionType *dtorType = new FunctionType( Type::Qualifiers(), false ); 429 458 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) ); 430 459 (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, 0, false, false ) ); 431 460 432 461 // add copy ctor: void ?{}(T *, T) 433 FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false );462 FunctionType *copyCtorType = new FunctionType( Type::Qualifiers(), false ); 434 463 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) ); 435 464 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) ); … … 437 466 438 467 // add default ctor: void ?{}(T *) 439 FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false );468 FunctionType *ctorType = new FunctionType( Type::Qualifiers(), false ); 440 469 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) ); 441 470 (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, 0, false, false ) ); 442 471 443 472 // add assignment operator: T * ?=?(T *, T) 444 FunctionType * assignType = new FunctionType( Type::Qualifiers(), false );473 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 445 474 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) ); 446 475 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) ); … … 451 480 } 452 481 453 Type * typebuild( const TypeData * td ) { 454 assert( td ); 455 switch ( td->kind ) { 456 case TypeData::Unknown: 482 Declaration *TypeData::buildDecl( std::string name, DeclarationNode::StorageClass sc, Expression *bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer *init ) const { 483 if ( kind == TypeData::Function ) { 484 FunctionDecl *decl; 485 if ( function->hasBody ) { 486 if ( function->body ) { 487 Statement *stmt = function->body->build(); 488 CompoundStmt *body = dynamic_cast< CompoundStmt* >( stmt ); 489 assert( body ); 490 decl = new FunctionDecl( name, sc, linkage, buildFunction(), body, isInline, isNoreturn ); 491 } else { 492 // std::list< Label > ls; 493 decl = new FunctionDecl( name, sc, linkage, buildFunction(), new CompoundStmt( std::list< Label >() ), isInline, isNoreturn ); 494 } // if 495 } else { 496 decl = new FunctionDecl( name, sc, linkage, buildFunction(), 0, isInline, isNoreturn ); 497 } // if 498 for ( DeclarationNode *cur = function->idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) { 499 if ( cur->get_name() != "" ) { 500 decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur->get_name() ); 501 } // if 502 } // for 503 buildList( function->oldDeclList, decl->get_oldDecls() ); 504 return decl; 505 } else if ( kind == TypeData::Aggregate ) { 506 return buildAggregate(); 507 } else if ( kind == TypeData::Enum ) { 508 return buildEnum(); 509 } else if ( kind == TypeData::Symbolic ) { 510 return buildSymbolic( name, sc ); 511 } else if ( kind == TypeData::Variable ) { 512 return buildVariable(); 513 } else { 514 return new ObjectDecl( name, sc, linkage, bitfieldWidth, build(), init, std::list< Attribute * >(), isInline, isNoreturn ); 515 } // if 516 return 0; 517 } 518 519 Type *TypeData::build() const { 520 switch ( kind ) { 521 case Unknown: 457 522 // fill in implicit int 458 return new BasicType( buildQualifiers( td), BasicType::SignedInt );459 case TypeData::Basic:460 return buildBasicType( td);461 case TypeData::Pointer:462 return buildPointer( td);463 case TypeData::Array:464 return buildArray( td);465 case TypeData::Function:466 return buildFunction( td);467 case TypeData::AggregateInst:468 return buildAggInst( td);469 case TypeData::EnumConstant:523 return new BasicType( buildQualifiers(), BasicType::SignedInt ); 524 case Basic: 525 return buildBasicType(); 526 case Pointer: 527 return buildPointer(); 528 case Array: 529 return buildArray(); 530 case Function: 531 return buildFunction(); 532 case AggregateInst: 533 return buildAggInst(); 534 case EnumConstant: 470 535 // the name gets filled in later -- by SymTab::Validate 471 return new EnumInstType( buildQualifiers( td), "" );472 case TypeData::SymbolicInst:473 return buildSymbolicInst( td);;474 case T ypeData::Tuple:475 return buildTuple( td);476 case Type Data::Typeof:477 return buildTypeof( td);478 case TypeData::Builtin:479 return new VarArgsType( buildQualifiers( td) );480 case TypeData::Attr:481 return buildAttr( td);482 case TypeData::Symbolic:483 case TypeData::Enum:484 case TypeData::Aggregate:485 case TypeData::Variable:536 return new EnumInstType( buildQualifiers(), "" ); 537 case SymbolicInst: 538 return buildSymbolicInst();; 539 case Tuple: 540 return buildTuple(); 541 case Typeof: 542 return buildTypeof(); 543 case Builtin: 544 return new VarArgsType( buildQualifiers() ); 545 case Attr: 546 return buildAttr(); 547 case Symbolic: 548 case Enum: 549 case Aggregate: 550 case Variable: 486 551 assert( false ); 487 552 } // switch 488 553 return 0; 489 } // typebuild 490 491 TypeData * typeextractAggregate( const TypeData * td, bool toplevel ) { 492 TypeData * ret = 0; 493 494 switch ( td->kind ) { 495 case TypeData::Aggregate: 496 if ( ! toplevel && td->aggregate->fields ) { 497 ret = td->clone(); 498 } // if 499 break; 500 case TypeData::Enum: 501 if ( ! toplevel && td->enumeration->constants ) { 502 ret = td->clone(); 503 } // if 504 break; 505 case TypeData::AggregateInst: 506 if ( td->aggInst->aggregate ) { 507 ret = typeextractAggregate( td->aggInst->aggregate, false ); 508 } // if 509 break; 510 default: 511 if ( td->base ) { 512 ret = typeextractAggregate( td->base, false ); 513 } // if 514 } // switch 515 return ret; 516 } // typeextractAggregate 517 518 Type::Qualifiers buildQualifiers( const TypeData * td ) { 554 } 555 556 Type::Qualifiers TypeData::buildQualifiers() const { 519 557 Type::Qualifiers q; 520 q.isConst = td->qualifiers[ DeclarationNode::Const ];521 q.isVolatile = td->qualifiers[ DeclarationNode::Volatile ];522 q.isRestrict = td->qualifiers[ DeclarationNode::Restrict ];523 q.isLvalue = td->qualifiers[ DeclarationNode::Lvalue ];524 q.isAtomic = td->qualifiers[ DeclarationNode::Atomic ];;558 q.isConst = qualifiers[ DeclarationNode::Const ]; 559 q.isVolatile = qualifiers[ DeclarationNode::Volatile ]; 560 q.isRestrict = qualifiers[ DeclarationNode::Restrict ]; 561 q.isLvalue = qualifiers[ DeclarationNode::Lvalue ]; 562 q.isAtomic = qualifiers[ DeclarationNode::Atomic ];; 525 563 return q; 526 } // buildQualifiers527 528 Type * buildBasicType( const TypeData * td ){564 } 565 566 Type *TypeData::buildBasicType() const { 529 567 static const BasicType::Kind kindMap[] = { BasicType::Char, BasicType::SignedInt, BasicType::Float, BasicType::Double, 530 568 BasicType::Char /* void */, BasicType::Bool, BasicType::DoubleComplex, … … 535 573 BasicType::Kind ret; 536 574 537 for ( std::list< DeclarationNode::BasicType >::const_iterator i = td->basic->typeSpec.begin(); i != td->basic->typeSpec.end(); ++i ) {575 for ( std::list< DeclarationNode::BasicType >::const_iterator i = basic->typeSpec.begin(); i != basic->typeSpec.end(); ++i ) { 538 576 if ( ! init ) { 539 577 init = true; 540 578 if ( *i == DeclarationNode::Void ) { 541 if ( td->basic->typeSpec.size() != 1 || ! td->basic->modifiers.empty() ) {542 throw SemanticError( "invalid type specifier \"void\" in type: ", t d);579 if ( basic->typeSpec.size() != 1 || ! basic->modifiers.empty() ) { 580 throw SemanticError( "invalid type specifier \"void\" in type: ", this ); 543 581 } else { 544 return new VoidType( buildQualifiers( td) );582 return new VoidType( buildQualifiers() ); 545 583 } // if 546 584 } else { … … 551 589 case DeclarationNode::Float: 552 590 if ( sawDouble ) { 553 throw SemanticError( "invalid type specifier \"float\" in type: ", t d);591 throw SemanticError( "invalid type specifier \"float\" in type: ", this ); 554 592 } else { 555 593 switch ( ret ) { … … 561 599 break; 562 600 default: 563 throw SemanticError( "invalid type specifier \"float\" in type: ", t d);601 throw SemanticError( "invalid type specifier \"float\" in type: ", this ); 564 602 } // switch 565 603 } // if … … 567 605 case DeclarationNode::Double: 568 606 if ( sawDouble ) { 569 throw SemanticError( "duplicate type specifier \"double\" in type: ", t d);607 throw SemanticError( "duplicate type specifier \"double\" in type: ", this ); 570 608 } else { 571 609 switch ( ret ) { … … 574 612 break; 575 613 default: 576 throw SemanticError( "invalid type specifier \"double\" in type: ", t d);614 throw SemanticError( "invalid type specifier \"double\" in type: ", this ); 577 615 } // switch 578 616 } // if … … 587 625 break; 588 626 default: 589 throw SemanticError( "invalid type specifier \"_Complex\" in type: ", t d);627 throw SemanticError( "invalid type specifier \"_Complex\" in type: ", this ); 590 628 } // switch 591 629 break; … … 599 637 break; 600 638 default: 601 throw SemanticError( "invalid type specifier \"_Imaginary\" in type: ", t d);639 throw SemanticError( "invalid type specifier \"_Imaginary\" in type: ", this ); 602 640 } // switch 603 641 break; 604 642 default: 605 throw SemanticError( std::string( "invalid type specifier \"" ) + DeclarationNode::basicTypeName[ *i ] + "\" in type: ", t d);643 throw SemanticError( std::string( "invalid type specifier \"" ) + DeclarationNode::basicTypeName[ *i ] + "\" in type: ", this ); 606 644 } // switch 607 645 } // if … … 611 649 } // for 612 650 613 for ( std::list< DeclarationNode::Modifier >::const_iterator i = td->basic->modifiers.begin(); i != td->basic->modifiers.end(); ++i ) {651 for ( std::list< DeclarationNode::Modifier >::const_iterator i = basic->modifiers.begin(); i != basic->modifiers.end(); ++i ) { 614 652 switch ( *i ) { 615 653 case DeclarationNode::Long: … … 641 679 break; 642 680 default: 643 throw SemanticError( "invalid type modifier \"long\" in type: ", t d);681 throw SemanticError( "invalid type modifier \"long\" in type: ", this ); 644 682 } // switch 645 683 } // if … … 658 696 break; 659 697 default: 660 throw SemanticError( "invalid type modifier \"short\" in type: ", t d);698 throw SemanticError( "invalid type modifier \"short\" in type: ", this ); 661 699 } // switch 662 700 } // if … … 667 705 ret = BasicType::SignedInt; 668 706 } else if ( sawSigned ) { 669 throw SemanticError( "duplicate type modifer \"signed\" in type: ", t d);707 throw SemanticError( "duplicate type modifer \"signed\" in type: ", this ); 670 708 } else { 671 709 switch ( ret ) { … … 683 721 break; 684 722 default: 685 throw SemanticError( "invalid type modifer \"signed\" in type: ", t d);723 throw SemanticError( "invalid type modifer \"signed\" in type: ", this ); 686 724 } // switch 687 725 } // if … … 692 730 ret = BasicType::UnsignedInt; 693 731 } else if ( sawSigned ) { 694 throw SemanticError( "invalid type modifer \"unsigned\" in type: ", t d);732 throw SemanticError( "invalid type modifer \"unsigned\" in type: ", this ); 695 733 } else { 696 734 switch ( ret ) { … … 711 749 break; 712 750 default: 713 throw SemanticError( "invalid type modifer \"unsigned\" in type: ", t d);751 throw SemanticError( "invalid type modifer \"unsigned\" in type: ", this ); 714 752 } // switch 715 753 } // if … … 722 760 } // for 723 761 724 BasicType * bt;762 BasicType *bt; 725 763 if ( ! init ) { 726 bt = new BasicType( buildQualifiers( td), BasicType::SignedInt );764 bt = new BasicType( buildQualifiers(), BasicType::SignedInt ); 727 765 } else { 728 bt = new BasicType( buildQualifiers( td), ret );766 bt = new BasicType( buildQualifiers(), ret ); 729 767 } // if 730 buildForall( td->forall, bt->get_forall() );768 buildForall( forall, bt->get_forall() ); 731 769 return bt; 732 } // buildBasicType 733 734 PointerType * buildPointer( const TypeData * td ) { 735 PointerType * pt; 736 if ( td->base ) { 737 pt = new PointerType( buildQualifiers( td ), typebuild( td->base ) ); 770 } 771 772 773 PointerType *TypeData::buildPointer() const { 774 PointerType *pt; 775 if ( base ) { 776 pt = new PointerType( buildQualifiers(), base->build() ); 738 777 } else { 739 pt = new PointerType( buildQualifiers( td), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );778 pt = new PointerType( buildQualifiers(), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 740 779 } // if 741 buildForall( td->forall, pt->get_forall() );780 buildForall( forall, pt->get_forall() ); 742 781 return pt; 743 } // buildPointer744 745 ArrayType * buildArray( const TypeData * td ){746 ArrayType * at;747 if ( td->base ) {748 at = new ArrayType( buildQualifiers( td ), typebuild( td->base ), maybeBuild< Expression >( td->array->dimension ),749 td->array->isVarLen, td->array->isStatic );782 } 783 784 ArrayType *TypeData::buildArray() const { 785 ArrayType *at; 786 if ( base ) { 787 at = new ArrayType( buildQualifiers(), base->build(), maybeBuild< Expression >( array->dimension ), 788 array->isVarLen, array->isStatic ); 750 789 } else { 751 at = new ArrayType( buildQualifiers( td), new BasicType( Type::Qualifiers(), BasicType::SignedInt ),752 maybeBuild< Expression >( td->array->dimension ), td->array->isVarLen, td->array->isStatic );790 at = new ArrayType( buildQualifiers(), new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 791 maybeBuild< Expression >( array->dimension ), array->isVarLen, array->isStatic ); 753 792 } // if 754 buildForall( td->forall, at->get_forall() );793 buildForall( forall, at->get_forall() ); 755 794 return at; 756 } // buildPointer 757 758 AggregateDecl * buildAggregate( const TypeData * td ) { 759 assert( td->kind == TypeData::Aggregate ); 760 AggregateDecl * at; 761 switch ( td->aggregate->kind ) { 795 } 796 797 FunctionType *TypeData::buildFunction() const { 798 assert( kind == Function ); 799 bool hasEllipsis = function->params ? function->params->get_hasEllipsis() : true; 800 if ( ! function->params ) hasEllipsis = ! function->newStyle; 801 FunctionType *ft = new FunctionType( buildQualifiers(), hasEllipsis ); 802 buildList( function->params, ft->get_parameters() ); 803 buildForall( forall, ft->get_forall() ); 804 if ( base ) { 805 switch ( base->kind ) { 806 case Tuple: 807 buildList( base->tuple->members, ft->get_returnVals() ); 808 break; 809 default: 810 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( base->buildDecl( "", DeclarationNode::NoStorageClass, 0, false, false, LinkageSpec::Cforall ) ) ); 811 } // switch 812 } else { 813 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 ) ); 814 } // if 815 return ft; 816 } 817 818 AggregateDecl *TypeData::buildAggregate() const { 819 assert( kind == Aggregate ); 820 AggregateDecl *at; 821 switch ( aggregate->kind ) { 762 822 case DeclarationNode::Struct: 763 at = new StructDecl( td->aggregate->name );764 buildForall( td->aggregate->params, at->get_parameters() );823 at = new StructDecl( aggregate->name ); 824 buildForall( aggregate->params, at->get_parameters() ); 765 825 break; 766 826 case DeclarationNode::Union: 767 at = new UnionDecl( td->aggregate->name );768 buildForall( td->aggregate->params, at->get_parameters() );827 at = new UnionDecl( aggregate->name ); 828 buildForall( aggregate->params, at->get_parameters() ); 769 829 break; 770 830 case DeclarationNode::Trait: 771 at = new TraitDecl( td->aggregate->name );772 buildList( td->aggregate->params, at->get_parameters() );831 at = new TraitDecl( aggregate->name ); 832 buildList( aggregate->params, at->get_parameters() ); 773 833 break; 774 834 default: … … 776 836 } // switch 777 837 778 buildList( td->aggregate->fields, at->get_members() );779 at->set_body( td->aggregate->body );838 buildList( aggregate->fields, at->get_members() ); 839 at->set_body( aggregate->body ); 780 840 781 841 return at; 782 } // buildAggregate783 784 ReferenceToType * buildAggInst( const TypeData * td ){785 assert( td->kind == TypeData::AggregateInst );786 787 ReferenceToType * ret;788 if ( td->aggInst->aggregate->kind == TypeData::Enum ) {789 ret = new EnumInstType( buildQualifiers( td ), td->aggInst->aggregate->enumeration->name );842 } 843 844 ReferenceToType *TypeData::buildAggInst() const { 845 assert( kind == AggregateInst ); 846 847 ReferenceToType *ret; 848 if ( aggInst->aggregate->kind == Enum ) { 849 ret = new EnumInstType( buildQualifiers(), aggInst->aggregate->enumeration->name ); 790 850 } else { 791 assert( td->aggInst->aggregate->kind == TypeData::Aggregate );792 switch ( td->aggInst->aggregate->aggregate->kind ) {851 assert( aggInst->aggregate->kind == Aggregate ); 852 switch ( aggInst->aggregate->aggregate->kind ) { 793 853 case DeclarationNode::Struct: 794 ret = new StructInstType( buildQualifiers( td ), td->aggInst->aggregate->aggregate->name );854 ret = new StructInstType( buildQualifiers(), aggInst->aggregate->aggregate->name ); 795 855 break; 796 856 case DeclarationNode::Union: 797 ret = new UnionInstType( buildQualifiers( td ), td->aggInst->aggregate->aggregate->name );857 ret = new UnionInstType( buildQualifiers(), aggInst->aggregate->aggregate->name ); 798 858 break; 799 859 case DeclarationNode::Trait: 800 ret = new TraitInstType( buildQualifiers( td ), td->aggInst->aggregate->aggregate->name );860 ret = new TraitInstType( buildQualifiers(), aggInst->aggregate->aggregate->name ); 801 861 break; 802 862 default: … … 804 864 } // switch 805 865 } // if 806 buildList( td->aggInst->params, ret->get_parameters() );807 buildForall( td->forall, ret->get_forall() );866 buildList( aggInst->params, ret->get_parameters() ); 867 buildForall( forall, ret->get_forall() ); 808 868 return ret; 809 } // buildAggInst 810 811 NamedTypeDecl * buildSymbolic( const TypeData * td, const std::string & name, DeclarationNode::StorageClass sc ) { 812 assert( td->kind == TypeData::Symbolic ); 813 NamedTypeDecl * ret; 814 assert( td->base ); 815 if ( td->symbolic->isTypedef ) { 816 ret = new TypedefDecl( name, sc, typebuild( td->base ) ); 869 } 870 871 NamedTypeDecl *TypeData::buildSymbolic( const std::string &name, DeclarationNode::StorageClass sc ) const { 872 assert( kind == Symbolic ); 873 NamedTypeDecl *ret; 874 if ( symbolic->isTypedef ) { 875 ret = new TypedefDecl( name, sc, maybeBuild< Type >( base ) ); 817 876 } else { 818 ret = new TypeDecl( name, sc, typebuild( td->base ), TypeDecl::Any );877 ret = new TypeDecl( name, sc, maybeBuild< Type >( base ), TypeDecl::Any ); 819 878 } // if 820 buildList( td->symbolic->params, ret->get_parameters() );821 buildList( td->symbolic->assertions, ret->get_assertions() );879 buildList( symbolic->params, ret->get_parameters() ); 880 buildList( symbolic->assertions, ret->get_assertions() ); 822 881 return ret; 823 } // buildSymbolic824 825 TypeDecl * buildVariable( const TypeData * td ){826 assert( td->kind == TypeData::Variable );882 } 883 884 TypeDecl *TypeData::buildVariable() const { 885 assert( kind == Variable ); 827 886 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype }; 828 887 829 TypeDecl * ret = new TypeDecl( td->variable->name, DeclarationNode::NoStorageClass, 0, kindMap[ td->variable->tyClass ] );830 buildList( td->variable->assertions, ret->get_assertions() );888 TypeDecl *ret = new TypeDecl( variable->name, DeclarationNode::NoStorageClass, 0, kindMap[ variable->tyClass ] ); 889 buildList( variable->assertions, ret->get_assertions() ); 831 890 return ret; 832 } // buildSymbolic833 834 EnumDecl * buildEnum( const TypeData * td ){835 assert( td->kind == TypeData::Enum );836 EnumDecl * ret = new EnumDecl( td->enumeration->name );837 buildList( td->enumeration->constants, ret->get_members() );891 } 892 893 EnumDecl *TypeData::buildEnum() const { 894 assert( kind == Enum ); 895 EnumDecl *ret = new EnumDecl( enumeration->name ); 896 buildList( enumeration->constants, ret->get_members() ); 838 897 std::list< Declaration * >::iterator members = ret->get_members().begin(); 839 for ( const DeclarationNode * cur = td->enumeration->constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {898 for ( const DeclarationNode *cur = enumeration->constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 840 899 if ( cur->has_enumeratorValue() ) { 841 ObjectDecl * member = dynamic_cast< ObjectDecl * >(*members);900 ObjectDecl *member = dynamic_cast< ObjectDecl * >(*members); 842 901 member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ), std::list< Expression * >() ) ); 843 902 } // if 844 903 } // for 845 904 return ret; 846 } // buildEnum847 848 TypeInstType * buildSymbolicInst( const TypeData * td ){849 assert( td->kind == TypeData::SymbolicInst );850 TypeInstType * ret = new TypeInstType( buildQualifiers( td ), td->symbolic->name, false );851 buildList( td->symbolic->actuals, ret->get_parameters() );852 buildForall( td->forall, ret->get_forall() );905 } 906 907 TypeInstType *TypeData::buildSymbolicInst() const { 908 assert( kind == SymbolicInst ); 909 TypeInstType *ret = new TypeInstType( buildQualifiers(), symbolic->name, false ); 910 buildList( symbolic->actuals, ret->get_parameters() ); 911 buildForall( forall, ret->get_forall() ); 853 912 return ret; 854 } // buildSymbolicInst855 856 TupleType * buildTuple( const TypeData * td ){857 assert( td->kind == TypeData::Tuple );858 TupleType * ret = new TupleType( buildQualifiers( td) );859 buildTypeList( t d->tuple->members, ret->get_types() );860 buildForall( td->forall, ret->get_forall() );913 } 914 915 TupleType *TypeData::buildTuple() const { 916 assert( kind == Tuple ); 917 TupleType *ret = new TupleType( buildQualifiers() ); 918 buildTypeList( tuple->members, ret->get_types() ); 919 buildForall( forall, ret->get_forall() ); 861 920 return ret; 862 } // buildTuple 863 864 TypeofType * buildTypeof( const TypeData * td ) { 865 assert( td->kind == TypeData::Typeof ); 866 assert( td->typeexpr ); 867 assert( td->typeexpr->expr ); 868 return new TypeofType( buildQualifiers( td ), td->typeexpr->expr->build() ); 869 } // buildTypeof 870 871 AttrType * buildAttr( const TypeData * td ) { 872 assert( td->kind == TypeData::Attr ); 873 assert( td->attr ); 874 AttrType * ret; 875 if ( td->attr->expr ) { 876 ret = new AttrType( buildQualifiers( td ), td->attr->name, td->attr->expr->build() ); 921 } 922 923 TypeofType *TypeData::buildTypeof() const { 924 assert( kind == Typeof ); 925 assert( typeexpr ); 926 assert( typeexpr->expr ); 927 TypeofType *ret = new TypeofType( buildQualifiers(), typeexpr->expr->build() ); 928 return ret; 929 } 930 931 AttrType *TypeData::buildAttr() const { 932 assert( kind == Attr ); 933 assert( attr ); 934 AttrType *ret; 935 if ( attr->expr ) { 936 ret = new AttrType( buildQualifiers(), attr->name, attr->expr->build() ); 877 937 } else { 878 assert( td->attr->type );879 ret = new AttrType( buildQualifiers( td ), td->attr->name, td->attr->type->buildType() );938 assert( attr->type ); 939 ret = new AttrType( buildQualifiers(), attr->name, attr->type->buildType() ); 880 940 } // if 881 941 return ret; 882 } // buildAttr 883 884 Declaration * buildDecl( const TypeData * td, std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init ) { 885 if ( td->kind == TypeData::Function ) { 886 FunctionDecl * decl; 887 if ( td->function->hasBody ) { 888 if ( td->function->body ) { 889 Statement * stmt = td->function->body->build(); 890 CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt ); 891 assert( body ); 892 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn ); 893 } else { 894 // std::list< Label > ls; 895 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), new CompoundStmt( std::list< Label >() ), isInline, isNoreturn ); 896 } // if 897 } else { 898 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), 0, isInline, isNoreturn ); 899 } // if 900 for ( DeclarationNode * cur = td->function->idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) { 901 if ( cur->get_name() != "" ) { 902 decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur->get_name() ); 903 } // if 904 } // for 905 buildList( td->function->oldDeclList, decl->get_oldDecls() ); 906 return decl; 907 } else if ( td->kind == TypeData::Aggregate ) { 908 return buildAggregate( td ); 909 } else if ( td->kind == TypeData::Enum ) { 910 return buildEnum( td ); 911 } else if ( td->kind == TypeData::Symbolic ) { 912 return buildSymbolic( td, name, sc ); 913 } else if ( td->kind == TypeData::Variable ) { 914 return buildVariable( td ); 915 } else { 916 return new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, std::list< Attribute * >(), isInline, isNoreturn ); 917 } // if 918 return 0; 919 } // buildDecl 920 921 FunctionType * buildFunction( const TypeData * td ) { 922 assert( td->kind == TypeData::Function ); 923 bool hasEllipsis = td->function->params ? td->function->params->get_hasEllipsis() : true; 924 if ( ! td->function->params ) hasEllipsis = ! td->function->newStyle; 925 FunctionType * ft = new FunctionType( buildQualifiers( td ), hasEllipsis ); 926 buildList( td->function->params, ft->get_parameters() ); 927 buildForall( td->forall, ft->get_forall() ); 928 if ( td->base ) { 929 switch ( td->base->kind ) { 930 case TypeData::Tuple: 931 buildList( td->base->tuple->members, ft->get_returnVals() ); 932 break; 933 default: 934 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base, "", DeclarationNode::NoStorageClass, 0, false, false, LinkageSpec::Cforall ) ) ); 935 } // switch 936 } else { 937 ft->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 0 ) ); 938 } // if 939 return ft; 940 } // buildFunction 942 } 941 943 942 944 // Local Variables: // -
src/Parser/TypeData.h
r5e644d3e r1e8b02f5 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 28 22:39:00201613 // Update Count : 8512 // Last Modified On : Thu Aug 25 17:34:06 2016 13 // Update Count : 26 14 14 // 15 15 … … 25 25 enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst, 26 26 Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Builtin, Attr } kind; 27 28 TypeData( Kind k = Unknown ); 29 ~TypeData(); 30 void print( std::ostream &, int indent = 0 ) const; 31 TypeData * clone() const; 32 33 Type * build() const; 34 FunctionType * buildFunction() const; 35 36 TypeData * base; 37 typedef std::bitset< DeclarationNode::NoOfQualifier > Qualifiers; 38 Qualifiers qualifiers; 39 DeclarationNode * forall; 27 40 28 41 struct Basic_t { … … 97 110 }; 98 111 99 TypeData * base;100 typedef std::bitset< DeclarationNode::NoOfQualifier > Qualifiers;101 Qualifiers qualifiers;102 DeclarationNode * forall;103 104 112 union { 105 113 Basic_t * basic; … … 117 125 }; 118 126 119 TypeData( Kind k = Unknown ); 120 ~TypeData(); 121 void print( std::ostream &, int indent = 0 ) const; 122 TypeData * clone() const; 127 TypeData * extractAggregate( bool toplevel = true ) const; 128 // helper function for DeclNodeImpl::build 129 Declaration * buildDecl( std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init = 0 ) const; 130 // helper functions for build() 131 Type::Qualifiers buildQualifiers() const; 132 Type * buildBasicType() const; 133 PointerType * buildPointer() const; 134 ArrayType * buildArray() const; 135 AggregateDecl * buildAggregate() const; 136 ReferenceToType * buildAggInst() const; 137 NamedTypeDecl * buildSymbolic( const std::string &name, DeclarationNode::StorageClass sc ) const; 138 TypeDecl* buildVariable() const; 139 EnumDecl* buildEnum() const; 140 TypeInstType * buildSymbolicInst() const; 141 TupleType * buildTuple() const; 142 TypeofType * buildTypeof() const; 143 AttrType * buildAttr() const; 123 144 }; 124 125 Type * typebuild( const TypeData * );126 TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );127 Type::Qualifiers buildQualifiers( const TypeData * td );128 Type * buildBasicType( const TypeData * );129 PointerType * buildPointer( const TypeData * );130 ArrayType * buildArray( const TypeData * );131 AggregateDecl * buildAggregate( const TypeData * );132 ReferenceToType * buildAggInst( const TypeData * );133 NamedTypeDecl * buildSymbolic( const TypeData *, const std::string &name, DeclarationNode::StorageClass sc );134 TypeDecl * buildVariable( const TypeData * );135 EnumDecl * buildEnum( const TypeData * );136 TypeInstType * buildSymbolicInst( const TypeData * );137 TupleType * buildTuple( const TypeData * );138 TypeofType * buildTypeof( const TypeData * );139 AttrType * buildAttr( const TypeData * );140 Declaration * buildDecl( const TypeData *, std::string, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = 0 );141 FunctionType * buildFunction( const TypeData * );142 145 143 146 #endif // TYPEDATA_H -
src/Parser/parser.yy
r5e644d3e r1e8b02f5 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 26 16:45:44201613 // Update Count : 196 412 // Last Modified On : Thu Aug 25 21:24:19 2016 13 // Update Count : 1963 14 14 // 15 15 … … 619 619 | ERassign { $$ = OperKinds::ERAssn; } 620 620 | ORassign { $$ = OperKinds::OrAssn; } 621 ;621 ; 622 622 623 623 tuple: // CFA, tuple -
src/libcfa/Makefile.am
r5e644d3e r1e8b02f5 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Fri Aug 26 12:03:37201614 ## Update Count : 19 913 ## Last Modified On : Thu Aug 11 15:36:32 2016 14 ## Update Count : 198 15 15 ############################################################################### 16 16 … … 56 56 CC = ${abs_top_srcdir}/src/driver/cfa 57 57 58 headers = limits stdlib math iostream fstream iterator rational containers/vector58 headers = limits stdlib math iostream fstream iterator rational # containers/vector 59 59 libobjs = ${headers:=.o} 60 60 -
src/libcfa/Makefile.in
r5e644d3e r1e8b02f5 89 89 libcfa_a_AR = $(AR) $(ARFLAGS) 90 90 libcfa_a_LIBADD = 91 am__dirstamp = $(am__leading_dot)dirstamp92 91 am__objects_1 = limits.$(OBJEXT) stdlib.$(OBJEXT) math.$(OBJEXT) \ 93 92 iostream.$(OBJEXT) fstream.$(OBJEXT) iterator.$(OBJEXT) \ 94 rational.$(OBJEXT) containers/vector.$(OBJEXT)93 rational.$(OBJEXT) 95 94 am_libcfa_a_OBJECTS = libcfa-prelude.$(OBJEXT) $(am__objects_1) 96 95 libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS) … … 234 233 cfalib_DATA = builtins.cf extras.cf prelude.cf 235 234 MAINTAINERCLEANFILES = builtins.cf extras.cf ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}} 236 headers = limits stdlib math iostream fstream iterator rational containers/vector235 headers = limits stdlib math iostream fstream iterator rational # containers/vector 237 236 libobjs = ${headers:=.o} 238 237 libcfa_a_SOURCES = libcfa-prelude.c ${headers:=.c} … … 304 303 clean-libLIBRARIES: 305 304 -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) 306 containers/$(am__dirstamp):307 @$(MKDIR_P) containers308 @: > containers/$(am__dirstamp)309 containers/$(DEPDIR)/$(am__dirstamp):310 @$(MKDIR_P) containers/$(DEPDIR)311 @: > containers/$(DEPDIR)/$(am__dirstamp)312 containers/vector.$(OBJEXT): containers/$(am__dirstamp) \313 containers/$(DEPDIR)/$(am__dirstamp)314 305 libcfa.a: $(libcfa_a_OBJECTS) $(libcfa_a_DEPENDENCIES) $(EXTRA_libcfa_a_DEPENDENCIES) 315 306 $(AM_V_at)-rm -f libcfa.a … … 319 310 mostlyclean-compile: 320 311 -rm -f *.$(OBJEXT) 321 -rm -f containers/vector.$(OBJEXT)322 312 323 313 distclean-compile: … … 332 322 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rational.Po@am__quote@ 333 323 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdlib.Po@am__quote@ 334 @AMDEP_TRUE@@am__include@ @am__quote@containers/$(DEPDIR)/vector.Po@am__quote@335 324 336 325 .c.o: … … 505 494 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 506 495 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 507 -rm -f containers/$(DEPDIR)/$(am__dirstamp)508 -rm -f containers/$(am__dirstamp)509 496 510 497 maintainer-clean-generic: … … 517 504 518 505 distclean: distclean-am 519 -rm -rf ./$(DEPDIR) containers/$(DEPDIR)506 -rm -rf ./$(DEPDIR) 520 507 -rm -f Makefile 521 508 distclean-am: clean-am distclean-compile distclean-generic \ … … 563 550 564 551 maintainer-clean: maintainer-clean-am 565 -rm -rf ./$(DEPDIR) containers/$(DEPDIR)552 -rm -rf ./$(DEPDIR) 566 553 -rm -f Makefile 567 554 maintainer-clean-am: distclean-am maintainer-clean-generic \
Note:
See TracChangeset
for help on using the changeset viewer.