aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-05-31 23:55:54 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-05-31 23:55:54 +0000
commit2771fe54e376ba6317e1c35548501dd455318ff2 (patch)
tree4f3739aba4cbd6834e7170f2b709c69b16eff980 /gcc/java/expr.c
parent9bcfe71d16f8de0e4ad005c0060511b20a4b3388 (diff)
downloadgcc-2771fe54e376ba6317e1c35548501dd455318ff2.zip
gcc-2771fe54e376ba6317e1c35548501dd455318ff2.tar.gz
gcc-2771fe54e376ba6317e1c35548501dd455318ff2.tar.bz2
java-tree.h (boolean_array_vtable, [...]): Declare.
* java-tree.h (boolean_array_vtable, byte_array_vtable, char_array_vtable, short_array_vtable, int_array_vtable, long_array_vtable, float_array_vtable, double_array_vtable): Declare. * expr.c (get_primitive_array_vtable): New function. (create_primitive_vtable): New function. (java_lang_expand_expr): Enable code to statically generate arrays. * decl.c (init_decl_processing): Create primitive vtables. (boolean_array_vtable, byte_array_vtable, char_array_vtable, short_array_vtable, int_array_vtable, long_array_vtable, float_array_vtable, double_array_vtable): Define. From-SVN: r34314
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index e1a5296..9a583b1 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -2251,6 +2251,33 @@ case_identity (t, v)
return v;
}
+/* Return the name of the vtable for an array of a given primitive
+ type. */
+static tree
+get_primitive_array_vtable (tree elt)
+{
+ tree r;
+ if (elt == boolean_type_node)
+ r = boolean_array_vtable;
+ else if (elt == byte_type_node)
+ r = byte_array_vtable;
+ else if (elt == char_type_node)
+ r = char_array_vtable;
+ else if (elt == short_type_node)
+ r = short_array_vtable;
+ else if (elt == int_type_node)
+ r = int_array_vtable;
+ else if (elt == long_type_node)
+ r = long_array_vtable;
+ else if (elt == float_type_node)
+ r = float_array_vtable;
+ else if (elt == double_type_node)
+ r = double_array_vtable;
+ else
+ abort ();
+ return build_address_of (r);
+}
+
struct rtx_def *
java_lang_expand_expr (exp, target, tmode, modifier)
register tree exp;
@@ -2272,22 +2299,25 @@ java_lang_expand_expr (exp, target, tmode, modifier)
tree length = build_int_2 (ilength, 0);
tree init = TREE_OPERAND (exp, 0);
tree array_decl;
-#if 0
- /* Enable this once we can set the vtable field statically. FIXME */
+
+ /* See if we can generate the array statically. */
if (TREE_CONSTANT (init) && TREE_STATIC (exp)
&& JPRIMITIVE_TYPE_P (element_type))
{
tree temp, value, init_decl;
+ struct rtx_def *r;
+ push_obstacks (&permanent_obstack, &permanent_obstack);
START_RECORD_CONSTRUCTOR (temp, object_type_node);
PUSH_FIELD_VALUE (temp, "vtable",
- null_pointer_node /* FIXME */
- );
+ get_primitive_array_vtable (element_type));
if (! flag_hash_synchronization)
PUSH_FIELD_VALUE (temp, "sync_info", null_pointer_node);
FINISH_RECORD_CONSTRUCTOR (temp);
START_RECORD_CONSTRUCTOR (value, array_type);
PUSH_SUPER_VALUE (value, temp);
- PUSH_FIELD_VALUE (value, "length", length);
+ /* FIXME: build a new `length' here to get it on the right
+ obstack. */
+ PUSH_FIELD_VALUE (value, "length", build_int_2 (ilength, 0));
PUSH_FIELD_VALUE (value, "data", init);
FINISH_RECORD_CONSTRUCTOR (value);
@@ -2299,9 +2329,11 @@ java_lang_expand_expr (exp, target, tmode, modifier)
TREE_READONLY (init_decl) = 1;
make_decl_rtl (init_decl, NULL, 1);
init = build1 (ADDR_EXPR, TREE_TYPE (exp), init_decl);
- return expand_expr (init, target, tmode, modifier);
+ r = expand_expr (init, target, tmode, modifier);
+ pop_obstacks ();
+ return r;
}
-#endif
+
array_decl = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (exp));
expand_decl (array_decl);
tmp = expand_assignment (array_decl,