This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: handle array classes
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 24 Mar 2005 12:54:01 -0700
- Subject: [gcjx] Patch: FYI: handle array classes
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
We can't emit direct references to things like `byte[].class'.
Instead we must emit a reference via the constant pool.
This patch fixes this.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* tree.cc (build_class_ref): Handle array types.
(build_new_object_array): Use build_class_ref.
* abi.cc (build_class_reference): Added assertion.
Index: abi.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.cc,v
retrieving revision 1.1.2.17
diff -u -r1.1.2.17 abi.cc
--- abi.cc 24 Mar 2005 17:07:14 -0000 1.1.2.17
+++ abi.cc 24 Mar 2005 19:55:30 -0000
@@ -202,7 +202,7 @@
aot_class *,
model_type *klass)
{
- // FIXME: handle primitive type.
+ assert (! klass->primitive_p () && klass != primitive_void_type);
tree class_obj
= builtins->map_class_object (assert_cast<model_class *> (klass));
return build1 (ADDR_EXPR, type_class_ptr, class_obj);
Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.23
diff -u -r1.1.2.23 tree.cc
--- tree.cc 24 Mar 2005 19:54:05 -0000 1.1.2.23
+++ tree.cc 24 Mar 2005 19:55:31 -0000
@@ -1941,9 +1941,7 @@
{
model_class *array_type = assert_cast<model_class *> (elt_type->array ());
- gcj_abi *abi = gcc_builtins->find_abi ();
- tree elt_type_tree
- = abi->build_class_reference (gcc_builtins, class_wrapper, elt_type);
+ tree elt_type_tree = build_class_ref (array_type, elt_type);
tree array_type_tree = gcc_builtins->lay_out_class (array_type);
tree args = tree_cons (NULL_TREE, size,
@@ -2019,6 +2017,14 @@
result = gcc_builtins->map_field_ref (class_wrapper, NULL_TREE,
field);
}
+ else if (t->array_p ())
+ {
+ // We can't refer to array types directly, so we emit a
+ // reference via the constant pool.
+ model_class *klass = assert_cast<model_class *> (t);
+ result = build_ref_from_constant_pool (type_class_ptr,
+ class_wrapper->add (klass));
+ }
else
{
gcj_abi *abi = gcc_builtins->find_abi ();