src/Types.h
changeset 167 cf82769eb136
parent 154 a85a0303bcb8
child 168 4d0fff61d65e
     1.1 --- a/src/Types.h	Sun Aug 05 14:19:19 2012 -0700
     1.2 +++ b/src/Types.h	Sun Aug 05 15:38:52 2012 -0700
     1.3 @@ -58,14 +58,37 @@
     1.4  class Type : public Object
     1.5  {
     1.6      enum Kind {
     1.7 +        // A primitive is a plain-old-data type.
     1.8          PRIMITIVE,
     1.9 +
    1.10 +        // An array is a fixed-length vector of any other type.
    1.11          ARRAY,
    1.12 +
    1.13 +        // A reference type may only be specified on parameters, and
    1.14 +        // references may only be computed to primitives or enums.
    1.15          REFERENCE,
    1.16 +
    1.17 +        // A function type encapsulates a function signature.
    1.18          FUNCTION,
    1.19 +
    1.20 +        // A native is a limited type of function used for system calls.
    1.21          NATIVE,
    1.22 +
    1.23 +        // Void is an internal type used to specify that a function returns no
    1.24 +        // value.
    1.25          VOID,
    1.26 +
    1.27 +        // Enums are plain-old-data with int32 storage. They allow for extra
    1.28 +        // type checking that would not be possible with integers.
    1.29          ENUM,
    1.30 -        STRUCT
    1.31 +
    1.32 +        // Structs are composite records that may contain primitives, arrays,
    1.33 +        // functions, enums, and other structs.
    1.34 +        STRUCT,
    1.35 +
    1.36 +        // Unchecked is a magic type that has implicit, bitwise coercion to
    1.37 +        // int32, float, bool, or an enum.
    1.38 +        UNCHECKED
    1.39      };
    1.40  
    1.41    private:
    1.42 @@ -78,6 +101,7 @@
    1.43      static const size_t MAX_UNSAFE_ARRAY_DEPTH = 5;
    1.44      
    1.45      static Type *NewVoid(Zone *zone);
    1.46 +    static Type *NewUnchecked(Zone *zone);
    1.47      static Type *NewPrimitive(Zone *zone, PrimitiveType type);
    1.48      static Type *NewArray(Zone *zone, Handle<Type> contained, int elements, bool isConst);
    1.49      static Type *NewReference(Zone *zone, Handle<Type> contained, bool isConst);
    1.50 @@ -111,6 +135,9 @@
    1.51      bool isVoid() {
    1.52          return kind() == VOID;
    1.53      }
    1.54 +    bool isUnchecked() {
    1.55 +        return kind() == UNCHECKED;
    1.56 +    }
    1.57      bool isStruct() {
    1.58          return kind() == STRUCT;
    1.59      }