ConstPoolPointerReference(GlobalValue *GV);
~ConstPoolPointerReference() {}
public:
- static ConstPoolPointerReference *get(GlobalValue *GV) {
- // FIXME: These should all be shared!
- return new ConstPoolPointerReference(GV);
- }
+ static ConstPoolPointerReference *get(GlobalValue *GV);
virtual string getStrValue() const;
BasicBlocksType BasicBlocks; // The basic blocks
ArgumentListType ArgumentList; // The formal arguments
- Module *Parent; // The module that contains this method
-
friend class ValueHolder<Method, Module, Module>;
void setParent(Module *parent);
bool isExternal() const { return BasicBlocks.empty(); }
- // Get the class structure that this method is contained inside of...
- inline Module *getParent() { return Parent; }
- inline const Module *getParent() const { return Parent; }
-
// Get the underlying elements of the Method...
inline const ArgumentListType &getArgumentList() const{ return ArgumentList; }
inline ArgumentListType &getArgumentList() { return ArgumentList; }
GlobalValue(const GlobalValue &); // do not implement
protected:
GlobalValue(const Type *Ty, ValueTy vty, const string &name = "")
- : User(Ty, vty, name) {}
+ : User(Ty, vty, name) { Parent = 0; }
+
+ Module *Parent;
public:
+ ~GlobalValue() {}
- // getType - Global values are always pointers (FIXME, methods should be ptrs too!)
+ // getType - Global values are always pointers.
inline const PointerType *getType() const {
return (const PointerType*)User::getType();
}
+ // Get the module that this global value is contained inside of...
+ inline Module *getParent() { return Parent; }
+ inline const Module *getParent() const { return Parent; }
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const GlobalValue *T) { return true; }
static inline bool classof(const Value *V) {
class PointerType;
class GlobalVariable : public GlobalValue {
- Module *Parent; // The module that contains this method
-
friend class ValueHolder<GlobalVariable, Module, Module>;
void setParent(Module *parent) { Parent = parent; }
// Specialize setName to handle symbol table majik...
virtual void setName(const string &name, SymbolTable *ST = 0);
- inline Module *getParent() { return Parent; }
- inline const Module *getParent() const { return Parent; }
-
// The initializer for the global variable/constant is held by Operands[0] if
// an initializer is specified.
//
return find(TypeID)->second.end();
}
+ void dump() const; // Debug method, print out symbol table
+
private:
// insertEntry - Insert a value into the symbol table with the specified
// name...
return Result;
}
+//---- ConstPoolPointerReference::get() implementation...
+//
+ConstPoolPointerReference *ConstPoolPointerReference::get(GlobalValue *GV) {
+ assert(GV->getParent());
+ // FIXME: These should all be shared!
+ return new ConstPoolPointerReference(GV);
+}
: GlobalValue(PointerType::get(Ty), Value::MethodVal, name),
SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) {
assert(::isa<MethodType>(Ty) && "Method signature must be of method type!");
- Parent = 0;
}
Method::~Method() {
ConstPoolVal *Initializer = 0,
const string &Name = "")
: GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Name),
- Parent(0), Constant(isConstant) {
+ Constant(isConstant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
assert(!isConstant || hasInitializer() &&
cast<const DerivedType>(NewType)->addAbstractTypeUser(this);
}
}
+
+
+#ifndef NDEBUG
+#include "llvm/Assembly/Writer.h"
+#include <algorithm>
+
+static void DumpVal(const pair<const string, Value *> &V) {
+ cout << " '%" << V.first << "' = " << V.second << endl;
+}
+
+static void DumpPlane(const pair<const Type *, map<const string, Value *> >&P) {
+ cout << " Plane: " << P.first << endl;
+ for_each(P.second.begin(), P.second.end(), DumpVal);
+}
+
+void SymbolTable::dump() const {
+ cout << "Symbol table dump:\n";
+ for_each(begin(), end(), DumpPlane);
+
+ if (ParentSymTab) {
+ cout << "Parent ";
+ ParentSymTab->dump();
+ }
+}
+
+#endif