[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Class.h Class.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Thu Mar 24 14:35:47 PST 2005
Changes in directory llvm-java/lib/Compiler:
Compiler.cpp updated: 1.243 -> 1.244
Class.h updated: 1.2 -> 1.3
Class.cpp updated: 1.2 -> 1.3
---
Log message:
Add a reference to the classfile object representing each Class object
if this exists (this only exists for interfaces and classes, but not
for arrays or primitive classes).
---
Diffs of the changes: (+14 -9)
Class.cpp | 12 +++++++-----
Class.h | 4 ++++
Compiler.cpp | 7 +++----
3 files changed, 14 insertions(+), 9 deletions(-)
Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.243 llvm-java/lib/Compiler/Compiler.cpp:1.244
--- llvm-java/lib/Compiler/Compiler.cpp:1.243 Thu Mar 24 07:38:30 2005
+++ llvm-java/lib/Compiler/Compiler.cpp Thu Mar 24 16:35:36 2005
@@ -2091,10 +2091,9 @@
void do_new(unsigned index) {
ConstantClass* classRef = cf_->getConstantClass(index);
- const ClassFile* cf = ClassFile::get(classRef->getName()->str());
- emitStaticInitializers(cf);
const Class& ci = resolver_->getClass(classRef->getName()->str());
- const VTableInfo& vi = getVTableInfo(cf);
+ emitStaticInitializers(ci.getClassFile());
+ const VTableInfo& vi = getVTableInfo(ci.getClassFile());
push(allocateObject(ci, vi, currentBB_));
}
@@ -2185,7 +2184,7 @@
// java/lang/Object's.
const Class& clazz = resolver_->getClass("[Ljava/lang/Object;");
const VTableInfo& vi =
- getObjectArrayVTableInfo(ClassFile::get("java/lang/Object"));
+ getObjectArrayVTableInfo(clazz.getClassFile());
push(allocateArray(clazz, vi, count, currentBB_));
}
Index: llvm-java/lib/Compiler/Class.h
diff -u llvm-java/lib/Compiler/Class.h:1.2 llvm-java/lib/Compiler/Class.h:1.3
--- llvm-java/lib/Compiler/Class.h:1.2 Thu Mar 24 07:38:30 2005
+++ llvm-java/lib/Compiler/Class.h Thu Mar 24 16:35:36 2005
@@ -22,12 +22,14 @@
namespace llvm { namespace Java {
+ class ClassFile;
class Resolver;
class Class {
static const unsigned INVALID_INTERFACE_INDEX = 0xFFFFFFFF;
Resolver* resolver_;
+ const ClassFile* classFile_;
const Class* superClass_;
const Class* componentClass_;
Type* structType_;
@@ -57,9 +59,11 @@
public:
const Type* getStructType() const { return structType_; }
const Type* getType() const { return type_; }
+ const ClassFile* getClassFile() const { return classFile_; }
const Class* getSuperClass() const { return superClass_; }
const Class* getComponentClass() const { return componentClass_; }
bool isArray() const { return componentClass_; }
+ bool isPrimitive() const { return !structType_; }
unsigned getInterfaceIndex() const { return interfaceIndex_; }
int getFieldIndex(const std::string& name) const;
};
Index: llvm-java/lib/Compiler/Class.cpp
diff -u llvm-java/lib/Compiler/Class.cpp:1.2 llvm-java/lib/Compiler/Class.cpp:1.3
--- llvm-java/lib/Compiler/Class.cpp:1.2 Thu Mar 24 07:38:30 2005
+++ llvm-java/lib/Compiler/Class.cpp Thu Mar 24 16:35:36 2005
@@ -27,6 +27,7 @@
Class::Class(Resolver& resolver)
: resolver_(&resolver),
+ classFile_(NULL),
superClass_(NULL),
componentClass_(NULL),
structType_(OpaqueType::get()),
@@ -38,6 +39,7 @@
Class::Class(Resolver& resolver, const Type* type)
: resolver_(&resolver),
+ classFile_(NULL),
superClass_(NULL),
componentClass_(NULL),
structType_(0),
@@ -68,12 +70,12 @@
void Class::buildClass(const std::string& className)
{
- const ClassFile* cf = ClassFile::get(className);
+ classFile_ = ClassFile::get(className);
// This is any class but java/lang/Object.
- if (cf->getSuperClass()) {
+ if (classFile_->getSuperClass()) {
const Class& superClass =
- resolver_->getClass(cf->getSuperClass()->getName()->str());
+ resolver_->getClass(classFile_->getSuperClass()->getName()->str());
// We first add the struct of the super class.
addField("super", superClass.getStructType());
@@ -83,7 +85,7 @@
// on interface types. So we only set the superClass_ field when
// the class is not an interface type, but we model the LLVM type
// of the interface to be as if it inherits java/lang/Object.
- if (cf->isInterface())
+ if (classFile_->isInterface())
interfaceIndex_ = resolver_->getNextInterfaceIndex();
else
superClass_ = &superClass;
@@ -93,7 +95,7 @@
addField("base", resolver_->getObjectBaseType());
// Then we add the rest of the fields.
- const Fields& fields = cf->getFields();
+ const Fields& fields = classFile_->getFields();
for (unsigned i = 0, e = fields.size(); i != e; ++i) {
Field& field = *fields[i];
if (!field.isStatic())
More information about the llvm-commits
mailing list