src/Types.cpp
changeset 238 e9bec7549c28
parent 236 072f1114ea5d
child 239 572668ef742b
     1.1 --- a/src/Types.cpp	Mon Dec 24 16:43:22 2012 -0800
     1.2 +++ b/src/Types.cpp	Tue Dec 25 16:32:06 2012 -0800
     1.3 @@ -25,6 +25,13 @@
     1.4  
     1.5  using namespace ke;
     1.6  
     1.7 +void
     1.8 +Type::init(Kind kind)
     1.9 +{
    1.10 +    this->kind_ = kind;
    1.11 +    this->root_ = this;
    1.12 +}
    1.13 +
    1.14  Type *
    1.15  Type::NewVoid(Zone *zone)
    1.16  {
    1.17 @@ -32,7 +39,7 @@
    1.18      if (!type)
    1.19          return NULL;
    1.20  
    1.21 -    type->kind_ = VOID;
    1.22 +    type->init(VOID);
    1.23      return type;
    1.24  }
    1.25  
    1.26 @@ -43,7 +50,7 @@
    1.27      if (!type)
    1.28          return NULL;
    1.29  
    1.30 -    type->kind_ = STRING;
    1.31 +    type->init(STRING);
    1.32      return type;
    1.33  }
    1.34  
    1.35 @@ -54,7 +61,7 @@
    1.36      if (!type)
    1.37          return NULL;
    1.38  
    1.39 -    type->kind_ = UNCHECKED;
    1.40 +    type->init(UNCHECKED);
    1.41      return type;
    1.42  }
    1.43  
    1.44 @@ -65,7 +72,7 @@
    1.45      if (!type)
    1.46          return NULL;
    1.47  
    1.48 -    type->kind_ = PRIMITIVE;
    1.49 +    type->init(PRIMITIVE);
    1.50      type->primitive_ = prim;
    1.51      return type;
    1.52  }
    1.53 @@ -84,7 +91,7 @@
    1.54      if (!type)
    1.55          return NULL;
    1.56  
    1.57 -    type->kind_ = ARRAY;
    1.58 +    type->init(ARRAY);
    1.59      type->contained_ = contained;
    1.60      type->elements_ = elements;
    1.61      if (!contained->isArray())
    1.62 @@ -103,7 +110,7 @@
    1.63  
    1.64      assert(contained->isPrimitive());
    1.65  
    1.66 -    type->kind_ = EXTERNAL_ARRAY;
    1.67 +    type->init(EXTERNAL_ARRAY);
    1.68      type->contained_ = contained;
    1.69      type->elements_ = DYNAMIC_ARRAY_SIZE;
    1.70      type->levels_ = 1;
    1.71 @@ -117,8 +124,7 @@
    1.72      if (!type)
    1.73          return NULL;
    1.74  
    1.75 -    type->kind_ = REFERENCE;
    1.76 -    type->const_ = false;
    1.77 +    type->init(REFERENCE);
    1.78      type->contained_ = contained;
    1.79      return type;
    1.80  }
    1.81 @@ -130,7 +136,7 @@
    1.82      if (!type)
    1.83          return NULL;
    1.84  
    1.85 -    type->kind_ = ENUM;
    1.86 +    type->init(ENUM);
    1.87      type->name_ = name;
    1.88      return type;
    1.89  }
    1.90 @@ -142,7 +148,7 @@
    1.91      if (!type)
    1.92          return NULL;
    1.93  
    1.94 -    type->kind_ = STRUCT;
    1.95 +    type->init(STRUCT);
    1.96      type->newMap_ = NULL;
    1.97      type->fields_ = fields;
    1.98      type->name_ = name;
    1.99 @@ -191,7 +197,7 @@
   1.100      if (!type)
   1.101          return NULL;
   1.102  
   1.103 -    type->kind_ = FUNCTION;
   1.104 +    type->init(FUNCTION);
   1.105      type->parameters_ = NULL;
   1.106      type->defaults_ = NULL;
   1.107      type->returnType_ = NULL;