aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--gcc/java/ChangeLog15
-rw-r--r--gcc/java/decl.c37
-rw-r--r--gcc/java/expr.c46
-rw-r--r--gcc/java/java-tree.h8
4 files changed, 98 insertions, 8 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index e124bce..ee9f6e9 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,18 @@
+2000-05-31 Tom Tromey <tromey@cygnus.com>
+
+ * 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.
+
2000-05-26 Zack Weinberg <zack@wolery.cumb.org>
* java/parse.y (find_applicable_accessible_methods_list):
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index c5008a0..7619d63 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -392,6 +392,16 @@ tree soft_irem_node;
tree soft_ldiv_node;
tree soft_lrem_node;
+/* Declarations for vtables for primitive arrays. */
+tree boolean_array_vtable;
+tree byte_array_vtable;
+tree char_array_vtable;
+tree short_array_vtable;
+tree int_array_vtable;
+tree long_array_vtable;
+tree float_array_vtable;
+tree double_array_vtable;
+
/* Build (and pushdecl) a "promoted type" for all standard
types shorter than int. */
@@ -451,6 +461,21 @@ builtin_function (name, type, function_code, class, library_name)
return decl;
}
+/* Return tree that represents a vtable for a primitive array. */
+static tree
+create_primitive_vtable (name)
+ const char *name;
+{
+ tree r;
+ char buf[50];
+
+ sprintf (buf, "_Jv_%sVTable", name);
+ r = build_decl (VAR_DECL, get_identifier (buf), ptr_type_node);
+ DECL_EXTERNAL (r) = 1;
+ make_decl_rtl (r, buf, 1);
+ return r;
+}
+
void
init_decl_processing ()
{
@@ -573,7 +598,17 @@ init_decl_processing ()
float_zero_node = build_real (float_type_node, dconst0);
double_zero_node = build_real (double_type_node, dconst0);
- /* As your adding items here, please update the code right after
+ /* These are the vtables for arrays of primitives. */
+ boolean_array_vtable = create_primitive_vtable ("boolean");
+ byte_array_vtable = create_primitive_vtable ("byte");
+ char_array_vtable = create_primitive_vtable ("char");
+ short_array_vtable = create_primitive_vtable ("short");
+ int_array_vtable = create_primitive_vtable ("int");
+ long_array_vtable = create_primitive_vtable ("long");
+ float_array_vtable = create_primitive_vtable ("float");
+ double_array_vtable = create_primitive_vtable ("double");
+
+ /* As you're adding items here, please update the code right after
this section, so that the filename containing the source code of
the pre-defined class gets registered correctly. */
unqualified_object_id_node = get_identifier ("Object");
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,
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 2b77434..a05573f 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -241,6 +241,14 @@ extern tree float_array_type_node;
extern tree array_array_type_node;
extern tree object_array_type_node;
extern tree string_array_type_node;
+extern tree boolean_array_vtable;
+extern tree byte_array_vtable;
+extern tree char_array_vtable;
+extern tree short_array_vtable;
+extern tree int_array_vtable;
+extern tree long_array_vtable;
+extern tree float_array_vtable;
+extern tree double_array_vtable;
extern tree TYPE_identifier_node; /* "TYPE" */
extern tree init_identifier_node; /* "<init>" */
extern tree clinit_identifier_node; /* "<clinit>" */