Changeset 3f7e12cb for src/Parser/TypeData.cc
- Timestamp:
- Nov 8, 2017, 5:43:33 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 954908d
- Parents:
- 78315272 (diff), e35f30a (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
r78315272 r3f7e12cb 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Sep 1 23:13:38201713 // Update Count : 5 6912 // Last Modified On : Mon Sep 25 18:33:41 2017 13 // Update Count : 587 14 14 // 15 15 … … 98 98 } // TypeData::TypeData 99 99 100 100 101 TypeData::~TypeData() { 101 102 delete base; … … 161 162 } // switch 162 163 } // TypeData::~TypeData 164 163 165 164 166 TypeData * TypeData::clone() const { … … 235 237 } // TypeData::clone 236 238 239 237 240 void TypeData::print( ostream &os, int indent ) const { 238 241 for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) { … … 399 402 } // TypeData::print 400 403 404 401 405 template< typename ForallList > 402 406 void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) { 403 407 buildList( firstNode, outputList ); 404 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i ) { 408 auto n = firstNode; 409 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i, n = (DeclarationNode*)n->get_next() ) { 405 410 TypeDecl * td = static_cast<TypeDecl *>(*i); 406 if ( td->get_kind() == TypeDecl::Any) {411 if ( n->variable.tyClass == DeclarationNode::Otype ) { 407 412 // add assertion parameters to `type' tyvars in reverse order 408 413 // add dtor: void ^?{}(T *) … … 430 435 } // if 431 436 } // for 432 } 437 } // buildForall 438 433 439 434 440 Type * typebuild( const TypeData * td ) { … … 477 483 } // typebuild 478 484 485 479 486 TypeData * typeextractAggregate( const TypeData * td, bool toplevel ) { 480 487 TypeData * ret = nullptr; … … 504 511 } // typeextractAggregate 505 512 513 506 514 Type::Qualifiers buildQualifiers( const TypeData * td ) { 507 515 return td->qualifiers; 508 516 } // buildQualifiers 509 517 518 519 static string genTSError( string msg, DeclarationNode::BasicType basictype ) { 520 throw SemanticError( string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." ); 521 } // genTSError 522 510 523 Type * buildBasicType( const TypeData * td ) { 511 524 BasicType::Kind ret; … … 513 526 switch ( td->basictype ) { 514 527 case DeclarationNode::Void: 515 if ( td->signedness != DeclarationNode::NoSignedness && td->length != DeclarationNode::NoLength ) { 516 throw SemanticError( "invalid type specifier \"void\" in type: ", td ); 517 } // if 518 528 if ( td->signedness != DeclarationNode::NoSignedness ) { 529 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 530 } // if 531 if ( td->length != DeclarationNode::NoLength ) { 532 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 533 } // if 519 534 return new VoidType( buildQualifiers( td ) ); 520 535 break; … … 522 537 case DeclarationNode::Bool: 523 538 if ( td->signedness != DeclarationNode::NoSignedness ) { 524 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td);539 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 525 540 } // if 526 541 if ( td->length != DeclarationNode::NoLength ) { 527 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);542 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 528 543 } // if 529 544 … … 538 553 539 554 if ( td->length != DeclarationNode::NoLength ) { 540 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);555 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 541 556 } // if 542 557 … … 557 572 break; 558 573 574 case DeclarationNode::Int128: 575 ret = td->signedness == 1 ? BasicType::UnsignedInt128 : BasicType::SignedInt128; 576 if ( td->length != DeclarationNode::NoLength ) { 577 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 578 } // if 579 break; 580 559 581 case DeclarationNode::Float: 582 case DeclarationNode::Float80: 583 case DeclarationNode::Float128: 560 584 case DeclarationNode::Double: 561 585 case DeclarationNode::LongDouble: // not set until below … … 568 592 FloatingPoint: ; 569 593 if ( td->signedness != DeclarationNode::NoSignedness ) { 570 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td);594 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 571 595 } // if 572 596 if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) { 573 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);597 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 574 598 } // if 575 599 if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) { 576 throw SemanticError( "invalid type specifier \"long\" in type: ", td);600 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 577 601 } // if 578 602 if ( td->length == DeclarationNode::Long ) { … … 593 617 goto Integral; 594 618 default: 595 assert (false);619 assertf( false, "unknown basic type" ); 596 620 return nullptr; 597 621 } // switch … … 601 625 return bt; 602 626 } // buildBasicType 627 603 628 604 629 PointerType * buildPointer( const TypeData * td ) { … … 612 637 return pt; 613 638 } // buildPointer 639 614 640 615 641 ArrayType * buildArray( const TypeData * td ) { … … 626 652 } // buildArray 627 653 654 628 655 ReferenceType * buildReference( const TypeData * td ) { 629 656 ReferenceType * rt; … … 637 664 } // buildReference 638 665 666 639 667 AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 640 668 assert( td->kind == TypeData::Aggregate ); … … 665 693 return at; 666 694 } // buildAggregate 695 667 696 668 697 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { … … 722 751 } // buildAggInst 723 752 753 724 754 ReferenceToType * buildAggInst( const TypeData * td ) { 725 755 assert( td->kind == TypeData::AggregateInst ); … … 761 791 } // buildAggInst 762 792 793 763 794 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) { 764 795 assert( td->kind == TypeData::Symbolic ); … … 768 799 ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage ); 769 800 } else { 770 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl:: Any);801 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Dtype, true ); 771 802 } // if 772 803 buildList( td->symbolic.params, ret->get_parameters() ); … … 774 805 return ret; 775 806 } // buildSymbolic 807 776 808 777 809 EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { … … 790 822 } // buildEnum 791 823 824 792 825 TypeInstType * buildSymbolicInst( const TypeData * td ) { 793 826 assert( td->kind == TypeData::SymbolicInst ); … … 797 830 return ret; 798 831 } // buildSymbolicInst 832 799 833 800 834 TupleType * buildTuple( const TypeData * td ) { … … 807 841 } // buildTuple 808 842 843 809 844 TypeofType * buildTypeof( const TypeData * td ) { 810 845 assert( td->kind == TypeData::Typeof ); … … 813 848 return new TypeofType( buildQualifiers( td ), td->typeexpr->build() ); 814 849 } // buildTypeof 850 815 851 816 852 Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, Expression *asmName, Initializer * init, std::list< Attribute * > attributes ) { … … 836 872 return nullptr; 837 873 } // buildDecl 874 838 875 839 876 FunctionType * buildFunction( const TypeData * td ) { … … 857 894 return ft; 858 895 } // buildFunction 896 859 897 860 898 // Transform KR routine declarations into C99 routine declarations:
Note:
See TracChangeset
for help on using the changeset viewer.