[llvm-commits] CVS: llvm-java/runtime/runtime.h runtime.c
Alkis Evlogimenos
alkis at cs.uiuc.edu
Sat Apr 2 11:58:35 PST 2005
Changes in directory llvm-java/runtime:
runtime.h added (r1.1)
runtime.c updated: 1.29 -> 1.30
---
Log message:
Extract a header from runtime.h.
---
Diffs of the changes: (+77 -58)
runtime.c | 63 ++++--------------------------------------------------
runtime.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 58 deletions(-)
Index: llvm-java/runtime/runtime.h
diff -c /dev/null llvm-java/runtime/runtime.h:1.1
*** /dev/null Sat Apr 2 13:58:34 2005
--- llvm-java/runtime/runtime.h Sat Apr 2 13:58:24 2005
***************
*** 0 ****
--- 1,72 ----
+ #include <llvm/Java/jni.h>
+
+ /* For now we cast a java/lang/Class reference to a class record. When
+ * we get proper java/lang/Class representation this will be a field
+ * access. */
+ #define GET_CLASS_RECORD(clazz) ((struct llvm_java_object_class_record*) clazz)
+ #define GET_CLASS(classRecord) ((jclass) classRecord)
+
+ const JNIEnv llvm_java_JNIEnv;
+
+ struct llvm_java_object_base;
+ struct llvm_java_object_header;
+ struct llvm_java_class_record;
+ struct llvm_java_typeinfo;
+
+ struct llvm_java_object_header {
+ /* gc info, hash info, locking */
+ int dummy;
+ };
+
+ struct llvm_java_object_base {
+ struct llvm_java_object_header header;
+ struct llvm_java_class_record* classRecord;
+ };
+
+ struct llvm_java_typeinfo {
+ /* The name of this class */
+ const char* name;
+
+ /* The number of super classes to java.lang.Object. */
+ jint depth;
+
+ /* The super class records up to java.lang.Object. */
+ struct llvm_java_class_record** superclasses;
+
+ /* If an interface its interface index, otherwise the last interface
+ * index implemented by this class. */
+ jint interfaceIndex;
+
+ /* The interface class records this class implements. */
+ struct llvm_java_class_record** interfaces;
+
+ /* The component class record if this is an array class, null
+ * otherwise. */
+ struct llvm_java_class_record* component;
+
+ /* If an array the size of its elements, otherwise 0 for classes, -1
+ * for interfaces and -2 for primitive classes. */
+ jint elementSize;
+ };
+
+ struct llvm_java_class_record {
+ struct llvm_java_typeinfo typeinfo;
+ };
+
+ #define HANDLE_TYPE(TYPE) \
+ struct llvm_java_##TYPE##array { \
+ struct llvm_java_object_base object_base; \
+ jint length; \
+ j##TYPE data[0]; \
+ };
+ #include "types.def"
+
+ struct llvm_java_class_record* llvm_java_find_class_record(const char* name);
+ struct llvm_java_class_record* llvm_java_get_class_record(jobject obj);
+ void llvm_java_set_class_record(jobject obj, struct llvm_java_class_record* cr);
+ jboolean
+ llvm_java_is_instance_of(jobject obj, struct llvm_java_class_record* cr);
+ jboolean
+ llvm_java_is_assignable_from(struct llvm_java_class_record* cr,
+ struct llvm_java_class_record* from);
+ jint llvm_java_throw(jobject obj);
Index: llvm-java/runtime/runtime.c
diff -u llvm-java/runtime/runtime.c:1.29 llvm-java/runtime/runtime.c:1.30
--- llvm-java/runtime/runtime.c:1.29 Sat Apr 2 12:55:56 2005
+++ llvm-java/runtime/runtime.c Sat Apr 2 13:58:24 2005
@@ -1,51 +1,6 @@
+#include "runtime.h"
#include <stdlib.h>
#include <string.h>
-#include <llvm/Java/jni.h>
-
-struct llvm_java_object_base;
-struct llvm_java_object_header;
-struct llvm_java_class_record;
-struct llvm_java_typeinfo;
-
-struct llvm_java_object_header {
- /* gc info, hash info, locking */
- int dummy;
-};
-
-struct llvm_java_object_base {
- struct llvm_java_object_header header;
- struct llvm_java_class_record* classRecord;
-};
-
-struct llvm_java_typeinfo {
- /* The name of this class */
- const char* name;
-
- /* The number of super classes to java.lang.Object. */
- jint depth;
-
- /* The super class records up to java.lang.Object. */
- struct llvm_java_class_record** superclasses;
-
- /* If an interface its interface index, otherwise the last interface
- * index implemented by this class. */
- jint interfaceIndex;
-
- /* The interface class records this class implements. */
- struct llvm_java_class_record** interfaces;
-
- /* The component class record if this is an array class, null
- * otherwise. */
- struct llvm_java_class_record* component;
-
- /* If an array the size of its elements, otherwise 0 for classes, -1
- * for interfaces and -2 for primitive classes. */
- jint elementSize;
-};
-
-struct llvm_java_class_record {
- struct llvm_java_typeinfo typeinfo;
-};
jint llvm_java_is_primitive_class(struct llvm_java_class_record* cr)
{
@@ -71,8 +26,8 @@
obj->classRecord = cr;
}
-jint llvm_java_is_assignable_from(struct llvm_java_class_record* cr,
- struct llvm_java_class_record* from) {
+jboolean llvm_java_is_assignable_from(struct llvm_java_class_record* cr,
+ struct llvm_java_class_record* from) {
/* trivial case: class records are the same */
if (cr == from)
return JNI_TRUE;
@@ -106,8 +61,8 @@
return JNI_FALSE;
}
-jint llvm_java_is_instance_of(jobject obj,
- struct llvm_java_class_record* cr) {
+jboolean llvm_java_is_instance_of(jobject obj,
+ struct llvm_java_class_record* cr) {
/* trivial case: a null object can be cast to any type */
if (!obj)
return JNI_TRUE;
@@ -132,14 +87,6 @@
return NULL;
}
-#define HANDLE_TYPE(TYPE) \
- struct llvm_java_##TYPE##array { \
- struct llvm_java_object_base object_base; \
- jint length; \
- j##TYPE data[0]; \
- };
-#include "types.def"
-
static jint llvm_java_get_array_length(JNIEnv* env, jarray array) {
return ((struct llvm_java_booleanarray*) array)->length;
}
More information about the llvm-commits
mailing list