diff -r 2b8512340180 -r bbb498ccb4ac src/Types.cpp --- a/src/Types.cpp Sat Dec 22 19:48:43 2012 -0800 +++ b/src/Types.cpp Sat Dec 22 23:18:57 2012 -0800 @@ -55,8 +55,7 @@ return NULL; type->kind_ = PRIMITIVE; - type->name_ = NULL; - type->primitive_ = prim; + type->primitive_ = prim; return type; } @@ -75,7 +74,6 @@ return NULL; type->kind_ = ARRAY; - type->name_ = NULL; type->contained_ = contained; type->elements_ = elements; if (!contained->isArray()) @@ -95,7 +93,6 @@ assert(contained->isPrimitive()); type->kind_ = EXTERNAL_ARRAY; - type->name_ = NULL; type->contained_ = contained; type->elements_ = DYNAMIC_ARRAY_SIZE; type->levels_ = 1; @@ -110,16 +107,15 @@ return NULL; type->kind_ = REFERENCE; - type->name_ = NULL; type->const_ = false; type->contained_ = contained; return type; } -Type * -Type::NewEnum(Zone *zone, Handle name) +EnumType * +EnumType::New(Zone *zone, Handle name) { - Local type(zone, Type::cast(zone->allocate(MapKind_Type, sizeof(Type), Heap::Tenure_Old))); + Local type(zone, EnumType::cast(zone->allocate(MapKind_EnumType, sizeof(EnumType), Heap::Tenure_Old))); if (!type) return NULL; @@ -138,7 +134,6 @@ return NULL; type->kind_ = NATIVE; - type->name_ = NULL; type->contained_ = NULL; type->fields_ = NULL; type->newMap_ = NULL; @@ -217,9 +212,9 @@ return NULL; type->kind_ = STRUCT; - type->name_ = name; type->newMap_ = NULL; type->fields_ = fields; + type->name_ = name; // Fill in field offsets. StructureBufferBuilder builder; @@ -259,17 +254,17 @@ } FunctionType * -FunctionType::New(Zone *zone, TokenKind token) +FunctionType::New(Zone *zone, Handle name, TokenKind token) { Local type(zone, FunctionType::cast(zone->allocate(MapKind_FunctionType, sizeof(FunctionType), Heap::Tenure_Old))); if (!type) return NULL; type->kind_ = FUNCTION; - type->name_ = NULL; type->parameters_ = NULL; type->defaults_ = NULL; type->returnType_ = NULL; + type->name_ = name; type->token_ = token; return type; } @@ -284,8 +279,10 @@ return "function"; if (type->isVoid()) return "void"; - if (type->isEnum() || type->isStruct()) - return type->name()->chars(); + if (type->isEnum()) + return EnumType::cast(type)->name()->chars(); + if (type->isStruct()) + return StructType::cast(type)->name()->chars(); if (type->isReference()) type = ReferenceType::cast(type)->contained(); switch (type->primitive()) {