Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rce8c12f rfa4805f  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 12:34:05 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 15:46:33 2017
    13 // Update Count     : 1018
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:27:00 2017
     13// Update Count     : 1019
    1414//
    1515
     
    5757        variable.tyClass = NoTypeClass;
    5858        variable.assertions = nullptr;
     59        variable.initializer = nullptr;
    5960
    6061//      attr.name = nullptr;
     
    7071//      delete variable.name;
    7172        delete variable.assertions;
     73        delete variable.initializer;
    7274
    7375        delete type;
     
    101103        newnode->variable.tyClass = variable.tyClass;
    102104        newnode->variable.assertions = maybeClone( variable.assertions );
     105        newnode->variable.initializer = maybeClone( variable.initializer );
    103106
    104107//      newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr;
     
    326329} // DeclarationNode::newTypeDecl
    327330
    328 DeclarationNode * DeclarationNode::newPointer( DeclarationNode * qualifiers, OperKinds kind ) {
    329         DeclarationNode * newnode = new DeclarationNode;
    330         newnode->type = new TypeData( kind == OperKinds::PointTo ? TypeData::Pointer : TypeData::Reference );
     331DeclarationNode * DeclarationNode::newPointer( DeclarationNode * qualifiers ) {
     332        DeclarationNode * newnode = new DeclarationNode;
     333        newnode->type = new TypeData( TypeData::Pointer );
    331334        if ( qualifiers ) {
    332335                return newnode->addQualifiers( qualifiers );
     
    745748DeclarationNode * DeclarationNode::addPointer( DeclarationNode * p ) {
    746749        if ( p ) {
    747                 assert( p->type->kind == TypeData::Pointer || TypeData::Reference );
     750                assert( p->type->kind == TypeData::Pointer );
    748751                setBase( p->type );
    749752                p->type = nullptr;
     
    854857DeclarationNode * DeclarationNode::addInitializer( InitializerNode * init ) {
    855858        initializer = init;
     859        return this;
     860}
     861
     862DeclarationNode * DeclarationNode::addTypeInitializer( DeclarationNode * init ) {
     863        assertf( variable.tyClass != NoTypeClass, "Called addTypeInitializer on something that isn't a type variable." );
     864        variable.initializer = init;
    856865        return this;
    857866}
     
    10141023                assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." );
    10151024                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1016                 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );
     1025                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.initializer ? variable.initializer->buildType() : nullptr );
    10171026                buildList( variable.assertions, ret->get_assertions() );
    10181027                return ret;
     
    10541063          case TypeData::Enum:
    10551064          case TypeData::Aggregate: {
    1056                   ReferenceToType * ret = buildComAggInst( type, attributes );
     1065                  ReferenceToType * ret = buildComAggInst( type, attributes, linkage );
    10571066                  buildList( type->aggregate.actuals, ret->get_parameters() );
    10581067                  return ret;
Note: See TracChangeset for help on using the changeset viewer.