gjavah.c (decompile_method): Decompile `return null'.
authorTom Tromey <tromey@cygnus.com>
Mon, 14 Dec 1998 11:25:19 +0000 (11:25 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 14 Dec 1998 11:25:19 +0000 (11:25 +0000)
* gjavah.c (decompile_method): Decompile `return null'.
(process_file): Generate `#pragma interface'.
(method_declared): New global.
(print_method_info): Set it.
(HANDLE_CODE_ATTRIBUTE): Only print it method_declared set.
(print_method_info): Handle abstract methods.

From-SVN: r24309

gcc/java/ChangeLog
gcc/java/gjavah.c

index 898b62adb926c2f92560f2626434844ab3476527..f81222fb3dbde5178cc6113e1554428e6a46186e 100644 (file)
@@ -1,3 +1,12 @@
+1998-12-14  Tom Tromey  <tromey@cygnus.com>
+
+       * gjavah.c (decompile_method): Decompile `return null'.
+       (process_file): Generate `#pragma interface'.
+       (method_declared): New global.
+       (print_method_info): Set it.
+       (HANDLE_CODE_ATTRIBUTE): Only print it method_declared set.
+       (print_method_info): Handle abstract methods.
+
 Sun Dec 13 17:31:40 1998  Per Bothner  <bothner@cygnus.com>
 
        * parse.y (patch_method_invocation):  If class_decl is null
index 5e879c75469a56b19dd85b5b6e6c6bb7be2b743f..8fa0d0eb738241b7267253bf773836020594b50d 100644 (file)
@@ -124,6 +124,7 @@ static int field_pass;
 
 #define HANDLE_CONSTANTVALUE(VALUEINDEX) current_field_value = (VALUEINDEX)
 
+static int method_declared = 0;
 static int method_access = 0;
 #define HANDLE_METHOD(ACCESS_FLAGS, NAME, SIGNATURE, ATTRIBUTE_COUNT) \
   if (out) { decompiled = 0; \
@@ -131,7 +132,7 @@ static int method_access = 0;
   }
 
 #define HANDLE_CODE_ATTRIBUTE(MAX_STACK, MAX_LOCALS, CODE_LENGTH) \
-  if (out) decompile_method (out, jcf, CODE_LENGTH);
+  if (out && method_declared) decompile_method (out, jcf, CODE_LENGTH);
 
 static int decompiled = 0;
 #define HANDLE_END_METHOD() \
@@ -399,6 +400,7 @@ DEFUN(print_method_info, (stream, jcf, name_index, sig_index, flags),
   int length, is_init = 0;
   char *override = NULL;
 
+  method_declared = 0;
   method_access = flags;
   if (JPOOL_TAG (jcf, name_index) != CONSTANT_Utf8)
     fprintf (stream, "<not a UTF8 constant>");
@@ -453,6 +455,11 @@ DEFUN(print_method_info, (stream, jcf, name_index, sig_index, flags),
        fputs ("virtual ", out);
     }
   print_c_decl (out, jcf, name_index, sig_index, flags, is_init, override);
+
+  if ((flags & ACC_ABSTRACT))
+    fputs (" = 0", out);
+  else
+    method_declared = 1;
 }
 
 /* Try to decompile a method body.  Right now we just try to handle a
@@ -506,6 +513,15 @@ decompile_method (out, jcf, code_len)
       fputs (" { }", out);
       decompiled = 1;
     }
+  else if (code_len == 2
+          && codes[0] == OPCODE_aconst_null
+          && codes[1] == OPCODE_areturn)
+    {
+      /* Found `return null'.  We don't want to depend on NULL being
+        defined.  */
+      fputs (" { return 0; }", out);
+      decompiled = 1;
+    }
 }
 
 /* Print one piece of a signature.  Returns pointer to next parseable
@@ -833,6 +849,11 @@ DEFUN(process_file, (jcf, out),
 
       print_mangled_classname (out, jcf, "#define __", jcf->this_class);
       fprintf (out, "__\n\n");
+
+      /* We do this to ensure that inline methods won't be `outlined'
+        by g++.  This works as long as method and fields are not
+        added by the user.  */
+      fprintf (out, "#pragma interface\n\n");
     }
 
   if (jcf->super_class && out)