From 7fac070215c8d4fd4a41ae58750e6c1faef4931f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 3 Oct 2001 14:53:21 +0000 Subject: * Both Method & GlobalVariable now subclass GlobalValue * ConstPoolPointerReference now represents a pointer to a GlobalValue * Methods name references are now explicit pointers to methods * Rename Value::GlobalVal to Value::GlobalVariableVal to avoid confusion llvm-svn: 703 --- llvm/lib/VMCore/Function.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'llvm/lib/VMCore/Function.cpp') diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index 9eb8277a272..372d0d28b91 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -26,8 +26,8 @@ template class ValueHolder; template class ValueHolder; Method::Method(const MethodType *Ty, const string &name) - : Value(Ty, Value::MethodVal, name), SymTabValue(this), BasicBlocks(this), - ArgumentList(this, this) { + : GlobalValue(PointerType::get(Ty), Value::MethodVal, name), + SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) { assert(::isa(Ty) && "Method signature must be of method type!"); Parent = 0; } @@ -62,8 +62,12 @@ void Method::setParent(Module *parent) { setParentSymTab(Parent ? Parent->getSymbolTableSure() : 0); } +const MethodType *Method::getMethodType() const { + return cast(cast(getType())->getValueType()); +} + const Type *Method::getReturnType() const { - return ((const MethodType *)getType())->getReturnType(); + return getMethodType()->getReturnType(); } // dropAllReferences() - This function causes all the subinstructions to "let @@ -85,8 +89,8 @@ void Method::dropAllReferences() { GlobalVariable::GlobalVariable(const Type *Ty, bool isConstant, ConstPoolVal *Initializer = 0, const string &Name = "") - : User(Ty, Value::GlobalVal, Name), Parent(0), Constant(isConstant) { - assert(Ty->isPointerType() && "Global Variables must be pointers!"); + : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Name), + Parent(0), Constant(isConstant) { if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); assert(!isConstant || hasInitializer() && -- cgit v1.2.3