jvm.h (_Jv_GetJavaVM): Declare.
[gcc.git] / libjava / include / java-interp.h
index 7022411bb51e3bf1cf49a23900ab45af87672f2f..3f33d54bb555688be1bc0312983dd340edd5f2fe 100644 (file)
@@ -14,18 +14,6 @@ details.  */
 #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
@@ -78,6 +66,27 @@ class _Jv_InterpException {
   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;
@@ -85,7 +94,6 @@ class _Jv_InterpMethod : public _Jv_MethodBase
   int              code_length;
 
   _Jv_ushort       exc_count;
-  _Jv_ushort       args_raw_size;
 
   unsigned char* bytecode () 
   {
@@ -154,8 +162,16 @@ class _Jv_InterpClass : public java::lang::Class
   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;        
@@ -169,14 +185,18 @@ struct _Jv_ResolvedMethod {
   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 *);
 
@@ -184,6 +204,15 @@ class _Jv_JNIMethod : public _Jv_MethodBase
 
   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__ */