src/TypeManager.cpp
changeset 145 e9d804821c48
parent 143 393f1b8ac8c3
child 146 dc7d3b7a918c
     1.1 --- a/src/TypeManager.cpp	Mon Jul 30 22:30:38 2012 -0700
     1.2 +++ b/src/TypeManager.cpp	Wed Aug 01 22:32:59 2012 -0700
     1.3 @@ -39,29 +39,15 @@
     1.4      if (!voidType_)
     1.5          return false;
     1.6  
     1.7 -    Local<String> floatTag(zone_, zone_->makeSymbol("Float"));
     1.8 -    if (!floatTag)
     1.9 -        return false;
    1.10 -
    1.11 -    Local<String> stringTag(zone_, zone_->makeSymbol("String"));
    1.12 -    if (!stringTag)
    1.13 +    if ((primitiveTypes_[PrimitiveType_Int32] = Type::NewPrimitive(zone_, PrimitiveType_Int32)) == NULL)
    1.14          return false;
    1.15 -
    1.16 -    Local<String> boolTag(zone_, zone_->makeSymbol("bool"));
    1.17 -    if (!boolTag)
    1.18 -        return false;
    1.19 -
    1.20 -    Local<String> nullTag(zone_);
    1.21 -
    1.22 -    if ((primitiveTypes_[PrimitiveType_Int32] = Type::NewPrimitive(zone_, nullTag)) == NULL)
    1.23 -        return false;
    1.24 -    if ((primitiveTypes_[PrimitiveType_Float] = Type::NewPrimitive(zone_, floatTag)) == NULL)
    1.25 +    if ((primitiveTypes_[PrimitiveType_Float] = Type::NewPrimitive(zone_, PrimitiveType_Float)) == NULL)
    1.26          return false;
    1.27      if ((primitiveTypes_[PrimitiveType_Native] = Type::NewPrimitive(zone_, PrimitiveType_Native)) == NULL)
    1.28          return false;
    1.29 -    if ((primitiveTypes_[PrimitiveType_Char] = Type::NewPrimitive(zone_, stringTag)) == NULL)
    1.30 +    if ((primitiveTypes_[PrimitiveType_Char] = Type::NewPrimitive(zone_, PrimitiveType_Char)) == NULL)
    1.31          return false;
    1.32 -    if ((primitiveTypes_[PrimitiveType_Bool] = Type::NewPrimitive(zone_, boolTag)) == NULL)
    1.33 +    if ((primitiveTypes_[PrimitiveType_Bool] = Type::NewPrimitive(zone_, PrimitiveType_Bool)) == NULL)
    1.34          return false;
    1.35  
    1.36      Local<Type> type(zone_);
    1.37 @@ -75,20 +61,6 @@
    1.38  }
    1.39  
    1.40  Type *
    1.41 -TypeManager::getPrimitiveForTag(Handle<String> tag)
    1.42 -{
    1.43 -    if (!tag || strcmp(tag->chars(), "_") == 0)
    1.44 -        return getPrimitive(PrimitiveType_Int32);
    1.45 -    if (strcmp(tag->chars(), "Float") == 0)
    1.46 -        return getPrimitive(PrimitiveType_Float);
    1.47 -    if (strcmp(tag->chars(), "String") == 0)
    1.48 -        return getPrimitive(PrimitiveType_Char);
    1.49 -
    1.50 -    // :TODO: cache this.
    1.51 -    return Type::NewPrimitive(zone_, tag);
    1.52 -}
    1.53 -
    1.54 -Type *
    1.55  TypeManager::unsafeArray(Handle<Type> contained, int elements, bool isConst)
    1.56  {
    1.57      // :TODO: cache this.
    1.58 @@ -98,7 +70,7 @@
    1.59  Type *
    1.60  TypeManager::getReference(Handle<Type> type, bool isConst)
    1.61  {
    1.62 -    if (!isConst && (type->isFloat() || (type->isInt32() && !type->tag())))
    1.63 +    if (!isConst && type->isPrimitive())
    1.64          return referenceTypes_[type->primitive()];
    1.65  
    1.66      // :TODO: cache this.
    1.67 @@ -119,6 +91,12 @@
    1.68      return Type::NewNative(zone_, returnType, args, variadic);
    1.69  }
    1.70  
    1.71 +Type *
    1.72 +TypeManager::newEnum(Handle<String> name)
    1.73 +{
    1.74 +    return Type::NewEnum(zone_, name);
    1.75 +}
    1.76 +
    1.77  void
    1.78  TypeManager::accept(VirtualObjectVisitor *visitor)
    1.79  {