aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-07-20 12:26:02 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-07-20 12:26:02 +0000
commitfa743e8cda25ba09a4731a3443df9e0e56e87581 (patch)
treed4f6d97c6ff518d744dc34b2b6c955e9348bb0b0 /gcc/java
parent35ae2ed81410448471c46f7757e6bc879d4de250 (diff)
downloadgcc-fa743e8cda25ba09a4731a3443df9e0e56e87581.zip
gcc-fa743e8cda25ba09a4731a3443df9e0e56e87581.tar.gz
gcc-fa743e8cda25ba09a4731a3443df9e0e56e87581.tar.bz2
tree.h: Include vec.h
.: * tree.h: Include vec.h (DEF_VEC_P(tree)): New type. (BINFO_BASE_BINFOS, BINFO_N_BASE_BINFOS, BINFO_BASE_BINFO): Adjust. (BINFO_BASE_APPEND, BINFO_BASE_ITERATE): New. (BINFO_LANG_SLOT): Remove. (BINFO_SUBVTT_INDEX, BINFO_VPTR_INDEX, BINFO_PRIMARY_BASE_OF): New. (struct tree_binfo): Turn base_binfos into a trailing VEC(tree). Add vtt_subvtt, vtt_vptr, primary fields. (binfo_lang_slots): Remove. * tree.c (binfo_lang_slots): Remove. (make_tree_binfo_stat): Take a base binfo count, not a lang slot count. Adjust. * Makefile.in (TREE_H): Add vec.h * alias.c (record_component_aliases): Adjust BINFO access. * dbxout.c (dbxout_type): Likewise. * dwarf2out.c (gen_member_die): Likewise. * sdbout.c (sdbout_one_type): Likewise. * tree-dump.c (deque_and_dump): Likewise. * config/i386/i386.c (classify_argument, contains_128bit_aligned_vector_p): Likewise. * config/sh/symbian.c (symbian_export_vtable_and_rtti_p): Likewise. * doc/c-tree.texi (Classes): Update BINFO documentation. cp: * cp-tree.h (DEF_VEC_P(tree)): Remove here. (BINFO_SUBVTT_INDEX, BINFO_VPTR_INDEX, BINFO_PRIMARY_BASE_OF): Moved to common. (BINFO_LANG_SLOTS): Remove. * tree.c (copy_binfo): Adjust BINFO creation and accessors. * decl.c (xref_basetypes): Adjust BINFO creation and accessors. * class.c (check_bases): Adjust BINFO accessors. (determine_primary_base, finish_struct_bits, maybe_warn_about_overly_private_class, warn_hidden, walk_subobject_offsets, propagate_binfo_offsets, end_of_class, warn_about_ambiguous_bases, get_vfield_name, dump_class_hierarchy_r, build_vtt_inits, accumulate_vtbl_inits, add_vcall_offset_vtbl_entries_r): Likewise. * dump.c (cp_dump_tree): Likewise. * init.c (sort_mem_initializers, expand_member_init, build_delete, push_base_cleanups): Likewise. * method.c (do_build_copy_constructor, do_build_assign_ref, synthesize_exception_spec): Likewise. name-lookup.c (arg_assoc_class): Likewise. * pt.c (instantiate_class_template, get_template_base_recursive): Likewise. * rtti.c (get_pseudo_ti_init, get_pseudo_ti_desc): Likewise. * typeck2.c (process_init_constructor): Likewise. * search.c (lookup_base_r, dynamic_cast_base_recurse, dfs_access_in_type, dfs_walk_real, look_for_overrides, types_overlap_p, copied_binfo, original_binfo): Likewise. (binfo_for_vtable): Remove java: * class.c (add_interface_do): Remove. (set_super_info, interface_of_p, maybe_add_interface, add_interface, make_class_data, layout_class, add_miranda_methods): Adjust BINFO accessors and addition. * expr.c (can_widen_reference_to, lookup_field): Adjust BINFO accessors. * jcf-write.c (generate_classfile): Likewise. * parse.y (patch_anonymous_class, check_inner_circular_reference, check_circular_reference, java_complete_class, check_abstract_method_definitions, java_check_abstract_method_definitions, check_interface_throws_clauses, java_check_abstract_methods, lookup_java_interface_method2, find_applicable_accessible_methods_list): Adjust BINFO accessors and addition. * typeck.c (find_method_in_interfaces): Adjust BINFO accessors. From-SVN: r84949
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog19
-rw-r--r--gcc/java/class.c141
-rw-r--r--gcc/java/expr.c26
-rw-r--r--gcc/java/jcf-write.c12
-rw-r--r--gcc/java/parse.y160
-rw-r--r--gcc/java/typeck.c11
6 files changed, 168 insertions, 201 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 308aaa3..b2322fd 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,22 @@
+2004-07-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ * class.c (add_interface_do): Remove.
+ (set_super_info, interface_of_p, maybe_add_interface,
+ add_interface, make_class_data, layout_class,
+ add_miranda_methods): Adjust BINFO accessors and addition.
+ * expr.c (can_widen_reference_to, lookup_field): Adjust BINFO
+ accessors.
+ * jcf-write.c (generate_classfile): Likewise.
+ * parse.y (patch_anonymous_class, check_inner_circular_reference,
+ check_circular_reference, java_complete_class,
+ check_abstract_method_definitions,
+ java_check_abstract_method_definitions,
+ check_interface_throws_clauses, java_check_abstract_methods,
+ lookup_java_interface_method2,
+ find_applicable_accessible_methods_list): Adjust BINFO accessors
+ and addition.
+ * typeck.c (find_method_in_interfaces): Adjust BINFO accessors.
+
2004-07-18 Roger Sayle <roger@eyesopen.com>
* builtins.c (max_builtin, min_builtin,
diff --git a/gcc/java/class.c b/gcc/java/class.c
index 64e4409..82ae822 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -57,7 +57,6 @@ static tree make_field_value (tree);
static tree get_dispatch_vector (tree);
static tree get_dispatch_table (tree, tree);
static int supers_all_compiled (tree type);
-static void add_interface_do (tree, tree, int);
static tree maybe_layout_super_class (tree, tree);
static void add_miranda_methods (tree, tree);
static int assume_compiled (const char *);
@@ -476,16 +475,14 @@ set_super_info (int access_flags, tree this_class,
if (super_class)
total_supers++;
- TYPE_BINFO (this_class) = make_tree_binfo (0);
+ TYPE_BINFO (this_class) = make_tree_binfo (total_supers);
TYPE_VFIELD (this_class) = TYPE_VFIELD (object_type_node);
- BINFO_BASE_BINFOS (TYPE_BINFO (this_class)) = make_tree_vec (total_supers);
if (super_class)
{
tree super_binfo = make_tree_binfo (0);
BINFO_TYPE (super_binfo) = super_class;
BINFO_OFFSET (super_binfo) = integer_zero_node;
- TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (this_class)), 0)
- = super_binfo;
+ BINFO_BASE_APPEND (TYPE_BINFO (this_class), super_binfo);
CLASS_HAS_SUPER_FLAG (TYPE_BINFO (this_class)) = 1;
}
@@ -530,26 +527,23 @@ class_depth (tree clas)
int
interface_of_p (tree type1, tree type2)
{
- int n, i;
- tree basetype_vec;
+ int i;
+ tree binfo, base_binfo;
if (! TYPE_BINFO (type2))
return 0;
- basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (type2));
- n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; i < n; i++)
- {
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- if (vec_elt && BINFO_TYPE (vec_elt) == type1)
- return 1;
- }
- for (i = 0; i < n; i++)
- {
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- if (vec_elt && BINFO_TYPE (vec_elt)
- && interface_of_p (type1, BINFO_TYPE (vec_elt)))
- return 1;
- }
+
+ for (binfo = TYPE_BINFO (type2), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ if (BINFO_TYPE (base_binfo) == type1)
+ return 1;
+
+ for (binfo = TYPE_BINFO (type2), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) /* */
+ if (BINFO_TYPE (base_binfo)
+ && interface_of_p (type1, BINFO_TYPE (base_binfo)))
+ return 1;
+
return 0;
}
@@ -636,17 +630,6 @@ common_enclosing_instance_p (tree type1, tree type2)
return 0;
}
-static void
-add_interface_do (tree basetype_vec, tree interface_class, int i)
-{
- tree interface_binfo = make_tree_binfo (0);
- BINFO_TYPE (interface_binfo) = interface_class;
- BINFO_OFFSET (interface_binfo) = integer_zero_node;
- BINFO_VPTR_FIELD (interface_binfo) = integer_zero_node;
- BINFO_VIRTUAL_P (interface_binfo) = 1;
- TREE_VEC_ELT (basetype_vec, i) = interface_binfo;
-}
-
/* Add INTERFACE_CLASS to THIS_CLASS iff INTERFACE_CLASS can't be
found in THIS_CLASS. Returns NULL_TREE upon success, INTERFACE_CLASS
if attempt is made to add it twice. */
@@ -654,22 +637,14 @@ add_interface_do (tree basetype_vec, tree interface_class, int i)
tree
maybe_add_interface (tree this_class, tree interface_class)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (this_class));
+ tree binfo, base_binfo;
int i;
- int n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; ; i++)
- {
- if (i >= n)
- {
- error ("internal error - too many interface type");
- return NULL_TREE;
- }
- else if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
- break;
- else if (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)) == interface_class)
- return interface_class;
- }
- add_interface_do (basetype_vec, interface_class, i);
+
+ for (binfo = TYPE_BINFO (this_class), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ if (BINFO_TYPE (base_binfo) == interface_class)
+ return interface_class;
+ add_interface (this_class, interface_class);
return NULL_TREE;
}
@@ -678,20 +653,14 @@ maybe_add_interface (tree this_class, tree interface_class)
void
add_interface (tree this_class, tree interface_class)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (this_class));
- int i;
- int n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; ; i++)
- {
- if (i >= n)
- {
- error ("internal error - too many interface type");
- return;
- }
- else if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
- break;
- }
- add_interface_do (basetype_vec, interface_class, i);
+ tree interface_binfo = make_tree_binfo (0);
+
+ BINFO_TYPE (interface_binfo) = interface_class;
+ BINFO_OFFSET (interface_binfo) = integer_zero_node;
+ BINFO_VPTR_FIELD (interface_binfo) = integer_zero_node;
+ BINFO_VIRTUAL_P (interface_binfo) = 1;
+
+ BINFO_BASE_APPEND (TYPE_BINFO (this_class), interface_binfo);
}
#if 0
@@ -1666,9 +1635,10 @@ make_class_data (tree type)
= build_prim_array_type (class_ptr_type, interface_len);
idecl = build_decl (VAR_DECL, mangled_classname ("_IF_", type),
interface_array_type);
+
for (i = interface_len; i > 0; i--)
{
- tree child = TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (type)), i);
+ tree child = BINFO_BASE_BINFO (TYPE_BINFO (type), i);
tree iclass = BINFO_TYPE (child);
tree index;
if (! flag_indirect_dispatch
@@ -2063,27 +2033,21 @@ layout_class (tree this_class)
of this itself. */
if (!CLASS_FROM_SOURCE_P (this_class))
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (this_class));
-
- if (basetype_vec)
+ int i;
+
+ for (i = BINFO_N_BASE_BINFOS (TYPE_BINFO (this_class)) - 1; i > 0; i--)
{
- int n = TREE_VEC_LENGTH (basetype_vec) - 1;
- int i;
- for (i = n; i > 0; i--)
+ tree binfo = BINFO_BASE_BINFO (TYPE_BINFO (this_class), i);
+ tree super_interface = BINFO_TYPE (binfo);
+ tree maybe_super_interface
+ = maybe_layout_super_class (super_interface, NULL_TREE);
+ if (maybe_super_interface == NULL
+ || TREE_CODE (TYPE_SIZE (maybe_super_interface)) == ERROR_MARK)
{
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- tree super_interface = BINFO_TYPE (vec_elt);
-
- tree maybe_super_interface
- = maybe_layout_super_class (super_interface, NULL_TREE);
- if (maybe_super_interface == NULL
- || TREE_CODE (TYPE_SIZE (maybe_super_interface)) == ERROR_MARK)
- {
- TYPE_SIZE (this_class) = error_mark_node;
- CLASS_BEING_LAIDOUT (this_class) = 0;
- class_list = TREE_CHAIN (class_list);
- return;
- }
+ TYPE_SIZE (this_class) = error_mark_node;
+ CLASS_BEING_LAIDOUT (this_class) = 0;
+ class_list = TREE_CHAIN (class_list);
+ return;
}
}
}
@@ -2099,15 +2063,14 @@ layout_class (tree this_class)
static void
add_miranda_methods (tree base_class, tree search_class)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (search_class));
- int i, n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 1; i < n; ++i)
+ tree binfo, base_binfo;
+ int i;
+
+ for (binfo = TYPE_BINFO (search_class), i = 1;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
tree method_decl;
- tree elt = TREE_VEC_ELT (basetype_vec, i);
- if (elt == NULL_TREE)
- break;
- elt = BINFO_TYPE (elt);
+ tree elt = BINFO_TYPE (base_binfo);
/* Ensure that interface methods are seen in declared order. */
layout_class_methods (elt);
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index a6bc575..228c1d1 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -426,15 +426,16 @@ can_widen_reference_to (tree source_type, tree target_type)
{
/* target_type is OK if source_type or source_type ancestors
implement target_type. We handle multiple sub-interfaces */
+ tree binfo, base_binfo;
+ int i;
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (source_type));
- int n = TREE_VEC_LENGTH (basetype_vec), i;
- for (i=0 ; i < n; i++)
- if (can_widen_reference_to
- (TREE_TYPE (TREE_VEC_ELT (basetype_vec, i)),
- target_type))
+ for (binfo = TYPE_BINFO (source_type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ if (can_widen_reference_to
+ (BINFO_TYPE (base_binfo), target_type))
return 1;
- if (n == 0)
+
+ if (!i)
return 0;
}
@@ -1459,21 +1460,20 @@ lookup_field (tree *typep, tree name)
}
do
{
- tree field, basetype_vec;
+ tree field, binfo, base_binfo;
tree save_field;
- int n, i;
+ int i;
for (field = TYPE_FIELDS (*typep); field; field = TREE_CHAIN (field))
if (DECL_NAME (field) == name)
return field;
/* Process implemented interfaces. */
- basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (*typep));
- n = TREE_VEC_LENGTH (basetype_vec);
save_field = NULL_TREE;
- for (i = 0; i < n; i++)
+ for (binfo = TYPE_BINFO (*typep), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+ tree t = BINFO_TYPE (base_binfo);
if ((field = lookup_field (&t, name)))
{
if (save_field == field)
diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c
index a41c355..a73b7be 100644
--- a/gcc/java/jcf-write.c
+++ b/gcc/java/jcf-write.c
@@ -2963,15 +2963,15 @@ generate_classfile (tree clas, struct jcf_partial *state)
}
else
{
- tree basetypes = BINFO_BASE_BINFOS (TYPE_BINFO (clas));
- tree base = BINFO_TYPE (TREE_VEC_ELT (basetypes, 0));
- int j = find_class_constant (&state->cpool, base);
+ tree binfo = TYPE_BINFO (clas);
+ tree base_binfo = BINFO_BASE_BINFO (binfo, 0);
+ int j = find_class_constant (&state->cpool, BINFO_TYPE (base_binfo));
+
PUT2 (j); /* super_class */
PUT2 (total_supers - 1); /* interfaces_count */
- for (i = 1; i < total_supers; i++)
+ for (i = 1; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- base = BINFO_TYPE (TREE_VEC_ELT (basetypes, i));
- j = find_class_constant (&state->cpool, base);
+ j = find_class_constant (&state->cpool, BINFO_TYPE (base_binfo));
PUT2 (j);
}
}
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 2ca09a2..2f41b1b 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -3879,16 +3879,24 @@ patch_anonymous_class (tree type_decl, tree class_decl, tree wfl)
/* If it's an interface, implement it */
if (CLASS_INTERFACE (type_decl))
{
- tree s_binfo;
- int length;
-
if (parser_check_super_interface (type_decl, class_decl, wfl))
return;
- s_binfo = TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (class)), 0);
- length = TREE_VEC_LENGTH (BINFO_BASE_BINFOS (TYPE_BINFO (class)))+1;
- BINFO_BASE_BINFOS (TYPE_BINFO (class)) = make_tree_vec (length);
- TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO (class)), 0) = s_binfo;
+ if (VEC_space (tree, BINFO_BASE_BINFOS (binfo), 1))
+ {
+ /* Extend the binfo - by reallocating and copying it. */
+ tree new_binfo;
+ tree base_binfo;
+ int i;
+
+ new_binfo = make_tree_binfo ((BINFO_N_BASE_BINFOS (binfo) + 1) * 2);
+ for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
+ BINFO_BASE_APPEND (new_binfo, base_binfo);
+ CLASS_HAS_SUPER_FLAG (new_binfo) = CLASS_HAS_SUPER_FLAG (binfo);
+ BINFO_VTABLE (new_binfo) = BINFO_VTABLE (binfo);
+ TYPE_BINFO (class) = new_binfo;
+ }
+
/* And add the interface */
parser_add_interface (class_decl, type_decl, wfl);
}
@@ -3897,7 +3905,7 @@ patch_anonymous_class (tree type_decl, tree class_decl, tree wfl)
{
if (parser_check_super (type_decl, class_decl, wfl))
return;
- BINFO_TYPE (TREE_VEC_ELT (BINFO_BASE_BINFOS (binfo), 0)) = type;
+ BINFO_TYPE (BINFO_BASE_BINFO (binfo, 0)) = type;
}
}
@@ -5213,23 +5221,18 @@ register_incomplete_type (int kind, tree wfl, tree decl, tree ptr)
static tree
check_inner_circular_reference (tree source, tree target)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (source));
+ tree base_binfo;
tree ctx, cl;
int i;
- if (!basetype_vec)
- return NULL_TREE;
-
- for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (source), i, base_binfo); i++)
{
tree su;
/* We can end up with a NULL_TREE or an incomplete type here if
we encountered previous type resolution errors. It's safe to
simply ignore these cases. */
- if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
- continue;
- su = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+ su = BINFO_TYPE (base_binfo);
if (INCOMPLETE_TYPE_P (su))
continue;
@@ -5259,10 +5262,10 @@ check_inner_circular_reference (tree source, tree target)
static tree
check_circular_reference (tree type)
{
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (type));
+ tree base_binfo;
int i;
- if (!basetype_vec)
+ if (!BINFO_N_BASE_BINFOS (TYPE_BINFO (type)))
return NULL_TREE;
if (! CLASS_INTERFACE (TYPE_NAME (type)))
@@ -5272,12 +5275,11 @@ check_circular_reference (tree type)
return NULL_TREE;
}
- for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (type), i, base_binfo); i++)
{
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
- && interface_of_p (type, BINFO_TYPE (vec_elt)))
- return lookup_cl (TYPE_NAME (BINFO_TYPE (vec_elt)));
+ if (BINFO_TYPE (base_binfo) != object_type_node
+ && interface_of_p (type, BINFO_TYPE (base_binfo)))
+ return lookup_cl (TYPE_NAME (BINFO_TYPE (base_binfo)));
}
return NULL_TREE;
}
@@ -5569,8 +5571,9 @@ java_complete_class (void)
/* Simply patch super */
if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
continue;
- BINFO_TYPE (TREE_VEC_ELT (BINFO_BASE_BINFOS (TYPE_BINFO
- (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
+ BINFO_TYPE (BINFO_BASE_BINFO
+ (TYPE_BINFO (TREE_TYPE (JDEP_DECL (dep))), 0))
+ = TREE_TYPE (decl);
break;
case JDEP_FIELD:
@@ -6198,12 +6201,13 @@ check_abstract_method_definitions (int do_interface, tree class_decl,
{
/* Check for implemented interfaces. */
int i;
- tree vector = BINFO_BASE_BINFOS (TYPE_BINFO (type));
- for (i = 1; ok && vector && i < TREE_VEC_LENGTH (vector); i++)
- {
- tree super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
- ok = check_abstract_method_definitions (1, class_decl, super);
- }
+ tree base_binfo;
+
+ for (i = 1;
+ ok && BINFO_BASE_ITERATE (TYPE_BINFO (type), i, base_binfo);
+ i++)
+ ok = check_abstract_method_definitions (1, class_decl,
+ BINFO_TYPE (base_binfo));
}
return ok;
@@ -6216,7 +6220,7 @@ static void
java_check_abstract_method_definitions (tree class_decl)
{
tree class = TREE_TYPE (class_decl);
- tree super, vector;
+ tree super, base_binfo;
int i;
if (CLASS_ABSTRACT (class_decl))
@@ -6230,12 +6234,8 @@ java_check_abstract_method_definitions (tree class_decl)
} while (super != object_type_node);
/* Check for implemented interfaces. */
- vector = BINFO_BASE_BINFOS (TYPE_BINFO (class));
- for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
- {
- super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
- check_abstract_method_definitions (1, class_decl, super);
- }
+ for (i = 1; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
+ check_abstract_method_definitions (1, class_decl, BINFO_TYPE (base_binfo));
}
/* Check all the types method DECL uses and return 1 if all of them
@@ -6493,8 +6493,6 @@ check_interface_throws_clauses (tree check_class_decl, tree class_decl)
{
for (; class_decl != NULL_TREE; class_decl = CLASSTYPE_SUPER (class_decl))
{
- tree bases;
- int iface_len;
int i;
if (! CLASS_LOADED_P (class_decl))
@@ -6505,11 +6503,10 @@ check_interface_throws_clauses (tree check_class_decl, tree class_decl)
load_class (class_decl, 1);
}
- bases = BINFO_BASE_BINFOS (TYPE_BINFO (class_decl));
- iface_len = TREE_VEC_LENGTH (bases) - 1;
- for (i = iface_len; i > 0; --i)
+ for (i = BINFO_N_BASE_BINFOS (TYPE_BINFO (class_decl)) - 1; i > 0; --i)
{
- tree interface = BINFO_TYPE (TREE_VEC_ELT (bases, i));
+ tree interface
+ = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (class_decl), i));
tree iface_method;
for (iface_method = TYPE_METHODS (interface);
@@ -6609,9 +6606,10 @@ check_throws_clauses (tree method, tree method_wfl, tree found)
static void
java_check_abstract_methods (tree interface_decl)
{
- int i, n;
- tree method, basetype_vec, found;
+ int i;
+ tree method, found;
tree interface = TREE_TYPE (interface_decl);
+ tree base_binfo;
for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
{
@@ -6637,16 +6635,11 @@ java_check_abstract_methods (tree interface_decl)
}
/* 4- Inherited methods can't differ by their returned types */
- if (!(basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (interface))))
- return;
- n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; i < n; i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (interface), i, base_binfo); i++)
{
tree sub_interface_method, sub_interface;
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
- if (!vec_elt)
- continue;
- sub_interface = BINFO_TYPE (vec_elt);
+
+ sub_interface = BINFO_TYPE (base_binfo);
for (sub_interface_method = TYPE_METHODS (sub_interface);
sub_interface_method;
sub_interface_method = TREE_CHAIN (sub_interface_method))
@@ -6676,26 +6669,21 @@ java_check_abstract_methods (tree interface_decl)
static tree
lookup_java_interface_method2 (tree class, tree method_decl)
{
- int i, n;
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (class));
+ int i;
+ tree base_binfo;
tree to_return;
- if (!basetype_vec)
- return NULL_TREE;
-
- n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 0; i < n; i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
{
- tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
- if ((BINFO_TYPE (vec_elt) != object_type_node)
+ if ((BINFO_TYPE (base_binfo) != object_type_node)
&& (to_return =
- lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
+ lookup_java_method2 (BINFO_TYPE (base_binfo), method_decl, 1)))
return to_return;
}
- for (i = 0; i < n; i++)
+ for (i = 0; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
{
to_return = lookup_java_interface_method2
- (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
+ (BINFO_TYPE (base_binfo), method_decl);
if (to_return)
return to_return;
}
@@ -10984,6 +10972,8 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
static htab_t searched_classes;
static int search_not_done = 0;
tree list = NULL_TREE, all_list = NULL_TREE;
+ tree base_binfo;
+ int i;
/* Check the hash table to determine if this class has been searched
already. */
@@ -11011,16 +11001,13 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
if (TREE_CODE (TYPE_NAME (class)) == TYPE_DECL
&& CLASS_INTERFACE (TYPE_NAME (class)))
{
- int i, n;
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (class));
search_applicable_methods_list (lc, TYPE_METHODS (class),
name, arglist, &list, &all_list);
- n = TREE_VEC_LENGTH (basetype_vec);
- for (i = 1; i < n; i++)
+ for (i = 1; BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
{
- tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+ tree t = BINFO_TYPE (base_binfo);
tree rlist;
-
+
rlist = find_applicable_accessible_methods_list (lc, t, name,
arglist);
list = chainon (rlist, list);
@@ -11044,21 +11031,20 @@ find_applicable_accessible_methods_list (int lc, tree class, tree name,
/* We must search all interfaces of this class */
if (!lc)
- {
- tree basetype_vec = BINFO_BASE_BINFOS (TYPE_BINFO (class));
- int n = TREE_VEC_LENGTH (basetype_vec), i;
- for (i = 1; i < n; i++)
- {
- tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
- if (t != object_type_node)
- {
- tree rlist
- = find_applicable_accessible_methods_list (lc, t,
- name, arglist);
- list = chainon (rlist, list);
- }
- }
- }
+ {
+ for (i = 1;
+ BINFO_BASE_ITERATE (TYPE_BINFO (class), i, base_binfo); i++)
+ {
+ tree t = BINFO_TYPE (base_binfo);
+ if (t != object_type_node)
+ {
+ tree rlist
+ = find_applicable_accessible_methods_list (lc, t,
+ name, arglist);
+ list = chainon (rlist, list);
+ }
+ }
+ }
/* Search superclass */
if (!lc && CLASSTYPE_SUPER (class) != NULL_TREE)
diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c
index 8a17439..0e6e404 100644
--- a/gcc/java/typeck.c
+++ b/gcc/java/typeck.c
@@ -796,13 +796,12 @@ find_method_in_interfaces (tree searched_class, int flags, tree method_name,
tree signature, tree (*signature_builder) (tree))
{
int i;
- int interface_len =
- TREE_VEC_LENGTH (BINFO_BASE_BINFOS (TYPE_BINFO (searched_class))) - 1;
+ tree binfo, base_binfo;
- for (i = interface_len; i > 0; i--)
+ for (binfo = TYPE_BINFO (searched_class), i = 1;
+ BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
- tree child = BINFO_BASE_BINFO (TYPE_BINFO (searched_class), i);
- tree iclass = BINFO_TYPE (child);
+ tree iclass = BINFO_TYPE (base_binfo);
tree method;
/* If the superinterface hasn't been loaded yet, do so now. */
@@ -814,7 +813,7 @@ find_method_in_interfaces (tree searched_class, int flags, tree method_name,
/* First, we look in ICLASS. If that doesn't work we'll
recursively look through all its superinterfaces. */
method = shallow_find_method (iclass, flags, method_name,
- signature, signature_builder);
+ signature, signature_builder);
if (method != NULL_TREE)
return method;