#include "llvm/AbstractTypeUser.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/Streams.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator.h"
#include <string>
class PointerType;
class IntegerType;
class TypeMapBase;
+class raw_ostream;
+class Module;
/// This file contains the declaration of the Type class. For more "Type" type
/// stuff, look in DerivedTypes.h.
PATypeHandle *ContainedTys;
public:
+ void print(raw_ostream &O) const;
void print(std::ostream &O) const;
- void print(std::ostream *O) const { if (O) print(*O); }
/// @brief Debugging support: print to stderr
void dump() const;
+ /// @brief Debugging support: print to stderr (use type names from context
+ /// module).
+ void dump(const Module *Context) const;
+
//===--------------------------------------------------------------------===//
// Property accessors for dealing with types... Some of these virtual methods
// are defined in private classes defined in Type.cpp for primitive types.
///
inline TypeID getTypeID() const { return ID; }
- /// getDescription - Return the string representation of the type...
- const std::string &getDescription() const;
+ /// getDescription - Return the string representation of the type.
+ std::string getDescription() const;
/// isInteger - True if this is an instance of IntegerType.
///
// Define inline methods for PATypeHolder.
+/// get - This implements the forwarding part of the union-find algorithm for
+/// abstract types. Before every access to the Type*, we check to see if the
+/// type we are pointing to is forwarding to a new type. If so, we drop our
+/// reference to the type.
+///
+inline Type* PATypeHolder::get() const {
+ const Type *NewTy = Ty->getForwardedType();
+ if (!NewTy) return const_cast<Type*>(Ty);
+ return *const_cast<PATypeHolder*>(this) = NewTy;
+}
+
inline void PATypeHolder::addRef() {
assert(Ty && "Type Holder has a null type!");
if (Ty->isAbstract())
}
std::ostream &operator<<(std::ostream &OS, const Type &T);
+raw_ostream &operator<<(raw_ostream &OS, const Type &T);
} // End llvm namespace