Changes in src/Parser/DeclarationNode.cc [c0aa336:44a81853]
- File:
-
- 1 edited
-
src/Parser/DeclarationNode.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rc0aa336 r44a81853 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 6 16:01:29201713 // Update Count : 73912 // Last Modified On : Sat Jan 14 14:36:23 2017 13 // Update Count : 669 14 14 // 15 15 … … 83 83 DeclarationNode * DeclarationNode::clone() const { 84 84 DeclarationNode * newnode = new DeclarationNode; 85 newnode-> set_next( maybeClone( get_next() ));85 newnode->type = maybeClone( type ); 86 86 newnode->name = name ? new string( *name ) : nullptr; 87 88 newnode->type = maybeClone( type );89 87 newnode->storageClass = storageClass; 90 newnode->bitfieldWidth = maybeClone( bitfieldWidth );91 88 newnode->isInline = isInline; 92 89 newnode->isNoreturn = isNoreturn; 93 newnode-> enumeratorValue.reset( maybeClone( enumeratorValue.get() ));90 newnode->bitfieldWidth = maybeClone( bitfieldWidth ); 94 91 newnode->hasEllipsis = hasEllipsis; 92 newnode->initializer = maybeClone( initializer ); 93 newnode->set_next( maybeClone( get_next() ) ); 95 94 newnode->linkage = linkage; 96 95 newnode->asmName = maybeClone( asmName ); 97 cloneAll( attributes, newnode->attributes );98 newnode->initializer = maybeClone( initializer );99 newnode->extension = extension;100 newnode->error = error;101 96 102 97 // newnode->variable.name = variable.name ? new string( *variable.name ) : nullptr; … … 164 159 newnode->type->function.newStyle = newStyle; 165 160 newnode->type->function.body = body; 166 167 161 // ignore unnamed routine declarations: void p( int (*)(int) ); 168 162 if ( newnode->name ) { … … 442 436 } // if 443 437 appendError( error, q->error ); 444 } // DeclarationNode::c heckStorageClasses438 } // DeclarationNode::copyStorageClasses 445 439 446 440 DeclarationNode * DeclarationNode::copyStorageClasses( DeclarationNode * q ) { … … 452 446 storageClass = q->storageClass; 453 447 } // if 454 455 for ( Attribute *attr: reverseIterate( q->attributes ) ) { 456 attributes.push_front( attr->clone() ); 457 } // for 448 attributes.splice( attributes.end(), q->attributes ); 458 449 return this; 459 450 } // DeclarationNode::copyStorageClasses … … 665 656 } 666 657 667 DeclarationNode * DeclarationNode::addAsmName( DeclarationNode* newname ) {658 DeclarationNode * DeclarationNode::addAsmName( ConstantExpr * newname ) { 668 659 assert( ! asmName ); 669 asmName = newname ? newname->asmName : nullptr;670 return this ->addQualifiers( newname );660 asmName = newname; 661 return this; 671 662 } 672 663 … … 699 690 } 700 691 701 DeclarationNode * DeclarationNode::setBase(TypeData * newType ) {692 static void setBase( TypeData *&type, TypeData * newType ) { 702 693 if ( type ) { 703 694 TypeData * prevBase = type; … … 711 702 type = newType; 712 703 } // if 713 return this; 714 } 715 716 DeclarationNode * DeclarationNode::copyAttribute( DeclarationNode * a ) { 717 if ( a ) { 718 for ( Attribute *attr: reverseIterate( a->attributes ) ) { 719 attributes.push_front( attr ); 720 } // for 721 a->attributes.clear(); 722 } // if 723 return this; 724 } // copyAttribute 704 } 725 705 726 706 DeclarationNode * DeclarationNode::addPointer( DeclarationNode * p ) { 727 707 if ( p ) { 728 708 assert( p->type->kind == TypeData::Pointer ); 729 setBase( p->type );709 setBase( type, p->type ); 730 710 p->type = nullptr; 731 copyAttribute( p );732 711 delete p; 733 712 } // if … … 738 717 if ( a ) { 739 718 assert( a->type->kind == TypeData::Array ); 740 setBase( a->type );719 setBase( type, a->type ); 741 720 a->type = nullptr; 742 copyAttribute( a );743 721 delete a; 744 722 } // if … … 812 790 TypeData * ftype = new TypeData( TypeData::Function ); 813 791 ftype->function.params = params; 814 setBase( ftype );792 setBase( type, ftype ); 815 793 return this; 816 794 } … … 858 836 TypeData * srcType = type; 859 837 860 // search for the base type by scanning off pointers and array designators861 838 while ( srcType->base ) { 862 839 srcType = srcType->base; … … 1009 986 if ( attr.expr ) { 1010 987 // return new AttrType( buildQualifiers( type ), *attr.name, attr.expr->build() ); 1011 return new AttrType( buildQualifiers( type ), *name, attr.expr->build() , attributes);988 return new AttrType( buildQualifiers( type ), *name, attr.expr->build() ); 1012 989 } else if ( attr.type ) { 1013 990 // return new AttrType( buildQualifiers( type ), *attr.name, attr.type->buildType() ); 1014 return new AttrType( buildQualifiers( type ), *name, attr.type->buildType() , attributes);991 return new AttrType( buildQualifiers( type ), *name, attr.type->buildType() ); 1015 992 } // if 1016 993 1017 994 switch ( type->kind ) { 1018 case TypeData::Enum: { 1019 EnumDecl * typedecl = buildEnum( type, attributes ); 1020 return new EnumInstType( buildQualifiers( type ), typedecl ); 1021 } 995 case TypeData::Enum: 996 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 1022 997 case TypeData::Aggregate: { 1023 AggregateDecl * typedecl = buildAggregate( type, attributes );1024 998 ReferenceToType * ret; 1025 999 switch ( type->aggregate.kind ) { 1026 1000 case DeclarationNode::Struct: 1027 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl);1001 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 1028 1002 break; 1029 1003 case DeclarationNode::Union: 1030 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl);1004 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 1031 1005 break; 1032 1006 case DeclarationNode::Trait: 1033 assert( false ); 1034 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 1007 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 1035 1008 break; 1036 1009 default: … … 1041 1014 } 1042 1015 case TypeData::Symbolic: { 1043 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false , attributes);1016 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false ); 1044 1017 buildList( type->symbolic.actuals, ret->get_parameters() ); 1045 1018 return ret; 1046 1019 } 1047 1020 default: 1048 Type * simpletypes = typebuild( type ); 1049 simpletypes->get_attributes() = attributes; // copy because member is const 1050 return simpletypes; 1021 return typebuild( type ); 1051 1022 } // switch 1052 1023 }
Note:
See TracChangeset
for help on using the changeset viewer.