From: Tom Tromey Date: Mon, 14 Dec 1998 11:25:19 +0000 (+0000) Subject: gjavah.c (decompile_method): Decompile `return null'. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8c2dfb32b76245329231a8b435aff957340b863d;p=gcc.git gjavah.c (decompile_method): Decompile `return null'. * 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 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 898b62adb92..f81222fb3db 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,12 @@ +1998-12-14 Tom Tromey + + * 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 * parse.y (patch_method_invocation): If class_decl is null diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c index 5e879c75469..8fa0d0eb738 100644 --- a/gcc/java/gjavah.c +++ b/gcc/java/gjavah.c @@ -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, ""); @@ -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)