Changes in / [23c4aa8:167a9c8]
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r23c4aa8 r167a9c8 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 23 15:45:02201713 // Update Count : 7 5912 // Last Modified On : Thu Feb 23 22:21:06 2017 13 // Update Count : 775 14 14 // 15 15 … … 607 607 type->aggInst.aggregate = o->type; 608 608 if ( o->type->kind == TypeData::Aggregate ) { 609 type->aggInst.hoistType = o->type->aggregate.body; 609 610 type->aggInst.params = maybeClone( o->type->aggregate.actuals ); 611 } else { 612 type->aggInst.hoistType = o->type->enumeration.body; 610 613 } // if 611 614 type->qualifiers |= o->type->qualifiers; … … 881 884 newType->aggInst.aggregate->aggregate.fields = nullptr; 882 885 } // if 886 // don't hoist twice 887 newType->aggInst.hoistType = false; 883 888 } // if 884 889 … … 941 946 SemanticError errors; 942 947 std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList ); 943 948 944 949 for ( const DeclarationNode * cur = firstNode; cur; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) { 945 950 try { … … 953 958 auto obj = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr ); 954 959 obj->location = cur->location; 955 * out++ = obj; 960 * out++ = obj; 956 961 delete agg; 957 962 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { … … 1035 1040 1036 1041 switch ( type->kind ) { 1037 case TypeData::Enum: { 1038 if ( type->enumeration.body ) { 1039 EnumDecl * typedecl = buildEnum( type, attributes ); 1040 return new EnumInstType( buildQualifiers( type ), typedecl ); 1041 } else { 1042 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 1043 } 1044 } 1042 case TypeData::Enum: 1045 1043 case TypeData::Aggregate: { 1046 ReferenceToType * ret; 1047 if ( type->aggregate.body ) { 1048 AggregateDecl * typedecl = buildAggregate( type, attributes ); 1049 switch ( type->aggregate.kind ) { 1050 case DeclarationNode::Struct: 1051 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 1052 break; 1053 case DeclarationNode::Union: 1054 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 1055 break; 1056 case DeclarationNode::Trait: 1057 assert( false ); 1058 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 1059 break; 1060 default: 1061 assert( false ); 1062 } // switch 1063 } else { 1064 switch ( type->aggregate.kind ) { 1065 case DeclarationNode::Struct: 1066 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 1067 break; 1068 case DeclarationNode::Union: 1069 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 1070 break; 1071 case DeclarationNode::Trait: 1072 assert( false ); 1073 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 1074 break; 1075 default: 1076 assert( false ); 1077 } // switch 1078 } // if 1044 ReferenceToType * ret = buildComAggInst( type, attributes ); 1079 1045 buildList( type->aggregate.actuals, ret->get_parameters() ); 1080 1046 return ret; -
src/Parser/TypeData.cc
r23c4aa8 r167a9c8 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 23 16:26:39201713 // Update Count : 4 7712 // Last Modified On : Thu Feb 23 21:48:55 2017 13 // Update Count : 485 14 14 // 15 15 … … 62 62 aggInst.aggregate = nullptr; 63 63 aggInst.params = nullptr; 64 aggInst.hoistType = false;; 64 65 break; 65 66 case Enum: … … 195 196 newtype->aggInst.aggregate = maybeClone( aggInst.aggregate ); 196 197 newtype->aggInst.params = maybeClone( aggInst.params ); 198 newtype->aggInst.hoistType = aggInst.hoistType; 197 199 break; 198 200 case Enum: … … 644 646 } // buildAggregate 645 647 648 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes ) { 649 switch ( type->kind ) { 650 case TypeData::Enum: { 651 if ( type->enumeration.body ) { 652 EnumDecl * typedecl = buildEnum( type, attributes ); 653 return new EnumInstType( buildQualifiers( type ), typedecl ); 654 } else { 655 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 656 } // if 657 } 658 case TypeData::Aggregate: { 659 ReferenceToType * ret; 660 if ( type->aggregate.body ) { 661 AggregateDecl * typedecl = buildAggregate( type, attributes ); 662 switch ( type->aggregate.kind ) { 663 case DeclarationNode::Struct: 664 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 665 break; 666 case DeclarationNode::Union: 667 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 668 break; 669 case DeclarationNode::Trait: 670 assert( false ); 671 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 672 break; 673 default: 674 assert( false ); 675 } // switch 676 } else { 677 switch ( type->aggregate.kind ) { 678 case DeclarationNode::Struct: 679 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 680 break; 681 case DeclarationNode::Union: 682 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 683 break; 684 case DeclarationNode::Trait: 685 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 686 break; 687 default: 688 assert( false ); 689 } // switch 690 } // if 691 return ret; 692 } 693 default: 694 assert( false ); 695 } // switch 696 } // buildAggInst 697 646 698 ReferenceToType * buildAggInst( const TypeData * td ) { 647 699 assert( td->kind == TypeData::AggregateInst ); 648 700 649 ReferenceToType * ret; 650 if ( td->aggInst.aggregate->kind == TypeData::Enum ) { 651 ret = new EnumInstType( buildQualifiers( td ), *td->aggInst.aggregate->enumeration.name ); 652 } else { 653 assert( td->aggInst.aggregate->kind == TypeData::Aggregate ); 654 switch ( td->aggInst.aggregate->aggregate.kind ) { 655 case DeclarationNode::Struct: 656 assert( td->aggInst.aggregate->aggregate.name ); 657 ret = new StructInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name ); 658 break; 659 case DeclarationNode::Union: 660 ret = new UnionInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name ); 661 break; 662 case DeclarationNode::Trait: 663 ret = new TraitInstType( buildQualifiers( td ), *td->aggInst.aggregate->aggregate.name ); 664 break; 665 default: 666 assert( false ); 667 } // switch 668 } // if 701 // ReferenceToType * ret = buildComAggInst( td->aggInst.aggregate, std::list< Attribute * >() ); 702 ReferenceToType * ret = nullptr; 703 TypeData * type = td->aggInst.aggregate; 704 switch ( type->kind ) { 705 case TypeData::Enum: { 706 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 707 } 708 case TypeData::Aggregate: { 709 switch ( type->aggregate.kind ) { 710 case DeclarationNode::Struct: 711 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 712 break; 713 case DeclarationNode::Union: 714 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 715 break; 716 case DeclarationNode::Trait: 717 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 718 break; 719 default: 720 assert( false ); 721 } // switch 722 } 723 break; 724 default: 725 assert( false ); 726 } // switch 727 728 ret->set_hoistType( td->aggInst.hoistType ); 669 729 buildList( td->aggInst.params, ret->get_parameters() ); 670 730 buildForall( td->forall, ret->get_forall() ); -
src/Parser/TypeData.h
r23c4aa8 r167a9c8 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 23 1 5:16:18201713 // Update Count : 15 512 // Last Modified On : Thu Feb 23 17:14:46 2017 13 // Update Count : 158 14 14 // 15 15 … … 38 38 TypeData * aggregate; 39 39 ExpressionNode * params; 40 bool hoistType; 40 41 }; 41 42 … … 104 105 ArrayType * buildArray( const TypeData * ); 105 106 AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > ); 107 ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes ); 106 108 ReferenceToType * buildAggInst( const TypeData * ); 107 109 NamedTypeDecl * buildSymbolic( const TypeData *, const std::string &name, DeclarationNode::StorageClass sc ); -
src/SymTab/Validate.cc
r23c4aa8 r167a9c8 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 17:47:54201713 // Update Count : 31 212 // Last Modified On : Thu Feb 23 21:33:55 2017 13 // Update Count : 318 14 14 // 15 15 … … 629 629 } else { 630 630 TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->get_name() ); 631 assertf( base != typedeclNames.end(), "Can't find name %s", typeInst->get_name().c_str() );631 assertf( base != typedeclNames.end(), "Can't find typedecl name %s", typeInst->get_name().c_str() ); 632 632 typeInst->set_baseType( base->second ); 633 633 } // if … … 660 660 // Note, qualifiers on the typedef are superfluous for the forward declaration. 661 661 if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( tyDecl->get_base() ) ) { 662 return new StructDecl( aggDecl->get_name() );662 return aggDecl->get_baseStruct() ? Mutator::mutate( aggDecl->get_baseStruct() ) : new StructDecl( aggDecl->get_name() ); 663 663 } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( tyDecl->get_base() ) ) { 664 return new UnionDecl( aggDecl->get_name() );664 return aggDecl->get_baseUnion() ? Mutator::mutate( aggDecl->get_baseUnion() ) : new UnionDecl( aggDecl->get_name() ); 665 665 } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( tyDecl->get_base() ) ) { 666 666 return new EnumDecl( enumDecl->get_name() ); … … 732 732 } 733 733 734 // there may be typedefs nested within aggregates in order for everything to work properly, these should be removed734 // there may be typedefs nested within aggregates. in order for everything to work properly, these should be removed 735 735 // as well 736 736 template<typename AggDecl> -
src/SynTree/ReferenceToType.cc
r23c4aa8 r167a9c8 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 17:45:07201713 // Update Count : 2 312 // Last Modified On : Thu Feb 23 16:38:54 2017 13 // Update Count : 24 14 14 // 15 15 … … 23 23 #include "Common/utility.h" 24 24 25 ReferenceToType::ReferenceToType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), name( name ) {25 ReferenceToType::ReferenceToType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), name( name ), hoistType( false ) { 26 26 } 27 27 28 ReferenceToType::ReferenceToType( const ReferenceToType &other ) : Type( other ), name( other.name ) {28 ReferenceToType::ReferenceToType( const ReferenceToType &other ) : Type( other ), name( other.name ), hoistType( other.hoistType ) { 29 29 cloneAll( other.parameters, parameters ); 30 30 } -
src/SynTree/Type.h
r23c4aa8 r167a9c8 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 17:43:01201713 // Update Count : 3 312 // Last Modified On : Thu Feb 23 16:38:53 2017 13 // Update Count : 34 14 14 // 15 15 … … 240 240 void set_name( std::string newValue ) { name = newValue; } 241 241 std::list< Expression* >& get_parameters() { return parameters; } 242 bool get_hoistType() const { return hoistType; } 243 void set_hoistType( bool newValue ) { hoistType = newValue; } 242 244 243 245 virtual ReferenceToType *clone() const = 0; … … 250 252 std::string name; 251 253 private: 254 bool hoistType; 252 255 }; 253 256
Note: See TracChangeset
for help on using the changeset viewer.