[llvm-commits] CVS: llvm-java/lib/Compiler/VMMethod.h VMMethod.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Fri Apr 1 10:24:59 PST 2005
Changes in directory llvm-java/lib/Compiler:
VMMethod.h updated: 1.2 -> 1.3
VMMethod.cpp updated: 1.1 -> 1.2
---
Log message:
Add another constructor for dynamically bound methods.
---
Diffs of the changes: (+32 -3)
VMMethod.cpp | 22 +++++++++++++++++++---
VMMethod.h | 13 +++++++++++++
2 files changed, 32 insertions(+), 3 deletions(-)
Index: llvm-java/lib/Compiler/VMMethod.h
diff -u llvm-java/lib/Compiler/VMMethod.h:1.2 llvm-java/lib/Compiler/VMMethod.h:1.3
--- llvm-java/lib/Compiler/VMMethod.h:1.2 Thu Mar 31 13:33:37 2005
+++ llvm-java/lib/Compiler/VMMethod.h Fri Apr 1 12:24:48 2005
@@ -32,6 +32,9 @@
const VMClass* parent_;
const Method* method_;
Function* function_;
+ int index_;
+
+ void init();
friend class VMClass;
// Interface for VMClass.
@@ -39,12 +42,22 @@
// Create statically bound method reference.
VMMethod(const VMClass* parent, const Method* method);
+ // Create dynamically bound method reference.
+ VMMethod(const VMClass* parent, const Method* method, int index);
+
public:
const VMClass* getParent() const { return parent_; }
const Method* getMethod() const { return method_; }
Function* getFunction() const { return function_; }
+ int getMethodIndex() const { return index_; }
+
+ bool isStaticallyBound() const {
+ return isStatic() || isPrivate() || getName()[0] == '<';
+ }
+ bool isDynamicallyBound() const { return !isStaticallyBound(); }
bool isAbstract() const { return method_->isAbstract(); }
bool isNative() const { return method_->isNative(); }
+ bool isPrivate() const { return method_->isPrivate(); }
bool isStatic() const { return method_->isStatic(); }
// FIXME: remove when transition is complete.
Index: llvm-java/lib/Compiler/VMMethod.cpp
diff -u llvm-java/lib/Compiler/VMMethod.cpp:1.1 llvm-java/lib/Compiler/VMMethod.cpp:1.2
--- llvm-java/lib/Compiler/VMMethod.cpp:1.1 Wed Mar 30 23:10:29 2005
+++ llvm-java/lib/Compiler/VMMethod.cpp Fri Apr 1 12:24:48 2005
@@ -21,9 +21,7 @@
using namespace llvm;
using namespace llvm::Java;
-VMMethod::VMMethod(const VMClass* parent, const Method* method)
- : parent_(parent),
- method_(method)
+void VMMethod::init()
{
const std::string& methodName = method_->getName()->str();
const std::string& methodDescriptor = method_->getDescriptor()->str();
@@ -37,3 +35,21 @@
Module* module = resolver->getModule();
function_ = module->getOrInsertFunction(functionName, functionType);
}
+
+VMMethod::VMMethod(const VMClass* parent, const Method* method)
+ : parent_(parent),
+ method_(method),
+ index_(-1)
+{
+ assert(isStaticallyBound() && "This should be a statically bound method!");
+ init();
+}
+
+VMMethod::VMMethod(const VMClass* parent, const Method* method, int index)
+ : parent_(parent),
+ method_(method),
+ index_(index)
+{
+ assert(isDynamicallyBound() && "This should be a dynamically bound method!");
+ init();
+}
More information about the llvm-commits
mailing list