This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Java: miscellaneous patches.
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH] Java: miscellaneous patches.
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Wed, 27 Jun 2001 13:29:33 -0700
- Reply-to: apbianco at cygnus dot com
This fixes a problem with reading InnerClasses attributes from
classfiles, the computation of DECL_MAX_LOCALS with native methods and
the handling of duplicate import on demands.
I'm checking this in.
./A
2001-06-27 Alexandre Petit-Bianco <apbianco@redhat.com>
* class.c (set_super_info): Call `set_class_decl_access_flags.'
(set_class_decl_access_flags): New function.
* java-tree.h (set_class_decl_access_flags): New prototype.
* jcf-parse.c (handle_innerclass_attribute): Read and set access flags.
(parse_class_file): New local `decl_max_locals.' Take wide types
into account to compute DECL_MAX_LOCALS.
* parse.y (type_import_on_demand_declaration:): Ignore duplicate
imports on demand.
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.99
diff -u -p -r1.99 class.c
--- class.c 2001/06/21 03:20:04 1.99
+++ class.c 2001/06/27 20:17:27
@@ -394,6 +394,14 @@ set_super_info (access_flags, this_class
CLASS_HAS_SUPER (this_class) = 1;
}
+ set_class_decl_access_flags (access_flags, class_decl);
+}
+
+void
+set_class_decl_access_flags (access_flags, class_decl)
+ int access_flags;
+ tree class_decl;
+{
if (access_flags & ACC_PUBLIC) CLASS_PUBLIC (class_decl) = 1;
if (access_flags & ACC_FINAL) CLASS_FINAL (class_decl) = 1;
if (access_flags & ACC_SUPER) CLASS_SUPER (class_decl) = 1;
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.113
diff -u -p -r1.113 java-tree.h
--- java-tree.h 2001/04/26 19:40:33 1.113
+++ java-tree.h 2001/06/27 20:17:32
@@ -1040,6 +1040,7 @@ extern void pop_labeled_block PARAMS ((v
extern const char *lang_printable_name PARAMS ((tree, int));
extern tree maybe_add_interface PARAMS ((tree, tree));
extern void set_super_info PARAMS ((int, tree, tree, int));
+extern void set_class_decl_access_flags PARAMS ((int, tree));
extern int get_access_flags_from_decl PARAMS ((tree));
extern int interface_of_p PARAMS ((tree, tree));
extern int inherits_from_p PARAMS ((tree, tree));
Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.85
diff -u -p -r1.85 jcf-parse.c
--- jcf-parse.c 2001/05/21 21:37:36 1.85
+++ jcf-parse.c 2001/06/27 20:17:35
@@ -465,6 +465,8 @@ handle_innerclass_attribute (count, jcf)
/* Read inner_name_index. If the class we're dealing with is
an annonymous class, it must be 0. */
int ini = JCF_readu2 (jcf);
+ /* Read the access flag. */
+ int acc = JCF_readu2 (jcf);
/* If icii is 0, don't try to read the class. */
if (icii >= 0)
{
@@ -475,13 +477,13 @@ handle_innerclass_attribute (count, jcf)
{
tree outer = TYPE_NAME (get_class_constant (jcf, ocii));
tree alias = (ini ? get_name_constant (jcf, ini) : NULL_TREE);
+ set_class_decl_access_flags (acc, decl);
DECL_CONTEXT (decl) = outer;
DECL_INNER_CLASS_LIST (outer) =
tree_cons (decl, alias, DECL_INNER_CLASS_LIST (outer));
CLASS_COMPLETE_P (decl) = 1;
}
}
- JCF_SKIP (jcf, 2);
}
}
@@ -788,10 +790,21 @@ parse_class_file ()
if (METHOD_NATIVE (method))
{
+ tree arg;
+ int decl_max_locals;
+
if (! flag_jni)
continue;
- DECL_MAX_LOCALS (method)
- = list_length (TYPE_ARG_TYPES (TREE_TYPE (method)));
+ /* We need to compute the DECL_MAX_LOCALS. We need to take
+ the wide types into account too. */
+ for (arg = TYPE_ARG_TYPES (TREE_TYPE (method)), decl_max_locals = 0;
+ arg != end_params_node;
+ arg = TREE_CHAIN (arg), decl_max_locals += 1)
+ {
+ if (TREE_VALUE (arg) && TYPE_IS_WIDE (TREE_VALUE (arg)))
+ decl_max_locals += 1;
+ }
+ DECL_MAX_LOCALS (method) = decl_max_locals;
start_java_method (method);
give_name_to_locals (jcf);
expand_expr_stmt (build_jni_stub (method));
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.290
diff -u -p -r1.290 parse.y
--- parse.y 2001/06/21 03:20:04 1.290
+++ parse.y 2001/06/27 20:18:13
@@ -781,8 +781,14 @@ type_import_on_demand_declaration:
IMPORT_TK name DOT_TK MULT_TK SC_TK
{
tree name = EXPR_WFL_NODE ($2);
- /* Don't import java.lang.* twice. */
- if (name != java_lang_id)
+ tree it;
+ /* Search for duplicates. */
+ for (it = ctxp->import_demand_list; it; it = TREE_CHAIN (it))
+ if (EXPR_WFL_NODE (TREE_PURPOSE (it)) == name)
+ break;
+ /* Don't import the same thing more than once, just ignore
+ duplicates (7.5.2) */
+ if (! it)
{
read_import_dir ($2);
ctxp->import_demand_list =