jvm.h (_Jv_GetJavaVM): Declare.
[gcc.git] / libjava / include / java-interp.h
index f29d3ddb95a1712f397bf90d56994bf45796fe8f..3f33d54bb555688be1bc0312983dd340edd5f2fe 100644 (file)
@@ -1,6 +1,6 @@
 // java-interp.h - Header file for the bytecode interpreter.  -*- c++ -*-
 
-/* Copyright (C) 1999  Cygnus Solutions
+/* Copyright (C) 1999, 2000  Red Hat, Inc.
 
    This file is part of libgcj.
 
@@ -66,17 +66,34 @@ class _Jv_InterpException {
   friend class _Jv_InterpMethod;
 };
 
-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;
   _Jv_ushort       max_locals;
   int              code_length;
 
   _Jv_ushort       exc_count;
-  _Jv_ushort       args_raw_size;
-
-  _Jv_InterpClass *defining_class;
-  _Jv_Method      *self;
 
   unsigned char* bytecode () 
   {
@@ -137,7 +154,7 @@ class _Jv_InterpMethodInvocation {
   
 class _Jv_InterpClass : public java::lang::Class
 {
-  _Jv_InterpMethod **interpreted_methods;
+  _Jv_MethodBase **interpreted_methods;
   _Jv_ushort        *field_initializers;
 
   friend class _Jv_ClassReader;
@@ -145,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;        
@@ -160,6 +185,34 @@ struct _Jv_ResolvedMethod {
   ffi_type *      arg_types[0];
 };
 
+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 *);
+
+  void *ncode ();
+
+  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__ */