Changeset f0ecf9b


Ignore:
Timestamp:
Nov 1, 2017, 5:40:05 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, 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:
fde89cf6
Parents:
b0837e4
Message:

Remove TypeDecl::Any, as it is subsumed by Dtype+sized

Location:
src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rb0837e4 rf0ecf9b  
    288288                assertf( ! genC, "TypeDecls should not reach code generation." );
    289289                output << typeDecl->genTypeString() << " " << typeDecl->name;
    290                 if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->sized ) {
     290                if ( typeDecl->sized ) {
    291291                        output << " | sized(" << typeDecl->name << ")";
    292292                }
  • src/GenPoly/InstantiateGeneric.cc

    rb0837e4 rf0ecf9b  
    238238                                        assertf( false, "Ttype parameters are not currently allowed as parameters to generic types." );
    239239                                        break;
    240                                 case TypeDecl::Any:
    241                                         assertf( false, "otype parameters handled by baseParam->isComplete()." );
     240                                default:
     241                                        assertf( false, "Unhandled type parameter kind" );
    242242                                        break;
    243243                        }
  • src/GenPoly/ScrubTyVars.cc

    rb0837e4 rf0ecf9b  
    4040                if ( tyVar != tyVars->end() ) {
    4141                        switch ( tyVar->second.kind ) {
    42                           case TypeDecl::Any:
    4342                          case TypeDecl::Dtype:
    4443                          case TypeDecl::Ttype:
  • src/Parser/DeclarationNode.cc

    rb0837e4 rf0ecf9b  
    10311031
    10321032        if ( variable.tyClass != NoTypeClass ) {
    1033                 static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype };
    1034                 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." );
     1033                // otype is internally converted to dtype + otype parameters
     1034                static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype };
     1035                assertf( sizeof(kindMap)/sizeof(kindMap[0]) == NoTypeClass, "DeclarationNode::build: kindMap is out of sync." );
    10351036                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    1036                 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.initializer ? variable.initializer->buildType() : nullptr );
     1037                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == Otype, variable.initializer ? variable.initializer->buildType() : nullptr );
    10371038                buildList( variable.assertions, ret->get_assertions() );
    10381039                return ret;
  • src/Parser/TypeData.cc

    rb0837e4 rf0ecf9b  
    406406void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) {
    407407        buildList( firstNode, outputList );
    408         for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
     408        auto n = firstNode;
     409        for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i, n = (DeclarationNode*)n->get_next() ) {
    409410                TypeDecl * td = static_cast<TypeDecl *>(*i);
    410                 if ( td->get_kind() == TypeDecl::Any ) {
     411                if ( n->variable.tyClass == DeclarationNode::Otype ) {
    411412                        // add assertion parameters to `type' tyvars in reverse order
    412413                        // add dtor:  void ^?{}(T *)
     
    798799                ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage );
    799800        } else {
    800                 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Any );
     801                ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Dtype, true );
    801802        } // if
    802803        buildList( td->symbolic.params, ret->get_parameters() );
  • src/ResolvExpr/Unify.cc

    rb0837e4 rf0ecf9b  
    138138        bool tyVarCompatible( const TypeDecl::Data & data, Type *type ) {
    139139                switch ( data.kind ) {
    140                   case TypeDecl::Any:
    141140                  case TypeDecl::Dtype:
    142141                        // to bind to an object type variable, the type must not be a function type.
  • src/SymTab/Autogen.cc

    rb0837e4 rf0ecf9b  
    696696                        if ( TypeInstType * ty = dynamic_cast< TypeInstType * >( t ) ) {
    697697                                if ( ! done.count( ty->get_baseType() ) ) {
    698                                         TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), Type::StorageClasses(), nullptr, TypeDecl::Any );
     698                                        TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), Type::StorageClasses(), nullptr, TypeDecl::Dtype, true );
    699699                                        TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl );
    700700                                        newDecl->get_assertions().push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr,
  • src/SymTab/Mangler.cc

    rb0837e4 rf0ecf9b  
    214214                        numStream << varNum->second.first;
    215215                        switch ( (TypeDecl::Kind )varNum->second.second ) {
    216                           case TypeDecl::Any:
    217                                 mangleName << "t";
    218                                 break;
    219216                          case TypeDecl::Dtype:
    220217                                mangleName << "d";
     
    274271                        for ( Type::ForallList::iterator i = type->forall.begin(); i != type->forall.end(); ++i ) {
    275272                                switch ( (*i)->get_kind() ) {
    276                                   case TypeDecl::Any:
    277                                         tcount++;
    278                                         break;
    279273                                  case TypeDecl::Dtype:
    280274                                        dcount++;
  • src/SynTree/Declaration.h

    rb0837e4 rf0ecf9b  
    200200        typedef NamedTypeDecl Parent;
    201201  public:
    202         enum Kind { Any, Dtype, Ftype, Ttype };
     202        enum Kind { Dtype, Ftype, Ttype };
    203203
    204204        Type * init;
     
    216216        };
    217217
    218         TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr );
     218        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );
    219219        TypeDecl( const TypeDecl &other );
    220220        virtual ~TypeDecl();
     
    225225        TypeDecl * set_init( Type * newValue ) { init = newValue; return this; }
    226226
    227         bool isComplete() const { return kind == Any || sized; }
     227        bool isComplete() const { return sized; }
    228228        bool get_sized() const { return sized; }
    229229        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
  • src/SynTree/TypeDecl.cc

    rb0837e4 rf0ecf9b  
    2121#include "Type.h"            // for Type, Type::StorageClasses
    2222
    23 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Any || kind == Ttype ), kind( kind ) {
     23TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Ttype || sized ), kind( kind ) {
    2424}
    2525
     
    3232
    3333std::string TypeDecl::typeString() const {
    34         static const std::string kindNames[] = { "type", "incomplete type", "function type", "tuple type" };
    35         return (kind != Any && isComplete() ? "sized " : "") + kindNames[ kind ];
     34        static const std::string kindNames[] = { "object type", "function type", "tuple type" };
     35        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." );
     36        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     37        return (isComplete() ? "sized " : "") + kindNames[ kind ];
    3638}
    3739
    3840std::string TypeDecl::genTypeString() const {
    39         static const std::string kindNames[] = { "otype", "dtype", "ftype", "ttype" };
     41        static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
     42        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
     43        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
    4044        return kindNames[ kind ];
    4145}
  • src/Tuples/TupleExpansion.cc

    rb0837e4 rf0ecf9b  
    204204                        decl->set_body( true );
    205205                        for ( size_t i = 0; i < tupleSize; ++i ) {
    206                                 TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", tupleSize, "_", i ), Type::StorageClasses(), nullptr, TypeDecl::Any );
     206                                TypeDecl * tyParam = new TypeDecl( toString( "tuple_param_", tupleSize, "_", i ), Type::StorageClasses(), nullptr, TypeDecl::Dtype, true );
    207207                                decl->get_members().push_back( new ObjectDecl( toString("field_", i ), Type::StorageClasses(), LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) );
    208208                                decl->get_parameters().push_back( tyParam );
Note: See TracChangeset for help on using the changeset viewer.