Add support for casting operators
[oota-llvm.git] / lib / VMCore / Type.cpp
index 5ae2cf9761c88842118c7eaeb251a63f23de0df7..2e0bee55e55f6d9b599fc0d42a6ad5bbc569bfe8 100644 (file)
@@ -70,6 +70,9 @@ public:
 
   // isSigned - Return whether a numeric type is signed.
   virtual bool isSigned() const { return 1; }
+  
+  // isIntegral - Return whether this is one of the integer types
+  virtual bool isIntegral() const { return 1; }
 };
 
 class UnsignedIntType : public Type {
@@ -81,6 +84,9 @@ public:
 
   // isUnsigned - Return whether a numeric type is signed.
   virtual bool isUnsigned() const { return 1; }
+  
+  // isIntegral - Return whether this is one of the integer types
+  virtual bool isIntegral() const { return 1; }
 };
 
 static struct TypeType : public Type {
@@ -143,7 +149,11 @@ ArrayType::ArrayType(const Type *ElType, int NumEl, const string &Name)
 }
 
 StructType::StructType(const vector<const Type*> &Types, const string &Name) 
-  : Type(Name, StructTyID), ETypes(Types) {
+  : Type(Name, StructTyID),
+    ETypes(Types),
+    layoutCache(new StructSizeAndOffsetInfo) 
+{
+  ResetCachedInfo();
 }
 
 PointerType::PointerType(const Type *E) 
@@ -208,6 +218,7 @@ const MethodType *MethodType::getMethodType(const Type *ReturnType,
 
 const ArrayType *ArrayType::getArrayType(const Type *ElementType, 
                                         int NumElements = -1) {
+  assert(ElementType && "Can't get array of null types!");
   static vector<const ArrayType*> ExistingTypesCache;
 
   // Search cache for value...
@@ -287,6 +298,7 @@ const StructType *StructType::getStructType(const ElementTypes &ETypes) {
 
 
 const PointerType *PointerType::getPointerType(const Type *ValueType) {
+  assert(ValueType && "Can't get a pointer to <null> type!");
   static vector<const PointerType*> ExistingTypesCache;
 
   // Search cache for value...