From de0b553f86bcb8075ed37ba0529c153a4ade45e5 Mon Sep 17 00:00:00 2001 From: Alexandre Petit-Bianco Date: Tue, 23 Mar 1999 11:20:03 +0000 Subject: [PATCH] parse.y (find_applicable_accessible_methods_list): When dealing with interface... Tue Mar 23 10:48:24 1999 Alexandre Petit-Bianco * parse.y (find_applicable_accessible_methods_list): When dealing with interface: ensure that a given interface or java.lang.Object are searched only once. From-SVN: r25925 --- gcc/java/ChangeLog | 6 ++++++ gcc/java/parse.c | 43 ++++++++++++++++++++++++++++++++++++------- gcc/java/parse.y | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index e03ee3eb8fc..917b40313eb 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +Tue Mar 23 10:48:24 1999 Alexandre Petit-Bianco + + * parse.y (find_applicable_accessible_methods_list): When dealing + with interface: ensure that a given interface or java.lang.Object + are searched only once. + Tue Mar 23 10:05:27 1999 Kaveh R. Ghazi * gjavah.c (print_c_decl): Remove unused argument `flags'. diff --git a/gcc/java/parse.c b/gcc/java/parse.c index 4c6c38433b1..d8e35839fd2 100644 --- a/gcc/java/parse.c +++ b/gcc/java/parse.c @@ -2222,7 +2222,7 @@ static const short yycheck[] = { 3, #define YYPURE 1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/local/gnu/share/bison.simple" +#line 3 "/usr/lib/bison.simple" /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. @@ -2415,7 +2415,7 @@ __yy_memcpy (char *to, char *from, int count) #endif #endif -#line 196 "/usr/local/gnu/share/bison.simple" +#line 196 "/usr/lib/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. @@ -4680,7 +4680,7 @@ case 493: break;} } /* the action file gets copied in in place of this dollarsign */ -#line 498 "/usr/local/gnu/share/bison.simple" +#line 498 "/usr/lib/bison.simple" yyvsp -= yylen; yyssp -= yylen; @@ -9771,20 +9771,49 @@ find_applicable_accessible_methods_list (lc, class, name, arglist) /* 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 */ diff --git a/gcc/java/parse.y b/gcc/java/parse.y index f06ee9f1a5a..1665f5697b8 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -7170,20 +7170,49 @@ find_applicable_accessible_methods_list (lc, class, name, arglist) /* 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 */ -- 2.30.2