diff options
author | Alexandre Petit-Bianco <apbianco@cygnus.com> | 1999-03-19 12:56:16 +0000 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 1999-03-19 04:56:16 -0800 |
commit | 1982388a57dbdb1e7b38c77f0aeca61ba02c60b0 (patch) | |
tree | e12187cefe329f846025ee7fa24351f8bacc32b8 /gcc/java | |
parent | 8db99db275183d379d0b6f2cd80942f6f5f5b4b2 (diff) | |
download | gcc-1982388a57dbdb1e7b38c77f0aeca61ba02c60b0.zip gcc-1982388a57dbdb1e7b38c77f0aeca61ba02c60b0.tar.gz gcc-1982388a57dbdb1e7b38c77f0aeca61ba02c60b0.tar.bz2 |
[multiple changes]
1999-03-19 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (find_applicable_accessible_methods_list): Extend the
search to superinterfaces when relevant.
(search_applicable_methods_list): New function.
1999-03-18 Alexandre Petit-Bianco <apbianco@cygnus.com>
* class.c (unmangle_classname): Implemented stricter testing
before setting the QUALIFIED_P flag on an identifier.
From-SVN: r25861
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/java/class.c | 14 | ||||
-rw-r--r-- | gcc/java/parse.y | 80 |
3 files changed, 80 insertions, 25 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index b08f635..263f2f8 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,14 @@ +1999-03-19 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * parse.y (find_applicable_accessible_methods_list): Extend the + search to superinterfaces when relevant. + (search_applicable_methods_list): New function. + +1999-03-18 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * class.c (unmangle_classname): Implemented stricter testing + before setting the QUALIFIED_P flag on an identifier. + Tue Mar 16 15:15:41 1999 Per Bothner <bothner@cygnus.com> * parse.y (java_complete_lhs): Call force_evaluation_order diff --git a/gcc/java/class.c b/gcc/java/class.c index 1ab753a..53ccf3e 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -142,8 +142,18 @@ unmangle_classname (name, name_length) const char *name; int name_length; { tree to_return = ident_subst (name, name_length, "", '/', '.', ""); - if (to_return != get_identifier ((char *)name)) - QUALIFIED_P (to_return) = 1; + /* It's not sufficient to compare to_return and get_identifier + (name) to determine whether to_return is qualified. There are + cases in signature analysis where name will be stripped of a + trailing ';'. */ + name = IDENTIFIER_POINTER (to_return); + while (*name) + if (*name++ == '.') + { + QUALIFIED_P (to_return) = 1; + break; + } + return to_return; } diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 81f5cb0..68dfe24 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -118,6 +118,8 @@ static tree resolve_no_layout PROTO ((tree, tree)); static int invocation_mode PROTO ((tree, int)); static tree find_applicable_accessible_methods_list PROTO ((int, tree, tree, tree)); +static void search_applicable_methods_list PROTO ((int, tree, tree, tree, + tree *, tree *)); static tree find_most_specific_methods_list PROTO ((tree)); static int argument_types_convertible PROTO ((tree, tree)); static tree patch_invoke PROTO ((tree, tree, tree)); @@ -7164,40 +7166,72 @@ find_applicable_accessible_methods_list (lc, class, name, arglist) int lc; tree class, name, arglist; { - tree method; tree list = NULL_TREE, all_list = NULL_TREE; - while (class != NULL_TREE) + /* Search interfaces */ + if (CLASS_INTERFACE (TYPE_NAME (class))) { - for (method = TYPE_METHODS (class); - method != NULL_TREE; method = TREE_CHAIN (method)) + int i, n; + tree basetype_vec = TYPE_BINFO_BASETYPES (class); + + 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++) { - if (lc && !DECL_CONSTRUCTOR_P (method)) - continue; - else if (!lc && (DECL_CONSTRUCTOR_P (method) - || (GET_METHOD_NAME (method) != name))) - continue; - - if (argument_types_convertible (method, arglist)) - { - /* Retain accessible methods only */ - if (!not_accessible_p (DECL_CONTEXT (current_function_decl), - method, 0)) - list = tree_cons (NULL_TREE, method, list); - else - /* Also retain all selected method here */ - all_list = tree_cons (NULL_TREE, method, list); - } + tree rlist = + find_applicable_accessible_methods_list + (lc, BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), + name, arglist); + all_list = chainon (rlist, (list ? list : all_list)); } - /* When dealing with constructor, stop here, otherwise search - other classes */ - class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class)); } + /* Search classes */ + else + while (class != NULL_TREE) + { + search_applicable_methods_list + (lc, TYPE_METHODS (class), name, arglist, &list, &all_list); + class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class)); + } + /* Either return the list obtained or all selected (but inaccessible) methods for better error report. */ return (!list ? all_list : list); } +/* Effectively search for the approriate method in method */ + +static void +search_applicable_methods_list(lc, method, name, arglist, list, all_list) + int lc; + tree method, name, arglist; + tree *list, *all_list; +{ + for (; method; method = TREE_CHAIN (method)) + { + /* When dealing with constructor, stop here, otherwise search + other classes */ + if (lc && !DECL_CONSTRUCTOR_P (method)) + continue; + else if (!lc && (DECL_CONSTRUCTOR_P (method) + || (GET_METHOD_NAME (method) != name))) + continue; + + if (argument_types_convertible (method, arglist)) + { + /* Retain accessible methods only */ + if (!not_accessible_p (DECL_CONTEXT (current_function_decl), + method, 0)) + *list = tree_cons (NULL_TREE, method, *list); + else + /* Also retain all selected method here */ + *all_list = tree_cons (NULL_TREE, method, *list); + } + } +} + /* 15.11.2.2 Choose the Most Specific Method */ static tree |