Changeset 6840e7c for src/Parser/TypeData.cc
- Timestamp:
- Oct 19, 2017, 12:01:04 PM (8 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 837ce06
- Parents:
- b96ec83 (diff), a15b72c (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
rb96ec83 r6840e7c 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 ) { … … 398 401 } // switch 399 402 } // TypeData::print 403 400 404 401 405 template< typename ForallList > … … 430 434 } // if 431 435 } // for 432 } 436 } // buildForall 437 433 438 434 439 Type * typebuild( const TypeData * td ) { … … 477 482 } // typebuild 478 483 484 479 485 TypeData * typeextractAggregate( const TypeData * td, bool toplevel ) { 480 486 TypeData * ret = nullptr; … … 504 510 } // typeextractAggregate 505 511 512 506 513 Type::Qualifiers buildQualifiers( const TypeData * td ) { 507 514 return td->qualifiers; 508 515 } // buildQualifiers 509 516 517 518 static string genTSError( string msg, DeclarationNode::BasicType basictype ) { 519 throw SemanticError( string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." ); 520 } // genTSError 521 510 522 Type * buildBasicType( const TypeData * td ) { 511 523 BasicType::Kind ret; … … 513 525 switch ( td->basictype ) { 514 526 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 527 if ( td->signedness != DeclarationNode::NoSignedness ) { 528 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 529 } // if 530 if ( td->length != DeclarationNode::NoLength ) { 531 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 532 } // if 519 533 return new VoidType( buildQualifiers( td ) ); 520 534 break; … … 522 536 case DeclarationNode::Bool: 523 537 if ( td->signedness != DeclarationNode::NoSignedness ) { 524 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td);538 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 525 539 } // if 526 540 if ( td->length != DeclarationNode::NoLength ) { 527 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);541 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 528 542 } // if 529 543 … … 538 552 539 553 if ( td->length != DeclarationNode::NoLength ) { 540 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);554 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 541 555 } // if 542 556 … … 557 571 break; 558 572 573 case DeclarationNode::Int128: 574 ret = td->signedness == 1 ? BasicType::UnsignedInt128 : BasicType::SignedInt128; 575 if ( td->length != DeclarationNode::NoLength ) { 576 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 577 } // if 578 break; 579 559 580 case DeclarationNode::Float: 581 case DeclarationNode::Float80: 582 case DeclarationNode::Float128: 560 583 case DeclarationNode::Double: 561 584 case DeclarationNode::LongDouble: // not set until below … … 568 591 FloatingPoint: ; 569 592 if ( td->signedness != DeclarationNode::NoSignedness ) { 570 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td);593 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); 571 594 } // if 572 595 if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) { 573 throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td);596 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 574 597 } // if 575 598 if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) { 576 throw SemanticError( "invalid type specifier \"long\" in type: ", td);599 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 577 600 } // if 578 601 if ( td->length == DeclarationNode::Long ) { … … 593 616 goto Integral; 594 617 default: 595 assert (false);618 assertf( false, "unknown basic type" ); 596 619 return nullptr; 597 620 } // switch … … 601 624 return bt; 602 625 } // buildBasicType 626 603 627 604 628 PointerType * buildPointer( const TypeData * td ) { … … 612 636 return pt; 613 637 } // buildPointer 638 614 639 615 640 ArrayType * buildArray( const TypeData * td ) { … … 626 651 } // buildArray 627 652 653 628 654 ReferenceType * buildReference( const TypeData * td ) { 629 655 ReferenceType * rt; … … 637 663 } // buildReference 638 664 665 639 666 AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 640 667 assert( td->kind == TypeData::Aggregate ); … … 665 692 return at; 666 693 } // buildAggregate 694 667 695 668 696 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { … … 722 750 } // buildAggInst 723 751 752 724 753 ReferenceToType * buildAggInst( const TypeData * td ) { 725 754 assert( td->kind == TypeData::AggregateInst ); … … 761 790 } // buildAggInst 762 791 792 763 793 NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) { 764 794 assert( td->kind == TypeData::Symbolic ); … … 775 805 } // buildSymbolic 776 806 807 777 808 EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 778 809 assert( td->kind == TypeData::Enum ); … … 790 821 } // buildEnum 791 822 823 792 824 TypeInstType * buildSymbolicInst( const TypeData * td ) { 793 825 assert( td->kind == TypeData::SymbolicInst ); … … 797 829 return ret; 798 830 } // buildSymbolicInst 831 799 832 800 833 TupleType * buildTuple( const TypeData * td ) { … … 807 840 } // buildTuple 808 841 842 809 843 TypeofType * buildTypeof( const TypeData * td ) { 810 844 assert( td->kind == TypeData::Typeof ); … … 813 847 return new TypeofType( buildQualifiers( td ), td->typeexpr->build() ); 814 848 } // buildTypeof 849 815 850 816 851 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 871 return nullptr; 837 872 } // buildDecl 873 838 874 839 875 FunctionType * buildFunction( const TypeData * td ) { … … 857 893 return ft; 858 894 } // buildFunction 895 859 896 860 897 // Transform KR routine declarations into C99 routine declarations:
Note:
See TracChangeset
for help on using the changeset viewer.