Changeset bb7422a for src/Parser/TypeData.cc
- Timestamp:
- Apr 4, 2023, 2:25:52 PM (15 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- beeff61e, e02e13f
- Parents:
- 4541b09
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypeData.cc
r4541b09 rbb7422a 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 15:12:51 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Feb 19 11:00:46202313 // Update Count : 6 7911 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Apr 4 13:39:00 2023 13 // Update Count : 680 14 14 // 15 16 #include "TypeData.h" 15 17 16 18 #include <cassert> // for assert 17 19 #include <ostream> // for operator<<, ostream, basic_ostream 18 20 21 #include "AST/Decl.hpp" // for AggregateDecl, ObjectDecl, TypeDe... 22 #include "AST/Init.hpp" // for SingleInit, ListInit 23 #include "AST/Print.hpp" // for print 19 24 #include "Common/SemanticError.h" // for SemanticError 20 #include "Common/utility.h" // for maybeClone, maybeBuild, maybeMoveB... 25 #include "Common/utility.h" // for splice, spliceBegin 26 #include "Parser/parserutility.h" // for maybeCopy, maybeBuild, maybeMoveB... 21 27 #include "Parser/ParseNode.h" // for DeclarationNode, ExpressionNode 22 #include "SynTree/Declaration.h" // for TypeDecl, ObjectDecl, FunctionDecl23 #include "SynTree/Expression.h" // for Expression, ConstantExpr (ptr only)24 #include "SynTree/Initializer.h" // for SingleInit, Initializer (ptr only)25 #include "SynTree/Statement.h" // for CompoundStmt, Statement26 #include "SynTree/Type.h" // for BasicType, Type, Type::ForallList27 #include "TypeData.h"28 28 29 29 class Attribute; … … 60 60 break; 61 61 case Aggregate: 62 aggregate.kind = AggregateDecl::NoAggregate;62 aggregate.kind = ast::AggregateDecl::NoAggregate; 63 63 aggregate.name = nullptr; 64 64 aggregate.params = nullptr; … … 89 89 typeexpr = nullptr; 90 90 break; 91 case Vtable: 91 92 case Builtin: 92 case Vtable:93 93 // No unique data to initialize. 94 94 break; … … 111 111 case EnumConstant: 112 112 case GlobalScope: 113 case Basic: 113 114 // No unique data to deconstruct. 114 break;115 case Basic:116 115 break; 117 116 case Array: … … 250 249 251 250 void TypeData::print( ostream &os, int indent ) const { 252 for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) { 253 if ( qualifiers[i] ) os << Type::QualifiersNames[ i ] << ' '; 254 } // for 251 ast::print( os, qualifiers ); 255 252 256 253 if ( forall ) { … … 325 322 break; 326 323 case Aggregate: 327 os << AggregateDecl::aggrString( aggregate.kind ) << ' ' << *aggregate.name << endl;324 os << ast::AggregateDecl::aggrString( aggregate.kind ) << ' ' << *aggregate.name << endl; 328 325 if ( aggregate.params ) { 329 326 os << string( indent + 2, ' ' ) << "with type parameters" << endl; … … 472 469 473 470 474 template< typename ForallList > 475 void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) { 476 buildList( firstNode, outputList ); 471 void buildForall( 472 const DeclarationNode * firstNode, 473 std::vector<ast::ptr<ast::TypeInstType>> &outputList ) { 474 { 475 std::vector<ast::ptr<ast::Type>> tmpList; 476 buildTypeList( firstNode, tmpList ); 477 for ( auto tmp : tmpList ) { 478 outputList.emplace_back( 479 strict_dynamic_cast<const ast::TypeInstType *>( 480 tmp.release() ) ); 481 } 482 } 477 483 auto n = firstNode; 478 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i, n = (DeclarationNode*)n->get_next() ) { 479 TypeDecl * td = static_cast<TypeDecl *>(*i); 480 if ( n->variable.tyClass == TypeDecl::Otype ) { 481 // add assertion parameters to `type' tyvars in reverse order 482 // add dtor: void ^?{}(T *) 483 FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false ); 484 dtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 485 td->get_assertions().push_front( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) ); 486 487 // add copy ctor: void ?{}(T *, T) 488 FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false ); 489 copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 490 copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 491 td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) ); 492 493 // add default ctor: void ?{}(T *) 494 FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false ); 495 ctorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 496 td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) ); 497 498 // add assignment operator: T * ?=?(T *, T) 499 FunctionType * assignType = new FunctionType( Type::Qualifiers(), false ); 500 assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 501 assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 502 assignType->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 503 td->get_assertions().push_front( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) ); 504 } // if 484 for ( auto i = outputList.begin() ; 485 i != outputList.end() ; 486 ++i, n = (DeclarationNode*)n->get_next() ) { 487 // Only the object type class adds additional assertions. 488 if ( n->variable.tyClass != ast::TypeDecl::Otype ) { 489 continue; 490 } 491 492 ast::TypeDecl const * td = i->strict_as<ast::TypeDecl>(); 493 std::vector<ast::ptr<ast::DeclWithType>> newAssertions; 494 auto mutTypeDecl = ast::mutate( td ); 495 const CodeLocation & location = mutTypeDecl->location; 496 *i = mutTypeDecl; 497 498 // add assertion parameters to `type' tyvars in reverse order 499 // add assignment operator: T * ?=?(T *, T) 500 newAssertions.push_back( new ast::FunctionDecl( 501 location, 502 "?=?", 503 {}, // forall 504 {}, // assertions 505 { 506 new ast::ObjectDecl( 507 location, 508 "", 509 new ast::ReferenceType( i->get() ), 510 (ast::Init *)nullptr, 511 ast::Storage::Classes(), 512 ast::Linkage::Cforall, 513 (ast::Expr *)nullptr 514 ), 515 new ast::ObjectDecl( 516 location, 517 "", 518 i->get(), 519 (ast::Init *)nullptr, 520 ast::Storage::Classes(), 521 ast::Linkage::Cforall, 522 (ast::Expr *)nullptr 523 ), 524 }, // params 525 { 526 new ast::ObjectDecl( 527 location, 528 "", 529 i->get(), 530 (ast::Init *)nullptr, 531 ast::Storage::Classes(), 532 ast::Linkage::Cforall, 533 (ast::Expr *)nullptr 534 ), 535 }, // returns 536 (ast::CompoundStmt *)nullptr, 537 ast::Storage::Classes(), 538 ast::Linkage::Cforall 539 ) ); 540 541 // add default ctor: void ?{}(T *) 542 newAssertions.push_back( new ast::FunctionDecl( 543 location, 544 "?{}", 545 {}, // forall 546 {}, // assertions 547 { 548 new ast::ObjectDecl( 549 location, 550 "", 551 new ast::ReferenceType( i->get() ), 552 (ast::Init *)nullptr, 553 ast::Storage::Classes(), 554 ast::Linkage::Cforall, 555 (ast::Expr *)nullptr 556 ), 557 }, // params 558 {}, // returns 559 (ast::CompoundStmt *)nullptr, 560 ast::Storage::Classes(), 561 ast::Linkage::Cforall 562 ) ); 563 564 // add copy ctor: void ?{}(T *, T) 565 newAssertions.push_back( new ast::FunctionDecl( 566 location, 567 "?{}", 568 {}, // forall 569 {}, // assertions 570 { 571 new ast::ObjectDecl( 572 location, 573 "", 574 new ast::ReferenceType( i->get() ), 575 (ast::Init *)nullptr, 576 ast::Storage::Classes(), 577 ast::Linkage::Cforall, 578 (ast::Expr *)nullptr 579 ), 580 new ast::ObjectDecl( 581 location, 582 "", 583 i->get(), 584 (ast::Init *)nullptr, 585 ast::Storage::Classes(), 586 ast::Linkage::Cforall, 587 (ast::Expr *)nullptr 588 ), 589 }, // params 590 {}, // returns 591 (ast::CompoundStmt *)nullptr, 592 ast::Storage::Classes(), 593 ast::Linkage::Cforall 594 ) ); 595 596 // add dtor: void ^?{}(T *) 597 newAssertions.push_back( new ast::FunctionDecl( 598 location, 599 "^?{}", 600 {}, // forall 601 {}, // assertions 602 { 603 new ast::ObjectDecl( 604 location, 605 "", 606 new ast::ReferenceType( i->get() ), 607 (ast::Init *)nullptr, 608 ast::Storage::Classes(), 609 ast::Linkage::Cforall, 610 (ast::Expr *)nullptr 611 ), 612 }, // params 613 {}, // returns 614 (ast::CompoundStmt *)nullptr, 615 ast::Storage::Classes(), 616 ast::Linkage::Cforall 617 ) ); 618 619 spliceBegin( mutTypeDecl->assertions, newAssertions ); 620 } // for 621 } 622 623 624 void buildForall( 625 const DeclarationNode * firstNode, 626 std::vector<ast::ptr<ast::TypeDecl>> &outputForall ) { 627 buildList( firstNode, outputForall ); 628 auto n = firstNode; 629 for ( auto i = outputForall.begin() ; 630 i != outputForall.end() ; 631 ++i, n = (DeclarationNode*)n->get_next() ) { 632 // Only the object type class adds additional assertions. 633 if ( n->variable.tyClass != ast::TypeDecl::Otype ) { 634 continue; 635 } 636 637 ast::TypeDecl const * td = i->strict_as<ast::TypeDecl>(); 638 std::vector<ast::ptr<ast::DeclWithType>> newAssertions; 639 auto mutTypeDecl = ast::mutate( td ); 640 const CodeLocation & location = mutTypeDecl->location; 641 *i = mutTypeDecl; 642 643 // add assertion parameters to `type' tyvars in reverse order 644 // add assignment operator: T * ?=?(T *, T) 645 newAssertions.push_back( new ast::FunctionDecl( 646 location, 647 "?=?", 648 {}, // forall 649 {}, // assertions 650 { 651 new ast::ObjectDecl( 652 location, 653 "", 654 new ast::ReferenceType( new ast::TypeInstType( td->name, *i ) ), 655 (ast::Init *)nullptr, 656 ast::Storage::Classes(), 657 ast::Linkage::Cforall, 658 (ast::Expr *)nullptr 659 ), 660 new ast::ObjectDecl( 661 location, 662 "", 663 new ast::TypeInstType( td->name, *i ), 664 (ast::Init *)nullptr, 665 ast::Storage::Classes(), 666 ast::Linkage::Cforall, 667 (ast::Expr *)nullptr 668 ), 669 }, // params 670 { 671 new ast::ObjectDecl( 672 location, 673 "", 674 new ast::TypeInstType( td->name, *i ), 675 (ast::Init *)nullptr, 676 ast::Storage::Classes(), 677 ast::Linkage::Cforall, 678 (ast::Expr *)nullptr 679 ), 680 }, // returns 681 (ast::CompoundStmt *)nullptr, 682 ast::Storage::Classes(), 683 ast::Linkage::Cforall 684 ) ); 685 686 // add default ctor: void ?{}(T *) 687 newAssertions.push_back( new ast::FunctionDecl( 688 location, 689 "?{}", 690 {}, // forall 691 {}, // assertions 692 { 693 new ast::ObjectDecl( 694 location, 695 "", 696 new ast::ReferenceType( 697 new ast::TypeInstType( td->name, i->get() ) ), 698 (ast::Init *)nullptr, 699 ast::Storage::Classes(), 700 ast::Linkage::Cforall, 701 (ast::Expr *)nullptr 702 ), 703 }, // params 704 {}, // returns 705 (ast::CompoundStmt *)nullptr, 706 ast::Storage::Classes(), 707 ast::Linkage::Cforall 708 ) ); 709 710 // add copy ctor: void ?{}(T *, T) 711 newAssertions.push_back( new ast::FunctionDecl( 712 location, 713 "?{}", 714 {}, // forall 715 {}, // assertions 716 { 717 new ast::ObjectDecl( 718 location, 719 "", 720 new ast::ReferenceType( 721 new ast::TypeInstType( td->name, *i ) ), 722 (ast::Init *)nullptr, 723 ast::Storage::Classes(), 724 ast::Linkage::Cforall, 725 (ast::Expr *)nullptr 726 ), 727 new ast::ObjectDecl( 728 location, 729 "", 730 new ast::TypeInstType( td->name, *i ), 731 (ast::Init *)nullptr, 732 ast::Storage::Classes(), 733 ast::Linkage::Cforall, 734 (ast::Expr *)nullptr 735 ), 736 }, // params 737 {}, // returns 738 (ast::CompoundStmt *)nullptr, 739 ast::Storage::Classes(), 740 ast::Linkage::Cforall 741 ) ); 742 743 // add dtor: void ^?{}(T *) 744 newAssertions.push_back( new ast::FunctionDecl( 745 location, 746 "^?{}", 747 {}, // forall 748 {}, // assertions 749 { 750 new ast::ObjectDecl( 751 location, 752 "", 753 new ast::ReferenceType( 754 new ast::TypeInstType( i->get() ) 755 ), 756 (ast::Init *)nullptr, 757 ast::Storage::Classes(), 758 ast::Linkage::Cforall, 759 (ast::Expr *)nullptr 760 ), 761 }, // params 762 {}, // returns 763 (ast::CompoundStmt *)nullptr, 764 ast::Storage::Classes(), 765 ast::Linkage::Cforall 766 ) ); 767 768 spliceBegin( mutTypeDecl->assertions, newAssertions ); 505 769 } // for 506 770 } // buildForall 507 771 508 772 509 Type * typebuild( const TypeData * td ) {773 ast::Type * typebuild( const TypeData * td ) { 510 774 assert( td ); 511 775 switch ( td->kind ) { 512 776 case TypeData::Unknown: 513 777 // fill in implicit int 514 return new BasicType( buildQualifiers( td ), BasicType::SignedInt ); 778 return new ast::BasicType( 779 ast::BasicType::SignedInt, 780 buildQualifiers( td ) 781 ); 515 782 case TypeData::Basic: 516 783 return buildBasicType( td ); … … 522 789 return buildReference( td ); 523 790 case TypeData::Function: 524 return buildFunction ( td );791 return buildFunctionType( td ); 525 792 case TypeData::AggregateInst: 526 793 return buildAggInst( td ); 527 794 case TypeData::EnumConstant: 528 return new EnumInstType( buildQualifiers( td ), "");795 return new ast::EnumInstType( "", buildQualifiers( td ) ); 529 796 case TypeData::SymbolicInst: 530 797 return buildSymbolicInst( td ); … … 539 806 switch ( td->builtintype ) { 540 807 case DeclarationNode::Zero: 541 return new ZeroType( noQualifiers);808 return new ast::ZeroType(); 542 809 case DeclarationNode::One: 543 return new OneType( noQualifiers);810 return new ast::OneType(); 544 811 default: 545 return new VarArgsType( buildQualifiers( td ) );812 return new ast::VarArgsType( buildQualifiers( td ) ); 546 813 } // switch 547 814 case TypeData::GlobalScope: 548 return new GlobalScopeType();815 return new ast::GlobalScopeType(); 549 816 case TypeData::Qualified: 550 return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) ); 817 return new ast::QualifiedType( 818 typebuild( td->qualified.parent ), 819 typebuild( td->qualified.child ), 820 buildQualifiers( td ) 821 ); 551 822 case TypeData::Symbolic: 552 823 case TypeData::Enum: … … 587 858 588 859 589 Type::Qualifiers buildQualifiers( const TypeData * td ) {860 ast::CV::Qualifiers buildQualifiers( const TypeData * td ) { 590 861 return td->qualifiers; 591 862 } // buildQualifiers … … 596 867 } // genTSError 597 868 598 Type * buildBasicType( const TypeData * td ) {599 BasicType::Kind ret;869 ast::Type * buildBasicType( const TypeData * td ) { 870 ast::BasicType::Kind ret; 600 871 601 872 switch ( td->basictype ) { … … 607 878 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); 608 879 } // if 609 return new VoidType( buildQualifiers( td ) );880 return new ast::VoidType( buildQualifiers( td ) ); 610 881 break; 611 882 … … 618 889 } // if 619 890 620 ret = BasicType::Bool;891 ret = ast::BasicType::Bool; 621 892 break; 622 893 … … 625 896 // character types. The implementation shall define char to have the same range, representation, and behavior as 626 897 // either signed char or unsigned char. 627 static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar,BasicType::Char };898 static ast::BasicType::Kind chartype[] = { ast::BasicType::SignedChar, ast::BasicType::UnsignedChar, ast::BasicType::Char }; 628 899 629 900 if ( td->length != DeclarationNode::NoLength ) { … … 635 906 636 907 case DeclarationNode::Int: 637 static BasicType::Kind inttype[2][4] = {638 { BasicType::ShortSignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt,BasicType::SignedInt },639 { BasicType::ShortUnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt,BasicType::UnsignedInt },908 static ast::BasicType::Kind inttype[2][4] = { 909 { ast::BasicType::ShortSignedInt, ast::BasicType::LongSignedInt, ast::BasicType::LongLongSignedInt, ast::BasicType::SignedInt }, 910 { ast::BasicType::ShortUnsignedInt, ast::BasicType::LongUnsignedInt, ast::BasicType::LongLongUnsignedInt, ast::BasicType::UnsignedInt }, 640 911 }; 641 912 … … 648 919 649 920 case DeclarationNode::Int128: 650 ret = td->signedness == DeclarationNode::Unsigned ? BasicType::UnsignedInt128 :BasicType::SignedInt128;921 ret = td->signedness == DeclarationNode::Unsigned ? ast::BasicType::UnsignedInt128 : ast::BasicType::SignedInt128; 651 922 if ( td->length != DeclarationNode::NoLength ) { 652 923 genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype ); … … 666 937 case DeclarationNode::uFloat128: 667 938 case DeclarationNode::uFloat128x: 668 static BasicType::Kind floattype[2][12] = {669 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, (BasicType::Kind)-1, (BasicType::Kind)-1, BasicType::uFloat16Complex, BasicType::uFloat32Complex, BasicType::uFloat32xComplex, BasicType::uFloat64Complex, BasicType::uFloat64xComplex, BasicType::uFloat128Complex,BasicType::uFloat128xComplex, },670 { BasicType::Float, BasicType::Double, BasicType::LongDouble, BasicType::uuFloat80, BasicType::uuFloat128, BasicType::uFloat16, BasicType::uFloat32, BasicType::uFloat32x, BasicType::uFloat64, BasicType::uFloat64x, BasicType::uFloat128,BasicType::uFloat128x, },939 static ast::BasicType::Kind floattype[2][12] = { 940 { ast::BasicType::FloatComplex, ast::BasicType::DoubleComplex, ast::BasicType::LongDoubleComplex, (ast::BasicType::Kind)-1, (ast::BasicType::Kind)-1, ast::BasicType::uFloat16Complex, ast::BasicType::uFloat32Complex, ast::BasicType::uFloat32xComplex, ast::BasicType::uFloat64Complex, ast::BasicType::uFloat64xComplex, ast::BasicType::uFloat128Complex, ast::BasicType::uFloat128xComplex, }, 941 { ast::BasicType::Float, ast::BasicType::Double, ast::BasicType::LongDouble, ast::BasicType::uuFloat80, ast::BasicType::uuFloat128, ast::BasicType::uFloat16, ast::BasicType::uFloat32, ast::BasicType::uFloat32x, ast::BasicType::uFloat64, ast::BasicType::uFloat64x, ast::BasicType::uFloat128, ast::BasicType::uFloat128x, }, 671 942 }; 672 943 … … 709 980 } // switch 710 981 711 BasicType * bt = new BasicType( buildQualifiers( td ), ret ); 712 buildForall( td->forall, bt->get_forall() ); 982 ast::BasicType * bt = new ast::BasicType( ret, buildQualifiers( td ) ); 713 983 return bt; 714 984 } // buildBasicType 715 985 716 986 717 PointerType * buildPointer( const TypeData * td ) {718 PointerType * pt;987 ast::PointerType * buildPointer( const TypeData * td ) { 988 ast::PointerType * pt; 719 989 if ( td->base ) { 720 pt = new PointerType( buildQualifiers( td ), typebuild( td->base ) ); 990 pt = new ast::PointerType( 991 typebuild( td->base ), 992 buildQualifiers( td ) 993 ); 721 994 } else { 722 pt = new PointerType( buildQualifiers( td ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 995 pt = new ast::PointerType( 996 new ast::BasicType( ast::BasicType::SignedInt ), 997 buildQualifiers( td ) 998 ); 723 999 } // if 724 buildForall( td->forall, pt->get_forall() );725 1000 return pt; 726 1001 } // buildPointer 727 1002 728 1003 729 ArrayType * buildArray( const TypeData * td ) {730 ArrayType * at;1004 ast::ArrayType * buildArray( const TypeData * td ) { 1005 ast::ArrayType * at; 731 1006 if ( td->base ) { 732 at = new ArrayType( buildQualifiers( td ), typebuild( td->base ), maybeBuild( td->array.dimension ), 733 td->array.isVarLen, td->array.isStatic ); 1007 at = new ast::ArrayType( 1008 typebuild( td->base ), 1009 maybeBuild( td->array.dimension ), 1010 td->array.isVarLen ? ast::VariableLen : ast::FixedLen, 1011 td->array.isStatic ? ast::StaticDim : ast::DynamicDim, 1012 buildQualifiers( td ) 1013 ); 734 1014 } else { 735 at = new ArrayType( buildQualifiers( td ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 736 maybeBuild( td->array.dimension ), td->array.isVarLen, td->array.isStatic ); 1015 at = new ast::ArrayType( 1016 new ast::BasicType( ast::BasicType::SignedInt ), 1017 maybeBuild( td->array.dimension ), 1018 td->array.isVarLen ? ast::VariableLen : ast::FixedLen, 1019 td->array.isStatic ? ast::StaticDim : ast::DynamicDim, 1020 buildQualifiers( td ) 1021 ); 737 1022 } // if 738 buildForall( td->forall, at->get_forall() );739 1023 return at; 740 1024 } // buildArray 741 1025 742 1026 743 ReferenceType * buildReference( const TypeData * td ) {744 ReferenceType * rt;1027 ast::ReferenceType * buildReference( const TypeData * td ) { 1028 ast::ReferenceType * rt; 745 1029 if ( td->base ) { 746 rt = new ReferenceType( buildQualifiers( td ), typebuild( td->base ) ); 1030 rt = new ast::ReferenceType( 1031 typebuild( td->base ), 1032 buildQualifiers( td ) 1033 ); 747 1034 } else { 748 rt = new ReferenceType( buildQualifiers( td ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 1035 rt = new ast::ReferenceType( 1036 new ast::BasicType( ast::BasicType::SignedInt ), 1037 buildQualifiers( td ) 1038 ); 749 1039 } // if 750 buildForall( td->forall, rt->get_forall() );751 1040 return rt; 752 1041 } // buildReference 753 1042 754 1043 755 AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {1044 ast::AggregateDecl * buildAggregate( const TypeData * td, std::vector<ast::ptr<ast::Attribute>> attributes, ast::Linkage::Spec linkage ) { 756 1045 assert( td->kind == TypeData::Aggregate ); 757 AggregateDecl * at;1046 ast::AggregateDecl * at; 758 1047 switch ( td->aggregate.kind ) { 759 case AggregateDecl::Struct: 760 case AggregateDecl::Coroutine: 761 case AggregateDecl::Exception: 762 case AggregateDecl::Generator: 763 case AggregateDecl::Monitor: 764 case AggregateDecl::Thread: 765 at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage ); 766 buildForall( td->aggregate.params, at->get_parameters() ); 767 break; 768 case AggregateDecl::Union: 769 at = new UnionDecl( *td->aggregate.name, attributes, linkage ); 770 buildForall( td->aggregate.params, at->get_parameters() ); 771 break; 772 case AggregateDecl::Trait: 773 at = new TraitDecl( *td->aggregate.name, attributes, linkage ); 774 buildList( td->aggregate.params, at->get_parameters() ); 1048 case ast::AggregateDecl::Struct: 1049 case ast::AggregateDecl::Coroutine: 1050 case ast::AggregateDecl::Exception: 1051 case ast::AggregateDecl::Generator: 1052 case ast::AggregateDecl::Monitor: 1053 case ast::AggregateDecl::Thread: 1054 at = new ast::StructDecl( td->location, 1055 *td->aggregate.name, 1056 td->aggregate.kind, 1057 std::move( attributes ), 1058 linkage 1059 ); 1060 buildForall( td->aggregate.params, at->params ); 1061 break; 1062 case ast::AggregateDecl::Union: 1063 at = new ast::UnionDecl( td->location, 1064 *td->aggregate.name, 1065 std::move( attributes ), 1066 linkage 1067 ); 1068 buildForall( td->aggregate.params, at->params ); 1069 break; 1070 case ast::AggregateDecl::Trait: 1071 at = new ast::TraitDecl( td->location, 1072 *td->aggregate.name, 1073 std::move( attributes ), 1074 linkage 1075 ); 1076 buildList( td->aggregate.params, at->params ); 775 1077 break; 776 1078 default: … … 778 1080 } // switch 779 1081 780 buildList( td->aggregate.fields, at-> get_members());1082 buildList( td->aggregate.fields, at->members ); 781 1083 at->set_body( td->aggregate.body ); 782 1084 … … 785 1087 786 1088 787 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 1089 ast::BaseInstType * buildComAggInst( 1090 const TypeData * type, 1091 std::vector<ast::ptr<ast::Attribute>> && attributes, 1092 ast::Linkage::Spec linkage ) { 788 1093 switch ( type->kind ) { 789 1094 case TypeData::Enum: 790 1095 if ( type->enumeration.body ) { 791 EnumDecl * typedecl = buildEnum( type, attributes, linkage ); 792 return new EnumInstType( buildQualifiers( type ), typedecl ); 1096 ast::EnumDecl * typedecl = 1097 buildEnum( type, std::move( attributes ), linkage ); 1098 return new ast::EnumInstType( 1099 typedecl, 1100 buildQualifiers( type ) 1101 ); 793 1102 } else { 794 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 795 } // if 1103 return new ast::EnumInstType( 1104 *type->enumeration.name, 1105 buildQualifiers( type ) 1106 ); 1107 } // if 1108 break; 796 1109 case TypeData::Aggregate: 797 1110 if ( type->aggregate.body ) { 798 AggregateDecl * typedecl = buildAggregate( type, attributes, linkage ); 1111 ast::AggregateDecl * typedecl = 1112 buildAggregate( type, std::move( attributes ), linkage ); 799 1113 switch ( type->aggregate.kind ) { 800 case AggregateDecl::Struct: 801 case AggregateDecl::Coroutine: 802 case AggregateDecl::Monitor: 803 case AggregateDecl::Thread: 804 return new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 805 case AggregateDecl::Union: 806 return new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 807 case AggregateDecl::Trait: 1114 case ast::AggregateDecl::Struct: 1115 case ast::AggregateDecl::Coroutine: 1116 case ast::AggregateDecl::Monitor: 1117 case ast::AggregateDecl::Thread: 1118 return new ast::StructInstType( 1119 strict_dynamic_cast<ast::StructDecl *>( typedecl ), 1120 buildQualifiers( type ) 1121 ); 1122 case ast::AggregateDecl::Union: 1123 return new ast::UnionInstType( 1124 strict_dynamic_cast<ast::UnionDecl *>( typedecl ), 1125 buildQualifiers( type ) 1126 ); 1127 case ast::AggregateDecl::Trait: 808 1128 assert( false ); 809 //return new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl );810 1129 break; 811 1130 default: … … 814 1133 } else { 815 1134 switch ( type->aggregate.kind ) { 816 case AggregateDecl::Struct: 817 case AggregateDecl::Coroutine: 818 case AggregateDecl::Monitor: 819 case AggregateDecl::Thread: 820 return new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 821 case AggregateDecl::Union: 822 return new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 823 case AggregateDecl::Trait: 824 return new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 1135 case ast::AggregateDecl::Struct: 1136 case ast::AggregateDecl::Coroutine: 1137 case ast::AggregateDecl::Monitor: 1138 case ast::AggregateDecl::Thread: 1139 return new ast::StructInstType( 1140 *type->aggregate.name, 1141 buildQualifiers( type ) 1142 ); 1143 case ast::AggregateDecl::Union: 1144 return new ast::UnionInstType( 1145 *type->aggregate.name, 1146 buildQualifiers( type ) 1147 ); 1148 case ast::AggregateDecl::Trait: 1149 return new ast::TraitInstType( 1150 *type->aggregate.name, 1151 buildQualifiers( type ) 1152 ); 825 1153 default: 826 1154 assert( false ); 827 1155 } // switch 828 } // if 829 return nullptr; 1156 break; 1157 } // if 1158 break; 830 1159 default: 831 1160 assert( false ); 832 1161 } // switch 1162 assert( false ); 833 1163 } // buildAggInst 834 1164 835 1165 836 ReferenceToType * buildAggInst( const TypeData * td ) {1166 ast::BaseInstType * buildAggInst( const TypeData * td ) { 837 1167 assert( td->kind == TypeData::AggregateInst ); 838 1168 839 // ReferenceToType * ret = buildComAggInst( td->aggInst.aggregate, std::list< Attribute * >() ); 840 ReferenceToType * ret = nullptr; 1169 ast::BaseInstType * ret = nullptr; 841 1170 TypeData * type = td->aggInst.aggregate; 842 1171 switch ( type->kind ) { 843 1172 case TypeData::Enum: 844 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 1173 return new ast::EnumInstType( 1174 *type->enumeration.name, 1175 buildQualifiers( type ) 1176 ); 845 1177 case TypeData::Aggregate: 846 1178 switch ( type->aggregate.kind ) { 847 case AggregateDecl::Struct: 848 case AggregateDecl::Coroutine: 849 case AggregateDecl::Monitor: 850 case AggregateDecl::Thread: 851 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 1179 case ast::AggregateDecl::Struct: 1180 case ast::AggregateDecl::Coroutine: 1181 case ast::AggregateDecl::Monitor: 1182 case ast::AggregateDecl::Thread: 1183 ret = new ast::StructInstType( 1184 *type->aggregate.name, 1185 buildQualifiers( type ) 1186 ); 852 1187 break; 853 case AggregateDecl::Union: 854 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 1188 case ast::AggregateDecl::Union: 1189 ret = new ast::UnionInstType( 1190 *type->aggregate.name, 1191 buildQualifiers( type ) 1192 ); 855 1193 break; 856 case AggregateDecl::Trait: 857 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 1194 case ast::AggregateDecl::Trait: 1195 ret = new ast::TraitInstType( 1196 *type->aggregate.name, 1197 buildQualifiers( type ) 1198 ); 858 1199 break; 859 1200 default: … … 865 1206 } // switch 866 1207 867 ret->set_hoistType( td->aggInst.hoistType ); 868 buildList( td->aggInst.params, ret->get_parameters() ); 869 buildForall( td->forall, ret->get_forall() ); 1208 ret->hoistType = td->aggInst.hoistType; 1209 buildList( td->aggInst.params, ret->params ); 870 1210 return ret; 871 1211 } // buildAggInst 872 1212 873 1213 874 NamedTypeDecl * buildSymbolic( const TypeData * td, std::list< Attribute * > attributes, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) { 1214 ast::NamedTypeDecl * buildSymbolic( 1215 const TypeData * td, 1216 std::vector<ast::ptr<ast::Attribute>> attributes, 1217 const std::string & name, 1218 ast::Storage::Classes scs, 1219 ast::Linkage::Spec linkage ) { 875 1220 assert( td->kind == TypeData::Symbolic ); 876 NamedTypeDecl * ret;1221 ast::NamedTypeDecl * ret; 877 1222 assert( td->base ); 878 1223 if ( td->symbolic.isTypedef ) { 879 ret = new TypedefDecl( name, td->location, scs, typebuild( td->base ), linkage ); 1224 ret = new ast::TypedefDecl( 1225 td->location, 1226 name, 1227 scs, 1228 typebuild( td->base ), 1229 linkage 1230 ); 880 1231 } else { 881 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Dtype, true ); 1232 ret = new ast::TypeDecl( 1233 td->location, 1234 name, 1235 scs, 1236 typebuild( td->base ), 1237 ast::TypeDecl::Dtype, 1238 true 1239 ); 882 1240 } // if 883 buildList( td->symbolic.assertions, ret-> get_assertions());884 ret->base->attributes.splice( ret->base->attributes.end(), attributes );1241 buildList( td->symbolic.assertions, ret->assertions ); 1242 splice( ret->base.get_and_mutate()->attributes, attributes ); 885 1243 return ret; 886 1244 } // buildSymbolic 887 1245 888 1246 889 EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 1247 ast::EnumDecl * buildEnum( 1248 const TypeData * td, 1249 std::vector<ast::ptr<ast::Attribute>> && attributes, 1250 ast::Linkage::Spec linkage ) { 890 1251 assert( td->kind == TypeData::Enum ); 891 Type * baseType = td->base ? typebuild(td->base) : nullptr; 892 EnumDecl * ret = new EnumDecl( *td->enumeration.name, attributes, td->enumeration.typed, linkage, baseType ); 893 buildList( td->enumeration.constants, ret->get_members() ); 894 list< Declaration * >::iterator members = ret->get_members().begin(); 895 ret->hide = td->enumeration.hiding == EnumHiding::Hide ? EnumDecl::EnumHiding::Hide : EnumDecl::EnumHiding::Visible; 1252 ast::Type * baseType = td->base ? typebuild(td->base) : nullptr; 1253 ast::EnumDecl * ret = new ast::EnumDecl( 1254 td->location, 1255 *td->enumeration.name, 1256 td->enumeration.typed, 1257 std::move( attributes ), 1258 linkage, 1259 baseType 1260 ); 1261 buildList( td->enumeration.constants, ret->members ); 1262 auto members = ret->members.begin(); 1263 ret->hide = td->enumeration.hiding == EnumHiding::Hide ? ast::EnumDecl::EnumHiding::Hide : ast::EnumDecl::EnumHiding::Visible; 896 1264 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 897 1265 if ( cur->enumInLine ) { … … 900 1268 SemanticError( td->location, "Enumerator of enum(void) cannot have an explicit initializer value." ); 901 1269 } else if ( cur->has_enumeratorValue() ) { 902 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); 903 member->set_init( new SingleInit( maybeMoveBuild( cur->consume_enumeratorValue() ) ) ); 1270 ast::Decl * member = members->get_and_mutate(); 1271 ast::ObjectDecl * object = strict_dynamic_cast<ast::ObjectDecl *>( member ); 1272 object->init = new ast::SingleInit( 1273 td->location, 1274 maybeMoveBuild( cur->consume_enumeratorValue() ), 1275 ast::NoConstruct 1276 ); 904 1277 } else if ( !cur->initializer ) { 905 if ( baseType && (!dynamic_cast< BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->isInteger())) {1278 if ( baseType && (!dynamic_cast<ast::BasicType *>(baseType) || !dynamic_cast<ast::BasicType *>(baseType)->isInteger())) { 906 1279 SemanticError( td->location, "Enumerators of an non-integer typed enum must be explicitly initialized." ); 907 1280 } … … 910 1283 // if 911 1284 } // for 912 ret-> set_body( td->enumeration.body );1285 ret->body = td->enumeration.body; 913 1286 return ret; 914 1287 } // buildEnum 915 1288 916 1289 917 TypeInstType * buildSymbolicInst( const TypeData * td ) {1290 ast::TypeInstType * buildSymbolicInst( const TypeData * td ) { 918 1291 assert( td->kind == TypeData::SymbolicInst ); 919 TypeInstType * ret = new TypeInstType( buildQualifiers( td ), *td->symbolic.name, false ); 920 buildList( td->symbolic.actuals, ret->get_parameters() ); 921 buildForall( td->forall, ret->get_forall() ); 1292 ast::TypeInstType * ret = new ast::TypeInstType( 1293 *td->symbolic.name, 1294 ast::TypeDecl::Dtype, 1295 buildQualifiers( td ) 1296 ); 1297 buildList( td->symbolic.actuals, ret->params ); 922 1298 return ret; 923 1299 } // buildSymbolicInst 924 1300 925 1301 926 TupleType * buildTuple( const TypeData * td ) {1302 ast::TupleType * buildTuple( const TypeData * td ) { 927 1303 assert( td->kind == TypeData::Tuple ); 928 std:: list< Type *> types;1304 std::vector<ast::ptr<ast::Type>> types; 929 1305 buildTypeList( td->tuple, types ); 930 TupleType * ret = new TupleType( buildQualifiers( td ), types ); 931 buildForall( td->forall, ret->get_forall() ); 1306 ast::TupleType * ret = new ast::TupleType( 1307 std::move( types ), 1308 buildQualifiers( td ) 1309 ); 932 1310 return ret; 933 1311 } // buildTuple 934 1312 935 1313 936 TypeofType * buildTypeof( const TypeData * td ) {1314 ast::TypeofType * buildTypeof( const TypeData * td ) { 937 1315 assert( td->kind == TypeData::Typeof || td->kind == TypeData::Basetypeof ); 938 1316 assert( td->typeexpr ); 939 // assert( td->typeexpr->expr ); 940 return new TypeofType{ buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof }; 1317 return new ast::TypeofType( 1318 td->typeexpr->build(), 1319 td->kind == TypeData::Typeof 1320 ? ast::TypeofType::Typeof : ast::TypeofType::Basetypeof, 1321 buildQualifiers( td ) 1322 ); 941 1323 } // buildTypeof 942 1324 943 1325 944 VTableType * buildVtable( const TypeData * td ) {1326 ast::VTableType * buildVtable( const TypeData * td ) { 945 1327 assert( td->base ); 946 return new VTableType{ buildQualifiers( td ), typebuild( td->base ) }; 1328 return new ast::VTableType( 1329 typebuild( td->base ), 1330 buildQualifiers( td ) 1331 ); 947 1332 } // buildVtable 948 1333 949 1334 950 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 ) { 1335 ast::FunctionDecl * buildFunctionDecl( 1336 const TypeData * td, 1337 const string &name, 1338 ast::Storage::Classes scs, 1339 ast::Function::Specs funcSpec, 1340 ast::Linkage::Spec linkage, 1341 ast::Expr * asmName, 1342 std::vector<ast::ptr<ast::Attribute>> && attributes ) { 1343 assert( td->kind == TypeData::Function ); 1344 // For some reason FunctionDecl takes a bool instead of an ArgumentFlag. 1345 bool isVarArgs = !td->function.params || td->function.params->hasEllipsis; 1346 ast::CV::Qualifiers cvq = buildQualifiers( td ); 1347 std::vector<ast::ptr<ast::TypeDecl>> forall; 1348 std::vector<ast::ptr<ast::DeclWithType>> assertions; 1349 std::vector<ast::ptr<ast::DeclWithType>> params; 1350 std::vector<ast::ptr<ast::DeclWithType>> returns; 1351 buildList( td->function.params, params ); 1352 buildForall( td->forall, forall ); 1353 // Functions do not store their assertions there anymore. 1354 for ( ast::ptr<ast::TypeDecl> & type_param : forall ) { 1355 auto mut = type_param.get_and_mutate(); 1356 splice( assertions, mut->assertions ); 1357 } 1358 if ( td->base ) { 1359 switch ( td->base->kind ) { 1360 case TypeData::Tuple: 1361 buildList( td->base->tuple, returns ); 1362 break; 1363 default: 1364 returns.push_back( dynamic_cast<ast::DeclWithType *>( 1365 buildDecl( 1366 td->base, 1367 "", 1368 ast::Storage::Classes(), 1369 (ast::Expr *)nullptr, // bitfieldWidth 1370 ast::Function::Specs(), 1371 ast::Linkage::Cforall, 1372 (ast::Expr *)nullptr // asmName 1373 ) 1374 ) ); 1375 } // switch 1376 } else { 1377 returns.push_back( new ast::ObjectDecl( 1378 td->location, 1379 "", 1380 new ast::BasicType( ast::BasicType::SignedInt ), 1381 (ast::Init *)nullptr, 1382 ast::Storage::Classes(), 1383 ast::Linkage::Cforall 1384 ) ); 1385 } // if 1386 ast::Stmt * stmt = maybeBuild( td->function.body ); 1387 ast::CompoundStmt * body = dynamic_cast<ast::CompoundStmt *>( stmt ); 1388 ast::FunctionDecl * decl = new ast::FunctionDecl( td->location, 1389 name, 1390 std::move( forall ), 1391 std::move( assertions ), 1392 std::move( params ), 1393 std::move( returns ), 1394 body, 1395 scs, 1396 linkage, 1397 std::move( attributes ), 1398 funcSpec, 1399 isVarArgs 1400 ); 1401 buildList( td->function.withExprs, decl->withExprs ); 1402 decl->asmName = asmName; 1403 // This may be redundant on a declaration. 1404 decl->type.get_and_mutate()->qualifiers = cvq; 1405 return decl; 1406 } // buildFunctionDecl 1407 1408 1409 ast::Decl * buildDecl( 1410 const TypeData * td, 1411 const string &name, 1412 ast::Storage::Classes scs, 1413 ast::Expr * bitfieldWidth, 1414 ast::Function::Specs funcSpec, 1415 ast::Linkage::Spec linkage, 1416 ast::Expr * asmName, 1417 ast::Init * init, 1418 std::vector<ast::ptr<ast::Attribute>> && attributes ) { 951 1419 if ( td->kind == TypeData::Function ) { 952 1420 if ( td->function.idList ) { // KR function ? … … 954 1422 } // if 955 1423 956 FunctionDecl * decl; 957 Statement * stmt = maybeBuild( td->function.body ); 958 CompoundStmt * body = dynamic_cast< CompoundStmt * >( stmt ); 959 decl = new FunctionDecl( name, scs, linkage, buildFunction( td ), body, attributes, funcSpec ); 960 buildList( td->function.withExprs, decl->withExprs ); 961 return decl->set_asmName( asmName ); 1424 return buildFunctionDecl( 1425 td, name, scs, funcSpec, linkage, 1426 asmName, std::move( attributes ) ); 962 1427 } else if ( td->kind == TypeData::Aggregate ) { 963 return buildAggregate( td, attributes, linkage );1428 return buildAggregate( td, std::move( attributes ), linkage ); 964 1429 } else if ( td->kind == TypeData::Enum ) { 965 return buildEnum( td, attributes, linkage );1430 return buildEnum( td, std::move( attributes ), linkage ); 966 1431 } else if ( td->kind == TypeData::Symbolic ) { 967 return buildSymbolic( td, attributes, name, scs, linkage );1432 return buildSymbolic( td, std::move( attributes ), name, scs, linkage ); 968 1433 } else { 969 return (new ObjectDecl( name, scs, linkage, bitfieldWidth, typebuild( td ), init, attributes ))->set_asmName( asmName ); 1434 auto ret = new ast::ObjectDecl( td->location, 1435 name, 1436 typebuild( td ), 1437 init, 1438 scs, 1439 linkage, 1440 bitfieldWidth, 1441 std::move( attributes ) 1442 ); 1443 ret->asmName = asmName; 1444 return ret; 970 1445 } // if 971 1446 return nullptr; … … 973 1448 974 1449 975 FunctionType * buildFunction( const TypeData * td ) {1450 ast::FunctionType * buildFunctionType( const TypeData * td ) { 976 1451 assert( td->kind == TypeData::Function ); 977 FunctionType * ft = new FunctionType( buildQualifiers( td ), ! td->function.params || td->function.params->hasEllipsis ); 978 buildList( td->function.params, ft->parameters ); 1452 ast::FunctionType * ft = new ast::FunctionType( 1453 ( !td->function.params || td->function.params->hasEllipsis ) 1454 ? ast::VariableArgs : ast::FixedArgs, 1455 buildQualifiers( td ) 1456 ); 1457 buildTypeList( td->function.params, ft->params ); 979 1458 buildForall( td->forall, ft->forall ); 980 1459 if ( td->base ) { 981 1460 switch ( td->base->kind ) { 982 1461 case TypeData::Tuple: 983 build List( td->base->tuple, ft->returnVals );1462 buildTypeList( td->base->tuple, ft->returns ); 984 1463 break; 985 1464 default: 986 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) ); 1465 ft->returns.push_back( typebuild( td->base ) ); 1466 break; 987 1467 } // switch 988 1468 } else { 989 ft->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) ); 1469 ft->returns.push_back( 1470 new ast::BasicType( ast::BasicType::SignedInt ) ); 990 1471 } // if 991 1472 return ft; 992 } // buildFunction 1473 } // buildFunctionType 993 1474 994 1475 … … 1021 1502 param->type = decl->type; // set copy declaration type to parameter type 1022 1503 decl->type = nullptr; // reset declaration type 1023 param->attributes.splice( param->attributes.end(), decl->attributes ); // copy and reset attributes from declaration to parameter 1504 // Copy and reset attributes from declaration to parameter: 1505 splice( param->attributes, decl->attributes ); 1024 1506 } // if 1025 1507 } // for
Note: See TracChangeset
for help on using the changeset viewer.