Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.cc

    r4cc4286 r4040425  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeData.cc --
     7// TypeData.cc -- 
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Jan 14 10:43:42 2016
    13 // Update Count     : 36
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Mar  2 17:26:45 2016
     13// Update Count     : 49
    1414//
    1515
     
    2323#include "SynTree/Expression.h"
    2424#include "SynTree/Statement.h"
     25#include "SynTree/Initializer.h"
    2526
    2627TypeData::TypeData( Kind k ) : kind( k ), base( 0 ), forall( 0 ) {
     
    8485                typeexpr->expr = 0;
    8586                break;
     87          case Builtin:
     88                builtin = new Builtin_t;
     89                break;
    8690          case Attr:
    8791                attr = new Attr_t;
     
    149153                delete typeexpr->expr;
    150154                delete typeexpr;
     155                break;
     156          case Builtin:
     157                delete builtin;
    151158                break;
    152159          case Attr:
     
    221228                newtype->typeexpr->expr = maybeClone( typeexpr->expr );
    222229                break;
     230          case Builtin:
     231                newtype->builtin->type = builtin->type;
     232                break;
    223233          case Attr:
    224234                newtype->attr->expr = maybeClone( attr->expr );
     
    397407                } // if
    398408                break;
     409          case Builtin:
     410                os << "gcc builtin type";
     411                break;
    399412          default:
    400413                os << "internal error: TypeData::print " << kind  << endl;
     
    436449        for ( std::list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
    437450                if ( (*i)->get_kind() == TypeDecl::Any ) {
    438                         // add assertion parameters to `type' tyvars in reverse order
    439                         // add dtor:  void ^?{}(T *)
    440                         FunctionType *dtorType = new FunctionType( Type::Qualifiers(), false );
    441                         dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
    442                         (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, 0, false, false ) );
    443 
    444                         // add copy ctor:  void ?{}(T *, T)
    445                         FunctionType *copyCtorType = new FunctionType( Type::Qualifiers(), false );
    446                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
    447                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), 0 ) );
    448                         (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, 0, false, false ) );
    449 
    450                         // add default ctor:  void ?{}(T *)
    451                         FunctionType *ctorType = new FunctionType( Type::Qualifiers(), false );
    452                         ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
    453                         (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, 0, false, false ) );
    454 
    455                         // add assignment operator:  T * ?=?(T *, T)
    456451                        FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    457452                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), 0 ) );
     
    524519          case Typeof:
    525520                return buildTypeof();
     521          case Builtin:
     522                return new VarArgsType( buildQualifiers() );
    526523          case Attr:
    527524                return buildAttr();
     
    823820                buildForall( aggregate->params, at->get_parameters() );
    824821                break;
    825           case DeclarationNode::Context:
    826                 at = new ContextDecl( aggregate->name );
     822          case DeclarationNode::Trait:
     823                at = new TraitDecl( aggregate->name );
    827824                buildList( aggregate->params, at->get_parameters() );
    828825                break;
     
    863860                        ret = new UnionInstType( buildQualifiers(), aggInst->aggregate->aggregate->name );
    864861                        break;
    865                   case DeclarationNode::Context:
    866                         ret = new ContextInstType( buildQualifiers(), aggInst->aggregate->aggregate->name );
     862                  case DeclarationNode::Trait:
     863                        ret = new TraitInstType( buildQualifiers(), aggInst->aggregate->aggregate->name );
    867864                        break;
    868865                  default:
     
    901898        EnumDecl *ret = new EnumDecl( enumeration->name );
    902899        buildList( enumeration->constants, ret->get_members() );
     900        std::list< Declaration * >::iterator members = ret->get_members().begin();
     901        for ( const DeclarationNode *cur = enumeration->constants; cur != NULL; cur = dynamic_cast<DeclarationNode *>( cur->get_link() ), ++members ) {
     902                if ( cur->get_enumeratorValue() != NULL ) {
     903                        ObjectDecl *member = dynamic_cast<ObjectDecl *>(*members);
     904                        member->set_init( new SingleInit( maybeBuild< Expression >( cur->get_enumeratorValue() ) ) );
     905                } // if
     906        } // for
    903907        return ret;
    904908}
Note: See TracChangeset for help on using the changeset viewer.