-//===-- llvm/Type.h - Classes for handling data types ------------*- C++ -*--=//
+//===-- llvm/Type.h - Classes for handling data types -----------*- C++ -*-===//
//
// This file contains the declaration of the Type class. For more "Type" type
// stuff, look in DerivedTypes.h.
class StructType;
class OpaqueType;
-class Type : public Value {
-public:
+struct Type : public Value {
///===-------------------------------------------------------------------===//
/// Definitions of all of the base types for the Type system. Based on this
/// value, you can cast to a "DerivedType" subclass (see DerivedTypes.h)
unsigned UID; // The unique ID number for this class
bool Abstract; // True if type contains an OpaqueType
+ const Type *getForwardedTypeInternal() const;
protected:
/// ctor is protected, so only subclasses can create Type objects...
Type(const std::string &Name, PrimitiveID id);
///
inline void setAbstract(bool Val) { Abstract = Val; }
+ /// isTypeAbstract - This method is used to calculate the Abstract bit.
+ ///
+ bool isTypeAbstract();
+
+ /// ForwardType - This field is used to implement the union find scheme for
+ /// abstract types. When types are refined to other types, this field is set
+ /// to the more refined type. Only abstract types can be forwarded.
+ mutable const Type *ForwardType;
+
public:
virtual void print(std::ostream &O) const;
///
unsigned getPrimitiveSize() const;
+ /// getForwaredType - Return the type that this type has been resolved to if
+ /// it has been resolved to anything. This is used to implement the
+ /// union-find algorithm for type resolution.
+ const Type *getForwardedType() const {
+ if (!ForwardType) return 0;
+ return getForwardedTypeInternal();
+ }
//===--------------------------------------------------------------------===//
// Type Iteration support