[llvm-commits] [vmkit] r51855 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaClass.h JavaTypes.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Jun 1 15:39:09 PDT 2008
Author: geoffray
Date: Sun Jun 1 17:39:09 2008
New Revision: 51855
URL: http://llvm.org/viewvc/llvm-project?rev=51855&view=rev
Log:
New class: ClassPrimitive for primitive types (int, double, ...).
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=51855&r1=51854&r2=51855&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Sun Jun 1 17:39:09 2008
@@ -28,8 +28,6 @@
using namespace jnjvm;
-const int CommonClass::MaxDisplay = 6;
-
const UTF8* Attribut::codeAttribut = 0;
const UTF8* Attribut::exceptionsAttribut = 0;
const UTF8* Attribut::constantAttribut = 0;
@@ -82,7 +80,12 @@
return 0;
}
+void CommonClass::destroyer(size_t sz) {
+ free(display);
+}
+
void Class::destroyer(size_t sz) {
+ CommonClass::destroyer(sz);
for (std::vector<Attribut*>::iterator i = attributs.begin(),
e = attributs.end(); i!= e; ++i) {
Attribut* cur = *i;
@@ -191,6 +194,16 @@
#endif
}
+ClassPrimitive::ClassPrimitive(Jnjvm* vm, const UTF8* n) :
+ CommonClass(vm, n, false) {
+
+ display = (CommonClass**)malloc(sizeof(CommonClass*));
+ display[0] = this;
+ isPrimitive = true;
+ status = ready;
+ access = ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC;
+}
+
Class::Class(Jnjvm* vm, const UTF8* n) : CommonClass(vm, n, false) {
classLoader = 0;
bytes = 0;
@@ -208,8 +221,9 @@
super = ClassArray::SuperArray;
interfaces = ClassArray::InterfacesArray;
depth = 1;
- display.push_back(ClassArray::SuperArray);
- display.push_back(this);
+ display = (CommonClass**)malloc(2 * sizeof(CommonClass*));
+ display[0] = ClassArray::SuperArray;
+ display[1] = this;
access = ACC_FINAL | ACC_ABSTRACT;
status = loaded;
}
@@ -426,10 +440,10 @@
return false;
}
-bool CommonClass::instantiationOfArray(CommonClass* cl) {
+bool CommonClass::instantiationOfArray(ClassArray* cl) {
if (this == cl) return true;
else {
- if (isArray && cl->isArray) {
+ if (isArray) {
CommonClass* baseThis = ((ClassArray*)this)->baseClass();
CommonClass* baseCl = ((ClassArray*)cl)->baseClass();
@@ -444,7 +458,7 @@
}
bool CommonClass::subclassOf(CommonClass* cl) {
- if (cl->depth < display.size()) {
+ if (cl->depth <= depth) {
return display[cl->depth] == cl;
} else {
return false;
@@ -457,7 +471,7 @@
} else if (isInterface(cl->access)) {
return this->implements(cl);
} else if (cl->isArray) {
- return this->instantiationOfArray(cl);
+ return this->instantiationOfArray((ClassArray*)cl);
} else {
return this->subclassOf(cl);
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=51855&r1=51854&r2=51855&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Sun Jun 1 17:39:09 2008
@@ -91,10 +91,19 @@
///
VirtualTable* virtualVT;
+ /// display - The class hierarchy of supers for this class.
+ ///
+ CommonClass** display;
+
+ /// depth - The depth of this class in its class hierarchy.
+ /// display[depth] contains the class.
+ ///
+ uint32 depth;
+
/// virtualTableSize - The size of the virtual table of this class.
///
uint32 virtualTableSize;
-
+
/// access - {public, private, protected}.
///
uint32 access;
@@ -183,14 +192,7 @@
///
method_map staticMethods;
- /// display - The class hierarchy of supers for this class.
- ///
- std::vector<CommonClass*> display;
- /// depth - The depth of this class in its class hierarchy.
- /// display[depth - 1] contains the class.
- uint32 depth;
-
JavaMethod* constructMethod(const UTF8* name, const UTF8* type,
uint32 access);
@@ -238,7 +240,7 @@
bool inheritName(const UTF8* Tname);
bool isOfTypeName(const UTF8* Tname);
bool implements(CommonClass* cl);
- bool instantiationOfArray(CommonClass* cl);
+ bool instantiationOfArray(ClassArray* cl);
bool subclassOf(CommonClass* cl);
bool isAssignableFrom(CommonClass* cl);
JavaObject* getClassDelegatee();
@@ -267,8 +269,14 @@
CommonClass() {}
static VirtualTable* VT;
- static const int MaxDisplay;
static JavaObject* jnjvmClassLoader;
+ virtual void destroyer(size_t sz);
+};
+
+class ClassPrimitive : public CommonClass {
+public:
+ static VirtualTable* VT;
+ ClassPrimitive(Jnjvm* vm, const UTF8* name);
};
class Class : public CommonClass {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp?rev=51855&r1=51854&r2=51855&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Sun Jun 1 17:39:09 2008
@@ -74,10 +74,7 @@
res->assocClassName = 0;
if (bid != I_PARG && bid != I_PARD && bid != I_REF && bid != I_TAB) {
- res->classType = new CommonClass(vm, res->UTF8Name, false);
- res->classType->status = ready;
- res->classType->isPrimitive = true;
- res->classType->access = ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC;
+ res->classType = new ClassPrimitive(vm, res->UTF8Name);
} else {
res->classType = 0;
}
More information about the llvm-commits
mailing list