diff -r c77540a61905 -r e9bec7549c28 src/Types.cpp --- a/src/Types.cpp Mon Dec 24 16:43:22 2012 -0800 +++ b/src/Types.cpp Tue Dec 25 16:32:06 2012 -0800 @@ -25,6 +25,13 @@ using namespace ke; +void +Type::init(Kind kind) +{ + this->kind_ = kind; + this->root_ = this; +} + Type * Type::NewVoid(Zone *zone) { @@ -32,7 +39,7 @@ if (!type) return NULL; - type->kind_ = VOID; + type->init(VOID); return type; } @@ -43,7 +50,7 @@ if (!type) return NULL; - type->kind_ = STRING; + type->init(STRING); return type; } @@ -54,7 +61,7 @@ if (!type) return NULL; - type->kind_ = UNCHECKED; + type->init(UNCHECKED); return type; } @@ -65,7 +72,7 @@ if (!type) return NULL; - type->kind_ = PRIMITIVE; + type->init(PRIMITIVE); type->primitive_ = prim; return type; } @@ -84,7 +91,7 @@ if (!type) return NULL; - type->kind_ = ARRAY; + type->init(ARRAY); type->contained_ = contained; type->elements_ = elements; if (!contained->isArray()) @@ -103,7 +110,7 @@ assert(contained->isPrimitive()); - type->kind_ = EXTERNAL_ARRAY; + type->init(EXTERNAL_ARRAY); type->contained_ = contained; type->elements_ = DYNAMIC_ARRAY_SIZE; type->levels_ = 1; @@ -117,8 +124,7 @@ if (!type) return NULL; - type->kind_ = REFERENCE; - type->const_ = false; + type->init(REFERENCE); type->contained_ = contained; return type; } @@ -130,7 +136,7 @@ if (!type) return NULL; - type->kind_ = ENUM; + type->init(ENUM); type->name_ = name; return type; } @@ -142,7 +148,7 @@ if (!type) return NULL; - type->kind_ = STRUCT; + type->init(STRUCT); type->newMap_ = NULL; type->fields_ = fields; type->name_ = name; @@ -191,7 +197,7 @@ if (!type) return NULL; - type->kind_ = FUNCTION; + type->init(FUNCTION); type->parameters_ = NULL; type->defaults_ = NULL; type->returnType_ = NULL;