2001-06-06 20:29:01 +00:00
|
|
|
//===-- llvm/DerivedTypes.h - Classes for handling data types ----*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// This file contains the declarations of classes that represent "derived
|
|
|
|
// types". These are things like "arrays of x" or "structure of x, y, z" or
|
|
|
|
// "method returning x taking (y,z) as parameters", etc...
|
|
|
|
//
|
|
|
|
// The implementations of these classes live in the Type.cpp file.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_DERIVED_TYPES_H
|
|
|
|
#define LLVM_DERIVED_TYPES_H
|
|
|
|
|
|
|
|
#include "llvm/Type.h"
|
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
class DerivedType : public Type {
|
2002-04-05 22:21:08 +00:00
|
|
|
char isRefining; // Used for recursive types
|
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
// AbstractTypeUsers - Implement a list of the users that need to be notified
|
|
|
|
// if I am a type, and I get resolved into a more concrete type.
|
|
|
|
//
|
|
|
|
///// FIXME: kill mutable nonsense when Type's are not const
|
2002-01-20 22:54:45 +00:00
|
|
|
mutable std::vector<AbstractTypeUser *> AbstractTypeUsers;
|
2001-09-07 16:19:29 +00:00
|
|
|
|
|
|
|
protected:
|
2001-12-14 16:20:21 +00:00
|
|
|
inline DerivedType(PrimitiveID id) : Type("", id) {
|
2002-04-05 22:21:08 +00:00
|
|
|
isRefining = 0;
|
|
|
|
}
|
|
|
|
~DerivedType() {
|
|
|
|
assert(AbstractTypeUsers.empty());
|
2001-09-07 16:19:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// typeIsRefined - Notify AbstractTypeUsers of this type that the current type
|
|
|
|
// has been refined a bit. The pointer is still valid and still should be
|
|
|
|
// used, but the subtypes have changed.
|
|
|
|
//
|
|
|
|
void typeIsRefined();
|
|
|
|
|
|
|
|
// setDerivedTypeProperties - Based on the subtypes, set the name of this
|
|
|
|
// type so that it is printed nicely by the type printer. Also calculate
|
|
|
|
// whether this type is abstract or not. Used by the constructor and when
|
|
|
|
// the type is refined.
|
|
|
|
//
|
|
|
|
void setDerivedTypeProperties();
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
public:
|
2001-09-07 16:19:29 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Abstract Type handling methods - These types have special lifetimes, which
|
|
|
|
// are managed by (add|remove)AbstractTypeUser. See comments in
|
|
|
|
// AbstractTypeUser.h for more information.
|
|
|
|
|
|
|
|
// addAbstractTypeUser - Notify an abstract type that there is a new user of
|
|
|
|
// it. This function is called primarily by the PATypeHandle class.
|
|
|
|
//
|
2002-04-05 22:21:08 +00:00
|
|
|
void addAbstractTypeUser(AbstractTypeUser *U) const;
|
2001-09-07 16:19:29 +00:00
|
|
|
|
|
|
|
// removeAbstractTypeUser - Notify an abstract type that a user of the class
|
|
|
|
// no longer has a handle to the type. This function is called primarily by
|
|
|
|
// the PATypeHandle class. When there are no users of the abstract type, it
|
|
|
|
// is anihilated, because there is no way to get a reference to it ever again.
|
|
|
|
//
|
|
|
|
void removeAbstractTypeUser(AbstractTypeUser *U) const;
|
|
|
|
|
|
|
|
// refineAbstractTypeTo - This function is used to when it is discovered that
|
|
|
|
// the 'this' abstract type is actually equivalent to the NewType specified.
|
|
|
|
// This causes all users of 'this' to switch to reference the more concrete
|
|
|
|
// type NewType and for 'this' to be deleted.
|
|
|
|
//
|
|
|
|
void refineAbstractTypeTo(const Type *NewType);
|
2001-10-01 18:26:53 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const DerivedType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
2001-10-01 18:26:53 +00:00
|
|
|
return T->isDerivedType();
|
|
|
|
}
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2002-06-25 16:12:52 +00:00
|
|
|
return isa<Type>(V) && classof(cast<Type>(V));
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-09-07 16:19:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-03-29 03:15:32 +00:00
|
|
|
class FunctionType : public DerivedType {
|
2001-09-07 16:19:29 +00:00
|
|
|
public:
|
2002-01-20 22:54:45 +00:00
|
|
|
typedef std::vector<PATypeHandle<Type> > ParamTypes;
|
2001-06-06 20:29:01 +00:00
|
|
|
private:
|
2001-09-07 16:19:29 +00:00
|
|
|
PATypeHandle<Type> ResultType;
|
2001-06-06 20:29:01 +00:00
|
|
|
ParamTypes ParamTys;
|
2001-07-25 22:47:55 +00:00
|
|
|
bool isVarArgs;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2002-03-29 03:15:32 +00:00
|
|
|
FunctionType(const FunctionType &); // Do not implement
|
|
|
|
const FunctionType &operator=(const FunctionType &); // Do not implement
|
2001-06-06 20:29:01 +00:00
|
|
|
protected:
|
|
|
|
// This should really be private, but it squelches a bogus warning
|
2002-03-29 03:15:32 +00:00
|
|
|
// from GCC to make them protected: warning: `class FunctionType' only
|
2001-06-06 20:29:01 +00:00
|
|
|
// defines private constructors and has no friends
|
|
|
|
|
|
|
|
// Private ctor - Only can be created by a static member...
|
2002-03-29 03:15:32 +00:00
|
|
|
FunctionType(const Type *Result, const std::vector<const Type*> &Params,
|
|
|
|
bool IsVarArgs);
|
2001-09-07 16:19:29 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
|
|
|
|
2001-07-25 22:47:55 +00:00
|
|
|
inline bool isVarArg() const { return isVarArgs; }
|
2001-06-06 20:29:01 +00:00
|
|
|
inline const Type *getReturnType() const { return ResultType; }
|
|
|
|
inline const ParamTypes &getParamTypes() const { return ParamTys; }
|
|
|
|
|
2002-03-29 19:04:19 +00:00
|
|
|
// Parameter type accessors...
|
|
|
|
const Type *getParamType(unsigned i) const { return ParamTys[i]; }
|
|
|
|
|
|
|
|
// getNumParams - Return the number of fixed parameters this function type
|
|
|
|
// requires. This does not consider varargs.
|
|
|
|
//
|
|
|
|
unsigned getNumParams() const { return ParamTys.size(); }
|
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
|
|
|
|
virtual const Type *getContainedType(unsigned i) const {
|
2001-10-13 06:12:30 +00:00
|
|
|
return i == 0 ? ResultType :
|
|
|
|
(i <= ParamTys.size() ? ParamTys[i-1].get() : 0);
|
2001-07-20 19:09:11 +00:00
|
|
|
}
|
2001-09-07 16:19:29 +00:00
|
|
|
virtual unsigned getNumContainedTypes() const { return ParamTys.size()+1; }
|
|
|
|
|
|
|
|
// refineAbstractType - Called when a contained type is found to be more
|
|
|
|
// concrete - this could potentially change us from an abstract type to a
|
|
|
|
// concrete type.
|
|
|
|
//
|
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
|
|
|
|
2002-03-29 03:15:32 +00:00
|
|
|
static FunctionType *get(const Type *Result,
|
|
|
|
const std::vector<const Type*> &Params,
|
|
|
|
bool isVarArg);
|
2001-10-01 16:18:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2002-03-29 03:15:32 +00:00
|
|
|
static inline bool classof(const FunctionType *T) { return true; }
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Type *T) {
|
2002-03-29 03:44:36 +00:00
|
|
|
return T->getPrimitiveID() == FunctionTyID;
|
2001-10-01 16:18:37 +00:00
|
|
|
}
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return isa<Type>(V) && classof(cast<const Type>(V));
|
2001-10-01 16:18:37 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
// CompositeType - Common super class of ArrayType, StructType, and PointerType
|
2001-11-26 16:46:45 +00:00
|
|
|
//
|
|
|
|
class CompositeType : public DerivedType {
|
|
|
|
protected:
|
2001-12-14 16:20:21 +00:00
|
|
|
inline CompositeType(PrimitiveID id) : DerivedType(id) { }
|
2001-11-26 16:46:45 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// getTypeAtIndex - Given an index value into the type, return the type of the
|
|
|
|
// element.
|
|
|
|
//
|
|
|
|
virtual const Type *getTypeAtIndex(const Value *V) const = 0;
|
|
|
|
virtual bool indexValid(const Value *V) const = 0;
|
|
|
|
|
|
|
|
// getIndexType - Return the type required of indices for this composite.
|
|
|
|
// For structures, this is ubyte, for arrays, this is uint
|
|
|
|
//
|
|
|
|
virtual const Type *getIndexType() const = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
|
|
static inline bool classof(const CompositeType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
|
|
|
return T->getPrimitiveID() == ArrayTyID ||
|
2001-12-14 16:20:21 +00:00
|
|
|
T->getPrimitiveID() == StructTyID ||
|
|
|
|
T->getPrimitiveID() == PointerTyID;
|
2001-11-26 16:46:45 +00:00
|
|
|
}
|
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return isa<Type>(V) && classof(cast<const Type>(V));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
class StructType : public CompositeType {
|
|
|
|
public:
|
2002-01-20 22:54:45 +00:00
|
|
|
typedef std::vector<PATypeHandle<Type> > ElementTypes;
|
2001-12-14 16:20:21 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
private:
|
2001-12-14 16:20:21 +00:00
|
|
|
ElementTypes ETypes; // Element types of struct
|
|
|
|
|
|
|
|
StructType(const StructType &); // Do not implement
|
|
|
|
const StructType &operator=(const StructType &); // Do not implement
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// This should really be private, but it squelches a bogus warning
|
2001-12-14 16:20:21 +00:00
|
|
|
// from GCC to make them protected: warning: `class StructType' only
|
2001-06-06 20:29:01 +00:00
|
|
|
// defines private constructors and has no friends
|
|
|
|
|
|
|
|
// Private ctor - Only can be created by a static member...
|
2002-01-20 22:54:45 +00:00
|
|
|
StructType(const std::vector<const Type*> &Types);
|
2001-12-14 16:20:21 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-12-14 16:20:21 +00:00
|
|
|
inline const ElementTypes &getElementTypes() const { return ETypes; }
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
virtual const Type *getContainedType(unsigned i) const {
|
2001-12-14 16:20:21 +00:00
|
|
|
return i < ETypes.size() ? ETypes[i].get() : 0;
|
2001-07-20 19:09:11 +00:00
|
|
|
}
|
2001-12-14 16:20:21 +00:00
|
|
|
virtual unsigned getNumContainedTypes() const { return ETypes.size(); }
|
2001-09-07 16:19:29 +00:00
|
|
|
|
2001-11-26 16:46:45 +00:00
|
|
|
// getTypeAtIndex - Given an index value into the type, return the type of the
|
2001-12-14 16:20:21 +00:00
|
|
|
// element. For a structure type, this must be a constant value...
|
2001-11-26 16:46:45 +00:00
|
|
|
//
|
2001-12-14 16:20:21 +00:00
|
|
|
virtual const Type *getTypeAtIndex(const Value *V) const ;
|
|
|
|
virtual bool indexValid(const Value *V) const;
|
2001-11-26 16:46:45 +00:00
|
|
|
|
|
|
|
// getIndexType - Return the type required of indices for this composite.
|
|
|
|
// For structures, this is ubyte, for arrays, this is uint
|
|
|
|
//
|
2001-12-14 16:20:21 +00:00
|
|
|
virtual const Type *getIndexType() const { return Type::UByteTy; }
|
2001-11-26 16:46:45 +00:00
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
// refineAbstractType - Called when a contained type is found to be more
|
|
|
|
// concrete - this could potentially change us from an abstract type to a
|
|
|
|
// concrete type.
|
|
|
|
//
|
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static StructType *get(const std::vector<const Type*> &Params);
|
2001-10-01 18:26:53 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-14 16:20:21 +00:00
|
|
|
static inline bool classof(const StructType *T) { return true; }
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Type *T) {
|
2001-12-14 16:20:21 +00:00
|
|
|
return T->getPrimitiveID() == StructTyID;
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return isa<Type>(V) && classof(cast<const Type>(V));
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
2001-07-23 05:03:15 +00:00
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
// SequentialType - This is the superclass of the array and pointer type
|
|
|
|
// classes. Both of these represent "arrays" in memory. The array type
|
|
|
|
// represents a specifically sized array, pointer types are unsized/unknown size
|
|
|
|
// arrays. SequentialType holds the common features of both, which stem from
|
|
|
|
// the fact that both lay their components out in memory identically.
|
|
|
|
//
|
|
|
|
class SequentialType : public CompositeType {
|
|
|
|
SequentialType(const SequentialType &); // Do not implement!
|
|
|
|
const SequentialType &operator=(const SequentialType &); // Do not implement!
|
2001-06-06 20:29:01 +00:00
|
|
|
protected:
|
2001-12-14 16:20:21 +00:00
|
|
|
PATypeHandle<Type> ElementType;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
SequentialType(PrimitiveID TID, const Type *ElType)
|
|
|
|
: CompositeType(TID), ElementType(PATypeHandle<Type>(ElType, this)) {
|
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-12-14 16:20:21 +00:00
|
|
|
|
|
|
|
inline const Type *getElementType() const { return ElementType; }
|
2001-09-07 16:19:29 +00:00
|
|
|
|
|
|
|
virtual const Type *getContainedType(unsigned i) const {
|
2001-12-14 16:20:21 +00:00
|
|
|
return i == 0 ? ElementType.get() : 0;
|
2001-07-20 19:09:11 +00:00
|
|
|
}
|
2001-12-14 16:20:21 +00:00
|
|
|
virtual unsigned getNumContainedTypes() const { return 1; }
|
2001-09-07 16:19:29 +00:00
|
|
|
|
2001-11-26 16:46:45 +00:00
|
|
|
// getTypeAtIndex - Given an index value into the type, return the type of the
|
2001-12-14 16:20:21 +00:00
|
|
|
// element. For sequential types, there is only one subtype...
|
2001-11-26 16:46:45 +00:00
|
|
|
//
|
2001-12-14 16:20:21 +00:00
|
|
|
virtual const Type *getTypeAtIndex(const Value *V) const {
|
|
|
|
return ElementType.get();
|
|
|
|
}
|
|
|
|
virtual bool indexValid(const Value *V) const {
|
2002-09-11 01:16:19 +00:00
|
|
|
return V->getType() == Type::LongTy; // Must be a 'long' index
|
2001-12-14 16:20:21 +00:00
|
|
|
}
|
2001-11-26 16:46:45 +00:00
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
// getIndexType() - Return the type required of indices for this composite.
|
2001-11-26 16:46:45 +00:00
|
|
|
// For structures, this is ubyte, for arrays, this is uint
|
|
|
|
//
|
2002-09-11 01:16:19 +00:00
|
|
|
virtual const Type *getIndexType() const { return Type::LongTy; }
|
2001-12-14 16:20:21 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
|
|
static inline bool classof(const SequentialType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
|
|
|
return T->getPrimitiveID() == ArrayTyID ||
|
|
|
|
T->getPrimitiveID() == PointerTyID;
|
|
|
|
}
|
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return isa<Type>(V) && classof(cast<const Type>(V));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ArrayType : public SequentialType {
|
|
|
|
unsigned NumElements;
|
|
|
|
|
|
|
|
ArrayType(const ArrayType &); // Do not implement
|
|
|
|
const ArrayType &operator=(const ArrayType &); // Do not implement
|
|
|
|
protected:
|
|
|
|
// This should really be private, but it squelches a bogus warning
|
|
|
|
// from GCC to make them protected: warning: `class ArrayType' only
|
|
|
|
// defines private constructors and has no friends
|
|
|
|
|
|
|
|
|
|
|
|
// Private ctor - Only can be created by a static member...
|
|
|
|
ArrayType(const Type *ElType, unsigned NumEl);
|
|
|
|
public:
|
|
|
|
inline unsigned getNumElements() const { return NumElements; }
|
2001-11-26 16:46:45 +00:00
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
// refineAbstractType - Called when a contained type is found to be more
|
|
|
|
// concrete - this could potentially change us from an abstract type to a
|
|
|
|
// concrete type.
|
|
|
|
//
|
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
static ArrayType *get(const Type *ElementType, unsigned NumElements);
|
2001-10-01 18:26:53 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-14 16:20:21 +00:00
|
|
|
static inline bool classof(const ArrayType *T) { return true; }
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Type *T) {
|
2001-12-14 16:20:21 +00:00
|
|
|
return T->getPrimitiveID() == ArrayTyID;
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return isa<Type>(V) && classof(cast<const Type>(V));
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-07-23 05:03:15 +00:00
|
|
|
};
|
2001-07-20 21:09:17 +00:00
|
|
|
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
class PointerType : public SequentialType {
|
2001-06-06 20:29:01 +00:00
|
|
|
PointerType(const PointerType &); // Do not implement
|
|
|
|
const PointerType &operator=(const PointerType &); // Do not implement
|
|
|
|
protected:
|
|
|
|
// This should really be private, but it squelches a bogus warning
|
|
|
|
// from GCC to make them protected: warning: `class PointerType' only
|
|
|
|
// defines private constructors and has no friends
|
|
|
|
|
|
|
|
|
|
|
|
// Private ctor - Only can be created by a static member...
|
|
|
|
PointerType(const Type *ElType);
|
|
|
|
public:
|
2001-12-14 16:20:21 +00:00
|
|
|
// PointerType::get - Named constructor for pointer types...
|
2001-09-07 16:19:29 +00:00
|
|
|
static PointerType *get(const Type *ElementType);
|
|
|
|
|
|
|
|
// refineAbstractType - Called when a contained type is found to be more
|
|
|
|
// concrete - this could potentially change us from an abstract type to a
|
|
|
|
// concrete type.
|
|
|
|
//
|
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
2001-10-01 18:26:53 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const PointerType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
2001-10-01 18:26:53 +00:00
|
|
|
return T->getPrimitiveID() == PointerTyID;
|
|
|
|
}
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return isa<Type>(V) && classof(cast<const Type>(V));
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-09-07 16:19:29 +00:00
|
|
|
};
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
class OpaqueType : public DerivedType {
|
|
|
|
private:
|
|
|
|
OpaqueType(const OpaqueType &); // Do not implement
|
|
|
|
const OpaqueType &operator=(const OpaqueType &); // Do not implement
|
|
|
|
protected:
|
|
|
|
// This should really be private, but it squelches a bogus warning
|
|
|
|
// from GCC to make them protected: warning: `class OpaqueType' only
|
|
|
|
// defines private constructors and has no friends
|
|
|
|
|
|
|
|
// Private ctor - Only can be created by a static member...
|
|
|
|
OpaqueType();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// get - Static factory method for the OpaqueType class...
|
|
|
|
static OpaqueType *get() {
|
|
|
|
return new OpaqueType(); // All opaque types are distinct
|
2001-07-20 19:09:11 +00:00
|
|
|
}
|
2001-10-01 18:26:53 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const OpaqueType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
2001-10-01 18:26:53 +00:00
|
|
|
return T->getPrimitiveID() == OpaqueTyID;
|
|
|
|
}
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2002-06-25 16:12:52 +00:00
|
|
|
return isa<Type>(V) && classof(cast<Type>(V));
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
|
|
|
|
// Define some inline methods for the AbstractTypeUser.h:PATypeHandle class.
|
|
|
|
// These are defined here because they MUST be inlined, yet are dependant on
|
|
|
|
// the definition of the Type class. Of course Type derives from Value, which
|
|
|
|
// contains an AbstractTypeUser instance, so there is no good way to factor out
|
|
|
|
// the code. Hence this bit of uglyness.
|
|
|
|
//
|
|
|
|
template <class TypeSubClass> void PATypeHandle<TypeSubClass>::addUser() {
|
2001-12-14 16:20:21 +00:00
|
|
|
assert(Ty && "Type Handle has a null type!");
|
2001-09-07 16:19:29 +00:00
|
|
|
if (Ty->isAbstract())
|
2001-10-01 18:26:53 +00:00
|
|
|
cast<DerivedType>(Ty)->addAbstractTypeUser(User);
|
2001-09-07 16:19:29 +00:00
|
|
|
}
|
|
|
|
template <class TypeSubClass> void PATypeHandle<TypeSubClass>::removeUser() {
|
|
|
|
if (Ty->isAbstract())
|
2001-10-01 18:26:53 +00:00
|
|
|
cast<DerivedType>(Ty)->removeAbstractTypeUser(User);
|
2001-09-07 16:19:29 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 03:27:53 +00:00
|
|
|
template <class TypeSubClass>
|
|
|
|
void PATypeHandle<TypeSubClass>::removeUserFromConcrete() {
|
|
|
|
if (!Ty->isAbstract())
|
|
|
|
cast<DerivedType>(Ty)->removeAbstractTypeUser(User);
|
|
|
|
}
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
#endif
|