aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
authorAlexandre Petit-Bianco <apbianco@cygnus.com>1999-04-26 19:09:37 +0000
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>1999-04-26 12:09:37 -0700
commit7f1d48663e8aa1d749c88ffd17365bf2aa80f21a (patch)
tree38ae2203c1adb1c12229db14df3792c799011465 /gcc/java/expr.c
parentccd63d90d14a15e87224d8fba54870ab78167a25 (diff)
downloadgcc-7f1d48663e8aa1d749c88ffd17365bf2aa80f21a.zip
gcc-7f1d48663e8aa1d749c88ffd17365bf2aa80f21a.tar.gz
gcc-7f1d48663e8aa1d749c88ffd17365bf2aa80f21a.tar.bz2
class.c (layout_class_method): Generate <clinit>'s rtl for interfaces.
Sat Apr 24 16:50:19 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> * class.c (layout_class_method): Generate <clinit>'s rtl for interfaces. * decl.c (complete_start_java_method): Don't call _Jv_InitClass for interfaces' <clinit>. * expr.c (lookup_field): Search for fields in interfaces. (expand_invoke): Fixed indentation. (expand_java_field_op): Likewise. Use IS_CLINIT. * parse.h (JPRIMITIVE_TYPE_OR_VOID_P): Macro removed. (IS_CLINIT): New macro. * parse.y (type_declaration:): Call maybe_generate_clinit after an interface was parsed. (maybe_generate_clinit): Don't generate if the current class is an interface with only fields of primitive types. (reset_method_name): Use IS_CLINIT. (java_complete_expand_method): Expand <clinit> when it exists for interfaces. Use IS_CLINIT. (resolve_expression_name): Use DECL_CONTEXT instead of current_class to build static field references. (java_complete_lhs): Use IS__CLINIT. Don't use SAVE_EXPR on ARRAY_REF when doing xreferencing. (check_final_assignment): Fixed typo in leading comment. Use IS_CLINIT. (patch_array_ref): Don't fully expand array references when xreferencing. (patch_return): Use IS_CLINIT. (patch_throw_statement): Likewise. From-SVN: r26661
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 8a7d086..bcecb2b 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -1167,10 +1167,20 @@ lookup_field (typep, name)
}
do
{
- tree field;
- for (field = TYPE_FIELDS (*typep); field; field = TREE_CHAIN (field))
+ tree field, basetype_vec;
+ int n, i;
+
+ for (field = TYPE_FIELDS (*typep); field; field = TREE_CHAIN (field))
+ if (DECL_NAME (field) == name)
+ return field;
+
+ /* Process implemented interfaces. */
+ basetype_vec = TYPE_BINFO_BASETYPES (*typep);
+ n = TREE_VEC_LENGTH (basetype_vec);
+ for (i = 0; i < n; i++)
{
- if (DECL_NAME (field) == name)
+ tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
+ if ((field = lookup_field (&t, name)))
return field;
}
*typep = CLASSTYPE_SUPER (*typep);
@@ -1626,7 +1636,8 @@ expand_invoke (opcode, method_ref_index, nargs)
if (opcode == OPCODE_invokestatic || opcode == OPCODE_invokespecial
|| (opcode == OPCODE_invokevirtual
&& (METHOD_PRIVATE (method)
- || METHOD_FINAL (method) || CLASS_FINAL (TYPE_NAME (self_type)))))
+ || METHOD_FINAL (method)
+ || CLASS_FINAL (TYPE_NAME (self_type)))))
func = build_known_method_ref (method, method_type, self_type,
method_signature, arg_list);
else
@@ -1663,11 +1674,14 @@ expand_java_field_op (is_static, is_putting, field_ref_index)
int is_putting;
int field_ref_index;
{
- tree self_type = get_class_constant
- (current_jcf, COMPONENT_REF_CLASS_INDEX (&current_jcf->cpool, field_ref_index));
+ tree self_type =
+ get_class_constant (current_jcf,
+ COMPONENT_REF_CLASS_INDEX (&current_jcf->cpool,
+ field_ref_index));
char *self_name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (self_type)));
tree field_name = COMPONENT_REF_NAME (&current_jcf->cpool, field_ref_index);
- tree field_signature = COMPONENT_REF_SIGNATURE (&current_jcf->cpool, field_ref_index);
+ tree field_signature = COMPONENT_REF_SIGNATURE (&current_jcf->cpool,
+ field_ref_index);
tree field_type = get_type_from_signature (field_signature);
tree new_value = is_putting ? pop_value (field_type) : NULL_TREE;
tree field_ref;
@@ -1727,15 +1741,15 @@ expand_java_field_op (is_static, is_putting, field_ref_index)
"assignment to final field `%s' not in field's class");
else if (FIELD_STATIC (field_decl))
{
- if (DECL_NAME (current_function_decl) != clinit_identifier_node)
+ if (!IS_CLINIT (current_function_decl))
error_with_decl (field_decl,
"assignment to final static field `%s' not in class initializer");
}
else
{
if (! DECL_CONSTRUCTOR_P (current_function_decl))
- error_with_decl (field_decl,
- "assignment to final field `%s' not in constructor");
+ error_with_decl (field_decl, "assignment to final field `%s' "
+ "not in constructor");
}
}
expand_assignment (field_ref, new_value, 0, 0);