Changeset 28307be for src/Parser/DeclarationNode.cc
- Timestamp:
- Aug 29, 2016, 10:52:33 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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:
- 3403534
- Parents:
- 8f6f47d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r8f6f47d7 r28307be 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 29 15:55:12201613 // Update Count : 3 1112 // Last Modified On : Mon Aug 29 22:30:56 2016 13 // Update Count : 327 14 14 // 15 15 … … 42 42 43 43 extern LinkageSpec::Spec linkage; // defined in parser.yy 44 45 DeclarationNode::DeclarationNode() 46 : type( 0 ) 47 , storageClass( NoStorageClass ) 48 , isInline( false ) 49 , isNoreturn( false ) 50 , bitfieldWidth( 0 ) 51 , initializer( 0 ) 52 , hasEllipsis( false ) 53 , linkage( ::linkage ) 54 , extension( false ) 55 , error() { 56 attr.expr = nullptr; 57 attr.type = nullptr; 58 59 variable.tyClass = DeclarationNode::Type; 60 variable.assertions = nullptr; 61 } 62 63 DeclarationNode::~DeclarationNode() { 64 delete attr.expr; 65 delete attr.type; 66 delete type; 67 delete bitfieldWidth; 68 delete initializer; 69 } 44 70 45 71 DeclarationNode *DeclarationNode::clone() const { … … 55 81 newnode->set_next( maybeClone( get_next() ) ); 56 82 newnode->linkage = linkage; 83 84 newnode->variable.assertions = maybeClone( variable.assertions ); 85 newnode->variable.name = variable.name; 86 newnode->variable.tyClass = variable.tyClass; 87 88 newnode->attr.expr = maybeClone( attr.expr ); 89 newnode->attr.type = maybeClone( attr.type ); 57 90 return newnode; 58 91 } // DeclarationNode::clone 59 60 DeclarationNode::DeclarationNode()61 : type( 0 )62 , storageClass( NoStorageClass )63 , isInline( false )64 , isNoreturn( false )65 , bitfieldWidth( 0 )66 , initializer( 0 )67 , hasEllipsis( false )68 , linkage( ::linkage )69 , extension( false )70 , error() {71 }72 73 DeclarationNode::~DeclarationNode() {74 delete type;75 delete bitfieldWidth;76 delete initializer;77 }78 92 79 93 bool DeclarationNode::get_hasEllipsis() const { … … 248 262 newnode->name = assign_strptr( name ); 249 263 newnode->type = new TypeData( TypeData::Variable ); 250 newnode-> type->variable.tyClass = tc;251 newnode-> type->variable.name = newnode->name;264 newnode->variable.tyClass = tc; 265 newnode->variable.name = newnode->name; 252 266 return newnode; 253 267 } // DeclarationNode::newTypeParam … … 341 355 DeclarationNode *newnode = new DeclarationNode; 342 356 newnode->type = new TypeData( TypeData::Attr ); 343 newnode-> type->attr.name = assign_strptr( name );344 newnode-> type->attr.expr = expr;357 newnode->attr.name = assign_strptr( name ); 358 newnode->attr.expr = expr; 345 359 return newnode; 346 360 } … … 349 363 DeclarationNode *newnode = new DeclarationNode; 350 364 newnode->type = new TypeData( TypeData::Attr ); 351 newnode-> type->attr.name = assign_strptr( name );352 newnode-> type->attr.type = type;365 newnode->attr.name = assign_strptr( name ); 366 newnode->attr.type = type; 353 367 return newnode; 354 368 } … … 542 556 break; 543 557 case TypeData::Variable: 544 if ( type->variable.assertions ) {545 type->variable.assertions->appendList( assertions );558 if ( variable.assertions ) { 559 variable.assertions->appendList( assertions ); 546 560 } else { 547 type->variable.assertions = assertions;561 variable.assertions = assertions; 548 562 } // if 549 563 break; … … 896 910 if ( ! error.empty() ) throw SemanticError( error, this ); 897 911 if ( type ) { 898 return buildDecl( type, name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension ); 912 if ( type->kind == TypeData::Variable ) { 913 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype }; 914 TypeDecl * ret = new TypeDecl( variable.name, DeclarationNode::NoStorageClass, 0, kindMap[ variable.tyClass ] ); 915 buildList( variable.assertions, ret->get_assertions() ); 916 return ret; 917 } else { 918 return buildDecl( type, name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension ); 919 } // if 899 920 } // if 900 921 if ( ! isInline && ! isNoreturn ) { … … 933 954 return ret; 934 955 } 956 case TypeData::Attr: { 957 assert( type->kind == TypeData::Attr ); 958 // assert( type->attr ); 959 AttrType * ret; 960 if ( attr.expr ) { 961 ret = new AttrType( buildQualifiers( type ), attr.name, attr.expr->build() ); 962 } else { 963 assert( attr.type ); 964 ret = new AttrType( buildQualifiers( type ), attr.name, attr.type->buildType() ); 965 } // if 966 return ret; 967 } 935 968 default: 936 969 return typebuild( type );
Note: See TracChangeset
for help on using the changeset viewer.