PATCH: Tighten method search in interfaces.
Alexandre Petit-Bianco
apbianco@cygnus.com
Tue Mar 23 11:29:00 GMT 1999
This patch makes sure that during the search for an appropriate
methods, interfaces and java.lang.Object are searched only once (an
interface can end up being searched twice, since Java allows diamonds
in the interface hierarchies.)
This patch is already checked in.
Tue Mar 23 10:48:24 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (find_applicable_accessible_methods_list): When dealing
with interface: ensure that a given interface or java.lang.Object
are searched only once.
Index: parse.y
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/parse.y,v
retrieving revision 1.65
diff -u -p -r1.65 parse.y
--- parse.y 1999/03/23 07:24:13 1.65
+++ parse.y 1999/03/23 19:15:59
@@ -7170,20 +7170,49 @@ find_applicable_accessible_methods_list
/* Search interfaces */
if (CLASS_INTERFACE (TYPE_NAME (class)))
{
+ static tree searched_interfaces = NULL_TREE;
+ static int search_not_done = 0;
int i, n;
tree basetype_vec = TYPE_BINFO_BASETYPES (class);
+ /* Have we searched this interface already? */
+ if (searched_interfaces)
+ {
+ tree current;
+ for (current = searched_interfaces;
+ current; current = TREE_CHAIN (current))
+ if (TREE_VALUE (current) == class)
+ return NULL;
+ }
+ searched_interfaces = tree_cons (NULL_TREE, class, searched_interfaces);
+
search_applicable_methods_list
(lc, TYPE_METHODS (class), name, arglist, &list, &all_list);
n = TREE_VEC_LENGTH (basetype_vec);
for (i = 0; i < n; i++)
{
- tree rlist =
- find_applicable_accessible_methods_list
- (lc, BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)),
- name, arglist);
+ tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+ tree rlist;
+
+ /* Skip java.lang.Object (we'll search it once later.) */
+ if (t == object_type_node)
+ continue;
+
+ search_not_done++;
+ rlist = find_applicable_accessible_methods_list (lc, t, name,
+ arglist);
all_list = chainon (rlist, (list ? list : all_list));
+ search_not_done--;
+ }
+
+ /* We're done. Reset the searched interfaces list and finally search
+ java.lang.Object */
+ if (!search_not_done)
+ {
+ searched_interfaces = NULL_TREE;
+ search_applicable_methods_list (lc, TYPE_METHODS (object_type_node),
+ name, arglist, &list, &all_list);
}
}
/* Search classes */
.--- Alex (www.cygnus.com/~apbianco, apbianco@cygnus.com)
| NT? Not Today, Not Tomorrow, No Thanks.
More information about the Gcc-patches
mailing list