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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34314
138bc75d-0d04-0410-961f-
82ee72b054a4
+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):
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. */
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 ()
{
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");
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;
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);
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,
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>" */