This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: misc small Java fixes
- To: egcs-patches at egcs dot cygnus dot com
- Subject: PATCH: misc small Java fixes
- From: Per Bothner <bothner at cygnus dot com>
- Date: Mon, 15 Mar 1999 13:12:13 -0800
I just checked in the following.
Mon Mar 15 12:18:29 1999 Per Bothner <bothner@cygnus.com>
* class.c (make_class): Don't set CLASS_P here (because
this function is also called by build_java_array_type).
(push_class): Set CLASS_P here instead.
* parse.h (TYPE_CLASS_P): Check for TYPE_ARRAY_P is redundant.
* jcf-dump.c (print_access_flags): Take extra parameter to indicate
context. If the context is class, perfer "super" over "synchronized".
* jcf-write.c (generate_classfile): Don't add ACC_SUPER if interface.
* parse.y (create_class): Don't call parser_check_super here;
it is not robust. Always wait until later.
* parse.y (method_header): For interfaces, set ACC_ABSTRACT (to
match what JDK 1.2 does), but don't set ACC_PUBLIC.
Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/class.c,v
retrieving revision 1.30
diff -u -p -r1.30 class.c
--- class.c 1999/03/12 18:18:59 1.30
+++ class.c 1999/03/15 21:08:33
@@ -128,7 +128,6 @@ make_class ()
#else
TYPE_BINFO (type) = make_tree_vec (6);
#endif
- CLASS_P (type) = 1;
pop_obstacks ();
return type;
@@ -157,6 +156,7 @@ push_class (class_type, class_name)
int save_lineno = lineno;
tree source_name = identifier_subst (class_name, "", '.', '/', ".java");
push_obstacks (&permanent_obstack, &permanent_obstack);
+ CLASS_P (class_type) = 1;
input_filename = IDENTIFIER_POINTER (source_name);
lineno = 0;
decl = build_decl (TYPE_DECL, class_name, class_type);
Index: parse.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/parse.h,v
retrieving revision 1.26
diff -u -p -r1.26 parse.h
--- parse.h 1999/03/12 18:19:02 1.26
+++ parse.h 1999/03/15 21:08:33
@@ -208,8 +208,7 @@ extern tree stabilize_reference PROTO ((
(CLASS_P (TYPE) && CLASS_INTERFACE (TYPE_NAME (TYPE)))
#define TYPE_CLASS_P(TYPE) (CLASS_P (TYPE) \
- && !CLASS_INTERFACE (TYPE_NAME (TYPE)) \
- && !TYPE_ARRAY_P (TYPE))
+ && !CLASS_INTERFACE (TYPE_NAME (TYPE)))
/* Standard error messages */
#define ERROR_CANT_CONVERT_TO_BOOLEAN(OPERATOR, NODE, TYPE) \
Index: jcf-dump.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/jcf-dump.c,v
retrieving revision 1.16
diff -u -p -r1.16 jcf-dump.c
--- jcf-dump.c 1999/03/12 17:13:12 1.16
+++ jcf-dump.c 1999/03/15 21:08:33
@@ -77,7 +77,7 @@ int class_access_flags = 0;
/* Print in format similar to javap. VERY IMCOMPLETE. */
int flag_javap_compatible = 0;
-static int print_access_flags PROTO ((FILE *, uint16));
+static int print_access_flags PROTO ((FILE *, uint16, char));
static void print_constant_terse PROTO ((FILE*, JCF*, int, int));
static void print_constant PROTO ((FILE *, JCF *, int, int));
static void print_constant_ref PROTO ((FILE *, JCF *, int));
@@ -127,7 +127,7 @@ DEFUN(utf8_equal_string, (jcf, index, va
class_access_flags = ACCESS_FLAGS; \
if (flag_print_class_info) \
{ fprintf (out, "\nAccess flags: 0x%x", ACCESS_FLAGS); \
- print_access_flags (out, ACCESS_FLAGS); \
+ print_access_flags (out, ACCESS_FLAGS, 'c'); \
fputc ('\n', out); \
fprintf (out, "This class: "); \
if (flag_print_constant_pool) \
@@ -163,7 +163,7 @@ DEFUN(utf8_equal_string, (jcf, index, va
if (flag_print_fields) \
{ fprintf (out, "Field name:"); \
print_constant_terse (out, jcf, NAME, CONSTANT_Utf8); \
- print_access_flags (out, ACCESS_FLAGS); \
+ print_access_flags (out, ACCESS_FLAGS, 'f'); \
fprintf (out, " Signature: "); \
if (flag_print_constant_pool) \
fprintf (out, "%d=", SIGNATURE); \
@@ -194,7 +194,7 @@ DEFUN(utf8_equal_string, (jcf, index, va
if (flag_javap_compatible) \
{ \
fprintf (out, " "); \
- print_access_flags (out, ACCESS_FLAGS); \
+ print_access_flags (out, ACCESS_FLAGS, 'm'); \
fputc (' ', out); \
print_signature (out, jcf, SIGNATURE, PRINT_SIGNATURE_RESULT_ONLY); \
fputc (' ', out); \
@@ -206,7 +206,7 @@ DEFUN(utf8_equal_string, (jcf, index, va
{ \
fprintf (out, "\nMethod name:"); \
print_constant_terse (out, jcf, NAME, CONSTANT_Utf8); \
- print_access_flags (out, ACCESS_FLAGS); \
+ print_access_flags (out, ACCESS_FLAGS, 'm'); \
fprintf (out, " Signature: "); \
if (flag_print_constant_pool) \
fprintf (out, "%d=", SIGNATURE); \
@@ -305,16 +305,24 @@ DEFUN(print_constant_ref, (stream, jcf,
fprintf (stream, ">");
}
+/* Print the access flags given by FLAGS.
+ The CONTEXT is one of 'c' (class flags), 'f' (field flags),
+ or 'm' (method flags). */
+
static int
-DEFUN (print_access_flags, (stream, flags),
- FILE *stream AND uint16 flags)
+DEFUN (print_access_flags, (stream, flags, context),
+ FILE *stream AND uint16 flags AND char context)
{
if (flags & ACC_PUBLIC) fprintf (stream, " public");
if (flags & ACC_PRIVATE) fprintf (stream, " private");
if (flags & ACC_PROTECTED) fprintf (stream, " protected");
if (flags & ACC_STATIC) fprintf (stream, " static");
if (flags & ACC_FINAL) fprintf (stream, " final");
- if (flags & ACC_SYNCHRONIZED) fprintf (stream, " synchronized");
+ if (flags & ACC_SYNCHRONIZED)
+ if (context == 'c')
+ fprintf (stream, " super");
+ else
+ fprintf (stream, " synchronized");
if (flags & ACC_VOLATILE) fprintf (stream, " volatile");
if (flags & ACC_TRANSIENT) fprintf (stream, " transient");
if (flags & ACC_NATIVE) fprintf (stream, " native");
Index: jcf-write.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/jcf-write.c,v
retrieving revision 1.29
diff -u -p -r1.29 jcf-write.c
--- jcf-write.c 1999/03/10 23:22:47 1.29
+++ jcf-write.c 1999/03/15 21:08:33
@@ -2696,7 +2696,9 @@ generate_classfile (clas, state)
else
i = 8 + 2 * total_supers;
ptr = append_chunk (NULL, i, state);
- i = get_access_flags (TYPE_NAME (clas)) | ACC_SUPER;
+ i = get_access_flags (TYPE_NAME (clas));
+ if (! (i & ACC_INTERFACE))
+ i |= ACC_SUPER;
PUT2 (i); /* acces_flags */
i = find_class_constant (&state->cpool, clas); PUT2 (i); /* this_class */
if (clas == object_type_node)
Index: parse.y
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/parse.y,v
retrieving revision 1.60
diff -u -p -r1.60 parse.y
--- parse.y 1999/03/12 18:19:04 1.60
+++ parse.y 1999/03/15 21:08:34
@@ -2991,17 +2991,8 @@ create_class (flags, id, super, interfac
return NULL_TREE;
}
- /* The class is known and exists if there is a decl. Otherwise,
- postpone the operation and do it later. */
- super_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (super));
- if (super_decl)
- {
- parser_check_super (super_decl, decl, id);
- super_decl_type = TREE_TYPE (super_decl);
- }
- else
- super_decl_type =
- register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
+ super_decl_type =
+ register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
}
else if (TREE_TYPE (decl) != object_type_node)
super_decl_type = object_type_node;