#include <jvm.h>
#include <java-cpool.h>
-// Base class for method representations. Subclasses are interpreted
-// and JNI methods.
-class _Jv_MethodBase
-{
-protected:
- // The class which defined this method.
- _Jv_InterpClass *defining_class;
-
- // The method description.
- _Jv_Method *self;
-};
-
#ifdef INTERPRETER
#pragma interface
friend class _Jv_InterpMethod;
};
+// Base class for method representations. Subclasses are interpreted
+// and JNI methods.
+class _Jv_MethodBase
+{
+protected:
+ // The class which defined this method.
+ _Jv_InterpClass *defining_class;
+
+ // The method description.
+ _Jv_Method *self;
+
+ // Size of raw arguments.
+ _Jv_ushort args_raw_size;
+
+public:
+ _Jv_Method *get_method ()
+ {
+ return self;
+ }
+};
+
class _Jv_InterpMethod : public _Jv_MethodBase
{
_Jv_ushort max_stack;
int code_length;
_Jv_ushort exc_count;
- _Jv_ushort args_raw_size;
unsigned char* bytecode ()
{
friend void _Jv_PrepareClass(jclass);
friend void _Jv_InitField (jobject, jclass, int);
friend void* _Jv_MarkObj (void *, void *, void *, void *);
+
+ friend _Jv_MethodBase ** _Jv_GetFirstMethod (_Jv_InterpClass *klass);
};
+extern inline _Jv_MethodBase **
+_Jv_GetFirstMethod (_Jv_InterpClass *klass)
+{
+ return klass->interpreted_methods;
+}
+
struct _Jv_ResolvedMethod {
jint stack_item_count;
jint vtable_index;
ffi_type * arg_types[0];
};
-#endif /* INTERPRETER */
-
class _Jv_JNIMethod : public _Jv_MethodBase
{
// The underlying function. If NULL we have to look for the
// function.
void *function;
+ // This is the CIF used by the JNI function.
+ ffi_cif jni_cif;
+
+ // These are the argument types used by the JNI function.
+ ffi_type **jni_arg_types;
+
// This function is used when making a JNI call from the interpreter.
static void call (ffi_cif *, void *, ffi_raw *, void *);
friend class _Jv_ClassReader;
friend void _Jv_PrepareClass(jclass);
+
+public:
+ // FIXME: this is ugly.
+ void set_function (void *f)
+ {
+ function = f;
+ }
};
+#endif /* INTERPRETER */
+
#endif /* __JAVA_INTERP_H__ */