Changeset 5b639ee
- Timestamp:
- Sep 12, 2016, 9:52:12 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:
- 101e0bd
- Parents:
- b6424d9
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rb6424d9 r5b639ee 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 11 09:24:11201613 // Update Count : 4 3812 // Last Modified On : Mon Sep 12 21:03:18 2016 13 // Update Count : 491 14 14 // 15 15 … … 32 32 // These must remain in the same order as the corresponding DeclarationNode enumerations. 33 33 const char *DeclarationNode::storageName[] = { "extern", "static", "auto", "register", "inline", "fortran", "_Noreturn", "_Thread_local", "NoStorageClass" }; 34 const char *DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue", "_Atomic" }; 35 const char *DeclarationNode::basicTypeName[] = { "char", "int", "float", "double", "void", "_Bool", "_Complex", "_Imaginary", }; 36 const char *DeclarationNode::modifierName[] = { "signed", "unsigned", "short", "long" }; 34 const char *DeclarationNode::qualifierName[] = { "const", "restrict", "volatile", "lvalue", "_Atomic", "NoQualifier" }; 35 const char *DeclarationNode::basicTypeName[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicType" }; 36 const char *DeclarationNode::complexTypeName[] = { "_Complex", "_Imaginary", "NoComplexType" }; 37 const char *DeclarationNode::signednessName[] = { "signed", "unsigned", "NoSignedness" }; 38 const char *DeclarationNode::lengthName[] = { "short", "long", "long long", "NoLength" }; 37 39 const char *DeclarationNode::aggregateName[] = { "struct", "union", "context" }; 38 const char *DeclarationNode::typeClassName[] = { " type", "dtype", "ftype" };40 const char *DeclarationNode::typeClassName[] = { "otype", "dtype", "ftype" }; 39 41 const char *DeclarationNode::builtinTypeName[] = { "__builtin_va_list" }; 40 42 … … 53 55 linkage( ::linkage ), 54 56 extension( false ) { 55 variable.tyClass = DeclarationNode:: Type;57 variable.tyClass = DeclarationNode::Otype; 56 58 variable.assertions = nullptr; 57 59 … … 188 190 DeclarationNode *newnode = new DeclarationNode; 189 191 newnode->type = new TypeData( TypeData::Basic ); 190 newnode->type->basic .typeSpec.push_back( bt );192 newnode->type->basictype = bt; 191 193 return newnode; 192 194 } // DeclarationNode::newBasicType 193 195 194 DeclarationNode * DeclarationNode::new Modifier( Modifier mod) {196 DeclarationNode * DeclarationNode::newComplexType( ComplexType ct ) { 195 197 DeclarationNode *newnode = new DeclarationNode; 196 198 newnode->type = new TypeData( TypeData::Basic ); 197 newnode->type->basic.modifiers.push_back( mod ); 198 return newnode; 199 } // DeclarationNode::newModifier 199 newnode->type->complextype = ct; 200 return newnode; 201 } // DeclarationNode::newComplexType 202 203 DeclarationNode * DeclarationNode::newSignedNess( Signedness sn ) { 204 DeclarationNode *newnode = new DeclarationNode; 205 newnode->type = new TypeData( TypeData::Basic ); 206 newnode->type->signedness = sn; 207 return newnode; 208 } // DeclarationNode::newSignedNess 209 210 DeclarationNode * DeclarationNode::newLength( Length lnth ) { 211 DeclarationNode *newnode = new DeclarationNode; 212 newnode->type = new TypeData( TypeData::Basic ); 213 newnode->type->length = lnth; 214 return newnode; 215 } // DeclarationNode::newLength 200 216 201 217 DeclarationNode * DeclarationNode::newFromTypedef( std::string *name ) { … … 388 404 } 389 405 406 void appendError( string & dst, const string & src ) { 407 if ( src.empty() ) return; 408 if ( dst.empty() ) { dst = src; return; } 409 dst += ", " + src; 410 } // appendError 411 390 412 void DeclarationNode::checkQualifiers( const TypeData *src, const TypeData *dst ) { 391 413 TypeData::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization 392 414 393 415 if ( (qsrc & qdst).any() ) { // common qualifier ? 394 for ( int i = 0; i < NoOfQualifier; i += 1 ) { // find common qualifiers 395 if ( qsrc[i] & qdst[i] ) { 396 if ( ! error.empty() ) error += ", "; // separator 397 error += string( "duplicate " ) + DeclarationNode::qualifierName[i]; 416 for ( int i = 0; i < NoQualifier; i += 1 ) { // find common qualifiers 417 if ( qsrc[i] && qdst[i] ) { 418 appendError( error, string( "duplicate " ) + DeclarationNode::qualifierName[i] ); 398 419 } // if 399 420 } // for … … 403 424 void DeclarationNode::checkStorageClasses( DeclarationNode *q ) { 404 425 if ( storageClass != NoStorageClass && q->storageClass != NoStorageClass ) { 405 if ( ! error.empty() ) error += ", "; // separator406 426 if ( storageClass == q->storageClass ) { // duplicate qualifier 407 error += string( "duplicate " ) + storageName[ storageClass ];427 appendError( error, string( "duplicate " ) + storageName[ storageClass ] ); 408 428 } else { // only one storage class 409 error += string( "conflicting " ) + storageName[ storageClass ] + " & " + storageName[ q->storageClass ]; 410 q->storageClass = storageClass; // FIX ERROR 411 } // if 412 if ( ! q->error.empty() ) error += ", " + q->error; // separator 413 } else { 414 if ( ! error.empty() ) { 415 if ( ! q->error.empty() ) error += ", " + q->error; // separator 416 } else if ( ! q->error.empty() ) error += q->error; 417 } // if 429 appendError( error, string( "conflicting " ) + storageName[ storageClass ] + " & " + storageName[ q->storageClass ] ); 430 q->storageClass = storageClass; // FIX ERROR, prevent assertions from triggering 431 } // if 432 } // if 433 appendError( error, q->error ); 418 434 } // DeclarationNode::copyStorageClasses 419 435 420 436 DeclarationNode *DeclarationNode::copyStorageClasses( DeclarationNode *q ) { 421 isInline = isInline | q->isInline;422 isNoreturn = isNoreturn | q->isNoreturn;437 isInline = isInline || q->isInline; 438 isNoreturn = isNoreturn || q->isNoreturn; 423 439 // do not overwrite an existing value with NoStorageClass 424 440 if ( q->storageClass != NoStorageClass ) { … … 483 499 if ( src->kind != TypeData::Unknown ) { 484 500 assert( src->kind == TypeData::Basic ); 485 dst->basic.modifiers.splice( dst->basic.modifiers.end(), src->basic.modifiers ); 486 dst->basic.typeSpec.splice( dst->basic.typeSpec.end(), src->basic.typeSpec ); 501 502 if ( dst->basictype == DeclarationNode::NoBasicType ) { 503 dst->basictype = src->basictype; 504 } else if ( src->basictype != DeclarationNode::NoBasicType ) 505 throw SemanticError( std::string( "conflicting type specifier " ) + DeclarationNode::basicTypeName[ src->basictype ] + " in type: ", src ); 506 507 if ( dst->complextype == DeclarationNode::NoComplexType ) { 508 dst->complextype = src->complextype; 509 } else if ( src->complextype != DeclarationNode::NoComplexType ) 510 throw SemanticError( std::string( "conflicting type specifier " ) + DeclarationNode::complexTypeName[ src->complextype ] + " in type: ", src ); 511 512 if ( dst->signedness == DeclarationNode::NoSignedness ) { 513 dst->signedness = src->signedness; 514 } else if ( src->signedness != DeclarationNode::NoSignedness ) 515 throw SemanticError( std::string( "conflicting type specifier " ) + DeclarationNode::signednessName[ src->signedness ] + " in type: ", src ); 516 517 if ( dst->length == DeclarationNode::NoLength ) { 518 dst->length = src->length; 519 } else if ( dst->length == DeclarationNode::Long && src->length == DeclarationNode::Long ) { 520 dst->length = DeclarationNode::LongLong; 521 } else if ( src->length != DeclarationNode::NoLength ) 522 throw SemanticError( std::string( "conflicting type specifier " ) + DeclarationNode::lengthName[ src->length ] + " in type: ", src ); 487 523 } // if 488 524 break; … … 875 911 while ( cur ) { 876 912 try { 877 /// if ( DeclarationNode *extr = cur->extractAggregate() ) {878 /// // handle the case where a structure declaration is contained within an object or type879 /// // declaration880 /// Declaration *decl = extr->build();881 /// if ( decl ) {882 /// *out++ = decl;883 /// }884 /// }885 913 Declaration *decl = cur->build(); 886 914 if ( decl ) { -
src/Parser/ParseNode.h
rb6424d9 r5b639ee 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 10 17:14:37201613 // Update Count : 58912 // Last Modified On : Mon Sep 12 08:00:05 2016 13 // Update Count : 603 14 14 // 15 15 … … 196 196 class DeclarationNode : public ParseNode { 197 197 public: 198 enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic, NoOfQualifier };198 // These must remain in the same order as the corresponding DeclarationNode names. 199 199 enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran, Noreturn, Threadlocal, NoStorageClass, }; 200 enum BasicType { Char, Int, Float, Double, Void, Bool, Complex, Imaginary }; 201 enum Modifier { Signed, Unsigned, Short, Long }; 200 enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic, NoQualifier }; 201 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 202 enum ComplexType { Complex, Imaginary, NoComplexType }; 203 enum Signedness { Signed, Unsigned, NoSignedness }; 204 enum Length { Short, Long, LongLong, NoLength }; 202 205 enum Aggregate { Struct, Union, Trait }; 203 enum TypeClass { Type, Dtype, Ftype };206 enum TypeClass { Otype, Dtype, Ftype }; 204 207 enum BuiltinType { Valist }; 205 208 209 static const char * storageName[]; 206 210 static const char * qualifierName[]; 207 static const char * storageName[];208 211 static const char * basicTypeName[]; 209 static const char * modifierName[]; 212 static const char * complexTypeName[]; 213 static const char * signednessName[]; 214 static const char * lengthName[]; 210 215 static const char * aggregateName[]; 211 216 static const char * typeClassName[]; … … 217 222 static DeclarationNode * newStorageClass( StorageClass ); 218 223 static DeclarationNode * newBasicType( BasicType ); 219 static DeclarationNode * newModifier( Modifier ); 224 static DeclarationNode * newComplexType( ComplexType ); 225 static DeclarationNode * newSignedNess( Signedness sn ); 226 static DeclarationNode * newLength( Length lnth ); 220 227 static DeclarationNode * newBuiltinType( BuiltinType ); 221 228 static DeclarationNode * newFromTypedef( std::string *); … … 309 316 TypeData * type; 310 317 std::string name; 311 // std::list< StorageClass > storageClasses;312 318 StorageClass storageClass; 313 319 bool isInline, isNoreturn; -
src/Parser/TypeData.cc
rb6424d9 r5b639ee 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 29 22:31:53201613 // Update Count : 27712 // Last Modified On : Mon Sep 12 21:11:22 2016 13 // Update Count : 377 14 14 // 15 15 … … 178 178 break; 179 179 case Basic: 180 newtype->basic.typeSpec = basic.typeSpec; 181 newtype->basic.modifiers = basic.modifiers; 180 newtype->basictype = basictype; 181 newtype->complextype = complextype; 182 newtype->signedness = signedness; 183 newtype->length = length; 182 184 break; 183 185 case Array: … … 247 249 using std::string; 248 250 249 for ( int i = 0; i < DeclarationNode::No OfQualifier; i += 1 ) {251 for ( int i = 0; i < DeclarationNode::NoQualifier; i += 1 ) { 250 252 if ( qualifiers[i] ) os << DeclarationNode::qualifierName[ i ] << ' '; 251 253 } // for … … 271 273 break; 272 274 case Basic: 273 printEnums( basic.modifiers.begin(), basic.modifiers.end(), DeclarationNode::modifierName, os ); 274 printEnums( basic.typeSpec.begin(), basic.typeSpec.end(), DeclarationNode::basicTypeName, os ); 275 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessName[ signedness ] << " "; 276 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthName[ length ] << " "; 277 assert( basictype != DeclarationNode::NoBasicType ); 278 os << DeclarationNode::basicTypeName[ basictype ] << " "; 279 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeName[ complextype ] << " "; 275 280 break; 276 281 case Array: … … 418 423 break; 419 424 default: 420 os << "internal error: TypeData::print " << kind 425 os << "internal error: TypeData::print " << kind << endl; 421 426 assert( false ); 422 427 } // switch … … 531 536 532 537 Type * buildBasicType( const TypeData * td ) { 533 static const BasicType::Kind kindMap[] = { BasicType::Char, BasicType::SignedInt, BasicType::Float, BasicType::Double,534 BasicType::Char /* void */, BasicType::Bool, BasicType::DoubleComplex,535 BasicType::DoubleImaginary };536 bool init = false;537 bool sawDouble = false;538 bool sawSigned = false;539 538 BasicType::Kind ret; 540 539 541 for ( std::list< DeclarationNode::BasicType >::const_iterator i = td->basic.typeSpec.begin(); i != td->basic.typeSpec.end(); ++i ) { 542 if ( ! init ) { 543 init = true; 544 if ( *i == DeclarationNode::Void ) { 545 if ( td->basic.typeSpec.size() != 1 || ! td->basic.modifiers.empty() ) { 546 throw SemanticError( "invalid type specifier \"void\" in type: ", td ); 547 } else { 548 return new VoidType( buildQualifiers( td ) ); 549 } // if 550 } else { 551 ret = kindMap[ *i ]; 552 } // if 553 } else { 554 switch ( *i ) { 555 case DeclarationNode::Float: 556 if ( sawDouble ) { 557 throw SemanticError( "invalid type specifier \"float\" in type: ", td ); 558 } else { 559 switch ( ret ) { 560 case BasicType::DoubleComplex: 561 ret = BasicType::FloatComplex; 562 break; 563 case BasicType::DoubleImaginary: 564 ret = BasicType::FloatImaginary; 565 break; 566 default: 567 throw SemanticError( "invalid type specifier \"float\" in type: ", td ); 568 } // switch 569 } // if 570 break; 571 case DeclarationNode::Double: 572 if ( sawDouble ) { 573 throw SemanticError( "duplicate type specifier \"double\" in type: ", td ); 574 } else { 575 switch ( ret ) { 576 case BasicType::DoubleComplex: 577 case BasicType::DoubleImaginary: 578 break; 579 default: 580 throw SemanticError( "invalid type specifier \"double\" in type: ", td ); 581 } // switch 582 } // if 583 break; 584 case DeclarationNode::Complex: 585 switch ( ret ) { 586 case BasicType::Float: 587 ret = BasicType::FloatComplex; 588 break; 589 case BasicType::Double: 590 ret = BasicType::DoubleComplex; 591 break; 592 default: 593 throw SemanticError( "invalid type specifier \"_Complex\" in type: ", td ); 594 } // switch 595 break; 596 case DeclarationNode::Imaginary: 597 switch ( ret ) { 598 case BasicType::Float: 599 ret = BasicType::FloatImaginary; 600 break; 601 case BasicType::Double: 602 ret = BasicType::DoubleImaginary; 603 break; 604 default: 605 throw SemanticError( "invalid type specifier \"_Imaginary\" in type: ", td ); 606 } // switch 607 break; 608 default: 609 throw SemanticError( std::string( "invalid type specifier \"" ) + DeclarationNode::basicTypeName[ *i ] + "\" in type: ", td ); 610 } // switch 611 } // if 612 if ( *i == DeclarationNode::Double ) { 613 sawDouble = true; 614 } // if 615 } // for 616 617 for ( std::list< DeclarationNode::Modifier >::const_iterator i = td->basic.modifiers.begin(); i != td->basic.modifiers.end(); ++i ) { 618 switch ( *i ) { 619 case DeclarationNode::Long: 620 if ( ! init ) { 621 init = true; 622 ret = BasicType::LongSignedInt; 623 } else { 624 switch ( ret ) { 625 case BasicType::SignedInt: 626 ret = BasicType::LongSignedInt; 627 break; 628 case BasicType::UnsignedInt: 629 ret = BasicType::LongUnsignedInt; 630 break; 631 case BasicType::LongSignedInt: 632 ret = BasicType::LongLongSignedInt; 633 break; 634 case BasicType::LongUnsignedInt: 635 ret = BasicType::LongLongUnsignedInt; 636 break; 637 case BasicType::Double: 638 ret = BasicType::LongDouble; 639 break; 640 case BasicType::DoubleComplex: 641 ret = BasicType::LongDoubleComplex; 642 break; 643 case BasicType::DoubleImaginary: 644 ret = BasicType::LongDoubleImaginary; 645 break; 646 default: 647 throw SemanticError( "invalid type modifier \"long\" in type: ", td ); 648 } // switch 649 } // if 650 break; 651 case DeclarationNode::Short: 652 if ( ! init ) { 653 init = true; 654 ret = BasicType::ShortSignedInt; 655 } else { 656 switch ( ret ) { 657 case BasicType::SignedInt: 658 ret = BasicType::ShortSignedInt; 659 break; 660 case BasicType::UnsignedInt: 661 ret = BasicType::ShortUnsignedInt; 662 break; 663 default: 664 throw SemanticError( "invalid type modifier \"short\" in type: ", td ); 665 } // switch 666 } // if 667 break; 668 case DeclarationNode::Signed: 669 if ( ! init ) { 670 init = true; 671 ret = BasicType::SignedInt; 672 } else if ( sawSigned ) { 673 throw SemanticError( "duplicate type modifer \"signed\" in type: ", td ); 674 } else { 675 switch ( ret ) { 676 case BasicType::LongLongSignedInt: 677 ret = BasicType::LongLongUnsignedInt; 678 break; 679 case BasicType::LongSignedInt: 680 ret = BasicType::LongUnsignedInt; 681 break; 682 case BasicType::SignedInt: 683 case BasicType::ShortSignedInt: 684 break; 685 case BasicType::Char: 686 ret = BasicType::SignedChar; 687 break; 688 default: 689 throw SemanticError( "invalid type modifer \"signed\" in type: ", td ); 690 } // switch 691 } // if 692 break; 693 case DeclarationNode::Unsigned: 694 if ( ! init ) { 695 init = true; 696 ret = BasicType::UnsignedInt; 697 } else if ( sawSigned ) { 698 throw SemanticError( "invalid type modifer \"unsigned\" in type: ", td ); 699 } else { 700 switch ( ret ) { 701 case BasicType::LongLongSignedInt: 702 ret = BasicType::LongLongUnsignedInt; 703 break; 704 case BasicType::LongSignedInt: 705 ret = BasicType::LongUnsignedInt; 706 break; 707 case BasicType::SignedInt: 708 ret = BasicType::UnsignedInt; 709 break; 710 case BasicType::ShortSignedInt: 711 ret = BasicType::ShortUnsignedInt; 712 break; 713 case BasicType::Char: 714 ret = BasicType::UnsignedChar; 715 break; 716 default: 717 throw SemanticError( "invalid type modifer \"unsigned\" in type: ", td ); 718 } // switch 719 } // if 720 break; 721 } // switch 722 723 if ( *i == DeclarationNode::Signed ) { 724 sawSigned = true; 725 } // if 726 } // for 727 728 BasicType * bt; 729 if ( ! init ) { 730 bt = new BasicType( buildQualifiers( td ), BasicType::SignedInt ); 731 } else { 732 bt = new BasicType( buildQualifiers( td ), ret ); 733 } // if 540 switch ( td->basictype ) { 541 case DeclarationNode::Void: 542 if ( td->signedness != DeclarationNode::NoSignedness && td->length != DeclarationNode::NoLength ) { 543 throw SemanticError( "invalid type specifier \"void\" in type: ", td ); 544 } // if 545 546 return new VoidType( buildQualifiers( td ) ); 547 break; 548 549 case DeclarationNode::Bool: 550 if ( td->signedness != DeclarationNode::NoSignedness ) { 551 throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td ); 552 } // if 553 if ( td->length != DeclarationNode::NoLength ) { 554 throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td ); 555 } // if 556 557 ret = BasicType::Bool; 558 break; 559 560 case DeclarationNode::Char: 561 // C11 Standard 6.2.5.15: The three types char, signed char, and unsigned char are collectively called the 562 // character types. The implementation shall define char to have the same range, representation, and behavior as 563 // either signed char or unsigned char. 564 static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char }; 565 566 if ( td->length != DeclarationNode::NoLength ) { 567 throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td ); 568 } // if 569 570 ret = chartype[ td->signedness ]; 571 break; 572 573 case DeclarationNode::Int: 574 static BasicType::Kind inttype[2][4] = { 575 { BasicType::ShortSignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt }, 576 { BasicType::ShortUnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt }, 577 }; 578 579 Integral: ; 580 if ( td->signedness == DeclarationNode::NoSignedness ) { 581 const_cast<TypeData *>(td)->signedness = DeclarationNode::Signed; 582 } // if 583 ret = inttype[ td->signedness ][ td->length ]; 584 break; 585 586 case DeclarationNode::Float: 587 case DeclarationNode::Double: 588 case DeclarationNode::LongDouble: // not set until below 589 static BasicType::Kind floattype[3][3] = { 590 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex }, 591 { BasicType::FloatImaginary, BasicType::DoubleImaginary, BasicType::LongDoubleImaginary }, 592 { BasicType::Float, BasicType::Double, BasicType::LongDouble }, 593 }; 594 595 FloatingPoint: ; 596 if ( td->signedness != DeclarationNode::NoSignedness ) { 597 throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td ); 598 } // if 599 if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) { 600 throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td ); 601 } // if 602 if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) { 603 throw SemanticError( "invalid type specifier \"long\" in type: ", td ); 604 } // if 605 if ( td->length == DeclarationNode::Long ) { 606 const_cast<TypeData *>(td)->basictype = DeclarationNode::LongDouble; 607 } // if 608 609 ret = floattype[ td->complextype ][ td->basictype - DeclarationNode::Float ]; 610 break; 611 612 case DeclarationNode::NoBasicType: 613 // No basic type in declaration => default double for Complex/Imaginary and int type for integral types 614 if ( td->complextype == DeclarationNode::Complex || td->complextype == DeclarationNode::Imaginary ) { 615 const_cast<TypeData *>(td)->basictype = DeclarationNode::Double; 616 goto FloatingPoint; 617 } // if 618 619 const_cast<TypeData *>(td)->basictype = DeclarationNode::Int; 620 goto Integral; 621 } // switch 622 623 BasicType * bt = new BasicType( buildQualifiers( td ), ret ); 734 624 buildForall( td->forall, bt->get_forall() ); 735 625 return bt; -
src/Parser/TypeData.h
rb6424d9 r5b639ee 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 10 09:42:54201613 // Update Count : 1 1812 // Last Modified On : Mon Sep 12 17:15:49 2016 13 // Update Count : 129 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 }; 27 28 struct Basic_t {29 std::list< DeclarationNode::BasicType > typeSpec;30 std::list< DeclarationNode::Modifier > modifiers;31 };32 27 33 28 struct Aggregate_t { … … 73 68 }; 74 69 75 // struct Tuple_t {76 // DeclarationNode * members;77 // };78 79 // struct Typeof_t {80 // ExpressionNode * expr;81 // };82 83 // struct Builtin_t {84 // DeclarationNode::BuiltinType type;85 // };86 87 70 Kind kind; 88 71 TypeData * base; 89 typedef std::bitset< DeclarationNode::NoOfQualifier > Qualifiers; 72 DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType; 73 DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType; 74 DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness; 75 DeclarationNode::Length length = DeclarationNode::NoLength; 76 typedef std::bitset< DeclarationNode::NoQualifier > Qualifiers; 90 77 Qualifiers qualifiers; 91 typedef std::bitset< DeclarationNode::NoStorageClass > StorageClasses;92 StorageClasses storageclasses;93 78 DeclarationNode * forall; 94 79 95 Basic_t basic;80 // Basic_t basic; 96 81 Aggregate_t aggregate; 97 82 AggInst_t aggInst; -
src/Parser/parser.cc
rb6424d9 r5b639ee 5929 5929 /* Line 1806 of yacc.c */ 5930 5930 #line 829 "parser.yy" 5931 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn) ) ); }5931 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn), true ) ); } 5932 5932 break; 5933 5933 … … 6744 6744 /* Line 1806 of yacc.c */ 6745 6745 #line 1365 "parser.yy" 6746 { (yyval.decl) = DeclarationNode::new Modifier( DeclarationNode::Long ); }6746 { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Long ); } 6747 6747 break; 6748 6748 … … 6751 6751 /* Line 1806 of yacc.c */ 6752 6752 #line 1367 "parser.yy" 6753 { (yyval.decl) = DeclarationNode::new Modifier( DeclarationNode::Short ); }6753 { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Short ); } 6754 6754 break; 6755 6755 … … 6758 6758 /* Line 1806 of yacc.c */ 6759 6759 #line 1369 "parser.yy" 6760 { (yyval.decl) = DeclarationNode::new Modifier( DeclarationNode::Signed ); }6760 { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Signed ); } 6761 6761 break; 6762 6762 … … 6765 6765 /* Line 1806 of yacc.c */ 6766 6766 #line 1371 "parser.yy" 6767 { (yyval.decl) = DeclarationNode::new Modifier( DeclarationNode::Unsigned ); }6767 { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); } 6768 6768 break; 6769 6769 … … 6786 6786 /* Line 1806 of yacc.c */ 6787 6787 #line 1377 "parser.yy" 6788 { (yyval.decl) = DeclarationNode::new BasicType( DeclarationNode::Complex ); }6788 { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 6789 6789 break; 6790 6790 … … 6793 6793 /* Line 1806 of yacc.c */ 6794 6794 #line 1379 "parser.yy" 6795 { (yyval.decl) = DeclarationNode::new BasicType( DeclarationNode::Imaginary ); }6795 { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 6796 6796 break; 6797 6797 … … 7544 7544 /* Line 1806 of yacc.c */ 7545 7545 #line 1851 "parser.yy" 7546 { (yyval.tclass) = DeclarationNode:: Type; }7546 { (yyval.tclass) = DeclarationNode::Otype; } 7547 7547 break; 7548 7548 -
src/Parser/parser.yy
rb6424d9 r5b639ee 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 : Mon Sep 12 17:29:45 2016 13 // Update Count : 1969 14 14 // 15 15 … … 827 827 { $$ = new StatementNode( build_while( $3, $5 ) ); } 828 828 | DO statement WHILE '(' comma_expression ')' ';' 829 { $$ = new StatementNode( build_while( $5, $2 ) ); }829 { $$ = new StatementNode( build_while( $5, $2, true ) ); } 830 830 | FOR '(' push for_control_expression ')' statement 831 831 { $$ = new StatementNode( build_for( $4, $6 ) ); } … … 1363 1363 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int ); } 1364 1364 | LONG 1365 { $$ = DeclarationNode::new Modifier( DeclarationNode::Long ); }1365 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1366 1366 | SHORT 1367 { $$ = DeclarationNode::new Modifier( DeclarationNode::Short ); }1367 { $$ = DeclarationNode::newLength( DeclarationNode::Short ); } 1368 1368 | SIGNED 1369 { $$ = DeclarationNode::new Modifier( DeclarationNode::Signed ); }1369 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Signed ); } 1370 1370 | UNSIGNED 1371 { $$ = DeclarationNode::new Modifier( DeclarationNode::Unsigned ); }1371 { $$ = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); } 1372 1372 | VOID 1373 1373 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } … … 1375 1375 { $$ = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 1376 1376 | COMPLEX // C99 1377 { $$ = DeclarationNode::new BasicType( DeclarationNode::Complex ); }1377 { $$ = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 1378 1378 | IMAGINARY // C99 1379 { $$ = DeclarationNode::new BasicType( DeclarationNode::Imaginary ); }1379 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1380 1380 | VALIST // GCC, __builtin_va_list 1381 1381 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } … … 1849 1849 type_class: // CFA 1850 1850 OTYPE 1851 { $$ = DeclarationNode:: Type; }1851 { $$ = DeclarationNode::Otype; } 1852 1852 | DTYPE 1853 1853 { $$ = DeclarationNode::Ftype; } -
src/libcfa/limits.c
rb6424d9 r5b639ee 10 10 // Created On : Wed Apr 6 18:06:52 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 8 13:23:33201613 // Update Count : 1 412 // Last Modified On : Mon Sep 12 10:34:48 2016 13 // Update Count : 17 14 14 // 15 15 … … 63 63 const long double _2_SQRT_PI = 1.1283791670955125738961589031215452_DL; // 2 / sqrt(pi) 64 64 65 const _Complex PI = 3.14159265358979323846_D+0.0_iD; // pi66 const _Complex PI_2 = 1.57079632679489661923_D+0.0_iD;// pi / 267 const _Complex PI_4 = 0.78539816339744830962_D+0.0_iD;// pi / 468 const _Complex _1_PI = 0.31830988618379067154_D+0.0_iD;// 1 / pi69 const _Complex _2_PI = 0.63661977236758134308_D+0.0_iD;// 2 / pi70 const _Complex _2_SQRT_PI = 1.12837916709551257390_D+0.0_iD; // 2 / sqrt(pi)65 const double _Complex PI = 3.14159265358979323846_D+0.0_iD; // pi 66 const double _Complex PI_2 = 1.57079632679489661923_D+0.0_iD; // pi / 2 67 const double _Complex PI_4 = 0.78539816339744830962_D+0.0_iD; // pi / 4 68 const double _Complex _1_PI = 0.31830988618379067154_D+0.0_iD; // 1 / pi 69 const double _Complex _2_PI = 0.63661977236758134308_D+0.0_iD; // 2 / pi 70 const double _Complex _2_SQRT_PI = 1.12837916709551257390_D+0.0_iD; // 2 / sqrt(pi) 71 71 72 const long _Complex PI = 3.1415926535897932384626433832795029_L+0.0iL; // pi73 const long _Complex PI_2 = 1.5707963267948966192313216916397514_L+0.0iL; // pi / 274 const long _Complex PI_4 = 0.7853981633974483096156608458198757_L+0.0iL; // pi / 475 const long _Complex _1_PI = 0.3183098861837906715377675267450287_L+0.0iL; // 1 / pi76 const long _Complex _2_PI = 0.6366197723675813430755350534900574_L+0.0iL; // 2 / pi77 const long _Complex _2_SQRT_PI = 1.1283791670955125738961589031215452_L+0.0iL; // 2 / sqrt(pi)72 const long double _Complex PI = 3.1415926535897932384626433832795029_L+0.0iL; // pi 73 const long double _Complex PI_2 = 1.5707963267948966192313216916397514_L+0.0iL; // pi / 2 74 const long double _Complex PI_4 = 0.7853981633974483096156608458198757_L+0.0iL; // pi / 4 75 const long double _Complex _1_PI = 0.3183098861837906715377675267450287_L+0.0iL; // 1 / pi 76 const long double _Complex _2_PI = 0.6366197723675813430755350534900574_L+0.0iL; // 2 / pi 77 const long double _Complex _2_SQRT_PI = 1.1283791670955125738961589031215452_L+0.0iL; // 2 / sqrt(pi) 78 78 79 79 const float E = 2.718281; // e … … 101 101 const long double _1_SQRT_2 = 0.7071067811865475244008443621048490_DL; // 1/sqrt(2) 102 102 103 const _Complex E = 2.7182818284590452354_D+0.0_iD;// e104 const _Complex LOG2_E = 1.4426950408889634074_D+0.0_iD;// log_2(e)105 const _Complex LOG10_E = 0.43429448190325182765_D+0.0_iD; // log_10(e)106 const _Complex LN_2 = 0.69314718055994530942_D+0.0_iD;// log_e(2)107 const _Complex LN_10 = 2.30258509299404568402_D+0.0_iD;// log_e(10)108 const _Complex SQRT_2 = 1.41421356237309504880_D+0.0_iD; // sqrt(2)109 const _Complex _1_SQRT_2 = 0.70710678118654752440_D+0.0_iD; // 1 / sqrt(2)103 const double _Complex E = 2.7182818284590452354_D+0.0_iD; // e 104 const double _Complex LOG2_E = 1.4426950408889634074_D+0.0_iD; // log_2(e) 105 const double _Complex LOG10_E = 0.43429448190325182765_D+0.0_iD; // log_10(e) 106 const double _Complex LN_2 = 0.69314718055994530942_D+0.0_iD; // log_e(2) 107 const double _Complex LN_10 = 2.30258509299404568402_D+0.0_iD; // log_e(10) 108 const double _Complex SQRT_2 = 1.41421356237309504880_D+0.0_iD; // sqrt(2) 109 const double _Complex _1_SQRT_2 = 0.70710678118654752440_D+0.0_iD; // 1 / sqrt(2) 110 110 111 const long _Complex E = 2.7182818284590452353602874713526625_L+0.0_iL; // e112 const long _Complex LOG2_E = 1.4426950408889634073599246810018921_L+0.0_iL; // log_2(e)113 const long _Complex LOG10_E = 0.4342944819032518276511289189166051_L+0.0_iL; // log_10(e)114 const long _Complex LN_2 = 0.6931471805599453094172321214581766_L+0.0_iL; // log_e(2)115 const long _Complex LN_10 = 2.3025850929940456840179914546843642_L+0.0_iL; // log_e(10)116 const long _Complex SQRT_2 = 1.4142135623730950488016887242096981_L+0.0_iL; // sqrt(2)117 const long _Complex _1_SQRT_2 = 0.7071067811865475244008443621048490_L+0.0_iL; // 1 / sqrt(2)111 const long double _Complex E = 2.7182818284590452353602874713526625_L+0.0_iL; // e 112 const long double _Complex LOG2_E = 1.4426950408889634073599246810018921_L+0.0_iL; // log_2(e) 113 const long double _Complex LOG10_E = 0.4342944819032518276511289189166051_L+0.0_iL; // log_10(e) 114 const long double _Complex LN_2 = 0.6931471805599453094172321214581766_L+0.0_iL; // log_e(2) 115 const long double _Complex LN_10 = 2.3025850929940456840179914546843642_L+0.0_iL; // log_e(10) 116 const long double _Complex SQRT_2 = 1.4142135623730950488016887242096981_L+0.0_iL; // sqrt(2) 117 const long double _Complex _1_SQRT_2 = 0.7071067811865475244008443621048490_L+0.0_iL; // 1 / sqrt(2) 118 118 119 119 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.