jitcraft/Types.cpp
changeset 12 75e385f68b7e
parent 11 a350c2cc736a
child 13 627b6b94e774
     1.1 --- a/jitcraft/Types.cpp	Fri Jun 29 19:35:17 2012 -0700
     1.2 +++ b/jitcraft/Types.cpp	Sat Jun 30 19:38:53 2012 -0700
     1.3 @@ -25,7 +25,7 @@
     1.4  Type::initPrimitive(Name *tag)
     1.5  {
     1.6      WRITE_FIELD(kind, PRIMITIVE);
     1.7 -    WRITE_FIELD(tag, CrapPtr(tag));
     1.8 +    WRITE_FIELD(tag, VoidPtr(tag));
     1.9      WRITE_FIELD_OBJ_NO_BARRIER(contained, NULL);
    1.10  
    1.11      if (tag && strcmp(tag, "Float") == 0)
    1.12 @@ -35,6 +35,15 @@
    1.13  }
    1.14  
    1.15  void
    1.16 +Type::initPrimitive(PrimitiveType type)
    1.17 +{
    1.18 +    WRITE_FIELD(kind, PRIMITIVE);
    1.19 +    WRITE_FIELD(tag, NULL);
    1.20 +    WRITE_FIELD_OBJ_NO_BARRIER(contained, NULL);
    1.21 +    WRITE_FIELD(primitive, type);
    1.22 +}
    1.23 +
    1.24 +void
    1.25  Type::initInlineArray(Type *contained, int elements)
    1.26  {
    1.27      WRITE_FIELD(kind, UNSAFE_ARRAY);
    1.28 @@ -60,6 +69,18 @@
    1.29  }
    1.30  
    1.31  Type *
    1.32 +Type::NewPrimitive(Zone *zone, PrimitiveType prim)
    1.33 +{
    1.34 +    Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);
    1.35 +    if (!obj)
    1.36 +        return NULL;
    1.37 +
    1.38 +    Type *type = Type::cast(obj);
    1.39 +    type->initPrimitive(prim);
    1.40 +    return type;
    1.41 +}
    1.42 +
    1.43 +Type *
    1.44  Type::NewUnsafeArray(Zone *zone, Type *contained, int elements)
    1.45  {
    1.46      Object *obj = zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old);